Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.36 KB | None | 0 0
  1. #include <Windows.h>
  2. #include "windows.h"
  3. #include "intrin.h"
  4. #include "d3d9.h"
  5. #include "d3dx9.h"
  6. #include "Detours.h"
  7. #include "classes.h"
  8.  
  9. #pragma comment(lib, "d3d9.lib")
  10. #pragma comment(lib, "d3dx9.lib")
  11. #pragma comment(lib, "Detours.lib")
  12.  
  13. #pragma intrinsic(_ReturnAddress)
  14.  
  15. #define Player 0xF54C81
  16. #define Smoke 0xF50AF4
  17.  
  18. bool bInit = false;
  19. bool bChams = false;
  20. bool bsmoke = false;
  21. bool bflash = false;
  22. bool bcrosshair = false;
  23.  
  24.  
  25. void no_flash()
  26. {
  27. SSystemGlobalEnvironment* pEnv = (SSystemGlobalEnvironment*)(*(DWORD*)(0x19064A0));
  28.  
  29. while (true)
  30. {
  31. if (!pEnv)
  32. continue;
  33. if (!bflash) continue;
  34.  
  35.  
  36. I3DEngine* p3DEngine = pEnv->p3DEngine;
  37. if (!p3DEngine)
  38. continue;
  39.  
  40. p3DEngine->SetPostEffectParam("Flashbang_Time", 0, true);
  41. }
  42. }
  43.  
  44.  
  45.  
  46. LPDIRECT3DTEXTURE9 texRed = NULL;
  47.  
  48. typedef HRESULT(WINAPI *Prototype_DrawIndexedPrimitive)(LPDIRECT3DDEVICE9, D3DPRIMITIVETYPE, INT, UINT, UINT, UINT, UINT);
  49. typedef HRESULT(WINAPI *END_SCENE)(LPDIRECT3DDEVICE9);
  50. END_SCENE ORIGINALNI_ENDSCENE;
  51. HRESULT WINAPI HOOK_ENDSCENE(LPDIRECT3DDEVICE9 pDevice);
  52. typedef long(__stdcall* tReset)(LPDIRECT3DDEVICE9*, D3DPRESENT_PARAMETERS);
  53. tReset pReset;
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61. LPD3DXFONT ZarioFont;
  62.  
  63. void createfont(LPDIRECT3DDEVICE9 Device) {
  64.  
  65. if (!ZarioFont) {
  66. D3DXCreateFont(Device, 15, 0, FW_BOLD, false, false, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Tahoma", &ZarioFont);
  67.  
  68. }
  69. }
  70.  
  71. void TextDraw(int x, int y, LPCSTR text, DWORD color) {
  72. RECT rect1, rect2;
  73. SetRect(&rect1, x, y, x, y);
  74. SetRect(&rect2, x - 0.1, y + 0.2, x - 0.1, y + 0.);
  75. ZarioFont->DrawTextA(NULL, text, -1, &rect2, DT_LEFT | DT_NOCLIP, 0x00000000);
  76. ZarioFont->DrawTextA(NULL, text, -1, &rect1, DT_LEFT | DT_NOCLIP, color);
  77. }
  78.  
  79.  
  80. void resetfont() {
  81. ZarioFont->OnLostDevice();
  82. ZarioFont->OnResetDevice();
  83. }
  84.  
  85.  
  86.  
  87.  
  88.  
  89. Prototype_DrawIndexedPrimitive Original_DrawIndexedPrimitive;
  90.  
  91. HRESULT WINAPI Hooked_DrawIndexedPrimitive(LPDIRECT3DDEVICE9 Device, D3DPRIMITIVETYPE PrimType, INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount);
  92.  
  93. DWORD FindDevice(DWORD Len)
  94. {
  95. DWORD dwObjBase = 0;
  96.  
  97. dwObjBase = (DWORD)LoadLibrary("d3d9.dll");
  98. while (dwObjBase++ < dwObjBase + Len)
  99. {
  100. if ((*(WORD*)(dwObjBase + 0x00)) == 0x06C7 && (*(WORD*)(dwObjBase + 0x06)) == 0x8689 && (*(WORD*)(dwObjBase + 0x0C)) == 0x8689) {
  101. dwObjBase += 2; break;
  102. }
  103. }
  104. return(dwObjBase);
  105. }
  106.  
  107. DWORD GetDeviceAddress(int VTableIndex)
  108. {
  109. PDWORD VTable;
  110. *(DWORD*)&VTable = *(DWORD*)FindDevice(0x128000);
  111. return VTable[VTableIndex];
  112. }
  113.  
  114. HRESULT GenerateTexture(LPDIRECT3DDEVICE9 pDevice, IDirect3DTexture9 **ppD3Dtex, DWORD colour32)
  115. {
  116. if (FAILED(pDevice->CreateTexture(8, 8, 1, 0, D3DFMT_A4R4G4B4, D3DPOOL_MANAGED, ppD3Dtex, NULL)))
  117. return E_FAIL;
  118. if (!bcrosshair);
  119. WORD colour16 = ((WORD)((colour32 >> 28) & 0xF) << 12)
  120. | (WORD)(((colour32 >> 20) & 0xF) << 8)
  121. | (WORD)(((colour32 >> 12) & 0xF) << 4)
  122. | (WORD)(((colour32 >> 4) & 0xF) << 0);
  123.  
  124. D3DLOCKED_RECT d3dlr;
  125. (*ppD3Dtex)->LockRect(0, &d3dlr, 0, 0);
  126. WORD *pDst16 = (WORD*)d3dlr.pBits;
  127.  
  128. for (int xy = 0; xy < 8 * 8; xy++)
  129. *pDst16++ = colour16;
  130.  
  131. (*ppD3Dtex)->UnlockRect(0);
  132.  
  133. return S_OK;
  134. }
  135.  
  136.  
  137.  
  138. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
  139. {
  140. if (dwReason == DLL_PROCESS_ATTACH)
  141. {
  142. CreateThread(0, 0, (LPTHREAD_START_ROUTINE)no_flash, 0, 0, 0);
  143. Original_DrawIndexedPrimitive = (Prototype_DrawIndexedPrimitive)DetourFunction((PBYTE)GetDeviceAddress(82), (PBYTE)Hooked_DrawIndexedPrimitive);
  144. ORIGINALNI_ENDSCENE = (END_SCENE)DetourFunction((PBYTE)GetDeviceAddress(42), (PBYTE)HOOK_ENDSCENE);
  145. }
  146. else if (dwReason == DLL_PROCESS_DETACH)
  147. {
  148. DetourRemove((PBYTE)Original_DrawIndexedPrimitive, (PBYTE)Hooked_DrawIndexedPrimitive);
  149. DetourRemove((PBYTE)ORIGINALNI_ENDSCENE, (PBYTE)HOOK_ENDSCENE);
  150. }
  151.  
  152. return TRUE;
  153. }
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160. void DRAWCROSS(LPDIRECT3DDEVICE9 MYDevice, D3DCOLOR color) {
  161. D3DVIEWPORT9 viewport;
  162. MYDevice->GetViewport(&viewport);
  163.  
  164. DWORD ScreenCenterY = viewport.Height / 2;
  165. DWORD ScreenCenterX = viewport.Width / 2;
  166.  
  167. D3DRECT lineX = { ScreenCenterX - 45, ScreenCenterY, ScreenCenterX + 45, ScreenCenterY + 2 };
  168. D3DRECT lineY = { ScreenCenterX, ScreenCenterY - 45, ScreenCenterX + 2, ScreenCenterY + 45 };
  169.  
  170. MYDevice->Clear(1, &lineX, D3DCLEAR_TARGET, color, 0, 0);
  171. MYDevice->Clear(1, &lineY, D3DCLEAR_TARGET, color, 0, 0);
  172. }
  173.  
  174.  
  175. HRESULT WINAPI HOOK_ENDSCENE(LPDIRECT3DDEVICE9 pDevice) {
  176.  
  177.  
  178. DRAWCROSS(pDevice, D3DCOLOR_ARGB(255, 255, 150, 0));
  179. createfont(pDevice);
  180. TextDraw(27, 54, "Chams", D3DCOLOR_ARGB(255, 180, 0, 180));
  181.  
  182. if (bChams) {
  183. TextDraw(120, 54, "ON", D3DCOLOR_ARGB(255, 60, 125, 0));
  184. }
  185.  
  186. if (!bChams) {
  187. TextDraw(120, 54, "OFF", D3DCOLOR_ARGB(255, 255, 100, 100));
  188. }
  189.  
  190. TextDraw(27, 35, "Smoke", D3DCOLOR_ARGB(255, 180, 0, 180));
  191.  
  192. if (bsmoke) {
  193. TextDraw(120, 35, "ON", D3DCOLOR_ARGB(255, 60, 125, 0));
  194. }
  195.  
  196. if (!bsmoke) {
  197. TextDraw(120, 35, "OFF", D3DCOLOR_ARGB(255, 255, 100, 100));
  198. }
  199.  
  200. TextDraw(27, 63, "Flash", D3DCOLOR_ARGB(255, 180, 0, 180));
  201.  
  202. if (bflash) {
  203. TextDraw(120, 63, "ON", D3DCOLOR_ARGB(255, 60, 125, 0));
  204. }
  205.  
  206. if (!bflash) {
  207. TextDraw(120, 63, "OFF", D3DCOLOR_ARGB(255, 255, 100, 100));
  208. }
  209.  
  210. if (GetAsyncKeyState(VK_F9) & 1) bChams = !bChams;
  211. if (GetAsyncKeyState(VK_F8) & 1) bsmoke = !bsmoke;
  212. if (GetAsyncKeyState(VK_F7) & 1) bflash = !bflash;
  213. if (GetAsyncKeyState(VK_F6) & 1) bcrosshair = !bcrosshair;
  214.  
  215. return ORIGINALNI_ENDSCENE(pDevice);
  216.  
  217. }
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225. HRESULT WINAPI Hooked_DrawIndexedPrimitive(LPDIRECT3DDEVICE9 Device, D3DPRIMITIVETYPE PrimType, INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount)
  226. {
  227. void* ReturnAddress = _ReturnAddress();
  228. if (texRed == 0)
  229. GenerateTexture(Device, &texRed, D3DCOLOR_ARGB(255, 255, 0, 0));
  230.  
  231.  
  232. if (ReturnAddress == (void*)Smoke&&bsmoke)
  233. return D3D_OK;
  234.  
  235. if (ReturnAddress == (void*)Player&&bChams)
  236. {
  237. Device->SetRenderState(D3DRS_ZENABLE, FALSE);
  238. Device->SetTexture(0, texRed);
  239. Original_DrawIndexedPrimitive(Device, PrimType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
  240. Device->SetRenderState(D3DRS_ZENABLE, TRUE);
  241. Device->SetTexture(0, texRed);
  242. }
  243.  
  244.  
  245. return Original_DrawIndexedPrimitive(Device, PrimType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
  246. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement