Reputation: 335
So I have an EXE file that is used as an installer of a program. And with 7-Zip I can extract the files inside the EXE and get the files it's installing. That's what I would like to do in code because right now I can only do it manually with 7-Zip.
if it helps, the EXE file starts with "4D 5A 90 00 03 00 00 00". Thanks in advance and if you need any more information please tell me.
Upvotes: 1
Views: 12051
Reputation: 1
Hope this helps. My requirement was to find the number of files inside a exe without extracting it.
using (ZipArchive archive = ZipFile.Open(@"C:\Users\User\Downloads\AMD-Chipset-Driver_D7R0K_WIN_19.100.16_A00_02.EXE", ZipArchiveMode.Read))
{
int count = 0;
int count1 = archive.Entries.Count;
// We count only named (i.e. that are with files) entries
foreach (var entry in archive.Entries)
if (!String.IsNullOrEmpty(entry.Name))
{
count += 1;
Console.WriteLine(entry.FullName);
}
Console.Write(count);
}
Upvotes: 0
Reputation: 366
On Windows executable files use PE format. Self-extracting archives are PE files concatenated with archives (sometimes with additional config).
When you trying to open such file in 7zfm it calculates the executable size and tries to unpack the data which is appended to it (this data usually called overlay
).
All you have to do is to find Overlay offset and try to unpack it.
In order to find Overlay offset you have to calculate headers size+segments size. This is easy to do by yourself but there should be some libraries which can do it for you.
Upvotes: 1