首页 > 编程语言 >如何在VC++ 6.0中实现拖动指令改变执行路径?

如何在VC++ 6.0中实现拖动指令改变执行路径?

时间:2023-02-24 13:13:01浏览次数:40  
标签:EIP code run VC6 拖动 C++ next statement 6.0

前文提要:

在VC6.0之后出现的VS系列开发工具都具有的调试功能:移动指针更改执行流,VC6不支持这个UI操作。

调试程序暂停时,源代码或“反汇编”窗口边距处的黄色箭头标记要运行的下一条语句的位置。 你可以通过移动此箭头来更改要运行的下一条语句。 你可以跳过代码,或者返回上一行。 在某些情况下移动指针很有用,例如,跳过包含已知 bug 的代码。

突发在奇想之后,想到了改变寄存器EIP的值来实现,下面这段英文介绍了什么是改变执行流,文尾给出VC6环境下如何实现。


Move the pointer to change the execution flow

When the debugger is paused, a yellow arrow in the margin of the source code or Disassembly window marks the location of the statement that will run next. You can change the next statement that will run by moving this arrow. You can skip over code or return to a previous line. Moving the pointer is useful for situations like skipping code that contains a known bug.

Animation that shows how to move the pointer.

If you want to change the next statement that will run, the debugger must be in break mode. In the source code or Disassembly window, drag the yellow arrow to a different line, or right-click the line you want to run next and select Set Next Statement.

The program counter jumps directly to the new location. Instructions between the old and new execution points aren't run. But if you move the execution point backwards, the intervening instructions aren't undone.

 Caution

  • Moving the next statement to another function or scope usually causes call-stack corruption, which causes a runtime error or exception. If you try to move the next statement to another scope, the debugger gives you a warning and a chance to cancel the operation.
  • In Visual Basic, you can't move the next statement to another scope or function.
  • In native C++, if you have runtime checks enabled, setting the next statement can cause an exception when execution reaches the end of the method.
  • When Edit and Continue is enabled, Set Next Statement fails if you've made edits that Edit and Continue can't remap immediately. This situation can occur, for example, if you've edited code in a catch block. When this happens, an error message tells you that the operation isn't supported.
  • In managed code, you can't move the next statement if:
    • The next statement is in a different method than the current statement.
    • Debugging was started by Just-In-Time debugging.
    • A call stack unwind is in progress.
    • A System.StackOverflowException or System.Threading.ThreadAbortException exception has been thrown.

熟悉Visual Studio开发工具的朋友们都已经习惯在调试代码时,通过拖动指令光标位置实现代码指令跳转(跳过某些不想要的条件判断),此功能比单步执行要灵活许多。

碰到手里还有VC6的老C++项目时,突然没有这个功能,非常不适应,在Google还未退出中国时就想过这个问题,水平有限也没有搜到解决办法。

就在昨天,想到了一招直接手动修改EIP指令来实现,简单介绍一下 VC6环境修改CPU寄存器的两种方法,也许对一部分朋友还是有些帮助的。

下面是VC6的环境示意图:

图中分别列出了源代码与反汇编代码窗体,同时也列出了寄存器窗口与右下角的变量观察辅助对话框

我们可以直接点击寄存器窗体中的 EIP 寄存器变量值的位置(不要双击,在要修改的位置前面单击即可)或是在变量观察对话框中双击value部分

需要注意:变量观察名子输入的是 EIP ,实际情况是需要输入@EIP的,这样不会与本地同名变量起冲突的

我们看到源码中当前指令执行到0X00A70B5E,同时EIP的值也是这个,我可改变它为:00A70B77,这样代码再次运行时,将直接实现跳转,略过前面的IF判断指令。

曲线实现了【移动指针更改执行流】,前面有英文注解, 需要注意的条件 :)

标签:EIP,code,run,VC6,拖动,C++,next,statement,6.0
From: https://www.cnblogs.com/ioriwellings/p/17151040.html

相关文章

  • c++中具有继承关系的隐式转换问题
    起因是群里有人问:   2,3,4是为什么。解答:2:2是因为B中的show(A)才是多态,Aa2=newB(),此时a2只有show(A)的多态,而面对的类型切割问题,在编译的时候派生类会将基类的多......
  • 使用C++实现Modbus CRC16检验相关内容
    使用C++实现ModbusCRC16检验相关内容ModbusCRC-16校验代码以下为ModbusCRC-16校验代码函数:其中参数int*crc_sum为校验返回值,分为两个字节;参数int*data_blk_ptr......
  • C++ primer 5th 第二章 变量和基本类型 阅读笔记
    第二章变量和基本类型第一节基本内置类型C++标准规定了算术类型尺寸的最小值,同时允许编译器赋予这些类型更大的尺寸。比如:类型含义最小尺寸bool布尔类型......
  • C++的内存模型
    C++的内存包含4个大区,它们分别是代码区、全局区、栈区和堆区。以下将对它们的分区进行进一步的阐述。代码区:对于一段代码,首先要经过编译之后生成可执行文件才能执行,在Wi......
  • C++学习(2)STL八股文
    1、STL实现原理及其实现STL提供了六⼤组件,彼此之间可以组合套⽤,这六⼤组件分别是:容器、算法、迭代器、仿函数、适配器(配接器)、空间配置器。STL六⼤组件的交互关系:a.容......
  • C++问题集
    const函数名后,加const使类的成员函数,不能修改类内成员。mutable可以突破const限制!在函数后面加const只能在类的成员函数中实现!普通的函数是无法进行这样的操作的!vo......
  • C/C++图书管理系统[2023-02-23]
    C/C++图书管理系统[2023-02-23](辅修)高级语言程序设计课程设计图书管理系统设计并实现一个学校图书馆的图书管理系统。具体要求:1、 图书信息和借阅信息等保存在文本文......
  • C++主函数参数
    学习C++主函数的参数输入,用于从commandline中读取参数,下面以读取视频文件为例进行说明#include<iostream>#include<fstream>#include<string>#include<opencv2/op......
  • C/C++宠物信息管理系统[2023-02-23]
    C/C++宠物信息管理系统[2023-02-23]计算机科学与技术专业课程设计任务书学生姓名专业班级学号题目宠物信息管理系统主要内容开发一个简单的宠物信息管理系统。要......
  • MongoDB 6.0.4 安装记录
    须知:版本号x.y.z,看y:偶数版为稳定版,奇数版为开发版(1)下载zip,解压1https://fastdl.mongodb.org/windows/mongodb-windows-x86_64-6.0.4.zip建立data文件夹,与bin同......