前文提要:

在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.

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,这样代码再次运行时,将直接实现跳转,略过前面的指令。

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

最新文章

  1. 深入Java虚拟机--判断对象存活状态
  2. 【原】npm 常用命令详解
  3. 消费RabbitMQ时的注意事项,如何禁止大量的消息涌到Consumer
  4. Linux Cmd Tool 系列之—script & scriptreplay
  5. 在线c++编译器(gcc)
  6. 转: VMware 安装mac osx 10.11 安装步骤(一)(from伟东)
  7. Android请求网络权限
  8. jprofiler安装与使用
  9. C++中函数中没写返回值会怎么样?
  10. OpenCV安装要点
  11. UVAlive3713 Astronauts(2-SAT)
  12. jquery 中获取URL参数的方法
  13. iOS开发-FFmpeg深入分析
  14. python 程序中调用go
  15. 如何修改Recovery的字符串资源
  16. day16,模块 , 用户管理系统 , 购物车程序 , 分页显示.
  17. 点云NDT配准方法介绍
  18. jQ如何选中被选中的单选按钮的值
  19. Python数据类型的可变与不可变
  20. python文件处理b模式

热门文章

  1. hook 无限debugger(猿人学第十四题)
  2. 【LeetCode】剑指 Offer 30. 包含min函数的栈
  3. jQuery类库
  4. JAVA中生成随机数Random VS ThreadLocalRandom性能比较
  5. Python + logging 控制台有日志输出,但日志文件中数据为空
  6. 浅谈 C++ 模板 & 泛化 (妈妈再也不用担心我不会用 std::sort 了)
  7. [编程基础] C++多线程入门3-小心地将参数传递给线程
  8. 记一个难以发现的 UB
  9. 从0开始学Java 第一期 开发前的准备
  10. vue构建打包兼容操作(vue代码规范建议)-转载Vuejs项目不改动一行代码同时支持用Rollup,vue-cli,parcel构建的一些建议