发信人: ikoo() 
整理人: simonshium(1999-06-30 20:16:32), 站内信件
 | 
 
 
This samples is from <<Undocumented Windows 95>> and I think it's simple  enouph and also complete to show some part of a VxD. Wish everyone enjoy it. :       comment % :       CURRDRIV.ASM :       Sample VxD that handles one INT 21h function entirely in protected  :       mode :       INT 21h Function 19h (Get Current Drive)
  :         masm5 -p -w2 currdriv.asm :         link386 currdriv.obj,currdriv.386,,,currdriv,def :         addhdr currdrv.386 :         put device=/unauthw/currdrv/currdriv.386 into system,ini [386] :         currdriv.def :         LIBARY CURRDRIV :         DESCRIPTION 'INT 21H FUNCTION 19 HANDER' :         EXETYPE DEV386 :         SEGMENTS :                 _LTEXT PRELOAD NNDISCARDABLE :         _DATA PRELOAD NONDISCARDABLE :                 _LTEXT CLASS 'ICODE' DISCARDABLE :                 _TDATA CLASS 'ICODE' DISCARDABLE :                 _TEXT CLASS 'PCODE' NONDISCARDABLE :                 _DATA CLASS 'PCODE' NONDISCARDABLE :         EXPORTS CURRDRIV_DDB @1 :         % :     ;##################################################################### :     .386p                                   ; the macro enable the p-code :     INCLUDE vmm.inc                         ; vmm service header :     INCLUDE v86mmgr.inc                     ; v86-mode service header :         ;;; This will become CURRDRIV_DDB :                                             ; this is a global macro :     ;##################################################################### :                                             ; instruction :         Declare_Virtual_Device CURRDRIV,1,0,\ :                 Control_Proc,\ :                 Undefined_Device_ID,\ :                 Undefined_Init_Order,,,\ :     ;##################################################################### :         VxD_DATA_SEG :         Lin_CurDrv      dd      0336h :         VxD_DATA_ENDS :     ;##################################################################### :         VxD_CODE_SEG :         BeginProc       Int21V86 :                 movzx   eax,[ebp.Client_AH] :                 cmp     al,19h :                 je      short Do_GetCurDrv :                 stc :                 ret :         Do_GetCurDrv: :                 mov     eax,[Lin_CurDrv] :                 ;; add  eax,[ebx.CB_High_Linear] :                 mov     al,byte ptr [eax] :                 mov     byte ptr [ebp.Client_AL],al :                 clc; :                 ret :         EndProc Int21V86 :         VxD_CODE_ENDS :     ;##################################################################### :     VxD_LOCKED_CODE_SEG :     BeginProc   Control_Proc :         Control_Dispatch Device_Init,Do_Device_Init :         clc :         ret :     EndProc Control_Proc :     VxD_LOCKED_CODE_ENDS :     ;Begin_Control_Dispatch VSAMPLED :     ;End_Control_Dispatch VSAMPLED :     ;##################################################################### :         VxD_ICODE_SEG :         BeginProc       Do_Device_Init :         Push_Client_State :         VMMcall         Begin_Nest_V86_Exec :         mov     [ebp.Client_AH],52h :         mov     eax,21h :         VMMcall Exec_Int :         movzx   eax,[ebp.Client_ES] :         shl     eax,4 :         add     Lin_CurDrv,eax :         VMMcall End_Nest_Exec :         Pop_Client_State :         mov     eax,21h :         mov     esi,offset32 Int21V86 :         VMMcall         Hook_V86_Int_Chain : again: :     jmp     again :         ret :         EndProc Do_Device_Init :         VxD_ICODE_ENDS   :     ;##################################################################### :     VXD_REAL_INIT_SEG           ; here will be called firstly :         real_init       proc near :     jmp short _display : msg db  'Hello, this is in the real mode initialize segment of VxD CURRENTDRIV.$' : _display:                        ; all the data must be defined here :     mov dx,offset msg :     mov ah,09h :     int 21h                     ; display hello message :     xor ax,ax                   ; contains the return value :     xor bx,bx                   ; null teminated array of page numbers :     xor si,si                   ; instance data item :     xor edx,edx                 ; 32-bits value to be passed to virtual device control procedure : next: :     jmp     next                ; this is a dead loop :         ret :     real_init    endp :         VXD_REAL_INIT_ENDS :     ;##################################################################### :         END
  -- ※ 来源:.广州网易 BBS bbs.nease.net.[FROM: 202.96.133.233]
  | 
 
 
 |