ReactOS  0.4.15-dev-1623-g66cf1d2
partlist.h File Reference
#include <pshpack1.h>
#include <poppack.h>
Include dependency graph for partlist.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _PARTITION_TYPE
 
struct  _PARTENTRY
 
struct  _DISKENTRY
 
struct  _BIOSDISKENTRY
 
struct  _PARTLIST
 
struct  _PARTITION
 
struct  _PARTITION_SECTOR
 
struct  BIOS_DISK
 

Macros

#define NUM_PARTITION_TYPE_ENTRIES   143
 
#define PARTITION_EISA   0x12
 
#define PARTITION_HIBERNATION   0x84
 
#define PARTITION_DIAGNOSTIC   0xA0
 
#define PARTITION_DELL   0xDE
 
#define PARTITION_IBM   0xFE
 
#define IsOEMPartition(PartitionType)
 
#define PARTITION_TBL_SIZE   4
 
#define PARTITION_MAGIC   0xAA55
 
#define EFI_PMBR_OSTYPE_EFI   0xEE
 

Typedefs

typedef struct _PARTITION_TYPE PARTITION_TYPE
 
typedef struct _PARTITION_TYPEPPARTITION_TYPE
 
typedef enum _FORMATSTATE FORMATSTATE
 
typedef enum _FORMATSTATEPFORMATSTATE
 
typedef struct _PARTENTRY PARTENTRY
 
typedef struct _PARTENTRYPPARTENTRY
 
typedef struct _DISKENTRY DISKENTRY
 
typedef struct _DISKENTRYPDISKENTRY
 
typedef struct _BIOSDISKENTRY BIOSDISKENTRY
 
typedef struct _BIOSDISKENTRYPBIOSDISKENTRY
 
typedef struct _PARTLIST PARTLIST
 
typedef struct _PARTLISTPPARTLIST
 
typedef struct _PARTITION PARTITION
 
typedef struct _PARTITIONPPARTITION
 
typedef struct _PARTITION_SECTOR PARTITION_SECTOR
 
typedef struct _PARTITION_SECTORPPARTITION_SECTOR
 
typedef struct BIOS_DISKPBIOS_DISK
 

Enumerations

enum  _FORMATSTATE {
  Unformatted, UnformattedOrDamaged, UnknownFormat, Preformatted,
  Formatted, Unformatted, UnformattedOrDamaged, UnknownFormat,
  Preformatted, Formatted
}
 

Functions

ULONGLONG AlignDown (IN ULONGLONG Value, IN ULONG Alignment)
 
ULONGLONG AlignUp (IN ULONGLONG Value, IN ULONG Alignment)
 
ULONGLONG RoundingDivide (IN ULONGLONG Dividend, IN ULONGLONG Divisor)
 
BOOLEAN IsSuperFloppy (IN PDISKENTRY DiskEntry)
 
BOOLEAN IsPartitionActive (IN PPARTENTRY PartEntry)
 
PPARTLIST CreatePartitionList (VOID)
 
VOID DestroyPartitionList (IN PPARTLIST List)
 
PDISKENTRY GetDiskByBiosNumber (IN PPARTLIST List, IN ULONG HwDiskNumber)
 
PDISKENTRY GetDiskByNumber (IN PPARTLIST List, IN ULONG DiskNumber)
 
PDISKENTRY GetDiskBySCSI (IN PPARTLIST List, IN USHORT Port, IN USHORT Bus, IN USHORT Id)
 
PDISKENTRY GetDiskBySignature (IN PPARTLIST List, IN ULONG Signature)
 
PPARTENTRY GetPartition (IN PDISKENTRY DiskEntry, IN ULONG PartitionNumber)
 
BOOLEAN GetDiskOrPartition (IN PPARTLIST List, IN ULONG DiskNumber, IN ULONG PartitionNumber OPTIONAL, OUT PDISKENTRY *pDiskEntry, OUT PPARTENTRY *pPartEntry OPTIONAL)
 
PPARTENTRY SelectPartition (IN PPARTLIST List, IN ULONG DiskNumber, IN ULONG PartitionNumber)
 
PPARTENTRY GetNextPartition (IN PPARTLIST List, IN PPARTENTRY CurrentPart OPTIONAL)
 
PPARTENTRY GetPrevPartition (IN PPARTLIST List, IN PPARTENTRY CurrentPart OPTIONAL)
 
BOOLEAN CreatePrimaryPartition (IN PPARTLIST List, IN OUT PPARTENTRY PartEntry, IN ULONGLONG SectorCount, IN BOOLEAN AutoCreate)
 
BOOLEAN CreateExtendedPartition (IN PPARTLIST List, IN OUT PPARTENTRY PartEntry, IN ULONGLONG SectorCount)
 
BOOLEAN CreateLogicalPartition (IN PPARTLIST List, IN OUT PPARTENTRY PartEntry, IN ULONGLONG SectorCount, IN BOOLEAN AutoCreate)
 
NTSTATUS DismountVolume (IN PPARTENTRY PartEntry)
 
BOOLEAN DeletePartition (IN PPARTLIST List, IN PPARTENTRY PartEntry, OUT PPARTENTRY *FreeRegion OPTIONAL)
 
PPARTENTRY FindSupportedSystemPartition (IN PPARTLIST List, IN BOOLEAN ForceSelect, IN PDISKENTRY AlternativeDisk OPTIONAL, IN PPARTENTRY AlternativePart OPTIONAL)
 
BOOLEAN SetActivePartition (IN PPARTLIST List, IN PPARTENTRY PartEntry, IN PPARTENTRY OldActivePart OPTIONAL)
 
NTSTATUS WritePartitions (IN PDISKENTRY DiskEntry)
 
BOOLEAN WritePartitionsToDisk (IN PPARTLIST List)
 
BOOLEAN SetMountedDeviceValue (IN WCHAR Letter, IN ULONG Signature, IN LARGE_INTEGER StartingOffset)
 
BOOLEAN SetMountedDeviceValues (IN PPARTLIST List)
 
VOID SetMBRPartitionType (IN PPARTENTRY PartEntry, IN UCHAR PartitionType)
 
ERROR_NUMBER PrimaryPartitionCreationChecks (IN PPARTENTRY PartEntry)
 
ERROR_NUMBER ExtendedPartitionCreationChecks (IN PPARTENTRY PartEntry)
 
ERROR_NUMBER LogicalPartitionCreationChecks (IN PPARTENTRY PartEntry)
 
BOOLEAN GetNextUnformattedPartition (IN PPARTLIST List, OUT PDISKENTRY *pDiskEntry OPTIONAL, OUT PPARTENTRY *pPartEntry)
 
BOOLEAN GetNextUncheckedPartition (IN PPARTLIST List, OUT PDISKENTRY *pDiskEntry OPTIONAL, OUT PPARTENTRY *pPartEntry)
 

Variables

PARTITION_TYPE PartitionTypes [NUM_PARTITION_TYPE_ENTRIES]
 

Macro Definition Documentation

◆ EFI_PMBR_OSTYPE_EFI

#define EFI_PMBR_OSTYPE_EFI   0xEE

Definition at line 187 of file partlist.h.

◆ IsOEMPartition

#define IsOEMPartition (   PartitionType)
Value:
#define PARTITION_EISA
Definition: partlist.h:28
#define PARTITION_IBM
Definition: partlist.h:32
#define PARTITION_HIBERNATION
Definition: partlist.h:29
#define PARTITION_DELL
Definition: partlist.h:31
CHAR PartitionType
Definition: part_xbox.c:32
#define PARTITION_DIAGNOSTIC
Definition: partlist.h:30

Definition at line 34 of file partlist.h.

◆ NUM_PARTITION_TYPE_ENTRIES

#define NUM_PARTITION_TYPE_ENTRIES   143

Definition at line 19 of file partlist.h.

◆ PARTITION_DELL

#define PARTITION_DELL   0xDE

Definition at line 31 of file partlist.h.

◆ PARTITION_DIAGNOSTIC

#define PARTITION_DIAGNOSTIC   0xA0

Definition at line 30 of file partlist.h.

◆ PARTITION_EISA

#define PARTITION_EISA   0x12

Definition at line 28 of file partlist.h.

◆ PARTITION_HIBERNATION

#define PARTITION_HIBERNATION   0x84

Definition at line 29 of file partlist.h.

◆ PARTITION_IBM

#define PARTITION_IBM   0xFE

Definition at line 32 of file partlist.h.

◆ PARTITION_MAGIC

#define PARTITION_MAGIC   0xAA55

Definition at line 184 of file partlist.h.

◆ PARTITION_TBL_SIZE

#define PARTITION_TBL_SIZE   4

Definition at line 182 of file partlist.h.

Typedef Documentation

◆ BIOSDISKENTRY

◆ DISKENTRY

◆ FORMATSTATE

◆ PARTENTRY

◆ PARTITION

◆ PARTITION_SECTOR

◆ PARTITION_TYPE

◆ PARTLIST

◆ PBIOS_DISK

◆ PBIOSDISKENTRY

◆ PDISKENTRY

◆ PFORMATSTATE

◆ PPARTENTRY

◆ PPARTITION

◆ PPARTITION_SECTOR

◆ PPARTITION_TYPE

◆ PPARTLIST

Enumeration Type Documentation

◆ _FORMATSTATE

Enumerator
Unformatted 
UnformattedOrDamaged 
UnknownFormat 
Preformatted 
Formatted 
Unformatted 
UnformattedOrDamaged 
UnknownFormat 
Preformatted 
Formatted 

Definition at line 44 of file partlist.h.

45 {
50  Formatted
enum _FORMATSTATE FORMATSTATE
enum _FORMATSTATE * PFORMATSTATE

Function Documentation

◆ AlignDown()

ULONGLONG AlignDown ( IN ULONGLONG  Value,
IN ULONG  Alignment 
)

Definition at line 246 of file partlist.c.

249 {
250  ULONGLONG Temp;
251 
252  Temp = Value / Alignment;
253 
254  return Temp * Alignment;
255 }
union Alignment_ Alignment
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:406
uint64_t ULONGLONG
Definition: typedefs.h:67

Referenced by InitializePartitionEntry(), and ScanForUnpartitionedDiskSpace().

◆ AlignUp()

ULONGLONG AlignUp ( IN ULONGLONG  Value,
IN ULONG  Alignment 
)

Definition at line 258 of file partlist.c.

261 {
262  ULONGLONG Temp, Result;
263 
264  Temp = Value / Alignment;
265 
266  Result = Temp * Alignment;
267  if (Value % Alignment)
268  Result += Alignment;
269 
270  return Result;
271 }
union Alignment_ Alignment
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:406
uint64_t ULONGLONG
Definition: typedefs.h:67

Referenced by PeFmtCreateSection().

◆ CreateExtendedPartition()

BOOLEAN CreateExtendedPartition ( IN PPARTLIST  List,
IN OUT PPARTENTRY  PartEntry,
IN ULONGLONG  SectorCount 
)

Definition at line 3029 of file partlist.c.

3033 {
3035 
3036  DPRINT1("CreateExtendedPartition(%I64u)\n", SectorCount);
3037 
3038  if (List == NULL || PartEntry == NULL ||
3039  PartEntry->DiskEntry == NULL || PartEntry->IsPartitioned)
3040  {
3041  return FALSE;
3042  }
3043 
3045  if (Error != NOT_AN_ERROR)
3046  {
3047  DPRINT1("ExtendedPartitionCreationChecks() failed with error %lu\n", Error);
3048  return FALSE;
3049  }
3050 
3051  /* Initialize the partition entry, inserting a new blank region if needed */
3052  if (!InitializePartitionEntry(PartEntry, SectorCount, FALSE))
3053  return FALSE;
3054 
3055  ASSERT(PartEntry->LogicalPartition == FALSE);
3056 
3057  if (PartEntry->StartSector.QuadPart < 1450560)
3058  {
3059  /* Partition starts below the 8.4GB boundary ==> CHS partition */
3060  PartEntry->PartitionType = PARTITION_EXTENDED;
3061  }
3062  else
3063  {
3064  /* Partition starts above the 8.4GB boundary ==> LBA partition */
3065  PartEntry->PartitionType = PARTITION_XINT13_EXTENDED;
3066  }
3067 
3068  // FIXME? Possibly to make GetNextUnformattedPartition work (i.e. skip the extended partition container)
3069  PartEntry->New = FALSE;
3070  PartEntry->FormatState = Formatted;
3071 
3072  PartEntry->DiskEntry->ExtendedPartition = PartEntry;
3073 
3074  AddLogicalDiskSpace(PartEntry->DiskEntry);
3075 
3076  UpdateDiskLayout(PartEntry->DiskEntry);
3078 
3079  return TRUE;
3080 }
ERROR_NUMBER ExtendedPartitionCreationChecks(IN PPARTENTRY PartEntry)
Definition: partlist.c:4160
#define TRUE
Definition: types.h:120
static BOOLEAN InitializePartitionEntry(IN OUT PPARTENTRY PartEntry, IN ULONGLONG SectorCount, IN BOOLEAN AutoCreate)
Definition: partlist.c:857
#define FALSE
Definition: types.h:117
static VOID UpdateDiskLayout(IN PDISKENTRY DiskEntry)
Definition: partlist.c:2713
#define PARTITION_EXTENDED
Definition: disk.h:91
#define ASSERT(a)
Definition: mode.c:45
BOOL Error
Definition: chkdsk.c:66
enum _ERROR_NUMBER ERROR_NUMBER
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
ULONG SectorCount
Definition: part_xbox.c:31
#define PARTITION_XINT13_EXTENDED
Definition: disk.h:98
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
static VOID AddLogicalDiskSpace(IN PDISKENTRY DiskEntry)
Definition: partlist.c:3002
static VOID AssignDriveLetters(IN PPARTLIST List)
Definition: partlist.c:317

Referenced by CreateExtendedPartitionPage().

◆ CreateLogicalPartition()

BOOLEAN CreateLogicalPartition ( IN PPARTLIST  List,
IN OUT PPARTENTRY  PartEntry,
IN ULONGLONG  SectorCount,
IN BOOLEAN  AutoCreate 
)

Definition at line 3083 of file partlist.c.

3088 {
3090 
3091  DPRINT1("CreateLogicalPartition(%I64u)\n", SectorCount);
3092 
3093  if (List == NULL || PartEntry == NULL ||
3094  PartEntry->DiskEntry == NULL || PartEntry->IsPartitioned)
3095  {
3096  return FALSE;
3097  }
3098 
3100  if (Error != NOT_AN_ERROR)
3101  {
3102  DPRINT1("LogicalPartitionCreationChecks() failed with error %lu\n", Error);
3103  return FALSE;
3104  }
3105 
3106  /* Initialize the partition entry, inserting a new blank region if needed */
3107  if (!InitializePartitionEntry(PartEntry, SectorCount, AutoCreate))
3108  return FALSE;
3109 
3110  ASSERT(PartEntry->LogicalPartition == TRUE);
3111 
3112  UpdateDiskLayout(PartEntry->DiskEntry);
3114 
3115  return TRUE;
3116 }
#define TRUE
Definition: types.h:120
ERROR_NUMBER LogicalPartitionCreationChecks(IN PPARTENTRY PartEntry)
Definition: partlist.c:4191
static BOOLEAN InitializePartitionEntry(IN OUT PPARTENTRY PartEntry, IN ULONGLONG SectorCount, IN BOOLEAN AutoCreate)
Definition: partlist.c:857
#define FALSE
Definition: types.h:117
static VOID UpdateDiskLayout(IN PDISKENTRY DiskEntry)
Definition: partlist.c:2713
#define ASSERT(a)
Definition: mode.c:45
BOOL Error
Definition: chkdsk.c:66
enum _ERROR_NUMBER ERROR_NUMBER
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
ULONG SectorCount
Definition: part_xbox.c:31
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
static VOID AssignDriveLetters(IN PPARTLIST List)
Definition: partlist.c:317

Referenced by CreateLogicalPartitionPage(), and SelectPartitionPage().

◆ CreatePartitionList()

PPARTLIST CreatePartitionList ( VOID  )

Definition at line 2026 of file partlist.c.

2027 {
2028  PPARTLIST List;
2029  PDISKENTRY SystemDisk;
2033  ULONG ReturnSize;
2034  NTSTATUS Status;
2035  ULONG DiskNumber;
2039 
2041  0,
2042  sizeof(PARTLIST));
2043  if (List == NULL)
2044  return NULL;
2045 
2046  List->SystemPartition = NULL;
2047 
2048  InitializeListHead(&List->DiskListHead);
2049  InitializeListHead(&List->BiosDiskListHead);
2050 
2051  /*
2052  * Enumerate the disks seen by the BIOS; this will be used later
2053  * to map drives seen by NTOS with their corresponding BIOS names.
2054  */
2056 
2057  /* Enumerate disks seen by NTOS */
2059  &Sdi,
2060  sizeof(Sdi),
2061  &ReturnSize);
2062  if (!NT_SUCCESS(Status))
2063  {
2064  DPRINT1("NtQuerySystemInformation() failed, Status 0x%08lx", Status);
2066  return NULL;
2067  }
2068 
2069  for (DiskNumber = 0; DiskNumber < Sdi.NumberOfDisks; DiskNumber++)
2070  {
2072  L"\\Device\\Harddisk%lu\\Partition0",
2073  DiskNumber);
2075 
2077  &Name,
2079  NULL,
2080  NULL);
2081 
2085  &Iosb,
2088  if (NT_SUCCESS(Status))
2089  {
2090  AddDiskToList(FileHandle, DiskNumber, List);
2092  }
2093  }
2094 
2098 
2099  /*
2100  * Retrieve the system partition: the active partition on the system
2101  * disk (the one that will be booted by default by the hardware).
2102  */
2103  SystemDisk = GetSystemDisk(List);
2104  List->SystemPartition = (SystemDisk ? GetActiveDiskPartition(SystemDisk) : NULL);
2105 
2106  return List;
2107 }
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)
struct _PARTLIST * PPARTLIST
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
static PPARTENTRY GetActiveDiskPartition(IN PDISKENTRY DiskEntry)
Definition: partlist.c:1970
NTSTRSAFEVAPI RtlStringCchPrintfW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
Definition: ntstrsafe.h:1110
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
static VOID UpdateDiskSignatures(IN PPARTLIST List)
Definition: partlist.c:1394
#define FILE_SHARE_READ
Definition: compat.h:136
HANDLE FileHandle
Definition: stats.c:38
#define FILE_READ_DATA
Definition: nt_native.h:628
struct NameRec_ * Name
Definition: cdprocs.h:459
Definition: bufpool.h:45
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
Status
Definition: gdiplustypes.h:24
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:4402
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static VOID UpdateHwDiskNumbers(IN PPARTLIST List)
Definition: partlist.c:1424
#define MAX_PATH
Definition: compat.h:34
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
#define FILE_READ_ATTRIBUTES
Definition: nt_native.h:647
static PDISKENTRY GetSystemDisk(IN PPARTLIST List)
Definition: partlist.c:1897
static const WCHAR L[]
Definition: oid.c:1250
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
#define SYNCHRONIZE
Definition: nt_native.h:61
HANDLE ProcessHeap
Definition: servman.c:15
static VOID EnumerateBiosDiskEntries(IN PPARTLIST PartList)
Definition: partlist.c:516
static VOID AddDiskToList(IN HANDLE FileHandle, IN ULONG DiskNumber, IN PPARTLIST List)
Definition: partlist.c:1485
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
#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
static VOID AssignDriveLetters(IN PPARTLIST List)
Definition: partlist.c:317

◆ CreatePrimaryPartition()

BOOLEAN CreatePrimaryPartition ( IN PPARTLIST  List,
IN OUT PPARTENTRY  PartEntry,
IN ULONGLONG  SectorCount,
IN BOOLEAN  AutoCreate 
)

Definition at line 2965 of file partlist.c.

2970 {
2972 
2973  DPRINT1("CreatePrimaryPartition(%I64u)\n", SectorCount);
2974 
2975  if (List == NULL || PartEntry == NULL ||
2976  PartEntry->DiskEntry == NULL || PartEntry->IsPartitioned)
2977  {
2978  return FALSE;
2979  }
2980 
2982  if (Error != NOT_AN_ERROR)
2983  {
2984  DPRINT1("PrimaryPartitionCreationChecks() failed with error %lu\n", Error);
2985  return FALSE;
2986  }
2987 
2988  /* Initialize the partition entry, inserting a new blank region if needed */
2989  if (!InitializePartitionEntry(PartEntry, SectorCount, AutoCreate))
2990  return FALSE;
2991 
2992  ASSERT(PartEntry->LogicalPartition == FALSE);
2993 
2994  UpdateDiskLayout(PartEntry->DiskEntry);
2996 
2997  return TRUE;
2998 }
#define TRUE
Definition: types.h:120
static BOOLEAN InitializePartitionEntry(IN OUT PPARTENTRY PartEntry, IN ULONGLONG SectorCount, IN BOOLEAN AutoCreate)
Definition: partlist.c:857
#define FALSE
Definition: types.h:117
static VOID UpdateDiskLayout(IN PDISKENTRY DiskEntry)
Definition: partlist.c:2713
ERROR_NUMBER PrimaryPartitionCreationChecks(IN PPARTENTRY PartEntry)
Definition: partlist.c:4133
#define ASSERT(a)
Definition: mode.c:45
BOOL Error
Definition: chkdsk.c:66
enum _ERROR_NUMBER ERROR_NUMBER
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
ULONG SectorCount
Definition: part_xbox.c:31
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
static VOID AssignDriveLetters(IN PPARTLIST List)
Definition: partlist.c:317

Referenced by CreatePrimaryPartitionPage(), SelectFileSystemPage(), and SelectPartitionPage().

◆ DeletePartition()

BOOLEAN DeletePartition ( IN PPARTLIST  List,
IN PPARTENTRY  PartEntry,
OUT PPARTENTRY *FreeRegion  OPTIONAL 
)

Definition at line 3226 of file partlist.c.

3230 {
3231  PDISKENTRY DiskEntry;
3232  PPARTENTRY PrevPartEntry;
3233  PPARTENTRY NextPartEntry;
3234  PPARTENTRY LogicalPartEntry;
3236 
3237  if (List == NULL || PartEntry == NULL ||
3238  PartEntry->DiskEntry == NULL || PartEntry->IsPartitioned == FALSE)
3239  {
3240  return FALSE;
3241  }
3242 
3243  ASSERT(PartEntry->PartitionType != PARTITION_ENTRY_UNUSED);
3244 
3245  /* Clear the system partition if it is being deleted */
3246  if (List->SystemPartition == PartEntry)
3247  {
3248  ASSERT(List->SystemPartition);
3249  List->SystemPartition = NULL;
3250  }
3251 
3252  DiskEntry = PartEntry->DiskEntry;
3253 
3254  /* Check which type of partition (primary/logical or extended) is being deleted */
3255  if (DiskEntry->ExtendedPartition == PartEntry)
3256  {
3257  /* An extended partition is being deleted: delete all logical partition entries */
3258  while (!IsListEmpty(&DiskEntry->LogicalPartListHead))
3259  {
3260  Entry = RemoveHeadList(&DiskEntry->LogicalPartListHead);
3261  LogicalPartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
3262 
3263  /* Dismount the logical partition */
3264  DismountVolume(LogicalPartEntry);
3265 
3266  /* Delete it */
3267  RtlFreeHeap(ProcessHeap, 0, LogicalPartEntry);
3268  }
3269 
3270  DiskEntry->ExtendedPartition = NULL;
3271  }
3272  else
3273  {
3274  /* A primary partition is being deleted: dismount it */
3275  DismountVolume(PartEntry);
3276  }
3277 
3278  /* Adjust the unpartitioned disk space entries */
3279 
3280  /* Get pointer to previous and next unpartitioned entries */
3281  PrevPartEntry = GetPrevUnpartitionedEntry(PartEntry);
3282  NextPartEntry = GetNextUnpartitionedEntry(PartEntry);
3283 
3284  if (PrevPartEntry != NULL && NextPartEntry != NULL)
3285  {
3286  /* Merge the previous, current and next unpartitioned entries */
3287 
3288  /* Adjust the previous entry length */
3289  PrevPartEntry->SectorCount.QuadPart += (PartEntry->SectorCount.QuadPart + NextPartEntry->SectorCount.QuadPart);
3290 
3291  /* Remove the current and next entries */
3292  RemoveEntryList(&PartEntry->ListEntry);
3293  RtlFreeHeap(ProcessHeap, 0, PartEntry);
3294  RemoveEntryList(&NextPartEntry->ListEntry);
3295  RtlFreeHeap(ProcessHeap, 0, NextPartEntry);
3296 
3297  /* Optionally return the freed region */
3298  if (FreeRegion)
3299  *FreeRegion = PrevPartEntry;
3300  }
3301  else if (PrevPartEntry != NULL && NextPartEntry == NULL)
3302  {
3303  /* Merge the current and the previous unpartitioned entries */
3304 
3305  /* Adjust the previous entry length */
3306  PrevPartEntry->SectorCount.QuadPart += PartEntry->SectorCount.QuadPart;
3307 
3308  /* Remove the current entry */
3309  RemoveEntryList(&PartEntry->ListEntry);
3310  RtlFreeHeap(ProcessHeap, 0, PartEntry);
3311 
3312  /* Optionally return the freed region */
3313  if (FreeRegion)
3314  *FreeRegion = PrevPartEntry;
3315  }
3316  else if (PrevPartEntry == NULL && NextPartEntry != NULL)
3317  {
3318  /* Merge the current and the next unpartitioned entries */
3319 
3320  /* Adjust the next entry offset and length */
3321  NextPartEntry->StartSector.QuadPart = PartEntry->StartSector.QuadPart;
3322  NextPartEntry->SectorCount.QuadPart += PartEntry->SectorCount.QuadPart;
3323 
3324  /* Remove the current entry */
3325  RemoveEntryList(&PartEntry->ListEntry);
3326  RtlFreeHeap(ProcessHeap, 0, PartEntry);
3327 
3328  /* Optionally return the freed region */
3329  if (FreeRegion)
3330  *FreeRegion = NextPartEntry;
3331  }
3332  else
3333  {
3334  /* Nothing to merge but change the current entry */
3335  PartEntry->IsPartitioned = FALSE;
3336  PartEntry->OnDiskPartitionNumber = 0;
3337  PartEntry->PartitionNumber = 0;
3338  // PartEntry->PartitionIndex = 0;
3339  PartEntry->BootIndicator = FALSE;
3340  PartEntry->PartitionType = PARTITION_ENTRY_UNUSED;
3341  PartEntry->FormatState = Unformatted;
3342  PartEntry->FileSystem[0] = L'\0';
3343  PartEntry->DriveLetter = 0;
3344  RtlZeroMemory(PartEntry->VolumeLabel, sizeof(PartEntry->VolumeLabel));
3345 
3346  /* Optionally return the freed region */
3347  if (FreeRegion)
3348  *FreeRegion = PartEntry;
3349  }
3350 
3351  UpdateDiskLayout(DiskEntry);
3353 
3354  return TRUE;
3355 }
ULARGE_INTEGER StartSector
Definition: partlist.h:61
struct _Entry Entry
Definition: kefuncs.h:627
#define TRUE
Definition: types.h:120
ULARGE_INTEGER SectorCount
Definition: partlist.h:62
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
PPARTENTRY ExtendedPartition
Definition: partlist.h:147
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
#define PARTITION_ENTRY_UNUSED
Definition: disk.h:86
LIST_ENTRY ListEntry
Definition: partlist.h:55
NTSTATUS DismountVolume(IN PPARTENTRY PartEntry)
Definition: partlist.c:3119
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
#define FALSE
Definition: types.h:117
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
static VOID UpdateDiskLayout(IN PDISKENTRY DiskEntry)
Definition: partlist.c:2713
#define ASSERT(a)
Definition: mode.c:45
static const WCHAR L[]
Definition: oid.c:1250
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
Definition: typedefs.h:119
HANDLE ProcessHeap
Definition: servman.c:15
static PPARTENTRY GetPrevUnpartitionedEntry(IN PPARTENTRY PartEntry)
Definition: partlist.c:2896
#define NULL
Definition: types.h:112
LIST_ENTRY LogicalPartListHead
Definition: partlist.h:144
static PPARTENTRY GetNextUnpartitionedEntry(IN PPARTENTRY PartEntry)
Definition: partlist.c:2931
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
base of all file and directory entries
Definition: entries.h:82
static VOID AssignDriveLetters(IN PPARTLIST List)
Definition: partlist.c:317
BOOLEAN IsPartitioned
Definition: partlist.h:78

Referenced by DeletePartitionPage().

◆ DestroyPartitionList()

VOID DestroyPartitionList ( IN PPARTLIST  List)

Definition at line 2110 of file partlist.c.

2112 {
2113  PDISKENTRY DiskEntry;
2114  PBIOSDISKENTRY BiosDiskEntry;
2115  PPARTENTRY PartEntry;
2117 
2118  /* Release disk and partition info */
2119  while (!IsListEmpty(&List->DiskListHead))
2120  {
2121  Entry = RemoveHeadList(&List->DiskListHead);
2122  DiskEntry = CONTAINING_RECORD(Entry, DISKENTRY, ListEntry);
2123 
2124  /* Release driver name */
2125  RtlFreeUnicodeString(&DiskEntry->DriverName);
2126 
2127  /* Release primary partition list */
2128  while (!IsListEmpty(&DiskEntry->PrimaryPartListHead))
2129  {
2130  Entry = RemoveHeadList(&DiskEntry->PrimaryPartListHead);
2131  PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
2132 
2133  RtlFreeHeap(ProcessHeap, 0, PartEntry);
2134  }
2135 
2136  /* Release logical partition list */
2137  while (!IsListEmpty(&DiskEntry->LogicalPartListHead))
2138  {
2139  Entry = RemoveHeadList(&DiskEntry->LogicalPartListHead);
2140  PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
2141 
2142  RtlFreeHeap(ProcessHeap, 0, PartEntry);
2143  }
2144 
2145  /* Release layout buffer */
2146  if (DiskEntry->LayoutBuffer != NULL)
2147  RtlFreeHeap(ProcessHeap, 0, DiskEntry->LayoutBuffer);
2148 
2149  /* Release disk entry */
2150  RtlFreeHeap(ProcessHeap, 0, DiskEntry);
2151  }
2152 
2153  /* Release the bios disk info */
2154  while (!IsListEmpty(&List->BiosDiskListHead))
2155  {
2156  Entry = RemoveHeadList(&List->BiosDiskListHead);
2157  BiosDiskEntry = CONTAINING_RECORD(Entry, BIOSDISKENTRY, ListEntry);
2158 
2159  RtlFreeHeap(ProcessHeap, 0, BiosDiskEntry);
2160  }
2161 
2162  /* Release list head */
2164 }
LIST_ENTRY PrimaryPartListHead
Definition: partlist.h:143
struct _Entry Entry
Definition: kefuncs.h:627
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
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:135
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
Definition: typedefs.h:119
HANDLE ProcessHeap
Definition: servman.c:15
#define NULL
Definition: types.h:112
LIST_ENTRY LogicalPartListHead
Definition: partlist.h:144
PDRIVE_LAYOUT_INFORMATION LayoutBuffer
Definition: partlist.h:137
base of all file and directory entries
Definition: entries.h:82

Referenced by QuitPage(), rescan_main(), SelectPartitionPage(), and wmain().

◆ DismountVolume()

NTSTATUS DismountVolume ( IN PPARTENTRY  PartEntry)

Definition at line 3119 of file partlist.c.

3121 {
3122  NTSTATUS Status;
3123  NTSTATUS LockStatus;
3127  HANDLE PartitionHandle;
3129 
3130  /* Check whether the partition is valid and was mounted by the system */
3131  if (!PartEntry->IsPartitioned ||
3132  IsContainerPartition(PartEntry->PartitionType) ||
3133  !IsRecognizedPartition(PartEntry->PartitionType) ||
3134  PartEntry->FormatState == UnknownFormat ||
3135  // NOTE: If FormatState == Unformatted but *FileSystem != 0 this means
3136  // it has been usually mounted with RawFS and thus needs to be dismounted.
3137  !*PartEntry->FileSystem ||
3138  PartEntry->PartitionNumber == 0)
3139  {
3140  /* The partition is not mounted, so just return success */
3141  return STATUS_SUCCESS;
3142  }
3143 
3144  ASSERT(PartEntry->PartitionType != PARTITION_ENTRY_UNUSED);
3145 
3146  /* Open the volume */
3148  L"\\Device\\Harddisk%lu\\Partition%lu",
3149  PartEntry->DiskEntry->DiskNumber,
3150  PartEntry->PartitionNumber);
3152 
3154  &Name,
3156  NULL,
3157  NULL);
3158 
3159  Status = NtOpenFile(&PartitionHandle,
3162  &IoStatusBlock,
3165  if (!NT_SUCCESS(Status))
3166  {
3167  DPRINT1("ERROR: Cannot open volume %wZ for dismounting! (Status 0x%lx)\n", &Name, Status);
3168  return Status;
3169  }
3170 
3171  /* Lock the volume */
3172  LockStatus = NtFsControlFile(PartitionHandle,
3173  NULL,
3174  NULL,
3175  NULL,
3176  &IoStatusBlock,
3178  NULL,
3179  0,
3180  NULL,
3181  0);
3182  if (!NT_SUCCESS(LockStatus))
3183  {
3184  DPRINT1("WARNING: Failed to lock volume! Operations may fail! (Status 0x%lx)\n", LockStatus);
3185  }
3186 
3187  /* Dismount the volume */
3188  Status = NtFsControlFile(PartitionHandle,
3189  NULL,
3190  NULL,
3191  NULL,
3192  &IoStatusBlock,
3194  NULL,
3195  0,
3196  NULL,
3197  0);
3198  if (!NT_SUCCESS(Status))
3199  {
3200  DPRINT1("Failed to unmount volume (Status 0x%lx)\n", Status);
3201  }
3202 
3203  /* Unlock the volume */
3204  LockStatus = NtFsControlFile(PartitionHandle,
3205  NULL,
3206  NULL,
3207  NULL,
3208  &IoStatusBlock,
3210  NULL,
3211  0,
3212  NULL,
3213  0);
3214  if (!NT_SUCCESS(LockStatus))
3215  {
3216  DPRINT1("Failed to unlock volume (Status 0x%lx)\n", LockStatus);
3217  }
3218 
3219  /* Close the volume */
3220  NtClose(PartitionHandle);
3221 
3222  return Status;
3223 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define FSCTL_UNLOCK_VOLUME
Definition: nt_native.h:833
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
NTSTRSAFEVAPI RtlStringCchPrintfW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
Definition: ntstrsafe.h:1110
LONG NTSTATUS
Definition: precomp.h:26
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define IsContainerPartition(PartitionType)
Definition: ntdddisk.h:316
NTSYSCALLAPI NTSTATUS NTAPI NtFsControlFile(HANDLE FileHandle, HANDLE Event, PIO_APC_ROUTINE ApcRoutine, PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, ULONG FsControlCode, PVOID InputBuffer, ULONG InputBufferLength, PVOID OutputBuffer, ULONG OutputBufferLength)
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_SHARE_READ
Definition: compat.h:136
#define PARTITION_ENTRY_UNUSED
Definition: disk.h:86
#define GENERIC_WRITE
Definition: nt_native.h:90
struct NameRec_ * Name
Definition: cdprocs.h:459
Definition: bufpool.h:45
#define FSCTL_DISMOUNT_VOLUME
Definition: nt_native.h:834
Status
Definition: gdiplustypes.h:24
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
#define ASSERT(a)
Definition: mode.c:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define IsRecognizedPartition(PartitionType)
Definition: ntdddisk.h:342
#define MAX_PATH
Definition: compat.h:34
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
static const WCHAR L[]
Definition: oid.c:1250
#define GENERIC_READ
Definition: compat.h:135
#define SYNCHRONIZE
Definition: nt_native.h:61
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
#define FSCTL_LOCK_VOLUME
Definition: nt_native.h:832
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by AddPartitionToDisk(), and DeletePartition().

◆ ExtendedPartitionCreationChecks()

ERROR_NUMBER ExtendedPartitionCreationChecks ( IN PPARTENTRY  PartEntry)

Definition at line 4160 of file partlist.c.

4162 {
4163  PDISKENTRY DiskEntry = PartEntry->DiskEntry;
4164 
4165  if (DiskEntry->DiskStyle == PARTITION_STYLE_GPT)
4166  {
4167  DPRINT1("GPT-partitioned disk detected, not currently supported by SETUP!\n");
4168  return ERROR_WARN_PARTITION;
4169  }
4170 
4171  /* Fail if the partition is already in use */
4172  if (PartEntry->IsPartitioned)
4173  return ERROR_NEW_PARTITION;
4174 
4175  /* Only one primary partition is allowed on super-floppy */
4176  if (IsSuperFloppy(DiskEntry))
4178 
4179  /* Fail if there are already 4 primary partitions in the list */
4180  if (GetPrimaryPartitionCount(DiskEntry) >= 4)
4182 
4183  /* Fail if there is another extended partition in the list */
4184  if (DiskEntry->ExtendedPartition != NULL)
4185  return ERROR_ONLY_ONE_EXTENDED;
4186 
4187  return ERROR_SUCCESS;
4188 }
#define ERROR_SUCCESS
Definition: deptool.c:10
PPARTENTRY ExtendedPartition
Definition: partlist.h:147
PARTITION_STYLE DiskStyle
Definition: partlist.h:133
static ULONG GetPrimaryPartitionCount(IN PDISKENTRY DiskEntry)
Definition: partlist.c:2607
BOOLEAN IsSuperFloppy(IN PDISKENTRY DiskEntry)
Definition: partlist.c:680
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8

Referenced by CreateExtendedPartition(), and SelectPartitionPage().

◆ FindSupportedSystemPartition()

PPARTENTRY FindSupportedSystemPartition ( IN PPARTLIST  List,
IN BOOLEAN  ForceSelect,
IN PDISKENTRY AlternativeDisk  OPTIONAL,
IN PPARTENTRY AlternativePart  OPTIONAL 
)

Definition at line 3439 of file partlist.c.

3444 {
3445  PLIST_ENTRY ListEntry;
3446  PDISKENTRY DiskEntry;
3447  PPARTENTRY PartEntry;
3448  PPARTENTRY ActivePartition;
3449  PPARTENTRY CandidatePartition = NULL;
3450 
3451  /* Check for empty disk list */
3452  if (IsListEmpty(&List->DiskListHead))
3453  {
3454  /* No system partition! */
3455  ASSERT(List->SystemPartition == NULL);
3456  goto NoSystemPartition;
3457  }
3458 
3459  /* Adjust the optional alternative disk if needed */
3460  if (!AlternativeDisk && AlternativePart)
3461  AlternativeDisk = AlternativePart->DiskEntry;
3462 
3463  /* Ensure that the alternative partition is on the alternative disk */
3464  if (AlternativePart)
3465  ASSERT(AlternativeDisk && (AlternativePart->DiskEntry == AlternativeDisk));
3466 
3467  /* Ensure that the alternative disk is in the list */
3468  if (AlternativeDisk)
3469  ASSERT(AlternativeDisk->PartList == List);
3470 
3471  /* Start fresh */
3472  CandidatePartition = NULL;
3473 
3474 //
3475 // Step 1 : Check the system disk.
3476 //
3477 
3478  /*
3479  * First, check whether the system disk, i.e. the one that will be booted
3480  * by default by the hardware, contains an active partition. If so this
3481  * should be our system partition.
3482  */
3483  DiskEntry = GetSystemDisk(List);
3484 
3485  if (DiskEntry->DiskStyle == PARTITION_STYLE_GPT)
3486  {
3487  DPRINT1("System disk -- GPT-partitioned disk detected, not currently supported by SETUP!\n");
3488  goto UseAlternativeDisk;
3489  }
3490 
3491  /* If we have a system partition (in the system disk), validate it */
3492  ActivePartition = List->SystemPartition;
3493  if (ActivePartition && IsSupportedActivePartition(ActivePartition))
3494  {
3495  CandidatePartition = ActivePartition;
3496 
3497  DPRINT1("Use the current system partition %lu in disk %lu, drive letter %C\n",
3498  CandidatePartition->PartitionNumber,
3499  CandidatePartition->DiskEntry->DiskNumber,
3500  (CandidatePartition->DriveLetter == 0) ? L'-' : CandidatePartition->DriveLetter);
3501 
3502  /* Return the candidate system partition */
3503  return CandidatePartition;
3504  }
3505 
3506  /* If the system disk is not the optional alternative disk, perform the minimal checks */
3507  if (DiskEntry != AlternativeDisk)
3508  {
3509  /*
3510  * No active partition has been recognized. Enumerate all the (primary)
3511  * partitions in the system disk, excluding the possible current active
3512  * partition, to find a new candidate.
3513  */
3514  for (ListEntry = DiskEntry->PrimaryPartListHead.Flink;
3515  ListEntry != &DiskEntry->PrimaryPartListHead;
3516  ListEntry = ListEntry->Flink)
3517  {
3518  /* Retrieve the partition */
3519  PartEntry = CONTAINING_RECORD(ListEntry, PARTENTRY, ListEntry);
3520 
3521  /* Skip the current active partition */
3522  if (PartEntry == ActivePartition)
3523  continue;
3524 
3525  /* Check if the partition is partitioned and used */
3526  if (PartEntry->IsPartitioned &&
3527  !IsContainerPartition(PartEntry->PartitionType))
3528  {
3530 
3531  /* If we get a candidate active partition in the disk, validate it */
3532  if (IsSupportedActivePartition(PartEntry))
3533  {
3534  CandidatePartition = PartEntry;
3535  goto UseAlternativePartition;
3536  }
3537  }
3538 
3539 #if 0
3540  /* Check if the partition is partitioned and used */
3541  if (!PartEntry->IsPartitioned)
3542  {
3544 
3545  // TODO: Check for minimal size!!
3546  CandidatePartition = PartEntry;
3547  goto UseAlternativePartition;
3548  }
3549 #endif
3550  }
3551 
3552  /*
3553  * Still nothing, look whether there is some free space that we can use
3554  * for the new system partition. We must be sure that the total number
3555  * of partition is less than the maximum allowed, and that the minimal
3556  * size is fine.
3557  */
3558 //
3559 // TODO: Fix the handling of system partition being created in unpartitioned space!!
3560 // --> When to partition it? etc...
3561 //
3562  if (GetPrimaryPartitionCount(DiskEntry) < 4)
3563  {
3564  for (ListEntry = DiskEntry->PrimaryPartListHead.Flink;
3565  ListEntry != &DiskEntry->PrimaryPartListHead;
3566  ListEntry = ListEntry->Flink)
3567  {
3568  /* Retrieve the partition */
3569  PartEntry = CONTAINING_RECORD(ListEntry, PARTENTRY, ListEntry);
3570 
3571  /* Skip the current active partition */
3572  if (PartEntry == ActivePartition)
3573  continue;
3574 
3575  /* Check for unpartitioned space */
3576  if (!PartEntry->IsPartitioned)
3577  {
3579 
3580  // TODO: Check for minimal size!!
3581  CandidatePartition = PartEntry;
3582  goto UseAlternativePartition;
3583  }
3584  }
3585  }
3586  }
3587 
3588 
3589 //
3590 // Step 2 : No active partition found: Check the alternative disk if specified.
3591 //
3592 
3593 UseAlternativeDisk:
3594  if (!AlternativeDisk || (!ForceSelect && (DiskEntry != AlternativeDisk)))
3595  goto NoSystemPartition;
3596 
3597  if (AlternativeDisk->DiskStyle == PARTITION_STYLE_GPT)
3598  {
3599  DPRINT1("Alternative disk -- GPT-partitioned disk detected, not currently supported by SETUP!\n");
3600  goto NoSystemPartition;
3601  }
3602 
3603  if (DiskEntry != AlternativeDisk)
3604  {
3605  /* Choose the alternative disk */
3606  DiskEntry = AlternativeDisk;
3607 
3608  /* If we get a candidate active partition, validate it */
3609  ActivePartition = GetActiveDiskPartition(DiskEntry);
3610  if (ActivePartition && IsSupportedActivePartition(ActivePartition))
3611  {
3612  CandidatePartition = ActivePartition;
3613  goto UseAlternativePartition;
3614  }
3615  }
3616 
3617  /* We now may have an unsupported active partition, or none */
3618 
3619 /***
3620  *** TODO: Improve the selection:
3621  *** - If we want a really separate system partition from the partition where
3622  *** we install, do something similar to what's done below in the code.
3623  *** - Otherwise if we allow for the system partition to be also the partition
3624  *** where we install, just directly fall down to using AlternativePart.
3625  ***/
3626 
3627  /* Retrieve the first partition of the disk */
3628  PartEntry = CONTAINING_RECORD(DiskEntry->PrimaryPartListHead.Flink,
3629  PARTENTRY, ListEntry);
3630  ASSERT(DiskEntry == PartEntry->DiskEntry);
3631 
3632  CandidatePartition = PartEntry;
3633 
3634  //
3635  // See: https://svn.reactos.org/svn/reactos/trunk/reactos/base/setup/usetup/partlist.c?r1=63355&r2=63354&pathrev=63355#l2318
3636  //
3637 
3638  /* Check if the disk is new and if so, use its first partition as the active system partition */
3639  if (DiskEntry->NewDisk)
3640  {
3641  // !IsContainerPartition(PartEntry->PartitionType);
3642  if (!CandidatePartition->IsPartitioned || !CandidatePartition->BootIndicator) /* CandidatePartition != ActivePartition */
3643  {
3644  ASSERT(DiskEntry == CandidatePartition->DiskEntry);
3645 
3646  DPRINT1("Use new first active system partition %lu in disk %lu, drive letter %C\n",
3647  CandidatePartition->PartitionNumber,
3648  CandidatePartition->DiskEntry->DiskNumber,
3649  (CandidatePartition->DriveLetter == 0) ? L'-' : CandidatePartition->DriveLetter);
3650 
3651  /* Return the candidate system partition */
3652  return CandidatePartition;
3653  }
3654 
3655  // FIXME: What to do??
3656  DPRINT1("NewDisk TRUE but first partition is used?\n");
3657  }
3658 
3659  /*
3660  * The disk is not new, check if any partition is initialized;
3661  * if not, the first one becomes the system partition.
3662  */
3663  for (ListEntry = DiskEntry->PrimaryPartListHead.Flink;
3664  ListEntry != &DiskEntry->PrimaryPartListHead;
3665  ListEntry = ListEntry->Flink)
3666  {
3667  /* Retrieve the partition */
3668  PartEntry = CONTAINING_RECORD(ListEntry, PARTENTRY, ListEntry);
3669 
3670  /* Check if the partition is partitioned and is used */
3671  // !IsContainerPartition(PartEntry->PartitionType);
3672  if (/* PartEntry->IsPartitioned && */
3673  PartEntry->PartitionType != PARTITION_ENTRY_UNUSED || PartEntry->BootIndicator)
3674  {
3675  break;
3676  }
3677  }
3678  if (ListEntry == &DiskEntry->PrimaryPartListHead)
3679  {
3680  /*
3681  * OK we haven't encountered any used and active partition,
3682  * so use the first one as the system partition.
3683  */
3684  ASSERT(DiskEntry == CandidatePartition->DiskEntry);
3685 
3686  DPRINT1("Use first active system partition %lu in disk %lu, drive letter %C\n",
3687  CandidatePartition->PartitionNumber,
3688  CandidatePartition->DiskEntry->DiskNumber,
3689  (CandidatePartition->DriveLetter == 0) ? L'-' : CandidatePartition->DriveLetter);
3690 
3691  /* Return the candidate system partition */
3692  return CandidatePartition;
3693  }
3694 
3695  /*
3696  * The disk is not new, we did not find any actual active partition,
3697  * or the one we found was not supported, or any possible other candidate
3698  * is not supported. We then use the alternative partition if specified.
3699  */
3700  if (AlternativePart)
3701  {
3702  DPRINT1("No valid or supported system partition has been found, use the alternative partition!\n");
3703  CandidatePartition = AlternativePart;
3704  goto UseAlternativePartition;
3705  }
3706  else
3707  {
3708 NoSystemPartition:
3709  DPRINT1("No valid or supported system partition has been found on this system!\n");
3710  return NULL;
3711  }
3712 
3713 UseAlternativePartition:
3714  /*
3715  * We are here because we did not find any (active) candidate system
3716  * partition that we know how to support. What we are going to do is
3717  * to change the existing system partition and use the alternative partition
3718  * (e.g. on which we install ReactOS) as the new system partition.
3719  * Then we will need to add in FreeLdr's boot menu an entry for booting
3720  * from the original system partition.
3721  */
3722  ASSERT(CandidatePartition);
3723 
3724  DPRINT1("Use alternative active system partition %lu in disk %lu, drive letter %C\n",
3725  CandidatePartition->PartitionNumber,
3726  CandidatePartition->DiskEntry->DiskNumber,
3727  (CandidatePartition->DriveLetter == 0) ? L'-' : CandidatePartition->DriveLetter);
3728 
3729  /* Return the candidate system partition */
3730  return CandidatePartition;
3731 }
LIST_ENTRY PrimaryPartListHead
Definition: partlist.h:143
WCHAR DriveLetter
Definition: partlist.h:70
ULONG PartitionNumber
Definition: partlist.h:67
static PPARTENTRY GetActiveDiskPartition(IN PDISKENTRY DiskEntry)
Definition: partlist.c:1970
static BOOLEAN IsSupportedActivePartition(IN PPARTENTRY PartEntry)
Definition: partlist.c:3359
#define IsContainerPartition(PartitionType)
Definition: ntdddisk.h:316
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
#define PARTITION_ENTRY_UNUSED
Definition: disk.h:86
PARTITION_STYLE DiskStyle
Definition: partlist.h:133
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 _LIST_ENTRY * Flink
Definition: typedefs.h:121
UCHAR PartitionType
Definition: partlist.h:65
struct _DISKENTRY * DiskEntry
Definition: partlist.h:58
#define ASSERT(a)
Definition: mode.c:45
static ULONG GetPrimaryPartitionCount(IN PDISKENTRY DiskEntry)
Definition: partlist.c:2607
static PDISKENTRY GetSystemDisk(IN PPARTLIST List)
Definition: partlist.c:1897
static const WCHAR L[]
Definition: oid.c:1250
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
Definition: typedefs.h:119
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
BOOLEAN BootIndicator
Definition: partlist.h:64
BOOLEAN NewDisk
Definition: partlist.h:132
BOOLEAN IsPartitioned
Definition: partlist.h:78

Referenced by SelectFileSystemPage().

◆ GetDiskByBiosNumber()

PDISKENTRY GetDiskByBiosNumber ( IN PPARTLIST  List,
IN ULONG  HwDiskNumber 
)

Definition at line 2167 of file partlist.c.

2170 {
2171  PDISKENTRY DiskEntry;
2173 
2174  /* Loop over the disks and find the correct one */
2175  for (Entry = List->DiskListHead.Flink;
2176  Entry != &List->DiskListHead;
2177  Entry = Entry->Flink)
2178  {
2179  DiskEntry = CONTAINING_RECORD(Entry, DISKENTRY, ListEntry);
2180 
2181  if (DiskEntry->HwDiskNumber == HwDiskNumber)
2182  {
2183  /* Disk found */
2184  return DiskEntry;
2185  }
2186  }
2187 
2188  /* Disk not found, stop there */
2189  return NULL;
2190 }
struct _Entry Entry
Definition: kefuncs.h:627
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
ULONG HwDiskNumber
Definition: partlist.h:117
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
Definition: typedefs.h:119
#define NULL
Definition: types.h:112
base of all file and directory entries
Definition: entries.h:82

◆ GetDiskByNumber()

PDISKENTRY GetDiskByNumber ( IN PPARTLIST  List,
IN ULONG  DiskNumber 
)

Definition at line 2193 of file partlist.c.

2196 {
2197  PDISKENTRY DiskEntry;
2199 
2200  /* Loop over the disks and find the correct one */
2201  for (Entry = List->DiskListHead.Flink;
2202  Entry != &List->DiskListHead;
2203  Entry = Entry->Flink)
2204  {
2205  DiskEntry = CONTAINING_RECORD(Entry, DISKENTRY, ListEntry);
2206 
2207  if (DiskEntry->DiskNumber == DiskNumber)
2208  {
2209  /* Disk found */
2210  return DiskEntry;
2211  }
2212  }
2213 
2214  /* Disk not found, stop there */
2215  return NULL;
2216 }
struct _Entry Entry
Definition: kefuncs.h:627
ULONG DiskNumber
Definition: partlist.h:123
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
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
Definition: typedefs.h:119
#define NULL
Definition: types.h:112
base of all file and directory entries
Definition: entries.h:82

Referenced by GetDiskOrPartition(), and SelectPartition().

◆ GetDiskBySCSI()

PDISKENTRY GetDiskBySCSI ( IN PPARTLIST  List,
IN USHORT  Port,
IN USHORT  Bus,
IN USHORT  Id 
)

Definition at line 2219 of file partlist.c.

2224 {
2225  PDISKENTRY DiskEntry;
2227 
2228  /* Loop over the disks and find the correct one */
2229  for (Entry = List->DiskListHead.Flink;
2230  Entry != &List->DiskListHead;
2231  Entry = Entry->Flink)
2232  {
2233  DiskEntry = CONTAINING_RECORD(Entry, DISKENTRY, ListEntry);
2234 
2235  if (DiskEntry->Port == Port &&
2236  DiskEntry->Bus == Bus &&
2237  DiskEntry->Id == Id)
2238  {
2239  /* Disk found */
2240  return DiskEntry;
2241  }
2242  }
2243 
2244  /* Disk not found, stop there */
2245  return NULL;
2246 }
CPPORT Port[4]
Definition: headless.c:35
USHORT Id
Definition: partlist.h:127
struct _Entry Entry
Definition: kefuncs.h:627
USHORT Bus
Definition: partlist.h:126
DWORD Id
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
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
Definition: typedefs.h:119
USHORT Port
Definition: partlist.h:125
#define NULL
Definition: types.h:112
base of all file and directory entries
Definition: entries.h:82

Referenced by ResolveArcNameManually().

◆ GetDiskBySignature()

PDISKENTRY GetDiskBySignature ( IN PPARTLIST  List,
IN ULONG  Signature 
)

Definition at line 2249 of file partlist.c.

2252 {
2253  PDISKENTRY DiskEntry;
2255 
2256  /* Loop over the disks and find the correct one */
2257  for (Entry = List->DiskListHead.Flink;
2258  Entry != &List->DiskListHead;
2259  Entry = Entry->Flink)
2260  {
2261  DiskEntry = CONTAINING_RECORD(Entry, DISKENTRY, ListEntry);
2262 
2263  if (DiskEntry->LayoutBuffer->Signature == Signature)
2264  {
2265  /* Disk found */
2266  return DiskEntry;
2267  }
2268  }
2269 
2270  /* Disk not found, stop there */
2271  return NULL;
2272 }
struct _Entry Entry
Definition: kefuncs.h:627
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
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
Definition: typedefs.h:119
#define NULL
Definition: types.h:112
static const WCHAR Signature[]
Definition: parser.c:141
PDRIVE_LAYOUT_INFORMATION LayoutBuffer
Definition: partlist.h:137
base of all file and directory entries
Definition: entries.h:82

Referenced by ResolveArcNameManually().

◆ GetDiskOrPartition()

BOOLEAN GetDiskOrPartition ( IN PPARTLIST  List,
IN ULONG  DiskNumber,
IN ULONG PartitionNumber  OPTIONAL,
OUT PDISKENTRY pDiskEntry,
OUT PPARTENTRY *pPartEntry  OPTIONAL 
)

Definition at line 2322 of file partlist.c.

2328 {
2329  PDISKENTRY DiskEntry;
2330  PPARTENTRY PartEntry = NULL;
2331 
2332  /* Find the disk */
2333  DiskEntry = GetDiskByNumber(List, DiskNumber);
2334  if (!DiskEntry)
2335  return FALSE;
2336 
2337  /* If we have a partition (PartitionNumber != 0), find it */
2338  if (PartitionNumber != 0)
2339  {
2340  if (DiskEntry->DiskStyle == PARTITION_STYLE_GPT)
2341  {
2342  DPRINT("GPT-partitioned disk detected, not currently supported by SETUP!\n");
2343  return FALSE;
2344  }
2345 
2346  PartEntry = GetPartition(/*List,*/ DiskEntry, PartitionNumber);
2347  if (!PartEntry)
2348  return FALSE;
2349  ASSERT(PartEntry->DiskEntry == DiskEntry);
2350  }
2351 
2352  /* Return the disk (and optionally the partition) */
2353  *pDiskEntry = DiskEntry;
2354  if (pPartEntry) *pPartEntry = PartEntry;
2355  return TRUE;
2356 }
#define TRUE
Definition: types.h:120
_In_ ULONG _In_ ULONG PartitionNumber
Definition: iofuncs.h:2056
PPARTENTRY GetPartition(IN PDISKENTRY DiskEntry, IN ULONG PartitionNumber)
Definition: partlist.c:2275
PARTITION_STYLE DiskStyle
Definition: partlist.h:133
#define FALSE
Definition: types.h:117
void DPRINT(...)
Definition: polytest.cpp:61
PDISKENTRY GetDiskByNumber(IN PPARTLIST List, IN ULONG DiskNumber)
Definition: partlist.c:2193
struct _DISKENTRY * DiskEntry
Definition: partlist.h:58
#define ASSERT(a)
Definition: mode.c:45
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
#define NULL
Definition: types.h:112

Referenced by EnumerateInstallations().

◆ GetNextPartition()

PPARTENTRY GetNextPartition ( IN PPARTLIST  List,
IN PPARTENTRY CurrentPart  OPTIONAL 
)

Definition at line 2386 of file partlist.c.

2389 {
2390  PLIST_ENTRY DiskListEntry;
2391  PLIST_ENTRY PartListEntry;
2393 
2394  /* Fail if no disks are available */
2395  if (IsListEmpty(&List->DiskListHead))
2396  return NULL;
2397 
2398  /* Check for the next usable entry on the current partition's disk */
2399  if (CurrentPart != NULL)
2400  {
2401  CurrentDisk = CurrentPart->DiskEntry;
2402 
2403  if (CurrentPart->LogicalPartition)
2404  {
2405  /* Logical partition */
2406 
2407  PartListEntry = CurrentPart->ListEntry.Flink;
2408  if (PartListEntry != &CurrentDisk->LogicalPartListHead)
2409  {
2410  /* Next logical partition */
2411  CurrentPart = CONTAINING_RECORD(PartListEntry, PARTENTRY, ListEntry);
2412  return CurrentPart;
2413  }
2414  else
2415  {
2416  PartListEntry = CurrentDisk->ExtendedPartition->ListEntry.Flink;
2417  if (PartListEntry != &CurrentDisk->PrimaryPartListHead)
2418  {
2419  CurrentPart = CONTAINING_RECORD(PartListEntry, PARTENTRY, ListEntry);
2420  return CurrentPart;
2421  }
2422  }
2423  }
2424  else
2425  {
2426  /* Primary or extended partition */
2427 
2428  if (CurrentPart->IsPartitioned &&
2429  IsContainerPartition(CurrentPart->PartitionType))
2430  {
2431  /* First logical partition */
2432  PartListEntry = CurrentDisk->LogicalPartListHead.Flink;
2433  if (PartListEntry != &CurrentDisk->LogicalPartListHead)
2434  {
2435  CurrentPart = CONTAINING_RECORD(PartListEntry, PARTENTRY, ListEntry);
2436  return CurrentPart;
2437  }
2438  }
2439  else
2440  {
2441  /* Next primary partition */
2442  PartListEntry = CurrentPart->ListEntry.Flink;
2443  if (PartListEntry != &CurrentDisk->PrimaryPartListHead)
2444  {
2445  CurrentPart = CONTAINING_RECORD(PartListEntry, PARTENTRY, ListEntry);
2446  return CurrentPart;
2447  }
2448  }
2449  }
2450  }
2451 
2452  /* Search for the first partition entry on the next disk */
2453  for (DiskListEntry = (CurrentPart ? CurrentDisk->ListEntry.Flink
2454  : List->DiskListHead.Flink);
2455  DiskListEntry != &List->DiskListHead;
2456  DiskListEntry = DiskListEntry->Flink)
2457  {
2458  CurrentDisk = CONTAINING_RECORD(DiskListEntry, DISKENTRY, ListEntry);
2459 
2461  {
2462  DPRINT("GPT-partitioned disk detected, not currently supported by SETUP!\n");
2463  continue;
2464  }
2465 
2466  PartListEntry = CurrentDisk->PrimaryPartListHead.Flink;
2467  if (PartListEntry != &CurrentDisk->PrimaryPartListHead)
2468  {
2469  CurrentPart = CONTAINING_RECORD(PartListEntry, PARTENTRY, ListEntry);
2470  return CurrentPart;
2471  }
2472  }
2473 
2474  return NULL;
2475 }
LIST_ENTRY PrimaryPartListHead
Definition: partlist.h:143
PDISKENTRY CurrentDisk
Definition: partlist.c:73
#define IsContainerPartition(PartitionType)
Definition: ntdddisk.h:316
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
PPARTENTRY ExtendedPartition
Definition: partlist.h:147
LIST_ENTRY ListEntry
Definition: partlist.h:55
PARTITION_STYLE DiskStyle
Definition: partlist.h:133
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
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
LIST_ENTRY ListEntry
Definition: partlist.h:95
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
Definition: typedefs.h:119
#define NULL
Definition: types.h:112
LIST_ENTRY LogicalPartListHead
Definition: partlist.h:144

Referenced by ScrollDownPartitionList().

◆ GetNextUncheckedPartition()

BOOLEAN GetNextUncheckedPartition ( IN PPARTLIST  List,
OUT PDISKENTRY *pDiskEntry  OPTIONAL,
OUT PPARTENTRY pPartEntry 
)

Definition at line 4273 of file partlist.c.

4277 {
4278  PLIST_ENTRY Entry1, Entry2;
4279  PDISKENTRY DiskEntry;
4280  PPARTENTRY PartEntry;
4281 
4282  for (Entry1 = List->DiskListHead.Flink;
4283  Entry1 != &List->DiskListHead;
4284  Entry1 = Entry1->Flink)
4285  {
4286  DiskEntry = CONTAINING_RECORD(Entry1,
4287  DISKENTRY,
4288  ListEntry);
4289 
4290  if (DiskEntry->DiskStyle == PARTITION_STYLE_GPT)
4291  {
4292  DPRINT("GPT-partitioned disk detected, not currently supported by SETUP!\n");
4293  continue;
4294  }
4295 
4296  for (Entry2 = DiskEntry->PrimaryPartListHead.Flink;
4297  Entry2 != &DiskEntry->PrimaryPartListHead;
4298  Entry2 = Entry2->Flink)
4299  {
4300  PartEntry = CONTAINING_RECORD(Entry2, PARTENTRY, ListEntry);
4301  if (PartEntry->IsPartitioned && PartEntry->NeedsCheck)
4302  {
4303  ASSERT(DiskEntry == PartEntry->DiskEntry);
4304  if (pDiskEntry) *pDiskEntry = DiskEntry;
4305  *pPartEntry = PartEntry;
4306  return TRUE;
4307  }
4308  }
4309 
4310  for (Entry2 = DiskEntry->LogicalPartListHead.Flink;
4311  Entry2 != &DiskEntry->LogicalPartListHead;
4312  Entry2 = Entry2->Flink)
4313  {
4314  PartEntry = CONTAINING_RECORD(Entry2, PARTENTRY, ListEntry);
4315  if (PartEntry->IsPartitioned && PartEntry->NeedsCheck)
4316  {
4317  ASSERT(DiskEntry == PartEntry->DiskEntry);
4318  if (pDiskEntry) *pDiskEntry = DiskEntry;
4319  *pPartEntry = PartEntry;
4320  return TRUE;
4321  }
4322  }
4323  }
4324 
4325  if (pDiskEntry) *pDiskEntry = NULL;
4326  *pPartEntry = NULL;
4327 
4328  return FALSE;
4329 }
LIST_ENTRY PrimaryPartListHead
Definition: partlist.h:143
#define TRUE
Definition: types.h:120
PARTITION_STYLE DiskStyle
Definition: partlist.h:133
#define FALSE
Definition: types.h:117
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
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
struct _DISKENTRY * DiskEntry
Definition: partlist.h:58
#define ASSERT(a)
Definition: mode.c:45
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
Definition: typedefs.h:119
BOOLEAN NeedsCheck
Definition: partlist.h:89
#define NULL
Definition: types.h:112
LIST_ENTRY LogicalPartListHead
Definition: partlist.h:144
BOOLEAN IsPartitioned
Definition: partlist.h:78

Referenced by CheckFileSystemPage().

◆ GetNextUnformattedPartition()

BOOLEAN GetNextUnformattedPartition ( IN PPARTLIST  List,
OUT PDISKENTRY *pDiskEntry  OPTIONAL,
OUT PPARTENTRY pPartEntry 
)

Definition at line 4214 of file partlist.c.

4218 {
4219  PLIST_ENTRY Entry1, Entry2;
4220  PDISKENTRY DiskEntry;
4221  PPARTENTRY PartEntry;
4222 
4223  for (Entry1 = List->DiskListHead.Flink;
4224  Entry1 != &List->DiskListHead;
4225  Entry1 = Entry1->Flink)
4226  {
4227  DiskEntry = CONTAINING_RECORD(Entry1,
4228  DISKENTRY,
4229  ListEntry);
4230 
4231  if (DiskEntry->DiskStyle == PARTITION_STYLE_GPT)
4232  {
4233  DPRINT("GPT-partitioned disk detected, not currently supported by SETUP!\n");
4234  continue;
4235  }
4236 
4237  for (Entry2 = DiskEntry->PrimaryPartListHead.Flink;
4238  Entry2 != &DiskEntry->PrimaryPartListHead;
4239  Entry2 = Entry2->Flink)
4240  {
4241  PartEntry = CONTAINING_RECORD(Entry2, PARTENTRY, ListEntry);
4242  if (PartEntry->IsPartitioned && PartEntry->New)
4243  {
4244  ASSERT(DiskEntry == PartEntry->DiskEntry);
4245  if (pDiskEntry) *pDiskEntry = DiskEntry;
4246  *pPartEntry = PartEntry;
4247  return TRUE;
4248  }
4249  }
4250 
4251  for (Entry2 = DiskEntry->LogicalPartListHead.Flink;
4252  Entry2 != &DiskEntry->LogicalPartListHead;
4253  Entry2 = Entry2->Flink)
4254  {
4255  PartEntry = CONTAINING_RECORD(Entry2, PARTENTRY, ListEntry);
4256  if (PartEntry->IsPartitioned && PartEntry->New)
4257  {
4258  ASSERT(DiskEntry == PartEntry->DiskEntry);
4259  if (pDiskEntry) *pDiskEntry = DiskEntry;
4260  *pPartEntry = PartEntry;
4261  return TRUE;
4262  }
4263  }
4264  }
4265 
4266  if (pDiskEntry) *pDiskEntry = NULL;
4267  *pPartEntry = NULL;
4268 
4269  return FALSE;
4270 }
LIST_ENTRY PrimaryPartListHead
Definition: partlist.h:143
#define TRUE
Definition: types.h:120
PARTITION_STYLE DiskStyle
Definition: partlist.h:133
#define FALSE
Definition: types.h:117
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
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
struct _DISKENTRY * DiskEntry
Definition: partlist.h:58
#define ASSERT(a)
Definition: mode.c:45
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
Definition: typedefs.h:119
BOOLEAN New
Definition: partlist.h:83
#define NULL
Definition: types.h:112
LIST_ENTRY LogicalPartListHead
Definition: partlist.h:144
BOOLEAN IsPartitioned
Definition: partlist.h:78

Referenced by SelectFileSystemPage().

◆ GetPartition()

PPARTENTRY GetPartition ( IN PDISKENTRY  DiskEntry,
IN ULONG  PartitionNumber 
)

Definition at line 2275 of file partlist.c.

2279 {
2280  PPARTENTRY PartEntry;
2282 
2283  if (DiskEntry->DiskStyle == PARTITION_STYLE_GPT)
2284  {
2285  DPRINT("GPT-partitioned disk detected, not currently supported by SETUP!\n");
2286  return NULL;
2287  }
2288 
2289  /* Disk found, loop over the primary partitions first... */
2290  for (Entry = DiskEntry->PrimaryPartListHead.Flink;
2291  Entry != &DiskEntry->PrimaryPartListHead;
2292  Entry = Entry->Flink)
2293  {
2294  PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
2295 
2296  if (PartEntry->PartitionNumber == PartitionNumber)
2297  {
2298  /* Partition found */
2299  return PartEntry;
2300  }
2301  }
2302 
2303  /* ... then over the logical partitions if needed */
2304  for (Entry = DiskEntry->LogicalPartListHead.Flink;
2305  Entry != &DiskEntry->LogicalPartListHead;
2306  Entry = Entry->Flink)
2307  {
2308  PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
2309 
2310  if (PartEntry->PartitionNumber == PartitionNumber)
2311  {
2312  /* Partition found */
2313  return PartEntry;
2314  }
2315  }
2316 
2317  /* The partition was not found on the disk, stop there */
2318  return NULL;
2319 }
ULONG PartitionNumber
Definition: partlist.h:67
struct _Entry Entry
Definition: kefuncs.h:627
_In_ ULONG _In_ ULONG PartitionNumber
Definition: iofuncs.h:2056
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
Definition: typedefs.h:119
#define NULL
Definition: types.h:112
base of all file and directory entries
Definition: entries.h:82

Referenced by GetDiskOrPartition(), ResolveArcNameManually(), and SelectPartition().

◆ GetPrevPartition()

PPARTENTRY GetPrevPartition ( IN PPARTLIST  List,
IN PPARTENTRY CurrentPart  OPTIONAL 
)

Definition at line 2478 of file partlist.c.

2481 {
2482  PLIST_ENTRY DiskListEntry;
2483  PLIST_ENTRY PartListEntry;
2485 
2486  /* Fail if no disks are available */
2487  if (IsListEmpty(&List->DiskListHead))
2488  return NULL;
2489 
2490  /* Check for the previous usable entry on the current partition's disk */
2491  if (CurrentPart != NULL)
2492  {
2493  CurrentDisk = CurrentPart->DiskEntry;
2494 
2495  if (CurrentPart->LogicalPartition)
2496  {
2497  /* Logical partition */
2498 
2499  PartListEntry = CurrentPart->ListEntry.Blink;
2500  if (PartListEntry != &CurrentDisk->LogicalPartListHead)
2501  {
2502  /* Previous logical partition */
2503  CurrentPart = CONTAINING_RECORD(PartListEntry, PARTENTRY, ListEntry);
2504  }
2505  else
2506  {
2507  /* Extended partition */
2508  CurrentPart = CurrentDisk->ExtendedPartition;
2509  }
2510  return CurrentPart;
2511  }
2512  else
2513  {
2514  /* Primary or extended partition */
2515 
2516  PartListEntry = CurrentPart->ListEntry.Blink;
2517  if (PartListEntry != &CurrentDisk->PrimaryPartListHead)
2518  {
2519  CurrentPart = CONTAINING_RECORD(PartListEntry, PARTENTRY, ListEntry);
2520 
2521  if (CurrentPart->IsPartitioned &&
2522  IsContainerPartition(CurrentPart->PartitionType))
2523  {
2524  PartListEntry = CurrentDisk->LogicalPartListHead.Blink;
2525  CurrentPart = CONTAINING_RECORD(PartListEntry, PARTENTRY, ListEntry);
2526  }
2527 
2528  return CurrentPart;
2529  }
2530  }
2531  }
2532 
2533  /* Search for the last partition entry on the previous disk */
2534  for (DiskListEntry = (CurrentPart ? CurrentDisk->ListEntry.Blink
2535  : List->DiskListHead.Blink);
2536  DiskListEntry != &List->DiskListHead;
2537  DiskListEntry = DiskListEntry->Blink)
2538  {
2539  CurrentDisk = CONTAINING_RECORD(DiskListEntry, DISKENTRY, ListEntry);
2540 
2542  {
2543  DPRINT("GPT-partitioned disk detected, not currently supported by SETUP!\n");
2544  continue;
2545  }
2546 
2547  PartListEntry = CurrentDisk->PrimaryPartListHead.Blink;
2548  if (PartListEntry != &CurrentDisk->PrimaryPartListHead)
2549  {
2550  CurrentPart = CONTAINING_RECORD(PartListEntry, PARTENTRY, ListEntry);
2551 
2552  if (CurrentPart->IsPartitioned &&
2553  IsContainerPartition(CurrentPart->PartitionType))
2554  {
2555  PartListEntry = CurrentDisk->LogicalPartListHead.Blink;
2556  if (PartListEntry != &CurrentDisk->LogicalPartListHead)
2557  {
2558  CurrentPart = CONTAINING_RECORD(PartListEntry, PARTENTRY, ListEntry);
2559  return CurrentPart;
2560  }
2561  }
2562  else
2563  {
2564  return CurrentPart;
2565  }
2566  }
2567  }
2568 
2569  return NULL;
2570 }
LIST_ENTRY PrimaryPartListHead
Definition: partlist.h:143
PDISKENTRY CurrentDisk
Definition: partlist.c:73
struct _LIST_ENTRY * Blink
Definition: typedefs.h:122
#define IsContainerPartition(PartitionType)
Definition: ntdddisk.h:316
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
PPARTENTRY ExtendedPartition
Definition: partlist.h:147
PARTITION_STYLE DiskStyle
Definition: partlist.h:133
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
LIST_ENTRY ListEntry
Definition: partlist.h:95
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
Definition: typedefs.h:119
#define NULL
Definition: types.h:112
LIST_ENTRY LogicalPartListHead
Definition: partlist.h:144

Referenced by ScrollUpPartitionList().

◆ IsPartitionActive()

BOOLEAN IsPartitionActive ( IN PPARTENTRY  PartEntry)

Definition at line 1947 of file partlist.c.

1949 {
1950  // TODO: Support for GPT disks!
1951 
1952  if (IsContainerPartition(PartEntry->PartitionType))
1953  return FALSE;
1954 
1955  /* Check if the partition is partitioned, used and active */
1956  if (PartEntry->IsPartitioned &&
1957  // !IsContainerPartition(PartEntry->PartitionType) &&
1958  PartEntry->BootIndicator)
1959  {
1960  /* Yes it is */
1961  ASSERT(PartEntry->PartitionType != PARTITION_ENTRY_UNUSED);
1962  return TRUE;
1963  }
1964 
1965  return FALSE;
1966 }
#define TRUE
Definition: types.h:120
#define IsContainerPartition(PartitionType)
Definition: ntdddisk.h:316
#define PARTITION_ENTRY_UNUSED
Definition: disk.h:86
#define FALSE
Definition: types.h:117
#define ASSERT(a)
Definition: mode.c:45

Referenced by GetActiveDiskPartition(), SelectPartitionPage(), and SetActivePartition().

◆ IsSuperFloppy()

BOOLEAN IsSuperFloppy ( IN PDISKENTRY  DiskEntry)

Definition at line 680 of file partlist.c.

682 {
684  ULONGLONG PartitionLengthEstimate;
685 
686  /* No layout buffer: we cannot say anything yet */
687  if (DiskEntry->LayoutBuffer == NULL)
688  return FALSE;
689 
690  /* We must have only one partition */
691  if (DiskEntry->LayoutBuffer->PartitionCount != 1)
692  return FALSE;
693 
694  /* Get the single partition entry */
695  PartitionInfo = DiskEntry->LayoutBuffer->PartitionEntry;
696 
697  /* The single partition must start at the beginning of the disk */
698  if (!(PartitionInfo->StartingOffset.QuadPart == 0 &&
699  PartitionInfo->HiddenSectors == 0))
700  {
701  return FALSE;
702  }
703 
704  /* The disk signature is usually set to one; warn in case it's not */
705  if (DiskEntry->LayoutBuffer->Signature != 1)
706  {
707  DPRINT1("Super-Floppy disk %lu signature %08x != 1!\n",
708  DiskEntry->DiskNumber, DiskEntry->LayoutBuffer->Signature);
709  }
710 
711  /*
712  * The partition number must be zero or one, be recognized,
713  * have FAT16 type and report as non-bootable.
714  */
715  if ((PartitionInfo->PartitionNumber != 0 &&
716  PartitionInfo->PartitionNumber != 1) ||
717  PartitionInfo->RecognizedPartition != TRUE ||
718  PartitionInfo->PartitionType != PARTITION_FAT_16 ||
719  PartitionInfo->BootIndicator != FALSE)
720  {
721  DPRINT1("Super-Floppy disk %lu does not return default settings!\n"
722  " PartitionNumber = %lu, expected 0\n"
723  " RecognizedPartition = %s, expected TRUE\n"
724  " PartitionType = 0x%02x, expected 0x04 (PARTITION_FAT_16)\n"
725  " BootIndicator = %s, expected FALSE\n",
726  DiskEntry->DiskNumber,
727  PartitionInfo->PartitionNumber,
728  PartitionInfo->RecognizedPartition ? "TRUE" : "FALSE",
729  PartitionInfo->PartitionType,
730  PartitionInfo->BootIndicator ? "TRUE" : "FALSE");
731  }
732 
733  /* The partition lengths should agree */
734  PartitionLengthEstimate = DiskEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
735  if (PartitionInfo->PartitionLength.QuadPart != PartitionLengthEstimate)
736  {
737  DPRINT1("PartitionLength = %I64u is different from PartitionLengthEstimate = %I64u\n",
738  PartitionInfo->PartitionLength.QuadPart, PartitionLengthEstimate);
739  }
740 
741  return TRUE;
742 }
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
uint64_t ULONGLONG
Definition: typedefs.h:67
_In_ ULONG _In_ struct _SET_PARTITION_INFORMATION_EX * PartitionInfo
Definition: iofuncs.h:2101
#define PARTITION_FAT_16
Definition: disk.h:90
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8

Referenced by AddDiskToList(), BootLoaderHarddiskMbrPage(), ExtendedPartitionCreationChecks(), LogicalPartitionCreationChecks(), PrimaryPartitionCreationChecks(), and xHalIoWritePartitionTable().

◆ LogicalPartitionCreationChecks()

ERROR_NUMBER LogicalPartitionCreationChecks ( IN PPARTENTRY  PartEntry)

Definition at line 4191 of file partlist.c.

4193 {
4194  PDISKENTRY DiskEntry = PartEntry->DiskEntry;
4195 
4196  if (DiskEntry->DiskStyle == PARTITION_STYLE_GPT)
4197  {
4198  DPRINT1("GPT-partitioned disk detected, not currently supported by SETUP!\n");
4199  return ERROR_WARN_PARTITION;
4200  }
4201 
4202  /* Fail if the partition is already in use */
4203  if (PartEntry->IsPartitioned)
4204  return ERROR_NEW_PARTITION;
4205 
4206  /* Only one primary partition is allowed on super-floppy */
4207  if (IsSuperFloppy(DiskEntry))
4209 
4210  return ERROR_SUCCESS;
4211 }
#define ERROR_SUCCESS
Definition: deptool.c:10
PARTITION_STYLE DiskStyle
Definition: partlist.h:133
BOOLEAN IsSuperFloppy(IN PDISKENTRY DiskEntry)
Definition: partlist.c:680
#define DPRINT1
Definition: precomp.h:8

Referenced by CreateLogicalPartition(), and SelectPartitionPage().

◆ PrimaryPartitionCreationChecks()

ERROR_NUMBER PrimaryPartitionCreationChecks ( IN PPARTENTRY  PartEntry)

Definition at line 4133 of file partlist.c.

4135 {
4136  PDISKENTRY DiskEntry = PartEntry->DiskEntry;
4137 
4138  if (DiskEntry->DiskStyle == PARTITION_STYLE_GPT)
4139  {
4140  DPRINT1("GPT-partitioned disk detected, not currently supported by SETUP!\n");
4141  return ERROR_WARN_PARTITION;
4142  }
4143 
4144  /* Fail if the partition is already in use */
4145  if (PartEntry->IsPartitioned)
4146  return ERROR_NEW_PARTITION;
4147 
4148  /* Only one primary partition is allowed on super-floppy */
4149  if (IsSuperFloppy(DiskEntry))
4151 
4152  /* Fail if there are already 4 primary partitions in the list */
4153  if (GetPrimaryPartitionCount(DiskEntry) >= 4)
4155 
4156  return ERROR_SUCCESS;
4157 }
#define ERROR_SUCCESS
Definition: deptool.c:10
PARTITION_STYLE DiskStyle
Definition: partlist.h:133
static ULONG GetPrimaryPartitionCount(IN PDISKENTRY DiskEntry)
Definition: partlist.c:2607
BOOLEAN IsSuperFloppy(IN PDISKENTRY DiskEntry)
Definition: partlist.c:680
#define DPRINT1
Definition: precomp.h:8

Referenced by CreatePrimaryPartition(), and SelectPartitionPage().

◆ RoundingDivide()

ULONGLONG RoundingDivide ( IN ULONGLONG  Dividend,
IN ULONGLONG  Divisor 
)

Definition at line 274 of file partlist.c.

277 {
278  return (Dividend + Divisor / 2) / Divisor;
279 }
_In_ LARGE_INTEGER Divisor
Definition: rtlfuncs.h:3046

Referenced by PrintDiskData(), and PrintPartitionData().

◆ SelectPartition()

PPARTENTRY SelectPartition ( IN PPARTLIST  List,
IN ULONG  DiskNumber,
IN ULONG  PartitionNumber 
)

Definition at line 2362 of file partlist.c.

2366 {
2367  PDISKENTRY DiskEntry;
2368  PPARTENTRY PartEntry;
2369 
2370  DiskEntry = GetDiskByNumber(List, DiskNumber);
2371  if (!DiskEntry)
2372  return NULL;
2373 
2374  PartEntry = GetPartition(/*List,*/ DiskEntry, PartitionNumber);
2375  if (!PartEntry)
2376  return NULL;
2377 
2378  ASSERT(PartEntry->DiskEntry == DiskEntry);
2379  ASSERT(DiskEntry->DiskNumber == DiskNumber);
2380  ASSERT(PartEntry->PartitionNumber == PartitionNumber);
2381 
2382  return PartEntry;
2383 }
ULONG PartitionNumber
Definition: partlist.h:67
ULONG DiskNumber
Definition: partlist.h:123
_In_ ULONG _In_ ULONG PartitionNumber
Definition: iofuncs.h:2056
PPARTENTRY GetPartition(IN PDISKENTRY DiskEntry, IN ULONG PartitionNumber)
Definition: partlist.c:2275
PDISKENTRY GetDiskByNumber(IN PPARTLIST List, IN ULONG DiskNumber)
Definition: partlist.c:2193
struct _DISKENTRY * DiskEntry
Definition: partlist.h:58
#define ASSERT(a)
Definition: mode.c:45
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
#define NULL
Definition: types.h:112

Referenced by SelectPartitionPage().

◆ SetActivePartition()

BOOLEAN SetActivePartition ( IN PPARTLIST  List,
IN PPARTENTRY  PartEntry,
IN PPARTENTRY OldActivePart  OPTIONAL 
)

Definition at line 3734 of file partlist.c.

3738 {
3739  /* Check for empty disk list */
3740  if (IsListEmpty(&List->DiskListHead))
3741  return FALSE;
3742 
3743  /* Validate the partition entry */
3744  if (!PartEntry)
3745  return FALSE;
3746 
3747  /*
3748  * If the partition entry is already the system partition, or if it is
3749  * the same as the old active partition hint the user provided (and if
3750  * it is already active), just return success.
3751  */
3752  if ((PartEntry == List->SystemPartition) ||
3753  ((PartEntry == OldActivePart) && IsPartitionActive(OldActivePart)))
3754  {
3755  return TRUE;
3756  }
3757 
3758  ASSERT(PartEntry->DiskEntry);
3759 
3760  /* Ensure that the partition's disk is in the list */
3761  ASSERT(PartEntry->DiskEntry->PartList == List);
3762 
3763  /*
3764  * If the user provided an old active partition hint, verify that it is
3765  * indeeed active and belongs to the same disk where the new partition
3766  * belongs. Otherwise determine the current active partition on the disk
3767  * where the new partition belongs.
3768  */
3769  if (!(OldActivePart && IsPartitionActive(OldActivePart) && (OldActivePart->DiskEntry == PartEntry->DiskEntry)))
3770  {
3771  /* It's not, determine the current active partition for the disk */
3772  OldActivePart = GetActiveDiskPartition(PartEntry->DiskEntry);
3773  }
3774 
3775  /* Unset the old active partition if it exists */
3776  if (OldActivePart)
3777  {
3778  OldActivePart->BootIndicator = FALSE;
3779  OldActivePart->DiskEntry->LayoutBuffer->PartitionEntry[OldActivePart->PartitionIndex].BootIndicator = FALSE;
3780  OldActivePart->DiskEntry->LayoutBuffer->PartitionEntry[OldActivePart->PartitionIndex].RewritePartition = TRUE;
3781  OldActivePart->DiskEntry->Dirty = TRUE;
3782  }
3783 
3784  /* Modify the system partition if the new partition is on the system disk */
3785  if (PartEntry->DiskEntry == GetSystemDisk(List))
3786  List->SystemPartition = PartEntry;
3787 
3788  /* Set the new active partition */
3789  PartEntry->BootIndicator = TRUE;
3790  PartEntry->DiskEntry->LayoutBuffer->PartitionEntry[PartEntry->PartitionIndex].BootIndicator = TRUE;
3791  PartEntry->DiskEntry->LayoutBuffer->PartitionEntry[PartEntry->PartitionIndex].RewritePartition = TRUE;
3792  PartEntry->DiskEntry->Dirty = TRUE;
3793 
3794  return TRUE;
3795 }
static PPARTENTRY GetActiveDiskPartition(IN PDISKENTRY DiskEntry)
Definition: partlist.c:1970
#define TRUE
Definition: types.h:120
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
#define FALSE
Definition: types.h:117
#define ASSERT(a)
Definition: mode.c:45
static PDISKENTRY GetSystemDisk(IN PPARTLIST List)
Definition: partlist.c:1897
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
BOOLEAN IsPartitionActive(IN PPARTENTRY PartEntry)
Definition: partlist.c:1947

Referenced by SelectFileSystemPage().

◆ SetMBRPartitionType()

VOID SetMBRPartitionType ( IN PPARTENTRY  PartEntry,
IN UCHAR  PartitionType 
)

Definition at line 4116 of file partlist.c.

4119 {
4120  PDISKENTRY DiskEntry = PartEntry->DiskEntry;
4121 
4122  ASSERT(DiskEntry->DiskStyle == PARTITION_STYLE_MBR);
4123 
4124  PartEntry->PartitionType = PartitionType;
4125 
4126  DiskEntry->Dirty = TRUE;
4127  DiskEntry->LayoutBuffer->PartitionEntry[PartEntry->PartitionIndex].PartitionType = PartitionType;
4128  DiskEntry->LayoutBuffer->PartitionEntry[PartEntry->PartitionIndex].RecognizedPartition = IsRecognizedPartition(PartitionType);
4129  DiskEntry->LayoutBuffer->PartitionEntry[PartEntry->PartitionIndex].RewritePartition = TRUE;
4130 }
#define TRUE
Definition: types.h:120
PARTITION_STYLE DiskStyle
Definition: partlist.h:133
BOOLEAN Dirty
Definition: partlist.h:130
PARTITION_INFORMATION PartitionEntry[1]
Definition: ntdddisk.h:426
#define ASSERT(a)
Definition: mode.c:45
#define IsRecognizedPartition(PartitionType)
Definition: ntdddisk.h:342
BOOLEAN RewritePartition
Definition: ntdddisk.h:420
CHAR PartitionType
Definition: part_xbox.c:32
BOOLEAN RecognizedPartition
Definition: ntdddisk.h:419
PDRIVE_LAYOUT_INFORMATION LayoutBuffer
Definition: partlist.h:137

Referenced by FormatPartition().

◆ SetMountedDeviceValue()

BOOLEAN SetMountedDeviceValue ( IN WCHAR  Letter,
IN ULONG  Signature,
IN LARGE_INTEGER  StartingOffset 
)

Definition at line 3979 of file partlist.c.

3983 {
3984  NTSTATUS Status;
3986  UNICODE_STRING KeyName = RTL_CONSTANT_STRING(L"SYSTEM\\MountedDevices");
3988  WCHAR ValueNameBuffer[16];
3989  HANDLE KeyHandle;
3990  REG_DISK_MOUNT_INFO MountInfo;
3991 
3992  RtlStringCchPrintfW(ValueNameBuffer, ARRAYSIZE(ValueNameBuffer),
3993  L"\\DosDevices\\%c:", Letter);
3994  RtlInitUnicodeString(&ValueName, ValueNameBuffer);
3995 
3997  &KeyName,
4000  NULL);
4001 
4004  &ObjectAttributes);
4005  if (!NT_SUCCESS(Status))
4006  {
4010  0,
4011  NULL,
4013  NULL);
4014  }
4015  if (!NT_SUCCESS(Status))
4016  {
4017  DPRINT1("NtCreateKey() failed (Status %lx)\n", Status);
4018  return FALSE;
4019  }
4020 
4021  MountInfo.Signature = Signature;
4022  MountInfo.StartingOffset = StartingOffset;
4024  &ValueName,
4025  0,
4026  REG_BINARY,
4027  (PVOID)&MountInfo,
4028  sizeof(MountInfo));
4029  NtClose(KeyHandle);
4030  if (!NT_SUCCESS(Status))
4031  {
4032  DPRINT1("NtSetValueKey() failed (Status %lx)\n", Status);
4033  return FALSE;
4034  }
4035 
4036  return TRUE;
4037 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
LARGE_INTEGER StartingOffset
Definition: partlist.c:26
NTSTATUS NTAPI NtCreateKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN ULONG TitleIndex, IN PUNICODE_STRING Class OPTIONAL, IN ULONG CreateOptions, OUT PULONG Disposition OPTIONAL)
Definition: ntapi.c:240
_In_ PFCB _In_ LONGLONG StartingOffset
Definition: cdprocs.h:290
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4711
#define REG_BINARY
Definition: nt_native.h:1496
#define TRUE
Definition: types.h:120
NTSTRSAFEVAPI RtlStringCchPrintfW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
Definition: ntstrsafe.h:1110
LONG NTSTATUS
Definition: precomp.h:26
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define FALSE
Definition: types.h:117
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2697
Status
Definition: gdiplustypes.h:24
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:240
static const WCHAR L[]
Definition: oid.c:1250
WCHAR Letter
HANDLE GetRootKeyByPredefKey(IN HANDLE KeyHandle, OUT PCWSTR *RootKeyMountPoint OPTIONAL)
Definition: registry.c:90
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define NULL
Definition: types.h:112
NTSYSAPI NTSTATUS NTAPI NtSetValueKey(IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName, IN ULONG TitleIndex OPTIONAL, IN ULONG Type, IN PVOID Data, IN ULONG DataSize)
Definition: ntapi.c:859
#define DPRINT1
Definition: precomp.h:8
NTSYSAPI NTSTATUS NTAPI NtOpenKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: ntapi.c:336
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
static const WCHAR Signature[]
Definition: parser.c:141
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14

Referenced by SetMountedDeviceValues().

◆ SetMountedDeviceValues()

BOOLEAN SetMountedDeviceValues ( IN PPARTLIST  List)

Definition at line 4040 of file partlist.c.

4042 {
4043  PLIST_ENTRY Entry1, Entry2;
4044  PDISKENTRY DiskEntry;
4045  PPARTENTRY PartEntry;
4047 
4048  if (List == NULL)
4049  return FALSE;
4050 
4051  for (Entry1 = List->DiskListHead.Flink;
4052  Entry1 != &List->DiskListHead;
4053  Entry1 = Entry1->Flink)
4054  {
4055  DiskEntry = CONTAINING_RECORD(Entry1,
4056  DISKENTRY,
4057  ListEntry);
4058 
4059  if (DiskEntry->DiskStyle == PARTITION_STYLE_GPT)
4060  {
4061  DPRINT("GPT-partitioned disk detected, not currently supported by SETUP!\n");
4062  continue;
4063  }
4064 
4065  for (Entry2 = DiskEntry->PrimaryPartListHead.Flink;
4066  Entry2 != &DiskEntry->PrimaryPartListHead;
4067  Entry2 = Entry2->Flink)
4068  {
4069  PartEntry = CONTAINING_RECORD(Entry2, PARTENTRY, ListEntry);
4070  if (PartEntry->IsPartitioned) // && !IsContainerPartition(PartEntry->PartitionType)
4071  {
4073 
4074  /* Assign a "\DosDevices\#:" mount point to this partition */
4075  if (PartEntry->DriveLetter)
4076  {
4077  StartingOffset.QuadPart = PartEntry->StartSector.QuadPart * DiskEntry->BytesPerSector;
4078  if (!SetMountedDeviceValue(PartEntry->DriveLetter,
4079  DiskEntry->LayoutBuffer->Signature,
4080  StartingOffset))
4081  {
4082  return FALSE;
4083  }
4084  }
4085  }
4086  }
4087 
4088  for (Entry2 = DiskEntry->LogicalPartListHead.Flink;
4089  Entry2 != &DiskEntry->LogicalPartListHead;
4090  Entry2 = Entry2->Flink)
4091  {
4092  PartEntry = CONTAINING_RECORD(Entry2, PARTENTRY, ListEntry);
4093  if (PartEntry->IsPartitioned) // && !IsContainerPartition(PartEntry->PartitionType)
4094  {
4096 
4097  /* Assign a "\DosDevices\#:" mount point to this partition */
4098  if (PartEntry->DriveLetter)
4099  {
4100  StartingOffset.QuadPart = PartEntry->StartSector.QuadPart * DiskEntry->BytesPerSector;
4101  if (!SetMountedDeviceValue(PartEntry->DriveLetter,
4102  DiskEntry->LayoutBuffer->Signature,
4103  StartingOffset))
4104  {
4105  return FALSE;
4106  }
4107  }
4108  }
4109  }
4110  }
4111 
4112  return TRUE;
4113 }
LIST_ENTRY PrimaryPartListHead
Definition: partlist.h:143
WCHAR DriveLetter
Definition: partlist.h:70
ULARGE_INTEGER StartSector
Definition: partlist.h:61
_In_ PFCB _In_ LONGLONG StartingOffset
Definition: cdprocs.h:290
#define TRUE
Definition: types.h:120
BOOLEAN SetMountedDeviceValue(IN WCHAR Letter, IN ULONG Signature, IN LARGE_INTEGER StartingOffset)
Definition: partlist.c:3979
#define PARTITION_ENTRY_UNUSED
Definition: disk.h:86
PARTITION_STYLE DiskStyle
Definition: partlist.h:133
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
#define FALSE
Definition: types.h:117
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
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
UCHAR PartitionType
Definition: partlist.h:65
ULONG BytesPerSector
Definition: partlist.h:107
#define ASSERT(a)
Definition: mode.c:45
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
Definition: typedefs.h:119
#define NULL
Definition: types.h:112
LIST_ENTRY LogicalPartListHead
Definition: partlist.h:144
PDRIVE_LAYOUT_INFORMATION LayoutBuffer
Definition: partlist.h:137
BOOLEAN IsPartitioned
Definition: partlist.h:78

Referenced by UpdateRegistry().

◆ WritePartitions()

NTSTATUS WritePartitions ( IN PDISKENTRY  DiskEntry)

Definition at line 3798 of file partlist.c.

3800 {
3801  NTSTATUS Status;
3806  ULONG BufferSize;
3808  ULONG PartitionCount;
3809  PLIST_ENTRY ListEntry;
3810  PPARTENTRY PartEntry;
3812 
3813  DPRINT("WritePartitions() Disk: %lu\n", DiskEntry->DiskNumber);
3814 
3815  /* If the disk is not dirty, there is nothing to do */
3816  if (!DiskEntry->Dirty)
3817  return STATUS_SUCCESS;
3818 
3820  L"\\Device\\Harddisk%lu\\Partition0",
3821  DiskEntry->DiskNumber);
3823 
3825  &Name,
3827  NULL,
3828  NULL);
3829 
3833  &Iosb,
3834  0,
3836  if (!NT_SUCCESS(Status))
3837  {
3838  DPRINT1("NtOpenFile() failed (Status %lx)\n", Status);
3839  return Status;
3840  }
3841 
3842 #ifdef DUMP_PARTITION_TABLE
3843  DumpPartitionTable(DiskEntry);
3844 #endif
3845 
3846  //
3847  // FIXME: We first *MUST* use IOCTL_DISK_CREATE_DISK to initialize
3848  // the disk in MBR or GPT format in case the disk was not initialized!!
3849  // For this we must ask the user which format to use.
3850  //
3851 
3852  /* Save the original partition count to be restored later (see comment below) */
3853  PartitionCount = DiskEntry->LayoutBuffer->PartitionCount;
3854 
3855  /* Set the new disk layout and retrieve its updated version with possibly modified partition numbers */
3857  ((PartitionCount - 1) * sizeof(PARTITION_INFORMATION));
3859  NULL,
3860  NULL,
3861  NULL,
3862  &Iosb,
3864  DiskEntry->LayoutBuffer,
3865  BufferSize,
3866  DiskEntry->LayoutBuffer,
3867  BufferSize);
3869 
3870  /*
3871  * IOCTL_DISK_SET_DRIVE_LAYOUT calls IoWritePartitionTable(), which converts
3872  * DiskEntry->LayoutBuffer->PartitionCount into a partition *table* count,
3873  * where such a table is expected to enumerate up to 4 partitions:
3874  * partition *table* count == ROUND_UP(PartitionCount, 4) / 4 .
3875  * Due to this we need to restore the original PartitionCount number.
3876  */
3877  DiskEntry->LayoutBuffer->PartitionCount = PartitionCount;
3878 
3879  /* Check whether the IOCTL_DISK_SET_DRIVE_LAYOUT call succeeded */
3880  if (!NT_SUCCESS(Status))
3881  {
3882  DPRINT1("IOCTL_DISK_SET_DRIVE_LAYOUT failed (Status 0x%08lx)\n", Status);
3883  return Status;
3884  }
3885 
3886 #ifdef DUMP_PARTITION_TABLE
3887  DumpPartitionTable(DiskEntry);
3888 #endif
3889 
3890  /* Update the partition numbers */
3891 
3892  /* Update the primary partition table */
3893  for (ListEntry = DiskEntry->PrimaryPartListHead.Flink;
3894  ListEntry != &DiskEntry->PrimaryPartListHead;
3895  ListEntry = ListEntry->Flink)
3896  {
3897  PartEntry = CONTAINING_RECORD(ListEntry, PARTENTRY, ListEntry);
3898 
3899  if (PartEntry->IsPartitioned)
3900  {
3902  PartitionInfo = &DiskEntry->LayoutBuffer->PartitionEntry[PartEntry->PartitionIndex];
3903  PartEntry->PartitionNumber = PartitionInfo->PartitionNumber;
3904  }
3905  }
3906 
3907  /* Update the logical partition table */
3908  for (ListEntry = DiskEntry->LogicalPartListHead.Flink;
3909  ListEntry != &DiskEntry->LogicalPartListHead;
3910  ListEntry = ListEntry->Flink)
3911  {
3912  PartEntry = CONTAINING_RECORD(ListEntry, PARTENTRY, ListEntry);
3913 
3914  if (PartEntry->IsPartitioned)
3915  {
3917  PartitionInfo = &DiskEntry->LayoutBuffer->PartitionEntry[PartEntry->PartitionIndex];
3918  PartEntry->PartitionNumber = PartitionInfo->PartitionNumber;
3919  }
3920  }
3921 
3922  //
3923  // NOTE: Originally (see r40437), we used to install here also a new MBR
3924  // for this disk (by calling InstallMbrBootCodeToDisk), only if:
3925  // DiskEntry->NewDisk == TRUE and DiskEntry->HwDiskNumber == 0.
3926  // Then after that, both DiskEntry->NewDisk and DiskEntry->NoMbr were set
3927  // to FALSE. In the other place (in usetup.c) where InstallMbrBootCodeToDisk
3928  // was called too, the installation test was modified by checking whether
3929  // DiskEntry->NoMbr was TRUE (instead of NewDisk).
3930  //
3931 
3932  // HACK: Parts of FIXMEs described above: (Re)set the PartitionStyle to MBR.
3933  DiskEntry->DiskStyle = PARTITION_STYLE_MBR;
3934 
3935  /* The layout has been successfully updated, the disk is not dirty anymore */
3936  DiskEntry->Dirty = FALSE;
3937 
3938  return Status;
3939 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
ULONG PartitionNumber
Definition: partlist.h:67
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
NTSTRSAFEVAPI RtlStringCchPrintfW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
Definition: ntstrsafe.h:1110
LONG NTSTATUS
Definition: precomp.h:26
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
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
#define PARTITION_ENTRY_UNUSED
Definition: disk.h:86
HANDLE FileHandle
Definition: stats.c:38
#define FALSE
Definition: types.h:117
IN HANDLE DstPath
Definition: fsutil.h:75
#define GENERIC_WRITE
Definition: nt_native.h:90
struct _DRIVE_LAYOUT_INFORMATION DRIVE_LAYOUT_INFORMATION
struct NameRec_ * Name
Definition: cdprocs.h:459
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
Status
Definition: gdiplustypes.h:24
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
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
UCHAR PartitionType
Definition: partlist.h:65
#define ASSERT(a)
Definition: mode.c:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
return Iosb
Definition: create.c:4402
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define MAX_PATH
Definition: compat.h:34
_In_ ULONG _In_ struct _SET_PARTITION_INFORMATION_EX * PartitionInfo
Definition: iofuncs.h:2101
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
static const WCHAR L[]
Definition: oid.c:1250
#define GENERIC_READ
Definition: compat.h:135
Definition: typedefs.h:119
#define SYNCHRONIZE
Definition: nt_native.h:61
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
#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
#define IOCTL_DISK_SET_DRIVE_LAYOUT
Definition: ntdddisk.h:205
#define STATUS_SUCCESS
Definition: shellext.h:65
#define BufferSize
Definition: mmc.h:75
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:251
BOOLEAN IsPartitioned
Definition: partlist.h:78
ULONG PartitionIndex
Definition: partlist.h:68

Referenced by FormatPartition(), and WritePartitionsToDisk().

◆ WritePartitionsToDisk()

BOOLEAN WritePartitionsToDisk ( IN PPARTLIST  List)

Definition at line 3942 of file partlist.c.

3944 {
3945  NTSTATUS Status;
3947  PDISKENTRY DiskEntry;
3948 
3949  if (List == NULL)
3950  return TRUE;
3951 
3952  for (Entry = List->DiskListHead.Flink;
3953  Entry != &List->DiskListHead;
3954  Entry = Entry->Flink)
3955  {
3956  DiskEntry = CONTAINING_RECORD(Entry, DISKENTRY, ListEntry);
3957 
3958  if (DiskEntry->DiskStyle == PARTITION_STYLE_GPT)
3959  {
3960  DPRINT("GPT-partitioned disk detected, not currently supported by SETUP!\n");
3961  continue;
3962  }
3963 
3964  if (DiskEntry->Dirty != FALSE)
3965  {
3966  Status = WritePartitions(DiskEntry);
3967  if (!NT_SUCCESS(Status))
3968  {
3969  DPRINT1("WritePartitionsToDisk() failed to update disk %lu, Status 0x%08lx\n",
3970  DiskEntry->DiskNumber, Status);
3971  }
3972  }
3973  }
3974 
3975  return TRUE;
3976 }
struct _Entry Entry
Definition: kefuncs.h:627
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
ULONG DiskNumber
Definition: partlist.h:123
PARTITION_STYLE DiskStyle
Definition: partlist.h:133
#define FALSE
Definition: types.h:117
BOOLEAN Dirty
Definition: partlist.h:130
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
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
Definition: typedefs.h:119
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
NTSTATUS WritePartitions(IN PDISKENTRY DiskEntry)
Definition: partlist.c:3798
base of all file and directory entries
Definition: entries.h:82

Referenced by SelectFileSystemPage().

Variable Documentation

◆ PartitionTypes

Definition at line 63 of file partlist.c.

Referenced by GetPartTypeStringFromPartitionType().