mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 08:25:03 +00:00
[DISKPART] Implement the SETID command
This commit is contained in:
parent
f06066dc6e
commit
7dec75ff67
12 changed files with 161 additions and 1 deletions
|
@ -117,6 +117,14 @@ BEGIN
|
|||
IDS_SELECT_VOLUME_INVALID "\nInvalid volume.\n\n"
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_SETID_FAIL "\nDiskPart konnte den Partitionstyp nicht ändern.\n"
|
||||
IDS_SETID_SUCCESS "\nDer Partitionstyp wurde erfolgreich geändert.\n"
|
||||
IDS_SETID_INVALID_FORMAT "\nDas Format des Partitionstyps ist ungültig.\n"
|
||||
IDS_SETID_INVALID_TYPE "\nDer Partitionstyp ist ungültig.\n"
|
||||
END
|
||||
|
||||
/* Disk Status */
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
|
|
|
@ -117,6 +117,14 @@ BEGIN
|
|||
IDS_SELECT_VOLUME_INVALID "\nInvalid volume.\n\n"
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_SETID_FAIL "\nDiskPart was unable to change the partition type.\n"
|
||||
IDS_SETID_SUCCESS "\nThe partition type was changed successfully.\n"
|
||||
IDS_SETID_INVALID_FORMAT "\nThe format of the partition type is invalid.\n"
|
||||
IDS_SETID_INVALID_TYPE "\nThe partition type is invalid.\n"
|
||||
END
|
||||
|
||||
/* Disk Status */
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
|
|
|
@ -117,6 +117,14 @@ BEGIN
|
|||
IDS_SELECT_VOLUME_INVALID "\nNieprawidłowy wolumin.\n\n"
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_SETID_FAIL "\nDiskPart was unable to change the partition type.\n"
|
||||
IDS_SETID_SUCCESS "\nThe partition type was changed successfully.\n"
|
||||
IDS_SETID_INVALID_FORMAT "\nThe format of the partition type is invalid.\n"
|
||||
IDS_SETID_INVALID_TYPE "\nThe partition type is invalid.\n"
|
||||
END
|
||||
|
||||
/* Disk Status */
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
|
|
|
@ -119,6 +119,14 @@ BEGIN
|
|||
IDS_SELECT_VOLUME_INVALID "\nInvalid volume.\n\n"
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_SETID_FAIL "\nDiskPart was unable to change the partition type.\n"
|
||||
IDS_SETID_SUCCESS "\nThe partition type was changed successfully.\n"
|
||||
IDS_SETID_INVALID_FORMAT "\nThe format of the partition type is invalid.\n"
|
||||
IDS_SETID_INVALID_TYPE "\nThe partition type is invalid.\n"
|
||||
END
|
||||
|
||||
/* Disk Status */
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
|
|
|
@ -119,6 +119,14 @@ BEGIN
|
|||
IDS_SELECT_VOLUME_INVALID "\nInvalid volume.\n\n"
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_SETID_FAIL "\nDiskPart was unable to change the partition type.\n"
|
||||
IDS_SETID_SUCCESS "\nThe partition type was changed successfully.\n"
|
||||
IDS_SETID_INVALID_FORMAT "\nThe format of the partition type is invalid.\n"
|
||||
IDS_SETID_INVALID_TYPE "\nThe partition type is invalid.\n"
|
||||
END
|
||||
|
||||
/* Disk Status */
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
|
|
|
@ -119,6 +119,14 @@ BEGIN
|
|||
IDS_SELECT_VOLUME_INVALID "\nInvalid volume.\n\n"
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_SETID_FAIL "\nDiskPart was unable to change the partition type.\n"
|
||||
IDS_SETID_SUCCESS "\nThe partition type was changed successfully.\n"
|
||||
IDS_SETID_INVALID_FORMAT "\nThe format of the partition type is invalid.\n"
|
||||
IDS_SETID_INVALID_TYPE "\nThe partition type is invalid.\n"
|
||||
END
|
||||
|
||||
/* Disk Status */
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
|
|
|
@ -121,6 +121,14 @@ BEGIN
|
|||
IDS_SELECT_VOLUME_INVALID "\nInvalid volume.\n\n"
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_SETID_FAIL "\nDiskPart was unable to change the partition type.\n"
|
||||
IDS_SETID_SUCCESS "\nThe partition type was changed successfully.\n"
|
||||
IDS_SETID_INVALID_FORMAT "\nThe format of the partition type is invalid.\n"
|
||||
IDS_SETID_INVALID_TYPE "\nThe partition type is invalid.\n"
|
||||
END
|
||||
|
||||
/* Disk Status */
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
|
|
|
@ -119,6 +119,14 @@ BEGIN
|
|||
IDS_SELECT_VOLUME_INVALID "\nInvalid volume.\n\n"
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_SETID_FAIL "\nDiskPart was unable to change the partition type.\n"
|
||||
IDS_SETID_SUCCESS "\nThe partition type was changed successfully.\n"
|
||||
IDS_SETID_INVALID_FORMAT "\nThe format of the partition type is invalid.\n"
|
||||
IDS_SETID_INVALID_TYPE "\nThe partition type is invalid.\n"
|
||||
END
|
||||
|
||||
/* Disk Status */
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
|
|
|
@ -126,6 +126,14 @@ BEGIN
|
|||
IDS_SELECT_VOLUME_INVALID "\nInvalid volume.\n\n"
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_SETID_FAIL "\nDiskPart was unable to change the partition type.\n"
|
||||
IDS_SETID_SUCCESS "\nThe partition type was changed successfully.\n"
|
||||
IDS_SETID_INVALID_FORMAT "\nThe format of the partition type is invalid.\n"
|
||||
IDS_SETID_INVALID_TYPE "\nThe partition type is invalid.\n"
|
||||
END
|
||||
|
||||
/* Disk Status */
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
|
|
|
@ -120,6 +120,14 @@ BEGIN
|
|||
IDS_SELECT_VOLUME_INVALID "\nInvalid volume.\n\n"
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_SETID_FAIL "\nDiskPart was unable to change the partition type.\n"
|
||||
IDS_SETID_SUCCESS "\nThe partition type was changed successfully.\n"
|
||||
IDS_SETID_INVALID_FORMAT "\nThe format of the partition type is invalid.\n"
|
||||
IDS_SETID_INVALID_TYPE "\nThe partition type is invalid.\n"
|
||||
END
|
||||
|
||||
/* Disk Status */
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
|
|
|
@ -89,6 +89,12 @@
|
|||
#define IDS_SELECT_VOLUME 4408
|
||||
#define IDS_SELECT_VOLUME_INVALID 4409
|
||||
|
||||
#define IDS_SETID_FAIL 4450
|
||||
#define IDS_SETID_SUCCESS 4451
|
||||
#define IDS_SETID_INVALID_FORMAT 4452
|
||||
#define IDS_SETID_INVALID_TYPE 4453
|
||||
|
||||
|
||||
#define IDS_STATUS_YES 31
|
||||
#define IDS_STATUS_NO 32
|
||||
#define IDS_STATUS_DISK_HEALTHY 33
|
||||
|
|
|
@ -8,7 +8,81 @@
|
|||
|
||||
#include "diskpart.h"
|
||||
|
||||
BOOL setid_main(INT argc, LPWSTR *argv)
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
|
||||
BOOL
|
||||
setid_main(
|
||||
_In_ INT argc,
|
||||
_In_ PWSTR *argv)
|
||||
{
|
||||
UCHAR PartitionType = 0;
|
||||
INT i, length;
|
||||
PWSTR pszSuffix = NULL;
|
||||
NTSTATUS Status;
|
||||
|
||||
DPRINT("SetId()\n");
|
||||
|
||||
if (CurrentDisk == NULL)
|
||||
{
|
||||
ConResPuts(StdOut, IDS_SELECT_NO_DISK);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (CurrentPartition == NULL)
|
||||
{
|
||||
ConResPuts(StdOut, IDS_SELECT_NO_PARTITION);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
if (HasPrefix(argv[i], L"id=", &pszSuffix))
|
||||
{
|
||||
/* id=<Byte>|<GUID> */
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue