mirror of
https://github.com/reactos/reactos.git
synced 2025-06-01 15:38:37 +00:00
[DISKPART]
- Use the partition list code from usetup. Scan all harddisks at startup and keep the list alive as long as diskpart is running. - Use the partiton list in the 'select disk' and 'list disk' commands. - Implement the 'list disk' and 'list partition' commmands. - Add required strings. svn path=/trunk/; revision=68473
This commit is contained in:
parent
afe5b2c7bf
commit
062fc062d2
12 changed files with 1640 additions and 162 deletions
|
@ -28,6 +28,7 @@ list(APPEND SOURCE
|
||||||
merge.c
|
merge.c
|
||||||
offline.c
|
offline.c
|
||||||
online.c
|
online.c
|
||||||
|
partlist.c
|
||||||
recover.c
|
recover.c
|
||||||
remove.c
|
remove.c
|
||||||
repair.c
|
repair.c
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include <winuser.h>
|
#include <winuser.h>
|
||||||
|
|
||||||
/* FUNCTIONS ******************************************************************/
|
/* FUNCTIONS ******************************************************************/
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
PrintResourceString(INT resID, ...)
|
PrintResourceString(INT resID, ...)
|
||||||
{
|
{
|
||||||
|
@ -95,17 +96,20 @@ int wmain(int argc, const LPWSTR argv[])
|
||||||
LPCWSTR tmpBuffer = NULL;
|
LPCWSTR tmpBuffer = NULL;
|
||||||
WCHAR appTitle[50];
|
WCHAR appTitle[50];
|
||||||
int index, timeout;
|
int index, timeout;
|
||||||
|
int result = EXIT_SUCCESS;
|
||||||
|
|
||||||
/* Sets the title of the program so the user will have an easier time
|
/* Sets the title of the program so the user will have an easier time
|
||||||
determining the current program, especially if diskpart is running a
|
determining the current program, especially if diskpart is running a
|
||||||
script */
|
script */
|
||||||
LoadStringW(GetModuleHandle(NULL), IDS_APP_HEADER, (LPWSTR)appTitle, 50);
|
LoadStringW(GetModuleHandle(NULL), IDS_APP_HEADER, (LPWSTR)appTitle, 50);
|
||||||
SetConsoleTitleW(appTitle);
|
SetConsoleTitleW(appTitle);
|
||||||
|
|
||||||
/* Sets the timeout value to 0 just in case the user doesn't
|
/* Sets the timeout value to 0 just in case the user doesn't
|
||||||
specify a value */
|
specify a value */
|
||||||
timeout = 0;
|
timeout = 0;
|
||||||
|
|
||||||
|
CreatePartitionList();
|
||||||
|
|
||||||
/* If there are no command arguments, then go straight to the interpreter */
|
/* If there are no command arguments, then go straight to the interpreter */
|
||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
{
|
{
|
||||||
|
@ -127,7 +131,8 @@ int wmain(int argc, const LPWSTR argv[])
|
||||||
{
|
{
|
||||||
/* If there is no flag, then return an error */
|
/* If there is no flag, then return an error */
|
||||||
PrintResourceString(IDS_ERROR_MSG_BAD_ARG, argv[index]);
|
PrintResourceString(IDS_ERROR_MSG_BAD_ARG, argv[index]);
|
||||||
return EXIT_FAILURE;
|
result = EXIT_FAILURE;
|
||||||
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Checks for the /? flag first since the program
|
/* Checks for the /? flag first since the program
|
||||||
|
@ -135,7 +140,8 @@ int wmain(int argc, const LPWSTR argv[])
|
||||||
if (_wcsicmp(tmpBuffer, L"?") == 0)
|
if (_wcsicmp(tmpBuffer, L"?") == 0)
|
||||||
{
|
{
|
||||||
PrintResourceString(IDS_APP_USAGE);
|
PrintResourceString(IDS_APP_USAGE);
|
||||||
return EXIT_SUCCESS;
|
result = EXIT_SUCCESS;
|
||||||
|
goto done;
|
||||||
}
|
}
|
||||||
/* Checks for the script flag */
|
/* Checks for the script flag */
|
||||||
else if (_wcsicmp(tmpBuffer, L"s") == 0)
|
else if (_wcsicmp(tmpBuffer, L"s") == 0)
|
||||||
|
@ -164,7 +170,8 @@ int wmain(int argc, const LPWSTR argv[])
|
||||||
{
|
{
|
||||||
/* Assume that the flag doesn't exist. */
|
/* Assume that the flag doesn't exist. */
|
||||||
PrintResourceString(IDS_ERROR_MSG_BAD_ARG, tmpBuffer);
|
PrintResourceString(IDS_ERROR_MSG_BAD_ARG, tmpBuffer);
|
||||||
return EXIT_FAILURE;
|
result = EXIT_FAILURE;
|
||||||
|
goto done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,18 +187,25 @@ int wmain(int argc, const LPWSTR argv[])
|
||||||
Sleep(timeout * 1000);
|
Sleep(timeout * 1000);
|
||||||
|
|
||||||
if (RunScript(script) == FALSE)
|
if (RunScript(script) == FALSE)
|
||||||
return EXIT_FAILURE;
|
{
|
||||||
|
result = EXIT_FAILURE;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Exit failure since the user wanted to run a script */
|
/* Exit failure since the user wanted to run a script */
|
||||||
PrintResourceString(IDS_ERROR_MSG_NO_SCRIPT, script);
|
PrintResourceString(IDS_ERROR_MSG_NO_SCRIPT, script);
|
||||||
return EXIT_FAILURE;
|
result = EXIT_FAILURE;
|
||||||
|
goto done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Let the user know the program is exiting */
|
/* Let the user know the program is exiting */
|
||||||
PrintResourceString(IDS_APP_LEAVING);
|
PrintResourceString(IDS_APP_LEAVING);
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
done:
|
||||||
|
DestroyPartitionList();
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,11 @@
|
||||||
#define WIN32_NO_STATUS
|
#define WIN32_NO_STATUS
|
||||||
#include <windef.h>
|
#include <windef.h>
|
||||||
#include <winbase.h>
|
#include <winbase.h>
|
||||||
|
#include <winreg.h>
|
||||||
|
#include <winuser.h>
|
||||||
|
#include <wincon.h>
|
||||||
|
|
||||||
|
/*
|
||||||
#define NTOS_MODE_USER
|
#define NTOS_MODE_USER
|
||||||
#include <ndk/exfuncs.h>
|
#include <ndk/exfuncs.h>
|
||||||
#include <ndk/iofuncs.h>
|
#include <ndk/iofuncs.h>
|
||||||
|
@ -24,6 +29,19 @@
|
||||||
#include <ndk/psfuncs.h>
|
#include <ndk/psfuncs.h>
|
||||||
#include <ndk/rtlfuncs.h>
|
#include <ndk/rtlfuncs.h>
|
||||||
#include <ndk/umfuncs.h>
|
#include <ndk/umfuncs.h>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define NTOS_MODE_USER
|
||||||
|
#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 "resource.h"
|
||||||
|
|
||||||
|
@ -50,10 +68,115 @@ extern COMMAND cmds[];
|
||||||
#define MAX_STRING_SIZE 1024
|
#define MAX_STRING_SIZE 1024
|
||||||
#define MAX_ARGS_COUNT 256
|
#define MAX_ARGS_COUNT 256
|
||||||
|
|
||||||
|
|
||||||
|
typedef enum _FORMATSTATE
|
||||||
|
{
|
||||||
|
Unformatted,
|
||||||
|
UnformattedOrDamaged,
|
||||||
|
UnknownFormat,
|
||||||
|
Preformatted,
|
||||||
|
Formatted
|
||||||
|
} FORMATSTATE, *PFORMATSTATE;
|
||||||
|
|
||||||
|
typedef struct _PARTENTRY
|
||||||
|
{
|
||||||
|
LIST_ENTRY ListEntry;
|
||||||
|
|
||||||
|
struct _DISKENTRY *DiskEntry;
|
||||||
|
|
||||||
|
ULARGE_INTEGER StartSector;
|
||||||
|
ULARGE_INTEGER SectorCount;
|
||||||
|
|
||||||
|
BOOLEAN BootIndicator;
|
||||||
|
UCHAR PartitionType;
|
||||||
|
ULONG HiddenSectors;
|
||||||
|
ULONG PartitionNumber;
|
||||||
|
ULONG PartitionIndex;
|
||||||
|
|
||||||
|
CHAR DriveLetter;
|
||||||
|
CHAR VolumeLabel[17];
|
||||||
|
CHAR FileSystemName[9];
|
||||||
|
|
||||||
|
BOOLEAN LogicalPartition;
|
||||||
|
|
||||||
|
/* Partition is partitioned disk space */
|
||||||
|
BOOLEAN IsPartitioned;
|
||||||
|
|
||||||
|
/* Partition is new. Table does not exist on disk yet */
|
||||||
|
BOOLEAN New;
|
||||||
|
|
||||||
|
/* Partition was created automatically. */
|
||||||
|
BOOLEAN AutoCreate;
|
||||||
|
|
||||||
|
FORMATSTATE FormatState;
|
||||||
|
|
||||||
|
/* Partition must be checked */
|
||||||
|
BOOLEAN NeedsCheck;
|
||||||
|
|
||||||
|
struct _FILE_SYSTEM_ITEM *FileSystem;
|
||||||
|
} PARTENTRY, *PPARTENTRY;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _BIOSDISKENTRY
|
||||||
|
{
|
||||||
|
LIST_ENTRY ListEntry;
|
||||||
|
ULONG DiskNumber;
|
||||||
|
ULONG Signature;
|
||||||
|
ULONG Checksum;
|
||||||
|
BOOLEAN Recognized;
|
||||||
|
CM_DISK_GEOMETRY_DEVICE_DATA DiskGeometry;
|
||||||
|
CM_INT13_DRIVE_PARAMETER Int13DiskData;
|
||||||
|
} BIOSDISKENTRY, *PBIOSDISKENTRY;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _DISKENTRY
|
||||||
|
{
|
||||||
|
LIST_ENTRY ListEntry;
|
||||||
|
|
||||||
|
ULONGLONG Cylinders;
|
||||||
|
ULONG TracksPerCylinder;
|
||||||
|
ULONG SectorsPerTrack;
|
||||||
|
ULONG BytesPerSector;
|
||||||
|
|
||||||
|
ULARGE_INTEGER SectorCount;
|
||||||
|
ULONG SectorAlignment;
|
||||||
|
ULONG CylinderAlignment;
|
||||||
|
|
||||||
|
BOOLEAN BiosFound;
|
||||||
|
ULONG BiosDiskNumber;
|
||||||
|
// ULONG Signature;
|
||||||
|
// ULONG Checksum;
|
||||||
|
|
||||||
|
ULONG DiskNumber;
|
||||||
|
USHORT Port;
|
||||||
|
USHORT Bus;
|
||||||
|
USHORT Id;
|
||||||
|
|
||||||
|
/* Has the partition list been modified? */
|
||||||
|
BOOLEAN Dirty;
|
||||||
|
|
||||||
|
BOOLEAN NewDisk;
|
||||||
|
BOOLEAN NoMbr; /* MBR is absent */
|
||||||
|
|
||||||
|
UNICODE_STRING DriverName;
|
||||||
|
|
||||||
|
PDRIVE_LAYOUT_INFORMATION LayoutBuffer;
|
||||||
|
|
||||||
|
PPARTENTRY ExtendedPartition;
|
||||||
|
|
||||||
|
LIST_ENTRY PrimaryPartListHead;
|
||||||
|
LIST_ENTRY LogicalPartListHead;
|
||||||
|
|
||||||
|
} DISKENTRY, *PDISKENTRY;
|
||||||
|
|
||||||
|
|
||||||
/* GLOBAL VARIABLES ***********************************************************/
|
/* GLOBAL VARIABLES ***********************************************************/
|
||||||
|
|
||||||
ULONG CurrentDisk;
|
extern LIST_ENTRY DiskListHead;
|
||||||
ULONG CurrentPartition;
|
extern LIST_ENTRY BiosDiskListHead;
|
||||||
|
|
||||||
|
extern PDISKENTRY CurrentDisk;
|
||||||
|
extern PPARTENTRY CurrentPartition;
|
||||||
|
|
||||||
/* PROTOTYPES *****************************************************************/
|
/* PROTOTYPES *****************************************************************/
|
||||||
|
|
||||||
|
@ -144,6 +267,13 @@ BOOL offline_main(INT argc, LPWSTR *argv);
|
||||||
/* online.c */
|
/* online.c */
|
||||||
BOOL online_main(INT argc, LPWSTR *argv);
|
BOOL online_main(INT argc, LPWSTR *argv);
|
||||||
|
|
||||||
|
/* partlist.c */
|
||||||
|
NTSTATUS
|
||||||
|
CreatePartitionList(VOID);
|
||||||
|
|
||||||
|
VOID
|
||||||
|
DestroyPartitionList(VOID);
|
||||||
|
|
||||||
/* recover.c */
|
/* recover.c */
|
||||||
BOOL recover_main(INT argc, LPWSTR *argv);
|
BOOL recover_main(INT argc, LPWSTR *argv);
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,10 @@ BEGIN
|
||||||
IDS_LIST_DISK_HEAD "\n Disk ### Status Size Free Dyn Gpt\n"
|
IDS_LIST_DISK_HEAD "\n Disk ### Status Size Free Dyn Gpt\n"
|
||||||
IDS_LIST_DISK_LINE " -------- ---------- ------- ------- --- ---\n"
|
IDS_LIST_DISK_LINE " -------- ---------- ------- ------- --- ---\n"
|
||||||
IDS_LIST_DISK_FORMAT "%c %7lu %-10s %4I64u %-2s %4I64u %-2s %1s %1s\n"
|
IDS_LIST_DISK_FORMAT "%c %7lu %-10s %4I64u %-2s %4I64u %-2s %1s %1s\n"
|
||||||
|
IDS_LIST_PARTITION_HEAD "\n Partition Type Size Offset\n"
|
||||||
|
IDS_LIST_PARTITION_LINE " ------------- ---------------- ------- -------\n"
|
||||||
|
IDS_LIST_PARTITION_FORMAT "%c Partition %2lu %-16s %4I64u %-2s %4I64u %-2s\n"
|
||||||
|
IDS_LIST_PARTITION_NO_DISK "\nThere is no disk for listing partitions.\nPlease select a disk and try again.\n\n"
|
||||||
IDS_LIST_VOLUME_HEAD " Volume ### Ltr Label\n"
|
IDS_LIST_VOLUME_HEAD " Volume ### Ltr Label\n"
|
||||||
END
|
END
|
||||||
|
|
||||||
|
@ -48,10 +52,13 @@ STRINGTABLE
|
||||||
BEGIN
|
BEGIN
|
||||||
IDS_SELECT_NO_DISK "\nThere is no disk currently selected.\nPlease select a disk and try again.\n\n"
|
IDS_SELECT_NO_DISK "\nThere is no disk currently selected.\nPlease select a disk and try again.\n\n"
|
||||||
IDS_SELECT_DISK "\nDisk %lu is now the selected disk.\n\n"
|
IDS_SELECT_DISK "\nDisk %lu is now the selected disk.\n\n"
|
||||||
IDS_SELECT_NO_VOLUME "\nThere is no volume currently selected.\nPlease select a disk and try again.\n\n"
|
IDS_SELECT_DISK_INVALID "\nInvalid disk.\n\n"
|
||||||
IDS_SELECT_VOLUME "\nVolume %lu is now the selected volume.\n\n"
|
|
||||||
IDS_SELECT_NO_PARTITION "\nThere is no partition currently selected.\nPlease select a disk and try again.\n\n"
|
IDS_SELECT_NO_PARTITION "\nThere is no partition currently selected.\nPlease select a disk and try again.\n\n"
|
||||||
IDS_SELECT_PARTITION "\nPartition %lu is now the selected partition.\n\n"
|
IDS_SELECT_PARTITION "\nPartition %lu is now the selected partition.\n\n"
|
||||||
|
IDS_SELECT_PARTITION_NO_DISK "\nThere is no disk for selecting a partition.\nPlease select a disk and try again.\n\n"
|
||||||
|
IDS_SELECT_PARTITION_INVALID "\nInvalid partition.\n\n"
|
||||||
|
IDS_SELECT_NO_VOLUME "\nThere is no volume currently selected.\nPlease select a disk and try again.\n\n"
|
||||||
|
IDS_SELECT_VOLUME "\nVolume %lu is now the selected volume.\n\n"
|
||||||
END
|
END
|
||||||
|
|
||||||
/* Disk Status */
|
/* Disk Status */
|
||||||
|
@ -122,7 +129,6 @@ BEGIN
|
||||||
IDS_ERROR_MSG_NO_SCRIPT "Error opening script: %s\n"
|
IDS_ERROR_MSG_NO_SCRIPT "Error opening script: %s\n"
|
||||||
IDS_ERROR_MSG_BAD_ARG "Error processing argument: %s\n"
|
IDS_ERROR_MSG_BAD_ARG "Error processing argument: %s\n"
|
||||||
IDS_ERROR_INVALID_ARGS "Invalid arguments\n"
|
IDS_ERROR_INVALID_ARGS "Invalid arguments\n"
|
||||||
IDS_ERROR_INVALID_DISK "Invalid disk\n"
|
|
||||||
END
|
END
|
||||||
|
|
||||||
/* Active help descriptions */
|
/* Active help descriptions */
|
||||||
|
|
|
@ -41,6 +41,10 @@ BEGIN
|
||||||
IDS_LIST_DISK_HEAD "\n Disc ### Stare Dimensiune Liber Dyn Gpt\n"
|
IDS_LIST_DISK_HEAD "\n Disc ### Stare Dimensiune Liber Dyn Gpt\n"
|
||||||
IDS_LIST_DISK_LINE " -------- ---------- ---------- ------- --- ---\n"
|
IDS_LIST_DISK_LINE " -------- ---------- ---------- ------- --- ---\n"
|
||||||
IDS_LIST_DISK_FORMAT "%c %7lu %-10s %4I64u %-2s %4I64u %-2s %1s %1s\n"
|
IDS_LIST_DISK_FORMAT "%c %7lu %-10s %4I64u %-2s %4I64u %-2s %1s %1s\n"
|
||||||
|
IDS_LIST_PARTITION_HEAD "\n Partition Type Size Offset\n"
|
||||||
|
IDS_LIST_PARTITION_LINE " ------------- ---------------- ------- -------\n"
|
||||||
|
IDS_LIST_PARTITION_FORMAT "%c Partition %2lu %-16s %4I64u %-2s %4I64u %-2s\n"
|
||||||
|
IDS_LIST_PARTITION_NO_DISK "\nThere is no disk for listing partitions.\nPlease select a disk and try again.\n\n"
|
||||||
IDS_LIST_VOLUME_HEAD "Volum ###\tLtr\tEtichetă\n"
|
IDS_LIST_VOLUME_HEAD "Volum ###\tLtr\tEtichetă\n"
|
||||||
END
|
END
|
||||||
|
|
||||||
|
@ -49,10 +53,13 @@ STRINGTABLE
|
||||||
BEGIN
|
BEGIN
|
||||||
IDS_SELECT_NO_DISK "\nThere is no disk currently selected.\nPlease select a disk and try again.\n\n"
|
IDS_SELECT_NO_DISK "\nThere is no disk currently selected.\nPlease select a disk and try again.\n\n"
|
||||||
IDS_SELECT_DISK "\nDisk %lu is now the selected disk.\n\n"
|
IDS_SELECT_DISK "\nDisk %lu is now the selected disk.\n\n"
|
||||||
IDS_SELECT_NO_VOLUME "\nThere is no volume currently selected.\nPlease select a disk and try again.\n\n"
|
IDS_SELECT_DISK_INVALID "\nInvalid disk.\n\n"
|
||||||
IDS_SELECT_VOLUME "\nVolume %lu is now the selected volume.\n\n"
|
|
||||||
IDS_SELECT_NO_PARTITION "\nThere is no partition currently selected.\nPlease select a disk and try again.\n\n"
|
IDS_SELECT_NO_PARTITION "\nThere is no partition currently selected.\nPlease select a disk and try again.\n\n"
|
||||||
IDS_SELECT_PARTITION "\nPartition %lu is now the selected partition.\n\n"
|
IDS_SELECT_PARTITION "\nPartition %lu is now the selected partition.\n\n"
|
||||||
|
IDS_SELECT_PARTITION_NO_DISK "\nThere is no disk for selecting a partition.\nPlease select a disk and try again.\n\n"
|
||||||
|
IDS_SELECT_PARTITION_INVALID "\nInvalid partition.\n\n"
|
||||||
|
IDS_SELECT_NO_VOLUME "\nThere is no volume currently selected.\nPlease select a disk and try again.\n\n"
|
||||||
|
IDS_SELECT_VOLUME "\nVolume %lu is now the selected volume.\n\n"
|
||||||
END
|
END
|
||||||
|
|
||||||
/* Disk Status */
|
/* Disk Status */
|
||||||
|
@ -123,7 +130,6 @@ BEGIN
|
||||||
IDS_ERROR_MSG_NO_SCRIPT "Eroare la deschiderea fișierului script: %s\n"
|
IDS_ERROR_MSG_NO_SCRIPT "Eroare la deschiderea fișierului script: %s\n"
|
||||||
IDS_ERROR_MSG_BAD_ARG "Eroare la prelucrarea argumentului: %s\n"
|
IDS_ERROR_MSG_BAD_ARG "Eroare la prelucrarea argumentului: %s\n"
|
||||||
IDS_ERROR_INVALID_ARGS "Invalid arguments\n"
|
IDS_ERROR_INVALID_ARGS "Invalid arguments\n"
|
||||||
IDS_ERROR_INVALID_DISK "Invalid disk\n"
|
|
||||||
END
|
END
|
||||||
|
|
||||||
/* Active help descriptions */
|
/* Active help descriptions */
|
||||||
|
|
|
@ -42,6 +42,10 @@ BEGIN
|
||||||
IDS_LIST_DISK_HEAD "\n Диск ### Состояние Размер Свободно Дин GPT\n"
|
IDS_LIST_DISK_HEAD "\n Диск ### Состояние Размер Свободно Дин GPT\n"
|
||||||
IDS_LIST_DISK_LINE " -------- ---------- ------- -------- --- ---\n"
|
IDS_LIST_DISK_LINE " -------- ---------- ------- -------- --- ---\n"
|
||||||
IDS_LIST_DISK_FORMAT "%c %7lu %-10s %4I64u %-2s %4I64u %-2s %1s %1s\n"
|
IDS_LIST_DISK_FORMAT "%c %7lu %-10s %4I64u %-2s %4I64u %-2s %1s %1s\n"
|
||||||
|
IDS_LIST_PARTITION_HEAD "\n Partition Type Size Offset\n"
|
||||||
|
IDS_LIST_PARTITION_LINE " ------------- ---------------- ------- -------\n"
|
||||||
|
IDS_LIST_PARTITION_FORMAT "%c Partition %2lu %-16s %4I64u %-2s %4I64u %-2s\n"
|
||||||
|
IDS_LIST_PARTITION_NO_DISK "\nThere is no disk for listing partitions.\nPlease select a disk and try again.\n\n"
|
||||||
IDS_LIST_VOLUME_HEAD "Том ###\tИмя\tМетка\n"
|
IDS_LIST_VOLUME_HEAD "Том ###\tИмя\tМетка\n"
|
||||||
END
|
END
|
||||||
|
|
||||||
|
@ -50,10 +54,13 @@ STRINGTABLE
|
||||||
BEGIN
|
BEGIN
|
||||||
IDS_SELECT_NO_DISK "\nThere is no disk currently selected.\nPlease select a disk and try again.\n\n"
|
IDS_SELECT_NO_DISK "\nThere is no disk currently selected.\nPlease select a disk and try again.\n\n"
|
||||||
IDS_SELECT_DISK "\nDisk %lu is now the selected disk.\n\n"
|
IDS_SELECT_DISK "\nDisk %lu is now the selected disk.\n\n"
|
||||||
IDS_SELECT_NO_VOLUME "\nThere is no volume currently selected.\nPlease select a disk and try again.\n\n"
|
IDS_SELECT_DISK_INVALID "\nInvalid disk.\n\n"
|
||||||
IDS_SELECT_VOLUME "\nVolume %lu is now the selected volume.\n\n"
|
|
||||||
IDS_SELECT_NO_PARTITION "\nThere is no partition currently selected.\nPlease select a disk and try again.\n\n"
|
IDS_SELECT_NO_PARTITION "\nThere is no partition currently selected.\nPlease select a disk and try again.\n\n"
|
||||||
IDS_SELECT_PARTITION "\nPartition %lu is now the selected partition.\n\n"
|
IDS_SELECT_PARTITION "\nPartition %lu is now the selected partition.\n\n"
|
||||||
|
IDS_SELECT_PARTITION_NO_DISK "\nThere is no disk for selecting a partition.\nPlease select a disk and try again.\n\n"
|
||||||
|
IDS_SELECT_PARTITION_INVALID "\nInvalid partition.\n\n"
|
||||||
|
IDS_SELECT_NO_VOLUME "\nThere is no volume currently selected.\nPlease select a disk and try again.\n\n"
|
||||||
|
IDS_SELECT_VOLUME "\nVolume %lu is now the selected volume.\n\n"
|
||||||
END
|
END
|
||||||
|
|
||||||
/* Disk Status */
|
/* Disk Status */
|
||||||
|
@ -124,7 +131,6 @@ BEGIN
|
||||||
IDS_ERROR_MSG_NO_SCRIPT "Ошибка открытия скрипта: %s\n"
|
IDS_ERROR_MSG_NO_SCRIPT "Ошибка открытия скрипта: %s\n"
|
||||||
IDS_ERROR_MSG_BAD_ARG "Ошибка обработки параметров: %s\n"
|
IDS_ERROR_MSG_BAD_ARG "Ошибка обработки параметров: %s\n"
|
||||||
IDS_ERROR_INVALID_ARGS "Invalid arguments\n"
|
IDS_ERROR_INVALID_ARGS "Invalid arguments\n"
|
||||||
IDS_ERROR_INVALID_DISK "Invalid disk\n"
|
|
||||||
END
|
END
|
||||||
|
|
||||||
/* Active help descriptions */
|
/* Active help descriptions */
|
||||||
|
|
|
@ -44,6 +44,10 @@ BEGIN
|
||||||
IDS_LIST_DISK_HEAD "\n Disk ### Status Size Free Dyn Gpt\n"
|
IDS_LIST_DISK_HEAD "\n Disk ### Status Size Free Dyn Gpt\n"
|
||||||
IDS_LIST_DISK_LINE " -------- ---------- ------- ------- --- ---\n"
|
IDS_LIST_DISK_LINE " -------- ---------- ------- ------- --- ---\n"
|
||||||
IDS_LIST_DISK_FORMAT "%c %7lu %-10s %4I64u %-2s %4I64u %-2s %1s %1s\n"
|
IDS_LIST_DISK_FORMAT "%c %7lu %-10s %4I64u %-2s %4I64u %-2s %1s %1s\n"
|
||||||
|
IDS_LIST_PARTITION_HEAD "\n Partition Type Size Offset\n"
|
||||||
|
IDS_LIST_PARTITION_LINE "%c ------------- ---------------- ------- -------\n"
|
||||||
|
IDS_LIST_PARTITION_FORMAT " Partition %2lu %-16s %4I64u %-2s %4I64u %-2s\n"
|
||||||
|
IDS_LIST_PARTITION_NO_DISK "\nThere is no disk for listing partitions.\nPlease select a disk and try again.\n\n"
|
||||||
IDS_LIST_VOLUME_HEAD "Volume ###\tLtr\tLabel\n"
|
IDS_LIST_VOLUME_HEAD "Volume ###\tLtr\tLabel\n"
|
||||||
END
|
END
|
||||||
|
|
||||||
|
@ -52,10 +56,13 @@ STRINGTABLE
|
||||||
BEGIN
|
BEGIN
|
||||||
IDS_SELECT_NO_DISK "\nThere is no disk currently selected.\nPlease select a disk and try again.\n\n"
|
IDS_SELECT_NO_DISK "\nThere is no disk currently selected.\nPlease select a disk and try again.\n\n"
|
||||||
IDS_SELECT_DISK "\nDisk %lu is now the selected disk.\n\n"
|
IDS_SELECT_DISK "\nDisk %lu is now the selected disk.\n\n"
|
||||||
IDS_SELECT_NO_VOLUME "\nThere is no volume currently selected.\nPlease select a disk and try again.\n\n"
|
IDS_SELECT_DISK_INVALID "\nInvalid disk.\n\n"
|
||||||
IDS_SELECT_VOLUME "\nVolume %lu is now the selected volume.\n\n"
|
|
||||||
IDS_SELECT_NO_PARTITION "\nThere is no partition currently selected.\nPlease select a disk and try again.\n\n"
|
IDS_SELECT_NO_PARTITION "\nThere is no partition currently selected.\nPlease select a disk and try again.\n\n"
|
||||||
IDS_SELECT_PARTITION "\nPartition %lu is now the selected partition.\n\n"
|
IDS_SELECT_PARTITION "\nPartition %lu is now the selected partition.\n\n"
|
||||||
|
IDS_SELECT_PARTITION_NO_DISK "\nThere is no disk for selecting a partition.\nPlease select a disk and try again.\n\n"
|
||||||
|
IDS_SELECT_PARTITION_INVALID "\nInvalid partition.\n\n"
|
||||||
|
IDS_SELECT_NO_VOLUME "\nThere is no volume currently selected.\nPlease select a disk and try again.\n\n"
|
||||||
|
IDS_SELECT_VOLUME "\nVolume %lu is now the selected volume.\n\n"
|
||||||
END
|
END
|
||||||
|
|
||||||
/* Disk Status */
|
/* Disk Status */
|
||||||
|
@ -126,7 +133,6 @@ BEGIN
|
||||||
IDS_ERROR_MSG_NO_SCRIPT "Error në hapjen e skriptes: %s\n"
|
IDS_ERROR_MSG_NO_SCRIPT "Error në hapjen e skriptes: %s\n"
|
||||||
IDS_ERROR_MSG_BAD_ARG "Error argumenti i procesimit: %s\n"
|
IDS_ERROR_MSG_BAD_ARG "Error argumenti i procesimit: %s\n"
|
||||||
IDS_ERROR_INVALID_ARGS "Invalid arguments\n"
|
IDS_ERROR_INVALID_ARGS "Invalid arguments\n"
|
||||||
IDS_ERROR_INVALID_DISK "Invalid disk\n"
|
|
||||||
END
|
END
|
||||||
|
|
||||||
/* Active help descriptions */
|
/* Active help descriptions */
|
||||||
|
|
|
@ -42,6 +42,10 @@ BEGIN
|
||||||
IDS_LIST_DISK_HEAD "\n Disk ### Durum Boyut Boş Dev Gpt\n"
|
IDS_LIST_DISK_HEAD "\n Disk ### Durum Boyut Boş Dev Gpt\n"
|
||||||
IDS_LIST_DISK_LINE " -------- ---------- ------- ------- --- ---\n"
|
IDS_LIST_DISK_LINE " -------- ---------- ------- ------- --- ---\n"
|
||||||
IDS_LIST_DISK_FORMAT "%c %7lu %-10s %4I64u %-2s %4I64u %-2s %1s %1s\n"
|
IDS_LIST_DISK_FORMAT "%c %7lu %-10s %4I64u %-2s %4I64u %-2s %1s %1s\n"
|
||||||
|
IDS_LIST_PARTITION_HEAD "\n Partition Type Size Offset\n"
|
||||||
|
IDS_LIST_PARTITION_LINE " ------------- ---------------- ------- -------\n"
|
||||||
|
IDS_LIST_PARTITION_FORMAT "%c Partition %2lu %-16s %4I64u %-2s %4I64u %-2s\n"
|
||||||
|
IDS_LIST_PARTITION_NO_DISK "\nThere is no disk for listing partitions.\nPlease select a disk and try again.\n\n"
|
||||||
IDS_LIST_VOLUME_HEAD "Birim ###\tHarf\tEtiket\n"
|
IDS_LIST_VOLUME_HEAD "Birim ###\tHarf\tEtiket\n"
|
||||||
END
|
END
|
||||||
|
|
||||||
|
@ -50,10 +54,13 @@ STRINGTABLE
|
||||||
BEGIN
|
BEGIN
|
||||||
IDS_SELECT_NO_DISK "\nThere is no disk currently selected.\nPlease select a disk and try again.\n\n"
|
IDS_SELECT_NO_DISK "\nThere is no disk currently selected.\nPlease select a disk and try again.\n\n"
|
||||||
IDS_SELECT_DISK "\nDisk %lu is now the selected disk.\n\n"
|
IDS_SELECT_DISK "\nDisk %lu is now the selected disk.\n\n"
|
||||||
IDS_SELECT_NO_VOLUME "\nThere is no volume currently selected.\nPlease select a disk and try again.\n\n"
|
IDS_SELECT_DISK_INVALID "\nInvalid disk.\n\n"
|
||||||
IDS_SELECT_VOLUME "\nVolume %lu is now the selected volume.\n\n"
|
|
||||||
IDS_SELECT_NO_PARTITION "\nThere is no partition currently selected.\nPlease select a disk and try again.\n\n"
|
IDS_SELECT_NO_PARTITION "\nThere is no partition currently selected.\nPlease select a disk and try again.\n\n"
|
||||||
IDS_SELECT_PARTITION "\nPartition %lu is now the selected partition.\n\n"
|
IDS_SELECT_PARTITION "\nPartition %lu is now the selected partition.\n\n"
|
||||||
|
IDS_SELECT_PARTITION_NO_DISK "\nThere is no disk for selecting a partition.\nPlease select a disk and try again.\n\n"
|
||||||
|
IDS_SELECT_PARTITION_INVALID "\nInvalid partition.\n\n"
|
||||||
|
IDS_SELECT_NO_VOLUME "\nThere is no volume currently selected.\nPlease select a disk and try again.\n\n"
|
||||||
|
IDS_SELECT_VOLUME "\nVolume %lu is now the selected volume.\n\n"
|
||||||
END
|
END
|
||||||
|
|
||||||
/* Disk Status */
|
/* Disk Status */
|
||||||
|
@ -124,7 +131,6 @@ BEGIN
|
||||||
IDS_ERROR_MSG_NO_SCRIPT "Betik açmada yanlışlık: %s\n"
|
IDS_ERROR_MSG_NO_SCRIPT "Betik açmada yanlışlık: %s\n"
|
||||||
IDS_ERROR_MSG_BAD_ARG "Değiştirgen işlemede yanlışlık: %s\n"
|
IDS_ERROR_MSG_BAD_ARG "Değiştirgen işlemede yanlışlık: %s\n"
|
||||||
IDS_ERROR_INVALID_ARGS "Invalid arguments\n"
|
IDS_ERROR_INVALID_ARGS "Invalid arguments\n"
|
||||||
IDS_ERROR_INVALID_DISK "Invalid disk\n"
|
|
||||||
END
|
END
|
||||||
|
|
||||||
/* Active help descriptions */
|
/* Active help descriptions */
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
/* FUNCTIONS ******************************************************************/
|
||||||
|
|
||||||
static
|
static
|
||||||
ULONGLONG
|
ULONGLONG
|
||||||
RoundingDivide(
|
RoundingDivide(
|
||||||
|
@ -25,115 +27,54 @@ static
|
||||||
VOID
|
VOID
|
||||||
ListDisk(VOID)
|
ListDisk(VOID)
|
||||||
{
|
{
|
||||||
WCHAR Buffer[MAX_PATH];
|
PLIST_ENTRY Entry;
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
PDISKENTRY DiskEntry;
|
||||||
SYSTEM_DEVICE_INFORMATION Sdi;
|
ULONGLONG DiskSize;
|
||||||
IO_STATUS_BLOCK Iosb;
|
ULONGLONG FreeSize;
|
||||||
DISK_GEOMETRY DiskGeometry;
|
|
||||||
ULONG ReturnSize;
|
|
||||||
ULONG DiskNumber;
|
|
||||||
UNICODE_STRING Name;
|
|
||||||
HANDLE FileHandle;
|
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
ULARGE_INTEGER DiskSize;
|
|
||||||
ULARGE_INTEGER FreeSize;
|
|
||||||
LPWSTR lpSizeUnit;
|
LPWSTR lpSizeUnit;
|
||||||
LPWSTR lpFreeUnit;
|
LPWSTR lpFreeUnit;
|
||||||
|
|
||||||
|
|
||||||
Status = NtQuerySystemInformation(SystemDeviceInformation,
|
|
||||||
&Sdi,
|
|
||||||
sizeof(SYSTEM_DEVICE_INFORMATION),
|
|
||||||
&ReturnSize);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Header labels */
|
/* Header labels */
|
||||||
PrintResourceString(IDS_LIST_DISK_HEAD);
|
PrintResourceString(IDS_LIST_DISK_HEAD);
|
||||||
PrintResourceString(IDS_LIST_DISK_LINE);
|
PrintResourceString(IDS_LIST_DISK_LINE);
|
||||||
|
|
||||||
for (DiskNumber = 0; DiskNumber < Sdi.NumberOfDisks; DiskNumber++)
|
Entry = DiskListHead.Flink;
|
||||||
|
while (Entry != &DiskListHead)
|
||||||
{
|
{
|
||||||
swprintf(Buffer,
|
DiskEntry = CONTAINING_RECORD(Entry, DISKENTRY, ListEntry);
|
||||||
L"\\Device\\Harddisk%d\\Partition0",
|
|
||||||
DiskNumber);
|
|
||||||
RtlInitUnicodeString(&Name,
|
|
||||||
Buffer);
|
|
||||||
|
|
||||||
InitializeObjectAttributes(&ObjectAttributes,
|
DiskSize = DiskEntry->SectorCount.QuadPart *
|
||||||
&Name,
|
(ULONGLONG)DiskEntry->BytesPerSector;
|
||||||
0,
|
|
||||||
NULL,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
Status = NtOpenFile(&FileHandle,
|
if (DiskSize >= 10737418240) /* 10 GB */
|
||||||
FILE_READ_DATA | FILE_READ_ATTRIBUTES | SYNCHRONIZE,
|
|
||||||
&ObjectAttributes,
|
|
||||||
&Iosb,
|
|
||||||
FILE_SHARE_READ,
|
|
||||||
FILE_SYNCHRONOUS_IO_NONALERT);
|
|
||||||
if (NT_SUCCESS(Status))
|
|
||||||
{
|
{
|
||||||
Status = NtDeviceIoControlFile(FileHandle,
|
DiskSize = RoundingDivide(DiskSize, 1073741824);
|
||||||
NULL,
|
lpSizeUnit = L"GB";
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
&Iosb,
|
|
||||||
IOCTL_DISK_GET_DRIVE_GEOMETRY,
|
|
||||||
NULL,
|
|
||||||
0,
|
|
||||||
&DiskGeometry,
|
|
||||||
sizeof(DISK_GEOMETRY));
|
|
||||||
if (NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DiskSize.QuadPart = DiskGeometry.Cylinders.QuadPart *
|
|
||||||
(ULONGLONG)DiskGeometry.TracksPerCylinder *
|
|
||||||
(ULONGLONG)DiskGeometry.SectorsPerTrack *
|
|
||||||
(ULONGLONG)DiskGeometry.BytesPerSector;
|
|
||||||
if (DiskSize.QuadPart >= 10737418240) /* 10 GB */
|
|
||||||
{
|
|
||||||
DiskSize.QuadPart = RoundingDivide(DiskSize.QuadPart, 1073741824);
|
|
||||||
lpSizeUnit = L"GB";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DiskSize.QuadPart = RoundingDivide(DiskSize.QuadPart, 1048576);
|
|
||||||
if (DiskSize.QuadPart == 0)
|
|
||||||
DiskSize.QuadPart = 1;
|
|
||||||
lpSizeUnit = L"MB";
|
|
||||||
}
|
|
||||||
|
|
||||||
/* FIXME */
|
|
||||||
FreeSize.QuadPart = 0;
|
|
||||||
lpFreeUnit = L"B";
|
|
||||||
|
|
||||||
PrintResourceString(IDS_LIST_DISK_FORMAT,
|
|
||||||
(CurrentDisk == DiskNumber) ? L'*': ' ',
|
|
||||||
DiskNumber,
|
|
||||||
L"Online",
|
|
||||||
DiskSize.QuadPart,
|
|
||||||
lpSizeUnit,
|
|
||||||
FreeSize.QuadPart,
|
|
||||||
lpFreeUnit,
|
|
||||||
L" ",
|
|
||||||
L" ");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("Status 0x%lx\n", Status);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
NtClose(FileHandle);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf("Status 0x%lx\n", Status);
|
DiskSize = RoundingDivide(DiskSize, 1048576);
|
||||||
|
if (DiskSize == 0)
|
||||||
|
DiskSize = 1;
|
||||||
|
lpSizeUnit = L"MB";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* FIXME */
|
||||||
|
FreeSize = 0;
|
||||||
|
lpFreeUnit = L"B";
|
||||||
|
|
||||||
|
PrintResourceString(IDS_LIST_DISK_FORMAT,
|
||||||
|
(CurrentDisk == DiskEntry) ? L'*': ' ',
|
||||||
|
DiskEntry->DiskNumber,
|
||||||
|
L"Online",
|
||||||
|
DiskSize,
|
||||||
|
lpSizeUnit,
|
||||||
|
FreeSize,
|
||||||
|
lpFreeUnit,
|
||||||
|
L" ",
|
||||||
|
L" ");
|
||||||
|
|
||||||
|
Entry = Entry->Flink;
|
||||||
}
|
}
|
||||||
|
|
||||||
wprintf(L"\n\n");
|
wprintf(L"\n\n");
|
||||||
|
@ -143,7 +84,137 @@ static
|
||||||
VOID
|
VOID
|
||||||
ListPartition(VOID)
|
ListPartition(VOID)
|
||||||
{
|
{
|
||||||
printf("List Partition!!\n");
|
PLIST_ENTRY Entry;
|
||||||
|
PPARTENTRY PartEntry;
|
||||||
|
ULONGLONG PartSize;
|
||||||
|
ULONGLONG PartOffset;
|
||||||
|
LPWSTR lpSizeUnit;
|
||||||
|
LPWSTR lpOffsetUnit;
|
||||||
|
ULONG PartNumber = 1;
|
||||||
|
|
||||||
|
if (CurrentDisk == NULL)
|
||||||
|
{
|
||||||
|
PrintResourceString(IDS_LIST_PARTITION_NO_DISK);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Header labels */
|
||||||
|
PrintResourceString(IDS_LIST_PARTITION_HEAD);
|
||||||
|
PrintResourceString(IDS_LIST_PARTITION_LINE);
|
||||||
|
|
||||||
|
Entry = CurrentDisk->PrimaryPartListHead.Flink;
|
||||||
|
while (Entry != &CurrentDisk->PrimaryPartListHead)
|
||||||
|
{
|
||||||
|
PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
|
||||||
|
|
||||||
|
if (PartEntry->PartitionType != 0)
|
||||||
|
{
|
||||||
|
PartSize = PartEntry->SectorCount.QuadPart * CurrentDisk->BytesPerSector;
|
||||||
|
|
||||||
|
if (PartSize >= 10737418240) /* 10 GB */
|
||||||
|
{
|
||||||
|
PartSize = RoundingDivide(PartSize, 1073741824);
|
||||||
|
lpSizeUnit = L"GB";
|
||||||
|
}
|
||||||
|
else if (PartSize >= 10485760) /* 10 MB */
|
||||||
|
{
|
||||||
|
PartSize = RoundingDivide(PartSize, 1048576);
|
||||||
|
lpSizeUnit = L"MB";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PartSize = RoundingDivide(PartSize, 1024);
|
||||||
|
lpSizeUnit = L"KB";
|
||||||
|
}
|
||||||
|
|
||||||
|
PartOffset = PartEntry->StartSector.QuadPart * CurrentDisk->BytesPerSector;
|
||||||
|
|
||||||
|
if (PartOffset >= 10737418240) /* 10 GB */
|
||||||
|
{
|
||||||
|
PartOffset = RoundingDivide(PartOffset, 1073741824);
|
||||||
|
lpOffsetUnit = L"GB";
|
||||||
|
}
|
||||||
|
else if (PartOffset >= 10485760) /* 10 MB */
|
||||||
|
{
|
||||||
|
PartOffset = RoundingDivide(PartOffset, 1048576);
|
||||||
|
lpOffsetUnit = L"MB";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PartOffset = RoundingDivide(PartOffset, 1024);
|
||||||
|
lpOffsetUnit = L"KB";
|
||||||
|
}
|
||||||
|
|
||||||
|
PrintResourceString(IDS_LIST_PARTITION_FORMAT,
|
||||||
|
(CurrentPartition == PartEntry) ? L'*': ' ',
|
||||||
|
PartNumber++,
|
||||||
|
IsContainerPartition(PartEntry->PartitionType) ? L"Extended" : L"Primary",
|
||||||
|
PartSize,
|
||||||
|
lpSizeUnit,
|
||||||
|
PartOffset,
|
||||||
|
lpOffsetUnit);
|
||||||
|
}
|
||||||
|
|
||||||
|
Entry = Entry->Flink;
|
||||||
|
}
|
||||||
|
|
||||||
|
Entry = CurrentDisk->LogicalPartListHead.Flink;
|
||||||
|
while (Entry != &CurrentDisk->LogicalPartListHead)
|
||||||
|
{
|
||||||
|
PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
|
||||||
|
|
||||||
|
if (PartEntry->PartitionType != 0)
|
||||||
|
{
|
||||||
|
PartSize = PartEntry->SectorCount.QuadPart * CurrentDisk->BytesPerSector;
|
||||||
|
|
||||||
|
if (PartSize >= 10737418240) /* 10 GB */
|
||||||
|
{
|
||||||
|
PartSize = RoundingDivide(PartSize, 1073741824);
|
||||||
|
lpSizeUnit = L"GB";
|
||||||
|
}
|
||||||
|
else if (PartSize >= 10485760) /* 10 MB */
|
||||||
|
{
|
||||||
|
PartSize = RoundingDivide(PartSize, 1048576);
|
||||||
|
lpSizeUnit = L"MB";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PartSize = RoundingDivide(PartSize, 1024);
|
||||||
|
lpSizeUnit = L"KB";
|
||||||
|
}
|
||||||
|
|
||||||
|
PartOffset = PartEntry->StartSector.QuadPart * CurrentDisk->BytesPerSector;
|
||||||
|
|
||||||
|
if (PartOffset >= 10737418240) /* 10 GB */
|
||||||
|
{
|
||||||
|
PartOffset = RoundingDivide(PartOffset, 1073741824);
|
||||||
|
lpOffsetUnit = L"GB";
|
||||||
|
}
|
||||||
|
else if (PartOffset >= 10485760) /* 10 MB */
|
||||||
|
{
|
||||||
|
PartOffset = RoundingDivide(PartOffset, 1048576);
|
||||||
|
lpOffsetUnit = L"MB";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PartOffset = RoundingDivide(PartOffset, 1024);
|
||||||
|
lpOffsetUnit = L"KB";
|
||||||
|
}
|
||||||
|
|
||||||
|
PrintResourceString(IDS_LIST_PARTITION_FORMAT,
|
||||||
|
(CurrentPartition == PartEntry) ? L'*': ' ',
|
||||||
|
PartNumber++,
|
||||||
|
L"Logical",
|
||||||
|
PartSize,
|
||||||
|
lpSizeUnit,
|
||||||
|
PartOffset,
|
||||||
|
lpOffsetUnit);
|
||||||
|
}
|
||||||
|
|
||||||
|
Entry = Entry->Flink;
|
||||||
|
}
|
||||||
|
|
||||||
|
wprintf(L"\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
|
|
1186
reactos/base/system/diskpart/partlist.c
Normal file
1186
reactos/base/system/diskpart/partlist.c
Normal file
File diff suppressed because it is too large
Load diff
|
@ -35,14 +35,21 @@
|
||||||
#define IDS_LIST_DISK_HEAD 3300
|
#define IDS_LIST_DISK_HEAD 3300
|
||||||
#define IDS_LIST_DISK_LINE 3301
|
#define IDS_LIST_DISK_LINE 3301
|
||||||
#define IDS_LIST_DISK_FORMAT 3302
|
#define IDS_LIST_DISK_FORMAT 3302
|
||||||
#define IDS_LIST_VOLUME_HEAD 3303
|
#define IDS_LIST_PARTITION_HEAD 3303
|
||||||
|
#define IDS_LIST_PARTITION_LINE 3304
|
||||||
|
#define IDS_LIST_PARTITION_FORMAT 3305
|
||||||
|
#define IDS_LIST_PARTITION_NO_DISK 3306
|
||||||
|
#define IDS_LIST_VOLUME_HEAD 3307
|
||||||
|
|
||||||
#define IDS_SELECT_NO_DISK 4400
|
#define IDS_SELECT_NO_DISK 4400
|
||||||
#define IDS_SELECT_DISK 4401
|
#define IDS_SELECT_DISK 4401
|
||||||
#define IDS_SELECT_NO_VOLUME 4402
|
#define IDS_SELECT_DISK_INVALID 4402
|
||||||
#define IDS_SELECT_VOLUME 4403
|
#define IDS_SELECT_NO_PARTITION 4403
|
||||||
#define IDS_SELECT_NO_PARTITION 4404
|
#define IDS_SELECT_PARTITION 4404
|
||||||
#define IDS_SELECT_PARTITION 4405
|
#define IDS_SELECT_PARTITION_NO_DISK 4405
|
||||||
|
#define IDS_SELECT_PARTITION_INVALID 4406
|
||||||
|
#define IDS_SELECT_NO_VOLUME 4407
|
||||||
|
#define IDS_SELECT_VOLUME 4408
|
||||||
|
|
||||||
#define IDS_STATUS_YES 31
|
#define IDS_STATUS_YES 31
|
||||||
#define IDS_STATUS_NO 32
|
#define IDS_STATUS_NO 32
|
||||||
|
@ -135,4 +142,3 @@
|
||||||
#define IDS_HELP_CMD_UNIQUEID 140
|
#define IDS_HELP_CMD_UNIQUEID 140
|
||||||
|
|
||||||
#define IDS_ERROR_INVALID_ARGS 211
|
#define IDS_ERROR_INVALID_ARGS 211
|
||||||
#define IDS_ERROR_INVALID_DISK 212
|
|
||||||
|
|
|
@ -11,10 +11,7 @@
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
/* FUNCTIONS ******************************************************************/
|
||||||
ULONG CurrentDisk = (ULONG)-1;
|
|
||||||
ULONG CurrentPartition = (ULONG)-1;
|
|
||||||
|
|
||||||
|
|
||||||
static
|
static
|
||||||
VOID
|
VOID
|
||||||
|
@ -22,10 +19,9 @@ SelectDisk(
|
||||||
INT argc,
|
INT argc,
|
||||||
LPWSTR *argv)
|
LPWSTR *argv)
|
||||||
{
|
{
|
||||||
SYSTEM_DEVICE_INFORMATION Sdi;
|
PLIST_ENTRY Entry;
|
||||||
ULONG ReturnSize;
|
PDISKENTRY DiskEntry;
|
||||||
NTSTATUS Status;
|
LONG lValue;
|
||||||
LONG value;
|
|
||||||
LPWSTR endptr = NULL;
|
LPWSTR endptr = NULL;
|
||||||
|
|
||||||
DPRINT("Select Disk()\n");
|
DPRINT("Select Disk()\n");
|
||||||
|
@ -38,40 +34,40 @@ SelectDisk(
|
||||||
|
|
||||||
if (argc == 2)
|
if (argc == 2)
|
||||||
{
|
{
|
||||||
if (CurrentDisk == (ULONG)-1)
|
if (CurrentDisk == NULL)
|
||||||
PrintResourceString(IDS_SELECT_NO_DISK);
|
PrintResourceString(IDS_SELECT_NO_DISK);
|
||||||
else
|
else
|
||||||
PrintResourceString(IDS_SELECT_DISK, CurrentDisk);
|
PrintResourceString(IDS_SELECT_DISK, CurrentDisk->DiskNumber);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
value = wcstol(argv[2], &endptr, 10);
|
lValue = wcstol(argv[2], &endptr, 10);
|
||||||
if (((value == 0) && (endptr == argv[2])) ||
|
if (((lValue == 0) && (endptr == argv[2])) ||
|
||||||
(value < 0))
|
(lValue < 0))
|
||||||
{
|
{
|
||||||
PrintResourceString(IDS_ERROR_INVALID_ARGS);
|
PrintResourceString(IDS_ERROR_INVALID_ARGS);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = NtQuerySystemInformation(SystemDeviceInformation,
|
CurrentDisk = NULL;
|
||||||
&Sdi,
|
|
||||||
sizeof(SYSTEM_DEVICE_INFORMATION),
|
Entry = DiskListHead.Flink;
|
||||||
&ReturnSize);
|
while (Entry != &DiskListHead)
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
{
|
||||||
return;
|
DiskEntry = CONTAINING_RECORD(Entry, DISKENTRY, ListEntry);
|
||||||
|
|
||||||
|
if (DiskEntry->DiskNumber == (ULONG)lValue)
|
||||||
|
{
|
||||||
|
CurrentDisk = DiskEntry;
|
||||||
|
CurrentPartition = NULL;
|
||||||
|
PrintResourceString(IDS_SELECT_DISK, CurrentDisk->DiskNumber);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Entry = Entry->Flink;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ULONG)value >= Sdi.NumberOfDisks)
|
PrintResourceString(IDS_SELECT_DISK_INVALID);
|
||||||
{
|
|
||||||
PrintResourceString(IDS_ERROR_INVALID_DISK);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
CurrentDisk = (ULONG)value;
|
|
||||||
CurrentPartition = (ULONG)-1;
|
|
||||||
|
|
||||||
PrintResourceString(IDS_SELECT_DISK, CurrentDisk);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -81,8 +77,11 @@ SelectPartition(
|
||||||
INT argc,
|
INT argc,
|
||||||
LPWSTR *argv)
|
LPWSTR *argv)
|
||||||
{
|
{
|
||||||
LONG value;
|
PLIST_ENTRY Entry;
|
||||||
|
PPARTENTRY PartEntry;
|
||||||
|
LONG lValue;
|
||||||
LPWSTR endptr = NULL;
|
LPWSTR endptr = NULL;
|
||||||
|
ULONG PartNumber = 1;
|
||||||
|
|
||||||
DPRINT("Select Partition()\n");
|
DPRINT("Select Partition()\n");
|
||||||
|
|
||||||
|
@ -92,28 +91,69 @@ SelectPartition(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (CurrentDisk == NULL)
|
||||||
|
{
|
||||||
|
PrintResourceString(IDS_SELECT_PARTITION_NO_DISK);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (argc == 2)
|
if (argc == 2)
|
||||||
{
|
{
|
||||||
if (CurrentPartition == (ULONG)-1)
|
if (CurrentPartition == NULL)
|
||||||
PrintResourceString(IDS_SELECT_NO_PARTITION);
|
PrintResourceString(IDS_SELECT_NO_PARTITION);
|
||||||
else
|
else
|
||||||
PrintResourceString(IDS_SELECT_PARTITION, CurrentPartition);
|
PrintResourceString(IDS_SELECT_PARTITION, CurrentPartition);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
value = wcstol(argv[2], &endptr, 10);
|
lValue = wcstol(argv[2], &endptr, 10);
|
||||||
if (((value == 0) && (endptr == argv[2])) ||
|
if (((lValue == 0) && (endptr == argv[2])) ||
|
||||||
(value < 0))
|
(lValue < 0))
|
||||||
{
|
{
|
||||||
PrintResourceString(IDS_ERROR_INVALID_ARGS);
|
PrintResourceString(IDS_ERROR_INVALID_ARGS);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: Check the new partition number */
|
Entry = CurrentDisk->PrimaryPartListHead.Flink;
|
||||||
|
while (Entry != &CurrentDisk->PrimaryPartListHead)
|
||||||
|
{
|
||||||
|
PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
|
||||||
|
|
||||||
CurrentPartition = (ULONG)value;
|
if (PartEntry->PartitionType != 0)
|
||||||
|
{
|
||||||
|
if (PartNumber == (ULONG)lValue)
|
||||||
|
{
|
||||||
|
CurrentPartition = PartEntry;
|
||||||
|
PrintResourceString(IDS_SELECT_PARTITION, PartNumber);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
PrintResourceString(IDS_SELECT_PARTITION, CurrentPartition);
|
PartNumber++;
|
||||||
|
}
|
||||||
|
|
||||||
|
Entry = Entry->Flink;
|
||||||
|
}
|
||||||
|
|
||||||
|
Entry = CurrentDisk->LogicalPartListHead.Flink;
|
||||||
|
while (Entry != &CurrentDisk->LogicalPartListHead)
|
||||||
|
{
|
||||||
|
PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
|
||||||
|
|
||||||
|
if (PartEntry->PartitionType != 0)
|
||||||
|
{
|
||||||
|
if (PartNumber == (ULONG)lValue)
|
||||||
|
{
|
||||||
|
CurrentPartition = PartEntry;
|
||||||
|
PrintResourceString(IDS_SELECT_PARTITION, PartNumber);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PartNumber++;
|
||||||
|
}
|
||||||
|
Entry = Entry->Flink;
|
||||||
|
}
|
||||||
|
|
||||||
|
PrintResourceString(IDS_SELECT_PARTITION_INVALID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue