Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

228 lines
5.2 KiB

  1. ;/*
  2. ; * Microsoft Confidential
  3. ; * Copyright (C) Microsoft Corporation 1991
  4. ; * All Rights Reserved.
  5. ; */
  6. ;================= DOS.ASM =========================
  7. COMMENT #
  8. johnhe - 05/09/90
  9. END COMMENT #
  10. ;========================================================
  11. INVALID_DRIVE EQU 15
  12. DOS_PUTCHAR EQU 02
  13. DOSSEG
  14. .Model SMALL,C
  15. .Data
  16. CrLf db 0dh, 0ah, 0
  17. .Code
  18. ; =========================================================================
  19. ; Verifies that a drive exists using the IsChangeable IOCtl function.
  20. ;
  21. ; int IsValidDrive( char DrvLetter )
  22. ;
  23. ; ARGUMENTS: DrvLetter - The drive letter to verify
  24. ; RETURNS: int - FALSE if not a valid drive letter
  25. ; else !FALSE
  26. ;
  27. ; =========================================================================
  28. IsValidDrive PROC Drive:WORD
  29. mov BX,Drive ; BX = Drive number
  30. cmp BX,26 ; Make not greater than drive Z
  31. jg NotValid
  32. mov AX,4408h ; AX = IOCtl Is changeable function
  33. int 21h
  34. jnc IsValid ; Drv valid
  35. ; Else check error code to see if
  36. cmp AX,INVALID_DRIVE ; invalid drive error
  37. jne IsValid ; Drive is valid
  38. NotValid:
  39. xor AX,AX ; Return FALSE
  40. jmp SHORT DrvChkRet ; Done
  41. IsValid:
  42. mov AX,1 ; Return TRUE
  43. DrvChkRet:
  44. ret ; Return AX = TRUE or FALSE
  45. IsValidDrive ENDP
  46. ; =========================================================================
  47. ; Displays a zero terminated ascii string on the console followed by
  48. ; a carriage return line feed conbination.
  49. ;
  50. ; void PutStr( char *String )
  51. ;
  52. ; ARGUMENTS: String - Ptr to string to be displayed
  53. ; RETURNS: void
  54. ;
  55. ; =========================================================================
  56. PutStr PROC USES SI, String:PTR
  57. mov SI,String ; DS:SI -> to caller's string
  58. mov CX,2 ; 2 loops
  59. PrintLoop:
  60. cld ; Always clear direction flag
  61. lodsb ; Load char in AL & inc SI
  62. or AL,AL ; Test for EOL character
  63. jz EndOfStr
  64. mov AH,DOS_PUTCHAR ; AH = DOS put char function
  65. mov DL,AL ; Put character to print in DL
  66. int 21h ; Output the character
  67. jmp SHORT PrintLoop ; Go back and do the next one
  68. EndOfStr:
  69. mov SI,OFFSET CrLf ; DS:SI -> CR/LF return string
  70. loop PrintLoop ; Go back and print CR/LF
  71. ret
  72. PutStr ENDP
  73. ; =========================================================================
  74. ;
  75. ; Seeks to the specified offset in an open disk
  76. ; disk file.
  77. ;
  78. ; long _dos_seek( int Handle, long lOffset, int Mode )
  79. ;
  80. ; ARGUMENTS: Handle - Open DOS file handle
  81. ; lOffset - Offset to seek to in bytes
  82. ; Mode - Seek mode as described below
  83. ; 0 = Beginning of file + offset
  84. ; 1 = Current file position + offset
  85. ; 2 = End of file + offset
  86. ; RETURNS: long - New offset in file is success
  87. ; or -1L if error
  88. ; =========================================================================
  89. _dos_seek PROC USES ES, Handle:WORD, lOffset:DWORD, Mode:BYTE
  90. mov AH,42h ; AH = DOS file SEEK function
  91. mov AL,Mode ; AL = SEEK mode specified by caller
  92. mov BX,Handle ; BX = Open file handle from caller
  93. LoadOffset:
  94. les DX,lOffset ; Load file offset into ES:DX
  95. mov CX,ES ; CX:DX = Offset to seek to in the file
  96. Int21Call:
  97. int 21h ; DOS call
  98. jc SeekError ; Error check
  99. jmp SHORT SeekReturn ;Everything is OK
  100. SeekError:
  101. mov AX,-1 ; Error code
  102. cwd ; Extend sign to make a LONG (dword)
  103. SeekReturn:
  104. ret
  105. _dos_seek ENDP
  106. ; =======================================================
  107. ; M001 ; Start of changes to check for SETVER.EXE in the
  108. ; device chain.
  109. ; =======================================================
  110. .DATA
  111. SetVerStr db 'SETVERXX'
  112. LEN_SETVERSTR EQU $-SetVerStr
  113. .Code
  114. ; =======================================================
  115. ;
  116. ; Checks to see if SETVER.EXE was installed as as a device
  117. ; driver by walking the device chain looking for the name
  118. ; "SETVERXX".
  119. ;
  120. ; int SetVerCheck ( void )
  121. ;
  122. ; ARGUMENTS: NONE
  123. ; RETURNS: int - TRUE if SetVer device driver is installed else FALSE
  124. ;
  125. ; =======================================================
  126. SetVerCheck PROC USES SI DI DS ES
  127. ASSUME ES:NOTHING
  128. mov AH,52h
  129. int 21h ; ES:BX --> first DBP
  130. push BX ; Save offset
  131. mov AH,30h
  132. int 21h ; AL == Major version
  133. pop DI ; Restore DPB offset to BX
  134. add DI,17h ; DOS 2.x offset of NULL device is 17h
  135. cmp AL,2 ; See if version is really 2.x
  136. jle @f
  137. add DI,0bh ; Offset for DOS > 2.x is 22h
  138. @@:
  139. mov AX,@DATA
  140. mov DS,AX
  141. mov SI,OFFSET SetVerStr
  142. mov CX,LEN_SETVERSTR
  143. cld
  144. NameCmpLoop:
  145. cmp DI,0ffffh ; See if ES:DX is xxxx:ffff
  146. je NoSetVer
  147. SaveSetup:
  148. push CX ; Save name length
  149. push DI ; Save ptr to current device
  150. push SI ; Save ptr to SetVer string
  151. add DI,0ah ; ES:DI --> Device name + 1
  152. repe cmpsb
  153. pop SI
  154. pop DI
  155. pop CX
  156. je FoundSetVer
  157. les DI,ES:[DI] ; Load ptr to next device.
  158. jmp SHORT NameCmpLoop
  159. NoSetVer:
  160. xor AX,AX
  161. jmp SHORT SetVerReturn
  162. FoundSetVer:
  163. mov AX,1
  164. SetVerReturn:
  165. ret
  166. SetVerCheck ENDP
  167. ; =======================================================
  168. ; M001 ; End of changes
  169. ; =======================================================
  170. END