     1                                  ;	SCCSID = @(#)dir2.asm	1.2 85/07/23
     2                                  ;	SCCSID = @(#)dir2.asm	1.2 85/07/23
     3                                  ;TITLE	DIR2 - Directory and path cracking
     4                                  ;NAME	Dir2
     5                                  ; Main Path cracking routines, low level search routines and device
     6                                  ;   name detection routines
     7                                  ;
     8                                  ;   GETPATH
     9                                  ;   GetPathNoSet
    10                                  ;   CHKDEV
    11                                  ;   ROOTPATH
    12                                  ;   FINDPATH
    13                                  ;   StartSrch
    14                                  ;   MatchAttributes
    15                                  ;   DEVNAME
    16                                  ;   Build_device_ent
    17                                  ;   Validate_CDS
    18                                  ;   CheckThisDevice
    19                                  ;
    20                                  ;   Revision history:
    21                                  ;
    22                                  ;	A000  version 4.00  Jan. 1988
    23                                  ;	A001  PTM 3564 -- search using fastopen
    24                                  
    25                                  ;
    26                                  ; get the appropriate segment definitions
    27                                  ;
    28                                  [list -]
    28          ******************       warning: redefining multi-line macro `struc' [-w+pp-macro-redef-multi]
    14                              <4> [list -]
    14                              <3> [list -]
     3                              <2> 
     4                              <2> addsection DOSSTART, align=16 PUBLIC class=DOSSTART
     5                              <2> ; (no prior section) ; DOSSTART		ENDS
     6                              <2> 
     7                              <2> addsection DOSSTARTJUMP, align=1 PUBLIC class=START
     8                              <2> ; (no prior section) ; DOSSTARTJUMP		ENDS
     9                              <2> 
    10                              <2> addsection CONSTANTS, align=2 PUBLIC class=CONST
    11                              <2> ; (no prior section) ; CONSTANTS	ENDS
    12                              <2> 
    13                              <2> addsection DATA, align=2 PUBLIC class=DATA
    14                              <2> ; (no prior section) ; DATA		ENDS
    15                              <2> 
    16                              <2> addsection TABLE, align=2 PUBLIC class=TABLE
    17                              <2> ; (no prior section) ; TABLE		ENDS
    18                              <2> 
    19                              <2> addsection DOSDATATABLE, align=2 PUBLIC class=DOSDATACODE
    20                              <2> ; (no prior section) ; DOSDATATABLE		ENDS
    21                              <2> 
    22                              <2> addsection DOSDATACODE, align=1 PUBLIC class=DOSDATACODE
    23                              <2> ; (no prior section) ; DOSDATACODE		ENDS
    24                              <2> 
    25                              <2> addsection DOSBIODATA, align=2 PUBLIC class=DOSBIODATA
    26                              <2> 
    27                              <2> addsection LAST, align=16 PUBLIC class=LAST
    28                              <2> ; (no prior section) ; LAST		ENDS
    29                              <2> 
    30                              <2> group DOSGROUP DOSSTART DOSSTARTJUMP CONSTANTS DATA TABLE DOSDATATABLE DOSDATACODE DOSBIODATA LAST
     8                              <1> 
     9                              <1> %include "dcodeseg.nas"
     1                              <2> 
     2                              <2> %ifndef DCODESEGNAS
     3                              <2> %assign DCODESEGNAS 1
     4                              <2> 
     5                              <2> section DOSCODETABLE align=2 PUBLIC class=DOSCODE
     6                              <2> ; (no prior section) ; DOSCODETABLE		ENDS
     7                              <2> section DOSCODECODE align=1 PUBLIC class=DOSCODE
     8                              <2> ; (no prior section) ; DOSCODECODE		ENDS
     9                              <2> section DOSBIOCODE align=2 PUBLIC class=DOSCODE
    10                              <2> section BIOCODE	align=2 PUBLIC class=DOSCODE
    11                              <2> 
    12                              <2> %ifnidni DOSENTRYGROUP, DOSCODEGROUP
    13                              <2>  group DOSCODEGROUP DOSCODETABLE DOSCODECODE DOSBIOCODE BIOCODE
    14                              <2> %endif
    15                              <2> 
    16                              <2> %endif
    10                              <1> 
    11                              <1> section LAST
    12                              <1> ; (no prior section) ; LAST		ENDS
    30                                  
    31                                  [list +]
    32                                  section DOSCODECODE
    33                                  [list -]
    33          ******************       warning: out: ... for DOS Version 4.00 ... [-w+user]
    33          ******************       warning: out: BPB.INC... [-w+user]
    33          ******************       warning: out: ... CLONE version build switch on ... [-w+user]
    33          ******************       warning: out: DEVSYM.INC... [-w+user]
    41                                  
    42                                  %ifndef Kanji
    43                                   %iassign Kanji 0
    44                                  %endif
    45                                  
    46                                  	i_need	NoSetDir,BYTE
    47                                  	i_need	EntFree,WORD
    48                                  	i_need	DirStart,WORD
    49                                  	i_need	LastEnt,WORD
    50                                  	i_need	WFP_START,WORD
    51                                  	i_need	CURR_DIR_END,WORD
    52                                  	i_need	CurBuf,DWORD
    53                                  	i_need	THISCDS,DWORD
    54                                  	i_need	Attrib,BYTE
    55                                  	i_need	SAttrib,BYTE
    56                                  	i_need	VolID,BYTE
    57                                  	i_need	Name1,BYTE
    58                                  	i_need	ThisDPB,DWORD
    59                                  	i_need	EntLast,WORD
    60                                  	i_need	Creating,BYTE
    61                                  	i_need	NULDEV,DWORD
    62                                  	i_need	DEVPT,DWORD
    63                                  	i_need	DEVFCB,BYTE
    64                                  	i_need	ALLOWED,BYTE
    65                                  	i_need	EXTERR_LOCUS,BYTE
    66                                  	I_need	FastOpenFlg,BYTE	  ;DOS 3.3
    67                                  	I_need	FastOpenTable,BYTE	  ;DOS 3.3
    68                                  	I_need	Dir_Info_Buff,BYTE	  ;DOS 3.3
    69                                  	I_need	FastOpen_Ext_Info,BYTE	  ;DOS 3.3
    70                                  	I_need	CLUSNUM,WORD		  ;DOS 3.3
    71                                  	I_need	Next_Element_Start,WORD   ;DOS 3.3
    72                                  	I_need	HIGH_SECTOR,WORD	  ;AN000;>32mb
    73                                  	I_need	DOS34_FLAG,WORD 	  ;AN000;>32mb
    74                                  
    75                                  
    76                                   assume nocheck, ss:DOSGROUP
    77                                  
    78                                  Break	<GETPATH -- PARSE A WFP>
    79                                  
    80                                  ; Inputs:
    81                                  ;	[WFP_START] Points to WFP string ("d:\" must be first 3 chars, NUL
    82                                  ;		terminated; d:/ (note forward slash) indicates a real device).
    83                                  ;	[CURR_DIR_END] Points to end of Current dir part of string
    84                                  ;		( = -1 if current dir not involved, else
    85                                  ;		 Points to first char after last "/" of current dir part)
    86                                  ;	[THISCDS] Points to CDS being used
    87                                  ;	[SATTRIB] Is attribute of search, determines what files can be found
    88                                  ;	[NoSetDir] set
    89                                  ;	[THISDPB] set to DPB if disk otherwise garbage.
    90                                  ; Function:
    91                                  ;	Crack the path
    92                                  ; Outputs:
    93                                  ;	Sets EXTERR_LOCUS = errLOC_Disk if disk file
    94                                  ;	Sets EXTERR_LOCUS = errLOC_Unk if char device
    95                                  ;	ID1 field of [THISCDS] updated appropriately
    96                                  ;	[ATTRIB] = [SATTRIB]
    97                                  ;	ES:BP Points to DPB
    98                                  ;	Carry set if bad path
    99                                  ;	   SI Points to path element causing failure
   100                                  ;	   Zero set
   101                                  ;	      [DIRSTART],[DIRSEC],[CLUSNUM], and [CLUSFAC] are set up to
   102                                  ;	      start a search on the last directory
   103                                  ;	      CL is zero if there is a bad name in the path
   104                                  ;	      CL is non-zero if the name was simply not found
   105                                  ;		 [ENTFREE] may have free spot in directory
   106                                  ;		 [NAME1] is the name.
   107                                  ;		 CL = 81H if '*'s or '?' in NAME1, 80H otherwise
   108                                  ;	   Zero reset
   109                                  ;	      File in middle of path or bad name in path or attribute mismatch
   110                                  ;		or path too long or malformed path
   111                                  ;	ELSE
   112                                  ;	   [CurBuf] = -1 if root directory
   113                                  ;	   [CURBUF] contains directory record with match
   114                                  ;	   [CURBUF+2]:BX Points into [CURBUF] to start of entry
   115                                  ;	   [CURBUF+2]:SI Points into [CURBUF] to dir_first field for entry
   116                                  ;	   AH = device ID
   117                                  ;	      bit 7 of AH set if device SI and BX
   118                                  ;	      will point DOSGROUP relative The firclus
   119                                  ;	      field of the device entry contains the device pointer
   120                                  ;	   [NAME1] Has name looked for
   121                                  ;	   If last element is a directory zero is set and:
   122                                  ;	      [DIRSTART],[SECCLUSPOS],[DIRSEC],[CLUSNUM], and [CLUSFAC]
   123                                  ;	      are set up to start a search on it.
   124                                  ;	      unless [NoSetDir] is non zero in which case the return is
   125                                  ;	      like that for a file (except for zero flag)
   126                                  ;	   If last element is a file zero is reset
   127                                  ;	      [DIRSEC],[CLUSNUM],[CLUSFAC],[NXTCLUSNUM],[SECCLUSPOS],
   128                                  ;	      [LASTENT], [ENTLAST] are set to continue search of last
   129                                  ;	      directory for furthur matches on NAME1 via the NEXTENT
   130                                  ;	      entry point in FindEntry (or GETENT entry in GETENTRY in
   131                                  ;	      which case [NXTCLUSNUM] and [SECCLUSPOS] need not be valid)
   132                                  ; DS preserved, Others destroyed
   133                                  
   134                                  	procedure   GETPATH,near
   134          ******************       warning: proc GETPATH... [-w+user]
   135                                  	DOSAssume   CS,<DS>,"GetPath"
   136                                  	ASSUME	ES:NOTHING
   137                                  
   138                                  CREATING equ Creating	; NASM port label
   139 00000000 C706[0000]00E5          	MOV	WORD PTR [CREATING],0E500H  ; Not Creating, not DEL *.*
   140                                  
   141                                  ;Same as GetPath only CREATING and DELALL already set
   142                                  	entry	GetPathNoSet
   143 00000006 C606[0000]02            	MOV	byte [EXTERR_LOCUS],errLOC_Disk
   144 0000000B C706[0000]FFFF          	MOV	WORD [CurBuf],-1	; initial setting
   145                                  ;
   146                                  ; See if the input indicates a device that has already been detected.  If so,
   147                                  ; go build the guy quickly.  Otherwise, let findpath find the device.
   148                                  ;
   149                                  Wfp_Start equ WFP_START	; NASM port label
   150 00000011 8B3E[0000]              	MOV	DI,[Wfp_Start]		; point to the beginning of the name
   151 00000015 817D013A5C              	CMP	WORD PTR [DI+1],('\' << 8) + ':'
   152 0000001A 743A                    	JZ	CrackIt
   153                                  ;
   154                                  ; Let ChkDev find it in the device list
   155                                  ;
   156 0000001C 83C703                  	ADD	DI,3
   157 0000001F 89FE                    	MOV	SI,DI			; let CHKDEV see the original name
   158                                  CHKDEV equ ChkDev	; NASM port label
   159 00000021 E8B400                  	CALL	CHKDEV
   160 00000024 722E                    	JC	InternalError
   161                                  Build_devJ:
   162 00000026 A0[0000]                	MOV	AL,[SAttrib]
   163 00000029 A2[0000]                	MOV	[Attrib],AL
   164 0000002C C606[0000]01            	MOV	byte [EXTERR_LOCUS],errLOC_Unk ; In the particular case of
   165                                  					; "finding" a char device
   166                                  					; set LOCUS to Unknown. This makes
   167                                  					; certain idiotic problems reported
   168                                  					; by a certain 3 letter OEM go away.
   169                                  ;
   170                                  ; Take name in name1 and pack it back into where wfp_start points.  This
   171                                  ; guarantees wfp_start pointing to a canonical representation of a device.
   172                                  ; We are allowed to do this as GetPath is *ALWAYS* called before entering a
   173                                  ; wfp into the share set.
   174                                  ;
   175                                  ; We copy chars from name1 to wfp_start remembering the position of the last
   176                                  ; non-space seen +1.  This position is kept in DX.
   177                                  ;
   178 00000031 1607                    	Context ES
   179                                  DOSGroup equ DOSGROUP	; NASM port equate
   180 00000033 BE[0000]                	mov	si,offset Name1 wrt DOSGroup
   181                                  wfp_start equ WFP_START	; NASM port label
   182 00000036 8B3E[0000]              	mov	di,[wfp_start]
   183 0000003A 89FA                    	mov	dx,di
   184 0000003C B90800                  	mov	cx,8			; 8 chars in device name
   185                                  MoveLoop:
   186 0000003F AC                      	lodsb
   187 00000040 AA                      	stosb
   188 00000041 3C20                    	cmp	al," "
   189                                  nosave equ NoSave	; NASM port label
   190 00000043 7402                    	jz	nosave
   191                                   %IF  DBCS				;AN000;;
   192                                  ;	cmp	al,81h			;AN000;; 2/23/KK
   193                                  ;	jne	notKanji		;AN000;; 2/23/KK
   194                                  ;	cmp	cx,1			;AN000; 2/23/KK
   195                                  ;	je	notKanji		;AN000; 2/23/KK
   196                                  ;	cmp	byte ptr [si],40h	;AN000; 2/23/KK
   197                                  ;	jne	notKanji		;AN000;; 2/23/KK
   198                                  ;	lodsb				;AN000;; 2/23/KK
   199                                  ;	stosb				;AN000;; 2/23/KK
   200                                  ;	dec	cx			;AN000;; 2/23/KK
   201                                  ;	jmp	nosave			;AN000;; 2/23/KK
   202                                  ;notKanji:				;AN000;; 2/23/KK
   203                                   %ENDIF
   204 00000045 89FA                    	mov	dx,di
   205                                  NoSave:
   206 00000047 E2F6                    	loop	MoveLoop
   207                                  ;
   208                                  ; DX is the position of the last seen non-space + 1.  We terminate the name
   209                                  ; at this point.
   210                                  ;
   211 00000049 89D7                    	mov	di,dx
   212 0000004B C60500                  	mov	byte ptr [di],0 	; end of string
   213 0000004E E8DE02                  	invoke	Build_device_ent	; Clears carry sets zero
   214 00000051 FEC0                    	INC	AL			; reset zero
   215 00000053 C3                      	return
   216                                  
   217                                  	assume	es:nothing
   218                                  
   219                                  InternalError:
   220 00000054 EBFE                    	JMP	InternalError		; freeze
   221                                  
   222                                  ;
   223                                  ; Start off at the correct spot.  Optimize if the current dir part is valid.
   224                                  ;
   225                                  CrackIt:
   226 00000056 8B36[0000]              	MOV	SI,[CURR_DIR_END]	; get current directory pointer
   227 0000005A 83FEFF                  	CMP	SI,-1			; valid?
   228 0000005D 7503                    	JNZ	LOOK_SING		; Yes, use it.
   229 0000005F 8D7503                  	LEA	SI,[DI+3]		; skip D:\.
   230                                  LOOK_SING:
   231                                  	Assert	ISDPB,<<WORD PTR THISDPB+2>,<WORD PTR THISDPB>>,"Crackit"
   232 00000062 C606[0000]16            	MOV	byte [Attrib],attr_directory+attr_system+attr_hidden
   233                                  					; Attributes to search through Dirs
   234 00000067 C43E[0000]              	LES	DI,[THISCDS]
   235                                   assume es:nothing
   236 0000006B B8FFFF                  	MOV	AX,-1
   237 0000006E 268B5D49                	MOV	BX,[ES:DI + curdir_ID]
   238 00000072 8B36[0000]              	MOV	SI,[CURR_DIR_END]
   239                                  ;
   240                                  ; AX = -1
   241                                  ; BX = cluster number of current directory.  THis number is -1 if the media
   242                                  ;      has been uncertainly changed.
   243                                  ; SI = offset in DOSGroup into path to end of current directory text.  This
   244                                  ;      may be -1 if no current directory part has been used.
   245                                  ;
   246 00000076 39C6                    	CMP	SI,AX			; if Current directory is not part
   247 00000078 7440                    	JZ	NO_CURR_D		; then we must crack from root
   248 0000007A 39C3                    	CMP	BX,AX			; is the current directory cluster valid
   249                                  
   250                                  ; DOS 3.3  6/25/86
   251 0000007C 743C                    	JZ	NO_CURR_D		; no, crack form the root
   252 0000007E F606[0000]01            	TEST	byte [FastOpenFlg],FastOpen_Set     ; for fastopen ?
   253 00000083 7443                    	JZ	GOT_SEARCH_CLUSTER	       ; no
   254 00000085 06                      	PUSH	ES			; save registers
   255 00000086 57                      	PUSH	DI
   256 00000087 51                      	PUSH	CX
   257 00000088 FF74FF                  	PUSH	word [SI-1]			; save \ and 1st char of next element
   258 0000008B 56                      	PUSH	SI
   259 0000008C 53                      	PUSH	BX
   260                                  
   261 0000008D C644FF00                	MOV	BYTE PTR [SI-1],0	; call fastopen to look up cur dir info
   262 00000091 8B36[0000]              	MOV	SI,[Wfp_Start]
   263 00000095 BB[0000]                	MOV	BX,OFFSET FastOpenTable wrt DOSGROUP
   264 00000098 BF[0000]                	MOV	DI,OFFSET Dir_Info_Buff wrt DOSGROUP
   265 0000009B B9[0000]                	MOV	CX,OFFSET FastOpen_Ext_Info wrt DOSGROUP
   266                                  FONC_look_up equ FONC_Look_up	; NASM port equate
   267 0000009E B001                    	MOV	AL,FONC_look_up
   268 000000A0 1E                      	PUSH	DS
   269 000000A1 07                      	POP	ES
   270                                   assume es:DOSGROUP
   271                                  FASTOPEN_NAME_CACHING equ Fastopen_Name_Caching	; NASM port equate
   272 000000A2 FF5F02                  	CALL	far [BX + FASTOPEN_NAME_CACHING]
   273 000000A5 7208                    	JC	GO_Chk_end1			;fastopen not installed, or wrong drive. Go to Got_Srch_cluster
   274 000000A7 803C00                  	CMP	BYTE PTR [SI],0 		;fastopen has current dir info?
   275 000000AA 7404                    	JE	GO_Chk_end			;yes. Go to got_serch_cluster
   276 000000AC F9                      	stc
   277 000000AD EB01                    	jmp	short GO_Chk_end		;Go to No_Curr_D
   278                                  GO_Chk_end1:
   279 000000AF F8                      	clc
   280                                  GO_Chk_end:					; restore registers
   281 000000B0 5B                      	POP	BX
   282 000000B1 5E                      	POP	SI
   283 000000B2 8F44FF                  	POP	word [SI-1]
   284 000000B5 59                      	POP	CX
   285 000000B6 5F                      	POP	DI
   286 000000B7 07                      	POP	ES
   287                                   assume es:nothing
   288 000000B8 730E                    	JNC	GOT_SEARCH_CLUSTER		; crack based on cur dir
   289                                  
   290                                  ; DOS 3.3  6/25/86
   291                                  ;
   292                                  ; We must cract the path beginning at the root.  Advance pointer to beginning
   293                                  ; of path and go crack from root.
   294                                  ;
   295                                  NO_CURR_D:
   296 000000BA 8B36[0000]              	MOV	SI,[WFP_START]
   297 000000BE 8D7403                  	LEA	SI,[SI+3]		; Skip "d:/"
   298                                  THISDPB equ ThisDPB	; NASM port label
   299 000000C1 C42E[0000]              	LES	BP,[THISDPB]		; Get ES:BP
   300 000000C5 EB41                    	JMP	ROOTPATH
   301 000000C7 90                      	nop	; identicalise
   302                                  ;
   303                                  ; We are able to crack from the current directory part.  Go set up for search
   304                                  ; of specified cluster.
   305                                  ;
   306                                  GOT_SEARCH_CLUSTER:
   307 000000C8 C42E[0000]              	LES	BP,[THISDPB]		; Get ES:BP
   308 000000CC E8(0000)                	invoke	SETDIRSRCH
   309 000000CF 7203                    	JC	SETFERR
   310 000000D1 EB46                    	JMP	FINDPATH
   311 000000D3 90                      	nop	; identicalise
   312                                  
   313                                  SETFERR:
   314 000000D4 30C9                    	XOR	CL,CL			; set zero
   315 000000D6 F9                      	STC
   316 000000D7 C3                      	Return
   317                                  
   318                                  EndProc GETPATH
   319                                  
   320                                  ; Check to see if the name at DS:DI is a device.  Returns carry set if not a
   321                                  ;   device.
   322                                  ; Blasts CX,SI,DI,AX,BX
   323                                  
   324                                  Procedure   ChkDev,NEAR
   324          ******************       warning: proc ChkDev... [-w+user]
   325                                  	ASSUME	ES:Nothing,DS:NOTHING
   326                                  
   327 000000D8 89FE                    	MOV	SI,DI
   328 000000DA 8CD7                    	MOV	DI,SS
   329 000000DC 8EC7                    	MOV	ES,DI
   330                                  	ASSUME	ES:DOSGroup		; Now here is where ES is DOSGroup
   331                                  
   332                                  NAME1 equ Name1	; NASM port label
   333 000000DE BF[0000]                	MOV	DI,OFFSET NAME1 wrt DOSGROUP
   334 000000E1 B90900                  	MOV	CX,9
   335                                  TESTLOOP:
   336 000000E4 E8(0000)                	invoke	GETLET
   337                                   %IF  DBCS				;AN000;
   338                                  	invoke	Testkanj		;AN000;; 2/13/KK
   339                                  	jz	Notkanja		;AN000;; 2/13/KK
   340                                  	stosb				;AN000;; Skip second byte   2/13/KK
   341                                  	dec	cx			;AN000;; 2/13/KK
   342                                  notdev equ NOTDEV	; NASM port label
   343                                  	jcxz	notdev			;AN000;; 2/13/KK
   344                                  	lodsb				;AN000;; 2/13/KK
   345                                  	jmp	short stowit		;AN000;; 2/13/KK
   346                                  Notkanja:				;AN000;
   347                                   %ENDIF					;AN000;
   348 000000E7 3C2E                    	CMP	AL,'.'
   349 000000E9 740E                    	JZ	TESTDEVICE
   350 000000EB E8(0000)                	invoke	PATHCHRCMP
   351 000000EE 7407                    	JZ	NOTDEV
   352 000000F0 08C0                    	OR	AL,AL
   353 000000F2 7405                    	JZ	TESTDEVICE
   354                                  stowit:
   355 000000F4 AA                      	STOSB
   356 000000F5 E2ED                    	LOOP	TESTLOOP
   357                                  NOTDEV:
   358 000000F7 F9                      	STC
   359 000000F8 C3                      	return
   360                                  
   361                                  TESTDEVICE:
   362 000000F9 83C102                  	ADD	CX,2
   363 000000FC B020                    	MOV	AL,' '
   364 000000FE F3AA                    	REP	STOSB
   365 00000100 8CD0                    	MOV	AX,SS
   366 00000102 8ED8                    	MOV	DS,AX
   367                                   assume ds:DOSGROUP
   368 00000104 E8C801                  	invoke	DEVNAME
   369 00000107 C3                      	return
   370                                  EndProc ChkDev
   371                                  
   372                                  Break	<ROOTPATH, FINDPATH -- PARSE A PATH>
   373                                  
   374                                  ; Inputs:
   375                                  ;	Same as FINDPATH but,
   376                                  ;	SI Points to asciz string of path which is assumed to start at
   377                                  ;		the root (no leading '/').
   378                                  ; Function:
   379                                  ;	Search from root for path
   380                                  ; Outputs:
   381                                  ;	Same as FINDPATH but:
   382                                  ;	If root directory specified, [CURBUF] and [NAME1] are NOT set, and
   383                                  ;	[NoSetDir] is ignored.
   384                                  
   385                                  	procedure   ROOTPATH,near
   385          ******************       warning: proc ROOTPATH... [-w+user]
   386                                  
   387                                  	DOSAssume   CS,<DS>,"RootPath"
   388                                  	ASSUME	ES:NOTHING
   389                                  
   390 00000108 E8(0000)                	invoke	SETROOTSRCH
   391 0000010B 803C00                  	CMP	BYTE PTR [SI],0
   392 0000010E 7509                    	JNZ	FINDPATH
   393                                  
   394                                  ; Root dir specified
   395 00000110 A0[0000]                	MOV	AL,[SAttrib]
   396 00000113 A2[0000]                	MOV	[Attrib],AL
   397 00000116 30E4                    	XOR	AH,AH			; Sets "device ID" byte, sets zero
   398                                  					; (dir), clears carry.
   399 00000118 C3                      	return
   400                                  
   401                                  ; Inputs:
   402                                  ;	[ATTRIB] Set to get through directories
   403                                  ;	[SATTRIB] Set to find last element
   404                                  ;	ES:BP Points to DPB
   405                                  ;	SI Points to asciz string of path (no leading '/').
   406                                  ;	[SECCLUSPOS] = 0
   407                                  ;	[DIRSEC] = Phys sec # of first sector of directory
   408                                  ;	[CLUSNUM] = Cluster # of next cluster
   409                                  ;	[CLUSFAC] = Sectors per cluster
   410                                  ;	[NoSetDir] set
   411                                  ;	[CURR_DIR_END] Points to end of Current dir part of string
   412                                  ;		( = -1 if current dir not involved, else
   413                                  ;		 Points to first char after last "/" of current dir part)
   414                                  ;	[THISCDS] Points to CDS being used
   415                                  ;	[CREATING] and [DELALL] set
   416                                  ; Function:
   417                                  ;	Parse path name
   418                                  ; Outputs:
   419                                  ;	ID1 field of [THISCDS] updated appropriately
   420                                  ;	[ATTRIB] = [SATTRIB]
   421                                  ;	ES:BP Points to DPB
   422                                  ;	[THISDPB] = ES:BP
   423                                  ;	Carry set if bad path
   424                                  ;	   SI Points to path element causing failure
   425                                  ;	   Zero set
   426                                  ;	      [DIRSTART],[DIRSEC],[CLUSNUM], and [CLUSFAC] are set up to
   427                                  ;	      start a search on the last directory
   428                                  ;	      CL is zero if there is a bad name in the path
   429                                  ;	      CL is non-zero if the name was simply not found
   430                                  ;		 [ENTFREE] may have free spot in directory
   431                                  ;		 [NAME1] is the name.
   432                                  ;		 CL = 81H if '*'s or '?' in NAME1, 80H otherwise
   433                                  ;	   Zero reset
   434                                  ;	      File in middle of path or bad name in path
   435                                  ;		or path too long or malformed path
   436                                  ;	ELSE
   437                                  ;	   [CURBUF] contains directory record with match
   438                                  ;	   [CURBUF+2]:BX Points into [CURBUF] to start of entry
   439                                  ;	   [CURBUF+2]:SI Points to fcb_FIRCLUS field for entry
   440                                  ;	   [NAME1] Has name looked for
   441                                  ;	   AH = device ID
   442                                  ;	      bit 7 of AH set if device SI and BX
   443                                  ;	      will point DOSGROUP relative The firclus
   444                                  ;	      field of the device entry contains the device pointer
   445                                  ;	   If last element is a directory zero is set and:
   446                                  ;	      [DIRSTART],[SECCLUSPOS],[DIRSEC],[CLUSNUM], and [CLUSFAC]
   447                                  ;	      are set up to start a search on it,
   448                                  ;	      unless [NoSetDir] is non zero in which case the return is
   449                                  ;	      like that for a file (except for zero flag)
   450                                  ;	   If last element is a file zero is reset
   451                                  ;	      [DIRSEC],[CLUSNUM],[CLUSFAC],[NXTCLUSNUM],[SECCLUSPOS],
   452                                  ;	      [LASTENT], [ENTLAST] are set to continue search of last
   453                                  ;	      directory for furthur matches on NAME1 via the NEXTENT
   454                                  ;	      entry point in FindEntry (or GETENT entry in GETENTRY in
   455                                  ;	      which case [NXTCLUSNUM] and [SECCLUSPOS] need not be valid)
   456                                  ; Destroys all other registers
   457                                  
   458                                      entry   FINDPATH
   459                                  	DOSAssume   CS,<DS>,"FindPath"
   460                                  	ASSUME	ES:NOTHING
   461                                  
   462                                  	Assert	ISDPB,<ES,BP>,"FindPath"
   463 00000119 06                      	PUSH	ES			; Save ES:BP
   464 0000011A 56                      	PUSH	SI
   465 0000011B 89F7                    	MOV	DI,SI
   466                                  DIRSTART equ DirStart	; NASM port label
   467 0000011D 8B0E[0000]              	MOV	CX,[DIRSTART]		; Get start clus of dir being searched
   468 00000121 833E[0000]FF            	CMP	word [CURR_DIR_END],-1
   469 00000126 740E                    	JZ	NOIDS			; No current dir part
   470 00000128 3B3E[0000]              	CMP	DI,[CURR_DIR_END]
   471 0000012C 7508                    	JNZ	NOIDS			; Not to current dir end yet
   472 0000012E C43E[0000]              	LES	DI,[THISCDS]
   473 00000132 26894D49                	MOV	[ES:DI + curdir_ID],CX	; Set current directory currency
   474                                  NOIDS:
   475                                  ;
   476                                  ; Parse the name off of DS:SI into NAME1.  AL = 1 if there was a meta
   477                                  ; character in the string.  CX,DI  may be destroyed.
   478                                  ;
   479                                  ;	invoke	NAMETRANS
   480                                  ;	MOV	CL,AL
   481                                  ;
   482                                  ; The above is the slow method.  The name has *already* been munged by
   483                                  ; TransPath so no special casing needs to be done.  All we do is try to copy
   484                                  ; the name until ., \ or 0 is hit.
   485                                  ;
   486 00000136 8CD0                    	MOV	AX,SS
   487 00000138 8EC0                    	MOV	ES,AX
   488                                   assume es:DOSGROUP
   489 0000013A BF[0000]                	MOV	DI,OFFSET Name1 wrt DOSGroup
   490 0000013D B82020                  	MOV	AX,'  '
   491 00000140 AA                      	STOSB
   492 00000141 AB                      	STOSW
   493 00000142 AB                      	STOSW
   494 00000143 AB                      	STOSW
   495 00000144 AB                      	STOSW
   496 00000145 AB                      	STOSW
   497 00000146 BF[0000]                	MOV	DI,OFFSET Name1 wrt DOSGroup
   498 00000149 30E4                    	XOR	AH,AH			; bits for CL
   499                                   %IF  DBCS				;AN000;
   500                                  ;-------------------------- Start of DBC;AN000;S 2/13/KK
   501                                  	XOR	CL,CL			;AN000;; clear count for volume id
   502                                  	LODSB				;AN000;;IBMJ fix 9/04/86
   503                                  	CMP	AL,05h			;AN000;;IBMJ fix 9/04/86
   504                                  	JNE	GetNam2 		;AN000;;IBMJ fix 9/04/86
   505                                  	PUSH	AX			;AN000;        ;IBMJ fix 9/04/86
   506                                  	MOV	AL,0E5h 		;AN000;;IBMJ fix 9/04/86
   507                                  	Invoke	TestKanj		;AN000;;IBMJ fix 9/04/86
   508                                  	POP	AX			;AN000;        ;IBMJ fix 9/04/86
   509                                  	JZ	Notkanjb		;AN000;        ;IBMJ fix 9/04/86
   510                                  	JMP	SHORT GetNam3		;AN000;;IBMJ fix 9/04/86
   511                                  ;-------------------------- End of DBCS ;AN000;2/13/KK
   512                                   %ENDIF
   513                                  GetNam:
   514 0000014B FEC1                    	INC	CL			;AN000; KK incrment volid count
   515 0000014D AC                      	LODSB
   516                                   %IF  DBCS				;AN000;
   517                                  GetNam2:				;AN000;; 2/13/KK
   518                                  	invoke	Testkanj		;AN000;; 2/13/KK
   519                                  	jz	Notkanjb		;AN000;; 2/13/KK
   520                                  GetNam3:				;AN000;; 2/13/KK
   521                                  	STOSB				;AN000;; 2/13/KK
   522                                  	INC	CL			;AN000;; KK incrment volid count
   523                                  	LODSB				;AN000;; 2/13/KK
   524                                  	TEST	word [DOS34_FLAG],DBCS_VOLID ;AN000;; 2/13/KK
   525                                  	JZ	notvol			;AN000;; 2/13/KK
   526                                  	CMP	CL,8			;AN000;; 2/13/KK
   527                                  	JNZ	notvol			;AN000;; 2/13/KK
   528                                  	CMP	AL,'.'                  ;AN000;; 2/13/KK
   529                                  	JNZ	notvol			;AN000;; 2/13/KK
   530                                  	LODSB				;AN000;; 2/13/KK
   531                                  notvol: 				;AN000;
   532                                  	jmp	short StoNam		;AN000;; 2/13/KK
   533                                  Notkanjb:				;AN000;; 2/13/KK
   534                                   %ENDIF					;AN000;
   535 0000014E 3C2E                    	CMP	AL,'.'
   536                                  setExt equ SetExt	; NASM port label
   537 00000150 7412                    	JZ	setExt
   538 00000152 08C0                    	OR	AL,AL
   539 00000154 7424                    	JZ	GetDone
   540 00000156 3C5C                    	CMP	AL,'\'
   541 00000158 7420                    	JZ	GetDone
   542 0000015A 3C3F                    	CMP	AL,'?'
   543 0000015C 7503                    	JNZ	StoNam
   544 0000015E 80CC01                  	OR	AH,1
   545 00000161 AA                      StoNam: STOSB
   546 00000162 EBE7                    	JMP	GetNam
   547                                  SetExt:
   548 00000164 BF[0800]                	MOV	DI,OFFSET Name1+8 wrt DOSGroup
   549                                  GetExt:
   550 00000167 AC                      	LODSB
   551                                   %IF  DBCS				;AN000;
   552                                  	invoke	TestKanj		;AN000;; 2/13/KK
   553                                  	jz	Notkanjc		;AN000;; 2/13/KK
   554                                  	STOSB				;AN000;; 2/13/KK
   555                                  	LODSB				;AN000;; 2/13/KK
   556                                  	jmp	short StoExt		;AN000;; 2/13/KK
   557                                  Notkanjc:				;AN000;; 2/13/KK
   558                                   %ENDIF					;AN000;
   559 00000168 08C0                    	OR	AL,AL
   560 0000016A 740E                    	JZ	GetDone
   561 0000016C 3C5C                    	CMP	AL,'\'
   562 0000016E 740A                    	JZ	GetDone
   563 00000170 3C3F                    	CMP	AL,'?'
   564 00000172 7503                    	JNZ	StoExt
   565 00000174 80CC01                  	OR	AH,1
   566 00000177 AA                      StoExt: STOSB
   567 00000178 EBED                    	JMP	GetExt
   568                                  GetDone:
   569 0000017A 4E                      	DEC	SI
   570 0000017B 88E1                    	MOV	CL,AH
   571                                  
   572                                  
   573 0000017D 80C980                  	OR	CL,80H
   574 00000180 5F                      	POP	DI			; Start of this element
   575 00000181 07                      	POP	ES			; Restore ES:BP
   576                                   assume es:nothing
   577 00000182 39FE                    	CMP	SI,DI
   578 00000184 7503                    	JNZ	check_device
   579 00000186 E9ED00                  	JMP	BADPATH 		; NUL parse (two delims most likely)
   580                                  check_device:
   581 00000189 56                      	PUSH	SI			; Start of next element
   582 0000018A 8A04                    	MOV	AL,BYTE PTR [SI]
   583 0000018C 08C0                    	OR	AL,AL
   584 0000018E 7508                    	JNZ	NOT_LAST
   585                                  
   586                                  ;
   587                                  ; for last element of the path switch to the correct search attributes
   588                                  ;
   589 00000190 8A3E[0000]              	MOV	BH,[SAttrib]
   590 00000194 883E[0000]              	MOV	[Attrib],BH
   591                                  NOT_LAST:
   592                                  
   593                                  ;
   594                                  ; check name1 to see if we have a device...
   595                                  ;
   596 00000198 06                      	PUSH	ES			; Save ES:BP
   597 00000199 1607                    	context ES
   598 0000019B E83101                  	invoke	DEVNAME 		; blast BX
   599 0000019E 07                      	POP	ES			; Restore ES:BP
   600                                  	ASSUME	ES:NOTHING
   601 0000019F 720B                    	JC	FindFile		; Not a device
   602 000001A1 08C0                    	OR	AL,AL			; Test next char again
   603 000001A3 7403                    	JZ	GO_BDEV
   604                                  FileInPath equ FILEINPATH	; NASM port label
   605 000001A5 E9D200                  	JMP	FileInPath		; Device name in middle of path
   606                                  
   607                                  GO_BDEV:
   608 000001A8 5E                      	POP	SI			; Points to NUL at end of path
   609 000001A9 E97AFE                  	JMP	Build_devJ
   610                                  
   611                                  FindFile:
   612                                  	ASSUME	ES:NOTHING
   613                                  ;;;; 7/28/86
   614 000001AC 803E[0000]E5            	CMP	BYTE PTR [NAME1],0E5H	; if 1st char = E5
   615 000001B1 7505                    	JNZ	NOE5			; no
   616 000001B3 C606[0000]05            	MOV	BYTE PTR [NAME1],05H	; change it to 05
   617                                  NOE5:
   618                                  
   619                                  ;;;; 7/28/86
   620 000001B8 57                      	PUSH	DI			; Start of this element
   621 000001B9 06                      	PUSH	ES			; Save ES:BP
   622 000001BA 51                      	PUSH	CX			; CL return from NameTrans
   623                                  ;DOS 3.3 FastOPen 6/12/86 F.C.
   624                                  
   625 000001BB E89C02                  	CALL	LookupPath		; call fastopen to get dir entry
   626 000001BE 7303                    	JNC	DIR_FOUND		; found dir entry
   627                                  
   628                                  ;DOS 3.3 FastOPen 6/12/86 F.C.
   629 000001C0 E8(0000)                	invoke	FINDENTRY
   630                                  DIR_FOUND:
   631 000001C3 59                      	POP	CX
   632 000001C4 07                      	POP	ES
   633                                   assume es:nothing
   634 000001C5 5F                      	POP	DI
   635 000001C6 7303                    	JNC	LOAD_BUF
   636 000001C8 E9D400                  	JMP	BADPATHPOP
   637                                  
   638                                  LOAD_BUF:
   639                                  CURBUF equ CurBuf	; NASM port label
   640 000001CB C53E[0000]              	LDS	DI,[CURBUF]
   641                                  ASSUME	DS:NOTHING
   642 000001CF F6470B10                	TEST	BYTE PTR [BX+dir_attr],attr_directory
   643 000001D3 7503                    	JNZ	GO_NEXT 		; DOS 3.3
   644 000001D5 E9A200                  	JMP	FileInPath		; Error or end of path
   645                                  ;
   646                                  ; if we are not setting the directory, then check for end of string
   647                                  ;
   648                                  GO_NEXT:
   649 000001D8 36803E[0000]00          	CMP	BYTE PTR [ss:NoSetDir],0
   650 000001DE 7426                    	JZ	SetDir
   651 000001E0 89FA                    	MOV	DX,DI			; Save pointer to entry
   652 000001E2 8CD9                    	MOV	CX,DS
   653 000001E4 161F                    	context DS
   654 000001E6 5F                      	POP	DI			; Start of next element
   655 000001E7 F606[0000]01            	TEST   byte [FastOpenFlg],FastOpen_Set     ;only DOSOPEN can take advantage of
   656 000001EC 740B                    	JZ     nofast			      ; the FastOpen
   657 000001EE F606[0000]02            	TEST   byte [FastOpenFlg],Lookup_Success   ; Lookup just happened
   658 000001F3 7404                    	JZ     nofast			      ; no
   659 000001F5 8B3E[0000]              	MOV    DI,[Next_Element_Start]	      ; no need to insert it again
   660                                  nofast:
   661 000001F9 803D00                  	CMP	BYTE PTR [DI],0
   662 000001FC 7503                    	JNZ	NEXT_ONE		; DOS 3.3
   663                                  SetRet equ SETRET	; NASM port label
   664 000001FE E99D00                  	JMP	SetRet			; Got it
   665                                  NEXT_ONE:
   666 00000201 57                      	PUSH	DI			; Put start of next element back on stack
   667 00000202 89D7                    	MOV	DI,DX
   668 00000204 8ED9                    	MOV	DS,CX			; Get back pointer to entry
   669                                  ASSUME	DS:NOTHING
   670                                  
   671                                  SetDir:
   672 00000206 8B14                    	MOV	DX,[SI] 		; Dir_first
   673                                  
   674                                  ;DOS 3.3 FastOPen 6/12/86 F.C.
   675                                  
   676 00000208 1E                      	PUSH	DS		      ; save [curbuf+2]
   677 00000209 161F                    	context DS		      ; set DS Dosgroup
   678 0000020B F606[0000]02            	TEST	byte [FastOpenFlg],Lookup_Success   ;
   679 00000210 7411                    	JZ	DO_NORMAL	      ; fastopen not in memory or path not
   680 00000212 89D3                    	MOV	BX,DX		      ; not found
   681 00000214 8B3E[0000]              	MOV	DI,[CLUSNUM]	      ; clusnum was set in LookupPath
   682 00000218 50                      	PUSH	AX		      ; save device id (AH)
   683 00000219 E8(0000)                	invoke	SETDIRSRCH
   684 0000021C 58                      	POP	AX		      ; restore device id (AH)
   685 0000021D 83C402                  	ADD	SP,2		      ; pop ds in stack
   686 00000220 EB3E                    	JMP	FAST_OPEN_SKIP
   687 00000222 90                      	nop	; identicalise
   688                                  
   689                                  DO_NORMAL:
   690 00000223 1F                      	POP	DS			; DS = [curbuf + 2]
   691                                   assume ds:nothing
   692                                  ;DOS 3.3 FastOPen 6/12/86 F.C.
   693                                  
   694 00000224 29FB                    	SUB	BX,DI			; Offset into sector of start of entry
   695 00000226 29FE                    	SUB	SI,DI			; Offset into sector of dir_first
   696 00000228 53                      	PUSH	BX
   697 00000229 50                      	PUSH	AX
   698 0000022A 56                      	PUSH	SI
   699 0000022B 51                      	PUSH	CX
   700 0000022C FF7508                  	PUSH	WORD PTR [DI + buf_sector]     ;AN000;>32mb
   701 0000022F FF750A                  	PUSH	WORD PTR [DI + buf_sector+2]   ;AN000;>32mb
   702 00000232 89D3                    	MOV	BX,DX
   703 00000234 161F                    	context DS
   704 00000236 E8(0000)                	invoke	SETDIRSRCH		; This uses UNPACK which might blow
   705                                  					; the entry sector buffer
   706 00000239 8F06[0000]              	POP	word [HIGH_SECTOR]
   707 0000023D 5A                      	POP	DX
   708 0000023E 720A                    	JC	SKIP_GETB
   709                                  allowed_RETRY equ Allowed_RETRY	; NASM port equate
   710                                  allowed_FAIL equ Allowed_FAIL	; NASM port equate
   711 00000240 C606[0000]18            	MOV	byte [ALLOWED],allowed_RETRY + allowed_FAIL
   712 00000245 30C0                    	XOR	AL,AL
   713 00000247 E8(0000)                	invoke	GETBUFFR		; Get the entry buffer back
   714                                  SKIP_GETB:
   715 0000024A 59                      	POP	CX
   716 0000024B 5E                      	POP	SI
   717 0000024C 58                      	POP	AX
   718 0000024D 5B                      	POP	BX
   719 0000024E 7305                    	JNC	SET_THE_BUF
   720 00000250 5F                      	POP	DI			; Start of next element
   721 00000251 89FE                    	MOV	SI,DI			; Point with SI
   722 00000253 EB21                    	JMP	SHORT BADPATH
   723                                  
   724                                  SET_THE_BUF:
   725 00000255 E8(0000)                	invoke	SET_BUF_AS_DIR
   726 00000258 8B3E[0000]              	MOV	DI,WORD PTR [CURBUF]
   727 0000025C 01FE                    	ADD	SI,DI			; Get the offsets back
   728 0000025E 01FB                    	ADD	BX,DI
   729                                  ; DOS 3.3 FasOpen 6/12/86  F.C.
   730                                  
   731                                  FAST_OPEN_SKIP:
   732                                  
   733 00000260 5F                      	POP	DI			; Start of next element
   734 00000261 E89302                  	CALL   InsertPath	     ; insert dir entry info
   735                                  
   736                                  ; DOS 3.3 FasOpen 6/12/86  F.C.
   737                                  
   738                                  
   739 00000264 8A05                    	MOV	AL,[DI]
   740 00000266 08C0                    	OR	AL,AL
   741 00000268 7434                    	JZ	SETRET			; At end
   742 0000026A 47                      	INC	DI			; Skip over "/"
   743 0000026B 89FE                    	MOV	SI,DI			; Point with SI
   744 0000026D E8(0000)                	invoke	PATHCHRCMP
   745 00000270 7503                    	JNZ	find_bad_name		; oops
   746 00000272 E9A4FE                  	JMP	FINDPATH		; Next element
   747                                  
   748                                  find_bad_name:
   749 00000275 4E                      	DEC	SI			; Undo above INC to get failure point
   750                                  BADPATH:
   751 00000276 30C9                    	XOR	CL,CL			; Set zero
   752 00000278 EB2C                    	JMP	SHORT BADPRET
   753                                  
   754                                  FILEINPATH:
   755 0000027A 5F                      	POP	DI			; Start of next element
   756 0000027B 161F                    	context DS			; Got to from one place with DS gone
   757                                  ; DOS 3.3 FastOpen
   758                                  
   759 0000027D F606[0000]01            	TEST	byte [FastOpenFlg],FastOpen_Set  ; do this here is we don't want to
   760 00000282 740B                    	JZ	NO_FAST 		    ; device info to fastopen
   761 00000284 F606[0000]02            	TEST	byte [FastOpenFlg],Lookup_Success
   762 00000289 7404                    	JZ	NO_FAST
   763 0000028B 8B3E[0000]              	MOV	DI,[Next_Element_Start]  ; This takes care of one time lookup
   764                                  					 ; success
   765                                  NO_FAST:
   766                                  
   767                                  ; DOS 3.3 FastOpen
   768                                  
   769 0000028F 8A05                    	MOV	AL,[DI]
   770 00000291 08C0                    	OR	AL,AL
   771 00000293 7404                    	JZ	INCRET
   772 00000295 89FE                    	MOV	SI,DI			; Path too long
   773 00000297 EB0D                    	JMP	SHORT BADPRET
   774                                  
   775                                  INCRET:
   776                                  ; DOS 3.3 FasOpen 6/12/86  F.C.
   777                                  
   778 00000299 E85B02                  	CALL   InsertPath	     ; insert dir entry info
   779                                  
   780                                  ; DOS 3.3 FasOpen 6/12/86  F.C.
   781 0000029C FEC0                    	INC	AL			; Reset zero
   782                                  SETRET:
   783 0000029E C3                      	return
   784                                  
   785                                  BADPATHPOP:
   786 0000029F 5E                      	POP	SI			; Start of next element
   787 000002A0 8A04                    	MOV	AL,[SI]
   788 000002A2 89FE                    	MOV	SI,DI			; Start of bad element
   789 000002A4 08C0                    	OR	AL,AL			; zero if bad element is last, non-zero if path too long
   790                                  BADPRET:
   791 000002A6 A0[0000]                	MOV	AL,[SAttrib]
   792 000002A9 A2[0000]                	MOV	[Attrib],AL		; Make sure return correct
   793 000002AC F9                      	STC
   794 000002AD C3                      	return
   795                                  EndProc ROOTPATH
   796                                  
   797                                  Break	<STARTSRCH -- INITIATE DIRECTORY SEARCH>
   798                                  
   799                                  ; Inputs:
   800                                  ;	[THISDPB] Set
   801                                  ; Function:
   802                                  ;	Set up a search for GETENTRY and NEXTENTRY
   803                                  ; Outputs:
   804                                  ;	ES:BP = Drive parameters
   805                                  ;	Sets up LASTENT, ENTFREE=ENTLAST=-1, VOLID=0
   806                                  ; Destroys ES,BP,AX
   807                                  
   808                                  	procedure   StartSrch,NEAR
   808          ******************       warning: proc StartSrch... [-w+user]
   809                                  	DOSAssume   CS,<DS>,"StartSrch"
   810                                  	ASSUME	ES:NOTHING
   811                                  
   812                                  	Assert	ISDPB,<<WORD PTR THISDPB+2>,<WORD PTR THISDPB>>,"StartSrch"
   813 000002AE C42E[0000]              	LES	BP,[THISDPB]
   814 000002B2 31C0                    	XOR	AX,AX
   815                                  LASTENT equ LastEnt	; NASM port label
   816 000002B4 A3[0000]                	MOV	[LASTENT],AX
   817                                  VOLID equ VolID	; NASM port label
   818 000002B7 A2[0000]                	MOV	BYTE PTR [VOLID],AL	; No volume ID found
   819 000002BA 48                      	DEC	AX
   820                                  ENTFREE equ EntFree	; NASM port label
   821 000002BB A3[0000]                	MOV	[ENTFREE],AX
   822                                  ENTLAST equ EntLast	; NASM port label
   823 000002BE A3[0000]                	MOV	[ENTLAST],AX
   824 000002C1 C3                      	return
   825                                  EndProc StartSrch
   826                                  
   827                                  BREAK <MatchAttributes - the final check for attribute matching>
   828                                  
   829                                  ;
   830                                  ; Input:    [Attrib] = attribute to search for
   831                                  ;	    CH = found attribute
   832                                  ; Output:   JZ <match>
   833                                  ;	    JNZ <nomatch>
   834                                  ; Registers modified: noneski
   835                                  	procedure MatchAttributes,near
   835          ******************       warning: proc MatchAttributes... [-w+user]
   836                                  	ASSUME	DS:NOTHING,ES:NOTHING
   837 000002C2 50                      	PUSH	AX
   838 000002C3 36A0[0000]              	MOV	AL,[ss:Attrib]		; AL <- SearchSet
   839 000002C7 F6D0                    	NOT	AL			; AL <- SearchSet'
   840 000002C9 20E8                    	AND	AL,CH			; AL <- SearchSet' and FoundSet
   841 000002CB 2416                    	AND	AL,attr_all		; AL <- SearchSet' and FoundSet and Important
   842                                  ;
   843                                  ; the result is non-zero if an attribute is not in the search set
   844                                  ; and in the found set and in the important set. This means that we do not
   845                                  ; have a match.  Do a JNZ <nomatch> or JZ <match>
   846                                  ;
   847 000002CD 58                      	POP	AX
   848 000002CE C3                      	return
   849                                  EndProc MatchAttributes
   850                                  
   851                                  Break <DEVNAME - Look for name of device>
   852                                  
   853                                  ; Inputs:
   854                                  ;	DS,ES:DOSGROUP
   855                                  ;	Filename in NAME1
   856                                  ;	ATTRIB set so that we can error out if looking for Volume IDs
   857                                  ; Function:
   858                                  ;	Determine if file is in list of I/O drivers
   859                                  ; Outputs:
   860                                  ;	Carry set if not a device
   861                                  ;	ELSE
   862                                  ;	Zero flag set
   863                                  ;	BH = Bit 7,6 = 1, bit 5 = 0 (cooked mode)
   864                                  ;	     bits 0-4 set from low byte of attribute word
   865                                  ;	DEVPT = DWORD pointer to Device header of device
   866                                  ; BX destroyed, others preserved
   867                                  
   868                                  	procedure   DEVNAME,NEAR
   868          ******************       warning: proc DEVNAME... [-w+user]
   869                                  	DOSAssume   CS,<ES,DS>,"DEVNAME"
   870                                  
   871 000002CF 56                      	PUSH	SI
   872 000002D0 57                      	PUSH	DI
   873 000002D1 51                      	PUSH	CX
   874 000002D2 50                      	PUSH	AX
   875                                  
   876                                  ; E5 special code
   877 000002D3 FF36[0000]              	PUSH	WORD PTR [NAME1]
   878 000002D7 803E[0000]05            	CMP	byte [NAME1],5
   879 000002DC 7505                    	JNZ	NOKTR
   880 000002DE C606[0000]E5            	MOV	byte [NAME1],0E5H
   881                                  NOKTR:
   882                                  
   883 000002E3 F606[0000]08            	TEST	byte [Attrib],attr_volume_id	; If looking for VOL id don't find devs
   884 000002E8 7522                    	JNZ	RET31
   885 000002EA BE[0000]                	MOV	SI,OFFSET NULDEV wrt DOSGROUP
   886                                  LOOKIO:
   887                                  ASSUME	DS:NOTHING
   888 000002ED F744040080              	TEST	word [SI + SDEVATT],DEVTYP
   889 000002F2 7411                    	JZ	SKIPDEV 		; Skip block devices (NET and LOCAL)
   890 000002F4 89F0                    	MOV	AX,SI
   891 000002F6 83C60A                  	ADD	SI,SDEVNAME
   892 000002F9 BF[0000]                	MOV	DI,OFFSET NAME1 wrt DOSGROUP
   893 000002FC B90400                  	MOV	CX,4			; All devices are 8 letters
   894 000002FF F3A7                    	REPE	CMPSW			; Check for name in list
   895 00000301 89C6                    	MOV	SI,AX
   896 00000303 7415                    	JZ	IOCHK			; Found it?
   897                                  SKIPDEV:
   898 00000305 C534                    	LDS	SI,[SI]	; Get address of next device
   899 00000307 83FEFF                  	CMP	SI,-1			; At end of list?
   900 0000030A 75E1                    	JNZ	LOOKIO
   901 0000030C F9                      RET31:	STC				; Not found
   902 0000030D 8CD1                    RETNV:	MOV	CX,SS
   903 0000030F 8ED9                    	MOV	DS,CX
   904                                  	ASSUME	DS:DOSGroup
   905 00000311 8F06[0000]              	POP	WORD PTR [NAME1]
   906 00000315 58                      	POP	AX
   907 00000316 59                      	POP	CX
   908 00000317 5F                      	POP	DI
   909 00000318 5E                      	POP	SI
   910 00000319 C3                      	RET
   911                                  
   912                                  IOCHK:
   913                                  ASSUME	DS:NOTHING
   914 0000031A 368C1E[0200]            	MOV	WORD PTR [ss:DEVPT+2],DS	; Save pointer to device
   915 0000031F 8A7C04                  	MOV	BH,BYTE PTR [SI + SDEVATT]
   916 00000322 80CFC0                  	OR	BH,0C0H
   917 00000325 80E7DF                  	AND	BH,~ 020H		; Clears Carry
   918 00000328 368936[0000]            	MOV	WORD PTR [ss:DEVPT],SI
   919 0000032D EBDE                    	JMP	RETNV
   920                                  EndProc DEVNAME
   921                                  
   922                                  BREAK <Build_device_ent - Make a Directory entry>
   923                                  
   924                                  ; Inputs:
   925                                  ;	[NAME1] has name
   926                                  ;	BH is attribute field (supplied by DEVNAME)
   927                                  ;	[DEVPT] points to device header (supplied by DEVNAME)
   928                                  ; Function:
   929                                  ;	Build a directory entry for a device at DEVFCB
   930                                  ; Outputs:
   931                                  ;	BX points to DEVFCB
   932                                  ;	SI points to dir_first field
   933                                  ;	AH = input BH
   934                                  ;	AL = 0
   935                                  ;	dir_first = DEVPT
   936                                  ;	Zero Set, Carry Clear
   937                                  ; DS,ES,BP preserved, others destroyed
   938                                  
   939                                  	procedure Build_device_ent,near
   939          ******************       warning: proc Build_device_ent... [-w+user]
   940                                  	DOSAssume   CS,<ES,DS>,"Build_Device_Ent"
   941                                  
   942 0000032F B82020                  	MOV	AX,"  "
   943 00000332 BF[0800]                	MOV	DI,OFFSET DEVFCB+8 wrt DOSGROUP ; Point to extent field
   944                                  ;
   945                                  ; Fill dir_ext
   946                                  ;
   947 00000335 AB                      	STOSW
   948 00000336 AA                      	STOSB				; Blank out extent field
   949 00000337 B040                    	MOV	AL,attr_device
   950                                  ;
   951                                  ; Fill Dir_attr
   952                                  ;
   953 00000339 AA                      	STOSB				; Set attribute field
   954 0000033A 31C0                    	XOR	AX,AX
   955 0000033C B90A00                  	MOV	CX,10
   956                                  ;
   957                                  ; Fill dir_pad
   958                                  ;
   959 0000033F F3AB                    	REP	STOSW			; Fill rest with zeros
   960 00000341 E8(0000)                	invoke	DATE16
   961 00000344 BF[1600]                	MOV	DI,OFFSET DEVFCB+dir_time wrt DOSGROUP
   962 00000347 92                      	XCHG	AX,DX
   963                                  ;
   964                                  ; Fill dir_time
   965                                  ;
   966 00000348 AB                      	STOSW
   967 00000349 92                      	XCHG	AX,DX
   968                                  ;
   969                                  ; Fill dir_date
   970                                  ;
   971 0000034A AB                      	STOSW
   972 0000034B 89FE                    	MOV	SI,DI			; SI points to dir_first field
   973 0000034D A1[0000]                	MOV	AX,WORD PTR [DEVPT]
   974                                  ;
   975                                  ; Fill dir_first
   976                                  ;
   977 00000350 AB                      	STOSW				; Dir_first points to device
   978 00000351 A1[0200]                	MOV	AX,WORD PTR [DEVPT+2]
   979                                  ;
   980                                  ; Fill dir_size_l
   981                                  ;
   982 00000354 AB                      	STOSW
   983 00000355 88FC                    	MOV	AH,BH			; Put device atts in AH
   984 00000357 BB[0000]                	MOV	BX,OFFSET DEVFCB wrt DOSGROUP
   985 0000035A 30C0                    	XOR	AL,AL			; Set zero, clear carry
   986 0000035C C3                      	return
   987                                  EndProc Build_device_ent
   988                                  
   989                                  Break	<ValidateCDS - given a CDS, validate the media and the current directory>
   990                                  
   991                                  ;
   992                                  ;   ValidateCDS - Get current CDS.  Splice it.	Call FatReadCDS to check
   993                                  ;   media.  If media has been changed, do DOS_Chdir to validate path.  If
   994                                  ;   invalid, reset original CDS to root.
   995                                  ;
   996                                  ;   Inputs:	ThisCDS points to CDS of interest
   997                                  ;		SS:DI points to temp buffer
   998                                  ;   Outputs:	The current directory string is validated on the appropriate
   999                                  ;		    drive
  1000                                  ;		ThisDPB changed
  1001                                  ;		ES:DI point to CDS
  1002                                  ;		Carry set if error (currently user FAILed to I 24)
  1003                                  ;   Registers modified: all
  1004                                  
  1005                                  Procedure   ValidateCDS,NEAR
  1005          ******************       warning: proc ValidateCDS... [-w+user]
  1006                                   ASSUME DS:NOTHING, ES:NOTHING, SS:DOSGROUP
  1007                                  Public DIR2001S,DIR2001E
  1008                                  DIR2001S:
  1009                                  	LocalVar    Temp,WORD
  1010                                  	LocalVar    SaveCDS,DWORD
  1011                                  DIR2001E:
  1012 0000035D 5589E583EC06            	Enter
  1013 00000363 897EFE                  	MOV	[Temp],DI
  1014                                  ThisCDS equ THISCDS	; NASM port label
  1015 00000366 36C536[0000]            	LDS	SI,[ss:ThisCDS]
  1016 0000036B 8976FA                  	MOV	[SaveCDSL],SI
  1017 0000036E 8C5EFC                  	MOV	[SaveCDSH],DS
  1018 00000371 E8(0000)                	EnterCrit   critDisk
  1019 00000374 F744430080              	TEST	word [SI + curdir_flags],curdir_isnet	; Clears carry
  1020 00000379 7403                    	JZ	DoSplice
  1021 0000037B E99300                  	JMP	FatFail
  1022                                  DoSplice:
  1023 0000037E 30D2                    	XOR	DL,DL
  1024 00000380 368616[0000]            	XCHG	DL,[ss:NoSetDir]
  1025 00000385 1607                    	Context ES
  1026 00000387 E8(0000)                	Invoke	FStrcpy
  1027 0000038A 8B76FE                  	MOV	SI,[Temp]
  1028 0000038D 161F                    	Context DS
  1029 0000038F E8(0000)                	Invoke	Splice
  1030                                  	ASSUME	DS:NOTHING
  1031 00000392 161F                    	Context DS			;   FatReadCDS (ThisCDS);
  1032 00000394 8816[0000]              	MOV	[NoSetDir],DL
  1033 00000398 C43E[0000]              	LES	DI,[ThisCDS]
  1034 0000039C 55                      	SaveReg <BP>
  1035 0000039D E8(0000)                	Invoke	FatRead_CDS
  1036 000003A0 5D                      	RestoreReg  <BP>
  1037 000003A1 726E                    	JC	FatFail
  1038 000003A3 C536[0000]              	LDS	SI,[ThisCDS]		;   if (ThisCDS->ID == -1) {
  1039                                  	ASSUME	DS:NOTHING
  1040 000003A7 837C49FF                	CMP	word [SI + curdir_ID],-1
  1041 000003AB 7556                    	JNZ	RestoreCDS
  1042 000003AD 1607                    	Context ES
  1043 000003AF 36FF36[0000]            	SaveReg <word [ss:wfp_Start]>	;	t = wfp_Start;
  1044 000003B4 3B76FA                  	CMP	SI,[SaveCDSL]		; if not spliced
  1045 000003B7 750B                    	JNZ	DoChdir
  1046 000003B9 8B7EFE                  	MOV	DI,[Temp]
  1047                                  wfp_Start equ WFP_START	; NASM port label
  1048 000003BC 36893E[0000]            	MOV	[ss:wfp_Start],DI		;	wfp_start = d;
  1049 000003C1 E8(0000)                	Invoke	FStrCpy 		;	strcpy (d, ThisCDS->Text);
  1050                                  DoChdir:
  1051 000003C4 161F                    	Context DS
  1052 000003C6 FF36[0000]55            	SaveReg <<word [SAttrib]>,BP>	;	c = DOSChDir ();
  1053 000003CB E8(0000)                	Invoke	DOS_ChDir
  1054 000003CE 5D5B8F06[0000]          	RestoreReg  <BP,BX,word [wfp_start]>	;	wfp_Start = t;
  1055 000003D4 881E[0000]              	MOV	[SAttrib],BL
  1056 000003D8 C576FA                  	LDS	SI,[SaveCDS]
  1057                                  	ASSUME	DS:NOTHING
  1058 000003DB 730F                    	JNC	SetCluster		;	if (c == -1) {
  1059 000003DD 368936[0000]            	MOV	WORD PTR [ss:ThisCDS],SI	;	    ThisCDS = TmpCDS;
  1060 000003E2 368C1E[0200]            	MOV	WORD PTR [ss:ThisCDS+2],DS
  1061 000003E7 31C9                    	XOR	CX,CX			;	    TmpCDS->text[3] = c = 0;
  1062 000003E9 884C03                  	MOV	[SI+3],CL		;	    }
  1063                                  SetCluster:
  1064 000003EC C74449FFFF              	MOV	word [SI + curdir_ID],-1	;	TmpCDS->ID = -1;
  1065 000003F1 36C536[0000]            	LDS	SI,[ss:ThisCDS]		;	ThisCDS->ID = c;
  1066 000003F6 F744430020              	TEST	word [SI + curdir_flags],curdir_splice      ;AN000;;MS.  for Join and Subst
  1067 000003FB 7403                    	JZ	setdirclus			     ;AN000;;MS.
  1068 000003FD B9FFFF                  	MOV	CX,-1				     ;AN000;;MS.
  1069                                  setdirclus:
  1070 00000400 894C49                  	MOV	[SI + curdir_ID],CX	;	}
  1071                                  RestoreCDS:
  1072 00000403 C47EFA                  	LES	DI,[SaveCDS]
  1073 00000406 36893E[0000]            	MOV	WORD PTR [ss:ThisCDS],DI
  1074 0000040B 368C06[0200]            	MOV	WORD PTR [ss:ThisCDS+2],ES
  1075 00000410 F8                      	CLC
  1076                                  FatFail:
  1077 00000411 E8(0000)                	LeaveCrit   critDisk
  1078 00000414 C47EFA                  	LES	DI,[SaveCDS]
  1079 00000417 89EC5D                  	Leave
  1080 0000041A C3                      	return
  1081                                  EndProc ValidateCDS
  1082                                  
  1083                                  Break	<CheckThisDevice - Check for being a device>
  1084                                  
  1085                                  ;
  1086                                  ;   CheckThisDevice - Examine the area at DS:SI to see if there is a valid
  1087                                  ;   device specified.  We will return carry if there is a device present.  The
  1088                                  ;   forms of devices we will recognize are:
  1089                                  ;
  1090                                  ;	[path]device
  1091                                  ;
  1092                                  ;   Note that the drive letter has *already* been removed.  All other forms
  1093                                  ;   are not considered to be devices.  If such a device is found we change the
  1094                                  ;   source pointer to point to the device component.
  1095                                  ;
  1096                                  ;   Inputs:	ES is DOSGroup
  1097                                  ;		DS:SI contains name
  1098                                  ;   Outputs:	ES is DOSGroup
  1099                                  ;		DS:SI point to name or device
  1100                                  ;		Carry flag set if device was found
  1101                                  ;		Carry flag reset otherwise
  1102                                  ;   Registers Modified: all except ES:DI, DS
  1103                                  
  1104                                  %if FALSE
  1105                                  Procedure   CheckThisDevice,NEAR
  1106                                  	DOSAssume CS,<ES>,"CheckThisDevice"
  1107                                  	ASSUME	DS:NOTHING
  1108                                  	SaveReg <DI,SI>
  1109                                  ;
  1110                                  ; Advance to after the final path character.
  1111                                  ;
  1112                                  	MOV	DI,SI			; remember first character
  1113                                  PathSkip:
  1114                                  	LODSB
  1115                                  	OR	AL,AL
  1116                                  	JZ	FoundEnd
  1117                                   %IF  DBCS			;AN000;
  1118                                  	invoke	Testkanj	;AN000;; 2/13/KK
  1119                                  Notkanje equ NotKanje	; NASM port label
  1120                                  	jz	Notkanje	;AN000;; 2/13/KK
  1121                                  	lodsb			;AN000;; 2/13/KK
  1122                                  	or	al,al		;AN000;; Skip second byte 2/13/KK  removed
  1123                                  	jz	FoundEnd	;AN000;; 2/13/KK		   removed
  1124                                  Pathskip equ PathSkip	; NASM port label
  1125                                  	jmp	Short Pathskip	;AN000;; Ignore missing second byte for now.
  1126                                  NotKanje:			;AN000;
  1127                                    %ENDIF 			;AN000;
  1128                                  ;kanji load of next char too	  2/13/KK
  1129                                  %IF Kanji
  1130                                   kanji load of next char too
  1131                                  %ENDIF
  1132                                  	invoke	PathChrCmp		; is it a path char?
  1133                                  	JNZ	PathSkip
  1134                                  	MOV	DI,SI
  1135                                  	JMP	PathSkip
  1136                                  FoundEnd:
  1137                                  	MOV	SI,DI
  1138                                  ;
  1139                                  ; Parse the name
  1140                                  ;
  1141                                  	SaveReg <DS,SI> 		; preserve the source pointer
  1142                                  	invoke	NameTrans		; advance DS:SI
  1143                                  	CMP	BYTE PTR [SI],0 	; parse entire string?
  1144                                  	STC				; simulate a Carry return from DEVNAME
  1145                                  	JNZ	SkipSearch		; no parse.  simulate a file return.
  1146                                  	Context DS
  1147                                  	Invoke	DEVNAME
  1148                                  	ASSUME	DS:NOTHING
  1149                                  SkipSearch:
  1150                                  	RestoreReg  <SI,DS>
  1151                                  ;
  1152                                  ; DS:SI points to the beginning of the potential device.  If we have a device
  1153                                  ; then we do not change SI.  If we have a file, then we reset SI back to the
  1154                                  ; original value.  At this point Carry set indicates FILE.
  1155                                  ;
  1156                                  	RestoreReg  <DI>		; get original SI
  1157                                  	JNC	CheckDone		; if device then do not reset pointer
  1158                                  	MOV	SI,DI
  1159                                  CheckDone:
  1160                                  	RestoreReg  <DI>
  1161                                  	CMC				; invert carry.  Carry => device
  1162                                  	return
  1163                                  %else
  1164                                  Procedure   CheckThisDevice,NEAR
  1164          ******************       warning: proc CheckThisDevice... [-w+user]
  1165                                  	DOSAssume CS,<ES>,"CheckThisDevice"
  1166                                  	ASSUME	DS:NOTHING
  1167 0000041B 5756                    	SaveReg <DI,SI>
  1168 0000041D 89F7                    	MOV	DI,SI
  1169                                  ;
  1170                                  ; Check for presence of \dev\ (Dam multiplan!)
  1171                                  ;
  1172 0000041F 8A04                    	MOV	AL,[SI]
  1173 00000421 E8(0000)                	Invoke	PathChrCmp		; is it a path char?
  1174 00000424 7517                    	JNZ	ParseDev		; no, go attempt to parse device
  1175 00000426 46                      	INC	SI			; simulate LODSB
  1176                                  ;
  1177                                  ; We have the leading path separator.  Look for DEV part.
  1178                                  ;
  1179 00000427 AD                      	LODSW
  1180 00000428 0D2020                  	OR	AX,2020h
  1181 0000042B 3D6465                  	CMP	AX,("e" << 8) + "d"
  1182 0000042E 7527                    	JNZ	NotDevice		; not "de", assume not device
  1183 00000430 AC                      	LODSB
  1184 00000431 0C20                    	OR	AL,20h
  1185 00000433 3C76                    	CMP	AL,"v"                  ; Not "v", assume not device
  1186 00000435 7520                    	JNZ	NotDevice
  1187 00000437 AC                      	LODSB
  1188 00000438 E8(0000)                	invoke	PathChrCmp		; do we have the last path separator?
  1189 0000043B 751A                    	JNZ	NotDevice		; no. go for it.
  1190                                  ;
  1191                                  ; DS:SI now points to a potential drive.  Preserve them as NameTrans advances
  1192                                  ; SI and DEVNAME may destroy DS.
  1193                                  ;
  1194                                  ParseDev:
  1195 0000043D 1E56                    	SaveReg <DS,SI> 		; preserve the source pointer
  1196 0000043F E8(0000)                	invoke	NameTrans		; advance DS:SI
  1197 00000442 803C00                  	CMP	BYTE PTR [SI],0 	; parse entire string?
  1198 00000445 F9                      	STC				; simulate a Carry return from DEVNAME
  1199 00000446 7505                    	JNZ	SkipSearch		; no parse.  simulate a file return.
  1200 00000448 161F                    	Context DS
  1201 0000044A E882FE                  	Invoke	DEVNAME
  1202                                  	ASSUME	DS:NOTHING
  1203                                  SkipSearch:
  1204 0000044D 5E1F                    	RestoreReg  <SI,DS>
  1205                                  ;
  1206                                  ; SI points to the beginning of the potential device.  If we have a device
  1207                                  ; then we do not change SI.  If we have a file, then we reset SI back to the
  1208                                  ; original value.  At this point Carry set indicates FILE.
  1209                                  ;
  1210                                  CheckReturn:
  1211 0000044F 5F                      	RestoreReg  <DI>		; get original SI
  1212 00000450 7302                    	JNC	CheckDone		; if device then do not reset pointer
  1213 00000452 89FE                    	MOV	SI,DI
  1214                                  CheckDone:
  1215 00000454 5F                      	RestoreReg  <DI>
  1216 00000455 F5                      	CMC				; invert carry.  Carry => device
  1217 00000456 C3                      	return
  1218                                  NotDevice:
  1219 00000457 F9                      	STC
  1220 00000458 EBF5                    	JMP	CheckReturn
  1221                                  %endif
  1222                                  
  1223                                  EndProc CheckThisDevice
  1224                                  
  1225                                  BREAK <LookupPath - call fastopen to get dir entry info>
  1226                                  
  1227                                  ;
  1228                                  ; Output  DS:SI -> path name,
  1229                                  ;	  ES:DI -> dir entry info buffer
  1230                                  ;	  ES:CX -> extended dir info buffer
  1231                                  ;
  1232                                  ;	  carry flag clear : tables pointed by ES:DI and ES:CX are filled by
  1233                                  ;			     FastOpen, DS:SI points to char just one after
  1234                                  ;			     the last char of path name which is fully or
  1235                                  ;			     partially found in FastOPen
  1236                                  ;	  carry flag set : FastOpen not in memory or path name not found
  1237                                  ;
  1238                                  	procedure LookupPath,NEAR
  1238          ******************       warning: proc LookupPath... [-w+user]
  1239                                  	ASSUME	ES:NOTHING
  1240                                  
  1241                                  ;	PUSH	AX
  1242 0000045A 36F606[0000]01          	TEST	byte [ss:FastOpenFlg],FastOpen_Set	    ; flg is set in DOSPEN
  1243 00000460 7503                    	JNZ	FASTINST			    ; and this routine is
  1244                                  NOLOOK:
  1245 00000462 E99000                  	JMP	NOLOOKUP			    ; executed once
  1246                                  FASTINST:
  1247 00000465 36F606[0000]08          	TEST	byte [ss:FastOpenFlg],No_Lookup 	    ; no more lookup?
  1248 0000046B 75F5                    	JNZ	NOLOOK				    ; yes
  1249                                  
  1250 0000046D BB[0000]                	MOV	BX,OFFSET FastOpenTable wrt DOSGROUP    ; get fastopen related tab
  1251 00000470 368B36[0000]            	MOV	SI,[ss:Wfp_Start]			    ; si points to path name
  1252 00000475 BF[0000]                	MOV	DI,OFFSET Dir_Info_Buff wrt DOSGROUP
  1253 00000478 B9[0000]                	MOV	CX,OFFSET FastOpen_Ext_Info wrt DOSGROUP
  1254 0000047B B001                    	MOV	AL,FONC_look_up 		    ; al = 1
  1255 0000047D 16                      	PUSH	ss
  1256 0000047E 07                      	POP	ES
  1257                                   assume es:DOSGROUP
  1258 0000047F FF5F02                  	CALL	far [BX + FASTOPEN_NAME_CACHING] ;call fastopen
  1259 00000482 7260                    	JC	NOTFOUND			    ; fastopen not in memory
  1260                                  
  1261 00000484 8D5CFE                  	LEA	BX,[SI-2]
  1262 00000487 363B1E[0000]            	CMP	BX,[ss:Wfp_Start]			    ; path found ?
  1263 0000048C 7456                    	JZ	NOTFOUND			    ; no
  1264                                  						    ; fully or partially found
  1265 0000048E 803C00                  	CMP	BYTE PTR [SI],0 		    ;AN000;FO.
  1266 00000491 751A                    	JNZ	parfnd				    ;AN000;FO.; partiallyfound
  1267 00000493 51                      	PUSH	CX				    ;AN000;FO.; is attribute matched ?
  1268 00000494 368A0E[0000]            	MOV	CL,[ss:Attrib]			    ;AN000;FO.;
  1269                                  Sattrib equ SAttrib	; NASM port label
  1270 00000499 368A2E[0000]            	MOV	CH,[ss:Sattrib]			    ;AN000;FO.; attrib=sattrib
  1271 0000049E 36882E[0000]            	MOV	[ss:Attrib],CH			    ;AN000;FO.;
  1272 000004A3 268A6D0B                	MOV	CH,[ES:DI + dir_attr]		    ;AN000;FO.;
  1273 000004A7 E818FE                  	invoke	MatchAttributes 		    ;AN000;FO.;
  1274                                  ;;;	MOV	Attrib,CL			    ;AN001;FO.; retore attrib
  1275 000004AA 59                      	POP	CX				    ;AN000;FO.;
  1276 000004AB 7548                    	JNZ	NOLOOKUP			    ;AN000;FO.; not matched
  1277                                  parfnd:
  1278 000004AD 368936[0000]            	MOV	[ss:Next_Element_Start],SI 		   ; save si
  1279 000004B2 89CB                    	MOV	BX,CX
  1280 000004B4 8B4707                  	MOV	AX,[BX + FEI_lastent]		    ;AN000;;FO. restore lastentry
  1281 000004B7 36A3[0000]              	MOV	[ss:LASTENT],AX			    ;AN000;;FO.
  1282 000004BB 8B4709                  	MOV	AX,[BX + FEI_dirstart]		    ;AN001;;FO. restore dirstart
  1283 000004BE 36A3[0000]              	MOV	[ss:DIRSTART],AX			    ;AN001;;FO.
  1284 000004C2 8B4705                  	MOV	AX,[BX + FEI_clusnum]		    ; restore next cluster num
  1285 000004C5 36A3[0000]              	MOV	[ss:CLUSNUM],AX			    ;
  1286                                  
  1287 000004C9 06                      	PUSH	ES				    ; save ES
  1288 000004CA 36C41E[0000]            	LES	BX,[ss:THISDPB]			    ; put drive id
  1289                                   assume es:DPB
  1290 000004CF 268A27                  	MOV	AH,[ES:BX + dpb_drive]		    ; in AH for DOOPEN
  1291 000004D2 07                      	POP	ES				    ; pop ES
  1292                                   assume es:nothing
  1293                                  
  1294 000004D3 368C06[0200]            	MOV	WORD PTR [ss:CURBUF+2],ES		    ; [curbuf+2].bx points to
  1295 000004D8 89FB                    	MOV	BX,DI				    ; start of entry
  1296 000004DA 8D751A                  	LEA	SI,[DI + dir_first]		    ; [curbuf+2]:si points to
  1297                                  						    ; dir_first field in the
  1298                                  						    ; dir entry
  1299                                  set_for_search equ Set_For_Search	; NASM port equate
  1300 000004DD 36800E[0000]12          	OR	byte [ss:FastOpenFlg],Lookup_Success + set_for_search
  1301                                  ;	POP	AX
  1302 000004E3 C3                      	RET
  1303                                  NOTFOUND:
  1304 000004E4 83F8FF                  	CMP	AX,-1				    ; not in memory ?
  1305 000004E7 7506                    	JNZ	Partial_Success 		    ; yes, in memory
  1306 000004E9 36C606[0000]00          	MOV	byte [ss:FastOpenFlg],0 		    ; no more fastopen
  1307                                  Partial_Success:
  1308 000004EF 368026[0000]FB          	AND	byte [ss:FastOpenFlg],Special_Fill_Reset
  1309                                  NOLOOKUP:
  1310                                  ;	POP	AX
  1311 000004F5 F9                      	STC
  1312 000004F6 C3                      	RET
  1313                                  EndProc LookupPath
  1314                                  
  1315                                  BREAK <InsertPath - call fastopen to insert dir entry info>
  1316                                  
  1317                                  ;
  1318                                  ; Input:  FastOpen_Set flag set when from DOSOPEN otherwise 0
  1319                                  ;	  Lookup_Success flag set when got dir entry info from FASTOPEN
  1320                                  ;	  DS = DOSGROUP
  1321                                  ; Output: FastOPen_Ext_Info is set and path dir info is inserted
  1322                                  ;
  1323                                  	procedure InsertPath,NEAR
  1323          ******************       warning: proc InsertPath... [-w+user]
  1324                                  	ASSUME	ES:NOTHING
  1325                                  
  1326 000004F7 9C                      	PUSHF
  1327 000004F8 36F606[0000]01          	TEST   byte [ss:FastOpenFlg],FastOpen_Set     ;only DOSOPEN can take advantage of
  1328 000004FE 747A                    	JZ     GET_NEXT_ELEMENT 	      ; the FastOpen
  1329 00000500 36F606[0000]02          	TEST   byte [ss:FastOpenFlg],Lookup_Success   ; Lookup just happened
  1330 00000506 740E                    	JZ     INSERT_DIR_INFO		      ; no
  1331 00000508 368026[0000]FD          	AND    byte [ss:FastOpenFlg],Lookup_Reset     ; we got dir info from fastopen so
  1332 0000050E 368B3E[0000]            	MOV    DI,[ss:Next_Element_Start]	      ; no need to insert it again
  1333 00000513 EB5F                    	JMP    GET_NEXT2
  1334 00000515 90                      	nop	; identicalise
  1335                                  INSERT_DIR_INFO:			      ; save registers
  1336 00000516 1E                      	PUSH   DS
  1337 00000517 06                      	PUSH   ES
  1338 00000518 53                      	PUSH   BX
  1339 00000519 56                      	PUSH   SI
  1340 0000051A 57                      	PUSH   DI
  1341 0000051B 51                      	PUSH   CX
  1342 0000051C 50                      	PUSH   AX
  1343                                  ;  int 3
  1344 0000051D 36C53E[0000]            	LDS    DI,[ss:CURBUF]		; DS:DI -> buffer header
  1345                                  ASSUME DS:NOTHING
  1346 00000522 BE[0000]                	MOV    SI,OFFSET FastOpen_Ext_Info wrt DOSGROUP
  1347 00000525 8B4508                  	MOV    AX,WORD PTR [DI + buf_sector]  ; get directory sector
  1348 00000528 36894401                	MOV    WORD PTR [ss:SI + FEI_dirsec],AX ;AN000; >32mb save dir sector
  1349 0000052C 8B450A                  	MOV    AX,WORD PTR [DI + buf_sector+2]  ;AN000; >32mb
  1350 0000052F 161F                    	context DS
  1351 00000531 894403                  	MOV    WORD PTR [SI + FEI_dirsec+2],AX  ;AN000;>32mb save high dir sector
  1352 00000534 A1[0000]                	MOV    AX,[CLUSNUM]		; save next cluster number
  1353 00000537 894405                  	MOV    [SI + FEI_clusnum],AX
  1354 0000053A A1[0000]                	MOV    AX,[LASTENT]		;AN000;FO. save lastentry for search first
  1355 0000053D 894407                  	MOV    [SI + FEI_lastent],AX	;AN000;FO.
  1356 00000540 A1[0000]                	MOV    AX,[DIRSTART]		;AN001;FO. save  for search first
  1357 00000543 894409                  	MOV    [SI + FEI_dirstart],AX	;AN001;FO.
  1358                                  
  1359 00000546 89D8                    	MOV    AX,BX
  1360 00000548 83C710                  	ADD    DI,BUFINSIZ		; DS:DI -> start of data in buffer
  1361 0000054B 29F8                    	SUB    AX,DI			; AX=BX relative to start of sector
  1362 0000054D B120                    	MOV    CL,dir_entry_struc_size
  1363                                  ;invoke debug_DOS
  1364 0000054F F6F1                    	DIV    CL
  1365 00000551 8804                    	MOV    [SI + FEI_dirpos],AL	; save directory entry # in buffer
  1366                                  
  1367 00000553 1E                      	PUSH   DS
  1368 00000554 07                      	POP    ES
  1369                                   assume es:DOSGROUP
  1370                                  
  1371 00000555 8E1E[0200]              	MOV    DS,WORD PTR [CURBUF+2]
  1372                                  ASSUME DS:NOTHING
  1373 00000559 89DF                    	MOV    DI,BX			; DS:DI -> dir entry info
  1374 0000055B 837D1A00                	CMP    word [DI + dir_first],0	; never insert info when file is empty
  1375 0000055F 740C                    	JZ     SKIP_INSERT		; e.g. newly created file
  1376                                  
  1377 00000561 56                      	PUSH   SI			; ES:BX -> extended info
  1378 00000562 5B                      	POP    BX
  1379                                  
  1380 00000563 B002                    	MOV    AL,FONC_insert		; call fastopen insert operation
  1381 00000565 BE[0000]                	MOV    SI,OFFSET FastOpenTable wrt DOSGROUP
  1382 00000568 26FF5C02                	CALL   far [ES:SI + FASTOPEN_NAME_CACHING]
  1383                                  
  1384 0000056C F8                      	CLC
  1385                                  SKIP_INSERT:
  1386 0000056D 58                      	POP    AX
  1387 0000056E 59                      	POP    CX			; restore registers
  1388 0000056F 5F                      	POP    DI
  1389 00000570 5E                      	POP    SI
  1390 00000571 5B                      	POP    BX
  1391 00000572 07                      	POP    ES
  1392                                   assume es:nothing
  1393 00000573 1F                      	POP    DS
  1394                                   assume ds:nothing
  1395                                  GET_NEXT2:
  1396 00000574 36800E[0000]08          	OR     byte [ss:FastOpenFlg],No_Lookup	      ; we got dir info from fastopen so
  1397                                  GET_NEXT_ELEMENT:
  1398 0000057A 9D                      	POPF
  1399 0000057B C3                      	RET
  1400                                  EndProc InsertPath
  1401                                  
  1402                                  CODE	ENDS
  1403                                      END
