mirror of
https://github.com/reactos/reactos.git
synced 2025-08-10 00:03:03 +00:00
[SETUPLIB][USETUP] Bring some suggestions from PR #59 in.
- Use OBJ_CASE_INSENSITIVE when initializing object attributes (no actual reason why to keep case sensitivity there). - Check the success of a RtlStringCchPrintfW call in EnumerateReactOSEntries(). - Explicitly check for returned STATUS_NOT_SUPPORTED from ChkdskPartition() or FormatPartition(), and display an appropriate error message. - Remove some left-over comments but also explain why I kept some commented code (mainly for future reference).
This commit is contained in:
parent
a7a11dd60d
commit
765994c9e3
7 changed files with 99 additions and 54 deletions
|
@ -341,6 +341,7 @@ EnumerateReactOSEntries(
|
|||
IN PBOOT_STORE_ENTRY BootEntry,
|
||||
IN PVOID Parameter OPTIONAL)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
PENUM_REACTOS_ENTRIES_DATA Data = (PENUM_REACTOS_ENTRIES_DATA)Parameter;
|
||||
PNTOS_OPTIONS Options = (PNTOS_OPTIONS)&BootEntry->OsOptions;
|
||||
WCHAR SystemPath[MAX_PATH];
|
||||
|
@ -372,16 +373,19 @@ EnumerateReactOSEntries(
|
|||
goto SkipThisEntry;
|
||||
}
|
||||
|
||||
RtlStringCchPrintfW(SystemPath, ARRAYSIZE(SystemPath), L"\"%s\"", Data->ArcPath);
|
||||
if ((_wcsicmp(Options->OsLoadPath, Data->ArcPath) != 0) &&
|
||||
(_wcsicmp(Options->OsLoadPath, SystemPath) != 0))
|
||||
if (_wcsicmp(Options->OsLoadPath, Data->ArcPath) != 0)
|
||||
{
|
||||
/*
|
||||
* This entry is a ReactOS entry, but the SystemRoot
|
||||
* does not match the one we are looking for.
|
||||
*/
|
||||
/* Continue the enumeration */
|
||||
goto SkipThisEntry;
|
||||
/* Not found, retry with a quoted path */
|
||||
Status = RtlStringCchPrintfW(SystemPath, ARRAYSIZE(SystemPath), L"\"%s\"", Data->ArcPath);
|
||||
if (!NT_SUCCESS(Status) || _wcsicmp(Options->OsLoadPath, SystemPath) != 0)
|
||||
{
|
||||
/*
|
||||
* This entry is a ReactOS entry, but the SystemRoot
|
||||
* does not match the one we are looking for.
|
||||
*/
|
||||
/* Continue the enumeration */
|
||||
goto SkipThisEntry;
|
||||
}
|
||||
}
|
||||
|
||||
DPRINT1(" Found a candidate Win2k3 install '%S' with ARC path '%S'\n",
|
||||
|
@ -668,10 +672,9 @@ SaveBootSector(
|
|||
|
||||
/* Write bootsector to DstPath */
|
||||
RtlInitUnicodeString(&Name, DstPath);
|
||||
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&Name,
|
||||
0,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
|
@ -780,7 +783,6 @@ InstallMbrBootCodeToDiskHelper(
|
|||
|
||||
/* Read new bootsector from SrcPath */
|
||||
RtlInitUnicodeString(&Name, SrcPath);
|
||||
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&Name,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
|
@ -835,7 +837,7 @@ InstallMbrBootCodeToDiskHelper(
|
|||
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&Name,
|
||||
0,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
|
@ -882,6 +884,12 @@ InstallMbrBootCodeToDisk(
|
|||
WCHAR DstPath[MAX_PATH];
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* The DestinationDevicePathBuffer parameter has been built with
|
||||
* the following instruction by the caller; I'm not yet sure whether
|
||||
* I actually want this function to build the path instead, hence
|
||||
* I keep this code here but disabled for now...
|
||||
*/
|
||||
WCHAR DestinationDevicePathBuffer[MAX_PATH];
|
||||
RtlStringCchPrintfW(DestinationDevicePathBuffer, ARRAYSIZE(DestinationDevicePathBuffer),
|
||||
L"\\Device\\Harddisk%d\\Partition0",
|
||||
|
@ -1038,7 +1046,7 @@ InstallFat12BootCodeToFloppy(
|
|||
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&Name,
|
||||
0,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
|
@ -1127,6 +1135,7 @@ InstallFat16BootCode(
|
|||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
Status = NtOpenFile(&FileHandle,
|
||||
GENERIC_READ | SYNCHRONIZE,
|
||||
&ObjectAttributes,
|
||||
|
@ -1211,6 +1220,7 @@ InstallFat16BootCodeToFile(
|
|||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
Status = NtOpenFile(&PartitionHandle,
|
||||
GENERIC_READ | SYNCHRONIZE,
|
||||
&ObjectAttributes,
|
||||
|
@ -1224,9 +1234,10 @@ InstallFat16BootCodeToFile(
|
|||
RtlInitUnicodeString(&Name, DstPath);
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&Name,
|
||||
0, // OBJ_CASE_INSENSITIVE,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
Status = NtCreateFile(&FileHandle,
|
||||
GENERIC_WRITE | SYNCHRONIZE,
|
||||
&ObjectAttributes,
|
||||
|
@ -1280,6 +1291,7 @@ InstallFat16BootCodeToDisk(
|
|||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
Status = NtOpenFile(&PartitionHandle,
|
||||
GENERIC_READ | GENERIC_WRITE | SYNCHRONIZE,
|
||||
&ObjectAttributes,
|
||||
|
@ -1353,6 +1365,7 @@ InstallFat32BootCode(
|
|||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
Status = NtOpenFile(&FileHandle,
|
||||
GENERIC_READ | SYNCHRONIZE,
|
||||
&ObjectAttributes,
|
||||
|
@ -1503,6 +1516,7 @@ InstallFat32BootCodeToFile(
|
|||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
Status = NtOpenFile(&PartitionHandle,
|
||||
GENERIC_READ | SYNCHRONIZE,
|
||||
&ObjectAttributes,
|
||||
|
@ -1516,9 +1530,10 @@ InstallFat32BootCodeToFile(
|
|||
RtlInitUnicodeString(&Name, DstPath);
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&Name,
|
||||
0, // OBJ_CASE_INSENSITIVE,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
Status = NtCreateFile(&FileHandle,
|
||||
GENERIC_WRITE | SYNCHRONIZE,
|
||||
&ObjectAttributes,
|
||||
|
@ -1572,6 +1587,7 @@ InstallFat32BootCodeToDisk(
|
|||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
Status = NtOpenFile(&PartitionHandle,
|
||||
GENERIC_READ | GENERIC_WRITE | SYNCHRONIZE,
|
||||
&ObjectAttributes,
|
||||
|
@ -1721,7 +1737,7 @@ InstallBtrfsBootCodeToDisk(
|
|||
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&Name,
|
||||
0,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
|
|
|
@ -34,9 +34,11 @@
|
|||
|
||||
FILE_SYSTEM RegisteredFileSystems[] =
|
||||
{
|
||||
/* NOTE: The FAT formatter automatically determines
|
||||
* whether it will use FAT-16 or FAT-32. */
|
||||
{ L"FAT" , VfatFormat, VfatChkdsk },
|
||||
// { L"FAT32", VfatFormat, VfatChkdsk },
|
||||
#if 0
|
||||
{ L"FAT32", VfatFormat, VfatChkdsk }, // Do we support specific FAT sub-formats specifications?
|
||||
{ L"FATX" , VfatxFormat, VfatxChkdsk },
|
||||
{ L"NTFS" , NtfsFormat, NtfsChkdsk },
|
||||
|
||||
|
|
|
@ -212,8 +212,8 @@ InstallSetupInfFile(
|
|||
PINICACHE UnattendCache;
|
||||
PINICACHEITERATOR Iterator;
|
||||
#else
|
||||
// PCWSTR CrLf = L"\r\n";
|
||||
PCSTR CrLf = "\r\n";
|
||||
// WCHAR CrLf[] = {L'\r', L'\n'};
|
||||
CHAR CrLf[] = {'\r', '\n'};
|
||||
HANDLE FileHandle, UnattendFileHandle, SectionHandle;
|
||||
FILE_STANDARD_INFORMATION FileInfo;
|
||||
ULONG FileSize;
|
||||
|
@ -360,7 +360,7 @@ Quit:
|
|||
NULL,
|
||||
&IoStatusBlock,
|
||||
(PVOID)CrLf,
|
||||
2 * sizeof(CHAR), // 2 * sizeof(WCHAR),
|
||||
sizeof(CrLf),
|
||||
&FileInfo.EndOfFile,
|
||||
NULL);
|
||||
|
||||
|
|
|
@ -135,7 +135,6 @@ SetupCopyFile(
|
|||
LARGE_INTEGER ByteOffset;
|
||||
|
||||
RtlInitUnicodeString(&FileName, SourceFileName);
|
||||
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&FileName,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
|
@ -206,7 +205,6 @@ SetupCopyFile(
|
|||
}
|
||||
|
||||
RtlInitUnicodeString(&FileName, DestinationFileName);
|
||||
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&FileName,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
|
@ -594,7 +592,6 @@ DoesPathExist(
|
|||
IO_STATUS_BLOCK IoStatusBlock;
|
||||
|
||||
RtlInitUnicodeString(&Name, PathName);
|
||||
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&Name,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
|
@ -756,7 +753,6 @@ OpenAndMapFile(
|
|||
/* Open the file */
|
||||
|
||||
RtlInitUnicodeString(&FileName, PathNameToFile);
|
||||
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&FileName,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
|
|
|
@ -1249,7 +1249,7 @@ CreatePartitionList(VOID)
|
|||
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&Name,
|
||||
0,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
|
@ -2777,9 +2777,10 @@ WritePartitions(
|
|||
L"\\Device\\Harddisk%lu\\Partition0",
|
||||
DiskEntry->DiskNumber);
|
||||
RtlInitUnicodeString(&Name, DstPath);
|
||||
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&Name,
|
||||
0,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
|
@ -2882,6 +2883,7 @@ SetMountedDeviceValue(
|
|||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
Status = NtOpenKey(&KeyHandle,
|
||||
KEY_ALL_ACCESS,
|
||||
&ObjectAttributes);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue