SevenZipSharp icon indicating copy to clipboard operation
SevenZipSharp copied to clipboard

Can not extract .exe files

Open RickZeeland opened this issue 4 years ago • 15 comments

I downloaded the zip file and on Windows 10 tried to extract files from an 7z archive, normal files are extracted but not the .exe files, my Winforms 4.7 application hangs without giving any errors. Code: SevenZipBase.SetLibraryPath(Path.Combine(GetCurrenDir(), "7z64.dll")); var zipExtractor = new SevenZipExtractor(fullFilename, password); zipExtractor.PreserveDirectoryStructure = true; zipExtractor.ExtractArchive(extractLocation);

Also tried without password on the 7z file, but same result.

RickZeeland avatar Apr 26 '21 09:04 RickZeeland

Hi, I'm a little unclear on what you're trying to do. You're saying you downloaded some archive, and are able to extract "normal" files from it but not executable files? Or are you trying to extract files from a .exe file (hopefully a self-extracting 7z executable)?

Do you have some example archive you could attach here so I can debug this?

squid-box avatar Apr 27 '21 22:04 squid-box

@squid-box The archive I downloaded was the source code from GitHub, also tried the latest NuGet package but same problem. just created a .7z archive with 7zip with some files including an .exe file.

Very strange, just tested again and with an archive with a .zip extension and that seems to work. Could not find anything in the Windows eventlog sadly ...

I used 7-Zip 16.04 from the right-click menu in Explorer to create the .7z archive.

RickZeeland avatar Apr 28 '21 04:04 RickZeeland

Just creating a 7z archive of a number of files (took a random installed program on my computer, created by context menu and 7-zip 21.01) including an .exe - I have no problems extracting the executable file.

Without an archive where the problem can be reproduced, I can't really say more than "it works on my machine" :(

squid-box avatar Apr 28 '21 07:04 squid-box

Thanks for testing, here is the culprit archive (password: root) https://drive.google.com/file/d/1EnoPnbPNQz4PU24FSpF8Z1OeWrhSVyZy/view?usp=sharing

RickZeeland avatar Apr 28 '21 07:04 RickZeeland

Thanks, I'll have a look tonight and get back to you.

squid-box avatar Apr 28 '21 09:04 squid-box

@RickZeeland: So, it looks like the file is encrypted - meaning I can't really check it without the password :)

squid-box avatar Apr 28 '21 18:04 squid-box

I mentioned the password: root Didn't that work?

RickZeeland avatar Apr 28 '21 19:04 RickZeeland

Bah, I appear to be blind - sorry... 🙈

I wrote a quick unit test for this, and I have no problems extracting the archive you've provided.

[Test]
public void ExtractTestArchive()
{
    using (var extractor = new SevenZipExtractor(@"TestData\Test.7z", "root"))
    {
        extractor.PreserveDirectoryStructure = true;
        Assert.IsTrue(extractor.Check());
        extractor.ExtractArchive(OutputDirectory);
    }

    Assert.AreEqual(3, Directory.GetFiles(OutputDirectory, "*", SearchOption.AllDirectories).Length);
}

It's weird that you'd get stuck with no exceptions being thrown, and the same code can extract your zip file without issue?

What version of the 7z dll are you using?

squid-box avatar Apr 28 '21 19:04 squid-box

Then it must be a case of "does not work on my machine" :) I'm using 7z64.dll version 21.01 alpha, and same problem with 7z.dll version 19.0

RickZeeland avatar Apr 29 '21 05:04 RickZeeland

I just encountered same issue. I simply renamed an text file with random text to dll. Then the SevenZipSharp refuses to extract and hangs forever.

8749236 avatar Sep 25 '21 19:09 8749236

Same problem with exe and dll compressed. The other extensions are fine but NOT for EXE and Dll. So back to use the Command Line instead.

leqnam avatar Oct 03 '21 19:10 leqnam

Same Problem with current version 32 and 64bit. When i use a very old version (7z 9.20 with SevenZipSharp 0.64) there is no problem with exe extraction). I used current Win11. I hope Defender is not the root of the problem.

I can reproduce it only when extraction is done in an child-process with Process.Start(...). If use in the main-process the exe is written.

bneidhold avatar Nov 22 '21 05:11 bneidhold

Same Problem with current version 64bit. I have tried 7z 9.20/16.04/19.00/22.01/23.01 with SevenZipSharp 1.6.1.23 and 7z 23.01 with SevenZipSharp 1.1.22/1.2.265/1.3.283), there is also the same problem. The OS is WIN11, 22621.1848 with using the 3rd Antivirus.

I can reproduce it only in some specific file, not all the files. In Visual Studio, it works normally, but I releasing my file, it would failed always when extracting into disk C. My application has run as ADMIN, and the extraction is in an child-process with Thread.Start().

GinzoGroot avatar Jun 25 '23 04:06 GinzoGroot

Same Problem with current version 32 and 64bit. When i use a very old version (7z 9.20 with SevenZipSharp 0.64) there is no problem with exe extraction). I used current Win11. I hope Defender is not the root of the problem.

I can reproduce it only when extraction is done in an child-process with Process.Start(...). If use in the main-process the exe is written.

Excuse me, how can I download SevenZipSharp 0.64? NuGet can only use the 1.1.22 as earliest version.

GinzoGroot avatar Jun 26 '23 03:06 GinzoGroot

Same Problem with current version 32 and 64bit. When i use a very old version (7z 9.20 with SevenZipSharp 0.64) there is no problem with exe extraction). I used current Win11. I hope Defender is not the root of the problem. I can reproduce it only when extraction is done in an child-process with Process.Start(...). If use in the main-process the exe is written.

Excuse me, how can I download SevenZipSharp 0.64? NuGet can only use the 1.1.22 as earliest version.

I have found my reason. It caused by my own code to deal with the file existed. THX to all.

GinzoGroot avatar Jun 27 '23 01:06 GinzoGroot