Advertisement
Guest User

Untitled

a guest
Mar 28th, 2020
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. #include "Memory.h"
  2.  
  3. CMemory Memory;
  4.  
  5. void CMemory::getHandle()
  6. {
  7. HANDLE hPID = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
  8. PROCESSENTRY32 ProcEntry;
  9. ProcEntry.dwSize = sizeof(ProcEntry);
  10. do
  11. {
  12. if (!strcmp(ProcEntry.szExeFile, "csgo.exe"))
  13. {
  14. Offsets.PID = ProcEntry.th32ProcessID;
  15. CloseHandle(hPID);
  16. Offsets.handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, Offsets.PID);
  17. std::cout << "Process found!\n";
  18. std::this_thread::sleep_for(std::chrono::milliseconds(1000));
  19. system("cls"); //Not best method to clean console, but works :)
  20. return;
  21. }
  22. } while (Process32Next(hPID, &ProcEntry));
  23. CloseHandle(hPID);
  24. std::cout << "Process not found.." << std::endl;
  25. Sleep(1000);
  26. exit(0);
  27. }
  28.  
  29. int CMemory::getModule(const char* moduleName)
  30. {
  31. HANDLE hModule = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, Offsets.PID);
  32. MODULEENTRY32 mEntry;
  33.  
  34. mEntry.dwSize = sizeof(mEntry);
  35.  
  36. while (Module32Next(hModule, &mEntry)) {
  37. if (!strcmp(mEntry.szModule, moduleName))
  38. {
  39. std::cout << moduleName << " found!\n";
  40. std::this_thread::sleep_for(std::chrono::milliseconds(1000));
  41. system("cls");
  42. CloseHandle(hModule);
  43. return (DWORD)mEntry.modBaseAddr;
  44. }
  45. }
  46. CloseHandle(hModule);
  47. return 0;
  48. }
  49.  
  50. #pragma once
  51.  
  52. #include <iostream>
  53. #include <Windows.h>
  54. #include <TlHelp32.h>
  55. #include <thread>
  56. #include "Offsets.h"
  57.  
  58. class CMemory
  59. {
  60. public:
  61. void getHandle();
  62. int getModule(const char* moduleName);
  63. };
  64.  
  65. extern CMemory Memory;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement