[SETUPLIB][USETUP] Introduce a 'SetupLib' library. CORE-13544

- Create the beginnings of a "setuplib" library, whose aim is to be shared between the (currently existing) 1st-stage text-mode installer, and the (future) 1st-stage GUI installer.
- Finish to split the GenList and PartList codes into their UI part, which remain in usetup, and their algorithmic part, which go into setuplib.
- Move SetMountedDeviceValue into the PartList module.
- Split the FileSystem list code into its UI and the algorithmic part (which goes into setuplib under the name fsutil.c).
  * The algo part is meant to be able to manage the filesystems available on the running system, similarly to what is mostly done (in scattered form) in fmifs, format, chkdsk / autochk codes...
    It also manages the partition filesystem recognition, using OS routines.
  * The UI part manages the FS list as it appears on screen, showing only the possible FSes that can be used to format the selected partition (a bit similar to what we do in the shell32's drive.c, etc...).
- Adapt the calling code to these changes.
- Remove some "host" code that was dating back from the dark old times.

svn path=/branches/setup_improvements/; revision=74570
svn path=/branches/setup_improvements/; revision=74659
This commit is contained in:
Hermès Bélusca-Maïto 2017-05-17 23:37:41 +00:00
parent 739e72b6ed
commit 3a19ee6a96
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
28 changed files with 4327 additions and 3992 deletions

View file

@ -1,4 +1,5 @@
add_subdirectory(lib)
add_subdirectory(reactos)
add_subdirectory(setup)
add_subdirectory(usetup)

View file

@ -0,0 +1,10 @@
list(APPEND SOURCE
fsutil.c
genlist.c
partlist.c
precomp.h)
add_library(setuplib ${SOURCE})
add_pch(setuplib precomp.h SOURCE)
add_dependencies(setuplib xdk) # psdk

View file

@ -0,0 +1,59 @@
/*
* PROJECT: ReactOS Setup Library
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
* PURPOSE: Setup error codes
* COPYRIGHT: Copyright 2007-2018 Johannes Anderwald <johannes.anderwald@reactos.org>
*/
#pragma once
typedef enum
{
NOT_AN_ERROR = 0, // ERROR_SUCCESS,
ERROR_NOT_INSTALLED,
ERROR_NO_HDD,
ERROR_NO_SOURCE_DRIVE,
ERROR_LOAD_TXTSETUPSIF,
ERROR_CORRUPT_TXTSETUPSIF,
ERROR_SIGNATURE_TXTSETUPSIF,
ERROR_DRIVE_INFORMATION,
ERROR_WRITE_BOOT,
ERROR_LOAD_COMPUTER,
ERROR_LOAD_DISPLAY,
ERROR_LOAD_KEYBOARD,
ERROR_LOAD_KBLAYOUT,
ERROR_WARN_PARTITION,
ERROR_NEW_PARTITION,
ERROR_DELETE_SPACE,
ERROR_INSTALL_BOOTCODE,
ERROR_NO_FLOPPY,
ERROR_UPDATE_KBSETTINGS,
ERROR_UPDATE_DISPLAY_SETTINGS,
ERROR_IMPORT_HIVE,
ERROR_FIND_REGISTRY,
ERROR_CREATE_HIVE,
ERROR_INITIALIZE_REGISTRY,
ERROR_INVALID_CABINET_INF,
ERROR_CABINET_MISSING,
ERROR_CABINET_SCRIPT,
ERROR_COPY_QUEUE,
ERROR_CREATE_DIR,
ERROR_TXTSETUP_SECTION,
ERROR_CABINET_SECTION,
ERROR_CREATE_INSTALL_DIR,
ERROR_FIND_SETUPDATA,
ERROR_WRITE_PTABLE,
ERROR_ADDING_CODEPAGE,
ERROR_UPDATE_LOCALESETTINGS,
ERROR_ADDING_KBLAYOUTS,
ERROR_UPDATE_GEOID,
ERROR_DIRECTORY_NAME,
ERROR_INSUFFICIENT_PARTITION_SIZE,
ERROR_PARTITION_TABLE_FULL,
ERROR_ONLY_ONE_EXTENDED,
ERROR_FORMATTING_PARTITION,
ERROR_LAST_ERROR_CODE
} ERROR_NUMBER;
/* EOF */

276
base/setup/lib/fsutil.c Normal file
View file

@ -0,0 +1,276 @@
/*
* PROJECT: ReactOS Setup Library
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
* PURPOSE: Filesystem support functions
* COPYRIGHT: Copyright 2002-2018 Eric Kohl
* Copyright 2003-2018 Casper S. Hornstrup (chorns@users.sourceforge.net)
* Copyright 2017-2018 Hermes Belusca-Maito
*/
//
// This is basically the code for listing available FileSystem providers
// (currently hardcoded in a list), and for performing a basic FileSystem
// recognition for a given disk partition.
//
// See also: https://git.reactos.org/?p=reactos.git;a=blob;f=reactos/dll/win32/fmifs/init.c;h=e895f5ef9cae4806123f6bbdd3dfed37ec1c8d33;hb=b9db9a4e377a2055f635b2fb69fef4e1750d219c
// for how to get FS providers in a dynamic way. In the (near) future we may
// consider merging some of this code with us into a fmifs / fsutil / fslib library...
//
/* INCLUDES *****************************************************************/
#include "precomp.h"
#include "fsutil.h"
#include "partlist.h"
/** For FileSystems **/
#include <fslib/vfatlib.h>
#include <fslib/ext2lib.h>
// #include <fslib/ntfslib.h>
#define NDEBUG
#include <debug.h>
FILE_SYSTEM RegisteredFileSystems[] =
{
{ L"FAT" , VfatFormat, VfatChkdsk },
// { L"FAT32", VfatFormat, VfatChkdsk },
#if 0
{ L"EXT2" , Ext2Format, Ext2Chkdsk },
{ L"NTFS" , NtfsFormat, NtfsChkdsk }
#endif
};
/* FUNCTIONS ****************************************************************/
PFILE_SYSTEM
GetRegisteredFileSystems(OUT PULONG Count)
{
*Count = ARRAYSIZE(RegisteredFileSystems);
return RegisteredFileSystems;
}
PFILE_SYSTEM
GetFileSystemByName(
// IN PFILE_SYSTEM_LIST List,
IN PCWSTR FileSystemName)
{
#if 0 // Reenable when the list of registered FSes will again be dynamic
PLIST_ENTRY ListEntry;
PFILE_SYSTEM_ITEM Item;
ListEntry = List->ListHead.Flink;
while (ListEntry != &List->ListHead)
{
Item = CONTAINING_RECORD(ListEntry, FILE_SYSTEM_ITEM, ListEntry);
if (Item->FileSystemName && wcsicmp(FileSystemName, Item->FileSystemName) == 0)
return Item;
ListEntry = ListEntry->Flink;
}
#else
ULONG Count;
PFILE_SYSTEM FileSystems;
FileSystems = GetRegisteredFileSystems(&Count);
if (!FileSystems || Count == 0)
return NULL;
while (Count--)
{
if (FileSystems->FileSystemName && wcsicmp(FileSystemName, FileSystems->FileSystemName) == 0)
return FileSystems;
++FileSystems;
}
#endif
return NULL;
}
//
// FileSystem recognition (using NT OS functionality)
//
#if 0 // FIXME: To be fully enabled when our storage stack & al. will work better!
/* NOTE: Ripped & adapted from base/system/autochk/autochk.c */
static NTSTATUS
_MyGetFileSystem(
IN struct _PARTENTRY* PartEntry,
IN OUT PWSTR FileSystemName,
IN SIZE_T FileSystemNameSize)
{
NTSTATUS Status;
HANDLE FileHandle;
IO_STATUS_BLOCK IoStatusBlock;
PFILE_FS_ATTRIBUTE_INFORMATION FileFsAttribute;
UCHAR Buffer[sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + MAX_PATH * sizeof(WCHAR)];
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING PartitionRootPath;
WCHAR PathBuffer[MAX_PATH];
FileFsAttribute = (PFILE_FS_ATTRIBUTE_INFORMATION)Buffer;
/* Set PartitionRootPath */
swprintf(PathBuffer,
// L"\\Device\\Harddisk%lu\\Partition%lu", // Should work! But because ReactOS sucks atm. it actually doesn't work!!
L"\\Device\\Harddisk%lu\\Partition%lu\\", // HACK: Use this as a temporary hack!
PartEntry->DiskEntry->DiskNumber,
PartEntry->PartitionNumber);
RtlInitUnicodeString(&PartitionRootPath, PathBuffer);
DPRINT("PartitionRootPath: %wZ\n", &PartitionRootPath);
/* Open the partition */
InitializeObjectAttributes(&ObjectAttributes,
&PartitionRootPath,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
Status = NtOpenFile(&FileHandle, // PartitionHandle,
FILE_GENERIC_READ /* | SYNCHRONIZE */,
&ObjectAttributes,
&IoStatusBlock,
FILE_SHARE_READ,
0 /* FILE_SYNCHRONOUS_IO_NONALERT */);
if (!NT_SUCCESS(Status))
{
DPRINT1("Failed to open partition %wZ, Status 0x%08lx\n", &PartitionRootPath, Status);
return Status;
}
/* Retrieve the FS attributes */
Status = NtQueryVolumeInformationFile(FileHandle,
&IoStatusBlock,
FileFsAttribute,
sizeof(Buffer),
FileFsAttributeInformation);
NtClose(FileHandle);
if (!NT_SUCCESS(Status))
{
DPRINT1("NtQueryVolumeInformationFile failed for partition %wZ, Status 0x%08lx\n", &PartitionRootPath, Status);
return Status;
}
if (FileSystemNameSize * sizeof(WCHAR) < FileFsAttribute->FileSystemNameLength + sizeof(WCHAR))
return STATUS_BUFFER_TOO_SMALL;
RtlCopyMemory(FileSystemName,
FileFsAttribute->FileSystemName,
FileFsAttribute->FileSystemNameLength);
FileSystemName[FileFsAttribute->FileSystemNameLength / sizeof(WCHAR)] = UNICODE_NULL;
return STATUS_SUCCESS;
}
#endif
PFILE_SYSTEM
GetFileSystem(
// IN PFILE_SYSTEM_LIST FileSystemList,
IN struct _PARTENTRY* PartEntry)
{
PFILE_SYSTEM CurrentFileSystem;
PWSTR FileSystemName = NULL;
#if 0 // For code temporarily disabled below
NTSTATUS Status;
WCHAR FsRecFileSystemName[MAX_PATH];
#endif
CurrentFileSystem = PartEntry->FileSystem;
/* We have a file system, return it */
if (CurrentFileSystem != NULL && CurrentFileSystem->FileSystemName != NULL)
return CurrentFileSystem;
DPRINT1("File system not found, try to guess one...\n");
CurrentFileSystem = NULL;
#if 0 // FIXME: To be fully enabled when our storage stack & al. will work better!
/*
* We don't have one...
*
* Try to infer one using NT file system recognition.
*/
Status = _MyGetFileSystem(PartEntry, FsRecFileSystemName, ARRAYSIZE(FsRecFileSystemName));
if (NT_SUCCESS(Status) && *FsRecFileSystemName)
{
/* Temporary HACK: map FAT32 back to FAT */
if (wcscmp(FsRecFileSystemName, L"FAT32") == 0)
wcscpy(FsRecFileSystemName, L"FAT");
FileSystemName = FsRecFileSystemName;
goto Quit;
}
#endif
/*
* We don't have one...
*
* Try to infer a preferred file system for this partition, given its ID.
*
* WARNING: This is partly a hack, since partitions with the same ID can
* be formatted with different file systems: for example, usual Linux
* partitions that are formatted in EXT2/3/4, ReiserFS, etc... have the
* same partition ID 0x83.
*
* The proper fix is to make a function that detects the existing FS
* from a given partition (not based on the partition ID).
* On the contrary, for unformatted partitions with a given ID, the
* following code is OK.
*/
if ((PartEntry->PartitionType == PARTITION_FAT_12) ||
(PartEntry->PartitionType == PARTITION_FAT_16) ||
(PartEntry->PartitionType == PARTITION_HUGE ) ||
(PartEntry->PartitionType == PARTITION_XINT13) ||
(PartEntry->PartitionType == PARTITION_FAT32 ) ||
(PartEntry->PartitionType == PARTITION_FAT32_XINT13))
{
FileSystemName = L"FAT";
}
else if (PartEntry->PartitionType == PARTITION_EXT2)
{
// WARNING: See the warning above.
FileSystemName = L"EXT2";
}
else if (PartEntry->PartitionType == PARTITION_IFS)
{
// WARNING: See the warning above.
FileSystemName = L"NTFS"; /* FIXME: Not quite correct! */
}
#if 0
Quit: // For code temporarily disabled above
#endif
// HACK: WARNING: We cannot write on this FS yet!
if (FileSystemName)
{
if (PartEntry->PartitionType == PARTITION_EXT2 || PartEntry->PartitionType == PARTITION_IFS)
DPRINT1("Recognized file system %S that doesn't support write support yet!\n", FileSystemName);
}
DPRINT1("GetFileSystem -- PartitionType: 0x%02X ; FileSystemName (guessed): %S\n",
PartEntry->PartitionType, FileSystemName ? FileSystemName : L"None");
if (FileSystemName != NULL)
CurrentFileSystem = GetFileSystemByName(/*FileSystemList,*/ FileSystemName);
return CurrentFileSystem;
}
/* EOF */

34
base/setup/lib/fsutil.h Normal file
View file

@ -0,0 +1,34 @@
/*
* PROJECT: ReactOS Setup Library
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
* PURPOSE: Filesystem support functions
* COPYRIGHT: Copyright 2002-2018 Eric Kohl
* Copyright 2003-2018 Casper S. Hornstrup (chorns@users.sourceforge.net)
* Copyright 2017-2018 Hermes Belusca-Maito
*/
#include <fmifs/fmifs.h>
typedef struct _FILE_SYSTEM
{
PCWSTR FileSystemName;
FORMATEX FormatFunc;
CHKDSKEX ChkdskFunc;
} FILE_SYSTEM, *PFILE_SYSTEM;
PFILE_SYSTEM
GetRegisteredFileSystems(OUT PULONG Count);
PFILE_SYSTEM
GetFileSystemByName(
// IN PFILE_SYSTEM_LIST List,
IN PCWSTR FileSystemName);
struct _PARTENTRY; // Defined in partlist.h
PFILE_SYSTEM
GetFileSystem(
// IN PFILE_SYSTEM_LIST FileSystemList,
IN struct _PARTENTRY* PartEntry);
/* EOF */

182
base/setup/lib/genlist.c Normal file
View file

@ -0,0 +1,182 @@
/*
* PROJECT: ReactOS Setup Library
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
* PURPOSE: Generic list functions
* COPYRIGHT: Copyright 2004-2018 Eric Kohl
* Copyright 2008-2018 Christoph von Wittich <christoph at reactos.org>
*/
/* INCLUDES *****************************************************************/
#include "precomp.h"
#include "genlist.h"
#define NDEBUG
#include <debug.h>
/* FUNCTIONS ****************************************************************/
PGENERIC_LIST
CreateGenericList(VOID)
{
PGENERIC_LIST List;
List = (PGENERIC_LIST)RtlAllocateHeap(ProcessHeap,
0,
sizeof(GENERIC_LIST));
if (List == NULL)
return NULL;
InitializeListHead(&List->ListHead);
List->NumOfEntries = 0;
List->CurrentEntry = NULL;
List->BackupEntry = NULL;
return List;
}
VOID
DestroyGenericList(
IN OUT PGENERIC_LIST List,
IN BOOLEAN FreeUserData)
{
PGENERIC_LIST_ENTRY ListEntry;
PLIST_ENTRY Entry;
/* Release list entries */
while (!IsListEmpty(&List->ListHead))
{
Entry = RemoveHeadList(&List->ListHead);
ListEntry = CONTAINING_RECORD(Entry, GENERIC_LIST_ENTRY, Entry);
/* Release user data */
if (FreeUserData && ListEntry->UserData != NULL)
RtlFreeHeap(ProcessHeap, 0, ListEntry->UserData);
/* Release list entry */
RtlFreeHeap(ProcessHeap, 0, ListEntry);
}
/* Release list head */
RtlFreeHeap(ProcessHeap, 0, List);
}
BOOLEAN
AppendGenericListEntry(
IN OUT PGENERIC_LIST List,
IN PCHAR Text,
IN PVOID UserData,
IN BOOLEAN Current)
{
PGENERIC_LIST_ENTRY Entry;
Entry = (PGENERIC_LIST_ENTRY)RtlAllocateHeap(ProcessHeap,
0,
sizeof(GENERIC_LIST_ENTRY) + strlen(Text));
if (Entry == NULL)
return FALSE;
strcpy (Entry->Text, Text);
Entry->List = List;
Entry->UserData = UserData;
InsertTailList(&List->ListHead, &Entry->Entry);
List->NumOfEntries++;
if (Current || List->CurrentEntry == NULL)
{
List->CurrentEntry = Entry;
}
return TRUE;
}
VOID
SetCurrentListEntry(
IN PGENERIC_LIST List,
IN PGENERIC_LIST_ENTRY Entry)
{
if (Entry->List != List)
return;
List->CurrentEntry = Entry;
}
PGENERIC_LIST_ENTRY
GetCurrentListEntry(
IN PGENERIC_LIST List)
{
return List->CurrentEntry;
}
PGENERIC_LIST_ENTRY
GetFirstListEntry(
IN PGENERIC_LIST List)
{
PLIST_ENTRY Entry = List->ListHead.Flink;
if (Entry == &List->ListHead)
return NULL;
return CONTAINING_RECORD(Entry, GENERIC_LIST_ENTRY, Entry);
}
PGENERIC_LIST_ENTRY
GetNextListEntry(
IN PGENERIC_LIST_ENTRY Entry)
{
PLIST_ENTRY Next = Entry->Entry.Flink;
if (Next == &Entry->List->ListHead)
return NULL;
return CONTAINING_RECORD(Next, GENERIC_LIST_ENTRY, Entry);
}
PVOID
GetListEntryUserData(
IN PGENERIC_LIST_ENTRY Entry)
{
return Entry->UserData;
}
LPCSTR
GetListEntryText(
IN PGENERIC_LIST_ENTRY Entry)
{
return Entry->Text;
}
ULONG
GetNumberOfListEntries(
IN PGENERIC_LIST List)
{
return List->NumOfEntries;
}
VOID
SaveGenericListState(
IN PGENERIC_LIST List)
{
List->BackupEntry = List->CurrentEntry;
}
VOID
RestoreGenericListState(
IN PGENERIC_LIST List)
{
List->CurrentEntry = List->BackupEntry;
}
BOOLEAN
GenericListHasSingleEntry(
IN PGENERIC_LIST List)
{
if (!IsListEmpty(&List->ListHead) && List->ListHead.Flink == List->ListHead.Blink)
return TRUE;
/* if both list head pointers (which normally point to the first and last list member, respectively)
point to the same entry then it means that there's just a single thing in there, otherwise... false! */
return FALSE;
}
/* EOF */

87
base/setup/lib/genlist.h Normal file
View file

@ -0,0 +1,87 @@
/*
* PROJECT: ReactOS Setup Library
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
* PURPOSE: Generic list functions
* COPYRIGHT: Copyright 2004-2018 Eric Kohl
* Copyright 2008-2018 Christoph von Wittich <christoph at reactos.org>
*/
#pragma once
typedef struct _GENERIC_LIST_ENTRY
{
LIST_ENTRY Entry;
struct _GENERIC_LIST* List;
PVOID UserData;
CHAR Text[1]; // FIXME: UI stuff
} GENERIC_LIST_ENTRY, *PGENERIC_LIST_ENTRY;
typedef struct _GENERIC_LIST
{
LIST_ENTRY ListHead;
ULONG NumOfEntries;
PGENERIC_LIST_ENTRY CurrentEntry;
PGENERIC_LIST_ENTRY BackupEntry;
} GENERIC_LIST, *PGENERIC_LIST;
PGENERIC_LIST
CreateGenericList(VOID);
VOID
DestroyGenericList(
IN OUT PGENERIC_LIST List,
IN BOOLEAN FreeUserData);
BOOLEAN
AppendGenericListEntry(
IN OUT PGENERIC_LIST List,
IN PCHAR Text,
IN PVOID UserData,
IN BOOLEAN Current);
VOID
SetCurrentListEntry(
IN PGENERIC_LIST List,
IN PGENERIC_LIST_ENTRY Entry);
PGENERIC_LIST_ENTRY
GetCurrentListEntry(
IN PGENERIC_LIST List);
PGENERIC_LIST_ENTRY
GetFirstListEntry(
IN PGENERIC_LIST List);
PGENERIC_LIST_ENTRY
GetNextListEntry(
IN PGENERIC_LIST_ENTRY Entry);
PVOID
GetListEntryUserData(
IN PGENERIC_LIST_ENTRY Entry);
LPCSTR
GetListEntryText(
IN PGENERIC_LIST_ENTRY Entry);
ULONG
GetNumberOfListEntries(
IN PGENERIC_LIST List);
VOID
SaveGenericListState(
IN PGENERIC_LIST List);
VOID
RestoreGenericListState(
IN PGENERIC_LIST List);
BOOLEAN
GenericListHasSingleEntry(
IN PGENERIC_LIST List);
/* EOF */

26
base/setup/lib/linklist.h Normal file
View file

@ -0,0 +1,26 @@
/*
* PROJECT: ReactOS Setup Library
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
* PURPOSE: Linked list support macros
* COPYRIGHT: Copyright 2005-2018 ReactOS Team
*/
#pragma once
#define InsertAscendingList(ListHead, NewEntry, Type, ListEntryField, SortField) \
do { \
PLIST_ENTRY current = (ListHead)->Flink; \
while (current != (ListHead)) \
{ \
if (CONTAINING_RECORD(current, Type, ListEntryField)->SortField >= \
(NewEntry)->SortField) \
{ \
break; \
} \
current = current->Flink; \
} \
\
InsertTailList(current, &((NewEntry)->ListEntryField)); \
} while (0)
/* EOF */

3056
base/setup/lib/partlist.c Normal file

File diff suppressed because it is too large Load diff

321
base/setup/lib/partlist.h Normal file
View file

@ -0,0 +1,321 @@
/*
* PROJECT: ReactOS Setup Library
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
* PURPOSE: Partition list functions
* COPYRIGHT: Copyright 2002-2018 Eric Kohl
* Copyright 2003-2018 Casper S. Hornstrup (chorns@users.sourceforge.net)
*/
#pragma once
typedef enum _FORMATSTATE
{
Unformatted,
UnformattedOrDamaged,
UnknownFormat,
Preformatted,
Formatted
} FORMATSTATE, *PFORMATSTATE;
typedef enum _FORMATMACHINESTATE
{
Start,
FormatSystemPartition,
FormatInstallPartition,
FormatOtherPartition,
FormatDone,
CheckSystemPartition,
CheckInstallPartition,
CheckOtherPartition,
CheckDone
} FORMATMACHINESTATE, *PFORMATMACHINESTATE;
struct _FILE_SYSTEM;
typedef struct _PARTENTRY
{
LIST_ENTRY ListEntry;
/* The disk this partition belongs to */
struct _DISKENTRY *DiskEntry;
/* Partition geometry */
ULARGE_INTEGER StartSector;
ULARGE_INTEGER SectorCount;
BOOLEAN BootIndicator;
UCHAR PartitionType;
ULONG HiddenSectors;
ULONG PartitionNumber; /* Enumerated partition number (primary partitions first -- excluding the extended partition container --, then the logical partitions) */
ULONG PartitionIndex; /* Index in the LayoutBuffer->PartitionEntry[] cached array of the corresponding DiskEntry */
CHAR DriveLetter;
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;
/* Partition must be checked */
BOOLEAN NeedsCheck;
FORMATSTATE FormatState;
struct _FILE_SYSTEM* 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;
/* Disk geometry */
ULONGLONG Cylinders;
ULONG TracksPerCylinder;
ULONG SectorsPerTrack;
ULONG BytesPerSector;
ULARGE_INTEGER SectorCount;
ULONG SectorAlignment;
ULONG CylinderAlignment;
/* BIOS parameters */
BOOLEAN BiosFound;
ULONG BiosDiskNumber;
// ULONG Signature;
// ULONG Checksum;
/* SCSI parameters */
ULONG DiskNumber;
USHORT Port;
USHORT Bus;
USHORT Id;
/* Has the partition list been modified? */
BOOLEAN Dirty;
BOOLEAN NewDisk;
BOOLEAN NoMbr; /* MBR is absent */ // See r40437
UNICODE_STRING DriverName;
PDRIVE_LAYOUT_INFORMATION LayoutBuffer;
// TODO: When adding support for GPT disks:
// Use PDRIVE_LAYOUT_INFORMATION_EX which indicates whether
// the disk is MBR, GPT, or unknown (uninitialized).
// Depending on the style, either use the MBR or GPT partition info.
/* Pointer to the unique extended partition on this disk */
PPARTENTRY ExtendedPartition;
LIST_ENTRY PrimaryPartListHead;
LIST_ENTRY LogicalPartListHead;
} DISKENTRY, *PDISKENTRY;
typedef struct _PARTLIST
{
/*
* Disk & Partition iterators.
*
* NOTE that when CurrentPartition != NULL, then CurrentPartition->DiskEntry
* must be the same as CurrentDisk. We should however keep the two members
* separated as we can have a current (selected) disk without any current
* partition, if the former does not contain any.
*/
PDISKENTRY CurrentDisk;
PPARTENTRY CurrentPartition;
/*
* The system partition where the boot manager resides.
* The corresponding system disk is obtained via:
* SystemPartition->DiskEntry.
*/
PPARTENTRY SystemPartition;
/*
* The original system partition in case we are redefining it because
* we do not have write support on it.
* Please note that this is partly a HACK and MUST NEVER happen on
* architectures where real system partitions are mandatory (because then
* they are formatted in FAT FS and we support write operation on them).
* The corresponding original system disk is obtained via:
* OriginalSystemPartition->DiskEntry.
*/
PPARTENTRY OriginalSystemPartition;
PPARTENTRY TempPartition;
FORMATMACHINESTATE FormatState;
LIST_ENTRY DiskListHead;
LIST_ENTRY BiosDiskListHead;
} PARTLIST, *PPARTLIST;
#define PARTITION_TBL_SIZE 4
#include <pshpack1.h>
typedef struct _PARTITION
{
unsigned char BootFlags; /* bootable? 0=no, 128=yes */
unsigned char StartingHead; /* beginning head number */
unsigned char StartingSector; /* beginning sector number */
unsigned char StartingCylinder; /* 10 bit nmbr, with high 2 bits put in begsect */
unsigned char PartitionType; /* Operating System type indicator code */
unsigned char EndingHead; /* ending head number */
unsigned char EndingSector; /* ending sector number */
unsigned char EndingCylinder; /* also a 10 bit nmbr, with same high 2 bit trick */
unsigned int StartingBlock; /* first sector relative to start of disk */
unsigned int SectorCount; /* number of sectors in partition */
} PARTITION, *PPARTITION;
typedef struct _PARTITION_SECTOR
{
UCHAR BootCode[440]; /* 0x000 */
ULONG Signature; /* 0x1B8 */
UCHAR Reserved[2]; /* 0x1BC */
PARTITION Partition[PARTITION_TBL_SIZE]; /* 0x1BE */
USHORT Magic; /* 0x1FE */
} PARTITION_SECTOR, *PPARTITION_SECTOR;
#include <poppack.h>
typedef struct
{
LIST_ENTRY ListEntry;
ULONG DiskNumber;
ULONG Identifier;
ULONG Signature;
} BIOS_DISK, *PBIOS_DISK;
ULONGLONG
AlignDown(
IN ULONGLONG Value,
IN ULONG Alignment);
ULONGLONG
AlignUp(
IN ULONGLONG Value,
IN ULONG Alignment);
ULONGLONG
RoundingDivide(
IN ULONGLONG Dividend,
IN ULONGLONG Divisor);
PPARTLIST
CreatePartitionList(VOID);
VOID
DestroyPartitionList(
IN PPARTLIST List);
ULONG
SelectPartition(
IN PPARTLIST List,
IN ULONG DiskNumber,
IN ULONG PartitionNumber);
PPARTENTRY
GetNextPartition(
IN PPARTLIST List);
PPARTENTRY
GetPrevPartition(
IN PPARTLIST List);
VOID
CreatePrimaryPartition(
IN PPARTLIST List,
IN ULONGLONG SectorCount,
IN BOOLEAN AutoCreate);
VOID
CreateExtendedPartition(
IN PPARTLIST List,
IN ULONGLONG SectorCount);
VOID
CreateLogicalPartition(
IN PPARTLIST List,
IN ULONGLONG SectorCount,
IN BOOLEAN AutoCreate);
VOID
DeleteCurrentPartition(
IN PPARTLIST List);
VOID
CheckActiveSystemPartition(
IN PPARTLIST List // ,
// IN PFILE_SYSTEM_LIST FileSystemList /* Needed for checking the FS of the candidate system partition */
);
BOOLEAN
WritePartitionsToDisk(
IN PPARTLIST List);
BOOLEAN
SetMountedDeviceValue(
IN CHAR Letter,
IN ULONG Signature,
IN LARGE_INTEGER StartingOffset);
BOOLEAN
SetMountedDeviceValues(
IN PPARTLIST List);
VOID
SetPartitionType(
IN PPARTENTRY PartEntry,
IN UCHAR PartitionType);
ERROR_NUMBER
PrimaryPartitionCreationChecks(
IN PPARTLIST List);
ERROR_NUMBER
ExtendedPartitionCreationChecks(
IN PPARTLIST List);
ERROR_NUMBER
LogicalPartitionCreationChecks(
IN PPARTLIST List);
BOOLEAN
GetNextUnformattedPartition(
IN PPARTLIST List,
OUT PDISKENTRY *pDiskEntry OPTIONAL,
OUT PPARTENTRY *pPartEntry);
BOOLEAN
GetNextUncheckedPartition(
IN PPARTLIST List,
OUT PDISKENTRY *pDiskEntry OPTIONAL,
OUT PPARTENTRY *pPartEntry);
/* EOF */

62
base/setup/lib/precomp.h Normal file
View file

@ -0,0 +1,62 @@
/*
* PROJECT: ReactOS Setup Library
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
* PURPOSE: Precompiled header
* COPYRIGHT: Copyright 2017-2018 Hermes Belusca-Maito
*/
/* C Headers */
#include <stdio.h>
#include <stdlib.h>
/* PSDK/NDK Headers */
#define WIN32_NO_STATUS
#include <windef.h>
#include <winbase.h>
#include <winreg.h>
#include <winuser.h>
#include <strsafe.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>
/* Filesystem headers */
#include <reactos/rosioctl.h> // For extra partition IDs
/** For FileSystems **/
// #include <fslib/vfatlib.h>
// #include <fslib/ext2lib.h>
// // #include <fslib/ntfslib.h>
//
///* Internal Headers */
//#include "interface/consup.h"
//#include "inffile.h"
//#include "inicache.h"
//#include "progress.h"
//#ifdef __REACTOS__
//#include "infros.h"
//#include "filequeue.h"
//#endif
//#include "registry.h"
//#include "fslist.h"
//#include "partlist.h"
//#include "cabinet.h"
//#include "filesup.h"
//#include "genlist.h"
extern HANDLE ProcessHeap;
#include "errorcode.h"
#include "linklist.h"

34
base/setup/lib/setuplib.h Normal file
View file

@ -0,0 +1,34 @@
/*
* PROJECT: ReactOS Setup Library
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
* PURPOSE: Public header
* COPYRIGHT: Copyright 2017-2018 Hermes Belusca-Maito
*/
#pragma once
/* Needed PSDK headers when using this library */
#if 0
#define WIN32_NO_STATUS
#define _INC_WINDOWS
#define COM_NO_WINDOWS_H
#include <wingdi.h> // For LF_FACESIZE and TranslateCharsetInfo()
#include <wincon.h>
#include <winnls.h> // For code page support
#include <winreg.h>
#endif
/* NOTE: Please keep the header inclusion order! */
extern HANDLE ProcessHeap;
#include "errorcode.h"
#include "linklist.h"
#include "fsutil.h"
#include "genlist.h"
#include "partlist.h"
/* EOF */

View file

@ -3,6 +3,8 @@ add_definitions(${I18N_DEFS})
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/../lib
# ${REACTOS_SOURCE_DIR}/base/setup/lib
${REACTOS_SOURCE_DIR}/sdk/lib/inflib
${REACTOS_SOURCE_DIR}/sdk/include/reactos/libs/zlib
${REACTOS_SOURCE_DIR}/sdk/include/reactos/drivers)
@ -38,8 +40,8 @@ if(USE_CLANG_CL)
add_target_compile_flags(usetup "-Wno-invalid-source-encoding")
endif()
target_link_libraries(usetup zlib_solo inflib ext2lib vfatlib)
set_module_type(usetup nativecui)
add_importlibs(usetup ntdll)
add_pch(usetup usetup.h SOURCE)
set_module_type(usetup nativecui)
target_link_libraries(usetup inflib setuplib zlib_solo ext2lib vfatlib)
add_importlibs(usetup ntdll)
add_cd_file(TARGET usetup DESTINATION reactos/system32 NO_CAB NAME_ON_CD smss.exe FOR bootcd regtest)

View file

@ -2659,17 +2659,24 @@ InstallFatBootcodeToFloppy(
PUNICODE_STRING DestinationArcPath)
{
NTSTATUS Status;
PFILE_SYSTEM FatFS;
UNICODE_STRING FloppyDevice = RTL_CONSTANT_STRING(L"\\Device\\Floppy0");
WCHAR SrcPath[MAX_PATH];
WCHAR DstPath[MAX_PATH];
/* Format the floppy first */
Status = VfatFormat(&FloppyDevice,
FMIFS_FLOPPY,
NULL,
TRUE,
0,
NULL);
FatFS = GetFileSystemByName(L"FAT");
if (!FatFS)
{
DPRINT1("FAT FS non existent on this system?!\n");
return STATUS_NOT_SUPPORTED;
}
Status = FatFS->FormatFunc(&FloppyDevice,
FMIFS_FLOPPY,
NULL,
TRUE,
0,
NULL);
if (!NT_SUCCESS(Status))
{
DPRINT1("VfatFormat() failed (Status %lx)\n", Status);

View file

@ -56,11 +56,13 @@ ChkdskCallback(
NTSTATUS
ChkdskPartition(
IN PUNICODE_STRING DriveRoot,
IN PFILE_SYSTEM_ITEM FileSystem)
/*IN PFILE_SYSTEM_ITEM FileSystemItem*/
IN PFILE_SYSTEM FileSystem)
{
NTSTATUS Status;
// PFILE_SYSTEM FileSystem = FileSystemItem->FileSystem;
if (!FileSystem->ChkdskFunc)
if (!FileSystem || !FileSystem->ChkdskFunc)
return STATUS_NOT_SUPPORTED;
ChkdskProgressBar = CreateProgressBar(6,

View file

@ -28,6 +28,7 @@
NTSTATUS
ChkdskPartition(
IN PUNICODE_STRING DriveRoot,
IN PFILE_SYSTEM_ITEM FileSystem);
/*IN PFILE_SYSTEM_ITEM FileSystemItem*/
IN PFILE_SYSTEM FileSystem);
/* EOF */

View file

@ -88,11 +88,12 @@ FormatCallback(
NTSTATUS
FormatPartition(
IN PUNICODE_STRING DriveRoot,
IN PFILE_SYSTEM_ITEM FileSystem)
IN PFILE_SYSTEM_ITEM FileSystemItem)
{
NTSTATUS Status;
PFILE_SYSTEM FileSystem = FileSystemItem->FileSystem;
if (!FileSystem->FormatFunc)
if (!FileSystem || !FileSystem->FormatFunc)
return STATUS_NOT_SUPPORTED;
FormatProgressBar = CreateProgressBar(6,
@ -107,11 +108,11 @@ FormatPartition(
ProgressSetStepCount(FormatProgressBar, 100);
Status = FileSystem->FormatFunc(DriveRoot,
FMIFS_HARDDISK, /* MediaFlag */
NULL, /* Label */
FileSystem->QuickFormat, /* QuickFormat */
0, /* ClusterSize */
FormatCallback); /* Callback */
FMIFS_HARDDISK, /* MediaFlag */
NULL, /* Label */
FileSystemItem->QuickFormat, /* QuickFormat */
0, /* ClusterSize */
FormatCallback); /* Callback */
DestroyProgressBar(FormatProgressBar);
FormatProgressBar = NULL;

View file

@ -29,6 +29,6 @@
NTSTATUS
FormatPartition(
IN PUNICODE_STRING DriveRoot,
IN PFILE_SYSTEM_ITEM FileSystem);
IN PFILE_SYSTEM_ITEM FileSystemItem);
/* EOF */

View file

@ -32,234 +32,54 @@
/* FUNCTIONS ****************************************************************/
VOID
static VOID
AddProvider(
IN OUT PFILE_SYSTEM_LIST List,
IN PCWSTR FileSystemName,
IN FORMATEX FormatFunc,
IN CHKDSKEX ChkdskFunc)
IN PCWSTR FileSystemName, // Redundant, I need to check whether this is reaaaaally needed....
IN PFILE_SYSTEM FileSystem)
{
PFILE_SYSTEM_ITEM Item;
Item = (PFILE_SYSTEM_ITEM)RtlAllocateHeap(ProcessHeap, 0, sizeof(FILE_SYSTEM_ITEM));
Item = (PFILE_SYSTEM_ITEM)RtlAllocateHeap(ProcessHeap, 0, sizeof(*Item));
if (!Item)
return;
Item->FileSystemName = FileSystemName;
Item->FormatFunc = FormatFunc;
Item->ChkdskFunc = ChkdskFunc;
Item->FileSystem = FileSystem;
Item->QuickFormat = TRUE;
InsertTailList(&List->ListHead, &Item->ListEntry);
if (!FormatFunc)
if (!FileSystem)
return;
Item = (PFILE_SYSTEM_ITEM)RtlAllocateHeap(ProcessHeap, 0, sizeof(FILE_SYSTEM_ITEM));
Item = (PFILE_SYSTEM_ITEM)RtlAllocateHeap(ProcessHeap, 0, sizeof(*Item));
if (!Item)
return;
Item->FileSystemName = FileSystemName;
Item->FormatFunc = FormatFunc;
Item->ChkdskFunc = ChkdskFunc;
Item->FileSystem = FileSystem;
Item->QuickFormat = FALSE;
InsertTailList(&List->ListHead, &Item->ListEntry);
}
PFILE_SYSTEM_ITEM
GetFileSystemByName(
IN PFILE_SYSTEM_LIST List,
IN PWSTR FileSystemName)
static VOID
InitializeFileSystemList(
IN PFILE_SYSTEM_LIST List)
{
PLIST_ENTRY ListEntry;
PFILE_SYSTEM_ITEM Item;
ULONG Count;
PFILE_SYSTEM FileSystems;
ListEntry = List->ListHead.Flink;
while (ListEntry != &List->ListHead)
FileSystems = GetRegisteredFileSystems(&Count);
if (!FileSystems || Count == 0)
return;
while (Count--)
{
Item = CONTAINING_RECORD(ListEntry, FILE_SYSTEM_ITEM, ListEntry);
if (Item->FileSystemName && wcsicmp(FileSystemName, Item->FileSystemName) == 0)
return Item;
ListEntry = ListEntry->Flink;
AddProvider(List, FileSystems->FileSystemName, FileSystems);
++FileSystems;
}
return NULL;
}
#if 0 // FIXME: To be fully enabled when our storage stack & al. will work better!
/* NOTE: Ripped & adapted from base/system/autochk/autochk.c */
static NTSTATUS
_MyGetFileSystem(
IN struct _PARTENTRY* PartEntry,
IN OUT PWSTR FileSystemName,
IN SIZE_T FileSystemNameSize)
{
NTSTATUS Status;
HANDLE FileHandle;
IO_STATUS_BLOCK IoStatusBlock;
PFILE_FS_ATTRIBUTE_INFORMATION FileFsAttribute;
UCHAR Buffer[sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + MAX_PATH * sizeof(WCHAR)];
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING PartitionRootPath;
WCHAR PathBuffer[MAX_PATH];
FileFsAttribute = (PFILE_FS_ATTRIBUTE_INFORMATION)Buffer;
/* Set PartitionRootPath */
swprintf(PathBuffer,
// L"\\Device\\Harddisk%lu\\Partition%lu", // Should work! But because ReactOS sucks atm. it actually doesn't work!!
L"\\Device\\Harddisk%lu\\Partition%lu\\", // HACK: Use this as a temporary hack!
PartEntry->DiskEntry->DiskNumber,
PartEntry->PartitionNumber);
RtlInitUnicodeString(&PartitionRootPath, PathBuffer);
DPRINT("PartitionRootPath: %wZ\n", &PartitionRootPath);
/* Open the partition */
InitializeObjectAttributes(&ObjectAttributes,
&PartitionRootPath,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
Status = NtOpenFile(&FileHandle, // PartitionHandle,
FILE_GENERIC_READ /* | SYNCHRONIZE */,
&ObjectAttributes,
&IoStatusBlock,
FILE_SHARE_READ,
0 /* FILE_SYNCHRONOUS_IO_NONALERT */);
if (!NT_SUCCESS(Status))
{
DPRINT1("Failed to open partition %wZ, Status 0x%08lx\n", &PartitionRootPath, Status);
return Status;
}
/* Retrieve the FS attributes */
Status = NtQueryVolumeInformationFile(FileHandle,
&IoStatusBlock,
FileFsAttribute,
sizeof(Buffer),
FileFsAttributeInformation);
NtClose(FileHandle);
if (!NT_SUCCESS(Status))
{
DPRINT1("NtQueryVolumeInformationFile failed for partition %wZ, Status 0x%08lx\n", &PartitionRootPath, Status);
return Status;
}
if (FileSystemNameSize * sizeof(WCHAR) < FileFsAttribute->FileSystemNameLength + sizeof(WCHAR))
return STATUS_BUFFER_TOO_SMALL;
RtlCopyMemory(FileSystemName,
FileFsAttribute->FileSystemName,
FileFsAttribute->FileSystemNameLength);
FileSystemName[FileFsAttribute->FileSystemNameLength / sizeof(WCHAR)] = UNICODE_NULL;
return STATUS_SUCCESS;
}
#endif
PFILE_SYSTEM_ITEM
GetFileSystem(
IN PFILE_SYSTEM_LIST FileSystemList,
IN struct _PARTENTRY* PartEntry)
{
PFILE_SYSTEM_ITEM CurrentFileSystem;
PWSTR FileSystemName = NULL;
#if 0 // For code temporarily disabled below
NTSTATUS Status;
WCHAR FsRecFileSystemName[MAX_PATH];
#endif
CurrentFileSystem = PartEntry->FileSystem;
/* We have a file system, return it */
if (CurrentFileSystem != NULL && CurrentFileSystem->FileSystemName != NULL)
return CurrentFileSystem;
DPRINT1("File system not found, try to guess one...\n");
CurrentFileSystem = NULL;
#if 0 // FIXME: To be fully enabled when our storage stack & al. will work better!
/*
* We don't have one...
*
* Try to infer one using NT file system recognition.
*/
Status = _MyGetFileSystem(PartEntry, FsRecFileSystemName, ARRAYSIZE(FsRecFileSystemName));
if (NT_SUCCESS(Status) && *FsRecFileSystemName)
{
/* Temporary HACK: map FAT32 back to FAT */
if (wcscmp(FsRecFileSystemName, L"FAT32") == 0)
wcscpy(FsRecFileSystemName, L"FAT");
FileSystemName = FsRecFileSystemName;
goto Quit;
}
#endif
/*
* We don't have one...
*
* Try to infer a preferred file system for this partition, given its ID.
*
* WARNING: This is partly a hack, since partitions with the same ID can
* be formatted with different file systems: for example, usual Linux
* partitions that are formatted in EXT2/3/4, ReiserFS, etc... have the
* same partition ID 0x83.
*
* The proper fix is to make a function that detects the existing FS
* from a given partition (not based on the partition ID).
* On the contrary, for unformatted partitions with a given ID, the
* following code is OK.
*/
if ((PartEntry->PartitionType == PARTITION_FAT_12) ||
(PartEntry->PartitionType == PARTITION_FAT_16) ||
(PartEntry->PartitionType == PARTITION_HUGE ) ||
(PartEntry->PartitionType == PARTITION_XINT13) ||
(PartEntry->PartitionType == PARTITION_FAT32 ) ||
(PartEntry->PartitionType == PARTITION_FAT32_XINT13))
{
FileSystemName = L"FAT";
}
else if (PartEntry->PartitionType == PARTITION_EXT2)
{
// WARNING: See the warning above.
FileSystemName = L"EXT2";
}
else if (PartEntry->PartitionType == PARTITION_IFS)
{
// WARNING: See the warning above.
FileSystemName = L"NTFS"; /* FIXME: Not quite correct! */
}
#if 0
Quit: // For code temporarily disabled above
#endif
// HACK: WARNING: We cannot write on this FS yet!
if (FileSystemName)
{
if (PartEntry->PartitionType == PARTITION_EXT2 || PartEntry->PartitionType == PARTITION_IFS)
DPRINT1("Recognized file system %S that doesn't support write support yet!\n", FileSystemName);
}
DPRINT1("GetFileSystem -- PartitionType: 0x%02X ; FileSystemName (guessed): %S\n",
PartEntry->PartitionType, FileSystemName ? FileSystemName : L"None");
if (FileSystemName != NULL)
CurrentFileSystem = GetFileSystemByName(FileSystemList, FileSystemName);
return CurrentFileSystem;
}
PFILE_SYSTEM_LIST
CreateFileSystemList(
IN SHORT Left,
@ -271,7 +91,7 @@ CreateFileSystemList(
PFILE_SYSTEM_ITEM Item;
PLIST_ENTRY ListEntry;
List = (PFILE_SYSTEM_LIST)RtlAllocateHeap(ProcessHeap, 0, sizeof(FILE_SYSTEM_LIST));
List = (PFILE_SYSTEM_LIST)RtlAllocateHeap(ProcessHeap, 0, sizeof(*List));
if (List == NULL)
return NULL;
@ -280,16 +100,11 @@ CreateFileSystemList(
List->Selected = NULL;
InitializeListHead(&List->ListHead);
AddProvider(List, L"FAT", VfatFormat, VfatChkdsk);
#if 0
AddProvider(List, L"EXT2", Ext2Format, Ext2Chkdsk);
AddProvider(List, L"NTFS", NtfsFormat, NtfsChkdsk);
#endif
InitializeFileSystemList(List);
if (!ForceFormat)
{
/* Add the 'Keep existing filesystem' dummy provider */
AddProvider(List, NULL, NULL, NULL);
AddProvider(List, NULL, NULL);
}
/* Search for SelectFileSystem in list */
@ -314,19 +129,17 @@ VOID
DestroyFileSystemList(
IN PFILE_SYSTEM_LIST List)
{
PLIST_ENTRY ListEntry = List->ListHead.Flink;
PLIST_ENTRY ListEntry;
PFILE_SYSTEM_ITEM Item;
PLIST_ENTRY Next;
while (ListEntry != &List->ListHead)
ListEntry = List->ListHead.Flink;
while (!IsListEmpty(&List->ListHead))
{
ListEntry = RemoveHeadList(&List->ListHead);
Item = CONTAINING_RECORD(ListEntry, FILE_SYSTEM_ITEM, ListEntry);
Next = ListEntry->Flink;
RtlFreeHeap(ProcessHeap, 0, Item);
ListEntry = Next;
}
RtlFreeHeap(ProcessHeap, 0, List);
}

View file

@ -31,9 +31,8 @@
typedef struct _FILE_SYSTEM_ITEM
{
LIST_ENTRY ListEntry;
PCWSTR FileSystemName; /* Not owned by the item */
FORMATEX FormatFunc;
CHKDSKEX ChkdskFunc;
PCWSTR FileSystemName; /* Not owned by the item */ // Redundant, I need to check whether this is reaaaaally needed....
PFILE_SYSTEM FileSystem;
BOOLEAN QuickFormat;
} FILE_SYSTEM_ITEM, *PFILE_SYSTEM_ITEM;
@ -45,24 +44,6 @@ typedef struct _FILE_SYSTEM_LIST
LIST_ENTRY ListHead; /* List of FILE_SYSTEM_ITEM */
} FILE_SYSTEM_LIST, *PFILE_SYSTEM_LIST;
VOID
AddProvider(
IN OUT PFILE_SYSTEM_LIST List,
IN PCWSTR FileSystemName,
IN FORMATEX FormatFunc,
IN CHKDSKEX ChkdskFunc);
PFILE_SYSTEM_ITEM
GetFileSystemByName(
IN PFILE_SYSTEM_LIST List,
IN PWSTR FileSystemName);
struct _PARTENTRY; // Defined in partlist.h
PFILE_SYSTEM_ITEM
GetFileSystem(
IN PFILE_SYSTEM_LIST FileSystemList,
IN struct _PARTENTRY* PartEntry);
PFILE_SYSTEM_LIST
CreateFileSystemList(
IN SHORT Left,

View file

@ -33,103 +33,6 @@
/* FUNCTIONS ****************************************************************/
typedef struct _GENERIC_LIST_ENTRY
{
LIST_ENTRY Entry;
PGENERIC_LIST List;
PVOID UserData;
CHAR Text[1]; // FIXME: UI stuff
} GENERIC_LIST_ENTRY;
typedef struct _GENERIC_LIST
{
LIST_ENTRY ListHead;
ULONG NumOfEntries;
PGENERIC_LIST_ENTRY CurrentEntry;
PGENERIC_LIST_ENTRY BackupEntry;
} GENERIC_LIST;
PGENERIC_LIST
CreateGenericList(VOID)
{
PGENERIC_LIST List;
List = (PGENERIC_LIST)RtlAllocateHeap(ProcessHeap,
0,
sizeof(GENERIC_LIST));
if (List == NULL)
return NULL;
InitializeListHead(&List->ListHead);
List->NumOfEntries = 0;
List->CurrentEntry = NULL;
List->BackupEntry = NULL;
return List;
}
VOID
DestroyGenericList(
IN OUT PGENERIC_LIST List,
IN BOOLEAN FreeUserData)
{
PGENERIC_LIST_ENTRY ListEntry;
PLIST_ENTRY Entry;
/* Release list entries */
while (!IsListEmpty (&List->ListHead))
{
Entry = RemoveHeadList (&List->ListHead);
ListEntry = CONTAINING_RECORD (Entry, GENERIC_LIST_ENTRY, Entry);
/* Release user data */
if (FreeUserData && ListEntry->UserData != NULL)
RtlFreeHeap (ProcessHeap, 0, ListEntry->UserData);
/* Release list entry */
RtlFreeHeap (ProcessHeap, 0, ListEntry);
}
/* Release list head */
RtlFreeHeap (ProcessHeap, 0, List);
}
BOOLEAN
AppendGenericListEntry(
IN OUT PGENERIC_LIST List,
IN PCHAR Text,
IN PVOID UserData,
IN BOOLEAN Current)
{
PGENERIC_LIST_ENTRY Entry;
Entry = (PGENERIC_LIST_ENTRY)RtlAllocateHeap(ProcessHeap,
0,
sizeof(GENERIC_LIST_ENTRY) + strlen(Text));
if (Entry == NULL)
return FALSE;
strcpy (Entry->Text, Text);
Entry->List = List;
Entry->UserData = UserData;
InsertTailList(&List->ListHead,
&Entry->Entry);
List->NumOfEntries++;
if (Current || List->CurrentEntry == NULL)
{
List->CurrentEntry = Entry;
}
return TRUE;
}
VOID
InitGenericListUi(
IN OUT PGENERIC_LIST_UI ListUi,
@ -229,7 +132,6 @@ DrawListFrame(
&Written);
}
static
VOID
DrawListEntries(
@ -249,7 +151,7 @@ DrawListEntries(
Entry = ListUi->FirstShown;
while (Entry != &List->ListHead)
{
ListEntry = CONTAINING_RECORD (Entry, GENERIC_LIST_ENTRY, Entry);
ListEntry = CONTAINING_RECORD(Entry, GENERIC_LIST_ENTRY, Entry);
if (coPos.Y == ListUi->Bottom)
break;
@ -298,7 +200,6 @@ DrawListEntries(
}
}
static
VOID
DrawScrollBarGenericList(
@ -347,7 +248,6 @@ DrawScrollBarGenericList(
}
}
static
VOID
CenterCurrentListItem(
@ -398,7 +298,6 @@ CenterCurrentListItem(
}
}
VOID
DrawGenericList(
IN PGENERIC_LIST_UI ListUi,
@ -426,53 +325,6 @@ DrawGenericList(
DrawScrollBarGenericList(ListUi);
}
VOID
ScrollPageDownGenericList(
IN PGENERIC_LIST_UI ListUi)
{
SHORT i;
/* Suspend auto-redraw */
ListUi->Redraw = FALSE;
for (i = ListUi->Top + 1; i < ListUi->Bottom - 1; i++)
{
ScrollDownGenericList(ListUi);
}
/* Update user interface */
DrawListEntries(ListUi);
DrawScrollBarGenericList(ListUi);
/* Re enable auto-redraw */
ListUi->Redraw = TRUE;
}
VOID
ScrollPageUpGenericList(
IN PGENERIC_LIST_UI ListUi)
{
SHORT i;
/* Suspend auto-redraw */
ListUi->Redraw = FALSE;
for (i = ListUi->Bottom - 1; i > ListUi->Top + 1; i--)
{
ScrollUpGenericList(ListUi);
}
/* Update user interface */
DrawListEntries(ListUi);
DrawScrollBarGenericList(ListUi);
/* Re enable auto-redraw */
ListUi->Redraw = TRUE;
}
VOID
ScrollDownGenericList(
IN PGENERIC_LIST_UI ListUi)
@ -501,6 +353,77 @@ ScrollDownGenericList(
}
}
VOID
ScrollUpGenericList(
IN PGENERIC_LIST_UI ListUi)
{
PGENERIC_LIST List = ListUi->List;
PLIST_ENTRY Entry;
if (List->CurrentEntry == NULL)
return;
if (List->CurrentEntry->Entry.Blink != &List->ListHead)
{
Entry = List->CurrentEntry->Entry.Blink;
if (ListUi->FirstShown == &List->CurrentEntry->Entry)
{
ListUi->FirstShown = ListUi->FirstShown->Blink;
ListUi->LastShown = ListUi->LastShown->Blink;
}
List->CurrentEntry = CONTAINING_RECORD(Entry, GENERIC_LIST_ENTRY, Entry);
if (ListUi->Redraw)
{
DrawListEntries(ListUi);
DrawScrollBarGenericList(ListUi);
}
}
}
VOID
ScrollPageDownGenericList(
IN PGENERIC_LIST_UI ListUi)
{
SHORT i;
/* Suspend auto-redraw */
ListUi->Redraw = FALSE;
for (i = ListUi->Top + 1; i < ListUi->Bottom - 1; i++)
{
ScrollDownGenericList(ListUi);
}
/* Update user interface */
DrawListEntries(ListUi);
DrawScrollBarGenericList(ListUi);
/* Re enable auto-redraw */
ListUi->Redraw = TRUE;
}
VOID
ScrollPageUpGenericList(
IN PGENERIC_LIST_UI ListUi)
{
SHORT i;
/* Suspend auto-redraw */
ListUi->Redraw = FALSE;
for (i = ListUi->Bottom - 1; i > ListUi->Top + 1; i--)
{
ScrollUpGenericList(ListUi);
}
/* Update user interface */
DrawListEntries(ListUi);
DrawScrollBarGenericList(ListUi);
/* Re enable auto-redraw */
ListUi->Redraw = TRUE;
}
VOID
ScrollToPositionGenericList(
@ -537,36 +460,6 @@ ScrollToPositionGenericList(
}
}
VOID
ScrollUpGenericList(
IN PGENERIC_LIST_UI ListUi)
{
PGENERIC_LIST List = ListUi->List;
PLIST_ENTRY Entry;
if (List->CurrentEntry == NULL)
return;
if (List->CurrentEntry->Entry.Blink != &List->ListHead)
{
Entry = List->CurrentEntry->Entry.Blink;
if (ListUi->FirstShown == &List->CurrentEntry->Entry)
{
ListUi->FirstShown = ListUi->FirstShown->Blink;
ListUi->LastShown = ListUi->LastShown->Blink;
}
List->CurrentEntry = CONTAINING_RECORD(Entry, GENERIC_LIST_ENTRY, Entry);
if (ListUi->Redraw)
{
DrawListEntries(ListUi);
DrawScrollBarGenericList(ListUi);
}
}
}
VOID
RedrawGenericList(
IN PGENERIC_LIST_UI ListUi)
@ -581,76 +474,6 @@ RedrawGenericList(
}
}
VOID
SetCurrentListEntry(
IN PGENERIC_LIST List,
IN PGENERIC_LIST_ENTRY Entry)
{
if (Entry->List != List)
return;
List->CurrentEntry = Entry;
}
PGENERIC_LIST_ENTRY
GetCurrentListEntry(
IN PGENERIC_LIST List)
{
return List->CurrentEntry;
}
PGENERIC_LIST_ENTRY
GetFirstListEntry(
IN PGENERIC_LIST List)
{
PLIST_ENTRY Entry = List->ListHead.Flink;
if (Entry == &List->ListHead)
return NULL;
return CONTAINING_RECORD(Entry, GENERIC_LIST_ENTRY, Entry);
}
PGENERIC_LIST_ENTRY
GetNextListEntry(
IN PGENERIC_LIST_ENTRY Entry)
{
PLIST_ENTRY Next = Entry->Entry.Flink;
if (Next == &Entry->List->ListHead)
return NULL;
return CONTAINING_RECORD(Next, GENERIC_LIST_ENTRY, Entry);
}
PVOID
GetListEntryUserData(
IN PGENERIC_LIST_ENTRY Entry)
{
return Entry->UserData;
}
LPCSTR
GetListEntryText(
IN PGENERIC_LIST_ENTRY Entry)
{
return Entry->Text;
}
ULONG
GetNumberOfListEntries(
IN PGENERIC_LIST List)
{
return List->NumOfEntries;
}
VOID
GenericListKeyPress(
IN PGENERIC_LIST_UI ListUi,
@ -714,33 +537,4 @@ End:
ListUi->Redraw = TRUE;
}
VOID
SaveGenericListState(
IN PGENERIC_LIST List)
{
List->BackupEntry = List->CurrentEntry;
}
VOID
RestoreGenericListState(
IN PGENERIC_LIST List)
{
List->CurrentEntry = List->BackupEntry;
}
BOOLEAN
GenericListHasSingleEntry(
IN PGENERIC_LIST List)
{
if (!IsListEmpty(&List->ListHead) && List->ListHead.Flink == List->ListHead.Blink)
return TRUE;
/* if both list head pointers (which normally point to the first and last list member, respectively)
point to the same entry then it means that there's just a single thing in there, otherwise... false! */
return FALSE;
}
/* EOF */

View file

@ -26,69 +26,7 @@
#pragma once
struct _GENERIC_LIST_ENTRY;
typedef struct _GENERIC_LIST_ENTRY *PGENERIC_LIST_ENTRY;
struct _GENERIC_LIST;
typedef struct _GENERIC_LIST *PGENERIC_LIST;
PGENERIC_LIST
CreateGenericList(VOID);
VOID
DestroyGenericList(
IN OUT PGENERIC_LIST List,
IN BOOLEAN FreeUserData);
BOOLEAN
AppendGenericListEntry(
IN OUT PGENERIC_LIST List,
IN PCHAR Text,
IN PVOID UserData,
IN BOOLEAN Current);
VOID
SetCurrentListEntry(
IN PGENERIC_LIST List,
IN PGENERIC_LIST_ENTRY Entry);
PGENERIC_LIST_ENTRY
GetCurrentListEntry(
IN PGENERIC_LIST List);
PGENERIC_LIST_ENTRY
GetFirstListEntry(
IN PGENERIC_LIST List);
PGENERIC_LIST_ENTRY
GetNextListEntry(
IN PGENERIC_LIST_ENTRY Entry);
PVOID
GetListEntryUserData(
IN PGENERIC_LIST_ENTRY Entry);
LPCSTR
GetListEntryText(
IN PGENERIC_LIST_ENTRY Entry);
ULONG
GetNumberOfListEntries(
IN PGENERIC_LIST List);
VOID
SaveGenericListState(
IN PGENERIC_LIST List);
VOID
RestoreGenericListState(
IN PGENERIC_LIST List);
BOOLEAN
GenericListHasSingleEntry(
IN PGENERIC_LIST List);
#include "../lib/genlist.h"
typedef struct _GENERIC_LIST_UI
{

File diff suppressed because it is too large Load diff

View file

@ -25,15 +25,9 @@
#pragma once
typedef enum _FORMATSTATE
{
Unformatted,
UnformattedOrDamaged,
UnknownFormat,
Preformatted,
Formatted
} FORMATSTATE, *PFORMATSTATE;
#include "../lib/partlist.h"
#if 0
typedef enum _FORMATMACHINESTATE
{
Start,
@ -46,276 +40,7 @@ typedef enum _FORMATMACHINESTATE
CheckOtherPartition,
CheckDone
} FORMATMACHINESTATE, *PFORMATMACHINESTATE;
typedef struct _PARTENTRY
{
LIST_ENTRY ListEntry;
/* The disk this partition belongs to */
struct _DISKENTRY *DiskEntry;
/* Partition geometry */
ULARGE_INTEGER StartSector;
ULARGE_INTEGER SectorCount;
BOOLEAN BootIndicator;
UCHAR PartitionType;
ULONG HiddenSectors;
ULONG PartitionNumber; /* Enumerated partition number (primary partitions first -- excluding the extended partition container --, then the logical partitions) */
ULONG PartitionIndex; /* Index in the LayoutBuffer->PartitionEntry[] cached array of the corresponding DiskEntry */
CHAR DriveLetter;
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;
/* Partition must be checked */
BOOLEAN NeedsCheck;
FORMATSTATE FormatState;
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;
/* Disk geometry */
ULONGLONG Cylinders;
ULONG TracksPerCylinder;
ULONG SectorsPerTrack;
ULONG BytesPerSector;
ULARGE_INTEGER SectorCount;
ULONG SectorAlignment;
ULONG CylinderAlignment;
/* BIOS parameters */
BOOLEAN BiosFound;
ULONG BiosDiskNumber;
// ULONG Signature;
// ULONG Checksum;
/* SCSI parameters */
ULONG DiskNumber;
USHORT Port;
USHORT Bus;
USHORT Id;
/* Has the partition list been modified? */
BOOLEAN Dirty;
BOOLEAN NewDisk;
BOOLEAN NoMbr; /* MBR is absent */ // See r40437
UNICODE_STRING DriverName;
PDRIVE_LAYOUT_INFORMATION LayoutBuffer;
// TODO: When adding support for GPT disks:
// Use PDRIVE_LAYOUT_INFORMATION_EX which indicates whether
// the disk is MBR, GPT, or unknown (uninitialized).
// Depending on the style, either use the MBR or GPT partition info.
/* Pointer to the unique extended partition on this disk */
PPARTENTRY ExtendedPartition;
LIST_ENTRY PrimaryPartListHead;
LIST_ENTRY LogicalPartListHead;
} DISKENTRY, *PDISKENTRY;
typedef struct _PARTLIST
{
/*
* Disk & Partition iterators.
*
* NOTE that when CurrentPartition != NULL, then CurrentPartition->DiskEntry
* must be the same as CurrentDisk. We should however keep the two members
* separated as we can have a current (selected) disk without any current
* partition, if the former does not contain any.
*/
PDISKENTRY CurrentDisk;
PPARTENTRY CurrentPartition;
/*
* The system partition where the boot manager resides.
* The corresponding system disk is obtained via:
* SystemPartition->DiskEntry.
*/
PPARTENTRY SystemPartition;
/*
* The original system partition in case we are redefining it because
* we do not have write support on it.
* Please note that this is partly a HACK and MUST NEVER happen on
* architectures where real system partitions are mandatory (because then
* they are formatted in FAT FS and we support write operation on them).
* The corresponding original system disk is obtained via:
* OriginalSystemPartition->DiskEntry.
*/
PPARTENTRY OriginalSystemPartition;
PPARTENTRY TempPartition;
FORMATMACHINESTATE FormatState;
LIST_ENTRY DiskListHead;
LIST_ENTRY BiosDiskListHead;
} PARTLIST, *PPARTLIST;
#define PARTITION_TBL_SIZE 4
#include <pshpack1.h>
typedef struct _PARTITION
{
unsigned char BootFlags; /* bootable? 0=no, 128=yes */
unsigned char StartingHead; /* beginning head number */
unsigned char StartingSector; /* beginning sector number */
unsigned char StartingCylinder; /* 10 bit nmbr, with high 2 bits put in begsect */
unsigned char PartitionType; /* Operating System type indicator code */
unsigned char EndingHead; /* ending head number */
unsigned char EndingSector; /* ending sector number */
unsigned char EndingCylinder; /* also a 10 bit nmbr, with same high 2 bit trick */
unsigned int StartingBlock; /* first sector relative to start of disk */
unsigned int SectorCount; /* number of sectors in partition */
} PARTITION, *PPARTITION;
typedef struct _PARTITION_SECTOR
{
UCHAR BootCode[440]; /* 0x000 */
ULONG Signature; /* 0x1B8 */
UCHAR Reserved[2]; /* 0x1BC */
PARTITION Partition[PARTITION_TBL_SIZE]; /* 0x1BE */
USHORT Magic; /* 0x1FE */
} PARTITION_SECTOR, *PPARTITION_SECTOR;
#include <poppack.h>
typedef struct
{
LIST_ENTRY ListEntry;
ULONG DiskNumber;
ULONG Identifier;
ULONG Signature;
} BIOS_DISK, *PBIOS_DISK;
VOID
GetPartTypeStringFromPartitionType(
IN UCHAR partitionType,
OUT PCHAR strPartType,
IN ULONG cchPartType);
PPARTLIST
CreatePartitionList(VOID);
VOID
DestroyPartitionList(
IN PPARTLIST List);
ULONG
SelectPartition(
IN PPARTLIST List,
IN ULONG DiskNumber,
IN ULONG PartitionNumber);
PPARTENTRY
GetNextPartition(
IN PPARTLIST List);
PPARTENTRY
GetPrevPartition(
IN PPARTLIST List);
VOID
CreatePrimaryPartition(
IN PPARTLIST List,
IN ULONGLONG SectorCount,
IN BOOLEAN AutoCreate);
VOID
CreateExtendedPartition(
IN PPARTLIST List,
IN ULONGLONG SectorCount);
VOID
CreateLogicalPartition(
IN PPARTLIST List,
IN ULONGLONG SectorCount,
IN BOOLEAN AutoCreate);
VOID
DeleteCurrentPartition(
IN PPARTLIST List);
VOID
CheckActiveSystemPartition(
IN PPARTLIST List,
IN PFILE_SYSTEM_LIST FileSystemList);
BOOLEAN
WritePartitionsToDisk(
IN PPARTLIST List);
BOOLEAN
SetMountedDeviceValues(
IN PPARTLIST List);
VOID
SetPartitionType(
IN PPARTENTRY PartEntry,
IN UCHAR PartitionType);
ULONG
PrimaryPartitionCreationChecks(
IN PPARTLIST List);
ULONG
ExtendedPartitionCreationChecks(
IN PPARTLIST List);
ULONG
LogicalPartitionCreationChecks(
IN PPARTLIST List);
BOOLEAN
GetNextUnformattedPartition(
IN PPARTLIST List,
OUT PDISKENTRY *pDiskEntry OPTIONAL,
OUT PPARTENTRY *pPartEntry);
BOOLEAN
GetNextUncheckedPartition(
IN PPARTLIST List,
OUT PDISKENTRY *pDiskEntry OPTIONAL,
OUT PPARTENTRY *pPartEntry);
#endif
typedef struct _PARTLIST_UI
{
@ -335,6 +60,13 @@ typedef struct _PARTLIST_UI
// BOOL Redraw;
} PARTLIST_UI, *PPARTLIST_UI;
VOID
GetPartTypeStringFromPartitionType(
IN UCHAR partitionType,
OUT PCHAR strPartType,
IN ULONG cchPartType);
VOID
InitPartitionListUi(
IN OUT PPARTLIST_UI ListUi,

View file

@ -57,16 +57,6 @@
#define Architecture L"ppc"
#endif
#include <pshpack1.h>
typedef struct _REG_DISK_MOUNT_INFO
{
ULONG Signature;
LARGE_INTEGER StartingOffset;
} REG_DISK_MOUNT_INFO, *PREG_DISK_MOUNT_INFO;
#include <poppack.h>
/* FUNCTIONS ****************************************************************/
static
@ -667,67 +657,6 @@ SetInstallPathValue(
}
BOOLEAN
SetMountedDeviceValue(
CHAR Letter,
ULONG Signature,
LARGE_INTEGER StartingOffset)
{
OBJECT_ATTRIBUTES ObjectAttributes;
WCHAR ValueNameBuffer[16];
UNICODE_STRING KeyName = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\SYSTEM\\MountedDevices");
UNICODE_STRING ValueName;
REG_DISK_MOUNT_INFO MountInfo;
NTSTATUS Status;
HANDLE KeyHandle;
swprintf(ValueNameBuffer, L"\\DosDevices\\%C:", Letter);
RtlInitUnicodeString(&ValueName, ValueNameBuffer);
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
Status = NtOpenKey(&KeyHandle,
KEY_ALL_ACCESS,
&ObjectAttributes);
if (!NT_SUCCESS(Status))
{
Status = NtCreateKey(&KeyHandle,
KEY_ALL_ACCESS,
&ObjectAttributes,
0,
NULL,
REG_OPTION_NON_VOLATILE,
NULL);
}
if (!NT_SUCCESS(Status))
{
DPRINT1("NtCreateKey() failed (Status %lx)\n", Status);
return FALSE;
}
MountInfo.Signature = Signature;
MountInfo.StartingOffset = StartingOffset;
Status = NtSetValueKey(KeyHandle,
&ValueName,
0,
REG_BINARY,
(PVOID)&MountInfo,
sizeof(MountInfo));
NtClose(KeyHandle);
if (!NT_SUCCESS(Status))
{
DPRINT1("NtSetValueKey() failed (Status %lx)\n", Status);
return FALSE;
}
return TRUE;
}
VOID
SetDefaultPagefile(
WCHAR Drive)

View file

@ -37,12 +37,6 @@ BOOLEAN
SetInstallPathValue(
PUNICODE_STRING InstallPath);
BOOLEAN
SetMountedDeviceValue(
CHAR Letter,
ULONG Signature,
LARGE_INTEGER StartingOffset);
VOID
SetDefaultPagefile(
WCHAR Drive);

View file

@ -2631,6 +2631,7 @@ SelectFileSystemPage(PINPUT_RECORD Ir)
return QUIT_PAGE;
}
#if 0
/*** HACK! ***/
if (FileSystemList == NULL)
{
@ -2643,9 +2644,10 @@ SelectFileSystemPage(PINPUT_RECORD Ir)
/* FIXME: Add file systems to list */
}
#endif
/* Find or set the active system partition */
CheckActiveSystemPartition(PartitionList, FileSystemList);
CheckActiveSystemPartition(PartitionList /*, FileSystemList*/);
if (PartitionList->SystemPartition == NULL)
{
/* FIXME: show an error dialog */
@ -2842,6 +2844,7 @@ SelectFileSystemPage(PINPUT_RECORD Ir)
if (FileSystemList == NULL)
{
/* Create the file system list, and by default select the "FAT" file system */
FileSystemList = CreateFileSystemList(6, 26, PartEntry->New, L"FAT");
if (FileSystemList == NULL)
{
@ -2864,7 +2867,14 @@ SelectFileSystemPage(PINPUT_RECORD Ir)
{
if (UnattendFormatPartition)
{
PartEntry->FileSystem = GetFileSystemByName(FileSystemList, L"FAT");
/*
* We use whatever currently selected file system we have
* (by default, this is "FAT", as per the initialization
* performed above). Note that it may be interesting to specify
* which file system to use in unattended installations, in the
* txtsetup.sif file.
*/
// PartEntry->FileSystem = GetFileSystemByName(FileSystemList, L"FAT");
return FORMAT_PARTITION_PAGE;
}
@ -2901,13 +2911,13 @@ SelectFileSystemPage(PINPUT_RECORD Ir)
}
else if (Ir->Event.KeyEvent.wVirtualKeyCode == VK_RETURN) /* ENTER */
{
if (!FileSystemList->Selected->FormatFunc)
if (!FileSystemList->Selected->FileSystem)
{
return SELECT_FILE_SYSTEM_PAGE;
}
else
{
PartEntry->FileSystem = FileSystemList->Selected;
// PartEntry->FileSystem = FileSystemList->Selected;
return FORMAT_PARTITION_PAGE;
}
}
@ -2941,6 +2951,7 @@ FormatPartitionPage(PINPUT_RECORD Ir)
WCHAR PathBuffer[MAX_PATH];
PDISKENTRY DiskEntry;
PPARTENTRY PartEntry;
PFILE_SYSTEM_ITEM SelectedFileSystem;
NTSTATUS Status;
#ifndef NDEBUG
@ -2963,6 +2974,8 @@ FormatPartitionPage(PINPUT_RECORD Ir)
PartEntry = PartitionList->TempPartition;
DiskEntry = PartEntry->DiskEntry;
SelectedFileSystem = FileSystemList->Selected; // PartEntry->FileSystem; // FIXME!!!!
while (TRUE)
{
if (!IsUnattendedSetup)
@ -2982,7 +2995,7 @@ FormatPartitionPage(PINPUT_RECORD Ir)
{
CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT));
if (wcscmp(PartEntry->FileSystem->FileSystemName, L"FAT") == 0)
if (wcscmp(SelectedFileSystem->FileSystemName, L"FAT") == 0)
{
if (PartEntry->SectorCount.QuadPart < 8192)
{
@ -3026,16 +3039,16 @@ FormatPartitionPage(PINPUT_RECORD Ir)
}
}
#if 0
else if (wcscmp(PartEntry->FileSystem->FileSystemName, L"EXT2") == 0)
else if (wcscmp(SelectedFileSystem->FileSystemName, L"EXT2") == 0)
{
SetPartitionType(PartEntry, PARTITION_EXT2);
}
else if (wcscmp(PartEntry->FileSystem->FileSystemName, L"NTFS") == 0)
else if (wcscmp(SelectedFileSystem->FileSystemName, L"NTFS") == 0)
{
SetPartitionType(PartEntry, PARTITION_IFS);
}
#endif
else if (!PartEntry->FileSystem->FormatFunc)
else if (!SelectedFileSystem->FileSystem)
{
/* FIXME: show an error dialog */
return QUIT_PAGE;
@ -3084,10 +3097,10 @@ FormatPartitionPage(PINPUT_RECORD Ir)
PathBuffer);
DPRINT("PartitionRootPath: %wZ\n", &PartitionRootPath);
if (PartEntry->FileSystem->FormatFunc)
if (SelectedFileSystem->FileSystem)
{
Status = FormatPartition(&PartitionRootPath,
PartEntry->FileSystem);
SelectedFileSystem);
if (!NT_SUCCESS(Status))
{
DPRINT1("FormatPartition() failed with status 0x%08lx\n", Status);
@ -3127,7 +3140,7 @@ FormatPartitionPage(PINPUT_RECORD Ir)
static PAGE_NUMBER
CheckFileSystemPage(PINPUT_RECORD Ir)
{
PFILE_SYSTEM_ITEM CurrentFileSystem;
PFILE_SYSTEM CurrentFileSystem;
UNICODE_STRING PartitionRootPath;
WCHAR PathBuffer[MAX_PATH];
CHAR Buffer[MAX_PATH];
@ -3158,7 +3171,7 @@ CheckFileSystemPage(PINPUT_RECORD Ir)
CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT));
CurrentFileSystem = GetFileSystem(FileSystemList, PartEntry);
CurrentFileSystem = PartEntry->FileSystem;
DPRINT1("CheckFileSystemPage -- PartitionType: 0x%02X ; FileSystemName: %S\n",
PartEntry->PartitionType, (CurrentFileSystem ? CurrentFileSystem->FileSystemName : L"n/a"));

View file

@ -52,11 +52,10 @@
#include <ntstrsafe.h>
/* Filesystem headers */
/* Setup library headers */
#include <reactos/rosioctl.h>
#include <fslib/vfatlib.h>
#include <fslib/ext2lib.h>
// #include <fslib/ntfslib.h>
#include <../lib/setuplib.h>
// #include "errorcode.h"
/* Internal Headers */
#include "consup.h"
@ -72,7 +71,6 @@
#include "filesup.h"
#include "genlist.h"
#include "mui.h"
#include "errorcode.h"
extern HANDLE ProcessHeap;
extern UNICODE_STRING SourceRootPath;
@ -159,22 +157,4 @@ typedef enum _PAGE_NUMBER
#define POPUP_WAIT_ANY_KEY 1
#define POPUP_WAIT_ENTER 2
#define InsertAscendingList(ListHead, NewEntry, Type, ListEntryField, SortField)\
{\
PLIST_ENTRY current;\
\
current = (ListHead)->Flink;\
while (current != (ListHead))\
{\
if (CONTAINING_RECORD(current, Type, ListEntryField)->SortField >=\
(NewEntry)->SortField)\
{\
break;\
}\
current = current->Flink;\
}\
\
InsertTailList(current, &((NewEntry)->ListEntryField));\
}
#endif /* _USETUP_PCH_ */