Skip to content

Instantly share code, notes, and snippets.

@mcfx
Created January 4, 2022 13:05
Show Gist options
  • Save mcfx/2a96fee0c7ec7edfb034b1becf65213c to your computer and use it in GitHub Desktop.
Save mcfx/2a96fee0c7ec7edfb034b1becf65213c to your computer and use it in GitHub Desktop.
Suspend gta5 without resource monitor
#include <cstdio>
#include <cstring>
#include <tlhelp32.h>
#include <windows.h>
int getpid(const char *pname) {
int pid = -1;
HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (hSnapshot) {
PROCESSENTRY32 pe32;
pe32.dwSize = sizeof(PROCESSENTRY32);
if (Process32First(hSnapshot, &pe32)) {
do {
if (strcmp(pname, pe32.szExeFile) == 0)
pid = pe32.th32ProcessID;
// printf("pid %d %s %d\n", pe32.th32ProcessID,
// pe32.szExeFile,strcmp(pname,pe32.szExeFile));
} while (Process32Next(hSnapshot, &pe32));
}
CloseHandle(hSnapshot);
}
return pid;
}
int main() {
int pid = getpid("GTA5.exe");
printf("gta5 pid: %d\n", pid);
DebugActiveProcess(pid);
puts("suspend ok");
printf("press enter to resume...");
getchar();
DebugActiveProcessStop(pid);
puts("resume ok");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment