获取Windows当前进程中符号的地址 [英] Get address for symbol in current process in Windows

查看:155
本文介绍了获取Windows当前进程中符号的地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在* 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当前进程中符号的地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆