#include "windows.h"

typedef DWORD(WINAPI *PFSuspendProcess)(HANDLE hProcess);
typedef DWORD(WINAPI *PFResumeProcess)(HANDLE hProcess);


#include "tlhelp32.h"

BOOL GetProcessPathByID(DWORD dwPID, LPTSTR lpOut)


{
BOOL bRet = FALSE;
HANDLE hModuleSnap = INVALID_HANDLE_VALUE;
MODULEENTRY32 me32;
hModuleSnap = CreateToolhelp32Snapshot( TH32CS_SNAPMODULE, dwPID );
if( hModuleSnap == INVALID_HANDLE_VALUE )

{
return bRet;
}
me32.dwSize = sizeof( MODULEENTRY32 );
if( !Module32First( hModuleSnap, &me32 ) )

{
CloseHandle( hModuleSnap );
return bRet;
}
lstrcpyn(lpOut, me32.szExePath ,MAX_PATH);
CloseHandle( hModuleSnap );
return( TRUE );
return bRet;
}

DWORD GetProcessIDByName(LPCTSTR lpName)


{
DWORD dwRet = 0;
HANDLE hProcessSnap = NULL;

PROCESSENTRY32 pe32 =
{0};

TCHAR szImagePath[MAX_PATH] =
{0};
hProcessSnap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
if ( hProcessSnap == INVALID_HANDLE_VALUE )

{
return dwRet;
}
pe32.dwSize = sizeof( PROCESSENTRY32 );
if( !Process32First( hProcessSnap, &pe32 ) )

{
CloseHandle( hProcessSnap );
return dwRet;
}
do

{
if ( pe32.th32ProcessID==0 || pe32.th32ProcessID==4 )

{
continue;
}
if (!lstrcmpi(lpName, pe32.szExeFile))

{
dwRet = pe32.th32ProcessID;
break;
}
ZeroMemory(&szImagePath,sizeof(szImagePath));
if (GetProcessPathByID(pe32.th32ProcessID,szImagePath) )

{
if (!lstrcmpi(lpName, szImagePath))

{
dwRet = pe32.th32ProcessID;
break;
}
}
} while( Process32Next( hProcessSnap, &pe32 ) );
CloseHandle(hProcessSnap);
return dwRet;
}

int _tmain(int argc, _TCHAR* argv[])


{
PFSuspendProcess SuspendProcess;
PFResumeProcess ResumeProcess;
HMODULE hNtDllLib = LoadLibrary(TEXT("ntdll.dll"));
SuspendProcess = (PFSuspendProcess)GetProcAddress(hNtDllLib, "ZwSuspendProcess");
ResumeProcess = (PFResumeProcess )GetProcAddress(hNtDllLib, "ZwResumeProcess" );
DWORD Pid = GetProcessIDByName(argv[1]);
if (Pid==0)

{
return 1;
}
if(SuspendProcess)

{
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, Pid);
SuspendProcess(hProcess);
printf("Press any key to resume process
");
getc(stdin);
ResumeProcess(hProcess);
CloseHandle(hProcess);
}

FreeLibrary(hNtDllLib);
getc(stdin);

return 0;
}