Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/305.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在windbg命令行界面中编辑局部变量值?_Python_Windbg - Fatal编程技术网

Python 如何在windbg命令行界面中编辑局部变量值?

Python 如何在windbg命令行界面中编辑局部变量值?,python,windbg,Python,Windbg,我正在将python与windbg集成,我想从脚本中编辑一个局部变量值。为此,我需要知道如何在windbg命令行中编辑局部变量值 我知道我可以通过变量获取值,但如何编辑相同的变量?如下: ???表情 并查阅: 左值=赋值 你可以简单地 ?? <variable name> = <value> 我发表了评论,但评论越来越长,所以我把它作为一个答案发布了出来 当打开函数条目时,不会初始化本地文件。 你什么时候在评估本地市场。 只有在函数范围内进行初始初始化后,对本地的赋值才

我正在将python与windbg集成,我想从脚本中编辑一个局部变量值。为此,我需要知道如何在windbg命令行中编辑局部变量值

我知道我可以通过变量获取值,但如何编辑相同的变量?

如下:

???表情

并查阅:

左值=赋值

你可以简单地

?? <variable name> = <value>

我发表了评论,但评论越来越长,所以我把它作为一个答案发布了出来

当打开函数条目时,不会初始化本地文件。
你什么时候在评估本地市场。 只有在函数范围内进行初始初始化后,对本地的赋值才会生效 在使用之前

<>你可以使用C++表达式计算器根据Sean Cline的建议分配给本地,但是非常重要的是你有精确的位置

假设您有这样的代码

:\>cat localedit.cpp
#include <stdio.h>
int addme(int a , int b) {
    int c = 25; int d = c*3;int e = a*c;int f = d*b;
    return c+d+e+f;
}
void main (void) {
    printf("%d\n" , addme( 50,50));
}
:\>
我们在函数入口

0:000> r @eip
eip=01341000

we can check what is the address of local c 
and may be write there but unless we step until 
01341006 c745fc19000000  mov     dword ptr [ebp-4],19h

what ever we write will be overwritten again 


0:000> ?? &c
int * 0x0026f7a8

0:000> dd 26f7a8 l1
0026f7a8  0135e2b0

0:000> .enable_long_status 1
0:000> ?? c
int 0x135e2b0


0:000> ?? *(int *)&c = 45
int 0x2d
0:000> ?? c
int 0x2d
0:000> dv
              a = 0x32
              b = 0x32
              d = 0
              c = 0x2d
              f = 0x26f7c0
              e = 0x13411bb
0:000> g
5100

你到现在都做了什么?你的代码是什么?假设我点击一个函数,通过使用??XYZ得到变量XYZ的值为1000。现在我想将同一变量编辑为2000,如何在windbg CLI中进行编辑?这可能吗?信不信由你,这很简单:
??XYZ=2000
。在函数输入时,不会初始化本地文件。你什么时候在评估本地市场。只有在函数中发生初始初始化后,才可对本地进行赋值scope@lebellinoz请返回到??变量,并可以突出它。它是一个WEBBG特定表达式而不是一个类型,它是C++表达式计算器,而不是双问题标记。谢谢。这就是我所要寻找的。
0:000> r

localedit!addme:
003d1000 55              push    ebp
0:000> dv
              a = 0n50
              b = 0n50
              d = 0n0
              c = 0n4121264
              f = 0n1308704
              e = 0n4002235
0:000> ?? c
int 0n4121264

0:000> ?? c = 100
int 0n100

0:000> ?? c
int 0n100
0:000> g
5100   <<<<<< see the result is same as executing without modification 

0:000> q
quit:

:\>localedit.exe
5100 <<<<<<<<<<<<<<<<
0:000> uf .
localedit!addme:
01341000 55              push    ebp
01341001 8bec            mov     ebp,esp
01341003 83ec10          sub     esp,10h
01341006 c745fc19000000  mov     dword ptr [ebp-4],19h
0134100d 6b45fc03        imul    eax,dword ptr [ebp-4],3
01341011 8945f8          mov     dword ptr [ebp-8],eax
01341014 8b4d08          mov     ecx,dword ptr [ebp+8]
01341017 0faf4dfc        imul    ecx,dword ptr [ebp-4]
0134101b 894df4          mov     dword ptr [ebp-0Ch],ecx
0134101e 8b55f8          mov     edx,dword ptr [ebp-8]
01341021 0faf550c        imul    edx,dword ptr [ebp+0Ch]
01341025 8955f0          mov     dword ptr [ebp-10h],edx
01341028 8b45fc          mov     eax,dword ptr [ebp-4]
0134102b 0345f8          add     eax,dword ptr [ebp-8]
0134102e 0345f4          add     eax,dword ptr [ebp-0Ch]
01341031 0345f0          add     eax,dword ptr [ebp-10h]
01341034 8be5            mov     esp,ebp
01341036 5d              pop     ebp
01341037 c3              ret
0:000> r @eip
eip=01341000

we can check what is the address of local c 
and may be write there but unless we step until 
01341006 c745fc19000000  mov     dword ptr [ebp-4],19h

what ever we write will be overwritten again 


0:000> ?? &c
int * 0x0026f7a8

0:000> dd 26f7a8 l1
0026f7a8  0135e2b0

0:000> .enable_long_status 1
0:000> ?? c
int 0x135e2b0


0:000> ?? *(int *)&c = 45
int 0x2d
0:000> ?? c
int 0x2d
0:000> dv
              a = 0x32
              b = 0x32
              d = 0
              c = 0x2d
              f = 0x26f7c0
              e = 0x13411bb
0:000> g
5100