Moderators: g3nuin3, SpeedWing, WhiteHat, mezzo
VOID On_ProcessIsOpening( LPVOID lpvEproc, DWORD dwParentId, DWORD dwProcId ) {
CHAR szBuffer[MAX_PATH];
if ( !GetProcessNameById( szBuffer, dwProcId ) ) { return; }
if ( StrICmp( szBuffer, "ENTERTHE_EXE_NAMEOFYOURGAMEHERE.exe" ) == 0 ) {
LoadProcess( dwProcId );
}
}
BOOL GetProcessNameById( CHAR * pcOutputName, DWORD dwId ) {
// Exactly the same as the Win32 API.
PROCESSENTRY32 pe32;
ZeroMemory( &pe32, sizeof( PROCESSENTRY32 ) );
pe32.dwSize = sizeof( PROCESSENTRY32 );
HANDLE hSnap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
if ( hSnap == INVALID_HANDLE_VALUE ) { // If the snap fails, error.
return false;
}
else {
BOOL bRet = false;
if ( Process32First( hSnap, &pe32 ) ) {
do {
if ( pe32.th32ProcessID == dwId ) {
bRet = true; // We have a match! Break immediately.
StrCpy( pcOutputName, pe32.szExeFile );
break;
}
} while ( Process32Next( hSnap, &pe32 ) );
}
// As with the Win32 API, we must close our handles.
// Technically we do not need to do this because the
// script will do it for us when this script thread exits,
// but that is bad coding practice.
CloseHandle( hSnap );
return bRet;
}
}
Users browsing this forum: No registered users and 0 guests