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.

306 lines
8.8 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. dncompv.c
  5. Abstract:
  6. Code for determining whether volumes are compressed (DoubleSpace,
  7. Stacker, etc).
  8. Author:
  9. Ted Miller (tedm) 1-April-1993
  10. Revision History:
  11. --*/
  12. #include "winnt.h"
  13. #include "dncompvp.h"
  14. /****************************************************************************
  15. *
  16. * WORD IsStackerLoaded (uchar *pchSwappedDrives)
  17. *
  18. * Returns NZ if Stacker driver loaded.
  19. *
  20. * Parameters:
  21. * pchSwappedDrives - array[26] to return swapped drives in.
  22. * To find out if a drive is swapped, look at pchSwappedDrives[Drive].
  23. * If pchSwappedDrives[Drive] == Drive, drive isn't swapped.
  24. * Otherwise, pchSwappedDrives[Drive] = drive it's swapped with.
  25. *
  26. * Return Value:
  27. * 0 if not loaded, else version# * 100.
  28. ****************************************************************************/
  29. //uint IsStackerLoaded (uchar *paucSwappedDrives)
  30. unsigned IsStackerLoaded (unsigned char *paucSwappedDrives)
  31. {
  32. unsigned rc;
  33. _asm {
  34. sub sp, 1024
  35. mov ax, 0cdcdh
  36. mov bx, sp
  37. mov cx, 1
  38. xor dx, dx
  39. mov word ptr [bx], dx
  40. push ds
  41. pop es
  42. push bp
  43. mov bp, bx
  44. int 25h
  45. pop cx ; Int25h leaves flags on stack. Nuke them.
  46. pop bp
  47. xor ax, ax
  48. mov bx, sp
  49. cmp word ptr [bx], 0CDCDh
  50. jnz sl_exit
  51. cmp word ptr 2[bx], 1
  52. jnz sl_exit
  53. les di, 4[bx]
  54. cmp word ptr es:[di], 0A55Ah
  55. jnz sl_exit
  56. ; mov word ptr st_ptr, di
  57. ; mov word ptr st_ptr+2, es
  58. mov ax, es:[di+2]
  59. cmp ax, 200d
  60. jb sl_exit
  61. ;
  62. ; Sanity Check, make sure 'SWAP' is at es:di+52h
  63. ;
  64. ; cmp word ptr es:[di+52h],'WS'
  65. cmp word ptr es:[di+52h], 05753h
  66. jnz sl_exit ; AX contains version.
  67. ; cmp word ptr es:[di+54h],'PA'
  68. cmp word ptr es:[di+54h], 05041h
  69. jnz sl_exit ; AX contains version.
  70. ;
  71. ; Copy swapped drive array.
  72. push ds ; Save DS
  73. ;
  74. ; Source is _StackerPointer + 56h.
  75. ;
  76. push es
  77. pop ds
  78. mov ax, di
  79. add ax, 56h
  80. mov si, ax
  81. push es
  82. push di
  83. ;
  84. ; Destination is ss:paucSwappedDrives
  85. ;
  86. les di, paucSwappedDrives
  87. ;mov di, paucSwappedDrives ; SwappedDrives array is stack relative.
  88. ;push ss
  89. ;pop es
  90. mov cx, 26d ; Copy 26 bytes.
  91. cld
  92. rep movsb ; Copy array.
  93. pop di ; Restore _StackerPointer.
  94. pop es
  95. pop ds ; Restore DS
  96. mov ax, es:[di+2] ; Get version number of stacker, again.
  97. sl_exit:
  98. mov word ptr [rc],ax ; do this to prevent compiler warning
  99. add sp, 1024
  100. }
  101. return(rc); // do this to prevent compiler warning
  102. }
  103. /*** DRVINFO.C - IsDoubleSpaceDrive function
  104. *
  105. #ifdef EXTERNAL
  106. * Version 1.00.03 - 5 January 1993
  107. #else
  108. * Microsoft Confidential
  109. * Copyright (C) Microsoft Corporation 1992-1993
  110. * All Rights Reserved.
  111. *
  112. * History:
  113. * 27-Sep-1992 bens Initial version
  114. * 06-Nov-1992 bens Improved comments
  115. * 05-Jan-1993 bens Update for external release
  116. #endif
  117. */
  118. /*** IsDoubleSpaceDrive - Get information on a DoubleSpace drive
  119. *
  120. * Entry:
  121. * drive - Drive to test (0=A, 1=B, etc.)
  122. * NOTE: No parameter checking is done on drive.
  123. * pdrHost - Receives drive number of host drive
  124. * pfSwapped - Receives TRUE/FALSE indicating if drive is swapped.
  125. * pseq - Receives CVFs sequence number if DoubleSpace drive
  126. *
  127. * Exit:
  128. * returns TRUE, if DoubleSpace drive:
  129. * *pdrHost = current drive number of host drive (0=A,...)
  130. * *pfSwapped = TRUE, if drive is swapped with host,
  131. * FALSE, if drive is not swapped with host
  132. * *pseq = CVF sequence number (always zero if swapped
  133. * with host drive)
  134. *
  135. * NOTE: The full file name of the CVF is:
  136. * *pdrHost:\DBLSPACE.*pseq
  137. *
  138. * pdrHost pseq Full Path
  139. * ------- ---- -----------
  140. * 0 1 a:\dblspace.001
  141. * 3 0 d:\dblspace.000
  142. *
  143. * returns FALSE, if *not* DoubleSpace drive:
  144. * *pdrHost = drive number of host drive at boot time
  145. * *pfSwapped = TRUE, if swapped with a DoubleSpace drive
  146. * FALSE, if not swapped with a DoubleSpace drive
  147. */
  148. BOOL IsDoubleSpaceDrive(BYTE drive, BOOL *pfSwapped, BYTE *pdrHost, int *pseq)
  149. {
  150. BYTE seq;
  151. BYTE drHost;
  152. BOOL fSwapped;
  153. BOOL fDoubleSpace;
  154. // Assume drive is a normal, non-host drive
  155. drHost = drive;
  156. fSwapped = FALSE;
  157. fDoubleSpace = FALSE;
  158. seq = 0;
  159. _asm
  160. {
  161. mov ax,4A11h ; DBLSPACE.BIN INT 2F number
  162. mov bx,1 ; bx = GetDriveMap function
  163. mov dl,drive ;
  164. int 2Fh ; (bl AND 80h) == DS drive flag
  165. ; (bl AND 7Fh) == host drive
  166. or ax,ax ; Success?
  167. jnz gdiExit ; NO, DoubleSpace not installed
  168. test bl,80h ; Is the drive compressed?
  169. jz gdiHost ; NO, could be host drive
  170. ; We have a DoubleSpace Drive, need to figure out host drive.
  171. ;
  172. ; This is tricky because of the manner in which DBLSPACE.BIN
  173. ; keeps track of drives.
  174. ;
  175. ; For a swapped CVF, the current drive number of the host
  176. ; drive is returned by the first GetDriveMap call. But for
  177. ; an unswapped CVF, we must make a second GetDriveMap call
  178. ; on the "host" drive returned by the first call. But, to
  179. ; distinguish between swapped and unswapped CVFs, we must
  180. ; make both of these calls. So, we make them, and then check
  181. ; the results.
  182. mov fDoubleSpace,1 ; Drive is DS drive
  183. mov seq,bh ; Save sequence number
  184. and bl,7Fh ; bl = "host" drive number
  185. mov drHost,bl ; Save 1st host drive
  186. mov dl,bl ; Set up for query of "host" drive
  187. mov ax,4A11h ; DBLSPACE.BIN INT 2F number
  188. mov bx,1 ; bx = GetDriveMap function
  189. int 2Fh ; (bl AND 7Fh) == 2nd host drive
  190. and bl,7Fh ; bl = 2nd host drive
  191. cmp bl,drive ; Is host of host of drive itself?
  192. mov fSwapped,1 ; Assume CVF is swapped
  193. je gdiExit ; YES, CVF is swapped
  194. mov fSwapped,0 ; NO, CVF is not swapped
  195. mov drHost,bl ; True host is 2nd host drive
  196. jmp short gdiExit
  197. gdiHost:
  198. and bl,7Fh ; bl = host drive number
  199. cmp bl,dl ; Is drive swapped?
  200. je gdiExit ; NO
  201. mov fSwapped,1 ; YES
  202. mov drHost,bl ; Set boot drive number
  203. gdiExit:
  204. }
  205. *pdrHost = drHost;
  206. *pfSwapped = fSwapped;
  207. *pseq = seq;
  208. return fDoubleSpace;
  209. }
  210. ///////////////////////////////////////////////////////////////////////////////
  211. BOOLEAN
  212. DnIsDriveCompressedVolume(
  213. IN unsigned Drive,
  214. OUT unsigned *HostDrive
  215. )
  216. /*++
  217. Routine Description:
  218. Determine whether a drive is actually a compressed volume.
  219. Currently we detect Stacker and DoubleSpace volumes.
  220. Arguments:
  221. Drive - drive (1=A, 2=B, etc).
  222. Return Value:
  223. TRUE if drive is non-host compressed volume.
  224. FALSE if not.
  225. --*/
  226. {
  227. static BOOLEAN StackerMapBuilt = FALSE;
  228. static unsigned StackerLoaded = 0;
  229. static unsigned char StackerSwappedDrives[26];
  230. BOOL Swapped;
  231. BYTE Host;
  232. int Seq;
  233. Drive--;
  234. if(!StackerMapBuilt) {
  235. StackerLoaded = IsStackerLoaded(StackerSwappedDrives);
  236. StackerMapBuilt = TRUE;
  237. }
  238. if(StackerLoaded && (StackerSwappedDrives[Drive] != (UCHAR)Drive)) {
  239. *HostDrive = StackerSwappedDrives[Drive];
  240. return(TRUE);
  241. }
  242. if(IsDoubleSpaceDrive((BYTE)(Drive),&Swapped,&Host,&Seq)) {
  243. *HostDrive = Host+1;
  244. return(TRUE);
  245. }
  246. return(FALSE);
  247. }