| View previous topic :: View next topic |
| Author |
Message |
dimey Newbie cheater
Reputation: 0
Joined: 11 Aug 2011 Posts: 10
|
Posted: Fri Aug 12, 2011 7:52 am Post subject: help with a conditional jump |
|
|
Hello,
I have some problems with a conditional jump instruction, it seems like it doesn't work (or it doesn't do what i think it does ).
This is the code I can't get working.
| Code: | [ENABLE]
//code from here to '[DISABLE]' will be used to enable the cheat
alloc(newmem,2048) //2kb should be enough
label(returnhere)
label(originalcode)
label(friend)
label(exit)
newmem: //this is allocated memory, you have read,write,execute access
test [eax+F4],0
je friend
originalcode:
sub [eax+0C],edx
friend:
mov eax,[esi+000012FC]
exit:
jmp returnhere
... |
in [eax+F4] there should be a value 0 or 1 but the code always jumps, regardless of the value.
Is it a code problem or could the value be changing right before that code executes?
Thanks
-DiMey
|
|
| Back to top |
|
 |
SwaggaJackin' Master Cheater
Reputation: 2
Joined: 06 Nov 2009 Posts: 312
|
Posted: Fri Aug 12, 2011 7:56 am Post subject: |
|
|
| I'd set a break on 'test [eax+F4],0' and double check that the code isn't always a '1' and isn't setting the zero flag.
|
|
| Back to top |
|
 |
dimey Newbie cheater
Reputation: 0
Joined: 11 Aug 2011 Posts: 10
|
Posted: Fri Aug 12, 2011 8:24 am Post subject: |
|
|
Hi,
I changed the code to this:
| Code: | alloc(newmem,2048) //2kb should be enough
label(returnhere)
label(originalcode)
label(friend)
label(exit)
newmem: //this is allocated memory, you have read,write,execute access
push ebx
mov ebx,[eax+F4]
test ebx,00000001
je friend
originalcode:
sub [eax+0C],edx
friend:
pop ebx
mov eax,[esi+000012FC]
exit:
jmp returnhere
... |
Now it works but I don't understand why.. I set a breakpoint on the test and after the test i have this:
ebx = 0 => zf = 1
ebx = 1 => zf = 0
shouldnt it be the opposite??
i thought the zero flag was set to 1 if they were equal..
Thanks
|
|
| Back to top |
|
 |
mgr.inz.Player I post too much
Reputation: 223
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Fri Aug 12, 2011 8:53 am Post subject: |
|
|
zero flag = 1 , EBX is equal zero? true!
zero flag = 0 , EBX is equal zero? false!
_________________
|
|
| Back to top |
|
 |
dimey Newbie cheater
Reputation: 0
Joined: 11 Aug 2011 Posts: 10
|
Posted: Fri Aug 12, 2011 9:04 am Post subject: |
|
|
oh.. so i don't need the ,00000001 in the test.. it's not comparing the two values.. ops
|
|
| Back to top |
|
 |
mgr.inz.Player I post too much
Reputation: 223
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Fri Aug 12, 2011 9:10 am Post subject: |
|
|
test ebx,1
and ebx,1
What's the difference?
and sets flag and stores result
test sets flag (only)
_________________
|
|
| Back to top |
|
 |
dimey Newbie cheater
Reputation: 0
Joined: 11 Aug 2011 Posts: 10
|
Posted: Fri Aug 12, 2011 9:36 am Post subject: |
|
|
i don't get it.. it does the and between ebx and 1 without storing the result?
if they are equal wouldn't the result of the and be different than 0?
also, in the CE help it says:
| Quote: | TEST EAX,EBX
JE 004822FFh
MOV EAX,EBX
JMP 004822FFh
This little example basically tests two values to see if they are equal, if so the program
will move the value 1 into the Zero Flag (ZF), thus allowing the conditional jump (JE) to
goto a memory location to execute opcodes there.
Now if it wasnt equal, the program will move 0 into ZF, and will skip the JE instruction, then
move the value in the EBX register to the EAX register, forcing to be equal then doing an
unconditional jump (JMP) to the same memory location.
|
here says that if they are equal the zf should be 1, not 0..
|
|
| Back to top |
|
 |
|