编译前的文件夹内容
:\>ls -l
-rw-rw-rw- 1 Admin 0 459 2015-09-10 10:23 structshow.cpp
资源
:\>cat structshow.cpp
#include <windows.h>
#include <dbghelp.h>
#include <stdio.h>
#pragma comment (lib,"dbghelp.lib")
BOOL CALLBACK mycallback(PSYMBOL_INFO pSymInfo,ULONG,PVOID){
printf("%s\n",pSymInfo->Name);
return true;
}
int main(){
HMODULE hmod = LoadLibraryA("c:\\windows\\system32\\ntdll.dll");
HANDLE hproc = GetCurrentProcess();
SymInitialize(hproc,"F:\\symbols",TRUE);
SymEnumTypesByName(hproc,(ULONG64)hmod,"*!_R*",mycallback,0);
return 0;
}
编译使用
:\>..\compile.bat
:\>if "C:\Program Files\Microsoft Visual Studio 10.0\VC\" == "" ()
:\>cl /Zi /EHsc /nologo /W4 /analyze *.cpp /link /RELEASE structshow.cpp
:\>ls -l
文件夹后编译的内容
-rw-rw-rw- 1 Admin 0 459 2015-09-10 10:23 structshow.cpp
-rwxrwxrwx 1 Admin 0 89088 2015-09-10 10:29 structshow.exe
-rw-rw-rw- 1 Admin 0 21081 2015-09-10 10:29 structshow.obj
-rw-rw-rw- 1 Admin 0 1002496 2015-09-10 10:29 structshow.pdb
-rw-rw-rw- 1 Admin 0 94208 2015-09-10 10:29 vc100.pdb
使用最新的 dbghelp.dll
:\>copy xxxx\dbghelp.dll .
1 file(s) copied.
:\>echo "do not use system dbghelp.dll it is
outdated SymbolEnumTypesbyName is available in
dbghelp version 6.8 and above only "
执行编译的二进制文件
:\>structshow.exe
_RTL_USER_PROCESS_PARAMETERS
_RTL_CRITICAL_SECTION <----------------------
_RTL_STACK_TRACE_ENTRY
_RTL_TRACE_BLOCK
_RTL_CRITICAL_SECTION_DEBUG
_RTL_DRIVE_LETTER_CURDIR
_RTL_TRACE_DATABASE
_RTL_TRACE_SEGMENT