Click here to Skip to main content
13,145,464 members (75,247 online)
Rate this:
Please Sign up or sign in to vote.
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)

__declspec(naked) void ExtractScore(void)
        pop ExtractScoreRetAddr
        mov CurrentScore, edx // EDX its the score.
    // Show the score
    CurrentScore = THE SCORE
        cmp edx, 0x3B9ACA00 // Orginal code after we codecave in it.
        push ExtractScoreRetAddr

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

1 solution

Rate this: bad
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.
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!
I like this response; my 5.
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.170915.1 | Last Updated 8 Aug 2012
Copyright © CodeProject, 1999-2017
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