+v8.5 beta internal rar unpacker can't detect RAR 5 SFX file
Moderators: Hacker, petermad, Stefan2, white
+v8.5 beta internal rar unpacker can't detect RAR 5 SFX file
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)
And TC 8.5 don't know it's a RAR 5 archive file. (with Ctrl - PGDN function in TC)
- ghisler(Author)
- Site Admin
- Posts: 50541
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
Sorry, RAR5 SFX files aren't supported yet because I haven't yet analyzed their format.
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
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):
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).
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]
}
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).
- ghisler(Author)
- Site Admin
- Posts: 50541
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
TC is already doing something similar - I just didn't add the code for RAR5 yet.
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
- ghisler(Author)
- Site Admin
- Posts: 50541
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
- ghisler(Author)
- Site Admin
- Posts: 50541
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
- ghisler(Author)
- Site Admin
- Posts: 50541
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact: