ReactOS
0.4.16-dev-197-g92996da
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
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
}
argc
static int argc
Definition:
ServiceArgs.c:12
ERANGE
#define ERANGE
Definition:
acclib.h:92
ConPuts
void ConPuts(FILE *fp, LPCWSTR psz)
Definition:
fc.c:16
ConPrintf
void ConPrintf(FILE *fp, LPCWSTR psz,...)
Definition:
fc.c:20
StdOut
#define StdOut
Definition:
fc.c:14
StdErr
#define StdErr
Definition:
fc.c:15
ConResPuts
void ConResPuts(FILE *fp, UINT nID)
Definition:
fc.c:27
IDS_ERROR_INVALID_ARGS
#define IDS_ERROR_INVALID_ARGS
Definition:
resource.h:187
IDS_SELECT_NO_DISK
#define IDS_SELECT_NO_DISK
Definition:
resource.h:85
UniqueIdDisk
BOOL UniqueIdDisk(_In_ INT argc, _In_ PWSTR *argv)
Definition:
uniqueid.c:17
diskpart.h
HasPrefix
BOOL HasPrefix(_In_ PWSTR pszString, _In_ PWSTR pszPrefix, _Out_opt_ PWSTR *pszSuffix)
Definition:
misc.c:58
CurrentDisk
PDISKENTRY CurrentDisk
Definition:
partlist.c:74
IsHexString
BOOL IsHexString(_In_ PWSTR pszHexString)
Definition:
misc.c:36
NULL
#define NULL
Definition:
types.h:112
TRUE
#define TRUE
Definition:
types.h:120
FALSE
#define FALSE
Definition:
types.h:117
BOOL
unsigned int BOOL
Definition:
ntddk_ex.h:94
wcstoul
_Check_return_ unsigned long __cdecl wcstoul(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
wcslen
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
argv
#define argv
Definition:
mplay32.c:18
_In_
#define _In_
Definition:
ms_sal.h:308
L
#define L(x)
Definition:
ntvdm.h:50
errno
#define errno
Definition:
errno.h:18
UpdateDiskLayout
static VOID UpdateDiskLayout(IN PDISKENTRY DiskEntry)
Definition:
partlist.c:2585
WritePartitions
NTSTATUS WritePartitions(IN PDISKENTRY DiskEntry)
Definition:
partlist.c:3587
DPRINT
#define DPRINT
Definition:
sndvol32.h:73
_DISKENTRY::Dirty
BOOLEAN Dirty
Definition:
partlist.h:136
_DISKENTRY::LayoutBuffer
PDRIVE_LAYOUT_INFORMATION LayoutBuffer
Definition:
partlist.h:143
_DRIVE_LAYOUT_INFORMATION::Signature
ULONG Signature
Definition:
ntdddisk.h:420
PWSTR
uint16_t * PWSTR
Definition:
typedefs.h:56
INT
int32_t INT
Definition:
typedefs.h:58
ULONG
uint32_t ULONG
Definition:
typedefs.h:59
base
system
diskpart
uniqueid.c
Generated on Wed Oct 30 2024 06:05:47 for ReactOS by
1.9.6