What would be the ASM code for the following:

IF jump came from a specific address

THEN execute the following instruction
ELSE continue


Thanks in advance!
Posted on 2004-08-27 09:29:52 by Talmar
1) Set the flags using cmp/test/and/etc
2) Use jxx (such as jnz,jz,jg,jc,jnc etc)
3) Throw in some jmp to make it jump the way it should be

Take a look at my article http://www.win32asmcommunity.net/phpwiki/index.php/ConditionalStatements
Posted on 2004-08-27 09:33:28 by roticv
Also check out the MASM reference to:

.if
.elseif
.else
.endif

Plus also check out:

.repeat
.while
.break
.continue

Regards, P1 8)
Posted on 2004-08-27 09:39:05 by Pone
Don't lead the poor soul astray. At least let him understand how to create conditional statements himself in assembly.
Posted on 2004-08-27 09:47:19 by roticv
On the Pentium Pro and Pentium II, you can put 1DBh in ECX and execute the RDMSR instruction to determine where the last branch occurred. However, it's not very useful to application programs since they can be interrupted at any time.


mov ecx,1DBh
rdmsr
cmp eax,Some_Address
jnz nope
; Some instruction
nope:
Posted on 2004-08-27 10:05:15 by Sephiroth3
On the Pentium Pro and Pentium II, you can put 1DBh in ECX and execute the RDMSR instruction to determine where the last branch occurred. However, it's not very useful to application programs since they can be interrupted at any time.


mov ecx,1DBh
rdmsr
cmp eax,Some_Address
jnz nope
; Some instruction
nope:


also, this is a privileged instruction @ ring3 under NT (at least, under XP)
Posted on 2004-08-27 12:42:16 by lifewire
I need assistance with the IF, THEN, ELSE commands in ASM. I would like to modify existing code to produce the following result:
0024AFB2   8B8C24 94000000  MOV ECX,DWORD PTR SS:[ESP+94]

0024AFB9 8B86 AC000000 MOV EAX,DWORD PTR DS:[ESI+AC]
0024AFBF 3B81 AC000000 CMP EAX,DWORD PTR DS:[ECX+AC]
0024AFC5 0F85 23030000 JNZ 0024B2EE <- Jump Origin
0024AFCB 48 DEC EAX <- Desired Return


0024B2EE 8B4C24 30 MOV ECX,DWORD PTR SS:[ESP+30] <- Jump Destination
0024B2F2 8B01 MOV EAX,DWORD PTR DS:[ECX]
0024B2F4 8B9424 A8000000 MOV EDX,DWORD PTR SS:[ESP+A8] <- Return from Code Cave
0024B2FB 3B42 04 CMP EAX,DWORD PTR DS:[EDX+4]


0024B2EE IF JUMP TO HERE ORIGINATED FROM 0024AFC5, THEN <- Desired Command
GOTO 0024AFCB, ELSE GOTO 006A2B20


006A2B20 8B4C24 30 MOV ECX,DWORD PTR SS:[ESP+30] <- Code Cave used for Op Code Balancing
006A2B24 8B01 MOV EAX,DWORD PTR DS:[ECX]
006A2B26 JMP 0024B2F4 <- Return to original process

Thanks in advance.
Posted on 2004-11-02 19:09:57 by Talmar
Hmm... what is your goal again?
The intention might be in violation of the forum rules.
Before the moderator(s) lock it, you'd better read the rules and make your intention clear. :)

Besides, why don't you click on the link in the first reply and read it? There's the answer already.
Posted on 2004-11-02 23:08:09 by Starless
Hmm... what is your goal again?
The intention might be in violation of the forum rules.
Before the moderator(s) lock it, you'd better read the rules and make your intention clear. :)

I have read the rules and my intention does not seem to violate them, which is to create a Game Trainer.
Posted on 2004-11-03 12:28:41 by Talmar
Making unautorized changes to somebody else's applications... including games... is not ok with the rules of this forum.

Take care....
Posted on 2004-11-03 14:14:35 by BogdanOntanu
*Cough* You sure you want to code a trainer when you do not know what you are doing?
Posted on 2004-11-03 20:37:38 by roticv