Skip to content

Instantly share code, notes, and snippets.

@Wizek
Last active November 28, 2016 06:37
Show Gist options
  • Save Wizek/bb942da3de6b4a0f2ff175d9c2b1742f to your computer and use it in GitHub Desktop.
Save Wizek/bb942da3de6b4a0f2ff175d9c2b1742f to your computer and use it in GitHub Desktop.
#include <windows.h>
#include <stdio.h>
typedef LONG (NTAPI *NtSuspendProcess)(IN HANDLE ProcessHandle);
void suspend(DWORD processId)
{
HANDLE processHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, processId);
NtSuspendProcess pfnNtSuspendProcess = (NtSuspendProcess)GetProcAddress(
GetModuleHandle("ntdll"), "NtSuspendProcess");
pfnNtSuspendProcess(processHandle);
CloseHandle(processHandle);
}
void resume(DWORD processId)
{
HANDLE processHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, processId);
NtSuspendProcess pfnNtResumeProcess = (NtSuspendProcess)GetProcAddress(
GetModuleHandle("ntdll"), "NtResumeProcess");
pfnNtResumeProcess(processHandle);
CloseHandle(processHandle);
}
int main() {
printf("1\n");
// suspend(10196);
// resume(10196);
GetForegroundWindow();
printf("2\n");
char array[320];
for (int i = 0; i < 10; ++i) {
GetWindowText(GetForegroundWindow(), array, 300);
printf("%s\n", array);
sleep(2);
}
printf("3\n");
// MessageBox(GetForegroundWindow(), "Text", "Title", Flags);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment