如果我设置了类似0x00000040的代码(我的代码位于此地址),那么程序将因以下错误而崩溃:

The application was unable to start correctly (0xc000007b)


但是如果我从代码部分中0x00400040然后它起作用了。是否可以从位于外部的代码开始执行程序?

我使用Windows8。

评论

如果将0x00000040设置在哪里?

0x40作为可选标头中的EP地址(0x110偏移)

该错误在WDK的ntstatus.h中定义。该错误代码已经存在很长时间了,并且以其符号名称STATUS_INVALID_IMAGE_FORMAT闻名。

#1 楼

Windows 8引入了一个新的限制:AddressOfEntryPoint不能小于SizeOfHeaders

SizeOfHeaders设置为AddressOfEntryPoint使其可以正常工作。如下:

//
// 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)