ReactOS  0.4.13-dev-249-gcba1a2f
partlist.c File Reference
#include "diskpart.h"
#include <ntddscsi.h>
#include <debug.h>
#include <pshpack1.h>
#include <poppack.h>
Include dependency graph for partlist.c:

Go to the source code of this file.

Classes

struct  _PARTITION
 
struct  _PARTITION_SECTOR
 

Macros

#define NDEBUG
 
#define InsertAscendingList(ListHead, NewEntry, Type, ListEntryField, SortField)
 
#define PARTITION_LINUX   0x83
 
#define PARTITION_TBL_SIZE   4
 
#define ROOT_NAME   L"\\Registry\\Machine\\HARDWARE\\DESCRIPTION\\System\\MultifunctionAdapter"
 

Typedefs

typedef struct _PARTITION PARTITION
 
typedef struct _PARTITIONPPARTITION
 
typedef struct _PARTITION_SECTOR PARTITION_SECTOR
 
typedef struct _PARTITION_SECTORPPARTITION_SECTOR
 

Functions

ULONGLONG AlignDown (IN ULONGLONG Value, IN ULONG Alignment)
 
static VOID GetDriverName (PDISKENTRY DiskEntry)
 
static NTSTATUS NTAPI DiskIdentifierQueryRoutine (PWSTR ValueName, ULONG ValueType, PVOID ValueData, ULONG ValueLength, PVOID Context, PVOID EntryContext)
 
static NTSTATUS NTAPI DiskConfigurationDataQueryRoutine (PWSTR ValueName, ULONG ValueType, PVOID ValueData, ULONG ValueLength, PVOID Context, PVOID EntryContext)
 
static NTSTATUS NTAPI SystemConfigurationDataQueryRoutine (PWSTR ValueName, ULONG ValueType, PVOID ValueData, ULONG ValueLength, PVOID Context, PVOID EntryContext)
 
static VOID EnumerateBiosDiskEntries (VOID)
 
static VOID AddPartitionToDisk (ULONG DiskNumber, PDISKENTRY DiskEntry, ULONG PartitionIndex, BOOLEAN LogicalPartition)
 
static VOID ScanForUnpartitionedDiskSpace (PDISKENTRY DiskEntry)
 
static VOID AddDiskToList (HANDLE FileHandle, ULONG DiskNumber)
 
NTSTATUS CreatePartitionList (VOID)
 
VOID DestroyPartitionList (VOID)
 

Variables

LIST_ENTRY DiskListHead
 
LIST_ENTRY BiosDiskListHead
 
PDISKENTRY CurrentDisk = NULL
 
PPARTENTRY CurrentPartition = NULL
 

Macro Definition Documentation

◆ InsertAscendingList

#define InsertAscendingList (   ListHead,
  NewEntry,
  Type,
  ListEntryField,
  SortField 
)
Value:
{\
PLIST_ENTRY current;\
\
current = (ListHead)->Flink;\
while (current != (ListHead))\
{\
if (CONTAINING_RECORD(current, Type, ListEntryField)->SortField >=\
(NewEntry)->SortField)\
{\
break;\
}\
current = current->Flink;\
}\
InsertTailList(current, &((NewEntry)->ListEntryField));\
}
Type
Definition: Type.h:6
#define InsertTailList(ListHead, Entry)
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct task_struct * current
Definition: linux.c:32

Definition at line 17 of file partlist.c.

◆ NDEBUG

#define NDEBUG

Definition at line 14 of file partlist.c.

◆ PARTITION_LINUX

#define PARTITION_LINUX   0x83

Definition at line 36 of file partlist.c.

◆ PARTITION_TBL_SIZE

#define PARTITION_TBL_SIZE   4

Definition at line 38 of file partlist.c.

◆ ROOT_NAME

#define ROOT_NAME   L"\\Registry\\Machine\\HARDWARE\\DESCRIPTION\\System\\MultifunctionAdapter"

Definition at line 248 of file partlist.c.

Typedef Documentation

◆ PARTITION

◆ PARTITION_SECTOR

◆ PPARTITION

◆ PPARTITION_SECTOR

Function Documentation

◆ AddDiskToList()

static VOID AddDiskToList ( HANDLE  FileHandle,
ULONG  DiskNumber 
)
static

Definition at line 758 of file partlist.c.

761 {
762  DISK_GEOMETRY DiskGeometry;
763  SCSI_ADDRESS ScsiAddress;
764  PDISKENTRY DiskEntry;
767  PPARTITION_SECTOR Mbr;
768  PULONG Buffer;
770  WCHAR Identifier[20];
771  ULONG Checksum;
773  ULONG i;
774  PLIST_ENTRY ListEntry;
775  PBIOSDISKENTRY BiosDiskEntry;
776  ULONG LayoutBufferSize;
777  PDRIVE_LAYOUT_INFORMATION NewLayoutBuffer;
778 
780  NULL,
781  NULL,
782  NULL,
783  &Iosb,
785  NULL,
786  0,
787  &DiskGeometry,
788  sizeof(DISK_GEOMETRY));
789  if (!NT_SUCCESS(Status))
790  {
791  return;
792  }
793 
794  if (DiskGeometry.MediaType != FixedMedia &&
795  DiskGeometry.MediaType != RemovableMedia)
796  {
797  return;
798  }
799 
801  NULL,
802  NULL,
803  NULL,
804  &Iosb,
806  NULL,
807  0,
808  &ScsiAddress,
809  sizeof(SCSI_ADDRESS));
810  if (!NT_SUCCESS(Status))
811  {
812  return;
813  }
814 
815  Mbr = (PARTITION_SECTOR*)RtlAllocateHeap(RtlGetProcessHeap(),
816  0,
817  DiskGeometry.BytesPerSector);
818  if (Mbr == NULL)
819  {
820  return;
821  }
822 
823  FileOffset.QuadPart = 0;
825  NULL,
826  NULL,
827  NULL,
828  &Iosb,
829  (PVOID)Mbr,
830  DiskGeometry.BytesPerSector,
831  &FileOffset,
832  NULL);
833  if (!NT_SUCCESS(Status))
834  {
835  RtlFreeHeap(RtlGetProcessHeap(), 0, Mbr);
836  DPRINT1("NtReadFile failed, status=%x\n", Status);
837  return;
838  }
839  Signature = Mbr->Signature;
840 
841  /* Calculate the MBR checksum */
842  Checksum = 0;
843  Buffer = (PULONG)Mbr;
844  for (i = 0; i < 128; i++)
845  {
846  Checksum += Buffer[i];
847  }
848  Checksum = ~Checksum + 1;
849 
850  swprintf(Identifier, L"%08x-%08x-A", Checksum, Signature);
851  DPRINT("Identifier: %S\n", Identifier);
852 
853  DiskEntry = RtlAllocateHeap(RtlGetProcessHeap(),
855  sizeof(DISKENTRY));
856  if (DiskEntry == NULL)
857  {
858  return;
859  }
860 
861 // DiskEntry->Checksum = Checksum;
862 // DiskEntry->Signature = Signature;
863  DiskEntry->BiosFound = FALSE;
864 
865  /* Check if this disk has a valid MBR */
866  if (Mbr->BootCode[0] == 0 && Mbr->BootCode[1] == 0)
867  DiskEntry->NoMbr = TRUE;
868  else
869  DiskEntry->NoMbr = FALSE;
870 
871  /* Free Mbr sector buffer */
872  RtlFreeHeap(RtlGetProcessHeap(), 0, Mbr);
873 
874  ListEntry = BiosDiskListHead.Flink;
875  while (ListEntry != &BiosDiskListHead)
876  {
877  BiosDiskEntry = CONTAINING_RECORD(ListEntry, BIOSDISKENTRY, ListEntry);
878  /* FIXME:
879  * Compare the size from bios and the reported size from driver.
880  * If we have more than one disk with a zero or with the same signatur
881  * we must create new signatures and reboot. After the reboot,
882  * it is possible to identify the disks.
883  */
884  if (BiosDiskEntry->Signature == Signature &&
885  BiosDiskEntry->Checksum == Checksum &&
886  !BiosDiskEntry->Recognized)
887  {
888  if (!DiskEntry->BiosFound)
889  {
890  DiskEntry->BiosDiskNumber = BiosDiskEntry->DiskNumber;
891  DiskEntry->BiosFound = TRUE;
892  BiosDiskEntry->Recognized = TRUE;
893  }
894  else
895  {
896  }
897  }
898  ListEntry = ListEntry->Flink;
899  }
900 
901  if (!DiskEntry->BiosFound)
902  {
903 #if 0
904  RtlFreeHeap(ProcessHeap, 0, DiskEntry);
905  return;
906 #else
907  DPRINT1("WARNING: Setup could not find a matching BIOS disk entry. Disk %d is not be bootable by the BIOS!\n", DiskNumber);
908 #endif
909  }
910 
913 
914  DiskEntry->Cylinders = DiskGeometry.Cylinders.QuadPart;
915  DiskEntry->TracksPerCylinder = DiskGeometry.TracksPerCylinder;
916  DiskEntry->SectorsPerTrack = DiskGeometry.SectorsPerTrack;
917  DiskEntry->BytesPerSector = DiskGeometry.BytesPerSector;
918 
919  DPRINT("Cylinders %I64u\n", DiskEntry->Cylinders);
920  DPRINT("TracksPerCylinder %I64u\n", DiskEntry->TracksPerCylinder);
921  DPRINT("SectorsPerTrack %I64u\n", DiskEntry->SectorsPerTrack);
922  DPRINT("BytesPerSector %I64u\n", DiskEntry->BytesPerSector);
923 
924  DiskEntry->SectorCount.QuadPart = DiskGeometry.Cylinders.QuadPart *
925  (ULONGLONG)DiskGeometry.TracksPerCylinder *
926  (ULONGLONG)DiskGeometry.SectorsPerTrack;
927 
928  DiskEntry->SectorAlignment = DiskGeometry.SectorsPerTrack;
929  DiskEntry->CylinderAlignment = DiskGeometry.SectorsPerTrack * DiskGeometry.TracksPerCylinder;
930 
931  DPRINT1("SectorCount: %I64u\n", DiskEntry->SectorCount);
932  DPRINT1("SectorAlignment: %lu\n", DiskEntry->SectorAlignment);
933  DPRINT1("CylinderAlignment: %lu\n", DiskEntry->CylinderAlignment);
934 
935  DiskEntry->DiskNumber = DiskNumber;
936  DiskEntry->Port = ScsiAddress.PortNumber;
937  DiskEntry->Bus = ScsiAddress.PathId;
938  DiskEntry->Id = ScsiAddress.TargetId;
939 
940  GetDriverName(DiskEntry);
941 
942  InsertAscendingList(&DiskListHead, DiskEntry, DISKENTRY, ListEntry, DiskNumber);
943 
944  /* Allocate a layout buffer with 4 partition entries first */
945  LayoutBufferSize = sizeof(DRIVE_LAYOUT_INFORMATION) +
946  ((4 - ANYSIZE_ARRAY) * sizeof(PARTITION_INFORMATION));
947  DiskEntry->LayoutBuffer = RtlAllocateHeap(RtlGetProcessHeap(),
949  LayoutBufferSize);
950  if (DiskEntry->LayoutBuffer == NULL)
951  {
952  DPRINT1("Failed to allocate the disk layout buffer!\n");
953  return;
954  }
955 
956  for (;;)
957  {
958  DPRINT1("Buffer size: %lu\n", LayoutBufferSize);
960  NULL,
961  NULL,
962  NULL,
963  &Iosb,
965  NULL,
966  0,
967  DiskEntry->LayoutBuffer,
968  LayoutBufferSize);
969  if (NT_SUCCESS(Status))
970  break;
971 
973  {
974  DPRINT1("NtDeviceIoControlFile() failed (Status: 0x%08lx)\n", Status);
975  return;
976  }
977 
978  LayoutBufferSize += 4 * sizeof(PARTITION_INFORMATION);
979  NewLayoutBuffer = RtlReAllocateHeap(RtlGetProcessHeap(),
981  DiskEntry->LayoutBuffer,
982  LayoutBufferSize);
983  if (NewLayoutBuffer == NULL)
984  {
985  DPRINT1("Failed to reallocate the disk layout buffer!\n");
986  return;
987  }
988 
989  DiskEntry->LayoutBuffer = NewLayoutBuffer;
990  }
991 
992  DPRINT1("PartitionCount: %lu\n", DiskEntry->LayoutBuffer->PartitionCount);
993 
994 #ifdef DUMP_PARTITION_TABLE
995  DumpPartitionTable(DiskEntry);
996 #endif
997 
998  if (DiskEntry->LayoutBuffer->PartitionEntry[0].StartingOffset.QuadPart != 0 &&
999  DiskEntry->LayoutBuffer->PartitionEntry[0].PartitionLength.QuadPart != 0 &&
1000  DiskEntry->LayoutBuffer->PartitionEntry[0].PartitionType != 0)
1001  {
1002  if ((DiskEntry->LayoutBuffer->PartitionEntry[0].StartingOffset.QuadPart / DiskEntry->BytesPerSector) % DiskEntry->SectorsPerTrack == 0)
1003  {
1004  DPRINT("Use %lu Sector alignment!\n", DiskEntry->SectorsPerTrack);
1005  }
1006  else if (DiskEntry->LayoutBuffer->PartitionEntry[0].StartingOffset.QuadPart % (1024 * 1024) == 0)
1007  {
1008  DPRINT1("Use megabyte (%lu Sectors) alignment!\n", (1024 * 1024) / DiskEntry->BytesPerSector);
1009  }
1010  else
1011  {
1012  DPRINT1("No matching alignment found! Partition 1 starts at %I64u\n", DiskEntry->LayoutBuffer->PartitionEntry[0].StartingOffset.QuadPart);
1013  }
1014  }
1015  else
1016  {
1017  DPRINT1("No valid partition table found! Use megabyte (%lu Sectors) alignment!\n", (1024 * 1024) / DiskEntry->BytesPerSector);
1018  }
1019 
1020 
1021  if (DiskEntry->LayoutBuffer->PartitionCount == 0)
1022  {
1023  DiskEntry->NewDisk = TRUE;
1024  DiskEntry->LayoutBuffer->PartitionCount = 4;
1025 
1026  for (i = 0; i < 4; i++)
1028  }
1029  else
1030  {
1031  for (i = 0; i < 4; i++)
1032  {
1033  AddPartitionToDisk(DiskNumber, DiskEntry, i, FALSE);
1034  }
1035 
1036  for (i = 4; i < DiskEntry->LayoutBuffer->PartitionCount; i += 4)
1037  {
1038  AddPartitionToDisk(DiskNumber, DiskEntry, i, TRUE);
1039  }
1040  }
1041 
1042  ScanForUnpartitionedDiskSpace(DiskEntry);
1043 }
UCHAR PathId
Definition: scsi_port.h:149
LIST_ENTRY DiskListHead
Definition: partlist.c:70
LIST_ENTRY PrimaryPartListHead
Definition: partlist.h:125
UCHAR PortNumber
Definition: scsi_port.h:148
USHORT Id
Definition: partlist.h:109
#define TRUE
Definition: types.h:120
LARGE_INTEGER PartitionLength
Definition: ntdddisk.h:394
#define IOCTL_SCSI_GET_ADDRESS
Definition: scsi_port.h:52
ULONG CylinderAlignment
Definition: partlist.h:93
LIST_ENTRY BiosDiskListHead
Definition: partlist.c:71
#define ANYSIZE_ARRAY
Definition: typedefs.h:45
USHORT Bus
Definition: partlist.h:108
ULONG Checksum
Definition: partlist.h:140
ULONG Signature
Definition: partlist.h:139
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:603
ULONG DiskNumber
Definition: partlist.h:105
ULONG BytesPerSector
Definition: ntdddisk.h:376
ULONG TracksPerCylinder
Definition: ntdddisk.h:374
NTSYSAPI NTSTATUS NTAPI NtDeviceIoControlFile(IN HANDLE hFile, IN HANDLE hEvent OPTIONAL, IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL, IN PVOID IoApcContext OPTIONAL, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG DeviceIoControlCode, IN PVOID InBuffer OPTIONAL, IN ULONG InBufferLength, OUT PVOID OutBuffer OPTIONAL, IN ULONG OutBufferLength)
struct _PARTITION_INFORMATION PARTITION_INFORMATION
NTSYSAPI PVOID WINAPI RtlReAllocateHeap(HANDLE, ULONG, PVOID, SIZE_T)
Definition: heap.c:2561
UCHAR TargetId
Definition: scsi_port.h:150
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
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
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
struct _DRIVE_LAYOUT_INFORMATION DRIVE_LAYOUT_INFORMATION
smooth NULL
Definition: ftsmooth.c:416
PARTITION_INFORMATION PartitionEntry[1]
Definition: ntdddisk.h:467
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
ULARGE_INTEGER SectorCount
Definition: partlist.h:91
ULONG SectorAlignment
Definition: partlist.h:92
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:585
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
BOOLEAN BiosFound
Definition: partlist.h:96
ULONG BytesPerSector
Definition: partlist.h:89
__wchar_t WCHAR
Definition: xmlstorage.h:180
return Iosb
Definition: create.c:4426
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
LARGE_INTEGER StartingOffset
Definition: ntdddisk.h:393
uint64_t ULONGLONG
Definition: typedefs.h:65
LARGE_INTEGER Cylinders
Definition: ntdddisk.h:372
ULONG SectorsPerTrack
Definition: ntdddisk.h:375
#define swprintf(buf, format,...)
Definition: sprintf.c:56
MEDIA_TYPE MediaType
Definition: ntdddisk.h:373
BOOLEAN RewritePartition
Definition: ntdddisk.h:400
static const WCHAR L[]
Definition: oid.c:1250
ULONG SectorsPerTrack
Definition: partlist.h:88
ULONG BiosDiskNumber
Definition: diskpart.h:147
Definition: typedefs.h:117
#define InsertAscendingList(ListHead, NewEntry, Type, ListEntryField, SortField)
Definition: partlist.c:17
ULONGLONG Cylinders
Definition: partlist.h:86
HANDLE ProcessHeap
Definition: servman.c:15
Status
Definition: gdiplustypes.h:24
#define IOCTL_DISK_GET_DRIVE_LAYOUT
Definition: ntdddisk.h:76
BOOLEAN Recognized
Definition: diskpart.h:127
ULONG DiskNumber
Definition: partlist.h:138
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:151
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
UCHAR BootCode[440]
Definition: partlist.h:195
static VOID GetDriverName(PDISKENTRY DiskEntry)
Definition: partlist.c:93
USHORT Port
Definition: partlist.h:107
unsigned int * PULONG
Definition: retypes.h:1
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
ULONG TracksPerCylinder
Definition: partlist.h:87
#define DPRINT1
Definition: precomp.h:8
LIST_ENTRY LogicalPartListHead
Definition: partlist.h:126
static VOID AddPartitionToDisk(ULONG DiskNumber, PDISKENTRY DiskEntry, ULONG PartitionIndex, BOOLEAN LogicalPartition)
Definition: partlist.c:392
unsigned int ULONG
Definition: retypes.h:1
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
static VOID ScanForUnpartitionedDiskSpace(PDISKENTRY DiskEntry)
Definition: partlist.c:502
static const WCHAR Signature[]
Definition: parser.c:141
PDRIVE_LAYOUT_INFORMATION LayoutBuffer
Definition: partlist.h:119
BOOLEAN NewDisk
Definition: partlist.h:114
#define IOCTL_DISK_GET_DRIVE_GEOMETRY
Definition: cdrw_usr.h:169
BOOLEAN NoMbr
Definition: diskpart.h:160
NTSTATUS NTAPI NtReadFile(HANDLE FileHandle, HANDLE Event, PIO_APC_ROUTINE ApcRoutine, PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, PVOID Buffer, ULONG Length, PLARGE_INTEGER ByteOffset, PULONG Key)
LONGLONG QuadPart
Definition: typedefs.h:112

Referenced by CreatePartitionList().

◆ AddPartitionToDisk()

static VOID AddPartitionToDisk ( ULONG  DiskNumber,
PDISKENTRY  DiskEntry,
ULONG  PartitionIndex,
BOOLEAN  LogicalPartition 
)
static

Definition at line 392 of file partlist.c.

397 {
399  PPARTENTRY PartEntry;
400 
401  PartitionInfo = &DiskEntry->LayoutBuffer->PartitionEntry[PartitionIndex];
402  if (PartitionInfo->PartitionType == 0 ||
403  (LogicalPartition == TRUE && IsContainerPartition(PartitionInfo->PartitionType)))
404  return;
405 
406  PartEntry = RtlAllocateHeap(RtlGetProcessHeap(),
408  sizeof(PARTENTRY));
409  if (PartEntry == NULL)
410  {
411  return;
412  }
413 
414  PartEntry->DiskEntry = DiskEntry;
415 
416  PartEntry->StartSector.QuadPart = (ULONGLONG)PartitionInfo->StartingOffset.QuadPart / DiskEntry->BytesPerSector;
417  PartEntry->SectorCount.QuadPart = (ULONGLONG)PartitionInfo->PartitionLength.QuadPart / DiskEntry->BytesPerSector;
418 
419  PartEntry->BootIndicator = PartitionInfo->BootIndicator;
420  PartEntry->PartitionType = PartitionInfo->PartitionType;
421  PartEntry->HiddenSectors = PartitionInfo->HiddenSectors;
422 
423  PartEntry->LogicalPartition = LogicalPartition;
424  PartEntry->IsPartitioned = TRUE;
425  PartEntry->PartitionNumber = PartitionInfo->PartitionNumber;
426  PartEntry->PartitionIndex = PartitionIndex;
427 
428  if (IsContainerPartition(PartEntry->PartitionType))
429  {
430  PartEntry->FormatState = Unformatted;
431 
432  if (LogicalPartition == FALSE && DiskEntry->ExtendedPartition == NULL)
433  DiskEntry->ExtendedPartition = PartEntry;
434  }
435  else if ((PartEntry->PartitionType == PARTITION_FAT_12) ||
436  (PartEntry->PartitionType == PARTITION_FAT_16) ||
437  (PartEntry->PartitionType == PARTITION_HUGE) ||
438  (PartEntry->PartitionType == PARTITION_XINT13) ||
439  (PartEntry->PartitionType == PARTITION_FAT32) ||
440  (PartEntry->PartitionType == PARTITION_FAT32_XINT13))
441  {
442 #if 0
443  if (CheckFatFormat())
444  {
445  PartEntry->FormatState = Preformatted;
446  }
447  else
448  {
449  PartEntry->FormatState = Unformatted;
450  }
451 #endif
452  PartEntry->FormatState = Preformatted;
453  }
454  else if (PartEntry->PartitionType == PARTITION_LINUX)
455  {
456 #if 0
457  if (CheckExt2Format())
458  {
459  PartEntry->FormatState = Preformatted;
460  }
461  else
462  {
463  PartEntry->FormatState = Unformatted;
464  }
465 #endif
466  PartEntry->FormatState = Preformatted;
467  }
468  else if (PartEntry->PartitionType == PARTITION_IFS)
469  {
470 #if 0
471  if (CheckNtfsFormat())
472  {
473  PartEntry->FormatState = Preformatted;
474  }
475  else if (CheckHpfsFormat())
476  {
477  PartEntry->FormatState = Preformatted;
478  }
479  else
480  {
481  PartEntry->FormatState = Unformatted;
482  }
483 #endif
484  PartEntry->FormatState = Preformatted;
485  }
486  else
487  {
488  PartEntry->FormatState = UnknownFormat;
489  }
490 
491  if (LogicalPartition)
493  &PartEntry->ListEntry);
494  else
496  &PartEntry->ListEntry);
497 }
LIST_ENTRY PrimaryPartListHead
Definition: partlist.h:125
#define PARTITION_FAT32
Definition: disk.h:95
ULONG PartitionNumber
Definition: partlist.h:49
ULARGE_INTEGER StartSector
Definition: partlist.h:42
#define TRUE
Definition: types.h:120
ULARGE_INTEGER SectorCount
Definition: partlist.h:43
#define IsContainerPartition(PartitionType)
Definition: ntdddisk.h:245
#define InsertTailList(ListHead, Entry)
#define PARTITION_XINT13
Definition: disk.h:97
PPARTENTRY ExtendedPartition
Definition: partlist.h:129
LIST_ENTRY ListEntry
Definition: partlist.h:36
BOOLEAN LogicalPartition
Definition: partlist.h:57
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
FORMATSTATE FormatState
Definition: partlist.h:55
#define PARTITION_HUGE
Definition: disk.h:92
smooth NULL
Definition: ftsmooth.c:416
PARTITION_INFORMATION PartitionEntry[1]
Definition: ntdddisk.h:467
#define PARTITION_IFS
Definition: disk.h:93
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:585
UCHAR PartitionType
Definition: partlist.h:46
struct _DISKENTRY * DiskEntry
Definition: partlist.h:39
ULONG BytesPerSector
Definition: partlist.h:89
uint64_t ULONGLONG
Definition: typedefs.h:65
_In_ ULONG _In_ struct _SET_PARTITION_INFORMATION_EX * PartitionInfo
Definition: iofuncs.h:2101
#define PARTITION_FAT_16
Definition: disk.h:90
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define PARTITION_LINUX
Definition: partlist.c:36
LIST_ENTRY LogicalPartListHead
Definition: partlist.h:126
BOOLEAN BootIndicator
Definition: partlist.h:45
#define PARTITION_FAT_12
Definition: disk.h:87
#define PARTITION_FAT32_XINT13
Definition: disk.h:96
PDRIVE_LAYOUT_INFORMATION LayoutBuffer
Definition: partlist.h:119
ULONG HiddenSectors
Definition: partlist.h:47
BOOLEAN IsPartitioned
Definition: partlist.h:60
ULONG PartitionIndex
Definition: partlist.h:50

Referenced by AddDiskToList().

◆ AlignDown()

ULONGLONG AlignDown ( IN ULONGLONG  Value,
IN ULONG  Alignment 
)

Definition at line 80 of file partlist.c.

83 {
84  ULONGLONG Temp;
85 
86  Temp = Value / Alignment;
87 
88  return Temp * Alignment;
89 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2327
union Alignment_ Alignment
uint64_t ULONGLONG
Definition: typedefs.h:65

◆ CreatePartitionList()

NTSTATUS CreatePartitionList ( VOID  )

Definition at line 1047 of file partlist.c.

1048 {
1052  ULONG ReturnSize;
1053  NTSTATUS Status;
1054  ULONG DiskNumber;
1058 
1059  CurrentDisk = NULL;
1061 
1062 // BootDisk = NULL;
1063 // BootPartition = NULL;
1064 
1065 // TempDisk = NULL;
1066 // TempPartition = NULL;
1067 // FormatState = Start;
1068 
1071 
1073 
1075  &Sdi,
1076  sizeof(SYSTEM_DEVICE_INFORMATION),
1077  &ReturnSize);
1078  if (!NT_SUCCESS(Status))
1079  {
1080  return Status;
1081  }
1082 
1083  for (DiskNumber = 0; DiskNumber < Sdi.NumberOfDisks; DiskNumber++)
1084  {
1085  swprintf(Buffer,
1086  L"\\Device\\Harddisk%d\\Partition0",
1087  DiskNumber);
1089  Buffer);
1090 
1092  &Name,
1093  0,
1094  NULL,
1095  NULL);
1096 
1100  &Iosb,
1103  if (NT_SUCCESS(Status))
1104  {
1105  AddDiskToList(FileHandle, DiskNumber);
1106 
1108  }
1109  }
1110 
1111 // UpdateDiskSignatures(List);
1112 
1113 // AssignDriveLetters(List);
1114 
1115  return STATUS_SUCCESS;
1116 }
LIST_ENTRY DiskListHead
Definition: partlist.c:70
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
NTSYSAPI NTSTATUS NTAPI NtQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInfoClass, OUT PVOID SystemInfoBuffer, IN ULONG SystemInfoBufferSize, OUT PULONG BytesReturned OPTIONAL)
PDISKENTRY CurrentDisk
Definition: partlist.c:73
LIST_ENTRY BiosDiskListHead
Definition: partlist.c:71
LONG NTSTATUS
Definition: precomp.h:26
#define FILE_SHARE_READ
Definition: compat.h:125
static VOID AddDiskToList(HANDLE FileHandle, ULONG DiskNumber)
Definition: partlist.c:758
HANDLE FileHandle
Definition: stats.c:38
static VOID EnumerateBiosDiskEntries(VOID)
Definition: partlist.c:252
#define FILE_READ_DATA
Definition: nt_native.h:628
struct NameRec_ * Name
Definition: cdprocs.h:464
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
NTSYSAPI NTSTATUS NTAPI NtOpenFile(OUT PHANDLE phFile, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG ShareMode, IN ULONG OpenMode)
Definition: file.c:3951
__wchar_t WCHAR
Definition: xmlstorage.h:180
return Iosb
Definition: create.c:4426
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define MAX_PATH
Definition: compat.h:26
#define swprintf(buf, format,...)
Definition: sprintf.c:56
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
#define FILE_READ_ATTRIBUTES
Definition: nt_native.h:647
static const WCHAR L[]
Definition: oid.c:1250
#define SYNCHRONIZE
Definition: nt_native.h:61
Status
Definition: gdiplustypes.h:24
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
return STATUS_SUCCESS
Definition: btrfs.c:2745
PPARTENTRY CurrentPartition
Definition: partlist.c:74

◆ DestroyPartitionList()

VOID DestroyPartitionList ( VOID  )

Definition at line 1120 of file partlist.c.

1121 {
1122  PDISKENTRY DiskEntry;
1123  PBIOSDISKENTRY BiosDiskEntry;
1124  PPARTENTRY PartEntry;
1126 
1127  CurrentDisk = NULL;
1129 
1130  /* Release disk and partition info */
1131  while (!IsListEmpty(&DiskListHead))
1132  {
1134  DiskEntry = CONTAINING_RECORD(Entry, DISKENTRY, ListEntry);
1135 
1136  /* Release driver name */
1137  RtlFreeUnicodeString(&DiskEntry->DriverName);
1138 
1139  /* Release primary partition list */
1140  while (!IsListEmpty(&DiskEntry->PrimaryPartListHead))
1141  {
1142  Entry = RemoveHeadList(&DiskEntry->PrimaryPartListHead);
1143  PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
1144 
1145  RtlFreeHeap(RtlGetProcessHeap(), 0, PartEntry);
1146  }
1147 
1148  /* Release logical partition list */
1149  while (!IsListEmpty(&DiskEntry->LogicalPartListHead))
1150  {
1151  Entry = RemoveHeadList(&DiskEntry->LogicalPartListHead);
1152  PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
1153 
1154  RtlFreeHeap(RtlGetProcessHeap(), 0, PartEntry);
1155  }
1156 
1157  /* Release layout buffer */
1158  if (DiskEntry->LayoutBuffer != NULL)
1159  RtlFreeHeap(RtlGetProcessHeap(), 0, DiskEntry->LayoutBuffer);
1160 
1161 
1162  /* Release disk entry */
1163  RtlFreeHeap(RtlGetProcessHeap(), 0, DiskEntry);
1164  }
1165 
1166  /* Release the bios disk info */
1167  while (!IsListEmpty(&BiosDiskListHead))
1168  {
1170  BiosDiskEntry = CONTAINING_RECORD(Entry, BIOSDISKENTRY, ListEntry);
1171 
1172  RtlFreeHeap(RtlGetProcessHeap(), 0, BiosDiskEntry);
1173  }
1174 }
LIST_ENTRY DiskListHead
Definition: partlist.c:70
LIST_ENTRY PrimaryPartListHead
Definition: partlist.h:125
PDISKENTRY CurrentDisk
Definition: partlist.c:73
struct _Entry Entry
Definition: kefuncs.h:640
LIST_ENTRY BiosDiskListHead
Definition: partlist.c:71
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:603
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
smooth NULL
Definition: ftsmooth.c:416
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:128
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
UNICODE_STRING DriverName
Definition: partlist.h:117
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
Definition: typedefs.h:117
LIST_ENTRY LogicalPartListHead
Definition: partlist.h:126
PDRIVE_LAYOUT_INFORMATION LayoutBuffer
Definition: partlist.h:119
base of all file and directory entries
Definition: entries.h:82
PPARTENTRY CurrentPartition
Definition: partlist.c:74

◆ DiskConfigurationDataQueryRoutine()

static NTSTATUS NTAPI DiskConfigurationDataQueryRoutine ( PWSTR  ValueName,
ULONG  ValueType,
PVOID  ValueData,
ULONG  ValueLength,
PVOID  Context,
PVOID  EntryContext 
)
static

Definition at line 158 of file partlist.c.

165 {
166  PBIOSDISKENTRY BiosDiskEntry = (PBIOSDISKENTRY)Context;
167  PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor;
168  PCM_DISK_GEOMETRY_DEVICE_DATA DiskGeometry;
169  ULONG i;
170 
173  return STATUS_UNSUCCESSFUL;
174 
175  FullResourceDescriptor = (PCM_FULL_RESOURCE_DESCRIPTOR)ValueData;
176 
177  /* Hm. Version and Revision are not set on Microsoft Windows XP... */
178 #if 0
179  if (FullResourceDescriptor->PartialResourceList.Version != 1 ||
180  FullResourceDescriptor->PartialResourceList.Revision != 1)
181  return STATUS_UNSUCCESSFUL;
182 #endif
183 
184  for (i = 0; i < FullResourceDescriptor->PartialResourceList.Count; i++)
185  {
187  FullResourceDescriptor->PartialResourceList.PartialDescriptors[i].u.DeviceSpecificData.DataSize != sizeof(CM_DISK_GEOMETRY_DEVICE_DATA))
188  continue;
189 
190  DiskGeometry = (PCM_DISK_GEOMETRY_DEVICE_DATA)&FullResourceDescriptor->PartialResourceList.PartialDescriptors[i + 1];
191  BiosDiskEntry->DiskGeometry = *DiskGeometry;
192 
193  return STATUS_SUCCESS;
194  }
195 
196  return STATUS_UNSUCCESSFUL;
197 }
#define CmResourceTypeDeviceSpecific
Definition: hwresource.cpp:127
_In_ PCWSTR _In_z_ PCWSTR _In_ ULONG ValueType
Definition: rtlfuncs.h:4000
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@369 u
struct _CM_DISK_GEOMETRY_DEVICE_DATA * PCM_DISK_GEOMETRY_DEVICE_DATA
struct _BIOSDISKENTRY * PBIOSDISKENTRY
CM_PARTIAL_RESOURCE_LIST PartialResourceList
Definition: hwresource.cpp:160
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
struct _CM_FULL_RESOURCE_DESCRIPTOR * PCM_FULL_RESOURCE_DESCRIPTOR
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@369::@378 DeviceSpecificData
#define REG_FULL_RESOURCE_DESCRIPTOR
Definition: nt_native.h:1503
CM_DISK_GEOMETRY_DEVICE_DATA DiskGeometry
Definition: partlist.h:142
_In_ GUID _In_ PVOID ValueData
Definition: hubbusif.h:311
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]
Definition: hwresource.cpp:119
_In_ GUID _In_ PVOID _In_ ULONG ValueLength
Definition: hubbusif.h:311
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2745

Referenced by EnumerateBiosDiskEntries().

◆ DiskIdentifierQueryRoutine()

static NTSTATUS NTAPI DiskIdentifierQueryRoutine ( PWSTR  ValueName,
ULONG  ValueType,
PVOID  ValueData,
ULONG  ValueLength,
PVOID  Context,
PVOID  EntryContext 
)
static

Definition at line 128 of file partlist.c.

135 {
136  PBIOSDISKENTRY BiosDiskEntry = (PBIOSDISKENTRY)Context;
137  UNICODE_STRING NameU;
138 
139  if (ValueType == REG_SZ &&
140  ValueLength == 20 * sizeof(WCHAR))
141  {
142  NameU.Buffer = (PWCHAR)ValueData;
143  NameU.Length = NameU.MaximumLength = 8 * sizeof(WCHAR);
144  RtlUnicodeStringToInteger(&NameU, 16, &BiosDiskEntry->Checksum);
145 
146  NameU.Buffer = (PWCHAR)ValueData + 9;
147  RtlUnicodeStringToInteger(&NameU, 16, &BiosDiskEntry->Signature);
148 
149  return STATUS_SUCCESS;
150  }
151 
152  return STATUS_UNSUCCESSFUL;
153 }
USHORT MaximumLength
Definition: env_spec_w32.h:370
ULONG Checksum
Definition: partlist.h:140
_In_ PCWSTR _In_z_ PCWSTR _In_ ULONG ValueType
Definition: rtlfuncs.h:4000
ULONG Signature
Definition: partlist.h:139
uint16_t * PWCHAR
Definition: typedefs.h:54
struct _BIOSDISKENTRY * PBIOSDISKENTRY
__wchar_t WCHAR
Definition: xmlstorage.h:180
_In_ GUID _In_ PVOID ValueData
Definition: hubbusif.h:311
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
_In_ GUID _In_ PVOID _In_ ULONG ValueLength
Definition: hubbusif.h:311
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToInteger(PUNICODE_STRING String, ULONG Base, PULONG Value)
return STATUS_SUCCESS
Definition: btrfs.c:2745
#define REG_SZ
Definition: layer.c:22

Referenced by EnumerateBiosDiskEntries().

◆ EnumerateBiosDiskEntries()

static VOID EnumerateBiosDiskEntries ( VOID  )
static

Definition at line 252 of file partlist.c.

253 {
255  WCHAR Name[120];
256  ULONG AdapterCount;
257  ULONG DiskCount;
259  PCM_INT13_DRIVE_PARAMETER Int13Drives;
260  PBIOSDISKENTRY BiosDiskEntry;
261 
262  memset(QueryTable, 0, sizeof(QueryTable));
263 
264  QueryTable[1].Name = L"Configuration Data";
266  Int13Drives = NULL;
268  L"\\Registry\\Machine\\HARDWARE\\DESCRIPTION\\System",
269  &QueryTable[1],
270  (PVOID)&Int13Drives,
271  NULL);
272  if (!NT_SUCCESS(Status))
273  {
274  DPRINT1("Unable to query the 'Configuration Data' key in '\\Registry\\Machine\\HARDWARE\\DESCRIPTION\\System', status=%lx\n", Status);
275  return;
276  }
277 
278  AdapterCount = 0;
279  while (1)
280  {
281  swprintf(Name, L"%s\\%lu", ROOT_NAME, AdapterCount);
283  Name,
284  &QueryTable[2],
285  NULL,
286  NULL);
287  if (!NT_SUCCESS(Status))
288  {
289  break;
290  }
291 
292  swprintf(Name, L"%s\\%lu\\DiskController", ROOT_NAME, AdapterCount);
294  Name,
295  &QueryTable[2],
296  NULL,
297  NULL);
298  if (NT_SUCCESS(Status))
299  {
300  while (1)
301  {
302  swprintf(Name, L"%s\\%lu\\DiskController\\0", ROOT_NAME, AdapterCount);
304  Name,
305  &QueryTable[2],
306  NULL,
307  NULL);
308  if (!NT_SUCCESS(Status))
309  {
310  RtlFreeHeap(RtlGetProcessHeap(), 0, Int13Drives);
311  return;
312  }
313 
314  swprintf(Name, L"%s\\%lu\\DiskController\\0\\DiskPeripheral", ROOT_NAME, AdapterCount);
316  Name,
317  &QueryTable[2],
318  NULL,
319  NULL);
320  if (NT_SUCCESS(Status))
321  {
322  QueryTable[0].Name = L"Identifier";
324  QueryTable[1].Name = L"Configuration Data";
326 
327  DiskCount = 0;
328  while (1)
329  {
330  BiosDiskEntry = (BIOSDISKENTRY*)RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(BIOSDISKENTRY));
331  if (BiosDiskEntry == NULL)
332  {
333  break;
334  }
335 
336  swprintf(Name, L"%s\\%lu\\DiskController\\0\\DiskPeripheral\\%lu", ROOT_NAME, AdapterCount, DiskCount);
338  Name,
339  QueryTable,
340  (PVOID)BiosDiskEntry,
341  NULL);
342  if (!NT_SUCCESS(Status))
343  {
344  RtlFreeHeap(RtlGetProcessHeap(), 0, BiosDiskEntry);
345  break;
346  }
347 
348  BiosDiskEntry->DiskNumber = DiskCount;
349  BiosDiskEntry->Recognized = FALSE;
350 
351  if (DiskCount < Int13Drives[0].NumberDrives)
352  {
353  BiosDiskEntry->Int13DiskData = Int13Drives[DiskCount];
354  }
355  else
356  {
357  DPRINT1("Didn't find int13 drive datas for disk %u\n", DiskCount);
358  }
359 
360  InsertTailList(&BiosDiskListHead, &BiosDiskEntry->ListEntry);
361 
362  DPRINT("DiskNumber: %lu\n", BiosDiskEntry->DiskNumber);
363  DPRINT("Signature: %08lx\n", BiosDiskEntry->Signature);
364  DPRINT("Checksum: %08lx\n", BiosDiskEntry->Checksum);
365  DPRINT("BytesPerSector: %lu\n", BiosDiskEntry->DiskGeometry.BytesPerSector);
366  DPRINT("NumberOfCylinders: %lu\n", BiosDiskEntry->DiskGeometry.NumberOfCylinders);
367  DPRINT("NumberOfHeads: %lu\n", BiosDiskEntry->DiskGeometry.NumberOfHeads);
368  DPRINT("DriveSelect: %02x\n", BiosDiskEntry->Int13DiskData.DriveSelect);
369  DPRINT("MaxCylinders: %lu\n", BiosDiskEntry->Int13DiskData.MaxCylinders);
370  DPRINT("SectorsPerTrack: %d\n", BiosDiskEntry->Int13DiskData.SectorsPerTrack);
371  DPRINT("MaxHeads: %d\n", BiosDiskEntry->Int13DiskData.MaxHeads);
372  DPRINT("NumberDrives: %d\n", BiosDiskEntry->Int13DiskData.NumberDrives);
373 
374  DiskCount++;
375  }
376  }
377 
378  RtlFreeHeap(RtlGetProcessHeap(), 0, Int13Drives);
379  return;
380  }
381  }
382 
383  AdapterCount++;
384  }
385 
386  RtlFreeHeap(RtlGetProcessHeap(), 0, Int13Drives);
387 }
_In_ PCWSTR _Inout_ _At_ QueryTable _Pre_unknown_ PRTL_QUERY_REGISTRY_TABLE QueryTable
Definition: rtlfuncs.h:3988
static NTSTATUS NTAPI DiskConfigurationDataQueryRoutine(PWSTR ValueName, ULONG ValueType, PVOID ValueData, ULONG ValueLength, PVOID Context, PVOID EntryContext)
Definition: partlist.c:158
LIST_ENTRY BiosDiskListHead
Definition: partlist.c:71
ULONG Checksum
Definition: partlist.h:140
ULONG Signature
Definition: partlist.h:139
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:603
#define InsertTailList(ListHead, Entry)
PRTL_QUERY_REGISTRY_ROUTINE QueryRoutine
Definition: nt_native.h:109
struct _BIOSDISKENTRY BIOSDISKENTRY
#define ROOT_NAME
Definition: partlist.c:248
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:585
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define swprintf(buf, format,...)
Definition: sprintf.c:56
CM_DISK_GEOMETRY_DEVICE_DATA DiskGeometry
Definition: partlist.h:142
NTSYSAPI NTSTATUS WINAPI RtlQueryRegistryValues(ULONG, PCWSTR, PRTL_QUERY_REGISTRY_TABLE, PVOID, PVOID)
static const WCHAR L[]
Definition: oid.c:1250
#define RTL_REGISTRY_ABSOLUTE
Definition: nt_native.h:161
Status
Definition: gdiplustypes.h:24
BOOLEAN Recognized
Definition: diskpart.h:127
LIST_ENTRY ListEntry
Definition: partlist.h:135
ULONG DiskNumber
Definition: partlist.h:138
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
CM_INT13_DRIVE_PARAMETER Int13DiskData
Definition: partlist.h:143
static NTSTATUS NTAPI DiskIdentifierQueryRoutine(PWSTR ValueName, ULONG ValueType, PVOID ValueData, ULONG ValueLength, PVOID Context, PVOID EntryContext)
Definition: partlist.c:128
static NTSTATUS NTAPI SystemConfigurationDataQueryRoutine(PWSTR ValueName, ULONG ValueType, PVOID ValueData, ULONG ValueLength, PVOID Context, PVOID EntryContext)
Definition: partlist.c:202
#define memset(x, y, z)
Definition: compat.h:39

Referenced by CreatePartitionList().

◆ GetDriverName()

static VOID GetDriverName ( PDISKENTRY  DiskEntry)
static

Definition at line 93 of file partlist.c.

95 {
97  WCHAR KeyName[32];
99 
100  RtlInitUnicodeString(&DiskEntry->DriverName,
101  NULL);
102 
104  L"\\Scsi\\Scsi Port %lu",
105  DiskEntry->Port);
106 
108  sizeof(QueryTable));
109 
110  QueryTable[0].Name = L"Driver";
112  QueryTable[0].EntryContext = &DiskEntry->DriverName;
113 
115  KeyName,
116  QueryTable,
117  NULL,
118  NULL);
119  if (!NT_SUCCESS(Status))
120  {
121  DPRINT1("RtlQueryRegistryValues() failed (Status %lx)\n", Status);
122  }
123 }
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING KeyName
Definition: ndis.h:4711
_In_ PCWSTR _Inout_ _At_ QueryTable _Pre_unknown_ PRTL_QUERY_REGISTRY_TABLE QueryTable
Definition: rtlfuncs.h:3988
LONG NTSTATUS
Definition: precomp.h:26
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
UNICODE_STRING DriverName
Definition: partlist.h:117
#define swprintf(buf, format,...)
Definition: sprintf.c:56
NTSYSAPI NTSTATUS WINAPI RtlQueryRegistryValues(ULONG, PCWSTR, PRTL_QUERY_REGISTRY_TABLE, PVOID, PVOID)
static const WCHAR L[]
Definition: oid.c:1250
Status
Definition: gdiplustypes.h:24
USHORT Port
Definition: partlist.h:107
#define DPRINT1
Definition: precomp.h:8
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define RTL_REGISTRY_DEVICEMAP
Definition: nt_native.h:165
#define RTL_QUERY_REGISTRY_DIRECT
Definition: nt_native.h:144

Referenced by AddDiskToList().

◆ ScanForUnpartitionedDiskSpace()

static VOID ScanForUnpartitionedDiskSpace ( PDISKENTRY  DiskEntry)
static

Definition at line 502 of file partlist.c.

504 {
505  ULONGLONG LastStartSector;
506  ULONGLONG LastSectorCount;
507  ULONGLONG LastUnusedSectorCount;
508  PPARTENTRY PartEntry;
509  PPARTENTRY NewPartEntry;
511 
512  DPRINT("ScanForUnpartitionedDiskSpace()\n");
513 
514  if (IsListEmpty(&DiskEntry->PrimaryPartListHead))
515  {
516  DPRINT1("No primary partition!\n");
517 
518  /* Create a partition table that represents the empty disk */
519  NewPartEntry = RtlAllocateHeap(RtlGetProcessHeap(),
521  sizeof(PARTENTRY));
522  if (NewPartEntry == NULL)
523  return;
524 
525  NewPartEntry->DiskEntry = DiskEntry;
526 
527  NewPartEntry->IsPartitioned = FALSE;
528  NewPartEntry->StartSector.QuadPart = (ULONGLONG)DiskEntry->SectorAlignment;
529  NewPartEntry->SectorCount.QuadPart = AlignDown(DiskEntry->SectorCount.QuadPart, DiskEntry->SectorAlignment) -
530  NewPartEntry->StartSector.QuadPart;
531 
532  DPRINT1("First Sector: %I64u\n", NewPartEntry->StartSector.QuadPart);
533  DPRINT1("Last Sector: %I64u\n", NewPartEntry->StartSector.QuadPart + NewPartEntry->SectorCount.QuadPart - 1);
534  DPRINT1("Total Sectors: %I64u\n", NewPartEntry->SectorCount.QuadPart);
535 
536  NewPartEntry->FormatState = Unformatted;
537 
539  &NewPartEntry->ListEntry);
540 
541  return;
542  }
543 
544  /* Start partition at head 1, cylinder 0 */
545  LastStartSector = DiskEntry->SectorAlignment;
546  LastSectorCount = 0ULL;
547  LastUnusedSectorCount = 0ULL;
548 
549  Entry = DiskEntry->PrimaryPartListHead.Flink;
550  while (Entry != &DiskEntry->PrimaryPartListHead)
551  {
552  PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
553 
554  if (PartEntry->PartitionType != PARTITION_ENTRY_UNUSED ||
555  PartEntry->SectorCount.QuadPart != 0ULL)
556  {
557  LastUnusedSectorCount =
558  PartEntry->StartSector.QuadPart - (LastStartSector + LastSectorCount);
559 
560  if (PartEntry->StartSector.QuadPart > (LastStartSector + LastSectorCount) &&
561  LastUnusedSectorCount >= (ULONGLONG)DiskEntry->SectorAlignment)
562  {
563  DPRINT("Unpartitioned disk space %I64u sectors\n", LastUnusedSectorCount);
564 
565  NewPartEntry = RtlAllocateHeap(RtlGetProcessHeap(),
567  sizeof(PARTENTRY));
568  if (NewPartEntry == NULL)
569  return;
570 
571  NewPartEntry->DiskEntry = DiskEntry;
572 
573  NewPartEntry->IsPartitioned = FALSE;
574  NewPartEntry->StartSector.QuadPart = LastStartSector + LastSectorCount;
575  NewPartEntry->SectorCount.QuadPart = AlignDown(NewPartEntry->StartSector.QuadPart + LastUnusedSectorCount, DiskEntry->SectorAlignment) -
576  NewPartEntry->StartSector.QuadPart;
577 
578  DPRINT1("First Sector: %I64u\n", NewPartEntry->StartSector.QuadPart);
579  DPRINT1("Last Sector: %I64u\n", NewPartEntry->StartSector.QuadPart + NewPartEntry->SectorCount.QuadPart - 1);
580  DPRINT1("Total Sectors: %I64u\n", NewPartEntry->SectorCount.QuadPart);
581 
582  NewPartEntry->FormatState = Unformatted;
583 
584  /* Insert the table into the list */
585  InsertTailList(&PartEntry->ListEntry,
586  &NewPartEntry->ListEntry);
587  }
588 
589  LastStartSector = PartEntry->StartSector.QuadPart;
590  LastSectorCount = PartEntry->SectorCount.QuadPart;
591  }
592 
593  Entry = Entry->Flink;
594  }
595 
596  /* Check for trailing unpartitioned disk space */
597  if ((LastStartSector + LastSectorCount) < DiskEntry->SectorCount.QuadPart)
598  {
599  LastUnusedSectorCount = AlignDown(DiskEntry->SectorCount.QuadPart - (LastStartSector + LastSectorCount), DiskEntry->SectorAlignment);
600 
601  if (LastUnusedSectorCount >= (ULONGLONG)DiskEntry->SectorAlignment)
602  {
603  DPRINT1("Unpartitioned disk space: %I64u sectors\n", LastUnusedSectorCount);
604 
605  NewPartEntry = RtlAllocateHeap(RtlGetProcessHeap(),
607  sizeof(PARTENTRY));
608  if (NewPartEntry == NULL)
609  return;
610 
611  NewPartEntry->DiskEntry = DiskEntry;
612 
613  NewPartEntry->IsPartitioned = FALSE;
614  NewPartEntry->StartSector.QuadPart = LastStartSector + LastSectorCount;
615  NewPartEntry->SectorCount.QuadPart = AlignDown(NewPartEntry->StartSector.QuadPart + LastUnusedSectorCount, DiskEntry->SectorAlignment) -
616  NewPartEntry->StartSector.QuadPart;
617 
618  DPRINT1("First Sector: %I64u\n", NewPartEntry->StartSector.QuadPart);
619  DPRINT1("Last Sector: %I64u\n", NewPartEntry->StartSector.QuadPart + NewPartEntry->SectorCount.QuadPart - 1);
620  DPRINT1("Total Sectors: %I64u\n", NewPartEntry->SectorCount.QuadPart);
621 
622  NewPartEntry->FormatState = Unformatted;
623 
624  /* Append the table to the list */
626  &NewPartEntry->ListEntry);
627  }
628  }
629 
630  if (DiskEntry->ExtendedPartition != NULL)
631  {
632  if (IsListEmpty(&DiskEntry->LogicalPartListHead))
633  {
634  DPRINT1("No logical partition!\n");
635 
636  /* Create a partition table entry that represents the empty extended partition */
637  NewPartEntry = RtlAllocateHeap(RtlGetProcessHeap(),
639  sizeof(PARTENTRY));
640  if (NewPartEntry == NULL)
641  return;
642 
643  NewPartEntry->DiskEntry = DiskEntry;
644  NewPartEntry->LogicalPartition = TRUE;
645 
646  NewPartEntry->IsPartitioned = FALSE;
647  NewPartEntry->StartSector.QuadPart = DiskEntry->ExtendedPartition->StartSector.QuadPart + (ULONGLONG)DiskEntry->SectorAlignment;
648  NewPartEntry->SectorCount.QuadPart = DiskEntry->ExtendedPartition->SectorCount.QuadPart - (ULONGLONG)DiskEntry->SectorAlignment;
649 
650  DPRINT1("First Sector: %I64u\n", NewPartEntry->StartSector.QuadPart);
651  DPRINT1("Last Sector: %I64u\n", NewPartEntry->StartSector.QuadPart + NewPartEntry->SectorCount.QuadPart - 1);
652  DPRINT1("Total Sectors: %I64u\n", NewPartEntry->SectorCount.QuadPart);
653 
654  NewPartEntry->FormatState = Unformatted;
655 
657  &NewPartEntry->ListEntry);
658 
659  return;
660  }
661 
662  /* Start partition at head 1, cylinder 0 */
663  LastStartSector = DiskEntry->ExtendedPartition->StartSector.QuadPart + (ULONGLONG)DiskEntry->SectorAlignment;
664  LastSectorCount = 0ULL;
665  LastUnusedSectorCount = 0ULL;
666 
667  Entry = DiskEntry->LogicalPartListHead.Flink;
668  while (Entry != &DiskEntry->LogicalPartListHead)
669  {
670  PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
671 
672  if (PartEntry->PartitionType != PARTITION_ENTRY_UNUSED ||
673  PartEntry->SectorCount.QuadPart != 0ULL)
674  {
675  LastUnusedSectorCount =
676  PartEntry->StartSector.QuadPart - (ULONGLONG)DiskEntry->SectorAlignment - (LastStartSector + LastSectorCount);
677 
678  if ((PartEntry->StartSector.QuadPart - (ULONGLONG)DiskEntry->SectorAlignment) > (LastStartSector + LastSectorCount) &&
679  LastUnusedSectorCount >= (ULONGLONG)DiskEntry->SectorAlignment)
680  {
681  DPRINT("Unpartitioned disk space %I64u sectors\n", LastUnusedSectorCount);
682 
683  NewPartEntry = RtlAllocateHeap(RtlGetProcessHeap(),
685  sizeof(PARTENTRY));
686  if (NewPartEntry == NULL)
687  return;
688 
689  NewPartEntry->DiskEntry = DiskEntry;
690  NewPartEntry->LogicalPartition = TRUE;
691 
692  NewPartEntry->IsPartitioned = FALSE;
693  NewPartEntry->StartSector.QuadPart = LastStartSector + LastSectorCount;
694  NewPartEntry->SectorCount.QuadPart = AlignDown(NewPartEntry->StartSector.QuadPart + LastUnusedSectorCount, DiskEntry->SectorAlignment) -
695  NewPartEntry->StartSector.QuadPart;
696 
697  DPRINT("First Sector: %I64u\n", NewPartEntry->StartSector.QuadPart);
698  DPRINT("Last Sector: %I64u\n", NewPartEntry->StartSector.QuadPart + NewPartEntry->SectorCount.QuadPart - 1);
699  DPRINT("Total Sectors: %I64u\n", NewPartEntry->SectorCount.QuadPart);
700 
701  NewPartEntry->FormatState = Unformatted;
702 
703  /* Insert the table into the list */
704  InsertTailList(&PartEntry->ListEntry,
705  &NewPartEntry->ListEntry);
706  }
707 
708  LastStartSector = PartEntry->StartSector.QuadPart;
709  LastSectorCount = PartEntry->SectorCount.QuadPart;
710  }
711 
712  Entry = Entry->Flink;
713  }
714 
715  /* Check for trailing unpartitioned disk space */
716  if ((LastStartSector + LastSectorCount) < DiskEntry->ExtendedPartition->StartSector.QuadPart + DiskEntry->ExtendedPartition->SectorCount.QuadPart)
717  {
718  LastUnusedSectorCount = AlignDown(DiskEntry->ExtendedPartition->StartSector.QuadPart + DiskEntry->ExtendedPartition->SectorCount.QuadPart - (LastStartSector + LastSectorCount),
719  DiskEntry->SectorAlignment);
720 
721  if (LastUnusedSectorCount >= (ULONGLONG)DiskEntry->SectorAlignment)
722  {
723  DPRINT("Unpartitioned disk space: %I64u sectors\n", LastUnusedSectorCount);
724 
725  NewPartEntry = RtlAllocateHeap(RtlGetProcessHeap(),
727  sizeof(PARTENTRY));
728  if (NewPartEntry == NULL)
729  return;
730 
731  NewPartEntry->DiskEntry = DiskEntry;
732  NewPartEntry->LogicalPartition = TRUE;
733 
734  NewPartEntry->IsPartitioned = FALSE;
735  NewPartEntry->StartSector.QuadPart = LastStartSector + LastSectorCount;
736  NewPartEntry->SectorCount.QuadPart = AlignDown(NewPartEntry->StartSector.QuadPart + LastUnusedSectorCount, DiskEntry->SectorAlignment) -
737  NewPartEntry->StartSector.QuadPart;
738 
739  DPRINT("First Sector: %I64u\n", NewPartEntry->StartSector.QuadPart);
740  DPRINT("Last Sector: %I64u\n", NewPartEntry->StartSector.QuadPart + NewPartEntry->SectorCount.QuadPart - 1);
741  DPRINT("Total Sectors: %I64u\n", NewPartEntry->SectorCount.QuadPart);
742 
743  NewPartEntry->FormatState = Unformatted;
744 
745  /* Append the table to the list */
747  &NewPartEntry->ListEntry);
748  }
749  }
750  }
751 
752  DPRINT("ScanForUnpartitionedDiskSpace() done\n");
753 }
LIST_ENTRY PrimaryPartListHead
Definition: partlist.h:125
ULARGE_INTEGER StartSector
Definition: partlist.h:42
#define TRUE
Definition: types.h:120
struct _Entry Entry
Definition: kefuncs.h:640
ULARGE_INTEGER SectorCount
Definition: partlist.h:43
#define InsertTailList(ListHead, Entry)
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
PPARTENTRY ExtendedPartition
Definition: partlist.h:129
#define PARTITION_ENTRY_UNUSED
Definition: disk.h:86
LIST_ENTRY ListEntry
Definition: partlist.h:36
while(1)
Definition: macro.lex.yy.c:740
BOOLEAN LogicalPartition
Definition: partlist.h:57
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
FORMATSTATE FormatState
Definition: partlist.h:55
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define ULL(a, b)
Definition: format_msg.c:27
ULARGE_INTEGER SectorCount
Definition: partlist.h:91
ULONG SectorAlignment
Definition: partlist.h:92
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:585
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
UCHAR PartitionType
Definition: partlist.h:46
struct _DISKENTRY * DiskEntry
Definition: partlist.h:39
uint64_t ULONGLONG
Definition: typedefs.h:65
ULONGLONG AlignDown(IN ULONGLONG Value, IN ULONG Alignment)
Definition: partlist.c:245
Definition: typedefs.h:117
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define DPRINT1
Definition: precomp.h:8
LIST_ENTRY LogicalPartListHead
Definition: partlist.h:126
base of all file and directory entries
Definition: entries.h:82
BOOLEAN IsPartitioned
Definition: partlist.h:60

Referenced by AddDiskToList().

◆ SystemConfigurationDataQueryRoutine()

static NTSTATUS NTAPI SystemConfigurationDataQueryRoutine ( PWSTR  ValueName,
ULONG  ValueType,
PVOID  ValueData,
ULONG  ValueLength,
PVOID  Context,
PVOID  EntryContext 
)
static

Definition at line 202 of file partlist.c.

209 {
210  PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor;
212  ULONG i;
213 
216  return STATUS_UNSUCCESSFUL;
217 
218  FullResourceDescriptor = (PCM_FULL_RESOURCE_DESCRIPTOR)ValueData;
219 
220  /* Hm. Version and Revision are not set on Microsoft Windows XP... */
221 #if 0
222  if (FullResourceDescriptor->PartialResourceList.Version != 1 ||
223  FullResourceDescriptor->PartialResourceList.Revision != 1)
224  return STATUS_UNSUCCESSFUL;
225 #endif
226 
227  for (i = 0; i < FullResourceDescriptor->PartialResourceList.Count; i++)
228  {
230  FullResourceDescriptor->PartialResourceList.PartialDescriptors[i].u.DeviceSpecificData.DataSize % sizeof(CM_INT13_DRIVE_PARAMETER) != 0)
231  continue;
232 
233  *Int13Drives = (CM_INT13_DRIVE_PARAMETER*)RtlAllocateHeap(RtlGetProcessHeap(), 0,
234  FullResourceDescriptor->PartialResourceList.PartialDescriptors[i].u.DeviceSpecificData.DataSize);
235  if (*Int13Drives == NULL)
236  return STATUS_NO_MEMORY;
237 
238  memcpy(*Int13Drives,
239  &FullResourceDescriptor->PartialResourceList.PartialDescriptors[i + 1],
240  FullResourceDescriptor->PartialResourceList.PartialDescriptors[i].u.DeviceSpecificData.DataSize);
241  return STATUS_SUCCESS;
242  }
243 
244  return STATUS_UNSUCCESSFUL;
245 }
#define CmResourceTypeDeviceSpecific
Definition: hwresource.cpp:127
_In_ PCWSTR _In_z_ PCWSTR _In_ ULONG ValueType
Definition: rtlfuncs.h:4000
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@369 u
CM_PARTIAL_RESOURCE_LIST PartialResourceList
Definition: hwresource.cpp:160
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
struct _CM_FULL_RESOURCE_DESCRIPTOR * PCM_FULL_RESOURCE_DESCRIPTOR
smooth NULL
Definition: ftsmooth.c:416
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@369::@378 DeviceSpecificData
#define REG_FULL_RESOURCE_DESCRIPTOR
Definition: nt_native.h:1503
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:585
_In_ GUID _In_ PVOID ValueData
Definition: hubbusif.h:311
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]
Definition: hwresource.cpp:119
_In_ GUID _In_ PVOID _In_ ULONG ValueLength
Definition: hubbusif.h:311
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2745

Referenced by EnumerateBiosDiskEntries().

Variable Documentation

◆ BiosDiskListHead

LIST_ENTRY BiosDiskListHead

◆ CurrentDisk

◆ CurrentPartition

PPARTENTRY CurrentPartition = NULL

Definition at line 74 of file partlist.c.

Referenced by CreatePartitionList(), and DestroyPartitionList().

◆ DiskListHead

LIST_ENTRY DiskListHead