Das Spiel krazt gleich beim start ab, aber der Fehler kann eig nur bei der WriteMem Funktion liegen, da es alles ohne sie funktioniert hat, also mein d3d menu lies sich öffnen un so^^
Code:
#pragma once
#pragma comment(lib, "d3d9.lib")
#pragma comment(lib, "d3dx9.lib")
#include <cstdio>
#include <windows.h>
#include <d3d9.h>
#include <d3dx9.h>
#include <iostream>
using namespace std;
typedef HRESULT (D3DAPI* Reset_t)(IDirect3DDevice9* pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters);
typedef HRESULT (WINAPI* tEndScene)(LPDIRECT3DDEVICE9 pDevice);
tEndScene pEndScene = NULL;
Reset_t pReset = 0;
DWORD dwEndScene;
DWORD dwDrawIndexedPrimitive;
LPD3DXFONT g_pFont = NULL; //D3D Font
void Funktionen();
void *DetourFunc(BYTE *src, const BYTE *dst, const int len);
void DrawFont (int X, int Y, D3DCOLOR Color, char *format, ...);
//Farben:
D3DCOLOR txtPink = D3DCOLOR_ARGB(255, 255, 0, 255);
D3DCOLOR txtRed = D3DCOLOR_ARGB(255, 255, 0, 0);
D3DCOLOR txtYellow = D3DCOLOR_ARGB(255, 255, 255, 0);
D3DCOLOR txtGreen = D3DCOLOR_ARGB(255, 0, 255, 0);
D3DCOLOR txtBlue = D3DCOLOR_ARGB(255, 0, 0, 255);
D3DCOLOR txtPurple = D3DCOLOR_ARGB(255, 102, 0, 153);
D3DCOLOR txtOrange = D3DCOLOR_ARGB(255, 255, 165, 0);
D3DCOLOR txtWhite = D3DCOLOR_ARGB(255, 255, 255, 255);
D3DCOLOR txtBlack = D3DCOLOR_ARGB(255, 0, 0, 0);
// Texturen
//LPDIRECT3DTEXTURE9 texPink;
//LPDIRECT3DTEXTURE9 texGreen;
//LPDIRECT3DTEXTURE9 texRed;
bool draw = false;
bool godmode = false;
//________________________________________________________//
bool bDataCompare(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 dwFindPattern(DWORD dwAddress,DWORD dwLen,BYTE *bMask,char * szMask)
{
for(DWORD i=0; i < dwLen; i++)
if( bDataCompare( (BYTE*)( dwAddress+i ),bMask,szMask) )
return (DWORD)(dwAddress+i);
return 0;
}
void WriteMem(DWORD dwAdresse, int Wert, int len)
{
unsigned long Protection;
VirtualProtect((void*)dwAdresse, len, PAGE_READWRITE, &Protection);
memset((void*)dwAdresse, Wert, len);
VirtualProtect((void*)dwAdresse, len, Protection, 0);
}
void Rechteck (LPDIRECT3DDEVICE9 Device_t, int X, int Y, int L, int H, D3DCOLOR color)
{
D3DRECT rect = {X, Y, X+L, Y+H};
Device_t->Clear(1, &rect, D3DCLEAR_TARGET, color, 0, 0);
}
void DrawFont (int X, int Y, D3DCOLOR Color, char *format, ...)
{
char buffer[256];
va_list args; // deswegen: #include <cstdio>
va_start (args, format);
vsprintf (buffer,format, args);
RECT FontRect = { X, Y, X + 120, Y + 16 };
g_pFont->DrawText( NULL, buffer, -1, &FontRect, DT_NOCLIP , Color ); // Zeichnen
va_end (args);
}
HRESULT D3DAPI hkReset(IDirect3DDevice9* pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters)
{
return pReset(pDevice, pPresentationParameters);
}
HRESULT WINAPI hkEndScene(LPDIRECT3DDEVICE9 pDevice)
{
_asm pushad
if (draw == true)
{
D3DXCreateFont(pDevice, 14, 0, FW_NORMAL, 1, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,ANTIALIASED_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial", &g_pFont );
Rechteck (pDevice, 5, 15, 140, 210, txtOrange);
Rechteck (pDevice, 10, 20, 130, 200, txtBlack);
DrawFont ( 10, 35, txtWhite, "* * * D3D Hack By Michi * * *" );
DrawFont ( 10, 45, txtWhite, "______________________" );
DrawFont ( 10, 15, txtWhite, "______________________" );
}
if(GetAsyncKeyState(VK_INSERT) &1) // Öffnen mit Einfg
{
draw = !draw; // Ein od. Aus
}
if (godmode == true)
{
DWORD offset = 0x14;
DWORD Base = (DWORD) GetModuleHandleA("server.dll") + 0x0037492C;
DWORD Address = *(DWORD*)(Base) + offset;
WriteMem(Address, 1, 1); // Value der Adresse mit 1 ersetzen
}
else
{
DWORD offset = 0x14;
DWORD Base = (DWORD) GetModuleHandleA("server.dll") + 0x0037492C;
DWORD Address = *(DWORD*)(Base) + offset;
WriteMem(Address, 0, 1); // Value der Adresse auf 0 zurück setzen
}
if(GetAsyncKeyState(VK_NUMPAD1) &1) // Aktivieren mit NUMPAD1
{
godmode = !godmode;
}
_asm popad
return pEndScene(pDevice);
}
void Funktionen()
{
HMODULE hModule = NULL;
while( !hModule )
{
hModule = GetModuleHandleA( "d3d9.dll" );
Sleep( 100 );
}
dwEndScene = (DWORD)hModule + 0x871A0;
DWORD* VTableStart = 0;
DWORD FoundByGordon = dwFindPattern((DWORD)hModule, 0x128000,(PBYTE)"\xC7\x06\x00\x00\x00\x00\x89\x86\x00\x00\x00\x00\x89\x86", "xx????xx????xx");
memcpy(&VTableStart, (void*)(FoundByGordon+2), 4);
dwDrawIndexedPrimitive = (DWORD)VTableStart[82];
dwEndScene = (DWORD)VTableStart[42];
pEndScene = (tEndScene )DetourFunc((PBYTE) dwEndScene ,(PBYTE)hkEndScene, 5);
}
int WINAPI DllMain(HINSTANCE hInst,DWORD reason,LPVOID reserved)
{
switch(reason)
{
case DLL_PROCESS_ATTACH:
MessageBoxA(0, "* * * Coded By Michi * * *", "Injected!", 0);
CreateThread(0, 0, (LPTHREAD_START_ROUTINE) Funktionen, 0, 0, 0);
break;
}
return true;
}
void *DetourFunc(BYTE *src, const BYTE *dst, const int len)
{
BYTE *jmp = (BYTE*)malloc(len+5);
DWORD dwback;
VirtualProtect(src, len, PAGE_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;
VirtualProtect(src, len, dwback, &dwback);
return (jmp-len);
}