diff --git a/base/system/diskpart/create.c b/base/system/diskpart/create.c index 72460823034..f2cbcb3723d 100644 --- a/base/system/diskpart/create.c +++ b/base/system/diskpart/create.c @@ -37,7 +37,7 @@ CreateExtendedPartition( if (CurrentDisk->PartitionStyle == PARTITION_STYLE_GPT) { - ConPuts(StdOut, L"GPT Partitions are not supported yet!\n"); + ConResPuts(StdOut, IDS_CREATE_PARTITION_INVALID_STYLE); return TRUE; } else if (CurrentDisk->PartitionStyle == PARTITION_STYLE_RAW) @@ -226,9 +226,9 @@ CreateLogicalPartition( return TRUE; } - if (CurrentDisk->PartitionStyle != PARTITION_STYLE_MBR) + if (CurrentDisk->PartitionStyle == PARTITION_STYLE_GPT) { - ConPuts(StdOut, L"Invalid partition style!\n"); + ConResPuts(StdOut, IDS_CREATE_PARTITION_INVALID_STYLE); return TRUE; } @@ -262,7 +262,7 @@ CreateLogicalPartition( } else if (HasPrefix(argv[i], L"id=", &pszSuffix)) { - /* id=| */ + /* id= */ DPRINT("Id : %s\n", pszSuffix); length = wcslen(pszSuffix); @@ -276,12 +276,6 @@ CreateLogicalPartition( return TRUE; } } -#if 0 - else if () - { - /* GUID */ - } -#endif else { ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS); diff --git a/base/system/diskpart/lang/de-DE.rc b/base/system/diskpart/lang/de-DE.rc index 733d505c2c2..2a74dc1a612 100644 --- a/base/system/diskpart/lang/de-DE.rc +++ b/base/system/diskpart/lang/de-DE.rc @@ -43,6 +43,7 @@ STRINGTABLE BEGIN IDS_CREATE_PARTITION_FAIL "\nDie angegebene Partition konnte nicht erstellt werden.\n" IDS_CREATE_PARTITION_SUCCESS "\nDie angegebene Partition wurde erfolgreich erstellt.\n" + IDS_CREATE_PARTITION_INVALID_STYLE "\nLogical or extended partitions can not be created on a GPT disk.\nCreate a primary partition on a GPT disk instead.\n" END STRINGTABLE @@ -144,6 +145,11 @@ BEGIN IDS_SETID_INVALID_TYPE "\nDer Partitionstyp ist ungültig.\n" END +STRINGTABLE +BEGIN + IDS_UNIQUID_DISK_INVALID_STYLE "\nThe selected disk is neither a GPT disk nor an MBR disk.\nSelect a GPT disk or an MBR disk.\n" +END + /* Disk Status */ STRINGTABLE BEGIN diff --git a/base/system/diskpart/lang/en-US.rc b/base/system/diskpart/lang/en-US.rc index ab6fa71b437..cac2a8c50b6 100644 --- a/base/system/diskpart/lang/en-US.rc +++ b/base/system/diskpart/lang/en-US.rc @@ -43,6 +43,7 @@ STRINGTABLE BEGIN IDS_CREATE_PARTITION_FAIL "\nDiskPart was unable to create the specified partition.\n" IDS_CREATE_PARTITION_SUCCESS "\nDiskPart succeeded in creating the specified partition.\n" + IDS_CREATE_PARTITION_INVALID_STYLE "\nLogical or extended partitions can not be created on a GPT disk.\nCreate a primary partition on a GPT disk instead.\n" END STRINGTABLE @@ -144,6 +145,11 @@ BEGIN IDS_SETID_INVALID_TYPE "\nThe partition type is invalid.\n" END +STRINGTABLE +BEGIN + IDS_UNIQUID_DISK_INVALID_STYLE "\nThe selected disk is neither a GPT disk nor an MBR disk.\nSelect a GPT disk or an MBR disk.\n" +END + /* Disk Status */ STRINGTABLE BEGIN diff --git a/base/system/diskpart/lang/it-IT.rc b/base/system/diskpart/lang/it-IT.rc index 2b8fcdc3462..bd5464e2bc7 100644 --- a/base/system/diskpart/lang/it-IT.rc +++ b/base/system/diskpart/lang/it-IT.rc @@ -50,6 +50,7 @@ STRINGTABLE BEGIN IDS_CREATE_PARTITION_FAIL "\nDiskPart non è stato in grado di creare la partizione specificata.\n" IDS_CREATE_PARTITION_SUCCESS "\nDiskPart ha creato con successo la partizione selezionata.\n" + IDS_CREATE_PARTITION_INVALID_STYLE "\nLogical or extended partitions can not be created on a GPT disk.\nCreate a primary partition on a GPT disk instead.\n" END STRINGTABLE @@ -151,6 +152,11 @@ BEGIN IDS_SETID_INVALID_TYPE "\nIl tipo di partizione non è valido.\n" END +STRINGTABLE +BEGIN + IDS_UNIQUID_DISK_INVALID_STYLE "\nThe selected disk is neither a GPT disk nor an MBR disk.\nSelect a GPT disk or an MBR disk.\n" +END + /* Disk Status */ STRINGTABLE BEGIN diff --git a/base/system/diskpart/lang/pl-PL.rc b/base/system/diskpart/lang/pl-PL.rc index 0fafe271fec..a2359b3cb20 100644 --- a/base/system/diskpart/lang/pl-PL.rc +++ b/base/system/diskpart/lang/pl-PL.rc @@ -43,6 +43,7 @@ STRINGTABLE BEGIN IDS_CREATE_PARTITION_FAIL "\nDiskPart nie może utworzyć określonej partycji.\n" IDS_CREATE_PARTITION_SUCCESS "\nDiskPart pomyślnie utworzył określoną partycję.\n" + IDS_CREATE_PARTITION_INVALID_STYLE "\nLogical or extended partitions can not be created on a GPT disk.\nCreate a primary partition on a GPT disk instead.\n" END STRINGTABLE @@ -144,6 +145,11 @@ BEGIN IDS_SETID_INVALID_TYPE "\nTyp partycji jest nieprawidłowy.\n" END +STRINGTABLE +BEGIN + IDS_UNIQUID_DISK_INVALID_STYLE "\nThe selected disk is neither a GPT disk nor an MBR disk.\nSelect a GPT disk or an MBR disk.\n" +END + /* Disk Status */ STRINGTABLE BEGIN diff --git a/base/system/diskpart/lang/pt-PT.rc b/base/system/diskpart/lang/pt-PT.rc index ee7c72ce722..9762f273a2b 100644 --- a/base/system/diskpart/lang/pt-PT.rc +++ b/base/system/diskpart/lang/pt-PT.rc @@ -45,6 +45,7 @@ STRINGTABLE BEGIN IDS_CREATE_PARTITION_FAIL "\nDiskPart was unable to create the specified partition.\n" IDS_CREATE_PARTITION_SUCCESS "\nDiskPart succeeded in creating the specified partition.\n" + IDS_CREATE_PARTITION_INVALID_STYLE "\nLogical or extended partitions can not be created on a GPT disk.\nCreate a primary partition on a GPT disk instead.\n" END STRINGTABLE @@ -146,6 +147,11 @@ BEGIN IDS_SETID_INVALID_TYPE "\nThe partition type is invalid.\n" END +STRINGTABLE +BEGIN + IDS_UNIQUID_DISK_INVALID_STYLE "\nThe selected disk is neither a GPT disk nor an MBR disk.\nSelect a GPT disk or an MBR disk.\n" +END + /* Disk Status */ STRINGTABLE BEGIN diff --git a/base/system/diskpart/lang/ro-RO.rc b/base/system/diskpart/lang/ro-RO.rc index d354f90d1a1..fe3c580fb75 100644 --- a/base/system/diskpart/lang/ro-RO.rc +++ b/base/system/diskpart/lang/ro-RO.rc @@ -51,6 +51,7 @@ STRINGTABLE BEGIN IDS_CREATE_PARTITION_FAIL "\nDiskPart nu a reușit să creeze partiția specificată.\n" IDS_CREATE_PARTITION_SUCCESS "\nDiskPart succeeded in creating the specified partition.\n" + IDS_CREATE_PARTITION_INVALID_STYLE "\nLogical or extended partitions can not be created on a GPT disk.\nCreate a primary partition on a GPT disk instead.\n" END STRINGTABLE @@ -152,6 +153,11 @@ BEGIN IDS_SETID_INVALID_TYPE "\nTipul partiției este nevalid.\n" END +STRINGTABLE +BEGIN + IDS_UNIQUID_DISK_INVALID_STYLE "\nThe selected disk is neither a GPT disk nor an MBR disk.\nSelect a GPT disk or an MBR disk.\n" +END + /* Disk Status */ STRINGTABLE BEGIN diff --git a/base/system/diskpart/lang/ru-RU.rc b/base/system/diskpart/lang/ru-RU.rc index 0ec51f8571b..56f5c23acd4 100644 --- a/base/system/diskpart/lang/ru-RU.rc +++ b/base/system/diskpart/lang/ru-RU.rc @@ -45,6 +45,7 @@ STRINGTABLE BEGIN IDS_CREATE_PARTITION_FAIL "\nDiskPart was unable to create the specified partition.\n" IDS_CREATE_PARTITION_SUCCESS "\nDiskPart succeeded in creating the specified partition.\n" + IDS_CREATE_PARTITION_INVALID_STYLE "\nLogical or extended partitions can not be created on a GPT disk.\nCreate a primary partition on a GPT disk instead.\n" END STRINGTABLE @@ -146,6 +147,11 @@ BEGIN IDS_SETID_INVALID_TYPE "\nThe partition type is invalid.\n" END +STRINGTABLE +BEGIN + IDS_UNIQUID_DISK_INVALID_STYLE "\nThe selected disk is neither a GPT disk nor an MBR disk.\nSelect a GPT disk or an MBR disk.\n" +END + /* Disk Status */ STRINGTABLE BEGIN diff --git a/base/system/diskpart/lang/sq-AL.rc b/base/system/diskpart/lang/sq-AL.rc index 9a0c8943218..be072441473 100644 --- a/base/system/diskpart/lang/sq-AL.rc +++ b/base/system/diskpart/lang/sq-AL.rc @@ -47,6 +47,7 @@ STRINGTABLE BEGIN IDS_CREATE_PARTITION_FAIL "\nDiskPart was unable to create the specified partition.\n" IDS_CREATE_PARTITION_SUCCESS "\nDiskPart succeeded in creating the specified partition.\n" + IDS_CREATE_PARTITION_INVALID_STYLE "\nLogical or extended partitions can not be created on a GPT disk.\nCreate a primary partition on a GPT disk instead.\n" END STRINGTABLE @@ -148,6 +149,11 @@ BEGIN IDS_SETID_INVALID_TYPE "\nThe partition type is invalid.\n" END +STRINGTABLE +BEGIN + IDS_UNIQUID_DISK_INVALID_STYLE "\nThe selected disk is neither a GPT disk nor an MBR disk.\nSelect a GPT disk or an MBR disk.\n" +END + /* Disk Status */ STRINGTABLE BEGIN diff --git a/base/system/diskpart/lang/tr-TR.rc b/base/system/diskpart/lang/tr-TR.rc index 52c5eefe247..e245442ec20 100644 --- a/base/system/diskpart/lang/tr-TR.rc +++ b/base/system/diskpart/lang/tr-TR.rc @@ -53,6 +53,7 @@ STRINGTABLE BEGIN IDS_CREATE_PARTITION_FAIL "\nDiskPart belirtilen bölümü oluşturamadı.\n" IDS_CREATE_PARTITION_SUCCESS "\nDiskPart, belirtilen bölümü oluşturdu.\n" + IDS_CREATE_PARTITION_INVALID_STYLE "\nLogical or extended partitions can not be created on a GPT disk.\nCreate a primary partition on a GPT disk instead.\n" END STRINGTABLE @@ -154,6 +155,11 @@ BEGIN IDS_SETID_INVALID_TYPE "\nBölüm türü geçersiz.\n" END +STRINGTABLE +BEGIN + IDS_UNIQUID_DISK_INVALID_STYLE "\nThe selected disk is neither a GPT disk nor an MBR disk.\nSelect a GPT disk or an MBR disk.\n" +END + /* Disk Status */ STRINGTABLE BEGIN diff --git a/base/system/diskpart/lang/zh-CN.rc b/base/system/diskpart/lang/zh-CN.rc index 7aa28db8727..313462d95d0 100644 --- a/base/system/diskpart/lang/zh-CN.rc +++ b/base/system/diskpart/lang/zh-CN.rc @@ -52,6 +52,7 @@ STRINGTABLE BEGIN IDS_CREATE_PARTITION_FAIL "\nDiskPart was unable to create the specified partition.\n" IDS_CREATE_PARTITION_SUCCESS "\nDiskPart succeeded in creating the specified partition.\n" + IDS_CREATE_PARTITION_INVALID_STYLE "\nLogical or extended partitions can not be created on a GPT disk.\nCreate a primary partition on a GPT disk instead.\n" END STRINGTABLE @@ -153,6 +154,11 @@ BEGIN IDS_SETID_INVALID_TYPE "\nThe partition type is invalid.\n" END +STRINGTABLE +BEGIN + IDS_UNIQUID_DISK_INVALID_STYLE "\nThe selected disk is neither a GPT disk nor an MBR disk.\nSelect a GPT disk or an MBR disk.\n" +END + /* Disk Status */ STRINGTABLE BEGIN diff --git a/base/system/diskpart/lang/zh-TW.rc b/base/system/diskpart/lang/zh-TW.rc index 54ceb431dac..cdac366711e 100644 --- a/base/system/diskpart/lang/zh-TW.rc +++ b/base/system/diskpart/lang/zh-TW.rc @@ -52,6 +52,7 @@ STRINGTABLE BEGIN IDS_CREATE_PARTITION_FAIL "\nDiskPart 無法建立指定的磁碟分割。\n" IDS_CREATE_PARTITION_SUCCESS "\nDiskPart 成功建立指定的磁碟分割。\n" + IDS_CREATE_PARTITION_INVALID_STYLE "\nLogical or extended partitions can not be created on a GPT disk.\nCreate a primary partition on a GPT disk instead.\n" END STRINGTABLE @@ -153,6 +154,11 @@ BEGIN IDS_SETID_INVALID_TYPE "\n無效的磁碟類型。\n" END +STRINGTABLE +BEGIN + IDS_UNIQUID_DISK_INVALID_STYLE "\nThe selected disk is neither a GPT disk nor an MBR disk.\nSelect a GPT disk or an MBR disk.\n" +END + /* Disk Status */ STRINGTABLE BEGIN diff --git a/base/system/diskpart/resource.h b/base/system/diskpart/resource.h index 51b5619c5f3..39acf9523d7 100644 --- a/base/system/diskpart/resource.h +++ b/base/system/diskpart/resource.h @@ -35,6 +35,7 @@ #define IDS_CREATE_PARTITION_FAIL 1050 #define IDS_CREATE_PARTITION_SUCCESS 1051 +#define IDS_CREATE_PARTITION_INVALID_STYLE 1052 #define IDS_DELETE_PARTITION_FAIL 1070 #define IDS_DELETE_PARTITION_SUCCESS 1071 @@ -107,6 +108,7 @@ #define IDS_SETID_INVALID_FORMAT 4452 #define IDS_SETID_INVALID_TYPE 4453 +#define IDS_UNIQUID_DISK_INVALID_STYLE 4500 #define IDS_STATUS_YES 31 #define IDS_STATUS_NO 32 diff --git a/base/system/diskpart/setid.c b/base/system/diskpart/setid.c index 7ab488de374..a7ab413ae2f 100644 --- a/base/system/diskpart/setid.c +++ b/base/system/diskpart/setid.c @@ -19,7 +19,7 @@ setid_main( { UCHAR PartitionType = 0; INT i, length; - PWSTR pszSuffix = NULL; + PWSTR pszSuffix, pszId = NULL; NTSTATUS Status; DPRINT("SetId()\n"); @@ -41,45 +41,70 @@ setid_main( if (HasPrefix(argv[i], L"id=", &pszSuffix)) { /* id=| */ - DPRINT("Id : %s\n", pszSuffix); - - length = wcslen(pszSuffix); - if (length == 0) - { - ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS); - return TRUE; - } - - if (length > 2) - { - ConResPuts(StdErr, IDS_SETID_INVALID_FORMAT); - return TRUE; - } - - /* Byte */ - PartitionType = (UCHAR)wcstoul(pszSuffix, NULL, 16); - if (PartitionType == 0) - { - ConResPuts(StdErr, IDS_SETID_INVALID_FORMAT); - return TRUE; - } + DPRINT("ID : %s\n", pszSuffix); + pszId = pszSuffix; + } + else if (_wcsicmp(argv[i], L"noerr") == 0) + { + /* noerr */ + DPRINT("NOERR\n"); + ConPuts(StdOut, L"The NOERR option is not supported yet!\n"); + } + else if (_wcsicmp(argv[i], L"override") == 0) + { + /* override */ + DPRINT("OVERRIDE\n"); + ConPuts(StdOut, L"The OVERRIDE option is not supported yet!\n"); + } + else + { + ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS); + return TRUE; } } - if (PartitionType == 0x42) + if (CurrentDisk->PartitionStyle == PARTITION_STYLE_GPT) { - ConResPuts(StdErr, IDS_SETID_INVALID_TYPE); + ConPuts(StdErr, L"The setid command does not support GPT disks yet!\n"); return TRUE; } - - CurrentPartition->PartitionType = PartitionType; - CurrentDisk->Dirty = TRUE; - UpdateDiskLayout(CurrentDisk); - Status = WritePartitions(CurrentDisk); - if (!NT_SUCCESS(Status)) + else if (CurrentDisk->PartitionStyle == PARTITION_STYLE_MBR) { - ConResPuts(StdOut, IDS_SETID_FAIL); - return TRUE; + length = wcslen(pszId); + if (length == 0) + { + ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS); + return TRUE; + } + + if (length > 2) + { + ConResPuts(StdErr, IDS_SETID_INVALID_FORMAT); + return TRUE; + } + + PartitionType = (UCHAR)wcstoul(pszSuffix, NULL, 16); + if ((PartitionType == 0) && (errno == ERANGE)) + { + ConResPuts(StdErr, IDS_SETID_INVALID_FORMAT); + return TRUE; + } + + if (PartitionType == 0x42) + { + ConResPuts(StdErr, IDS_SETID_INVALID_TYPE); + return TRUE; + } + + CurrentPartition->PartitionType = PartitionType; + CurrentDisk->Dirty = TRUE; + UpdateDiskLayout(CurrentDisk); + Status = WritePartitions(CurrentDisk); + if (!NT_SUCCESS(Status)) + { + ConResPuts(StdOut, IDS_SETID_FAIL); + return TRUE; + } } ConResPuts(StdOut, IDS_SETID_SUCCESS); diff --git a/base/system/diskpart/uniqueid.c b/base/system/diskpart/uniqueid.c index 7eb467dee8b..a56981c73ac 100644 --- a/base/system/diskpart/uniqueid.c +++ b/base/system/diskpart/uniqueid.c @@ -19,7 +19,8 @@ UniqueIdDisk( _In_ PWSTR *argv) { WCHAR szBuffer[40]; - PWSTR pszSuffix = NULL; + PWSTR pszSuffix, pszId = NULL; + INT i; ULONG ulValue; if (CurrentDisk == NULL) @@ -48,32 +49,58 @@ UniqueIdDisk( return TRUE; } - if (!HasPrefix(argv[2], L"ID=", &pszSuffix)) + for (i = 1; i < argc; i++) { - ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS); - return TRUE; + if (HasPrefix(argv[2], L"id=", &pszSuffix)) + { + /* id=| */ + DPRINT("ID : %s\n", pszSuffix); + pszId = pszSuffix; + } + else if (_wcsicmp(argv[i], L"noerr") == 0) + { + /* noerr */ + DPRINT("NOERR\n"); + ConPuts(StdOut, L"The NOERR option is not supported yet!\n"); + } + else + { + ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS); + return TRUE; + } } - if ((pszSuffix == NULL) || - (wcslen(pszSuffix) != 8) || - (IsHexString(pszSuffix) == FALSE)) + if (CurrentDisk->PartitionStyle == PARTITION_STYLE_GPT) { - ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS); - return TRUE; + ConPuts(StdErr, L"The uniqueid disk command does not support GPT disks yet!\n"); } - - ulValue = wcstoul(pszSuffix, NULL, 16); - if ((ulValue == 0) && (errno == ERANGE)) + else if (CurrentDisk->PartitionStyle == PARTITION_STYLE_MBR) { - ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS); - return TRUE; - } + if ((pszId == NULL) || + (wcslen(pszId) != 8) || + (IsHexString(pszId) == FALSE)) + { + ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS); + return TRUE; + } - DPRINT("New Signature: 0x%08lx\n", ulValue); - CurrentDisk->LayoutBuffer->Mbr.Signature = ulValue; - CurrentDisk->Dirty = TRUE; - UpdateDiskLayout(CurrentDisk); - WritePartitions(CurrentDisk); + ulValue = wcstoul(pszId, NULL, 16); + if ((ulValue == 0) && (errno == ERANGE)) + { + ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS); + return TRUE; + } + + DPRINT("New Signature: 0x%08lx\n", ulValue); + CurrentDisk->LayoutBuffer->Mbr.Signature = ulValue; + CurrentDisk->Dirty = TRUE; + UpdateDiskLayout(CurrentDisk); + WritePartitions(CurrentDisk); + } + else + { + ConResPuts(StdOut, IDS_UNIQUID_DISK_INVALID_STYLE); + } return TRUE; }