Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Windows.h>
- #include "windows.h"
- #include "intrin.h"
- #include "d3d9.h"
- #include "d3dx9.h"
- #include "Detours.h"
- #include "classes.h"
- #pragma comment(lib, "d3d9.lib")
- #pragma comment(lib, "d3dx9.lib")
- #pragma comment(lib, "Detours.lib")
- #pragma intrinsic(_ReturnAddress)
- #define Player 0xF54C81
- #define Smoke 0xF50AF4
- bool bInit = false;
- bool bChams = false;
- bool bsmoke = false;
- bool bflash = false;
- bool bcrosshair = false;
- void no_flash()
- {
- SSystemGlobalEnvironment* pEnv = (SSystemGlobalEnvironment*)(*(DWORD*)(0x19064A0));
- while (true)
- {
- if (!pEnv)
- continue;
- if (!bflash) continue;
- I3DEngine* p3DEngine = pEnv->p3DEngine;
- if (!p3DEngine)
- continue;
- p3DEngine->SetPostEffectParam("Flashbang_Time", 0, true);
- }
- }
- LPDIRECT3DTEXTURE9 texRed = NULL;
- typedef HRESULT(WINAPI *Prototype_DrawIndexedPrimitive)(LPDIRECT3DDEVICE9, D3DPRIMITIVETYPE, INT, UINT, UINT, UINT, UINT);
- typedef HRESULT(WINAPI *END_SCENE)(LPDIRECT3DDEVICE9);
- END_SCENE ORIGINALNI_ENDSCENE;
- HRESULT WINAPI HOOK_ENDSCENE(LPDIRECT3DDEVICE9 pDevice);
- typedef long(__stdcall* tReset)(LPDIRECT3DDEVICE9*, D3DPRESENT_PARAMETERS);
- tReset pReset;
- LPD3DXFONT ZarioFont;
- void createfont(LPDIRECT3DDEVICE9 Device) {
- if (!ZarioFont) {
- D3DXCreateFont(Device, 15, 0, FW_BOLD, false, false, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Tahoma", &ZarioFont);
- }
- }
- void TextDraw(int x, int y, LPCSTR text, DWORD color) {
- RECT rect1, rect2;
- SetRect(&rect1, x, y, x, y);
- SetRect(&rect2, x - 0.1, y + 0.2, x - 0.1, y + 0.);
- ZarioFont->DrawTextA(NULL, text, -1, &rect2, DT_LEFT | DT_NOCLIP, 0x00000000);
- ZarioFont->DrawTextA(NULL, text, -1, &rect1, DT_LEFT | DT_NOCLIP, color);
- }
- void resetfont() {
- ZarioFont->OnLostDevice();
- ZarioFont->OnResetDevice();
- }
- Prototype_DrawIndexedPrimitive Original_DrawIndexedPrimitive;
- HRESULT WINAPI Hooked_DrawIndexedPrimitive(LPDIRECT3DDEVICE9 Device, D3DPRIMITIVETYPE PrimType, INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount);
- DWORD FindDevice(DWORD Len)
- {
- DWORD dwObjBase = 0;
- dwObjBase = (DWORD)LoadLibrary("d3d9.dll");
- while (dwObjBase++ < dwObjBase + Len)
- {
- if ((*(WORD*)(dwObjBase + 0x00)) == 0x06C7 && (*(WORD*)(dwObjBase + 0x06)) == 0x8689 && (*(WORD*)(dwObjBase + 0x0C)) == 0x8689) {
- dwObjBase += 2; break;
- }
- }
- return(dwObjBase);
- }
- DWORD GetDeviceAddress(int VTableIndex)
- {
- PDWORD VTable;
- *(DWORD*)&VTable = *(DWORD*)FindDevice(0x128000);
- return VTable[VTableIndex];
- }
- HRESULT GenerateTexture(LPDIRECT3DDEVICE9 pDevice, IDirect3DTexture9 **ppD3Dtex, DWORD colour32)
- {
- if (FAILED(pDevice->CreateTexture(8, 8, 1, 0, D3DFMT_A4R4G4B4, D3DPOOL_MANAGED, ppD3Dtex, NULL)))
- return E_FAIL;
- if (!bcrosshair);
- WORD colour16 = ((WORD)((colour32 >> 28) & 0xF) << 12)
- | (WORD)(((colour32 >> 20) & 0xF) << 8)
- | (WORD)(((colour32 >> 12) & 0xF) << 4)
- | (WORD)(((colour32 >> 4) & 0xF) << 0);
- D3DLOCKED_RECT d3dlr;
- (*ppD3Dtex)->LockRect(0, &d3dlr, 0, 0);
- WORD *pDst16 = (WORD*)d3dlr.pBits;
- for (int xy = 0; xy < 8 * 8; xy++)
- *pDst16++ = colour16;
- (*ppD3Dtex)->UnlockRect(0);
- return S_OK;
- }
- BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
- {
- if (dwReason == DLL_PROCESS_ATTACH)
- {
- CreateThread(0, 0, (LPTHREAD_START_ROUTINE)no_flash, 0, 0, 0);
- Original_DrawIndexedPrimitive = (Prototype_DrawIndexedPrimitive)DetourFunction((PBYTE)GetDeviceAddress(82), (PBYTE)Hooked_DrawIndexedPrimitive);
- ORIGINALNI_ENDSCENE = (END_SCENE)DetourFunction((PBYTE)GetDeviceAddress(42), (PBYTE)HOOK_ENDSCENE);
- }
- else if (dwReason == DLL_PROCESS_DETACH)
- {
- DetourRemove((PBYTE)Original_DrawIndexedPrimitive, (PBYTE)Hooked_DrawIndexedPrimitive);
- DetourRemove((PBYTE)ORIGINALNI_ENDSCENE, (PBYTE)HOOK_ENDSCENE);
- }
- return TRUE;
- }
- void DRAWCROSS(LPDIRECT3DDEVICE9 MYDevice, D3DCOLOR color) {
- D3DVIEWPORT9 viewport;
- MYDevice->GetViewport(&viewport);
- DWORD ScreenCenterY = viewport.Height / 2;
- DWORD ScreenCenterX = viewport.Width / 2;
- D3DRECT lineX = { ScreenCenterX - 45, ScreenCenterY, ScreenCenterX + 45, ScreenCenterY + 2 };
- D3DRECT lineY = { ScreenCenterX, ScreenCenterY - 45, ScreenCenterX + 2, ScreenCenterY + 45 };
- MYDevice->Clear(1, &lineX, D3DCLEAR_TARGET, color, 0, 0);
- MYDevice->Clear(1, &lineY, D3DCLEAR_TARGET, color, 0, 0);
- }
- HRESULT WINAPI HOOK_ENDSCENE(LPDIRECT3DDEVICE9 pDevice) {
- DRAWCROSS(pDevice, D3DCOLOR_ARGB(255, 255, 150, 0));
- createfont(pDevice);
- TextDraw(27, 54, "Chams", D3DCOLOR_ARGB(255, 180, 0, 180));
- if (bChams) {
- TextDraw(120, 54, "ON", D3DCOLOR_ARGB(255, 60, 125, 0));
- }
- if (!bChams) {
- TextDraw(120, 54, "OFF", D3DCOLOR_ARGB(255, 255, 100, 100));
- }
- TextDraw(27, 35, "Smoke", D3DCOLOR_ARGB(255, 180, 0, 180));
- if (bsmoke) {
- TextDraw(120, 35, "ON", D3DCOLOR_ARGB(255, 60, 125, 0));
- }
- if (!bsmoke) {
- TextDraw(120, 35, "OFF", D3DCOLOR_ARGB(255, 255, 100, 100));
- }
- TextDraw(27, 63, "Flash", D3DCOLOR_ARGB(255, 180, 0, 180));
- if (bflash) {
- TextDraw(120, 63, "ON", D3DCOLOR_ARGB(255, 60, 125, 0));
- }
- if (!bflash) {
- TextDraw(120, 63, "OFF", D3DCOLOR_ARGB(255, 255, 100, 100));
- }
- if (GetAsyncKeyState(VK_F9) & 1) bChams = !bChams;
- if (GetAsyncKeyState(VK_F8) & 1) bsmoke = !bsmoke;
- if (GetAsyncKeyState(VK_F7) & 1) bflash = !bflash;
- if (GetAsyncKeyState(VK_F6) & 1) bcrosshair = !bcrosshair;
- return ORIGINALNI_ENDSCENE(pDevice);
- }
- HRESULT WINAPI Hooked_DrawIndexedPrimitive(LPDIRECT3DDEVICE9 Device, D3DPRIMITIVETYPE PrimType, INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount)
- {
- void* ReturnAddress = _ReturnAddress();
- if (texRed == 0)
- GenerateTexture(Device, &texRed, D3DCOLOR_ARGB(255, 255, 0, 0));
- if (ReturnAddress == (void*)Smoke&&bsmoke)
- return D3D_OK;
- if (ReturnAddress == (void*)Player&&bChams)
- {
- Device->SetRenderState(D3DRS_ZENABLE, FALSE);
- Device->SetTexture(0, texRed);
- Original_DrawIndexedPrimitive(Device, PrimType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
- Device->SetRenderState(D3DRS_ZENABLE, TRUE);
- Device->SetTexture(0, texRed);
- }
- return Original_DrawIndexedPrimitive(Device, PrimType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement