8

If I set something like 0x00000040 (my code is located at this address), then the program crashes with this error:

The application was unable to start correctly (0xc000007b)

But if I jmp from the code section to 0x00400040 then it works.

Why did I get error with that strange address (0xc000007b) ? Is it possible to start the execution of program from code which is located outside sections?

I use Windows 8.

perror
  • 19,083
  • 29
  • 87
  • 150
edhoklorf
  • 81
  • 3

1 Answers1

12

Windows 8 introduces a new restriction: the AddressOfEntryPoint can't be smaller than SizeOfHeaders.

Set SizeOfHeaders to AddressOfEntryPoint to make it work.

The error you get is defined in ntstatus.h as follows:

//
// MessageId: STATUS_INVALID_IMAGE_FORMAT
//
// MessageText:
//
// {Bad Image}
// %hs is either not designed to run on Windows or it contains an error. Try installing the program again using the original installation media or contact your system administrator or the software vendor for support. Error status 0x%08lx.
//
#define STATUS_INVALID_IMAGE_FORMAT      ((NTSTATUS)0xC000007BL)
0xC0000022L
  • 10,908
  • 9
  • 41
  • 79
Ange
  • 6,694
  • 3
  • 28
  • 62