|
|
1.1 ! root 1: name dosdrvr ! 2: title 'DOSDRVR - Stub driver for Application based intercept under NT' ! 3: ;****************************************************************************** ! 4: ; ! 5: ; DOSDRVR ! 6: ; ! 7: ; This DOS character device driver demonstrates basic communication ! 8: ; with a NT VDD. It handles DOS OPEN, CLOSE and IOCTL Read requests. ! 9: ; ! 10: ; Operation: ! 11: ; ! 12: ; INIT - Issues RegisterModule() call to get VDD handle. ! 13: ; ! 14: ; OPEN, CLOSE, IOCTL Read - The VDD exposes a private interface ! 15: ; that correspond to these DOS calls. The driver basically passes ! 16: ; these calls from a DOS application on to the VDD using the ! 17: ; DispatchCall() function. ! 18: ; ! 19: ;****************************************************************************** ! 20: ! 21: ! 22: _TEXT segment byte public 'CODE' ! 23: ! 24: assume cs:_TEXT,ds:_TEXT,es:NOTHING ! 25: ! 26: org 0 ! 27: ! 28: include isvbop.inc ! 29: ! 30: MaxCmd equ 24 ; Maximum DOS command value ! 31: ! 32: ; VDD Command codes ! 33: ! 34: VDDOPEN equ 1 ! 35: VDDCLOSE equ 2 ! 36: VDDINFO equ 3 ! 37: ! 38: Header: ; Device Header ! 39: DD -1 ! 40: DW 0c840h ! 41: DW DrvStrat ! 42: DW DrvIntr ! 43: DB 'DOSDRV00' ! 44: ! 45: RHPtr DD ? ; Pointer to Request Header ! 46: ! 47: ! 48: DllName DB "IOCTLVDD.DLL",0 ! 49: InitFunc DB "VDDRegisterInit",0 ! 50: DispFunc DB "VDDDispatch",0 ! 51: ! 52: hVDD DW ? ! 53: ! 54: Dispatch: ; Interrupt routine command code ! 55: DW Init ! 56: DW DrvNOP ; MediaChk ! 57: DW DrvNOP ; BuildBPB ! 58: DW IoctlRd ! 59: DW DrvNOP ; Read ! 60: DW DrvNOP ; NdRead ! 61: DW DrvNOP ; InpStat ! 62: DW DrvNOP ; InpFlush ! 63: DW DrvNOP ; Write ! 64: DW DrvNOP ; WriteVfy ! 65: DW DrvNOP ; OutStat ! 66: DW DrvNOP ; OutFlush ! 67: DW DrvNOP ; IoctlWt ! 68: DW DevOpen ! 69: DW DevClose ! 70: DW DrvNOP ; RemMedia ! 71: DW DrvNOP ; OutBusy ! 72: DW Error ! 73: DW Error ! 74: DW DrvNOP ; GenIOCTL ! 75: DW Error ! 76: DW Error ! 77: DW Error ! 78: DW DrvNOP ; GetLogDev ! 79: DW DrvNOP ; SetLogDev ! 80: ! 81: ;****************************************************************************** ! 82: ; ! 83: ; DrvStrat ! 84: ; DrvIntr ! 85: ; ! 86: ; The following routines are standard, required DOS driver routines. ! 87: ; The DrvIntr routine uses the "Dispatch" table to call the appropriate ! 88: ; subroutine, based on the driver request. ! 89: ; ! 90: ;****************************************************************************** ! 91: DrvStrat proc far ; Strategy Routine ! 92: ! 93: mov word ptr cs:[RhPtr],bx ! 94: mov word ptr cs:[RhPtr+2],es ! 95: ret ! 96: ! 97: DrvStrat endp ! 98: ! 99: DrvIntr proc far ; INterrupt routine ! 100: ! 101: push ax ; Save registers ! 102: push bx ! 103: push cx ! 104: push dx ! 105: push ds ! 106: push es ! 107: push di ! 108: push si ! 109: push bp ! 110: ! 111: push cs ! 112: pop ds ; DS = CS ! 113: ! 114: les di,[RHPtr] ; ES:DI = request header ! 115: ! 116: mov bl,es:[di+2] ! 117: xor bh,bh ; BX = command code ! 118: cmp bx,MaxCmd ! 119: jle FIntr1 ! 120: ! 121: call Error ; Unknown command ! 122: jmp FIntr2 ! 123: ! 124: FIntr1: ! 125: shl bx,1 ! 126: call word ptr [bx+Dispatch] ; call command routine ! 127: les di,[RhPtr] ; ES:DI = request header ! 128: ! 129: FIntr2: ! 130: or ax,0100h ; Set Done bit in the status ! 131: mov es:[di+3],ax ; Store the status ! 132: ! 133: pop bp ; restore registers ! 134: pop si ! 135: pop di ! 136: pop es ! 137: pop ds ! 138: pop dx ! 139: pop cx ! 140: pop bx ! 141: pop ax ! 142: ret ! 143: ! 144: DrvIntr endp ! 145: ! 146: DrvNOP proc near ! 147: xor ax,ax ! 148: ret ! 149: DrvNOP endp ! 150: ! 151: Error proc near ! 152: mov ax,8003h ; Bad Command Code ! 153: ret ! 154: Error endp ! 155: ! 156: ! 157: ;****************************************************************************** ! 158: ; ! 159: ; IoctlRd ! 160: ; ! 161: ; This routine is entered when a DOS application issues an IOCTL READ ! 162: ; to this driver. The target buffer address for the IOCTL is passed ! 163: ; on to the VDD. ! 164: ; ! 165: ;****************************************************************************** ! 166: IoctlRd proc near ! 167: ! 168: push es ! 169: push di ! 170: ! 171: mov ax, word ptr cs:[hVDD] ; VDD handle ! 172: mov dx, VDDINFO ! 173: mov cx, es:[di+18] ; size of buffer ! 174: les di, es:[di+14] ; pointer to target buffer ! 175: DispatchCall ! 176: ! 177: pop di ! 178: pop es ! 179: ! 180: jnc @f ; jif Success ! 181: ! 182: call Error ; Operation Failed ! 183: ret ! 184: ! 185: @@: ! 186: mov es:[di+18], cx ; # of bytes read ! 187: xor ax,ax ! 188: ret ! 189: ! 190: IoctlRd endp ! 191: ! 192: ;****************************************************************************** ! 193: ; ! 194: ; DevOpen ! 195: ; ! 196: ; This routine is entered when a DOS application does a DOS OPEN to ! 197: ; this driver. The open request is passed along to the VDD. ! 198: ; ! 199: ;****************************************************************************** ! 200: DevOpen proc near ! 201: ! 202: mov ax, word ptr cs:[hVDD] ; VDD handle ! 203: mov dx, VDDOPEN ; Open file ! 204: DispatchCall ! 205: jnc @f ; jif Success ! 206: call Error ; Operation Failed ! 207: ret ! 208: @@: ! 209: xor ax,ax ! 210: ret ! 211: ! 212: DevOpen endp ! 213: ! 214: ;****************************************************************************** ! 215: ; ! 216: ; DevClose ! 217: ; ! 218: ; This routine is entered when a DOS application issues a CLOSE on the ! 219: ; handle for the driver. A close request is issued to the VDD. ! 220: ; ! 221: ;****************************************************************************** ! 222: DevClose proc near ! 223: ! 224: mov ax, word ptr cs:[hVDD] ; VDD handle ! 225: mov dx, VDDCLOSE ; Close file ! 226: ! 227: DispatchCall ! 228: jnc @f ; jif Success ! 229: call Error ; Operation Failed ! 230: ret ! 231: @@: ! 232: xor ax,ax ! 233: ret ! 234: ! 235: DevClose endp ! 236: ! 237: ! 238: ;****************************************************************************** ! 239: ; ! 240: ; INIT ! 241: ; ! 242: ; This routine is entered when the VDM is booting. The code in this ! 243: ; routine is only present during initialization. Here, a RegisterModule ! 244: ; is issued to get a handle to the VDD. This handle is then used by ! 245: ; the DispatchCall's in the other driver routines. ! 246: ; ! 247: ; If RegisterModule returns with error, then the driver indicates to ! 248: ; DOS that an error occurred. ! 249: ; ! 250: ;****************************************************************************** ! 251: Init proc near ! 252: push es ! 253: push di ; Save Request Header add ! 254: ! 255: push ds ! 256: pop es ! 257: ! 258: ; Load ioctlvdd.dll ! 259: mov si, offset DllName ; ds:si = dll name ! 260: mov di, offset InitFunc ; es:di = init routine ! 261: mov bx, offset DispFunc ; ds:bx = dispatch routine ! 262: ! 263: RegisterModule ! 264: jnc saveHVDD ; NC -> Success ! 265: ! 266: call Error ; Indicate failure ! 267: ! 268: pop di ! 269: pop es ! 270: mov byte ptr es:[di+13],0 ; unit supported 0 ! 271: mov word ptr es:[di+14],offset Header ; Unload this device ! 272: mov word ptr es:[di+16],cs ! 273: mov si, offset Header ! 274: and [si+4],8FFFh ; clear bit 15 for failure ! 275: ret ! 276: ! 277: saveHVDD: ! 278: mov [hVDD],ax ! 279: ! 280: pop di ! 281: pop es ! 282: mov word ptr es:[di+14],offset Init ; Free Memory address ! 283: mov word ptr es:[di+16],cs ! 284: xor ax,ax ; return success ! 285: ret ! 286: Init endp ! 287: ! 288: _TEXT ends ! 289: ! 290: end
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.