📄 macro2.asm
字号:
TITLE MACRO2 - Pathname and macro related internal routines
NAME MACRO2
;
; Microsoft Confidential
; Copyright (C) Microsoft Corporation 1991
; All Rights Reserved.
;
;** MACRO2.ASM
;
; TransFCB
; TransPath
; TransPathSet
; TransPathNoSet
; Canonicalize
; PathSep
; SkipBack
; CopyComponent
; Splice
; $NameTrans
; DriveFromText
; TextFromDrive
; PathPref
; ScanPathChar
;
; Revision history:
;
; Created: MZ 4 April 1983
; MZ 18 April 1983 Make TransFCB handle extended FCBs
; AR 2 June 1983 Define/Delete macro for NET redir.
; MZ 3 Nov 83 Fix InitCDS to reset length to 2
; MZ 4 Nov 83 Fix NetAssign to use STRLEN only
; MZ 18 Nov 83 Rewrite string processing for subtree
; aliasing.
; BAS 3 Jan 85 ScanPathChar to search for path separator
; in null terminated string.
;
; MSDOS performs several types of name translation. First, we maintain for
; each valid drive letter the text of the current directory on that drive.
; For invalid drive letters, there is no current directory so we pretend to
; be at the root. A current directory is either the raw local directory
; (consisting of drive:\path) or a local network directory (consisting of
; \\machine\path. There is a limit on the point to which a .. is allowed.
;
; Given a path, MSDOS will transform this into a real from-the-root path
; without . or .. entries. Any component that is > 8.3 is truncated to
; this and all * are expanded into ?'s.
;
; The second part of name translation involves subtree aliasing. A list of
; subtree pairs is maintained by the external utility SUBST. The results of
; the previous 'canonicalization' are then examined to see if any of the
; subtree pairs is a prefix of the user path. If so, then this prefix is
; replaced with the other subtree in the pair.
;
; A third part involves mapping this "real" path into a "physical" path. A
; list of drive/subtree pairs are maintained by the external utility JOIN.
; The output of the previous translation is examined to see if any of the
; subtrees in this list are a prefix of the string. If so, then the prefix
; is replaced by the appropriate drive letter. In this manner, we can
; 'mount' one device under another.
;
; The final form of name translation involves the mapping of a user's
; logical drive number into the internal physical drive. This is
; accomplished by converting the drive number into letter:CON, performing
; the above translation and then converting the character back into a drive
; number.
;
; M015 - allocate even number of bytes on stack in TransFCB
; M027 - set up Sattrib in $Nametrans
.xlist
.xcref
include version.inc
include dosseg.inc
INCLUDE DOSSYM.INC
INCLUDE DEVSYM.INC
include mult.inc
include curdir.inc
.cref
.list
Installed = TRUE
I_need Splices,BYTE ; TRUE => splices are being done.
I_need WFP_Start,WORD ; pointer to beginning of expansion
I_need Curr_Dir_End,WORD ; offset to end of current dir
I_need ThisCDS,DWORD ; pointer to CDS used
I_need ThisDPB,DWORD ; pointer to DPB used
I_need NAME1,11 ; Parse output of NameTrans
I_need OpenBuf,128 ; ususal destination of strings
I_need ExtFCB,BYTE ; flag for extended FCBs
I_need Sattrib,BYTE ; attribute of search
I_need fSplice,BYTE ; TRUE => do splice after canonicalize
I_need fSharing,BYTE ; TRUE => no redirection allowed
I_Need NoSetDir,BYTE ; TRUE => syscall is interested in
; entry, not contents. We splice only
; inexact matches
I_Need cMeta,BYTE ; count of meta chars in path
I_Need Temp_Var,WORD ;AN000; variable for temporary use 3/31/KK
I_Need DOS34_FLAG,WORD ;AN000; variable for dos34
DOSCODE SEGMENT
ASSUME SS:DOSDATA,CS:DOSCODE
ifdef DBCS
EXTRN TestKanj:near
endif
EXTRN PathChrCmp:near
BREAK <TransFCB - convert an FCB into a path, doing substitution>
;
; TransFCB - Copy an FCB from DS:DX into a reserved area doing all of the
; gritty substitution.
;
; Inputs: DS:DX - pointer to FCB
; ES:DI - point to destination
; Outputs: Carry Set - invalid path in final map
; Carry Clear - FCB has been mapped into ES:DI
; Sattrib is set from possibly extended FCB
; ExtFCB set if extended FCB found
; Registers modified: most
Procedure TransFCB,NEAR
ASSUME CS:DOSCODE,SS:DOSDATA
PUBLIC MACRO001S,MACRO001E
MACRO001S:
LocalVar FCBTmp,16 ; M015 - allocate even number of bytes on stack
MACRO001E:
Enter
Context ES ; get DOSDATA addressability
SAVE <ES,DI> ; save away final destination
LEA DI,FCBTmp ; point to FCB temp area
MOV [ExtFCB],0 ; no extended FCB found ;smr;SS Override
MOV [Sattrib],0 ; default search attributes;smr;SS Override
invoke GetExtended ; get FCB, extended or not
JZ GetDrive ; not an extended FCB, get drive
MOV AL,[SI-1] ; get attributes
MOV [SAttrib],AL ; store search attributes;smr;SS Override
MOV [ExtFCB],-1 ; signal extended FCB ;smr;SS Override
GetDrive:
LODSB ; get drive byte
invoke GetThisDrv
jc BadPack
CALL TextFromDrive ; convert 0-based drive to text
;
; Scan the source to see if there are any illegal chars
;
IFDEF DBCS ;
;----------------------------- Start of DBCS 2/13/KK
SAVE <SI> ; back over name, ext
MOV CX,8 ; 8 chars in main part of name
FCBScan:LODSB ; get a byte
call TestKanj ;
jz notkanj2 ;
DEC CX ;
JCXZ VolidChck ; Kanji half char screw up
LODSB ; second kanji byte
jmp short Nextch
VolidChck:
TEST [SAttrib],attr_volume_id ; volume id ? ;smr;SS Override
JZ Badpack ; no, error
OR [DOS34_FLAG],DBCS_VOLID ; no, error ;smr;SS Override
DEC CX ; cx=-1
INC SI ; next char
JMP SHORT FCBScango
notkanj2:
invoke GetCharType ;get bits;smr;
TEST AL,fFCB
JZ BadPack
NextCh:
LOOP FCBScan
FCBScango:
ADD CX,3 ; Three chars in extension
FCBScanE:
LODSB
call TestKanj
jz notkanj3
DEC CX
JCXZ BadPack ; Kanji half char problem
LODSB ; second kanji byte
jmp short NextChE
notkanj3:
invoke GetCharType ;get bits;smr;
TEST AL,fFCB
JZ BadPack
NextChE:
LOOP FCBScanE
;----------------------------- End of DBCS 2/13/KK
ELSE
MOV CX,11
SAVE <SI> ; back over name, ext
FCBScan:LODSB ; get a byte
invoke GetCharType ;get bits;smr;
TEST AL,fFCB
JZ BadPack
NextCh: LOOP FCBScan
ENDIF
RESTORE <SI>
MOV BX,DI
invoke PackName ; crunch the path
RESTORE <DI,ES> ; get original destination
Context DS ; get DS addressability
LEA SI,FCBTmp ; point at new pathname
CMP BYTE PTR [BX],0
JZ BadPack
SAVE <BP>
CALL TransPathSet ; convert the path
RESTORE <BP>
JNC FCBRet ; bye with transPath error code
BadPack:
STC
MOV AL,error_path_not_found
FCBRet: Leave
return
EndProc TransFCB,NoCheck
BREAK <TransPath - copy a path, do string sub and put in current dir>
;
; TransPath - copy a path from DS:SI to ES:DI, performing component string
; substitution, insertion of current directory and fixing . and ..
; entries. Perform splicing. Allow input string to match splice
; exactly.
;
; TransPathSet - Same as above except No splicing is performed if input path
; matches splice.
;
; TransPathNoSet - No splicing/local using is performed at all.
;
; The following anomalous behaviour is required:
;
; Drive letters on devices are ignored. (set up DummyCDS)
; Paths on devices are ignored. (truncate to 0-length)
; Raw net I/O sets ThisCDS => NULL.
; fSharing => dummyCDS and no subst/splice. Only canonicalize.
;
; Other behaviour:
;
; ThisCDS set up.
; FatRead done on local CDS.
; ValidateCDS done on local CDS.
;
; Brief flowchart:
;
; if fSharing then
; set up DummyCDS (ThisCDS)
; canonicalize (sets cMeta)
; splice
; fatRead
; return
; if \\ or d:\\ lead then
; set up null CDS (ThisCDS)
; canonicalize (sets cMeta)
; return
; if device then
; set up dummyCDS (ThisCDS)
; canonicalize (sets cMeta)
; return
; if file then
; getCDS (sets (ThisCDS) from name)
; validateCDS (may reset current dir)
; Copy current dir
; canonicalize (set cMeta)
; splice
; generate correct CDS (ThisCDS)
; if local then
; fatread
; return
;
; Inputs: DS:SI - point to ASCIZ string path
; DI - point to buffer in DOSDATA
; Outputs: Carry Set - invalid path specification: too many .., bad
; syntax, etc. or user FAILed to I 24.
; WFP_Start - points to beginning of buffer
; Curr_Dir_End - points to end of current dir in path
; DS - DOSDATA
; Registers modified: most
Procedure TransPath,NEAR
ASSUME CS:DOSCODE,SS:DOSDATA
XOR AL,AL
JMP SHORT SetSplice
Entry TransPathSet
MOV AL,-1
SetSplice:
MOV NoSetDir,AL ; NoSetDir = !fExact; ;smr;SS Override
MOV AL,-1
Entry TransPathNoSet
MOV fSplice,AL ; fSplice = TRUE; ;smr;SS Override
MOV cMeta,-1 ;smr;SS Override
MOV WFP_Start,DI ;smr;SS Override
MOV Curr_Dir_End,-1 ; crack from start ;smr;SS Override
Context ES
LEA BP,[DI+TEMPLEN] ; end of buffer
;
; if this is through the server dos call, fsharing is set. We set up a
; dummy cds and let the operation go.
;
TEST fSharing,-1 ; if no sharing ;smr;SS Override
JZ CheckUNC ; skip to UNC check
;
; ES:DI point to buffer
;
CALL DriveFromText ; get drive and advance DS:SI
invoke GetThisDrv ; Set ThisCDS and convert to 0-based
jc NoPath
CALL TextFromDrive ; drop in new
LEA BX,[DI+1] ; backup limit
CALL Canonicalize ; copy and canonicalize
retc ; errors
;
; Perform splices for net guys.
;
Context DS
MOV SI,wfp_Start ; point to name
TEST fSplice,-1
JZ NoServerSplice
CALL Splice
NoServerSplice:
Context DS ; for FATREAD
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -