summaryrefslogtreecommitdiffstats
path: root/private/mvdm/vdd/samples/mscdex/tsr/mscdexnt.asm
blob: ca0ff46a12bed1d6156420620214646926283d40 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
        name    mscdexnt
;
;       MSCDEXNT
;
;   Author: Neil Sandlin (neilsa)
;
;   Description:
;
;       This TSR implements the v86 mode portion of MSCDEX support under
;       NT. Basically, all this piece does is hook INT2F and watch for
;       MSCDEX calls. When the first one occurs, it tries to load VCDEX.DLL.
;       If that succeeds, it passes the call (and all subsequent calls)
;       to VCDEX for processing.
;
        include isvbop.inc
        include mscdexnt.inc

_TEXT   segment word public 'CODE'
        assume cs:_TEXT,ds:_TEXT,es:_TEXT

;*-----------------------  TSR Code --------------------------*

DrvStrat proc   far              ; Strategy Routine
        ret
DrvStrat endp

DrvIntr proc    far                     ; INterrupt routine
        ret
DrvIntr endp

;******************************************************************************
;
;       Int2FHook
;
;
;******************************************************************************
Int2FHook  proc    near

        cmp     ah, MSCDEX_ID               ;MSCDEX?
        jnz     int2fchain                  ;no
        cmp     al, MAX_MSCDEX_CMD          ;command too high?
        ja      int2fchain                  ;yes

        cmp     word ptr cs:[hVDD], 0       ;zero is an invalid module handle
        jnz     callvdd                     ;registered ok

        cmp     byte ptr cs:[fVDDChecked],1
        jz      vddfailed

        call    RegisterVDD
        jc      vddfailed                   ;didn't get it

callvdd:
        push    ax                          ;put ax on stack
        mov     ax, word ptr cs:[hVDD]
        DispatchCall
        add     sp, 2                       ;vdd has set ax accordingly
        iret                                ;svc handled, return to caller

vddfailed:
        or      al,al
        jnz     try_0b
        xor     bx,bx
        jmp     short int2f_done
try_0b:
        cmp     al,0bh
        jne     int2f_done
;; williamh - June 1 1993 - if unable to load VDD, we should tell
;;			    the caller that the drive is NOT a cd rom.
	xor	ax, ax
	mov	bx,0adadh
int2f_done:
        iret

int2fchain:
        jmp     dword ptr cs:[oldint]

Int2FHook  endp

;****************************************************************************
;
;       RegisterVDD
;
;****************************************************************************
RegisterVDD proc    near

        push    ax
        push    bx
        push    cx
        push    dx
        push    si
        push    di
        push    ds
        push    es


        mov     ax, cs
        mov     ds, ax
        mov     es, ax
        ; Load vcdex.dll
        mov     si, offset DllName      ; ds:si = dll name
        mov     di, offset InitFunc     ; es:di = init routine
        mov     bx, offset DispFunc     ; ds:bx = dispatch routine

        push    cs                      ; pass far pointer to headers
        pop     cx                      ; in cx:dx
        mov     dx, offset drive_header

        RegisterModule
        jc      errorexit               ; jif error
        mov     cs:[hVDD],ax            ; save handle

errorexit:
        mov     byte ptr cs:[fVDDChecked],1
        pop     es
        pop     ds
        pop     di
        pop     si
        pop     dx
        pop     cx
        pop     bx
        pop     ax
        ret

RegisterVDD endp

;*-----------------------  TSR Data Area ---------------------*
oldint  dd      0
hVDD    DW      0

fVDDChecked DB  0       ; 0 - VDD never called. 1 - VDD once called.

DllName DB      "VCDEX.DLL",0
InitFunc  DB    "VDDRegisterInit",0
DispFunc  DB    "VDDDispatch",0


        ALIGN   16
drive_header:
        DrvHd   'MSCDEX00'

        ALIGN   16
Init_Fence:
;*-------------------------- Initialization Code ----------------------*

mscdexnt proc    far

        ; at this point es,ds -> PSP
        ; SS:SP points to stack

        ; first check that we are running under NT

        mov     ax, GET_NT_VERSION
        int     21h
        cmp     bl, NT_MAJOR_VERSION
        je      cdx_chk_more
        jmp     cdx_badver
cdx_chk_more:
        cmp     bh, NT_MINOR_VERSION
        je      cdx_ver_ok
        jmp     cdx_badver

cdx_ver_ok:
        ; Now check that this TSR is'nt already installed
        mov     ah,MSCDEX_ID
        mov     al,0bh                  ; call function 0b
        int     MPX_INT                 ; int 2f

        cmp     bx,0adadh
        jne     cdx_chks_done
        jmp     cdx_installed

cdx_chks_done:

        ; free the env segment

        push    es
        push    ds
        mov     es, es:[2ch]
        mov     ah, 49h
        int     21h

        mov     ah, DOS_GET_VECTOR
        mov     al, MPX_INT             ; 2f
        int     21h                     ; get old vector
        mov     WORD PTR cs:oldint,bx   ; save old vector here
        mov     WORD PTR cs:oldint+2,es

        mov     dx, offset Int2FHook
        push    cs                      ; get current code segment
        pop     ds
        mov     ah, DOS_SET_VECTOR
        mov     al, MPX_INT             ; vector to hook
        int     21h                     ; hook that vector

;
; Compute size of TSR area
;
        pop     ds
        pop     es
        mov     dx, offset Init_Fence   ; end of fixed TSR code
        mov     cl, 4                   ; divide by 16
        shr     dx, cl
        add     dx, 16                  ; add in PSP
;
; Terminate and stay resident
;
        mov     ah, DOS_TSR             ; TSR
        mov     al, 0
        int     21h                     ; TSR

cdx_badver:
        mov     dx, offset Message1
        push    cs
        pop     ds
        mov     ah,09h
        int     21h
        jmp     short cdx_exit

cdx_installed:
        mov     dx, offset Message2
        push    cs
        pop     ds
        mov     ah,09h
        int     21h

cdx_exit:
        mov     ax,4c00h                 ; Exit
        int     21h

mscdexnt endp

        include messages.inc

_TEXT   ends

InitStack       segment para stack 'STACK'

        dw      256 dup (?)

top_of_stack    equ     $

InitStack       ends

        end     mscdexnt