当前位置:网站首页>(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再来看咯
学习没有好奇心哪来的动力,就好像小说不挖坑怎么吸引人
边栏推荐
- Tensorflow模型量化(Quantization)原理及其实现方法
- torch.optim.Adam() function usage
- (1) Cloud computing technology learning - virtualized vSphere learning
- 疫情之下的裁员浪潮,7点建议帮你斩获心仪offer
- LeetCode318:单词长度的最大乘积
- Visual Studio编辑器 2019:scanf函数返回值被忽略(C4996)报错及解决办法
- 基于STM32F407使用ADC采集电压实验
- 字符串复制、拼接、比较以及分割函数总结(一)
- Public Key Retrieval is not allowed error solution
- 报错500,“message“: “nested exception is org.apache.ibatis.binding.BindingException: 解决记录
猜你喜欢
如何注册域名、备案以及解析
Win11如何把d盘空间分给c盘?Win11d盘分盘出来给c盘的方法
华为云数据治理生产线DataArts,让“数据‘慧’说话”
论文阅读 (63):Get To The Point: Summarization with Pointer-Generator Networks
Discuz杂志/新闻报道模板(jeavi_line)UTF8-GBK模板
Paper reading (63): Get To The Point: Summarization with Pointer-Generator Networks
Gorilla Mux 和 GORM 的使用方法
Nervegrowold d2l (7) kaggle housing forecast model, numerical stability and the initialization and activation function
SQLServer下载与安装
LeetCode167:有序数组两数之和
随机推荐
【SOC FPGA】Peripheral KEY LED
测试管理与规范
有没有并发系统设计的经验,我该怎么说?
Oracle动态监听与静态监听详解
Discuz杂志/新闻报道模板(jeavi_line)UTF8-GBK模板
Lotus 1.16.0 minimum snapshot export import
What does a good resume look like in the eyes of a big factory interviewer?
【综合类型第 34 篇】喜讯!喜讯!!喜讯!!!,我在 CSDN 的第一个实体铭牌
Mongoose模块
SLIM: Sparse Linear Methods (TopN推荐)
LeetCode167:有序数组两数之和
腾讯专家献上技术干货,带你一览腾讯广告召回系统的演进
Tensorflow模型量化(Quantization)原理及其实现方法
每日练习------生成13位条形, Ean-13码规则:第十三位数字是前十二位数字经过计算得到的校验码。
Google Cloud Spanner的实践经验
vivo announced to extend the product warranty period, the system launched a variety of functional services
升级Win11后不喜欢怎么退回Win10系统?
Leetcode 118. Yanghui Triangle
win下搭建php环境的方法
你是一流的输家,你因此成为一流的赢家