Deprecated: The behavior of unparenthesized expressions containing both '.' and '+'/'-' will change in PHP 8: '+'/'-' will take a higher precedence in /home/iano/public_html/tpforums-vb5/forum/includes/class_core.php on line 5842

PHP Warning: Use of undefined constant MYSQL_NUM - assumed 'MYSQL_NUM' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_ASSOC - assumed 'MYSQL_ASSOC' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_BOTH - assumed 'MYSQL_BOTH' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 588

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 612

PHP Warning: Use of undefined constant archive_postsperpage - assumed 'archive_postsperpage' (this will throw an Error in a future version of PHP) in ..../archive/index.php on line 456
Hook PrintFps [Archive] - Forums

PDA

View Full Version : Hook PrintFps



wgrzelak
03-03-2015, 05:58 PM
Well I have problem with hooking PrintFps function. I don't know how to catch all arguments like position X, also I can modify orginal fps but when I call more than one PrintText() is not working.



void MyPrintFps(int nY, int nFont, int nRed, int nGreen, int nBlue, char* lpText, int nSurface, int unk/* test next arg */) //10.76
{
typedef void _PrintText(int nY, int nFont, int nRed, int nGreen, int nBlue, char* lpText, int nSurface);
static _PrintText *PrintText = (_PrintText*)(PrintName + Addresses::GetProcessImageBase());

nY = 50;
//nFont = 3;
lpText = "Tpforums";
nRed = 60, nGreen = 226, nBlue = 34;


PrintText(nY, nFont, nRed, nGreen, nBlue, lpText, nSurface);
PrintText(0, 2, nRed, nGreen, nBlue, "Test", nSurface); //not working


Console::cout() << nY << Console::endl();
Console::cout() << nFont << Console::endl();
Console::cout() << nRed << Console::endl();
Console::cout() << nGreen << Console::endl();
Console::cout() << nBlue << Console::endl();
Console::cout() << lpText << Console::endl();
Console::cout() << nSurface << Console::endl();
Console::cout() << unk << Console::endl(); //checking next arg
Console::cout() << "------------------------" << Console::endl();
}
HookCall((DWORD)(PrintFps + Addresses::GetProcessImageBase()), (DWORD)&MyPrintFps);


Screen:
http://i58.tinypic.com/34hj4u0.png

there is unk = -923413 so I think so there is no more arguments.

wgrzelak
03-03-2015, 10:40 PM
Just need to add __fastcall and working (catch int nSurface, int nX from register)



void __fastcall MyPrintFps(int nSurface, int nX, int nY, int nFont, int nRed, int nGreen, int nBlue, char* lpText, int nAlign) //10.76

---------------------------------------------------------------------------------------------------------------------
still another problem, print is working but I get error with calling convention

Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.

PrintText function...


typedef void __fastcall _PrintText(int nSurface, int nX, int nY, int nFont, int nRed, int nGreen, int nBlue, char* lpText, int nAlign);
static _PrintText *PrintText = (_PrintText*)original;
PrintText(nSurface, nX, nY, nFont, nRed, nGreen, nBlue, lpText, nAlign);

ottizy
03-03-2015, 11:02 PM
int x = 0;
int surface = 0;

__asm{
MOV x, EDX
MOV surface, ECX
}


Edit, too late :p

wgrzelak
03-03-2015, 11:51 PM
int x = 0;
int surface = 0;

__asm{
MOV x, EDX
MOV surface, ECX
}


Edit, too late :p

ottizy, I saw your solution and I have no idea why but ECX = 0 when it's = 1.

like


void MyPrintFps(/*int nSurface, int nX,*/ int nY, int nFont, int nRed, int nGreen, int nBlue, char* lpText, int nAlign) //10.76
{
int nSurface;
int nX;
__asm
{
mov nX, edx
mov nSurface, ecx
}
//ecx = 0 and client will crash
PrintText(nSurface, nX, nY, nFont, nRed, nGreen, nBlue, lpText, nAlign);
}

but that is not important because with _fastcall is working great. Still have error when call PrintText() try calling any convention (stdcall, cdecl, fastcall, thiscall) and still problem, only _fastcall without crash but with error as above.

Edit, fastcall conversion in asm, working but still problem with esp :(


_asm
{
push nAlign
push lpText
push nBlue
push nGreen
push nRed
push nFont
push nY
mov edx, nX
mov ecx, 1
//add esp, 0x1c //7*4
call original
}


Edit, I got it working just I was making mistake because I was add esp before call function...so noob :P