-
-
[求助]大脑当机了,怎么也看不出哪里循环
-
发表于:
2009-5-17 21:47
4096
-
各个大哥,提点下小弟,初学SDK,诸多障碍
BOOL CALLBACK EnumWindowsProc(HWND hwnd,LPARAM lParam)
{
DWORD aProcesses[1024], cbNeededa, cProcesses;
if ( !EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeededa ) )
return TRUE;
cProcesses = cbNeededa / sizeof(DWORD);
HMODULE hMods[1024];
HANDLE hProcess;
DWORD cbNeeded;
unsigned int i;
unsigned int j;
for(j= 0; j < cProcesses; j++)
{
hProcess = OpenProcess( PROCESS_QUERY_INFORMATION |
PROCESS_VM_READ,
FALSE, aProcesses[j]);
if (NULL == hProcess)
continue;
if( EnumProcessModules(hProcess, hMods, sizeof(hMods), &cbNeeded))
{
for ( i = 0; i < (cbNeeded / sizeof(HMODULE)); i++ )
{
TCHAR szModName[MAX_PATH];
if ( GetModuleFileNameEx(hProcess, hMods[i], szModName,
sizeof(szModName)/sizeof(TCHAR)))
{
unsigned int h;
unsigned int j;
for (h=0;h<MAX_PATH && szModName[h]!=L'\0';h++);
for (j=h;j!=0 && szModName[j]!=L'\\';j--);
unsigned int f=h-j;
TCHAR *buffer=new TCHAR[f];
for (unsigned int g=0;g<f;g++,j++)
{
buffer[g]=szModName[j+1];
}
if (!StrCmpCW(buffer,L"22-ImgWalk.DLL"))
{
DWORD lpdwProcessId=NULL;
GetWindowThreadProcessId(hwnd,&lpdwProcessId);
HANDLE hInsB=OpenProcess(PROCESS_ALL_ACCESS,FALSE,lpdwProcessId);
if (hInsB==hProcess)
{
if(!SetWindowPos(hwnd,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE))
{
MessageBox(hwnd,L"error",L"error",MB_OK);
}
CloseHandle(hInsB);
}
}
delete [] buffer;
}
}
}
CloseHandle(hProcess);
}
return true;
}
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课