Storing the result of .dvalloc to a variable

大憨熊 提交于 2020-06-16 05:06:07

问题


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

I mean the start address of allocated memory


回答1:


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

Store it manually

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

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

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


来源:https://stackoverflow.com/questions/39559127/storing-the-result-of-dvalloc-to-a-variable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!