NtProtectVirutalMemory 不是 VirtualAlloc 调用的一部分,它是 VirtualProtect 调用的一部分
您可以在分配内存的任何可执行文件上使用此 windbg 条件断点验证 pintool 跟踪
0:000> bl
0 e 7c809af1 0001 (0001) 0:**** kernel32!VirtualAlloc "bp /1 @$ra \"g\";wt"
0:000> $$ break on valloc set a one time condtional break on return address on the stack (condition == keep executing as is) and trace the call
0:000> g
结果
Tracing kernel32!VirtualAlloc to return address 76fdc3ac
9 0 [ 0] kernel32!VirtualAlloc
3 0 [ 1] kernel32!VirtualAllocEx
19 0 [ 2] kernel32!_SEH_prolog
16 19 [ 1] kernel32!VirtualAllocEx
1 0 [ 2] ntdll!ZwAllocateVirtualMemory
2 0 [ 2] ntdll!NtAllocateVirtualMemory
2 0 [ 3] ntdll!KiFastSystemCall
1 0 [ 2] ntdll!NtAllocateVirtualMemory
22 25 [ 1] kernel32!VirtualAllocEx
9 0 [ 2] kernel32!_SEH_epilog
23 34 [ 1] kernel32!VirtualAllocEx
11 57 [ 0] kernel32!VirtualAlloc
68 instructions were executed in 67 events (0 from other threads)
Function Name Invocations MinInst MaxInst AvgInst
kernel32!VirtualAlloc 1 11 11 11
kernel32!VirtualAllocEx 1 23 23 23
kernel32!_SEH_epilog 1 9 9 9
kernel32!_SEH_prolog 1 19 19 19
ntdll!KiFastSystemCall 1 2 2 2
ntdll!NtAllocateVirtualMemory 2 1 2 1
ntdll!ZwAllocateVirtualMemory 1 1 1 1
1 system call was executed
Calls System Call
1 ntdll!KiFastSystemCall
编辑
带有调用堆栈和 esp 的原始双字转储的 VirtualProtect 的跟踪结果
0:001> bl
0 e 7c801ad4 0001 (0001) 0:**** kernel32!VirtualProtect "dd esp l8;kb 3;bp /1 @$ra \"g\";wt"
dd esp l8
009df560 03042c08 00b10000 00002ab0 00000002
009df570 009df588 00000440 00832758 009df54c
KB 3
ChildEBP RetAddr Args to Child
009df55c 03042c08 00b10000 00002ab0 00000002 kernel32!VirtualProtect
009df58c 030420f7 008124b0 0084a610 00832758 dbghelp!idd2me+0x3d8
009dfa3c 03041c5a 00000440 00832758 00832758 dbghelp!modload+0x367
重量
Tracing kernel32!VirtualProtect to return address 03042c08
9 0 [ 0] kernel32!VirtualProtect
14 0 [ 1] kernel32!VirtualProtectEx
1 0 [ 2] ntdll!ZwProtectVirtualMemory
2 0 [ 2] ntdll!NtProtectVirtualMemory
2 0 [ 3] ntdll!KiFastSystemCall
1 0 [ 2] ntdll!NtProtectVirtualMemory
23 6 [ 1] kernel32!VirtualProtectEx
11 29 [ 0] kernel32!VirtualProtect
40 instructions were executed in 39 events (0 from other threads)
Function Name Invocations MinInst MaxInst AvgInst
kernel32!VirtualProtect 1 11 11 11
kernel32!VirtualProtectEx 1 23 23 23
ntdll!KiFastSystemCall 1 2 2 2
ntdll!NtProtectVirtualMemory 2 1 2 1
ntdll!ZwProtectVirtualMemory 1 1 1 1
1 system call was executed
Calls System Call
1 ntdll!KiFastSystemCall