:


---------------------------------------------------------------
 Date: 14 Apr 1997
 From: Kazennov Vladimir 
   
---------------------------------------------------------------

       ,    ,  -   
   .         
      .  
    Windows    Microsoft   .
   -         Windows, 
 ,       ,
       .       
Windows,    Windows     .
           ,
          -   
,     (VxD),   
  .   ,        
    Windows,     
 (dynamic link libraries - DLLs).


- , , , Windows. , , . - , Windows (Enhanced mode) 386, , (VxD). . , : , . . 1 , . 2 , , 1 , , 0 , . 7 , . . , , 1. +--------------------------------------------------------+ | 7 6...3 2 1 0 | +---------+-------------------+---------+-------+--------+ | PRESENT | | ERROR | IRQ | BUSY | +---------+-------------------+---------+-------+--------+ PRESENT - ; ERROR - ; IRQ - ; BUSY - . ( .) . 1. . 2 , . 1 , . 0 , -. ( , . , , , .) +--------------------------------------------------------+ | 7...2 1 0 | +---------------------------------------+-------+--------+ | 1 1 1 1 1 1 | EOI | START | +---------------------------------------+-------+--------+ EOI - , ; START - -. ( 1 .) . 2.

    MS-DOS

1 dostest.asm, MS-DOS, . , . _____________________________________________________________________ page ,132 ; masm tisr ; >err .286p .xlist include ..\..\include\bogus.inc .list Words struc LoWord dw ? HiWord dw ? Words ends EOI equ 020h ; EOI PIC INTA00 equ 020h ; PIC INTA01 equ 021h ; PIC INT_MASTER_0 equ 08h ; INT . PIC INTB00 equ 0A0h ; PIC INTB01 equ 0A1h ; PIC INT_SLAVE_0 EQU 70h ; INT PIC ; ; ; ife (FAKE_IRQ GE 8) INT_DEV equ (INT_MASTER_0+(FAKE_IRQ AND 7)) PIC00 equ INTA00 PIC01 equ INTA01 else INT_DEV equ (INT_SLAVE_0+(FAKE_IRQ AND 7)) INT_MASK equ 1 SHL (FAKE_IRQ AND 7) PIC00 equ INTB00 PIC01 equ INTB01 endif page CONST SEGMENT DWORD PUBLIC 'DATA' sdNoBogus db 'I do not see the bogus device.',Odh,Oah,'$' sdPrompt db Odh,Oah,'S)tart, or Q)uit: ','$' sdCRLF db Odh,Oah,'$' sdDot db '.','$' CONST ENDS DATA SEGMENT DWORD PUBLIC 'DATA' dwCount1 dw 0 dwCount2 dw 0 lpPrevISR dd 0 ; ISR fStopping db 0 ; TRUE DATA ENDS STACK SEGMENT DWORD STACK 'STACK' db 512 dup (?) STACK ENDS DGroup GROUP CONST,DATA,STACK page ;IP IntSvcRtn - The Interrupt Service Routine ( ; ) ; WARNINGS () ; ; NOTES () ; ISR (dwCount1) ; . ; ; "fStopping", . ; FIXED_TEXT SEGMENT PARA PUBLIC 'CODE' segData1 dw DGroup assume CS:FIXED_TEXT,DS:NOTHING IntSvcRtn proc far push ax push dx push ds mov ds,segDatal assume ds:DGroup inc dwCount1 mov al,NOT FAKE_CTL_EOI mov dx,FAKE_PORT out dx,al ; EOI mov al,EOI out PIC00,al ; EOI PIC ife (PIC00 EQ INTA00) out INTA00,al ; EOI . PIC endif cmp fStopping,0 ; ? jnz isr9 ; , mov al,NOT FAKE_CTL_START mov dx,FAKE_PORT out dx,al ; - isr9: pop ds assume ds:NOTHING pop dx pop ax iret IntSvcRtn endp FIXED_TEXT ENDS page ;IP_main - ; NOTES () ; : ;S)tart() Q)uit(). S, ; , ; , . ; _TEXT SEGMENT PARA PUBLIC 'CODE' segData2 dw DGroup segfixed dw FIXED_TEXT assume cs:_TEXT,ds:NOTHING _main label far mov ds,segData2 ; assume ds:DGroup mov dx,FAKE_PORT in al,dx ; ? or al,al jns m10 ;, mov dx,OFFSET DGroup:sdNoBogus mov ah,9 int 21h ; mov ax,4C01h int 21h ; m10: mov ax,3500h+INT_DEV cli int 21h ; ISR mov lpPrevISR.LoWord,bx mov lpPrevISR.HiWord,es ; mov dx,OFFSET FIXED_TEXT:IntSvcRtn push ds mov ds,segFixed assume ds:NOTHING mov ax,2500h+INT_DEV int 21h ; ISR pop ds assume ds:DGroup sti mov dx,OFFSET DGroup:sdPrompt mov ax,9 int 21h ; S)tart Q)uit ml1: mov dl,0PFh mov ah,6 int 21h ; , jz ml3 or al,40h cmp al,'q' je ml8 ; , "Q" cmp al,'s' jne ml3 ; , "S" cli in al,PIC01 ; and al,NOT INT_MASK out PIC01,al sti mov al,NOT FAKE_CTL_START mov dx,FAKE_PORT out dx,al ; - ml3: mov ax,dwCount1 cmp ax,dwCount2 je ml4 ; , mov dwCount2,ax mov dx,OFFSET DGroup:sdDot mov ah,9 int 21,h ; ml4: jmp ml1 ; ml8: mov fStopping,1 ; ISR mov dx,FAKE_PORT ml9: in al,dx rcr al,1 jnc ml9 ; , cli in al,PIC01 or al,INT_MASK out PIC01,al ; sti push ds lds dx,lpPrevISR assume ds:NOTHING mov ax,2500h+INT_DEV int 21h ; ISR pop ds assume ds:DGroup mov ax,4C00h int 21h ; _TEXT ENDS end_main ; _____________________________________________________________________

    1. dostest.asm

, . MS-DOS 11. , , , . : Start() Quit(). S, -. Q, , . -, MS-DOS (programmable interrupt controller - PIC) ( 11). - 1 0 . , (interrupt service routine - ISR). , ISR , EOI (.. 1 1 ) PIC. , -, , ISR . ISR - , 1 0 . , ISR - , , -. - ISR (dwCount1) , . - , (".") - , , . , Q. , ISR , . , - , PIC .

    Windows

MS-DOS, , Windows. Windows, , , , MS-DOS. , . , ISR, , MS-DOS, Windows , (DLL) (Application Program Interface - API).

    DLL

Windows : (moveable) (discardable). , .. , Windows . (selector) , , , - Windows . - , - . , , () -. Windows, , Windows . , ISR? , ISR , , . , FIXED (), MOVEABLE () DISCARDABLE (). FIXED , . , , . , : Windows FIXED, DLL. FIXED MOVEABLE. Windows ISR . DLL. 2 bogusa.asm DLL, ISR Windows. IntSvcRtn , MS-DOS. - ISR Windows. , , - wCount 0 1. wCount , , Windows. , Windows , MS-DOS. _____________________________________________________________________ page ,132 ; masm tisr ; >err .286p .xlist include bogus.inc include pic.h .list WM_COMMAND =0111h EXTRN POSTMESSAGE:FAR Words struc LoWord dw ? HiWord dw ? Words ends ; ; ; ife (FAKE_IRQ GE 8) INT_DEV equ (INT_MASTER_0+(FAKE_IRQ AND 7)) PIC00 equ INTA00 PIC01 equ INTA01 else INT_DEV equ (INT_SLAVE_0+(FAKE_IRQ AND 7)) INT_MASK equ 1 SHL (FAKE_IRQ AND 7)) PIC00 equ INTB00 PIC01 equ INTB01 endif page FIXED_DATA SEGMENT DWORD PUBLIC 'DATA' PUBLIC _hWndEvent,_wParamEvent,_wCount _hWndEvent label word hWndEvent dw 0 ; _wParamEvent label word wParamEvent dw 0 ; wParam _wCount label word wCount dw 0 ; FIXED_DATA ENDS page ; IP IntSvcRtn - ; ; WARNINGS () ; ; NOTES () ; ISR ; . ; 0, ; ; "fStopping", . ; FIXED_TEXT SEGMENT PARA PUBLIC 'CODE' selData1 dw FIXED_DATA assume CS:FIXED_TEXT,DS:NOTHING PUBLIC _IntSvcRtn _IntSvcRtn label far IntSvcRtn proc far push ax push dx push ds mov ds,selDatal assume ds:FIXED_DATA inc wCount mov al,NOT FAKE_CTL_EOI mov dx,FAKE_PORT out dx,al ; EOI mov al,EOI out PIC00,al ; EOI PIC ife (PIC00 EQ INTA00) out INTA00,al ; EOI PIC endif cmp hWndEvent,0 ; ? jz isr9 ; , ; cmp wCount,1 ; ? jne isr8 ; , push bx ; push cx push es push hWndEvent push WM_COMMAND push wParamEvent push 0 ; lParam 0 push 0 call POSTMESSAGE ; pop es pop cx pop bx isr8: mov al,NOT FAKE_CTL_START mov dx,FAKE_PORT out dx,al ; - isr9: pop ds assume ds:NOTHING pop dx pop ax iret IntSvcRtn endp ; AllocIntReflector PUBLIC _BogusCallback _BogusCallback label far BogusCallback proc far pushf call IntSvcRtn ret BogusCallback endp FIXED_TEXT ENDS end ; _____________________________________________________________________

    2. bogusa.asm

    API

ISR ( DLL Windows), , API. 3 bogus.h, API. 4 DLL. _____________________________________________________________________ #ifndef EXPORT #define EXPORT #endif extern int EXPORT FAR PASCAL BogusCheck(void) ; extern void EXPORT FAR PASCAL BogusStart(HWND hWnd,WPARAM wParam) ; extern int EXPORT FAR PASCAL BogusGetEvent(void) ; extern void EXPORT FAR PASCAL BogusStop(void) ; /* */ ______________________________________________________________________ 3. bogus.h. BogusCheck . TRUE, ( 7 ), FALSE . BogusStart BogusStop . , BogusStart , BogusStop . BogusGetEvent , , BogusGetEvent. ( BogusGetEvent .)

    Windows

, Windows, , . Windows, MS-DOS, . Windows 3.1 , , , - , ( MS-DOS). Windows MS-DOS - , . , DLL , Windows , ISR , MS-DOS. 80386, , 80286, , , . , , , . DLL Windows - , SetPMVector, 4 ( bogus.c). , MS-DOS, - setvector MS-DOS. MS-DOS, Windows , . Windows . ( far Windows), ( far MS-DOS). , , . , . ______________________________________________________________________ /*EM BOGUS.C - DLL * * SUMMARY () * LibMain, WEP * * COMMENTS () * * WARNINGS () * */ #include #include "bogusa.h" #include "pic.h" #include "dpmi.h" #define EXPORT _export _loadds #include "bogus.h" #define FAKE_PORT 0x141 /* (bogosity) - 9.4 */ #define FAKE_IRQ 11 /* (bogosity) - 9.8 */ #define FAKE_CTL_START 0x01 /* "" ( ) */ #define FAKE_CTL_EOI 0x02 /* EOI */ #define FAKE_STAT_BUSY 0x01 /* (zero=>busy) */ #define FAKE_STAT_IRQ 0x02 /* IRQ (zero=>IRQ) */ #define FAKE_STAT_ERROR 0x04 /* - (zero=>error) ( ) */ /* */ #if (FAKE_IRQ<8) #define INT_DEV (INT_MASTER_0+(FAKE_IRQ & 7)) #define PIC00 INTA00 #define PIC01 INTA01 #else #define INT_DEV (INT_SLAVE_0+(FAKE_IRQ & 7)) #define PIC00 INTB00 #define PIC01 INTB01 #endif #define INT_MASK (1 << (FAKE_IRQ & 7)) BOOL FAR PASCAL LibMain(HANDLE hInstance /* */ ,WORD wDataSeg /* */ ,WORD cbHeap /* */ ,LPSTR lpszCmdLine) ; /* */ int FAR PASCAL WEP(int fSystemExit) ; #pragma alloc_text(INIT_TEXT,LibMain) /* LIBENTRY.ASM */ #pragma alloc_text(FIXED_TEXT,WEP) HANDLE hLibInstance ; FARPROC lpfnPrevISR ; /* ISR*/ DWORD lpfnPrevRMISR ; /* ISR */ HANDLE hReflector ; DWORD DPMI_AllocateRMCallback(FARPROC lpfnCallback, _RMCS FAR *lpRMCS) { DWORD dwRet ; _asm { push ds lds si,lpfnCallback les di,lpRMCS mov ax,DPMI_ALLOCRMC int IVEC_DPMI pop ds jc lbl1 mov word ptr dwRet,dx ; mov word ptr dwRet+2,cx jmp short lbl2 lbl1: mov word ptr dwRet,ax ; ax mov word ptr dwRet+2,0 ; seg=0, lbl2: } return dwRet ; } DWORD DPMI_FreeRMCallback(FARPROC lpfnCallback) { DWORD wRet ; _asm { mov dx,word ptr lpfnCallback mov cx,word ptr lpfnCallback+2 mov ax,DPMI_FREERMC int IVEC_DPMI jc lbl1 xor ax,ax lbl1: mov wRet,ax } return wRet ; } DWORD DPMI_GetRMVector(int iVector) { DWORD dwRet ; _asm { mov ax,DPMI_GETRMVEC mov bl,byte ptr iVector int 31h mov word ptr dwRet,dx mov word ptr dwRet+2,cx } return dwRet ; } void DPMI_SetRMVector(int iVector, DWORD lpfnRMISR) { _asm { mov ax,DPMI_SETRMVEC mov bl,byte ptr iVector mov dx,word ptr lpfnRMISR mov cx,word ptr lpfnRMISR+2 int 31h } } FARPROC GetPMVector(int iVector) { FARPROC dwRet ; _asm { mov bl,byte ptr iVector mov ah,35h int 21h mov word ptr dwRet,bx mov word ptr dwRet+2,es ; } return dwRet ; } void SetPMVector(int iVector, FARPROC lpfnISR) { _asm { push ds lds dx,lpfnISR mov al,byte ptr iVector mov ah,25h int 21h ; ISR pop ds } } HANDLE AllocIntReflector(int iVector, FARPROC lpfnCallback) { DWORD dwDosMem ; LPSTR lpLowRMISR ; DWORD lpfnRMCallback ; _RMCS FAR *lpSaveRegs ; /* DOS ISR, * */ dwDosMem = GlobalDosAlloc(16 + sizeof (int) + sizeof (_RMCS) ; if (dwDosMem == 0) return 0; lpLowRMISR = (LPSTR) MAKELONG(0,LOWORD(dwDosMem)) ; lpSaveRegs = (_RMCS FAR *) (&lpLowRMISR[16]) ; /* (callback), * */ lpfnRMCallback = DPMI_AllocateRMCallback((FARPROC)lpfnCallback, lpSaveRegs) ; if (HIWORD((DWORD)lpfnRMCallback == 0) { GlobalDosFree(LOWORD(dwDosMem)) ; return 0; } /* ( 6 )*/ lpLowRMISR[0] = 0x9A ; /* FAR */ *((DWORD FAR *)&(lpLowRMISR[1])) = lpfnRMCallback ; lpLowRMISR[5] = 0xCF ; /*IRET */ *((int FAR *)&(lpLowRMISR[6])) = iVector ; /* */ DPMI_SetRMVector(iVector,MAKELONG(0,HIWORD(dwDosMem))) ; return (HANDLE) LOWORD(dwDosMem) ; /* - */ } void FreeIntReflector(HANDLE hReflector) { LPSTR lpLowRMISR ; DWORD lpfnRMCallback ; /* ISR */ lpLowRMISR = (LPSTR)MAKELONG(0,(WORD)hReflector) ; /* , */ if ((lpLowRMISR[0] != 0x9A) || (lpLowRMISR[5] != 0xCF)) return ; /* , */ /* */ lpfnRMCallback = *((DWORD FAR *)&((lpLowRMISR[1])) ; DPMI_FreeRMCallback(lpfnRMCallback) ; /* */ GlobalDosFree((WORD)hReflector) ; } /*XP< LibMain - */ * * ENTRY () * * EXIT () * * RETURNS () * , * TRUE, - FALSE * * WARNINGS () * * CALLS () * * NOTES () * * LIBENTRY.ASM, * */ BOOL FAR PASCAL LibMain(HANDLE hInstance /* */ ,WORD wDataSeg /* */ ,WORD cbHeap /* */ ,LPSTR lpszCmdLine) ; /* */ /*>*/ { lpszCmdLine = lpszCmdLine ; /* -W4 */ wDataSeg = wDataSeg ; cbHeap = cbHeap ; hInstance = hInstance ; /* * */ return TRUE ; } /*XP< WEP - Windows */ * * ENTRY () * fSystemExit Windows. * DLL. * RETURNS () * 1 * * WARNINGS () * - Windows 3.0 ( * ) * . , * DS , ( * ). * * , . * * CALLS () * * NOTES () * DLL. * */ int FAR PASCAL WEP(int fSystemExit) /*>*/ { fSystemExit = fSystemExit /* -W4 */ return 1 ; /* */ } int EXPORT FAR PASCAL BogusCheck(void) { BYTE bPortVal ; _asm { mov dx,FAKE_PORT in al,dx ; ? mov bPortVal,al } return ((bPortVal & 0x80) == 0) ; /* TRUE, */ } void EXPORT FAR PASCAL BogusStart(HWND hWnd, WPARAM wParam) { wParamEvent = wParam ; hWndEvent = hWnd ; if (!lpfnPrevISR) { /* ISR */ _asm cli lpfnPrevISR = GetPMVector(INT_DEV) ; SetPMVector(INT_DEV,(FARPROC)IntSvcRtn) ; _asm sti /* ISR * */ lpfnPrevRMISR = DPMI_GetRMVector(INT_DEV) ; hReflector = AllocIntReflector(INT_DEV,(FARPROC)BogusCallback) ; /* - * */ _asm { cli in al,PIC01 ; and al,NOT INT_MASK out PIC01,al sti mov al,NOT FAKE_CTL_START mov dx,FAKE_PORT out dx,al ; - } } } int EXPORT FAR PASCAL BogusGetEvent(void) { WORD wCountRet ; _asm { mov ax,SEG wCount mov es,ax xor ax,ax xchg ax,es:wCount ; , mov wCountRet,ax } return wCountRet ; } void EXPORT FAR PASCAL BogusStop(void) { hWndEvent - 0x0000 ; /* ISR " "*/ if (!lpfnPrevISR) return ; /* , */ _asm { mov dx,FAKE_PORT l1: in al,dx rcr al,1 jnc l1 ; , cli in al,PIC01 or al,INT_MASK out PIC01,al ; sti } DPMI_SetRMVector(INT_DEV, lpfnPrevRMISR) ; /* */ FreeIntReflector(hReflector) ; /* */ SetPMVector(INT_DEV, lpfnPrevISR) ; /* */ lpfnPrevISR = NULL ; } /* */ _____________________________________________________________________

    4. bogus.c

    MS-DOS

Windows , MS-DOS (MS-DOS Protected Mode Interface - DPMI). ( DPMI 1.0, Windows 0.9. 1.0 Windows 3.1.) DPMI_SetRMVector DPMI, . , DPMI ( AX ) INT31h. DPMI ( ), DPMI , , , - Microsoft. DPMI_AllocateRMCallback DPMI, (callback), , , . , TSR MS-DOS DLL Windows . DPMI_AllocateRMCallback : , , , , . DPMI_FreeRMCallback , DPMI_AllocateRMCallback. DPMI_FreeRMCallback , .

    ISR

, ISR , . , , ISR . , , . Windows, , , , , . BogusStart. , MS-DOS. , . , , . , AllocIntReflector, , ISR . BogusStart : . IRQ PIC , 1 START . , ISR. BogusStop , BogusStart. , , -.

    WINTEST

wintest.c, - (. 5), , , . MainDlgProc BogusStart WM_INITDIALOG, . ISR , . MainDlgProc wCountTotal. , WM_COMMAND wParam, IDM_BOGUSEVENT, , . , ISR , , ( ) , WM_COMMAND . , , ISR , BogusCheck , , . , , -. _____________________________________________________________________ #include #include "bogus.h" #include "wintest.h" HANDLE hPgmInstance ; #define IDM_BOGUSEVENT 0x3000 void CenterWindow(HWND hWnd) { int xSize, ySixe, xPos, yPos ; RECT rc ; xSize = GetSystemMetrics(SM_CXSCREEN) ; ySize = GetSystemMetrics(SM_CYSCREEN) ; GetWindowRect(hWnd, &rc) ; xPos = (xSize - (rc.right - rc.left)) / 2 ; yPos = (ySize - (rc.bottom - rc.top)) / 2 ; SetWindowRect(hWnd, NULL, xPos, yPos, 0, 0, SWP_DRAWFRAME | SWP_NOSIZE | SWP_NOZORDER) ; } LRESULT _loadds FAR PASCAL MainDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { static WORD wCountTotal = 0; WORD wCount ; lParam = lParam ; switch (msg) { case WM_INITDIALOG: RemoveMenu(GetSystemMenu(hwndDlg,0), SC_CLOSE,MF_BYCOMMAND) ; BogusStart(hwndDlg, IDM_BOGUSEVENT) ; break ; case WM_SHOWWINDOW: if (wParam) CenterWindow(hwndDlg) ; break ; case WM_COMMAND: switch (wParam) { case IDM_BOGUSEVENT: wCount = BogusGetEvent() ; while 9wCount) { wCountTotal += wCount ; wCount = BogusGetEvent() ; } SetDlgItemInt(hwndDlg, IDM_COUNT, wCountTotal, FALSE); break ; case IDCANCEL: EndDialog(hwndDlg, 0) ; break ; } break ; default: return FALSE ; } return TRUE ; } int PASCAL WinMain(HANDLE hInstance, HANDLE hPrevInstance, LPSTR lpCmdLine, intnCmdShow) { hPgmInstance = hInstance ; hPrevInstance = hPrevInstance ; lpCmdLine = lpCmdLine ; nCmdShow = nCmdShow ; if (!hPrevInstance) { if (BogusCheck()) { if (MessageBox(0, "Press OK to begin bogus I/O", "WinTest", MB_OKCANCEL|MB_APPLMODAL) == IDOK) { DialogBox(hPgmInstance, "MainDlg", 0, (FARPROC) MainDlgProc) ; BogusStop() ; } } else MessageBox(0, "Bogus device not found", "WinTest", MB_ICOMMAND|MB_OK|MB_APPLMODAL) ; } else MessageBox(0, "Another instance already running", "WinTest", MB_ICONEXCLAMATION|MB_OK|MB_APPLMODAL) ; return 0 ; } /* */ ______________________________________________________________________

    5. wintest.c.

vxd2.asm ( 6 7) . , , , (Device Driver Kit - DDK) Windows Microsoft, .. 32- , DDK (MASM5). DDK- LINK386 ADDHDR. , (include files), DDK. , VxD , Declare _Virtual_Device, , Windows. , , - , VxD. , . , , . VxD , - . . _____________________________________________________________________ PAGE ,132 title VxD2B.ASM - #2b ;EM VxD2B - #2b ; ; Copyright 1992, Cherry Hill Software ; All rights reserved ; ; SUMMARY () ; . ; () : ; ; 0 - (Start) -. ; -. ; 1/10 . ; . ; ; 1 - EOI. ; " " (End- ; of-interrupt - EOI) ; . ; . ; : ; . ; ; : ; ; 0 - 1, ; , 1 , ; , ; . , ; 1, , ; . ; ; 1 - 1, ; , ; , ; . , , ; , ; 1, . ; ; : ; . ; ; WARNINGS () ; ; .386p .xlist include vmm.inc include debug.inc include v86mmgr.inc include vpicd.inc include ..\include\bogus.inc .list VM_Not_Executable equ VM_Not_Executeable ; acckk; subttl VxD Declaration/Definition page VxD2B_Init_Order equ VNETBIOS_Init_Order+100 ; VxD2B_Device_ID equ Bogus_Device_ID Declare_Virtual_Device VXD2, 1, 0, Vxd2B_Control, VxD2B_Device_ID, \ VxD2B_Init_Order VxD_DATA_SEG ; ; ; ; VPIDC_Virtualize_IRQ. ; , ; , , VPICD, ; VM VM ; . ; IRQD VPICD_IRQ_Descriptor hIRQ dd -1 ; IRQ hOwner dd -1 ; , VM hTimeout dd 0 ; - bFakeData dd 01111111b ; - VxD_DATA_ENDS subttl Dispatch VxD Control page VxD_LOCKED_CODE_SEG BeginProc CheckOwner, NO_LOG cmp ebx,hOwner jne short col ret ; , col: cmp hOwner,-1 jne short co2 ; , mov hOwner,ebx ; ret co2: mov al,-1 ret EndProc CheckOwner BeginProc TimeoutProc mov hTimeout,0 ; cmp edx,hOwner ; ? jne short tol ; , test bFakeData,FAKE_STAT_BUSY ; -? jnz short tol ; , cmp hOwner,-1 ; ? je short tol ; , mov eax,hIRQ mov ebx,hOwner VxDcall VPICD_Set_Int_Request ; mov al,bFakeData and al,NOT (FAKE_STAT_IRQ) ; or al,FAKE_STAT_BUSY ; , mov bFakeData,al tol: ret End Proc TimeoutProc ;IP Port_IO_Callback - FAKE_PORT ; ; ENTRY () ; EAX - ( ) ; EBX - VM ; ECX - - ; DS,ES - FLAT ; ; EXIT () ; EAX - ( ) ; ; WARNINGS () ; ; NOTES () ; , ; . ; ; . ; ; CALLS () BeginProc Port_IO_Callback, NO_LOG Dispatch_Byte_IO Fall_through,Port_Output_Callback Port_Input_Callback: call CheckOwner jc short ioexit mov al,bFakeData or bFakeData,FAKE_STAT_ERROR ; ioexit: ret Port_Output_Callback: call CheckOwner jc short ioexit ; -, test al,FAKE_CTL_START jnz short,poc1 ;, - test bFakeData,FAKE_START_BUSY jz short,poc1 ;, test bFakeData,FAKE_START_IRQ jz short,poc1 ;, IRQ push eax push edx and bFakeData,NOT (FAKE_STAT_ERROR) ; mov eax,100 ; 1/10 mov edx,hOwner ; mov esi,OFFSET32 TimeoutProc VMMcall Set_VM_Time_Out pop edx pop eax or esi,esi jz short,poc1 ;, and bFakeData,NOT (FAKE_STAT_BUSY) ; or bFakeData,FAKE_STAT_ERROR ; mov hTimeout,esi ; - poc1: test al,FAKE_CTL_EOI jnz short poc2 ; , EOI test bFakeData,FAKE_STAT_IRQ ; ? jnz short poc2 ; , or bFakeData,FAKE_STAT_IRQ ;, - push eax mov eax,hIRQ VxDcall VPICD_Clear_Int_Request pop eax poc2: ret EndProc Port_IO_Callback ; ECX == 0 if unmasking (enabling), ECX != 0 if masking (disabling). BeginProc VxD2_Mask_Change_Proc call CheckOwner jc short mcp9 ; , jcxz mcp9 ; , () ; ; . VM ; . ; mov hOwner,-1 ; mcp9: ret EndProc VxD2_Mask_Change_Proc ; , ISR BeginProc VxD2_VInt_Proc mov eax,High_Pri_Device_Boost VMMCall Adjust_Exec_Priority ; ret EndProc VxD2_VInt_Proc ; ISR (IRETs) BeginProc VxD2_IRET_Proc mov eax,-(High_Pri_Device_Boost) VMMCall Adjust_Exec_Priority ; ret EndProc VxD2_IRET_Proc ifdef DEBUG BeginProc VxD2B_Debug_Query Trace_Out "VxD2 has no debug command support." clc ret End Proc VxD2B_Debug_Query endif ; ; VxD2B_Control ; CtlDisp macro x Control_Dispatch x, VxD2B_&x endm Begin_Control_Dispatch VxD2B CtlDisp Device_Init ifdef DEBUG CtlDisp Debug_Query endif End_Control_Dispatch VxD2B VxD_LOCKED_CODE_ENDS VxD_CODE_SEG VxD_CODE_ENDS subttl VxD Initialization page VxD_ICODE_SEG page ; EP VxD2B_Device_Init - ; ; ENTRY () ; EBP - ; EBX - VM ; DS,ES - FLAT ; ; EXIT () ; SUCCESS () ; Carry clear (" ") ; FAILURE () ; Carry set (" ") ; ; ; WARNINGS () ; ; NOTES () ; ; CALLS () ; BeginProc VxD2B_Device_Init Debug_Out "VxD2B_Device_Init" mov edi,OFFSET32 IRQD VxDcall VPICD_Virtualize_IRQ ; jc short vdi1 ; , mov hIRQ,eax ; mov edx,FAKE_PORT mov esi,OFFSET32 Port_IO_Callback VMMCall Install_IO_Handler VMMCall Enable_Global_Trapping ; clc ; vdi1: ret EndProc VxD2B_Device_Init VxD_ICODE_ENDS VxD_REAL_INIT_SEG VxD2B_Real_Init LABEL FAR ; , Windows mov ax,Device_Load_OK ; VxD xor bx,bx ; (Exclude) EMM xor si,si ; ; edx ret VxD_REAL_INIT_ENDS END VxD2B_Real_Init ; _____________________________________________________________________

    6. vxd2.asm

_____________________________________________________________________ LIBRARY VXD2 DESCRIPTION 'Enhanced Windows VXD2(B) Device (Version 1.0)' EXETYPE DEV386 SEGMENTS _LTEXT PRELOAD NONDISCARDABLE _LDATA PRELOAD NONDISCARDABLE _ITEXT CLASS 'ICODE' DISCARDABLE _IDATA CLASS 'ICODE' DISCARDABLE _TEXT CLASS 'PCODE' NONDISCARDABLE _DATA CLASS 'PCODE' NONDISCARDABLE EXPORTS VXD2_DDB @1 _____________________________________________________________________

    7. vxd2.def

    ,

, Windows , , VM , VxD , . , , Windows , VxD. VxD -------------------+-------------------------------------------------- Sys_Critical_Init | ; | . VxD | . -------------------+-------------------------------------------------- Device_Init | ; VxD - | ; | DOS. -------------------+-------------------------------------------------- Init_Complete | , VxD | Device_Init. -------------------+-------------------------------------------------- System_Exit | , Windows | DOS. | DOS , | Windows. -------------------+-------------------------------------------------- Sys_Critical_Exit | ; | . -------------------+-------------------------------------------------- Create_VM | | VM; VxD , | VM. -------------------+-------------------------------------------------- VM_Critical_Init | VM. -------------------+-------------------------------------------------- VM_Init | VM. Sys_VM_Init | VxD | VM. -------------------+-------------------------------------------------- Query_Destroy | VxD | | VM. -------------------+-------------------------------------------------- VM_Terminate | Sys_VM_Terminate | VM. | VM, , | , , | Windows. -------------------+-------------------------------------------------- VM_Not_Executeable | VM . | VM. -------------------+-------------------------------------------------- VxD Device_Init. - 11, . VxD - . VxD , . Install_IO_Handler , -. , - VM, Windows (Virtual Machine Manager - VMM) VxD , -. VPICD_Virtualize_IRQ , . , ( IRQ 11) .

    ""

- (141) VM ( , ), VxD Port_IO_Callback (. 6). Dispatch_Byte_IO - ( : byte, word, dword, string ..) : . . , . - , . , ( TimeoutProc) 1/10 BUSY. , VPICD_Clear_Int_ Request . TimeoutProc - VM VPICD_Clear_Int_Request . dostest wintest ( EOI) . VxD2_VInt_Proc VxD2_IRET _Proc. , VPICD_Virtualize_IRQ. VM. VM, . VxD VM, . ( , VM , VM.)

    VxD

VxD, Windows device= [386Enh] system.ini. Windows , VxD . , dostest wintest.

Windows , . , MIPS, Windows NT 80x86, MS-DOS.

Last-modified: Mon, 14 Feb 2000 17:32:34 GMT
: