-1
我知道,在C#中我可以這樣做:C++ BaseAddress和入口地址
Process currentProcess = System.Diagnostics.Process.GetCurrentProcess();
currentProcess.Modules[0].BaseAddress
currentProcess.Modules[0].EntryPointAddress
我將如何得到C++這些信息?
縱觀我有:在非託管代碼
void
get_module_name_for_address(LPVOID address,
TCHAR *buf, int buf_size)
{
HANDLE process;
HMODULE modules[256];
DWORD bytes_needed, num_modules;
unsigned int i;
buf[0] = '\0';
process = GetCurrentProcess();
if (EnumProcessModules(process, (HMODULE *) &modules,
sizeof(modules), &bytes_needed) == 0)
{
return;
}
if (bytes_needed > sizeof(modules))
bytes_needed = sizeof(modules);
num_modules = bytes_needed/sizeof(HMODULE);
for (i = 0; i < num_modules; i++)
{
MODULEINFO mi;
if (GetModuleInformation(process, modules[i], &mi, sizeof(mi)) != 0)
{
LPVOID start, end;
start = mi.lpBaseOfDll;
end = (char *) start + mi.SizeOfImage;
if (address >= start && address <= end)
{
GetModuleBaseName(process, modules[i], buf, buf_size);
return;
}
}
}
}
什麼是你的問題?你有代碼,顯然做你所需要的。 MSDN示例中包含您所需的全部內容:http://msdn.microsoft.com/en-us/library/windows/desktop/ms682621(v=vs.85).aspx – 2012-03-22 13:23:10