ReactOS 0.4.15-dev-8102-g108db8f
diskpart.h
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/diskpart.h
5 * PURPOSE: Manages all the partitions of the OS in an interactive way.
6 * PROGRAMMERS: Lee Schroeder
7 */
8
9#ifndef DISKPART_H
10#define DISKPART_H
11
12/* INCLUDES ******************************************************************/
13
14#include <stdio.h>
15#include <stdlib.h>
16
17#define WIN32_NO_STATUS
18#include <windef.h>
19#include <winbase.h>
20#include <winreg.h>
21#include <wincon.h>
22#include <winioctl.h>
23
24#include <errno.h>
25#include <strsafe.h>
26
27#include <conutils.h>
28
29/*
30#define NTOS_MODE_USER
31#include <ndk/exfuncs.h>
32#include <ndk/iofuncs.h>
33#include <ndk/obfuncs.h>
34#include <ndk/psfuncs.h>
35#include <ndk/rtlfuncs.h>
36#include <ndk/umfuncs.h>
37*/
38
39#define NTOS_MODE_USER
40#include <ndk/cmfuncs.h>
41#include <ndk/exfuncs.h>
42#include <ndk/iofuncs.h>
43#include <ndk/kefuncs.h>
44#include <ndk/mmfuncs.h>
45#include <ndk/obfuncs.h>
46#include <ndk/psfuncs.h>
47#include <ndk/rtlfuncs.h>
48#include <ndk/setypes.h>
49#include <ndk/umfuncs.h>
50
51#include "resource.h"
52
53/* DEFINES *******************************************************************/
54
55typedef struct _COMMAND
56{
64
65extern COMMAND cmds[];
66
67/* NOERR codes for the program */
68//#define ERROR_NONE 0
69//#define ERROR_FATAL 1
70//#define ERROR_CMD_ARG 2
71//#define ERROR_FILE 3
72//#define ERROR_SERVICE 4
73//#define ERROR_SYNTAX 5
74
75#define MAX_STRING_SIZE 1024
76#define MAX_ARGS_COUNT 256
77
78
79typedef enum _FORMATSTATE
80{
87
88typedef enum _VOLUME_TYPE
89{
95
96typedef struct _PARTENTRY
97{
99
100 struct _DISKENTRY *DiskEntry;
101
104
110
115
117
118 /* Partition is partitioned disk space */
120
121 /* Partition is new. Table does not exist on disk yet */
122 BOOLEAN New;
123
124 /* Partition was created automatically. */
126
127 /* Partition must be checked */
129
132
133
134typedef struct _BIOSDISKENTRY
135{
144
145
146typedef struct _DISKENTRY
147{
149
154
158
161// ULONG Signature;
162// ULONG Checksum;
163
165 USHORT Port;
169
170 /* Has the partition list been modified? */
172
174 BOOLEAN NoMbr; /* MBR is absent */
175
177
179
181
184
186
187typedef struct _VOLENTRY
188{
190
194
196
201
203
205
206
207/* GLOBAL VARIABLES ***********************************************************/
208
212
216
217/* PROTOTYPES *****************************************************************/
218
219/* active.c */
221
222/* add.c */
224
225/* assign.c */
227
228/* attach.c */
230
231/* attributes.h */
233
234/* automount.c */
236
237/* break.c */
239
240/* clean.c */
242
243/* compact.c */
245
246/* convert.c */
248
249/* create.c */
250BOOL
252 _In_ INT argc,
253 _In_ PWSTR *argv);
254
255BOOL
257 _In_ INT argc,
258 _In_ PWSTR *argv);
259
260BOOL
262 _In_ INT argc,
263 _In_ PWSTR *argv);
264
265/* delete.c */
266BOOL
268 _In_ INT argc,
269 _In_ PWSTR *argv);
270
271BOOL
273 _In_ INT argc,
274 _In_ PWSTR *argv);
275
276BOOL
278 _In_ INT argc,
279 _In_ PWSTR *argv);
280
281
282/* detach.c */
284
285/* detail.c */
286BOOL
288 INT argc,
289 PWSTR *argv);
290
291BOOL
293 INT argc,
294 PWSTR *argv);
295
296BOOL
298 INT argc,
299 PWSTR *argv);
300
301/* diskpart.c */
302
303/* dump.c */
304BOOL
306 _In_ INT argc,
307 _In_ LPWSTR *argv);
308
309BOOL
311 _In_ INT argc,
312 _In_ LPWSTR *argv);
313
314
315/* expand.c */
317
318/* extend.c */
320
321/* filesystem.c */
323
324/* format.c */
326
327/* gpt.c */
329
330/* help.c */
333BOOL HelpCommand(PCOMMAND pCommand);
334
335/* import. c */
337
338/* inactive.c */
340
341/* interpreter.c */
345
346/* list.c */
347BOOL
349 INT argc,
350 PWSTR *argv);
351
352BOOL
354 INT argc,
355 PWSTR *argv);
356
357BOOL
359 INT argc,
360 PWSTR *argv);
361
362BOOL
364 INT argc,
365 PWSTR *argv);
366
367VOID
369 _In_ PDISKENTRY DiskEntry);
370
371VOID
373 _In_ PVOLENTRY VolumeEntry);
374
375/* merge.c */
377
378/* misc.c */
379BOOL
381 _In_ PWSTR pszDecString);
382
383BOOL
385 _In_ PWSTR pszHexString);
386
387BOOL
390 _In_ PWSTR pszPrefix,
391 _Out_opt_ PWSTR *pszSuffix);
392
395 _In_ ULONGLONG Dividend,
397
398PWSTR
400 _In_ PWSTR pszInString);
401
402PWSTR
404 _In_ PWSTR pszInString);
405
406/* offline.c */
408
409/* online.c */
411
412/* partlist.c */
417
420
421VOID
423
426
427VOID
429
432 _In_ PDISKENTRY DiskEntry);
433
434VOID
436 _In_ PDISKENTRY DiskEntry);
437
440 _In_ PPARTENTRY PartEntry);
441
444 _In_ PPARTENTRY PartEntry);
445
446ULONG
448 _In_ PDISKENTRY DiskEntry);
449
452 _In_ PPARTENTRY PartEntry);
453
456 _In_ PPARTENTRY PartEntry);
457
458VOID
460 _In_ PVOLENTRY VolumeEntry);
461
462
463/* recover.c */
465
466/* remove.c */
468
469/* repair.c */
471
472/* rescan.c */
474
475/* retain.c */
477
478/* san.c */
480
481/* select.c */
482BOOL
484 INT argc,
485 PWSTR *argv);
486
487BOOL
489 INT argc,
490 PWSTR *argv);
491
492BOOL
494 INT argc,
495 PWSTR *argv);
496/*
497BOOL
498SelectVirtualDisk(
499 INT argc,
500 PWSTR *argv);
501*/
502/* setid.c */
504
505/* shrink.c */
507
508/* uniqueid.c */
509BOOL
511 _In_ INT argc,
512 _In_ PWSTR *argv);
513
514#endif /* DISKPART_H */
unsigned char BOOLEAN
static int argc
Definition: ServiceArgs.c:12
LONG NTSTATUS
Definition: precomp.h:26
BOOL HelpCommand(PCOMMAND pCommand)
Definition: help.c:46
BOOL retain_main(INT argc, LPWSTR *argv)
Definition: retain.c:11
VOID RemoveVolume(_In_ PVOLENTRY VolumeEntry)
Definition: partlist.c:2103
BOOL ListPartition(INT argc, PWSTR *argv)
Definition: list.c:88
BOOL DumpPartition(_In_ INT argc, _In_ LPWSTR *argv)
Definition: dump.c:146
LIST_ENTRY VolumeListHead
Definition: partlist.c:72
ULONGLONG AlignDown(_In_ ULONGLONG Value, _In_ ULONG Alignment)
Definition: partlist.c:82
_VOLUME_TYPE
Definition: diskpart.h:89
@ VOLUME_TYPE_UNKNOWN
Definition: diskpart.h:93
@ VOLUME_TYPE_REMOVABLE
Definition: diskpart.h:92
@ VOLUME_TYPE_CDROM
Definition: diskpart.h:90
@ VOLUME_TYPE_PARTITION
Definition: diskpart.h:91
BOOL HasPrefix(_In_ PWSTR pszString, _In_ PWSTR pszPrefix, _Out_opt_ PWSTR *pszSuffix)
Definition: misc.c:58
ULONG GetPrimaryPartitionCount(_In_ PDISKENTRY DiskEntry)
Definition: partlist.c:1635
BOOL filesystems_main(INT argc, LPWSTR *argv)
BOOL SelectDisk(INT argc, PWSTR *argv)
Definition: select.c:17
BOOL online_main(INT argc, LPWSTR *argv)
Definition: online.c:11
BOOL attributes_main(INT argc, LPWSTR *argv)
Definition: attributes.c:11
BOOL extend_main(INT argc, LPWSTR *argv)
Definition: extend.c:11
BOOL expand_main(INT argc, LPWSTR *argv)
Definition: expand.c:11
LIST_ENTRY BiosDiskListHead
Definition: partlist.c:71
BOOL InterpretScript(LPWSTR line)
Definition: interpreter.c:183
PPARTENTRY GetPrevUnpartitionedEntry(_In_ PPARTENTRY PartEntry)
Definition: partlist.c:1901
BOOL rescan_main(INT argc, LPWSTR *argv)
Definition: rescan.c:11
struct _VOLENTRY VOLENTRY
BOOL SelectPartition(INT argc, PWSTR *argv)
Definition: select.c:79
enum _FORMATSTATE FORMATSTATE
BOOL detach_main(INT argc, LPWSTR *argv)
Definition: detach.c:11
BOOL merge_main(INT argc, LPWSTR *argv)
Definition: merge.c:11
enum _FORMATSTATE * PFORMATSTATE
BOOL UniqueIdDisk(_In_ INT argc, _In_ PWSTR *argv)
Definition: uniqueid.c:17
BOOL InterpretCmd(INT argc, LPWSTR *argv)
BOOL offline_main(INT argc, LPWSTR *argv)
Definition: offline.c:11
VOID DestroyVolumeList(VOID)
Definition: partlist.c:1450
BOOL assign_main(INT argc, LPWSTR *argv)
Definition: assign.c:11
BOOL inactive_main(INT argc, LPWSTR *argv)
NTSTATUS DismountVolume(_In_ PPARTENTRY PartEntry)
Definition: partlist.c:1958
NTSTATUS WritePartitions(_In_ PDISKENTRY DiskEntry)
Definition: partlist.c:1479
PDISKENTRY CurrentDisk
Definition: partlist.c:74
struct _COMMAND * PCOMMAND
BOOL ListVolume(INT argc, PWSTR *argv)
Definition: list.c:282
BOOL CreateLogicalPartition(_In_ INT argc, _In_ PWSTR *argv)
Definition: create.c:195
NTSTATUS CreateVolumeList(VOID)
Definition: partlist.c:1412
struct _VOLENTRY * PVOLENTRY
VOID DestroyPartitionList(VOID)
Definition: partlist.c:1131
BOOL shrink_main(INT argc, LPWSTR *argv)
Definition: shrink.c:11
BOOL convert_main(INT argc, LPWSTR *argv)
Definition: convert.c:11
struct _PARTENTRY * PPARTENTRY
struct _BIOSDISKENTRY * PBIOSDISKENTRY
@ UnknownFormat
Definition: diskpart.h:83
@ Preformatted
Definition: diskpart.h:84
@ Formatted
Definition: diskpart.h:85
@ Unformatted
Definition: diskpart.h:81
@ UnformattedOrDamaged
Definition: diskpart.h:82
LIST_ENTRY DiskListHead
Definition: partlist.c:70
BOOL CreateExtendedPartition(_In_ INT argc, _In_ PWSTR *argv)
Definition: create.c:16
BOOL add_main(INT argc, LPWSTR *argv)
Definition: add.c:11
BOOL DumpDisk(_In_ INT argc, _In_ LPWSTR *argv)
Definition: dump.c:48
BOOL SelectVolume(INT argc, PWSTR *argv)
Definition: select.c:169
BOOL automount_main(INT argc, LPWSTR *argv)
Definition: automount.c:11
BOOL clean_main(INT argc, LPWSTR *argv)
BOOL import_main(INT argc, LPWSTR *argv)
Definition: import.c:11
BOOL repair_main(INT argc, LPWSTR *argv)
Definition: repair.c:11
struct _COMMAND COMMAND
BOOL DetailVolume(INT argc, PWSTR *argv)
BOOL format_main(INT argc, LPWSTR *argv)
Definition: format.c:11
NTSTATUS CreatePartitionList(VOID)
Definition: partlist.c:1867
BOOL ListVirtualDisk(INT argc, PWSTR *argv)
Definition: list.c:310
struct _DISKENTRY DISKENTRY
enum _VOLUME_TYPE VOLUME_TYPE
PVOLENTRY CurrentVolume
Definition: partlist.c:76
BOOL help_main(INT argc, LPWSTR *argv)
Definition: help.c:120
BOOL IsDecString(_In_ PWSTR pszDecString)
Definition: misc.c:14
PPARTENTRY CurrentPartition
Definition: partlist.c:75
PVOLENTRY GetVolumeFromPartition(_In_ PPARTENTRY PartEntry)
Definition: partlist.c:2066
VOID InterpretMain(VOID)
Definition: interpreter.c:231
BOOL IsHexString(_In_ PWSTR pszHexString)
Definition: misc.c:36
VOID PrintDisk(_In_ PDISKENTRY DiskEntry)
Definition: list.c:17
COMMAND cmds[]
Definition: main.c:21
BOOL attach_main(INT argc, LPWSTR *argv)
Definition: attach.c:11
VOID HelpCommandList(VOID)
Definition: help.c:16
BOOL setid_main(INT argc, LPWSTR *argv)
BOOL DeleteVolume(_In_ INT argc, _In_ PWSTR *argv)
Definition: delete.c:203
BOOL remove_main(INT argc, LPWSTR *argv)
Definition: remove.c:11
VOID UpdateDiskLayout(_In_ PDISKENTRY DiskEntry)
Definition: partlist.c:1731
enum _VOLUME_TYPE * PVOLUME_TYPE
BOOL break_main(INT argc, LPWSTR *argv)
Definition: break.c:11
BOOL CreatePrimaryPartition(_In_ INT argc, _In_ PWSTR *argv)
Definition: create.c:395
PPARTENTRY GetNextUnpartitionedEntry(_In_ PPARTENTRY PartEntry)
Definition: partlist.c:1930
BOOL compact_main(INT argc, LPWSTR *argv)
Definition: compact.c:11
BOOL DeletePartition(_In_ INT argc, _In_ PWSTR *argv)
Definition: delete.c:37
BOOL san_main(INT argc, LPWSTR *argv)
Definition: san.c:11
BOOL gpt_main(INT argc, LPWSTR *argv)
Definition: gpt.c:11
BOOL DeleteDisk(_In_ INT argc, _In_ PWSTR *argv)
Definition: delete.c:28
ULONGLONG RoundingDivide(_In_ ULONGLONG Dividend, _In_ ULONGLONG Divisor)
Definition: misc.c:75
PWSTR DuplicateQuotedString(_In_ PWSTR pszInString)
Definition: misc.c:84
BOOL ListDisk(INT argc, PWSTR *argv)
Definition: list.c:59
struct _BIOSDISKENTRY BIOSDISKENTRY
VOID PrintVolume(_In_ PVOLENTRY VolumeEntry)
Definition: list.c:230
struct _DISKENTRY * PDISKENTRY
BOOL active_main(INT argc, LPWSTR *argv)
struct _PARTENTRY PARTENTRY
BOOL DetailPartition(INT argc, PWSTR *argv)
BOOL DetailDisk(INT argc, PWSTR *argv)
BOOL recover_main(INT argc, LPWSTR *argv)
Definition: recover.c:11
#define MAX_PATH
Definition: compat.h:34
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum func
Definition: glext.h:6028
_FORMATSTATE
Definition: partlist.h:33
#define argv
Definition: mplay32.c:18
#define _Out_opt_
Definition: ms_sal.h:346
#define _In_
Definition: ms_sal.h:308
#define BOOL
Definition: nt_native.h:43
unsigned short USHORT
Definition: pedump.c:61
#define INT
Definition: polytest.cpp:20
#define DuplicateString(x)
Definition: stringutils.h:45
BOOLEAN Recognized
Definition: diskpart.h:140
LIST_ENTRY ListEntry
Definition: partlist.h:138
ULONG DiskNumber
Definition: partlist.h:141
ULONG Checksum
Definition: partlist.h:143
ULONG Signature
Definition: partlist.h:142
CM_DISK_GEOMETRY_DEVICE_DATA DiskGeometry
Definition: partlist.h:145
CM_INT13_DRIVE_PARAMETER Int13DiskData
Definition: partlist.h:146
Definition: main.c:15
INT help
Definition: diskpart.h:61
PWSTR cmd3
Definition: diskpart.h:59
DWORD help_detail
Definition: diskpart.h:62
PWSTR cmd2
Definition: diskpart.h:58
PWSTR cmd1
Definition: diskpart.h:57
ULONG SectorAlignment
Definition: partlist.h:95
ULONG BiosDiskNumber
Definition: diskpart.h:160
ULARGE_INTEGER SectorCount
Definition: partlist.h:94
UNICODE_STRING DriverName
Definition: partlist.h:120
ULONG SectorsPerTrack
Definition: partlist.h:91
USHORT TargetId
Definition: diskpart.h:167
PPARTENTRY ExtendedPartition
Definition: partlist.h:132
LIST_ENTRY LogicalPartListHead
Definition: partlist.h:129
BOOLEAN NewDisk
Definition: partlist.h:117
ULONG DiskNumber
Definition: partlist.h:108
ULONG BytesPerSector
Definition: partlist.h:92
USHORT PathId
Definition: diskpart.h:166
BOOLEAN BiosFound
Definition: partlist.h:99
ULONGLONG Cylinders
Definition: partlist.h:89
USHORT Lun
Definition: diskpart.h:168
LIST_ENTRY ListEntry
Definition: partlist.h:80
BOOLEAN Dirty
Definition: partlist.h:115
BOOLEAN NoMbr
Definition: diskpart.h:174
USHORT Port
Definition: partlist.h:110
ULONG TracksPerCylinder
Definition: partlist.h:90
LIST_ENTRY PrimaryPartListHead
Definition: partlist.h:128
ULONG CylinderAlignment
Definition: partlist.h:96
PDRIVE_LAYOUT_INFORMATION LayoutBuffer
Definition: partlist.h:122
Definition: typedefs.h:120
BOOLEAN IsPartitioned
Definition: partlist.h:66
UCHAR PartitionType
Definition: partlist.h:53
BOOLEAN AutoCreate
Definition: diskpart.h:125
BOOLEAN New
Definition: partlist.h:71
ULARGE_INTEGER SectorCount
Definition: partlist.h:50
BOOLEAN BootIndicator
Definition: partlist.h:52
WCHAR VolumeLabel[20]
Definition: partlist.h:59
struct _DISKENTRY * DiskEntry
Definition: partlist.h:46
BOOLEAN LogicalPartition
Definition: partlist.h:63
CHAR DriveLetter
Definition: diskpart.h:111
FORMATSTATE FormatState
Definition: partlist.h:61
struct _FILE_SYSTEM_ITEM * FileSystem
Definition: diskpart.h:130
ULONG OnDiskPartitionNumber
Definition: partlist.h:54
BOOLEAN NeedsCheck
Definition: partlist.h:74
LIST_ENTRY ListEntry
Definition: partlist.h:43
ULONG PartitionNumber
Definition: partlist.h:55
ULARGE_INTEGER StartSector
Definition: partlist.h:49
ULONG PartitionIndex
Definition: partlist.h:56
CHAR FileSystemName[9]
Definition: diskpart.h:113
ULARGE_INTEGER Size
Definition: diskpart.h:200
VOLUME_TYPE VolumeType
Definition: diskpart.h:199
PVOLUME_DISK_EXTENTS pExtents
Definition: diskpart.h:202
ULONG VolumeNumber
Definition: diskpart.h:191
PWSTR pszFilesystem
Definition: diskpart.h:198
WCHAR VolumeName[MAX_PATH]
Definition: diskpart.h:192
LIST_ENTRY ListEntry
Definition: diskpart.h:189
PWSTR pszLabel
Definition: diskpart.h:197
WCHAR DriveLetter
Definition: diskpart.h:195
Definition: parser.c:49
uint16_t * PWSTR
Definition: typedefs.h:56
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG
Definition: typedefs.h:59
uint64_t ULONGLONG
Definition: typedefs.h:67
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3275
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
_In_ DWORD _In_ DWORD _Out_writes_to_opt_ pcchString LPSTR pszString
Definition: wincrypt.h:4505
_In_ LARGE_INTEGER Divisor
Definition: rtlfuncs.h:3044
unsigned char UCHAR
Definition: xmlstorage.h:181
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
char CHAR
Definition: xmlstorage.h:175