CybEl

GDI ESP Code

Feb 19th, 2020
22,966
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.57 KB | None | 0 0
  1. #include "pch.h"
  2. #include "Offsets.h"
  3. #include <iostream>
  4. #include <Windows.h>
  5. #include <TlHelp32.h>
  6.  
  7. /* SexOffenderSally helped code a lot/most of this with me, a long time friend! Give him a <3 on discord
  8. Make sure character set is 'Multi-Byte' in project settings! And game must be windowed fullscreen.
  9. Updated offsets: https://github.com/frk1/hazedumper/blob/master/csgo.cs */
  10.  
  11. #define EnemyPen 0x000000FF
  12. HBRUSH EnemyBrush = CreateSolidBrush(0x000000FF);
  13.  
  14. int screenX = GetSystemMetrics(SM_CXSCREEN);
  15. int screenY = GetSystemMetrics(SM_CYSCREEN);
  16.  
  17. DWORD GetProcId(const wchar_t* procName)
  18. {
  19. DWORD procId = 0;
  20. HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
  21. if (hSnap != INVALID_HANDLE_VALUE)
  22. {
  23. PROCESSENTRY32 procEntry;
  24. procEntry.dwSize = sizeof(procEntry);
  25.  
  26. if (Process32First(hSnap, &procEntry))
  27. {
  28. do
  29. {
  30. if (!_wcsicmp(procEntry.szExeFile, procName))
  31. {
  32. procId = procEntry.th32ProcessID;
  33. break;
  34. }
  35. } while (Process32Next(hSnap, &procEntry));
  36.  
  37. }
  38. }
  39. CloseHandle(hSnap);
  40. return procId;
  41. }
  42.  
  43. uintptr_t GetModuleBaseAddress(DWORD procId, const wchar_t* modName)
  44. {
  45. uintptr_t modBaseAddr = 0;
  46. HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, procId);
  47. if (hSnap != INVALID_HANDLE_VALUE)
  48. {
  49. MODULEENTRY32 modEntry;
  50. modEntry.dwSize = sizeof(modEntry);
  51. if (Module32First(hSnap, &modEntry))
  52. {
  53. do
  54. {
  55. if (!_wcsicmp(modEntry.szModule, modName))
  56. {
  57. modBaseAddr = (uintptr_t)modEntry.modBaseAddr;
  58. break;
  59. }
  60. } while (Module32Next(hSnap, &modEntry));
  61. }
  62. }
  63. CloseHandle(hSnap);
  64. return modBaseAddr;
  65. }
  66.  
  67. uintptr_t moduleBase = GetModuleBaseAddress(GetProcId(L"csgo.exe"), L"client_panorama.dll");
  68. HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, NULL, GetProcId(L"csgo.exe"));
  69. HDC hdc = GetDC(FindWindowA(NULL, "Counter-Strike: Global Offensive"));
  70.  
  71. template<typename T> T RPM(SIZE_T address) {
  72. //The buffer for data that is going to be read from memory
  73. T buffer;
  74.  
  75. //The actual RPM
  76. ReadProcessMemory(hProcess, (LPCVOID)address, &buffer, sizeof(T), NULL);
  77.  
  78. //Return our buffer
  79. return buffer;
  80. }
  81.  
  82. struct view_matrix_t {
  83. float* operator[ ](int index) {
  84. return matrix[index];
  85. }
  86.  
  87. float matrix[4][4];
  88. };
  89.  
  90. struct Vector3
  91. {
  92. float x, y, z;
  93. };
  94.  
  95. Vector3 WorldToScreen(const Vector3 pos, view_matrix_t matrix) {
  96. float _x = matrix[0][0] * pos.x + matrix[0][1] * pos.y + matrix[0][2] * pos.z + matrix[0][3];
  97. float _y = matrix[1][0] * pos.x + matrix[1][1] * pos.y + matrix[1][2] * pos.z + matrix[1][3];
  98.  
  99. float w = matrix[3][0] * pos.x + matrix[3][1] * pos.y + matrix[3][2] * pos.z + matrix[3][3];
  100.  
  101. float inv_w = 1.f / w;
  102. _x *= inv_w;
  103. _y *= inv_w;
  104.  
  105. float x = screenX * .5f;
  106. float y = screenY * .5f;
  107.  
  108. x += 0.5f * _x * screenX + 0.5f;
  109. y -= 0.5f * _y * screenY + 0.5f;
  110.  
  111. return { x,y,w };
  112. }
  113.  
  114. void DrawFilledRect(int x, int y, int w, int h)
  115. {
  116. RECT rect = { x, y, x + w, y + h };
  117. FillRect(hdc, &rect, EnemyBrush);
  118. }
  119.  
  120. void DrawBorderBox(int x, int y, int w, int h, int thickness)
  121. {
  122. DrawFilledRect(x, y, w, thickness); //Top horiz line
  123. DrawFilledRect(x, y, thickness, h); //Left vertical line
  124. DrawFilledRect((x + w), y, thickness, h); //right vertical line
  125. DrawFilledRect(x, y + h, w + thickness, thickness); //bottom horiz line
  126. }
  127.  
  128. void DrawLine(float StartX, float StartY, float EndX, float EndY)
  129. {
  130. int a, b = 0;
  131. HPEN hOPen;
  132. HPEN hNPen = CreatePen(PS_SOLID, 2, EnemyPen);// penstyle, width, color
  133. hOPen = (HPEN)SelectObject(hdc, hNPen);
  134. MoveToEx(hdc, StartX, StartY, NULL); //start
  135. a = LineTo(hdc, EndX, EndY); //end
  136. DeleteObject(SelectObject(hdc, hOPen));
  137. }
  138.  
  139. int main()
  140. {
  141. while (true)
  142. {
  143. view_matrix_t vm = RPM<view_matrix_t>(moduleBase + dwViewMatrix);
  144. int localteam = RPM<int>(RPM<DWORD>(moduleBase + dwEntityList) + m_iTeamNum);
  145.  
  146. for (int i = 1; i < 64; i++)
  147. {
  148. uintptr_t pEnt = RPM<DWORD>(moduleBase + dwEntityList + (i * 0x10));
  149.  
  150. int health = RPM<int>(pEnt + m_iHealth);
  151. int team = RPM<int>(pEnt + m_iTeamNum);
  152.  
  153. Vector3 pos = RPM<Vector3>(pEnt + m_vecOrigin);
  154. Vector3 head;
  155. head.x = pos.x;
  156. head.y = pos.y;
  157. head.z = pos.z + 75.f;
  158. Vector3 screenpos = WorldToScreen(pos, vm);
  159. Vector3 screenhead = WorldToScreen(head, vm);
  160. float height = screenhead.y - screenpos.y;
  161. float width = height / 2.4f;
  162.  
  163. if (screenpos.z >= 0.01f && team != localteam && health > 0 && health < 101) {
  164. DrawBorderBox(screenpos.x - (width / 2), screenpos.y, width, height, 1);
  165. DrawLine(screenX / 2, screenY, screenpos.x, screenpos.y);
  166. }
  167. }
  168. }
  169. }
Add Comment
Please, Sign In to add comment