1 /* 2 * PROJECT: ReactOS DiskPart 3 * LICENSE: GPL - See COPYING in the top level directory 4 * FILE: base/system/diskpart/uniqueid.c 5 * PURPOSE: Manages all the partitions of the OS in an interactive way. 6 * PROGRAMMERS: Lee Schroeder 7 */ 8 9 #include "diskpart.h" 10 11 #define NDEBUG 12 #include <debug.h> 13 14 /* FUNCTIONS ******************************************************************/ 15 16 BOOL 17 UniqueIdDisk( 18 _In_ INT argc, 19 _In_ PWSTR *argv) 20 { 21 PWSTR pszSuffix = NULL; 22 ULONG ulValue; 23 24 if (CurrentDisk == NULL) 25 { 26 ConResPuts(StdOut, IDS_SELECT_NO_DISK); 27 return TRUE; 28 } 29 30 if (argc == 2) 31 { 32 ConPuts(StdOut, L"\n"); 33 ConPrintf(StdOut, L"Disk ID: %08lx\n", CurrentDisk->LayoutBuffer->Signature); 34 ConPuts(StdOut, L"\n"); 35 return TRUE; 36 } 37 38 if (argc != 3) 39 { 40 ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS); 41 return TRUE; 42 } 43 44 if (!HasPrefix(argv[2], L"ID=", &pszSuffix)) 45 { 46 ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS); 47 return TRUE; 48 } 49 50 if ((pszSuffix == NULL) || 51 (wcslen(pszSuffix) != 8) || 52 (IsHexString(pszSuffix) == FALSE)) 53 { 54 ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS); 55 return TRUE; 56 } 57 58 ulValue = wcstoul(pszSuffix, NULL, 16); 59 if ((ulValue == 0) && (errno == ERANGE)) 60 { 61 ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS); 62 return TRUE; 63 } 64 65 DPRINT("New Signature: 0x%08lx\n", ulValue); 66 CurrentDisk->LayoutBuffer->Signature = ulValue; 67 CurrentDisk->Dirty = TRUE; 68 UpdateDiskLayout(CurrentDisk); 69 WritePartitions(CurrentDisk); 70 71 return TRUE; 72 } 73