EFI-module compression

Hi,

i’m searching a tool which can compress efi-modules in windows.
I found a tool for extracting and decompressing uefi, but no tool for compressing. Only sourcecode in c++, but its useless for me, because i’m no programmer…

What exactly do you mean by EFI modules, what are you trying to compress? And what compression: EFI, Tiano, LZMA? There are some tools in EDK2 like LZMACompress and TianoCompress, but it is hard to say how appropriate they are for your case when you haven’t explained your case.

It is EFI-Part from GPU. I have no idea which type of compression was used, i can only test it. The tools from EDK (LZMA and Tiano) don’t work, the files differ from the compressed files (compressed original -> decompressed -> compressed).

If it is about GOP (EFI ROM from GPU firmware), you should firstly read this thread. Secondly, for GOP compression you must use Efirom from EDK2, but there is a warning about its use, present in the linked thread. And yes, with newer versions the compression algorithm is better and there will be a difference. But I remember an older version had the same compression as the one from GPU vendors, as you can see in the third picture of that thread.

If you really need that version that has the same compression, I will check to see if I still have it.

EFIRom.exe doesn’t compress it the right way.

I attached two files, the compressed and uncompressed one. Uncompressing was done with UEFIRomExtract.exe; the uncompressed header of the efi-file (160 bytes) is removed. You must rename them to .rom/.bin/whatever because of restricted endings.

compressed.rar (41.4 KB)

uncompressed.rar (109 KB)

But what is the file you are trying to compress? Is it uncompressed.rar/rom, are you trying to obtain the exact compression as in compressed.rar/rom? By the way: from where is this file, because I see it is not a generic AMD GOP; can you share the whole file; do you know it is compiled as byte code and not x86/x64?

Anyway, if you are trying to process uncompressed.rar/rom and obtain an exact copy of compressed.rar/rom (the same compression algorithm), then rev52 of Efirom does the job:

efirom52.png



In the left you have your compressed.bin, in the right you have uncompressed.bin after it was compressed with efirom rev52.

EfiRom_rev52.rar (133 KB)

It is the efi-part of an Mac-videocard. You can also compress/decompress it with this scripts(?), but they only work with linux and osx: http://boeglin.org/static/efidecompress/
The site for the sourcecode is down; whatever, i have absolute no compiling-skills, so the sourcecode would be completely useless for me.

Attached are the complete rom and the efi-part.

Ok, my fault: I forgot to ignore the header.
So i can use this tool for compressing, header should be inserted manually. Thanks!

efipart.rar (42 KB)

hd5870.rar (128 KB)

Is there any reason in using that specific revision of Efirom? I would guess the newest revision it is backward compatible, otherwise it would be confusing and dangerous to use and it should print that you need a specific UEFI revision to support the new compression. But when it comes to safety, there is never too much.

It depends on how you want to use the tool. If you just want to patch something in the original EFI, then the recompression shouldn’t change too much things. But if you plan on replacing the GOP, you need to fix some things in the header. This is the header of the EFI ROM:

hd5870.png



You need to make sure the image size and image length is updated, that the new EFI is byte code or change that to the machine code type. And you also need to look out for the microcode at the end, it might need a fix position.



LZMA decoder is simple. But PPMd decoder is complex. LZMA2 is better than LZMA. LZMA2 compression does not replace (supersede) LZMA compression, but LZMA2 is merely an additional "wrapper" around LZMA. With LZMA2, data is split into blocks, but each block is still compressed by "normal" LZMA. Because individula blocks are compressed separately, processing the blocks can be parallelized, which allows for multi-threading. LZMA2 also allows "uncompressed" blocks, to better deal with "already compressed" inputs.

@winstongel :
Welcome to the Win-RAID Forum and thanks for your contribution.
Regards
Dieter (alias Fernando)