vovan333

some winapi shitcode

Nov 5th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <Windows.h>
  2. #include <Psapi.h>
  3. #include <stdio.h>
  4. #include <string>
  5.  
  6. class Process
  7. {
  8.     private:
  9.     HANDLE Handle;
  10.  
  11.     public:
  12.     int Id;
  13.  
  14.     Process(int id)
  15.     {
  16.         Handle = OpenProcess(PROCESS_QUERY_INFORMATION, false, id);
  17.         Id = id;
  18.     }
  19.  
  20.     std::string GetFileName()
  21.     {
  22.         LPTSTR fileName = LPTSTR("");
  23.         GetProcessImageFileName(Handle, fileName, 10000);
  24.         return std::string((char*)fileName);
  25.     }
  26.  
  27.     void Terminate()
  28.     {
  29.         TerminateProcess(Handle, 0);
  30.     }
  31.  
  32.     void WriteMemory(unsigned long start, byte* bytes)
  33.     {
  34.         WriteProcessMemory(Handle, LPVOID(start), bytes, sizeof(bytes), nullptr);
  35.     }
  36.  
  37.     byte* ReadMemory(unsigned long start, unsigned long bytesLength)
  38.     {
  39.         LPVOID result;
  40.         ReadProcessMemory(Handle, LPVOID(start), result, SIZE_T(bytesLength), nullptr);
  41.         return (byte*)result;
  42.     }
  43. };
  44.  
  45. int main()
  46. {
  47.     int pid = 6460;
  48.     Process googleChrome(pid);
  49.     googleChrome.GetFileName();
  50. }
Add Comment
Please, Sign In to add comment