Advertisement
Guest User

Untitled

a guest
Jan 27th, 2020
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1. #include <Windows.h>
  2. #include <Tlhelp32.h>
  3. #include <tchar.h>
  4. #include <iostream>
  5.  
  6. void pressSpace();
  7. uintptr_t GetModuleBaseAddress(DWORD procId, const wchar_t* modName);
  8.  
  9. int main()
  10. {
  11. DWORD processID;
  12. DWORD posX = 0x28BA354;
  13. DWORD posY = 0x28BA358;
  14. DWORD posZ = 0x28BA35C;
  15. DWORD onGround = 0x28BA3B9;
  16. DWORD PlayerJump = 0x28BA38C;
  17. float cPosX;
  18. bool bhop;
  19.  
  20. HWND hWnd = FindWindowA(NULL, "AssaultCube");
  21. GetWindowThreadProcessId(hWnd, &processID);
  22. HANDLE gHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, processID);
  23.  
  24. uintptr_t ac_client = (GetModuleBaseAddress(processID, L"ac_client.exe"));
  25.  
  26. // Die Adresse zum LocalPlayer (pointer)
  27. DWORD localPlayerAddr = (ac_client + 0x10F4F4);
  28. // Das LocalPlayer Objekt, also das, worauf der pointer LocalPlayerAddr, zeigt
  29. DWORD localPlayerObject = 0x0;
  30.  
  31. // So finden wir heraus, worauf der Pointer zeigt
  32. ReadProcessMemory(gHandle, (LPCVOID)localPlayerAddr, &localPlayerObject, sizeof(localPlayerObject), NULL);
  33.  
  34. // Das Offset für Leben ist 0xF8, also vom LocalPlayer die 0xF8 dazuzählen
  35. DWORD healthAddr = localPlayerObject + 0xF8;
  36. int healthValue;
  37.  
  38. // Schauen welche Int value an der Adresse healthAddr liegt
  39. ReadProcessMemory(gHandle, (LPCVOID)healthAddr, &healthValue, sizeof(healthValue), NULL);
  40.  
  41.  
  42. std::cout << "ac_client: " << healthValue << std::endl;
  43.  
  44. if (hWnd == 0)
  45. {
  46. printf("Coulnd't find game window!\n");
  47. return 0;
  48. }
  49.  
  50.  
  51. while (1)
  52. {
  53.  
  54. if (GetAsyncKeyState(VK_CONTROL))
  55.  
  56. {
  57. ReadProcessMemory(gHandle, (LPVOID)onGround, &bhop, sizeof(bhop), 0);
  58. if (bhop == 1)
  59. {
  60. pressSpace();
  61. }
  62. }
  63.  
  64. }
  65.  
  66.  
  67. return 0;
  68. }
  69.  
  70. void pressSpace()
  71. {
  72. INPUT ip;
  73.  
  74. ip.type = INPUT_KEYBOARD;
  75. ip.ki.wScan = 0;
  76. ip.ki.time = 0;
  77. ip.ki.dwExtraInfo = 0;
  78.  
  79. ip.ki.wVk = 0x20;
  80. ip.ki.dwFlags = 0; //Press the key down ?
  81. SendInput(1, &ip, sizeof(INPUT)); //Use function
  82.  
  83. Sleep(50); //Sleep so it doesn't spam the key press
  84.  
  85. ip.ki.dwFlags = KEYEVENTF_KEYUP; //Release the key
  86. SendInput(1, &ip, sizeof(INPUT)); //Use function
  87. }
  88.  
  89.  
  90. uintptr_t GetModuleBaseAddress(DWORD procId, const wchar_t* modName)
  91. {
  92. uintptr_t modBaseAddr = 0;
  93. HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, procId);
  94. if (hSnap != INVALID_HANDLE_VALUE)
  95. {
  96. MODULEENTRY32 modEntry;
  97. modEntry.dwSize = sizeof(modEntry);
  98. if (Module32First(hSnap, &modEntry))
  99. {
  100. do
  101. {
  102. if (!_wcsicmp(modEntry.szModule, modName))
  103. {
  104. modBaseAddr = (uintptr_t)modEntry.modBaseAddr;
  105. break;
  106. }
  107. } while (Module32Next(hSnap, &modEntry));
  108. }
  109. }
  110. CloseHandle(hSnap);
  111. return modBaseAddr;
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement