ReactOS  0.4.15-dev-4914-g2220e56
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 
55 typedef struct _COMMAND
56 {
60  BOOL (*func)(INT, WCHAR**);
63 } COMMAND, *PCOMMAND;
64 
65 extern 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 
79 typedef enum _FORMATSTATE
80 {
87 
88 typedef enum _VOLUME_TYPE
89 {
95 
96 typedef 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 
134 typedef struct _BIOSDISKENTRY
135 {
139  ULONG Checksum;
144 
145 
146 typedef struct _DISKENTRY
147 {
149 
154 
158 
161 // ULONG Signature;
162 // ULONG Checksum;
163 
165  USHORT Port;
169 
170  /* Has the partition list been modified? */
171  BOOLEAN Dirty;
172 
174  BOOLEAN NoMbr; /* MBR is absent */
175 
177 
179 
181 
184 
186 
187 typedef struct _VOLENTRY
188 {
190 
194 
196 
201 
203 
204 } VOLENTRY, *PVOLENTRY;
205 
206 
207 /* GLOBAL VARIABLES ***********************************************************/
208 
209 extern LIST_ENTRY DiskListHead;
212 
213 extern PDISKENTRY CurrentDisk;
215 extern PVOLENTRY CurrentVolume;
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 */
250 BOOL
252  _In_ INT argc,
253  _In_ PWSTR *argv);
254 
255 BOOL
257  _In_ INT argc,
258  _In_ PWSTR *argv);
259 
260 BOOL
262  _In_ INT argc,
263  _In_ PWSTR *argv);
264 
265 /* delete.c */
266 BOOL
267 DeleteDisk(
268  _In_ INT argc,
269  _In_ PWSTR *argv);
270 
271 BOOL
273  _In_ INT argc,
274  _In_ PWSTR *argv);
275 
276 BOOL
278  _In_ INT argc,
279  _In_ PWSTR *argv);
280 
281 
282 /* detach.c */
284 
285 /* detail.c */
286 BOOL
287 DetailDisk(
288  INT argc,
289  PWSTR *argv);
290 
291 BOOL
293  INT argc,
294  PWSTR *argv);
295 
296 BOOL
298  INT argc,
299  PWSTR *argv);
300 
301 /* diskpart.c */
302 
303 /* dump.c */
304 BOOL
305 DumpDisk(
306  _In_ INT argc,
307  _In_ LPWSTR *argv);
308 
309 BOOL
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 */
333 BOOL HelpCommand(PCOMMAND pCommand);
334 
335 /* import. c */
337 
338 /* inactive.c */
340 
341 /* interpreter.c */
345 
346 /* list.c */
347 BOOL
348 ListDisk(
349  INT argc,
350  PWSTR *argv);
351 
352 BOOL
354  INT argc,
355  PWSTR *argv);
356 
357 BOOL
358 ListVolume(
359  INT argc,
360  PWSTR *argv);
361 
362 BOOL
364  INT argc,
365  PWSTR *argv);
366 
367 VOID
368 PrintDisk(
369  _In_ PDISKENTRY DiskEntry);
370 
371 VOID
373  _In_ PVOLENTRY VolumeEntry);
374 
375 /* merge.c */
377 
378 /* misc.c */
379 BOOL
381  _In_ PWSTR pszDecString);
382 
383 BOOL
385  _In_ PWSTR pszHexString);
386 
387 BOOL
388 HasPrefix(
390  _In_ PWSTR pszPrefix,
391  _Out_opt_ PWSTR *pszSuffix);
392 
393 ULONGLONG
395  _In_ ULONGLONG Dividend,
397 
398 PWSTR
400  _In_ PWSTR pszInString);
401 
402 PWSTR
404  _In_ PWSTR pszInString);
405 
406 /* offline.c */
408 
409 /* online.c */
411 
412 /* partlist.c */
413 ULONGLONG
414 AlignDown(
417 
418 NTSTATUS
420 
421 VOID
423 
424 NTSTATUS
426 
427 VOID
429 
430 NTSTATUS
432  _In_ PDISKENTRY DiskEntry);
433 
434 VOID
436  _In_ PDISKENTRY DiskEntry);
437 
440  _In_ PPARTENTRY PartEntry);
441 
444  _In_ PPARTENTRY PartEntry);
445 
446 ULONG
448  _In_ PDISKENTRY DiskEntry);
449 
450 NTSTATUS
452  _In_ PPARTENTRY PartEntry);
453 
454 PVOLENTRY
456  _In_ PPARTENTRY PartEntry);
457 
458 VOID
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 */
482 BOOL
483 SelectDisk(
484  INT argc,
485  PWSTR *argv);
486 
487 BOOL
489  INT argc,
490  PWSTR *argv);
491 
492 BOOL
494  INT argc,
495  PWSTR *argv);
496 /*
497 BOOL
498 SelectVirtualDisk(
499  INT argc,
500  PWSTR *argv);
501 */
502 /* setid.c */
504 
505 /* shrink.c */
507 
508 /* uniqueid.c */
509 BOOL
511  _In_ INT argc,
512  _In_ PWSTR *argv);
513 
514 #endif /* DISKPART_H */
LIST_ENTRY PrimaryPartListHead
Definition: partlist.h:131
USHORT TargetId
Definition: diskpart.h:167
GLenum func
Definition: glext.h:6028
PPARTENTRY CurrentPartition
Definition: partlist.c:75
PWSTR cmd2
Definition: diskpart.h:58
BOOL filesystems_main(INT argc, LPWSTR *argv)
BOOL DeleteVolume(_In_ INT argc, _In_ PWSTR *argv)
Definition: delete.c:203
static int argc
Definition: ServiceArgs.c:12
ULONG PartitionNumber
Definition: partlist.h:55
BOOL active_main(INT argc, LPWSTR *argv)
ULARGE_INTEGER StartSector
Definition: partlist.h:49
BOOL SelectPartition(INT argc, PWSTR *argv)
Definition: select.c:79
BOOL HasPrefix(_In_ PWSTR pszString, _In_ PWSTR pszPrefix, _Out_opt_ PWSTR *pszSuffix)
Definition: misc.c:58
BOOL setid_main(INT argc, LPWSTR *argv)
BOOL shrink_main(INT argc, LPWSTR *argv)
Definition: shrink.c:11
BOOL attach_main(INT argc, LPWSTR *argv)
Definition: attach.c:11
WCHAR VolumeLabel[20]
Definition: partlist.h:59
BOOL DetailVolume(INT argc, PWSTR *argv)
ULONG CylinderAlignment
Definition: partlist.h:99
ULONG GetPrimaryPartitionCount(_In_ PDISKENTRY DiskEntry)
Definition: partlist.c:1635
BOOL SelectVolume(INT argc, PWSTR *argv)
Definition: select.c:169
BOOL assign_main(INT argc, LPWSTR *argv)
Definition: assign.c:11
struct _PARTENTRY * PPARTENTRY
BOOL help_main(INT argc, LPWSTR *argv)
Definition: help.c:120
uint16_t * PWSTR
Definition: typedefs.h:56
ULARGE_INTEGER SectorCount
Definition: partlist.h:50
ULONG Checksum
Definition: partlist.h:146
char CHAR
Definition: xmlstorage.h:175
struct _FILE_SYSTEM_ITEM * FileSystem
Definition: diskpart.h:130
VOID PrintDisk(_In_ PDISKENTRY DiskEntry)
Definition: list.c:17
BOOL format_main(INT argc, LPWSTR *argv)
Definition: format.c:11
ULONG Signature
Definition: partlist.h:145
LONG NTSTATUS
Definition: precomp.h:26
enum _VOLUME_TYPE VOLUME_TYPE
#define INT
Definition: polytest.cpp:20
BOOL DumpDisk(_In_ INT argc, _In_ LPWSTR *argv)
Definition: dump.c:48
PPARTENTRY GetPrevUnpartitionedEntry(_In_ PPARTENTRY PartEntry)
Definition: partlist.c:1901
VOID RemoveVolume(_In_ PVOLENTRY VolumeEntry)
Definition: partlist.c:2103
BOOL recover_main(INT argc, LPWSTR *argv)
Definition: recover.c:11
PPARTENTRY GetNextUnpartitionedEntry(_In_ PPARTENTRY PartEntry)
Definition: partlist.c:1930
PVOLUME_DISK_EXTENTS pExtents
Definition: diskpart.h:202
enum _FORMATSTATE * PFORMATSTATE
ULARGE_INTEGER Size
Definition: diskpart.h:200
ULONG DiskNumber
Definition: partlist.h:111
LIST_ENTRY BiosDiskListHead
Definition: partlist.c:71
BOOL HelpCommand(PCOMMAND pCommand)
Definition: help.c:46
BOOL CreateLogicalPartition(_In_ INT argc, _In_ PWSTR *argv)
Definition: create.c:195
enum _VOLUME_TYPE * PVOLUME_TYPE
PDISKENTRY CurrentDisk
Definition: partlist.c:74
struct _BIOSDISKENTRY * PBIOSDISKENTRY
BOOL rescan_main(INT argc, LPWSTR *argv)
Definition: rescan.c:11
#define argv
Definition: mplay32.c:18
#define BOOL
Definition: nt_native.h:43
BOOL CreateExtendedPartition(_In_ INT argc, _In_ PWSTR *argv)
Definition: create.c:16
NTSTATUS CreateVolumeList(VOID)
Definition: partlist.c:1412
int32_t INT
Definition: typedefs.h:58
struct _COMMAND * PCOMMAND
VOID InterpretMain(VOID)
Definition: interpreter.c:231
LIST_ENTRY ListEntry
Definition: diskpart.h:189
DWORD help_detail
Definition: diskpart.h:62
PPARTENTRY ExtendedPartition
Definition: partlist.h:135
struct _VOLENTRY * PVOLENTRY
BOOL attributes_main(INT argc, LPWSTR *argv)
Definition: attributes.c:11
BOOL IsHexString(_In_ PWSTR pszHexString)
Definition: misc.c:36
LIST_ENTRY ListEntry
Definition: partlist.h:43
BOOL DeleteDisk(_In_ INT argc, _In_ PWSTR *argv)
Definition: delete.c:28
BOOLEAN LogicalPartition
Definition: partlist.h:63
BOOL DeletePartition(_In_ INT argc, _In_ PWSTR *argv)
Definition: delete.c:37
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3272
NTSTATUS DismountVolume(_In_ PPARTENTRY PartEntry)
Definition: partlist.c:1958
PWSTR cmd1
Definition: diskpart.h:57
COMMAND cmds[]
Definition: main.c:21
struct _DISKENTRY * PDISKENTRY
unsigned int BOOL
Definition: ntddk_ex.h:94
WCHAR DriveLetter
Definition: diskpart.h:195
FORMATSTATE FormatState
Definition: partlist.h:61
VOID HelpCommandList(VOID)
Definition: help.c:16
enum _FORMATSTATE FORMATSTATE
PVOLENTRY GetVolumeFromPartition(_In_ PPARTENTRY PartEntry)
Definition: partlist.c:2066
WCHAR VolumeName[MAX_PATH]
Definition: diskpart.h:192
VOID DestroyVolumeList(VOID)
Definition: partlist.c:1450
BOOL break_main(INT argc, LPWSTR *argv)
Definition: break.c:11
BOOL InterpretScript(LPWSTR line)
Definition: interpreter.c:183
BOOLEAN Dirty
Definition: partlist.h:118
unsigned char BOOLEAN
#define _In_
Definition: ms_sal.h:308
Definition: parser.c:48
PWSTR pszLabel
Definition: diskpart.h:197
BOOL add_main(INT argc, LPWSTR *argv)
Definition: add.c:11
BOOL CreatePrimaryPartition(_In_ INT argc, _In_ PWSTR *argv)
Definition: create.c:395
ULARGE_INTEGER SectorCount
Definition: partlist.h:97
BOOLEAN AutoCreate
Definition: partlist.h:74
ULONG SectorAlignment
Definition: partlist.h:98
BOOL DumpPartition(_In_ INT argc, _In_ LPWSTR *argv)
Definition: dump.c:146
LIST_ENTRY DiskListHead
Definition: partlist.c:70
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:406
INT help
Definition: diskpart.h:61
USHORT Lun
Definition: diskpart.h:168
BOOL ListVolume(INT argc, PWSTR *argv)
Definition: list.c:282
UCHAR PartitionType
Definition: partlist.h:53
BOOLEAN BiosFound
Definition: partlist.h:102
struct _DISKENTRY * DiskEntry
Definition: partlist.h:46
ULONG BytesPerSector
Definition: partlist.h:95
struct _PARTENTRY PARTENTRY
__wchar_t WCHAR
Definition: xmlstorage.h:180
UNICODE_STRING DriverName
Definition: partlist.h:123
uint64_t ULONGLONG
Definition: typedefs.h:67
ULONG OnDiskPartitionNumber
Definition: partlist.h:54
struct _VOLENTRY VOLENTRY
#define MAX_PATH
Definition: compat.h:34
CM_DISK_GEOMETRY_DEVICE_DATA DiskGeometry
Definition: partlist.h:148
CHAR DriveLetter
Definition: diskpart.h:111
LIST_ENTRY ListEntry
Definition: partlist.h:83
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL InterpretCmd(INT argc, LPWSTR *argv)
BOOL SelectDisk(INT argc, PWSTR *argv)
Definition: select.c:17
USHORT PathId
Definition: diskpart.h:166
ULONGLONG RoundingDivide(_In_ ULONGLONG Dividend, _In_ ULONGLONG Divisor)
Definition: misc.c:75
unsigned char UCHAR
Definition: xmlstorage.h:181
BOOL inactive_main(INT argc, LPWSTR *argv)
ULONG SectorsPerTrack
Definition: partlist.h:94
BOOL ListDisk(INT argc, PWSTR *argv)
Definition: list.c:59
struct _COMMAND COMMAND
ULONG BiosDiskNumber
Definition: diskpart.h:160
Definition: typedefs.h:119
BOOL automount_main(INT argc, LPWSTR *argv)
Definition: automount.c:11
ULONGLONG Cylinders
Definition: partlist.h:92
NTSTATUS CreatePartitionList(VOID)
Definition: partlist.c:1847
struct _DISKENTRY DISKENTRY
BOOLEAN New
Definition: partlist.h:71
BOOL remove_main(INT argc, LPWSTR *argv)
Definition: remove.c:11
BOOLEAN Recognized
Definition: diskpart.h:140
BOOLEAN NeedsCheck
Definition: partlist.h:77
BOOL compact_main(INT argc, LPWSTR *argv)
Definition: compact.c:11
BOOL convert_main(INT argc, LPWSTR *argv)
Definition: convert.c:11
ULONG VolumeNumber
Definition: diskpart.h:191
enum _FORMATSTATE FORMATSTATE
LIST_ENTRY ListEntry
Definition: partlist.h:141
BOOL extend_main(INT argc, LPWSTR *argv)
Definition: extend.c:11
unsigned short USHORT
Definition: pedump.c:61
BOOL DetailDisk(INT argc, PWSTR *argv)
ULONG DiskNumber
Definition: partlist.h:144
BOOL retain_main(INT argc, LPWSTR *argv)
Definition: retain.c:11
VOLUME_TYPE VolumeType
Definition: diskpart.h:199
BOOL ListPartition(INT argc, PWSTR *argv)
Definition: list.c:88
BOOL import_main(INT argc, LPWSTR *argv)
Definition: import.c:11
USHORT Port
Definition: partlist.h:113
#define _Out_opt_
Definition: ms_sal.h:346
PWSTR pszFilesystem
Definition: diskpart.h:198
PWSTR cmd3
Definition: diskpart.h:59
ULONG TracksPerCylinder
Definition: partlist.h:93
struct _BIOSDISKENTRY BIOSDISKENTRY
BOOL expand_main(INT argc, LPWSTR *argv)
Definition: expand.c:11
BOOL detach_main(INT argc, LPWSTR *argv)
Definition: detach.c:11
LIST_ENTRY LogicalPartListHead
Definition: partlist.h:132
BOOL offline_main(INT argc, LPWSTR *argv)
Definition: offline.c:11
BOOLEAN BootIndicator
Definition: partlist.h:52
BOOL online_main(INT argc, LPWSTR *argv)
Definition: online.c:11
BOOL repair_main(INT argc, LPWSTR *argv)
Definition: repair.c:11
PWSTR DuplicateQuotedString(_In_ PWSTR pszInString)
Definition: misc.c:84
_In_ LARGE_INTEGER Divisor
Definition: rtlfuncs.h:3044
BOOL ListVirtualDisk(INT argc, PWSTR *argv)
Definition: list.c:310
unsigned int ULONG
Definition: retypes.h:1
ULONGLONG AlignDown(_In_ ULONGLONG Value, _In_ ULONG Alignment)
Definition: partlist.c:82
BOOL UniqueIdDisk(_In_ INT argc, _In_ PWSTR *argv)
Definition: uniqueid.c:17
LIST_ENTRY VolumeListHead
Definition: partlist.c:72
_FORMATSTATE
Definition: partlist.h:32
PVOLENTRY CurrentVolume
Definition: partlist.c:76
_VOLUME_TYPE
Definition: diskpart.h:88
PWSTR DuplicateString(_In_ PWSTR pszInString)
Definition: misc.c:129
BOOL merge_main(INT argc, LPWSTR *argv)
Definition: merge.c:11
CM_INT13_DRIVE_PARAMETER Int13DiskData
Definition: partlist.h:149
NTSTATUS WritePartitions(_In_ PDISKENTRY DiskEntry)
Definition: partlist.c:1479
BOOL clean_main(INT argc, LPWSTR *argv)
WCHAR * LPWSTR
Definition: xmlstorage.h:184
VOID PrintVolume(_In_ PVOLENTRY VolumeEntry)
Definition: list.c:230
Definition: main.c:14
CHAR FileSystemName[9]
Definition: diskpart.h:113
PDRIVE_LAYOUT_INFORMATION LayoutBuffer
Definition: partlist.h:125
BOOL DetailPartition(INT argc, PWSTR *argv)
BOOLEAN NewDisk
Definition: partlist.h:120
VOID UpdateDiskLayout(_In_ PDISKENTRY DiskEntry)
Definition: partlist.c:1731
BOOL gpt_main(INT argc, LPWSTR *argv)
Definition: gpt.c:11
BOOLEAN NoMbr
Definition: diskpart.h:174
BOOL IsDecString(_In_ PWSTR pszDecString)
Definition: misc.c:14
BOOL san_main(INT argc, LPWSTR *argv)
Definition: san.c:11
VOID DestroyPartitionList(VOID)
Definition: partlist.c:1131
_In_ DWORD _In_ DWORD _Out_writes_to_opt_ pcchString LPSTR pszString
Definition: wincrypt.h:4505
BOOLEAN IsPartitioned
Definition: partlist.h:66
ULONG PartitionIndex
Definition: partlist.h:56