Pesquisar na Comunidade
Mostrando resultados para as tags ''resumir''.
Encontrado 1 registro
-
Pode ser utilizado para pausar processos para injetar Dll's ou pausar jogos para leitura da memória ,por exemplo. #include <Windows.h> #include <iostream> #include <TlHelp32.h> using namespace std; #pragma warning(disable:4996) int GetPID(char* Process_Name) { HANDLE hAndle; PROCESSENTRY32 pEntry32; hAndle = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); ZeroMemory(&pEntry32, sizeof(PROCESSENTRY32)); pEntry32.dwSize = sizeof(PROCESSENTRY32); Process32First(hAndle, &pEntry32); char Name[40] = ""; do { wcstombs(Name, pEntry32.szExeFile, 40); if (!strcmp(Name, Process_Name)) { CloseHandle(hAndle); return pEntry32.th32ProcessID; } } while (Process32Next(hAndle, &pEntry32)); CloseHandle(hAndle); return 0; } int ThreadID(int PID,int *TIDs) // Retorna o número thread's { HANDLE hAndle; THREADENTRY32 tEntry32; hAndle = CreateToolhelp32Snapshot(TH32CS_SNAPALL, 0); ZeroMemory(&tEntry32, sizeof(THREADENTRY32)); tEntry32.dwSize = sizeof(THREADENTRY32); Thread32First(hAndle, &tEntry32); int i = 0; for (; Thread32Next(hAndle, &tEntry32);) { if (tEntry32.th32OwnerProcessID == PID) { if (TIDs != NULL) { TIDs[i] = tEntry32.th32ThreadID; } i++; } } CloseHandle(hAndle); return i; } int sSuspendThread(int * TIDs, int Numero_de_Threads) { for (int i = 0; i <= Numero_de_Threads; i++) { SuspendThread(OpenThread(THREAD_ALL_ACCESS, FALSE, TIDs[i])); } return 1; } int sResumeThread(int * TIDs, int Numero_de_Threads) { for (int i = 0; i <= Numero_de_Threads; i++) { ResumeThread(OpenThread(THREAD_ALL_ACCESS, FALSE, TIDs[i])); } return 1; } int main() { int TIDs[60]; int Length = ThreadID(GetPID("ProcessHacker.exe"), TIDs); bool OnOff = false; printf_s("Nome do processo: ProcessHacker.exe PID: %i Numero de Threads: %i \n", GetPID("ProcessHacker.exe"), ThreadID(GetPID("ProcessHacker.exe"), NULL)); while (true) { if (GetAsyncKeyState(VK_CONTROL) && OnOff == false) { Sleep(250); sSuspendThread(TIDs, Length); OnOff = !OnOff; cout << "Threads pausadas!" << endl; } if (GetAsyncKeyState(VK_CONTROL) && OnOff == true) { Sleep(250); sResumeThread(TIDs, Length); OnOff = !OnOff; cout << "Threads resumidas!" << endl; } } system("pause"); return 0; } Resultado:
- 2 respostas
-
- 3
-
