24 for (ListEntry = pDisk->PrimaryPartListHead.
Flink;
26 ListEntry = ListEntry->
Flink)
32 if (ullSectorSize == 0
ULL)
34 DPRINT(
"Claim whole unused space!\n");
50 DPRINT(
"Claim matching unused space!\n");
62 else if (ullSectorSize < PartEntry->
SectorCount.QuadPart)
64 DPRINT(
"Claim part of unused space\n");
66 if (NewPartEntry ==
NULL)
116 DPRINT1(
"CreateEfiPartition()\n");
135 DPRINT(
"NoErr\n", pszSuffix);
148 DPRINT(
"Size : %s\n", pszSuffix);
160 DPRINT(
"Offset : %s\n", pszSuffix);
182 DPRINT1(
"Size: %I64u\n", ullSize);
184 DPRINT1(
"Offset: %I64u\n", ullOffset);
193 DPRINT1(
"SectorCount: %I64u\n", ullSectorCount);
195#ifdef DUMP_PARTITION_LIST
201 &PARTITION_SYSTEM_GUID);
202 if (PartEntry ==
FALSE)
212#ifdef DUMP_PARTITION_LIST
261 CREATE_DISK DiskInfo;
270 DPRINT1(
"CreateDisk() failed!\n");
285 DPRINT(
"NoErr\n", pszSuffix);
298 DPRINT(
"Size : %s\n", pszSuffix);
310 DPRINT(
"Offset : %s\n", pszSuffix);
324 DPRINT(
"Align : %s\n", pszSuffix);
341 DPRINT1(
"Size: %I64u\n", ullSize);
343 DPRINT1(
"Offset: %I64u\n", ullOffset);
354 ConPuts(
StdOut,
L"We already have an extended partition on this disk!\n");
363 DPRINT1(
"SectorCount: %I64u\n", ullSectorCount);
370 ConPuts(
StdOut,
L"No disk space left for an extended partition!\n");
374 if (ullSectorCount == 0)
401 if (NewPartEntry ==
NULL)
479 DPRINT(
"NoErr\n", pszSuffix);
492 DPRINT(
"Size : %s\n", pszSuffix);
504 DPRINT(
"Offset : %s\n", pszSuffix);
518 DPRINT(
"Id : %s\n", pszSuffix);
540 DPRINT(
"Align : %s\n", pszSuffix);
557 DPRINT1(
"Size: %I64u\n", ullSize);
559 DPRINT1(
"Offset: %I64u\n", ullOffset);
568 DPRINT1(
"SectorCount: %I64u\n", ullSectorCount);
572 ListEntry = ListEntry->
Flink)
578 if (ullSectorCount == 0)
607 if (NewPartEntry ==
NULL)
667 DPRINT1(
"CreateMsrPartition()\n");
686 DPRINT(
"NoErr\n", pszSuffix);
699 DPRINT(
"Size : %s\n", pszSuffix);
711 DPRINT(
"Offset : %s\n", pszSuffix);
733 DPRINT1(
"Size: %I64u\n", ullSize);
735 DPRINT1(
"Offset: %I64u\n", ullOffset);
744 DPRINT1(
"SectorSize: %I64u\n", ullSectorSize);
746#ifdef DUMP_PARTITION_LIST
752 &PARTITION_MSFT_RESERVED_GUID);
753 if (PartEntry ==
FALSE)
763#ifdef DUMP_PARTITION_LIST
795 if (pszPartitionType)
818 ConPuts(
StdOut,
L"No space left for another primary partition!\n");
827 DPRINT1(
"SectorCount: %I64u\n", ullSectorCount);
831 ListEntry = ListEntry->
Flink)
837 if (ullSectorCount == 0)
866 if (NewPartEntry ==
NULL)
917 GUID guidPartitionType;
921 if (pszPartitionType)
923 if (!
StringToGUID(&guidPartitionType, pszPartitionType))
931 CopyMemory(&guidPartitionType, &PARTITION_BASIC_DATA_GUID,
sizeof(
GUID));
940 DPRINT1(
"SectorCount: %I64u\n", ullSectorCount);
942#ifdef DUMP_PARTITION_LIST
949 if (PartEntry ==
FALSE)
959#ifdef DUMP_PARTITION_LIST
998 CREATE_DISK DiskInfo;
1007 DPRINT1(
"CreateDisk() failed!\n");
1022 DPRINT(
"NoErr\n", pszSuffix);
1035 DPRINT(
"Size : %s\n", pszSuffix);
1047 DPRINT(
"Offset : %s\n", pszSuffix);
1061 DPRINT(
"Id : %s\n", pszSuffix);
1062 pszPartitionType = pszSuffix;
1067 DPRINT(
"Align : %s\n", pszSuffix);
1084 DPRINT(
"Size: %I64u\n", ullSize);
1086 DPRINT1(
"Offset: %I64u\n", ullOffset);
1091 DPRINT(
"Partition Type: %s\n", pszPartitionType);
void ConPuts(FILE *fp, LPCWSTR psz)
void ConResPuts(FILE *fp, UINT nID)
static VOID CreatePrimaryGptPartition(_In_ ULONGLONG ullSize, _In_ PWSTR pszPartitionType)
EXIT_CODE CreateMsrPartition(_In_ INT argc, _In_ PWSTR *argv)
EXIT_CODE CreatePrimaryPartition(_In_ INT argc, _In_ PWSTR *argv)
EXIT_CODE CreateEfiPartition(_In_ INT argc, _In_ PWSTR *argv)
EXIT_CODE CreateExtendedPartition(_In_ INT argc, _In_ PWSTR *argv)
static VOID CreatePrimaryMbrPartition(_In_ ULONGLONG ullSize, _In_ PWSTR pszPartitionType)
static PPARTENTRY InsertGptPartition(_In_ PDISKENTRY pDisk, _In_ ULONGLONG ullSectorSize, _In_ const GUID *pPartitionType)
EXIT_CODE CreateLogicalPartition(_In_ INT argc, _In_ PWSTR *argv)
#define IDS_CREATE_PARTITION_INVALID_STYLE
#define IDS_CREATE_PARTITION_FAIL
#define IDS_ERROR_INVALID_ARGS
#define IDS_SELECT_NO_DISK
#define IDS_CREATE_PARTITION_SUCCESS
#define PARTITION_EXTENDED
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
VOID UpdateMbrDiskLayout(_In_ PDISKENTRY DiskEntry)
VOID CreateGUID(_Out_ GUID *pGuid)
BOOL HasPrefix(_In_ PWSTR pszString, _In_ PWSTR pszPrefix, _Out_opt_ PWSTR *pszSuffix)
enum _EXIT_CODE EXIT_CODE
VOID UpdateGptDiskLayout(_In_ PDISKENTRY DiskEntry, _In_ BOOL DeleteEntry)
NTSTATUS WriteMbrPartitions(_In_ PDISKENTRY DiskEntry)
VOID ScanForUnpartitionedMbrDiskSpace(PDISKENTRY DiskEntry)
NTSTATUS WriteGptPartitions(_In_ PDISKENTRY DiskEntry)
VOID CreateSignature(_Out_ PDWORD pSignature)
BOOL StringToGUID(_Out_ GUID *pGuid, _In_ PWSTR pszString)
#define NT_SUCCESS(StatCode)
_ACRTIMP __msvcrt_ulong __cdecl wcstoul(const wchar_t *, wchar_t **, int)
_ACRTIMP unsigned __int64 __cdecl _wcstoui64(const wchar_t *, wchar_t **, int)
_ACRTIMP int __cdecl _wcsicmp(const wchar_t *, const wchar_t *)
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
#define InsertTailList(ListHead, Entry)
GLuint GLsizei GLsizei * length
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
#define GetPrimaryPartitionCount(DiskEntry)
ULARGE_INTEGER SectorCount
PPARTENTRY ExtendedPartition
LIST_ENTRY LogicalPartListHead
ULARGE_INTEGER StartSector
LIST_ENTRY PrimaryPartListHead
struct _LIST_ENTRY * Blink
struct _LIST_ENTRY * Flink
ULARGE_INTEGER SectorCount
struct _DISKENTRY * DiskEntry
ULARGE_INTEGER StartSector
NTSTATUS CreateDisk(_In_ ULONG DiskNumber, _In_ PCREATE_DISK DiskInfo)
#define CONTAINING_RECORD(address, type, field)
static PPARTENTRY CurrentPartition