.text:
00407781
.text:
00407781
loc_407781: ; CODE XREF: _KiBBTUnexpectedRange
+
18
↑j
.text:
00407781
; _KiSystemService
+
6E
↑j
.text:
00407781
mov edi, eax ;eax中是系统服务号
.text:
00407783
shr edi,
8
;edi右移
8
位
.text:
00407786
and
edi,
30h
;判断系统服务号
12
位,
0
:edi
=
=
0x00
;
1
:edi
=
=
0x10
.text:
00407789
mov ecx, edi
.text:
0040778B
add edi, [esi
+
0E0h
]; [esi
+
0E0h
]:_KTHREAD
+
0xE0
=
ServiceTable,edi指向系统服务表,这里将系统服务表所在地址直接加上edi的运算结果,巧妙地得到要查哪张表(两张表是连续的),每张表占
16
字节
.text:
00407791
mov ebx, eax
.text:
00407793
and
eax,
0FFFh
;与运算后,只保留系统服务号低
12
位
.text:
00407798
cmp
eax, [edi
+
8
] ;edi指向系统服务表,[edi
+
8
]:NumberOfService,判断要找的函数是否超出范围
.text:
0040779B
jnb _KiBBTUnexpectedRange ;若大于系统调用号的个数则跳转,即系统调用号越界
.text:
004077A1
cmp
ecx,
10h
;ecx 保存的是 edi 与
0x30
与运算后的结果,只能是
0x00
或
0x10
.text:
004077A4
jnz short loc_4077C0 ;若系统调用号小于
0x1000
,则跳转
.text:
004077A6
mov ecx, ds:
0FFDFF018h
;只有当ecx
=
=
0x10
才会向下执行,作用是动态加载GUI等图形相关函数
.text:
004077AC
xor ebx, ebx
.text:
004077AE
.text:
004077AE
loc_4077AE: ; DATA XREF: _KiTrap0E
+
110
↓o
.text:
004077AE
or
ebx, [ecx
+
0F70h
]
.text:
004077B4
jz short loc_4077C0
.text:
004077B6
push edx
.text:
004077B7
push eax
.text:
004077B8
call ds:_KeGdiFlushUserBatch
.text:
004077BE
pop eax
.text:
004077BF
pop edx
.text:
004077C0
.text:
004077C0
loc_4077C0: ; CODE XREF: _KiFastCallEntry
+
B4↑j
.text:
004077C0
; _KiFastCallEntry
+
C4↑j
.text:
004077C0
inc dword ptr ds:
0FFDFF638h
;
.text:
004077C6
mov esi, edx ;edx:三环参数指针
.text:
004077C8
mov ebx, [edi
+
0Ch
] ; [edi
+
0Ch
]:ParamTableBase(参数表指针)
.text:
004077CB
xor ecx, ecx ;eax保存的是
3
环传入的系统调用号
.text:
004077CD
mov cl, [eax
+
ebx] ;eax保存的是
3
环传入的系统调用号,ebx保存的是是参数表指针,这条指令的目的是得到内核函数的参数总长度,存入cl
.text:
004077D0
mov edi, [edi] ;取出系统调用表的第一个成员(函数地址指针)
.text:
004077D2
mov ebx, [edi
+
eax
*
4
] ;函数地址指针
+
系统调用号
*
4
(乘
4
是因为每个成员占
4
字节),ebx中存入函数地址
.text:
004077D5
sub esp, ecx ;提升堆栈,提升高度为cl,目的是要把三环堆栈中的参数存进来
.text:
004077D7
shr ecx,
2
;参数总长度
/
4
=
参数个数
.text:
004077DA
mov edi, esp ;设置参数的
0
环堆栈地址
.text:
004077DC
cmp
esi, ds:_MmUserProbeAddress ;判断esi与用户程序能访问的最大地址范围,是否越界
.text:
004077E2
jnb loc_407990 ;如果越界了 进行跳转,处理异常
.text:
004077E8
.text:
004077E8
loc_4077E8: ; CODE XREF: _KiFastCallEntry
+
2A4
↓j
.text:
004077E8
; DATA XREF: _KiTrap0E
+
106
↓o
.text:
004077E8
rep movsd ;复制参数(执行几次取决于参数个数<
-
004077D7
结果 )到
0
环的堆栈
.text:
004077EA
call ebx ;调用内核函数NtReadVirtualMemory