40 static const CHAR Hex[] =
"0123456789abcdef";
92 ERR(
"DiskOpen(): DiskReadBufferSize is 0, something is wrong.\n");
100 if (DrivePartition == 0xff)
116 if (DrivePartition != 0xff && DrivePartition != 0)
132 ERR(
"SectorSize (%lu) != Geometry.BytesPerSector (%lu), expect problems!\n",
144 Context->DriveNumber = DriveNumber;
159 ULONG Length, TotalSectors, MaxSectors, ReadSectors;
165 TotalSectors = (N +
Context->SectorSize - 1) /
Context->SectorSize;
177 ReadSectors = TotalSectors;
178 if (ReadSectors > MaxSectors)
179 ReadSectors = MaxSectors;
197 TotalSectors -= ReadSectors;
273 ERR(
"Reading MBR failed\n");
275 sprintf(Identifier,
"BIOSDISK%d", DriveNumber - 0x80 + 1);
287 for (
i = 0;
i < 512 /
sizeof(
ULONG);
i++)
291 Checksum = ~Checksum + 1;
292 TRACE(
"Checksum: %x\n", Checksum);
297 sprintf(ArcName,
"multi(0)disk(0)rdisk(%u)", DriveNumber - 0x80);
300 sprintf(ArcName,
"multi(0)disk(0)rdisk(%u)partition(0)", DriveNumber - 0x80);
310 sprintf(ArcName,
"multi(0)disk(0)rdisk(%u)partition(%lu)", DriveNumber - 0x80,
i);
318 Identifier[0] =
Hex[(Checksum >> 28) & 0x0F];
319 Identifier[1] =
Hex[(Checksum >> 24) & 0x0F];
320 Identifier[2] =
Hex[(Checksum >> 20) & 0x0F];
321 Identifier[3] =
Hex[(Checksum >> 16) & 0x0F];
322 Identifier[4] =
Hex[(Checksum >> 12) & 0x0F];
323 Identifier[5] =
Hex[(Checksum >> 8) & 0x0F];
324 Identifier[6] =
Hex[(Checksum >> 4) & 0x0F];
325 Identifier[7] =
Hex[Checksum & 0x0F];
335 Identifier[17] =
'-';
336 Identifier[18] = (ValidPartitionTable ?
'A' :
'X');
338 TRACE(
"Identifier: %s\n", Identifier);
344 UCHAR DiskCount, DriveNumber;
348 *BootDriveReported =
FALSE;
374 TRACE(
"BIOS reports success for disk %d (0x%02X) but data didn't change\n",
375 (
int)DiskCount, DriveNumber);
384 *BootDriveReported =
TRUE;
393 TRACE(
"BIOS reports %d harddisk%s\n",
394 (
int)DiskCount, (DiskCount == 1) ?
"" :
"s");
409 if ((DriveNumber >= 0x80) || (DriveNumber == 0x49))
455 ERR(
"Failed to get boot partition entry\n");
462 "multi(0)disk(0)rdisk(%u)partition(%lu)",
495 ERR(
"Reading MBR failed\n");
506 for (
i = 0;
i < 2048 /
sizeof(
ULONG);
i++)
510 Checksum = ~Checksum + 1;
511 TRACE(
"Checksum: %x\n", Checksum);
521 return (DiskCount != 0);
BOOLEAN DissectArcPath(IN PCSTR ArcPath, OUT PCSTR *Path OPTIONAL, OUT PUCHAR DriveNumber, OUT PULONG PartitionNumber)
#define MachDiskReadLogicalSectors(Drive, Start, Count, Buf)
static ARC_STATUS DiskSeek(ULONG FileId, LARGE_INTEGER *Position, SEEKMODE SeekMode)
USHORT MasterBootRecordMagic
_In_ ULONG _In_ ULONG _In_ ULONG Length
CCHAR FrLdrBootPath[MAX_PATH]
static ARC_STATUS DiskOpen(CHAR *Path, OPENMODE OpenMode, ULONG *FileId)
IN BOOLEAN OUT PSTR Buffer
ULONG PartitionSectorCount
VOID DiskDetectPartitionType(IN UCHAR DriveNumber)
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
ULONG SectorCountBeforePartition
_In_ WDFREQUEST _In_ NTSTATUS _In_ ULONG_PTR Information
VOID * FsGetDeviceSpecific(ULONG FileId)
static VOID GetHarddiskInformation(UCHAR DriveNumber)
NTSTRSAFEAPI RtlStringCbCopyA(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCSTR pszSrc)
#define PARTITION_ENTRY_UNUSED
#define sprintf(buf, format,...)
PCHAR GetHarddiskIdentifier(UCHAR DriveNumber)
BOOLEAN PcInitializeBootDevices(VOID)
FORCEINLINE PVOID FrLdrTempAlloc(_In_ SIZE_T Size, _In_ ULONG Tag)
#define MachDiskGetDriveGeometry(Drive, Geom)
static ARC_STATUS DiskGetFileInformation(ULONG FileId, FILEINFORMATION *Information)
NTSTRSAFEVAPI RtlStringCbPrintfA(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ _Printf_format_string_ NTSTRSAFE_PCSTR pszFormat,...)
static BOOLEAN DiskGetBootPath(BOOLEAN IsPxe)
static BOOLEAN DiskIsDriveRemovable(UCHAR DriveNumber)
static ARC_STATUS DiskClose(ULONG FileId)
struct tagDISKCONTEXT DISKCONTEXT
VOID FsSetDeviceSpecific(ULONG FileId, VOID *Specific)
static CHAR PcDiskIdentifier[32][20]
BOOLEAN DiskGetPartitionEntry(IN UCHAR DriveNumber, IN ULONG PartitionNumber, OUT PPARTITION_TABLE_ENTRY PartitionTableEntry)
SIZE_T DiskReadBufferSize
BOOLEAN DiskGetBootPartitionEntry(IN UCHAR DriveNumber, OUT PPARTITION_TABLE_ENTRY PartitionTableEntry, OUT PULONG BootPartition)
VOID FsRegisterDevice(CHAR *Prefix, const DEVVTBL *FuncTable)
VOID AddReactOSArcDiskInfo(IN PSTR ArcName, IN ULONG Signature, IN ULONG Checksum, IN BOOLEAN ValidPartitionTable)
static ARC_STATUS DiskRead(ULONG FileId, VOID *Buffer, ULONG N, ULONG *Count)
LONG DiskReportError(BOOLEAN bShowError)
PRTL_UNICODE_STRING_BUFFER Path
DBG_DEFAULT_CHANNEL(HWDETECT)
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
#define TAG_HW_DISK_CONTEXT
struct tagContext Context
struct _MASTER_BOOT_RECORD * PMASTER_BOOT_RECORD
#define RtlZeroMemory(Destination, Length)
#define RtlCopyMemory(Destination, Source, Length)
static UCHAR EnumerateHarddisks(OUT PBOOLEAN BootDriveReported)
static const WCHAR Signature[]
static const DEVVTBL DiskVtbl
FORCEINLINE VOID FrLdrTempFree(PVOID Allocation, ULONG Tag)