Advertisement
Guest User

Untitled

a guest
May 29th, 2016
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.44 KB | None | 0 0
  1. #include <Windows.h>
  2. #include <Psapi.h>
  3. #include <TlHelp32.h>
  4. #include <vector>
  5. #include <string>
  6. #include "Includes.h"
  7. #include "DXfunctions.h"
  8.  
  9. using namespace std;
  10.  
  11. bool HideMenu = false;
  12. DWORD MenuPosition = 0;
  13.  
  14. bool ENABLE_AIMBOT = true;
  15. bool ENABLE_CROSSHAIR = true;
  16. bool ENABLE_CHAMS = true;
  17. float AIM_X = 0.1f;
  18. float AIM_Y = -0.2f;
  19. float AIM_Z = 1.6f;
  20. DWORD AIM_PLAYERS = 2;
  21. DWORD AIM_KEY = VK_END;
  22. DWORD AIM_KEY_SEATED = VK_F5;
  23. int AIM_FOV = 0;
  24. int AIM_SMOOTH = 0;
  25.  
  26. const DWORD MaxOptions = 8;
  27. const wchar_t* AimOptions[3] = { L"", L"", L"" };
  28. struct ContractWarsMenu_t
  29. {
  30. wchar_t* type;
  31. float Number;
  32. bool IsTrue;
  33. };
  34. ContractWarsMenu_t HackMenu[MaxOptions] = {
  35. { L"", 0.0f , true },
  36. { L"", 0.1f , false },
  37. { L"", -0.2f , false },
  38. { L"", 1.6f , false },
  39. { L"", 0.0f , false },
  40. { L"", 2.0f , false },
  41. { L"", 0.0f , true },
  42. { L"", 0.0f , true }
  43. };
  44.  
  45. void ShowMenuOptions(LPDIRECT3DDEVICE9 pDevice)
  46. {
  47. pDevice->GetViewport(&viewport);
  48. if (viewport.Width <= 100) return;
  49.  
  50. if (GetAsyncKeyState(VK_F7) & 1) HideMenu = !HideMenu;
  51. if (HideMenu) return;
  52.  
  53. DrawString(hackMenuFont, 10, 10, 0xFF00CCFF, L"Hack created by Chase Nelson", 1);
  54.  
  55. int LastValue = 0;
  56. for (int i = 0; i < MaxOptions; i++)
  57. {
  58. if (i == MenuPosition)
  59. {
  60. DrawRectangle(pDevice, hackMenuLine, 8, 48 + (i * 15), 230, 18, 0xFF0000FF);
  61. }
  62. DrawString(hackMenuFont, 10, 50 + (i * 15), 0xFF00FF00, L"", HackMenu[i].type);
  63. if (i == 0 || i == 6 || i == 7) DrawString(hackMenuFont, 150, 50 + (i * 15), HackMenu[i].IsTrue == true ? 0xFF00FF00 : 0xFFFF0000, L"", HackMenu[i].IsTrue == true ? L"TRUE" : L"FALSE"); else
  64. if (i == 1 || i == 2 || i == 3 || i == 4) DrawString(hackMenuFont, 150, 50 + (i * 15), 0xFF00FF00, L"", HackMenu[i].Number); else//4.2 = mostrar só duas casas decimais
  65. if (i == 5) DrawString(hackMenuFont, 150, 50 + (i * 15), 0xFF00FF00, L"", AimOptions[(int)HackMenu[i].Number]);
  66. LastValue = i;
  67. }
  68.  
  69. DrawString(hackMenuFont, 10, 50 + ((LastValue + 2) * 15), RED, L"", 1);
  70.  
  71.  
  72. if (GetAsyncKeyState(VK_F7) & 1) { if (MenuPosition > 0) MenuPosition--; }
  73. if (GetAsyncKeyState(VK_F8) & 1) { if (MenuPosition < MaxOptions - 1) MenuPosition++; }
  74.  
  75. if (GetAsyncKeyState(VK_F5) & 1)
  76. {
  77. if (MenuPosition == 0) HackMenu[MenuPosition].IsTrue = false; else
  78. if (MenuPosition == 1) HackMenu[MenuPosition].Number -= 0.1f; else
  79. if (MenuPosition == 2) HackMenu[MenuPosition].Number -= 0.1f; else
  80. if (MenuPosition == 3) HackMenu[MenuPosition].Number -= 0.1f; else
  81. if (MenuPosition == 4) { if (HackMenu[MenuPosition].Number > 50) HackMenu[MenuPosition].Number -= 1.0f; }
  82. else
  83. if (MenuPosition == 5) { if (HackMenu[MenuPosition].Number > 0) HackMenu[MenuPosition].Number -= 1.0f; }
  84. else
  85. if (MenuPosition == 6) HackMenu[MenuPosition].IsTrue = false; else
  86. if (MenuPosition == 7) HackMenu[MenuPosition].IsTrue = false;
  87. }
  88.  
  89. if (GetAsyncKeyState(VK_F7) & 1)
  90. {
  91. if (MenuPosition == 0) HackMenu[MenuPosition].IsTrue = true; else
  92. if (MenuPosition == 1) HackMenu[MenuPosition].Number += 0.1f; else
  93. if (MenuPosition == 2) HackMenu[MenuPosition].Number += 0.1f; else
  94. if (MenuPosition == 3) HackMenu[MenuPosition].Number += 0.1f; else
  95. if (MenuPosition == 4) { if (HackMenu[MenuPosition].Number < 200) HackMenu[MenuPosition].Number += 1.0f; }
  96. else
  97. if (MenuPosition == 5) { if (HackMenu[MenuPosition].Number < 2) HackMenu[MenuPosition].Number += 1.0f; }
  98. else
  99. if (MenuPosition == 6) HackMenu[MenuPosition].IsTrue = true; else
  100. if (MenuPosition == 7) HackMenu[MenuPosition].IsTrue = true;
  101. }
  102.  
  103. ENABLE_AIMBOT = HackMenu[0].IsTrue;
  104. AIM_X = HackMenu[1].Number;
  105. AIM_Y = HackMenu[2].Number;
  106. AIM_Z = HackMenu[3].Number;
  107. AIM_FOV = HackMenu[4].Number;
  108. AIM_PLAYERS = HackMenu[5].Number;
  109. ENABLE_CROSSHAIR = HackMenu[6].IsTrue;
  110. ENABLE_CHAMS = HackMenu[7].IsTrue;
  111. }
  112.  
  113. struct PlayerINFO
  114. {
  115. D3DXVECTOR3 Position2D;
  116.  
  117. D3DXVECTOR3 PositionFoot;
  118. D3DXVECTOR3 PositionHead;
  119.  
  120. float DistanceFromPlayer;
  121. float CrosshairDistance;
  122. int Team;
  123. };
  124. vector<PlayerINFO*>pINFO;
  125.  
  126. void AddEnemy(LPDIRECT3DDEVICE9 Device, int Team)
  127. {
  128. if (hackMenuLine == NULL) return;
  129. if (hackMenuFont == NULL) return;
  130.  
  131. PlayerINFO* playerINFO = new PlayerINFO;
  132. playerINFO->Team = Team;
  133.  
  134. D3DXMATRIX matrix;
  135. D3DXVECTOR4 position, positionH, positionF;
  136. D3DXVECTOR4 input;
  137.  
  138. Device->GetVertexShaderConstantF(0, (float *)&matrix, 4);
  139.  
  140. input.x = AIM_X;
  141. input.y = AIM_Y;
  142. input.z = AIM_Z;
  143. if ((GetAsyncKeyState(AIM_KEY_SEATED) & 0x8000)) input.z -= 0.5f;
  144. input.w = 0;
  145.  
  146. D3DXMatrixTranspose((D3DXMATRIX *)&matrix, (D3DXMATRIX *)&matrix);
  147.  
  148. position.x = input.x * matrix._11 + input.y * matrix._21 + input.z * matrix._31 + matrix._41;
  149. position.y = input.x * matrix._12 + input.y * matrix._22 + input.z * matrix._32 + matrix._42;
  150. position.z = input.x * matrix._13 + input.y * matrix._23 + input.z * matrix._33 + matrix._43;
  151. position.w = input.x * matrix._14 + input.y * matrix._24 + input.z * matrix._34 + matrix._44;
  152.  
  153. float A = 0.1f;
  154. float B = -0.2f;
  155. float C = 0.0f;
  156. positionF.x = A * matrix._11 + B * matrix._21 + C * matrix._31 + matrix._41;
  157. positionF.y = A * matrix._12 + B * matrix._22 + C * matrix._32 + matrix._42;
  158. positionF.z = A * matrix._13 + B * matrix._23 + C * matrix._33 + matrix._43;
  159. positionF.w = A * matrix._14 + B * matrix._24 + C * matrix._34 + matrix._44;
  160.  
  161. A = 0.1f;
  162. B = -0.2f;
  163. C = 1.8f;
  164. positionH.x = A * matrix._11 + B * matrix._21 + C * matrix._31 + matrix._41;
  165. positionH.y = A * matrix._12 + B * matrix._22 + C * matrix._32 + matrix._42;
  166. positionH.z = A * matrix._13 + B * matrix._23 + C * matrix._33 + matrix._43;
  167. positionH.w = A * matrix._14 + B * matrix._24 + C * matrix._34 + matrix._44;
  168.  
  169. playerINFO->DistanceFromPlayer = position.z;
  170.  
  171. if (matrix._44 > 1.0f)
  172. {
  173. playerINFO->Position2D.x = ((position.x / position.w) * (viewport.Width / 2)) + viewport.X + (viewport.Width / 2);
  174. playerINFO->Position2D.y = viewport.Y + (viewport.Height / 2) - ((position.y / position.w) * (viewport.Height / 2));
  175.  
  176. playerINFO->PositionHead.x = ((positionH.x / positionH.w) * (viewport.Width / 2)) + viewport.X + (viewport.Width / 2);
  177. playerINFO->PositionHead.y = viewport.Y + (viewport.Height / 2) - ((positionH.y / positionH.w) * (viewport.Height / 2));
  178.  
  179. playerINFO->PositionFoot.x = ((positionF.x / positionF.w) * (viewport.Width / 2)) + viewport.X + (viewport.Width / 2);
  180. playerINFO->PositionFoot.y = viewport.Y + (viewport.Height / 2) - ((positionF.y / positionF.w) * (viewport.Height / 2));
  181.  
  182. pINFO.push_back(playerINFO);
  183. }
  184. }
  185.  
  186. void AimEnemy(LPDIRECT3DDEVICE9 Device)
  187. {
  188. if (pINFO.size() != NULL)
  189. {
  190. UINT BestTarget = -1;
  191. DOUBLE fClosestPos = 99999;
  192. float Radius = 4.0f;
  193.  
  194. float ScreenCenterX = viewport.Width / 2.0f;
  195. float ScreenCenterY = viewport.Height / 2.0f;
  196.  
  197. for (int i = 0; i < pINFO.size(); i++)
  198. {
  199. if (AIM_PLAYERS == 2 || (AIM_PLAYERS == (float)pINFO[i]->Team))
  200. {
  201. float h = pINFO[i]->PositionHead.y - pINFO[i]->PositionFoot.y;
  202. float w = h / 4;
  203.  
  204. if (h < viewport.Height / 4)
  205. {
  206. //DrawPoint(Device, (int)pINFO[i]->Position2D.x, viewport.Height - (int)pINFO[i]->Position2D.y, 4, 4, RED);
  207. //DrawCircle((int)pINFO[i]->Position2D.x, viewport.Height - (int)pINFO[i]->Position2D.y, Radius, 20, Device, hackMenuLine, RED);
  208. //DrawLine(ScreenCenterX, ScreenCenterY*2.0f, pINFO[i]->Position2D.x, viewport.Height - pINFO[i]->Position2D.y + Radius, 1, RED, Device, hackMenuLine);
  209. //DrawString(hackMenuFont, pINFO[i]->Position2D.x + 3, viewport.Height - pINFO[i]->Position2D.y, 0xFF00FF00, L"Distance: %4.2f mts", ModelInfo[i]->DistanceFromPlayer);
  210.  
  211. //DrawRectangle(Device, hackMenuLine, pINFO[i]->PositionFoot.x - w + w / 2, viewport.Height - pINFO[i]->PositionFoot.y - h, w, h, RED);
  212. }
  213.  
  214. float radius = AIM_FOV;
  215.  
  216. pINFO[i]->CrosshairDistance = GetDistance(pINFO[i]->Position2D.x, pINFO[i]->Position2D.y, ScreenCenterX, ScreenCenterY);
  217.  
  218. if (pINFO[i]->Position2D.x >= ScreenCenterX - radius && pINFO[i]->Position2D.x <= ScreenCenterX + radius && pINFO[i]->Position2D.y >= ScreenCenterY - radius && pINFO[i]->Position2D.y <= ScreenCenterY + radius)
  219. {
  220. if (pINFO[i]->CrosshairDistance < fClosestPos)
  221. {
  222. fClosestPos = pINFO[i]->CrosshairDistance;
  223. BestTarget = i;
  224. }
  225. }
  226. }
  227. }
  228.  
  229. if (BestTarget != -1)
  230. {
  231. double DistX = (double)pINFO[BestTarget]->Position2D.x - ScreenCenterX;
  232. double DistY = (double)pINFO[BestTarget]->Position2D.y - ScreenCenterY;
  233.  
  234. DistX /= AIM_SMOOTH;
  235. DistY /= -AIM_SMOOTH;
  236.  
  237. if ((GetAsyncKeyState(AIM_KEY) & 0x8000) || (GetAsyncKeyState(AIM_KEY_SEATED) & 0x8000))
  238. mouse_event(MOUSEEVENTF_MOVE, (DWORD)DistX, (DWORD)DistY, NULL, NULL);
  239. }
  240.  
  241. pINFO.clear();
  242. }
  243. }
  244.  
  245. LPDIRECT3DTEXTURE9 g_pTexRed = NULL;
  246. LPDIRECT3DTEXTURE9 g_pTexOrange = NULL;
  247. LPDIRECT3DTEXTURE9 g_pTexGreen = NULL;
  248. LPDIRECT3DTEXTURE9 g_pTexBlue = NULL;
  249.  
  250. const BYTE red[58] = {
  251. 0x42, 0x4D, 0x3A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x28, 0x00,
  252. 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x18, 0x00, 0x00, 0x00,
  253. 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  254. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00
  255. };
  256.  
  257. const BYTE orange[58] = {
  258. 0x42, 0x4D, 0x3A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x28, 0x00,
  259. 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x18, 0x00, 0x00, 0x00,
  260. 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  261. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA5, 0xFF, 0x00
  262. };
  263.  
  264. const BYTE green[60] =
  265. {
  266. 0x42, 0x4D, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  267. 0x00, 0x36, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00,
  268. 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
  269. 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  270. 0x00, 0x00, 0x12, 0x0B, 0x00, 0x00, 0x12, 0x0B, 0x00,
  271. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  272. 0x20, 0xA0, 0x00, 0x00, 0xFF, 0xFF
  273. };
  274.  
  275. const BYTE blue[60] =
  276. {
  277. 0x42, 0x4D, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  278. 0x00, 0x36, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00,
  279. 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
  280. 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  281. 0x00, 0x00, 0x12, 0x0B, 0x00, 0x00, 0x12, 0x0B, 0x00,
  282. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  283. 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00
  284. };
  285.  
  286. void CreatePlayerChams(LPDIRECT3DDEVICE9 pDevice,
  287. D3DPRIMITIVETYPE PrimType,
  288. INT BaseVertexIndex,
  289. UINT MinVertexIndex,
  290. UINT NumVertices,
  291. UINT startIndex,
  292. UINT primCount,
  293. LPDIRECT3DTEXTURE9 VisibleColor,
  294. LPDIRECT3DTEXTURE9 BehindWallColor)
  295. {
  296. DWORD old_render;
  297. pDevice->SetRenderState(D3DRS_ZENABLE, false);
  298. pDevice->SetTexture(0, VisibleColor);
  299. pDevice->GetRenderState(D3DRS_ZFUNC, &old_render);
  300. pDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_NEVER);
  301. oDrawIndexedPrimitive(pDevice, PrimType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
  302. pDevice->SetRenderState(D3DRS_ZENABLE, true);
  303. pDevice->SetRenderState(D3DRS_ZFUNC, old_render);
  304. pDevice->SetTexture(0, BehindWallColor);
  305. }
  306.  
  307. HRESULT WINAPI hkReset(LPDIRECT3DDEVICE9 pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters)
  308. {
  309. HRESULT hr = NULL;
  310. if (hackMenuFont != NULL) hackMenuFont->OnLostDevice();
  311. if (hackMenuLine != NULL) hackMenuLine->OnLostDevice();
  312. hr = oReset(pDevice, pPresentationParameters);
  313. if (hackMenuFont != NULL) hackMenuFont->OnResetDevice();
  314. if (hackMenuLine != NULL) hackMenuLine->OnResetDevice();
  315. return hr;
  316. }
  317.  
  318. HRESULT WINAPI hkEndScene(LPDIRECT3DDEVICE9 pDevice)
  319. {
  320. pDevice->GetViewport(&viewport);
  321. if (hackMenuFont == NULL) D3DXCreateFont(pDevice, 15, 0, FW_BOLD, 1, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Verdana", &hackMenuFont);
  322. if (hackMenuLine == NULL) D3DXCreateLine(pDevice, &hackMenuLine);
  323.  
  324. if (g_pTexRed == NULL) D3DXCreateTextureFromFileInMemory(pDevice, (LPCVOID)&red, sizeof(red), &g_pTexRed);
  325. if (g_pTexOrange == NULL) D3DXCreateTextureFromFileInMemory(pDevice, (LPCVOID)&orange, sizeof(orange), &g_pTexOrange);
  326. if (g_pTexGreen == NULL) D3DXCreateTextureFromFileInMemory(pDevice, (LPCVOID)&green, sizeof(green), &g_pTexGreen);
  327. if (g_pTexBlue == NULL) D3DXCreateTextureFromFileInMemory(pDevice, (LPCVOID)&blue, sizeof(blue), &g_pTexBlue);
  328.  
  329. ShowMenuOptions(pDevice);
  330. if (ENABLE_AIMBOT) AimEnemy(pDevice);
  331. if (ENABLE_CROSSHAIR) ShowCrossHair(pDevice, viewport, 10, RED);
  332. return oEndScene(pDevice);
  333. }
  334.  
  335. HRESULT WINAPI hkDrawIndexedPrimitive(LPDIRECT3DDEVICE9 pDevice, D3DPRIMITIVETYPE PrimType, INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount)
  336. {
  337. if (viewport.Width <= 100) return oDrawIndexedPrimitive(pDevice, PrimType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
  338.  
  339. if (pDevice->GetStreamSource(0, &pStreamData, &XOffset, &Stride) == D3D_OK) if (pStreamData != NULL) { pStreamData->Release(); pStreamData = NULL; }
  340.  
  341. bool isBEAR = Stride == 40 && (((NumVertices == 452) && (primCount == 434)) || ((NumVertices == 1099) && (primCount == 1222)) || ((NumVertices == 859) && (primCount == 1272)) || ((NumVertices == 192) && (primCount == 256)) || ((NumVertices == 1618) && (primCount == 2004)) || ((NumVertices == 114) && (primCount == 194)) || ((NumVertices == 612) && (primCount == 288)) || ((NumVertices == 651) && (primCount == 957)) || ((NumVertices == 530) && (primCount == 936)) || ((NumVertices == 724) && (primCount == 8)) || ((NumVertices == 651) && (primCount == 957)));
  342. bool isUSEC = Stride == 40 && (((NumVertices == 279) && (primCount == 335)));
  343.  
  344. if (ENABLE_AIMBOT == true)
  345. {
  346. if (isBEAR || isUSEC)
  347. {
  348. if (isBEAR)
  349. {
  350. AddEnemy(pDevice, 0);
  351. if (ENABLE_CHAMS) CreatePlayerChams(pDevice, PrimType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount, g_pTexOrange, g_pTexRed);
  352. }
  353. else if (isUSEC)
  354. {
  355. AddEnemy(pDevice, 1);
  356. if (ENABLE_CHAMS) CreatePlayerChams(pDevice, PrimType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount, g_pTexBlue, g_pTexGreen);
  357. }
  358. }
  359. }
  360.  
  361. return oDrawIndexedPrimitive(pDevice, PrimType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
  362. }
  363.  
  364. void InitHOOK(DWORD* table)
  365. {
  366. LPDIRECT3DDEVICE9 pd3dDevice;
  367. pd3dDevice = GETp3dDevice();
  368.  
  369. DWORD* pVTable = (DWORD*)pd3dDevice;
  370. pVTable = (DWORD*)pVTable[0];
  371.  
  372. table[ENDSCENE] = pVTable[42];
  373. table[DIP] = pVTable[82];
  374. table[RESET] = pVTable[16];
  375. }
  376.  
  377. bool CustomWPM(HANDLE hProcess, LPVOID lpBaseAddress, byte* lpBuffer, char* mask)
  378. {
  379. DWORD dwOldProtectionState;
  380. DWORD dummy;
  381. BOOL result = FALSE;
  382. DWORD Addr = (DWORD)lpBaseAddress;
  383.  
  384. for (; *mask; mask++, lpBuffer++, Addr++)
  385. {
  386. if (*mask == 'x')
  387. {
  388. if (VirtualProtectEx(hProcess, (LPVOID)Addr, 1, PAGE_READWRITE, &dwOldProtectionState) == TRUE)
  389. {
  390. result = WriteProcessMemory(hProcess, (LPVOID)Addr, &*lpBuffer, 1, NULL);
  391. VirtualProtectEx(hProcess, (LPVOID)Addr, 1, dwOldProtectionState, &dummy);
  392. }
  393. }
  394.  
  395. }
  396. return result;
  397. }
  398.  
  399. bool DataCompare(byte* pData, byte* pattern, char* mask)
  400. {
  401. for (; *mask; mask++, pattern++, pData++)
  402. {
  403. if (*mask == 'x' && *pData != *pattern)
  404. return false;
  405. }
  406. return true;
  407. }
  408.  
  409. vector<DWORD> FindPattern(HANDLE hProcess, DWORD addr, DWORD length, byte* pattern, char* mask)
  410. {
  411. MEMORY_BASIC_INFORMATION mbi = { 0 };
  412. DWORD offset = 0;
  413. DWORD dwTemp;
  414. vector<DWORD> Enderecos;
  415.  
  416. while (offset < length)
  417. {
  418. VirtualQueryEx(hProcess, (LPCVOID)(addr + offset), &mbi, sizeof(MEMORY_BASIC_INFORMATION));
  419. //if (mbi.State != MEM_FREE) //Aqui procura todo tipo de memória
  420. if (mbi.Type == MEM_PRIVATE && (mbi.State != MEM_RESERVE))//Aqui é um filtro... localizou muito rápido e funciona no CW (15SET2015)
  421. {
  422. byte* buffer = new byte[mbi.RegionSize];
  423. ReadProcessMemory(hProcess, mbi.BaseAddress, buffer, mbi.RegionSize, NULL);
  424. for (unsigned int i = 0; i < mbi.RegionSize; i++)
  425. {
  426. if (DataCompare(buffer + i, pattern, mask))
  427. {
  428. dwTemp = (DWORD)mbi.BaseAddress + i;
  429. Enderecos.push_back(dwTemp);
  430. }
  431. }
  432. delete[] buffer;
  433. }
  434. offset += mbi.RegionSize;
  435. }
  436.  
  437. return Enderecos;
  438. }
  439.  
  440. DWORD GetBaseAddr(DWORD id)
  441. {
  442. MODULEINFO modinfo = { 0 };
  443. GetModuleInformation((HANDLE)id, GetModuleHandle(NULL), &modinfo, sizeof(MODULEINFO));
  444. return (DWORD)modinfo.lpBaseOfDll;
  445. }
  446.  
  447. DWORD WINAPI StartingHACK(LPVOID)
  448. {
  449. vector<DWORD> Addresses;
  450.  
  451. while (GetModuleHandle("d3d9.dll") == NULL)
  452. {
  453. Sleep(250);
  454. }
  455.  
  456. DWORD BaseAddr = GetBaseAddr((DWORD)GetCurrentProcess());
  457. HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, GetCurrentProcessId());
  458.  
  459. Addresses = FindPattern(hProcess, BaseAddr, 0x7FFFFFFF, (PBYTE)"\x02\x28\x00\x00\x00\x00\x18\x40\x00\x00\x00\x00\x22\x00\x00\x80\x40\x2A\x02\x28\x00\x00\x00\x00\x17", "xx????xx????x??xxxxx????x");
  460.  
  461. if (Addresses.size() != NULL)
  462. {
  463. DWORD Addr;
  464. for (unsigned int a = 0; a < Addresses.size(); a++)
  465. {
  466. Addr = Addresses[a];
  467. CustomWPM(hProcess, (LPVOID)Addr, (PBYTE)"\x22\x00\x00\x00\x00\x2A", "xxxxxx");
  468. }
  469. Addresses.clear();
  470. }
  471.  
  472. DWORD VTable[3] = { 0 };
  473.  
  474. InitHOOK(VTable);
  475.  
  476. HOOK(EndScene, VTable[ENDSCENE]);
  477. HOOK(DrawIndexedPrimitive, VTable[DIP]);
  478. HOOK(Reset, VTable[RESET]);
  479.  
  480. return 0;
  481. }
  482.  
  483. BOOL WINAPI DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpvReserved)
  484. {
  485. if (dwReason == DLL_PROCESS_ATTACH)
  486. {
  487. CreateThread(0, 0, StartingHACK, 0, 0, 0);
  488. }
  489.  
  490. return TRUE;
  491. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement