bool enableDebugPriv()
{
HANDLE hToken;
LUID sedebugnameValue;
TOKEN_PRIVILEGES tkp;
if (!OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY,&hToken))
{
return false;
}
if (!LookupPrivilegeValue(NULL,SE_DEBUG_NAME,&sedebugnameValue))
{
CloseHandle(hToken);
return false;
}
tkp.PrivilegeCount=1;
tkp.Privileges[0].Attributes=SE_PRIVILEGE_ENABLED;
tkp.Privileges[0].Luid=sedebugnameValue;
if (!AdjustTokenPrivileges(hToken,FALSE,&tkp,sizeof(tkp),NULL,NULL))
{CloseHandle(hToken);
return false;
}
return true;
}
DWORD OpenMap(DWORD pid)
{
MODULEENTRY32 me32;
me32.dwSize=sizeof(MODULEENTRY32);
HANDLE hSnap=::CreateToolhelp32Snapshot(TH32CS_SNAPMODULE,pid);
if(hSnap==INVALID_HANDLE_VALUE)
{
AfxMessageBox("创建快照失败!");
DWORD eid=GetLastError();
return 0;
}
BOOL ret=Module32First(hSnap,&me32);
do
{
if(!strcmp(me32.szModule,"Game.dll"))
{
return (DWORD)(me32.modBaseAddr);
}
}while(ret=Module32Next(hSnap,&me32));
return 0;
}
如上函数,当pid是War3的进程时就失败了啊,其他的没有问题,我的电脑是win7,求解决啊
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课