Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Dos Network Redirector interface, peculiaraties of 'dir' command

96 views
Skip to first unread message

Dav

unread,
Nov 16, 1997, 3:00:00 AM11/16/97
to

Does anyone have any information, or example code using the MS redirector
interface? My own experiments have had somewhat inconclusive results.

Specifically, the 'dir' command on a redirected drive returns 'path not found',
unless 'dir *.*' is used in which case it works perfectly. Interestingly
enough, 'dir' does not use 'findfirst' to determine the volume label, but it
does to get the directory listing - using '*' as the search template. Normally,
calling 'findfirst' with '*' (or 'C:' or any other path valid for 'dir') cause
an error: the path must be fully qualified. However, the function seems to
work fine for 'dir'.

Also, 'dir G:\*.*' returns 'Access denied' (where G is a redirected drive).

Any help would be greatly appreciated.


-------------------------------------------------
DavMac - Sharking!!
Dav...@iname.com
http://corryong.albury.net.au/~smcall/davpage.htm
-------------------------------------------------


Dav

unread,
Nov 19, 1997, 3:00:00 AM11/19/97
to

Well, for anyone who's interested, I've played around and further managed to
isolate the problems I've been having. Here's the source code complete with
documentation.

- Dav

;Test.asm - Masm v6.11 - D. McCall
;compiled and linked as 'TEST.EXE'
;
;Purpose: This is an experiment with the MS-DOS redirector interface. It
; creates a new ram-based drive (drive G:) with cut-down functionality
; (basically, all you can do is do a directory on it). It's turned up
; some very interesting results.
;
;Notes (IMPORTANT!!):
; - DOS below v4.0 uses diff SDA format - this prog will wreak havoc on
; systems with DOS version prior to 4.0, and is not likely to work on any
; DOS prior to version 5.0
; - Must specify LASTDRIVE=G: in CONFIG.SYS. Lower is likely to cause
; problems. The program will prevent access to any drive G: which might
; otherwise exist, and will also (most likely) clash violently with any
; other redirector programs already loaded.
;
;Strange and unexplainable bug: The execution of *some* EXE files (MZ
;format) causes to DOS to stop the dos 'dir' command from working properly
;on the redirected drive. But then, the dos 'dir' command looks like a very
;strange beast in other ways too, judging from my experiments. Specifically:
;
; - '*' passed to FindFirst/FindNext returns *all* files for 'dir', but only
; those without an extension to any normal program
; - 'dir' does not apparently need to use 'FindFirst' to discover the volume
; label of the redirected drive. However the redirector's FindFirst is
; called (by DOS kernel?) to discover the label.
;
;All this is very interesting and calls for further investigation - unless
;somebody else already knows the answers.

DATA SEGMENT STACK 'DATA'

LclName DB "G:", 0
SrvrName DB "\\SRVR\", 0, 0
SDAoffset DW ?
OnlyFname DB "README TXT"
DiskLabel DB "DAVSDISK NW"

db 1024 dup (?) ; Stack space

DATA ENDS

; Code segment

CODE SEGMENT 'CODE'

MyPsp DW ?
OldhandlerOfs DW ? ;Code seg storage for old Int 2Fh handler addr
OldhandlerSeg DW ?

ASSUME CS:CODE
NewHandler PROC
;Note: Because this is interrupt, can't return carry set by 'STC'
;followed by 'IRET'.

pushf ;Save flags, registers
.if AX == 1100h
;Installation check
mov AX, 01FFh
add sp, 2
iret
.endif
.if AX == 1105h
;Chdir (not implemented - return Ok to DOS)
popf
push BP
mov BP, SP ; [bp+2]=ret addr +6 = flags
and byte ptr [BP+6], 0FEh ; clear carry
pop BP
iret
.endif
.if AX == 111Eh
;Redirection call (not currently supported)
popf
push BP
mov BP, SP ; [BP+2]=ret addr [+6]=ret flags
or word ptr [BP+6], 1 ;set carry flag
mov AX, 1
pop BP
iret
.endif
.if AX == 111Bh
;Find first
popf
push BP
mov BP, SP
and byte ptr [BP+6], 0FEh ;clear carry
pop BP
push SI
push DS
push DI
push ES
push CX
mov AX, DATA
mov DS, AX
mov DI, DS:[SDAoffset]
mov CL, SS:[DI+24Dh] ; get search attribs
LES DI, dword ptr SS:[DI+0Ch] ;DS:SI = DTA
mov byte ptr ES:[DI], 10000110b ;Set high bit (remote) drive G
mov byte ptr ES:[DI+0Ch], CL ; fill in search attribs
inc word ptr ES:[DI+0Dh] ;not necessarry here but what the
;hell
mov word ptr ES:[DI+15h+1Ch], 100 ; size (100 bytes)
mov word ptr ES:[DI+15h+1Eh], 0
lea DI, [DI+15h]

.if CL & 8
mov byte ptr ES:[DI+0Bh], 8 ; attributes
mov SI, OFFSET DiskLabel ;Vol label
mov CX, 11
rep movsb
.else
mov byte ptr ES:[DI+0Bh], 0
mov SI, OFFSET OnlyFname ;Filename
mov CX, 11
rep movsb
.endif
pop CX
pop ES
pop DI
pop DS
pop SI
xor AX, AX
iret
.endif
.if AX == 111Ch
;Find next (currently always fails)
pop AX
push BP
mov BP, SP
or word ptr [BP+6], 1 ; set carry flag
pop BP
mov AX, 12h ; no more files
iret
.endif
.if AX == 111Dh
;Close remote files for aborting process
add sp, 2
iret
.endif
.if AX == 1122h
;Process termination hook
add sp, 2
iret
.endif
.if AX == 1123h
;Qualify filename
popf
push BP
mov BP, SP
or word ptr [BP+6], 1 ;set carry flag - let DOS do it
pop BP
iret
.endif
.if AX == 1125h
;Printer redirection
popf
push BP
mov BP, SP ;[BP]=BP, [BP+2]=ret addr [BP+6]=flags [BP+8] = param
mov AX, [BP+8] ;AX = param
.IF AX == 5D07h
mov DL, 0
.ELSE
or word ptr [BP+6], 1 ;Set carry flag
mov AX, 1 ; error - function invalid
.ENDIF ; (not supported in this case)
pop BP
iret
.endif
.if AH == 11h
;General fail command
popf
push bp
mov bp, sp
or byte ptr [BP+6], 1 ;set carry
pop BP
iret
.endif
popf
jmp DWORD PTR OldhandlerOfs
NewHandler ENDP

;Redirect drive G, to '\\SRVR\'
SetupRedir PROC
mov AH, 52h ;Get list of lists (ES:BX)
int 21h
les BX, ES:[BX+16h] ;Get CDS array pointer (ES:BX)
mov AX, ('G' - 'A') * 58h
add BX, AX ;ES:BX = CDS drive G:
mov DI, BX ;Copy in server name (root section of directory)
mov AX, DATA
mov DS, AX
mov SI, OFFSET SrvrName
mov CX, 8
rep movsb
mov word ptr ES:[BX+43h], 1100000000000000b ;Redirected physical drive
mov word ptr ES:[BX+45h], 0FFFFh ; Invalid DPB
mov word ptr ES:[BX+47h], 0FFFFh
mov word ptr ES:[BX+49h], 0FFFFh ; No REDIRIFS record
mov word ptr ES:[BX+4Bh], 0FFFFh
mov word ptr ES:[BX+4Fh], 6 ; No. of hidden root dir chars
mov byte ptr ES:[BX+51h], 4 ; Network drive
mov word ptr ES:[BX+52h], OFFSET NewHandler ;Try this. Don't know what
mov word ptr ES:[BX+54h], CS ; it really should be.
ret
SetupRedir ENDP

start:
mov MyPsp, DS ;Save the PSP for uninstaller
mov ES, DS:[2Ch] ;Free local environment table
mov AH, 49h
int 21h
mov AX, DATA ;Save offset of SDA in DOS seg
mov ES, AX
mov AX, 5D06h
int 21h
mov ES:[SDAoffset], SI
mov AX, 352Fh ;Get Int 2Fh vector (ES:BX)
int 21h
mov OldhandlerOfs, BX
mov OldhandlerSeg, ES
mov AX, CS ;Set new handler
mov DS, AX
mov AX, 252Fh
mov DX, OFFSET NewHandler
int 21h
INVOKE SetupRedir
mov DX, CS ;TSR
sub DX, MyPsp
mov CL, 4
mov AX, OFFSET start
shr AX, CL
inc AX
add DX, AX
mov AX, 3100h
int 21h

CODE ENDS

END start

0 new messages