11

I created a >4GB SFX archive (the self extracting archives) in 7-Zip, without warning. When the recipient tried to extract it, he got this error ribbon:

enter image description here

I found it's because the .exe is larger than 4GB. After installing 7-Zip he was able to extract the archive, but I am wondering why can't Windows run such an executable? And is it possible to via some override?

3
  • 2
    You normally can just not on 32-bit systems
    – Ramhound
    Oct 30 '13 at 22:38
  • 1
    To expand on what Ramhound said, it is possible the 7-Zip self-extractor stores itself in RAM which for 32-bit systems, has a maximum access size of 4 GB. It would also explain why 7-Zip was able to extract, as the archive didn't need to be fully stored in memory (albeit that would depend on whether the archive was solid or had other compression settings). Oct 30 '13 at 22:47
  • Yes, I thought that was the problem at first, but he's using Win64 with 16GB of RAM. I'm using it too with 8GB. Oct 31 '13 at 3:47
11

Windows won't support executables greater than 4GB in size according to this thread:

http://sourceforge.net/p/sevenzip/discussion/45798/thread/337fc13e/

The commenter "Igor Pavlov" is the creator and the maintainer of 7-Zip. While that comment is somewhat curt, there are other threads on the sourceforge forums which repeat the same advice. I don't believe running the executable on a 64-bit OS would make any difference as this may well be a limitation of the size of a windows executable file, i.e. a limitation of the Windows PE format itself.

This article on Writing 64-bit programs suggests that:

The executable "image" (the code/data as loaded in memory) of a Win64 file is limited in size to 2GB. This is because the AMD64/EM64T processors use relative addressing for most instructions, and the relative address is kept in a dword. A dword is only capable of holding a relative value of ±2GB.

Presumably Igor has come up with a way of using ±2GB to achieve 4GB.

2
  • 1
    A signed dword has a range of 2,147,483,647. An unsigned dword has a range of 4,294,967,295, and that number is the source of most limitations in Windows and in 32-bit systems outside of it. Dec 31 '18 at 17:04
  • 1
    @Hashim is absolutely correct, the limit is 4GiB - 1B = 2^32 - 1 bytes = 4,294,967,295 bytes. I was able to verify it on Windows 10 64-bit by creating self-extracting archives with WinRAR in the form of .EXE-files. An executable with a size of 4GiB won't launch, but 4GiB - 1B works fine. Oct 16 '19 at 22:31
0

Having a self extracting executable larger than 4GB is on the extreme side, since there's a 4gb limit on Windows executable files like *.exe, *.dll etc. for PE32 and a 64-bit version PE32+ (applies to 32-bit and 64-bit versions).

Second, executable file is loaded completely into RAM before execution and even if you are not limited by Windows (but you are), you could be easily limited by the hardware, which is the physical amount of RAM in such a case

1
  • As I know there are ways to tell Windows to load only a specific section of the exe file, not the whole file with resources. I think many large DOS programs use this trick too since the limit in 16-bit x86 is too small
    – phuclv
    Oct 31 '13 at 0:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.