ReactOS 0.4.16-dev-1972-gf20c09f
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#include <ntsecapi.h>
24
25#include <errno.h>
26#include <strsafe.h>
27
28#include <conutils.h>
29
30/*
31#define NTOS_MODE_USER
32#include <ndk/exfuncs.h>
33#include <ndk/iofuncs.h>
34#include <ndk/obfuncs.h>
35#include <ndk/psfuncs.h>
36#include <ndk/rtlfuncs.h>
37#include <ndk/umfuncs.h>
38*/
39
40#define NTOS_MODE_USER
41#include <ndk/cmfuncs.h>
42#include <ndk/exfuncs.h>
43#include <ndk/iofuncs.h>
44#include <ndk/kefuncs.h>
45#include <ndk/mmfuncs.h>
46#include <ndk/obfuncs.h>
47#include <ndk/psfuncs.h>
48#include <ndk/rtlfuncs.h>
49#include <ndk/setypes.h>
50#include <ndk/umfuncs.h>
51
52#include <fmifs/fmifs.h>
53
54#include "resource.h"
55
56//#define DUMP_PARTITION_TABLE
57
58/* DEFINES *******************************************************************/
59
60typedef struct _COMMAND
61{
69
70extern COMMAND cmds[];
71
72/* NOERR codes for the program */
73//#define ERROR_NONE 0
74//#define ERROR_FATAL 1
75//#define ERROR_CMD_ARG 2
76//#define ERROR_FILE 3
77//#define ERROR_SERVICE 4
78//#define ERROR_SYNTAX 5
79
80#define MAX_STRING_SIZE 1024
81#define MAX_ARGS_COUNT 256
82
83
84typedef enum _FORMATSTATE
85{
92
93typedef enum _VOLUME_TYPE
94{
100
101typedef struct _PARTENTRY
102{
104
105 struct _DISKENTRY *DiskEntry;
106
109
115
120
122
123 /* Partition is partitioned disk space */
125
126 /* Partition is new. Table does not exist on disk yet */
127 BOOLEAN New;
128
129 /* Partition was created automatically. */
131
132 /* Partition must be checked */
134
137
138
139typedef struct _BIOSDISKENTRY
140{
149
150
151typedef struct _DISKENTRY
152{
154
159
163
166// ULONG Signature;
167// ULONG Checksum;
168
170 USHORT Port;
174
175 /* Has the partition list been modified? */
177
180
182
183 PDRIVE_LAYOUT_INFORMATION_EX LayoutBuffer;
184
186
189
191
192typedef struct _VOLENTRY
193{
195
199
201
206
208
210
211
212/* GLOBAL VARIABLES ***********************************************************/
213
217
221
222/* PROTOTYPES *****************************************************************/
223
224/* active.c */
226
227/* add.c */
229
230/* assign.c */
232
233/* attach.c */
235
236/* attributes.h */
238
239/* automount.c */
241
242/* break.c */
244
245/* clean.c */
247
248/* compact.c */
250
251/* convert.c */
254 _In_ ULONG DiskNumber,
255 _In_ PCREATE_DISK DiskInfo);
256
257BOOL
259 _In_ INT argc,
260 _In_ PWSTR *argv);
261
262BOOL
264 _In_ INT argc,
265 _In_ PWSTR *argv);
266
267/* create.c */
268BOOL
270 _In_ INT argc,
271 _In_ PWSTR *argv);
272
273BOOL
275 _In_ INT argc,
276 _In_ PWSTR *argv);
277
278BOOL
280 _In_ INT argc,
281 _In_ PWSTR *argv);
282
283/* delete.c */
284BOOL
286 _In_ INT argc,
287 _In_ PWSTR *argv);
288
289BOOL
291 _In_ INT argc,
292 _In_ PWSTR *argv);
293
294BOOL
296 _In_ INT argc,
297 _In_ PWSTR *argv);
298
299
300/* detach.c */
302
303/* detail.c */
304BOOL
306 INT argc,
307 PWSTR *argv);
308
309BOOL
311 INT argc,
312 PWSTR *argv);
313
314BOOL
316 INT argc,
317 PWSTR *argv);
318
319/* diskpart.c */
320
321/* dump.c */
322BOOL
324 _In_ INT argc,
325 _In_ LPWSTR *argv);
326
327BOOL
329 _In_ INT argc,
330 _In_ LPWSTR *argv);
331
332
333/* expand.c */
335
336/* extend.c */
338
339/* filesystem.c */
341
342/* format.c */
344
345/* gpt.c */
347
348/* help.c */
351BOOL HelpCommand(PCOMMAND pCommand);
352
353/* import. c */
355
356/* inactive.c */
358
359/* interpreter.c */
363
364/* list.c */
365BOOL
367 INT argc,
368 PWSTR *argv);
369
370BOOL
372 INT argc,
373 PWSTR *argv);
374
375BOOL
377 INT argc,
378 PWSTR *argv);
379
380BOOL
382 INT argc,
383 PWSTR *argv);
384
385VOID
387 _In_ PDISKENTRY DiskEntry);
388
389VOID
391 _In_ PVOLENTRY VolumeEntry);
392
393/* merge.c */
395
396/* misc.c */
397BOOL
399 _In_ PWSTR pszDecString);
400
401BOOL
403 _In_ PWSTR pszHexString);
404
405BOOL
407 _In_ PWSTR pszString,
408 _In_ PWSTR pszPrefix,
409 _Out_opt_ PWSTR *pszSuffix);
410
413 _In_ ULONGLONG Dividend,
415
416PWSTR
418 _In_ PWSTR pszInString);
419
420PWSTR
422 _In_ PWSTR pszInString);
423
424VOID
426 _Out_ GUID *pGuid);
427
428VOID
430 _Out_ PDWORD pSignature);
431
432VOID
434 _Out_ PWSTR pszBuffer,
435 _In_ GUID *pGuid);
436
437/* offline.c */
439
440/* online.c */
442
443/* partlist.c */
444#ifdef DUMP_PARTITION_TABLE
445VOID
446DumpPartitionTable(
447 _In_ PDISKENTRY DiskEntry);
448#endif
449
454
457
458VOID
460
463
464VOID
466
467VOID
470 _In_ PDISKENTRY DiskEntry);
471
474 _In_ PDISKENTRY DiskEntry);
475
476VOID
478 _In_ PDISKENTRY DiskEntry);
479
482 _In_ PPARTENTRY PartEntry);
483
486 _In_ PPARTENTRY PartEntry);
487
488ULONG
490 _In_ PDISKENTRY DiskEntry);
491
494 _In_ PPARTENTRY PartEntry);
495
498 _In_ PPARTENTRY PartEntry);
499
500VOID
502 _In_ PVOLENTRY VolumeEntry);
503
504
505/* recover.c */
507
508/* remove.c */
510
511/* repair.c */
513
514/* rescan.c */
516
517/* retain.c */
519
520/* san.c */
522
523/* select.c */
524BOOL
526 INT argc,
527 PWSTR *argv);
528
529BOOL
531 INT argc,
532 PWSTR *argv);
533
534BOOL
536 INT argc,
537 PWSTR *argv);
538/*
539BOOL
540SelectVirtualDisk(
541 INT argc,
542 PWSTR *argv);
543*/
544/* setid.c */
546
547/* shrink.c */
549
550/* uniqueid.c */
551BOOL
553 _In_ INT argc,
554 _In_ PWSTR *argv);
555
556#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:2190
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:74
VOID CreateGUID(_Out_ GUID *pGuid)
Definition: misc.c:152
ULONGLONG AlignDown(_In_ ULONGLONG Value, _In_ ULONG Alignment)
Definition: partlist.c:135
_VOLUME_TYPE
Definition: diskpart.h:94
@ VOLUME_TYPE_UNKNOWN
Definition: diskpart.h:98
@ VOLUME_TYPE_REMOVABLE
Definition: diskpart.h:97
@ VOLUME_TYPE_CDROM
Definition: diskpart.h:95
@ VOLUME_TYPE_PARTITION
Definition: diskpart.h:96
BOOL ConvertGPT(_In_ INT argc, _In_ PWSTR *argv)
Definition: convert.c:94
BOOL HasPrefix(_In_ PWSTR pszString, _In_ PWSTR pszPrefix, _Out_opt_ PWSTR *pszSuffix)
Definition: misc.c:58
BOOL ConvertMBR(_In_ INT argc, _In_ PWSTR *argv)
Definition: convert.c:149
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:73
BOOL InterpretScript(LPWSTR line)
Definition: interpreter.c:186
PPARTENTRY GetPrevUnpartitionedEntry(_In_ PPARTENTRY PartEntry)
Definition: partlist.c:1987
BOOL rescan_main(INT argc, LPWSTR *argv)
Definition: rescan.c:11
struct _VOLENTRY VOLENTRY
VOID PrintGUID(_Out_ PWSTR pszBuffer, _In_ GUID *pGuid)
Definition: misc.c:187
BOOL SelectPartition(INT argc, PWSTR *argv)
Definition: select.c:119
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:1529
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:2045
NTSTATUS WritePartitions(_In_ PDISKENTRY DiskEntry)
Definition: partlist.c:1558
PDISKENTRY CurrentDisk
Definition: partlist.c:76
struct _COMMAND * PCOMMAND
BOOL ListVolume(INT argc, PWSTR *argv)
Definition: list.c:282
BOOL CreateLogicalPartition(_In_ INT argc, _In_ PWSTR *argv)
Definition: create.c:206
NTSTATUS CreateVolumeList(VOID)
Definition: partlist.c:1491
struct _VOLENTRY * PVOLENTRY
VOID DestroyPartitionList(VOID)
Definition: partlist.c:1210
BOOL shrink_main(INT argc, LPWSTR *argv)
Definition: shrink.c:11
VOID ReadLayoutBuffer(_In_ HANDLE FileHandle, _In_ PDISKENTRY DiskEntry)
Definition: partlist.c:816
struct _PARTENTRY * PPARTENTRY
struct _BIOSDISKENTRY * PBIOSDISKENTRY
@ UnknownFormat
Definition: diskpart.h:88
@ Preformatted
Definition: diskpart.h:89
@ Formatted
Definition: diskpart.h:90
@ Unformatted
Definition: diskpart.h:86
@ UnformattedOrDamaged
Definition: diskpart.h:87
LIST_ENTRY DiskListHead
Definition: partlist.c:72
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:209
BOOL automount_main(INT argc, LPWSTR *argv)
Definition: automount.c:11
NTSTATUS CreateDisk(_In_ ULONG DiskNumber, _In_ PCREATE_DISK DiskInfo)
Definition: convert.c:15
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:1988
BOOL ListVirtualDisk(INT argc, PWSTR *argv)
Definition: list.c:310
struct _DISKENTRY DISKENTRY
enum _VOLUME_TYPE VOLUME_TYPE
PVOLENTRY CurrentVolume
Definition: partlist.c:78
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:77
PVOLENTRY GetVolumeFromPartition(_In_ PPARTENTRY PartEntry)
Definition: partlist.c:2153
VOID InterpretMain(VOID)
Definition: interpreter.c:234
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:1810
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:406
PPARTENTRY GetNextUnpartitionedEntry(_In_ PPARTENTRY PartEntry)
Definition: partlist.c:2016
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)
VOID CreateSignature(_Out_ PDWORD pSignature)
Definition: misc.c:168
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
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
Definition: fltkernel.h:1231
GLenum func
Definition: glext.h:6028
_FORMATSTATE
Definition: partlist.h:33
#define argv
Definition: mplay32.c:18
#define _Out_opt_
Definition: no_sal2.h:214
#define _Out_
Definition: no_sal2.h:160
#define _In_
Definition: no_sal2.h:158
#define BOOL
Definition: nt_native.h:43
DWORD * PDWORD
Definition: pedump.c:68
unsigned short USHORT
Definition: pedump.c:61
#define INT
Definition: polytest.cpp:20
#define GetPrimaryPartitionCount(DiskEntry)
Definition: partlist.c:2527
#define DuplicateString(x)
Definition: stringutils.h:45
BOOLEAN Recognized
Definition: diskpart.h:145
LIST_ENTRY ListEntry
Definition: partlist.h:159
ULONG DiskNumber
Definition: partlist.h:162
ULONG Checksum
Definition: partlist.h:164
ULONG Signature
Definition: partlist.h:163
CM_DISK_GEOMETRY_DEVICE_DATA DiskGeometry
Definition: partlist.h:166
CM_INT13_DRIVE_PARAMETER Int13DiskData
Definition: partlist.h:167
Definition: main.c:15
INT help
Definition: diskpart.h:66
PWSTR cmd3
Definition: diskpart.h:64
DWORD help_detail
Definition: diskpart.h:67
PWSTR cmd2
Definition: diskpart.h:63
PWSTR cmd1
Definition: diskpart.h:62
ULONG SectorAlignment
Definition: partlist.h:116
ULONG BiosDiskNumber
Definition: diskpart.h:165
PDRIVE_LAYOUT_INFORMATION_EX LayoutBuffer
Definition: diskpart.h:183
ULARGE_INTEGER SectorCount
Definition: partlist.h:115
UNICODE_STRING DriverName
Definition: partlist.h:141
ULONG SectorsPerTrack
Definition: partlist.h:112
USHORT TargetId
Definition: diskpart.h:172
PPARTENTRY ExtendedPartition
Definition: partlist.h:153
LIST_ENTRY LogicalPartListHead
Definition: partlist.h:150
BOOLEAN NewDisk
Definition: partlist.h:138
ULONG DiskNumber
Definition: partlist.h:129
ULONG BytesPerSector
Definition: partlist.h:113
USHORT PathId
Definition: diskpart.h:171
BOOLEAN BiosFound
Definition: partlist.h:120
ULONGLONG Cylinders
Definition: partlist.h:110
USHORT Lun
Definition: diskpart.h:173
LIST_ENTRY ListEntry
Definition: partlist.h:101
BOOLEAN Dirty
Definition: partlist.h:136
USHORT Port
Definition: partlist.h:131
DWORD PartitionStyle
Definition: diskpart.h:179
ULONG TracksPerCylinder
Definition: partlist.h:111
LIST_ENTRY PrimaryPartListHead
Definition: partlist.h:149
ULONG CylinderAlignment
Definition: partlist.h:117
Definition: typedefs.h:120
BOOLEAN IsPartitioned
Definition: partlist.h:82
UCHAR PartitionType
Definition: partlist.h:73
BOOLEAN AutoCreate
Definition: diskpart.h:130
BOOLEAN New
Definition: partlist.h:85
ULARGE_INTEGER SectorCount
Definition: partlist.h:70
BOOLEAN BootIndicator
Definition: partlist.h:72
CHAR VolumeLabel[17]
Definition: diskpart.h:117
struct _DISKENTRY * DiskEntry
Definition: partlist.h:66
BOOLEAN LogicalPartition
Definition: partlist.h:79
CHAR DriveLetter
Definition: diskpart.h:116
FORMATSTATE FormatState
Definition: diskpart.h:119
struct _FILE_SYSTEM_ITEM * FileSystem
Definition: diskpart.h:135
ULONG OnDiskPartitionNumber
Definition: partlist.h:74
BOOLEAN NeedsCheck
Definition: diskpart.h:133
LIST_ENTRY ListEntry
Definition: partlist.h:63
ULONG PartitionNumber
Definition: partlist.h:75
ULARGE_INTEGER StartSector
Definition: partlist.h:69
ULONG PartitionIndex
Definition: partlist.h:76
CHAR FileSystemName[9]
Definition: diskpart.h:118
ULARGE_INTEGER Size
Definition: diskpart.h:205
VOLUME_TYPE VolumeType
Definition: diskpart.h:204
PVOLUME_DISK_EXTENTS pExtents
Definition: diskpart.h:207
ULONG VolumeNumber
Definition: diskpart.h:196
PWSTR pszFilesystem
Definition: diskpart.h:203
WCHAR VolumeName[MAX_PATH]
Definition: diskpart.h:197
LIST_ENTRY ListEntry
Entry in VolumesList.
Definition: partlist.h:45
PWSTR pszLabel
Definition: diskpart.h:202
WCHAR DriveLetter
Definition: diskpart.h:200
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:3281
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
_In_ LARGE_INTEGER Divisor
Definition: rtlfuncs.h:3061
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