Download WINDOWS ASSEMBLY LANGUAGE & SYSTEMS PROGRAMMING

Transcript
32-Bit Ring 0 303
Here is some 32-bit ring-0 code for RINGOFUNC that calls a
VMM function:
INCLUDE vmm-tiny.inc
;enables us to call vmm and vxd
;functions (derived from VMM.INC, in the DDK).
ringOstack:DWORD
EXTERN defaultOesp:DWORD
EXTERN defaultOss:WORD
PUBLIC RINGOFUNC
TEXT2 SEGMENT DWORD PUBLIC USE32 'CODE'
-ASSUME CS:_TEXTZ
RING0 FUNC
PROC
FAR
;assuming that no parameters are passed, the ring 0 stack
;contains:
;return-EIP, return-CS, old-ESP, old-SS.
;the last two, deepest in the stack, reference the ring-3
;application stack.
I*I think DS still points to old data segment, so can
;still use....
cli
pushfd
pushad
push ds
push es
push fs
push qs
mov defaultOesp,esp
mov defaultOss,ss
;make sure actual flag is clear.
;save default ring 0 stack.
;
/
I-setup a new stack...
mov
mov
lea
add
sti
ax,30h
ss,ax
esp,ringOstack+l996
esp,flatdatalin
;calc Flat linear addr.
*ring-3-ds works here, but let's replace it with
JFLAT-ds...
mov ax,ds
;use fs to access data in our prog.
mov fs,ax
/
mov ax,30h
iFlat ds.
mov ds,ax
/
;
mov es,ax
mov gs,ax
*example of calling a VMM service.
int 20h
; =1
DW
GET CUR VM HANDLE
;= 1
DW
VMM-DEV~CE~ID
-
I
*example of using a '386 privileged instruction...
;get task (tss) register (selector)
str cx
I