Click here to Skip to main content
11,490,973 members (62,727 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ ASM
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)

__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 8-Aug-12 2:33am
Comments
Richard MacCutchan at 8-Aug-12 8:11am
   
A common consequence of hacking, I'm afraid.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
v2
Comments
Id0Hadar at 8-Aug-12 9:49am
   
Can you show me example .. -.- ?
Its now not crahing the game, but not working ..
pasztorpisti at 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 at 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 at 8-Aug-12 18:50pm
   
I like this response; my 5.
--SA
pasztorpisti at 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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 521
1 Andy Lanng 288
2 Sascha Lefèvre 240
3 Maciej Los 195
4 OriginalGriff 163
0 Sergey Alexandrovich Kryukov 9,829
1 OriginalGriff 8,520
2 Sascha Lefèvre 3,574
3 Maciej Los 3,151
4 Richard Deeming 2,370


Advertise | Privacy | Mobile
Web01 | 2.8.150520.1 | Last Updated 8 Aug 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100