OpenProcess初学者问题
HWNDhWnd=FindWindow(0,"扫雷");DWORDproid=GetWindowThreadProcessId(hWnd,NULL);HANDLEhPro...
HWND hWnd = FindWindow(0, "扫雷");
DWORD proid = GetWindowThreadProcessId(hWnd, NULL);
HANDLE hPro = OpenProcess(PROCESS_ALL_ACCESS, FALSE, proid);
cout << hWnd << endl;
cout << proid << endl;
cout << hPro << endl;
hWnd和proid都有值,但hPro是0,是哪里错了啊
HANDLE hPro = OpenProcess(PROCESS_ALL_ACCESS, FALSE, proid);
这句有问题吗?? 展开
DWORD proid = GetWindowThreadProcessId(hWnd, NULL);
HANDLE hPro = OpenProcess(PROCESS_ALL_ACCESS, FALSE, proid);
cout << hWnd << endl;
cout << proid << endl;
cout << hPro << endl;
hWnd和proid都有值,但hPro是0,是哪里错了啊
HANDLE hPro = OpenProcess(PROCESS_ALL_ACCESS, FALSE, proid);
这句有问题吗?? 展开
3个回答
展开全部
把PROCESS_ALL_ACCESS改成下面这些PROCESS_CREATE_THREAD|PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_VM_READ
也可以先提权再用PROCESS_ALL_ACCESS,提权代码你到网上搜一搜,一大堆。
另外本人菜鸟,只是按自己犯过的错误说下供参考是不是犯了同样的错误,我用VC
++2008试了下如下代码正确:
HWND hWnd=::FindWindow(NULL,_T("扫雷"));
DWORD ID;
LPDWORD PID=&ID;
::GetWindowThreadProcessId(hWnd,PID);
HANDLE hPro=OpenProcess(PROCESS_CREATE_THREAD|PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_VM_READ,FALSE,ID);
也可以先提权再用PROCESS_ALL_ACCESS,提权代码你到网上搜一搜,一大堆。
另外本人菜鸟,只是按自己犯过的错误说下供参考是不是犯了同样的错误,我用VC
++2008试了下如下代码正确:
HWND hWnd=::FindWindow(NULL,_T("扫雷"));
DWORD ID;
LPDWORD PID=&ID;
::GetWindowThreadProcessId(hWnd,PID);
HANDLE hPro=OpenProcess(PROCESS_CREATE_THREAD|PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_VM_READ,FALSE,ID);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询