16#define InsertAscendingList(ListHead, NewEntry, Type, ListEntryField, SortField)\
20 current = (ListHead)->Flink;\
21 while (current != (ListHead))\
23 if (CONTAINING_RECORD(current, Type, ListEntryField)->SortField >=\
24 (NewEntry)->SortField)\
28 current = current->Flink;\
31 InsertTailList(current, &((NewEntry)->ListEntryField));\
35#define PARTITION_LINUX 0x83
37#define PARTITION_TBL_SIZE 4
39#define MBR_MAGIC 0xAA55
82#ifdef DUMP_PARTITION_TABLE
94 DbgPrint(
"Index Start Length Hidden Nr Type Boot RW\n");
95 DbgPrint(
"----- ------------ ------------ ---------- -- ---- ---- --\n");
97 for (
i = 0;
i < DiskEntry->LayoutBuffer->PartitionCount;
i++)
100 DbgPrint(
" %3lu %12I64u %12I64u %10lu %2lu %2x %c %c\n",
102 PartitionInfo->StartingOffset.QuadPart / DiskEntry->BytesPerSector,
103 PartitionInfo->PartitionLength.QuadPart / DiskEntry->BytesPerSector,
113 DbgPrint(
"Index Start Length Nr RW Type \n");
114 DbgPrint(
"----- ------------ ------------ -- -- --------\n");
115 for (
i = 0;
i < DiskEntry->LayoutBuffer->PartitionCount;
i++)
119 DbgPrint(
" %3lu %12I64u %12I64u %2lu %c %08lx\n",
121 PartitionInfo->StartingOffset.QuadPart / DiskEntry->BytesPerSector,
122 PartitionInfo->PartitionLength.QuadPart / DiskEntry->BytesPerSector,
133#ifdef DUMP_PARTITION_LIST
145 DbgPrint(
"Disk Start Disk End Disk Length \n");
146 DbgPrint(
"------------ ------------ ------------\n");
147 DbgPrint(
"%12I64u %12I64u %12I64u\n",
148 DiskEntry->StartSector.QuadPart,
149 DiskEntry->EndSector.QuadPart,
150 DiskEntry->EndSector.QuadPart - DiskEntry->StartSector.QuadPart + 1);
154 DbgPrint(
"Start End Length Nr Type P\n");
155 DbgPrint(
"------------ ------------ ------------ --- -------- --\n");
157 for (ListEntry = DiskEntry->PrimaryPartListHead.Flink;
158 ListEntry != &DiskEntry->PrimaryPartListHead;
159 ListEntry = ListEntry->
Flink)
163 DbgPrint(
"%12I64u %12I64u %12I64u %3lu %08lx %c\n",
174 DbgPrint(
"Disk Start Disk End Disk Length \n");
175 DbgPrint(
"------------ ------------ ------------\n");
176 DbgPrint(
"%12I64u %12I64u %12I64u\n",
177 DiskEntry->StartSector.QuadPart,
178 DiskEntry->EndSector.QuadPart,
179 DiskEntry->EndSector.QuadPart - DiskEntry->StartSector.QuadPart + 1);
213 L"\\Scsi\\Scsi Port %lu",
230 DPRINT1(
"RtlQueryRegistryValues() failed (Status %lx)\n",
Status);
344 if (*Int13Drives ==
NULL)
357#define ROOT_NAME L"\\Registry\\Machine\\HARDWARE\\DESCRIPTION\\System\\MultifunctionAdapter"
377 L"\\Registry\\Machine\\HARDWARE\\DESCRIPTION\\System",
383 DPRINT1(
"Unable to query the 'Configuration Data' key in '\\Registry\\Machine\\HARDWARE\\DESCRIPTION\\System', status=%lx\n",
Status);
403 L"%s\\%lu\\DiskController",
ROOT_NAME, AdapterCount);
414 L"%s\\%lu\\DiskController\\0",
ROOT_NAME, AdapterCount);
427 L"%s\\%lu\\DiskController\\0\\DiskPeripheral",
ROOT_NAME, AdapterCount);
444 if (BiosDiskEntry ==
NULL)
450 L"%s\\%lu\\DiskController\\0\\DiskPeripheral\\%lu",
ROOT_NAME, AdapterCount, DiskCount);
454 (
PVOID)BiosDiskEntry,
458 RtlFreeHeap(RtlGetProcessHeap(), 0, BiosDiskEntry);
462 BiosDiskEntry->DiskNumber = DiskCount;
463 BiosDiskEntry->Recognized =
FALSE;
465 if (DiskCount < Int13Drives[0].NumberDrives)
467 BiosDiskEntry->Int13DiskData = Int13Drives[DiskCount];
471 DPRINT1(
"Didn't find int13 drive datas for disk %u\n", DiskCount);
476 DPRINT(
"DiskNumber: %lu\n", BiosDiskEntry->DiskNumber);
477 DPRINT(
"Signature: %08lx\n", BiosDiskEntry->Signature);
478 DPRINT(
"Checksum: %08lx\n", BiosDiskEntry->Checksum);
479 DPRINT(
"BytesPerSector: %lu\n", BiosDiskEntry->DiskGeometry.BytesPerSector);
480 DPRINT(
"NumberOfCylinders: %lu\n", BiosDiskEntry->DiskGeometry.NumberOfCylinders);
481 DPRINT(
"NumberOfHeads: %lu\n", BiosDiskEntry->DiskGeometry.NumberOfHeads);
482 DPRINT(
"DriveSelect: %02x\n", BiosDiskEntry->Int13DiskData.DriveSelect);
483 DPRINT(
"MaxCylinders: %lu\n", BiosDiskEntry->Int13DiskData.MaxCylinders);
484 DPRINT(
"SectorsPerTrack: %d\n", BiosDiskEntry->Int13DiskData.SectorsPerTrack);
485 DPRINT(
"MaxHeads: %d\n", BiosDiskEntry->Int13DiskData.MaxHeads);
486 DPRINT(
"NumberDrives: %d\n", BiosDiskEntry->Int13DiskData.NumberDrives);
509 ULONG PartitionIndex,
523 if (PartEntry ==
NULL)
557 if (CheckFatFormat())
571 if (CheckExt2Format())
585 if (CheckNtfsFormat())
589 else if (CheckHpfsFormat())
619 ULONG PartitionIndex)
631 if (PartEntry ==
NULL)
671 DPRINT(
"ScanForUnpartitionedMbrDiskSpace()\n");
680 DPRINT1(
"No primary partition!\n");
686 if (NewPartEntry ==
NULL)
709 LastStartSector = StartSector;
710 LastSectorCount = 0
ULL;
711 LastUnusedSectorCount = 0
ULL;
721 LastUnusedSectorCount =
727 DPRINT(
"Unpartitioned disk space %I64u sectors\n", LastUnusedSectorCount);
732 if (NewPartEntry ==
NULL)
761 if ((LastStartSector + LastSectorCount) < (EndSector + 1))
763 LastUnusedSectorCount =
AlignDown((EndSector + 1) - (LastStartSector + LastSectorCount), DiskEntry->
SectorAlignment);
767 DPRINT1(
"Unpartitioned disk space: %I64u sectors\n", LastUnusedSectorCount);
772 if (NewPartEntry ==
NULL)
798 DPRINT1(
"No logical partition!\n");
804 if (NewPartEntry ==
NULL)
828 LastSectorCount = 0
ULL;
829 LastUnusedSectorCount = 0
ULL;
839 LastUnusedSectorCount =
845 DPRINT(
"Unpartitioned disk space %I64u sectors\n", LastUnusedSectorCount);
850 if (NewPartEntry ==
NULL)
887 DPRINT(
"Unpartitioned disk space: %I64u sectors\n", LastUnusedSectorCount);
892 if (NewPartEntry ==
NULL)
916 DPRINT(
"ScanForUnpartitionedMbrDiskSpace() done\n");
931 DPRINT(
"ScanForUnpartitionedGptDiskSpace()\n");
933#ifdef DUMP_PARTITION_LIST
934 DumpPartitionList(DiskEntry);
939 DPRINT(
"No partitions!\n");
945 if (NewPartEntry ==
NULL)
963#ifdef DUMP_PARTITION_LIST
964 DumpPartitionList(DiskEntry);
972 LastSectorCount = 0
ULL;
973 LastUnusedSectorCount = 0
ULL;
983 LastUnusedSectorCount =
989 DPRINT(
"Unpartitioned disk space %I64u sectors\n", LastUnusedSectorCount);
994 if (NewPartEntry ==
NULL)
1029 DPRINT(
"Unpartitioned disk space: %I64u sectors\n", LastUnusedSectorCount);
1034 if (NewPartEntry ==
NULL)
1056#ifdef DUMP_PARTITION_LIST
1057 DumpPartitionList(DiskEntry);
1060 DPRINT(
"ScanForUnpartitionedGptDiskSpace() done\n");
1069 ULONG LayoutBufferSize;
1070 PDRIVE_LAYOUT_INFORMATION_EX NewLayoutBuffer;
1075 LayoutBufferSize =
sizeof(DRIVE_LAYOUT_INFORMATION_EX) +
1080 if (DiskEntry->LayoutBuffer ==
NULL)
1082 DPRINT1(
"Failed to allocate the disk layout buffer!\n");
1088 DPRINT(
"Buffer size: %lu\n", LayoutBufferSize);
1097 DiskEntry->LayoutBuffer,
1104 DPRINT1(
"NtDeviceIoControlFile() failed (Status: 0x%08lx)\n",
Status);
1111 DiskEntry->LayoutBuffer,
1113 if (NewLayoutBuffer ==
NULL)
1115 DPRINT1(
"Failed to reallocate the disk layout buffer!\n");
1119 DiskEntry->LayoutBuffer = NewLayoutBuffer;
1196 &StoragePropertyQuery,
1236 for (
i = 0;
i < 128;
i++)
1240 Checksum = ~Checksum + 1;
1249 if (DiskEntry ==
NULL)
1262 DPRINT(
"DescriptorHeader.Size %lu\n", pDescriptorHeader->
Size);
1264 if (pDescriptorHeader->
Size <= 1024)
1283 INT VendorLength = 0, ProductLength = 0;
1296 VendorLength *
sizeof(
WCHAR));
1317 ProductLength *
sizeof(
WCHAR));
1329 (VendorLength + ProductLength + 2) *
sizeof(
WCHAR));
1333 if ((VendorLength > 0) && (ProductLength > 0))
1342 RtlFreeHeap(RtlGetProcessHeap(), 0, VendorBuffer);
1345 RtlFreeHeap(RtlGetProcessHeap(), 0, ProductBuffer);
1358 DPRINT(
"Partition style: RAW\n");
1365 DPRINT(
"Partition style: GPT\n");
1370 DPRINT(
"Partition style: MBR\n");
1389 BiosDiskEntry->
Checksum == Checksum &&
1402 ListEntry = ListEntry->
Flink;
1411 DPRINT1(
"WARNING: Setup could not find a matching BIOS disk entry. Disk %d is not be bootable by the BIOS!\n", DiskNumber);
1445 DiskEntry->
Lun = ScsiAddress.
Lun;
1455#ifdef DUMP_PARTITION_TABLE
1456 DumpPartitionTable(DiskEntry);
1480 DPRINT1(
"No valid partition table found! Use megabyte (%lu Sectors) alignment!\n", (1024 * 1024) / DiskEntry->
BytesPerSector);
1493 for (
i = 0;
i < 4;
i++)
1498 for (
i = 0;
i < 4;
i++)
1573 for (DiskNumber = 0; DiskNumber < Sdi.
NumberOfDisks; DiskNumber++)
1576 L"\\Device\\Harddisk%d\\Partition0",
1668 RtlFreeHeap(RtlGetProcessHeap(), 0, BiosDiskEntry);
1686 if (pExtents ==
NULL)
1711 if (pExtents ==
NULL)
1735 VolumeEntry->pExtents = pExtents;
1790 ZeroMemory(&FullSizeInfo,
sizeof(FullSizeInfo));
1826 DPRINT(
"GetVolumeSize() failed!\n");
1841 DPRINT(
"GetDiskFromVolume(%p)\n", VolumeEntry);
1843 DPRINT(
"Extents: %p\n", VolumeEntry->pExtents);
1844 if (VolumeEntry->pExtents ==
NULL)
1847 DPRINT(
"Extents: %lu\n", VolumeEntry->pExtents->NumberOfDiskExtents);
1854 for (
i = 0;
i < VolumeEntry->pExtents->NumberOfDiskExtents;
i++)
1856 DPRINT(
"DiskNumber: %lu -- %lu\n", VolumeEntry->pExtents->Extents[
i].DiskNumber, DiskEntry->
DiskNumber);
1857 if (VolumeEntry->pExtents->Extents[
i].DiskNumber == DiskEntry->
DiskNumber)
1878 DPRINT(
"GetPartitionFromVolume(%p)\n", VolumeEntry);
1880 DPRINT(
"Extents: %p\n", VolumeEntry->pExtents);
1881 if (VolumeEntry->pExtents ==
NULL)
1884 DPRINT(
"Extents: %lu\n", VolumeEntry->pExtents->NumberOfDiskExtents);
1891 for (
i = 0;
i < VolumeEntry->pExtents->NumberOfDiskExtents;
i++)
1893 DPRINT(
"DiskNumber: %lu -- %lu\n", VolumeEntry->pExtents->Extents[
i].DiskNumber, DiskEntry->
DiskNumber);
1894 if (VolumeEntry->pExtents->Extents[
i].DiskNumber == DiskEntry->
DiskNumber)
1902 if ((VolumeEntry->pExtents->Extents[
i].StartingOffset.QuadPart == PartEntry->
StartSector.
QuadPart * PartEntry->
DiskEntry->BytesPerSector) &&
1906 Entry2 = Entry2->
Flink;
1914 if ((VolumeEntry->pExtents->Extents[
i].StartingOffset.QuadPart == PartEntry->
StartSector.
QuadPart * PartEntry->
DiskEntry->BytesPerSector) &&
1918 Entry2 = Entry2->
Flink;
1923 Entry1 = Entry1->
Flink;
1940 DPRINT(
"IsVolumeSystem()\n");
1942 VolumeEntry->IsSystem =
FALSE;
1955 dwLength =
sizeof(szSystemPartition);
1960 (
PBYTE)szSystemPartition,
1970 DPRINT(
"SystemPartition: %S\n", szSystemPartition);
1971 DPRINT(
"DeviceName: %S\n", VolumeEntry->DeviceName);
1973 if (
_wcsnicmp(szSystemPartition, VolumeEntry->DeviceName,
wcslen(szSystemPartition)) == 0)
1975 VolumeEntry->IsSystem =
TRUE;
1993 DPRINT(
"IsVolumeBoot()\n");
1995 VolumeEntry->IsBoot =
FALSE;
2003 DPRINT(
"SystemDirectory: %S\n", szSystemDir);
2004 DPRINT(
"DriveLetter: %C\n", VolumeEntry->DriveLetter);
2006 if (szSystemDir[0] == VolumeEntry->DriveLetter)
2008 VolumeEntry->IsBoot =
TRUE;
2024 ULONG ulVolumeNumber,
2025 PWSTR pszVolumeName)
2035 DWORD CharCount = 0;
2043 DPRINT(
"AddVolumeToList(%S)\n", pszVolumeName);
2048 if (VolumeEntry ==
NULL)
2056 pszVolumeName[
Index] =
L'\0';
2060 pszVolumeName[
Index] =
L'\\';
2120 (3 + 1) *
sizeof(
WCHAR));
2136 PWSTR pszPath = szPathNames;
2139 DPRINT(
"PathName: %S\n", pszPath);
2140 nPathLength =
wcslen(pszPath);
2141 if ((nPathLength == 3) && (
iswalpha(pszPath[0])) &&
2142 (pszPath[1] ==
L':') && (pszPath[2] ==
L'\\'))
2145 pszPath += (nPathLength + 1);
2162 ULONG ulVolumeNumber = 0;
2235 ULONG PartitionCount;
2240 DPRINT(
"WriteMbrPartitions() Disk: %lu\n", DiskEntry->DiskNumber);
2243 if (!DiskEntry->Dirty)
2247 L"\\Device\\Harddisk%lu\\Partition0",
2248 DiskEntry->DiskNumber);
2276 PartitionCount = DiskEntry->LayoutBuffer->PartitionCount;
2279 BufferSize =
sizeof(DRIVE_LAYOUT_INFORMATION_EX) +
2287 DiskEntry->LayoutBuffer,
2289 DiskEntry->LayoutBuffer,
2300 DiskEntry->LayoutBuffer->PartitionCount = PartitionCount;
2305 DPRINT1(
"IOCTL_DISK_SET_DRIVE_LAYOUT failed (Status 0x%08lx)\n",
Status);
2312 for (ListEntry = DiskEntry->PrimaryPartListHead.
Flink;
2313 ListEntry != &DiskEntry->PrimaryPartListHead;
2314 ListEntry = ListEntry->
Flink)
2327 for (ListEntry = DiskEntry->LogicalPartListHead.
Flink;
2328 ListEntry != &DiskEntry->LogicalPartListHead;
2329 ListEntry = ListEntry->
Flink)
2342 DiskEntry->Dirty =
FALSE;
2360 DPRINT(
"WriteGptPartitions() Disk: %lu\n", DiskEntry->DiskNumber);
2363 if (!DiskEntry->Dirty)
2367 L"\\Device\\Harddisk%lu\\Partition0",
2368 DiskEntry->DiskNumber);
2396 BufferSize =
sizeof(DRIVE_LAYOUT_INFORMATION_EX) +
2404 DiskEntry->LayoutBuffer,
2406 DiskEntry->LayoutBuffer,
2413 DPRINT1(
"IOCTL_DISK_SET_DRIVE_LAYOUT_EX failed (Status 0x%08lx)\n",
Status);
2418 DiskEntry->Dirty =
FALSE;
2446 if ((
PartitionInfo->StartingOffset.QuadPart == PartEntry->StartSector.QuadPart * DiskEntry->BytesPerSector) &&
2447 (
PartitionInfo->PartitionLength.QuadPart == PartEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector))
2464 for (
Entry = DiskEntry->PrimaryPartListHead.Flink;
2465 Entry != &DiskEntry->PrimaryPartListHead;
2486 for (ListEntry = DiskEntry->LogicalPartListHead.
Flink;
2487 ListEntry != &DiskEntry->LogicalPartListHead;
2488 ListEntry = ListEntry->
Flink)
2504 PDRIVE_LAYOUT_INFORMATION_EX NewLayoutBuffer;
2505 ULONG NewPartitionCount;
2506 ULONG CurrentPartitionCount = 0;
2507 ULONG LayoutBufferSize;
2510 DPRINT1(
"ReAllocateLayoutBuffer()\n");
2514 if (DiskEntry->LayoutBuffer)
2515 CurrentPartitionCount = DiskEntry->LayoutBuffer->PartitionCount;
2517 DPRINT1(
"CurrentPartitionCount: %lu ; NewPartitionCount: %lu\n",
2518 CurrentPartitionCount, NewPartitionCount);
2520 if (CurrentPartitionCount == NewPartitionCount)
2523 LayoutBufferSize =
sizeof(DRIVE_LAYOUT_INFORMATION_EX) +
2527 DiskEntry->LayoutBuffer,
2529 if (NewLayoutBuffer ==
NULL)
2531 DPRINT1(
"Failed to allocate the new layout buffer (size: %lu)\n", LayoutBufferSize);
2535 NewLayoutBuffer->PartitionCount = NewPartitionCount;
2538 if (NewPartitionCount > CurrentPartitionCount)
2540 for (
i = CurrentPartitionCount;
i < NewPartitionCount;
i++)
2542 NewLayoutBuffer->PartitionEntry[
i].RewritePartition =
TRUE;
2546 DiskEntry->LayoutBuffer = NewLayoutBuffer;
2564 DPRINT(
"UpdateMbrDiskLayout()\n");
2569 DPRINT(
"ReAllocateLayoutBuffer() failed.\n");
2577 for (ListEntry = DiskEntry->PrimaryPartListHead.
Flink;
2578 ListEntry != &DiskEntry->PrimaryPartListHead;
2579 ListEntry = ListEntry->
Flink)
2598 DPRINT1(
"Updating primary partition entry %lu\n",
Index);
2622 for (ListEntry = DiskEntry->LogicalPartListHead.
Flink;
2623 ListEntry != &DiskEntry->LogicalPartListHead;
2624 ListEntry = ListEntry->
Flink)
2641 DPRINT1(
"Updating logical partition entry %lu\n",
Index);
2646 PartitionInfo->Mbr.HiddenSectors = DiskEntry->SectorAlignment;
2654 if (LinkInfo !=
NULL)
2659 HiddenSectors64.
QuadPart = PartEntry->
StartSector.
QuadPart - DiskEntry->SectorAlignment - DiskEntry->ExtendedPartition->StartSector.QuadPart;
2669 LinkInfo = &DiskEntry->LayoutBuffer->PartitionEntry[
Index + 1];
2685 DPRINT1(
"Wiping primary partition entry %lu\n",
Index);
2700 for (
Index = 4;
Index < DiskEntry->LayoutBuffer->PartitionCount;
Index++)
2725 DiskEntry->Dirty =
TRUE;
2739 DPRINT(
"UpdateGptDiskLayout()\n");
2743 for (ListEntry = DiskEntry->PrimaryPartListHead.
Flink;
2744 ListEntry != &DiskEntry->PrimaryPartListHead;
2745 ListEntry = ListEntry->
Flink)
2759 if (
Count != DiskEntry->LayoutBuffer->PartitionCount)
2761 PDRIVE_LAYOUT_INFORMATION_EX NewLayoutBuffer;
2762 ULONG NewLayoutBufferSize;
2764 NewLayoutBufferSize =
sizeof(DRIVE_LAYOUT_INFORMATION_EX) +
2768 DiskEntry->LayoutBuffer,
2769 NewLayoutBufferSize);
2770 if (NewLayoutBuffer ==
NULL)
2772 DPRINT1(
"Failed to allocate the new layout buffer (size: %lu)\n", NewLayoutBufferSize);
2776 NewLayoutBuffer->PartitionCount =
Count;
2777 DiskEntry->LayoutBuffer = NewLayoutBuffer;
2782 for (ListEntry = DiskEntry->PrimaryPartListHead.
Flink;
2783 ListEntry != &DiskEntry->PrimaryPartListHead;
2784 ListEntry = ListEntry->
Flink)
2793 DPRINT(
"Updating primary partition entry %lu\n",
Index);
2827 if (PartEntry->LogicalPartition)
2832 if (PartEntry->ListEntry.Blink != ListHead)
2840 return PrevPartEntry;
2856 if (PartEntry->LogicalPartition)
2861 if (PartEntry->ListEntry.Flink != ListHead)
2869 return NextPartEntry;
2890 if (!PartEntry->IsPartitioned ||
2897 PartEntry->PartitionNumber == 0)
2907 L"\\Device\\Harddisk%lu\\Partition%lu",
2908 PartEntry->DiskEntry->DiskNumber,
2909 PartEntry->PartitionNumber);
2926 DPRINT1(
"ERROR: Cannot open volume %wZ for dismounting! (Status 0x%lx)\n", &
Name,
Status);
2943 DPRINT1(
"WARNING: Failed to lock volume! Operations may fail! (Status 0x%lx)\n", LockStatus);
2959 DPRINT1(
"Failed to unmount volume (Status 0x%lx)\n",
Status);
2975 DPRINT1(
"Failed to unlock volume (Status 0x%lx)\n", LockStatus);
2993 if ((PartEntry ==
NULL) ||
2994 (PartEntry->DiskEntry ==
NULL))
3026 if (VolumeEntry ==
NULL)
3034 if (VolumeEntry->pszLabel)
3035 RtlFreeHeap(RtlGetProcessHeap(), 0, VolumeEntry->pszLabel);
3037 if (VolumeEntry->pszFilesystem)
3038 RtlFreeHeap(RtlGetProcessHeap(), 0, VolumeEntry->pszFilesystem);
3040 if (VolumeEntry->pExtents)
3041 RtlFreeHeap(RtlGetProcessHeap(), 0, VolumeEntry->pExtents);
#define FILE_DIRECTORY_FILE
#define PARTITION_ENTRY_UNUSED
#define PARTITION_EXTENDED
#define PARTITION_FAT32_XINT13
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
#define RegCloseKey(hKey)
while(CdLookupNextInitialFileDirent(IrpContext, Fcb, FileContext))
_In_ PFCB _In_ LONGLONG FileOffset
#define IOCTL_DISK_GET_DRIVE_GEOMETRY
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
#define NT_SUCCESS(StatCode)
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
#define INVALID_HANDLE_VALUE
#define MultiByteToWideChar
static DWORD DWORD * dwLength
DWORD WINAPI QueryDosDeviceW(LPCWSTR lpDeviceName, LPWSTR lpTargetPath, DWORD ucchMax)
BOOL WINAPI FindNextVolumeW(IN HANDLE handle, IN LPWSTR volume, IN DWORD len)
BOOL WINAPI GetVolumeInformationW(IN LPCWSTR lpRootPathName, IN LPWSTR lpVolumeNameBuffer, IN DWORD nVolumeNameSize, OUT LPDWORD lpVolumeSerialNumber OPTIONAL, OUT LPDWORD lpMaximumComponentLength OPTIONAL, OUT LPDWORD lpFileSystemFlags OPTIONAL, OUT LPWSTR lpFileSystemNameBuffer OPTIONAL, IN DWORD nFileSystemNameSize)
HANDLE WINAPI FindFirstVolumeW(IN LPWSTR volume, IN DWORD len)
BOOL WINAPI FindVolumeClose(IN HANDLE hFindVolume)
BOOL WINAPI GetVolumePathNamesForVolumeNameW(IN LPCWSTR lpszVolumeName, IN LPWSTR lpszVolumePathNames, IN DWORD cchBufferLength, OUT PDWORD lpcchReturnLength)
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
_ACRTIMP int __cdecl _wcsnicmp(const wchar_t *, const wchar_t *, size_t)
static const WCHAR Signature[]
#define RemoveEntryList(Entry)
#define InsertTailList(ListHead, Entry)
#define IsListEmpty(ListHead)
#define RemoveHeadList(ListHead)
#define InitializeListHead(ListHead)
#define IOCTL_DISK_GET_DRIVE_LAYOUT_EX
@ SystemDeviceInformation
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
_Must_inspect_result_ _Out_ PHANDLE VolumeHandle
#define FILE_SYNCHRONOUS_IO_NONALERT
@ FileFsDeviceInformation
#define FILE_OPEN_FOR_BACKUP_INTENT
union Alignment_ Alignment
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
_In_ GUID _In_ PVOID ValueData
#define OBJ_CASE_INSENSITIVE
NTSYSAPI PVOID WINAPI RtlReAllocateHeap(HANDLE, ULONG, PVOID, SIZE_T) __WINE_ALLOC_SIZE(4) __WINE_DEALLOC(RtlFreeHeap
NTSYSAPI NTSTATUS WINAPI RtlQueryRegistryValues(ULONG, PCWSTR, PRTL_QUERY_REGISTRY_TABLE, PVOID, PVOID)
struct _BIOSDISKENTRY * PBIOSDISKENTRY
struct _BIOSDISKENTRY BIOSDISKENTRY
#define InsertAscendingList(ListHead, NewEntry, Type, ListEntryField, SortField)
#define memcpy(s1, s2, n)
struct _PARTITION_INFORMATION_EX PARTITION_INFORMATION_EX
#define InitializeObjectAttributes(p, n, a, r, s)
_In_ PCWSTR _Inout_ _At_ QueryTable EntryContext
_In_ PCWSTR _Inout_ _At_ QueryTable _Pre_unknown_ PRTL_QUERY_REGISTRY_TABLE QueryTable
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)
#define FSCTL_LOCK_VOLUME
#define FILE_READ_ATTRIBUTES
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RTL_REGISTRY_ABSOLUTE
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToInteger(PUNICODE_STRING String, ULONG Base, PULONG Value)
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)
#define RTL_REGISTRY_DEVICEMAP
#define RTL_QUERY_REGISTRY_DIRECT
#define FSCTL_UNLOCK_VOLUME
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define FSCTL_DISMOUNT_VOLUME
NTSYSAPI NTSTATUS NTAPI NtFsControlFile(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)
#define FILE_REMOVABLE_MEDIA
#define REG_FULL_RESOURCE_DESCRIPTOR
#define IsContainerPartition(PartitionType)
#define IsRecognizedPartition(PartitionType)
#define IOCTL_DISK_SET_DRIVE_LAYOUT_EX
struct _VOLUME_DISK_EXTENTS VOLUME_DISK_EXTENTS
struct _DISK_EXTENT DISK_EXTENT
#define IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS
static OUT PIO_STATUS_BLOCK IoStatusBlock
#define FileFsFullSizeInformation
#define IsEqualGUID(rguid1, rguid2)
#define IOCTL_STORAGE_QUERY_PROPERTY
#define FILE_DEVICE_DISK_FILE_SYSTEM
#define FILE_DEVICE_CD_ROM
#define FILE_DEVICE_CD_ROM_FILE_SYSTEM
struct _CM_FULL_RESOURCE_DESCRIPTOR * PCM_FULL_RESOURCE_DESCRIPTOR
#define CmResourceTypeDeviceSpecific
#define IOCTL_SCSI_GET_ADDRESS
static VOID GetDriverName(IN PDISKENTRY DiskEntry)
VOID NTAPI DestroyPartitionList(IN PPARTLIST List)
static BOOLEAN IsSamePrimaryLayoutEntry(_In_ PPARTITION_INFORMATION PartitionInfo, _In_ PPARTENTRY PartEntry)
ULONGLONG AlignDown(IN ULONGLONG Value, IN ULONG Alignment)
static NTSTATUS NTAPI DiskConfigurationDataQueryRoutine(PWSTR ValueName, ULONG ValueType, PVOID ValueData, ULONG ValueLength, PVOID Context, PVOID EntryContext)
static VOID AddDiskToList(IN HANDLE FileHandle, IN ULONG DiskNumber, IN PPARTLIST List)
static NTSTATUS NTAPI SystemConfigurationDataQueryRoutine(PWSTR ValueName, ULONG ValueType, PVOID ValueData, ULONG ValueLength, PVOID Context, PVOID EntryContext)
PPARTLIST NTAPI CreatePartitionList(VOID)
static VOID EnumerateBiosDiskEntries(IN PPARTLIST PartList)
static BOOLEAN IsEmptyLayoutEntry(_In_ PPARTITION_INFORMATION PartitionInfo)
static BOOLEAN ReAllocateLayoutBuffer(IN PDISKENTRY DiskEntry)
#define GetLogicalPartitionCount(DiskEntry)
#define GetPrimaryPartitionCount(DiskEntry)
static NTSTATUS NTAPI DiskIdentifierQueryRoutine(PWSTR ValueName, ULONG ValueType, PVOID ValueData, ULONG ValueLength, PVOID Context, PVOID EntryContext)
NTSTATUS NTAPI NtQueryVolumeInformationFile(HANDLE FileHandle, PIO_STATUS_BLOCK IoStatusBlock, PVOID FsInformation, ULONG Length, FS_INFORMATION_CLASS FsInformationClass)
#define STATUS_BUFFER_TOO_SMALL
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)
NTSYSAPI NTSTATUS NTAPI NtQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInfoClass, OUT PVOID SystemInfoBuffer, IN ULONG SystemInfoBufferSize, OUT PULONG BytesReturned OPTIONAL)
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
base of all file and directory entries
CM_DISK_GEOMETRY_DEVICE_DATA DiskGeometry
CM_PARTIAL_RESOURCE_LIST PartialResourceList
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@432 u
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@432::@441 DeviceSpecificData
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]
ULARGE_INTEGER SectorCount
UNICODE_STRING DriverName
PPARTENTRY ExtendedPartition
LIST_ENTRY LogicalPartListHead
ULARGE_INTEGER StartSector
LIST_ENTRY PrimaryPartListHead
PDRIVE_LAYOUT_INFORMATION LayoutBuffer
LARGE_INTEGER StartingOffset
LARGE_INTEGER ExtentLength
struct _LIST_ENTRY * Flink
ULARGE_INTEGER SectorCount
struct _DISKENTRY * DiskEntry
ULONG OnDiskPartitionNumber
ULARGE_INTEGER StartSector
PARTITION Partition[PARTITION_TBL_SIZE]
unsigned char PartitionType
unsigned char EndingSector
unsigned char StartingHead
unsigned int StartingBlock
unsigned char EndingCylinder
unsigned char StartingSector
unsigned char StartingCylinder
PRTL_QUERY_REGISTRY_ROUTINE QueryRoutine
ULONG ProductRevisionOffset
STORAGE_QUERY_TYPE QueryType
STORAGE_PROPERTY_ID PropertyId
PVOLUME_DISK_EXTENTS pExtents
ULONG SectorsPerAllocationUnit
WCHAR VolumeName[MAX_PATH]
LIST_ENTRY ListEntry
Entry in VolumesList.
WCHAR DeviceName[MAX_PATH]
ULONG NumberOfDiskExtents
VOID UpdateMbrDiskLayout(_In_ PDISKENTRY DiskEntry)
static PDISKENTRY GetDiskForVolume(_In_ PVOLENTRY VolumeEntry)
VOID RemoveVolume(_In_ PVOLENTRY VolumeEntry)
LIST_ENTRY VolumeListHead
static VOID GetVolumeType(_In_ HANDLE VolumeHandle, _In_ PVOLENTRY VolumeEntry)
struct _PARTITION * PPARTITION
static VOID AddGptPartitionToDisk(ULONG DiskNumber, PDISKENTRY DiskEntry, ULONG PartitionIndex)
LIST_ENTRY BiosDiskListHead
PPARTENTRY GetPrevUnpartitionedEntry(_In_ PPARTENTRY PartEntry)
VOID UpdateGptDiskLayout(_In_ PDISKENTRY DiskEntry, _In_ BOOL DeleteEntry)
VOID DestroyVolumeList(VOID)
struct _PARTITION_SECTOR * PPARTITION_SECTOR
static VOID AddMbrPartitionToDisk(ULONG DiskNumber, PDISKENTRY DiskEntry, ULONG PartitionIndex, BOOLEAN LogicalPartition)
static VOID IsVolumeBoot(_In_ PVOLENTRY VolumeEntry)
#define PARTITION_TBL_SIZE
static VOID AddVolumeToList(ULONG ulVolumeNumber, PWSTR pszVolumeName)
NTSTATUS CreateVolumeList(VOID)
NTSTATUS WriteMbrPartitions(_In_ PDISKENTRY DiskEntry)
VOID ReadLayoutBuffer(_In_ HANDLE FileHandle, _In_ PDISKENTRY DiskEntry)
struct _PARTITION_SECTOR PARTITION_SECTOR
VOID ScanForUnpartitionedMbrDiskSpace(PDISKENTRY DiskEntry)
PPARTENTRY CurrentPartition
NTSTATUS WriteGptPartitions(_In_ PDISKENTRY DiskEntry)
PVOLENTRY GetVolumeFromPartition(_In_ PPARTENTRY PartEntry)
static VOID GetVolumeSize(_In_ HANDLE VolumeHandle, _In_ PVOLENTRY VolumeEntry)
PPARTENTRY GetNextUnpartitionedEntry(_In_ PPARTENTRY PartEntry)
static PPARTENTRY GetPartitionForVolume(_In_ PVOLENTRY VolumeEntry)
static VOID IsVolumeSystem(_In_ PVOLENTRY VolumeEntry)
VOID ScanForUnpartitionedGptDiskSpace(PDISKENTRY DiskEntry)
static VOID GetVolumeExtents(_In_ HANDLE VolumeHandle, _In_ PVOLENTRY VolumeEntry)
struct _PARTITION PARTITION
#define RtlZeroMemory(Destination, Length)
#define CONTAINING_RECORD(address, type, field)
#define STATUS_UNSUCCESSFUL
NTSTATUS DismountVolume(_Inout_ PVOLINFO Volume, _In_ BOOLEAN Force)
Attempts to dismount the designated volume.
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_ ULONG _Out_opt_ PULONG _Out_opt_ PULONG ValueType
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_ ULONG ValueLength
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
DWORD WINAPI GetLastError(void)
_Reserved_ PVOID Reserved
struct _STORAGE_DESCRIPTOR_HEADER * PSTORAGE_DESCRIPTOR_HEADER
struct _STORAGE_DEVICE_DESCRIPTOR * PSTORAGE_DEVICE_DESCRIPTOR
#define ERROR_UNRECOGNIZED_VOLUME
#define HKEY_LOCAL_MACHINE
struct _CM_DISK_GEOMETRY_DEVICE_DATA * PCM_DISK_GEOMETRY_DEVICE_DATA
_In_ ULONG _In_ struct _SET_PARTITION_INFORMATION_EX * PartitionInfo
_In_ ULONG _In_ ULONG PartitionNumber