All pastes #829443 Raw Edit

KOrUPt

public text v1 · immutable
#829443 ·published 2007-12-23 04:36 UTC
rendered paste body
//by EvilFourZero(don't forgot to give credit), KOrUPt. 
HANDLE GetProcessHandle(LPSTR szExeName)
{
    PROCESSENTRY32 Pc = { sizeof(PROCESSENTRY32) };
    hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPALL, 0);
    if(lpfProcess32First(hSnapshot, &Pc))
    {
          do{
           if(!strcmp(Pc.szExeFile, szExeName))
             {
              if(!hProcess)
               {
                return OpenProcess(PROCESS_ALL_ACCESS, TRUE, Pc.th32ProcessID);
               }
              }
          Sleep(100);
         }while(lpfProcess32Next(hSnapshot, &Pc));
    }
   return NULL;
}