summaryrefslogtreecommitdiffstats
path: root/private/ntos/nbt/vxd/cvxdfile.asm
blob: 451f185013d91489d240761efbb2b09d269797a7 (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
;/**********************************************************************/
;/**                       Microsoft Windows/NT                       **/
;/**                Copyright(c) Microsoft Corp., 1994                **/
;/**********************************************************************/

;/*
;    cvxdFile.asm
;
;    Contains simple VXD File I/O routines (that use VxdInt 21h macro)
;        for dhcp.bin support
;
;    FILE HISTORY:
;        madana   07-May-1994     Created
;        koti     10-Oct-1994     Copied over/modified for vnbt
;
;*/

        .386p
        include vmm.inc
        include v86mmgr.inc
        include dosmgr.inc
        include opttest.inc
        include netvxd.inc
        include debug.inc
        include pageable.inc

EXTRN _fInInit:DWORD
EXTRN _GetInDosFlag:NEAR


;****************************************************************************
;**     PushState Macro
;
;  Saves the client state.
;
PushState MACRO

    push    edi
    push    esi
    push    ebx

    mov     ecx, 0
    VMMCall Begin_Critical_Section

ENDM

;****************************************************************************
;**     PopState Macro
;
;  Restores client state.
;
PopState MACRO

    VMMCall End_Critical_Section

    pop     ebx
    pop     esi
    pop     edi

ENDM

NBT_PAGEABLE_CODE_SEG

;****************************************************************************
;**     _VxdFileOpen
;
;       Opens a file
;
;       Entry:  [ESP+4] - Pointer to full path of file, path must be flat
;                               pointer.
;
;       Exit: EAX will contain a handle to the openned file
;
BeginProc _VxdFileOpen

        PushState                       ; This pushes lots of crap

        mov     edx, [esp+16]           ; move flat pointer file name
        mov     eax, 3d02h              ; Open file, read/write, share

        VxDInt 21h

        jc      VFO_6                   ; Carry set if error
        jmp     VFO_10                  ; successful file open, eax has file handle

VFO_6:
;        Debug_Out "VxdFileOpen failed, error #EAX"
        mov     eax, 0                  ; Failed to open the file

VFO_10:
        PopState
        ret

EndProc _VxdFileOpen


;****************************************************************************
;**     _VxdFileRead
;
;       Reads x bytes from a previously openned file
;
;       Entry:  [ESP+4] - Handle from _VxdFileOpen
;               [ESP+8] - Count of bytes to read
;               [ESP+12]- flat pointer to destination buffer
;
;       Exit: EAX will contain the number of bytes read, 0 if EOF or
;             an error occurred.
;
BeginProc _VxdFileRead

        PushState                       ; Pushes lots of crap

        mov     ebx, [esp+16]           ; File Handle
        mov     ecx, [esp+20]           ; Bytes to read
        mov     edx, [esp+24]           ; flat buffer pointer
        mov     eax, 3f00h

        VxDInt 21h

        jc      VFR_6                   ; Carry set if error
        jmp     VFR_7                   ; successful file open, eax has bytes read

VFR_6:
;        Debug_Out "VxdFileRead failed"
        mov     eax, 0                  ; Failed to read the file
VFR_7:
        PopState
        ret

EndProc _VxdFileRead

;****************************************************************************
;**     _VxdFileClose
;
;       Closes a file openned with VxdOpenFile
;
;       Entry:  [ESP+4] - Handle from _VxdFileOpen
;
BeginProc _VxdFileClose

        PushState                       ; Pushes lots of crap

        mov     ebx, [esp+16]           ; File Handle
        mov     eax, 3e00h

        VxDInt 21h

        jc      VFCL_6                   ; Carry set if error
        jmp     VFCL_7                   ; successful set.

VFCL_6:
        Debug_Out "VxdFileClose - Read failed"
        mov     eax, 0                  ; Failed to close the file
VFCL_7:
        PopState
        ret

EndProc _VxdFileClose

;****************************************************************************
;**     _VxdWindowsPath
;
;       Gets a pointer to (null-terminated) path to the windows directory
;
;       This is an Init time only routine
;
;       Entry:  nothing
;
;       Exit: pointer to path to windows directory
;
BeginProc _VxdWindowsPath
        PushState                       ; Pushes lots of crap

        VmmCall Get_Config_Directory

        mov     eax, edx                ; path is returned in edx

        PopState                        ; now pop all that crap

        ret

EndProc _VxdWindowsPath

NBT_PAGEABLE_CODE_ENDS

END