;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;ml /c /coff wdm.asm
;link /subsystem:NATIVE /driver:wdm /release /out:wdm.sys wdm.obj
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.586P ; 保护模式
.model flat,stdcall
option casemap:none
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; Include 文件定义
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;Win2k驱动相关文件
;====================================================================
include \masm32\include\w2k\ntddk.inc
;====================================================================
;中断相关数据结构
IDT_REG STRUCT
limit WORD ?
base DWORD ?
IDT_REG ENDS
;中断描述符
INT_DESCRIPTOR STRUCT
offs0_15 WORD ?
sel WORD ?
paramcnt BYTE ?
attrs BYTE ?
offs16_31 WORD ?
INT_DESCRIPTOR ENDS
IntNum equ 21h
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 代码段
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.Code
szOldInt INT_DESCRIPTOR <0e8h,0100h> ;用来保存以前的中断向量
szBuffer IDT_REG <0e8h,0e8000000h> ;设置临时中断向量
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
MyIntFunc Proc ;入口参数,EAX=子程序,EDX=参数
push edx
call eax
iretd
MyIntFunc EndP
;====================================================================
AddMyInt Proc
sidt szBuffer
mov esi,(IDT_REG ptr [szBuffer]).base
add esi,IntNum*8
; 保存原有Int 19中断向量
mov edi,offset szOldInt
mov ecx,8
rep movsb
sub esi,8
; 设置Int 19中断向量
mov eax,offset MyIntFunc
mov WORD ptr [esi],ax
shr eax,16
mov WORD ptr [esi+6],ax ; 设置入口地址
mov WORD ptr [esi+2],cs ; 设置段地址
; 设置Ring3可以访问
mov WORD ptr [esi+4],0EE00h
ret
AddMyInt EndP
;====================================================================
WdmUnload Proc DriverObject:DWORD
pushad
sidt szBuffer
mov edi,(IDT_REG ptr [szBuffer]).base
add edi,IntNum*8
; 恢复原有Int 19中断向量
mov esi,offset szOldInt
mov ecx,8
rep movsb
sub esi,8
popad
ret
WdmUnload EndP
;====================================================================
DriverEntry Proc DriverObj:DWORD,RegistryPath:DWORD
pushad
mov eax,DriverObj
assume eax:ptr DRIVER_OBJECT
mov [eax].DriverUnload,offset WdmUnload
assume eax:nothing
invoke AddMyInt
popad
xor eax,eax
ret
DriverEntry EndP
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
end DriverEntry
[招生]科锐逆向工程师培训(2024年11月15日实地,远程教学同时开班, 第51期)