ReactOS  0.4.15-dev-5097-g328cc41
diskpart.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <windef.h>
#include <winbase.h>
#include <winreg.h>
#include <wincon.h>
#include <winioctl.h>
#include <errno.h>
#include <strsafe.h>
#include <conutils.h>
#include <ndk/cmfuncs.h>
#include <ndk/exfuncs.h>
#include <ndk/iofuncs.h>
#include <ndk/kefuncs.h>
#include <ndk/mmfuncs.h>
#include <ndk/obfuncs.h>
#include <ndk/psfuncs.h>
#include <ndk/rtlfuncs.h>
#include <ndk/setypes.h>
#include <ndk/umfuncs.h>
#include "resource.h"
Include dependency graph for diskpart.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _COMMAND
 
struct  _PARTENTRY
 
struct  _BIOSDISKENTRY
 
struct  _DISKENTRY
 
struct  _VOLENTRY
 

Macros

#define WIN32_NO_STATUS
 
#define NTOS_MODE_USER
 
#define MAX_STRING_SIZE   1024
 
#define MAX_ARGS_COUNT   256
 

Typedefs

typedef struct _COMMAND COMMAND
 
typedef struct _COMMANDPCOMMAND
 
typedef enum _FORMATSTATE FORMATSTATE
 
typedef enum _FORMATSTATEPFORMATSTATE
 
typedef enum _VOLUME_TYPE VOLUME_TYPE
 
typedef enum _VOLUME_TYPEPVOLUME_TYPE
 
typedef struct _PARTENTRY PARTENTRY
 
typedef struct _PARTENTRYPPARTENTRY
 
typedef struct _BIOSDISKENTRY BIOSDISKENTRY
 
typedef struct _BIOSDISKENTRYPBIOSDISKENTRY
 
typedef struct _DISKENTRY DISKENTRY
 
typedef struct _DISKENTRYPDISKENTRY
 
typedef struct _VOLENTRY VOLENTRY
 
typedef struct _VOLENTRYPVOLENTRY
 

Enumerations

enum  _FORMATSTATE {
  Unformatted, UnformattedOrDamaged, UnknownFormat, Preformatted,
  Formatted, Unformatted, UnformattedOrDamaged, UnknownFormat,
  Preformatted, Formatted
}
 
enum  _VOLUME_TYPE { VOLUME_TYPE_CDROM, VOLUME_TYPE_PARTITION, VOLUME_TYPE_REMOVABLE, VOLUME_TYPE_UNKNOWN }
 

Functions

BOOL active_main (INT argc, LPWSTR *argv)
 
BOOL add_main (INT argc, LPWSTR *argv)
 
BOOL assign_main (INT argc, LPWSTR *argv)
 
BOOL attach_main (INT argc, LPWSTR *argv)
 
BOOL attributes_main (INT argc, LPWSTR *argv)
 
BOOL automount_main (INT argc, LPWSTR *argv)
 
BOOL break_main (INT argc, LPWSTR *argv)
 
BOOL clean_main (INT argc, LPWSTR *argv)
 
BOOL compact_main (INT argc, LPWSTR *argv)
 
BOOL convert_main (INT argc, LPWSTR *argv)
 
BOOL CreateExtendedPartition (_In_ INT argc, _In_ PWSTR *argv)
 
BOOL CreateLogicalPartition (_In_ INT argc, _In_ PWSTR *argv)
 
BOOL CreatePrimaryPartition (_In_ INT argc, _In_ PWSTR *argv)
 
BOOL DeleteDisk (_In_ INT argc, _In_ PWSTR *argv)
 
BOOL DeletePartition (_In_ INT argc, _In_ PWSTR *argv)
 
BOOL DeleteVolume (_In_ INT argc, _In_ PWSTR *argv)
 
BOOL detach_main (INT argc, LPWSTR *argv)
 
BOOL DetailDisk (INT argc, PWSTR *argv)
 
BOOL DetailPartition (INT argc, PWSTR *argv)
 
BOOL DetailVolume (INT argc, PWSTR *argv)
 
BOOL DumpDisk (_In_ INT argc, _In_ LPWSTR *argv)
 
BOOL DumpPartition (_In_ INT argc, _In_ LPWSTR *argv)
 
BOOL expand_main (INT argc, LPWSTR *argv)
 
BOOL extend_main (INT argc, LPWSTR *argv)
 
BOOL filesystems_main (INT argc, LPWSTR *argv)
 
BOOL format_main (INT argc, LPWSTR *argv)
 
BOOL gpt_main (INT argc, LPWSTR *argv)
 
BOOL help_main (INT argc, LPWSTR *argv)
 
VOID HelpCommandList (VOID)
 
BOOL HelpCommand (PCOMMAND pCommand)
 
BOOL import_main (INT argc, LPWSTR *argv)
 
BOOL inactive_main (INT argc, LPWSTR *argv)
 
BOOL InterpretScript (LPWSTR line)
 
BOOL InterpretCmd (INT argc, LPWSTR *argv)
 
VOID InterpretMain (VOID)
 
BOOL ListDisk (INT argc, PWSTR *argv)
 
BOOL ListPartition (INT argc, PWSTR *argv)
 
BOOL ListVolume (INT argc, PWSTR *argv)
 
BOOL ListVirtualDisk (INT argc, PWSTR *argv)
 
VOID PrintDisk (_In_ PDISKENTRY DiskEntry)
 
VOID PrintVolume (_In_ PVOLENTRY VolumeEntry)
 
BOOL merge_main (INT argc, LPWSTR *argv)
 
BOOL IsDecString (_In_ PWSTR pszDecString)
 
BOOL IsHexString (_In_ PWSTR pszHexString)
 
BOOL HasPrefix (_In_ PWSTR pszString, _In_ PWSTR pszPrefix, _Out_opt_ PWSTR *pszSuffix)
 
ULONGLONG RoundingDivide (_In_ ULONGLONG Dividend, _In_ ULONGLONG Divisor)
 
PWSTR DuplicateQuotedString (_In_ PWSTR pszInString)
 
PWSTR DuplicateString (_In_ PWSTR pszInString)
 
BOOL offline_main (INT argc, LPWSTR *argv)
 
BOOL online_main (INT argc, LPWSTR *argv)
 
ULONGLONG AlignDown (_In_ ULONGLONG Value, _In_ ULONG Alignment)
 
NTSTATUS CreatePartitionList (VOID)
 
VOID DestroyPartitionList (VOID)
 
NTSTATUS CreateVolumeList (VOID)
 
VOID DestroyVolumeList (VOID)
 
NTSTATUS WritePartitions (_In_ PDISKENTRY DiskEntry)
 
VOID UpdateDiskLayout (_In_ PDISKENTRY DiskEntry)
 
PPARTENTRY GetPrevUnpartitionedEntry (_In_ PPARTENTRY PartEntry)
 
PPARTENTRY GetNextUnpartitionedEntry (_In_ PPARTENTRY PartEntry)
 
ULONG GetPrimaryPartitionCount (_In_ PDISKENTRY DiskEntry)
 
NTSTATUS DismountVolume (_In_ PPARTENTRY PartEntry)
 
PVOLENTRY GetVolumeFromPartition (_In_ PPARTENTRY PartEntry)
 
VOID RemoveVolume (_In_ PVOLENTRY VolumeEntry)
 
BOOL recover_main (INT argc, LPWSTR *argv)
 
BOOL remove_main (INT argc, LPWSTR *argv)
 
BOOL repair_main (INT argc, LPWSTR *argv)
 
BOOL rescan_main (INT argc, LPWSTR *argv)
 
BOOL retain_main (INT argc, LPWSTR *argv)
 
BOOL san_main (INT argc, LPWSTR *argv)
 
BOOL SelectDisk (INT argc, PWSTR *argv)
 
BOOL SelectPartition (INT argc, PWSTR *argv)
 
BOOL SelectVolume (INT argc, PWSTR *argv)
 
BOOL setid_main (INT argc, LPWSTR *argv)
 
BOOL shrink_main (INT argc, LPWSTR *argv)
 
BOOL UniqueIdDisk (_In_ INT argc, _In_ PWSTR *argv)
 

Variables

COMMAND cmds []
 
LIST_ENTRY DiskListHead
 
LIST_ENTRY BiosDiskListHead
 
LIST_ENTRY VolumeListHead
 
PDISKENTRY CurrentDisk
 
PPARTENTRY CurrentPartition
 
PVOLENTRY CurrentVolume
 

Macro Definition Documentation

◆ MAX_ARGS_COUNT

#define MAX_ARGS_COUNT   256

Definition at line 76 of file diskpart.h.

◆ MAX_STRING_SIZE

#define MAX_STRING_SIZE   1024

Definition at line 75 of file diskpart.h.

◆ NTOS_MODE_USER

#define NTOS_MODE_USER

Definition at line 39 of file diskpart.h.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 17 of file diskpart.h.

Typedef Documentation

◆ BIOSDISKENTRY

◆ COMMAND

◆ DISKENTRY

◆ FORMATSTATE

◆ PARTENTRY

◆ PBIOSDISKENTRY

◆ PCOMMAND

◆ PDISKENTRY

◆ PFORMATSTATE

◆ PPARTENTRY

◆ PVOLENTRY

◆ PVOLUME_TYPE

◆ VOLENTRY

◆ VOLUME_TYPE

Enumeration Type Documentation

◆ _FORMATSTATE

Enumerator
Unformatted 
UnformattedOrDamaged 
UnknownFormat 
Preformatted 
Formatted 
Unformatted 
UnformattedOrDamaged 
UnknownFormat 
Preformatted 
Formatted 

Definition at line 79 of file diskpart.h.

80 {
85  Formatted
enum _FORMATSTATE * PFORMATSTATE
enum _FORMATSTATE FORMATSTATE

◆ _VOLUME_TYPE

Enumerator
VOLUME_TYPE_CDROM 
VOLUME_TYPE_PARTITION 
VOLUME_TYPE_REMOVABLE 
VOLUME_TYPE_UNKNOWN 

Definition at line 88 of file diskpart.h.

Function Documentation

◆ active_main()

BOOL active_main ( INT  argc,
LPWSTR argv 
)

◆ add_main()

BOOL add_main ( INT  argc,
LPWSTR argv 
)

Definition at line 11 of file add.c.

12 {
13  return TRUE;
14 }
#define TRUE
Definition: types.h:120

◆ AlignDown()

ULONGLONG AlignDown ( _In_ ULONGLONG  Value,
_In_ ULONG  Alignment 
)

Definition at line 82 of file partlist.c.

85 {
86  ULONGLONG Temp;
87 
88  Temp = Value / Alignment;
89 
90  return Temp * Alignment;
91 }
union Alignment_ Alignment
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:406
uint64_t ULONGLONG
Definition: typedefs.h:67

◆ assign_main()

BOOL assign_main ( INT  argc,
LPWSTR argv 
)

Definition at line 11 of file assign.c.

12 {
13  return TRUE;
14 }
#define TRUE
Definition: types.h:120

◆ attach_main()

BOOL attach_main ( INT  argc,
LPWSTR argv 
)

Definition at line 11 of file attach.c.

12 {
13  return TRUE;
14 }
#define TRUE
Definition: types.h:120

◆ attributes_main()

BOOL attributes_main ( INT  argc,
LPWSTR argv 
)

Definition at line 11 of file attributes.c.

12 {
13  return TRUE;
14 }
#define TRUE
Definition: types.h:120

◆ automount_main()

BOOL automount_main ( INT  argc,
LPWSTR argv 
)

Definition at line 11 of file automount.c.

12 {
13  ConPuts(StdOut, L"Automount\n");
14  return TRUE;
15 }
#define TRUE
Definition: types.h:120
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: fc.c:16
#define L(x)
Definition: ntvdm.h:50
#define StdOut
Definition: fc.c:14

◆ break_main()

BOOL break_main ( INT  argc,
LPWSTR argv 
)

Definition at line 11 of file break.c.

12 {
13  ConPuts(StdOut, L"\nTODO: Add code later since Win 7 Home Premium doesn't have this feature.\n");
14  return TRUE;
15 }
#define TRUE
Definition: types.h:120
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: fc.c:16
#define L(x)
Definition: ntvdm.h:50
#define StdOut
Definition: fc.c:14

◆ clean_main()

BOOL clean_main ( INT  argc,
LPWSTR argv 
)

◆ compact_main()

BOOL compact_main ( INT  argc,
LPWSTR argv 
)

Definition at line 11 of file compact.c.

12 {
13  return 0;
14 }

◆ convert_main()

BOOL convert_main ( INT  argc,
LPWSTR argv 
)

Definition at line 11 of file convert.c.

12 {
13  return TRUE;
14 }
#define TRUE
Definition: types.h:120

◆ CreateExtendedPartition()

BOOL CreateExtendedPartition ( _In_ INT  argc,
_In_ PWSTR argv 
)

Definition at line 16 of file create.c.

19 {
20  PPARTENTRY PartEntry, NewPartEntry;
21  PLIST_ENTRY ListEntry;
22  ULONGLONG ullSize = 0ULL;
23  ULONGLONG ullSectorCount;
24 #if 0
25  ULONGLONG ullOffset = 0ULL;
26  BOOL bNoErr = FALSE;
27 #endif
28  INT i;
29  PWSTR pszSuffix = NULL;
31 
32  if (CurrentDisk == NULL)
33  {
35  return TRUE;
36  }
37 
38  for (i = 3; i < argc; i++)
39  {
40  if (HasPrefix(argv[i], L"size=", &pszSuffix))
41  {
42  /* size=<N> (MB) */
43  DPRINT("Size : %s\n", pszSuffix);
44 
45  ullSize = _wcstoui64(pszSuffix, NULL, 10);
46  if ((ullSize == 0) && (errno == ERANGE))
47  {
49  return TRUE;
50  }
51  }
52  else if (HasPrefix(argv[i], L"offset=", &pszSuffix))
53  {
54  /* offset=<N> (KB) */
55  DPRINT("Offset : %s\n", pszSuffix);
56  ConPuts(StdOut, L"The OFFSET option is not supported yet!\n");
57 #if 0
58  ullOffset = _wcstoui64(pszSuffix, NULL, 10);
59  if ((ullOffset == 0) && (errno == ERANGE))
60  {
62  return TRUE;
63  }
64 #endif
65  }
66  else if (HasPrefix(argv[i], L"align=", &pszSuffix))
67  {
68  /* align=<N> */
69  DPRINT("Align : %s\n", pszSuffix);
70  ConPuts(StdOut, L"The ALIGN option is not supported yet!\n");
71 #if 0
72  bAlign = TRUE;
73 #endif
74  }
75  else if (_wcsicmp(argv[i], L"noerr") == 0)
76  {
77  /* noerr */
78  DPRINT("NoErr\n", pszSuffix);
79  ConPuts(StdOut, L"The NOERR option is not supported yet!\n");
80 #if 0
81  bNoErr = TRUE;
82 #endif
83  }
84  else
85  {
87  return TRUE;
88  }
89  }
90 
91  DPRINT1("Size: %I64u\n", ullSize);
92 #if 0
93  DPRINT1("Offset: %I64u\n", ullOffset);
94 #endif
95 
97  {
98  ConPuts(StdOut, L"No space left for an extended partition!\n");
99  return TRUE;
100  }
101 
103  {
104  ConPuts(StdOut, L"We already have an extended partition on this disk!\n");
105  return TRUE;
106  }
107 
108  if (ullSize != 0)
109  ullSectorCount = (ullSize * 1024 * 1024) / CurrentDisk->BytesPerSector;
110  else
111  ullSectorCount = 0;
112 
113  DPRINT1("SectorCount: %I64u\n", ullSectorCount);
114 
116 
117  PartEntry = CONTAINING_RECORD(ListEntry, PARTENTRY, ListEntry);
118  if (PartEntry->IsPartitioned)
119  {
120  ConPuts(StdOut, L"No disk space left for an extended partition!\n");
121  return TRUE;
122  }
123 
124  if (ullSectorCount == 0)
125  {
126  PartEntry->IsPartitioned = TRUE;
127  PartEntry->New = TRUE;
128  PartEntry->PartitionType = PARTITION_EXTENDED;
129  PartEntry->FormatState = Unformatted;
130  PartEntry->FileSystemName[0] = L'\0';
131 
132  CurrentPartition = PartEntry;
134  }
135  else
136  {
137  if (PartEntry->SectorCount.QuadPart == ullSectorCount)
138  {
139  PartEntry->IsPartitioned = TRUE;
140  PartEntry->New = TRUE;
141  PartEntry->PartitionType = PARTITION_EXTENDED;
142  PartEntry->FormatState = Unformatted;
143  PartEntry->FileSystemName[0] = L'\0';
144 
145  CurrentPartition = PartEntry;
147  }
148  else if (PartEntry->SectorCount.QuadPart > ullSectorCount)
149  {
150  NewPartEntry = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(PPARTENTRY));
151  if (NewPartEntry == NULL)
152  {
153  ConPuts(StdOut, L"Memory allocation failed!\n");
154  return TRUE;
155  }
156 
157  NewPartEntry->DiskEntry = PartEntry->DiskEntry;
158 
159  NewPartEntry->StartSector.QuadPart = PartEntry->StartSector.QuadPart;
160  NewPartEntry->SectorCount.QuadPart = ullSectorCount;
161 
162  NewPartEntry->LogicalPartition = FALSE;
163  NewPartEntry->IsPartitioned = TRUE;
164  NewPartEntry->New = TRUE;
165  NewPartEntry->PartitionType = PARTITION_EXTENDED;
166  NewPartEntry->FormatState = Unformatted;
167  NewPartEntry->FileSystemName[0] = L'\0';
168 
169  PartEntry->StartSector.QuadPart += ullSectorCount;
170  PartEntry->SectorCount.QuadPart -= ullSectorCount;
171 
172  InsertTailList(ListEntry, &NewPartEntry->ListEntry);
173 
174  CurrentPartition = NewPartEntry;
176  }
177  }
178 
181  if (!NT_SUCCESS(Status))
182  {
185  return TRUE;
186  }
187 
189 
190  return TRUE;
191 }
LIST_ENTRY PrimaryPartListHead
Definition: partlist.h:131
static int argc
Definition: ServiceArgs.c:12
ULARGE_INTEGER StartSector
Definition: partlist.h:49
BOOL HasPrefix(_In_ PWSTR pszString, _In_ PWSTR pszPrefix, _Out_opt_ PWSTR *pszSuffix)
Definition: misc.c:58
Iosb Status
Definition: create.c:4287
#define TRUE
Definition: types.h:120
uint16_t * PWSTR
Definition: typedefs.h:56
struct _LIST_ENTRY * Blink
Definition: typedefs.h:122
ULARGE_INTEGER SectorCount
Definition: partlist.h:50
LONG NTSTATUS
Definition: precomp.h:26
__MINGW_EXTENSION _Check_return_ _CRTIMP unsigned __int64 __cdecl _wcstoui64(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
static PPARTENTRY CurrentPartition
Definition: usetup.c:76
PDISKENTRY CurrentDisk
Definition: partlist.c:74
int errno
#define InsertTailList(ListHead, Entry)
#define argv
Definition: mplay32.c:18
int32_t INT
Definition: typedefs.h:58
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: fc.c:16
PPARTENTRY ExtendedPartition
Definition: partlist.h:135
LIST_ENTRY ListEntry
Definition: partlist.h:43
#define IDS_ERROR_INVALID_ARGS
Definition: resource.h:187
BOOLEAN LogicalPartition
Definition: partlist.h:63
#define L(x)
Definition: ntvdm.h:50
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
FORMATSTATE FormatState
Definition: partlist.h:61
BOOLEAN Dirty
Definition: partlist.h:118
void ConResPuts(FILE *fp, UINT nID)
Definition: fc.c:27
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
static VOID UpdateDiskLayout(IN PDISKENTRY DiskEntry)
Definition: partlist.c:2534
#define ULL(a, b)
Definition: format_msg.c:27
#define PARTITION_EXTENDED
Definition: disk.h:91
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
Status
Definition: gdiplustypes.h:24
UCHAR PartitionType
Definition: partlist.h:53
struct _DISKENTRY * DiskEntry
Definition: partlist.h:46
ULONG BytesPerSector
Definition: partlist.h:95
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
uint64_t ULONGLONG
Definition: typedefs.h:67
#define IDS_CREATE_PARTITION_SUCCESS
Definition: resource.h:30
#define IDS_SELECT_NO_DISK
Definition: resource.h:85
#define ERANGE
Definition: acclib.h:92
static ULONG GetPrimaryPartitionCount(IN PDISKENTRY DiskEntry)
Definition: partlist.c:2428
Definition: typedefs.h:119
BOOLEAN New
Definition: partlist.h:71
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define NULL
Definition: types.h:112
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define DPRINT1
Definition: precomp.h:8
#define StdOut
Definition: fc.c:14
NTSTATUS WritePartitions(IN PDISKENTRY DiskEntry)
Definition: partlist.c:3619
#define DPRINT
Definition: sndvol32.h:71
#define IDS_CREATE_PARTITION_FAIL
Definition: resource.h:29
CHAR FileSystemName[9]
Definition: diskpart.h:113
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
BOOLEAN IsPartitioned
Definition: partlist.h:66
#define StdErr
Definition: fc.c:15

◆ CreateLogicalPartition()

BOOL CreateLogicalPartition ( _In_ INT  argc,
_In_ PWSTR argv 
)

Definition at line 195 of file create.c.

198 {
199  PPARTENTRY PartEntry, NewPartEntry;
200  PLIST_ENTRY ListEntry;
201  ULONGLONG ullSize = 0ULL;
202  ULONGLONG ullSectorCount;
203 #if 0
204  ULONGLONG ullOffset = 0ULL;
205  BOOL bNoErr = FALSE;
206 #endif
208  INT i, length;
209  PWSTR pszSuffix = NULL;
211 
212  if (CurrentDisk == NULL)
213  {
215  return TRUE;
216  }
217 
218  for (i = 3; i < argc; i++)
219  {
220  if (HasPrefix(argv[i], L"size=", &pszSuffix))
221  {
222  /* size=<N> (MB) */
223  DPRINT("Size : %s\n", pszSuffix);
224 
225  ullSize = _wcstoui64(pszSuffix, NULL, 10);
226  if ((ullSize == 0) && (errno == ERANGE))
227  {
229  return TRUE;
230  }
231  }
232  else if (HasPrefix(argv[i], L"offset=", &pszSuffix))
233  {
234  /* offset=<N> (KB) */
235  DPRINT("Offset : %s\n", pszSuffix);
236  ConPuts(StdOut, L"The OFFSET option is not supported yet!\n");
237 #if 0
238  ullOffset = _wcstoui64(pszSuffix, NULL, 10);
239  if ((ullOffset == 0) && (errno == ERANGE))
240  {
242  return TRUE;
243  }
244 #endif
245  }
246  else if (HasPrefix(argv[i], L"id=", &pszSuffix))
247  {
248  /* id=<Byte>|<GUID> */
249  DPRINT("Id : %s\n", pszSuffix);
250 
251  length = wcslen(pszSuffix);
252  if ((length == 1) || (length == 2))
253  {
254  /* Byte */
255  PartitionType = (UCHAR)wcstoul(pszSuffix, NULL, 16);
256  if ((PartitionType == 0) && (errno == ERANGE))
257  {
259  return TRUE;
260  }
261  }
262 #if 0
263  else if ()
264  {
265  /* GUID */
266  }
267 #endif
268  else
269  {
271  return TRUE;
272  }
273  }
274  else if (HasPrefix(argv[i], L"align=", &pszSuffix))
275  {
276  /* align=<N> */
277  DPRINT("Align : %s\n", pszSuffix);
278  ConPuts(StdOut, L"The ALIGN option is not supported yet!\n");
279 #if 0
280  bAlign = TRUE;
281 #endif
282  }
283  else if (_wcsicmp(argv[i], L"noerr") == 0)
284  {
285  /* noerr */
286  DPRINT("NoErr\n", pszSuffix);
287  ConPuts(StdOut, L"The NOERR option is not supported yet!\n");
288 #if 0
289  bNoErr = TRUE;
290 #endif
291  }
292  else
293  {
295  return TRUE;
296  }
297  }
298 
299  DPRINT1("Size: %I64u\n", ullSize);
300 #if 0
301  DPRINT1("Offset: %I64u\n", ullOffset);
302 #endif
303  DPRINT1("Partition Type: %hx\n", PartitionType);
304 
305  if (ullSize != 0)
306  ullSectorCount = (ullSize * 1024 * 1024) / CurrentDisk->BytesPerSector;
307  else
308  ullSectorCount = 0;
309 
310  DPRINT1("SectorCount: %I64u\n", ullSectorCount);
311 
312  for (ListEntry = CurrentDisk->LogicalPartListHead.Flink;
313  ListEntry != &CurrentDisk->LogicalPartListHead;
314  ListEntry = ListEntry->Flink)
315  {
316  PartEntry = CONTAINING_RECORD(ListEntry, PARTENTRY, ListEntry);
317  if (PartEntry->IsPartitioned)
318  continue;
319 
320  if (ullSectorCount == 0)
321  {
322  PartEntry->IsPartitioned = TRUE;
323  PartEntry->New = TRUE;
324  PartEntry->PartitionType = PartitionType;
325  PartEntry->FormatState = Unformatted;
326  PartEntry->FileSystemName[0] = L'\0';
327 
328  CurrentPartition = PartEntry;
330  break;
331  }
332  else
333  {
334  if (PartEntry->SectorCount.QuadPart == ullSectorCount)
335  {
336  PartEntry->IsPartitioned = TRUE;
337  PartEntry->New = TRUE;
338  PartEntry->PartitionType = PartitionType;
339  PartEntry->FormatState = Unformatted;
340  PartEntry->FileSystemName[0] = L'\0';
341 
342  CurrentPartition = PartEntry;
344  break;
345  }
346  else if (PartEntry->SectorCount.QuadPart > ullSectorCount)
347  {
348  NewPartEntry = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(PPARTENTRY));
349  if (NewPartEntry == NULL)
350  {
351  ConPuts(StdOut, L"Memory allocation failed!\n");
352  return TRUE;
353  }
354 
355  NewPartEntry->DiskEntry = PartEntry->DiskEntry;
356 
357  NewPartEntry->StartSector.QuadPart = PartEntry->StartSector.QuadPart;
358  NewPartEntry->SectorCount.QuadPart = ullSectorCount;
359 
360  NewPartEntry->LogicalPartition = TRUE;
361  NewPartEntry->IsPartitioned = TRUE;
362  NewPartEntry->New = TRUE;
363  NewPartEntry->PartitionType = PartitionType;
364  NewPartEntry->FormatState = Unformatted;
365  NewPartEntry->FileSystemName[0] = L'\0';
366 
367  PartEntry->StartSector.QuadPart += ullSectorCount;
368  PartEntry->SectorCount.QuadPart -= ullSectorCount;
369 
370  InsertTailList(ListEntry, &NewPartEntry->ListEntry);
371 
372  CurrentPartition = NewPartEntry;
374  break;
375  }
376  }
377  }
378 
381  if (!NT_SUCCESS(Status))
382  {
385  return TRUE;
386  }
387 
389 
390  return TRUE;
391 }
static int argc
Definition: ServiceArgs.c:12
ULARGE_INTEGER StartSector
Definition: partlist.h:49
BOOL HasPrefix(_In_ PWSTR pszString, _In_ PWSTR pszPrefix, _Out_opt_ PWSTR *pszSuffix)
Definition: misc.c:58
Iosb Status
Definition: create.c:4287
#define TRUE
Definition: types.h:120
uint16_t * PWSTR
Definition: typedefs.h:56
ULARGE_INTEGER SectorCount
Definition: partlist.h:50
LONG NTSTATUS
Definition: precomp.h:26
__MINGW_EXTENSION _Check_return_ _CRTIMP unsigned __int64 __cdecl _wcstoui64(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
static PPARTENTRY CurrentPartition
Definition: usetup.c:76
PDISKENTRY CurrentDisk
Definition: partlist.c:74
int errno
_Check_return_ unsigned long __cdecl wcstoul(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
#define InsertTailList(ListHead, Entry)
#define argv
Definition: mplay32.c:18
int32_t INT
Definition: typedefs.h:58
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: fc.c:16
LIST_ENTRY ListEntry
Definition: partlist.h:43
#define IDS_ERROR_INVALID_ARGS
Definition: resource.h:187
BOOLEAN LogicalPartition
Definition: partlist.h:63
#define L(x)
Definition: ntvdm.h:50
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
FORMATSTATE FormatState
Definition: partlist.h:61
#define PARTITION_HUGE
Definition: disk.h:92
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
BOOLEAN Dirty
Definition: partlist.h:118
void ConResPuts(FILE *fp, UINT nID)
Definition: fc.c:27
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
static VOID UpdateDiskLayout(IN PDISKENTRY DiskEntry)
Definition: partlist.c:2534
#define ULL(a, b)
Definition: format_msg.c:27
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
Status
Definition: gdiplustypes.h:24
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
UCHAR PartitionType
Definition: partlist.h:53
struct _DISKENTRY * DiskEntry
Definition: partlist.h:46
ULONG BytesPerSector
Definition: partlist.h:95
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
uint64_t ULONGLONG
Definition: typedefs.h:67
#define IDS_CREATE_PARTITION_SUCCESS
Definition: resource.h:30
#define IDS_SELECT_NO_DISK
Definition: resource.h:85
#define ERANGE
Definition: acclib.h:92
unsigned char UCHAR
Definition: xmlstorage.h:181
Definition: typedefs.h:119
BOOLEAN New
Definition: partlist.h:71
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define NULL
Definition: types.h:112
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define DPRINT1
Definition: precomp.h:8
LIST_ENTRY LogicalPartListHead
Definition: partlist.h:132
#define StdOut
Definition: fc.c:14
NTSTATUS WritePartitions(IN PDISKENTRY DiskEntry)
Definition: partlist.c:3619
CHAR PartitionType
Definition: part_xbox.c:32
#define DPRINT
Definition: sndvol32.h:71
#define IDS_CREATE_PARTITION_FAIL
Definition: resource.h:29
CHAR FileSystemName[9]
Definition: diskpart.h:113
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
BOOLEAN IsPartitioned
Definition: partlist.h:66
#define StdErr
Definition: fc.c:15

◆ CreatePartitionList()

NTSTATUS CreatePartitionList ( VOID  )

Definition at line 1847 of file partlist.c.

1848 {
1849  PPARTLIST List;
1850  PDISKENTRY SystemDisk;
1854  ULONG ReturnSize;
1855  NTSTATUS Status;
1856  ULONG DiskNumber;
1860 
1862  0,
1863  sizeof(PARTLIST));
1864  if (List == NULL)
1865  return NULL;
1866 
1867  List->SystemPartition = NULL;
1868 
1869  InitializeListHead(&List->DiskListHead);
1870  InitializeListHead(&List->BiosDiskListHead);
1871 
1872  /*
1873  * Enumerate the disks seen by the BIOS; this will be used later
1874  * to map drives seen by NTOS with their corresponding BIOS names.
1875  */
1877 
1878  /* Enumerate disks seen by NTOS */
1880  &Sdi,
1881  sizeof(Sdi),
1882  &ReturnSize);
1883  if (!NT_SUCCESS(Status))
1884  {
1885  DPRINT1("NtQuerySystemInformation() failed, Status 0x%08lx", Status);
1887  return NULL;
1888  }
1889 
1890  for (DiskNumber = 0; DiskNumber < Sdi.NumberOfDisks; DiskNumber++)
1891  {
1893  L"\\Device\\Harddisk%lu\\Partition0",
1894  DiskNumber);
1896 
1898  &Name,
1900  NULL,
1901  NULL);
1902 
1906  &Iosb,
1909  if (NT_SUCCESS(Status))
1910  {
1911  AddDiskToList(FileHandle, DiskNumber, List);
1913  }
1914  }
1915 
1919 
1920  /*
1921  * Retrieve the system partition: the active partition on the system
1922  * disk (the one that will be booted by default by the hardware).
1923  */
1924  SystemDisk = GetSystemDisk(List);
1925  List->SystemPartition = (SystemDisk ? GetActiveDiskPartition(SystemDisk) : NULL);
1926 
1927  return List;
1928 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
NTSYSAPI NTSTATUS NTAPI NtQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInfoClass, OUT PVOID SystemInfoBuffer, IN ULONG SystemInfoBufferSize, OUT PULONG BytesReturned OPTIONAL)
struct _PARTLIST * PPARTLIST
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
static PPARTENTRY GetActiveDiskPartition(IN PDISKENTRY DiskEntry)
Definition: partlist.c:1791
NTSTRSAFEVAPI RtlStringCchPrintfW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
Definition: ntstrsafe.h:1110
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
static VOID UpdateDiskSignatures(IN PPARTLIST List)
Definition: partlist.c:1215
#define FILE_SHARE_READ
Definition: compat.h:136
#define L(x)
Definition: ntvdm.h:50
#define FILE_READ_DATA
Definition: nt_native.h:628
struct NameRec_ * Name
Definition: cdprocs.h:459
Definition: bufpool.h:45
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
Status
Definition: gdiplustypes.h:24
NTSYSAPI NTSTATUS NTAPI NtOpenFile(OUT PHANDLE phFile, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG ShareMode, IN ULONG OpenMode)
Definition: file.c:3951
__wchar_t WCHAR
Definition: xmlstorage.h:180
return Iosb
Definition: create.c:4402
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static VOID UpdateHwDiskNumbers(IN PPARTLIST List)
Definition: partlist.c:1245
#define MAX_PATH
Definition: compat.h:34
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
#define FILE_READ_ATTRIBUTES
Definition: nt_native.h:647
static PDISKENTRY GetSystemDisk(IN PPARTLIST List)
Definition: partlist.c:1718
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
#define SYNCHRONIZE
Definition: nt_native.h:61
HANDLE ProcessHeap
Definition: servman.c:15
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
Definition: fltkernel.h:1230
static VOID EnumerateBiosDiskEntries(IN PPARTLIST PartList)
Definition: partlist.c:337
static VOID AddDiskToList(IN HANDLE FileHandle, IN ULONG DiskNumber, IN PPARTLIST List)
Definition: partlist.c:1306
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
static VOID AssignDriveLetters(IN PPARTLIST List)
Definition: partlist.c:138

Referenced by LoadSetupData(), rescan_main(), SelectPartitionPage(), UpgradeRepairPage(), and wmain().

◆ CreatePrimaryPartition()

BOOL CreatePrimaryPartition ( _In_ INT  argc,
_In_ PWSTR argv 
)

Definition at line 395 of file create.c.

398 {
399  PPARTENTRY PartEntry, NewPartEntry;
400  PLIST_ENTRY ListEntry;
401  ULONGLONG ullSize = 0ULL;
402  ULONGLONG ullSectorCount;
403 #if 0
404  ULONGLONG ullOffset = 0ULL;
405  BOOL bNoErr = FALSE;
406 #endif
408  INT i, length;
409  PWSTR pszSuffix = NULL;
411 
412  if (CurrentDisk == NULL)
413  {
415  return TRUE;
416  }
417 
418  for (i = 3; i < argc; i++)
419  {
420  if (HasPrefix(argv[i], L"size=", &pszSuffix))
421  {
422  /* size=<N> (MB) */
423  DPRINT("Size : %s\n", pszSuffix);
424 
425  ullSize = _wcstoui64(pszSuffix, NULL, 10);
426  if ((ullSize == 0) && (errno == ERANGE))
427  {
429  return TRUE;
430  }
431  }
432  else if (HasPrefix(argv[i], L"offset=", &pszSuffix))
433  {
434  /* offset=<N> (KB) */
435  DPRINT("Offset : %s\n", pszSuffix);
436  ConPuts(StdOut, L"The OFFSET option is not supported yet!\n");
437 #if 0
438  ullOffset = _wcstoui64(pszSuffix, NULL, 10);
439  if ((ullOffset == 0) && (errno == ERANGE))
440  {
442  return TRUE;
443  }
444 #endif
445  }
446  else if (HasPrefix(argv[i], L"id=", &pszSuffix))
447  {
448  /* id=<Byte>|<GUID> */
449  DPRINT("Id : %s\n", pszSuffix);
450 
451  length = wcslen(pszSuffix);
452  if ((length == 1) || (length == 2))
453  {
454  /* Byte */
455  PartitionType = (UCHAR)wcstoul(pszSuffix, NULL, 16);
456  if ((PartitionType == 0) && (errno == ERANGE))
457  {
459  return TRUE;
460  }
461  }
462 #if 0
463  else if ()
464  {
465  /* GUID */
466  }
467 #endif
468  else
469  {
471  return TRUE;
472  }
473  }
474  else if (HasPrefix(argv[i], L"align=", &pszSuffix))
475  {
476  /* align=<N> */
477  DPRINT("Align : %s\n", pszSuffix);
478  ConPuts(StdOut, L"The ALIGN option is not supported yet!\n");
479 #if 0
480  bAlign = TRUE;
481 #endif
482  }
483  else if (_wcsicmp(argv[i], L"noerr") == 0)
484  {
485  /* noerr */
486  DPRINT("NoErr\n", pszSuffix);
487  ConPuts(StdOut, L"The NOERR option is not supported yet!\n");
488 #if 0
489  bNoErr = TRUE;
490 #endif
491  }
492  else
493  {
495  return TRUE;
496  }
497  }
498 
499  DPRINT1("Size: %I64u\n", ullSize);
500 #if 0
501  DPRINT1("Offset: %I64u\n", ullOffset);
502 #endif
503  DPRINT1("Partition Type: %hx\n", PartitionType);
504 
506  {
507  ConPuts(StdOut, L"No space left for another primary partition!\n");
508  return TRUE;
509  }
510 
511  if (ullSize != 0)
512  ullSectorCount = (ullSize * 1024 * 1024) / CurrentDisk->BytesPerSector;
513  else
514  ullSectorCount = 0;
515 
516  DPRINT1("SectorCount: %I64u\n", ullSectorCount);
517 
518  for (ListEntry = CurrentDisk->PrimaryPartListHead.Flink;
519  ListEntry != &CurrentDisk->PrimaryPartListHead;
520  ListEntry = ListEntry->Flink)
521  {
522  PartEntry = CONTAINING_RECORD(ListEntry, PARTENTRY, ListEntry);
523  if (PartEntry->IsPartitioned)
524  continue;
525 
526  if (ullSectorCount == 0)
527  {
528  PartEntry->IsPartitioned = TRUE;
529  PartEntry->New = TRUE;
530  PartEntry->PartitionType = PartitionType;
531  PartEntry->FormatState = Unformatted;
532  PartEntry->FileSystemName[0] = L'\0';
533 
534  CurrentPartition = PartEntry;
536  break;
537  }
538  else
539  {
540  if (PartEntry->SectorCount.QuadPart == ullSectorCount)
541  {
542  PartEntry->IsPartitioned = TRUE;
543  PartEntry->New = TRUE;
544  PartEntry->PartitionType = PartitionType;
545  PartEntry->FormatState = Unformatted;
546  PartEntry->FileSystemName[0] = L'\0';
547 
548  CurrentPartition = PartEntry;
550  break;
551  }
552  else if (PartEntry->SectorCount.QuadPart > ullSectorCount)
553  {
554  NewPartEntry = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(PPARTENTRY));
555  if (NewPartEntry == NULL)
556  {
557  ConPuts(StdOut, L"Memory allocation failed!\n");
558  return TRUE;
559  }
560 
561  NewPartEntry->DiskEntry = PartEntry->DiskEntry;
562 
563  NewPartEntry->StartSector.QuadPart = PartEntry->StartSector.QuadPart;
564  NewPartEntry->SectorCount.QuadPart = ullSectorCount;
565 
566  NewPartEntry->LogicalPartition = FALSE;
567  NewPartEntry->IsPartitioned = TRUE;
568  NewPartEntry->New = TRUE;
569  NewPartEntry->PartitionType = PartitionType;
570  NewPartEntry->FormatState = Unformatted;
571  NewPartEntry->FileSystemName[0] = L'\0';
572 
573  PartEntry->StartSector.QuadPart += ullSectorCount;
574  PartEntry->SectorCount.QuadPart -= ullSectorCount;
575 
576  InsertTailList(ListEntry, &NewPartEntry->ListEntry);
577 
578  CurrentPartition = NewPartEntry;
580  break;
581  }
582  }
583  }
584 
587  if (!NT_SUCCESS(Status))
588  {
591  return TRUE;
592  }
593 
595 
596  return TRUE;
597 }
LIST_ENTRY PrimaryPartListHead
Definition: partlist.h:131
static int argc
Definition: ServiceArgs.c:12
ULARGE_INTEGER StartSector
Definition: partlist.h:49
BOOL HasPrefix(_In_ PWSTR pszString, _In_ PWSTR pszPrefix, _Out_opt_ PWSTR *pszSuffix)
Definition: misc.c:58
Iosb Status
Definition: create.c:4287
#define TRUE
Definition: types.h:120
uint16_t * PWSTR
Definition: typedefs.h:56
ULARGE_INTEGER SectorCount
Definition: partlist.h:50
LONG NTSTATUS
Definition: precomp.h:26
__MINGW_EXTENSION _Check_return_ _CRTIMP unsigned __int64 __cdecl _wcstoui64(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
static PPARTENTRY CurrentPartition
Definition: usetup.c:76
PDISKENTRY CurrentDisk
Definition: partlist.c:74
int errno
_Check_return_ unsigned long __cdecl wcstoul(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
#define InsertTailList(ListHead, Entry)
#define argv
Definition: mplay32.c:18
int32_t INT
Definition: typedefs.h:58
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: fc.c:16
LIST_ENTRY ListEntry
Definition: partlist.h:43
#define IDS_ERROR_INVALID_ARGS
Definition: resource.h:187
BOOLEAN LogicalPartition
Definition: partlist.h:63
#define L(x)
Definition: ntvdm.h:50
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
FORMATSTATE FormatState
Definition: partlist.h:61
#define PARTITION_HUGE
Definition: disk.h:92
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
BOOLEAN Dirty
Definition: partlist.h:118
void ConResPuts(FILE *fp, UINT nID)
Definition: fc.c:27
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
static VOID UpdateDiskLayout(IN PDISKENTRY DiskEntry)
Definition: partlist.c:2534
#define ULL(a, b)
Definition: format_msg.c:27
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
Status
Definition: gdiplustypes.h:24
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
UCHAR PartitionType
Definition: partlist.h:53
struct _DISKENTRY * DiskEntry
Definition: partlist.h:46
ULONG BytesPerSector
Definition: partlist.h:95
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
uint64_t ULONGLONG
Definition: typedefs.h:67
#define IDS_CREATE_PARTITION_SUCCESS
Definition: resource.h:30
#define IDS_SELECT_NO_DISK
Definition: resource.h:85
#define ERANGE
Definition: acclib.h:92
unsigned char UCHAR
Definition: xmlstorage.h:181
static ULONG GetPrimaryPartitionCount(IN PDISKENTRY DiskEntry)
Definition: partlist.c:2428
Definition: typedefs.h:119
BOOLEAN New
Definition: partlist.h:71
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define NULL
Definition: types.h:112
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define DPRINT1
Definition: precomp.h:8
#define StdOut
Definition: fc.c:14
NTSTATUS WritePartitions(IN PDISKENTRY DiskEntry)
Definition: partlist.c:3619
CHAR PartitionType
Definition: part_xbox.c:32
#define DPRINT
Definition: sndvol32.h:71
#define IDS_CREATE_PARTITION_FAIL
Definition: resource.h:29
CHAR FileSystemName[9]
Definition: diskpart.h:113
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
BOOLEAN IsPartitioned
Definition: partlist.h:66
#define StdErr
Definition: fc.c:15

◆ CreateVolumeList()

NTSTATUS CreateVolumeList ( VOID  )

Definition at line 1412 of file partlist.c.

1413 {
1414  HANDLE hVolume = INVALID_HANDLE_VALUE;
1415  WCHAR szVolumeName[MAX_PATH];
1416  ULONG ulVolumeNumber = 0;
1417  BOOL Success;
1418 
1419  CurrentVolume = NULL;
1420 
1422 
1423  hVolume = FindFirstVolumeW(szVolumeName, ARRAYSIZE(szVolumeName));
1424  if (hVolume == INVALID_HANDLE_VALUE)
1425  {
1426 
1427  return STATUS_UNSUCCESSFUL;
1428  }
1429 
1430  AddVolumeToList(ulVolumeNumber++, szVolumeName);
1431 
1432  for (;;)
1433  {
1434  Success = FindNextVolumeW(hVolume, szVolumeName, ARRAYSIZE(szVolumeName));
1435  if (!Success)
1436  {
1437  break;
1438  }
1439 
1440  AddVolumeToList(ulVolumeNumber++, szVolumeName);
1441  }
1442 
1443  FindVolumeClose(hVolume);
1444 
1445  return STATUS_SUCCESS;
1446 }
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
HANDLE WINAPI FindFirstVolumeW(IN LPWSTR volume, IN DWORD len)
Definition: volume.c:660
BOOL WINAPI FindNextVolumeW(IN HANDLE handle, IN LPWSTR volume, IN DWORD len)
Definition: volume.c:1082
unsigned int BOOL
Definition: ntddk_ex.h:94
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:34
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
LIST_ENTRY VolumeListHead
Definition: partlist.c:72
PVOLENTRY CurrentVolume
Definition: partlist.c:76
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
#define STATUS_SUCCESS
Definition: shellext.h:65
static VOID AddVolumeToList(ULONG ulVolumeNumber, PWSTR pszVolumeName)
Definition: partlist.c:1296
BOOL WINAPI FindVolumeClose(IN HANDLE hFindVolume)
Definition: volume.c:741

Referenced by rescan_main(), and wmain().

◆ DeleteDisk()

BOOL DeleteDisk ( _In_ INT  argc,
_In_ PWSTR argv 
)

Definition at line 28 of file delete.c.

31 {
32  return TRUE;
33 }
#define TRUE
Definition: types.h:120

◆ DeletePartition()

BOOL DeletePartition ( _In_ INT  argc,
_In_ PWSTR argv 
)

Definition at line 37 of file delete.c.

40 {
41  PPARTENTRY PrevPartEntry;
42  PPARTENTRY NextPartEntry;
43  PPARTENTRY LogicalPartEntry;
45  INT i;
46  BOOL bOverride = FALSE;
48 
49  DPRINT("DeletePartition()\n");
50 
51  if (CurrentDisk == NULL)
52  {
54  return TRUE;
55  }
56 
57  if (CurrentPartition == NULL)
58  {
60  return TRUE;
61  }
62 
64 
65  for (i = 2; i < argc; i++)
66  {
67  if (_wcsicmp(argv[i], L"noerr") == 0)
68  {
69  /* noerr */
70  DPRINT("NOERR\n");
71  ConPuts(StdOut, L"The NOERR option is not supported yet!\n");
72 #if 0
73  bNoErr = TRUE;
74 #endif
75  }
76  else if (_wcsicmp(argv[i], L"override") == 0)
77  {
78  /* noerr */
79  DPRINT("OVERRIDE\n");
80  bOverride = TRUE;
81  }
82  else
83  {
85  return TRUE;
86  }
87  }
88 
89 
90  /* Clear the system partition if it is being deleted */
91 #if 0
92  if (List->SystemPartition == PartEntry)
93  {
94  ASSERT(List->SystemPartition);
95  List->SystemPartition = NULL;
96  }
97 #endif
98 
99  if ((bOverride == FALSE) && (IsKnownPartition(CurrentPartition) == FALSE))
100  {
102  return FALSE;
103  }
104 
105  /* Check which type of partition (primary/logical or extended) is being deleted */
107  {
108  /* An extended partition is being deleted: delete all logical partition entries */
110  {
112  LogicalPartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
113 
114  /* Dismount the logical partition */
115  DismountVolume(LogicalPartEntry);
116 
117  /* Delete it */
118  RtlFreeHeap(RtlGetProcessHeap(), 0, LogicalPartEntry);
119  }
120 
122  }
123  else
124  {
125  /* A primary partition is being deleted: dismount it */
127  }
128 
129  /* Adjust the unpartitioned disk space entries */
130 
131  /* Get pointer to previous and next unpartitioned entries */
134 
135  if (PrevPartEntry != NULL && NextPartEntry != NULL)
136  {
137  /* Merge the previous, current and next unpartitioned entries */
138 
139  /* Adjust the previous entry length */
140  PrevPartEntry->SectorCount.QuadPart += (CurrentPartition->SectorCount.QuadPart + NextPartEntry->SectorCount.QuadPart);
141 
142  /* Remove the current and next entries */
144  RtlFreeHeap(RtlGetProcessHeap(), 0, CurrentPartition);
145  RemoveEntryList(&NextPartEntry->ListEntry);
146  RtlFreeHeap(RtlGetProcessHeap(), 0, NextPartEntry);
147  }
148  else if (PrevPartEntry != NULL && NextPartEntry == NULL)
149  {
150  /* Merge the current and the previous unpartitioned entries */
151 
152  /* Adjust the previous entry length */
154 
155  /* Remove the current entry */
157  RtlFreeHeap(RtlGetProcessHeap(), 0, CurrentPartition);
158  }
159  else if (PrevPartEntry == NULL && NextPartEntry != NULL)
160  {
161  /* Merge the current and the next unpartitioned entries */
162 
163  /* Adjust the next entry offset and length */
166 
167  /* Remove the current entry */
169  RtlFreeHeap(RtlGetProcessHeap(), 0, CurrentPartition);
170  }
171  else
172  {
173  /* Nothing to merge but change the current entry */
177  // CurrentPartition->PartitionIndex = 0;
184  }
185 
187 
190  if (!NT_SUCCESS(Status))
191  {
193  return TRUE;
194  }
195 
197 
198  return TRUE;
199 }
#define IDS_SELECT_NO_PARTITION
Definition: resource.h:88
WCHAR DriveLetter
Definition: partlist.h:58
static int argc
Definition: ServiceArgs.c:12
ULONG PartitionNumber
Definition: partlist.h:55
ULARGE_INTEGER StartSector
Definition: partlist.h:49
WCHAR VolumeLabel[20]
Definition: partlist.h:59
struct _Entry Entry
Definition: kefuncs.h:629
#define TRUE
Definition: types.h:120
ULARGE_INTEGER SectorCount
Definition: partlist.h:50
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
static PPARTENTRY CurrentPartition
Definition: usetup.c:76
PDISKENTRY CurrentDisk
Definition: partlist.c:74
#define argv
Definition: mplay32.c:18
int32_t INT
Definition: typedefs.h:58
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: fc.c:16
PPARTENTRY ExtendedPartition
Definition: partlist.h:135
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
#define PARTITION_ENTRY_UNUSED
Definition: disk.h:86
LIST_ENTRY ListEntry
Definition: partlist.h:43
#define IDS_ERROR_INVALID_ARGS
Definition: resource.h:187
NTSTATUS DismountVolume(IN PPARTENTRY PartEntry)
Definition: partlist.c:2940
#define L(x)
Definition: ntvdm.h:50
static BOOL IsKnownPartition(_In_ PPARTENTRY PartEntry)
Definition: delete.c:16
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
FORMATSTATE FormatState
Definition: partlist.h:61
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:128
#define IDS_DELETE_PARTITION_SUCCESS
Definition: resource.h:33
void ConResPuts(FILE *fp, UINT nID)
Definition: fc.c:27
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
static VOID UpdateDiskLayout(IN PDISKENTRY DiskEntry)
Definition: partlist.c:2534
Status
Definition: gdiplustypes.h:24
UCHAR PartitionType
Definition: partlist.h:53
#define ASSERT(a)
Definition: mode.c:44
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ULONG OnDiskPartitionNumber
Definition: partlist.h:54
#define IDS_SELECT_NO_DISK
Definition: resource.h:85
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
#define IDS_DELETE_PARTITION_FAIL
Definition: resource.h:32
Definition: typedefs.h:119
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static PPARTENTRY GetPrevUnpartitionedEntry(IN PPARTENTRY PartEntry)
Definition: partlist.c:2717
#define NULL
Definition: types.h:112
LIST_ENTRY LogicalPartListHead
Definition: partlist.h:132
BOOLEAN BootIndicator
Definition: partlist.h:52
#define StdOut
Definition: fc.c:14
static PPARTENTRY GetNextUnpartitionedEntry(IN PPARTENTRY PartEntry)
Definition: partlist.c:2752
NTSTATUS WritePartitions(IN PDISKENTRY DiskEntry)
Definition: partlist.c:3619
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define DPRINT
Definition: sndvol32.h:71
CHAR FileSystemName[9]
Definition: diskpart.h:113
base of all file and directory entries
Definition: entries.h:82
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
BOOLEAN IsPartitioned
Definition: partlist.h:66
#define StdErr
Definition: fc.c:15

◆ DeleteVolume()

BOOL DeleteVolume ( _In_ INT  argc,
_In_ PWSTR argv 
)

Definition at line 203 of file delete.c.

206 {
207  return TRUE;
208 }
#define TRUE
Definition: types.h:120

◆ DestroyPartitionList()

VOID DestroyPartitionList ( VOID  )

Definition at line 1131 of file partlist.c.

1132 {
1133  PDISKENTRY DiskEntry;
1134  PBIOSDISKENTRY BiosDiskEntry;
1135  PPARTENTRY PartEntry;
1137 
1138  CurrentDisk = NULL;
1140 
1141  /* Release disk and partition info */
1142  while (!IsListEmpty(&DiskListHead))
1143  {
1145  DiskEntry = CONTAINING_RECORD(Entry, DISKENTRY, ListEntry);
1146 
1147  /* Release driver name */
1148  RtlFreeUnicodeString(&DiskEntry->DriverName);
1149 
1150  /* Release primary partition list */
1151  while (!IsListEmpty(&DiskEntry->PrimaryPartListHead))
1152  {
1153  Entry = RemoveHeadList(&DiskEntry->PrimaryPartListHead);
1154  PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
1155 
1156  RtlFreeHeap(RtlGetProcessHeap(), 0, PartEntry);
1157  }
1158 
1159  /* Release logical partition list */
1160  while (!IsListEmpty(&DiskEntry->LogicalPartListHead))
1161  {
1162  Entry = RemoveHeadList(&DiskEntry->LogicalPartListHead);
1163  PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
1164 
1165  RtlFreeHeap(RtlGetProcessHeap(), 0, PartEntry);
1166  }
1167 
1168  /* Release layout buffer */
1169  if (DiskEntry->LayoutBuffer != NULL)
1170  RtlFreeHeap(RtlGetProcessHeap(), 0, DiskEntry->LayoutBuffer);
1171 
1172 
1173  /* Release disk entry */
1174  RtlFreeHeap(RtlGetProcessHeap(), 0, DiskEntry);
1175  }
1176 
1177  /* Release the bios disk info */
1178  while (!IsListEmpty(&BiosDiskListHead))
1179  {
1181  BiosDiskEntry = CONTAINING_RECORD(Entry, BIOSDISKENTRY, ListEntry);
1182 
1183  RtlFreeHeap(RtlGetProcessHeap(), 0, BiosDiskEntry);
1184  }
1185 }
LIST_ENTRY DiskListHead
Definition: partlist.c:70
LIST_ENTRY PrimaryPartListHead
Definition: partlist.h:131
PDISKENTRY CurrentDisk
Definition: partlist.c:74
struct _Entry Entry
Definition: kefuncs.h:629
LIST_ENTRY BiosDiskListHead
Definition: partlist.c:71
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:128
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
UNICODE_STRING DriverName
Definition: partlist.h:123
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
Definition: typedefs.h:119
#define NULL
Definition: types.h:112
LIST_ENTRY LogicalPartListHead
Definition: partlist.h:132
PDRIVE_LAYOUT_INFORMATION LayoutBuffer
Definition: partlist.h:125
base of all file and directory entries
Definition: entries.h:82
PPARTENTRY CurrentPartition
Definition: partlist.c:75

◆ DestroyVolumeList()

VOID DestroyVolumeList ( VOID  )

Definition at line 1450 of file partlist.c.

1451 {
1453  PVOLENTRY VolumeEntry;
1454 
1455  CurrentVolume = NULL;
1456 
1457  /* Release disk and partition info */
1458  while (!IsListEmpty(&VolumeListHead))
1459  {
1461  VolumeEntry = CONTAINING_RECORD(Entry, VOLENTRY, ListEntry);
1462 
1463  if (VolumeEntry->pszLabel)
1464  RtlFreeHeap(RtlGetProcessHeap(), 0, VolumeEntry->pszLabel);
1465 
1466  if (VolumeEntry->pszFilesystem)
1467  RtlFreeHeap(RtlGetProcessHeap(), 0, VolumeEntry->pszFilesystem);
1468 
1469  if (VolumeEntry->pExtents)
1470  RtlFreeHeap(RtlGetProcessHeap(), 0, VolumeEntry->pExtents);
1471 
1472  /* Release disk entry */
1473  RtlFreeHeap(RtlGetProcessHeap(), 0, VolumeEntry);
1474  }
1475 }
struct _Entry Entry
Definition: kefuncs.h:629
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
PVOLUME_DISK_EXTENTS pExtents
Definition: diskpart.h:202
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:128
PWSTR pszLabel
Definition: diskpart.h:197
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
LIST_ENTRY VolumeListHead
Definition: partlist.c:72
PVOLENTRY CurrentVolume
Definition: partlist.c:76
Definition: typedefs.h:119
#define NULL
Definition: types.h:112
PWSTR pszFilesystem
Definition: diskpart.h:198
base of all file and directory entries
Definition: entries.h:82

Referenced by rescan_main(), and wmain().

◆ detach_main()

BOOL detach_main ( INT  argc,
LPWSTR argv 
)

Definition at line 11 of file detach.c.

12 {
13  return TRUE;
14 }
#define TRUE
Definition: types.h:120

◆ DetailDisk()

BOOL DetailDisk ( INT  argc,
PWSTR argv 
)

◆ DetailPartition()

BOOL DetailPartition ( INT  argc,
PWSTR argv 
)

◆ DetailVolume()

BOOL DetailVolume ( INT  argc,
PWSTR argv 
)

◆ DismountVolume()

NTSTATUS DismountVolume ( _In_ PPARTENTRY  PartEntry)

Definition at line 1958 of file partlist.c.

1960 {
1961  NTSTATUS Status;
1962  NTSTATUS LockStatus;
1966  HANDLE PartitionHandle;
1968 
1969  /* Check whether the partition is valid and was mounted by the system */
1970  if (!PartEntry->IsPartitioned ||
1971  IsContainerPartition(PartEntry->PartitionType) ||
1972  !IsRecognizedPartition(PartEntry->PartitionType) ||
1973  PartEntry->FormatState == UnknownFormat ||
1974  // NOTE: If FormatState == Unformatted but *FileSystem != 0 this means
1975  // it has been usually mounted with RawFS and thus needs to be dismounted.
1976 /* !*PartEntry->FileSystem || */
1977  PartEntry->PartitionNumber == 0)
1978  {
1979  /* The partition is not mounted, so just return success */
1980  return STATUS_SUCCESS;
1981  }
1982 
1983  ASSERT(PartEntry->PartitionType != PARTITION_ENTRY_UNUSED);
1984 
1985  /* Open the volume */
1987  L"\\Device\\Harddisk%lu\\Partition%lu",
1988  PartEntry->DiskEntry->DiskNumber,
1989  PartEntry->PartitionNumber);
1991 
1993  &Name,
1995  NULL,
1996  NULL);
1997 
1998  Status = NtOpenFile(&PartitionHandle,
2001  &IoStatusBlock,
2004  if (!NT_SUCCESS(Status))
2005  {
2006  DPRINT1("ERROR: Cannot open volume %wZ for dismounting! (Status 0x%lx)\n", &Name, Status);
2007  return Status;
2008  }
2009 
2010  /* Lock the volume */
2011  LockStatus = NtFsControlFile(PartitionHandle,
2012  NULL,
2013  NULL,
2014  NULL,
2015  &IoStatusBlock,
2017  NULL,
2018  0,
2019  NULL,
2020  0);
2021  if (!NT_SUCCESS(LockStatus))
2022  {
2023  DPRINT1("WARNING: Failed to lock volume! Operations may fail! (Status 0x%lx)\n", LockStatus);
2024  }
2025 
2026  /* Dismount the volume */
2027  Status = NtFsControlFile(PartitionHandle,
2028  NULL,
2029  NULL,
2030  NULL,
2031  &IoStatusBlock,
2033  NULL,
2034  0,
2035  NULL,
2036  0);
2037  if (!NT_SUCCESS(Status))
2038  {
2039  DPRINT1("Failed to unmount volume (Status 0x%lx)\n", Status);
2040  }
2041 
2042  /* Unlock the volume */
2043  LockStatus = NtFsControlFile(PartitionHandle,
2044  NULL,
2045  NULL,
2046  NULL,
2047  &IoStatusBlock,
2049  NULL,
2050  0,
2051  NULL,
2052  0);
2053  if (!NT_SUCCESS(LockStatus))
2054  {
2055  DPRINT1("Failed to unlock volume (Status 0x%lx)\n", LockStatus);
2056  }
2057 
2058  /* Close the volume */
2059  NtClose(PartitionHandle);
2060 
2061  return Status;
2062 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define FSCTL_UNLOCK_VOLUME
Definition: nt_native.h:833
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
LONG NTSTATUS
Definition: precomp.h:26
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define IsContainerPartition(PartitionType)
Definition: ntdddisk.h:316
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_SHARE_READ
Definition: compat.h:136
#define PARTITION_ENTRY_UNUSED
Definition: disk.h:86
#define L(x)
Definition: ntvdm.h:50
#define GENERIC_WRITE
Definition: nt_native.h:90
struct NameRec_ * Name
Definition: cdprocs.h:459
Definition: bufpool.h:45
#define FSCTL_DISMOUNT_VOLUME
Definition: nt_native.h:834
Status
Definition: gdiplustypes.h:24
NTSYSAPI NTSTATUS NTAPI NtOpenFile(OUT PHANDLE phFile, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG ShareMode, IN ULONG OpenMode)
Definition: file.c:3951
NTSYSAPI NTSTATUS NTAPI NtFsControlFile(IN HANDLE hFile, IN HANDLE hEvent OPTIONAL, IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL, IN PVOID IoApcContext OPTIONAL, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG DeviceIoControlCode, IN PVOID InBuffer OPTIONAL, IN ULONG InBufferLength, OUT PVOID OutBuffer OPTIONAL, IN ULONG OutBufferLength)
#define ASSERT(a)
Definition: mode.c:44
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define IsRecognizedPartition(PartitionType)
Definition: ntdddisk.h:342
#define MAX_PATH
Definition: compat.h:34
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
#define GENERIC_READ
Definition: compat.h:135
#define SYNCHRONIZE
Definition: nt_native.h:61
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
#define FSCTL_LOCK_VOLUME
Definition: nt_native.h:832
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define STATUS_SUCCESS
Definition: shellext.h:65

◆ DumpDisk()

BOOL DumpDisk ( _In_ INT  argc,
_In_ LPWSTR argv 
)

Definition at line 48 of file dump.c.

51 {
58  PUCHAR pSectorBuffer = NULL;
60  LONGLONG Sector;
61  LPWSTR endptr = NULL;
62 
63 #if 0
64  if (argc == 2)
65  {
66  ConResPuts(StdOut, IDS_HELP_CMD_DUMP_DISK);
67  return TRUE;
68  }
69 #endif
70 
71  if (CurrentDisk == NULL)
72  {
74  return TRUE;
75  }
76 
77  Sector = _wcstoi64(argv[2], &endptr, 0);
78  if (((Sector == 0) && (endptr == argv[2])) ||
79  (Sector < 0))
80  {
82  return TRUE;
83  }
84 
85  pSectorBuffer = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, CurrentDisk->BytesPerSector);
86  if (pSectorBuffer == NULL)
87  {
88  DPRINT1("\n");
89  /* Error message */
90  goto done;
91  }
92 
94  L"\\Device\\Harddisk%d\\Partition0",
97  Buffer);
98 
100  &Name,
101  0,
102  NULL,
103  NULL);
104 
108  &Iosb,
111  if (!NT_SUCCESS(Status))
112  {
113  DPRINT1("\n");
114  goto done;
115  }
116 
117  FileOffset.QuadPart = Sector * CurrentDisk->BytesPerSector;
119  NULL,
120  NULL,
121  NULL,
122  &Iosb,
123  (PVOID)pSectorBuffer,
125  &FileOffset,
126  NULL);
127  if (!NT_SUCCESS(Status))
128  {
129  DPRINT1("NtReadFile failed, status=%x\n", Status);
130  goto done;
131  }
132 
133  HexDump(pSectorBuffer, CurrentDisk->BytesPerSector);
134 
135 done:
136  if (FileHandle)
138 
139  RtlFreeHeap(RtlGetProcessHeap(), 0, pSectorBuffer);
140 
141  return TRUE;
142 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
static int argc
Definition: ServiceArgs.c:12
#define TRUE
Definition: types.h:120
unsigned char * PUCHAR
Definition: retypes.h:3
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
ULONG DiskNumber
Definition: partlist.h:111
PDISKENTRY CurrentDisk
Definition: partlist.c:74
#define argv
Definition: mplay32.c:18
#define FILE_SHARE_READ
Definition: compat.h:136
#define IDS_ERROR_INVALID_ARGS
Definition: resource.h:187
#define L(x)
Definition: ntvdm.h:50
__MINGW_EXTENSION _Check_return_ _CRTIMP __int64 __cdecl _wcstoi64(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
#define FILE_READ_DATA
Definition: nt_native.h:628
struct NameRec_ * Name
Definition: cdprocs.h:459
static VOID HexDump(_In_ UCHAR *addr, _In_ int len)
Definition: dump.c:18
Definition: bufpool.h:45
void ConResPuts(FILE *fp, UINT nID)
Definition: fc.c:27
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
Status
Definition: gdiplustypes.h:24
int64_t LONGLONG
Definition: typedefs.h:68
NTSYSAPI NTSTATUS NTAPI NtOpenFile(OUT PHANDLE phFile, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG ShareMode, IN ULONG OpenMode)
Definition: file.c:3951
ULONG BytesPerSector
Definition: partlist.h:95
__wchar_t WCHAR
Definition: xmlstorage.h:180
return Iosb
Definition: create.c:4402
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define MAX_PATH
Definition: compat.h:34
#define IDS_SELECT_NO_DISK
Definition: resource.h:85
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
#define FILE_READ_ATTRIBUTES
Definition: nt_native.h:647
#define SYNCHRONIZE
Definition: nt_native.h:61
int _cdecl swprintf(const WCHAR *,...)
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
Definition: fltkernel.h:1230
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:159
#define NULL
Definition: types.h:112
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define DPRINT1
Definition: precomp.h:8
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
#define StdOut
Definition: fc.c:14
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
WCHAR * LPWSTR
Definition: xmlstorage.h:184
NTSTATUS NTAPI NtReadFile(HANDLE FileHandle, HANDLE Event, PIO_APC_ROUTINE ApcRoutine, PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, PVOID Buffer, ULONG Length, PLARGE_INTEGER ByteOffset, PULONG Key)
#define StdErr
Definition: fc.c:15

◆ DumpPartition()

BOOL DumpPartition ( _In_ INT  argc,
_In_ LPWSTR argv 
)

Definition at line 146 of file dump.c.

149 {
156  PUCHAR pSectorBuffer = NULL;
158  LONGLONG Sector;
159  LPWSTR endptr = NULL;
160 
161 
162 #if 0
163  if (argc == 2)
164  {
165  ConResPuts(StdOut, IDS_HELP_CMD_DUMP_DISK);
166  return TRUE;
167  }
168 #endif
169 
170  if (CurrentDisk == NULL)
171  {
173  return TRUE;
174  }
175 
176  if (CurrentPartition == NULL)
177  {
179  return TRUE;
180  }
181 
182  Sector = _wcstoi64(argv[2], &endptr, 0);
183  if (((Sector == 0) && (endptr == argv[2])) ||
184  (Sector < 0))
185  {
187  return TRUE;
188  }
189 
190  pSectorBuffer = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, CurrentDisk->BytesPerSector);
191  if (pSectorBuffer == NULL)
192  {
193  DPRINT1("\n");
194  /* Error message */
195  goto done;
196  }
197 
199  L"\\Device\\Harddisk%d\\Partition%d",
203  Buffer);
204 
206  &Name,
207  0,
208  NULL,
209  NULL);
210 
214  &Iosb,
217  if (!NT_SUCCESS(Status))
218  {
219  DPRINT1("\n");
220  goto done;
221  }
222 
223  FileOffset.QuadPart = Sector * CurrentDisk->BytesPerSector;
225  NULL,
226  NULL,
227  NULL,
228  &Iosb,
229  (PVOID)pSectorBuffer,
231  &FileOffset,
232  NULL);
233  if (!NT_SUCCESS(Status))
234  {
235  DPRINT1("NtReadFile failed, status=%x\n", Status);
236  goto done;
237  }
238 
239  HexDump(pSectorBuffer, CurrentDisk->BytesPerSector);
240 
241 done:
242  if (FileHandle)
244 
245  RtlFreeHeap(RtlGetProcessHeap(), 0, pSectorBuffer);
246 
247  return TRUE;
248 }
#define IDS_SELECT_NO_PARTITION
Definition: resource.h:88
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
static int argc
Definition: ServiceArgs.c:12
ULONG PartitionNumber
Definition: partlist.h:55
#define TRUE
Definition: types.h:120
unsigned char * PUCHAR
Definition: retypes.h:3
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
ULONG DiskNumber
Definition: partlist.h:111
static PPARTENTRY CurrentPartition
Definition: usetup.c:76
PDISKENTRY CurrentDisk
Definition: partlist.c:74
#define argv
Definition: mplay32.c:18
#define FILE_SHARE_READ
Definition: compat.h:136
#define IDS_ERROR_INVALID_ARGS
Definition: resource.h:187
#define L(x)
Definition: ntvdm.h:50
__MINGW_EXTENSION _Check_return_ _CRTIMP __int64 __cdecl _wcstoi64(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
#define FILE_READ_DATA
Definition: nt_native.h:628
struct NameRec_ * Name
Definition: cdprocs.h:459
static VOID HexDump(_In_ UCHAR *addr, _In_ int len)
Definition: dump.c:18
Definition: bufpool.h:45
void ConResPuts(FILE *fp, UINT nID)
Definition: fc.c:27
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
Status
Definition: gdiplustypes.h:24
int64_t LONGLONG
Definition: typedefs.h:68
NTSYSAPI NTSTATUS NTAPI NtOpenFile(OUT PHANDLE phFile, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG ShareMode, IN ULONG OpenMode)
Definition: file.c:3951
ULONG BytesPerSector
Definition: partlist.h:95
__wchar_t WCHAR
Definition: xmlstorage.h:180
return Iosb
Definition: create.c:4402
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define MAX_PATH
Definition: compat.h:34
#define IDS_SELECT_NO_DISK
Definition: resource.h:85
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
#define FILE_READ_ATTRIBUTES
Definition: nt_native.h:647
#define SYNCHRONIZE
Definition: nt_native.h:61
int _cdecl swprintf(const WCHAR *,...)
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
Definition: fltkernel.h:1230
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:159
#define NULL
Definition: types.h:112
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define DPRINT1
Definition: precomp.h:8
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
#define StdOut
Definition: fc.c:14
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
WCHAR * LPWSTR
Definition: xmlstorage.h:184
NTSTATUS NTAPI NtReadFile(HANDLE FileHandle, HANDLE Event, PIO_APC_ROUTINE ApcRoutine, PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, PVOID Buffer, ULONG Length, PLARGE_INTEGER ByteOffset, PULONG Key)
#define StdErr
Definition: fc.c:15

◆ DuplicateQuotedString()

PWSTR DuplicateQuotedString ( _In_ PWSTR  pszInString)

Definition at line 84 of file misc.c.

86 {
87  PWSTR pszOutString = NULL;
88  PWSTR pStart, pEnd;
89  INT nLength;
90 
91  if ((pszInString == NULL) || (pszInString[0] == UNICODE_NULL))
92  return NULL;
93 
94  if (pszInString[0] == L'"')
95  {
96  if (pszInString[1] == UNICODE_NULL)
97  return NULL;
98 
99  pStart = &pszInString[1];
100  pEnd = wcschr(pStart, '"');
101  if (pEnd == NULL)
102  {
103  nLength = wcslen(pStart);
104  }
105  else
106  {
107  nLength = (pEnd - pStart);
108  }
109  }
110  else
111  {
112  pStart = pszInString;
113  nLength = wcslen(pStart);
114  }
115 
116  pszOutString = RtlAllocateHeap(RtlGetProcessHeap(),
118  (nLength + 1) * sizeof(WCHAR));
119  if (pszOutString == NULL)
120  return NULL;
121 
122  wcsncpy(pszOutString, pStart, nLength);
123 
124  return pszOutString;
125 }
uint16_t * PWSTR
Definition: typedefs.h:56
_In_ DWORD nLength
Definition: wincon.h:473
int32_t INT
Definition: typedefs.h:58
#define L(x)
Definition: ntvdm.h:50
#define UNICODE_NULL
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
__wchar_t WCHAR
Definition: xmlstorage.h:180
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
#define NULL
Definition: types.h:112
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

◆ DuplicateString()

PWSTR DuplicateString ( _In_ PWSTR  pszInString)

Definition at line 129 of file misc.c.

131 {
132  PWSTR pszOutString = NULL;
133  INT nLength;
134 
135  if ((pszInString == NULL) || (pszInString[0] == UNICODE_NULL))
136  return NULL;
137 
138  nLength = wcslen(pszInString);
139  pszOutString = RtlAllocateHeap(RtlGetProcessHeap(),
141  (nLength + 1) * sizeof(WCHAR));
142  if (pszOutString == NULL)
143  return NULL;
144 
145  wcscpy(pszOutString, pszInString);
146 
147  return pszOutString;
148 }
uint16_t * PWSTR
Definition: typedefs.h:56
_In_ DWORD nLength
Definition: wincon.h:473
int32_t INT
Definition: typedefs.h:58
#define UNICODE_NULL
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
__wchar_t WCHAR
Definition: xmlstorage.h:180
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define NULL
Definition: types.h:112
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

◆ expand_main()

BOOL expand_main ( INT  argc,
LPWSTR argv 
)

Definition at line 11 of file expand.c.

12 {
13  return TRUE;
14 }
#define TRUE
Definition: types.h:120

◆ extend_main()

BOOL extend_main ( INT  argc,
LPWSTR argv 
)

Definition at line 11 of file extend.c.

12 {
13  return TRUE;
14 }
#define TRUE
Definition: types.h:120

◆ filesystems_main()

BOOL filesystems_main ( INT  argc,
LPWSTR argv 
)

◆ format_main()

BOOL format_main ( INT  argc,
LPWSTR argv 
)

Definition at line 11 of file format.c.

12 {
13  return TRUE;
14 }
#define TRUE
Definition: types.h:120

◆ GetNextUnpartitionedEntry()

PPARTENTRY GetNextUnpartitionedEntry ( _In_ PPARTENTRY  PartEntry)

Definition at line 1930 of file partlist.c.

1932 {
1933  PDISKENTRY DiskEntry = PartEntry->DiskEntry;
1934  PPARTENTRY NextPartEntry;
1935  PLIST_ENTRY ListHead;
1936 
1937  if (PartEntry->LogicalPartition)
1938  ListHead = &DiskEntry->LogicalPartListHead;
1939  else
1940  ListHead = &DiskEntry->PrimaryPartListHead;
1941 
1942  if (PartEntry->ListEntry.Flink != ListHead)
1943  {
1944  NextPartEntry = CONTAINING_RECORD(PartEntry->ListEntry.Flink,
1945  PARTENTRY,
1946  ListEntry);
1947  if (!NextPartEntry->IsPartitioned)
1948  {
1949  ASSERT(NextPartEntry->PartitionType == PARTITION_ENTRY_UNUSED);
1950  return NextPartEntry;
1951  }
1952  }
1953 
1954  return NULL;
1955 }
LIST_ENTRY PrimaryPartListHead
Definition: partlist.h:131
#define PARTITION_ENTRY_UNUSED
Definition: disk.h:86
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
UCHAR PartitionType
Definition: partlist.h:53
#define ASSERT(a)
Definition: mode.c:44
Definition: typedefs.h:119
#define NULL
Definition: types.h:112
LIST_ENTRY LogicalPartListHead
Definition: partlist.h:132
BOOLEAN IsPartitioned
Definition: partlist.h:66

◆ GetPrevUnpartitionedEntry()

PPARTENTRY GetPrevUnpartitionedEntry ( _In_ PPARTENTRY  PartEntry)

Definition at line 1901 of file partlist.c.

1903 {
1904  PDISKENTRY DiskEntry = PartEntry->DiskEntry;
1905  PPARTENTRY PrevPartEntry;
1906  PLIST_ENTRY ListHead;
1907 
1908  if (PartEntry->LogicalPartition)
1909  ListHead = &DiskEntry->LogicalPartListHead;
1910  else
1911  ListHead = &DiskEntry->PrimaryPartListHead;
1912 
1913  if (PartEntry->ListEntry.Blink != ListHead)
1914  {
1915  PrevPartEntry = CONTAINING_RECORD(PartEntry->ListEntry.Blink,
1916  PARTENTRY,
1917  ListEntry);
1918  if (!PrevPartEntry->IsPartitioned)
1919  {
1920  ASSERT(PrevPartEntry->PartitionType == PARTITION_ENTRY_UNUSED);
1921  return PrevPartEntry;
1922  }
1923  }
1924 
1925  return NULL;
1926 }
LIST_ENTRY PrimaryPartListHead
Definition: partlist.h:131
#define PARTITION_ENTRY_UNUSED
Definition: disk.h:86
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
UCHAR PartitionType
Definition: partlist.h:53
#define ASSERT(a)
Definition: mode.c:44
Definition: typedefs.h:119
#define NULL
Definition: types.h:112
LIST_ENTRY LogicalPartListHead
Definition: partlist.h:132
BOOLEAN IsPartitioned
Definition: partlist.h:66

◆ GetPrimaryPartitionCount()

ULONG GetPrimaryPartitionCount ( _In_ PDISKENTRY  DiskEntry)

Definition at line 1635 of file partlist.c.

1637 {
1639  PPARTENTRY PartEntry;
1640  ULONG Count = 0;
1641 
1642  for (Entry = DiskEntry->PrimaryPartListHead.Flink;
1643  Entry != &DiskEntry->PrimaryPartListHead;
1644  Entry = Entry->Flink)
1645  {
1646  PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
1647  if (PartEntry->IsPartitioned)
1648  Count++;
1649  }
1650 
1651  return Count;
1652 }
struct _Entry Entry
Definition: kefuncs.h:629
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
int Count
Definition: noreturn.cpp:7
Definition: typedefs.h:119
unsigned int ULONG
Definition: retypes.h:1
base of all file and directory entries
Definition: entries.h:82
BOOLEAN IsPartitioned
Definition: partlist.h:66

Referenced by UpdateDiskLayout().

◆ GetVolumeFromPartition()

PVOLENTRY GetVolumeFromPartition ( _In_ PPARTENTRY  PartEntry)

Definition at line 2066 of file partlist.c.

2068 {
2070  PVOLENTRY VolumeEntry;
2071  ULONG i;
2072 
2073  if ((PartEntry == NULL) ||
2074  (PartEntry->DiskEntry == NULL))
2075  return NULL;
2076 
2078  while (Entry != &VolumeListHead)
2079  {
2080  VolumeEntry = CONTAINING_RECORD(Entry, VOLENTRY, ListEntry);
2081 
2082  if (VolumeEntry->pExtents == NULL)
2083  return NULL;
2084 
2085  for (i = 0; i < VolumeEntry->pExtents->NumberOfDiskExtents; i++)
2086  {
2087  if (VolumeEntry->pExtents->Extents[i].DiskNumber == PartEntry->DiskEntry->DiskNumber)
2088  {
2089  if ((VolumeEntry->pExtents->Extents[i].StartingOffset.QuadPart == PartEntry->StartSector.QuadPart * PartEntry->DiskEntry->BytesPerSector) &&
2090  (VolumeEntry->pExtents->Extents[i].ExtentLength.QuadPart == PartEntry->SectorCount.QuadPart * PartEntry->DiskEntry->BytesPerSector))
2091  return VolumeEntry;
2092  }
2093  }
2094 
2095  Entry = Entry->Flink;
2096  }
2097 
2098  return NULL;
2099 }
LARGE_INTEGER ExtentLength
Definition: ntddvol.h:115
struct _Entry Entry
Definition: kefuncs.h:629
PVOLUME_DISK_EXTENTS pExtents
Definition: diskpart.h:202
DISK_EXTENT Extents[1]
Definition: ntddvol.h:120
ULONG DiskNumber
Definition: ntddvol.h:113
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
LIST_ENTRY VolumeListHead
Definition: partlist.c:72
Definition: typedefs.h:119
ULONG NumberOfDiskExtents
Definition: ntddvol.h:119
LARGE_INTEGER StartingOffset
Definition: ntddvol.h:114
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
base of all file and directory entries
Definition: entries.h:82
LONGLONG QuadPart
Definition: typedefs.h:114

Referenced by clean_main().

◆ gpt_main()

BOOL gpt_main ( INT  argc,
LPWSTR argv 
)

Definition at line 11 of file gpt.c.

12 {
13  return TRUE;
14 }
#define TRUE
Definition: types.h:120

◆ HasPrefix()

BOOL HasPrefix ( _In_ PWSTR  pszString,
_In_ PWSTR  pszPrefix,
_Out_opt_ PWSTR pszSuffix 
)

Definition at line 58 of file misc.c.

62 {
63  INT nPrefixLength, ret;
64 
65  nPrefixLength = wcslen(pszPrefix);
66  ret = _wcsnicmp(pszString, pszPrefix, nPrefixLength);
67  if ((ret == 0) && (ppszSuffix != NULL))
68  *ppszSuffix = &pszString[nPrefixLength];
69 
70  return (ret == 0);
71 }
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
int32_t INT
Definition: typedefs.h:58
int ret
#define NULL
Definition: types.h:112
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
_In_ DWORD _In_ DWORD _Out_writes_to_opt_ pcchString LPSTR pszString
Definition: wincrypt.h:4505

Referenced by AcpiExGetNameString(), CreateExtendedPartition(), CreateLogicalPartition(), CreatePrimaryPartition(), setid_main(), and UniqueIdDisk().

◆ help_main()

BOOL help_main ( INT  argc,
LPWSTR argv 
)

Definition at line 120 of file help.c.

121 {
122  PCOMMAND cmdptr;
123  PCOMMAND cmdptr1 = NULL;
124  PCOMMAND cmdptr2 = NULL;
125  PCOMMAND cmdptr3 = NULL;
126 
127  if (argc == 1)
128  {
129  HelpCommandList();
130  return TRUE;
131  }
132 
133  /* Scan internal command table */
134  for (cmdptr = cmds; cmdptr->cmd1; cmdptr++)
135  {
136  if ((cmdptr1 == NULL) &&
137  (wcsicmp(argv[1], cmdptr->cmd1) == 0))
138  cmdptr1 = cmdptr;
139 
140  if ((cmdptr2 == NULL) &&
141  (argc >= 3) &&
142  (wcsicmp(argv[1], cmdptr->cmd1) == 0) &&
143  (wcsicmp(argv[2], cmdptr->cmd2) == 0))
144  cmdptr2 = cmdptr;
145 
146  if ((cmdptr3 == NULL) &&
147  (argc >= 4) &&
148  (wcsicmp(argv[1], cmdptr->cmd1) == 0) &&
149  (wcsicmp(argv[2], cmdptr->cmd2) == 0) &&
150  (wcsicmp(argv[3], cmdptr->cmd3) == 0))
151  cmdptr3 = cmdptr;
152  }
153 
154  if (cmdptr3 != NULL)
155  {
156  return HelpCommand(cmdptr3);
157  }
158  else if (cmdptr2 != NULL)
159  {
160  return HelpCommand(cmdptr2);
161  }
162  else if (cmdptr1 != NULL)
163  {
164  return HelpCommand(cmdptr1);
165  }
166 
167  HelpCommandList();
168 
169  return TRUE;
170 }
PWSTR cmd2
Definition: diskpart.h:58
static int argc
Definition: ServiceArgs.c:12
BOOL HelpCommand(PCOMMAND pCommand)
Definition: help.c:46
#define TRUE
Definition: types.h:120
COMMAND cmds[]
Definition: main.c:21
#define argv
Definition: mplay32.c:18
PWSTR cmd1
Definition: diskpart.h:57
#define wcsicmp
Definition: compat.h:15
#define NULL
Definition: types.h:112
PWSTR cmd3
Definition: diskpart.h:59
VOID HelpCommandList(VOID)
Definition: help.c:16
Definition: main.c:14

◆ HelpCommand()

BOOL HelpCommand ( PCOMMAND  pCommand)

Definition at line 46 of file help.c.

48 {
49  PCOMMAND cmdptr;
50  BOOL bSubCommands = FALSE;
51  WCHAR szFormat[64];
52  WCHAR szOutput[256];
53 
55 
56  ConPuts(StdOut, L"\n");
57 
58  /* List all the commands and the basic descriptions */
59  for (cmdptr = cmds; cmdptr->cmd1; cmdptr++)
60  {
61  if (pCommand->cmd1 != NULL && pCommand->cmd2 == NULL && pCommand->cmd3 == NULL)
62  {
63  if ((wcsicmp(pCommand->cmd1, cmdptr->cmd1) == 0) &&
64  (cmdptr->cmd2 != NULL) &&
65  (cmdptr->cmd3 == NULL) &&
66  (cmdptr->help != IDS_NONE))
67  {
68  K32LoadStringW(GetModuleHandle(NULL), cmdptr->help, szOutput, ARRAYSIZE(szOutput));
69  ConPrintf(StdOut, szFormat, cmdptr->cmd2, szOutput);
70  bSubCommands = TRUE;
71  }
72  }
73  else if (pCommand->cmd1 != NULL && pCommand->cmd2 != NULL && pCommand->cmd3 == NULL)
74  {
75  if ((wcsicmp(pCommand->cmd1, cmdptr->cmd1) == 0) &&
76  (wcsicmp(pCommand->cmd2, cmdptr->cmd2) == 0) &&
77  (cmdptr->cmd3 != NULL) &&
78  (cmdptr->help != IDS_NONE))
79  {
80  K32LoadStringW(GetModuleHandle(NULL), cmdptr->help, szOutput, ARRAYSIZE(szOutput));
81  ConPrintf(StdOut, szFormat, cmdptr->cmd3, szOutput);
82  bSubCommands = TRUE;
83  }
84  }
85  else if (pCommand->cmd1 != NULL && pCommand->cmd2 != NULL && pCommand->cmd3 != NULL)
86  {
87  if ((wcsicmp(pCommand->cmd1, cmdptr->cmd1) == 0) &&
88  (wcsicmp(pCommand->cmd2, cmdptr->cmd2) == 0) &&
89  (wcsicmp(pCommand->cmd3, cmdptr->cmd3) == 0) &&
90  (cmdptr->help_detail != MSG_NONE))
91  {
94  NULL,
95  cmdptr->help_detail,
97  bSubCommands = TRUE;
98  }
99  }
100  }
101 
102  if ((bSubCommands == FALSE) && (pCommand->help_detail != MSG_NONE))
103  {
106  NULL,
107  pCommand->help_detail,
109  }
110 
111  ConPuts(StdOut, L"\n");
112 
113  return TRUE;
114 }
PWSTR cmd2
Definition: diskpart.h:58
#define TRUE
Definition: types.h:120
#define IDS_NONE
Definition: resource.h:124
COMMAND cmds[]
Definition: main.c:21
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
INT WINAPI K32LoadStringW(IN HINSTANCE hInstance OPTIONAL, IN UINT uID, OUT LPWSTR lpBuffer, IN INT nBufferMax)
Definition: utils.c:173
DWORD help_detail
Definition: diskpart.h:62
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: fc.c:16
#define L(x)
Definition: ntvdm.h:50
#define MSG_NONE
Definition: resource.h:12
PWSTR cmd1
Definition: diskpart.h:57
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FORMAT_MESSAGE_FROM_HMODULE
Definition: winbase.h:419
INT help
Definition: diskpart.h:61
__wchar_t WCHAR
Definition: xmlstorage.h:180
INT ConMsgPuts(IN PCON_STREAM Stream, IN DWORD dwFlags, IN LPCVOID lpSource OPTIONAL, IN DWORD dwMessageId, IN DWORD dwLanguageId)
Definition: outstream.c:837
#define wcsicmp
Definition: compat.h:15
void ConPrintf(FILE *fp, LPCWSTR psz,...)
Definition: fc.c:20
#define GetModuleHandle
Definition: winbase.h:3688
#define NULL
Definition: types.h:112
PWSTR cmd3
Definition: diskpart.h:59
#define StdOut
Definition: fc.c:14
#define IDS_HELP_FORMAT_STRING
Definition: resource.h:64
Definition: main.c:14
#define LANG_USER_DEFAULT
Definition: tnerror.cpp:50

Referenced by help_main(), InterpretCmd(), and main().

◆ HelpCommandList()

VOID HelpCommandList ( VOID  )

Definition at line 16 of file help.c.

17 {
18  PCOMMAND cmdptr;
19  WCHAR szFormat[64];
20  WCHAR szOutput[256];
21 
23 
24  /* Print the header information */
26  ConPuts(StdOut, L"\n");
27 
28  /* List all the commands and the basic descriptions */
29  for (cmdptr = cmds; cmdptr->cmd1; cmdptr++)
30  {
31  if ((cmdptr->cmd1 != NULL) &&
32  (cmdptr->cmd2 == NULL) &&
33  (cmdptr->cmd3 == NULL) &&
34  (cmdptr->help != IDS_NONE))
35  {
36  K32LoadStringW(GetModuleHandle(NULL), cmdptr->help, szOutput, ARRAYSIZE(szOutput));
37  ConPrintf(StdOut, szFormat, cmdptr->cmd1, szOutput);
38  }
39  }
40 
41  ConPuts(StdOut, L"\n");
42 }
PWSTR cmd2
Definition: diskpart.h:58
#define IDS_NONE
Definition: resource.h:124
COMMAND cmds[]
Definition: main.c:21
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
INT WINAPI K32LoadStringW(IN HINSTANCE hInstance OPTIONAL, IN UINT uID, OUT LPWSTR lpBuffer, IN INT nBufferMax)
Definition: utils.c:173
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: fc.c:16
#define L(x)
Definition: ntvdm.h:50
PWSTR cmd1
Definition: diskpart.h:57
void ConResPuts(FILE *fp, UINT nID)
Definition: fc.c:27
INT help
Definition: diskpart.h:61
__wchar_t WCHAR
Definition: xmlstorage.h:180
void ConPrintf(FILE *fp, LPCWSTR psz,...)
Definition: fc.c:20
#define GetModuleHandle
Definition: winbase.h:3688
#define NULL
Definition: types.h:112
PWSTR cmd3
Definition: diskpart.h:59
#define IDS_APP_HEADER
Definition: resource.h:14
#define StdOut
Definition: fc.c:14
#define IDS_HELP_FORMAT_STRING
Definition: resource.h:64
Definition: main.c:14

Referenced by help_main(), and InterpretCmd().

◆ import_main()

BOOL import_main ( INT  argc,
LPWSTR argv 
)

Definition at line 11 of file import.c.

12 {
13  return TRUE;
14 }
#define TRUE
Definition: types.h:120

◆ inactive_main()

BOOL inactive_main ( INT  argc,
LPWSTR argv 
)

◆ InterpretCmd()

BOOL InterpretCmd ( INT  argc,
LPWSTR argv 
)

◆ InterpretMain()

VOID InterpretMain ( VOID  )

Definition at line 231 of file interpreter.c.

232 {
233  WCHAR input_line[MAX_STRING_SIZE];
234  LPWSTR args_vector[MAX_ARGS_COUNT];
235  INT args_count = 0;
236  BOOL bWhiteSpace = TRUE;
237  BOOL bQuote = FALSE;
238  BOOL bRun = TRUE;
239  LPWSTR ptr;
240 
241  while (bRun != FALSE)
242  {
243  args_count = 0;
244  memset(args_vector, 0, sizeof(args_vector));
245 
246  /* Shown just before the input where the user places commands */
248 
249  /* Get input from the user. */
250  fgetws(input_line, MAX_STRING_SIZE, stdin);
251 
252  bQuote = FALSE;
253  ptr = input_line;
254  while (*ptr != 0)
255  {
256  if (*ptr == L'"')
257  bQuote = !bQuote;
258 
259  if ((iswspace(*ptr) && (bQuote == FALSE))|| *ptr == L'\n')
260  {
261  *ptr = 0;
262  bWhiteSpace = TRUE;
263  }
264  else
265  {
266  if ((bWhiteSpace != FALSE) && (bQuote == FALSE) && (args_count < MAX_ARGS_COUNT))
267  {
268  args_vector[args_count] = ptr;
269  args_count++;
270  }
271  bWhiteSpace = FALSE;
272  }
273  ptr++;
274  }
275 
276  /* Send the string to find the command */
277  bRun = InterpretCmd(args_count, args_vector);
278  }
279 }
#define TRUE
Definition: types.h:120
FILE * stdin
int32_t INT
Definition: typedefs.h:58
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
static PVOID ptr
Definition: dispmode.c:27
void ConResPuts(FILE *fp, UINT nID)
Definition: fc.c:27
#define MAX_STRING_SIZE
Definition: diskpart.h:75
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define iswspace(_c)
Definition: ctype.h:669
#define IDS_APP_PROMPT
Definition: resource.h:19
BOOL InterpretCmd(int argc, LPWSTR *argv)
Definition: interpreter.c:108
#define MAX_ARGS_COUNT
Definition: diskpart.h:76
#define StdOut
Definition: fc.c:14
wchar_t * fgetws(wchar_t *buf, int bufsize, FILE *file)
Definition: wmain.c:22
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define memset(x, y, z)
Definition: compat.h:39

Referenced by wmain().

◆ InterpretScript()

BOOL InterpretScript ( LPWSTR  line)

Definition at line 183 of file interpreter.c.

184 {
185  LPWSTR args_vector[MAX_ARGS_COUNT];
186  INT args_count = 0;
187  BOOL bWhiteSpace = TRUE;
188  BOOL bQuote = FALSE;
189  LPWSTR ptr;
190 
191  memset(args_vector, 0, sizeof(args_vector));
192 
193  bQuote = FALSE;
194  ptr = input_line;
195  while (*ptr != 0)
196  {
197  if (*ptr == L'"')
198  bQuote = !bQuote;
199 
200  if ((iswspace(*ptr) && (bQuote == FALSE))|| *ptr == L'\n')
201  {
202  *ptr = 0;
203  bWhiteSpace = TRUE;
204  }
205  else
206  {
207  if ((bWhiteSpace != FALSE) && (bQuote == FALSE) && (args_count < MAX_ARGS_COUNT))
208  {
209  args_vector[args_count] = ptr;
210  args_count++;
211  }
212 
213  bWhiteSpace = FALSE;
214  }
215 
216  ptr++;
217  }
218 
219  /* sends the string to find the command */
220  return InterpretCmd(args_count, args_vector);
221 }
#define TRUE
Definition: types.h:120
int32_t INT
Definition: typedefs.h:58
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
static PVOID ptr
Definition: dispmode.c:27
#define iswspace(_c)
Definition: ctype.h:669
BOOL InterpretCmd(int argc, LPWSTR *argv)
Definition: interpreter.c:108
#define MAX_ARGS_COUNT
Definition: diskpart.h:76
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define memset(x, y, z)
Definition: compat.h:39

Referenced by RunScript().

◆ IsDecString()

BOOL IsDecString ( _In_ PWSTR  pszDecString)

Definition at line 14 of file misc.c.

16 {
17  PWSTR ptr;
18 
19  if ((pszDecString == NULL) || (*pszDecString == UNICODE_NULL))
20  return FALSE;
21 
22  ptr = pszDecString;
23  while (*ptr != UNICODE_NULL)
24  {
25  if (!iswdigit(*ptr))
26  return FALSE;
27 
28  ptr++;
29  }
30 
31  return TRUE;
32 }
#define TRUE
Definition: types.h:120
uint16_t * PWSTR
Definition: typedefs.h:56
#define iswdigit(_c)
Definition: ctype.h:667
#define FALSE
Definition: types.h:117
#define UNICODE_NULL
static PVOID ptr
Definition: dispmode.c:27
#define NULL
Definition: types.h:112

Referenced by SelectDisk(), SelectPartition(), and SelectVolume().

◆ IsHexString()

BOOL IsHexString ( _In_ PWSTR  pszHexString)

Definition at line 36 of file misc.c.

38 {
39  PWSTR ptr;
40 
41  if ((pszHexString == NULL) || (*pszHexString == UNICODE_NULL))
42  return FALSE;
43 
44  ptr = pszHexString;
45  while (*ptr != UNICODE_NULL)
46  {
47  if (!iswxdigit(*ptr))
48  return FALSE;
49 
50  ptr++;
51  }
52 
53  return TRUE;
54 }
#define TRUE
Definition: types.h:120
uint16_t * PWSTR
Definition: typedefs.h:56
#define iswxdigit(_c)
Definition: ctype.h:668
#define FALSE
Definition: types.h:117
#define UNICODE_NULL
static PVOID ptr
Definition: dispmode.c:27
#define NULL
Definition: types.h:112

Referenced by UniqueIdDisk().

◆ ListDisk()

BOOL ListDisk ( INT  argc,
PWSTR argv 
)

Definition at line 59 of file list.c.

62 {
64  PDISKENTRY DiskEntry;
65 
66  /* Header labels */
67  ConPuts(StdOut, L"\n");
70 
72  while (Entry != &DiskListHead)
73  {
74  DiskEntry = CONTAINING_RECORD(Entry, DISKENTRY, ListEntry);
75 
76  PrintDisk(DiskEntry);
77 
78  Entry = Entry->Flink;
79  }
80 
81  ConPuts(StdOut, L"\n\n");
82 
83  return TRUE;
84 }
#define IDS_LIST_DISK_LINE
Definition: resource.h:72
struct _Entry Entry
Definition: kefuncs.h:629
#define TRUE
Definition: types.h:120
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: fc.c:16
#define L(x)
Definition: ntvdm.h:50
#define IDS_LIST_DISK_HEAD
Definition: resource.h:71
void ConResPuts(FILE *fp, UINT nID)
Definition: fc.c:27
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
LIST_ENTRY DiskListHead
Definition: partlist.c:70
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
Definition: typedefs.h:119
VOID PrintDisk(_In_ PDISKENTRY DiskEntry)
Definition: list.c:17
#define StdOut
Definition: fc.c:14
base of all file and directory entries
Definition: entries.h:82

◆ ListPartition()

BOOL ListPartition ( INT  argc,
PWSTR argv 
)

Definition at line 88 of file list.c.

91 {
93  PPARTENTRY PartEntry;
94  ULONGLONG PartSize;
95  ULONGLONG PartOffset;
96  LPWSTR lpSizeUnit;
97  LPWSTR lpOffsetUnit;
98  ULONG PartNumber = 1;
99 
100  if (CurrentDisk == NULL)
101  {
103  return TRUE;
104  }
105 
106  /* Header labels */
107  ConPuts(StdOut, L"\n");
110 
113  {
114  PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
115 
116  if (PartEntry->PartitionType != 0)
117  {
118  PartSize = PartEntry->SectorCount.QuadPart * CurrentDisk->BytesPerSector;
119 
120  if (PartSize >= 10737418240) /* 10 GB */
121  {
122  PartSize = RoundingDivide(PartSize, 1073741824);
123  lpSizeUnit = L"GB";
124  }
125  else if (PartSize >= 10485760) /* 10 MB */
126  {
127  PartSize = RoundingDivide(PartSize, 1048576);
128  lpSizeUnit = L"MB";
129  }
130  else
131  {
132  PartSize = RoundingDivide(PartSize, 1024);
133  lpSizeUnit = L"KB";
134  }
135 
136  PartOffset = PartEntry->StartSector.QuadPart * CurrentDisk->BytesPerSector;
137 
138  if (PartOffset >= 10737418240) /* 10 GB */
139  {
140  PartOffset = RoundingDivide(PartOffset, 1073741824);
141  lpOffsetUnit = L"GB";
142  }
143  else if (PartOffset >= 10485760) /* 10 MB */
144  {
145  PartOffset = RoundingDivide(PartOffset, 1048576);
146  lpOffsetUnit = L"MB";
147  }
148  else
149  {
150  PartOffset = RoundingDivide(PartOffset, 1024);
151  lpOffsetUnit = L"KB";
152  }
153 
155  (CurrentPartition == PartEntry) ? L'*' : L' ',
156  PartNumber++,
157  IsContainerPartition(PartEntry->PartitionType) ? L"Extended" : L"Primary",
158  PartSize,
159  lpSizeUnit,
160  PartOffset,
161  lpOffsetUnit);
162  }
163 
164  Entry = Entry->Flink;
165  }
166 
169  {
170  PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
171 
172  if (PartEntry->PartitionType != 0)
173  {
174  PartSize = PartEntry->SectorCount.QuadPart * CurrentDisk->BytesPerSector;
175 
176  if (PartSize >= 10737418240) /* 10 GB */
177  {
178  PartSize = RoundingDivide(PartSize, 1073741824);
179  lpSizeUnit = L"GB";
180  }
181  else if (PartSize >= 10485760) /* 10 MB */
182  {
183  PartSize = RoundingDivide(PartSize, 1048576);
184  lpSizeUnit = L"MB";
185  }
186  else
187  {
188  PartSize = RoundingDivide(PartSize, 1024);
189  lpSizeUnit = L"KB";
190  }
191 
192  PartOffset = PartEntry->StartSector.QuadPart * CurrentDisk->BytesPerSector;
193 
194  if (PartOffset >= 10737418240) /* 10 GB */
195  {
196  PartOffset = RoundingDivide(PartOffset, 1073741824);
197  lpOffsetUnit = L"GB";
198  }
199  else if (PartOffset >= 10485760) /* 10 MB */
200  {
201  PartOffset = RoundingDivide(PartOffset, 1048576);
202  lpOffsetUnit = L"MB";
203  }
204  else
205  {
206  PartOffset = RoundingDivide(PartOffset, 1024);
207  lpOffsetUnit = L"KB";
208  }
209 
211  (CurrentPartition == PartEntry) ? L'*' : L' ',
212  PartNumber++,
213  L"Logical",
214  PartSize,
215  lpSizeUnit,
216  PartOffset,
217  lpOffsetUnit);
218  }
219 
220  Entry = Entry->Flink;
221  }
222 
223  ConPuts(StdOut, L"\n");
224 
225  return TRUE;
226 }
LIST_ENTRY PrimaryPartListHead
Definition: partlist.h:131
ULARGE_INTEGER StartSector
Definition: partlist.h:49
struct _Entry Entry
Definition: kefuncs.h:629
#define TRUE
Definition: types.h:120
ULARGE_INTEGER SectorCount
Definition: partlist.h:50
#define IDS_LIST_PARTITION_LINE
Definition: resource.h:75
static PPARTENTRY CurrentPartition
Definition: usetup.c:76
PDISKENTRY CurrentDisk
Definition: partlist.c:74
#define IsContainerPartition(PartitionType)
Definition: ntdddisk.h:316
#define IDS_LIST_PARTITION_FORMAT
Definition: resource.h:76
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: fc.c:16
#define L(x)
Definition: ntvdm.h:50
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
void ConResPuts(FILE *fp, UINT nID)
Definition: fc.c:27
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
void ConResPrintf(FILE *fp, UINT nID,...)
Definition: fc.c:33
UCHAR PartitionType
Definition: partlist.h:53
ULONG BytesPerSector
Definition: partlist.h:95
uint64_t ULONGLONG
Definition: typedefs.h:67
Definition: typedefs.h:119
ULONGLONG RoundingDivide(IN ULONGLONG Dividend, IN ULONGLONG Divisor)
Definition: partlist.c:95
#define IDS_LIST_PARTITION_NO_DISK
Definition: resource.h:77
#define NULL
Definition: types.h:112
LIST_ENTRY LogicalPartListHead
Definition: partlist.h:132
#define IDS_LIST_PARTITION_HEAD
Definition: resource.h:74
#define StdOut
Definition: fc.c:14
unsigned int ULONG
Definition: retypes.h:1
WCHAR * LPWSTR
Definition: xmlstorage.h:184
base of all file and directory entries
Definition: entries.h:82

◆ ListVirtualDisk()

BOOL ListVirtualDisk ( INT  argc,
PWSTR argv 
)

Definition at line 310 of file list.c.

313 {
314  ConPuts(StdOut, L"ListVirtualDisk()!\n");
315  return TRUE;
316 }
#define TRUE
Definition: types.h:120
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: fc.c:16
#define L(x)
Definition: ntvdm.h:50
#define StdOut
Definition: fc.c:14

◆ ListVolume()

BOOL ListVolume ( INT  argc,
PWSTR argv 
)

Definition at line 282 of file list.c.

285 {
287  PVOLENTRY VolumeEntry;
288 
289  ConPuts(StdOut, L"\n");
292 
294  while (Entry != &VolumeListHead)
295  {
296  VolumeEntry = CONTAINING_RECORD(Entry, VOLENTRY, ListEntry);
297 
298  PrintVolume(VolumeEntry);
299 
300  Entry = Entry->Flink;
301  }
302 
303  ConPuts(StdOut, L"\n");
304 
305  return TRUE;
306 }
struct _Entry Entry
Definition: kefuncs.h:629
#define TRUE
Definition: types.h:120
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: fc.c:16
#define L(x)
Definition: ntvdm.h:50
void ConResPuts(FILE *fp, UINT nID)
Definition: fc.c:27
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
VOID PrintVolume(_In_ PVOLENTRY VolumeEntry)
Definition: list.c:230
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define IDS_LIST_VOLUME_LINE
Definition: resource.h:79
Definition: typedefs.h:119
#define IDS_LIST_VOLUME_HEAD
Definition: resource.h:78
#define StdOut
Definition: fc.c:14
LIST_ENTRY VolumeListHead
Definition: partlist.c:72
base of all file and directory entries
Definition: entries.h:82

◆ merge_main()

BOOL merge_main ( INT  argc,
LPWSTR argv 
)

Definition at line 11 of file merge.c.

12 {
13  return TRUE;
14 }
#define TRUE
Definition: types.h:120

◆ offline_main()

BOOL offline_main ( INT  argc,
LPWSTR argv 
)

Definition at line 11 of file offline.c.

12 {
13  return TRUE;
14 }
#define TRUE
Definition: types.h:120

◆ online_main()

BOOL online_main ( INT  argc,
LPWSTR argv 
)

Definition at line 11 of file online.c.

12 {
13  return TRUE;
14 }
#define TRUE
Definition: types.h:120

◆ PrintDisk()

VOID PrintDisk ( _In_ PDISKENTRY  DiskEntry)

Definition at line 17 of file list.c.

19 {
20  ULONGLONG DiskSize;
21  ULONGLONG FreeSize;
22  LPWSTR lpSizeUnit;
23  LPWSTR lpFreeUnit;
24 
25  DiskSize = DiskEntry->SectorCount.QuadPart *
26  (ULONGLONG)DiskEntry->BytesPerSector;
27 
28  if (DiskSize >= 10737418240) /* 10 GB */
29  {
30  DiskSize = RoundingDivide(DiskSize, 1073741824);
31  lpSizeUnit = L"GB";
32  }
33  else
34  {
35  DiskSize = RoundingDivide(DiskSize, 1048576);
36  if (DiskSize == 0)
37  DiskSize = 1;
38  lpSizeUnit = L"MB";
39  }
40 
41  /* FIXME */
42  FreeSize = 0;
43  lpFreeUnit = L"B";
44 
46  (CurrentDisk == DiskEntry) ? L'*' : L' ',
47  DiskEntry->DiskNumber,
48  L"Online",
49  DiskSize,
50  lpSizeUnit,
51  FreeSize,
52  lpFreeUnit,
53  L" ",
54  L" ");
55 }
PDISKENTRY CurrentDisk
Definition: partlist.c:74
if(dx==0 &&dy==0)
Definition: linetemp.h:174
#define L(x)
Definition: ntvdm.h:50
void ConResPrintf(FILE *fp, UINT nID,...)
Definition: fc.c:33
uint64_t ULONGLONG
Definition: typedefs.h:67
ULONGLONG RoundingDivide(IN ULONGLONG Dividend, IN ULONGLONG Divisor)
Definition: partlist.c:95
#define StdOut
Definition: fc.c:14
#define IDS_LIST_DISK_FORMAT
Definition: resource.h:73
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by DetailVolume(), and ListDisk().

◆ PrintVolume()

VOID PrintVolume ( _In_ PVOLENTRY  VolumeEntry)

Definition at line 230 of file list.c.

232 {
233  ULONGLONG VolumeSize;
234  PWSTR pszSizeUnit;
235  PWSTR pszVolumeType;
236 
237  VolumeSize = VolumeEntry->Size.QuadPart;
238  if (VolumeSize >= 10737418240) /* 10 GB */
239  {
240  VolumeSize = RoundingDivide(VolumeSize, 1073741824);
241  pszSizeUnit = L"GB";
242  }
243  else if (VolumeSize >= 10485760) /* 10 MB */
244  {
245  VolumeSize = RoundingDivide(VolumeSize, 1048576);
246  pszSizeUnit = L"MB";
247  }
248  else
249  {
250  VolumeSize = RoundingDivide(VolumeSize, 1024);
251  pszSizeUnit = L"KB";
252  }
253  switch (VolumeEntry->VolumeType)
254  {
255  case VOLUME_TYPE_CDROM:
256  pszVolumeType = L"DVD";
257  break;
259  pszVolumeType = L"Partition";
260  break;
262  pszVolumeType = L"Removable";
263  break;
264  case VOLUME_TYPE_UNKNOWN:
265  default:
266  pszVolumeType = L"Unknown";
267  break;
268  }
269 
271  (CurrentVolume == VolumeEntry) ? L'*' : L' ',
272  VolumeEntry->VolumeNumber,
273  VolumeEntry->DriveLetter,
274  (VolumeEntry->pszLabel) ? VolumeEntry->pszLabel : L"",
275  (VolumeEntry->pszFilesystem) ? VolumeEntry->pszFilesystem : L"",
276  pszVolumeType,
277  VolumeSize, pszSizeUnit);
278 }
uint16_t * PWSTR
Definition: typedefs.h:56
#define L(x)
Definition: ntvdm.h:50
void ConResPrintf(FILE *fp, UINT nID,...)
Definition: fc.c:33
#define IDS_LIST_VOLUME_FORMAT
Definition: resource.h:80
uint64_t ULONGLONG
Definition: typedefs.h:67
ULONGLONG RoundingDivide(IN ULONGLONG Dividend, IN ULONGLONG Divisor)
Definition: partlist.c:95
#define StdOut
Definition: fc.c:14
PVOLENTRY CurrentVolume
Definition: partlist.c:76

Referenced by DetailDisk(), DetailPartition(), and ListVolume().

◆ recover_main()

BOOL recover_main ( INT  argc,
LPWSTR argv 
)

Definition at line 11 of file recover.c.

12 {
13  return TRUE;
14 }
#define TRUE
Definition: types.h:120

◆ remove_main()

BOOL remove_main ( INT  argc,
LPWSTR argv 
)

Definition at line 11 of file remove.c.

12 {
13  return TRUE;
14 }
#define TRUE
Definition: types.h:120

◆ RemoveVolume()

VOID RemoveVolume ( _In_ PVOLENTRY  VolumeEntry)

Definition at line 2103 of file partlist.c.

2105 {
2106  if (VolumeEntry == NULL)
2107  return;
2108 
2109  if (VolumeEntry == CurrentVolume)
2110  CurrentVolume = NULL;
2111 
2112  RemoveEntryList(&VolumeEntry->ListEntry);
2113 
2114  if (VolumeEntry->pszLabel)
2115  RtlFreeHeap(RtlGetProcessHeap(), 0, VolumeEntry->pszLabel);
2116 
2117  if (VolumeEntry->pszFilesystem)
2118  RtlFreeHeap(RtlGetProcessHeap(), 0, VolumeEntry->pszFilesystem);
2119 
2120  if (VolumeEntry->pExtents)
2121  RtlFreeHeap(RtlGetProcessHeap(), 0, VolumeEntry->pExtents);
2122 
2123  /* Release disk entry */
2124  RtlFreeHeap(RtlGetProcessHeap(), 0, VolumeEntry);
2125 }
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
PVOLENTRY CurrentVolume
Definition: partlist.c:76
#define NULL
Definition: types.h:112

Referenced by clean_main().

◆ repair_main()

BOOL repair_main ( INT  argc,
LPWSTR argv 
)

Definition at line 11 of file repair.c.

12 {
13  ConPuts(StdOut, L"\nTODO: Add code later since Win 7 Home Premium doesn't have this feature.\n");
14  return TRUE;
15 }
#define TRUE
Definition: types.h:120
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: fc.c:16
#define L(x)
Definition: ntvdm.h:50
#define StdOut
Definition: fc.c:14

◆ rescan_main()

BOOL rescan_main ( INT  argc,
LPWSTR argv 
)

Definition at line 11 of file rescan.c.

12 {
19 
20  return TRUE;
21 }
PPARTLIST CreatePartitionList(VOID)
Definition: partlist.c:1847
#define TRUE
Definition: types.h:120
#define IDS_RESCAN_END
Definition: resource.h:83
NTSTATUS CreateVolumeList(VOID)
Definition: partlist.c:1412
#define IDS_RESCAN_START
Definition: resource.h:82
VOID DestroyVolumeList(VOID)
Definition: partlist.c:1450
void ConResPuts(FILE *fp, UINT nID)
Definition: fc.c:27
VOID DestroyPartitionList(IN PPARTLIST List)
Definition: partlist.c:1931
#define StdOut
Definition: fc.c:14

◆ retain_main()

BOOL retain_main ( INT  argc,
LPWSTR argv 
)

Definition at line 11 of file retain.c.

12 {
13  return TRUE;
14 }
#define TRUE
Definition: types.h:120

◆ RoundingDivide()

ULONGLONG RoundingDivide ( _In_ ULONGLONG  Dividend,
_In_ ULONGLONG  Divisor 
)

Definition at line 75 of file misc.c.

78 {
79  return (Dividend + Divisor / 2) / Divisor;
80 }
_In_ LARGE_INTEGER Divisor
Definition: rtlfuncs.h:3044

◆ san_main()

BOOL san_main ( INT  argc,
LPWSTR argv 
)

Definition at line 11 of file san.c.

12 {
13  return TRUE;
14 }
#define TRUE
Definition: types.h:120

◆ SelectDisk()

BOOL SelectDisk ( INT  argc,
PWSTR argv 
)

Definition at line 17 of file select.c.

20 {
22  PDISKENTRY DiskEntry;
23  ULONG ulValue;
24 
25  DPRINT("Select Disk()\n");
26 
27  if (argc > 3)
28  {
30  return TRUE;
31  }
32 
33  if (argc == 2)
34  {
35  if (CurrentDisk == NULL)
37  else
39  return TRUE;
40  }
41 
42  if (!IsDecString(argv[2]))
43  {
45  return TRUE;
46  }
47 
48  ulValue = wcstoul(argv[2], NULL, 10);
49  if ((ulValue == 0) && (errno == ERANGE))
50  {
52  return TRUE;
53  }
54 
55  CurrentDisk = NULL;
56 
58  while (Entry != &DiskListHead)
59  {
60  DiskEntry = CONTAINING_RECORD(Entry, DISKENTRY, ListEntry);
61 
62  if (DiskEntry->DiskNumber == ulValue)
63  {
64  CurrentDisk = DiskEntry;
67  return TRUE;
68  }
69 
70  Entry = Entry->Flink;
71  }
72 
74  return TRUE;
75 }
static int argc
Definition: ServiceArgs.c:12
struct _Entry Entry
Definition: kefuncs.h:629
#define IDS_SELECT_DISK_INVALID
Definition: resource.h:87
#define TRUE
Definition: types.h:120
ULONG DiskNumber
Definition: partlist.h:111
static PPARTENTRY CurrentPartition
Definition: usetup.c:76
PDISKENTRY CurrentDisk
Definition: partlist.c:74
int errno
_Check_return_ unsigned long __cdecl wcstoul(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
#define argv
Definition: mplay32.c:18
#define IDS_ERROR_INVALID_ARGS
Definition: resource.h:187
void ConResPuts(FILE *fp, UINT nID)
Definition: fc.c:27
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
LIST_ENTRY DiskListHead
Definition: partlist.c:70
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
void ConResPrintf(FILE *fp, UINT nID,...)
Definition: fc.c:33
#define IDS_SELECT_NO_DISK
Definition: resource.h:85
#define ERANGE
Definition: acclib.h:92
Definition: typedefs.h:119
#define NULL
Definition: types.h:112
#define IDS_SELECT_DISK
Definition: resource.h:86
#define StdOut
Definition: fc.c:14
unsigned int ULONG
Definition: retypes.h:1
#define DPRINT
Definition: sndvol32.h:71
base of all file and directory entries
Definition: entries.h:82
BOOL IsDecString(_In_ PWSTR pszDecString)
Definition: misc.c:14
#define StdErr
Definition: fc.c:15

◆ SelectPartition()

BOOL SelectPartition ( INT  argc,
PWSTR argv 
)

Definition at line 79 of file select.c.

82 {
84  PPARTENTRY PartEntry;
85  ULONG ulValue;
86  ULONG PartNumber = 1;
87 
88  DPRINT("Select Partition()\n");
89 
90  if (argc > 3)
91  {
93  return TRUE;
94  }
95 
96  if (CurrentDisk == NULL)
97  {
99  return TRUE;
100  }
101 
102  if (argc == 2)
103  {
104  if (CurrentPartition == NULL)
106  else
108  return TRUE;
109  }
110 
111  if (!IsDecString(argv[2]))
112  {
114  return TRUE;
115  }
116 
117  ulValue = wcstoul(argv[2], NULL, 10);
118  if ((ulValue == 0) && (errno == ERANGE))
119  {
121  return TRUE;
122  }
123 
126  {
127  PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
128 
129  if (PartEntry->PartitionType != 0)
130  {
131  if (PartNumber == ulValue)
132  {
133  CurrentPartition = PartEntry;
135  return TRUE;
136  }
137 
138  PartNumber++;
139  }
140 
141  Entry = Entry->Flink;
142  }
143 
146  {
147  PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
148 
149  if (PartEntry->PartitionType != 0)
150  {
151  if (PartNumber == ulValue)
152  {
153  CurrentPartition = PartEntry;
155  return TRUE;
156  }
157 
158  PartNumber++;
159  }
160  Entry = Entry->Flink;
161  }
162 
164  return TRUE;
165 }
#define IDS_SELECT_PARTITION_INVALID
Definition: resource.h:91
LIST_ENTRY PrimaryPartListHead
Definition: partlist.h:131
#define IDS_SELECT_NO_PARTITION
Definition: resource.h:88
static int argc
Definition: ServiceArgs.c:12
struct _Entry Entry
Definition: kefuncs.h:629
#define TRUE
Definition: types.h:120
static PPARTENTRY CurrentPartition
Definition: usetup.c:76
PDISKENTRY CurrentDisk
Definition: partlist.c:74
int errno
_Check_return_ unsigned long __cdecl wcstoul(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
#define argv
Definition: mplay32.c:18
#define IDS_SELECT_PARTITION
Definition: resource.h:89
#define IDS_ERROR_INVALID_ARGS
Definition: resource.h:187
void ConResPuts(FILE *fp, UINT nID)
Definition: fc.c:27
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
void ConResPrintf(FILE *fp, UINT nID,...)
Definition: fc.c:33
UCHAR PartitionType
Definition: partlist.h:53
#define ERANGE
Definition: acclib.h:92
#define IDS_SELECT_PARTITION_NO_DISK
Definition: resource.h:90
Definition: typedefs.h:119
#define NULL
Definition: types.h:112
LIST_ENTRY LogicalPartListHead
Definition: partlist.h:132
#define StdOut
Definition: fc.c:14
unsigned int ULONG
Definition: retypes.h:1
#define DPRINT
Definition: sndvol32.h:71
base of all file and directory entries
Definition: entries.h:82
BOOL IsDecString(_In_ PWSTR pszDecString)
Definition: misc.c:14
#define StdErr
Definition: fc.c:15

◆ SelectVolume()

BOOL SelectVolume ( INT  argc,
PWSTR argv 
)

Definition at line 169 of file select.c.

172 {
174  PVOLENTRY VolumeEntry;
175  ULONG ulValue;
176 
177  DPRINT("SelectVolume()\n");
178 
179  if (argc > 3)
180  {
182  return TRUE;
183  }
184 
185  if (