I'm writing a small x86 Assembly program on a Windows machine. At one point I want to check if the value stored in the EDX register is a valid address pointing to the code segment of the same program. Can anyone please tell me how and if this can be done?
At the start of your program, put a label like this...
The_Code_Starts_Here:
At the end of your program, put a label like this...
The_Code_Ends_Here:
In your section where you want to question the validity of that address, do something like this...
Cmp Edx, The_Code_Starts_Here ; Is it in the code segment ?
Jb Bombs_Away ; No, bomb out
Cmp Edx, The_Code_Ends_Here ; Is it in the code segment ?
Jae Bombs_Away ; No, bomb out
; Else, good stuff, go on
If I screwed up on the Jb
and Ja
nomenclature, then just switch them.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.