|
发表于 2020-7-18 15:15:01
|
显示全部楼层
参看《保护模式下的80386编程》或Intel 手册(Intel网站上可以下载)第一卷
98下课可以直接读写,例如下列汇编程序就改写了中断:
.386
.model flat, stdcall
option casemap: none
include windows.inc
include kernel32.inc
include user32.inc
INTNUM equ 9
includelib kernel32.lib
includelib user32.lib
.data
szAppName db "Ring0 Try--using IDT",0
szFormat db "My INT %u handler return the value of CRO: %08X",0
szMsg db 512 dup(0)
IDTR df 0
OldGate dq 0
MyGate dw 0
dw 28h
dw 0EE00h
dw 0
.code
start:
;construct my call gate
mov eax, IntHandler
mov MyGate, ax
shr eax, 16
mov [MyGate+6], ax
;save old IDT
sidt IDTR
mov ebx, dword ptr [IDTR+2]
add ebx, 8*INTNUM
push ebx
mov esi, ebx
mov edi, offset OldGate
cld
movsd
movsd
;modify IDT
mov edi, ebx
mov esi, offset MyGate
cli
movsd
movsd
;interrupt!
sti
int INTNUM
;restore IDT
pop edi
mov esi, offset OldGate
cli
movsd
movsd
sti
;OK!
invoke wsprintf, addr szMsg, addr szFormat, INTNUM, eax
invoke MessageBox, NULL, addr szMsg, addr szAppName, MB_OK
invoke ExitProcess, 0
IntHandler:
mov eax, cr0
iretd
end start
但NT/2000/XP不行,需要编写内核驱动才行 |
|