[DISKPART] Command function return EXIT_CODE instead of BOOL

This simplifies the implementation of the NOERR option.
This commit is contained in:
Eric Kohl
2026-01-01 13:46:05 +01:00
parent e616f29a24
commit d2ae286c6b
40 changed files with 520 additions and 355 deletions

View File

@@ -12,7 +12,7 @@
#include <debug.h>
BOOL
EXIT_CODE
active_main(
_In_ INT argc,
_In_ PWSTR *argv)
@@ -24,13 +24,13 @@ active_main(
if (CurrentDisk == NULL)
{
ConResPuts(StdOut, IDS_SELECT_NO_DISK);
return TRUE;
return EXIT_SUCCESS;
}
if (CurrentPartition == NULL)
{
ConResPuts(StdOut, IDS_SELECT_NO_PARTITION);
return TRUE;
return EXIT_SUCCESS;
}
if (CurrentDisk->PartitionStyle == PARTITION_STYLE_MBR)
@@ -38,7 +38,7 @@ active_main(
if (CurrentPartition->Mbr.BootIndicator)
{
ConResPuts(StdOut, IDS_ACTIVE_ALREADY);
return TRUE;
return EXIT_SUCCESS;
}
CurrentPartition->Mbr.BootIndicator = TRUE;
@@ -59,5 +59,5 @@ active_main(
ConResPuts(StdOut, IDS_ACTIVE_NO_MBR);
}
return TRUE;
return EXIT_SUCCESS;
}

View File

@@ -8,7 +8,10 @@
#include "diskpart.h"
BOOL add_main(INT argc, LPWSTR *argv)
EXIT_CODE
add_main(
_In_ INT argc,
_In_ PWSTR *argv)
{
return TRUE;
return EXIT_SUCCESS;
}

View File

@@ -11,7 +11,7 @@
#define NDEBUG
#include <debug.h>
BOOL
EXIT_CODE
assign_main(
_In_ INT argc,
_In_ LPWSTR *argv)
@@ -26,7 +26,7 @@ assign_main(
if (CurrentVolume == NULL)
{
ConResPuts(StdOut, IDS_SELECT_NO_VOLUME);
return TRUE;
return EXIT_SUCCESS;
}
for (i = 1; i < argc; i++)
@@ -54,7 +54,7 @@ assign_main(
else
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
return EXIT_SUCCESS;
}
}
else if (HasPrefix(argv[i], L"mount=", &pszSuffix))
@@ -70,14 +70,14 @@ assign_main(
else
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
return EXIT_SUCCESS;
}
}
if (nExclusive > 1)
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
return EXIT_SUCCESS;
}
DPRINT1("VolumeName: %S\n", CurrentVolume->VolumeName);
@@ -91,13 +91,13 @@ assign_main(
if ((DriveLetter < L'C') || (DriveLetter > L'Z'))
{
ConResPuts(StdOut, IDS_ASSIGN_INVALID_LETTER);
return TRUE;
return EXIT_SUCCESS;
}
if (DriveLetter == CurrentVolume->DriveLetter)
{
ConResPuts(StdOut, IDS_ASSIGN_ALREADY_ASSIGNED);
return TRUE;
return EXIT_SUCCESS;
}
}
@@ -108,7 +108,7 @@ assign_main(
if (bResult == FALSE)
{
ConResPuts(StdOut, IDS_ASSIGN_FAIL);
return TRUE;
return EXIT_SUCCESS;
}
CurrentVolume->DriveLetter = UNICODE_NULL;
@@ -122,7 +122,7 @@ assign_main(
if (bResult == FALSE)
{
ConResPuts(StdOut, IDS_ASSIGN_FAIL);
return TRUE;
return EXIT_SUCCESS;
}
CurrentVolume->DriveLetter = DriveLetter;
@@ -134,17 +134,17 @@ assign_main(
if (bResult == FALSE)
{
ConResPuts(StdOut, IDS_ASSIGN_FAIL);
return TRUE;
return EXIT_SUCCESS;
}
if (CurrentVolume->DriveLetter == UNICODE_NULL)
{
ConResPuts(StdOut, IDS_ASSIGN_NO_MORE_LETTER);
return TRUE;
return EXIT_SUCCESS;
}
}
ConResPuts(StdOut, IDS_REMOVE_SUCCESS);
return TRUE;
return EXIT_SUCCESS;
}

View File

@@ -8,7 +8,10 @@
#include "diskpart.h"
BOOL attach_main(INT argc, LPWSTR *argv)
EXIT_CODE
attach_main(
_In_ INT argc,
_In_ PWSTR *argv)
{
return TRUE;
return EXIT_SUCCESS;
}

View File

@@ -8,7 +8,10 @@
#include "diskpart.h"
BOOL attributes_main(INT argc, LPWSTR *argv)
EXIT_CODE
attributes_main(
_In_ INT argc,
_In_ PWSTR *argv)
{
return TRUE;
return EXIT_SUCCESS;
}

View File

@@ -12,10 +12,10 @@
#include <debug.h>
BOOL
EXIT_CODE
automount_main(
INT argc,
LPWSTR *argv)
_In_ INT argc,
_In_ PWSTR *argv)
{
BOOL bDisable = FALSE, bEnable = FALSE, bScrub = FALSE;
#if 0
@@ -134,5 +134,5 @@ automount_main(
ConPuts(StdOut, L"\n");
}
return TRUE;
return EXIT_SUCCESS;
}

View File

@@ -8,8 +8,11 @@
#include "diskpart.h"
BOOL break_main(INT argc, LPWSTR *argv)
EXIT_CODE
break_main(
_In_ INT argc,
_In_ PWSTR *argv)
{
ConPuts(StdOut, L"\nTODO: Add code later since Win 7 Home Premium doesn't have this feature.\n");
return TRUE;
return EXIT_SUCCESS;
}

View File

@@ -12,7 +12,7 @@
#include <debug.h>
BOOL
EXIT_CODE
clean_main(
_In_ INT argc,
_In_ PWSTR *argv)
@@ -37,7 +37,7 @@ clean_main(
if (CurrentDisk == NULL)
{
ConResPuts(StdOut, IDS_SELECT_NO_DISK);
return TRUE;
return EXIT_SUCCESS;
}
/* Do not allow to clean the boot disk */
@@ -45,7 +45,7 @@ clean_main(
(CurrentDisk->BiosDiskNumber == 0))
{
ConResPuts(StdOut, IDS_CLEAN_SYSTEM);
return TRUE;
return EXIT_SUCCESS;
}
for (i = 1; i < argc; i++)
@@ -112,7 +112,7 @@ clean_main(
if (CurrentDisk->LayoutBuffer == NULL)
{
DPRINT1("Failed to allocate the disk layout buffer!\n");
return TRUE;
return EXIT_SUCCESS;
}
CurrentDisk->LayoutBuffer->PartitionStyle = PARTITION_STYLE_RAW;
@@ -246,5 +246,5 @@ done:
if (SectorsBuffer != NULL)
RtlFreeHeap(RtlGetProcessHeap(), 0, SectorsBuffer);
return TRUE;
return EXIT_SUCCESS;
}

View File

@@ -8,7 +8,10 @@
#include "diskpart.h"
BOOL compact_main(INT argc, LPWSTR *argv)
EXIT_CODE
compact_main(
_In_ INT argc,
_In_ PWSTR *argv)
{
return 0;
return EXIT_SUCCESS;
}

View File

@@ -84,7 +84,7 @@ done:
}
BOOL
EXIT_CODE
ConvertGPT(
_In_ INT argc,
_In_ PWSTR *argv)
@@ -97,19 +97,19 @@ ConvertGPT(
if (CurrentDisk == NULL)
{
ConResPuts(StdOut, IDS_SELECT_NO_DISK);
return TRUE;
return EXIT_SUCCESS;
}
if (CurrentDisk->PartitionStyle == PARTITION_STYLE_GPT)
{
ConResPuts(StdOut, IDS_CONVERT_GPT_ALREADY);
return TRUE;
return EXIT_SUCCESS;
}
if (GetPrimaryPartitionCount(CurrentDisk) != 0)
{
ConResPuts(StdOut, IDS_CONVERT_GPT_NOT_EMPTY);
return TRUE;
return EXIT_SUCCESS;
}
#if 0
@@ -117,7 +117,7 @@ ConvertGPT(
if (CurrentDisk->SectorCount.QuadPart * CurrentDisk->BytesPerSector < 128ULL * 1024ULL * 1024ULL)
{
ConResPuts(StdOut, IDS_CONVERT_GPT_TOO_SMALL);
return TRUE;
return EXIT_SUCCESS;
}
#endif
@@ -129,7 +129,7 @@ ConvertGPT(
if (!NT_SUCCESS(Status))
{
DPRINT1("CreateDisk() failed!\n");
return TRUE;
return EXIT_SUCCESS;
}
CurrentDisk->StartSector.QuadPart = AlignDown(CurrentDisk->LayoutBuffer->Gpt.StartingUsableOffset.QuadPart / CurrentDisk->BytesPerSector,
@@ -140,11 +140,11 @@ ConvertGPT(
ScanForUnpartitionedGptDiskSpace(CurrentDisk);
ConResPuts(StdOut, IDS_CONVERT_GPT_SUCCESS);
return TRUE;
return EXIT_SUCCESS;
}
BOOL
EXIT_CODE
ConvertMBR(
_In_ INT argc,
_In_ PWSTR *argv)
@@ -157,20 +157,20 @@ ConvertMBR(
if (CurrentDisk == NULL)
{
ConResPuts(StdOut, IDS_SELECT_NO_DISK);
return TRUE;
return EXIT_SUCCESS;
}
if ((CurrentDisk->PartitionStyle == PARTITION_STYLE_MBR) ||
(CurrentDisk->PartitionStyle == PARTITION_STYLE_RAW))
{
ConResPuts(StdOut, IDS_CONVERT_MBR_ALREADY);
return TRUE;
return EXIT_SUCCESS;
}
if (GetPrimaryPartitionCount(CurrentDisk) != 0)
{
ConResPuts(StdOut, IDS_CONVERT_MBR_NOT_EMPTY);
return TRUE;
return EXIT_SUCCESS;
}
DiskInfo.PartitionStyle = PARTITION_STYLE_MBR;
@@ -180,7 +180,7 @@ ConvertMBR(
if (!NT_SUCCESS(Status))
{
DPRINT1("CreateDisk() failed!\n");
return TRUE;
return EXIT_SUCCESS;
}
CurrentDisk->StartSector.QuadPart = (ULONGLONG)CurrentDisk->SectorAlignment;
@@ -189,5 +189,5 @@ ConvertMBR(
ScanForUnpartitionedMbrDiskSpace(CurrentDisk);
ConResPuts(StdOut, IDS_CONVERT_MBR_SUCCESS);
return TRUE;
return EXIT_SUCCESS;
}

View File

@@ -12,7 +12,7 @@
#include <debug.h>
BOOL
EXIT_CODE
CreateEfiPartition(
_In_ INT argc,
_In_ PWSTR *argv)
@@ -34,13 +34,13 @@ CreateEfiPartition(
if (CurrentDisk == NULL)
{
ConResPuts(StdOut, IDS_SELECT_NO_DISK);
return TRUE;
return EXIT_SUCCESS;
}
if (CurrentDisk->PartitionStyle != PARTITION_STYLE_GPT)
{
ConResPuts(StdOut, IDS_CREATE_PARTITION_INVALID_STYLE);
return TRUE;
return EXIT_SUCCESS;
}
for (i = 3; i < argc; i++)
@@ -67,7 +67,7 @@ CreateEfiPartition(
if ((ullSize == 0) && (errno == ERANGE))
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
return EXIT_SUCCESS;
}
}
else if (HasPrefix(argv[i], L"offset=", &pszSuffix))
@@ -91,7 +91,7 @@ CreateEfiPartition(
else
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
return EXIT_SUCCESS;
}
}
@@ -201,16 +201,16 @@ CreateEfiPartition(
{
ConResPuts(StdOut, IDS_CREATE_PARTITION_FAIL);
CurrentPartition = NULL;
return TRUE;
return EXIT_SUCCESS;
}
ConResPuts(StdOut, IDS_CREATE_PARTITION_SUCCESS);
return TRUE;
return EXIT_SUCCESS;
}
BOOL
EXIT_CODE
CreateExtendedPartition(
_In_ INT argc,
_In_ PWSTR *argv)
@@ -230,13 +230,13 @@ CreateExtendedPartition(
if (CurrentDisk == NULL)
{
ConResPuts(StdOut, IDS_SELECT_NO_DISK);
return TRUE;
return EXIT_SUCCESS;
}
if (CurrentDisk->PartitionStyle == PARTITION_STYLE_GPT)
{
ConResPuts(StdOut, IDS_CREATE_PARTITION_INVALID_STYLE);
return TRUE;
return EXIT_SUCCESS;
}
else if (CurrentDisk->PartitionStyle == PARTITION_STYLE_RAW)
{
@@ -250,7 +250,7 @@ CreateExtendedPartition(
if (!NT_SUCCESS(Status))
{
DPRINT1("CreateDisk() failed!\n");
return TRUE;
return EXIT_SUCCESS;
}
CurrentDisk->StartSector.QuadPart = (ULONGLONG)CurrentDisk->SectorAlignment;
@@ -283,7 +283,7 @@ CreateExtendedPartition(
if ((ullSize == 0) && (errno == ERANGE))
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
return EXIT_SUCCESS;
}
}
else if (HasPrefix(argv[i], L"offset=", &pszSuffix))
@@ -296,7 +296,7 @@ CreateExtendedPartition(
if ((ullOffset == 0) && (errno == ERANGE))
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
return EXIT_SUCCESS;
}
#endif
}
@@ -316,7 +316,7 @@ CreateExtendedPartition(
else
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
return EXIT_SUCCESS;
}
}
@@ -328,13 +328,13 @@ CreateExtendedPartition(
if (GetPrimaryPartitionCount(CurrentDisk) >= 4)
{
ConPuts(StdOut, L"No space left for an extended partition!\n");
return TRUE;
return EXIT_SUCCESS;
}
if (CurrentDisk->ExtendedPartition != NULL)
{
ConPuts(StdOut, L"We already have an extended partition on this disk!\n");
return TRUE;
return EXIT_SUCCESS;
}
if (ullSize != 0)
@@ -350,7 +350,7 @@ CreateExtendedPartition(
if (PartEntry->IsPartitioned)
{
ConPuts(StdOut, L"No disk space left for an extended partition!\n");
return TRUE;
return EXIT_SUCCESS;
}
if (ullSectorCount == 0)
@@ -414,16 +414,16 @@ CreateExtendedPartition(
{
ConResPuts(StdOut, IDS_CREATE_PARTITION_FAIL);
CurrentPartition = NULL;
return TRUE;
return EXIT_SUCCESS;
}
ConResPuts(StdOut, IDS_CREATE_PARTITION_SUCCESS);
return TRUE;
return EXIT_SUCCESS;
}
BOOL
EXIT_CODE
CreateLogicalPartition(
_In_ INT argc,
_In_ PWSTR *argv)
@@ -444,13 +444,13 @@ CreateLogicalPartition(
if (CurrentDisk == NULL)
{
ConResPuts(StdOut, IDS_SELECT_NO_DISK);
return TRUE;
return EXIT_SUCCESS;
}
if (CurrentDisk->PartitionStyle != PARTITION_STYLE_MBR)
{
ConResPuts(StdOut, IDS_CREATE_PARTITION_INVALID_STYLE);
return TRUE;
return EXIT_SUCCESS;
}
for (i = 3; i < argc; i++)
@@ -477,7 +477,7 @@ CreateLogicalPartition(
if ((ullSize == 0) && (errno == ERANGE))
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
return EXIT_SUCCESS;
}
}
else if (HasPrefix(argv[i], L"offset=", &pszSuffix))
@@ -490,7 +490,7 @@ CreateLogicalPartition(
if ((ullOffset == 0) && (errno == ERANGE))
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
return EXIT_SUCCESS;
}
#endif
}
@@ -507,13 +507,13 @@ CreateLogicalPartition(
if ((PartitionType == 0) && (errno == ERANGE))
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
return EXIT_SUCCESS;
}
}
else
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
return EXIT_SUCCESS;
}
}
else if (HasPrefix(argv[i], L"align=", &pszSuffix))
@@ -532,7 +532,7 @@ CreateLogicalPartition(
else
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
return EXIT_SUCCESS;
}
}
@@ -622,16 +622,16 @@ CreateLogicalPartition(
{
ConResPuts(StdOut, IDS_CREATE_PARTITION_FAIL);
CurrentPartition = NULL;
return TRUE;
return EXIT_SUCCESS;
}
ConResPuts(StdOut, IDS_CREATE_PARTITION_SUCCESS);
return TRUE;
return EXIT_SUCCESS;
}
BOOL
EXIT_CODE
CreateMsrPartition(
_In_ INT argc,
_In_ PWSTR *argv)
@@ -653,13 +653,13 @@ CreateMsrPartition(
if (CurrentDisk == NULL)
{
ConResPuts(StdOut, IDS_SELECT_NO_DISK);
return TRUE;
return EXIT_SUCCESS;
}
if (CurrentDisk->PartitionStyle != PARTITION_STYLE_GPT)
{
ConResPuts(StdOut, IDS_CREATE_PARTITION_INVALID_STYLE);
return TRUE;
return EXIT_SUCCESS;
}
for (i = 3; i < argc; i++)
@@ -686,7 +686,7 @@ CreateMsrPartition(
if ((ullSize == 0) && (errno == ERANGE))
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
return EXIT_SUCCESS;
}
}
else if (HasPrefix(argv[i], L"offset=", &pszSuffix))
@@ -699,7 +699,7 @@ CreateMsrPartition(
if ((ullOffset == 0) && (errno == ERANGE))
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
return EXIT_SUCCESS;
}
#endif
}
@@ -710,7 +710,7 @@ CreateMsrPartition(
else
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
return EXIT_SUCCESS;
}
}
@@ -820,12 +820,12 @@ CreateMsrPartition(
{
ConResPuts(StdOut, IDS_CREATE_PARTITION_FAIL);
CurrentPartition = NULL;
return TRUE;
return EXIT_SUCCESS;
}
ConResPuts(StdOut, IDS_CREATE_PARTITION_SUCCESS);
return TRUE;
return EXIT_SUCCESS;
}
@@ -1090,7 +1090,7 @@ CreatePrimaryGptPartition(
}
BOOL
EXIT_CODE
CreatePrimaryPartition(
_In_ INT argc,
_In_ PWSTR *argv)
@@ -1107,7 +1107,7 @@ CreatePrimaryPartition(
if (CurrentDisk == NULL)
{
ConResPuts(StdOut, IDS_SELECT_NO_DISK);
return TRUE;
return EXIT_SUCCESS;
}
if (CurrentDisk->PartitionStyle == PARTITION_STYLE_RAW)
@@ -1122,7 +1122,7 @@ CreatePrimaryPartition(
if (!NT_SUCCESS(Status))
{
DPRINT1("CreateDisk() failed!\n");
return TRUE;
return EXIT_SUCCESS;
}
CurrentDisk->StartSector.QuadPart = (ULONGLONG)CurrentDisk->SectorAlignment;
@@ -1155,7 +1155,7 @@ CreatePrimaryPartition(
if ((ullSize == 0) && (errno == ERANGE))
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
return EXIT_SUCCESS;
}
}
else if (HasPrefix(argv[i], L"offset=", &pszSuffix))
@@ -1168,7 +1168,7 @@ CreatePrimaryPartition(
if ((ullOffset == 0) && (errno == ERANGE))
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
return EXIT_SUCCESS;
}
#endif
}
@@ -1194,7 +1194,7 @@ CreatePrimaryPartition(
else
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
return EXIT_SUCCESS;
}
}
@@ -1213,5 +1213,5 @@ CreatePrimaryPartition(
CreatePrimaryGptPartition(ullSize, pszPartitionType);
}
return TRUE;
return EXIT_SUCCESS;
}

View File

@@ -24,12 +24,12 @@ IsKnownPartition(
}
BOOL
EXIT_CODE
DeleteDisk(
_In_ INT argc,
_In_ PWSTR *argv)
{
return TRUE;
return EXIT_SUCCESS;
}
@@ -270,7 +270,7 @@ DeleteGptPartition(
}
BOOL
EXIT_CODE
DeletePartition(
_In_ INT argc,
_In_ PWSTR *argv)
@@ -283,13 +283,13 @@ DeletePartition(
if (CurrentDisk == NULL)
{
ConResPuts(StdOut, IDS_SELECT_NO_DISK);
return TRUE;
return EXIT_SUCCESS;
}
if (CurrentPartition == NULL)
{
ConResPuts(StdOut, IDS_SELECT_NO_PARTITION);
return TRUE;
return EXIT_SUCCESS;
}
for (i = 2; i < argc; i++)
@@ -320,7 +320,7 @@ DeletePartition(
else
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
return EXIT_SUCCESS;
}
}
@@ -333,14 +333,14 @@ DeletePartition(
DeleteGptPartition(bOverride);
}
return TRUE;
return EXIT_SUCCESS;
}
BOOL
EXIT_CODE
DeleteVolume(
_In_ INT argc,
_In_ PWSTR *argv)
{
return TRUE;
return EXIT_SUCCESS;
}

View File

@@ -8,7 +8,10 @@
#include "diskpart.h"
BOOL detach_main(INT argc, LPWSTR *argv)
EXIT_CODE
detach_main(
_In_ INT argc,
_In_ PWSTR *argv)
{
return TRUE;
return EXIT_SUCCESS;
}

View File

@@ -64,7 +64,7 @@ IsPartitionInVolume(
}
BOOL
EXIT_CODE
DetailDisk(
_In_ INT argc,
_In_ PWSTR *argv)
@@ -79,13 +79,13 @@ DetailDisk(
if (argc > 2)
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
return EXIT_SUCCESS;
}
if (CurrentDisk == NULL)
{
ConResPuts(StdOut, IDS_SELECT_NO_DISK);
return TRUE;
return EXIT_SUCCESS;
}
/* TODO: Print more disk details */
@@ -128,11 +128,11 @@ DetailDisk(
ConPuts(StdOut, L"\n");
return TRUE;
return EXIT_SUCCESS;
}
BOOL
EXIT_CODE
DetailPartition(
_In_ INT argc,
_In_ PWSTR *argv)
@@ -149,19 +149,19 @@ DetailPartition(
if (argc > 2)
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
return EXIT_SUCCESS;
}
if (CurrentDisk == NULL)
{
ConResPuts(StdOut, IDS_SELECT_PARTITION_NO_DISK);
return TRUE;
return EXIT_SUCCESS;
}
if (CurrentPartition == NULL)
{
ConResPuts(StdOut, IDS_SELECT_NO_PARTITION);
return TRUE;
return EXIT_SUCCESS;
}
PartEntry = CurrentPartition;
@@ -214,11 +214,11 @@ DetailPartition(
ConPuts(StdOut, L"\n");
return TRUE;
return EXIT_SUCCESS;
}
BOOL
EXIT_CODE
DetailVolume(
_In_ INT argc,
_In_ PWSTR *argv)
@@ -232,13 +232,13 @@ DetailVolume(
if (argc > 2)
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
return EXIT_SUCCESS;
}
if (CurrentVolume == NULL)
{
ConResPuts(StdOut, IDS_SELECT_NO_VOLUME);
return TRUE;
return EXIT_SUCCESS;
}
@@ -271,5 +271,5 @@ DetailVolume(
ConPuts(StdOut, L"\n");
return TRUE;
return EXIT_SUCCESS;
}

View File

@@ -37,11 +37,12 @@ ShowHeader(VOID)
* opens the file, reads the contents, convert the text into readable
* code for the computer, and then execute commands in order.
*/
BOOL
EXIT_CODE
RunScript(LPCWSTR filename)
{
FILE *script;
WCHAR tmp_string[MAX_STRING_SIZE];
EXIT_CODE Result;
/* Open the file for processing */
script = _wfopen(filename, L"r");
@@ -55,17 +56,18 @@ RunScript(LPCWSTR filename)
/* Read and process the script */
while (fgetws(tmp_string, MAX_STRING_SIZE, script) != NULL)
{
if (InterpretScript(tmp_string) == FALSE)
Result = InterpretScript(tmp_string);
if (Result != EXIT_SUCCESS)
{
fclose(script);
return FALSE;
return (Result == EXIT_EXIT) ? EXIT_SUCCESS : Result;
}
}
/* Close the file */
fclose(script);
return TRUE;
return EXIT_SUCCESS;
}
/*
@@ -117,7 +119,7 @@ int wmain(int argc, const LPWSTR argv[])
{
/* If there is no flag, then return an error */
ConResPrintf(StdErr, IDS_ERROR_MSG_BAD_ARG, argv[index]);
result = EXIT_FAILURE;
result = EXIT_SYNTAX;
goto done;
}
@@ -156,7 +158,7 @@ int wmain(int argc, const LPWSTR argv[])
{
/* Assume that the flag doesn't exist. */
ConResPrintf(StdErr, IDS_ERROR_MSG_BAD_ARG, tmpBuffer);
result = EXIT_FAILURE;
result = EXIT_SYNTAX;
goto done;
}
}
@@ -172,17 +174,15 @@ int wmain(int argc, const LPWSTR argv[])
if (timeout > 0)
Sleep(timeout * 1000);
if (RunScript(script) == FALSE)
{
result = EXIT_FAILURE;
result = RunScript(script);
if (result != EXIT_SUCCESS)
goto done;
}
}
else
{
/* Exit failure since the user wanted to run a script */
ConResPrintf(StdErr, IDS_ERROR_MSG_NO_SCRIPT, script);
result = EXIT_FAILURE;
result = EXIT_SYNTAX;
goto done;
}
}

View File

@@ -66,26 +66,33 @@
/* DEFINES *******************************************************************/
/* NOERR codes for the program */
#undef EXIT_SUCCESS
#undef EXIT_FAILURE
typedef enum _EXIT_CODE
{
EXIT_SUCCESS = 0,
EXIT_FATAL,
EXIT_CMD_ARG,
EXIT_FILE,
EXIT_SERVICE,
EXIT_SYNTAX,
EXIT_EXIT /* Only used by the exit command */
} EXIT_CODE;
typedef struct _COMMAND
{
PWSTR cmd1;
PWSTR cmd2;
PWSTR cmd3;
BOOL (*func)(INT, WCHAR**);
EXIT_CODE (*func)(INT, PWSTR*);
INT help;
DWORD help_detail;
} COMMAND, *PCOMMAND;
extern COMMAND cmds[];
/* NOERR codes for the program */
//#define ERROR_NONE 0
//#define ERROR_FATAL 1
//#define ERROR_CMD_ARG 2
//#define ERROR_FILE 3
//#define ERROR_SERVICE 4
//#define ERROR_SYNTAX 5
#define MAX_STRING_SIZE 1024
#define MAX_ARGS_COUNT 256
@@ -270,31 +277,58 @@ extern PVOLENTRY CurrentVolume;
/* PROTOTYPES *****************************************************************/
/* active.c */
BOOL active_main(INT argc, LPWSTR *argv);
EXIT_CODE
active_main(
_In_ INT argc,
_In_ PWSTR *argv);
/* add.c */
BOOL add_main(INT argc, LPWSTR *argv);
EXIT_CODE
add_main(
_In_ INT argc,
_In_ PWSTR *argv);
/* assign.c */
BOOL assign_main(INT argc, LPWSTR *argv);
EXIT_CODE
assign_main(
_In_ INT argc,
_In_ PWSTR *argv);
/* attach.c */
BOOL attach_main(INT argc, LPWSTR *argv);
EXIT_CODE
attach_main(
_In_ INT argc,
_In_ PWSTR *argv);
/* attributes.h */
BOOL attributes_main(INT argc, LPWSTR *argv);
EXIT_CODE
attributes_main(
_In_ INT argc,
_In_ PWSTR *argv);
/* automount.c */
BOOL automount_main(INT argc, LPWSTR *argv);
EXIT_CODE
automount_main(
_In_ INT argc,
_In_ PWSTR *argv);
/* break.c */
BOOL break_main(INT argc, LPWSTR *argv);
EXIT_CODE
break_main(
_In_ INT argc,
_In_ PWSTR *argv);
/* clean.c */
BOOL clean_main(INT argc, LPWSTR *argv);
EXIT_CODE
clean_main(
_In_ INT argc,
_In_ PWSTR *argv);
/* compact.c */
BOOL compact_main(INT argc, LPWSTR *argv);
EXIT_CODE
compact_main(
_In_ INT argc,
_In_ PWSTR *argv);
/* convert.c */
NTSTATUS
@@ -302,74 +336,77 @@ CreateDisk(
_In_ ULONG DiskNumber,
_In_ PCREATE_DISK DiskInfo);
BOOL
EXIT_CODE
ConvertGPT(
_In_ INT argc,
_In_ PWSTR *argv);
BOOL
EXIT_CODE
ConvertMBR(
_In_ INT argc,
_In_ PWSTR *argv);
/* create.c */
BOOL
EXIT_CODE
CreateEfiPartition(
_In_ INT argc,
_In_ PWSTR *argv);
BOOL
EXIT_CODE
CreateExtendedPartition(
_In_ INT argc,
_In_ PWSTR *argv);
BOOL
EXIT_CODE
CreateLogicalPartition(
_In_ INT argc,
_In_ PWSTR *argv);
BOOL
EXIT_CODE
CreateMsrPartition(
_In_ INT argc,
_In_ PWSTR *argv);
BOOL
EXIT_CODE
CreatePrimaryPartition(
_In_ INT argc,
_In_ PWSTR *argv);
/* delete.c */
BOOL
EXIT_CODE
DeleteDisk(
_In_ INT argc,
_In_ PWSTR *argv);
BOOL
EXIT_CODE
DeletePartition(
_In_ INT argc,
_In_ PWSTR *argv);
BOOL
EXIT_CODE
DeleteVolume(
_In_ INT argc,
_In_ PWSTR *argv);
/* detach.c */
BOOL detach_main(INT argc, LPWSTR *argv);
EXIT_CODE
detach_main(
_In_ INT argc,
_In_ PWSTR *argv);
/* detail.c */
BOOL
EXIT_CODE
DetailDisk(
INT argc,
PWSTR *argv);
BOOL
EXIT_CODE
DetailPartition(
INT argc,
PWSTR *argv);
BOOL
EXIT_CODE
DetailVolume(
INT argc,
PWSTR *argv);
@@ -377,65 +414,102 @@ DetailVolume(
/* diskpart.c */
/* dump.c */
BOOL
EXIT_CODE
DumpDisk(
_In_ INT argc,
_In_ LPWSTR *argv);
BOOL
EXIT_CODE
DumpPartition(
_In_ INT argc,
_In_ LPWSTR *argv);
/* expand.c */
BOOL expand_main(INT argc, LPWSTR *argv);
EXIT_CODE
expand_main(
_In_ INT argc,
_In_ PWSTR *argv);
/* extend.c */
BOOL extend_main(INT argc, LPWSTR *argv);
EXIT_CODE
extend_main(
_In_ INT argc,
_In_ PWSTR *argv);
/* filesystem.c */
BOOL filesystems_main(INT argc, LPWSTR *argv);
EXIT_CODE
filesystems_main(
_In_ INT argc,
_In_ PWSTR *argv);
/* format.c */
BOOL format_main(INT argc, LPWSTR *argv);
EXIT_CODE
format_main(
_In_ INT argc,
_In_ PWSTR *argv);
/* gpt.c */
BOOL gpt_main(INT argc, LPWSTR *argv);
EXIT_CODE
gpt_main(
_In_ INT argc,
_In_ PWSTR *argv);
/* help.c */
BOOL help_main(INT argc, LPWSTR *argv);
VOID HelpCommandList(VOID);
BOOL HelpCommand(PCOMMAND pCommand);
EXIT_CODE
help_main(
_In_ INT argc,
_In_ PWSTR *argv);
VOID
HelpCommandList(VOID);
EXIT_CODE
HelpCommand(
_In_ PCOMMAND pCommand);
/* import. c */
BOOL import_main(INT argc, LPWSTR *argv);
EXIT_CODE
import_main(
_In_ INT argc,
_In_ PWSTR *argv);
/* inactive.c */
BOOL inactive_main(INT argc, LPWSTR *argv);
EXIT_CODE
inactive_main(
_In_ INT argc,
_In_ PWSTR *argv);
/* interpreter.c */
BOOL InterpretScript(LPWSTR line);
BOOL InterpretCmd(INT argc, LPWSTR *argv);
VOID InterpretMain(VOID);
EXIT_CODE
InterpretScript(
_In_ LPWSTR line);
EXIT_CODE
InterpretCmd(
_In_ INT argc,
_In_ PWSTR *argv);
VOID
InterpretMain(VOID);
/* list.c */
BOOL
EXIT_CODE
ListDisk(
INT argc,
PWSTR *argv);
BOOL
EXIT_CODE
ListPartition(
INT argc,
PWSTR *argv);
BOOL
EXIT_CODE
ListVolume(
INT argc,
PWSTR *argv);
BOOL
EXIT_CODE
ListVirtualDisk(
INT argc,
PWSTR *argv);
@@ -449,7 +523,10 @@ PrintVolume(
_In_ PVOLENTRY VolumeEntry);
/* merge.c */
BOOL merge_main(INT argc, LPWSTR *argv);
EXIT_CODE
merge_main(
_In_ INT argc,
_In_ PWSTR *argv);
/* misc.c */
BOOL
@@ -530,10 +607,16 @@ DeleteDriveLetter(
_In_ WCHAR DriveLetter);
/* offline.c */
BOOL offline_main(INT argc, LPWSTR *argv);
EXIT_CODE
offline_main(
_In_ INT argc,
_In_ PWSTR *argv);
/* online.c */
BOOL online_main(INT argc, LPWSTR *argv);
EXIT_CODE
online_main(
_In_ INT argc,
_In_ PWSTR *argv);
/* partlist.c */
#ifdef DUMP_PARTITION_TABLE
@@ -621,52 +704,76 @@ RemoveVolume(
/* recover.c */
BOOL recover_main(INT argc, LPWSTR *argv);
EXIT_CODE
recover_main(
_In_ INT argc,
_In_ PWSTR *argv);
/* remove.c */
BOOL remove_main(INT argc, LPWSTR *argv);
EXIT_CODE
remove_main(
_In_ INT argc,
_In_ PWSTR *argv);
/* repair.c */
BOOL repair_main(INT argc, LPWSTR *argv);
EXIT_CODE
repair_main(
_In_ INT argc,
_In_ PWSTR *argv);
/* rescan.c */
BOOL rescan_main(INT argc, LPWSTR *argv);
EXIT_CODE
rescan_main(
_In_ INT argc,
_In_ PWSTR *argv);
/* retain.c */
BOOL retain_main(INT argc, LPWSTR *argv);
EXIT_CODE
retain_main(
_In_ INT argc,
_In_ PWSTR *argv);
/* san.c */
BOOL san_main(INT argc, LPWSTR *argv);
EXIT_CODE
san_main(
_In_ INT argc,
_In_ PWSTR *argv);
/* select.c */
BOOL
EXIT_CODE
SelectDisk(
INT argc,
PWSTR *argv);
BOOL
EXIT_CODE
SelectPartition(
INT argc,
PWSTR *argv);
BOOL
EXIT_CODE
SelectVolume(
INT argc,
PWSTR *argv);
/*
BOOL
EXIT_CODE
SelectVirtualDisk(
INT argc,
PWSTR *argv);
*/
/* setid.c */
BOOL setid_main(INT argc, LPWSTR *argv);
EXIT_CODE
setid_main(
_In_ INT argc,
_In_ PWSTR *argv);
/* shrink.c */
BOOL shrink_main(INT argc, LPWSTR *argv);
EXIT_CODE
shrink_main(
_In_ INT argc,
_In_ PWSTR *argv);
/* uniqueid.c */
BOOL
EXIT_CODE
UniqueIdDisk(
_In_ INT argc,
_In_ PWSTR *argv);

View File

@@ -44,10 +44,10 @@ HexDump(
}
BOOL
EXIT_CODE
DumpDisk(
_In_ INT argc,
_In_ LPWSTR *argv)
_In_ PWSTR *argv)
{
OBJECT_ATTRIBUTES ObjectAttributes;
IO_STATUS_BLOCK Iosb;
@@ -64,14 +64,14 @@ DumpDisk(
if (argc == 2)
{
ConResPuts(StdOut, IDS_HELP_CMD_DUMP_DISK);
return TRUE;
return EXIT_SUCCESS;
}
#endif
if (CurrentDisk == NULL)
{
ConResPuts(StdOut, IDS_SELECT_NO_DISK);
return TRUE;
return EXIT_SUCCESS;
}
Sector = _wcstoi64(argv[2], &endptr, 0);
@@ -79,7 +79,7 @@ DumpDisk(
(Sector < 0))
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
return EXIT_SUCCESS;
}
pSectorBuffer = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, CurrentDisk->BytesPerSector);
@@ -138,14 +138,14 @@ done:
RtlFreeHeap(RtlGetProcessHeap(), 0, pSectorBuffer);
return TRUE;
return EXIT_SUCCESS;
}
BOOL
EXIT_CODE
DumpPartition(
_In_ INT argc,
_In_ LPWSTR *argv)
_In_ PWSTR *argv)
{
OBJECT_ATTRIBUTES ObjectAttributes;
IO_STATUS_BLOCK Iosb;
@@ -163,20 +163,20 @@ DumpPartition(
if (argc == 2)
{
ConResPuts(StdOut, IDS_HELP_CMD_DUMP_DISK);
return TRUE;
return EXIT_SUCCESS;
}
#endif
if (CurrentDisk == NULL)
{
ConResPuts(StdOut, IDS_SELECT_NO_DISK);
return TRUE;
return EXIT_SUCCESS;
}
if (CurrentPartition == NULL)
{
ConResPuts(StdOut, IDS_SELECT_NO_PARTITION);
return TRUE;
return EXIT_SUCCESS;
}
Sector = _wcstoi64(argv[2], &endptr, 0);
@@ -184,7 +184,7 @@ DumpPartition(
(Sector < 0))
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
return EXIT_SUCCESS;
}
pSectorBuffer = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, CurrentDisk->BytesPerSector);
@@ -244,5 +244,5 @@ done:
RtlFreeHeap(RtlGetProcessHeap(), 0, pSectorBuffer);
return TRUE;
return EXIT_SUCCESS;
}

View File

@@ -8,7 +8,10 @@
#include "diskpart.h"
BOOL expand_main(INT argc, LPWSTR *argv)
EXIT_CODE
expand_main(
_In_ INT argc,
_In_ PWSTR *argv)
{
return TRUE;
return EXIT_SUCCESS;
}

View File

@@ -8,7 +8,10 @@
#include "diskpart.h"
BOOL extend_main(INT argc, LPWSTR *argv)
EXIT_CODE
extend_main(
_In_ INT argc,
_In_ PWSTR *argv)
{
return TRUE;
return EXIT_SUCCESS;
}

View File

@@ -84,7 +84,7 @@ ShowInstalledFileSystems(
}
BOOL
EXIT_CODE
filesystems_main(
_In_ INT argc,
_In_ PWSTR *argv)
@@ -92,7 +92,7 @@ filesystems_main(
if (CurrentVolume == NULL)
{
ConResPuts(StdOut, IDS_SELECT_NO_VOLUME);
return TRUE;
return EXIT_SUCCESS;
}
ConPuts(StdOut, L"\n");
@@ -100,5 +100,5 @@ filesystems_main(
ShowFileSystemInfo(CurrentVolume);
ShowInstalledFileSystems(CurrentVolume);
return TRUE;
return EXIT_SUCCESS;
}

View File

@@ -8,7 +8,10 @@
#include "diskpart.h"
BOOL format_main(INT argc, LPWSTR *argv)
EXIT_CODE
format_main(
_In_ INT argc,
_In_ PWSTR *argv)
{
return TRUE;
return EXIT_SUCCESS;
}

View File

@@ -12,10 +12,10 @@
#include <debug.h>
BOOL
EXIT_CODE
gpt_main(
INT argc,
LPWSTR *argv)
_In_ INT argc,
_In_ PWSTR *argv)
{
ULONGLONG ullAttributes = 0ULL;
PWSTR pszSuffix = NULL;
@@ -25,19 +25,19 @@ gpt_main(
if (CurrentDisk == NULL)
{
ConResPuts(StdOut, IDS_SELECT_NO_DISK);
return TRUE;
return EXIT_SUCCESS;
}
if (CurrentPartition == NULL)
{
ConResPuts(StdOut, IDS_SELECT_NO_PARTITION);
return TRUE;
return EXIT_SUCCESS;
}
if (CurrentDisk->PartitionStyle != PARTITION_STYLE_GPT)
{
ConResPuts(StdOut, IDS_CREATE_PARTITION_INVALID_STYLE);
return TRUE;
return EXIT_SUCCESS;
}
for (i = 1; i < argc; i++)
@@ -51,13 +51,13 @@ gpt_main(
if ((ullAttributes == 0) && (errno == ERANGE))
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
return EXIT_SUCCESS;
}
}
else
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
return EXIT_SUCCESS;
}
}
@@ -70,10 +70,10 @@ gpt_main(
if (!NT_SUCCESS(Status))
{
ConResPuts(StdOut, IDS_GPT_FAIL);
return TRUE;
return EXIT_SUCCESS;
}
ConResPuts(StdOut, IDS_GPT_SUCCESS);
return TRUE;
return EXIT_SUCCESS;
}

View File

@@ -42,7 +42,7 @@ HelpCommandList(VOID)
}
BOOL
EXIT_CODE
HelpCommand(
PCOMMAND pCommand)
{
@@ -110,14 +110,17 @@ HelpCommand(
ConPuts(StdOut, L"\n");
return TRUE;
return EXIT_SUCCESS;
}
/* help_main(char *arg):
* main entry point for the help command. Gives help to users who needs it.
*/
BOOL help_main(INT argc, LPWSTR *argv)
EXIT_CODE
help_main(
_In_ INT argc,
_In_ PWSTR *argv)
{
PCOMMAND cmdptr;
PCOMMAND cmdptr1 = NULL;
@@ -127,7 +130,7 @@ BOOL help_main(INT argc, LPWSTR *argv)
if (argc == 1)
{
HelpCommandList();
return TRUE;
return EXIT_SUCCESS;
}
/* Scan internal command table */
@@ -172,5 +175,5 @@ BOOL help_main(INT argc, LPWSTR *argv)
HelpCommandList();
return TRUE;
return EXIT_SUCCESS;
}

View File

@@ -8,7 +8,10 @@
#include "diskpart.h"
BOOL import_main(INT argc, LPWSTR *argv)
EXIT_CODE
import_main(
_In_ INT argc,
_In_ PWSTR *argv)
{
return TRUE;
return EXIT_SUCCESS;
}

View File

@@ -12,7 +12,7 @@
#include <debug.h>
BOOL
EXIT_CODE
inactive_main(
_In_ INT argc,
_In_ PWSTR *argv)
@@ -24,13 +24,13 @@ inactive_main(
if (CurrentDisk == NULL)
{
ConResPuts(StdOut, IDS_SELECT_NO_DISK);
return TRUE;
return EXIT_SUCCESS;
}
if (CurrentPartition == NULL)
{
ConResPuts(StdOut, IDS_SELECT_NO_PARTITION);
return TRUE;
return EXIT_SUCCESS;
}
if (CurrentDisk->PartitionStyle == PARTITION_STYLE_MBR)
@@ -38,7 +38,7 @@ inactive_main(
if (!CurrentPartition->Mbr.BootIndicator)
{
ConResPuts(StdOut, IDS_INACTIVE_ALREADY);
return TRUE;
return EXIT_SUCCESS;
}
CurrentPartition->Mbr.BootIndicator = FALSE;
@@ -59,5 +59,5 @@ inactive_main(
ConResPuts(StdOut, IDS_INACTIVE_NO_MBR);
}
return TRUE;
return EXIT_SUCCESS;
}

View File

@@ -10,9 +10,6 @@
#include "diskpart.h"
#include "diskpart_msg.h"
BOOL exit_main(INT argc, LPWSTR *argv);
BOOL rem_main(INT argc, LPWSTR *argv);
COMMAND cmds[] =
{
@@ -107,7 +104,7 @@ COMMAND cmds[] =
* compares the command name to a list of available commands, and
* determines which function to invoke.
*/
BOOL
EXIT_CODE
InterpretCmd(
int argc,
LPWSTR *argv)
@@ -119,15 +116,15 @@ InterpretCmd(
/* If no args provided */
if (argc < 1)
return TRUE;
return EXIT_SUCCESS;
/* First, determine if the user wants to exit
or to use a comment */
if (_wcsicmp(argv[0], L"exit") == 0)
return FALSE;
return EXIT_EXIT;
if (_wcsicmp(argv[0], L"rem") == 0)
return TRUE;
return EXIT_SUCCESS;
/* Scan internal command table */
for (cmdptr = cmds; cmdptr->cmd1; cmdptr++)
@@ -174,7 +171,7 @@ InterpretCmd(
HelpCommandList();
return TRUE;
return EXIT_SUCCESS;
}
@@ -182,14 +179,15 @@ InterpretCmd(
* InterpretScript(char *line):
* The main function used for when reading commands from scripts.
*/
BOOL
InterpretScript(LPWSTR input_line)
EXIT_CODE
InterpretScript(
_In_ PWSTR input_line)
{
LPWSTR args_vector[MAX_ARGS_COUNT];
PWSTR args_vector[MAX_ARGS_COUNT];
INT args_count = 0;
BOOL bWhiteSpace = TRUE;
BOOL bQuote = FALSE;
LPWSTR ptr;
PWSTR ptr;
memset(args_vector, 0, sizeof(args_vector));
@@ -238,10 +236,10 @@ InterpretMain(VOID)
INT args_count = 0;
BOOL bWhiteSpace = TRUE;
BOOL bQuote = FALSE;
BOOL bRun = TRUE;
EXIT_CODE ExitCode = EXIT_SUCCESS;
LPWSTR ptr;
while (bRun != FALSE)
while (ExitCode != EXIT_EXIT)
{
args_count = 0;
memset(args_vector, 0, sizeof(args_vector));
@@ -277,6 +275,6 @@ InterpretMain(VOID)
}
/* Send the string to find the command */
bRun = InterpretCmd(args_count, args_vector);
ExitCode = InterpretCmd(args_count, args_vector);
}
}

View File

@@ -148,10 +148,10 @@ PrintDisk(
}
BOOL
EXIT_CODE
ListDisk(
INT argc,
PWSTR *argv)
_In_ INT argc,
_In_ PWSTR *argv)
{
PLIST_ENTRY Entry;
PDISKENTRY DiskEntry;
@@ -173,14 +173,14 @@ ListDisk(
ConPuts(StdOut, L"\n\n");
return TRUE;
return EXIT_SUCCESS;
}
BOOL
EXIT_CODE
ListPartition(
INT argc,
PWSTR *argv)
_In_ INT argc,
_In_ PWSTR *argv)
{
PLIST_ENTRY Entry;
PPARTENTRY PartEntry;
@@ -194,7 +194,7 @@ ListPartition(
if (CurrentDisk == NULL)
{
ConResPuts(StdOut, IDS_LIST_PARTITION_NO_DISK);
return TRUE;
return EXIT_SUCCESS;
}
if (CurrentDisk->PartitionStyle == PARTITION_STYLE_MBR)
@@ -227,7 +227,7 @@ ListPartition(
ConPuts(StdOut, L"\n");
ConResPuts(StdOut, IDS_LIST_PARTITION_NONE);
ConPuts(StdOut, L"\n");
return TRUE;
return EXIT_SUCCESS;
}
/* Header labels */
@@ -463,7 +463,7 @@ ListPartition(
ConPuts(StdOut, L"\n");
return TRUE;
return EXIT_SUCCESS;
}
@@ -525,10 +525,10 @@ PrintVolume(
}
BOOL
EXIT_CODE
ListVolume(
INT argc,
PWSTR *argv)
_In_ INT argc,
_In_ PWSTR *argv)
{
PLIST_ENTRY Entry;
PVOLENTRY VolumeEntry;
@@ -549,15 +549,15 @@ ListVolume(
ConPuts(StdOut, L"\n");
return TRUE;
return EXIT_SUCCESS;
}
BOOL
EXIT_CODE
ListVirtualDisk(
INT argc,
PWSTR *argv)
_In_ INT argc,
_In_ PWSTR *argv)
{
ConPuts(StdOut, L"ListVirtualDisk()!\n");
return TRUE;
return EXIT_SUCCESS;
}

View File

@@ -8,7 +8,10 @@
#include "diskpart.h"
BOOL merge_main(INT argc, LPWSTR *argv)
EXIT_CODE
merge_main(
_In_ INT argc,
_In_ PWSTR *argv)
{
return TRUE;
return EXIT_SUCCESS;
}

View File

@@ -8,7 +8,10 @@
#include "diskpart.h"
BOOL offline_main(INT argc, LPWSTR *argv)
EXIT_CODE
offline_main(
_In_ INT argc,
_In_ PWSTR *argv)
{
return TRUE;
return EXIT_SUCCESS;
}

View File

@@ -8,7 +8,10 @@
#include "diskpart.h"
BOOL online_main(INT argc, LPWSTR *argv)
EXIT_CODE
online_main(
_In_ INT argc,
_In_ PWSTR *argv)
{
return TRUE;
return EXIT_SUCCESS;
}

View File

@@ -8,7 +8,10 @@
#include "diskpart.h"
BOOL recover_main(INT argc, LPWSTR *argv)
EXIT_CODE
recover_main(
_In_ INT argc,
_In_ PWSTR *argv)
{
return TRUE;
return EXIT_SUCCESS;
}

View File

@@ -11,10 +11,10 @@
#define NDEBUG
#include <debug.h>
BOOL
EXIT_CODE
remove_main(
_In_ INT argc,
_In_ LPWSTR *argv)
_In_ PWSTR *argv)
{
PWSTR pszSuffix = NULL;
WCHAR DriveLetter = UNICODE_NULL;
@@ -26,13 +26,13 @@ remove_main(
if (CurrentVolume == NULL)
{
ConResPuts(StdOut, IDS_SELECT_NO_VOLUME);
return TRUE;
return EXIT_SUCCESS;
}
if (CurrentVolume->DriveLetter == UNICODE_NULL)
{
ConResPuts(StdOut, IDS_REMOVE_NO_LETTER);
return TRUE;
return EXIT_SUCCESS;
}
for (i = 1; i < argc; i++)
@@ -59,7 +59,7 @@ remove_main(
else
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
return EXIT_SUCCESS;
}
}
else if (HasPrefix(argv[i], L"mount=", &pszSuffix))
@@ -84,14 +84,14 @@ remove_main(
else
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
return EXIT_SUCCESS;
}
}
if (nExclusive > 1)
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
return EXIT_SUCCESS;
}
DPRINT("VolumeName: %S\n", CurrentVolume->VolumeName);
@@ -105,13 +105,13 @@ remove_main(
if ((DriveLetter < L'C') || (DriveLetter > L'Z'))
{
ConResPuts(StdOut, IDS_ASSIGN_INVALID_LETTER);
return TRUE;
return EXIT_SUCCESS;
}
if (DriveLetter != CurrentVolume->DriveLetter)
{
ConResPuts(StdOut, IDS_REMOVE_WRONG_LETTER);
return TRUE;
return EXIT_SUCCESS;
}
}
else
@@ -123,11 +123,11 @@ remove_main(
if (bResult == FALSE)
{
ConResPuts(StdOut, IDS_REMOVE_FAIL);
return TRUE;
return EXIT_SUCCESS;
}
CurrentVolume->DriveLetter = UNICODE_NULL;
ConResPuts(StdOut, IDS_REMOVE_SUCCESS);
return TRUE;
return EXIT_SUCCESS;
}

View File

@@ -8,8 +8,11 @@
#include "diskpart.h"
BOOL repair_main(INT argc, LPWSTR *argv)
EXIT_CODE
repair_main(
_In_ INT argc,
_In_ PWSTR *argv)
{
ConPuts(StdOut, L"\nTODO: Add code later since Win 7 Home Premium doesn't have this feature.\n");
return TRUE;
return EXIT_SUCCESS;
}

View File

@@ -8,7 +8,10 @@
#include "diskpart.h"
BOOL rescan_main(INT argc, LPWSTR *argv)
EXIT_CODE
rescan_main(
_In_ INT argc,
_In_ PWSTR *argv)
{
ConResPuts(StdOut, IDS_RESCAN_START);
DestroyVolumeList();
@@ -17,5 +20,5 @@ BOOL rescan_main(INT argc, LPWSTR *argv)
CreateVolumeList();
ConResPuts(StdOut, IDS_RESCAN_END);
return TRUE;
return EXIT_SUCCESS;
}

View File

@@ -8,7 +8,10 @@
#include "diskpart.h"
BOOL retain_main(INT argc, LPWSTR *argv)
EXIT_CODE
retain_main(
_In_ INT argc,
_In_ PWSTR *argv)
{
return TRUE;
return EXIT_SUCCESS;
}

View File

@@ -8,7 +8,10 @@
#include "diskpart.h"
BOOL san_main(INT argc, LPWSTR *argv)
EXIT_CODE
san_main(
_In_ INT argc,
_In_ PWSTR *argv)
{
return TRUE;
return EXIT_SUCCESS;
}

View File

@@ -13,10 +13,10 @@
/* FUNCTIONS ******************************************************************/
BOOL
EXIT_CODE
SelectDisk(
INT argc,
PWSTR *argv)
_In_ INT argc,
_In_ PWSTR *argv)
{
PLIST_ENTRY Entry;
PDISKENTRY DiskEntry;
@@ -27,7 +27,7 @@ SelectDisk(
if (argc > 3)
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
return EXIT_SUCCESS;
}
if (argc == 2)
@@ -36,7 +36,7 @@ SelectDisk(
ConResPuts(StdOut, IDS_SELECT_NO_DISK);
else
ConResPrintf(StdOut, IDS_SELECT_DISK, CurrentDisk->DiskNumber);
return TRUE;
return EXIT_SUCCESS;
}
if (!_wcsicmp(argv[2], L"system"))
@@ -49,7 +49,7 @@ SelectDisk(
CurrentDisk = DiskEntry;
CurrentPartition = NULL;
ConResPrintf(StdOut, IDS_SELECT_DISK, CurrentDisk->DiskNumber);
return TRUE;
return EXIT_SUCCESS;
}
else if (!_wcsicmp(argv[2], L"next"))
{
@@ -57,7 +57,7 @@ SelectDisk(
{
CurrentPartition = NULL;
ConResPuts(StdErr, IDS_SELECT_DISK_ENUM_NO_START);
return TRUE;
return EXIT_SUCCESS;
}
if (CurrentDisk->ListEntry.Flink == &DiskListHead)
@@ -65,7 +65,7 @@ SelectDisk(
CurrentDisk = NULL;
CurrentPartition = NULL;
ConResPuts(StdErr, IDS_SELECT_DISK_ENUM_FINISHED);
return TRUE;
return EXIT_SUCCESS;
}
Entry = CurrentDisk->ListEntry.Flink;
@@ -75,7 +75,7 @@ SelectDisk(
CurrentDisk = DiskEntry;
CurrentPartition = NULL;
ConResPrintf(StdOut, IDS_SELECT_DISK, CurrentDisk->DiskNumber);
return TRUE;
return EXIT_SUCCESS;
}
else if (IsDecString(argv[2]))
{
@@ -83,7 +83,7 @@ SelectDisk(
if ((ulValue == 0) && (errno == ERANGE))
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
return EXIT_SUCCESS;
}
CurrentDisk = NULL;
@@ -98,7 +98,7 @@ SelectDisk(
CurrentDisk = DiskEntry;
CurrentPartition = NULL;
ConResPrintf(StdOut, IDS_SELECT_DISK, CurrentDisk->DiskNumber);
return TRUE;
return EXIT_SUCCESS;
}
Entry = Entry->Flink;
@@ -107,18 +107,18 @@ SelectDisk(
else
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
return EXIT_SUCCESS;
}
ConResPuts(StdErr, IDS_SELECT_DISK_INVALID);
return TRUE;
return EXIT_SUCCESS;
}
BOOL
EXIT_CODE
SelectPartition(
INT argc,
PWSTR *argv)
_In_ INT argc,
_In_ PWSTR *argv)
{
PLIST_ENTRY Entry;
PPARTENTRY PartEntry;
@@ -130,13 +130,13 @@ SelectPartition(
if (argc > 3)
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
return EXIT_SUCCESS;
}
if (CurrentDisk == NULL)
{
ConResPuts(StdOut, IDS_SELECT_PARTITION_NO_DISK);
return TRUE;
return EXIT_SUCCESS;
}
if (argc == 2)
@@ -145,20 +145,20 @@ SelectPartition(
ConResPuts(StdOut, IDS_SELECT_NO_PARTITION);
else
ConResPrintf(StdOut, IDS_SELECT_PARTITION, CurrentPartition);
return TRUE;
return EXIT_SUCCESS;
}
if (!IsDecString(argv[2]))
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
return EXIT_SUCCESS;
}
ulValue = wcstoul(argv[2], NULL, 10);
if ((ulValue == 0) && (errno == ERANGE))
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
return EXIT_SUCCESS;
}
if (CurrentDisk->PartitionStyle == PARTITION_STYLE_MBR)
@@ -174,7 +174,7 @@ SelectPartition(
{
CurrentPartition = PartEntry;
ConResPrintf(StdOut, IDS_SELECT_PARTITION, PartNumber);
return TRUE;
return EXIT_SUCCESS;
}
PartNumber++;
@@ -194,7 +194,7 @@ SelectPartition(
{
CurrentPartition = PartEntry;
ConResPrintf(StdOut, IDS_SELECT_PARTITION, PartNumber);
return TRUE;
return EXIT_SUCCESS;
}
PartNumber++;
@@ -215,7 +215,7 @@ SelectPartition(
{
CurrentPartition = PartEntry;
ConResPrintf(StdOut, IDS_SELECT_PARTITION, PartNumber);
return TRUE;
return EXIT_SUCCESS;
}
PartNumber++;
@@ -226,14 +226,14 @@ SelectPartition(
}
ConResPuts(StdErr, IDS_SELECT_PARTITION_INVALID);
return TRUE;
return EXIT_SUCCESS;
}
BOOL
EXIT_CODE
SelectVolume(
INT argc,
PWSTR *argv)
_In_ INT argc,
_In_ PWSTR *argv)
{
PLIST_ENTRY Entry;
PVOLENTRY VolumeEntry;
@@ -244,7 +244,7 @@ SelectVolume(
if (argc > 3)
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
return EXIT_SUCCESS;
}
if (argc == 2)
@@ -253,20 +253,20 @@ SelectVolume(
ConResPuts(StdOut, IDS_SELECT_NO_VOLUME);
else
ConResPrintf(StdOut, IDS_SELECT_VOLUME, CurrentVolume->VolumeNumber);
return TRUE;
return EXIT_SUCCESS;
}
if (!IsDecString(argv[2]))
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
return EXIT_SUCCESS;
}
ulValue = wcstoul(argv[2], NULL, 10);
if ((ulValue == 0) && (errno == ERANGE))
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
return EXIT_SUCCESS;
}
CurrentVolume = NULL;
@@ -287,5 +287,5 @@ SelectVolume(
}
ConResPuts(StdErr, IDS_SELECT_VOLUME_INVALID);
return TRUE;
return EXIT_SUCCESS;
}

View File

@@ -12,7 +12,7 @@
#include <debug.h>
BOOL
EXIT_CODE
setid_main(
_In_ INT argc,
_In_ PWSTR *argv)
@@ -26,13 +26,13 @@ setid_main(
if (CurrentDisk == NULL)
{
ConResPuts(StdOut, IDS_SELECT_NO_DISK);
return TRUE;
return EXIT_SUCCESS;
}
if (CurrentPartition == NULL)
{
ConResPuts(StdOut, IDS_SELECT_NO_PARTITION);
return TRUE;
return EXIT_SUCCESS;
}
for (i = 1; i < argc; i++)
@@ -66,7 +66,7 @@ setid_main(
else
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
return EXIT_SUCCESS;
}
}
@@ -75,7 +75,7 @@ setid_main(
if (!StringToGUID(&CurrentPartition->Gpt.PartitionType, pszId))
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
return EXIT_SUCCESS;
}
CurrentDisk->Dirty = TRUE;
@@ -84,7 +84,7 @@ setid_main(
if (!NT_SUCCESS(Status))
{
ConResPuts(StdOut, IDS_SETID_FAIL);
return TRUE;
return EXIT_SUCCESS;
}
}
else if (CurrentDisk->PartitionStyle == PARTITION_STYLE_MBR)
@@ -95,26 +95,26 @@ setid_main(
if (length == 0)
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
return EXIT_SUCCESS;
}
if (length > 2)
{
ConResPuts(StdErr, IDS_SETID_INVALID_FORMAT);
return TRUE;
return EXIT_SUCCESS;
}
PartitionType = (UCHAR)wcstoul(pszSuffix, NULL, 16);
if ((PartitionType == 0) && (errno == ERANGE))
{
ConResPuts(StdErr, IDS_SETID_INVALID_FORMAT);
return TRUE;
return EXIT_SUCCESS;
}
if (PartitionType == 0x42)
{
ConResPuts(StdErr, IDS_SETID_INVALID_TYPE);
return TRUE;
return EXIT_SUCCESS;
}
CurrentPartition->Mbr.PartitionType = PartitionType;
@@ -124,11 +124,11 @@ setid_main(
if (!NT_SUCCESS(Status))
{
ConResPuts(StdOut, IDS_SETID_FAIL);
return TRUE;
return EXIT_SUCCESS;
}
}
ConResPuts(StdOut, IDS_SETID_SUCCESS);
return TRUE;
return EXIT_SUCCESS;
}

View File

@@ -8,7 +8,10 @@
#include "diskpart.h"
BOOL shrink_main(INT argc, LPWSTR *argv)
EXIT_CODE
shrink_main(
_In_ INT argc,
_In_ PWSTR *argv)
{
return TRUE;
return EXIT_SUCCESS;
}

View File

@@ -13,7 +13,7 @@
/* FUNCTIONS ******************************************************************/
BOOL
EXIT_CODE
UniqueIdDisk(
_In_ INT argc,
_In_ PWSTR *argv)
@@ -26,7 +26,7 @@ UniqueIdDisk(
if (CurrentDisk == NULL)
{
ConResPuts(StdOut, IDS_SELECT_NO_DISK);
return TRUE;
return EXIT_SUCCESS;
}
if (argc == 2)
@@ -40,13 +40,13 @@ UniqueIdDisk(
wcscpy(szBuffer, L"00000000");
ConPrintf(StdOut, L"Disk ID: %s\n", szBuffer);
ConPuts(StdOut, L"\n");
return TRUE;
return EXIT_SUCCESS;
}
if (argc != 3)
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
return EXIT_SUCCESS;
}
for (i = 1; i < argc; i++)
@@ -74,7 +74,7 @@ UniqueIdDisk(
else
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
return EXIT_SUCCESS;
}
}
@@ -83,7 +83,7 @@ UniqueIdDisk(
if (!StringToGUID(&CurrentDisk->LayoutBuffer->Gpt.DiskId, pszId))
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
return EXIT_SUCCESS;
}
CurrentDisk->Dirty = TRUE;
@@ -97,14 +97,14 @@ UniqueIdDisk(
(IsHexString(pszId) == FALSE))
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
return EXIT_SUCCESS;
}
ulValue = wcstoul(pszId, NULL, 16);
if ((ulValue == 0) && (errno == ERANGE))
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return TRUE;
return EXIT_SUCCESS;
}
DPRINT("New Signature: 0x%08lx\n", ulValue);
@@ -118,5 +118,5 @@ UniqueIdDisk(
ConResPuts(StdOut, IDS_UNIQUID_DISK_INVALID_STYLE);
}
return TRUE;
return EXIT_SUCCESS;
}