将 .dvalloc 的结果存储到变量中 [英] Storing the result of .dvalloc to a variable

查看:23
本文介绍了将 .dvalloc 的结果存储到变量中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将 .dvalloc 的结果存储到一个变量中?

Is it possible to store the result of .dvalloc to a variable?

我的意思是分配内存的起始地址

I mean the start address of allocated memory

推荐答案

我不认为在单个命令中很容易实现,所以所有选项都有点讨厌:

I don't think it's easily possible in a single command, so all options are kind of nasty:

优点:易于理解.使用复制/粘贴(右击复制,右击粘贴BTW)

Pro: easy to understand. Use copy/paste (right click to copy, right click to paste BTW)

0:000> .dvalloc 100000
Allocated 100000 bytes starting at 00000000`00290000
0:000> r $t9 = 00000000`00290000
0:000> ? $t9
Evaluate expression: 2686976 = 00000000`00290000

使用 WinDbg 脚本

专家:没有错别字.很好用,例如来自 .cmdtree 如果你只需要一些内存.

Use a WinDbg script

Pro: no typos. Nice to use e.g. from a .cmdtree if you just need some memory once.

0:000> .foreach /pS 5 (addr {.dvalloc 100000}) {r $t8=${addr}}
0:000> ? $t8
Evaluate expression: 6881280 = 00000000`00690000

你也可以定义一个别名来代替寄存器

Instead of a register you could also define an alias

0:000> as /c memory .foreach /pS 5 (addr {.dvalloc 100000}) {.echo ${addr}}
0:000> ? memory
Evaluate expression: 12124160 = 00000000`00b90000

先存储地址,然后在.dvalloc中使用

这种方法的缺点:您需要知道地址是否未使用.

Store the address first, then use it in .dvalloc

Downside of this approach: you need to know if the address is unused.

0:000> r $t7=01000000; .dvalloc /b $t7 100000
Allocated 100000 bytes starting at 00000000`01000000
0:000> ? $t7
Evaluate expression: 16777216 = 00000000`01000000

这篇关于将 .dvalloc 的结果存储到变量中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆