ReactOS 0.4.16-dev-329-g9223134
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 <fmifs/fmifs.h>
52
53#include "resource.h"
54
55/* DEFINES *******************************************************************/
56
57typedef struct _COMMAND
58{
66
67extern COMMAND cmds[];
68
69/* NOERR codes for the program */
70//#define ERROR_NONE 0
71//#define ERROR_FATAL 1
72//#define ERROR_CMD_ARG 2
73//#define ERROR_FILE 3
74//#define ERROR_SERVICE 4
75//#define ERROR_SYNTAX 5
76
77#define MAX_STRING_SIZE 1024
78#define MAX_ARGS_COUNT 256
79
80
81typedef enum _FORMATSTATE
82{
89
90typedef enum _VOLUME_TYPE
91{
97
98typedef struct _PARTENTRY
99{
101
102 struct _DISKENTRY *DiskEntry;
103
106
112
117
119
120 /* Partition is partitioned disk space */
122
123 /* Partition is new. Table does not exist on disk yet */
124 BOOLEAN New;
125
126 /* Partition was created automatically. */
128
129 /* Partition must be checked */
131
134
135
136typedef struct _BIOSDISKENTRY
137{
146
147
148typedef struct _DISKENTRY
149{
151
156
160
163// ULONG Signature;
164// ULONG Checksum;
165
167 USHORT Port;
171
172 /* Has the partition list been modified? */
174
176 BOOLEAN NoMbr; /* MBR is absent */
177
179
181
183
186
188
189typedef struct _VOLENTRY
190{
192
196
198
203
205
207
208
209/* GLOBAL VARIABLES ***********************************************************/
210
214
218
219/* PROTOTYPES *****************************************************************/
220
221/* active.c */
223
224/* add.c */
226
227/* assign.c */
229
230/* attach.c */
232
233/* attributes.h */
235
236/* automount.c */
238
239/* break.c */
241
242/* clean.c */
244
245/* compact.c */
247
248/* convert.c */
250
251/* create.c */
252BOOL
254 _In_ INT argc,
255 _In_ PWSTR *argv);
256
257BOOL
259 _In_ INT argc,
260 _In_ PWSTR *argv);
261
262BOOL
264 _In_ INT argc,
265 _In_ PWSTR *argv);
266
267/* delete.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
284/* detach.c */
286
287/* detail.c */
288BOOL
290 INT argc,
291 PWSTR *argv);
292
293BOOL
295 INT argc,
296 PWSTR *argv);
297
298BOOL
300 INT argc,
301 PWSTR *argv);
302
303/* diskpart.c */
304
305/* dump.c */
306BOOL
308 _In_ INT argc,
309 _In_ LPWSTR *argv);
310
311BOOL
313 _In_ INT argc,
314 _In_ LPWSTR *argv);
315
316
317/* expand.c */
319
320/* extend.c */
322
323/* filesystem.c */
325
326/* format.c */
328
329/* gpt.c */
331
332/* help.c */
335BOOL HelpCommand(PCOMMAND pCommand);
336
337/* import. c */
339
340/* inactive.c */
342
343/* interpreter.c */
347
348/* list.c */
349BOOL
351 INT argc,
352 PWSTR *argv);
353
354BOOL
356 INT argc,
357 PWSTR *argv);
358
359BOOL
361 INT argc,
362 PWSTR *argv);
363
364BOOL
366 INT argc,
367 PWSTR *argv);
368
369VOID
371 _In_ PDISKENTRY DiskEntry);
372
373VOID
375 _In_ PVOLENTRY VolumeEntry);
376
377/* merge.c */
379
380/* misc.c */
381BOOL
383 _In_ PWSTR pszDecString);
384
385BOOL
387 _In_ PWSTR pszHexString);
388
389BOOL
392 _In_ PWSTR pszPrefix,
393 _Out_opt_ PWSTR *pszSuffix);
394
397 _In_ ULONGLONG Dividend,
399
400PWSTR
402 _In_ PWSTR pszInString);
403
404PWSTR
406 _In_ PWSTR pszInString);
407
408/* offline.c */
410
411/* online.c */
413
414/* partlist.c */
419
422
423VOID
425
428
429VOID
431
434 _In_ PDISKENTRY DiskEntry);
435
436VOID
438 _In_ PDISKENTRY DiskEntry);
439
442 _In_ PPARTENTRY PartEntry);
443
446 _In_ PPARTENTRY PartEntry);
447
448ULONG
450 _In_ PDISKENTRY DiskEntry);
451
454 _In_ PPARTENTRY PartEntry);
455
458 _In_ PPARTENTRY PartEntry);
459
460VOID
462 _In_ PVOLENTRY VolumeEntry);
463
464
465/* recover.c */
467
468/* remove.c */
470
471/* repair.c */
473
474/* rescan.c */
476
477/* retain.c */
479
480/* san.c */
482
483/* select.c */
484BOOL
486 INT argc,
487 PWSTR *argv);
488
489BOOL
491 INT argc,
492 PWSTR *argv);
493
494BOOL
496 INT argc,
497 PWSTR *argv);
498/*
499BOOL
500SelectVirtualDisk(
501 INT argc,
502 PWSTR *argv);
503*/
504/* setid.c */
506
507/* shrink.c */
509
510/* uniqueid.c */
511BOOL
513 _In_ INT argc,
514 _In_ PWSTR *argv);
515
516#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:2105
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
ULONGLONG AlignDown(_In_ ULONGLONG Value, _In_ ULONG Alignment)
Definition: partlist.c:84
_VOLUME_TYPE
Definition: diskpart.h:91
@ VOLUME_TYPE_UNKNOWN
Definition: diskpart.h:95
@ VOLUME_TYPE_REMOVABLE
Definition: diskpart.h:94
@ VOLUME_TYPE_CDROM
Definition: diskpart.h:92
@ VOLUME_TYPE_PARTITION
Definition: diskpart.h:93
BOOL HasPrefix(_In_ PWSTR pszString, _In_ PWSTR pszPrefix, _Out_opt_ PWSTR *pszSuffix)
Definition: misc.c:58
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:183
PPARTENTRY GetPrevUnpartitionedEntry(_In_ PPARTENTRY PartEntry)
Definition: partlist.c:1903
BOOL rescan_main(INT argc, LPWSTR *argv)
Definition: rescan.c:11
struct _VOLENTRY VOLENTRY
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:1452
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:1960
NTSTATUS WritePartitions(_In_ PDISKENTRY DiskEntry)
Definition: partlist.c:1481
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:195
NTSTATUS CreateVolumeList(VOID)
Definition: partlist.c:1414
struct _VOLENTRY * PVOLENTRY
VOID DestroyPartitionList(VOID)
Definition: partlist.c:1133
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:85
@ Preformatted
Definition: diskpart.h:86
@ Formatted
Definition: diskpart.h:87
@ Unformatted
Definition: diskpart.h:83
@ UnformattedOrDamaged
Definition: diskpart.h:84
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
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:2068
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:1733
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:1932
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: no_sal2.h:214
#define _In_
Definition: no_sal2.h:158
#define BOOL
Definition: nt_native.h:43
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:142
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:63
PWSTR cmd3
Definition: diskpart.h:61
DWORD help_detail
Definition: diskpart.h:64
PWSTR cmd2
Definition: diskpart.h:60
PWSTR cmd1
Definition: diskpart.h:59
ULONG SectorAlignment
Definition: partlist.h:116
ULONG BiosDiskNumber
Definition: diskpart.h:162
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:169
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:168
BOOLEAN BiosFound
Definition: partlist.h:120
ULONGLONG Cylinders
Definition: partlist.h:110
USHORT Lun
Definition: diskpart.h:170
LIST_ENTRY ListEntry
Definition: partlist.h:101
BOOLEAN Dirty
Definition: partlist.h:136
BOOLEAN NoMbr
Definition: diskpart.h:176
USHORT Port
Definition: partlist.h:131
ULONG TracksPerCylinder
Definition: partlist.h:111
LIST_ENTRY PrimaryPartListHead
Definition: partlist.h:149
ULONG CylinderAlignment
Definition: partlist.h:117
PDRIVE_LAYOUT_INFORMATION LayoutBuffer
Definition: partlist.h:143
Definition: typedefs.h:120
BOOLEAN IsPartitioned
Definition: partlist.h:82
UCHAR PartitionType
Definition: partlist.h:73
BOOLEAN AutoCreate
Definition: diskpart.h:127
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:114
struct _DISKENTRY * DiskEntry
Definition: partlist.h:66
BOOLEAN LogicalPartition
Definition: partlist.h:79
CHAR DriveLetter
Definition: diskpart.h:113
FORMATSTATE FormatState
Definition: diskpart.h:116
struct _FILE_SYSTEM_ITEM * FileSystem
Definition: diskpart.h:132
ULONG OnDiskPartitionNumber
Definition: partlist.h:74
BOOLEAN NeedsCheck
Definition: diskpart.h:130
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:115
ULARGE_INTEGER Size
Definition: diskpart.h:202
VOLUME_TYPE VolumeType
Definition: diskpart.h:201
PVOLUME_DISK_EXTENTS pExtents
Definition: diskpart.h:204
ULONG VolumeNumber
Definition: diskpart.h:193
PWSTR pszFilesystem
Definition: diskpart.h:200
WCHAR VolumeName[MAX_PATH]
Definition: diskpart.h:194
LIST_ENTRY ListEntry
Entry in VolumesList.
Definition: partlist.h:45
PWSTR pszLabel
Definition: diskpart.h:199
WCHAR DriveLetter
Definition: diskpart.h:197
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: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