|
|
1.1 root 1: name faxdrv
2: title 'FAX16 - Stub driver for Application based intercept under NT'
3:
4: ;
5: ; fax16.asm: This is a very simple DOS stub device driver for NTVDM.
6: ; It shows how to use application based intercept services
7: ; provided by NTVDM. FAX32.dll is its DLL which will be loaded
8: ; in the NTVDM process by this stub device driver.
9: ;
10: ; This driver only has meaningful code for init,read and write.
11: ; Rest all command codes always succeed. We are assuming here
12: ; that the 16 bit fax application for this stub device driver
13: ; opens this device and just make read and write calls. The
14: ; meaning of read is to get a fax message and write means
15: ; send a message
16:
17: _TEXT segment byte public 'CODE'
18:
19: assume cs:_TEXT,ds:_TEXT,es:NOTHING
20:
21: org 0
22:
23: include isvbop.inc
24:
25: MaxCmd equ 24 ; Maximum allowed command
26:
27: ; VDD Command codes
28:
29: OpGet equ 1 ; Read a FAX
30: OpSend equ 2 ; Send a FAX
31:
32: Header: ; Fax Device Header
33: DD -1
34: DW 0c840h
35: DW FaxStrat
36: DW FaxIntr
37: DB 'FAXDRV00'
38:
39: RHPtr DD ? ; Pointer to Request Header
40:
41: Dispatch: ; Interrupt routine command code
42: DW Init
43: DW MediaChk
44: DW BuildBPB
45: DW IoctlRd
46: DW Read
47: DW NdRead
48: DW InpStat
49: DW InpFlush
50: DW Write
51: DW WriteVfy
52: DW OutStat
53: DW OutFlush
54: DW IoctlWt
55: DW DevOpen
56: DW DevClose
57: DW RemMedia
58: DW OutBusy
59: DW Error
60: DW Error
61: DW GenIOCTL
62: DW Error
63: DW Error
64: DW Error
65: DW GetLogDev
66: DW SetLogDev
67:
68: DllName DB "FAX32.DLL",0
69: InitFunc DB "FAXVDDRegisterInit",0
70: DispFunc DB "FAXVDDDispatch",0
71:
72: F32Mes DB "We are called from 32 staff", 10, 13, "$"
73:
74: hVDD DW ?
75:
76: FaxStrat proc far ; Strategy Routine
77:
78: mov word ptr cs:[RhPtr],bx
79: mov word ptr cs:[RhPtr+2],es
80: ret
81:
82: FaxStrat endp
83:
84: FaxIntr proc far ; INterrupt routine
85:
86: push ax ; Save registers
87: push bx
88: push cx
89: push dx
90: push ds
91: push es
92: push di
93: push si
94: push bp
95:
96: push cs
97: pop ds ; DS = CS
98:
99: les di,[RHPtr] ; ES:DI = request header
100:
101: mov bl,es:[di+2]
102: xor bh,bh ; BX = command code
103: cmp bx,MaxCmd
104: jle FIntr1
105:
106: call Error ; Unknown command
107: jmp FIntr2
108:
109: FIntr1:
110: shl bx,1
111: call word ptr [bx+Dispatch] ; call command routine
112: les di,[RhPtr] ; ES:DI = request header
113:
114: FIntr2:
115: or ax,0100h ; Set Done bit in the status
116: mov es:[di+3],ax ; Store the status
117:
118: pop bp ; restore registers
119: pop si
120: pop di
121: pop es
122: pop ds
123: pop dx
124: pop cx
125: pop bx
126: pop ax
127:
128: ret
129:
130:
131: MediaChk proc near
132: xor ax,ax
133: ret
134: MediaChk endp
135:
136: BuildBPB proc near
137: xor ax,ax
138: ret
139: BuildBPB endp
140:
141: IoctlRd proc near
142: xor ax,ax
143: ret
144: IoctlRd endp
145:
146: Read proc near
147: push es
148: push di ; Save Request Header add
149:
150: mov bx,word ptr es:[di+14] ; buffer offset
151: mov ax,word ptr es:[di+16] ; buffer segment
152: mov cx,word ptr es:[di+18] ; buffer length
153:
154: mov es,ax ; es:bx is the buffer where
155: ; fax has to be read from
156: ; the NT device driver
157:
158: mov ax,word ptr cs:[hVDD] ; VDD handle returned by
159: ; register module
160: mov dx,OpGet ; Read the fax command
161:
162: DispatchCall
163:
164: pop di
165: pop es
166:
167: jnc rOK ; NC -> Success and CX has
168: ; the count read.
169:
170: call Error ; Operation Failed
171: ret
172:
173: rOK:
174: mov word ptr es:[di+12],cx ; return in header how much
175: ; was read
176: xor ax,ax
177: ret
178: Read endp
179:
180: NdRead proc near
181: xor ax,ax
182: ret
183: NdRead endp
184:
185: InpStat proc near
186: xor ax,ax
187: ret
188: InpStat endp
189:
190: InpFlush proc near
191: xor ax,ax
192: ret
193: InpFlush endp
194:
195: Write proc near
196: push es
197: push di ; Save Request Header add
198:
199: mov bx,word ptr es:[di+14] ; buffer offset
200: mov ax,word ptr es:[di+16] ; buffer segment
201: mov cx,word ptr es:[di+18] ; buffer length
202:
203: mov es,ax ; es:bx is the FAX message where
204: ; to be send by NT device
205: ; driver
206:
207: mov ax,word ptr cs:[hVDD] ; VDD handle returned by
208: ; register module
209: mov dx,OpSend ; Send the fax command
210:
211: DispatchCall
212:
213: pop di
214: pop es
215:
216: jnc wOK ; NC -> Success and CX has
217: ; the count read.
218:
219: call Error ; Operation Failed
220: ret
221:
222: wOK:
223: mov word ptr es:[di+12],cx ; return in header how much
224: ; was actually written
225: xor ax,ax
226: ret
227: Write endp
228:
229: WriteVfy proc near
230: xor ax,ax
231: ret
232: WriteVfy endp
233:
234: OutStat proc near
235: xor ax,ax
236: ret
237: OutStat endp
238:
239: OutFlush proc near
240: xor ax,ax
241: ret
242: OutFlush endp
243:
244: IoctlWt proc near
245: xor ax,ax
246: ret
247: IoctlWt endp
248:
249: DevOpen proc near
250: xor ax,ax
251: ret
252: DevOpen endp
253:
254: DevClose proc near
255: xor ax,ax
256: ret
257: DevClose endp
258:
259: RemMedia proc near
260: xor ax,ax
261: ret
262: RemMedia endp
263:
264: OutBusy proc near
265: xor ax,ax
266: ret
267: OutBusy endp
268:
269: GenIOCTL proc near
270: xor ax,ax
271: ret
272: GenIOCTL endp
273:
274: GetLogDev proc near
275: xor ax,ax
276: ret
277: GetLogDev endp
278:
279: SetLogDev proc near
280: xor ax,ax
281: ret
282: SetLogDev endp
283:
284: Error proc near
285: mov ax,8003h ; Bad Command Code
286: ret
287: Error endp
288: ;
289: ;
290: ; This function is a sample sub that calling from 32-bits part of VDD
291: ;
292: From32Sub proc near
293:
294: push cs
295: pop ds
296: mov dx, offset F32mes
297: mov ah, 09h
298: int 21h
299: VDDUnSimulate16
300: ret
301:
302: From32Sub endp
303:
304: Init proc near
305: push es
306: push di ; Save Request Header add
307:
308: push ds
309: pop es
310:
311: ; Load fax32.dll
312: mov si, offset DllName ; ds:si = fax32.dll
313: mov di, offset InitFunc ; es:di = init routine
314: mov bx, offset DispFunc ; ds:bx = dispatch routine
315: mov ax, offset From32Sub ; ds:ax = From32Sub
316:
317:
318: RegisterModule
319: jnc saveHVDD ; NC -> Success
320:
321: call Error ; Indicate failure
322:
323: pop di
324: pop es
325: mov byte ptr es:[di+13],0 ; unit supported 0
326: mov word ptr es:[di+14],offset Header ; Unload this device
327: mov word ptr es:[di+16],cs
328: mov si, offset Header
329: and [si+4],8FFFh ; clear bit 15 for failure
330: ret
331:
332: saveHVDD:
333: mov [hVDD],ax
334:
335: pop di
336: pop es
337: mov word ptr es:[di+14],offset Init ; Free Memory address
338: mov word ptr es:[di+16],cs
339:
340: xor ax,ax ; return success
341: ret
342: Init endp
343:
344: FaxIntr endp
345:
346: _TEXT ends
347:
348: end
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.