Subversion Repositories SvarDOS

Rev

Rev 2042 | Rev 2045 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2042 Rev 2044
Line 75... Line 75...
75
  findData->dwReserved1 = 0;
75
  findData->dwReserved1 = 0;
76
}
76
}
77
 
77
 
78
HANDLE FindFirstFile(const char *pathname, struct WIN32_FIND_DATA *findData)
78
HANDLE FindFirstFile(const char *pathname, struct WIN32_FIND_DATA *findData)
79
{
79
{
80
  char path[1024];
80
  static char path[1024];
81
  HANDLE hnd;
81
  HANDLE hnd;
82
  short cflag = 0;  /* used to indicate if findfirst is succesful or not */
82
  short cflag = 0;  /* used to indicate if findfirst is succesful or not */
83
 
83
 
84
  /* verify findData is valid */
84
  /* verify findData is valid */
85
  if (findData == NULL)
85
  if (findData == NULL)
Line 97... Line 97...
97
  memset(findData, 0, sizeof(struct WIN32_FIND_DATA));
97
  memset(findData, 0, sizeof(struct WIN32_FIND_DATA));
98
 
98
 
99
  /* First try DOS LFN (0x714E) findfirst, going to old (0x4E) if error */
99
  /* First try DOS LFN (0x714E) findfirst, going to old (0x4E) if error */
100
  if (LFN_Enable_Flag)
100
  if (LFN_Enable_Flag)
101
  {
101
  {
-
 
102
    unsigned short attr = searchAttr;
-
 
103
    unsigned short varax = 0xffff;
-
 
104
    unsigned short finddata_seg = FP_SEG(findData);
-
 
105
    unsigned short finddata_off = FP_OFF(findData);
-
 
106
    unsigned char cf = 1;
-
 
107
    unsigned short pathname_seg = FP_SEG(pathname);
-
 
108
    unsigned short pathname_off = FP_OFF(pathname);
102
    hnd->flag = FINDFILELFN;
109
    hnd->flag = FINDFILELFN;
103
 
110
 
104
    asm {
111
    _asm {
-
 
112
      push ax
-
 
113
      push bx
-
 
114
      push cx
-
 
115
      push dx
105
      STC                          //; In case not supported
116
      push es
106
      PUSH SI                      //; Ensure borlands registers unmodified
117
      push si
107
      PUSH DI
118
      push di
-
 
119
 
-
 
120
      stc                          //; In case not supported
108
      MOV SI, 1                    //; same format as when old style used, set to 0 for 64bit value
121
      mov si, 1                    //; same format as when old style used, set to 0 for 64bit value
109
      MOV AX, DS                   //; Set address of findData into ES:DI
122
      mov di, finddata_off         //; Set address of findData into ES:DI
110
      MOV ES, AX
-
 
111
      MOV DI, [findData]
123
      mov es, finddata_seg
112
      MOV AX, 714Eh                //; LFN version of FindFirst
124
      mov ax, 0x714E               //; LFN version of FindFirst
-
 
125
      mov cx, attr
113
      MOV DX, [pathname]           //; Load DS:DX with pointer to path for Findfirt
126
      mov dx, pathname_off         //; Load DS:DX with pointer to path for Findfirst
114
    }
127
      push ds
115
    _CX = searchAttr;
128
      mov ds, pathname_seg
116
    asm {
-
 
117
      INT 21h                      //; Execute interrupt
129
      int 0x21                     //; Execute interrupt
-
 
130
      pop ds
118
      POP DI                       //; Restore DI
131
      jc lfnerror
-
 
132
      mov cf, 0
-
 
133
      mov varax, ax
-
 
134
      lfnerror:
-
 
135
 
-
 
136
      pop di
-
 
137
      pop si
-
 
138
      pop es
-
 
139
      pop dx
-
 
140
      pop cx
-
 
141
      pop bx
-
 
142
      pop ax
-
 
143
    }
-
 
144
    if (cf == 0) {
119
      POP SI                       //; Restore SI
145
      hnd->fhnd.handle = varax;  /* store handle finally :) */
120
      JC lfnerror
146
      return hnd;
121
    }
147
    }
122
    hnd->fhnd.handle = _AX;  /* store handle finally :) */
-
 
123
    return hnd;
-
 
124
 
148
 
125
lfnerror:
-
 
126
    /* AX is supposed to contain 7100h if function not supported, else real error */
149
    /* AX is supposed to contain 7100h if function not supported, else real error */
127
    /* However, FreeDOS returns AX = 1 = Invalid function number instead.         */
150
    /* However, FreeDOS returns AX = 1 = Invalid function number instead.         */
128
    if ((_AX != 0x7100) && (_AX != 0x0001))
151
    if ((varax != 0x7100) && (varax != 0x0001)) {
129
    {
-
 
130
      free(hnd);
152
      free(hnd);
131
      return INVALID_HANDLE_VALUE;
153
      return INVALID_HANDLE_VALUE;
132
    }
154
    }
133
  }
155
  }
134
 
156
 
Line 147... Line 169...
147
  {
169
  {
148
  int eos = strlen(path) - 1;
170
  int eos = strlen(path) - 1;
149
  if ((path[eos] == '*') && (path[eos - 1] == '\\')) strcat(path, ".*");
171
  if ((path[eos] == '*') && (path[eos - 1] == '\\')) strcat(path, ".*");
150
  }
172
  }
151
 
173
 
-
 
174
  {
-
 
175
    unsigned short ffdta_seg, ffdta_off;
-
 
176
    unsigned short path_seg, path_off;
-
 
177
    unsigned short sattr = searchAttr;
-
 
178
    ffdta_seg = FP_SEG((*hnd).fhnd.ffdtaptr);
-
 
179
    ffdta_off = FP_OFF((*hnd).fhnd.ffdtaptr);
-
 
180
    path_seg = FP_SEG(path);
-
 
181
    path_off = FP_OFF(path);
-
 
182
 
152
  asm {
183
  _asm {
-
 
184
    push ax
-
 
185
    push bx
-
 
186
    push cx
-
 
187
    push dx
-
 
188
    push es
-
 
189
 
153
    MOV AH, 2Fh                    //; Get Current DTA
190
    mov ah, 0x2F                   //; Get Current DTA
154
    INT 21h                        //; Execute interrupt, returned in ES:BX
191
    int 0x21                       //; Execute interrupt, returned in ES:BX
155
    PUSH BX                        //; Store its Offset, then Segment
192
    push bx                        //; Store its Offset, then Segment
156
    PUSH ES
193
    push es
157
    MOV AH, 1Ah                    //; Set Current DTA to our buffer, DS:DX
194
    mov ah, 0x1A                   //; Set Current DTA to our buffer, DS:DX
158
 }
-
 
159
    _DX = (WORD)(*hnd).fhnd.ffdtaptr;   //; Load our buffer for new DTA.
195
    mov dx, ffdta_off
160
 asm {
196
    push ds
-
 
197
    mov ds, ffdta_seg
161
    INT 21h                        //; Execute interrupt
198
    int 0x21                       //; Execute interrupt
-
 
199
    pop ds
162
    MOV AX, 4E00h                  //; Actual findfirst call
200
    mov ax, 0x4E00                 //; Actual findfirst call
-
 
201
    mov cx, sattr
163
    LEA DX, path                   //; Load DS:DX with pointer to path for Findfirt
202
    mov dx, path_off               //; Load DS:DX with pointer to path for Findfirt
164
  }
203
    push ds
165
    _CX = searchAttr;
204
    mov ds, path_seg
166
  asm {
-
 
167
    INT 21h                        //; Execute interrupt
205
    int 0x21                       //; Execute interrupt
-
 
206
    pop ds
168
    JNC success                    //; If carry is not set then succesful
207
    jnc success                    //; If carry is not set then succesful
169
    MOV [cflag], AX                //; Set flag with error.
208
    mov [cflag], ax                //; Set flag with error.
170
  }
-
 
171
success:
209
success:
172
  asm {
-
 
173
    MOV AH, 1Ah               //; Set Current DTA back to original, DS:DX
210
    mov ah, 0x1A              //; Set Current DTA back to original, DS:DX
174
    MOV DX, DS                //; Store DS, must be preserved
211
    mov dx, ds                //; Store DS, must be preserved
175
    POP DS                    //; Popping ES into DS since thats where we need it.
212
    pop ds                    //; Popping ES into DS since thats where we need it.
176
    POP BX                    //; Now DS:BX points to original DTA
213
    pop bx                    //; Now DS:BX points to original DTA
177
    INT 21h                   //; Execute interrupt to restore.
214
    int 0x21                  //; Execute interrupt to restore.
178
    MOV DS, DX                //; Restore DS
215
    mov ds, dx                //; Restore DS
-
 
216
 
-
 
217
    pop es
-
 
218
    pop dx
-
 
219
    pop cx
-
 
220
    pop bx
-
 
221
    pop ax
-
 
222
  }
179
  }
223
  }
180
 
224
 
181
  if (cflag)
225
  if (cflag)
182
  {
226
  {
183
    free(hnd->fhnd.ffdtaptr);
227
    free(hnd->fhnd.ffdtaptr);
Line 206... Line 250...
206
  memset(findData, 0, sizeof(struct WIN32_FIND_DATA));
250
  memset(findData, 0, sizeof(struct WIN32_FIND_DATA));
207
 
251
 
208
  /* Flag indicate if using LFN DOS (0x714F) or not */
252
  /* Flag indicate if using LFN DOS (0x714F) or not */
209
  if (hnd->flag == FINDFILELFN)
253
  if (hnd->flag == FINDFILELFN)
210
  {
254
  {
211
    _BX = hnd->fhnd.handle;        //; Move the Handle returned by previous findfirst into BX
255
    unsigned short handle = hnd->fhnd.handle;
-
 
256
    unsigned char cf = 0;
212
    asm {
257
    _asm {
-
 
258
      push ax
-
 
259
      push bx
-
 
260
      push cx
-
 
261
      push dx
-
 
262
      push es
-
 
263
      push si
-
 
264
      push di
-
 
265
 
213
      STC                          //; In case not supported
266
      mov bx, handle               //; Move the Handle returned by prev findfirst into BX
214
      PUSH SI                      //; Ensure borlands registers unmodified
267
      stc                          //; In case not supported
215
      PUSH DI
-
 
216
      MOV SI, 1                    //; same format as when old style used, set to 0 for 64bit value
268
      mov si, 1                    //; same format as when old style used, set to 0 for 64bit value
217
      MOV AX, DS                   //; Set address of findData into ES:DI
269
      mov ax, ds                   //; Set address of findData into ES:DI
218
      MOV ES, AX
270
      mov es, ax
219
      MOV DI, [findData]
271
      mov di, [findData]
220
      MOV AX, 714Fh                //; LFN version of FindNext
272
      mov ax, 0x714F               //; LFN version of FindNext
221
      INT 21h                      //; Execute interrupt
273
      int 0x21                     //; Execute interrupt
222
      POP DI                       //; Restore DI
274
      jnc DONE
223
      POP SI                       //; Restore SI
275
      mov cf, 1
-
 
276
      DONE:
-
 
277
 
-
 
278
      pop di
-
 
279
      pop si
224
      JC lfnerror
280
      pop es
-
 
281
      pop dx
-
 
282
      pop cx
-
 
283
      pop bx
-
 
284
      pop ax
225
    }
285
    }
226
    return 1;   /* success */
286
    if (cf == 0) return 1;   /* success */
227
 
-
 
228
lfnerror:
-
 
229
    return 0;   /* Any errors here, no other option but to return error/no more files */
287
    return 0;   /* Any errors here, no other option but to return error/no more files */
230
  }
-
 
231
  else  /* Use DOS (0x4F) findnext, returning if error */
288
  } else { /* Use DOS (0x4F) findnext, returning if error */
-
 
289
    unsigned short dta_seg = FP_SEG((*hnd).fhnd.ffdtaptr);
-
 
290
    unsigned short dta_off = FP_OFF((*hnd).fhnd.ffdtaptr);
232
  {
291
    _asm {
-
 
292
      push ax
-
 
293
      push bx
-
 
294
      push cx
-
 
295
      push dx
233
    asm {
296
      push es
-
 
297
 
234
      MOV AH, 2Fh                   //; Get Current DTA
298
      mov ah, 0x2F                  //; Get Current DTA
235
      INT 21h                       //; Execute interrupt, returned in ES:BX
299
      int 0x21                      //; Execute interrupt, returned in ES:BX
236
      PUSH BX                       //; Store its Offset, then Segment
300
      push bx                       //; Store its Offset, then Segment
237
      PUSH ES
301
      push es
238
    }
-
 
239
    _DX = (WORD)(*hnd).fhnd.ffdtaptr;    //; Load our buffer for new DTA.
302
      mov ax, 0x1A00                //; Set Current DTA to our buffer, DS:DX
-
 
303
      mov dx, dta_off
240
    asm {
304
      push ds
241
      MOV AX, 1A00h                 //; Set Current DTA to our buffer, DS:DX
305
      mov ds, dta_seg
242
      INT 21h                       //; Execute interrupt
306
      int 0x21                      //; Execute interrupt
-
 
307
      pop ds
243
      MOV AX, 4F00h                 //; Actual findnext call
308
      mov ax, 0x4F00                //; Actual findnext call
244
      INT 21h                       //; Execute interrupt
309
      int 0x21                      //; Execute interrupt
245
      JNC success                   //; If carry is not set then succesful
310
      JNC success                   //; If carry is not set then succesful
246
      MOV [cflag], AX               //; Set flag with error.
311
      mov [cflag], ax               //; Set flag with error.
247
    }
-
 
248
success:
312
success:
249
    asm {
-
 
250
      MOV AH, 1Ah                   //; Set Current DTA back to original, DS:DX
313
      mov ah, 0x1A                  //; Set Current DTA back to original, DS:DX
251
      MOV DX, DS                    //; Store DS, must be preserved
314
      MOV dx, ds                    //; Store DS, must be preserved
252
      POP DS                        //; Popping ES into DS since thats where we need it.
315
      pop ds                        //; Popping ES into DS since thats where we need it.
253
      POP BX                        //; Now DS:BX points to original DTA
316
      pop bx                        //; Now DS:BX points to original DTA
254
      INT 21h                       //; Execute interrupt to restore.
317
      int 0x21                      //; Execute interrupt to restore.
255
      MOV DS, DX                    //; Restore DS
318
      mov ds, dx                    //; Restore DS
-
 
319
 
-
 
320
      pop es
-
 
321
      pop dx
-
 
322
      pop cx
-
 
323
      pop bx
-
 
324
      pop ax
256
    }
325
    }
257
 
326
 
258
  if (cflag)
-
 
259
    return 0;
327
  if (cflag) return 0;
260
 
328
 
261
  /* copy its results over */
329
  /* copy its results over */
262
  copyFileData(findData, hnd->fhnd.ffdtaptr);
330
  copyFileData(findData, hnd->fhnd.ffdtaptr);
263
 
331
 
264
  return 1;
332
  return 1;
Line 279... Line 347...
279
        free(hnd->fhnd.ffdtaptr);
347
        free(hnd->fhnd.ffdtaptr);
280
      hnd->fhnd.ffdtaptr = NULL;
348
      hnd->fhnd.ffdtaptr = NULL;
281
    }
349
    }
282
    else /* must call LFN findclose */
350
    else /* must call LFN findclose */
283
    {
351
    {
284
      _BX = hnd->fhnd.handle;     /* Move handle returned from findfirst into BX */
352
      unsigned short handle = hnd->fhnd.handle;
285
      asm {
353
      _asm {
-
 
354
        push ax
-
 
355
        push bx
-
 
356
 
-
 
357
        mov bx, handle            /* Move handle returned from findfirst into BX */
286
        STC
358
        stc
287
        MOV AX, 71A1h
359
        mov ax, 0x71A1
288
        INT 21h                   /* carry set on error */
360
        int 0x21                  /* carry set on error */
-
 
361
 
-
 
362
        pop bx
-
 
363
        pop ax
289
      }
364
      }
290
      hnd->fhnd.handle = 0;
365
      hnd->fhnd.handle = 0;
291
    }
366
    }
292
 
367
 
293
    free(hnd);                    /* Free memory used for the handle itself */
368
    free(hnd);                    /* Free memory used for the handle itself */
Line 314... Line 389...
314
/* returns zero on failure, if lpRootPathName is NULL or "" we use current
389
/* returns zero on failure, if lpRootPathName is NULL or "" we use current
315
 * default drive. */
390
 * default drive. */
316
int GetVolumeInformation(const char *lpRootPathName, char *lpVolumeNameBuffer,
391
int GetVolumeInformation(const char *lpRootPathName, char *lpVolumeNameBuffer,
317
  DWORD nVolumeNameSize, DWORD *lpVolumeSerialNumber) {
392
  DWORD nVolumeNameSize, DWORD *lpVolumeSerialNumber) {
318
 
393
 
319
  /* File info for getting  Volume Label (using directory entry) */
-
 
320
  struct FFDTA finfo;
-
 
321
 
-
 
322
  /* Using DOS interrupt to get serial number */
394
  /* Using DOS interrupt to get serial number */
323
  struct media_info
395
  struct media_info {
324
  {
-
 
325
    short dummy;
396
    short dummy;
326
    DWORD serial;
397
    DWORD serial;
327
    char volume[11];
398
    char volume[11];
328
    short ftype[8];
399
    short ftype[8];
329
  } media;
400
  } media;
Line 340... Line 411...
340
   * 2 = LFN api unsupported (tentative failure)
411
   * 2 = LFN api unsupported (tentative failure)
341
   */
412
   */
342
  int cflag=2;
413
  int cflag=2;
343
 
414
 
344
  /* validate root path to obtain info on, NULL or "" means use current */
415
  /* validate root path to obtain info on, NULL or "" means use current */
345
  if ((lpRootPathName == NULL) || (*lpRootPathName == '\0'))
416
  if ((lpRootPathName == NULL) || (*lpRootPathName == '\0')) {
346
  {
-
 
347
    /* Assume if NULL user wants current drive, eg C:\ */
417
    /* Assume if NULL user wants current drive, eg C:\ */
348
    asm {
418
    _asm {
-
 
419
      push ax
-
 
420
      push bx
-
 
421
 
349
      MOV AH, 19h             //; Get Current Default Drive
422
      mov ah, 0x19            //; Get Current Default Drive
350
      INT 21h                 //; returned in AL, 0=A, 1=B,...
423
      int 0x21                //; returned in AL, 0=A, 1=B,...
351
      LEA BX, pathname        //; load pointer to our buffer
424
      lea bx, pathname        //; load pointer to our buffer
352
      ADD AL, 'A'             //; Convert #returned to a letter
425
      add al, 'A'             //; Convert #returned to a letter
353
      MOV [BX], AL            //; Store drive letter
426
      mov [bx], al            //; Store drive letter
354
      INC BX                  //; point to next character
427
      inc bx                  //; point to next character
355
      MOV BYTE PTR [BX], ':'  //; Store the colon
428
      mov byte ptr [bx], ':'  //; Store the colon
356
      INC BX
429
      inc bx
357
      MOV BYTE PTR [BX], '\'  //; and the \ (this gets converted correctly as a single \
430
      mov byte ptr [bx], '\'  //; this gets converted correctly as a single bkslsh
358
      INC BX
431
      inc bx
359
      MOV BYTE PTR [BX], 0    //; Most importantly the '\0' terminator
432
      mov byte ptr [bx], 0    //; Most importantly the '\0' terminator
-
 
433
 
-
 
434
      pop bx
-
 
435
      pop ax
360
    }
436
    }
361
  } else {
437
  } else {
362
    strcpy(pathname, lpRootPathName);
438
    strcpy(pathname, lpRootPathName);
363
  }
439
  }
364
 
440
 
365
  /* Flag indicate if using LFN DOS or not */
441
  /* Flag indicate if using LFN DOS or not */
366
  if (LFN_Enable_Flag)
442
  if (LFN_Enable_Flag)
367
  {
443
  {
368
    asm {
444
    _asm {
-
 
445
      push ax
-
 
446
      push bx
-
 
447
      push cx
-
 
448
      push dx
-
 
449
      push es
-
 
450
      push di
-
 
451
 
369
      MOV AX, 71A0h            //; LFN GetVolumeInformation
452
      mov ax, 0x71A0           //; LFN GetVolumeInformation
370
      PUSH DI                  //; Preserve DI for borland
-
 
371
      MOV DX, DS               //; Load buffer for file system name into ES:DI
453
      mov dx, ds               //; Load buffer for file system name into ES:DI
372
      MOV ES, DX
454
      MOV es, dx
373
      LEA DI, fsystem
455
      lea di, fsystem
374
      MOV CX, 32               //; size of ES:DI buffer
456
      mov cx, 32               //; size of ES:DI buffer
375
      LEA DX, pathname         //; Load root name into DS:DX
457
      lea dx, pathname         //; Load root name into DS:DX
376
      STC                      //; in case LFN api unsupported
458
      stc                      //; in case LFN api unsupported
377
      INT 21h
459
      int 0x21
378
      POP DI                   //; restore Borland's register
460
      jc getvolerror           //; on any error skip storing any info
379
      JC getvolerror           //; on any error skip storing any info
461
      mov cflag, 0             //; indicate no error
380
    }
462
      jmp endgetvol
381
    /* store stuff
463
    /* store stuff
382
	    BX = file system flags (see #01783)
464
       BX = file system flags (see #01783)
383
	    CX = maximum length of file name [usually 255]
465
       CX = maximum length of file name [usually 255]
384
	    DX = maximum length of path [usually 260]
466
       DX = maximum length of path [usually 260]
385
	    fsystem buffer filled (ASCIZ, e.g. "FAT","NTFS","CDFS")
467
       fsystem buffer filled (ASCIZ, e.g. "FAT","NTFS","CDFS")
386
    */
468
    */
387
    cflag = 0;                 //; indicate no error
-
 
388
    goto endgetvol;
-
 
389
 
-
 
390
getvolerror:
469
getvolerror:
391
    asm {
-
 
392
      CMP AX, 7100h            //; see if real error or unsupported
470
      cmp ax, 0x7100           //; see if real error or unsupported
393
      JE endgetvol             //; if so skip ahead
471
      je endgetvol             //; if so skip ahead
394
      CMP AX, 0001h            //; FreeDOS returns AX = 1 = Invalid function number
472
      cmp ax, 0x0001           //; FreeDOS returns AX = 1 = Invalid function number
395
      JE endgetvol
473
      je endgetvol
396
    }
-
 
397
    cflag = 1;                 //; indicate failure
474
      mov cflag, 1             //; indicate failure
398
 
-
 
399
endgetvol:
475
endgetvol:
-
 
476
 
-
 
477
      pop di
-
 
478
      pop es
-
 
479
      pop dx
-
 
480
      pop cx
-
 
481
      pop bx
-
 
482
      pop ax
-
 
483
    }
400
  }
484
  }
401
 
485
 
402
 
486
 
403
  if (cflag != 1)  /* if no error validating volume info or LFN getVolInfo unsupported */
487
  if (cflag != 1)  /* if no error validating volume info or LFN getVolInfo unsupported */
404
  {
488
  {
405
    /* if a drive, test if valid, get volume, and possibly serial # */
489
    /* if a drive, test if valid, get volume, and possibly serial # */
406
    if (pathname[1] == ':')
490
    if (pathname[1] == ':') {
-
 
491
      struct FFDTA finfo;
-
 
492
      unsigned short attr_seg = FP_SEG(finfo.ff_attr);
-
 
493
      unsigned short attr_off = FP_OFF(finfo.ff_attr);
-
 
494
      unsigned short finfo_seg = FP_SEG(&finfo);
-
 
495
      unsigned short finfo_off = FP_OFF(&finfo);
-
 
496
      unsigned short pathname_seg = FP_SEG(pathname);
-
 
497
      unsigned short pathname_off = FP_OFF(pathname);
407
    {
498
 
408
      /* assume these calls will succeed, change on an error */
499
      /* assume these calls will succeed, change on an error */
409
      cflag = 0;
500
      cflag = 0;
410
 
501
 
411
      /* get path ending in \*.*, */
502
      /* get path ending in \*.*, */
412
      if (pathname[strlen(pathname)-1] != '\\')
503
      if (pathname[strlen(pathname)-1] != '\\')
Line 415... Line 506...
415
	strcat(pathname, "*.*");
506
	strcat(pathname, "*.*");
416
 
507
 
417
      /* Search for volume using old findfirst, as LFN version (NT5 DOS box) does
508
      /* Search for volume using old findfirst, as LFN version (NT5 DOS box) does
418
       * not recognize FILE_ATTRIBUTE_LABEL = 0x0008 as label attribute.
509
       * not recognize FILE_ATTRIBUTE_LABEL = 0x0008 as label attribute.
419
       */
510
       */
420
      asm {
511
      _asm {
-
 
512
        push ax
-
 
513
        push bx
-
 
514
        push cx
-
 
515
        push dx
-
 
516
        push es
-
 
517
 
421
	MOV AH, 2Fh               //; Get Current DTA
518
        mov ah, 0x2F              //; Get Current DTA
422
	INT 21h                   //; Execute interrupt, returned in ES:BX
519
        int 0x21                  //; Execute interrupt, returned in ES:BX
423
	PUSH BX                   //; Store its Offset, then Segment
520
        push bx                   //; Store its Offset, then Segment
424
	PUSH ES
521
        push es
425
	MOV AH, 1Ah               //; Set Current DTA to our buffer, DS:DX
522
        mov ah, 0x1A              //; Set Current DTA to our buffer, DS:DX
426
	LEA DX, finfo       	    //; Load our buffer for new DTA.
523
        mov dx, finfo_off         //; Load our buffer for new DTA.
-
 
524
        push ds
-
 
525
        mov ds, finfo_seg
427
	INT 21h                   //; Execute interrupt
526
        int 0x21                  //; Execute interrupt
-
 
527
        pop ds
428
	MOV AX, 4E00h             //; Actual findfirst call
528
        mov ax, 0x4E00            //; Actual findfirst call
-
 
529
        mov cx, FILE_ATTRIBUTE_LABEL
429
	LEA DX, pathname          //; Load DS:DX with pointer to modified RootPath for Findfirt
530
        mov dx, pathname_off      //; Load DS:DX with pointer to modified RootPath for Findfirt
-
 
531
        push ds
430
	MOV CX, FILE_ATTRIBUTE_LABEL
532
        mov ds, pathname_seg
431
	INT 21h                   //; Execute interrupt, Carry set on error, unset on success
533
        int 0x21                  //; Execute interrupt, Carry set on error, unset on success
-
 
534
        pop ds
432
	JNC success               //; If carry is not set then succesful
535
        jnc success               //; If carry is not set then succesful
433
	MOV [cflag], AX           //; Set flag with error.
536
        mov [cflag], ax           //; Set flag with error.
434
	JMP cleanup               //; Restore DTA
537
        jmp cleanup               //; Restore DTA
435
      }
-
 
436
success:                        //; True volume entry only has volume attribute set [MS' LFNspec]
538
success:                        //; True volume entry only has volume attribute set [MS' LFNspec]
437
      asm {                     //;     But they may also have archive bit set!!!
539
        mov bx, attr_off
-
 
540
        push es
438
	LEA BX, finfo.ff_attr   //; Load address of file's attributes returned by findfirst/next
541
        mov es, attr_seg
439
	MOV AL, BYTE PTR [BX]     //; Looking for a BYTE that is FILE_ATTRIBUTE_LABEL only
542
        mov al, [es:bx]              //; Looking for a BYTE that is FILE_ATTRIBUTE_LABEL only
-
 
543
        pop es
440
      AND AL, 0xDF              //; Ignore Archive bit
544
        and al, 0xDF              //; Ignore Archive bit
441
	CMP AL, FILE_ATTRIBUTE_LABEL
545
        cmp al, FILE_ATTRIBUTE_LABEL
442
	JE cleanup                //; They match, so should be true volume entry.
546
        je cleanup                //; They match, so should be true volume entry.
443
	MOV AX, 4F00h             //; Otherwise keep looking (findnext)
547
        mov ax, 0x4F00            //; Otherwise keep looking (findnext)
444
	INT 21h                   //; Execute interrupt
548
        int 0x21                  //; Execute interrupt
445
	JNC success               //; If carry is not set then succesful
549
        jnc success               //; If carry is not set then succesful
446
	MOV [cflag], AX           //; Set flag with error.
550
        mov [cflag], ax           //; Set flag with error.
447
      }
-
 
448
cleanup:
551
cleanup:
449
      asm {
-
 
450
	MOV AH, 1Ah               //; Set Current DTA back to original, DS:DX
552
        mov ah, 0x1A              //; Set Current DTA back to original, DS:DX
451
	MOV DX, DS                //; Store DS, must be preserved
553
        mov dx, ds                //; Store DS, must be preserved
452
	POP DS                    //; Popping ES into DS since thats where we need it.
554
        pop ds                    //; Popping ES into DS since thats where we need it.
453
	POP BX                    //; Now DS:BX points to original DTA
555
        pop bx                    //; Now DS:BX points to original DTA
454
	INT 21h                   //; Execute interrupt to restore.
556
        int 0x21                  //; Execute interrupt to restore.
455
	MOV DS, DX                //; Restore DS
557
        mov ds, dx                //; Restore DS
-
 
558
 
-
 
559
        pop es
-
 
560
        pop dx
-
 
561
        pop cx
-
 
562
        pop bx
-
 
563
        pop ax
456
      }
564
      }
457
      /* copy over volume label, if buffer given */
565
      /* copy over volume label, if buffer given */
458
      if (lpVolumeNameBuffer != NULL)
566
      if (lpVolumeNameBuffer != NULL)
459
      {
567
      {
460
	if (cflag != 0)    /* error or no label */
568
	if (cflag != 0)    /* error or no label */
Line 482... Line 590...
482
        cflag = 0;       /* so assume valid drive  */
590
        cflag = 0;       /* so assume valid drive  */
483
 
591
 
484
 
592
 
485
      /* Get Serial Number, only supports drives mapped to letters */
593
      /* Get Serial Number, only supports drives mapped to letters */
486
      media.serial = 0;         /* set to 0, stays 0 on an error */
594
      media.serial = 0;         /* set to 0, stays 0 on an error */
487
 
595
      {
-
 
596
        unsigned short media_off = FP_OFF(&media);
-
 
597
        unsigned short media_seg = FP_SEG(&media);
488
      _BX = (pathname[0] & '\xDF') - 'A' + 1; /* Clear BH, drive in BL */
598
        unsigned char drv = (pathname[0] & 0xDF) - 'A' + 1;
489
      asm {
599
      _asm {
-
 
600
        push ax
-
 
601
        push bx
-
 
602
        push cx
-
 
603
        push dx
-
 
604
 
-
 
605
        xor bh, bh
490
        LEA DX, media           //; DS:DX pointer to media structure
606
        mov bl, drv             //; Clear BH, drive in BL
491
        MOV CX, 0866h           //; CH=disk drive, CL=Get Serial #
607
        mov cx, 0x0866          //; CH=disk drive, CL=Get Serial #
492
        MOV AX, 440Dh           //; Generic IOCTL
608
        mov ax, 0x440D          //; Generic IOCTL
-
 
609
        mov dx, media_off       //; DS:DX pointer to media structure
-
 
610
        push ds
-
 
611
        mov ds, media_seg
493
        INT 21h
612
        int 0x21
-
 
613
        pop ds
-
 
614
 
-
 
615
        pop dx
-
 
616
        pop cx
-
 
617
        pop bx
-
 
618
        pop ax
-
 
619
      }
494
      }
620
      }
495
 
621
 
496
/***************** Replaced with 'documented' version of Get Serial Number *********************/
622
/***************** Replaced with 'documented' version of Get Serial Number *********************/
497
      /* NT2000pro does NOT set or clear the carry for int21h subfunction 6900h
623
      /* NT2000pro does NOT set or clear the carry for int21h subfunction 6900h
498
       *   if an error occurs, it leaves media unchanged.
624
       *   if an error occurs, it leaves media unchanged.
Line 542... Line 668...
542
 
668
 
543
    segread(&s);                      /* load with current segment values     */
669
    segread(&s);                      /* load with current segment values     */
544
    s.ds = FP_SEG(pathname);          /* get Segment of our filename pointer  */
670
    s.ds = FP_SEG(pathname);          /* get Segment of our filename pointer  */
545
 
671
 
546
    r.x.cflag = 1;                    /* should be set when unsupported ***   */
672
    r.x.cflag = 1;                    /* should be set when unsupported ***   */
547
    asm stc;                          /* but clib usually ignores on entry    */
673
    _asm stc;                          /* but clib usually ignores on entry    */
548
 
674
 
549
    /* Actually perform the call, carry should be set on error or unuspported */
675
    /* Actually perform the call, carry should be set on error or unuspported */
550
    intdosx(&r, &r, &s);         /* Clib function to invoke DOS int21h call   */
676
    intdosx(&r, &r, &s);         /* Clib function to invoke DOS int21h call   */
551
 
677
 
552
    if (!r.x.cflag)              /* if carry not set then cx has desired info */
678
    if (!r.x.cflag)              /* if carry not set then cx has desired info */