Re: Can I not OpenProcess(PROCESS_ALL_ACCESS...) in DLL under WinXP?
- From: ccbruce@xxxxxxxxx
- Date: Mon, 24 Dec 2007 17:53:14 -0800 (PST)
No, I didn' call OpenProcess in DllMain... I am sure that the same
thing was done in dll and exe.
The following is my code:
bool __stdcall _FindApp(wstring sClass, wstring sImage,
PROCESS_INFORMATION *pi)
{
DECLARE_DBG_SCOPE(_FindApp, true)
TCHAR buf[MAXSTR]=NULLSTR;
HWND hWnd=NULL;
hWnd=FindWindow((TCHAR *)sClass.c_str(), NULL);
pi->dwThreadId=GetWindowThreadProcessId(hWnd, &pi->dwProcessId);
pi->hProcess=OpenProcess(PROCESS_ALL_ACCESS, FALSE, pi->dwProcessId);
ASSERT(pi->hProcess); //in debug mode or under vista, this line
passes. but in xp, pi->hProcess==NULL and
GetLastError()==ACCESS_DENIED
GetModuleBaseName(pi->hProcess, NULL, buf, MAXSTR);
if(!hWnd || wstring(buf)!=sImage)
{
CloseHandle(pi->hProcess);
return false;
}
pi->hThread=OpenThread(THREAD_ALL_ACCESS, FALSE, pi->dwThreadId);
return true;
}
.
- Follow-Ups:
- Re: Can I not OpenProcess(PROCESS_ALL_ACCESS...) in DLL under WinXP?
- From: Joseph M . Newcomer
- Re: Can I not OpenProcess(PROCESS_ALL_ACCESS...) in DLL under WinXP?
- From: David Ching
- Re: Can I not OpenProcess(PROCESS_ALL_ACCESS...) in DLL under WinXP?
- References:
- Can I not OpenProcess(PROCESS_ALL_ACCESS...) in DLL under WinXP?
- From: ccbruce
- Re: Can I not OpenProcess(PROCESS_ALL_ACCESS...) in DLL under WinXP?
- From: Joseph M . Newcomer
- Can I not OpenProcess(PROCESS_ALL_ACCESS...) in DLL under WinXP?
- Prev by Date: Re: Draw checkmark algorithm
- Next by Date: Re: How to create the GDI+ Bitmap object from images stored in memory?
- Previous by thread: Re: Can I not OpenProcess(PROCESS_ALL_ACCESS...) in DLL under WinXP?
- Next by thread: Re: Can I not OpenProcess(PROCESS_ALL_ACCESS...) in DLL under WinXP?
- Index(es):
Relevant Pages
|