+v8.5 beta internal rar unpacker can't detect RAR 5 SFX file

Bug reports will be moved here when the described bug has been fixed

Moderators: white, Hacker, petermad, Stefan2

Post Reply
cmingyan
Junior Member
Junior Member
Posts: 9
Joined: 2011-11-24, 08:19 UTC

+v8.5 beta internal rar unpacker can't detect RAR 5 SFX file

Post by *cmingyan »

I create a file as with RAR 5 SFX module (.exe).
And TC 8.5 don't know it's a RAR 5 archive file. (with Ctrl - PGDN function in TC)
Biozynotiker
Member
Member
Posts: 164
Joined: 2011-03-22, 09:57 UTC
Location: Germany

Post by *Biozynotiker »

Confirmed
#92832
User avatar
eugensyl
Power Member
Power Member
Posts: 564
Joined: 2004-06-03, 18:27 UTC
Location: România
Contact:

Post by *eugensyl »

Biozynotiker wrote:Confirmed
Confirmed too.
My Best Wishes,

Eugen
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48083
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Sorry, RAR5 SFX files aren't supported yet because I haven't yet analyzed their format.
Author of Total Commander
https://www.ghisler.com
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

ghisler,
All SFX usually just add executable module before archive itself, so you only need to skip this module.
It is quite easy to determine its size from PE header (last section's raw data offset plus raw data size):

Code: Select all

#define word_at(x) (*(WORD*)(x))
#define dword_at(x) (*(DWORD*)(x))

				byte* archive_data=pbasedata;
				if (word_at(pbasedata)==IMAGE_DOS_SIGNATURE) {
					byte* phdrpe=pbasedata+dword_at(pbasedata+0x3C);
					DWORD* plastdata=(DWORD*)(phdrpe+word_at(phdrpe+0x14)+word_at(phdrpe+6)*0x28);
					DWORD sfx_size=plastdata[0]+plastdata[1];
					if (sfx_size<file_size) archive_data=pbasedata+sfx_size;
				}

				static const char* signature[]={
					"RE~^",			// Rar 1.4 (from Unrar sources)
					"Rar!\x1a\x07", // Rar 1.5+ (Rar 5 defines seventh signature byte: 0x01 - Rar 5, 0x02 - future versions)
					"7zј\xAF\x27",	// 7-Zip
					"MSCF"			// Microsoft Cabinet
				};
				static const int signature_length[]={4, 6, 5, 4};

				for (int i=0; i<sizeof(signature)/sizeof(signature[0]); ++i) {
					if (memcmp(archive_data, signature[i], signature_length[i])) continue;

					// we have an archive with signature[i]
				}
Just tried it with Rar 3, Rar 5, 7-Zip... works ok.
However some stupid installers put archives (e.g. CAB in dotnetfx 2.0.exe) into resource section... so it is necessary to scan through it to find archive. Also some SFX modules put additional data between SFX module and archive (e.g. 7-Zip's 7zSD.sfx).
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48083
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

TC is already doing something similar - I just didn't add the code for RAR5 yet.
Author of Total Commander
https://www.ghisler.com
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48083
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Please, can someone try this now with beta 5?
Author of Total Commander
https://www.ghisler.com
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48083
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Anyone?
Author of Total Commander
https://www.ghisler.com
User avatar
sztihamer
Member
Member
Posts: 117
Joined: 2012-01-31, 17:46 UTC

Post by *sztihamer »

Went and created a RAR5 SFX archive of a file with WinRAR 5.00 and tried pressing "Ctrl+Page Down". It worked like a charm and showed the contents of the archive. Also I was able to extract it from the .exe file.

Seems like this issue has been fixed.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48083
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Nice to hear that, thanks for your test!
Author of Total Commander
https://www.ghisler.com
Post Reply