Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Windows.h>
- #include <tlhelp32.h>
- #include <shlwapi.h>
- #include <d3d9.h>
- #include <d3dx9.h>
- #define WIN32_LEAN_AND_MEAN
- #define WIN32_EXTRA_LEAN
- #pragma warning(disable:4482)
- #pragma warning(disable:4244)
- #pragma warning(disable:4996)
- #pragma comment(lib, "d3d9.lib")
- #pragma comment(lib, "d3dx9.lib")
- #define D3DparamX , UINT paramx
- #define D3DparamvalX , paramx
- bool Match(const BYTE* pData, const BYTE* bMask, const char* szMask)
- {
- for(;*szMask;++szMask,++pData,++bMask)
- if(*szMask=='x' && *pData!=*bMask )
- return false;
- return (*szMask) == NULL;
- }
- DWORD FindPattern(DWORD dwAddress,DWORD dwLen,BYTE *bMask,char * szMask)
- {
- for(DWORD i=0; i<dwLen; i++)
- if(Match((BYTE*)(dwAddress + i), bMask, szMask))
- return (DWORD)(dwAddress+i);
- return 0;
- }
- void MakeJMP(BYTE *pAddress, DWORD dwJumpTo, DWORD dwLen)
- {
- DWORD dwOldProtect, dwBkup, dwRelAddr;
- VirtualProtect(pAddress, dwLen, PAGE_EXECUTE_READWRITE, &dwOldProtect);
- dwRelAddr = (DWORD) (dwJumpTo - (DWORD) pAddress) - 5;
- *pAddress = 0xE9;
- *((DWORD *)(pAddress + 0x1)) = dwRelAddr;
- for(DWORD x = 0x5; x < dwLen; x++) *(pAddress + x) = 0x90;
- VirtualProtect(pAddress, dwLen, dwOldProtect, &dwBkup);
- return;
- }
- DWORD retMyDIP;
- #define sWeapon 36
- #define sMap 24
- #define sSkyWalls 28
- #define sBody 44
- #define sHead 40
- bool bEnable = true;
- bool Generate = true;
- void FillRGB(float x, float y, float w, float h, DWORD color,LPDIRECT3DDEVICE9 pDevice)
- {
- D3DRECT rec = { x, y, x + w, y + h };
- pDevice->Clear(1, &rec, D3DCLEAR_TARGET, color, 0, 0);
- }
- HRESULT PheonxTexture(LPDIRECT3DDEVICE9 pD3Ddev, IDirect3DTexture9 **ppD3Dtex, DWORD colour32)
- {
- if(FAILED(pD3Ddev->CreateTexture(8, 8, 1, 0, D3DFMT_A4R4G4B4, D3DPOOL_MANAGED, ppD3Dtex, NULL)))
- return E_FAIL;
- 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;
- }
- LPDIRECT3DTEXTURE9 Red,Green;
- D3DCOLOR RED = D3DCOLOR_ARGB(255, 255, 0, 0);
- D3DCOLOR GREEN = D3DCOLOR_ARGB(255, 0, 255, 0);
- void D3Dfunktionen (LPDIRECT3DDEVICE9 pDevice)
- {
- IDirect3DVertexBuffer9* pStreamData = NULL;
- UINT iOffsetInBytes,iStride;
- pDevice->GetStreamSource(0,&pStreamData,&iOffsetInBytes,&iStride);
- if (Generate)
- {
- PheonxTexture(pDevice, &Red, RED);
- PheonxTexture(pDevice, &Green, GREEN);
- Generate = false;
- }
- if(iStride == sBody || iStride == sHead || iStride == sWeapon)
- {
- pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
- }
- }
- __declspec(naked) HRESULT WINAPI MyDIP()
- {
- static LPDIRECT3DDEVICE9 pDevice;
- __asm
- {
- MOV EDI,EDI
- PUSH EBP
- MOV EBP,ESP
- MOV EAX,DWORD PTR SS:[EBP + 0x8]
- MOV pDevice,EAX
- }
- if(GetAsyncKeyState(VK_INSERT)&1) bEnable = !bEnable;
- if(bEnable){
- FillRGB(40, 40, 40, 40, RED, pDevice);
- D3Dfunktionen(pDevice);
- }
- __asm
- {
- JMP retMyDIP
- }
- }
- void Hook ()
- {
- DWORD hD3D = (DWORD)LoadLibraryA("d3d9.dll");
- DWORD *vtbl;
- DWORD adr = FindPattern(hD3D, 0x128000, (PBYTE)"\xC7\x06\x00\x00\x00\x00\x89\x86\x00\x00\x00\x00\x89\x86", "xx????xx????xx");
- if(adr)
- {
- memcpy(&vtbl,(void*)(adr + 2),4);
- retMyDIP = vtbl[147] + 0x5;
- MakeJMP((PBYTE)vtbl[147],(DWORD)MyDIP,0x5);
- }
- }
- extern "C"
- {
- BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
- {
- switch (fdwReason)
- {
- case DLL_PROCESS_ATTACH:
- CreateThread(0,0,(LPTHREAD_START_ROUTINE)Hook,0,0,0);
- //MessageBoxA(NULL,"","Injetou",0);
- //HideModule(hinstDLL);
- break;
- }
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement