使用 windows 调试器查看用 C 语言写入的内存位置?
using windows debugger to view a memory location written to in C?
我有 Turbo C 和 windows 在 dosbox 中调试 运行ning
我有这个C程序,它有两条主线,如你所见。 int a=5
然后一行显示a的地址,printf("address of a=%x",&a)
我运行它
好像告诉我a已经分配到了fff4的地址
现在我想使用调试希望在该内存地址看到 5 的值
但是没有显示
如何在调试中看到它?
这是编译后的 main
函数的 DEBUG 输出:
16E1:01FA 55 PUSH BP
16E1:01FB 8BEC MOV BP,SP
16E1:01FD 83EC02 SUB SP,+02
16E1:0200 C746FE0500 MOV WORD PTR [BP-02],0005
16E1:0205 8D46FE LEA AX,[BP-02]
16E1:0208 50 PUSH AX
16E1:0209 B89401 MOV AX,0194
16E1:020C 50 PUSH AX
16E1:020D E8AA06 CALL 08BA
16E1:0210 59 POP CX
16E1:0211 59 POP CX
16E1:0212 8BE5 MOV SP,BP
16E1:0214 5D POP BP
16E1:0215 C3 RET
int a=5;
是函数 main
中的一个 local 变量,存储在堆栈 (MOV WORD PTR [BP-02],0005
) 中。当您离开函数 (RET
) 时,堆栈上的值会丢失。你在 运行 程序之外看不到它。
如果你
你的计划会很顺利
- 初始化一个全局变量并
- 制作一个微型 .com 程序。
simplepr.c:
#include <stdio.h>
int a=5;
void main()
{
printf ("address of a=%x",&a);
}
编译:
TCC.EXE -mt -lt simplepr.c
调试会话:
n simplepr.com
l
g -> address of a=125c (example)
d 125c -> or what the address is
我有 Turbo C 和 windows 在 dosbox 中调试 运行ning
我有这个C程序,它有两条主线,如你所见。 int a=5
然后一行显示a的地址,printf("address of a=%x",&a)
我运行它
好像告诉我a已经分配到了fff4的地址
现在我想使用调试希望在该内存地址看到 5 的值
但是没有显示
如何在调试中看到它?
这是编译后的 main
函数的 DEBUG 输出:
16E1:01FA 55 PUSH BP
16E1:01FB 8BEC MOV BP,SP
16E1:01FD 83EC02 SUB SP,+02
16E1:0200 C746FE0500 MOV WORD PTR [BP-02],0005
16E1:0205 8D46FE LEA AX,[BP-02]
16E1:0208 50 PUSH AX
16E1:0209 B89401 MOV AX,0194
16E1:020C 50 PUSH AX
16E1:020D E8AA06 CALL 08BA
16E1:0210 59 POP CX
16E1:0211 59 POP CX
16E1:0212 8BE5 MOV SP,BP
16E1:0214 5D POP BP
16E1:0215 C3 RET
int a=5;
是函数 main
中的一个 local 变量,存储在堆栈 (MOV WORD PTR [BP-02],0005
) 中。当您离开函数 (RET
) 时,堆栈上的值会丢失。你在 运行 程序之外看不到它。
如果你
你的计划会很顺利- 初始化一个全局变量并
- 制作一个微型 .com 程序。
simplepr.c:
#include <stdio.h>
int a=5;
void main()
{
printf ("address of a=%x",&a);
}
编译:
TCC.EXE -mt -lt simplepr.c
调试会话:
n simplepr.com
l
g -> address of a=125c (example)
d 125c -> or what the address is