[英]How to check that value stored in register is a valid address in the code segment
I'm writing a small x86 Assembly program on a Windows machine. 我正在Windows机器上编写一个小的x86 Assembly程序。 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.
一方面,我想检查存储在EDX寄存器中的值是否是指向同一程序的代码段的有效地址。 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. 如果我搞砸了
Jb
和Ja
术语,则只需切换它们即可。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.