我可以在windbg反汇编中看到进程堆的句柄,由Windows(WINDOWS 10)为我的进程分配:
0:000> dt nt!_PEB 0106c000
ntdll!_PEB
+0x000 InheritedAddressSpace : 0 ''
+0x001 ReadImageFileExecOptions : 0 ''
+0x002 BeingDebugged : 0x1 ''
+0x003 BitField : 0x4 ''
+0x003 ImageUsesLargePages : 0y0
+0x003 IsProtectedProcess : 0y0
+0x003 IsImageDynamicallyRelocated : 0y1
+0x003 SkipPatchingUser32Forwarders : 0y0
+0x003 IsPackagedProcess : 0y0
+0x003 IsAppContainer : 0y0
+0x003 IsProtectedProcessLight : 0y0
+0x003 IsLongPathAwareProcess : 0y0
+0x004 Mutant : 0xffffffff Void
+0x008 ImageBaseAddress : 0x00840000 Void
+0x00c Ldr : 0x77a4ebe0 _PEB_LDR_DATA
+0x010 ProcessParameters : 0x03b885e0 _RTL_USER_PROCESS_PARAMETERS
+0x014 SubSystemData : (null)
+0x018 ProcessHeap : 0x03b70000 Void
现在我想检查堆头,并应用dt !_HEAP到ProcessHeap:0x03b70000,但我可以看到我在结果得到完全以无效数据。!heap -s给了我完全不同的堆结果,
LFH Key : 0xd5ec6951
Termination on corruption : ENABLED
Heap Flags Reserv Commit Virt Free List UCR Virt Lock Fast
(k) (k) (k) (k) length blocks cont. heap
-----------------------------------------------------------------------------
05e90000 00000002 1020 4 1020 2 1 1 0 0
00ff0000 00001002 60 4 60 2 1 1 0 0
我明白,必须从这个句柄ProcessHeap : 0x03b70000 Void计算堆头开始的地址,但我不明白它是如何计算的。它不是 va,因为 00840000 + 03b70000 != 05e90000 ,那么如何从堆句柄获取到 _HEAP 结构头的实际地址?