在* nix上,您可以使用 -rdynamic 编译程序或加载动态库,使用 dlopen(NULL,RTLD_NOW)获取当前进程的句柄,然后将 dlsym()与句柄一起使用以获取当前进程中符号的地址。
On *nix, you can compile a program with -rdynamic or loading dynamic libraries, use dlopen(NULL, RTLD_NOW) to get handle of current process, then use dlsym() with the handle to get address for a symbol within current process.
我想知道在Windows上这样做的等效性是什么。
I am wondering what is the equivalent for doing so on Windows.
推荐答案在Windows上,您可以依赖 LoadLibrary() 和 GetProcAddress() kernel32.dll 的code> API,用于加载库并解析其功能地址。关于 GetProcAddr():
On Windows, you can rely on LoadLibrary() and GetProcAddress() APIs, both from kernel32.dll, to load a library and resolve its functions addresses. About GetProcAddr():
从中获取导出函数或变量的地址指定了动态链接库(DLL)。
Retrieves the address of an exported function or variable from the specified dynamic-link library (DLL).
并接受参数:
包含函数或变量的DLL模块的句柄。 LoadLibrary,LoadLibraryEx,LoadPackagedLibrary或GetModuleHandle 函数将返回此句柄。
A handle to the DLL module that contains the function or variable. The LoadLibrary, LoadLibraryEx, LoadPackagedLibrary, or GetModuleHandle function returns this handle.
如果要解决外部流程的库中的地址,最好的选择是使用 DebugActiveProcess 和 ReadProcessMemory()
If you want to resolve the adresses within the libraries of the process from an external process, your best bet would be to debug it with DebugActiveProcess and ReadProcessMemory()
您将必须从进程的基地址浏览PE格式结构。不平凡,但并不难。该主题与代码注入紧密相关,但是您可能需要阅读了解导入地址表
You will have to browse the PE Format structures from the base address of the process. Not trivial, but not that hard. This topic is closely related to code injection, but you might want to read Understanding the Imports Address Table
更多推荐
获取Windows当前进程中符号的地址
发布评论