简体   繁体   English

如何检查寄存器中存储的值是代码段中的有效地址

[英]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. 如果我搞砸了JbJa术语,则只需切换它们即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 数据如何存储在内存或寄存器中 - How data is stored in memory or register 如何使用C ++代码检查指定的字符串是否为有效的URL - How to check a specified string is a valid URL or not using C++ code 如何在程序中查找数据段和代码段范围 - How to find data segment and code segment range in program 如何批量检查存储在变量中的字符串是否与netstat -nao的IP地址相同 - How to check if a string stored in a variable is the same as an ip address from netstat -nao in batch Windows 文件名 - 如何检查文件名是否有效? - Windows filename - How to check if filename would be valid? 如何在Windows批处理脚本中检查URL是否有效 - How to check if a URL is valid or not in Windows batch script 从地址查找堆或堆块或段 - Finding heap or heap block or segment from address 如何在C ++中返回存储在特定内存地址的变量的名称 - How to return the name of a variable stored at a particular memory address in C++ {"errorMessages":["Unexpected character (''' (code 39)): 期望一个有效值 - {"errorMessages":["Unexpected character (''' (code 39)): expected a valid value 线程fs段寄存器在用户和内核之间切换 - thread fs segment register switching between user and kernel land
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM