NoamCohen123

Apc_Injection

Jul 17th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.95 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <wchar.h>
  4.  
  5.  
  6. #include <cstdio>
  7. #include <windows.h>
  8. #include <tlhelp32.h>
  9.  
  10. #define UNICODE
  11. #define _UNICODE
  12. int wmain(int argc ,wchar_t *argv[])
  13. {
  14.     HANDLE hProcessSnap;
  15.     PROCESSENTRY32 entry;
  16.     entry.dwSize = sizeof(PROCESSENTRY32);
  17.     HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
  18.     int i = 0;
  19.     //wchar_t *process_name= argv[1];
  20.    
  21.  
  22.     if (Process32First(snapshot, &entry) == TRUE)
  23.     {
  24.         while (Process32Next(snapshot, &entry) == TRUE)
  25.         {
  26.             i++;
  27.  
  28.             if (wcscmp(argv[1], entry.szExeFile) == 0)
  29.             {
  30.                 //HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, entry.th32ProcessID);
  31.                 printf("%d", entry.th32ProcessID);
  32.                 //printf("%d", entry.cntThreads);
  33.  
  34.  
  35.                 // Do stuff..
  36.  
  37.                 //CloseHandle(hProcess);
  38.             }
  39.             //_wprintf_l(TEXT("Process id: %s , process number: %d\n"), entry.szExeFile, i);
  40.        
  41.  
  42.         }
  43.     }
  44.     getchar();
  45.     CloseHandle(snapshot);
  46.     return 0;
  47.  
  48.    
  49. }
Advertisement
Add Comment
Please, Sign In to add comment