EXE或DLL映像基址 [英] EXE or DLL Image base address
问题描述
在C ++ / windows中有没有办法获取exe / DLL映像基址?
感谢:)
Is there a way in C++/windows to get the exe/DLL image base address? thanks :)
推荐答案
如果将二进制文件加载到自己的进程中,可以使用 GetModuleHandle 。它返回一个HMODULE,但这是与HINSTANCE和基地址。
If you load the binary into your own process you can use GetModuleHandle. It returns a HMODULE, but that is the same as HINSTANCE and the base address.
如果你想知道什么是基地址,二进制文件应该读PE头。请参见此处,并在IMAGE_OPTIONAL_HEADER中查找ImageBase字段。
If you want to know what base address the binary prefers you should read the PE header. See here and look for the ImageBase field in IMAGE_OPTIONAL_HEADER.
Edit:GetModuleHandle(NULL)将返回当前进程的基地址(指定类型为HMODULE)。
GetModuleHandle(NULL) will return the base address (altough the specified type is HMODULE) for the current process.
这篇关于EXE或DLL映像基址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!