当前位置:网站首页>(18)[系统调用]追踪系统调用(服务表)
(18)[系统调用]追踪系统调用(服务表)
2022-07-30 16:56:00 【一口一个橘子】
前情回顾
反汇编
上次我们分析到KiFastCallEntry和KiSystemService交汇的地方,但是由于篇幅过长,所以截断了
系统服务表

继续分析
00407781 loc_407781: ; CODE XREF: _KiBBTUnexpectedRange+18↑j
.text:00407781 ; _KiSystemService+6E↑j
.text:00407781 mov edi, eax ; eax没有动过,所以还是 服务号
.text:00407783 shr edi, 8
.text:00407786 and edi, 30h ; edi = 系统服务表 ? 0x00 : 0x10
.text:00407786 ; 0x00: 普通服务函数
.text:00407786 ; 0x10: 图形界面函数
.text:00407789 mov ecx, edi ; ecx记录使用什么表
.text:0040778B add edi, [esi+0E0h] ; edi = _KThread.ServiceTable + 系统服务表项(0x00 or 0x10)
.text:0040778B ; 一个表四个项,刚好0x10,真是好算计
.text:00407791 mov ebx, eax ; ebx = 服务号
.text:00407793 and eax, 0FFFh ; 服务号.bit_12 = 0 (第十二位置零)
.text:00407798 cmp eax, [edi+8]
.text:0040779B jnb _KiBBTUnexpectedRange ; if (服务表.ServiceLimit < 服务号) 跳走(没有这个服务)
.text:004077A1 cmp ecx, 10h
.text:004077A4 jnz short loc_4077C0 ; if (ecx == 0 (普通函数表)) 跳转
.text:004077A6 mov ecx, ds:0FFDFF018h ; ecx = _KPCR._NT_TIB(异常链表).self
.text:004077A6 ; 这个结构体是嵌在_KPCR里的,所以刚好也指向了_KPCR的头部
.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 ; _KPCR._KPRCB.KeSystemCalls += 1;
.text:004077B6 push edx ; 3环参数头部
.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 ; _KPCR._KPRCB.KeSystemCalls += 1;
.text:004077C6 mov esi, edx ; esi = 3环参数头部
.text:004077C8 mov ebx, [edi+0Ch] ; ebx = 系统服务表.ArgmentTable(参数表首地址)
.text:004077CB xor ecx, ecx
.text:004077CD mov cl, [eax+ebx] ; eax = 服务号 & 0xFFF (往上看)
.text:004077CD ; cl = ((BYTE*)参数表)[服务号]
.text:004077D0 mov edi, [edi] ; edi = 系统服务表.ServiceTable (函数地址表)
.text:004077D2 mov ebx, [edi+eax*4] ; ebx = *(DWORD*)(函数地址表(首地址) + 服务号 * 4)
.text:004077D2 ; //或者 ebx = ((DWORD*)函数地址表)[服务号]
.text:004077D2 ; 其中 服务号 * 4 是 地址偏移
.text:004077D5 sub esp, ecx ; 预留 压入参数 的空间
.text:004077D7 shr ecx, 2 ; ecx = 参数个数
.text:004077DA mov edi, esp ; edi = 参数首地址
.text:004077DC cmp esi, ds:_MmUserProbeAddress ; 检查 C0000005
.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 ; 参数复制,一次一个DWORD
.text:004077E8 ; 这里base都一样,es ds可以忽略
.text:004077E8 ; while (ecx != 0){
.text:004077E8 ; step = Eflags.D ? -sizeof(dowrd) : sizeof(dword);
.text:004077E8 ; mov dword ptr es:[edi], dword ptr ds:[esi];
.text:004077E8 ; edi += step, esi += step;
.text:004077E8 ; ecx--;
.text:004077E8 ; }
.text:004077EA call ebx ; 要么C0000005,要么执行这个
.text:004077EA ; 这个就是之前找到的 服务函数,也就是最终的目标
.text:004077EC
.text:004077EC loc_4077EC: ; CODE XREF: _KiFastCallEntry+2AF↓j
.text:004077EC ; DATA XREF: _KiTrap0E+126↓o ...
.text:004077EC mov esp, ebp
.text:004077EE
好吧,这就算跟踪完了,但是返回怎么回呢,只能继续保持好奇心等学完APC再来看咯
学习没有好奇心哪来的动力,就好像小说不挖坑怎么吸引人
边栏推荐
- 第六章:决胜秋招
- Invalid or corrupt jarfile xxx.jar
- 阿里巴巴CAN:Embedding前置的特征交互新思路
- 对话框 QDialog ( 详解 )
- HUAWEI CLOUD data governance production line DataArts, let "data 'wisdom' speak"
- lotus 爆块失败
- huato hot update environment construction (DLL method hot update C# code)
- The way of life, share with you!
- [Geek Challenge 2020] Roamphp1-Welcome
- LeetCode167: Sum of two numbers in sorted array
猜你喜欢

Goland opens file saving and automatically formats

FP6606CMP5 CPC-16L USB类型-C和PD充电控制器 百盛电子代理商

olap——入门ClickHouse

What does a good resume look like in the eyes of a big factory interviewer?

DTSE Tech Talk丨第2期:1小时深度解读SaaS应用系统设计

OpenCV形状检测
![[Geek Challenge 2020] Roamphp1-Welcome](/img/3b/2fa91f7478b8abf6efe0feafd24e58.png)
[Geek Challenge 2020] Roamphp1-Welcome

【Linux Operating System】 Virtual File System | File Cache

向量检索基础方法总结

leetcode:1488. 避免洪水泛滥【二分 + 贪心】
随机推荐
.NET 6.0中使用Identity框架实现JWT身份认证与授权
SLIM: Sparse Linear Methods (TopN推荐)
字符串复制、拼接、比较以及分割函数总结(一)
如何在 UE4 中用代码去控制角色移动
华为云数据治理生产线DataArts,让“数据‘慧’说话”
[HarekazeCTF2019]Avatar Uploader 1
理解实现搜索二叉树
支付系统架构设计详解,精彩!
Nervegrowold d2l (7) kaggle housing forecast model, numerical stability and the initialization and activation function
华为云数据治理生产线DataArts,让“数据‘慧’说话”
C# 跨程序传图(共享内存块传图)跨exe传图
MySQL索引常见面试题(2022版)
[NCTF2019] Fake XML cookbook-1|XXE vulnerability|XXE information introduction
PHP message feedback management system source code
第六章:决胜秋招
Various meanings of SQL's PARTITION BY syntax (with examples)
Visual Studio编辑器 2019:scanf函数返回值被忽略(C4996)报错及解决办法
DTSE Tech Talk丨Phase 2: 1 hour in-depth interpretation of SaaS application system design
探究CSAPP实验二-bomb lab-第一节
olap——入门ClickHouse