ReactOS 0.4.16-dev-2104-gb84fa49
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
20{
21 WCHAR szBuffer[40];
22 PWSTR pszSuffix, pszId = NULL;
23 INT i;
24 ULONG ulValue;
25
26 if (CurrentDisk == NULL)
27 {
29 return EXIT_SUCCESS;
30 }
31
32 if (argc == 2)
33 {
34 ConPuts(StdOut, L"\n");
35 if (CurrentDisk->LayoutBuffer->PartitionStyle == PARTITION_STYLE_GPT)
36 PrintGUID(szBuffer, &CurrentDisk->LayoutBuffer->Gpt.DiskId);
37 else if (CurrentDisk->LayoutBuffer->PartitionStyle == PARTITION_STYLE_MBR)
38 swprintf(szBuffer, L"%08lx", CurrentDisk->LayoutBuffer->Mbr.Signature);
39 else
40 wcscpy(szBuffer, L"00000000");
41 ConPrintf(StdOut, L"Disk ID: %s\n", szBuffer);
42 ConPuts(StdOut, L"\n");
43 return EXIT_SUCCESS;
44 }
45
46 if (argc != 3)
47 {
49 return EXIT_SUCCESS;
50 }
51
52 for (i = 1; i < argc; i++)
53 {
54 if (_wcsicmp(argv[i], L"noerr") == 0)
55 {
56 /* noerr */
57 DPRINT("NOERR\n");
58 ConPuts(StdOut, L"The NOERR option is not supported yet!\n");
59 }
60 }
61
62 for (i = 1; i < argc; i++)
63 {
64 if (HasPrefix(argv[2], L"id=", &pszSuffix))
65 {
66 /* id=<Byte>|<GUID> */
67 DPRINT("ID : %s\n", pszSuffix);
68 pszId = pszSuffix;
69 }
70 else if (_wcsicmp(argv[i], L"noerr") == 0)
71 {
72 /* noerr - Already handled above */
73 }
74 else
75 {
77 return EXIT_SUCCESS;
78 }
79 }
80
82 {
83 if (!StringToGUID(&CurrentDisk->LayoutBuffer->Gpt.DiskId, pszId))
84 {
86 return EXIT_SUCCESS;
87 }
88
92 }
94 {
95 if ((pszId == NULL) ||
96 (wcslen(pszId) != 8) ||
97 (IsHexString(pszId) == FALSE))
98 {
100 return EXIT_SUCCESS;
101 }
102
103 ulValue = wcstoul(pszId, NULL, 16);
104 if ((ulValue == 0) && (errno == ERANGE))
105 {
107 return EXIT_SUCCESS;
108 }
109
110 DPRINT("New Signature: 0x%08lx\n", ulValue);
111 CurrentDisk->LayoutBuffer->Mbr.Signature = ulValue;
115 }
116 else
117 {
119 }
120
121 return EXIT_SUCCESS;
122}
static int argc
Definition: ServiceArgs.c:12
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: fc.c:16
void ConPrintf(FILE *fp, LPCWSTR psz,...)
Definition: fc.c:20
#define StdOut
Definition: fc.c:14
#define StdErr
Definition: fc.c:15
void ConResPuts(FILE *fp, UINT nID)
Definition: fc.c:27
#define IDS_ERROR_INVALID_ARGS
Definition: resource.h:229
#define IDS_UNIQUID_DISK_INVALID_STYLE
Definition: resource.h:139
#define IDS_SELECT_NO_DISK
Definition: resource.h:121
EXIT_CODE UniqueIdDisk(_In_ INT argc, _In_ PWSTR *argv)
Definition: uniqueid.c:17
VOID UpdateMbrDiskLayout(_In_ PDISKENTRY DiskEntry)
Definition: partlist.c:2362
BOOL HasPrefix(_In_ PWSTR pszString, _In_ PWSTR pszPrefix, _Out_opt_ PWSTR *pszSuffix)
Definition: misc.c:58
enum _EXIT_CODE EXIT_CODE
VOID PrintGUID(_Out_ PWSTR pszBuffer, _In_ GUID *pGuid)
Definition: misc.c:187
VOID UpdateGptDiskLayout(_In_ PDISKENTRY DiskEntry, _In_ BOOL DeleteEntry)
Definition: partlist.c:2539
PDISKENTRY CurrentDisk
Definition: partlist.c:75
NTSTATUS WriteMbrPartitions(_In_ PDISKENTRY DiskEntry)
Definition: partlist.c:2034
NTSTATUS WriteGptPartitions(_In_ PDISKENTRY DiskEntry)
Definition: partlist.c:2158
BOOL IsHexString(_In_ PWSTR pszHexString)
Definition: misc.c:36
BOOL StringToGUID(_Out_ GUID *pGuid, _In_ PWSTR pszString)
Definition: misc.c:227
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
_ACRTIMP __msvcrt_ulong __cdecl wcstoul(const wchar_t *, wchar_t **, int)
Definition: wcs.c:2912
_ACRTIMP int __cdecl _wcsicmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:159
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2983
#define ERANGE
Definition: errno.h:55
#define errno
Definition: errno.h:120
#define swprintf
Definition: precomp.h:40
#define L(x)
Definition: resources.c:13
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
@ PARTITION_STYLE_GPT
Definition: imports.h:202
@ PARTITION_STYLE_MBR
Definition: imports.h:201
#define argv
Definition: mplay32.c:18
#define _In_
Definition: no_sal2.h:158
#define EXIT_SUCCESS
Definition: rdjpgcom.c:55
wcscpy
#define DPRINT
Definition: sndvol32.h:73
BOOLEAN Dirty
Definition: partlist.h:136
DWORD PartitionStyle
Definition: diskpart.h:219
PDRIVE_LAYOUT_INFORMATION LayoutBuffer
Definition: partlist.h:143
uint16_t * PWSTR
Definition: typedefs.h:56
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG
Definition: typedefs.h:59
__wchar_t WCHAR
Definition: xmlstorage.h:180