在 Win32 二进制文件中获取类偏移量 [英] Getting class offset in a Win32 binary

查看:28
本文介绍了在 Win32 二进制文件中获取类偏移量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于 Win32 可移植可执行文件 (PE)

For a Win32 Portable Executable (PE)

  • 如何获取使用的类列表
  • 如何获取给定类的偏移量

推荐答案

一个类没有偏移量——它的方法有偏移量.如果PE文件是一个DLL,并且导出了一个类,你可以从导出的函数表中获取其方法的偏移量.名称将被破坏.重整方案是特定于编译器和版本的.

A class does not have an offset - its methods have offsets. If the PE file is a DLL, and a class is exported, you can get offsets of its methods from the exported function table. The names will be mangled though. The mangling scheme is compiler- and version-specific.

您可以使用 DUMPBIN 工具(在 Visual Studio 中或在 Platform SDK 中可用)来查看导出表.IIRC,它甚至可以为您解开名称.如果您想以编程方式执行此操作,请使用 ImageHlp API 中的函数 - ImageLoad() 等.

You can use the DUMPBIN tool (available with Visual Studio, or in Platform SDK) to watch the export table. IIRC, it can even unmangle the names for you. If you want to do it programmatically, use the functions from the ImageHlp API - ImageLoad() and so forth.

没有获得非导出类方法的偏移量的好方法.

There's no good way to get offsets of nonexported class methods.

此外,偏移量可以在 MAP 文件、调试符号或 PDB 文件中找到.如果是第三方产品,您很可能无法使用这些产品.

Also, offsets can be found in a MAP file, or in debug symbols, or in a PDB file. If it's a third party product, those won't be available to you, most likely.

编辑回复:Microsoft DLL.Microsoft 通过 Microsoft Symbol Server 为他们的许多文件(Win32 和 .NET)提供了调试符号.自 2005 版以来,Visual Studio 可以在 DLL 加载时自动提取这些符号.

EDIT re: Microsoft DLLs. Microsoft makes debug symbols for a lot of their files (both Win32 and .NET) available via the Microsoft Symbol Server. Visual Studio since v. 2005 can pull those symbols automatically upon DLL loading.

这篇关于在 Win32 二进制文件中获取类偏移量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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