diff options
author | Adam <you@example.com> | 2020-05-17 05:51:50 +0200 |
---|---|---|
committer | Adam <you@example.com> | 2020-05-17 05:51:50 +0200 |
commit | e611b132f9b8abe35b362e5870b74bce94a1e58e (patch) | |
tree | a5781d2ec0e085eeca33cf350cf878f2efea6fe5 /private/mvdm/vdd/samples/sample1 | |
download | NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.gz NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.bz2 NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.lz NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.xz NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.zst NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.zip |
Diffstat (limited to 'private/mvdm/vdd/samples/sample1')
-rw-r--r-- | private/mvdm/vdd/samples/sample1/dirs | 1 | ||||
-rw-r--r-- | private/mvdm/vdd/samples/sample1/fax16/fax16.asm | 348 | ||||
-rw-r--r-- | private/mvdm/vdd/samples/sample1/fax16/makefile | 41 | ||||
-rw-r--r-- | private/mvdm/vdd/samples/sample1/fax32/fax32.c | 248 | ||||
-rw-r--r-- | private/mvdm/vdd/samples/sample1/fax32/fax32.def | 8 | ||||
-rw-r--r-- | private/mvdm/vdd/samples/sample1/fax32/fax32.h | 29 | ||||
-rw-r--r-- | private/mvdm/vdd/samples/sample1/fax32/makefile | 11 | ||||
-rw-r--r-- | private/mvdm/vdd/samples/sample1/fax32/sources | 21 |
8 files changed, 707 insertions, 0 deletions
diff --git a/private/mvdm/vdd/samples/sample1/dirs b/private/mvdm/vdd/samples/sample1/dirs new file mode 100644 index 000000000..083484f16 --- /dev/null +++ b/private/mvdm/vdd/samples/sample1/dirs @@ -0,0 +1 @@ +DIRS=fax32 diff --git a/private/mvdm/vdd/samples/sample1/fax16/fax16.asm b/private/mvdm/vdd/samples/sample1/fax16/fax16.asm new file mode 100644 index 000000000..0d8a6d86a --- /dev/null +++ b/private/mvdm/vdd/samples/sample1/fax16/fax16.asm @@ -0,0 +1,348 @@ + name faxdrv + title 'FAX16 - Stub driver for Application based intercept under NT' + +; +; fax16.asm: This is a very simple DOS stub device driver for NTVDM. +; It shows how to use application based intercept services +; provided by NTVDM. FAX32.dll is its DLL which will be loaded +; in the NTVDM process by this stub device driver. +; +; This driver only has meaningful code for init,read and write. +; Rest all command codes always succeed. We are assuming here +; that the 16 bit fax application for this stub device driver +; opens this device and just make read and write calls. The +; meaning of read is to get a fax message and write means +; send a message + +_TEXT segment byte public 'CODE' + + assume cs:_TEXT,ds:_TEXT,es:NOTHING + + org 0 + + include isvbop.inc + +MaxCmd equ 24 ; Maximum allowed command + +; VDD Command codes + +OpGet equ 1 ; Read a FAX +OpSend equ 2 ; Send a FAX + +Header: ; Fax Device Header + DD -1 + DW 0c840h + DW FaxStrat + DW FaxIntr + DB 'FAXDRV00' + +RHPtr DD ? ; Pointer to Request Header + +Dispatch: ; Interrupt routine command code + DW Init + DW MediaChk + DW BuildBPB + DW IoctlRd + DW Read + DW NdRead + DW InpStat + DW InpFlush + DW Write + DW WriteVfy + DW OutStat + DW OutFlush + DW IoctlWt + DW DevOpen + DW DevClose + DW RemMedia + DW OutBusy + DW Error + DW Error + DW GenIOCTL + DW Error + DW Error + DW Error + DW GetLogDev + DW SetLogDev + +DllName DB "FAX32.DLL",0 +InitFunc DB "FAXVDDRegisterInit",0 +DispFunc DB "FAXVDDDispatch",0 + +F32Mes DB "We are called from 32 staff", 10, 13, "$" + +hVDD DW ? + +FaxStrat proc far ; Strategy Routine + + mov word ptr cs:[RhPtr],bx + mov word ptr cs:[RhPtr+2],es + ret + +FaxStrat endp + +FaxIntr proc far ; INterrupt routine + + push ax ; Save registers + push bx + push cx + push dx + push ds + push es + push di + push si + push bp + + push cs + pop ds ; DS = CS + + les di,[RHPtr] ; ES:DI = request header + + mov bl,es:[di+2] + xor bh,bh ; BX = command code + cmp bx,MaxCmd + jle FIntr1 + + call Error ; Unknown command + jmp FIntr2 + +FIntr1: + shl bx,1 + call word ptr [bx+Dispatch] ; call command routine + les di,[RhPtr] ; ES:DI = request header + +FIntr2: + or ax,0100h ; Set Done bit in the status + mov es:[di+3],ax ; Store the status + + pop bp ; restore registers + pop si + pop di + pop es + pop ds + pop dx + pop cx + pop bx + pop ax + + ret + + +MediaChk proc near + xor ax,ax + ret +MediaChk endp + +BuildBPB proc near + xor ax,ax + ret +BuildBPB endp + +IoctlRd proc near + xor ax,ax + ret +IoctlRd endp + +Read proc near + push es + push di ; Save Request Header add + + mov bx,word ptr es:[di+14] ; buffer offset + mov ax,word ptr es:[di+16] ; buffer segment + mov cx,word ptr es:[di+18] ; buffer length + + mov es,ax ; es:bx is the buffer where + ; fax has to be read from + ; the NT device driver + + mov ax,word ptr cs:[hVDD] ; VDD handle returned by + ; register module + mov dx,OpGet ; Read the fax command + + DispatchCall + + pop di + pop es + + jnc rOK ; NC -> Success and CX has + ; the count read. + + call Error ; Operation Failed + ret + +rOK: + mov word ptr es:[di+12],cx ; return in header how much + ; was read + xor ax,ax + ret +Read endp + +NdRead proc near + xor ax,ax + ret +NdRead endp + +InpStat proc near + xor ax,ax + ret +InpStat endp + +InpFlush proc near + xor ax,ax + ret +InpFlush endp + +Write proc near + push es + push di ; Save Request Header add + + mov bx,word ptr es:[di+14] ; buffer offset + mov ax,word ptr es:[di+16] ; buffer segment + mov cx,word ptr es:[di+18] ; buffer length + + mov es,ax ; es:bx is the FAX message where + ; to be send by NT device + ; driver + + mov ax,word ptr cs:[hVDD] ; VDD handle returned by + ; register module + mov dx,OpSend ; Send the fax command + + DispatchCall + + pop di + pop es + + jnc wOK ; NC -> Success and CX has + ; the count read. + + call Error ; Operation Failed + ret + +wOK: + mov word ptr es:[di+12],cx ; return in header how much + ; was actually written + xor ax,ax + ret +Write endp + +WriteVfy proc near + xor ax,ax + ret +WriteVfy endp + +OutStat proc near + xor ax,ax + ret +OutStat endp + +OutFlush proc near + xor ax,ax + ret +OutFlush endp + +IoctlWt proc near + xor ax,ax + ret +IoctlWt endp + +DevOpen proc near + xor ax,ax + ret +DevOpen endp + +DevClose proc near + xor ax,ax + ret +DevClose endp + +RemMedia proc near + xor ax,ax + ret +RemMedia endp + +OutBusy proc near + xor ax,ax + ret +OutBusy endp + +GenIOCTL proc near + xor ax,ax + ret +GenIOCTL endp + +GetLogDev proc near + xor ax,ax + ret +GetLogDev endp + +SetLogDev proc near + xor ax,ax + ret +SetLogDev endp + +Error proc near + mov ax,8003h ; Bad Command Code + ret +Error endp +; +; +; This function is a sample sub that calling from 32-bits part of VDD +; +From32Sub proc near + + push cs + pop ds + mov dx, offset F32mes + mov ah, 09h + int 21h + VDDUnSimulate16 + ret + +From32Sub endp + +Init proc near + push es + push di ; Save Request Header add + + push ds + pop es + + ; Load fax32.dll + mov si, offset DllName ; ds:si = fax32.dll + mov di, offset InitFunc ; es:di = init routine + mov bx, offset DispFunc ; ds:bx = dispatch routine + mov ax, offset From32Sub ; ds:ax = From32Sub + + + RegisterModule + jnc saveHVDD ; NC -> Success + + call Error ; Indicate failure + + pop di + pop es + mov byte ptr es:[di+13],0 ; unit supported 0 + mov word ptr es:[di+14],offset Header ; Unload this device + mov word ptr es:[di+16],cs + mov si, offset Header + and [si+4],8FFFh ; clear bit 15 for failure + ret + +saveHVDD: + mov [hVDD],ax + + pop di + pop es + mov word ptr es:[di+14],offset Init ; Free Memory address + mov word ptr es:[di+16],cs + + xor ax,ax ; return success + ret +Init endp + +FaxIntr endp + +_TEXT ends + + end diff --git a/private/mvdm/vdd/samples/sample1/fax16/makefile b/private/mvdm/vdd/samples/sample1/fax16/makefile new file mode 100644 index 000000000..640ae45d7 --- /dev/null +++ b/private/mvdm/vdd/samples/sample1/fax16/makefile @@ -0,0 +1,41 @@ +# Makefile for fax16 stub device driver + +!IFNDEF BUILDMSG +BUILDMSG= +!ENDIF + +########## Path definition so we find 16 bit tools ########## +# Also works around stupid bug in RC 3.1 that doesn't allow rcpp.err to be +# in a directory that is greater than 128 chars down the path, even if +# rc 3.1 is running as an OS/2 app. + +PATH = $(_NTBINDIR)\private\mvdm\tools16;$(PATH) + +.SUFFIXES: +.SUFFIXES: .c .obj .lst .exe .exc .exs .com .sal .cod .sil .inc .skl .cla .cl1 .ctl .asm .idx .msg + +MAKE =nmake +asm =masm +awarn =-W1 +aflags =-Mx -t $(awarn) $(extasw) +ainc =-I. -I$(_NTBINDIR)\public\sdk\inc + + +.asm.obj: + $(asm) $(ainc) $(aflags) $*.asm; + +.asm.lst: + $(asm) -l $(ainc) $(aflags) $*.asm; + +all: fax16.sys + +clean: + if exist *.obj del *.obj + if exist *.exe del *.exe + if exist *.map del *.map + if exist *.sym del *.sym + if exist *.sys del *.sys + +fax16.sys: fax16.obj + link16 fax16; + exe2bin fax16.exe fax16.sys diff --git a/private/mvdm/vdd/samples/sample1/fax32/fax32.c b/private/mvdm/vdd/samples/sample1/fax32/fax32.c new file mode 100644 index 000000000..cb162b10e --- /dev/null +++ b/private/mvdm/vdd/samples/sample1/fax32/fax32.c @@ -0,0 +1,248 @@ +/*++ + * + * VDD v1.0 + * + * Copyright (c) 1991, Microsoft Corporation + * + * VDD.C - Sample VDD for NT-MVDM + * +--*/ +#include "fax32.h" +#include "vddsvc.h" + + +USHORT Sub16CS; +USHORT Sub16IP; + +BOOL +VDDInitialize( + IN PVOID DllHandle, + IN ULONG Reason, + IN PCONTEXT Context OPTIONAL + ) + +/*++ + +Routine Description: + + +Arguments: + + DllHandle - Not Used + + Reason - Attach or Detach + + Context - Not Used + +Return Value: + + SUCCESS - TRUE + FAILURE - FALSE + +--*/ + +{ + + switch ( Reason ) { + + case DLL_PROCESS_ATTACH: + // Allocate VDD's local heap if needed. Check that NT FAX driver + // is available by opening that device. + //.... + // Install user hook for callback service. + + if(!VDDInstallUserHook (DllHandle,&FAXVDDCreate, &FAXVDDTerminate, + &FAXVDDBlock, &FAXVDDResume)) + OutputDebugString("FAX32: UserHook not installed\n"); + else + OutputDebugString("FAX32: UserHook installed!\n"); + + // UserHook # 2 + if(!VDDInstallUserHook (DllHandle,&FAXVDDCreate, NULL, + NULL, &FAXVDDResume)) + OutputDebugString("FAX32: UserHook #2 not installed\n"); + else + OutputDebugString("FAX32: UserHook #2 installed!\n"); + + break; + + case DLL_PROCESS_DETACH: + // Deallocate VDD's local heap if needed + // communicate to appropriate Device driver about your departure + //... + // Deinstall user hook for callback service. + if(!VDDDeInstallUserHook (DllHandle)) + OutputDebugString("FAX32: UserHook not deinstalled\n"); + else + OutputDebugString("FAX32: UserHook deinstalled!\n"); + + break; + default: + break; + } + + return TRUE; +} + +// Sample function +VOID FAXVDDTerminate(USHORT usPDB) +{ + USHORT uSaveCS, uSaveIP; + + OutputDebugString("FAX32: Terminate message\n"); + + // VDDHostSimulate + + uSaveCS = getCS(); + uSaveIP = getIP(); + setCS(Sub16CS); + setIP(Sub16IP); + VDDSimulate16(); + setCS(uSaveCS); + setIP(uSaveIP); + +} + +// Sample function +VOID FAXVDDCreate(USHORT usPDB) +{ + OutputDebugString("FAX32: Create Message\n"); +} + +// Sample function +VOID FAXVDDBlock(VOID) +{ + OutputDebugString("FAX32: Block Message\n"); +} + +// Sample function +VOID FAXVDDResume(VOID) +{ + OutputDebugString("FAX32: Resume Message\n"); +} + + +VOID +FAXVDDTerminateVDM( + VOID + ) +/*++ + +Arguments: + +Return Value: + + SUCCESS - TRUE + FAILURE - FALSE + +--*/ + + +{ + + // Cleanup any resource taken for this vdm + + + return; +} + + +VOID +FAXVDDRegisterInit( + VOID + ) +/*++ + +Arguments: + +Return Value: + + SUCCESS - TRUE + FAILURE - FALSE + +--*/ + + +{ + // Save addresses for fax16 + Sub16CS = getDS(); + Sub16IP = getAX(); + + OutputDebugString("FAX32: GET_ADD\n"); + + // Called from the BOP manager. If VDDInitialize has done all the + // checking and resources alloaction, just return success. + + setCF(0); + return; +} + + +#define GET_A_FAX 1 +#define SEND_A_FAX 2 + +VOID +FAXVDDDispatch( + VOID + ) +/*++ + +Arguments: + Client (DX) = Command code + 01 - get a message from NT device driver + 02 - send a message through NT device driver + 03 - address of 16 bit routine + + Client (ES:BX) = Message Buffer + Client (CX) = Buffer Size + +Return Value: + + SUCCESS - Client Carry Clear and CX has the count transferred + FAILURE - Client Carry Set + +--*/ + + +{ +PCHAR Buffer; +USHORT cb; +USHORT uCom; +BOOL Success = TRUE; // In this sample operation always succeeds + + uCom = getDX(); + + cb = getCX(); + Buffer = (PCHAR) GetVDMPointer ((ULONG)((getES() << 16)|getBX()),cb,FALSE); + switch (uCom) { + case GET_A_FAX: + // Make a DeviceIOControl or ReadFile on NT FAX driver with + // cb and Buffer.Then set CX if success. + + if (Success) { + setCX(cb); + setCF(0); + } + else + setCF(1); + + break; + + + case SEND_A_FAX: + // Make a DeviceIOControl or WriteFile on NT FAX driver with + // cb and Buffer.Then set CX if success. + + if (Success) { + setCX(cb); + setCF(0); + } + else + setCF(1); + + break; + default: + setCF(1); + } + return; +} diff --git a/private/mvdm/vdd/samples/sample1/fax32/fax32.def b/private/mvdm/vdd/samples/sample1/fax32/fax32.def new file mode 100644 index 000000000..826d5579a --- /dev/null +++ b/private/mvdm/vdd/samples/sample1/fax32/fax32.def @@ -0,0 +1,8 @@ +LIBRARY VDD + +DESCRIPTION 'Sample ISV VDD for NT-MVDM' + +EXPORTS + FAXVDDDispatch + FAXVDDTerminateVDM + FAXVDDRegisterInit diff --git a/private/mvdm/vdd/samples/sample1/fax32/fax32.h b/private/mvdm/vdd/samples/sample1/fax32/fax32.h new file mode 100644 index 000000000..fc5c45650 --- /dev/null +++ b/private/mvdm/vdd/samples/sample1/fax32/fax32.h @@ -0,0 +1,29 @@ +/* vdd.h - main include file for the VDD + * + */ + + + +#ifdef WIN_32 +#define WIN +#define FLAT_32 +#define TRUE_IF_WIN32 1 +#else +#define TRUE_IF_WIN32 0 +#endif + +#ifdef WIN +#define _WINDOWS +#include "windows.h" +#endif + + + +BOOL VDDInitialize(PVOID,ULONG,PCONTEXT); +VOID FAXVDDTerminateVDM(VOID); +VOID FAXVDDInit (VOID); +VOID FAXVDDDispatch (VOID); +VOID FAXVDDTerminate(USHORT usPDB); +VOID FAXVDDCreate(USHORT usPDB); +VOID FAXVDDBlock(VOID); +VOID FAXVDDResume(VOID); diff --git a/private/mvdm/vdd/samples/sample1/fax32/makefile b/private/mvdm/vdd/samples/sample1/fax32/makefile new file mode 100644 index 000000000..85f1ecf36 --- /dev/null +++ b/private/mvdm/vdd/samples/sample1/fax32/makefile @@ -0,0 +1,11 @@ +# Sample VDD makefile +# +# Copyright (c) 1991, Microsoft Corporation +# + + +# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source +# file to this component. This file merely indirects to the real make file +# that is shared by all the components of NT +# +!INCLUDE $(NTMAKEENV)\makefile.def diff --git a/private/mvdm/vdd/samples/sample1/fax32/sources b/private/mvdm/vdd/samples/sample1/fax32/sources new file mode 100644 index 000000000..942d66469 --- /dev/null +++ b/private/mvdm/vdd/samples/sample1/fax32/sources @@ -0,0 +1,21 @@ +INDENTED_DIRECTIVES=1 + +MAJORCOMP=vdd +MINORCOMP=fax32 + +TARGETNAME=fax32 +TARGETPATH=$(BASEDIR)\public\sdk\lib +TARGETTYPE=DYNLINK +TARGETLIBS=$(BASEDIR)\public\sdk\lib\*\kernel32.lib \ + $(BASEDIR)\public\sdk\lib\*\ntvdm.lib + +DLLENTRY=VDDInitialize +DLLBASE=0x2000000 + +SOURCES=fax32.c + +C_DEFINES=-DWIN_32 -DDEBUG + +UMTYPE=windows +UMTEST= +UMLIBS= |