DECLARE_VIRTUAL_DEVICE MESSAGE,1,0, MESSAGE_Control, UNDEFINED_DEVICE_ID, UNDEFINED_INIT_ORDER
Begin_control_dispatch MESSAGE
Control_Dispatch Create_VM, OnVMCreate
Control_Dispatch VM_Terminate2, OnVMClose
End_control_dispatch MESSAGE
VxD_PAGEABLE_DATA_SEG
MsgTitle db "VxD MessageBox",0
VMCreated db "A VM is created",0
VMDestroyed db "A VM is destroyed",0
VxD_PAGEABLE_DATA_ENDS
VxD_PAGEABLE_CODE_SEG
BeginProc
OnVMCreate
mov ecx, OFFSET32
VMCreated
CommonCode:
VMMCall Get_sys_vm_handle
mov
eax,MB_OK+MB_ICONEXCLAMATION
mov
edi, OFFSET32 MsgTitle
xor
esi,esi
xor
edx,edx
VxDCall
SHELL_Message
ret
EndProc
OnVMCreate
BeginProc
OnVMClose
mov ecx,OFFSET32
VMDestroyed
jmp
CommonCode
EndProc OnVMClose
VxD_PAGEABLE_CODE_ENDS
end
分析: Begin_control_dispatch MESSAGESEGMENTS
_LPTEXT CLASS 'LCODE' PRELOAD
NONDISCARDABLE
_LTEXT CLASS
'LCODE' PRELOAD NONDISCARDABLE
_LDATA CLASS 'LCODE'
PRELOAD NONDISCARDABLE
_TEXT CLASS
'LCODE' PRELOAD NONDISCARDABLE
_DATA CLASS
'LCODE' PRELOAD NONDISCARDABLE
CONST CLASS
'LCODE' PRELOAD NONDISCARDABLE
_TLS CLASS
'LCODE' PRELOAD NONDISCARDABLE
_BSS CLASS
'LCODE' PRELOAD NONDISCARDABLE
_LMGTABLE CLASS 'MCODE' PRELOAD
NONDISCARDABLE IOPL
_LMSGDATA
CLASS 'MCODE' PRELOAD NONDISCARDABLE
IOPL
_IMSGTABLE CLASS
'MCODE' PRELOAD DISCARDABLE IOPL
_IMSGDATA CLASS 'MCODE' PRELOAD
DISCARDABLE IOPL
_ITEXT CLASS
'ICODE' DISCARDABLE
_IDATA CLASS 'ICODE'
DISCARDABLE
_PTEXT CLASS
'PCODE' NONDISCARDABLE
_PMSGTABLE CLASS 'MCODE' NONDISCARDABLE
IOPL
_PMSGDATA CLASS
'MCODE' NONDISCARDABLE IOPL
_PDATA CLASS 'PDATA'
NONDISCARDABLE SHARED
_STEXT CLASS 'SCODE'
RESIDENT
_SDATA CLASS
'SCODE' RESIDENT
_DBOSTART
CLASS 'DBOCODE' PRELOAD NONDISCARDABLE CONFORMING
_DBOCODE CLASS 'DBOCODE' PRELOAD NONDISCARDABLE
CONFORMING
_DBODATA CLASS
'DBOCODE' PRELOAD NONDISCARDABLE CONFORMING
_16ICODE CLASS '16ICODE' PRELOAD
DISCARDABLE
_RCODE CLASS
'RCODE'
EXPORTS
MESSAGE_DDB @1
汇编过程: ml -coff -c -Cx -DMASM6 -DBLD_COFF -DIS_32 message.asm link
-VxD -def:message.def message.obj
VxD 的安装:
把message.VxD放到\system目录下。
在system.ini文件里的[386enh]部分里加上如下的一行:
device=message.VxD
重启你的计算机。
测试这个VxD:
打开一dos窗口,你会看到弹出的消息框,显示“A VM is created."。当你关闭一个dos窗口,又会弹出一个消息框显示“A
VM is destroyed"。
本文地址:http://com.8s8s.com/it/it4131.htm