Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
3.50/5 (4 votes)
See more:
So, I have code in naked function.
and its can show me value from the game inside ..
Its just take the varible, the score in game.
and put it in C++ global varible ..

I wanna change this score .
and I tried to change the function itself.
But the game its crashing .. (Codecave)

CSS
__declspec(naked) void ExtractScore(void)
{
    __asm
    {
        pop ExtractScoreRetAddr
        mov CurrentScore, edx // EDX its the score.
        pushad
        pushfd
    }

    // Show the score
    CurrentScore = THE SCORE

    __asm
    {
        popfd
        popad
        cmp edx, 0x3B9ACA00 // Orginal code after we codecave in it.
        push ExtractScoreRetAddr
        ret
    }
}


So, how we can edit it ?
I tried to move to edx, or add him ..
But noting .. (the game is crashing)

Btw ..
cmp edx, 0x3B9ACA00

its 7 Bytes .
Posted
Comments
Richard MacCutchan 8-Aug-12 8:11am    
A common consequence of hacking, I'm afraid.

1 solution

I guess you put a jmp somewhere that jumps to your function and the "cmp edx, 0x3B9ACA00" is the instruction that was replaced with your jump. You should have the address of the code that follows your hook jump instruction, either in a global variable or as a constant like 0xBEEFBEEF.
First, you shouldnt pop anything at the beginning of your function, so pop ExtractScoreRetAddr is totally unnecessary (one of the reasons fro crashing. Second, before return you should push the global variable or constant that is the address of the code after your inserted hook jmp instruction.

EDIT: If you want to edit the score from C++ then assign a value to the CurrentScore between the 2 asm blocks and then in the second asm block "move edx, dword [CurrentScore]" after popfd and popad.
 
Share this answer
 
v2
Comments
Id0Hadar 8-Aug-12 9:49am    
Can you show me example .. -.- ?
Its now not crahing the game, but not working ..
pasztorpisti 8-Aug-12 10:02am    
Its not my game, its not my hack code, how to show you an example? Why don't you use a debugger to find out what the problem is?
pasztorpisti 8-Aug-12 10:26am    
Forgot to mention, if you used a call instruction instead of a jmp to hijack the code to your function then you need neither the first pop, nor the last push!
Sergey Alexandrovich Kryukov 8-Aug-12 18:50pm    
I like this response; my 5.
--SA
pasztorpisti 8-Aug-12 18:54pm    
Thank you!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900