Windows NT 4.0 source code leak
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.

146 lines
4.0 KiB

4 years ago
  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. fat_rec.h
  5. Abstract:
  6. This module contains the mini-file system recognizer for FAT.
  7. Author:
  8. Darryl E. Havens (darrylh) 8-dec-1992
  9. Environment:
  10. Kernel mode, local to I/O system
  11. Revision History:
  12. --*/
  13. //
  14. // The following types and macros are used to help unpack the packed and
  15. // misaligned fields found in the Bios parameter block
  16. //
  17. typedef union _UCHAR1 {
  18. UCHAR Uchar[1];
  19. UCHAR ForceAlignment;
  20. } UCHAR1, *PUCHAR1;
  21. typedef union _UCHAR2 {
  22. UCHAR Uchar[2];
  23. USHORT ForceAlignment;
  24. } UCHAR2, *PUCHAR2;
  25. typedef union _UCHAR4 {
  26. UCHAR Uchar[4];
  27. ULONG ForceAlignment;
  28. } UCHAR4, *PUCHAR4;
  29. //
  30. // This macro copies an unaligned src byte to an aligned dst byte
  31. //
  32. #define CopyUchar1(Dst,Src) { \
  33. *((UCHAR1 *)(Dst)) = *((UNALIGNED UCHAR1 *)(Src)); \
  34. }
  35. //
  36. // This macro copies an unaligned src word to an aligned dst word
  37. //
  38. #define CopyUchar2(Dst,Src) { \
  39. *((UCHAR2 *)(Dst)) = *((UNALIGNED UCHAR2 *)(Src)); \
  40. }
  41. //
  42. // This macro copies an unaligned src longword to an aligned dsr longword
  43. //
  44. #define CopyUchar4(Dst,Src) { \
  45. *((UCHAR4 *)(Dst)) = *((UNALIGNED UCHAR4 *)(Src)); \
  46. }
  47. //
  48. // Define the Packed and Unpacked BIOS Parameter Block
  49. //
  50. typedef struct _PACKED_BIOS_PARAMETER_BLOCK {
  51. UCHAR BytesPerSector[2]; // offset = 0x000 0
  52. UCHAR SectorsPerCluster[1]; // offset = 0x002 2
  53. UCHAR ReservedSectors[2]; // offset = 0x003 3
  54. UCHAR Fats[1]; // offset = 0x005 5
  55. UCHAR RootEntries[2]; // offset = 0x006 6
  56. UCHAR Sectors[2]; // offset = 0x008 8
  57. UCHAR Media[1]; // offset = 0x00A 10
  58. UCHAR SectorsPerFat[2]; // offset = 0x00B 11
  59. UCHAR SectorsPerTrack[2]; // offset = 0x00D 13
  60. UCHAR Heads[2]; // offset = 0x00F 15
  61. UCHAR HiddenSectors[4]; // offset = 0x011 17
  62. UCHAR LargeSectors[4]; // offset = 0x015 21
  63. } PACKED_BIOS_PARAMETER_BLOCK; // sizeof = 0x019 25
  64. typedef PACKED_BIOS_PARAMETER_BLOCK *PPACKED_BIOS_PARAMETER_BLOCK;
  65. typedef struct BIOS_PARAMETER_BLOCK {
  66. USHORT BytesPerSector;
  67. UCHAR SectorsPerCluster;
  68. USHORT ReservedSectors;
  69. UCHAR Fats;
  70. USHORT RootEntries;
  71. USHORT Sectors;
  72. UCHAR Media;
  73. USHORT SectorsPerFat;
  74. USHORT SectorsPerTrack;
  75. USHORT Heads;
  76. ULONG HiddenSectors;
  77. ULONG LargeSectors;
  78. } BIOS_PARAMETER_BLOCK, *PBIOS_PARAMETER_BLOCK;
  79. //
  80. // Define the boot sector
  81. //
  82. typedef struct _PACKED_BOOT_SECTOR {
  83. UCHAR Jump[3]; // offset = 0x000 0
  84. UCHAR Oem[8]; // offset = 0x003 3
  85. PACKED_BIOS_PARAMETER_BLOCK PackedBpb; // offset = 0x00B 11
  86. UCHAR PhysicalDriveNumber; // offset = 0x024 36
  87. UCHAR Reserved; // offset = 0x025 37
  88. UCHAR Signature; // offset = 0x026 38
  89. UCHAR Id[4]; // offset = 0x027 39
  90. UCHAR VolumeLabel[11]; // offset = 0x02B 43
  91. UCHAR SystemId[8]; // offset = 0x036 54
  92. } PACKED_BOOT_SECTOR; // sizeof = 0x03E 62
  93. typedef PACKED_BOOT_SECTOR *PPACKED_BOOT_SECTOR;
  94. //
  95. // Define the functions provided by this driver.
  96. //
  97. BOOLEAN
  98. IsFatVolume(
  99. IN PPACKED_BOOT_SECTOR Buffer
  100. );
  101. BOOLEAN
  102. FatReadBlock(
  103. IN PDEVICE_OBJECT DeviceObject,
  104. IN PLARGE_INTEGER ByteOffset,
  105. IN ULONG MinimumBytes,
  106. OUT PNTSTATUS ExtendedStatus,
  107. OUT PPACKED_BOOT_SECTOR *Buffer
  108. );
  109. VOID
  110. UnpackBiosParameterBlock(
  111. IN PPACKED_BIOS_PARAMETER_BLOCK Bios,
  112. OUT PBIOS_PARAMETER_BLOCK UnpackedBios
  113. );