驱动编程学习六 ReadProcessMemory(x,x,x,x,x) 进入内核情况分析

(15条消息) KiFastCallEntry() 机制分析_wupangzi的博客-CSDN博客

三、系统调用 - 腾讯云开发者社区-腾讯云 (tencent.com)

一、查看  _KUSER_SHARED_DATA    结构

 1、显示所有进程 :    kd> !process 0 0

 2、选一个进程的地址

PROCESS 89d2f020 SessionId: 0 Cid: 0740 Peb: 7ffd8000 ParentCid: 0698
DirBase: 0aac0360 ObjectTable: e2216bb0 HandleCount: 61.
Image: Dbgview_chx32.exe

3、挂靠进程:  kd> .process 89d2f020

0: kd> .process 89d2f020
Implicit process is now 89d2f020
WARNING: .cache forcedecodeuser is not enabled

4、查看结构

0: kd> dt _KUSER_SHARED_DATA 7FFE0000
ntdll!_KUSER_SHARED_DATA
+0x000 TickCountLow : 0x17bb
+0x004 TickCountMultiplier : 0xfa00000
+0x008 InterruptTime : _KSYSTEM_TIME
+0x014 SystemTime : _KSYSTEM_TIME
+0x020 TimeZoneBias : _KSYSTEM_TIME
+0x02c ImageNumberLow : 0x14c
+0x02e ImageNumberHigh : 0x14c
+0x030 NtSystemRoot : [260] 0x43
+0x238 MaxStackTraceDepth : 0
+0x23c CryptoExponent : 0
+0x240 TimeZoneId : 0
+0x244 Reserved2 : [8] 0
+0x264 NtProductType : 1 ( NtProductWinNt )
+0x268 ProductTypeIsValid : 0x1 ''
+0x26c NtMajorVersion : 5
+0x270 NtMinorVersion : 1
+0x274 ProcessorFeatures : [64] ""
+0x2b4 Reserved1 : 0x7ffeffff
+0x2b8 Reserved3 : 0x80000000
+0x2bc TimeSlip : 0
+0x2c0 AlternativeArchitecture : 0 ( StandardDesign )
+0x2c8 SystemExpirationDate : _LARGE_INTEGER 0x0
+0x2d0 SuiteMask : 0x110
+0x2d4 KdDebuggerEnabled : 0x3 ''
+0x2d5 NXSupportPolicy : 0x2 ''
+0x2d8 ActiveConsoleId : 0
+0x2dc DismountCount : 0
+0x2e0 ComPlusPackage : 0xffffffff
+0x2e4 LastSystemRITEventTickCount : 0x12517
+0x2e8 NumberOfPhysicalPages : 0xbff7a
+0x2ec SafeBootMode : 0 ''
+0x2f0 TraceLogging : 0
+0x2f8 TestRetInstruction : 0xc3
+0x300 SystemCall : 0x7c92e4f0       NtReadVirtualMemory(x,x,x,x,x)   这个函数调用的是这个位置的函数   mov     edx, 7FFE0300h
+0x304 SystemCallReturn : 0x7c92e4f4
+0x308 SystemCallPad : [3] 0
+0x320 TickCount : _KSYSTEM_TIME
+0x320 TickCountQuad : 0
+0x330 Cookie : 0xdf7e46a9

5、进入内核的地方

kd> uf 0x7c92e4f0
ntdll!KiFastSystemCall:      通过这个函数  快速调用 进入内核              
7c92e4f0 8bd4 mov edx,esp
7c92e4f2 0f34 sysenter         //sysenter/sysexit 原理 - 腾讯云开发者社区-腾讯云 (tencent.com)        //SYSENTER-HOOK 技术分析_函数 (sohu.com)
7c92e4f4 c3 ret

快速调用  MSR

0: kd> rdmsr 174
msr[174] = 00000000`00000008     cs
0: kd> rdmsr 175
msr[175] = 00000000`bacd0000            esp
0: kd> rdmsr 176
msr[176] = 00000000`80542520    eip

kd> u 80542520
nt!KiFastCallEntry:
80542520 b923000000 mov ecx,23h
80542525 6a30 push 30h
80542527 0fa1 pop fs
80542529 8ed9 mov ds,cx
8054252b 8ec1 mov es,cx
8054252d 648b0d40000000 mov ecx,dword ptr fs:[40h]
80542534 8b6104 mov esp,dword ptr [ecx+4]
80542537 6a23 push 23h

 

如果不是快速调用:KiIntSystemCall() .text 000000007C92E500 00000007 00000000 00000005 R . . . . . T .

 kd> dt _ktrap_frame
ntdll!_KTRAP_FRAME
   +0x000 DbgEbp           : Uint4B
   +0x004 DbgEip           : Uint4B
   +0x008 DbgArgMark       : Uint4B
   +0x00c DbgArgPointer    : Uint4B
   +0x010 TempSegCs        : Uint4B
   +0x014 TempEsp          : Uint4B
   +0x018 Dr0              : Uint4B
   +0x01c Dr1              : Uint4B
   +0x020 Dr2              : Uint4B
   +0x024 Dr3              : Uint4B
   +0x028 Dr6              : Uint4B
   +0x02c Dr7              : Uint4B
   +0x030 SegGs            : Uint4B
   +0x034 SegEs            : Uint4B
   +0x038 SegDs            : Uint4B
   +0x03c Edx              : Uint4B
   +0x040 Ecx              : Uint4B
   +0x044 Eax              : Uint4B
   +0x048 PreviousPreviousMode : Uint4B
   +0x04c ExceptionList    : Ptr32 _EXCEPTION_REGISTRATION_RECORD
   +0x050 SegFs            : Uint4B
   +0x054 Edi              : Uint4B
   +0x058 Esi              : Uint4B
   +0x05c Ebx              : Uint4B
   +0x060 Ebp              : Uint4B
   +0x064 ErrCode          : Uint4B   这里往下是 cpu填充的  往上是 操作系统 填充的
   +0x068 Eip              : Uint4B
   +0x06c SegCs            : Uint4B
   +0x070 EFlags           : Uint4B
   +0x074 HardwareEsp      : Uint4B
   +0x078 HardwareSegSs    : Uint4B
   +0x07c V86Es            : Uint4B
   +0x080 V86Ds            : Uint4B
   +0x084 V86Fs            : Uint4B
   +0x088 V86Gs            : Uint4B

 

kd> !vtop 0aac0360 0x7ffe0000
X86VtoP: Virt 7ffe0000, pagedir aac0360
X86VtoP: PAE PDPE aac0368 - 0000000017ee0801
X86VtoP: PAE PDE 17ee0ff8 - 0000000018300867
X86VtoP: PAE PTE 18300f00 - 0000000000041025  //1000001000000100101 在R3  第二位 R/W=0 只读的
X86VtoP: PAE Mapped phys 41000
Virtual address 7ffe0000 translates to physical address 41000.
0: kd> !vtop 0aac0360 0x7ffdf0000
X86VtoP: Virt ffdf0000, pagedir aac0360
X86VtoP: PAE PDPE aac0378 - 0000000017e5e801
X86VtoP: PAE PDE 17e5eff0 - 0000000000b1e163
X86VtoP: PAE PTE b1ef80 - 0000000000041163   //1000001000101100011 在R0  第二位 R/W = 1 可读可写
X86VtoP: PAE Mapped phys 41000
Virtual address 7ffdf0000 translates to physical address 41000.

 

posted on 2022-12-04 13:54  悠心不已  阅读(24)  评论(0)    收藏  举报

导航