ReactOS  0.4.15-dev-5461-g062a8f2
uniqueid.c
Go to the documentation of this file.
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
18  _In_ INT argc,
19  _In_ PWSTR *argv)
20 {
21  PWSTR pszSuffix = NULL;
22  ULONG ulValue;
23 
24  if (CurrentDisk == NULL)
25  {
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  {
41  return TRUE;
42  }
43 
44  if (!HasPrefix(argv[2], L"ID=", &pszSuffix))
45  {
47  return TRUE;
48  }
49 
50  if ((pszSuffix == NULL) ||
51  (wcslen(pszSuffix) != 8) ||
52  (IsHexString(pszSuffix) == FALSE))
53  {
55  return TRUE;
56  }
57 
58  ulValue = wcstoul(pszSuffix, NULL, 16);
59  if ((ulValue == 0) && (errno == ERANGE))
60  {
62  return TRUE;
63  }
64 
65  DPRINT("New Signature: 0x%08lx\n", ulValue);
70 
71  return TRUE;
72 }
static int argc
Definition: ServiceArgs.c:12
BOOL HasPrefix(_In_ PWSTR pszString, _In_ PWSTR pszPrefix, _Out_opt_ PWSTR *pszSuffix)
Definition: misc.c:58
#define TRUE
Definition: types.h:120
uint16_t * PWSTR
Definition: typedefs.h:56
PDISKENTRY CurrentDisk
Definition: partlist.c:74
int errno
_Check_return_ unsigned long __cdecl wcstoul(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
#define argv
Definition: mplay32.c:18
int32_t INT
Definition: typedefs.h:58
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: fc.c:16
BOOL IsHexString(_In_ PWSTR pszHexString)
Definition: misc.c:36
#define IDS_ERROR_INVALID_ARGS
Definition: resource.h:187
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOLEAN Dirty
Definition: partlist.h:118
#define _In_
Definition: ms_sal.h:308
void ConResPuts(FILE *fp, UINT nID)
Definition: fc.c:27
static VOID UpdateDiskLayout(IN PDISKENTRY DiskEntry)
Definition: partlist.c:2534
#define IDS_SELECT_NO_DISK
Definition: resource.h:85
#define ERANGE
Definition: acclib.h:92
BOOL UniqueIdDisk(_In_ INT argc, _In_ PWSTR *argv)
Definition: uniqueid.c:17
void ConPrintf(FILE *fp, LPCWSTR psz,...)
Definition: fc.c:20
#define NULL
Definition: types.h:112
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define StdOut
Definition: fc.c:14
NTSTATUS WritePartitions(IN PDISKENTRY DiskEntry)
Definition: partlist.c:3619
unsigned int ULONG
Definition: retypes.h:1
#define DPRINT
Definition: sndvol32.h:71
PDRIVE_LAYOUT_INFORMATION LayoutBuffer
Definition: partlist.h:125
#define StdErr
Definition: fc.c:15