获取Windows当前进程中符号的地址

编程入门 行业动态 更新时间:2024-10-26 03:35:09
本文介绍了获取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当前进程中符号的地址

本文发布于:2023-11-17 11:42:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1609899.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:符号   进程   地址   Windows

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!