获取加载到内存中时DLL或EXE的代码段的大小
Getting the size of the code segment of a DLL or EXE when loaded in memory
我可以使用GetModuleHandle来获取它的基偏移量,但我也需要知道DLL或EXE的代码段的大小。例如,我需要在以下代码中估计nSize:
char aCrashSignatureBytesAtEIP[] = { 0x87, 0x12, 0x00, ... };
char* pBaseOffset = (char*) GetModuleHandle(NULL);
int nSize = ???;
for (int i = 0; i<nSize; i++)
if (!memcmp(&pBaseOffset[i], aCrashSignatureBytesAtEIP, sizeof(aCrashSignatureBytesAtEIP)))
{
printf("Crash signature found at offset %p", &pBaseOffset[i]);
}
PSAPI
为您提供以下信息:GetModuleInformation
函数返回MODULEINFO
结构,其中包含图像的基地址和大小。
typedef struct _MODULEINFO {
LPVOID lpBaseOfDll;
DWORD SizeOfImage;
LPVOID EntryPoint;
} MODULEINFO, *LPMODULEINFO;
相关文章:
- 为cl.exe(Visual Studio代码)指定命令行C++版本
- VI工作室代码错误无法打开输出文件主.exe
- NMAKE:致命错误 U1077:cl.exe 和 nmake.exe 返回代码'0x2'
- 无法在代码块 IDE 中打开输出文件.exe
- 如何检查 win32 exe 文件是否已运行?(使用 win32 API 代码)
- 如何在 Azure 应用服务中使用 cl.exe 编译 C++ 代码并生成可执行文件
- 'Cannot output file filename.exe Permission denied' C++ 代码::块中的错误
- 是否可以将Visual Studio 2017将C 代码编译到EXE以外的文件类型中
- 安装生成工具后找不到Visual Studio代码MSVC cl.exe
- 将代码移动到函数中时,DLL "myApp.exe"中找不到序号错误0xC0000138
- circle.exe 在代码块中使用 graphics.h 时停止工作
- 编译C++代码以.EXE返回双精度
- 将32位和64位应用程序(具有相同代码)编译为一个EXE
- 如何使用Visual Studio C/C++编译器(cl.exe)来预处理我的objective-C代码
- C++ - 代码在Visual Studio中完美运行,但命令行中的.exe不断崩溃
- 如何修复使用代码 2 退出"CL.exe"
- C++ / CannyEdgeDetection.exe 已停止工作 代码块 /OpenCV 错误:断言失败
- 错误 MSB6006:"midl.exe"退出,代码为 -1073741515
- 使用 Eclipse 运行.exe C 代码文件
- 在visual studio中调试exe代码