Advertisement
Guest User

ProcessModder.h

a guest
Jun 6th, 2013
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. #ifndef PROCESSMODDER_H
  2. #define PROCESSMODDER_H
  3. #include <Windows.h>
  4.  
  5. const DWORD PROCESS_ALL_LEGACY_ACCESS = PROCESS_CREATE_PROCESS|PROCESS_CREATE_THREAD|PROCESS_DUP_HANDLE|
  6. PROCESS_QUERY_INFORMATION|PROCESS_SET_INFORMATION|PROCESS_SET_QUOTA|
  7. PROCESS_SUSPEND_RESUME|PROCESS_TERMINATE|PROCESS_VM_OPERATION|
  8. PROCESS_VM_READ|PROCESS_VM_WRITE|SYNCHRONIZE;
  9.  
  10. class ProcessModder
  11. {
  12. public:
  13.  
  14. // Constructors / Destructors
  15. ProcessModder() : hookedProcess(NULL) { } // Default constructor
  16. ~ProcessModder() { close(); } // Destructor
  17.  
  18. // Attempts to find and hook the process with the given information
  19. bool openWithProcessID(DWORD processID);
  20. bool openWithProcessName(const char* szProcessName);
  21. bool openWithWindowName(const char* szWindowName);
  22. bool openWithProcessHandle(HANDLE hProcess);
  23.  
  24. // Returns true if a process has been hooked and remains open
  25. bool isOpen();
  26.  
  27. // Cleans up process handles
  28. void close();
  29.  
  30. // Replaces the item at address with 'value'
  31. template <typename valueType>
  32. bool writeMem(UINT address, valueType value);
  33.  
  34. // Reads the item at address into 'value'
  35. template <typename valueType>
  36. bool readMem(UINT address, valueType &value);
  37.  
  38.  
  39. protected:
  40.  
  41. // Hooks the process with the given process ID
  42. bool Hook(DWORD processID);
  43.  
  44. /** Finds the process ID that corresponding to the name
  45. returns true and sets processID if successful */
  46. bool FindProcess(const char* szProcessName, DWORD &processID);
  47.  
  48.  
  49. private:
  50.  
  51. HANDLE hookedProcess; // Handle to the currently hooked process
  52. };
  53.  
  54. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement