ReactOS  0.4.15-dev-4570-g4f8bbd1
diskpart.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <windef.h>
#include <winbase.h>
#include <winreg.h>
#include <wincon.h>
#include <errno.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 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
}
 

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 (INT argc, PWSTR *argv)
 
BOOL CreateLogicalPartition (INT argc, PWSTR *argv)
 
BOOL CreatePrimaryPartition (INT argc, PWSTR *argv)
 
BOOL delete_main (INT argc, LPWSTR *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 dump_main (INT argc, 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)
 
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)
 
BOOL offline_main (INT argc, LPWSTR *argv)
 
BOOL online_main (INT argc, LPWSTR *argv)
 
NTSTATUS CreatePartitionList (VOID)
 
VOID DestroyPartitionList (VOID)
 
NTSTATUS CreateVolumeList (VOID)
 
VOID DestroyVolumeList (VOID)
 
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 74 of file diskpart.h.

◆ MAX_STRING_SIZE

#define MAX_STRING_SIZE   1024

Definition at line 73 of file diskpart.h.

◆ NTOS_MODE_USER

#define NTOS_MODE_USER

Definition at line 37 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

◆ VOLENTRY

Enumeration Type Documentation

◆ _FORMATSTATE

Enumerator
Unformatted 
UnformattedOrDamaged 
UnknownFormat 
Preformatted 
Formatted 
Unformatted 
UnformattedOrDamaged 
UnknownFormat 
Preformatted 
Formatted 

Definition at line 77 of file diskpart.h.

78 {
83  Formatted
enum _FORMATSTATE * PFORMATSTATE
enum _FORMATSTATE FORMATSTATE

Function Documentation

◆ active_main()

BOOL active_main ( INT  argc,
LPWSTR argv 
)

Definition at line 11 of file active.c.

12 {
13  ConPuts(StdOut, L"\nActive\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

◆ 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

◆ 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 
)

Definition at line 11 of file clean.c.

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

◆ 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 ( INT  argc,
PWSTR argv 
)

Definition at line 12 of file create.c.

15 {
16  if (CurrentDisk == NULL)
17  {
19  return TRUE;
20  }
21 
22  ConPrintf(StdOut, L"Not implemented yet!\n");
23 
24  return TRUE;
25 }
#define TRUE
Definition: types.h:120
PDISKENTRY CurrentDisk
Definition: partlist.c:74
#define L(x)
Definition: ntvdm.h:50
void ConResPuts(FILE *fp, UINT nID)
Definition: fc.c:27
#define IDS_SELECT_NO_DISK
Definition: resource.h:57
void ConPrintf(FILE *fp, LPCWSTR psz,...)
Definition: fc.c:20
#define NULL
Definition: types.h:112
#define StdOut
Definition: fc.c:14

◆ CreateLogicalPartition()

BOOL CreateLogicalPartition ( INT  argc,
PWSTR argv 
)

Definition at line 29 of file create.c.

32 {
33  if (CurrentDisk == NULL)
34  {
36  return TRUE;
37  }
38 
39  ConPrintf(StdOut, L"Not implemented yet!\n");
40 
41  return TRUE;
42 }
#define TRUE
Definition: types.h:120
PDISKENTRY CurrentDisk
Definition: partlist.c:74
#define L(x)
Definition: ntvdm.h:50
void ConResPuts(FILE *fp, UINT nID)
Definition: fc.c:27
#define IDS_SELECT_NO_DISK
Definition: resource.h:57
void ConPrintf(FILE *fp, LPCWSTR psz,...)
Definition: fc.c:20
#define NULL
Definition: types.h:112
#define StdOut
Definition: fc.c:14

◆ 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
HANDLE FileHandle
Definition: stats.c:38
#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:3401
#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
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 ( INT  argc,
PWSTR argv 
)

Definition at line 46 of file create.c.

49 {
50  LARGE_INTEGER liSize, liOffset;
51  INT i;
52 // BOOL bNoErr = FALSE;
53  PWSTR pszSuffix = NULL;
54 
55  liSize.QuadPart = -1;
56  liOffset.QuadPart = -1;
57 
58 /*
59  if (CurrentDisk == NULL)
60  {
61  ConResPuts(StdOut, IDS_SELECT_NO_DISK);
62  return TRUE;
63  }
64 */
65 
66  for (i = 3; i < argc; i++)
67  {
68  if (HasPrefix(argv[i], L"size=", &pszSuffix))
69  {
70  /* size=<N> (MB) */
71  ConPrintf(StdOut, L"Size : %s\n", pszSuffix);
72 
73  liSize.QuadPart = _wcstoui64(pszSuffix, NULL, 10);
74  if (((liSize.QuadPart == 0) && (errno == ERANGE)) ||
75  (liSize.QuadPart < 0))
76  {
78  return TRUE;
79  }
80  }
81  else if (HasPrefix(argv[i], L"offset=", &pszSuffix))
82  {
83  /* offset=<N> (KB) */
84  ConPrintf(StdOut, L"Offset : %s\n", pszSuffix);
85 
86  liOffset.QuadPart = _wcstoui64(pszSuffix, NULL, 10);
87  if (((liOffset.QuadPart == 0) && (errno == ERANGE)) ||
88  (liOffset.QuadPart < 0))
89  {
91  return TRUE;
92  }
93  }
94  else if (HasPrefix(argv[i], L"id=", &pszSuffix))
95  {
96  /* id=<Byte>|<GUID> */
97  ConPrintf(StdOut, L"Id : %s\n", pszSuffix);
98  }
99  else if (HasPrefix(argv[i], L"align=", &pszSuffix))
100  {
101  /* align=<N> */
102  ConPrintf(StdOut, L"Align : %s\n", pszSuffix);
103  }
104  else if (_wcsicmp(argv[i], L"noerr") == 0)
105  {
106  /* noerr */
107  ConPrintf(StdOut, L"NoErr\n", pszSuffix);
108 // bNoErr = TRUE;
109  }
110  else
111  {
113  return TRUE;
114  }
115  }
116 
117  ConPrintf(StdOut, L"Size: %I64d\n", liSize.QuadPart);
118  ConPrintf(StdOut, L"Offset: %I64d\n", liOffset.QuadPart);
119 
120  return TRUE;
121 }
static int argc
Definition: ServiceArgs.c:12
BOOL HasPrefix(_In_ PWSTR pszString, _In_ PWSTR pszPrefix, _Out_opt_ PWSTR *pszSuffix)
Definition: misc.c:58
#define TRUE
Definition: types.h:120
uint16_t * PWSTR
Definition: typedefs.h:56
__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)
int errno
#define argv
Definition: mplay32.c:18
int32_t INT
Definition: typedefs.h:58
#define IDS_ERROR_INVALID_ARGS
Definition: resource.h:201
#define L(x)
Definition: ntvdm.h:50
void ConResPuts(FILE *fp, UINT nID)
Definition: fc.c:27
#define ERANGE
Definition: acclib.h:92
void ConPrintf(FILE *fp, LPCWSTR psz,...)
Definition: fc.c:20
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 StdOut
Definition: fc.c:14
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
LONGLONG QuadPart
Definition: typedefs.h:114
#define StdErr
Definition: fc.c:15

◆ CreateVolumeList()

NTSTATUS CreateVolumeList ( VOID  )

Definition at line 1250 of file partlist.c.

1251 {
1252  HANDLE hVolume = INVALID_HANDLE_VALUE;
1253  WCHAR szVolumeName[MAX_PATH];
1254  ULONG ulVolumeNumber = 0;
1255  BOOL Success;
1256 
1257  CurrentVolume = NULL;
1258 
1260 
1261  hVolume = FindFirstVolumeW(szVolumeName, ARRAYSIZE(szVolumeName));
1262  if (hVolume == INVALID_HANDLE_VALUE)
1263  {
1264 
1265  return STATUS_UNSUCCESSFUL;
1266  }
1267 
1268  AddVolumeToList(ulVolumeNumber++, szVolumeName);
1269 
1270  for (;;)
1271  {
1272  Success = FindNextVolumeW(hVolume, szVolumeName, ARRAYSIZE(szVolumeName));
1273  if (!Success)
1274  {
1275  break;
1276  }
1277 
1278  AddVolumeToList(ulVolumeNumber++, szVolumeName);
1279  }
1280 
1281  FindVolumeClose(hVolume);
1282 
1283  return STATUS_SUCCESS;
1284 }
#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:1182
BOOL WINAPI FindVolumeClose(IN HANDLE hFindVolume)
Definition: volume.c:741

Referenced by rescan_main(), and wmain().

◆ delete_main()

BOOL delete_main ( INT  argc,
LPWSTR argv 
)

Definition at line 11 of file delete.c.

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

◆ DestroyPartitionList()

VOID DestroyPartitionList ( VOID  )

Definition at line 1123 of file partlist.c.

1124 {
1125  PDISKENTRY DiskEntry;
1126  PBIOSDISKENTRY BiosDiskEntry;
1127  PPARTENTRY PartEntry;
1129 
1130  CurrentDisk = NULL;
1132 
1133  /* Release disk and partition info */
1134  while (!IsListEmpty(&DiskListHead))
1135  {
1137  DiskEntry = CONTAINING_RECORD(Entry, DISKENTRY, ListEntry);
1138 
1139  /* Release driver name */
1140  RtlFreeUnicodeString(&DiskEntry->DriverName);
1141 
1142  /* Release primary partition list */
1143  while (!IsListEmpty(&DiskEntry->PrimaryPartListHead))
1144  {
1145  Entry = RemoveHeadList(&DiskEntry->PrimaryPartListHead);
1146  PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
1147 
1148  RtlFreeHeap(RtlGetProcessHeap(), 0, PartEntry);
1149  }
1150 
1151  /* Release logical partition list */
1152  while (!IsListEmpty(&DiskEntry->LogicalPartListHead))
1153  {
1154  Entry = RemoveHeadList(&DiskEntry->LogicalPartListHead);
1155  PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
1156 
1157  RtlFreeHeap(RtlGetProcessHeap(), 0, PartEntry);
1158  }
1159 
1160  /* Release layout buffer */
1161  if (DiskEntry->LayoutBuffer != NULL)
1162  RtlFreeHeap(RtlGetProcessHeap(), 0, DiskEntry->LayoutBuffer);
1163 
1164 
1165  /* Release disk entry */
1166  RtlFreeHeap(RtlGetProcessHeap(), 0, DiskEntry);
1167  }
1168 
1169  /* Release the bios disk info */
1170  while (!IsListEmpty(&BiosDiskListHead))
1171  {
1173  BiosDiskEntry = CONTAINING_RECORD(Entry, BIOSDISKENTRY, ListEntry);
1174 
1175  RtlFreeHeap(RtlGetProcessHeap(), 0, BiosDiskEntry);
1176  }
1177 }
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 1288 of file partlist.c.

1289 {
1291  PVOLENTRY VolumeEntry;
1292 
1293  CurrentVolume = NULL;
1294 
1295  /* Release disk and partition info */
1296  while (!IsListEmpty(&VolumeListHead))
1297  {
1299  VolumeEntry = CONTAINING_RECORD(Entry, VOLENTRY, ListEntry);
1300 
1301  if (VolumeEntry->pszLabel)
1302  RtlFreeHeap(RtlGetProcessHeap(), 0, VolumeEntry->pszLabel);
1303 
1304  if (VolumeEntry->pszFilesystem)
1305  RtlFreeHeap(RtlGetProcessHeap(), 0, VolumeEntry->pszFilesystem);
1306 
1307  /* Release disk entry */
1308  RtlFreeHeap(RtlGetProcessHeap(), 0, VolumeEntry);
1309  }
1310 }
struct _Entry Entry
Definition: kefuncs.h:629
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
PWSTR pszLabel
Definition: diskpart.h:187
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:188
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 
)

Definition at line 17 of file detail.c.

20 {
21  DPRINT("DetailDisk()\n");
22 
23  if (argc > 2)
24  {
26  return TRUE;
27  }
28 
29  if (CurrentDisk == NULL)
30  {
32  return TRUE;
33  }
34 
35  /* TODO: Print more disk details */
36  ConPuts(StdOut, L"\n");
41  ConPuts(StdOut, L"\n");
42 
43  return TRUE;
44 }
USHORT TargetId
Definition: diskpart.h:158
static int argc
Definition: ServiceArgs.c:12
#define TRUE
Definition: types.h:120
#define IDS_DETAIL_INFO_TARGET
Definition: resource.h:24
PDISKENTRY CurrentDisk
Definition: partlist.c:74
#define IDS_DETAIL_INFO_DISK_ID
Definition: resource.h:20
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: fc.c:16
#define IDS_ERROR_INVALID_ARGS
Definition: resource.h:201
#define L(x)
Definition: ntvdm.h:50
void ConResPuts(FILE *fp, UINT nID)
Definition: fc.c:27
USHORT Lun
Definition: diskpart.h:159
void ConResPrintf(FILE *fp, UINT nID,...)
Definition: fc.c:33
#define IDS_SELECT_NO_DISK
Definition: resource.h:57
USHORT PathId
Definition: diskpart.h:157
#define IDS_DETAIL_INFO_LUN_ID
Definition: resource.h:25
#define NULL
Definition: types.h:112
#define StdOut
Definition: fc.c:14
#define IDS_DETAIL_INFO_PATH
Definition: resource.h:23
#define DPRINT
Definition: sndvol32.h:71
PDRIVE_LAYOUT_INFORMATION LayoutBuffer
Definition: partlist.h:125
#define StdErr
Definition: fc.c:15

◆ DetailPartition()

BOOL DetailPartition ( INT  argc,
PWSTR argv 
)

Definition at line 48 of file detail.c.

51 {
52  PPARTENTRY PartEntry;
53  ULONGLONG PartOffset;
54 
55  DPRINT("DetailPartition()\n");
56 
57  if (argc > 2)
58  {
60  return TRUE;
61  }
62 
63  if (CurrentDisk == NULL)
64  {
66  return TRUE;
67  }
68 
69  if (CurrentPartition == NULL)
70  {
72  return TRUE;
73  }
74 
75  PartEntry = CurrentPartition;
76  PartOffset = PartEntry->StartSector.QuadPart * CurrentDisk->BytesPerSector;
77 
78  /* TODO: Print more partition details */
79  ConPuts(StdOut, L"\n");
85  ConPuts(StdOut, L"\n");
86 
87  return TRUE;
88 }
#define IDS_SELECT_NO_PARTITION
Definition: resource.h:60
static int argc
Definition: ServiceArgs.c:12
#define IDS_DETAIL_PARTITION_ACTIVE
Definition: resource.h:38
ULONG PartitionNumber
Definition: partlist.h:55
ULARGE_INTEGER StartSector
Definition: partlist.h:49
#define TRUE
Definition: types.h:120
static PPARTENTRY CurrentPartition
Definition: usetup.c:76
PDISKENTRY CurrentDisk
Definition: partlist.c:74
#define IDS_DETAIL_PARTITION_NUMBER
Definition: resource.h:35
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: fc.c:16
#define IDS_ERROR_INVALID_ARGS
Definition: resource.h:201
#define L(x)
Definition: ntvdm.h:50
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
#define IDS_DETAIL_PARTITION_TYPE
Definition: resource.h:36
void ConResPuts(FILE *fp, UINT nID)
Definition: fc.c:27
void ConResPrintf(FILE *fp, UINT nID,...)
Definition: fc.c:33
UCHAR PartitionType
Definition: partlist.h:53
ULONG BytesPerSector
Definition: partlist.h:95
#define IDS_DETAIL_PARTITION_OFFSET
Definition: resource.h:39
uint64_t ULONGLONG
Definition: typedefs.h:67
#define IDS_SELECT_PARTITION_NO_DISK
Definition: resource.h:62
#define NULL
Definition: types.h:112
BOOLEAN BootIndicator
Definition: partlist.h:52
#define StdOut
Definition: fc.c:14
#define IDS_DETAIL_PARTITION_HIDDEN
Definition: resource.h:37
#define DPRINT
Definition: sndvol32.h:71
#define StdErr
Definition: fc.c:15

◆ DetailVolume()

BOOL DetailVolume ( INT  argc,
PWSTR argv 
)

Definition at line 92 of file detail.c.

95 {
96  DPRINT("DetailVolume()\n");
97 
98  if (argc > 2)
99  {
101  return TRUE;
102  }
103 
104  if (CurrentVolume == NULL)
105  {
107  return TRUE;
108  }
109 
110  /* TODO: Print volume details */
111 
112  return TRUE;
113 }
static int argc
Definition: ServiceArgs.c:12
#define TRUE
Definition: types.h:120
#define IDS_SELECT_NO_VOLUME
Definition: resource.h:64
#define IDS_ERROR_INVALID_ARGS
Definition: resource.h:201
void ConResPuts(FILE *fp, UINT nID)
Definition: fc.c:27
#define NULL
Definition: types.h:112
#define StdOut
Definition: fc.c:14
PVOLENTRY CurrentVolume
Definition: partlist.c:76
#define DPRINT
Definition: sndvol32.h:71
#define StdErr
Definition: fc.c:15

◆ dump_main()

BOOL dump_main ( INT  argc,
LPWSTR argv 
)

◆ 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 
)

Definition at line 11 of file filesystems.c.

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

◆ 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

◆ 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(), CreatePrimaryPartition(), and UniqueIdDisk().

◆ help_main()

BOOL help_main ( INT  argc,
LPWSTR argv 
)

Definition at line 102 of file help.c.

103 {
104  PCOMMAND cmdptr;
105  PCOMMAND cmdptr1 = NULL;
106  PCOMMAND cmdptr2 = NULL;
107  PCOMMAND cmdptr3 = NULL;
108 
109  if (argc == 1)
110  {
111  HelpCommandList();
112  return TRUE;
113  }
114 
115  /* Scan internal command table */
116  for (cmdptr = cmds; cmdptr->cmd1; cmdptr++)
117  {
118  if ((cmdptr1 == NULL) &&
119  (wcsicmp(argv[1], cmdptr->cmd1) == 0))
120  cmdptr1 = cmdptr;
121 
122  if ((cmdptr2 == NULL) &&
123  (argc >= 3) &&
124  (wcsicmp(argv[1], cmdptr->cmd1) == 0) &&
125  (wcsicmp(argv[2], cmdptr->cmd2) == 0))
126  cmdptr2 = cmdptr;
127 
128  if ((cmdptr3 == NULL) &&
129  (argc >= 4) &&
130  (wcsicmp(argv[1], cmdptr->cmd1) == 0) &&
131  (wcsicmp(argv[2], cmdptr->cmd2) == 0) &&
132  (wcsicmp(argv[3], cmdptr->cmd3) == 0))
133  cmdptr3 = cmdptr;
134  }
135 
136  if (cmdptr3 != NULL)
137  {
138  return HelpCommand(cmdptr3);
139  }
140  else if (cmdptr2 != NULL)
141  {
142  return HelpCommand(cmdptr2);
143  }
144  else if (cmdptr1 != NULL)
145  {
146  return HelpCommand(cmdptr1);
147  }
148 
149  HelpCommandList();
150 
151  return TRUE;
152 }
PWSTR cmd2
Definition: diskpart.h:56
static int argc
Definition: ServiceArgs.c:12
BOOL HelpCommand(PCOMMAND pCommand)
Definition: help.c:43
#define TRUE
Definition: types.h:120
COMMAND cmds[]
Definition: main.c:21
#define argv
Definition: mplay32.c:18
PWSTR cmd1
Definition: diskpart.h:55
#define wcsicmp
Definition: compat.h:15
#define NULL
Definition: types.h:112
PWSTR cmd3
Definition: diskpart.h:57
VOID HelpCommandList(VOID)
Definition: help.c:16
Definition: main.c:14

◆ HelpCommand()

BOOL HelpCommand ( PCOMMAND  pCommand)

Definition at line 43 of file help.c.

45 {
46  PCOMMAND cmdptr;
47  BOOL bSubCommands = FALSE;
48  WCHAR szFormat[64];
49  WCHAR szOutput[256];
50 
52 
53  ConPuts(StdOut, L"\n");
54 
55  /* List all the commands and the basic descriptions */
56  for (cmdptr = cmds; cmdptr->cmd1; cmdptr++)
57  {
58  if (pCommand->cmd1 != NULL && pCommand->cmd2 == NULL && pCommand->cmd3 == NULL)
59  {
60  if (wcsicmp(pCommand->cmd1, cmdptr->cmd1) == 0 && cmdptr->cmd2 != NULL && cmdptr->cmd3 == NULL)
61  {
62  K32LoadStringW(GetModuleHandle(NULL), cmdptr->help, szOutput, ARRAYSIZE(szOutput));
63  ConPrintf(StdOut, szFormat, cmdptr->cmd2, szOutput);
64  bSubCommands = TRUE;
65  }
66  }
67  else if (pCommand->cmd1 != NULL && pCommand->cmd2 != NULL && pCommand->cmd3 == NULL)
68  {
69  if ((wcsicmp(pCommand->cmd1, cmdptr->cmd1) == 0) &&
70  (wcsicmp(pCommand->cmd2, cmdptr->cmd2) == 0) &&
71  (cmdptr->cmd3 != NULL))
72  {
73  K32LoadStringW(GetModuleHandle(NULL), cmdptr->help, szOutput, ARRAYSIZE(szOutput));
74  ConPrintf(StdOut, szFormat, cmdptr->cmd3, szOutput);
75  bSubCommands = TRUE;
76  }
77  }
78  else if (pCommand->cmd1 != NULL && pCommand->cmd2 != NULL && pCommand->cmd3 != NULL)
79  {
80  if ((wcsicmp(pCommand->cmd1, cmdptr->cmd1) == 0) &&
81  (wcsicmp(pCommand->cmd2, cmdptr->cmd2) == 0) &&
82  (wcsicmp(pCommand->cmd3, cmdptr->cmd3) == 0) &&
83  (cmdptr->help_detail != IDS_NONE))
84  ConResPuts(StdOut, cmdptr->help_detail);
85  }
86  }
87 
88  if ((bSubCommands == FALSE) && (pCommand->help_detail != IDS_NONE))
89  {
90  ConResPuts(StdOut, pCommand->help_detail);
91  }
92 
93  ConPuts(StdOut, L"\n");
94 
95  return TRUE;
96 }
PWSTR cmd2
Definition: diskpart.h:56
#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
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: fc.c:16
#define L(x)
Definition: ntvdm.h:50
INT help_detail
Definition: diskpart.h:60
PWSTR cmd1
Definition: diskpart.h:55
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
void ConResPuts(FILE *fp, UINT nID)
Definition: fc.c:27
INT help
Definition: diskpart.h:59
__wchar_t WCHAR
Definition: xmlstorage.h:180
#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:57
#define StdOut
Definition: fc.c:14
#define IDS_HELP_FORMAT_STRING
Definition: resource.h:41
Definition: main.c:14

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 && cmdptr->cmd2 == NULL && cmdptr->cmd3 == NULL)
32  {
33  K32LoadStringW(GetModuleHandle(NULL), cmdptr->help, szOutput, ARRAYSIZE(szOutput));
34  ConPrintf(StdOut, szFormat, cmdptr->cmd1, szOutput);
35  }
36  }
37 
38  ConPuts(StdOut, L"\n");
39 }
PWSTR cmd2
Definition: diskpart.h:56
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:55
void ConResPuts(FILE *fp, UINT nID)
Definition: fc.c:27
INT help
Definition: diskpart.h:59
__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:57
#define IDS_APP_HEADER
Definition: resource.h:13
#define StdOut
Definition: fc.c:14
#define IDS_HELP_FORMAT_STRING
Definition: resource.h:41
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 
)

Definition at line 11 of file inactive.c.

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

◆ InterpretCmd()

BOOL InterpretCmd ( INT  argc,
LPWSTR argv 
)

◆ InterpretMain()

VOID InterpretMain ( VOID  )

Definition at line 218 of file interpreter.c.

219 {
220  WCHAR input_line[MAX_STRING_SIZE];
221  LPWSTR args_vector[MAX_ARGS_COUNT];
222  INT args_count = 0;
223  BOOL bWhiteSpace = TRUE;
224  BOOL bRun = TRUE;
225  LPWSTR ptr;
226 
227  while (bRun != FALSE)
228  {
229  args_count = 0;
230  memset(args_vector, 0, sizeof(args_vector));
231 
232  /* Shown just before the input where the user places commands */
234 
235  /* Get input from the user. */
236  fgetws(input_line, MAX_STRING_SIZE, stdin);
237 
238  ptr = input_line;
239  while (*ptr != 0)
240  {
241  if (iswspace(*ptr) || *ptr == L'\n')
242  {
243  *ptr = 0;
244  bWhiteSpace = TRUE;
245  }
246  else
247  {
248  if ((bWhiteSpace != FALSE) && (args_count < MAX_ARGS_COUNT))
249  {
250  args_vector[args_count] = ptr;
251  args_count++;
252  }
253  bWhiteSpace = FALSE;
254  }
255  ptr++;
256  }
257 
258  /* Send the string to find the command */
259  bRun = InterpretCmd(args_count, args_vector);
260  }
261 }
#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:73
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define iswspace(_c)
Definition: ctype.h:669
#define IDS_APP_PROMPT
Definition: resource.h:18
BOOL InterpretCmd(int argc, LPWSTR *argv)
Definition: interpreter.c:100
#define MAX_ARGS_COUNT
Definition: diskpart.h:74
#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 175 of file interpreter.c.

176 {
177  LPWSTR args_vector[MAX_ARGS_COUNT];
178  INT args_count = 0;
179  BOOL bWhiteSpace = TRUE;
180  LPWSTR ptr;
181 
182  memset(args_vector, 0, sizeof(args_vector));
183 
184  ptr = input_line;
185  while (*ptr != 0)
186  {
187  if (iswspace(*ptr) || *ptr == L'\n')
188  {
189  *ptr = 0;
190  bWhiteSpace = TRUE;
191  }
192  else
193  {
194  if ((bWhiteSpace != FALSE) && (args_count < MAX_ARGS_COUNT))
195  {
196  args_vector[args_count] = ptr;
197  args_count++;
198  }
199 
200  bWhiteSpace = FALSE;
201  }
202 
203  ptr++;
204  }
205 
206  /* sends the string to find the command */
207  return InterpretCmd(args_count, args_vector);
208 }
#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:100
#define MAX_ARGS_COUNT
Definition: diskpart.h:74
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 17 of file list.c.

20 {
22  PDISKENTRY DiskEntry;
23  ULONGLONG DiskSize;
24  ULONGLONG FreeSize;
25  LPWSTR lpSizeUnit;
26  LPWSTR lpFreeUnit;
27 
28  /* Header labels */
31 
33  while (Entry != &DiskListHead)
34  {
35  DiskEntry = CONTAINING_RECORD(Entry, DISKENTRY, ListEntry);
36 
37  DiskSize = DiskEntry->SectorCount.QuadPart *
38  (ULONGLONG)DiskEntry->BytesPerSector;
39 
40  if (DiskSize >= 10737418240) /* 10 GB */
41  {
42  DiskSize = RoundingDivide(DiskSize, 1073741824);
43  lpSizeUnit = L"GB";
44  }
45  else
46  {
47  DiskSize = RoundingDivide(DiskSize, 1048576);
48  if (DiskSize == 0)
49  DiskSize = 1;
50  lpSizeUnit = L"MB";
51  }
52 
53  /* FIXME */
54  FreeSize = 0;
55  lpFreeUnit = L"B";
56 
58  (CurrentDisk == DiskEntry) ? L'*': ' ',
59  DiskEntry->DiskNumber,
60  L"Online",
61  DiskSize,
62  lpSizeUnit,
63  FreeSize,
64  lpFreeUnit,
65  L" ",
66  L" ");
67 
68  Entry = Entry->Flink;
69  }
70 
71  ConPuts(StdOut, L"\n\n");
72 
73  return TRUE;
74 }
#define IDS_LIST_DISK_LINE
Definition: resource.h:44
struct _Entry Entry
Definition: kefuncs.h:629
#define TRUE
Definition: types.h:120
ULONG DiskNumber
Definition: partlist.h:111
PDISKENTRY CurrentDisk
Definition: partlist.c:74
if(dx==0 &&dy==0)
Definition: linetemp.h:174
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: fc.c:16
#define L(x)
Definition: ntvdm.h:50
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
#define IDS_LIST_DISK_HEAD
Definition: resource.h:43
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
ULARGE_INTEGER SectorCount
Definition: partlist.h:97
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
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 StdOut
Definition: fc.c:14
#define IDS_LIST_DISK_FORMAT
Definition: resource.h:45
WCHAR * LPWSTR
Definition: xmlstorage.h:184
base of all file and directory entries
Definition: entries.h:82

◆ ListPartition()

BOOL ListPartition ( INT  argc,
PWSTR argv 
)

Definition at line 78 of file list.c.

81 {
83  PPARTENTRY PartEntry;
84  ULONGLONG PartSize;
85  ULONGLONG PartOffset;
86  LPWSTR lpSizeUnit;
87  LPWSTR lpOffsetUnit;
88  ULONG PartNumber = 1;
89 
90  if (CurrentDisk == NULL)
91  {
93  return TRUE;
94  }
95 
96  /* Header labels */
99 
102  {
103  PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
104 
105  if (PartEntry->PartitionType != 0)
106  {
107  PartSize = PartEntry->SectorCount.QuadPart * CurrentDisk->BytesPerSector;
108 
109  if (PartSize >= 10737418240) /* 10 GB */
110  {
111  PartSize = RoundingDivide(PartSize, 1073741824);
112  lpSizeUnit = L"GB";
113  }
114  else if (PartSize >= 10485760) /* 10 MB */
115  {
116  PartSize = RoundingDivide(PartSize, 1048576);
117  lpSizeUnit = L"MB";
118  }
119  else
120  {
121  PartSize = RoundingDivide(PartSize, 1024);
122  lpSizeUnit = L"KB";
123  }
124 
125  PartOffset = PartEntry->StartSector.QuadPart * CurrentDisk->BytesPerSector;
126 
127  if (PartOffset >= 10737418240) /* 10 GB */
128  {
129  PartOffset = RoundingDivide(PartOffset, 1073741824);
130  lpOffsetUnit = L"GB";
131  }
132  else if (PartOffset >= 10485760) /* 10 MB */
133  {
134  PartOffset = RoundingDivide(PartOffset, 1048576);
135  lpOffsetUnit = L"MB";
136  }
137  else
138  {
139  PartOffset = RoundingDivide(PartOffset, 1024);
140  lpOffsetUnit = L"KB";
141  }
142 
144  (CurrentPartition == PartEntry) ? L'*': ' ',
145  PartNumber++,
146  IsContainerPartition(PartEntry->PartitionType) ? L"Extended" : L"Primary",
147  PartSize,
148  lpSizeUnit,
149  PartOffset,
150  lpOffsetUnit);
151  }
152 
153  Entry = Entry->Flink;
154  }
155 
158  {
159  PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
160 
161  if (PartEntry->PartitionType != 0)
162  {
163  PartSize = PartEntry->SectorCount.QuadPart * CurrentDisk->BytesPerSector;
164 
165  if (PartSize >= 10737418240) /* 10 GB */
166  {
167  PartSize = RoundingDivide(PartSize, 1073741824);
168  lpSizeUnit = L"GB";
169  }
170  else if (PartSize >= 10485760) /* 10 MB */
171  {
172  PartSize = RoundingDivide(PartSize, 1048576);
173  lpSizeUnit = L"MB";
174  }
175  else
176  {
177  PartSize = RoundingDivide(PartSize, 1024);
178  lpSizeUnit = L"KB";
179  }
180 
181  PartOffset = PartEntry->StartSector.QuadPart * CurrentDisk->BytesPerSector;
182 
183  if (PartOffset >= 10737418240) /* 10 GB */
184  {
185  PartOffset = RoundingDivide(PartOffset, 1073741824);
186  lpOffsetUnit = L"GB";
187  }
188  else if (PartOffset >= 10485760) /* 10 MB */
189  {
190  PartOffset = RoundingDivide(PartOffset, 1048576);
191  lpOffsetUnit = L"MB";
192  }
193  else
194  {
195  PartOffset = RoundingDivide(PartOffset, 1024);
196  lpOffsetUnit = L"KB";
197  }
198 
200  (CurrentPartition == PartEntry) ? L'*': ' ',
201  PartNumber++,
202  L"Logical",
203  PartSize,
204  lpSizeUnit,
205  PartOffset,
206  lpOffsetUnit);
207  }
208 
209  Entry = Entry->Flink;
210  }
211 
212  ConPuts(StdOut, L"\n");
213 
214  return TRUE;
215 }
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:47
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:48
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:49
#define NULL
Definition: types.h:112
LIST_ENTRY LogicalPartListHead
Definition: partlist.h:132
#define IDS_LIST_PARTITION_HEAD
Definition: resource.h:46
#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 271 of file list.c.

274 {
275  ConPuts(StdOut, L"ListVirtualDisk()!\n");
276  return TRUE;
277 }
#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 219 of file list.c.

222 {
224  PVOLENTRY VolumeEntry;
225  ULONGLONG VolumeSize;
226  LPWSTR lpSizeUnit;
227 
230 
232  while (Entry != &VolumeListHead)
233  {
234  VolumeEntry = CONTAINING_RECORD(Entry, VOLENTRY, ListEntry);
235 
236  VolumeSize = VolumeEntry->Size.QuadPart;
237  if (VolumeSize >= 10737418240) /* 10 GB */
238  {
239  VolumeSize = RoundingDivide(VolumeSize, 1073741824);
240  lpSizeUnit = L"GB";
241  }
242  else if (VolumeSize >= 10485760) /* 10 MB */
243  {
244  VolumeSize = RoundingDivide(VolumeSize, 1048576);
245  lpSizeUnit = L"MB";
246  }
247  else
248  {
249  VolumeSize = RoundingDivide(VolumeSize, 1024);
250  lpSizeUnit = L"KB";
251  }
252 
254  VolumeEntry->VolumeNumber,
255  VolumeEntry->DriveLetter,
256  (VolumeEntry->pszLabel) ? VolumeEntry->pszLabel : L"",
257  (VolumeEntry->pszFilesystem) ? VolumeEntry->pszFilesystem : L"",
258  VolumeEntry->DriveType,
259  VolumeSize, lpSizeUnit);
260 
261  Entry = Entry->Flink;
262  }
263 
264  ConPuts(StdOut, L"\n\n");
265 
266  return TRUE;
267 }
struct _Entry Entry
Definition: kefuncs.h:629
#define TRUE
Definition: types.h:120
ULARGE_INTEGER Size
Definition: diskpart.h:190
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: fc.c:16
#define L(x)
Definition: ntvdm.h:50
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
WCHAR DriveLetter
Definition: diskpart.h:185
PWSTR pszLabel
Definition: diskpart.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
#define IDS_LIST_VOLUME_FORMAT
Definition: resource.h:52
uint64_t ULONGLONG
Definition: typedefs.h:67
UINT DriveType
Definition: diskpart.h:189
#define IDS_LIST_VOLUME_LINE
Definition: resource.h:51
Definition: typedefs.h:119
#define IDS_LIST_VOLUME_HEAD
Definition: resource.h:50
ULONGLONG RoundingDivide(IN ULONGLONG Dividend, IN ULONGLONG Divisor)
Definition: partlist.c:95
ULONG VolumeNumber
Definition: diskpart.h:182
PWSTR pszFilesystem
Definition: diskpart.h:188
#define StdOut
Definition: fc.c:14
LIST_ENTRY VolumeListHead
Definition: partlist.c:72
WCHAR * LPWSTR
Definition: xmlstorage.h:184
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

◆ 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

◆ 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:55
NTSTATUS CreateVolumeList(VOID)
Definition: partlist.c:1250
#define IDS_RESCAN_START
Definition: resource.h:54
VOID DestroyVolumeList(VOID)
Definition: partlist.c:1288
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:59
#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:201
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:57
#define ERANGE
Definition: acclib.h:92
Definition: typedefs.h:119
#define NULL
Definition: types.h:112
#define IDS_SELECT_DISK
Definition: resource.h:58
#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:63
LIST_ENTRY PrimaryPartListHead
Definition: partlist.h:131
#define IDS_SELECT_NO_PARTITION
Definition: resource.h:60
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:61
#define IDS_ERROR_INVALID_ARGS
Definition: resource.h:201
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:62
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 (argc == 2)
186  {
187  if (CurrentDisk == NULL)
189  else
191  return TRUE;
192  }
193 
194  if (!IsDecString(argv[2]))
195  {
197  return TRUE;
198  }
199 
200  ulValue = wcstoul(argv[2], NULL, 10);
201  if ((ulValue == 0) && (errno == ERANGE))
202  {
204  return TRUE;
205  }
206 
208 
210  while (Entry != &VolumeListHead)
211  {
212  VolumeEntry = CONTAINING_RECORD(Entry, VOLENTRY, ListEntry);
213 
214  if (VolumeEntry->VolumeNumber == ulValue)
215  {
216  CurrentVolume = VolumeEntry;
218  return TRUE;
219  }
220 
221  Entry = Entry->Flink;
222  }
223 
225  return TRUE;
226 }
static int argc
Definition: ServiceArgs.c:12
struct _Entry Entry
Definition: kefuncs.h:629
#define TRUE
Definition: types.h:120
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_NO_VOLUME
Definition: resource.h:64
#define IDS_ERROR_INVALID_ARGS
Definition: resource.h:201
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
#define IDS_SELECT_VOLUME_INVALID
Definition: resource.h:66
#define ERANGE
Definition: acclib.h:92
Definition: typedefs.h:119
ULONG VolumeNumber
Definition: diskpart.h:182
#define NULL
Definition: types.h:112
#define StdOut
Definition: fc.c:14
unsigned int ULONG
Definition: retypes.h:1
LIST_ENTRY VolumeListHead
Definition: partlist.c:72
PVOLENTRY CurrentVolume
Definition: partlist.c:76
#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 IDS_SELECT_VOLUME
Definition: resource.h:65
#define StdErr
Definition: fc.c:15

◆ setid_main()

BOOL setid_main ( INT  argc,
LPWSTR argv 
)

Definition at line 11 of file setid.c.

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

◆ shrink_main()

BOOL shrink_main ( INT  argc,
LPWSTR argv 
)

Definition at line 11 of file shrink.c.

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

◆ UniqueIdDisk()

BOOL UniqueIdDisk ( _In_ INT  argc,
_In_ PWSTR argv 
)

Definition at line 17 of file uniqueid.c.

20 {
21  PWSTR pszSuffix = NULL;
22  ULONG ulValue;
23 
24  if (CurrentDisk == NULL)
25  {
27  return TRUE;
28  }
29 
30  if (argc == 2)
31  {
32  ConPuts(StdOut, L"\n");
33  ConPrintf(StdOut, L"Disk ID: %08lx\n", CurrentDisk->LayoutBuffer->Signature);
34  ConPuts(StdOut, L"\n");
35  return TRUE;
36  }
37 
38  if (argc != 3)
39  {
41  return TRUE;
42  }
43 
44  if (!HasPrefix(argv[2], L"ID=", &pszSuffix))
45  {
47  return TRUE;
48  }
49 
50  if ((pszSuffix == NULL) ||
51  (wcslen(pszSuffix) > 8) ||
52  (IsHexString(pszSuffix) == FALSE))
53  {
55  return TRUE;
56  }
57 
58  ulValue = wcstoul(pszSuffix, NULL, 16);
59  if ((ulValue == 0) && (errno == ERANGE))
60  {
62  return TRUE;
63  }
64 
65  ConPrintf(StdOut, L"Setting the disk signature is not implemented yet!\n");
66 #if 0
67  DPRINT1("New Signature: %lx\n", ulValue);
69 // SetDiskLayout(CurrentDisk);
70 #endif
71 
72  return TRUE;
73 }
static int argc
Definition: ServiceArgs.c:12
BOOL HasPrefix(_In_ PWSTR pszString, _In_ PWSTR pszPrefix, _Out_opt_ PWSTR *pszSuffix)
Definition: misc.c:58
#define TRUE
Definition: types.h:120
uint16_t * PWSTR
Definition: typedefs.h:56
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
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: fc.c:16
BOOL IsHexString(_In_ PWSTR pszHexString)
Definition: misc.c:36
#define IDS_ERROR_INVALID_ARGS
Definition: resource.h:201
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
void ConResPuts(FILE *fp, UINT nID)
Definition: fc.c:27
#define IDS_SELECT_NO_DISK
Definition: resource.h:57
#define ERANGE
Definition: acclib.h:92
void ConPrintf(FILE *fp, LPCWSTR psz,...)
Definition: fc.c:20
#define NULL
Definition: types.h:112
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define DPRINT1
Definition: precomp.h:8
#define StdOut
Definition: fc.c:14
unsigned int ULONG
Definition: retypes.h:1
PDRIVE_LAYOUT_INFORMATION LayoutBuffer
Definition: partlist.h:125
#define StdErr
Definition: fc.c:15

Variable Documentation

◆ BiosDiskListHead

LIST_ENTRY BiosDiskListHead

◆ cmds

◆ CurrentDisk

◆ CurrentPartition

PPARTENTRY CurrentPartition

Definition at line 75 of file partlist.c.

Referenced by CreatePartitionList(), and DestroyPartitionList().

◆ CurrentVolume

PVOLENTRY CurrentVolume

Definition at line 76 of file partlist.c.

Referenced by CreateVolumeList(), DestroyVolumeList(), DetailVolume(), and SelectVolume().

◆ DiskListHead

LIST_ENTRY DiskListHead

◆ VolumeListHead

LIST_ENTRY VolumeListHead