ReactOS  0.4.15-dev-492-ga1108f6
hal.h File Reference

Go to the source code of this file.

Classes

struct  _PARTITION_DESCRIPTOR
 
struct  _BOOT_SECTOR_INFO
 
struct  _PARTITION_TABLE
 
struct  _DISK_LAYOUT
 
struct  _PTE
 

Macros

#define PARTITION_TABLE_OFFSET   (0x1BE / 2)
 
#define BOOT_SIGNATURE_OFFSET   ((0x200 / 2) - 1)
 
#define BOOT_RECORD_RESERVED   0x1BC
 
#define BOOT_RECORD_SIGNATURE   0xAA55
 
#define NUM_PARTITION_TABLE_ENTRIES   4
 
#define GET_STARTING_SECTOR(p)
 
#define GET_ENDING_S_OF_CHS(p)   ((UCHAR)(p->EndingCylinderLsb & 0x3F))
 
#define GET_PARTITION_LENGTH(p)
 
#define SET_PARTITION_LENGTH(p, l)
 

Typedefs

typedef struct _PARTITION_DESCRIPTOR PARTITION_DESCRIPTOR
 
typedef struct _PARTITION_DESCRIPTORPPARTITION_DESCRIPTOR
 
typedef struct _BOOT_SECTOR_INFO BOOT_SECTOR_INFO
 
typedef struct _BOOT_SECTOR_INFOPBOOT_SECTOR_INFO
 
typedef struct _PARTITION_TABLE PARTITION_TABLE
 
typedef struct _PARTITION_TABLEPPARTITION_TABLE
 
typedef struct _DISK_LAYOUT DISK_LAYOUT
 
typedef struct _DISK_LAYOUTPDISK_LAYOUT
 
typedef struct _PTE PTE
 
typedef struct _PTEPPTE
 

Functions

VOID FASTCALL xHalExamineMBR (IN PDEVICE_OBJECT DeviceObject, IN ULONG SectorSize, IN ULONG MbrTypeIdentifier, OUT PVOID *MbrBuffer)
 
VOID FASTCALL xHalIoAssignDriveLetters (IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN PSTRING NtDeviceName, OUT PUCHAR NtSystemPath, OUT PSTRING NtSystemPathString)
 
NTSTATUS FASTCALL xHalIoReadPartitionTable (IN PDEVICE_OBJECT DeviceObject, IN ULONG SectorSize, IN BOOLEAN ReturnRecognizedPartitions, IN OUT PDRIVE_LAYOUT_INFORMATION *PartitionBuffer)
 
NTSTATUS FASTCALL xHalIoSetPartitionInformation (IN PDEVICE_OBJECT DeviceObject, IN ULONG SectorSize, IN ULONG PartitionNumber, IN ULONG PartitionType)
 
NTSTATUS FASTCALL xHalIoWritePartitionTable (IN PDEVICE_OBJECT DeviceObject, IN ULONG SectorSize, IN ULONG SectorsPerTrack, IN ULONG NumberOfHeads, IN PDRIVE_LAYOUT_INFORMATION PartitionBuffer)
 
VOID NTAPI xHalHaltSystem (VOID)
 
VOID NTAPI xHalEndOfBoot (VOID)
 
VOID NTAPI xHalSetWakeEnable (IN BOOLEAN Enable)
 
UCHAR NTAPI xHalVectorToIDTEntry (IN ULONG Vector)
 
NTSTATUS NTAPI xHalGetInterruptTranslator (IN INTERFACE_TYPE ParentInterfaceType, IN ULONG ParentBusNumber, IN INTERFACE_TYPE BridgeInterfaceType, IN USHORT Size, IN USHORT Version, OUT PTRANSLATOR_INTERFACE Translator, OUT PULONG BridgeBusNumber)
 
PBUS_HANDLER FASTCALL xHalHandlerForBus (IN INTERFACE_TYPE InterfaceType, IN ULONG BusNumber)
 
VOID FASTCALL xHalReferenceHandler (IN PBUS_HANDLER BusHandler)
 
NTSTATUS NTAPI xHalInitPnpDriver (VOID)
 
NTSTATUS NTAPI xHalInitPowerManagement (IN PPM_DISPATCH_TABLE PmDriverDispatchTable, OUT PPM_DISPATCH_TABLE *PmHalDispatchTable)
 
NTSTATUS NTAPI xHalStartMirroring (VOID)
 
NTSTATUS NTAPI xHalEndMirroring (IN ULONG PassNumber)
 
NTSTATUS NTAPI xHalMirrorPhysicalMemory (IN PHYSICAL_ADDRESS PhysicalAddress, IN LARGE_INTEGER NumberOfBytes)
 
NTSTATUS NTAPI xHalQueryBusSlots (IN PBUS_HANDLER BusHandler, IN ULONG BufferSize, OUT PULONG SlotNumbers, OUT PULONG ReturnedLength)
 
NTSTATUS NTAPI xHalSetSystemInformation (IN HAL_SET_INFORMATION_CLASS InformationClass, IN ULONG BufferSize, IN PVOID Buffer)
 
NTSTATUS NTAPI xHalQuerySystemInformation (IN HAL_QUERY_INFORMATION_CLASS InformationClass, IN ULONG BufferSize, IN OUT PVOID Buffer, OUT PULONG ReturnedLength)
 
VOID NTAPI xHalLocateHiberRanges (IN PVOID MemoryMap)
 
NTSTATUS NTAPI xHalRegisterBusHandler (IN INTERFACE_TYPE InterfaceType, IN BUS_DATA_TYPE ConfigSpace, IN ULONG BusNumber, IN INTERFACE_TYPE ParentInterfaceType, IN ULONG ParentBusNumber, IN ULONG ContextSize, IN PINSTALL_BUS_HANDLER InstallCallback, OUT PBUS_HANDLER *BusHandler)
 
VOID NTAPI xHalSetWakeAlarm (IN ULONGLONG AlartTime, IN PTIME_FIELDS TimeFields)
 
BOOLEAN NTAPI xHalTranslateBusAddress (IN INTERFACE_TYPE InterfaceType, IN ULONG BusNumber, IN PHYSICAL_ADDRESS BusAddress, IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress)
 
NTSTATUS NTAPI xHalAllocateMapRegisters (IN PADAPTER_OBJECT AdapterObject, IN ULONG Unknown, IN ULONG Unknown2, PMAP_REGISTER_ENTRY Registers)
 
NTSTATUS NTAPI xKdSetupPciDeviceForDebugging (IN PVOID LoaderBlock OPTIONAL, IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice)
 
NTSTATUS NTAPI xKdReleasePciDeviceForDebugging (IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice)
 
PVOID NTAPI xKdGetAcpiTablePhase (IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock, IN ULONG Signature)
 
PVOID NTAPI MatchAll (IN PHYSICAL_ADDRESS PhysicalAddress, IN ULONG NumberPages, IN BOOLEAN FlushCurrentTLB)
 
VOID NTAPI xKdUnmapVirtualAddress (IN PVOID VirtualAddress, IN ULONG NumberPages, IN BOOLEAN FlushCurrentTLB)
 

Macro Definition Documentation

◆ BOOT_RECORD_RESERVED

#define BOOT_RECORD_RESERVED   0x1BC

Definition at line 245 of file hal.h.

◆ BOOT_RECORD_SIGNATURE

#define BOOT_RECORD_SIGNATURE   0xAA55

Definition at line 246 of file hal.h.

◆ BOOT_SIGNATURE_OFFSET

#define BOOT_SIGNATURE_OFFSET   ((0x200 / 2) - 1)

Definition at line 244 of file hal.h.

◆ GET_ENDING_S_OF_CHS

#define GET_ENDING_S_OF_CHS (   p)    ((UCHAR)(p->EndingCylinderLsb & 0x3F))

Definition at line 258 of file hal.h.

◆ GET_PARTITION_LENGTH

#define GET_PARTITION_LENGTH (   p)
Value:
((ULONG)(p->PartitionLengthLsb0) + \
(ULONG)(p->PartitionLengthLsb1 << 8) + \
(ULONG)(p->PartitionLengthMsb0 << 16) + \
(ULONG)(p->PartitionLengthMsb1 << 24))
unsigned int ULONG
Definition: retypes.h:1
GLfloat GLfloat p
Definition: glext.h:8902

Definition at line 261 of file hal.h.

◆ GET_STARTING_SECTOR

#define GET_STARTING_SECTOR (   p)
Value:
((ULONG)(p->StartingSectorLsb0) + \
(ULONG)(p->StartingSectorLsb1 << 8 ) + \
(ULONG)(p->StartingSectorMsb0 << 16) + \
(ULONG)(p->StartingSectorMsb1 << 24))
unsigned int ULONG
Definition: retypes.h:1
GLfloat GLfloat p
Definition: glext.h:8902

Definition at line 252 of file hal.h.

◆ NUM_PARTITION_TABLE_ENTRIES

#define NUM_PARTITION_TABLE_ENTRIES   4

Definition at line 247 of file hal.h.

◆ PARTITION_TABLE_OFFSET

#define PARTITION_TABLE_OFFSET   (0x1BE / 2)

Definition at line 243 of file hal.h.

◆ SET_PARTITION_LENGTH

#define SET_PARTITION_LENGTH (   p,
  l 
)
Value:
p->PartitionLengthLsb0 = l & 0xFF; \
p->PartitionLengthLsb1 = (l >> 8) & 0xFF; \
p->PartitionLengthMsb0 = (l >> 16) & 0xFF; \
p->PartitionLengthMsb1 = (l >> 24) & 0xFF
r l[0]
Definition: byte_order.h:167
GLfloat GLfloat p
Definition: glext.h:8902

Definition at line 267 of file hal.h.

Typedef Documentation

◆ BOOT_SECTOR_INFO

◆ DISK_LAYOUT

◆ PARTITION_DESCRIPTOR

◆ PARTITION_TABLE

◆ PBOOT_SECTOR_INFO

◆ PDISK_LAYOUT

◆ PPARTITION_DESCRIPTOR

◆ PPARTITION_TABLE

◆ PPTE

typedef struct _PTE * PPTE

◆ PTE

typedef struct _PTE PTE

Function Documentation

◆ MatchAll()

PVOID NTAPI MatchAll ( IN PHYSICAL_ADDRESS  PhysicalAddress,
IN ULONG  NumberPages,
IN BOOLEAN  FlushCurrentTLB 
)

Definition at line 277 of file halstub.c.

280 {
281  return NULL;
282 }
smooth NULL
Definition: ftsmooth.c:416

◆ xHalAllocateMapRegisters()

NTSTATUS NTAPI xHalAllocateMapRegisters ( IN PADAPTER_OBJECT  AdapterObject,
IN ULONG  Unknown,
IN ULONG  Unknown2,
PMAP_REGISTER_ENTRY  Registers 
)

Definition at line 242 of file halstub.c.

246 {
247  PAGED_CODE();
248 
249  return STATUS_NOT_IMPLEMENTED;
250 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
#define PAGED_CODE()

◆ xHalEndMirroring()

NTSTATUS NTAPI xHalEndMirroring ( IN ULONG  PassNumber)

Definition at line 146 of file halstub.c.

147 {
148  return STATUS_NOT_SUPPORTED;
149 }
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409

◆ xHalEndOfBoot()

VOID NTAPI xHalEndOfBoot ( VOID  )

Definition at line 88 of file halstub.c.

89 {
90  PAGED_CODE();
91 
92  /* Nothing */
93  return;
94 }
#define PAGED_CODE()

◆ xHalExamineMBR()

VOID FASTCALL xHalExamineMBR ( IN PDEVICE_OBJECT  DeviceObject,
IN ULONG  SectorSize,
IN ULONG  MbrTypeIdentifier,
OUT PVOID MbrBuffer 
)

Definition at line 1642 of file disksup.c.

1646 {
1648  PUCHAR Buffer;
1649  ULONG BufferSize;
1650  KEVENT Event;
1652  PIRP Irp;
1653  PPARTITION_DESCRIPTOR PartitionDescriptor;
1654  NTSTATUS Status;
1655  PIO_STACK_LOCATION IoStackLocation;
1656  Offset.QuadPart = 0;
1657 
1658  /* Assume failure */
1659  *MbrBuffer = NULL;
1660 
1661  /* Normalize the buffer size */
1662  BufferSize = max(SectorSize, 512);
1663 
1664  /* Allocate the buffer */
1666  PAGE_SIZE > BufferSize ?
1668  TAG_FILE_SYSTEM);
1669  if (!Buffer) return;
1670 
1671  /* Initialize the Event */
1673 
1674  /* Build the IRP */
1676  DeviceObject,
1677  Buffer,
1678  BufferSize,
1679  &Offset,
1680  &Event,
1681  &IoStatusBlock);
1682  if (!Irp)
1683  {
1684  /* Failed */
1686  return;
1687  }
1688 
1689  /* Make sure to override volume verification */
1690  IoStackLocation = IoGetNextIrpStackLocation(Irp);
1691  IoStackLocation->Flags |= SL_OVERRIDE_VERIFY_VOLUME;
1692 
1693  /* Call the driver */
1695  if (Status == STATUS_PENDING)
1696  {
1697  /* Wait for completion */
1700  }
1701 
1702  /* Check driver Status */
1703  if (NT_SUCCESS(Status))
1704  {
1705  /* Validate the MBR Signature */
1707  {
1708  /* Failed */
1710  return;
1711  }
1712 
1713  /* Get the partition entry */
1714  PartitionDescriptor = (PPARTITION_DESCRIPTOR)
1716 
1717  /* Make sure it's what the caller wanted */
1718  if (PartitionDescriptor->PartitionType != MbrTypeIdentifier)
1719  {
1720  /* It's not, free our buffer */
1722  }
1723  else
1724  {
1725  /* Check if this is a secondary entry */
1726  if (PartitionDescriptor->PartitionType == 0x54)
1727  {
1728  /* Return our buffer, but at sector 63 */
1729  *(PULONG)Buffer = 63;
1730  *MbrBuffer = Buffer;
1731  }
1732  else if (PartitionDescriptor->PartitionType == 0x55)
1733  {
1734  /* EZ Drive, return the buffer directly */
1735  *MbrBuffer = Buffer;
1736  }
1737  else
1738  {
1739  /* Otherwise crash on debug builds */
1740  ASSERT(PartitionDescriptor->PartitionType == 0x55);
1741  }
1742  }
1743  }
1744 }
#define TAG_FILE_SYSTEM
Definition: tag.h:50
#define max(a, b)
Definition: svc.c:63
PIRP NTAPI IoBuildSynchronousFsdRequest(IN ULONG MajorFunction, IN PDEVICE_OBJECT DeviceObject, IN PVOID Buffer, IN ULONG Length, IN PLARGE_INTEGER StartingOffset, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:1069
_In_ PIRP Irp
Definition: csq.h:116
unsigned char * PUCHAR
Definition: retypes.h:3
LONG NTSTATUS
Definition: precomp.h:26
#define PARTITION_TABLE_OFFSET
Definition: hal.h:243
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:437
smooth NULL
Definition: ftsmooth.c:416
#define SL_OVERRIDE_VERIFY_VOLUME
Definition: iotypes.h:1782
Definition: bufpool.h:45
#define BOOT_RECORD_SIGNATURE
Definition: parttest.c:17
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
UCHAR PartitionType
Definition: hal.h:282
struct _PARTITION_DESCRIPTOR * PPARTITION_DESCRIPTOR
#define BufferSize
Definition: classpnp.h:419
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define BOOT_SIGNATURE_OFFSET
Definition: hal.h:244
#define PAGE_SIZE
Definition: env_spec_w32.h:49
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2647
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1569
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
unsigned int * PULONG
Definition: retypes.h:1
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define IRP_MJ_READ
Definition: rdpdr.c:46
unsigned int ULONG
Definition: retypes.h:1
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
_In_ ULONG SectorSize
Definition: halfuncs.h:291
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
unsigned short * PUSHORT
Definition: retypes.h:2

◆ xHalGetInterruptTranslator()

NTSTATUS NTAPI xHalGetInterruptTranslator ( IN INTERFACE_TYPE  ParentInterfaceType,
IN ULONG  ParentBusNumber,
IN INTERFACE_TYPE  BridgeInterfaceType,
IN USHORT  Size,
IN USHORT  Version,
OUT PTRANSLATOR_INTERFACE  Translator,
OUT PULONG  BridgeBusNumber 
)

Definition at line 156 of file translate.c.

163 {
164  PAGED_CODE();
165 
167  ASSERT(Size >= sizeof(TRANSLATOR_INTERFACE));
168 
169  /* Only (E)ISA interfaces are supported */
170  if (BridgeInterfaceType == Internal || BridgeInterfaceType >= MicroChannel)
171  {
172  return STATUS_NOT_IMPLEMENTED;
173  }
174 
175  /* Fill in output struct */
176  Translator->Size = sizeof(TRANSLATOR_INTERFACE);
177  Translator->Version = HAL_IRQ_TRANSLATOR_VERSION;
178  /* In case caller set interface to undefined, faulty it to ISA */
179  Translator->Context = UlongToPtr((BridgeInterfaceType == InterfaceTypeUndefined) ? Isa : BridgeInterfaceType);
180  Translator->InterfaceReference = FstubTranslatorNull;
181  Translator->InterfaceDereference = FstubTranslatorNull;
182  Translator->TranslateResources = FstubTranslateResource;
183  Translator->TranslateResourceRequirements = FstubTranslateRequirement;
184 
185  return STATUS_SUCCESS;
186 }
IN PVOID IN PVOID IN USHORT Version
Definition: pci.h:361
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
VOID NTAPI FstubTranslatorNull(PVOID Context)
Definition: translate.c:22
#define UlongToPtr(u)
Definition: config.h:106
#define HAL_IRQ_TRANSLATOR_VERSION
Definition: haltypes.h:276
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
NTSTATUS NTAPI FstubTranslateRequirement(IN OUT PVOID Context OPTIONAL, IN PIO_RESOURCE_DESCRIPTOR Source, IN PDEVICE_OBJECT PhysicalDeviceObject, OUT PULONG TargetCount, OUT PIO_RESOURCE_DESCRIPTOR *Target)
Definition: translate.c:113
struct _TRANSLATOR_INTERFACE TRANSLATOR_INTERFACE
NTSTATUS NTAPI FstubTranslateResource(IN OUT PVOID Context OPTIONAL, IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Source, IN RESOURCE_TRANSLATION_DIRECTION Direction, IN ULONG AlternativesCount OPTIONAL, IN IO_RESOURCE_DESCRIPTOR Alternatives[], IN PDEVICE_OBJECT PhysicalDeviceObject, OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Target)
Definition: translate.c:35
return STATUS_SUCCESS
Definition: btrfs.c:3014
#define PAGED_CODE()

◆ xHalHaltSystem()

VOID NTAPI xHalHaltSystem ( VOID  )

Definition at line 41 of file halstub.c.

42 {
43  /* Halt execution */
44  while (TRUE);
45 }
#define TRUE
Definition: types.h:120

◆ xHalHandlerForBus()

PBUS_HANDLER FASTCALL xHalHandlerForBus ( IN INTERFACE_TYPE  InterfaceType,
IN ULONG  BusNumber 
)

Definition at line 106 of file halstub.c.

108 {
109  return NULL;
110 }
smooth NULL
Definition: ftsmooth.c:416

◆ xHalInitPnpDriver()

NTSTATUS NTAPI xHalInitPnpDriver ( VOID  )

Definition at line 122 of file halstub.c.

123 {
124  return STATUS_NOT_SUPPORTED;
125 }
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409

◆ xHalInitPowerManagement()

NTSTATUS NTAPI xHalInitPowerManagement ( IN PPM_DISPATCH_TABLE  PmDriverDispatchTable,
OUT PPM_DISPATCH_TABLE PmHalDispatchTable 
)

Definition at line 129 of file halstub.c.

131 {
132  return STATUS_NOT_SUPPORTED;
133 }
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409

◆ xHalIoAssignDriveLetters()

VOID FASTCALL xHalIoAssignDriveLetters ( IN PLOADER_PARAMETER_BLOCK  LoaderBlock,
IN PSTRING  NtDeviceName,
OUT PUCHAR  NtSystemPath,
OUT PSTRING  NtSystemPathString 
)

Definition at line 912 of file disksup.c.

916 {
917  USHORT i;
918  PULONG Devices;
920  WCHAR Buffer[50];
922  UCHAR DriveLetter;
923  BOOLEAN SystemFound;
924  IO_STATUS_BLOCK StatusBlock;
926  ANSI_STRING StringA1, StringA2;
927  PSTR Buffer1, Buffer2, LoadOptions;
929  PDRIVE_LAYOUT_INFORMATION LayoutInfo;
930  PCONFIGURATION_INFORMATION ConfigInfo;
931  UNICODE_STRING StringU1, StringU2, StringU3;
932  ULONG Increment, DiskCount, RealDiskCount, HarddiskCount, PartitionCount, SystemPartition;
933 
934  PAGED_CODE();
935 
936  /* Get our disk count */
937  ConfigInfo = IoGetConfigurationInformation();
938  DiskCount = ConfigInfo->DiskCount;
939  RealDiskCount = 0;
940 
941  /* Allocate two generic string buffers we'll use and reuser later on */
944  if (Buffer1 == NULL || Buffer2 == NULL)
945  {
946  KeBugCheck(ASSIGN_DRIVE_LETTERS_FAILED);
947  }
948 
949  /* In case of a remote boot, setup system path */
950  if (IoRemoteBootClient)
951  {
952  PSTR Last, Saved;
953 
954  /* Find last \ */
955  Last = strrchr(LoaderBlock->NtBootPathName, '\\');
956  Saved = NULL;
957  /* Misformed name, fail */
958  if (Last == NULL)
959  {
960  KeBugCheck(ASSIGN_DRIVE_LETTERS_FAILED);
961  }
962 
963  /* In case the name was terminated by a \... */
964  if (Last[1] == ANSI_NULL)
965  {
966  /* Erase it, save position and find the previous \ */
967  *Last = ANSI_NULL;
968  Saved = Last;
969  Last = strrchr(LoaderBlock->NtBootPathName, '\\');
970  *Saved = '\\';
971  }
972 
973  /* Misformed name, fail */
974  if (Last == NULL)
975  {
976  KeBugCheck(ASSIGN_DRIVE_LETTERS_FAILED);
977  }
978 
979  /* For a remote boot, assign X drive letter */
980  NtSystemPath[0] = 'X';
981  NtSystemPath[1] = ':';
982  /* And copy the end of the boot path */
983  strcpy((PSTR)&NtSystemPath[2], Last);
984 
985  /* If we had to remove the trailing \, remove it here too */
986  if (Saved != NULL)
987  {
988  NtSystemPath[strlen((PSTR)NtSystemPath) - 1] = ANSI_NULL;
989  }
990 
991  /* Setup output string */
992  RtlInitString(NtSystemPathString, (PSTR)NtSystemPath);
993  }
994 
995  /* For each of our disks, create the physical device DOS device */
996  Increment = 0;
997  if (DiskCount != 0)
998  {
999  for (i = 0; i < DiskCount; ++i)
1000  {
1001  /* Setup the origin name */
1002  sprintf(Buffer1, "\\Device\\Harddisk%d\\Partition%d", i, 0);
1003  RtlInitAnsiString(&StringA1, Buffer1);
1004  if (!NT_SUCCESS(RtlAnsiStringToUnicodeString(&StringU1, &StringA1, TRUE)))
1005  {
1006  /* We cannot fail */
1007  KeBugCheck(ASSIGN_DRIVE_LETTERS_FAILED);
1008  }
1009 
1010  /* Open the device */
1012  &StringU1,
1014  NULL,
1015  NULL);
1019  &StatusBlock,
1022  if (NT_SUCCESS(Status))
1023  {
1024  /* If we managed, create the link */
1025  sprintf(Buffer2, "\\DosDevices\\PhysicalDrive%d", i);
1026  RtlInitAnsiString(&StringA2, Buffer2);
1027  Status = RtlAnsiStringToUnicodeString(&StringU2, &StringA2, TRUE);
1028  if (NT_SUCCESS(Status))
1029  {
1030  IoCreateSymbolicLink(&StringU2, &StringU1);
1031  RtlFreeUnicodeString(&StringU2);
1032  }
1033 
1035 
1036  RealDiskCount = i + 1;
1037  }
1038 
1039  RtlFreeUnicodeString(&StringU1);
1040 
1041  if (!NT_SUCCESS(Status))
1042  {
1043  if (Increment < 50)
1044  {
1045  ++Increment;
1046  ++DiskCount;
1047  }
1048  }
1049  }
1050  }
1051 
1052  /* We done for our buffers */
1053  ExFreePoolWithTag(Buffer1, TAG_FSTUB);
1054  ExFreePoolWithTag(Buffer2, TAG_FSTUB);
1055 
1056  /* Upcase our load options, if any */
1057  if (LoaderBlock->LoadOptions != NULL)
1058  {
1059  LoadOptions = _strupr(LoaderBlock->LoadOptions);
1060  }
1061  else
1062  {
1063  LoadOptions = NULL;
1064  }
1065 
1066  /* If we boot with /MININT (system hive as volatile) option, assign X letter to boot device */
1067  if (LoadOptions != NULL &&
1068  strstr(LoadOptions, "MININT") != 0 &&
1069  NT_SUCCESS(RtlAnsiStringToUnicodeString(&StringU1, NtDeviceName, TRUE)))
1070  {
1071  if (NT_SUCCESS(HalpSetMountLetter(&StringU1, 'X')))
1072  {
1073  *NtSystemPath = 'X';
1074  }
1075 
1076  RtlFreeUnicodeString(&StringU1);
1077  }
1078 
1079  /* Compute our disks derangements */
1080  DiskCount -= Increment;
1081  if (RealDiskCount > DiskCount)
1082  {
1083  DiskCount = RealDiskCount;
1084  }
1085  Devices = IopComputeHarddiskDerangements(DiskCount);
1086 
1087  /* Now, start browsing all our disks for assigning drive letters
1088  * Here, we'll only handle boot partition and primary partitions
1089  */
1090  HarddiskCount = 0;
1091  for (i = 0; i < DiskCount; ++i)
1092  {
1093  /* Get device ID according to derangements map */
1094  if (Devices != NULL)
1095  {
1096  HarddiskCount = Devices[i];
1097  }
1098 
1099  /* Query disk layout */
1100  swprintf(Buffer, L"\\Device\\Harddisk%d\\Partition0", HarddiskCount);
1101  RtlInitUnicodeString(&StringU1, Buffer);
1102  if (!NT_SUCCESS(HalpQueryDriveLayout(&StringU1, &LayoutInfo)))
1103  {
1104  LayoutInfo = NULL;
1105  }
1106 
1107  /* Assume we didn't find system */
1108  SystemFound = FALSE;
1109  swprintf(Buffer, L"\\Device\\Harddisk%d\\Partition%d", HarddiskCount, 1);
1110  RtlInitUnicodeString(&StringU1, Buffer);
1111  /* Query partition info for our disk */
1112  if (!NT_SUCCESS(HalpQueryPartitionType(&StringU1, LayoutInfo, &PartitionType)))
1113  {
1114  /* It failed, retry for all the partitions */
1115  for (PartitionCount = 1; ; ++PartitionCount)
1116  {
1117  swprintf(Buffer, L"\\Device\\Harddisk%d\\Partition%d", HarddiskCount, PartitionCount);
1118  RtlInitUnicodeString(&StringU1, Buffer);
1119  if (!NT_SUCCESS(HalpQueryPartitionType(&StringU1, LayoutInfo, &PartitionType)))
1120  {
1121  break;
1122  }
1123 
1124  /* We found a primary partition, assign a drive letter */
1126  {
1127  HalpNextDriveLetter(&StringU1, NtDeviceName, NtSystemPath, 0);
1128  break;
1129  }
1130  }
1131  }
1132  else
1133  {
1134  /* All right */
1135  for (PartitionCount = 2; ; ++PartitionCount)
1136  {
1137  /* If our partition is bootable (MBR) or data (GPT), that's system partition */
1139  {
1140  SystemFound = TRUE;
1141 
1142  /* Assign a drive letter and stop here if MBR */
1143  HalpNextDriveLetter(&StringU1, NtDeviceName, NtSystemPath, 0);
1145  {
1146  break;
1147  }
1148  }
1149 
1150  /* Keep looping on all the partitions */
1151  swprintf(Buffer, L"\\Device\\Harddisk%d\\Partition%d", HarddiskCount, PartitionCount);
1152  RtlInitUnicodeString(&StringU1, Buffer);
1153  if (!NT_SUCCESS(HalpQueryPartitionType(&StringU1, LayoutInfo, &PartitionType)))
1154  {
1155  /* Mount every primary partition if we didn't find system */
1156  if (!SystemFound)
1157  {
1158  for (PartitionCount = 1; ; ++PartitionCount)
1159  {
1160  swprintf(Buffer, L"\\Device\\Harddisk%d\\Partition%d", HarddiskCount, PartitionCount);
1161  RtlInitUnicodeString(&StringU1, Buffer);
1162  if (!NT_SUCCESS(HalpQueryPartitionType(&StringU1, LayoutInfo, &PartitionType)))
1163  {
1164  break;
1165  }
1166 
1168  {
1169  HalpNextDriveLetter(&StringU1, NtDeviceName, NtSystemPath, 0);
1170  break;
1171  }
1172  }
1173  }
1174 
1175  break;
1176  }
1177  }
1178  }
1179 
1180  /* Free layout, we'll reallocate it for next device */
1181  if (LayoutInfo != NULL)
1182  {
1183  ExFreePoolWithTag(LayoutInfo, TAG_FSTUB);
1184  }
1185 
1186  HarddiskCount = i + 1;
1187  }
1188 
1189  /* Now, assign logical partitions */
1190  for (i = 0; i < DiskCount; ++i)
1191  {
1192  /* Get device ID according to derangements map */
1193  if (Devices != NULL)
1194  {
1195  HarddiskCount = Devices[i];
1196  }
1197  else
1198  {
1199  HarddiskCount = i;
1200  }
1201 
1202  /* Query device layout */
1203  swprintf(Buffer, L"\\Device\\Harddisk%d\\Partition0", HarddiskCount);
1204  RtlInitUnicodeString(&StringU1, Buffer);
1205  if (!NT_SUCCESS(HalpQueryDriveLayout(&StringU1, &LayoutInfo)))
1206  {
1207  LayoutInfo = NULL;
1208  }
1209 
1210  /* And assign drive letter to logical partitions */
1211  for (PartitionCount = 1; ; ++PartitionCount)
1212  {
1213  swprintf(Buffer, L"\\Device\\Harddisk%d\\Partition%d", HarddiskCount, PartitionCount);
1214  RtlInitUnicodeString(&StringU1, Buffer);
1215  if (!NT_SUCCESS(HalpQueryPartitionType(&StringU1, LayoutInfo, &PartitionType)))
1216  {
1217  break;
1218  }
1219 
1221  {
1222  HalpNextDriveLetter(&StringU1, NtDeviceName, NtSystemPath, 0);
1223  }
1224  }
1225 
1226  /* Free layout, we'll reallocate it for next device */
1227  if (LayoutInfo != NULL)
1228  {
1229  ExFreePoolWithTag(LayoutInfo, 0);
1230  }
1231  }
1232 
1233  /* Now, assign drive letters to everything else */
1234  for (i = 0; i < DiskCount; ++i)
1235  {
1236  /* Get device ID according to derangements map */
1237  if (Devices != NULL)
1238  {
1239  HarddiskCount = Devices[i];
1240  }
1241  else
1242  {
1243  HarddiskCount = i;
1244  }
1245 
1246  /* Query device layout */
1247  swprintf(Buffer, L"\\Device\\Harddisk%d\\Partition0", HarddiskCount);
1248  RtlInitUnicodeString(&StringU1, Buffer);
1249  if (!NT_SUCCESS(HalpQueryDriveLayout(&StringU1, &LayoutInfo)))
1250  {
1251  LayoutInfo = NULL;
1252  }
1253 
1254  /* Save system partition if any */
1255  SystemPartition = 0;
1256  for (PartitionCount = 1; ; ++PartitionCount)
1257  {
1258  swprintf(Buffer, L"\\Device\\Harddisk%d\\Partition%d", HarddiskCount, PartitionCount);
1259  RtlInitUnicodeString(&StringU1, Buffer);
1260  if (!NT_SUCCESS(HalpQueryPartitionType(&StringU1, LayoutInfo, &PartitionType)))
1261  {
1262  break;
1263  }
1264 
1266  {
1267  SystemPartition = PartitionCount;
1268  }
1269  }
1270 
1271  /* And assign drive letter to anything but system partition */
1272  for (PartitionCount = 1; ; ++PartitionCount)
1273  {
1274  if (PartitionCount != SystemPartition)
1275  {
1276  swprintf(Buffer, L"\\Device\\Harddisk%d\\Partition%d", HarddiskCount, PartitionCount);
1277  RtlInitUnicodeString(&StringU1, Buffer);
1278  if (!NT_SUCCESS(HalpQueryPartitionType(&StringU1, LayoutInfo, &PartitionType)))
1279  {
1280  if (LayoutInfo != NULL)
1281  {
1282  ExFreePoolWithTag(LayoutInfo, 0);
1283  }
1284 
1285  break;
1286  }
1287 
1289  {
1290  HalpNextDriveLetter(&StringU1, NtDeviceName, NtSystemPath, 0);
1291  }
1292  }
1293  }
1294  }
1295 
1296  /* We're done with disks, if we have a device map, free it */
1297  if (Devices != NULL)
1298  {
1299  ExFreePoolWithTag(Devices, TAG_FSTUB);
1300  }
1301 
1302  /* Now, assign drive letter to floppy drives */
1303  for (i = 0; i < ConfigInfo->FloppyCount; ++i)
1304  {
1305  swprintf(Buffer, L"\\Device\\Floppy%d", i);
1306  RtlInitUnicodeString(&StringU1, Buffer);
1307  if (HalpIsOldStyleFloppy(&StringU1))
1308  {
1309  HalpNextDriveLetter(&StringU1, NtDeviceName, NtSystemPath, TRUE);
1310  }
1311  }
1312 
1313  /* And CD drives */
1314  for (i = 0; i < ConfigInfo->CdRomCount; ++i)
1315  {
1316  swprintf(Buffer, L"\\Device\\CdRom%d", i);
1317  RtlInitUnicodeString(&StringU1, Buffer);
1318  HalpNextDriveLetter(&StringU1, NtDeviceName, NtSystemPath, TRUE);
1319  }
1320 
1321  /* If not remote boot, handle NtDeviceName */
1322  if (!IoRemoteBootClient && NT_SUCCESS(RtlAnsiStringToUnicodeString(&StringU1, NtDeviceName, TRUE)))
1323  {
1324  /* Assign it a drive letter */
1325  DriveLetter = HalpNextDriveLetter(&StringU1, NULL, NULL, TRUE);
1326  if (DriveLetter != 0)
1327  {
1328  if (DriveLetter != 0xFF)
1329  {
1330  *NtSystemPath = DriveLetter;
1331  }
1332  }
1333  /* If it fails through mount manager, retry manually */
1334  else
1335  {
1336  RtlInitUnicodeString(&StringU2, L"\\Device\\Floppy");
1337  RtlInitUnicodeString(&StringU3, L"\\Device\\CdRom");
1338 
1339  if (RtlPrefixUnicodeString(&StringU2, &StringU1, TRUE))
1340  {
1341  DriveLetter = 'A';
1342  }
1343  else if (RtlPrefixUnicodeString(&StringU3, &StringU1, TRUE))
1344  {
1345  DriveLetter = 'D';
1346  }
1347  else
1348  {
1349  DriveLetter = 'C';
1350  }
1351 
1352  /* Try any drive letter */
1353  while (HalpSetMountLetter(&StringU1, DriveLetter) != STATUS_SUCCESS)
1354  {
1355  ++DriveLetter;
1356 
1357  if (DriveLetter > 'Z')
1358  {
1359  break;
1360  }
1361  }
1362 
1363  /* If we're beyond Z (ie, no slot left) */
1364  if (DriveLetter > 'Z')
1365  {
1366  /* Delete Z, and reuse it for system */
1367  HalpDeleteMountLetter('Z');
1368  HalpSetMountLetter(&StringU1, 'Z');
1369  *NtSystemPath = 'Z';
1370  }
1371  else
1372  {
1373  /* Return matching drive letter */
1374  *NtSystemPath = DriveLetter;
1375  }
1376  }
1377 
1378  RtlFreeUnicodeString(&StringU1);
1379  }
1380 
1381  /* Enable auto assignement for mountmgr */
1383 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define TRUE
Definition: types.h:120
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
PCONFIGURATION_INFORMATION NTAPI IoGetConfigurationInformation(VOID)
Definition: iorsrce.c:830
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
LONG NTSTATUS
Definition: precomp.h:26
VOID HalpEnableAutomaticDriveLetterAssignment(VOID)
Definition: disksup.c:857
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
NTSTATUS HalpDeleteMountLetter(UCHAR DriveLetter)
Definition: disksup.c:766
#define FILE_SHARE_READ
Definition: compat.h:125
NTSTATUS HalpQueryPartitionType(IN PUNICODE_STRING DeviceName, IN PDRIVE_LAYOUT_INFORMATION LayoutInfo, OUT PPARTITION_TYPE PartitionType)
Definition: disksup.c:165
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
#define sprintf(buf, format,...)
Definition: sprintf.c:55
HANDLE FileHandle
Definition: stats.c:38
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define ANSI_NULL
DECLSPEC_NORETURN VOID NTAPI KeBugCheck(ULONG BugCheckCode)
Definition: bug.c:1431
#define FILE_READ_DATA
Definition: nt_native.h:628
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
UCHAR HalpNextDriveLetter(IN PUNICODE_STRING DeviceName, IN PSTRING NtDeviceName, OUT PUCHAR NtSystemPath, BOOLEAN IsRemovable)
Definition: disksup.c:607
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define swprintf(buf, format,...)
Definition: sprintf.c:56
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
static PPARTENTRY SystemPartition
Definition: usetup.c:61
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
NTSYSAPI NTSTATUS NTAPI ZwOpenFile(_Out_ PHANDLE FileHandle, _In_ ACCESS_MASK DesiredAccess, _In_ POBJECT_ATTRIBUTES ObjectAttributes, _Out_ PIO_STATUS_BLOCK IoStatusBlock, _In_ ULONG ShareAccess, _In_ ULONG OpenOptions)
NTSTATUS HalpSetMountLetter(IN PUNICODE_STRING DeviceName, UCHAR DriveLetter)
Definition: disksup.c:522
unsigned char UCHAR
Definition: xmlstorage.h:181
static const WCHAR L[]
Definition: oid.c:1250
#define TAG_FSTUB
Definition: tag.h:195
#define SYNCHRONIZE
Definition: nt_native.h:61
NTSYSAPI VOID NTAPI RtlInitString(PSTRING DestinationString, PCSZ SourceString)
Status
Definition: gdiplustypes.h:24
_CRTIMP char *__cdecl _strupr(_Inout_z_ char *_String)
unsigned short USHORT
Definition: pedump.c:61
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
signed char * PSTR
Definition: retypes.h:7
unsigned int * PULONG
Definition: retypes.h:1
PULONG IopComputeHarddiskDerangements(IN ULONG DiskCount)
Definition: disksup.c:320
NTSYSAPI BOOLEAN NTAPI RtlPrefixUnicodeString(IN PUNICODE_STRING String1, IN PUNICODE_STRING String2, IN BOOLEAN CaseInSensitive)
BOOLEAN HalpIsOldStyleFloppy(PUNICODE_STRING DeviceName)
Definition: disksup.c:707
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
CHAR PartitionType
Definition: part_xbox.c:32
unsigned int ULONG
Definition: retypes.h:1
NTSTATUS FASTCALL HalpQueryDriveLayout(IN PUNICODE_STRING DeviceName, OUT PDRIVE_LAYOUT_INFORMATION *LayoutInfo)
Definition: disksup.c:56
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
IN OUT PLONG IN OUT PLONG Addend IN OUT PLONG IN LONG Increment
Definition: CrNtStubs.h:42
return STATUS_SUCCESS
Definition: btrfs.c:3014
#define PAGED_CODE()
BOOLEAN IoRemoteBootClient
Definition: init.c:68

◆ xHalIoReadPartitionTable()

NTSTATUS FASTCALL xHalIoReadPartitionTable ( IN PDEVICE_OBJECT  DeviceObject,
IN ULONG  SectorSize,
IN BOOLEAN  ReturnRecognizedPartitions,
IN OUT PDRIVE_LAYOUT_INFORMATION PartitionBuffer 
)

Definition at line 1767 of file disksup.c.

1771 {
1772  KEVENT Event;
1774  PIRP Irp;
1775  PPARTITION_DESCRIPTOR PartitionDescriptor;
1776  CCHAR Entry;
1777  NTSTATUS Status;
1779  PUCHAR Buffer = NULL;
1780  ULONG BufferSize = 2048, InputSize;
1781  PDRIVE_LAYOUT_INFORMATION DriveLayoutInfo = NULL;
1782  LONG j = -1, i = -1, k;
1783  DISK_GEOMETRY_EX DiskGeometryEx;
1784  LONGLONG EndSector, MaxSector, StartOffset;
1785  LARGE_INTEGER Offset, VolumeOffset;
1786  BOOLEAN IsPrimary = TRUE, IsEzDrive = FALSE, MbrFound = FALSE;
1787  BOOLEAN IsValid, IsEmpty = TRUE;
1788  PVOID MbrBuffer;
1789  PIO_STACK_LOCATION IoStackLocation;
1791  LARGE_INTEGER HiddenSectors64;
1792  VolumeOffset.QuadPart = Offset.QuadPart = 0;
1793  PAGED_CODE();
1794 
1795  /* Allocate the buffer */
1797  BufferSize,
1798  TAG_FILE_SYSTEM);
1800 
1801  /* Normalize the buffer size */
1802  InputSize = max(512, SectorSize);
1803 
1804  /* Check for EZ Drive */
1805  HalExamineMBR(DeviceObject, InputSize, 0x55, &MbrBuffer);
1806  if (MbrBuffer)
1807  {
1808  /* EZ Drive found, bias the offset */
1809  IsEzDrive = TRUE;
1810  ExFreePoolWithTag(MbrBuffer, TAG_FILE_SYSTEM);
1811  Offset.QuadPart = 512;
1812  }
1813 
1814  /* Get drive geometry */
1815  Status = HalpGetFullGeometry(DeviceObject, &DiskGeometryEx);
1816  if (!NT_SUCCESS(Status))
1817  {
1819  *PartitionBuffer = NULL;
1820  return Status;
1821  }
1822 
1823  /* Get the end and maximum sector */
1824  EndSector = DiskGeometryEx.DiskSize.QuadPart / DiskGeometryEx.Geometry.BytesPerSector;
1825  MaxSector = EndSector << 1;
1826  DPRINT("FSTUB: DiskSize = %#I64x, MaxSector = %#I64x\n",
1827  DiskGeometryEx.DiskSize, MaxSector);
1828 
1829  /* Allocate our buffer */
1831  if (!Buffer)
1832  {
1833  /* Fail, free the input buffer */
1835  *PartitionBuffer = NULL;
1837  }
1838 
1839  /* Start partition loop */
1840  do
1841  {
1842  /* Assume the partition is valid */
1843  IsValid = TRUE;
1844 
1845  /* Initialize the event */
1847 
1848  /* Clear the buffer and build the IRP */
1849  RtlZeroMemory(Buffer, InputSize);
1851  DeviceObject,
1852  Buffer,
1853  InputSize,
1854  &Offset,
1855  &Event,
1856  &IoStatusBlock);
1857  if (!Irp)
1858  {
1859  /* Failed */
1861  break;
1862  }
1863 
1864  /* Make sure to disable volume verification */
1865  IoStackLocation = IoGetNextIrpStackLocation(Irp);
1866  IoStackLocation->Flags |= SL_OVERRIDE_VERIFY_VOLUME;
1867 
1868  /* Call the driver */
1870  if (Status == STATUS_PENDING)
1871  {
1872  /* Wait for completion */
1875  }
1876 
1877  /* Normalize status code and check for failure */
1879  if (!NT_SUCCESS(Status)) break;
1880 
1881  /* If we biased for EZ-Drive, unbias now */
1882  if (IsEzDrive && (Offset.QuadPart == 512)) Offset.QuadPart = 0;
1883 
1884  /* Make sure this is a valid MBR */
1886  {
1887  /* It's not, fail */
1888  DPRINT1("FSTUB: (IoReadPartitionTable) No 0xaa55 found in "
1889  "partition table %d\n", j + 1);
1890  break;
1891  }
1892 
1893  /* At this point we have a valid MBR */
1894  MbrFound = TRUE;
1895 
1896  /* Check if we weren't given an offset */
1897  if (!Offset.QuadPart)
1898  {
1899  /* Then read the signature off the disk */
1900  (*PartitionBuffer)->Signature = ((PULONG)Buffer)[PARTITION_TABLE_OFFSET / 2 - 1];
1901  }
1902 
1903  /* Get the partition descriptor array */
1904  PartitionDescriptor = (PPARTITION_DESCRIPTOR)
1906 
1907  /* Start looping partitions */
1908  j++;
1909  DPRINT("FSTUB: Partition Table %d:\n", j);
1910  for (Entry = 1, k = 0; Entry <= 4; Entry++, PartitionDescriptor++)
1911  {
1912  /* Get the partition type */
1913  PartitionType = PartitionDescriptor->PartitionType;
1914 
1915  /* Print debug messages */
1916  DPRINT("Partition Entry %d,%d: type %#x %s\n",
1917  j,
1918  Entry,
1919  PartitionType,
1920  (PartitionDescriptor->ActiveFlag) ? "Active" : "");
1921  DPRINT("\tOffset %#08lx for %#08lx Sectors\n",
1922  GET_STARTING_SECTOR(PartitionDescriptor),
1923  GET_PARTITION_LENGTH(PartitionDescriptor));
1924 
1925  /* Check whether we're facing a protective MBR */
1927  {
1928  /* Partition length might be bigger than disk size */
1929  FstubFixupEfiPartition(PartitionDescriptor, DiskGeometryEx.DiskSize.QuadPart);
1930  }
1931 
1932  /* Make sure that the partition is valid, unless it's the first */
1933  if (!(HalpIsValidPartitionEntry(PartitionDescriptor,
1934  DiskGeometryEx.DiskSize.QuadPart,
1935  MaxSector)) && (j == 0))
1936  {
1937  /* It's invalid, so fail */
1938  IsValid = FALSE;
1939  break;
1940  }
1941 
1942  /* Check if it's a container */
1944  {
1945  /* Increase the count of containers */
1946  if (++k != 1)
1947  {
1948  /* More then one table is invalid */
1949  DPRINT1("FSTUB: Multiple container partitions found in "
1950  "partition table %d\n - table is invalid\n",
1951  j);
1952  IsValid = FALSE;
1953  break;
1954  }
1955  }
1956 
1957  /* Check if the partition is supposedly empty */
1958  if (IsEmpty)
1959  {
1960  /* But check if it actually has a start and/or length */
1961  if ((GET_STARTING_SECTOR(PartitionDescriptor)) ||
1962  (GET_PARTITION_LENGTH(PartitionDescriptor)))
1963  {
1964  /* So then it's not really empty */
1965  IsEmpty = FALSE;
1966  }
1967  }
1968 
1969  /* Check if the caller wanted only recognized partitions */
1971  {
1972  /* Then check if this one is unused, or a container */
1975  {
1976  /* Skip it, since the caller doesn't want it */
1977  continue;
1978  }
1979  }
1980 
1981  /* Increase the structure count and check if they can fit */
1982  if ((sizeof(DRIVE_LAYOUT_INFORMATION) +
1983  (++i * sizeof(PARTITION_INFORMATION))) >
1984  BufferSize)
1985  {
1986  /* Allocate a new buffer that's twice as big */
1987  DriveLayoutInfo = ExAllocatePoolWithTag(NonPagedPool,
1988  BufferSize << 1,
1989  TAG_FILE_SYSTEM);
1990  if (!DriveLayoutInfo)
1991  {
1992  /* Out of memory, unto this extra structure */
1993  --i;
1995  break;
1996  }
1997 
1998  /* Copy the contents of the old buffer */
1999  RtlMoveMemory(DriveLayoutInfo,
2000  *PartitionBuffer,
2001  BufferSize);
2002 
2003  /* Free the old buffer and set this one as the new one */
2005  *PartitionBuffer = DriveLayoutInfo;
2006 
2007  /* Double the size */
2008  BufferSize <<= 1;
2009  }
2010 
2011  /* Now get the current structure being filled and initialize it */
2012  PartitionInfo = &(*PartitionBuffer)->PartitionEntry[i];
2013  PartitionInfo->PartitionType = PartitionType;
2014  PartitionInfo->RewritePartition = FALSE;
2015 
2016  /* Check if we're dealing with a partition that's in use */
2018  {
2019  /* Check if it's bootable */
2020  PartitionInfo->BootIndicator = PartitionDescriptor->
2021  ActiveFlag & 0x80 ?
2022  TRUE : FALSE;
2023 
2024  /* Check if its' a container */
2026  {
2027  /* Then don't recognize it and use the volume offset */
2028  PartitionInfo->RecognizedPartition = FALSE;
2029  StartOffset = VolumeOffset.QuadPart;
2030  }
2031  else
2032  {
2033  /* Then recognize it and use the partition offset */
2034  PartitionInfo->RecognizedPartition = TRUE;
2035  StartOffset = Offset.QuadPart;
2036  }
2037 
2038  /* Get the starting offset */
2039  PartitionInfo->StartingOffset.QuadPart =
2040  StartOffset +
2041  UInt32x32To64(GET_STARTING_SECTOR(PartitionDescriptor),
2042  SectorSize);
2043 
2044  /* Calculate the number of hidden sectors */
2045  HiddenSectors64.QuadPart = (PartitionInfo->
2046  StartingOffset.QuadPart -
2047  StartOffset) /
2048  SectorSize;
2049  PartitionInfo->HiddenSectors = HiddenSectors64.LowPart;
2050 
2051  /* Get the partition length */
2052  PartitionInfo->PartitionLength.QuadPart =
2053  UInt32x32To64(GET_PARTITION_LENGTH(PartitionDescriptor),
2054  SectorSize);
2055 
2056  /* Get the partition number */
2057  PartitionInfo->PartitionNumber = (!IsContainerPartition(PartitionType)) ? i + 1 : 0;
2058  }
2059  else
2060  {
2061  /* Otherwise, clear all the relevant fields */
2062  PartitionInfo->BootIndicator = FALSE;
2063  PartitionInfo->RecognizedPartition = FALSE;
2064  PartitionInfo->StartingOffset.QuadPart = 0;
2065  PartitionInfo->PartitionLength.QuadPart = 0;
2066  PartitionInfo->HiddenSectors = 0;
2067 
2068  PartitionInfo->PartitionNumber = 0;
2069  }
2070  }
2071 
2072  /* Finish debug log, and check for failure */
2073  DPRINT("\n");
2074  if (!NT_SUCCESS(Status)) break;
2075 
2076  /* Also check if we hit an invalid entry here */
2077  if (!IsValid)
2078  {
2079  /* We did, so break out of the loop minus one entry */
2080  j--;
2081  break;
2082  }
2083 
2084  /* Reset the offset */
2085  Offset.QuadPart = 0;
2086 
2087  /* Go back to the descriptor array and loop it */
2088  PartitionDescriptor = (PPARTITION_DESCRIPTOR)
2090  for (Entry = 1; Entry <= 4; Entry++, PartitionDescriptor++)
2091  {
2092  /* Check if this is a container partition, since we skipped them */
2093  if (IsContainerPartition(PartitionDescriptor->PartitionType))
2094  {
2095  /* Get its offset */
2096  Offset.QuadPart = VolumeOffset.QuadPart +
2097  UInt32x32To64(
2098  GET_STARTING_SECTOR(PartitionDescriptor),
2099  SectorSize);
2100 
2101  /* If this is a primary partition, this is the volume offset */
2102  if (IsPrimary) VolumeOffset = Offset;
2103 
2104  /* Also update the maximum sector */
2105  MaxSector = GET_PARTITION_LENGTH(PartitionDescriptor);
2106  DPRINT1("FSTUB: MaxSector now = %I64d\n", MaxSector);
2107  break;
2108  }
2109  }
2110 
2111  /* Loop the next partitions, which are not primary anymore */
2112  IsPrimary = FALSE;
2113  } while (Offset.HighPart | Offset.LowPart);
2114 
2115  /* Check if this is a removable device that's probably a super-floppy */
2116  if ((DiskGeometryEx.Geometry.MediaType == RemovableMedia) &&
2117  (j == 0) && (MbrFound) && (IsEmpty))
2118  {
2119  PBOOT_SECTOR_INFO BootSectorInfo = (PBOOT_SECTOR_INFO)Buffer;
2120 
2121  /* Read the jump bytes to detect super-floppy */
2122  if ((BootSectorInfo->JumpByte[0] == 0xeb) ||
2123  (BootSectorInfo->JumpByte[0] == 0xe9))
2124  {
2125  /* Super floppes don't have typical MBRs, so skip them */
2126  DPRINT1("FSTUB: Jump byte %#x found along with empty partition "
2127  "table - disk is a super floppy and has no valid MBR\n",
2128  BootSectorInfo->JumpByte);
2129  j = -1;
2130  }
2131  }
2132 
2133  /* Check if we're still at partition -1 */
2134  if (j == -1)
2135  {
2136  /* The likely cause is the super floppy detection above */
2137  if ((MbrFound) || (DiskGeometryEx.Geometry.MediaType == RemovableMedia))
2138  {
2139  /* Print out debugging information */
2140  DPRINT1("FSTUB: Drive %#p has no valid MBR. Make it into a "
2141  "super-floppy\n",
2142  DeviceObject);
2143  DPRINT1("FSTUB: Drive has %I64d sectors and is %#016I64x "
2144  "bytes large\n",
2145  EndSector, DiskGeometryEx.DiskSize);
2146 
2147  /* We should at least have some sectors */
2148  if (EndSector > 0)
2149  {
2150  /* Get the entry we'll use */
2151  PartitionInfo = &(*PartitionBuffer)->PartitionEntry[0];
2152 
2153  /* Fill it out with data for a super-floppy */
2154  PartitionInfo->RewritePartition = FALSE;
2155  PartitionInfo->RecognizedPartition = TRUE;
2156  PartitionInfo->PartitionType = PARTITION_FAT_16;
2157  PartitionInfo->BootIndicator = FALSE;
2158  PartitionInfo->HiddenSectors = 0;
2159  PartitionInfo->StartingOffset.QuadPart = 0;
2160  PartitionInfo->PartitionLength = DiskGeometryEx.DiskSize;
2161 
2162  /* FIXME: REACTOS HACK */
2163  PartitionInfo->PartitionNumber = 0;
2164 
2165  /* Set the signature and set the count back to 0 */
2166  (*PartitionBuffer)->Signature = 1;
2167  i = 0;
2168  }
2169  }
2170  else
2171  {
2172  /* Otherwise, this isn't a super floppy, so set an invalid count */
2173  i = -1;
2174  }
2175  }
2176 
2177  /* Set the partition count */
2178  (*PartitionBuffer)->PartitionCount = ++i;
2179 
2180  /* If we have no count, delete the signature */
2181  if (!i) (*PartitionBuffer)->Signature = 0;
2182 
2183  /* Free the buffer and check for success */
2185  if (!NT_SUCCESS(Status))
2186  {
2188  *PartitionBuffer = NULL;
2189  }
2190 
2191  /* Return status */
2192  return Status;
2193 }
#define TAG_FILE_SYSTEM
Definition: tag.h:50
#define max(a, b)
Definition: svc.c:63
#define TRUE
Definition: types.h:120
#define GET_STARTING_SECTOR(p)
Definition: hal.h:252
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define EFI_PMBR_OSTYPE_EFI
Definition: disksup.c:25
_In_ PFCB _In_ LONGLONG StartingOffset
Definition: cdprocs.h:290
struct _Entry Entry
Definition: kefuncs.h:627
PIRP NTAPI IoBuildSynchronousFsdRequest(IN ULONG MajorFunction, IN PDEVICE_OBJECT DeviceObject, IN PVOID Buffer, IN ULONG Length, IN PLARGE_INTEGER StartingOffset, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:1069
_In_ PIRP Irp
Definition: csq.h:116
UCHAR JumpByte[1]
Definition: hal.h:301
unsigned char * PUCHAR
Definition: retypes.h:3
LONG NTSTATUS
Definition: precomp.h:26
#define PARTITION_TABLE_OFFSET
Definition: hal.h:243
#define IsContainerPartition(PartitionType)
Definition: ntdddisk.h:250
ULONG BytesPerSector
Definition: ntdddisk.h:381
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
LARGE_INTEGER DiskSize
Definition: ntdddisk.h:386
#define PARTITION_ENTRY_UNUSED
Definition: disk.h:86
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
long LONG
Definition: pedump.c:60
DISK_GEOMETRY Geometry
Definition: ntdddisk.h:385
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:437
_In_ ULONG _In_ BOOLEAN _Out_ struct _DRIVE_LAYOUT_INFORMATION ** PartitionBuffer
Definition: iofuncs.h:2048
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define SL_OVERRIDE_VERIFY_VOLUME
Definition: iotypes.h:1782
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
int64_t LONGLONG
Definition: typedefs.h:67
#define GET_PARTITION_LENGTH(p)
Definition: hal.h:261
#define BOOT_RECORD_SIGNATURE
Definition: parttest.c:17
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
char CCHAR
Definition: typedefs.h:51
UCHAR PartitionType
Definition: hal.h:282
struct _PARTITION_DESCRIPTOR * PPARTITION_DESCRIPTOR
_In_ ULONG _In_ struct _SET_PARTITION_INFORMATION_EX * PartitionInfo
Definition: iofuncs.h:2101
#define BufferSize
Definition: classpnp.h:419
MEDIA_TYPE MediaType
Definition: ntdddisk.h:378
#define PARTITION_FAT_16
Definition: disk.h:90
VOID NTAPI FstubFixupEfiPartition(IN PPARTITION_DESCRIPTOR PartitionDescriptor, IN ULONGLONG MaxOffset)
Definition: disksup.c:1748
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
unsigned char UCHAR
Definition: xmlstorage.h:181
BOOLEAN NTAPI HalpIsValidPartitionEntry(IN PPARTITION_DESCRIPTOR Entry, IN ULONGLONG MaxOffset, IN ULONGLONG MaxSector)
Definition: disksup.c:1440
_In_ ULONG _In_ BOOLEAN ReturnRecognizedPartitions
Definition: iofuncs.h:2046
#define BOOT_SIGNATURE_OFFSET
Definition: hal.h:244
ULONG LowPart
Definition: typedefs.h:105
NTSTATUS NTAPI HalpGetFullGeometry(IN PDEVICE_OBJECT DeviceObject, OUT PDISK_GEOMETRY_EX Geometry)
Definition: disksup.c:1389
#define STATUS_NO_DATA_DETECTED
Definition: udferr_usr.h:131
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2647
UCHAR ActiveFlag
Definition: hal.h:278
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1569
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
unsigned int * PULONG
Definition: retypes.h:1
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define DPRINT1
Definition: precomp.h:8
#define IRP_MJ_READ
Definition: rdpdr.c:46
CHAR PartitionType
Definition: part_xbox.c:32
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
VOID FASTCALL HalExamineMBR(IN PDEVICE_OBJECT DeviceObject, IN ULONG SectorSize, IN ULONG MbrTypeIdentifier, OUT PVOID *MbrBuffer)
Definition: disksup.c:2679
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
_In_ ULONG SectorSize
Definition: halfuncs.h:291
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
return STATUS_SUCCESS
Definition: btrfs.c:3014
#define UInt32x32To64(a, b)
Definition: intsafe.h:258
int k
Definition: mpi.c:3369
unsigned short * PUSHORT
Definition: retypes.h:2
base of all file and directory entries
Definition: entries.h:82
struct _BOOT_SECTOR_INFO * PBOOT_SECTOR_INFO
LONGLONG QuadPart
Definition: typedefs.h:113
#define PAGED_CODE()

◆ xHalIoSetPartitionInformation()

NTSTATUS FASTCALL xHalIoSetPartitionInformation ( IN PDEVICE_OBJECT  DeviceObject,
IN ULONG  SectorSize,
IN ULONG  PartitionNumber,
IN ULONG  PartitionType 
)

Definition at line 2197 of file disksup.c.

2201 {
2202  PIRP Irp;
2203  KEVENT Event;
2205  NTSTATUS Status;
2206  LARGE_INTEGER Offset, VolumeOffset;
2207  PUCHAR Buffer = NULL;
2208  ULONG BufferSize;
2209  ULONG i = 0;
2210  ULONG Entry;
2211  PPARTITION_DESCRIPTOR PartitionDescriptor;
2212  BOOLEAN IsPrimary = TRUE, IsEzDrive = FALSE;
2213  PVOID MbrBuffer;
2214  PIO_STACK_LOCATION IoStackLocation;
2215  VolumeOffset.QuadPart = Offset.QuadPart = 0;
2216  PAGED_CODE();
2217 
2218  /* Normalize the buffer size */
2219  BufferSize = max(512, SectorSize);
2220 
2221  /* Check for EZ Drive */
2222  HalExamineMBR(DeviceObject, BufferSize, 0x55, &MbrBuffer);
2223  if (MbrBuffer)
2224  {
2225  /* EZ Drive found, bias the offset */
2226  IsEzDrive = TRUE;
2227  ExFreePoolWithTag(MbrBuffer, TAG_FILE_SYSTEM);
2228  Offset.QuadPart = 512;
2229  }
2230 
2231  /* Allocate our partition buffer */
2234 
2235  /* Initialize the event we'll use and loop partitions */
2237  do
2238  {
2239  /* Reset the event since we reuse it */
2240  KeClearEvent(&Event);
2241 
2242  /* Build the read IRP */
2244  DeviceObject,
2245  Buffer,
2246  BufferSize,
2247  &Offset,
2248  &Event,
2249  &IoStatusBlock);
2250  if (!Irp)
2251  {
2252  /* Fail */
2254  break;
2255  }
2256 
2257  /* Make sure to disable volume verification */
2258  IoStackLocation = IoGetNextIrpStackLocation(Irp);
2259  IoStackLocation->Flags |= SL_OVERRIDE_VERIFY_VOLUME;
2260 
2261  /* Call the driver */
2263  if (Status == STATUS_PENDING)
2264  {
2265  /* Wait for completion */
2268  }
2269 
2270  /* Check for failure */
2271  if (!NT_SUCCESS(Status)) break;
2272 
2273  /* If we biased for EZ-Drive, unbias now */
2274  if (IsEzDrive && (Offset.QuadPart == 512)) Offset.QuadPart = 0;
2275 
2276  /* Make sure this is a valid MBR */
2278  {
2279  /* It's not, fail */
2281  break;
2282  }
2283 
2284  /* Get the partition descriptors and loop them */
2285  PartitionDescriptor = (PPARTITION_DESCRIPTOR)
2287  for (Entry = 1; Entry <= 4; Entry++, PartitionDescriptor++)
2288  {
2289  /* Check if it's unused or a container partition */
2290  if ((PartitionDescriptor->PartitionType ==
2292  (IsContainerPartition(PartitionDescriptor->PartitionType)))
2293  {
2294  /* Go to the next one */
2295  continue;
2296  }
2297 
2298  /* It's a valid partition, so increase the partition count */
2299  if (++i == PartitionNumber)
2300  {
2301  /* We found a match, set the type */
2302  PartitionDescriptor->PartitionType = (UCHAR)PartitionType;
2303 
2304  /* Reset the reusable event */
2305  KeClearEvent(&Event);
2306 
2307  /* Build the write IRP */
2309  DeviceObject,
2310  Buffer,
2311  BufferSize,
2312  &Offset,
2313  &Event,
2314  &IoStatusBlock);
2315  if (!Irp)
2316  {
2317  /* Fail */
2319  break;
2320  }
2321 
2322  /* Disable volume verification */
2323  IoStackLocation = IoGetNextIrpStackLocation(Irp);
2324  IoStackLocation->Flags |= SL_OVERRIDE_VERIFY_VOLUME;
2325 
2326  /* Call the driver */
2328  if (Status == STATUS_PENDING)
2329  {
2330  /* Wait for completion */
2332  Executive,
2333  KernelMode,
2334  FALSE,
2335  NULL);
2337  }
2338 
2339  /* We're done, break out of the loop */
2340  break;
2341  }
2342  }
2343 
2344  /* If we looped all the partitions, break out */
2345  if (Entry <= NUM_PARTITION_TABLE_ENTRIES) break;
2346 
2347  /* Nothing found yet, get the partition array again */
2348  PartitionDescriptor = (PPARTITION_DESCRIPTOR)
2350  for (Entry = 1; Entry <= 4; Entry++, PartitionDescriptor++)
2351  {
2352  /* Check if this was a container partition (we skipped these) */
2353  if (IsContainerPartition(PartitionDescriptor->PartitionType))
2354  {
2355  /* Update the partition offset */
2356  Offset.QuadPart = VolumeOffset.QuadPart +
2357  GET_STARTING_SECTOR(PartitionDescriptor) *
2358  SectorSize;
2359 
2360  /* If this was the primary partition, update the volume too */
2361  if (IsPrimary) VolumeOffset = Offset;
2362  break;
2363  }
2364  }
2365 
2366  /* Check if we already searched all the partitions */
2368  {
2369  /* Then we failed to find a good MBR */
2371  break;
2372  }
2373 
2374  /* Loop the next partitions, which are not primary anymore */
2375  IsPrimary = FALSE;
2376  } while (i < PartitionNumber);
2377 
2378  /* Everything done, cleanup */
2380  return Status;
2381 }
#define TAG_FILE_SYSTEM
Definition: tag.h:50
#define max(a, b)
Definition: svc.c:63
#define TRUE
Definition: types.h:120
#define GET_STARTING_SECTOR(p)
Definition: hal.h:252
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
struct _Entry Entry
Definition: kefuncs.h:627
PIRP NTAPI IoBuildSynchronousFsdRequest(IN ULONG MajorFunction, IN PDEVICE_OBJECT DeviceObject, IN PVOID Buffer, IN ULONG Length, IN PLARGE_INTEGER StartingOffset, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:1069
_In_ PIRP Irp
Definition: csq.h:116
unsigned char * PUCHAR
Definition: retypes.h:3
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_BAD_MASTER_BOOT_RECORD
Definition: ntstatus.h:391
#define PARTITION_TABLE_OFFSET
Definition: hal.h:243
#define IsContainerPartition(PartitionType)
Definition: ntdddisk.h:250
_In_ ULONG _In_ ULONG PartitionNumber
Definition: iofuncs.h:2056
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
#define PARTITION_ENTRY_UNUSED
Definition: disk.h:86
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:437
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define SL_OVERRIDE_VERIFY_VOLUME
Definition: iotypes.h:1782
Definition: bufpool.h:45
#define BOOT_RECORD_SIGNATURE
Definition: parttest.c:17
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
UCHAR PartitionType
Definition: hal.h:282
struct _PARTITION_DESCRIPTOR * PPARTITION_DESCRIPTOR
#define BufferSize
Definition: classpnp.h:419
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
unsigned char UCHAR
Definition: xmlstorage.h:181
#define BOOT_SIGNATURE_OFFSET
Definition: hal.h:244
#define PAGE_SIZE
Definition: env_spec_w32.h:49
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2647
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1569
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define IRP_MJ_READ
Definition: rdpdr.c:46
CHAR PartitionType
Definition: part_xbox.c:32
#define NUM_PARTITION_TABLE_ENTRIES
Definition: hal.h:247
unsigned int ULONG
Definition: retypes.h:1
VOID FASTCALL HalExamineMBR(IN PDEVICE_OBJECT DeviceObject, IN ULONG SectorSize, IN ULONG MbrTypeIdentifier, OUT PVOID *MbrBuffer)
Definition: disksup.c:2679
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
_In_ ULONG SectorSize
Definition: halfuncs.h:291
VOID NTAPI KeClearEvent(IN PKEVENT Event)
Definition: eventobj.c:22
unsigned short * PUSHORT
Definition: retypes.h:2
base of all file and directory entries
Definition: entries.h:82
LONGLONG QuadPart
Definition: typedefs.h:113
#define PAGED_CODE()

◆ xHalIoWritePartitionTable()

NTSTATUS FASTCALL xHalIoWritePartitionTable ( IN PDEVICE_OBJECT  DeviceObject,
IN ULONG  SectorSize,
IN ULONG  SectorsPerTrack,
IN ULONG  NumberOfHeads,
IN PDRIVE_LAYOUT_INFORMATION  PartitionBuffer 
)

Definition at line 2385 of file disksup.c.

2390 {
2391  KEVENT Event;
2393  PIRP Irp;
2395  ULONG BufferSize;
2396  PUSHORT Buffer;
2397  PPTE Entry;
2398  PPARTITION_TABLE PartitionTable;
2399  LARGE_INTEGER Offset, NextOffset, ExtendedOffset, SectorOffset;
2400  LARGE_INTEGER StartOffset, PartitionLength;
2401  ULONG i, j;
2402  CCHAR k;
2403  BOOLEAN IsEzDrive = FALSE, IsSuperFloppy = FALSE, DoRewrite = FALSE, IsMbr;
2404  ULONG ConventionalCylinders;
2405  LONGLONG DiskSize;
2407  PVOID MbrBuffer;
2409  PIO_STACK_LOCATION IoStackLocation;
2412  ExtendedOffset.QuadPart = NextOffset.QuadPart = Offset.QuadPart = 0;
2413  PAGED_CODE();
2414 
2415  /* Normalize the buffer size */
2416  BufferSize = max(512, SectorSize);
2417 
2418  /* Get the partial drive geometry */
2419  xHalGetPartialGeometry(DeviceObject, &ConventionalCylinders, &DiskSize);
2420 
2421  /* Check for EZ Drive */
2422  HalExamineMBR(DeviceObject, BufferSize, 0x55, &MbrBuffer);
2423  if (MbrBuffer)
2424  {
2425  /* EZ Drive found, bias the offset */
2426  IsEzDrive = TRUE;
2427  ExFreePoolWithTag(MbrBuffer, TAG_FILE_SYSTEM);
2428  Offset.QuadPart = 512;
2429  }
2430 
2431  /* Get the number of bits to shift to multiply by the sector size */
2432  for (k = 0; k < 32; k++) if ((SectorSize >> k) == 1) break;
2433 
2434  /* Check if there's only one partition */
2435  if (PartitionBuffer->PartitionCount == 1)
2436  {
2437  /* Check if it has no starting offset or hidden sectors */
2438  if (!(PartitionInfo->StartingOffset.QuadPart) &&
2439  !(PartitionInfo->HiddenSectors))
2440  {
2441  /* Then it's a super floppy */
2442  IsSuperFloppy = TRUE;
2443 
2444  /* Which also means it must be non-bootable FAT-16 */
2445  if ((PartitionInfo->PartitionNumber) ||
2446  (PartitionInfo->PartitionType != PARTITION_FAT_16) ||
2447  (PartitionInfo->BootIndicator))
2448  {
2449  /* It's not, so we fail */
2450  return STATUS_INVALID_PARAMETER;
2451  }
2452 
2453  /* Check if it needs a rewrite, and disable EZ drive for sure */
2454  if (PartitionInfo->RewritePartition) DoRewrite = TRUE;
2455  IsEzDrive = FALSE;
2456  }
2457  }
2458 
2459  /* Count the number of partition tables */
2460  DiskLayout->TableCount = (PartitionBuffer->PartitionCount + 4 - 1) / 4;
2461 
2462  /* Allocate our partition buffer */
2465 
2466  /* Loop the entries */
2468  for (i = 0; i < DiskLayout->TableCount; i++)
2469  {
2470  /* Set if this is the MBR partition */
2471  IsMbr= (BOOLEAN)!i;
2472 
2473  /* Initialize th event */
2475 
2476  /* Build the read IRP */
2478  DeviceObject,
2479  Buffer,
2480  BufferSize,
2481  &Offset,
2482  &Event,
2483  &IoStatusBlock);
2484  if (!Irp)
2485  {
2486  /* Fail */
2488  break;
2489  }
2490 
2491  /* Make sure to disable volume verification */
2492  IoStackLocation = IoGetNextIrpStackLocation(Irp);
2493  IoStackLocation->Flags |= SL_OVERRIDE_VERIFY_VOLUME;
2494 
2495  /* Call the driver */
2497  if (Status == STATUS_PENDING)
2498  {
2499  /* Wait for completion */
2502  }
2503 
2504  /* Check for failure */
2505  if (!NT_SUCCESS(Status)) break;
2506 
2507  /* If we biased for EZ-Drive, unbias now */
2508  if (IsEzDrive && (Offset.QuadPart == 512)) Offset.QuadPart = 0;
2509 
2510  /* Check if this is a normal disk */
2511  if (!IsSuperFloppy)
2512  {
2513  /* Set the boot record signature */
2515 
2516  /* By default, don't require a rewrite */
2517  DoRewrite = FALSE;
2518 
2519  /* Check if we don't have an offset */
2520  if (!Offset.QuadPart)
2521  {
2522  /* Check if the signature doesn't match */
2523  if (((PULONG)Buffer)[PARTITION_TABLE_OFFSET / 2 - 1] !=
2524  PartitionBuffer->Signature)
2525  {
2526  /* Then write the signature and now we need a rewrite */
2527  ((PULONG)Buffer)[PARTITION_TABLE_OFFSET / 2 - 1] =
2528  PartitionBuffer->Signature;
2529  DoRewrite = TRUE;
2530  }
2531  }
2532 
2533  /* Loop the partition table entries */
2534  PartitionTable = &DiskLayout->PartitionTable[i];
2535  for (j = 0; j < 4; j++)
2536  {
2537  /* Get the current entry and type */
2538  TableEntry = &PartitionTable->PartitionEntry[j];
2539  PartitionType = TableEntry->PartitionType;
2540 
2541  /* Check if the entry needs a rewrite */
2542  if (TableEntry->RewritePartition)
2543  {
2544  /* Then we need one too */
2545  DoRewrite = TRUE;
2546 
2547  /* Save the type and if it's a bootable partition */
2548  Entry[j].PartitionType = TableEntry->PartitionType;
2549  Entry[j].ActiveFlag = TableEntry->BootIndicator ? 0x80 : 0;
2550 
2551  /* Make sure it's used */
2553  {
2554  /* Make sure it's not a container (unless primary) */
2555  if ((IsMbr) || !(IsContainerPartition(PartitionType)))
2556  {
2557  /* Use the partition offset */
2558  StartOffset.QuadPart = Offset.QuadPart;
2559  }
2560  else
2561  {
2562  /* Use the extended logical partition offset */
2563  StartOffset.QuadPart = ExtendedOffset.QuadPart;
2564  }
2565 
2566  /* Set the sector offset */
2567  SectorOffset.QuadPart = TableEntry->
2568  StartingOffset.QuadPart -
2569  StartOffset.QuadPart;
2570 
2571  /* Now calculate the starting sector */
2572  StartOffset.QuadPart = SectorOffset.QuadPart >> k;
2573  Entry[j].StartingSector = StartOffset.LowPart;
2574 
2575  /* As well as the length */
2576  PartitionLength.QuadPart = TableEntry->PartitionLength.
2577  QuadPart >> k;
2578  Entry[j].PartitionLength = PartitionLength.LowPart;
2579 
2580  /* Calculate the CHS values */
2581  HalpCalculateChsValues(&TableEntry->StartingOffset,
2582  &TableEntry->PartitionLength,
2583  k,
2585  NumberOfHeads,
2586  ConventionalCylinders,
2588  &Entry[j]);
2589  }
2590  else
2591  {
2592  /* Otherwise set up an empty entry */
2593  Entry[j].StartingSector = 0;
2594  Entry[j].PartitionLength = 0;
2595  Entry[j].StartingTrack = 0;
2596  Entry[j].EndingTrack = 0;
2597  Entry[j].StartingCylinder = 0;
2598  Entry[j].EndingCylinder = 0;
2599  }
2600  }
2601 
2602  /* Check if this is a container partition */
2604  {
2605  /* Then update the offset to use */
2606  NextOffset = TableEntry->StartingOffset;
2607  }
2608  }
2609  }
2610 
2611  /* Check if we need to write back the buffer */
2612  if (DoRewrite)
2613  {
2614  /* We don't need to do this again */
2615  DoRewrite = FALSE;
2616 
2617  /* Initialize the event */
2619 
2620  /* If we unbiased for EZ-Drive, rebias now */
2621  if ((IsEzDrive) && !(Offset.QuadPart)) Offset.QuadPart = 512;
2622 
2623  /* Build the write IRP */
2625  DeviceObject,
2626  Buffer,
2627  BufferSize,
2628  &Offset,
2629  &Event,
2630  &IoStatusBlock);
2631  if (!Irp)
2632  {
2633  /* Fail */
2635  break;
2636  }
2637 
2638  /* Make sure to disable volume verification */
2639  IoStackLocation = IoGetNextIrpStackLocation(Irp);
2640  IoStackLocation->Flags |= SL_OVERRIDE_VERIFY_VOLUME;
2641 
2642  /* Call the driver */
2644  if (Status == STATUS_PENDING)
2645  {
2646  /* Wait for completion */
2648  Executive,
2649  KernelMode,
2650  FALSE,
2651  NULL);
2653  }
2654 
2655  /* Check for failure */
2656  if (!NT_SUCCESS(Status)) break;
2657 
2658  /* If we biased for EZ-Drive, unbias now */
2659  if (IsEzDrive && (Offset.QuadPart == 512)) Offset.QuadPart = 0;
2660  }
2661 
2662  /* Update the partition offset and set the extended offset if needed */
2663  Offset = NextOffset;
2664  if (IsMbr) ExtendedOffset = NextOffset;
2665  }
2666 
2667  /* If we had a buffer, free it, then return status */
2669  return Status;
2670 }
#define TAG_FILE_SYSTEM
Definition: tag.h:50
#define max(a, b)
Definition: svc.c:63
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PFCB _In_ LONGLONG StartingOffset
Definition: cdprocs.h:290
struct _Entry Entry
Definition: kefuncs.h:627
Definition: hal.h:331
struct _PTE * PPTE
PIRP NTAPI IoBuildSynchronousFsdRequest(IN ULONG MajorFunction, IN PDEVICE_OBJECT DeviceObject, IN PVOID Buffer, IN ULONG Length, IN PLARGE_INTEGER StartingOffset, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:1069
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
VOID NTAPI HalpCalculateChsValues(IN PLARGE_INTEGER PartitionOffset, IN PLARGE_INTEGER PartitionLength, IN CCHAR ShiftCount, IN ULONG SectorsPerTrack, IN ULONG NumberOfTracks, IN ULONG ConventionalCylinders, OUT PPARTITION_DESCRIPTOR PartitionDescriptor)
Definition: disksup.c:1481
LONG NTSTATUS
Definition: precomp.h:26
#define PARTITION_TABLE_OFFSET
Definition: hal.h:243
#define IsContainerPartition(PartitionType)
Definition: ntdddisk.h:250
_In_ ULONG _In_ ULONG _In_ ULONG NumberOfHeads
Definition: iofuncs.h:2066
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
struct _DISK_LAYOUT * PDISK_LAYOUT
PARTITION_INFORMATION PartitionEntry[4]
Definition: hal.h:318
#define PARTITION_ENTRY_UNUSED
Definition: disk.h:86
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_In_ ULONG _In_ ULONG SectorsPerTrack
Definition: iofuncs.h:2066
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:437
_In_ ULONG _In_ BOOLEAN _Out_ struct _DRIVE_LAYOUT_INFORMATION ** PartitionBuffer
Definition: iofuncs.h:2048
#define SectorOffset(L)
Definition: cdprocs.h:1622
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define SL_OVERRIDE_VERIFY_VOLUME
Definition: iotypes.h:1782
Definition: bufpool.h:45
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
int64_t LONGLONG
Definition: typedefs.h:67
#define BOOT_RECORD_SIGNATURE
Definition: parttest.c:17
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
char CCHAR
Definition: typedefs.h:51
ULONG TableCount
Definition: hal.h:323
_In_ ULONG _In_ struct _SET_PARTITION_INFORMATION_EX * PartitionInfo
Definition: iofuncs.h:2101
#define BufferSize
Definition: classpnp.h:419
PARTITION_TABLE PartitionTable[1]
Definition: hal.h:325
#define PARTITION_FAT_16
Definition: disk.h:90
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
unsigned char UCHAR
Definition: xmlstorage.h:181
#define BOOT_SIGNATURE_OFFSET
Definition: hal.h:244
ULONG LowPart
Definition: typedefs.h:105
#define PAGE_SIZE
Definition: env_spec_w32.h:49
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2647
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1569
VOID FASTCALL xHalGetPartialGeometry(IN PDEVICE_OBJECT DeviceObject, IN PULONG ConventionalCylinders, IN PLONGLONG DiskSize)
Definition: disksup.c:1556
BOOLEAN IsSuperFloppy(IN PDISKENTRY DiskEntry)
Definition: partlist.c:680
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
unsigned int * PULONG
Definition: retypes.h:1
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
_Must_inspect_result_ typedef _In_ ULONG TableEntry
Definition: iotypes.h:3949
#define IRP_MJ_READ
Definition: rdpdr.c:46
#define BOOLEAN
Definition: pedump.c:73
CHAR PartitionType
Definition: part_xbox.c:32
ret QuadPart
Definition: rtlfuncs.h:3091
unsigned int ULONG
Definition: retypes.h:1
VOID FASTCALL HalExamineMBR(IN PDEVICE_OBJECT DeviceObject, IN ULONG SectorSize, IN ULONG MbrTypeIdentifier, OUT PVOID *MbrBuffer)
Definition: disksup.c:2679
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
_In_ ULONG SectorSize
Definition: halfuncs.h:291
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
return STATUS_SUCCESS
Definition: btrfs.c:3014
int k
Definition: mpi.c:3369
unsigned short * PUSHORT
Definition: retypes.h:2
base of all file and directory entries
Definition: entries.h:82
LONGLONG QuadPart
Definition: typedefs.h:113
#define PAGED_CODE()

◆ xHalLocateHiberRanges()

VOID NTAPI xHalLocateHiberRanges ( IN PVOID  MemoryMap)

Definition at line 196 of file halstub.c.

197 {
198  /* Nothing */
199  return;
200 }

◆ xHalMirrorPhysicalMemory()

NTSTATUS NTAPI xHalMirrorPhysicalMemory ( IN PHYSICAL_ADDRESS  PhysicalAddress,
IN LARGE_INTEGER  NumberOfBytes 
)

Definition at line 153 of file halstub.c.

155 {
156  return STATUS_NOT_SUPPORTED;
157 }
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409

◆ xHalQueryBusSlots()

NTSTATUS NTAPI xHalQueryBusSlots ( IN PBUS_HANDLER  BusHandler,
IN ULONG  BufferSize,
OUT PULONG  SlotNumbers,
OUT PULONG  ReturnedLength 
)

Definition at line 161 of file halstub.c.

165 {
166  PAGED_CODE();
167 
168  return STATUS_NOT_SUPPORTED;
169 }
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
#define PAGED_CODE()

◆ xHalQuerySystemInformation()

NTSTATUS NTAPI xHalQuerySystemInformation ( IN HAL_QUERY_INFORMATION_CLASS  InformationClass,
IN ULONG  BufferSize,
IN OUT PVOID  Buffer,
OUT PULONG  ReturnedLength 
)

Definition at line 184 of file halstub.c.

188 {
189  PAGED_CODE();
190 
191  return STATUS_INVALID_LEVEL;
192 }
#define STATUS_INVALID_LEVEL
Definition: ntstatus.h:550
#define PAGED_CODE()

◆ xHalReferenceHandler()

VOID FASTCALL xHalReferenceHandler ( IN PBUS_HANDLER  BusHandler)

Definition at line 114 of file halstub.c.

115 {
116  /* Nothing */
117  return;
118 }

◆ xHalRegisterBusHandler()

NTSTATUS NTAPI xHalRegisterBusHandler ( IN INTERFACE_TYPE  InterfaceType,
IN BUS_DATA_TYPE  ConfigSpace,
IN ULONG  BusNumber,
IN INTERFACE_TYPE  ParentInterfaceType,
IN ULONG  ParentBusNumber,
IN ULONG  ContextSize,
IN PINSTALL_BUS_HANDLER  InstallCallback,
OUT PBUS_HANDLER BusHandler 
)

Definition at line 204 of file halstub.c.

212 {
213  PAGED_CODE();
214 
215  return STATUS_NOT_SUPPORTED;
216 }
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
#define PAGED_CODE()

◆ xHalSetSystemInformation()

NTSTATUS NTAPI xHalSetSystemInformation ( IN HAL_SET_INFORMATION_CLASS  InformationClass,
IN ULONG  BufferSize,
IN PVOID  Buffer 
)

Definition at line 173 of file halstub.c.

176 {
177  PAGED_CODE();
178 
179  return STATUS_INVALID_LEVEL;
180 }
#define STATUS_INVALID_LEVEL
Definition: ntstatus.h:550
#define PAGED_CODE()

◆ xHalSetWakeAlarm()

VOID NTAPI xHalSetWakeAlarm ( IN ULONGLONG  AlartTime,
IN PTIME_FIELDS  TimeFields 
)

Definition at line 220 of file halstub.c.

222 {
223  /* Nothing */
224  return;
225 }

◆ xHalSetWakeEnable()

VOID NTAPI xHalSetWakeEnable ( IN BOOLEAN  Enable)

Definition at line 98 of file halstub.c.

99 {
100  /* Nothing */
101  return;
102 }

◆ xHalStartMirroring()

NTSTATUS NTAPI xHalStartMirroring ( VOID  )

Definition at line 137 of file halstub.c.

138 {
139  PAGED_CODE();
140 
141  return STATUS_NOT_SUPPORTED;
142 }
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
#define PAGED_CODE()

◆ xHalTranslateBusAddress()

BOOLEAN NTAPI xHalTranslateBusAddress ( IN INTERFACE_TYPE  InterfaceType,
IN ULONG  BusNumber,
IN PHYSICAL_ADDRESS  BusAddress,
IN OUT PULONG  AddressSpace,
OUT PPHYSICAL_ADDRESS  TranslatedAddress 
)

Definition at line 229 of file halstub.c.

234 {
235  KeBugCheckEx(HAL_INITIALIZATION_FAILED, 0, 0, 0, 0);
236 
237  return FALSE;
238 }
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:108

◆ xHalVectorToIDTEntry()

UCHAR NTAPI xHalVectorToIDTEntry ( IN ULONG  Vector)

Definition at line 33 of file halstub.c.

34 {
35  /* Return the vector */
36  return (UCHAR)Vector;
37 }
unsigned char UCHAR
Definition: xmlstorage.h:181
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID _In_opt_ PKSPIN_LOCK _In_ ULONG Vector
Definition: iofuncs.h:798

◆ xKdGetAcpiTablePhase()

PVOID NTAPI xKdGetAcpiTablePhase ( IN struct _LOADER_PARAMETER_BLOCK LoaderBlock,
IN ULONG  Signature 
)

Definition at line 269 of file halstub.c.

271 {
272  return NULL;
273 }
smooth NULL
Definition: ftsmooth.c:416

◆ xKdReleasePciDeviceForDebugging()

NTSTATUS NTAPI xKdReleasePciDeviceForDebugging ( IN OUT PDEBUG_DEVICE_DESCRIPTOR  PciDevice)

Definition at line 262 of file halstub.c.

263 {
264  return STATUS_NOT_IMPLEMENTED;
265 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225

◆ xKdSetupPciDeviceForDebugging()

NTSTATUS NTAPI xKdSetupPciDeviceForDebugging ( IN PVOID LoaderBlock  OPTIONAL,
IN OUT PDEBUG_DEVICE_DESCRIPTOR  PciDevice 
)

Definition at line 254 of file halstub.c.

256 {
257  return STATUS_NOT_IMPLEMENTED;
258 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225

◆ xKdUnmapVirtualAddress()

VOID NTAPI xKdUnmapVirtualAddress ( IN PVOID  VirtualAddress,
IN ULONG  NumberPages,
IN BOOLEAN  FlushCurrentTLB 
)

Definition at line 286 of file halstub.c.

289 {
290  /* Nothing */
291  return;
292 }