Join date : 01.01.70
| Subyek: New SC D3D Menu Mon Nov 07, 2011 9:41 pm | |
| Bahan yg di butuhkan : -Detours.h -detours.lib Malmsteen.cpp - Spoiler:
#include <windows.h> #include <stdio.h> #include <fstream> #include "detours.h" #include "andremenuclass.h" #include "Main.h" #include <d3d9.h> #include <d3dx9.h> // zenixMenu dMenu; LPD3DXFONT g_pFont = NULL; LPDIRECT3DDEVICE9 g_pDevice = 0; LPD3DXSPRITE Sprite; LPDIRECT3DTEXTURE9 MenuTexture; static BOOL init = TRUE; /**************************************************************************************************************************************************************************************************************/ int xFontOffSet = 770;// nih di ganti spy.. gak terlalu jauh MENUNYa int hackopt1; int MenuHeight = 20;// no smoke knpa?g aktif //klw mau nambabhin 1 hit dmna kk// kan 1 hit dah gak bisa.. ntar w cari addresnya deh /. nih liat aku cari addres oke tungguin// ne dh bisa d buil ?? 716 541 220 int show=1; int b = 1; //==================================================================tapi gw bingung kok ini No respawn sama invitime gak fungsi? //Menu HACK int hack1 = 0; int hack2 = 0; int hack3 = 0; int hack4 = 0; int hack5 = 0; //#define My_HWID (-1539772165) #define SMOKE (NumVertices == 192 || primCount == 52 || NumVertices == 256) //--------------------------------------------------------------------------------------------------------------------------------- UCHAR szFileSys[255], szVolNameBuff[255]; DWORD dwMFL, dwSysFlags, dwSerial; //---------------------------------------------------------------------------------------------------------------------------------. HRESULT GenerateTexture(IDirect3DDevice9 *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)<< |(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; } //VOID CheckValidHardwareID() //{ /* WEAK POINT */ /* LAKUKAN PERLINDUNGAN TERHADAP FUNGSI CheckValidHardwareID() karena jika CheckValidHardwareID() di patch dengan RET maka CheckValidHardwareID() tidak akan dipanggil dan dll berjalan tanpa pengecekan HWID ! kamu bisa gunakan CodeVirtualizer, Themida Code Replace, atau Enigma Protector untuk melindungi fungsi CheckValidHardwareID() */ //CODEREPLACE_START // CODE REPLACE EXAMPLE //VIRTUALIZER_START // VIRTUALIZER EXAMPLE //#include "vm_begin.inc" // ENIGMA PROTECTOR EXAMPLE //GetVolumeInformation("C:\\",(LPTSTR)szVolNameBuff,255,&dwSerial, &dwMFL,&dwSysFlags,(LPTSTR)szFileSys,255); //if (dwSerial == My_HWID) // Lakukan perbandingan dengan hwid yang baru diambil dengan My_HWID //{ // MessageBox(0,"LANJUT","INFORMATION",MB_OK | MB_ICONINFORMATION); // Serial valid // } // //else // Jika serial tersebut tidak cocok // { // MessageBox(0,"GAK COCOK BREW","INFORMATION",MB_OK | MB_ICONERROR); // ExitProcess(1); // Force Exit // Invalid Serial //} //CODEREPLACE_END // CODE REPLACE EXAMPLE //VIRTUALIZER_END // VIRTUALIZER EXAMPLE //#include "vm_end.inc" // ENIGMA PROTECTOR EXAMPLE //} void zenixMenu::CreateItem(int index, char * title, int *hack, int hackmaxval, int hacktype, void *actionfunc) { hackcount++; HACKITEM[hackcount].index = index; HACKITEM[hackcount].hack = hack; HACKITEM[hackcount].hackmaxval = hackmaxval; HACKITEM[hackcount].hacktype = hacktype; HACKITEM[hackcount].functionAddy = actionfunc; // << added // Mengatur tinggi rendahnya Menu Hack PrintText(title, xFontOffSet, index*25,HACKITEM[hackcount].HCOLOR,pFont); //Spasi untuk teks D3D Menu } void PrintText(LPD3DXFONT pFont, long x, long y, D3DCOLOR fontColor, char *text, ...) { RECT rct; rct.left = x - 1; rct.right = x + 1; rct.top = y - 1 ; rct.bottom = y + 1; if(!text) { return; } va_list va_alist; char logbuf[256] = {0}; va_start (va_alist, text); _vsnprintf(logbuf+strlen(logbuf), sizeof(logbuf) - strlen(logbuf), text, va_alist); va_end (va_alist); RECT FontRect = { x, y, x, y }; pFont->DrawText(NULL, logbuf, -1, &rct, DT_NOCLIP, fontColor); } void zenixMenu::BuildMenu(char * menuname, int x, int y, int h, int w, DWORD TITLECOL, DWORD BACKCOLOR, DWORD BORDERCOLOR, LPDIRECT3DDEVICE9 pDevice) { if(GetAsyncKeyState(VK_INSERT)&1)show=(!show); //Memunculkan Menu HACK (INSERT) if(!show) { DrawBox(NULL , NULL, w, 48, BACKCOLOR, BORDERCOLOR, pDevice); PrintText(menuname, 4, 2, TITLECOL, pFont); return; } // DrawBox(x,y, w, h, BACKCOLOR, BORDERCOLOR, pDevice); // Sesuaikan dengan Base Menu HACK PrintText(menuname, x+400, y+2, TITLECOL, pFont); CreateItem(1,"SEMPAK TERO", &hack1); CreateItem(2,"SEMPAK CT", &hack2); CreateItem(3,"Wallhack Glass", &hack3); CreateItem(4,"No Smoke", &hack4); CreateItem(5,"Map Mini", &hack5); RenderMenu(); } void zenixMenu::RenderMenu() //Hotkey menu { if(GetAsyncKeyState(VK_DOWN)&1) selector++; if(GetAsyncKeyState(VK_UP)&1) if(selector > 1) selector--; if (GetAsyncKeyState(VK_RIGHT)<0){ for(int i=0;i < (hackcount+1);i++){ if(selector == HACKITEM[i].index){ if(*HACKITEM[i].hack < HACKITEM[i].hackmaxval) *HACKITEM[i].hack += 1; } } } if (GetAsyncKeyState(VK_LEFT)<0){ for(int i=0;i < (hackcount+1);i++){ if(selector == HACKITEM[i].index){ *HACKITEM[i].hack = 0; Sleep(200); } } } for(int i=0;i < (hackcount+1);i++){ if(selector == HACKITEM[i].index) HACKITEM[i].HCOLOR = BLUE; else HACKITEM[i].HCOLOR = RED; } for(int i=1; i<(hackcount+1); i++){ if(HACKITEM[i].hacktype == 0){ if(*HACKITEM[i].hack == 1) // Mengatur tinggi rendahnya Menu Hotkey PrintText("On", xFontOffSet+200, HACKITEM[i].index*25,BLUE,pFont);//25 = Spasi tex ON. 150 = Jarak ON else PrintText("Off", xFontOffSet+200, HACKITEM[i].index*25,RED,pFont); } } if(selector < 1) selector = 1; if(selector > hackcount) selector = 1; hackcount = 0; } void ReFont(LPDIRECT3DDEVICE9 pDevice) //Untuk penggantian font { if (g_pDevice != pDevice) { g_pDevice = pDevice; try { if (dMenu.pFont != NULL) dMenu.pFont->Release(); } catch (...) {} dMenu.pFont = NULL; D3DXCreateFontA(pDevice, 14, 0, FW_BOLD, 1, 0, DEFAULT_CHARSET, OUT_TT_ONLY_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Engravers MT", &dMenu.pFont); } } HRESULT WINAPI Reset(IDirect3DDevice9* pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters ) { dMenu.pFont->OnLostDevice(); g_pFont->OnLostDevice(); HRESULT hRet = oReset(pDevice, pPresentationParameters); g_pFont->OnResetDevice(); dMenu.pFont->OnResetDevice(); return hRet; } // Menu TITLE HRESULT WINAPI hkEndScene(LPDIRECT3DDEVICE9 pDevice) { if(init){D3DXCreateTextureFromFileInMemory(pDevice,&Menu,sizeof(Menu),&MenuTexture); // SPRITE D3DXCreateSprite(pDevice,&Sprite); init = FALSE;} D3DXVECTOR3 POS; POS.x = 15; POS.y = 15; POS.z = 0; Sprite->Begin(D3DXSPRITE_ALPHABLEND); Sprite->Draw(MenuTexture,NULL,NULL,NULL,0xFFFFFFFF); Sprite->End(); ReFont(pDevice); dMenu.BuildMenu("=== A N D R E M A L M S T E E N ===",0,750,0,750,RED,BLACK,GREEN,pDevice); if(g_pFont == NULL) D3DXCreateFont(pDevice, 28, 0, FW_BOLD, 1, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Viner Hand ITC", &g_pFont); PrintText(g_pFont, 350, 10, D3DCOLOR_ARGB(255,255,0,0), "|---> A N D R E M A L M S T E E N <---|\n P R I V A T E O N L Y"); return oEndScene(pDevice); } HRESULT WINAPI hkDrawIndexedPrimitive(LPDIRECT3DDEVICE9 pDevice, D3DPRIMITIVETYPE PrimType,INT BaseVertexIndex,UINT MinVertexIndex,UINT NumVertices,UINT startIndex,UINT primCount) { LPDIRECT3DVERTEXBUFFER9 Stream_Data; UINT Offset = 0; UINT Stride = 0; if(pDevice->GetStreamSource(0,&Stream_Data,&OffsetInBytes,&m_Stride) == D3D_OK) Stream_Data->Release(); DWORD dwOldZEnable = D3DZB_TRUE; if (Generate) { GenerateTexture(pDevice, &texGreen , D3DCOLOR_ARGB(255,0,255,0)); GenerateTexture(pDevice, &texRed , D3DCOLOR_ARGB(255,255,0,0)); GenerateTexture(pDevice, &texBlue , D3DCOLOR_ARGB(255,0,0,255)); GenerateTexture(pDevice, &texOrange , D3DCOLOR_ARGB(255,255,165,0)); GenerateTexture(pDevice, &texYellow , D3DCOLOR_ARGB(255,255,255,0)); GenerateTexture(pDevice, &texPink , D3DCOLOR_ARGB(255,255,192,203)); GenerateTexture(pDevice, &texCyan , D3DCOLOR_ARGB(255,0,255,255)); GenerateTexture(pDevice, &texPurple , D3DCOLOR_ARGB(255,160,32,240)); GenerateTexture(pDevice, &texBlack , D3DCOLOR_ARGB(255,0,0,0)); GenerateTexture(pDevice, &texWhite , D3DCOLOR_ARGB(255,255,255,255)); GenerateTexture(pDevice, &texSteelBlue , D3DCOLOR_ARGB(255,33,104,140)); GenerateTexture(pDevice, &texLightSteelBlue, D3DCOLOR_ARGB(255,201,255,255)); GenerateTexture(pDevice, &texLightBlue , D3DCOLOR_ARGB(255,26,140,306)); GenerateTexture(pDevice, &texSalmon , D3DCOLOR_ARGB(255,196,112,112)); GenerateTexture(pDevice, &texBrown , D3DCOLOR_ARGB(255,168,99,20)); GenerateTexture(pDevice, &texTeal , D3DCOLOR_ARGB(255,38,140,140)); GenerateTexture(pDevice, &texLime , D3DCOLOR_ARGB(255,50,205,50)); GenerateTexture(pDevice, &texElectricLime , D3DCOLOR_ARGB(255,204,255,0)); GenerateTexture(pDevice, &texGold , D3DCOLOR_ARGB(255,255, 215, 0)); GenerateTexture(pDevice, &texOrangeRed , D3DCOLOR_ARGB(255,255,69,0)); GenerateTexture(pDevice, &texGreenYellow , D3DCOLOR_ARGB(255,173,255,47)); GenerateTexture(pDevice, &texAquaMarine , D3DCOLOR_ARGB(255,127,255,212)); GenerateTexture(pDevice, &texSkyBlue , D3DCOLOR_ARGB(255,0,191,255)); GenerateTexture(pDevice, &texSlateBlue , D3DCOLOR_ARGB(255,132, 112, 255)); GenerateTexture(pDevice, &texCrimson , D3DCOLOR_ARGB(255,220,20,60)); GenerateTexture(pDevice, &texDarkOliveGreen, D3DCOLOR_ARGB(255,188,238,104 )); GenerateTexture(pDevice, &texPaleGreen , D3DCOLOR_ARGB(255,154,255, 154)); GenerateTexture(pDevice, &texDarkGoldenRod , D3DCOLOR_ARGB(255,255, 185, 15 )); GenerateTexture(pDevice, &texFireBrick , D3DCOLOR_ARGB(255,255,48,48)); GenerateTexture(pDevice, &texDarkBlue , D3DCOLOR_ARGB(255,0,0,204)); GenerateTexture(pDevice, &texDarkerBlue , D3DCOLOR_ARGB(255,0,0,153)); GenerateTexture(pDevice, &texDarkYellow , D3DCOLOR_ARGB(255,255,204,0)); GenerateTexture(pDevice, &texLightYellow , D3DCOLOR_ARGB(255,255,255,153)); Generate = false; } if(hack1) { if((m_Stride == 44))//tero { DWORD dwOldZEnable; pDevice-> GetRenderState (D3DRS_ZENABLE, & dwOldZEnable); pDevice-> SetRenderState (D3DRS_ZENABLE, D3DZB_FALSE); pDevice->SetRenderState( D3DRS_FILLMODE,D3DFILL_SOLID ); pDevice->SetTexture( 0, texPaleGreen); oDrawIndexedPrimitive(pDevice, PrimType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount); pDevice-> SetRenderState (D3DRS_ZENABLE, dwOldZEnable); } } if(hack2) { if((m_Stride == 52))//ct { DWORD dwOldZEnable; pDevice-> GetRenderState (D3DRS_ZENABLE, & dwOldZEnable); pDevice-> SetRenderState (D3DRS_ZENABLE, D3DZB_FALSE); pDevice->SetRenderState( D3DRS_FILLMODE,D3DFILL_SOLID ); pDevice->SetTexture( 0, texLightSteelBlue ); oDrawIndexedPrimitive(pDevice, PrimType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount); pDevice-> SetRenderState (D3DRS_ZENABLE, dwOldZEnable); } } if(hack3) { if((m_Stride == 52 || m_Stride == 48))//kan ini coding wh glass//wh nya mau kk cman charm tero nya g bisa .. oohhh.. klo untuk chams tero cuman tambahin ini gan.. { DWORD dwOldZEnable; pDevice-> GetRenderState (D3DRS_ZENABLE, & dwOldZEnable); pDevice-> SetRenderState (D3DRS_ZENABLE, D3DZB_FALSE); pDevice-> SetTexture( 0, texPaleGreen ); oDrawIndexedPrimitive(pDevice, PrimType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount); } } if(hack4) { if( Stride == 24 ){ pDevice->SetRenderState(D3DRS_ZENABLE, true); } } if(hack5) { if(Stride == 44 || Stride == 52 || Stride ==76 || Stride == 36 ) { DWORD dwOldZEnable; pDevice-> GetRenderState (D3DRS_ZENABLE, & dwOldZEnable); pDevice-> SetRenderState (D3DRS_ZENABLE, D3DZB_FALSE); pDevice->SetRenderState( D3DRS_FILLMODE,D3DFILL_SOLID ); pDevice->SetTexture( 0, texPaleGreen); oDrawIndexedPrimitive(pDevice, PrimType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount); pDevice-> SetRenderState (D3DRS_ZENABLE, dwOldZEnable); } } return oDrawIndexedPrimitive(pDevice, PrimType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount); } int D3D(void) { HINSTANCE hD3D; DWORD vTable[105]; hD3D=0; do { hD3D = GetModuleHandle("d3d9.dll"); if (!hD3D) Sleep(250); } while(!hD3D); if (D3Ddiscover((void *)&vTable[0],420)==0) return 0; { while(1) { if(memcmp((void*)vTable[82],(void*)(PBYTE)"\x8B\xFF",2)== 0) { oDrawIndexedPrimitive = (tDrawIndexedPrimitive) DetourCreate((PBYTE)vTable[82], (PBYTE)hkDrawIndexedPrimitive, 5); oEndScene = (tEndScene) DetourCreate((PBYTE) vTable[42], (PBYTE)hkEndScene,5); } Sleep(200); } return 0; } } BOOL WINAPI DllMain(HMODULE hDll, DWORD dwReason, LPVOID lpReserved) { DisableThreadLibraryCalls(hDll); //CheckValidHardwareID(); if (dwReason == DLL_PROCESS_ATTACH) { MessageBox (0,"\n============================== A N D R E M A L M S T E E N ==============================\n________________________________________________________________________________\n\nCredit by \n\nA N D R E M A L M S T E E N\n\n\n ----------> A N D R E M A L M S T E E N <----------\n\n\n\nJika Bermasalah Hubungi :\nkantor lurah\nKantor Camat\nKantor RT\nkantor RW\nPUSKESMAS\natau\nSEMPAK TERDEKAT\n\n\n________________________________________________________________________________\n============================== A N D R E M A L M S T E E N ==============================\n","A N D R E M A L M S T E E N @ N 2", MB_OK | MB_ICONEXCLAMATION); CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)D3D, NULL, NULL, NULL); //CreateThread(0, 0, (LPTHREAD_START_ROUTINE)ThreadStarter,0, 0, 0); } return TRUE; }
MainBase.cpp - Spoiler:
#define WIN32_LEAN_AND_MEAN #define WIN32_EXTRA_LEAN
#include <windows.h>
#include "based.h"
DWORD ade32_table[512] = { /* 00 */ C_MODRM, /* 01 */ C_MODRM, /* 02 */ C_MODRM, /* 03 */ C_MODRM, /* 04 */ C_DATA1, /* 05 */ C_DATA66, /* 06 */ C_BAD, /* 07 */ C_BAD, /* 08 */ C_MODRM, /* 09 */ C_MODRM, /* 0A */ C_MODRM, /* 0B */ C_MODRM, /* 0C */ C_DATA1, /* 0D */ C_DATA66, /* 0E */ C_BAD, /* 0F */ C_OPCODE2, /* 10 */ C_MODRM+C_BAD, /* 11 */ C_MODRM, /* 12 */ C_MODRM+C_BAD, /* 13 */ C_MODRM, /* 14 */ C_DATA1+C_BAD, /* 15 */ C_DATA66+C_BAD, /* 16 */ C_BAD, /* 17 */ C_BAD, /* 18 */ C_MODRM+C_BAD, /* 19 */ C_MODRM, /* 1A */ C_MODRM, /* 1B */ C_MODRM, /* 1C */ C_DATA1+C_BAD, /* 1D */ C_DATA66+C_BAD, /* 1E */ C_BAD, /* 1F */ C_BAD, /* 20 */ C_MODRM, /* 21 */ C_MODRM, /* 22 */ C_MODRM, /* 23 */ C_MODRM, /* 24 */ C_DATA1, /* 25 */ C_DATA66, /* 26 */ C_SEG+C_BAD, /* 27 */ C_BAD, /* 28 */ C_MODRM, /* 29 */ C_MODRM, /* 2A */ C_MODRM, /* 2B */ C_MODRM, /* 2C */ C_DATA1, /* 2D */ C_DATA66, /* 2E */ C_SEG+C_BAD, /* 2F */ C_BAD, /* 30 */ C_MODRM, /* 31 */ C_MODRM, /* 32 */ C_MODRM, /* 33 */ C_MODRM, /* 34 */ C_DATA1, /* 35 */ C_DATA66, /* 36 */ C_SEG+C_BAD, /* 37 */ C_BAD, /* 38 */ C_MODRM, /* 39 */ C_MODRM, /* 3A */ C_MODRM, /* 3B */ C_MODRM, /* 3C */ C_DATA1, /* 3D */ C_DATA66, /* 3E */ C_SEG+C_BAD, /* 3F */ C_BAD, /* 40 */ 0, /* 41 */ 0, /* 42 */ 0, /* 43 */ 0, /* 44 */ C_BAD, /* 45 */ 0, /* 46 */ 0, /* 47 */ 0, /* 48 */ 0, /* 49 */ 0, /* 4A */ 0, /* 4B */ 0, /* 4C */ C_BAD, /* 4D */ 0, /* 4E */ 0, /* 4F */ 0, /* 50 */ 0, /* 51 */ 0, /* 52 */ 0, /* 53 */ 0, /* 54 */ 0, /* 55 */ 0, /* 56 */ 0, /* 57 */ 0, /* 58 */ 0, /* 59 */ 0, /* 5A */ 0, /* 5B */ 0, /* 5C */ C_BAD, /* 5D */ 0, /* 5E */ 0, /* 5F */ 0, /* 60 */ C_BAD, /* 61 */ C_BAD, /* 62 */ C_MODRM+C_BAD, /* 63 */ C_MODRM+C_BAD, /* 64 */ C_SEG, /* 65 */ C_SEG+C_BAD, /* 66 */ C_66, /* 67 */ C_67, /* 68 */ C_DATA66, /* 69 */ C_MODRM+C_DATA66, /* 6A */ C_DATA1, /* 6B */ C_MODRM+C_DATA1, /* 6C */ C_BAD, /* 6D */ C_BAD, /* 6E */ C_BAD, /* 6F */ C_BAD, /* 70 */ C_DATA1+C_REL+C_BAD, /* 71 */ C_DATA1+C_REL+C_BAD, /* 72 */ C_DATA1+C_REL, /* 73 */ C_DATA1+C_REL, /* 74 */ C_DATA1+C_REL, /* 75 */ C_DATA1+C_REL, /* 76 */ C_DATA1+C_REL, /* 77 */ C_DATA1+C_REL, /* 78 */ C_DATA1+C_REL, /* 79 */ C_DATA1+C_REL, /* 7A */ C_DATA1+C_REL+C_BAD, /* 7B */ C_DATA1+C_REL+C_BAD, /* 7C */ C_DATA1+C_REL, /* 7D */ C_DATA1+C_REL, /* 7E */ C_DATA1+C_REL, /* 7F */ C_DATA1+C_REL, /* 80 */ C_MODRM+C_DATA1, /* 81 */ C_MODRM+C_DATA66, /* 82 */ C_MODRM+C_DATA1+C_BAD, /* 83 */ C_MODRM+C_DATA1, /* 84 */ C_MODRM, /* 85 */ C_MODRM, /* 86 */ C_MODRM, /* 87 */ C_MODRM, /* 88 */ C_MODRM, /* 89 */ C_MODRM, /* 8A */ C_MODRM, /* 8B */ C_MODRM, /* 8C */ C_MODRM+C_BAD, /* 8D */ C_MODRM, /* 8E */ C_MODRM+C_BAD, /* 8F */ C_MODRM, /* 90 */ 0, /* 91 */ 0, /* 92 */ 0, /* 93 */ C_BAD, /* 94 */ C_BAD, /* 95 */ C_BAD, /* 96 */ C_BAD, /* 97 */ C_BAD, /* 98 */ C_BAD, /* 99 */ 0, /* 9A */ C_DATA66+C_DATA2+C_BAD, /* 9B */ 0, /* 9C */ C_BAD, /* 9D */ C_BAD, /* 9E */ C_BAD, /* 9F */ C_BAD, /* A0 */ C_ADDR67, /* A1 */ C_ADDR67, /* A2 */ C_ADDR67, /* A3 */ C_ADDR67, /* A4 */ 0, /* A5 */ 0, /* A6 */ 0, /* A7 */ 0, /* A8 */ C_DATA1, /* A9 */ C_DATA66, /* AA */ 0, /* AB */ 0, /* AC */ 0, /* AD */ C_BAD, /* AE */ 0, /* AF */ C_BAD, /* B0 */ C_DATA1, /* B1 */ C_DATA1, /* B2 */ C_DATA1, /* B3 */ C_DATA1, /* B4 */ C_DATA1, /* B5 */ C_DATA1, /* B6 */ C_DATA1+C_BAD, /* B7 */ C_DATA1+C_BAD, /* B8 */ C_DATA66, /* B9 */ C_DATA66, /* BA */ C_DATA66, /* BB */ C_DATA66, /* BC */ C_DATA66+C_BAD, /* BD */ C_DATA66, /* BE */ C_DATA66, /* BF */ C_DATA66, /* C0 */ C_MODRM+C_DATA1, /* C1 */ C_MODRM+C_DATA1, /* C2 */ C_DATA2+C_STOP, /* C3 */ C_STOP, /* C4 */ C_MODRM+C_BAD, /* C5 */ C_MODRM+C_BAD, /* C6 */ C_MODRM+C_DATA1, /* C7 */ C_MODRM+C_DATA66, /* C8 */ C_DATA2+C_DATA1, /* C9 */ 0, /* CA */ C_DATA2+C_STOP+C_BAD, /* CB */ C_STOP+C_BAD, /* CC */ C_BAD, /* CD */ C_BAD, /* CE */ C_BAD, /* CF */ C_STOP+C_BAD, /* D0 */ C_MODRM, /* D1 */ C_MODRM, /* D2 */ C_MODRM, /* D3 */ C_MODRM, /* D4 */ C_DATA1+C_BAD, /* D5 */ C_DATA1+C_BAD, /* D6 */ C_BAD, /* D7 */ C_BAD, /* D8 */ C_MODRM, /* D9 */ C_MODRM, /* DA */ C_MODRM, /* DB */ C_MODRM, /* DC */ C_MODRM, /* DD */ C_MODRM, /* DE */ C_MODRM, /* DF */ C_MODRM, /* E0 */ C_DATA1+C_REL+C_BAD, /* E1 */ C_DATA1+C_REL+C_BAD, /* E2 */ C_DATA1+C_REL, /* E3 */ C_DATA1+C_REL, /* E4 */ C_DATA1+C_BAD, /* E5 */ C_DATA1+C_BAD, /* E6 */ C_DATA1+C_BAD, /* E7 */ C_DATA1+C_BAD, /* E8 */ C_DATA66+C_REL, /* E9 */ C_DATA66+C_REL+C_STOP, /* EA */ C_DATA66+C_DATA2+C_BAD, /* EB */ C_DATA1+C_REL+C_STOP, /* EC */ C_BAD, /* ED */ C_BAD, /* EE */ C_BAD, /* EF */ C_BAD, /* F0 */ C_LOCK+C_BAD, /* F1 */ C_BAD, /* F2 */ C_REP, /* F3 */ C_REP, /* F4 */ C_BAD, /* F5 */ C_BAD, /* F6 */ C_MODRM, /* F7 */ C_MODRM, /* F8 */ 0, /* F9 */ 0, /* FA */ C_BAD, /* FB */ C_BAD, /* FC */ 0, /* FD */ 0, /* FE */ C_MODRM, /* FF */ C_MODRM, /* 00 */ C_MODRM, /* 01 */ C_MODRM, /* 02 */ C_MODRM, /* 03 */ C_MODRM, /* 04 */ C_ERROR, /* 05 */ C_ERROR, /* 06 */ 0, /* 07 */ C_ERROR, /* 08 */ 0, /* 09 */ 0, /* 0A */ 0, /* 0B */ 0, /* 0C */ C_ERROR, /* 0D */ C_ERROR, /* 0E */ C_ERROR, /* 0F */ C_ERROR, /* 10 */ C_ERROR, /* 11 */ C_ERROR, /* 12 */ C_ERROR, /* 13 */ C_ERROR, /* 14 */ C_ERROR, /* 15 */ C_ERROR, /* 16 */ C_ERROR, /* 17 */ C_ERROR, /* 18 */ C_ERROR, /* 19 */ C_ERROR, /* 1A */ C_ERROR, /* 1B */ C_ERROR, /* 1C */ C_ERROR, /* 1D */ C_ERROR, /* 1E */ C_ERROR, /* 1F */ C_ERROR, /* 20 */ C_ERROR, /* 21 */ C_ERROR, /* 22 */ C_ERROR, /* 23 */ C_ERROR, /* 24 */ C_ERROR, /* 25 */ C_ERROR, /* 26 */ C_ERROR, /* 27 */ C_ERROR, /* 28 */ C_ERROR, /* 29 */ C_ERROR, /* 2A */ C_ERROR, /* 2B */ C_ERROR, /* 2C */ C_ERROR, /* 2D */ C_ERROR, /* 2E */ C_ERROR, /* 2F */ C_ERROR, /* 30 */ C_ERROR, /* 31 */ C_ERROR, /* 32 */ C_ERROR, /* 33 */ C_ERROR, /* 34 */ C_ERROR, /* 35 */ C_ERROR, /* 36 */ C_ERROR, /* 37 */ C_ERROR, /* 38 */ C_ERROR, /* 39 */ C_ERROR, /* 3A */ C_ERROR, /* 3B */ C_ERROR, /* 3C */ C_ERROR, /* 3D */ C_ERROR, /* 3E */ C_ERROR, /* 3F */ C_ERROR, /* 40 */ C_ERROR, /* 41 */ C_ERROR, /* 42 */ C_ERROR, /* 43 */ C_ERROR, /* 44 */ C_ERROR, /* 45 */ C_ERROR, /* 46 */ C_ERROR, /* 47 */ C_ERROR, /* 48 */ C_ERROR, /* 49 */ C_ERROR, /* 4A */ C_ERROR, /* 4B */ C_ERROR, /* 4C */ C_ERROR, /* 4D */ C_ERROR, /* 4E */ C_ERROR, /* 4F */ C_ERROR, /* 50 */ C_ERROR, /* 51 */ C_ERROR, /* 52 */ C_ERROR, /* 53 */ C_ERROR, /* 54 */ C_ERROR, /* 55 */ C_ERROR, /* 56 */ C_ERROR, /* 57 */ C_ERROR, /* 58 */ C_ERROR, /* 59 */ C_ERROR, /* 5A */ C_ERROR, /* 5B */ C_ERROR, /* 5C */ C_ERROR, /* 5D */ C_ERROR, /* 5E */ C_ERROR, /* 5F */ C_ERROR, /* 60 */ C_ERROR, /* 61 */ C_ERROR, /* 62 */ C_ERROR, /* 63 */ C_ERROR, /* 64 */ C_ERROR, /* 65 */ C_ERROR, /* 66 */ C_ERROR, /* 67 */ C_ERROR, /* 68 */ C_ERROR, /* 69 */ C_ERROR, /* 6A */ C_ERROR, /* 6B */ C_ERROR, /* 6C */ C_ERROR, /* 6D */ C_ERROR, /* 6E */ C_ERROR, /* 6F */ C_ERROR, /* 70 */ C_ERROR, /* 71 */ C_ERROR, /* 72 */ C_ERROR, /* 73 */ C_ERROR, /* 74 */ C_ERROR, /* 75 */ C_ERROR, /* 76 */ C_ERROR, /* 77 */ C_ERROR, /* 78 */ C_ERROR, /* 79 */ C_ERROR, /* 7A */ C_ERROR, /* 7B */ C_ERROR, /* 7C */ C_ERROR, /* 7D */ C_ERROR, /* 7E */ C_ERROR, /* 7F */ C_ERROR, /* 80 */ C_DATA66+C_REL, /* 81 */ C_DATA66+C_REL, /* 82 */ C_DATA66+C_REL, /* 83 */ C_DATA66+C_REL, /* 84 */ C_DATA66+C_REL, /* 85 */ C_DATA66+C_REL, /* 86 */ C_DATA66+C_REL, /* 87 */ C_DATA66+C_REL, /* 88 */ C_DATA66+C_REL, /* 89 */ C_DATA66+C_REL, /* 8A */ C_DATA66+C_REL, /* 8B */ C_DATA66+C_REL, /* 8C */ C_DATA66+C_REL, /* 8D */ C_DATA66+C_REL, /* 8E */ C_DATA66+C_REL, /* 8F */ C_DATA66+C_REL, /* 90 */ C_MODRM, /* 91 */ C_MODRM, /* 92 */ C_MODRM, /* 93 */ C_MODRM, /* 94 */ C_MODRM, /* 95 */ C_MODRM, /* 96 */ C_MODRM, /* 97 */ C_MODRM, /* 98 */ C_MODRM, /* 99 */ C_MODRM, /* 9A */ C_MODRM, /* 9B */ C_MODRM, /* 9C */ C_MODRM, /* 9D */ C_MODRM, /* 9E */ C_MODRM, /* 9F */ C_MODRM, /* A0 */ 0, /* A1 */ 0, /* A2 */ 0, /* A3 */ C_MODRM, /* A4 */ C_MODRM+C_DATA1, /* A5 */ C_MODRM, /* A6 */ C_ERROR, /* A7 */ C_ERROR, /* A8 */ 0, /* A9 */ 0, /* AA */ 0, /* AB */ C_MODRM, /* AC */ C_MODRM+C_DATA1, /* AD */ C_MODRM, /* AE */ C_ERROR, /* AF */ C_MODRM, /* B0 */ C_MODRM, /* B1 */ C_MODRM, /* B2 */ C_MODRM, /* B3 */ C_MODRM, /* B4 */ C_MODRM, /* B5 */ C_MODRM, /* B6 */ C_MODRM, /* B7 */ C_MODRM, /* B8 */ C_ERROR, /* B9 */ C_ERROR, /* BA */ C_MODRM+C_DATA1, /* BB */ C_MODRM, /* BC */ C_MODRM, /* BD */ C_MODRM, /* BE */ C_MODRM, /* BF */ C_MODRM, /* C0 */ C_MODRM, /* C1 */ C_MODRM, /* C2 */ C_ERROR, /* C3 */ C_ERROR, /* C4 */ C_ERROR, /* C5 */ C_ERROR, /* C6 */ C_ERROR, /* C7 */ C_ERROR, /* C8 */ 0, /* C9 */ 0, /* CA */ 0, /* CB */ 0, /* CC */ 0, /* CD */ C_DATA1, /* CE */ 0, /* CF */ 0, /* D0 */ C_ERROR, /* D1 */ C_ERROR, /* D2 */ C_ERROR, /* D3 */ C_ERROR, /* D4 */ C_ERROR, /* D5 */ C_ERROR, /* D6 */ C_ERROR, /* D7 */ C_ERROR, /* D8 */ C_ERROR, /* D9 */ C_ERROR, /* DA */ C_ERROR, /* DB */ C_ERROR, /* DC */ C_ERROR, /* DD */ C_ERROR, /* DE */ C_ERROR, /* DF */ C_ERROR, /* E0 */ C_ERROR, /* E1 */ C_ERROR, /* E2 */ C_ERROR, /* E3 */ C_ERROR, /* E4 */ C_ERROR, /* E5 */ C_ERROR, /* E6 */ C_ERROR, /* E7 */ C_ERROR, /* E8 */ C_ERROR, /* E9 */ C_ERROR, /* EA */ C_ERROR, /* EB */ C_ERROR, /* EC */ C_ERROR, /* ED */ C_ERROR, /* EE */ C_ERROR, /* EF */ C_ERROR, /* F0 */ C_ERROR, /* F1 */ C_ERROR, /* F2 */ C_ERROR, /* F3 */ C_ERROR, /* F4 */ C_ERROR, /* F5 */ C_ERROR, /* F6 */ C_ERROR, /* F7 */ C_ERROR, /* F8 */ C_ERROR, /* F9 */ C_ERROR, /* FA */ C_ERROR, /* FB */ C_ERROR, /* FC */ C_ERROR, /* FD */ C_ERROR, /* FE */ C_ERROR, /* FF */ C_ERROR }; // ade32_table[]
int disasm(BYTE* opcode0, disasm_struct* diza){ BYTE* opcode = opcode0;
memset(diza, 0x00, sizeof(disasm_struct)); diza->disasm_defdata = 4; diza->disasm_defaddr = 4;
if(*(WORD*)opcode == 0x0000) return 0; if(*(WORD*)opcode == 0xFFFF) return 0;
DWORD flag = 0;
repeat_prefix:
BYTE c = *opcode++; DWORD t = ade32_table[ c ];
if(t & C_ANYPREFIX){ if(flag & t) return 0;
flag |= t;
if(t & C_67) diza->disasm_defaddr ^= 2^4; else if(t & C_66) diza->disasm_defdata ^= 2^4; else if(t & C_SEG) diza->disasm_seg = c; else if(t & C_REP) diza->disasm_rep = c; // LOCK
goto repeat_prefix; } // C_ANYPREFIX
flag |= t; diza->disasm_opcode = c;
if(c == 0x0F){ c = *opcode++; diza->disasm_opcode2 = c; flag |= ade32_table[256+c]; // 2nd flagtable half
if(flag == C_ERROR) return 0; }else if(c == 0xF7){ if(((*opcode) & 0x38) == 0) flag |= C_DATA66; }else if(c == 0xF6){ if(((*opcode) & 0x38) == 0) flag |= C_DATA1; }else if(c == 0xCD){ if(*opcode == 0x20) flag |= C_DATA4; }
if(flag & C_MODRM){ c = *opcode++; diza->disasm_modrm = c;
if(((c & 0x38) == 0x20) && (diza->disasm_opcode == 0xFF)) flag |= C_STOP;
BYTE mod = c & 0xC0; BYTE rm = c & 0x07;
if(mod != 0xC0){ if(diza->disasm_defaddr == 4){ if(rm == 4){ flag |= C_SIB; c = *opcode++; diza->disasm_sib = c; rm = c & 0x07; }
if(mod == 0x40) flag |= C_ADDR1; else if(mod == 0x80) flag |= C_ADDR4; else if (rm == 5) flag |= C_ADDR4; }else{ // MODRM 16-bit if(mod == 0x40) flag |= C_ADDR1; else if(mod == 0x80) flag |= C_ADDR2; else if(rm == 6) flag |= C_ADDR2; } } } // C_MODRM
diza->disasm_flag = flag;
DWORD a = flag & (C_ADDR1 | C_ADDR2 | C_ADDR4); DWORD d = (flag & (C_DATA1 | C_DATA2 | C_DATA4)) >> 8;
if(flag & C_ADDR67) a += diza->disasm_defaddr; if(flag & C_DATA66) d += diza->disasm_defdata;
diza->disasm_addrsize = a; diza->disasm_datasize = d;
DWORD i; for(i = 0; i < a; i++) diza->disasm_addr_b[i] = *opcode++;
for(i = 0; i < d; i++) diza->disasm_data_b[i] = *opcode++;
diza->disasm_len = opcode - opcode0;
return diza->disasm_len; }
int oplen(BYTE *opcode){ disasm_struct diza; memset(&diza,0,sizeof(diza));
disasm((BYTE*)opcode,&diza);
if((diza.disasm_flag == C_ERROR) || ((diza.disasm_flag&C_STOP) == C_STOP) || ((diza.disasm_flag&C_REL)==C_REL) || ((diza.disasm_flag&C_BAD)==C_BAD)) return -1;
return diza.disasm_len; } /******************************************************************************************************************************************
andremenuclass.h - Spoiler:
#include <windows.h> #include "Functions.h"
typedef struct{ int index; char * title; int *hack; int hackmaxval; int hacktype; DWORD HCOLOR; void *functionAddy; }ITEM;
class zenixMenu { public: LPDIRECT3DDEVICE9 pDevice; LPD3DXFONT pFont;
int hackcount; int selector; int x,y,w,h; DWORD COLOR;
ITEM HACKITEM[99]; char hackrval[256];
void CreateItem(int index, char * title, int *hack,int hackmaxval=1,int hacktype=0, void* actionfunc=NULL); void BuildMenu(char * menuname, int x, int y, int h, int w, DWORD TITLECOL, DWORD BACKCOLOR, DWORD BORDERCOLOR, LPDIRECT3DDEVICE9 pDevice); void RenderMenu(); };
typedef HRESULT (WINAPI* tEndScene)(LPDIRECT3DDEVICE9 pDevice); tEndScene oEndScene;
typedef HRESULT (WINAPI* tDrawIndexedPrimitive)(LPDIRECT3DDEVICE9 pDevice, D3DPRIMITIVETYPE PrimType,INT BaseVertexIndex,UINT MinVertexIndex,UINT NumVertices,UINT startIndex,UINT primCount); tDrawIndexedPrimitive oDrawIndexedPrimitive;
typedef HRESULT(WINAPI* tReset)(LPDIRECT3DDEVICE9 pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters); tReset oReset;
//Colors A,R,G,B Gan Silahkan dipakai untuk membuat Chams #define RED D3DCOLOR_ARGB(255, 255, 0, 0) #define GREEN D3DCOLOR_ARGB(255, 0, 255, 0) #define BLUE D3DCOLOR_ARGB(255, 0, 0, 255) #define WHITE D3DCOLOR_ARGB(255, 255, 255, 255) #define BLACK D3DCOLOR_ARGB(255, 0, 0, 0) #define YELLOW D3DCOLOR_ARGB(255, 255, 255, 0) #define TEAL D3DCOLOR_ARGB(255, 0, 255, 255) #define PINK D3DCOLOR_ARGB(255, 255, 240, 0) #define ORANGE D3DCOLOR_ARGB(255, 255, 132, 0) #define LIME D3DCOLOR_ARGB(255, 198, 255, 0) #define SKYBLUE D3DCOLOR_ARGB(255, 0, 180, 255) #define MAROON D3DCOLOR_ARGB(255, 142, 30, 0) #define LGRAY D3DCOLOR_ARGB(255, 174, 174, 174) #define DGRAY D3DCOLOR_ARGB(255, 71, 65, 64) #define BROWN D3DCOLOR_ARGB(255, 77, 46, 38) #define SHIT D3DCOLOR_ARGB(255, 74, 38, 38) based.h - Spoiler:
#ifndef __FAKE_H__ #define __FAKE_H__
#define C_ERROR 0xFFFFFFFF #define C_ADDR1 0x00000001 #define C_ADDR2 0x00000002 #define C_ADDR4 0x00000004 #define C_LOCK 0x00000008 #define C_67 0x00000010 #define C_66 0x00000020 #define C_REP 0x00000040 #define C_SEG 0x00000080 #define C_ANYPREFIX (C_66+C_67+C_LOCK+C_REP+C_SEG) #define C_DATA1 0x00000100 #define C_DATA2 0x00000200 #define C_DATA4 0x00000400 #define C_SIB 0x00000800 #define C_ADDR67 0x00001000 #define C_DATA66 0x00002000 #define C_MODRM 0x00004000 #define C_BAD 0x00008000 #define C_OPCODE2 0x00010000 #define C_REL 0x00020000 #define C_STOP 0x00040000
#pragma pack(push) #pragma pack(1)
struct disasm_struct { BYTE disasm_defaddr; // 00 BYTE disasm_defdata; // 01 DWORD disasm_len; // 02 03 04 05 DWORD disasm_flag; // 06 07 08 09 DWORD disasm_addrsize; // 0A 0B 0C 0D DWORD disasm_datasize; // 0E 0F 10 11 BYTE disasm_rep; // 12 BYTE disasm_seg; // 13 BYTE disasm_opcode; // 14 BYTE disasm_opcode2; // 15 BYTE disasm_modrm; // 16 BYTE disasm_sib; // 17
union { BYTE disasm_addr_b[8]; // 18 19 1A 1B 1C 1D 1E 1F WORD disasm_addr_w[4]; DWORD disasm_addr_d[2]; char disasm_addr_c[8]; short disasm_addr_s[4]; long disasm_addr_l[2]; };
union { BYTE disasm_data_b[8]; // 20 21 22 23 24 25 26 27 WORD disasm_data_w[4]; DWORD disasm_data_d[2]; char disasm_data_c[8]; short disasm_data_s[4]; long disasm_data_l[2]; }; };
#pragma pack(pop)
int disasm(BYTE* opcode0, disasm_struct* diza); int oplen(BYTE* opcode);
#endif Functions.h - Spoiler:
#include <windows.h> #include "SystemIncludes.h" #include "d3d9types.h"
void PrintText(char pString[], int x, int y, D3DCOLOR col, ID3DXFont *font) { RECT FontRect = { x, y, x+500, y+30 }; font->DrawText( NULL, pString, -1, &FontRect, DT_LEFT | DT_WORDBREAK, col); }
void FillRGB( int x, int y, int w, int h, D3DCOLOR color, IDirect3DDevice9* pDevice ) { if( w < 0 )w = 1; if( h < 0 )h = 1; if( x < 0 )x = 1; if( y < 0 )y = 1;
D3DRECT rec = { x, y, x + w, y + h }; pDevice->Clear( 1, &rec, D3DCLEAR_TARGET, color, 0, 0 ); }
void DrawBorder( int x, int y, int w, int h, int px, D3DCOLOR BorderColor, IDirect3DDevice9* pDevice ) { FillRGB( x, (y + h - px), w, px, BorderColor, pDevice ); FillRGB( x, y, px, h, BorderColor, pDevice ); FillRGB( x, y, w, px, BorderColor, pDevice ); FillRGB( (x + w - px), y, px, h, BorderColor, pDevice ); }
void DrawBox( int x, int y, int w, int h, D3DCOLOR BoxColor, D3DCOLOR BorderColor, IDirect3DDevice9* pDevice ) { FillRGB( x, y, w, h, BoxColor, pDevice ); DrawBorder( x, y, w, h, 1, BorderColor, pDevice ); }
bool isMouseinRegion(int x1, int y1, int x2, int y2) { POINT cPos; GetCursorPos(&cPos); if(cPos.x > x1 && cPos.x < x2 && cPos.y > y1 && cPos.y < y2){ return true; } else { return false; } }
bool bCompare(const BYTE* pData, const BYTE* bMask, const char* szMask) { for(;*szMask;++szMask,++pData,++bMask) if(*szMask=='x' && *pData!=*bMask) return 0; return (*szMask) == NULL; } typedef enum { AdapterGetCaps, AdapterCreateDevice, AdapterCloseAdapter, }adpfunc_t;
typedef enum _D3DDDIRENDERSTATETYPE { D3DDDIRS_ZENABLE = 7, D3DDDIRS_FILLMODE = 8, D3DDDIRS_SHADEMODE = 9, D3DDDIRS_LINEPATTERN = 10, D3DDDIRS_ZWRITEENABLE = 14, D3DDDIRS_ALPHATESTENABLE = 15, D3DDDIRS_LASTPIXEL = 16, D3DDDIRS_SRCBLEND = 19, D3DDDIRS_DESTBLEND = 20, D3DDDIRS_CULLMODE = 22, D3DDDIRS_ZFUNC = 23, D3DDDIRS_ALPHAREF = 24, D3DDDIRS_ALPHAFUNC = 25, D3DDDIRS_DITHERENABLE = 26, D3DDDIRS_ALPHABLENDENABLE = 27, D3DDDIRS_FOGENABLE = 28, D3DDDIRS_SPECULARENABLE = 29, D3DDDIRS_ZVISIBLE = 30, D3DDDIRS_FOGCOLOR = 34, D3DDDIRS_FOGTABLEMODE = 35, D3DDDIRS_FOGSTART = 36, D3DDDIRS_FOGEND = 37, D3DDDIRS_FOGDENSITY = 38, D3DDDIRS_EDGEANTIALIAS = 40, D3DDDIRS_COLORKEYENABLE = 41, D3DDDIRS_OLDALPHABLENDENABLE = 42, D3DDDIRS_ZBIAS = 47, D3DDDIRS_RANGEFOGENABLE = 48, D3DDDIRS_TRANSLUCENTSORTINDEPENDENT = 51, D3DDDIRS_STENCILENABLE = 52, D3DDDIRS_STENCILFAIL = 53, D3DDDIRS_STENCILZFAIL = 54, D3DDDIRS_STENCILPASS = 55, D3DDDIRS_STENCILFUNC = 56, D3DDDIRS_STENCILREF = 57, D3DDDIRS_STENCILMASK = 58, D3DDDIRS_STENCILWRITEMASK = 59, D3DDDIRS_TEXTUREFACTOR = 60, D3DDDIRS_SCENECAPTURE = 62, D3DDDIRS_STIPPLEPATTERN00 = 64, D3DDDIRS_STIPPLEPATTERN01 = 65, D3DDDIRS_STIPPLEPATTERN02 = 66, D3DDDIRS_STIPPLEPATTERN03 = 67, D3DDDIRS_STIPPLEPATTERN04 = 68, D3DDDIRS_STIPPLEPATTERN05 = 69, D3DDDIRS_STIPPLEPATTERN06 = 70, D3DDDIRS_STIPPLEPATTERN07 = 71, D3DDDIRS_STIPPLEPATTERN08 = 72, D3DDDIRS_STIPPLEPATTERN09 = 73, D3DDDIRS_STIPPLEPATTERN10 = 74, D3DDDIRS_STIPPLEPATTERN11 = 75, D3DDDIRS_STIPPLEPATTERN12 = 76, D3DDDIRS_STIPPLEPATTERN13 = 77, D3DDDIRS_STIPPLEPATTERN14 = 78, D3DDDIRS_STIPPLEPATTERN15 = 79, D3DDDIRS_STIPPLEPATTERN16 = 80, D3DDDIRS_STIPPLEPATTERN17 = 81, D3DDDIRS_STIPPLEPATTERN18 = 82, D3DDDIRS_STIPPLEPATTERN19 = 83, D3DDDIRS_STIPPLEPATTERN20 = 84, D3DDDIRS_STIPPLEPATTERN21 = 85, D3DDDIRS_STIPPLEPATTERN22 = 86, D3DDDIRS_STIPPLEPATTERN23 = 87, D3DDDIRS_STIPPLEPATTERN24 = 88, D3DDDIRS_STIPPLEPATTERN25 = 89, D3DDDIRS_STIPPLEPATTERN26 = 90, D3DDDIRS_STIPPLEPATTERN27 = 91, D3DDDIRS_STIPPLEPATTERN28 = 92, D3DDDIRS_STIPPLEPATTERN29 = 93, D3DDDIRS_STIPPLEPATTERN30 = 94, D3DDDIRS_STIPPLEPATTERN31 = 95, D3DDDIRS_WRAP0 = 128, D3DDDIRS_WRAP1 = 129, D3DDDIRS_WRAP2 = 130, D3DDDIRS_WRAP3 = 131, D3DDDIRS_WRAP4 = 132, D3DDDIRS_WRAP5 = 133, D3DDDIRS_WRAP6 = 134, D3DDDIRS_WRAP7 = 135, D3DDDIRS_CLIPPING = 136, D3DDDIRS_LIGHTING = 137, D3DDDIRS_AMBIENT = 139, D3DDDIRS_FOGVERTEXMODE = 140, D3DDDIRS_COLORVERTEX = 141, D3DDDIRS_LOCALVIEWER = 142, D3DDDIRS_NORMALIZENORMALS = 143, D3DDDIRS_COLORKEYBLENDENABLE = 144, D3DDDIRS_DIFFUSEMATERIALSOURCE = 145, D3DDDIRS_SPECULARMATERIALSOURCE = 146, D3DDDIRS_AMBIENTMATERIALSOURCE = 147, D3DDDIRS_EMISSIVEMATERIALSOURCE = 148, D3DDDIRS_VERTEXBLEND = 151, D3DDDIRS_CLIPPLANEENABLE = 152, D3DDDIRS_SOFTWAREVERTEXPROCESSING = 153, D3DDDIRS_POINTSIZE = 154, D3DDDIRS_POINTSIZE_MIN = 155, D3DDDIRS_POINTSPRITEENABLE = 156, D3DDDIRS_POINTSCALEENABLE = 157, D3DDDIRS_POINTSCALE_A = 158, D3DDDIRS_POINTSCALE_B = 159, D3DDDIRS_POINTSCALE_C = 160, D3DDDIRS_MULTISAMPLEANTIALIAS = 161, D3DDDIRS_MULTISAMPLEMASK = 162, D3DDDIRS_PATCHEDGESTYLE = 163, D3DDDIRS_PATCHSEGMENTS = 164, D3DDDIRS_DEBUGMONITORTOKEN = 165, D3DDDIRS_POINTSIZE_MAX = 166, D3DDDIRS_INDEXEDVERTEXBLENDENABLE = 167, D3DDDIRS_COLORWRITEENABLE = 168, D3DDDIRS_DELETERTPATCH = 169, D3DDDIRS_TWEENFACTOR = 170, D3DDDIRS_BLENDOP = 171, D3DDDIRS_POSITIONDEGREE = 172, D3DDDIRS_NORMALDEGREE = 173, D3DDDIRS_SCISSORTESTENABLE = 174, D3DDDIRS_SLOPESCALEDEPTHBIAS = 175, D3DDDIRS_ANTIALIASEDLINEENABLE = 176, D3DDDIRS_MINTESSELLATIONLEVEL = 178, D3DDDIRS_MAXTESSELLATIONLEVEL = 179, D3DDDIRS_ADAPTIVETESS_X = 180, D3DDDIRS_ADAPTIVETESS_Y = 181, D3DDDIRS_ADAPTIVETESS_Z = 182, D3DDDIRS_ADAPTIVETESS_W = 183, D3DDDIRS_ENABLEADAPTIVETESSELLATION = 184, D3DDDIRS_TWOSIDEDSTENCILMODE = 185, D3DDDIRS_CCW_STENCILFAIL = 186, D3DDDIRS_CCW_STENCILZFAIL = 187, D3DDDIRS_CCW_STENCILPASS = 188, D3DDDIRS_CCW_STENCILFUNC = 189, D3DDDIRS_COLORWRITEENABLE1 = 190, D3DDDIRS_COLORWRITEENABLE2 = 191, D3DDDIRS_COLORWRITEENABLE3 = 192, D3DDDIRS_BLENDFACTOR = 193, D3DDDIRS_SRGBWRITEENABLE = 194, D3DDDIRS_DEPTHBIAS = 195, D3DDDIRS_WRAP8 = 198, D3DDDIRS_WRAP9 = 199, D3DDDIRS_WRAP10 = 200, D3DDDIRS_WRAP11 = 201, D3DDDIRS_WRAP12 = 202, D3DDDIRS_WRAP13 = 203, D3DDDIRS_WRAP14 = 204, D3DDDIRS_WRAP15 = 205, D3DDDIRS_SEPARATEALPHABLENDENABLE = 206, D3DDDIRS_SRCBLENDALPHA = 207, D3DDDIRS_DESTBLENDALPHA = 208, D3DDDIRS_BLENDOPALPHA = 209, D3DDDIRS_FORCE_DWORD = 0x7fffffff, } D3DDDIRENDERSTATETYPE;
typedef enum { AdpSetRenderState, AdpUpdateWInfo, AdpValidateDevice, AdpSetTextureStageState, AdpAdpSetTexture, AdpSetPixelShader, AdpSetPixelShaderConst, AdpSetStreamSourceUm, AdpSetIndices, AdpSetIndicesUm, AdpDrawPrimitive, AdpDrawIndexedPrimitive, AdpDrawRectPatch, AdpDrawTriPatch, AdpDrawPrimitive2, AdpDrawIndexedPrimitive2, AdpVolBlt, AdpBufBlt, AdpTexBlt, AdpStateSet, AdpSetPriority, AdpClear, AdpUpdatePalette, AdpSetPalette, AdpSetVertexShaderConst, AdpMultiplyTransform, AdpSetTransform, AdpSetViewport, AdpSetZRange, AdpSetMaterial, AdpSetLight, AdpCreateLight, AdpDestroyLight, AdpSetClipPlane, AdpGetInfo, AdpLock, AdpUnlock, AdpCreateResource, AdpDestroyResource, AdpSetDisplayMode, AdpPresent, AdpFlush, AdpCreateVertexShaderFunc, AdpDeleteVertexShaderFunc, AdpSetVertexShaderFunc, AdpCreateVertexShaderDecl, AdpDeleteVertexShaderDecl, AdpSetVertexShaderDecl, AdpSetVertexShaderConstI, AdpSetVertexShaderConstB, AdpSetScissorRect, AdpSetStreamSource, AdpSetStreamSourceFreq, AdpSetConvolutionKernelMono, AdpComposeRects, AdpBlt, AdpColorFill, AdpDepthFill, AdpCreateQuery, AdpDestroyQuery, AdpIssueQuery, AdpGetQueryData, AdpSetRenderTarget, AdpSetDepthStencil, AdpGenerateMipSubLevels, AdpSetPixelShaderConstI, AdpSetPixelShaderConstB, AdpCreatePixelShader, AdpDeletePixelShader, AdpCreateDecodeDevice, AdpDestroyDecodeDevice, AdpSetDecodeRenderTarget, AdpDecodeBeginFrame, AdpDecodeEndFrame, AdpDecodeExecute, AdpDecodeExtensionExecute, AdpCreateVideoProcessDevice, AdpDestroyVideoProcessDevice, AdpVideoProcessBeginFrame, AdpVideoProcessEndFrame, AdpSetVideoProcessRenderTarget, AdpVideoProcessBlt, AdpCreateExtensionDevice, AdpDestroyExtensionDevice, AdpExtensionExecute, AdpCreateOverlay, AdpUpdateOverlay, AdpFlipOverlay, AdpGetOverlayColorControls, AdpSetOverlayColorControls, AdpDestroyOverlay, AdpDestroyDevice, AdpQueryResourceResidency, AdpOpenResource, AdpGetCaptureAllocationHandle, AdpCaptureToSysMem, AdpLockAsync, AdpUnlockAsync, AdpRename, #if (D3D_UMD_INTERFACE_VERSION >= D3D_UMD_INTERFACE_VERSION_WIN7) AdpCreateVideoProcessor, AdpSetVideoProcessBltState, AdpGetVideoProcessBltStatePrivate, AdpSetVideoProcessStreamState, AdpGetVideoProcessStreamStatePrivate, AdpVideoProcessBltHD, AdpDestroyVideoProcessor, AdpCreateAuthenticatedChannel, AdpAuthenticatedChannelKeyExchange, AdpQueryAuthenticatedChannel, AdpConfigureAuthenticatedChannel, AdpDestroyAuthenticatedChannel, AdpCreateCryptoSession, AdpCryptoSessionKeyExchange, AdpDestroyCryptoSession, AdpEncryptionBlt, AdpGetPitch, AdpStartSessionKeyRefresh, AdpFinishSessionKeyRefresh, AdpGetEncryptionBltKey, AdpDecryptionBlt, AdpResolveSharedResource, #endif }adpdev_t;
typedef enum D3DDDI_FLIPINTERVAL_TYPE { D3DDDI_FLIPINTERVAL_IMMEDIATE, D3DDDI_FLIPINTERVAL_ONE, D3DDDI_FLIPINTERVAL_TWO, D3DDDI_FLIPINTERVAL_THREE, D3DDDI_FLIPINTERVAL_FOUR, } D3DDDI_FLIPINTERVAL_TYPE;
typedef struct _D3DDDIARG_CREATEDEVICE { HANDLE hDevice; UINT Interface; UINT Version; CONST VOID* pCallbacks; VOID* pCommandBuffer; UINT CommandBufferSize; VOID* pAllocationList; UINT AllocationListSize; VOID* pPatchLocationList; UINT PatchLocationListSize; PULONG pDeviceFuncs; DWORD Flags; } D3DDDIARG_CREATEDEVICE;
typedef struct _D3DDDIARG_OPENADAPTER { HANDLE hAdapter; UINT Interface; UINT Version; CONST VOID* pAdapterCallbacks; PULONG pAdapterFuncs; UINT DriverVersion; } D3DDDIARG_OPENADAPTER;
typedef struct _D3DDDI_PRESENTFLAGS { union { struct { UINT Blt:1; UINT ColorFill:1; UINT Flip:1; UINT Reserved:29; }; UINT Value; }; } D3DDDI_PRESENTFLAGS;
typedef struct _D3DDDIARG_PRESENT { HANDLE hSrcResource; UINT SrcSubResourceIndex; HANDLE hDstResource; UINT DstSubResourceIndex; D3DDDI_PRESENTFLAGS Flags; D3DDDI_FLIPINTERVAL_TYPE FlipInterval; } D3DDDIARG_PRESENT;
typedef struct _D3DDDIARG_RENDERSTATE { D3DDDIRENDERSTATETYPE State; UINT Value; } D3DDDIARG_RENDERSTATE;
typedef struct _D3DDDIARG_DRAWINDEXEDPRIMITIVE { D3DPRIMITIVETYPE PrimitiveType; INT BaseVertexIndex; UINT MinIndex; UINT NumVertices; UINT StartIndex; UINT PrimitiveCount; }D3DDDIARG_DRAWINDEXEDPRIMITIVE;
typedef struct _D3DDDIARG_DRAWINDEXEDPRIMITIVE2 { D3DPRIMITIVETYPE PrimitiveType; INT BaseVertexOffset; UINT MinIndex; UINT NumVertices; UINT StartIndexOffset; UINT PrimitiveCount; }D3DDDIARG_DRAWINDEXEDPRIMITIVE2;
typedef struct _D3DDDIARG_SETSTREAMSOURCE { UINT Stream; HANDLE hVertexBuffer; UINT Offset; UINT Stride; } D3DDDIARG_SETSTREAMSOURCE;
VOID InstallDetours(D3DDDIARG_CREATEDEVICE*); VOID RemoveDetours();
//WORD FindPattern(DWORD dwAddress,DWORD dwLen,BYTE *bMask,char * szMask) //{ //for(DWORD i=0; i<dwLen; i++) //if (bCompare((BYTE*)(dwAddress+i),bMask,szMask)) return (DWORD)(dwAddress+i); //return 0; //}
Main.h - Spoiler:
#define WIN32_LEAN_AND_MEAN #define WIN32_EXTRA_LEAN
#include <windows.h>
#include "based.h"
#define DETOUR_LEN_AUTO 0 // Finds the detour length automatically
enum { DETOUR_TYPE_JMP, // min detour len: 5 DETOUR_TYPE_PUSH_RET, // min detour len: 6 DETOUR_TYPE_NOP_JMP, // min detour len: 6 DETOUR_TYPE_NOP_NOP_JMP, // min detour len: 7 DETOUR_TYPE_STC_JC, // min detour len: 7 DETOUR_TYPE_CLC_JNC, // min detour len: 7 };
LPVOID DetourCreate(LPVOID lpFuncOrig, LPVOID lpFuncDetour, int patchType, int detourLen=DETOUR_LEN_AUTO); LPVOID DetourCreate(LPCSTR lpModuleName, LPCSTR lpProcName, LPVOID lpFuncDetour, int patchType, int detourLen=DETOUR_LEN_AUTO); BOOL DetourRemove(LPVOID lpDetourCreatePtr);
#pragma warning(disable: 4311) #pragma warning(disable: 4312) #pragma warning(disable: 4244) #pragma warning(disable: 4996) #pragma warning(disable: 4101) #pragma warning(disable: 4102)
#define DETOUR_MAX_SRCH_OPLEN 64
#define JMP32_SZ 5 #define BIT32_SZ 4
// jmp32 sig #define SIG_SZ 3 #define SIG_OP_0 0xCC #define SIG_OP_1 0x90 #define SIG_OP_2 0xC3
static DWORD Silamguard;
int GetDetourLen(int patchType); int GetDetourLenAuto(PBYTE &pbFuncOrig, int minDetLen);
// Thin wrapper for APIs LPVOID DetourCreate(LPCSTR lpModuleName, LPCSTR lpProcName, LPVOID lpFuncDetour, int patchType, int detourLen) { LPVOID lpFuncOrig = NULL;
if((lpFuncOrig = GetProcAddress(GetModuleHandle(lpModuleName), lpProcName)) == NULL) return NULL;
return DetourCreate(lpFuncOrig, lpFuncDetour, patchType, detourLen); }
LPVOID DetourCreate(LPVOID lpFuncOrig, LPVOID lpFuncDetour, int patchType, int detourLen) { LPVOID lpMallocPtr = NULL; DWORD dwProt = NULL; PBYTE NewocPBrs = NULL; PBYTE pbFuncOrig = (PBYTE)lpFuncOrig; PBYTE pbFuncDetour = (PBYTE)lpFuncDetour; PBYTE pbPatchBuf = NULL; int minDetLen = 0; int detLen = 0;
// Get detour length if((minDetLen = GetDetourLen(patchType)) == 0) return NULL;
if(detourLen != DETOUR_LEN_AUTO) detLen = detourLen;
else if((detLen = GetDetourLenAuto(pbFuncOrig, minDetLen)) < minDetLen) return NULL;
// Alloc mem for the overwritten bytes if((lpMallocPtr = (LPVOID)malloc(detLen+JMP32_SZ+SIG_SZ)) == NULL) return NULL;
NewocPBrs = (PBYTE)lpMallocPtr;
// Enable writing to original VirtualProtect(lpFuncOrig, detLen, PAGE_READWRITE, &dwProt);
// Write overwritten bytes to the malloc memcpy(lpMallocPtr, lpFuncOrig, detLen); NewocPBrs += detLen; NewocPBrs[0] = 0xE9; *(DWORD*)(NewocPBrs+1) = (DWORD)((pbFuncOrig+detLen)-NewocPBrs)-JMP32_SZ; NewocPBrs += JMP32_SZ; NewocPBrs[0] = SIG_OP_0; NewocPBrs[1] = SIG_OP_1; NewocPBrs[2] = SIG_OP_2;
// Create a buffer to prepare the detour bytes pbPatchBuf = new BYTE[detLen]; memset(pbPatchBuf, 0x90, detLen);
switch(patchType) { case DETOUR_TYPE_JMP: pbPatchBuf[0] = 0xE9; *(DWORD*)&pbPatchBuf[1] = (DWORD)(pbFuncDetour - pbFuncOrig) - 5; break;
case DETOUR_TYPE_PUSH_RET: pbPatchBuf[0] = 0x68; *(DWORD*)&pbPatchBuf[1] = (DWORD)pbFuncDetour; pbPatchBuf[5] = 0xC3; break;
case DETOUR_TYPE_NOP_JMP: pbPatchBuf[0] = 0x90; pbPatchBuf[1] = 0xE9; *(DWORD*)&pbPatchBuf[2] = (DWORD)(pbFuncDetour - pbFuncOrig) - 6; break;
case DETOUR_TYPE_NOP_NOP_JMP: pbPatchBuf[0] = 0x90; pbPatchBuf[1] = 0x90; pbPatchBuf[2] = 0xE9; *(DWORD*)&pbPatchBuf[3] = (DWORD)(pbFuncDetour - pbFuncOrig) - 7; break;
case DETOUR_TYPE_STC_JC: pbPatchBuf[0] = 0xF9; pbPatchBuf[1] = 0x0F; pbPatchBuf[2] = 0x82; *(DWORD*)&pbPatchBuf[3] = (DWORD)(pbFuncDetour - pbFuncOrig) - 7; break;
case DETOUR_TYPE_CLC_JNC: pbPatchBuf[0] = 0xF8; pbPatchBuf[1] = 0x0F; pbPatchBuf[2] = 0x83; *(DWORD*)&pbPatchBuf[3] = (DWORD)(pbFuncDetour - pbFuncOrig) - 7; break;
default: return NULL; }
// Write the detour for(int i=0; i<detLen; i++) pbFuncOrig[i] = pbPatchBuf[i];
delete [] pbPatchBuf;
// Reset original mem flags VirtualProtect(lpFuncOrig, detLen, dwProt, &Silamguard);
return lpMallocPtr; }
BOOL DetourRemove(LPVOID lpDetourCreatePtr) { PBYTE NewocPBrs = NULL; DWORD NewOrig = NULL; DWORD NewProt = NULL; int i=0;
if((NewocPBrs = (PBYTE)lpDetourCreatePtr) == NULL) return FALSE;
// Find the orig jmp32 opcode sig for(i=0; i<=DETOUR_MAX_SRCH_OPLEN; i++) { if(NewocPBrs[i] == SIG_OP_0 && NewocPBrs[i+1] == SIG_OP_1 && NewocPBrs[i+2] == SIG_OP_2) break;
if(i == DETOUR_MAX_SRCH_OPLEN) return FALSE; }
// Calculate the original address NewocPBrs += (i-JMP32_SZ+1); // Inc to jmp NewOrig = *(DWORD*)NewocPBrs; // Get 32bit jmp NewocPBrs += BIT32_SZ; // Inc to end of jmp NewOrig += (DWORD)NewocPBrs; // Add this addr to 32bit jmp NewOrig -= (i-JMP32_SZ); // Dec by detour len to get to start of orig
// Write the overwritten bytes back to the original VirtualProtect((LPVOID)NewOrig, (i-JMP32_SZ), PAGE_READWRITE, &NewProt); memcpy((LPVOID)NewOrig, lpDetourCreatePtr, (i-JMP32_SZ)); VirtualProtect((LPVOID)NewOrig, (i-JMP32_SZ), NewProt, &Silamguard);
// Memory cleanup free(lpDetourCreatePtr);
return TRUE; }
int GetDetourLen(int patchType) { switch(patchType) { case DETOUR_TYPE_JMP: return 5;
case DETOUR_TYPE_PUSH_RET: case DETOUR_TYPE_NOP_JMP: return 6;
case DETOUR_TYPE_NOP_NOP_JMP: case DETOUR_TYPE_STC_JC: case DETOUR_TYPE_CLC_JNC: return 7;
default: return 0; } }
int GetDetourLenAuto(PBYTE &pbFuncOrig, int minDetLen) { int len = 0; PBYTE pbCurOp = pbFuncOrig;
while(len < minDetLen) { int i = oplen(pbCurOp);
if(i == 0 || i == -1) return 0;
if(len > DETOUR_MAX_SRCH_OPLEN) return 0;
len += i; pbCurOp += i; }
return len; }
SystemIncludes.h - Spoiler:
#include <windows.h> #include <stdio.h> #include <d3d9.h> #include <d3dx9.h> #include <fstream> #include "detours.h"
#include <d3d9.h> #pragma comment(lib, "d3d9.lib") #include <d3dx9.h> #pragma comment(lib, "d3dx9.lib")
LPDIRECT3DTEXTURE9 texYellow, texRed, texGreen, texBlue, texBlack, texWhite, texPink, texOrange, texLightBlue, texCyan, texPurple, texSteelBlue, texLightSteelBlue, texSalmon, texBrown, texTeal, texLime, texElectricLime, texGold, texOrangeRed, texGreenYellow, texAquaMarine, texSkyBlue, texSlateBlue, texCrimson, texDarkOliveGreen, texPaleGreen, texDarkGoldenRod, texFireBrick, texDarkBlue, texDarkerBlue, texDarkYellow, texLightYellow;
LPDIRECT3DVERTEXBUFFER9 Stream_Data; UINT Offset = 0; UINT Stride = 0;
UINT OffsetInBytes; UINT m_Stride;
bool Generate = true;
PVOID D3Ddiscover(void *tbl, int size) { HWND hWnd; void *pInterface=0 ; D3DPRESENT_PARAMETERS d3dpp;
if ((hWnd=CreateWindowEx(NULL,WC_DIALOG,"",WS_OVERLAPPED,0,0,50,50,NULL,NULL,NULL,NULL))==NULL) return 0; ShowWindow(hWnd, SW_HIDE);
LPDIRECT3D9 pD3D; LPDIRECT3DDEVICE9 pD3Ddev; if ((pD3D = Direct3DCreate9(D3D_SDK_VERSION))!=NULL)
{ ZeroMemory(&d3dpp, sizeof(d3dpp)); d3dpp.Windowed = TRUE; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.hDeviceWindow = hWnd; d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8; d3dpp.BackBufferWidth = d3dpp.BackBufferHeight = 600; pD3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hWnd,D3DCREATE_SOFTWARE_VERTEXPROCESSING,&d3dpp,&pD3Ddev); if (pD3Ddev) { pInterface = (PDWORD)*(DWORD *)pD3Ddev; memcpy(tbl,(void *)pInterface,size); pD3Ddev->Release(); } pD3D->Release(); } DestroyWindow(hWnd); return pInterface; }
| |
|