读: nt!DbgkCreateThread+0x22a: 856ab86a 399eec000000 cmp dword ptr [esi+0ECh],ebx nt!PsGetProcessDebugPort+0x8: 85514130 8b80ec000000 mov eax,dword ptr [eax+0ECh] nt!DbgkpSetProcessDebugObject+0x8d: 856f7959 83beec00000000 cmp dword ptr [esi+0ECh],0 nt!DbgkpSetProcessDebugObject+0x9d: 856f7969 89beec000000 mov dword ptr [esi+0ECh],edi nt!DbgkpMarkProcessPeb+0x85: 856f6e90 3987ec000000 cmp dword ptr [edi+0ECh],eax nt!DbgkpQueueMessage+0xad: 856f74a7 8b80ec000000 mov eax,dword ptr [eax+0ECh] nt!KiDispatchException+0x1d8: 8550539f 39b0ec000000 cmp dword ptr [eax+0ECh],esi nt!DbgkForwardException+0x49: 8565deac 8b98ec000000 mov ebx,dword ptr [eax+0ECh] nt!PspExitThread+0x2ad: 8569094c 83bfec00000000 cmp dword ptr [edi+0ECh],0 nt!DbgkExitThread+0x28: 856f8cf1 83b9ec00000000 cmp dword ptr [ecx+0ECh],0 nt!PspTerminateAllThreads+0x1dd: 856a7ff4 83bfec00000000 cmp dword ptr [edi+0ECh],0 nt!DbgkExitProcess+0x28: 856f8d63 83b9ec00000000 cmp dword ptr [ecx+0ECh],0 nt!DbgkpCloseObject+0xd6: 856f707f 3998ec000000 cmp dword ptr [eax+0ECh],ebx nt!DbgkpCloseObject+0x119: 856f70c2 3998ec000000 cmp dword ptr [eax+0ECh],ebx nt!DbgkpCloseObject+0x121: 856f70ca 83a0ec00000000 and dword ptr [eax+0ECh],0
写: nt!DbgkpSetProcessDebugObject+0xa3 //和读其中一个重复 nt!DbgkClearProcessDebugObject+0x41: 856d3e84 05ec000000 add eax,0ECh nt!DbgkpCloseObject+0x128 ////和读其中一个重复
至此我们就找到了WIN7下 调试写入DebugPort的内核相关函数。
==========================================================
但是这个时候的函数并不完整,比如在最后HOOK这些函数后,进行调试发现退出时还是会出错,
这个时候在退出调试时再对debugport进行检测 及其对网上现有XP代码中的debugport相关函数的反汇编发下还有如下代码:
nt!PspProcessDelete+0xbc: 840aa771 8db7ec000000 lea esi,[edi+0ECh] nt!DbgkCopyProcessDebugPort+0xf: 84089865 83a0ec00000000 and dword ptr [eax+0ECh],0 nt!DbgkCopyProcessDebugPort+0x1e: 84089874 8b7d0c mov edi,dword ptr [ebp+0Ch] nt!DbgkCopyProcessDebugPort+0x5e: 840898b4 8bbfec000000 mov edi,dword ptr [edi+0ECh] nt!DbgkOpenProcessDebugPort+0x16: 840e4c5e 399fec000000 cmp dword ptr [edi+0ECh],ebx nt!DbgkOpenProcessDebugPort+0x54: 840e4c9c 8bbfec000000 mov edi,dword ptr [edi+0ECh] nt!ObpCloseHandle+0xd1: 8407c13e 3988ec000000 cmp dword ptr [eax+0ECh],ecx nt!ObpCloseHandleTableEntry+0x181: 8407c326 83b8ec00000000 cmp dword ptr [eax+0ECh],0 nt!PsIsProcessBeingDebugged+0x8: 84113a11 83b8ec00000000 cmp dword ptr [eax+0ECh],0 nt!NtQueryInformationProcess+0x91d: 8406f00c 8b81ec000000 mov eax,dword ptr [ecx+0ECh]至于是否完整,这个验证方法只有HOOK以后调试时才能发现,如果发现错误,可以再次监控debugport,通过栈回溯来发现漏掉的函数。