invoke DbgPrint, $CTA0("mycallgate function executed\n")
;add your code here, you can doanything ifyou like.
sti
popfd
popad
retf
Ring0Fun endp
2. 由于ring0时fs为0x30,故修改之
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Ring0Fun proc
pushad
pushfd
cli
push fs
mov bx, 30h
mov fs, bx
invoke DbgPrint, $CTA0("mycallgate function executed\n")
;add your code here, you can doanything ifyou like.
pop fs
sti
popfd
popad
retf
Ring0Fun endp
可惜 当ring0通过retf返回ring3时,fs变成了0,应用程序异常结束。
3. 通过查阅intel手册,发现如下一段话
Checks the contents of the DS, ES, FS, and GS segment registers. If any of these registers refer to segments whose DPL is less than the new CPL (excluding conforming code egments), the segment register is loaded with a null segment selector.