26#define MaxDriveNumber 0xFF
30#define XBOX_SIGNATURE_SECTOR 3
31#define XBOX_SIGNATURE ('B' | ('R' << 8) | ('F' << 16) | ('R' << 24))
34#define FATX_DATA_PARTITION 1
66 TRACE(
"Dumping partition table for drive 0x%x:\n", DriveNumber);
67 TRACE(
"Boot record logical start sector = %d\n", LogicalSectorNumber);
72 TRACE(
"-------------------------------------------\n");
74 TRACE(
"BootIndicator: 0x%x\n", BootRecord->PartitionTable[
Index].BootIndicator);
75 TRACE(
"StartHead: 0x%x\n", BootRecord->PartitionTable[
Index].StartHead);
76 TRACE(
"StartSector (Plus 2 cylinder bits): 0x%x\n", BootRecord->PartitionTable[
Index].StartSector);
77 TRACE(
"StartCylinder: 0x%x\n", BootRecord->PartitionTable[
Index].StartCylinder);
78 TRACE(
"SystemIndicator: 0x%x\n", BootRecord->PartitionTable[
Index].SystemIndicator);
79 TRACE(
"EndHead: 0x%x\n", BootRecord->PartitionTable[
Index].EndHead);
80 TRACE(
"EndSector (Plus 2 cylinder bits): 0x%x\n", BootRecord->PartitionTable[
Index].EndSector);
81 TRACE(
"EndCylinder: 0x%x\n", BootRecord->PartitionTable[
Index].EndCylinder);
82 TRACE(
"SectorCountBeforePartition: 0x%x\n", BootRecord->PartitionTable[
Index].SectorCountBeforePartition);
83 TRACE(
"PartitionSectorCount: 0x%x\n", BootRecord->PartitionTable[
Index].PartitionSectorCount);
87 return (BootRecord->MasterBootRecordMagic == 0xaa55);
139 ULONG BootablePartitionCount = 0;
140 ULONG CurrentPartitionNumber;
145 *ActivePartition = 0;
153 CurrentPartitionNumber = 0;
162 CurrentPartitionNumber++;
167 BootablePartitionCount++;
168 *ActivePartition = CurrentPartitionNumber;
172 ThisPartitionTableEntry,
179 if (BootablePartitionCount == 0)
181 ERR(
"No bootable (active) partitions found.\n");
184 else if (BootablePartitionCount != 1)
186 ERR(
"Too many bootable (active) partitions found.\n");
201 ULONG ExtendedPartitionNumber;
202 ULONG ExtendedPartitionOffset;
204 ULONG CurrentPartitionNumber;
213 CurrentPartitionNumber = 0;
222 CurrentPartitionNumber++;
237 ExtendedPartitionNumber =
PartitionNumber - CurrentPartitionNumber - 1;
244 ExtendedPartitionOffset = 0;
256 if (ExtendedPartitionOffset == 0)
319 ULONG PartitionCount = 0;
345 if (PartitionCount == 1 && GPTProtect)
357 TRACE(
"Drive 0x%X partition type Xbox-BRFR\n", DriveNumber);
363 TRACE(
"Drive 0x%X partition type unknown\n", DriveNumber);
380 FIXME(
"DiskGetBootPartitionEntry() unimplemented for GPT\n");
383 case PARTITION_STYLE_RAW:
385 FIXME(
"DiskGetBootPartitionEntry() unimplemented for RAW\n");
388 case PARTITION_STYLE_BRFR:
399 ERR(
"Drive 0x%X partition type = %d, should not happen!\n", DriveNumber,
DiskPartitionType[DriveNumber]);
420 FIXME(
"DiskGetPartitionEntry() unimplemented for GPT\n");
423 case PARTITION_STYLE_RAW:
425 FIXME(
"DiskGetPartitionEntry() unimplemented for RAW\n");
428 case PARTITION_STYLE_BRFR:
434 ERR(
"Drive 0x%X partition type = %d, should not happen!\n", DriveNumber,
DiskPartitionType[DriveNumber]);
481 PartitionEntry->StartingOffset.QuadPart = (
ULONGLONG)PartitionTableEntry->SectorCountBeforePartition *
SectorSize;
482 PartitionEntry->PartitionLength.QuadPart = (
ULONGLONG)PartitionTableEntry->PartitionSectorCount *
SectorSize;
483 PartitionEntry->HiddenSectors = 0;
484 PartitionEntry->PartitionNumber = 0;
485 PartitionEntry->PartitionType = PartitionTableEntry->SystemIndicator;
486 PartitionEntry->BootIndicator = (PartitionTableEntry->BootIndicator & 0x80) ?
TRUE :
FALSE;
487 PartitionEntry->RecognizedPartition = IsRecognized;
488 PartitionEntry->RewritePartition =
FALSE;
512 if (!MasterBootRecord)
532 for (
i = 0;
i < 4;
i++)
544 if (NbPartitions == 0)
562 for (
i = 0;
i < 4;
i++)
#define XBOX_SIGNATURE_SECTOR
static BOOLEAN DiskReadBootRecord(IN UCHAR DriveNumber, IN ULONGLONG LogicalSectorNumber, OUT PMASTER_BOOT_RECORD BootRecord)
#define FATX_DATA_PARTITION
static BOOLEAN DiskGetBrfrPartitionEntry(IN UCHAR DriveNumber, IN ULONG PartitionNumber, OUT PPARTITION_TABLE_ENTRY PartitionTableEntry)
BOOLEAN DiskGetPartitionEntry(IN UCHAR DriveNumber, IN ULONG PartitionNumber, OUT PPARTITION_TABLE_ENTRY PartitionTableEntry)
static BOOLEAN DiskGetActivePartitionEntry(IN UCHAR DriveNumber, OUT PPARTITION_TABLE_ENTRY PartitionTableEntry, OUT PULONG ActivePartition)
static struct @154 XboxPartitions[]
static PARTITION_STYLE DiskPartitionType[MaxDriveNumber+1]
BOOLEAN NTAPI IopCopyPartitionRecord(IN BOOLEAN ReturnRecognizedPartitions, IN ULONG SectorSize, IN PPARTITION_TABLE_ENTRY PartitionTableEntry, OUT PARTITION_INFORMATION *PartitionEntry)
static BOOLEAN DiskGetFirstPartitionEntry(IN PMASTER_BOOT_RECORD MasterBootRecord, OUT PPARTITION_TABLE_ENTRY PartitionTableEntry)
NTSTATUS NTAPI IopReadBootRecord(IN PDEVICE_OBJECT DeviceObject, IN ULONGLONG LogicalSectorNumber, IN ULONG SectorSize, OUT PMASTER_BOOT_RECORD BootRecord)
static BOOLEAN DiskGetMbrPartitionEntry(IN UCHAR DriveNumber, IN ULONG PartitionNumber, OUT PPARTITION_TABLE_ENTRY PartitionTableEntry)
BOOLEAN DiskGetBootPartitionEntry(IN UCHAR DriveNumber, OUT PPARTITION_TABLE_ENTRY PartitionTableEntry, OUT PULONG BootPartition)
static BOOLEAN DiskGetFirstExtendedPartitionEntry(IN PMASTER_BOOT_RECORD MasterBootRecord, OUT PPARTITION_TABLE_ENTRY PartitionTableEntry)
ULONG PartitionSectorCount
NTSTATUS FASTCALL IoReadPartitionTable(IN PDEVICE_OBJECT DeviceObject, IN ULONG SectorSize, IN BOOLEAN ReturnRecognizedPartitions, OUT PDRIVE_LAYOUT_INFORMATION *PartitionBuffer)
ULONG SectorCountBeforePartition
VOID DiskDetectPartitionType(IN UCHAR DriveNumber)
#define DBG_DEFAULT_CHANNEL(ch)
#define PARTITION_ENTRY_UNUSED
#define PARTITION_EXTENDED
#define PARTITION_XINT13_EXTENDED
ARC_STATUS ArcSeek(ULONG FileId, LARGE_INTEGER *Position, SEEKMODE SeekMode)
ARC_STATUS ArcRead(ULONG FileId, VOID *Buffer, ULONG N, ULONG *Count)
#define MachDiskReadLogicalSectors(Drive, Start, Count, Buf)
#define NT_SUCCESS(StatCode)
#define ExAllocatePool(type, size)
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
enum _PARTITION_STYLE PARTITION_STYLE
struct _PARTITION_INFORMATION PARTITION_INFORMATION
#define STATUS_NOT_SUPPORTED
PARTITION_TABLE_ENTRY PartitionTable[4]
ULONG SectorCountBeforePartition
USHORT MasterBootRecordMagic
PARTITION_TABLE_ENTRY PartitionTable[4]
#define FIELD_OFFSET(t, f)
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
#define STATUS_IO_DEVICE_ERROR
_In_ WDFCOLLECTION _In_ ULONG Index
_In_ PDEVICE_OBJECT DeviceObject
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesRead
_In_ ULONG _In_ BOOLEAN ReturnRecognizedPartitions
_In_ ULONG _In_ BOOLEAN _Out_ struct _DRIVE_LAYOUT_INFORMATION ** PartitionBuffer
_In_ ULONG _In_ ULONG PartitionNumber