2011-09-24 10:33:33 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS DiskPart
|
|
|
|
* LICENSE: GPL - See COPYING in the top level directory
|
|
|
|
* FILE: base/system/diskpart/uniqueid.c
|
2016-10-01 22:58:21 +00:00
|
|
|
* PURPOSE: Manages all the partitions of the OS in an interactive way.
|
2011-09-24 10:33:33 +00:00
|
|
|
* PROGRAMMERS: Lee Schroeder
|
|
|
|
*/
|
2014-01-13 13:07:50 +00:00
|
|
|
|
2011-09-24 10:33:33 +00:00
|
|
|
#include "diskpart.h"
|
|
|
|
|
2022-03-27 15:54:38 +00:00
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
|
|
|
|
|
|
|
/* FUNCTIONS ******************************************************************/
|
|
|
|
|
|
|
|
static
|
|
|
|
BOOL
|
|
|
|
isHexString(
|
|
|
|
_In_ PWSTR pszHexString)
|
|
|
|
{
|
|
|
|
PWSTR ptr;
|
|
|
|
|
|
|
|
ptr = pszHexString;
|
|
|
|
while (*ptr != UNICODE_NULL)
|
|
|
|
{
|
|
|
|
if (!iswxdigit(*ptr))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
ptr++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
BOOL
|
|
|
|
hasPrefix(
|
|
|
|
_In_ PWSTR pszString,
|
|
|
|
_In_ PWSTR pszPrefix)
|
|
|
|
{
|
|
|
|
return (_wcsnicmp(pszString, pszPrefix, wcslen(pszPrefix)) == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
VOID
|
|
|
|
UniqueIdDisk(
|
|
|
|
_In_ INT argc,
|
|
|
|
_In_ LPWSTR *argv)
|
|
|
|
{
|
|
|
|
ULONG ulLength;
|
|
|
|
ULONG ulValue;
|
|
|
|
PWSTR startptr = NULL, endptr = NULL;
|
|
|
|
|
|
|
|
if (CurrentDisk == NULL)
|
|
|
|
{
|
|
|
|
ConResPuts(StdOut, IDS_SELECT_NO_DISK);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (argc == 2)
|
|
|
|
{
|
|
|
|
ConPuts(StdOut, L"\n");
|
|
|
|
ConPrintf(StdOut, L"Disk ID: %08lx\n", CurrentDisk->LayoutBuffer->Signature);
|
|
|
|
ConPuts(StdOut, L"\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (argc != 3)
|
|
|
|
{
|
|
|
|
ConResPuts(StdOut, IDS_ERROR_INVALID_ARGS);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ulLength = wcslen(argv[2]);
|
|
|
|
if ((ulLength <= 3) || (ulLength > 11))
|
|
|
|
{
|
|
|
|
ConResPuts(StdOut, IDS_ERROR_INVALID_ARGS);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!hasPrefix(argv[2], L"ID="))
|
|
|
|
{
|
|
|
|
ConResPuts(StdOut, IDS_ERROR_INVALID_ARGS);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
startptr = &argv[2][3];
|
|
|
|
if (isHexString(startptr) == FALSE)
|
|
|
|
{
|
|
|
|
ConResPuts(StdOut, IDS_ERROR_INVALID_ARGS);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ulValue = wcstoul(startptr, &endptr, 16);
|
|
|
|
if ((ulValue == 0) && (errno == ERANGE))
|
|
|
|
{
|
|
|
|
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ConPrintf(StdOut, L"Setting the disk signature is not implemented yet!\n");
|
|
|
|
#if 0
|
|
|
|
DPRINT1("New Signature: %lx\n", ulValue);
|
|
|
|
CurrentDisk->LayoutBuffer->Signature = ulValue;
|
|
|
|
// SetDiskLayout(CurrentDisk);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-05-29 11:40:43 +00:00
|
|
|
BOOL uniqueid_main(INT argc, LPWSTR *argv)
|
2011-09-24 10:33:33 +00:00
|
|
|
{
|
2022-03-27 15:54:38 +00:00
|
|
|
/* gets the first word from the string */
|
|
|
|
if (argc == 1)
|
|
|
|
{
|
|
|
|
ConResPuts(StdOut, IDS_HELP_CMD_UNIQUEID);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* determines which details to print (disk, partition, etc.) */
|
|
|
|
if (!wcsicmp(argv[1], L"disk"))
|
|
|
|
UniqueIdDisk(argc, argv);
|
|
|
|
else
|
|
|
|
ConResPuts(StdOut, IDS_HELP_CMD_UNIQUEID);
|
|
|
|
|
2011-09-24 10:33:33 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|