ReactOS 0.4.16-dev-751-g45ed1a9
disk.h File Reference
#include <reactos/rosioctl.h>
#include <pshpack1.h>
#include <poppack.h>
Include dependency graph for disk.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _GEOMETRY
 
struct  _EXTENDED_GEOMETRY
 
struct  _PARTITION_TABLE_ENTRY
 
struct  _MASTER_BOOT_RECORD
 

Macros

#define PARTITION_ENTRY_UNUSED   0x00
 
#define PARTITION_FAT_12   0x01
 
#define PARTITION_XENIX_1   0x02
 
#define PARTITION_XENIX_2   0x03
 
#define PARTITION_FAT_16   0x04
 
#define PARTITION_EXTENDED   0x05
 
#define PARTITION_HUGE   0x06
 
#define PARTITION_IFS   0x07
 
#define PARTITION_OS2BOOTMGR   0x0A
 
#define PARTITION_FAT32   0x0B
 
#define PARTITION_FAT32_XINT13   0x0C
 
#define PARTITION_XINT13   0x0E
 
#define PARTITION_XINT13_EXTENDED   0x0F
 
#define PARTITION_NTFS   0x17
 
#define PARTITION_PREP   0x41
 
#define PARTITION_LDM   0x42
 
#define PARTITION_UNIX   0x63
 
#define VALID_NTFT   0xC0
 
#define PARTITION_NTFT   0x80
 
#define PARTITION_GPT   0xEE
 

Typedefs

typedef struct _GEOMETRY GEOMETRY
 
typedef struct _GEOMETRYPGEOMETRY
 
typedef struct _EXTENDED_GEOMETRY EXTENDED_GEOMETRY
 
typedef struct _EXTENDED_GEOMETRYPEXTENDED_GEOMETRY
 
typedef struct _PARTITION_TABLE_ENTRY PARTITION_TABLE_ENTRY
 
typedef struct _PARTITION_TABLE_ENTRYPPARTITION_TABLE_ENTRY
 
typedef struct _MASTER_BOOT_RECORD MASTER_BOOT_RECORD
 
typedef struct _MASTER_BOOT_RECORDPMASTER_BOOT_RECORD
 

Functions

VOID DiskDetectPartitionType (IN UCHAR DriveNumber)
 
BOOLEAN DiskGetBootPartitionEntry (IN UCHAR DriveNumber, OUT PPARTITION_TABLE_ENTRY PartitionTableEntry, OUT PULONG BootPartition)
 
BOOLEAN DiskGetPartitionEntry (IN UCHAR DriveNumber, IN ULONG PartitionNumber, OUT PPARTITION_TABLE_ENTRY PartitionTableEntry)
 
ULONG LoadBootDeviceDriver (VOID)
 
PCCHAR FrLdrGetBootPath (VOID)
 
UCHAR FrldrGetBootDrive (VOID)
 
ULONG FrldrGetBootPartition (VOID)
 

Variables

PVOID DiskReadBuffer
 
SIZE_T DiskReadBufferSize
 
CCHAR FrLdrBootPath [MAX_PATH]
 

Macro Definition Documentation

◆ PARTITION_ENTRY_UNUSED

#define PARTITION_ENTRY_UNUSED   0x00

Definition at line 87 of file disk.h.

◆ PARTITION_EXTENDED

#define PARTITION_EXTENDED   0x05

Definition at line 92 of file disk.h.

◆ PARTITION_FAT32

#define PARTITION_FAT32   0x0B

Definition at line 96 of file disk.h.

◆ PARTITION_FAT32_XINT13

#define PARTITION_FAT32_XINT13   0x0C

Definition at line 97 of file disk.h.

◆ PARTITION_FAT_12

#define PARTITION_FAT_12   0x01

Definition at line 88 of file disk.h.

◆ PARTITION_FAT_16

#define PARTITION_FAT_16   0x04

Definition at line 91 of file disk.h.

◆ PARTITION_GPT

#define PARTITION_GPT   0xEE

Definition at line 106 of file disk.h.

◆ PARTITION_HUGE

#define PARTITION_HUGE   0x06

Definition at line 93 of file disk.h.

◆ PARTITION_IFS

#define PARTITION_IFS   0x07

Definition at line 94 of file disk.h.

◆ PARTITION_LDM

#define PARTITION_LDM   0x42

Definition at line 102 of file disk.h.

◆ PARTITION_NTFS

#define PARTITION_NTFS   0x17

Definition at line 100 of file disk.h.

◆ PARTITION_NTFT

#define PARTITION_NTFT   0x80

Definition at line 105 of file disk.h.

◆ PARTITION_OS2BOOTMGR

#define PARTITION_OS2BOOTMGR   0x0A

Definition at line 95 of file disk.h.

◆ PARTITION_PREP

#define PARTITION_PREP   0x41

Definition at line 101 of file disk.h.

◆ PARTITION_UNIX

#define PARTITION_UNIX   0x63

Definition at line 103 of file disk.h.

◆ PARTITION_XENIX_1

#define PARTITION_XENIX_1   0x02

Definition at line 89 of file disk.h.

◆ PARTITION_XENIX_2

#define PARTITION_XENIX_2   0x03

Definition at line 90 of file disk.h.

◆ PARTITION_XINT13

#define PARTITION_XINT13   0x0E

Definition at line 98 of file disk.h.

◆ PARTITION_XINT13_EXTENDED

#define PARTITION_XINT13_EXTENDED   0x0F

Definition at line 99 of file disk.h.

◆ VALID_NTFT

#define VALID_NTFT   0xC0

Definition at line 104 of file disk.h.

Typedef Documentation

◆ EXTENDED_GEOMETRY

◆ GEOMETRY

◆ MASTER_BOOT_RECORD

◆ PARTITION_TABLE_ENTRY

◆ PEXTENDED_GEOMETRY

◆ PGEOMETRY

◆ PMASTER_BOOT_RECORD

◆ PPARTITION_TABLE_ENTRY

Function Documentation

◆ DiskDetectPartitionType()

VOID DiskDetectPartitionType ( IN UCHAR  DriveNumber)

Definition at line 314 of file partition.c.

316{
317 MASTER_BOOT_RECORD MasterBootRecord;
318 ULONG Index;
319 ULONG PartitionCount = 0;
320 PPARTITION_TABLE_ENTRY ThisPartitionTableEntry;
321 BOOLEAN GPTProtect = FALSE;
322 PARTITION_TABLE_ENTRY PartitionTableEntry;
323
324 /* Probe for Master Boot Record */
325 if (DiskReadBootRecord(DriveNumber, 0, &MasterBootRecord))
326 {
328
329 /* Check for GUID Partition Table */
330 for (Index = 0; Index < 4; Index++)
331 {
332 ThisPartitionTableEntry = &MasterBootRecord.PartitionTable[Index];
333
334 if (ThisPartitionTableEntry->SystemIndicator != PARTITION_ENTRY_UNUSED)
335 {
336 PartitionCount++;
337
338 if (Index == 0 && ThisPartitionTableEntry->SystemIndicator == PARTITION_GPT)
339 {
340 GPTProtect = TRUE;
341 }
342 }
343 }
344
345 if (PartitionCount == 1 && GPTProtect)
346 {
348 }
349 TRACE("Drive 0x%X partition type %s\n", DriveNumber, DiskPartitionType[DriveNumber] == PARTITION_STYLE_MBR ? "MBR" : "GPT");
350 return;
351 }
352
353 /* Probe for Xbox-BRFR partitioning */
354 if (DiskGetBrfrPartitionEntry(DriveNumber, FATX_DATA_PARTITION, &PartitionTableEntry))
355 {
356 DiskPartitionType[DriveNumber] = PARTITION_STYLE_BRFR;
357 TRACE("Drive 0x%X partition type Xbox-BRFR\n", DriveNumber);
358 return;
359 }
360
361 /* Failed to detect partitions, assume partitionless disk */
362 DiskPartitionType[DriveNumber] = PARTITION_STYLE_RAW;
363 TRACE("Drive 0x%X partition type unknown\n", DriveNumber);
364}
unsigned char BOOLEAN
static BOOLEAN DiskReadBootRecord(IN UCHAR DriveNumber, IN ULONGLONG LogicalSectorNumber, OUT PMASTER_BOOT_RECORD BootRecord)
Definition: partition.c:52
#define FATX_DATA_PARTITION
Definition: partition.c:34
static BOOLEAN DiskGetBrfrPartitionEntry(IN UCHAR DriveNumber, IN ULONG PartitionNumber, OUT PPARTITION_TABLE_ENTRY PartitionTableEntry)
Definition: partition.c:285
static PARTITION_STYLE DiskPartitionType[MaxDriveNumber+1]
Definition: partition.c:27
#define PARTITION_ENTRY_UNUSED
Definition: disk.h:87
#define PARTITION_GPT
Definition: disk.h:106
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
@ PARTITION_STYLE_GPT
Definition: imports.h:202
@ PARTITION_STYLE_MBR
Definition: imports.h:201
#define TRACE(s)
Definition: solgame.cpp:4
PARTITION_TABLE_ENTRY PartitionTable[4]
Definition: parttest.c:92
Definition: parttest.c:75
Definition: disk.h:56
UCHAR SystemIndicator
Definition: disk.h:62
uint32_t ULONG
Definition: typedefs.h:59
_In_ WDFCOLLECTION _In_ ULONG Index

Referenced by GetHarddiskInformation().

◆ DiskGetBootPartitionEntry()

BOOLEAN DiskGetBootPartitionEntry ( IN UCHAR  DriveNumber,
OUT PPARTITION_TABLE_ENTRY  PartitionTableEntry,
OUT PULONG  BootPartition 
)

Definition at line 367 of file partition.c.

371{
372 switch (DiskPartitionType[DriveNumber])
373 {
375 {
376 return DiskGetActivePartitionEntry(DriveNumber, PartitionTableEntry, BootPartition);
377 }
379 {
380 FIXME("DiskGetBootPartitionEntry() unimplemented for GPT\n");
381 return FALSE;
382 }
383 case PARTITION_STYLE_RAW:
384 {
385 FIXME("DiskGetBootPartitionEntry() unimplemented for RAW\n");
386 return FALSE;
387 }
388 case PARTITION_STYLE_BRFR:
389 {
390 if (DiskGetBrfrPartitionEntry(DriveNumber, FATX_DATA_PARTITION, PartitionTableEntry))
391 {
392 *BootPartition = FATX_DATA_PARTITION;
393 return TRUE;
394 }
395 return FALSE;
396 }
397 default:
398 {
399 ERR("Drive 0x%X partition type = %d, should not happen!\n", DriveNumber, DiskPartitionType[DriveNumber]);
400 ASSERT(FALSE);
401 }
402 }
403 return FALSE;
404}
#define FIXME(fmt,...)
Definition: precomp.h:53
#define ERR(fmt,...)
Definition: precomp.h:57
static BOOLEAN DiskGetActivePartitionEntry(IN UCHAR DriveNumber, OUT PPARTITION_TABLE_ENTRY PartitionTableEntry, OUT PULONG ActivePartition)
Definition: partition.c:134
#define ASSERT(a)
Definition: mode.c:44

Referenced by DiskGetBootPath().

◆ DiskGetPartitionEntry()

BOOLEAN DiskGetPartitionEntry ( IN UCHAR  DriveNumber,
IN ULONG  PartitionNumber,
OUT PPARTITION_TABLE_ENTRY  PartitionTableEntry 
)

Definition at line 407 of file partition.c.

411{
412 switch (DiskPartitionType[DriveNumber])
413 {
415 {
416 return DiskGetMbrPartitionEntry(DriveNumber, PartitionNumber, PartitionTableEntry);
417 }
419 {
420 FIXME("DiskGetPartitionEntry() unimplemented for GPT\n");
421 return FALSE;
422 }
423 case PARTITION_STYLE_RAW:
424 {
425 FIXME("DiskGetPartitionEntry() unimplemented for RAW\n");
426 return FALSE;
427 }
428 case PARTITION_STYLE_BRFR:
429 {
430 return DiskGetBrfrPartitionEntry(DriveNumber, PartitionNumber, PartitionTableEntry);
431 }
432 default:
433 {
434 ERR("Drive 0x%X partition type = %d, should not happen!\n", DriveNumber, DiskPartitionType[DriveNumber]);
435 ASSERT(FALSE);
436 }
437 }
438 return FALSE;
439}
static BOOLEAN DiskGetMbrPartitionEntry(IN UCHAR DriveNumber, IN ULONG PartitionNumber, OUT PPARTITION_TABLE_ENTRY PartitionTableEntry)
Definition: partition.c:194
_In_ ULONG _In_ ULONG PartitionNumber
Definition: iofuncs.h:2061

Referenced by DiskOpen(), GetHarddiskInformation(), and UefiDiskOpen().

◆ FrldrGetBootDrive()

UCHAR FrldrGetBootDrive ( VOID  )

Definition at line 201 of file freeldr.c.

202{
203 return FrldrBootDrive;
204}
UCHAR FrldrBootDrive
Definition: uefidisk.c:47

◆ FrldrGetBootPartition()

ULONG FrldrGetBootPartition ( VOID  )

Definition at line 206 of file freeldr.c.

207{
208 return FrldrBootPartition;
209}
ULONG FrldrBootPartition
Definition: uefidisk.c:48

◆ FrLdrGetBootPath()

PCCHAR FrLdrGetBootPath ( VOID  )

Definition at line 196 of file freeldr.c.

197{
198 return FrLdrBootPath;
199}
CCHAR FrLdrBootPath[MAX_PATH]
Definition: freeldr.c:29

Referenced by BuildArgvForOsLoader(), and LoadBootDeviceDriver().

◆ LoadBootDeviceDriver()

ULONG LoadBootDeviceDriver ( VOID  )

Definition at line 1635 of file scsiport.c.

1636{
1637 PLDR_DATA_TABLE_ENTRY BootDdDTE;
1638 CHAR NtBootDdPath[MAX_PATH];
1639 PVOID ImageBase = NULL;
1642
1643 // FIXME: Must be done *INSIDE* the HAL!
1644#ifdef _M_IX86
1647#endif
1648
1649 /* Create full ntbootdd.sys path */
1650 strcpy(NtBootDdPath, FrLdrGetBootPath());
1651 strcat(NtBootDdPath, "\\NTBOOTDD.SYS");
1652
1653 /* Load ntbootdd.sys */
1654 Success = PeLdrLoadBootImage(NtBootDdPath,
1655 "ntbootdd.sys",
1656 ImageBase,
1657 &BootDdDTE);
1658 if (!Success)
1659 {
1660 /* That's OK, file simply doesn't exist */
1661 return ESUCCESS;
1662 }
1663
1664 /* Call the entrypoint */
1665 EntryPoint = VaToPa(BootDdDTE->EntryPoint);
1666 (*EntryPoint)(NULL, NULL);
1667
1668 return ESUCCESS;
1669}
VOID NTAPI HalpInitBusHandler(VOID)
Definition: bushndlr.c:444
VOID NTAPI HalpInitializePciStubs(VOID)
Definition: pcibus.c:1190
FORCEINLINE PVOID VaToPa(PVOID Va)
Definition: conversion.h:15
#define NULL
Definition: types.h:112
#define MAX_PATH
Definition: compat.h:34
@ Success
Definition: eventcreate.c:712
PCCHAR FrLdrGetBootPath(VOID)
Definition: freeldr.c:196
BOOLEAN PeLdrLoadBootImage(_In_ PCSTR FilePath, _In_ PCSTR BaseDllName, _Out_ PVOID *ImageBase, _Out_ PLDR_DATA_TABLE_ENTRY *DataTableEntry)
Definition: peloader.c:1052
@ ESUCCESS
Definition: arc.h:32
strcat
Definition: string.h:92
strcpy
Definition: string.h:131
Definition: btrfs_drv.h:1876
PVOID EntryPoint
Definition: ntddk_ex.h:203
#define NTAPI
Definition: typedefs.h:36
#define IN
Definition: typedefs.h:39
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
char CHAR
Definition: xmlstorage.h:175

Referenced by RunLoader().

Variable Documentation

◆ DiskReadBuffer

◆ DiskReadBufferSize

SIZE_T DiskReadBufferSize
extern

◆ FrLdrBootPath