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++)
567 &Partitions->PartitionEntry[NbPartitions]))
569 Partitions->PartitionEntry[NbPartitions].PartitionNumber = NbPartitions + 1;
581 Partitions->PartitionCount = NbPartitions;
582 Partitions->Signature = MasterBootRecord->
Signature;
#define MachDiskReadLogicalSectors(Drive, Start, Count, Buf)
return STATUS_NOT_SUPPORTED
USHORT MasterBootRecordMagic
static BOOLEAN DiskGetActivePartitionEntry(IN UCHAR DriveNumber, OUT PPARTITION_TABLE_ENTRY PartitionTableEntry, OUT PULONG ActivePartition)
VOID DiskDetectPartitionType(IN UCHAR DriveNumber)
NTSTATUS FASTCALL IoReadPartitionTable(IN PDEVICE_OBJECT DeviceObject, IN ULONG SectorSize, IN BOOLEAN ReturnRecognizedPartitions, OUT PDRIVE_LAYOUT_INFORMATION *PartitionBuffer)
DBG_DEFAULT_CHANNEL(DISK)
IN PVOID IN PVOID IN USHORT IN USHORT Size
BOOLEAN NTAPI IopCopyPartitionRecord(IN BOOLEAN ReturnRecognizedPartitions, IN ULONG SectorSize, IN PPARTITION_TABLE_ENTRY PartitionTableEntry, OUT PARTITION_INFORMATION *PartitionEntry)
_In_ ULONG _In_ ULONG PartitionNumber
ULONG SectorCountBeforePartition
struct _PARTITION_INFORMATION PARTITION_INFORMATION
_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
#define STATUS_IO_DEVICE_ERROR
#define PARTITION_ENTRY_UNUSED
static BOOLEAN DiskGetMbrPartitionEntry(IN UCHAR DriveNumber, IN ULONG PartitionNumber, OUT PPARTITION_TABLE_ENTRY PartitionTableEntry)
_In_ PDEVICE_OBJECT DeviceObject
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
#define FATX_DATA_PARTITION
_In_ ULONG _In_ BOOLEAN _Out_ struct _DRIVE_LAYOUT_INFORMATION ** PartitionBuffer
ULONG SectorCountBeforePartition
static BOOLEAN DiskGetFirstPartitionEntry(IN PMASTER_BOOT_RECORD MasterBootRecord, OUT PPARTITION_TABLE_ENTRY PartitionTableEntry)
static PARTITION_STYLE DiskPartitionType[MaxDriveNumber+1]
#define PARTITION_EXTENDED
NTSTATUS NTAPI IopReadBootRecord(IN PDEVICE_OBJECT DeviceObject, IN ULONGLONG LogicalSectorNumber, IN ULONG SectorSize, OUT PMASTER_BOOT_RECORD BootRecord)
#define NT_SUCCESS(StatCode)
static BOOLEAN DiskGetFirstExtendedPartitionEntry(IN PMASTER_BOOT_RECORD MasterBootRecord, OUT PPARTITION_TABLE_ENTRY PartitionTableEntry)
_In_ WDFCOLLECTION _In_ ULONG Index
static struct @149 XboxPartitions[]
BOOLEAN DiskGetPartitionEntry(IN UCHAR DriveNumber, IN ULONG PartitionNumber, OUT PPARTITION_TABLE_ENTRY PartitionTableEntry)
PARTITION_TABLE_ENTRY PartitionTable[4]
BOOLEAN DiskGetBootPartitionEntry(IN UCHAR DriveNumber, OUT PPARTITION_TABLE_ENTRY PartitionTableEntry, OUT PULONG BootPartition)
ARC_STATUS ArcRead(ULONG FileId, VOID *Buffer, ULONG N, ULONG *Count)
#define XBOX_SIGNATURE_SECTOR
#define ExAllocatePool(type, size)
ARC_STATUS ArcSeek(ULONG FileId, LARGE_INTEGER *Position, SEEKMODE SeekMode)
_In_ ULONG _In_ BOOLEAN ReturnRecognizedPartitions
enum _PARTITION_STYLE PARTITION_STYLE
static BOOLEAN DiskGetBrfrPartitionEntry(IN UCHAR DriveNumber, IN ULONG PartitionNumber, OUT PPARTITION_TABLE_ENTRY PartitionTableEntry)
#define PARTITION_XINT13_EXTENDED
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
ULONG PartitionSectorCount
static BOOLEAN DiskReadBootRecord(IN UCHAR DriveNumber, IN ULONGLONG LogicalSectorNumber, OUT PMASTER_BOOT_RECORD BootRecord)
#define FIELD_OFFSET(t, f)
#define RtlZeroMemory(Destination, Length)
#define RtlCopyMemory(Destination, Source, Length)
PARTITION_TABLE_ENTRY PartitionTable[4]