Tutorial Membuat D3D Crosshair
Mungkin beberapa orang udah pada tau. disini saya mau share tutorialnya. :D
Tools yg di butuhkan :
1. Microsoft Visual C++ 2010 Express
2. Microsoft DirectX SDK (Kalo saya pake yg Versi June 2010)
Setelah sudah ada semua.
1. Jalankan C++ nya, lalu buat project baru.
2. Pertama Buat header, lalu masukan Source Code ini ke Base.h
3. Kedua Buat header lagi, lalu masukan Source Code ini ke Function.h#ifndef _BASE_H#define _BASE_H #include <d3dx9.h> #include <vector> #pragma comment(lib,"d3dx9.lib") #define PDEVICE LPDIRECT3DDEVICE9 typedef HRESULT (WINAPI* oDrawIndexedPrimitive) (LPDIRECT3DDEVICE9 pDevice, D3DPRIMITIVETYPE Type,INT BaseIndex,UINT MinIndex,UINT NumVertices,UINT StartIndex,UINT PrimitiveCount); oDrawIndexedPrimitive pDrawIndexedPrimitive; #endif
4. ketiga buat file *.CPP nya, lalu masukan Source Code ini ke Base.cpp#include "Base.h" typedef HRESULT ( WINAPI* oReset )( LPDIRECT3DDEVICE9 pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters ); typedef HRESULT (WINAPI* oEndScene)(LPDIRECT3DDEVICE9 pDevice); void *DetourFunction (BYTE *src, const BYTE *dst, const int len) { BYTE *jmp = (BYTE*)malloc(len+5); DWORD dwBack; VirtualProtect(src, len, PAGE_EXECUTE_READWRITE, &dwBack); memcpy(jmp, src, len); jmp += len; jmp[0] = 0xE9; *(DWORD*)(jmp+1) = (DWORD)(src+len - jmp) - 5; src[0] = 0xE9; *(DWORD*)(src+1) = (DWORD)(dst - src) - 5; for (int i=5; i<len; i++) src[i]=0x90; VirtualProtect(src, len, dwBack, &dwBack); return (jmp-len); }
5. SaveALL Semua, Lalu Build .#include "Base.h" #include "Function.h" PDEVICE pDevice; oEndScene pEndScene; bool xhair = false; D3DCOLOR colRed = D3DCOLOR_XRGB(255, 0, 0); D3DVIEWPORT9 g_ViewPort; #define PI 3.14159265//Defining what PI is. PI is a Circle int CenterX = GetSystemMetrics( 0 ) / 2-1;//Gets screen X resolution then cutting it in half to get the center. int CenterY = GetSystemMetrics( 1 ) / 2-1;//Gets screen Y resolution then cutting it in half to get the center. ID3DXLine *pLine; void FillRGB( int x, int y, int w, int h, D3DCOLOR color, IDirect3DDevice9* pDevice ) { D3DRECT rec = { x, y, x + w, y + h }; pDevice->Clear( 1, &rec, D3DCLEAR_TARGET, color, 0, 0 ); } void kosong(){ } HRESULT WINAPI myEndScene (PDEVICE pDevice) { pDevice->GetViewport(&g_ViewPort); CenterX = ( int )g_ViewPort.Width / 2; CenterY = ( int )g_ViewPort.Height / 2; if(xhair){ FillRGB(CenterX-15, CenterY, 30, 1,colRed,pDevice);//Diagonal line FillRGB(CenterX, CenterY-15, 1, 30,colRed,pDevice);//Vertical line } if((GetKeyState(VK_LSHIFT)&0x8000)&&(GetKeyState(VK_RSHIFT)&0x8000)){//Hotkey for Crosshair xhair = !xhair; } Sleep(10); return pEndScene (pDevice); } //==============================================================================================// bool bCompare(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 (bCompare((BYTE*)(dwAddress+i),bMask,szMask)) return (DWORD)(dwAddress+i); return 0; } //==============================================================================================// int D3Dhook(void){ DWORD hD3D, adr, *vTable; // wait for the d3dx dll hD3D=0; do{ hD3D = (DWORD)GetModuleHandleA("d3d9.dll"); Sleep(10); } while(!hD3D); 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(&vTable,(void *)(adr+2),4); pEndScene = (oEndScene) DetourFunction((PBYTE)vTable[42], (PBYTE)myEndScene,5); } return 0; } DWORD WINAPI thread01(LPVOID param){ kosong(); MessageBox(0,"Click 'OK' bila tampilan Form Login telah muncul.","PangYa Info", MB_OK + MB_ICONEXCLAMATION ); Sleep(1000); CreateThread(0, 0, (LPTHREAD_START_ROUTINE)D3Dhook, 0, 0, 0); Sleep(10); return TRUE; } BOOL WINAPI DllMain ( HMODULE hDll, DWORD dwReason, LPVOID lpReserved ){ DisableThreadLibraryCalls(hDll); if (dwReason == DLL_PROCESS_ATTACH) CreateThread(0, 0, (LPTHREAD_START_ROUTINE)thread01, 0, 0, 0); return TRUE; }
6. Jangan lupa rubah Properties Project rubah Application (.exe) menjadi Dinamic Library (.dll)
Frequently Questions and Answers :
Q1 : Gan apa ini bisa di pake di PointBlank ?
A2 : Saya Belum Coba di PointBlank, Tapi dilihat dari SC nya, sepertinya tidak bisa. tapi apa salah nya jika Agan Mencoba :D
0 komentar:
Posting Komentar