Ok, my DLL code looks like this:
Code:
#include <windows.h>
#include <iostream>
(PBYTE)xEndScene);
bool DetourFunc( BYTE* oldFunc, BYTE* newFunc, DWORD len )
{
BYTE* newMem4base = NULL;
DWORD dwOld;
newMem4base = ( BYTE* )malloc( 5+len );
if( newMem4base == NULL )
return false;
for( DWORD i = 0; i < ( len+5 ); i++ )
newMem4base[i] = 0x90;
VirtualProtect( oldFunc, len, PAGE_READWRITE, &dwOld );
memcpy( newMem4base, oldFunc, len );
oldFunc[0] = 0xE8;
*( DWORD* )( oldFunc+0x01 ) = DWORD( newFunc-oldFunc-5 );
oldFunc[5] = 0xE9;
*( DWORD* )( oldFunc+0x06 ) = DWORD( newMem4base-( oldFunc+0x5 )-5 );
newMem4base += len;
newMem4base[0] = 0xE9;
*( DWORD* )( newMem4base+0x01 ) = DWORD( ( oldFunc+10 )-newMem4base-5 );
for( DWORD i = 10; i <len; i++ )
oldFunc[i] = 0x90;
return true;
}
void xEndScene(void)
{
//Code Here?
}
DWORD WINAPI Thread( LPVOID lpParam )
{
DetourFunc( ( BYTE* )0x01031470, ( BYTE* )&xEndScene, 10);
return 0;
}
BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved )
{
if( ul_reason_for_call == DLL_PROCESS_ATTACH )
{
HANDLE hThread = CreateThread( NULL, 0, Thread, NULL, 0, NULL );
CloseHandle( hThread );
}
return TRUE;
}
For the Draw function i foud this code(But cant compile(Problem with RGBA color and arguments):
Code:
#include <iostream>
#include <windows.h>
typedef void* (*GetFontType_)(char* FontName, int Unknown1);
GetFontType_ GetFontType = (GetFontType_)0x505670;
typedef int (*DrawEngineText_)(char* Text, int Unknown1, void* Font, float X, float Y, float Unknown2, float Unknown3, float Unknown4, RGBA_COLOR* Color, int Unknown5);
DrawEngineText_ DrawEngineText = (DrawEngineText_)0x509D80;
struct RGBA_COLOR
{
float r, g, b, a;
};
void DrawTextWithEngine(float x, float y, RGBA_COLOR* Color, const char* Text, ...)
{
void* Font = GetFontType( "fonts/smalldevfont", 0 );
char buf[300] = "";
va_list va_alist;
va_start(va_alist,Text);
vsnprintf(buf,sizeof(buf),Text,va_alist);
va_end(va_alist);
DrawEngineText(buf,0x7FFFFFFF,Font,x,y,1.0f,1.0f,0.0f,Color,0);
}
But i am a little helpless now. I don't know what to next.