这不是一个直接的答案,但WinDbg中有一个很好的命令,让你“解密”的答案,大多数这些问题自己命令的名称是.ocommand
显示如何确定用户大小指向使用此命令的示例
#include <stdio.h>
#include <windows.h>
void dbg (PCHAR cmdstr , PVOID value) {
char buff[0x300] = {0};
sprintf_s(buff,cmdstr,value);
OutputDebugStringA(buff);
return ;
}
int main(void) {
printf (
"This is a windbg .ocommand Example\n"
"This command can be leveraged to execute windbg commands \n"
"For example command !heap -p -a is performed on allocated heap\n"
"Output of !heap -p -a <address> can be viewed in windbg \n"
"issue .ocommand myjick in windbg prior to running this exe\n"
"or run this exe with windbg -c \".ocommand myjick\" ocommand.exe\n"
);
HANDLE hHeap = NULL;
if((hHeap = GetProcessHeap() ) != NULL) {
for (int i = 1 ; i< 6; i++) {
PCHAR mem[6] = {0};
if (( mem[i] = (PCHAR)HeapAlloc(hHeap,0,0x101*i) ) != NULL) {
dbg("myjick !heap -p -a %x ;g;\n\n",mem[i]);
}
}
}
return 0; //all the allocated heaps need to be freed
}
上面代码的输出
cdb -c ".ocommand myjick ;g;q" ocommand.exe
0:000> cdb: Reading initial command '.ocommand myjick ;g;q'
Treat output prefixed with 'myjick ' as a command
This is a windbg .ocommand Example
This command can be leveraged to execute windbg commands
For example command !heap -p -a is performed on allocated heap
Output of !heap -p -a <address> can be viewed in windbg
issue .ocommand myjick in windbg prior to running this exe
or run this exe with windbg -c ".ocommand myjick" ocommand.exe
address 001537e8 found in
_HEAP @ 150000
HEAP_ENTRY Size Prev Flags UserPtr UserSize - state
001537e0 0024 0000 [07] 001537e8 00101 - (busy)
address 00153908 found in
_HEAP @ 150000
HEAP_ENTRY Size Prev Flags UserPtr UserSize - state
00153900 0044 0000 [07] 00153908 00202 - (busy)
address 00153b28 found in
_HEAP @ 150000
HEAP_ENTRY Size Prev Flags UserPtr UserSize - state
00153b20 0064 0000 [07] 00153b28 00303 - (busy)
address 00153e48 found in
_HEAP @ 150000
HEAP_ENTRY Size Prev Flags UserPtr UserSize - state
00153e40 0084 0000 [07] 00153e48 00404 - (busy)
address 00154268 found in
_HEAP @ 150000
HEAP_ENTRY Size Prev Flags UserPtr UserSize - state
00154260 00a4 0000 [07] 00154268 00505 - (busy)