1

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.

I tried:

  • using the 7-Zip standalone console version, but it turns out it only supports 7z, ZIP, gzip, bzip2, Z and tar, unlike the "normal" one that supports 31 formats...

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.

Flafy
  • 176
  • 1
  • 3
  • 15

2 Answers2

1

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.

espkk
  • 346
  • 1
  • 9
0

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);
}
Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Sumit S
  • 1
  • 1