mirror of
https://github.com/reactos/reactos.git
synced 2025-07-23 02:43:38 +00:00
[SETUPLIB][USETUP] Transform the existing ConcatPaths() function into a variadic function, and derive a CombinePaths() from it (plus their equivalent taking va_list).
This allows building concatenated paths with an arbitrary number of separated components. - Use the newly-introduced CombinePaths() and ConcatPaths() functions. - Fix also few comments, and place some UNICODE_NULLs here & there. svn path=/branches/setup_improvements/; revision=74637 svn path=/branches/setup_improvements/; revision=74640
This commit is contained in:
parent
92b99b865e
commit
d27ef70aab
8 changed files with 201 additions and 167 deletions
|
@ -798,7 +798,7 @@ ArcPathToNtPath(
|
|||
*/
|
||||
if (BeginOfPath && *BeginOfPath)
|
||||
{
|
||||
Status = ConcatPaths(NtPath->Buffer, NtPath->MaximumLength / sizeof(WCHAR), BeginOfPath);
|
||||
Status = ConcatPaths(NtPath->Buffer, NtPath->MaximumLength / sizeof(WCHAR), 1, BeginOfPath);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
/* Buffer not large enough, or whatever...: just bail out */
|
||||
|
|
|
@ -13,36 +13,113 @@
|
|||
#include <debug.h>
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
NTSTATUS
|
||||
ConcatPaths(
|
||||
IN OUT PWSTR PathElem1,
|
||||
ConcatPathsV(
|
||||
IN OUT PWSTR PathBuffer,
|
||||
IN SIZE_T cchPathSize,
|
||||
IN PCWSTR PathElem2 OPTIONAL)
|
||||
IN ULONG NumberOfPathComponents,
|
||||
IN va_list PathComponentsList)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
SIZE_T cchPathLen;
|
||||
PCWSTR PathComponent;
|
||||
|
||||
if (!PathElem2)
|
||||
return STATUS_SUCCESS;
|
||||
if (cchPathSize <= 1)
|
||||
if (cchPathSize < 1)
|
||||
return STATUS_SUCCESS;
|
||||
|
||||
cchPathLen = min(cchPathSize, wcslen(PathElem1));
|
||||
|
||||
if (PathElem2[0] != L'\\' && cchPathLen > 0 && PathElem1[cchPathLen-1] != L'\\')
|
||||
while (NumberOfPathComponents--)
|
||||
{
|
||||
/* PathElem2 does not start with '\' and PathElem1 does not end with '\' */
|
||||
Status = RtlStringCchCatW(PathElem1, cchPathSize, L"\\");
|
||||
PathComponent = va_arg(PathComponentsList, PCWSTR);
|
||||
if (!PathComponent)
|
||||
continue;
|
||||
|
||||
cchPathLen = min(cchPathSize, wcslen(PathBuffer));
|
||||
if (cchPathLen >= cchPathSize)
|
||||
return STATUS_BUFFER_OVERFLOW;
|
||||
|
||||
if (PathComponent[0] != OBJ_NAME_PATH_SEPARATOR &&
|
||||
cchPathLen > 0 && PathBuffer[cchPathLen-1] != OBJ_NAME_PATH_SEPARATOR)
|
||||
{
|
||||
/* PathComponent does not start with '\' and PathBuffer does not end with '\' */
|
||||
Status = RtlStringCchCatW(PathBuffer, cchPathSize, L"\\");
|
||||
if (!NT_SUCCESS(Status))
|
||||
return Status;
|
||||
}
|
||||
else if (PathComponent[0] == OBJ_NAME_PATH_SEPARATOR &&
|
||||
cchPathLen > 0 && PathBuffer[cchPathLen-1] == OBJ_NAME_PATH_SEPARATOR)
|
||||
{
|
||||
/* PathComponent starts with '\' and PathBuffer ends with '\' */
|
||||
while (*PathComponent == OBJ_NAME_PATH_SEPARATOR)
|
||||
++PathComponent; // Skip any backslash
|
||||
}
|
||||
Status = RtlStringCchCatW(PathBuffer, cchPathSize, PathComponent);
|
||||
if (!NT_SUCCESS(Status))
|
||||
return Status;
|
||||
}
|
||||
else if (PathElem2[0] == L'\\' && cchPathLen > 0 && PathElem1[cchPathLen-1] == L'\\')
|
||||
{
|
||||
/* PathElem2 starts with '\' and PathElem1 ends with '\' */
|
||||
while (*PathElem2 == L'\\')
|
||||
++PathElem2; // Skip any backslash
|
||||
}
|
||||
Status = RtlStringCchCatW(PathElem1, cchPathSize, PathElem2);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
CombinePathsV(
|
||||
OUT PWSTR PathBuffer,
|
||||
IN SIZE_T cchPathSize,
|
||||
IN ULONG NumberOfPathComponents,
|
||||
IN va_list PathComponentsList)
|
||||
{
|
||||
if (cchPathSize < 1)
|
||||
return STATUS_SUCCESS;
|
||||
|
||||
*PathBuffer = UNICODE_NULL;
|
||||
return ConcatPathsV(PathBuffer, cchPathSize,
|
||||
NumberOfPathComponents,
|
||||
PathComponentsList);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
ConcatPaths(
|
||||
IN OUT PWSTR PathBuffer,
|
||||
IN SIZE_T cchPathSize,
|
||||
IN ULONG NumberOfPathComponents,
|
||||
IN /* PCWSTR */ ...)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
va_list PathComponentsList;
|
||||
|
||||
if (cchPathSize < 1)
|
||||
return STATUS_SUCCESS;
|
||||
|
||||
va_start(PathComponentsList, NumberOfPathComponents);
|
||||
Status = ConcatPathsV(PathBuffer, cchPathSize,
|
||||
NumberOfPathComponents,
|
||||
PathComponentsList);
|
||||
va_end(PathComponentsList);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
CombinePaths(
|
||||
OUT PWSTR PathBuffer,
|
||||
IN SIZE_T cchPathSize,
|
||||
IN ULONG NumberOfPathComponents,
|
||||
IN /* PCWSTR */ ...)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
va_list PathComponentsList;
|
||||
|
||||
if (cchPathSize < 1)
|
||||
return STATUS_SUCCESS;
|
||||
|
||||
*PathBuffer = UNICODE_NULL;
|
||||
|
||||
va_start(PathComponentsList, NumberOfPathComponents);
|
||||
Status = CombinePathsV(PathBuffer, cchPathSize,
|
||||
NumberOfPathComponents,
|
||||
PathComponentsList);
|
||||
va_end(PathComponentsList);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -95,14 +172,7 @@ DoesFileExist(
|
|||
UNICODE_STRING Name;
|
||||
WCHAR FullName[MAX_PATH];
|
||||
|
||||
if (PathName)
|
||||
RtlStringCchCopyW(FullName, ARRAYSIZE(FullName), PathName);
|
||||
else
|
||||
FullName[0] = UNICODE_NULL;
|
||||
|
||||
if (FileName)
|
||||
ConcatPaths(FullName, ARRAYSIZE(FullName), FileName);
|
||||
|
||||
CombinePaths(FullName, ARRAYSIZE(FullName), 2, PathName, FileName);
|
||||
RtlInitUnicodeString(&Name, FullName);
|
||||
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
|
@ -243,14 +313,7 @@ OpenAndMapFile(
|
|||
UNICODE_STRING Name;
|
||||
WCHAR FullName[MAX_PATH];
|
||||
|
||||
if (PathName)
|
||||
RtlStringCchCopyW(FullName, ARRAYSIZE(FullName), PathName);
|
||||
else
|
||||
FullName[0] = UNICODE_NULL;
|
||||
|
||||
if (FileName)
|
||||
ConcatPaths(FullName, ARRAYSIZE(FullName), FileName);
|
||||
|
||||
CombinePaths(FullName, ARRAYSIZE(FullName), 2, PathName, FileName);
|
||||
RtlInitUnicodeString(&Name, FullName);
|
||||
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
|
|
|
@ -16,10 +16,32 @@ IsValidPath(
|
|||
#endif
|
||||
|
||||
NTSTATUS
|
||||
ConcatPaths(
|
||||
IN OUT PWSTR PathElem1,
|
||||
ConcatPathsV(
|
||||
IN OUT PWSTR PathBuffer,
|
||||
IN SIZE_T cchPathSize,
|
||||
IN PCWSTR PathElem2 OPTIONAL);
|
||||
IN ULONG NumberOfPathComponents,
|
||||
IN va_list PathComponentsList);
|
||||
|
||||
NTSTATUS
|
||||
CombinePathsV(
|
||||
OUT PWSTR PathBuffer,
|
||||
IN SIZE_T cchPathSize,
|
||||
IN ULONG NumberOfPathComponents,
|
||||
IN va_list PathComponentsList);
|
||||
|
||||
NTSTATUS
|
||||
ConcatPaths(
|
||||
IN OUT PWSTR PathBuffer,
|
||||
IN SIZE_T cchPathSize,
|
||||
IN ULONG NumberOfPathComponents,
|
||||
IN /* PCWSTR */ ...);
|
||||
|
||||
NTSTATUS
|
||||
CombinePaths(
|
||||
OUT PWSTR PathBuffer,
|
||||
IN SIZE_T cchPathSize,
|
||||
IN ULONG NumberOfPathComponents,
|
||||
IN /* PCWSTR */ ...);
|
||||
|
||||
BOOLEAN
|
||||
DoesPathExist(
|
||||
|
|
|
@ -1269,7 +1269,10 @@ InstallMbrBootCodeToDisk(
|
|||
return Status;
|
||||
}
|
||||
|
||||
/* Copy partition table from old MBR to new */
|
||||
/*
|
||||
* Copy the disk signature, the reserved fields and
|
||||
* the partition table from the old MBR to the new one.
|
||||
*/
|
||||
RtlCopyMemory(&NewBootSector->Signature,
|
||||
&OrigBootSector->Signature,
|
||||
sizeof(PARTITION_SECTOR) - offsetof(PARTITION_SECTOR, Signature) /* Length of partition table */);
|
||||
|
@ -2258,10 +2261,8 @@ InstallFatBootcodeToPartition(
|
|||
DPRINT("System path: '%wZ'\n", SystemRootPath);
|
||||
|
||||
/* Copy FreeLoader to the system partition */
|
||||
wcscpy(SrcPath, SourceRootPath->Buffer);
|
||||
wcscat(SrcPath, L"\\loader\\freeldr.sys");
|
||||
wcscpy(DstPath, SystemRootPath->Buffer);
|
||||
wcscat(DstPath, L"\\freeldr.sys");
|
||||
CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\freeldr.sys");
|
||||
CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"\\freeldr.sys");
|
||||
|
||||
DPRINT("Copy: %S ==> %S\n", SrcPath, DstPath);
|
||||
Status = SetupCopyFile(SrcPath, DstPath);
|
||||
|
@ -2272,10 +2273,9 @@ InstallFatBootcodeToPartition(
|
|||
}
|
||||
|
||||
/* Prepare for possibly copying 'freeldr.ini' */
|
||||
wcscpy(DstPath, SystemRootPath->Buffer);
|
||||
wcscat(DstPath, L"\\freeldr.ini");
|
||||
CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"\\freeldr.ini");
|
||||
|
||||
DoesFreeLdrExist = DoesFileExist(NULL, SystemRootPath->Buffer, L"freeldr.ini");
|
||||
DoesFreeLdrExist = DoesFileExist(NULL, NULL, DstPath);
|
||||
if (DoesFreeLdrExist)
|
||||
{
|
||||
/* Update existing 'freeldr.ini' */
|
||||
|
@ -2303,8 +2303,7 @@ InstallFatBootcodeToPartition(
|
|||
{
|
||||
/* Create new 'freeldr.ini' */
|
||||
DPRINT1("Create new 'freeldr.ini'\n");
|
||||
// wcscpy(DstPath, SystemRootPath->Buffer);
|
||||
// wcscat(DstPath, L"\\freeldr.ini");
|
||||
// CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"\\freeldr.ini");
|
||||
|
||||
Status = CreateFreeLoaderIniForReactOS(DstPath, DestinationArcPath->Buffer);
|
||||
if (!NT_SUCCESS(Status))
|
||||
|
@ -2314,15 +2313,13 @@ InstallFatBootcodeToPartition(
|
|||
}
|
||||
|
||||
/* Install new bootcode into a file */
|
||||
wcscpy(DstPath, SystemRootPath->Buffer);
|
||||
wcscat(DstPath, L"\\bootsect.ros");
|
||||
CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"\\bootsect.ros");
|
||||
|
||||
if (PartitionType == PARTITION_FAT32 ||
|
||||
PartitionType == PARTITION_FAT32_XINT13)
|
||||
{
|
||||
/* Install FAT32 bootcode */
|
||||
wcscpy(SrcPath, SourceRootPath->Buffer);
|
||||
wcscat(SrcPath, L"\\loader\\fat32.bin");
|
||||
CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\fat32.bin");
|
||||
|
||||
DPRINT1("Install FAT32 bootcode: %S ==> %S\n", SrcPath, DstPath);
|
||||
Status = InstallFat32BootCodeToFile(SrcPath, DstPath,
|
||||
|
@ -2336,8 +2333,7 @@ InstallFatBootcodeToPartition(
|
|||
else
|
||||
{
|
||||
/* Install FAT16 bootcode */
|
||||
wcscpy(SrcPath, SourceRootPath->Buffer);
|
||||
wcscat(SrcPath, L"\\loader\\fat.bin");
|
||||
CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\fat.bin");
|
||||
|
||||
DPRINT1("Install FAT bootcode: %S ==> %S\n", SrcPath, DstPath);
|
||||
Status = InstallFat16BootCodeToFile(SrcPath, DstPath,
|
||||
|
@ -2351,8 +2347,7 @@ InstallFatBootcodeToPartition(
|
|||
}
|
||||
|
||||
/* Update 'boot.ini' */
|
||||
wcscpy(DstPath, SystemRootPath->Buffer);
|
||||
wcscat(DstPath, L"\\boot.ini");
|
||||
CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"\\boot.ini");
|
||||
|
||||
DPRINT1("Update 'boot.ini': %S\n", DstPath);
|
||||
Status = UpdateBootIni(DstPath,
|
||||
|
@ -2422,8 +2417,7 @@ InstallFatBootcodeToPartition(
|
|||
{
|
||||
/* Create new 'freeldr.ini' */
|
||||
DPRINT1("Create new 'freeldr.ini'\n");
|
||||
// wcscpy(DstPath, SystemRootPath->Buffer);
|
||||
// wcscat(DstPath, L"\\freeldr.ini");
|
||||
// CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"\\freeldr.ini");
|
||||
|
||||
if (IsThereAValidBootSector(SystemRootPath->Buffer))
|
||||
{
|
||||
|
@ -2438,8 +2432,7 @@ InstallFatBootcodeToPartition(
|
|||
}
|
||||
|
||||
/* Save current bootsector */
|
||||
wcscpy(DstPath, SystemRootPath->Buffer);
|
||||
wcscat(DstPath, BootSectorFileName);
|
||||
CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, BootSectorFileName);
|
||||
|
||||
DPRINT1("Save bootsector: %S ==> %S\n", SystemRootPath->Buffer, DstPath);
|
||||
Status = SaveBootSector(SystemRootPath->Buffer, DstPath, SECTORSIZE);
|
||||
|
@ -2464,8 +2457,7 @@ InstallFatBootcodeToPartition(
|
|||
PartitionType == PARTITION_FAT32_XINT13)
|
||||
{
|
||||
/* Install FAT32 bootcode */
|
||||
wcscpy(SrcPath, SourceRootPath->Buffer);
|
||||
wcscat(SrcPath, L"\\loader\\fat32.bin");
|
||||
CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\fat32.bin");
|
||||
|
||||
DPRINT1("Install FAT32 bootcode: %S ==> %S\n", SrcPath, SystemRootPath->Buffer);
|
||||
Status = InstallFat32BootCodeToDisk(SrcPath, SystemRootPath->Buffer);
|
||||
|
@ -2478,8 +2470,7 @@ InstallFatBootcodeToPartition(
|
|||
else
|
||||
{
|
||||
/* Install FAT16 bootcode */
|
||||
wcscpy(SrcPath, SourceRootPath->Buffer);
|
||||
wcscat(SrcPath, L"\\loader\\fat.bin");
|
||||
CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\fat.bin");
|
||||
|
||||
DPRINT1("Install FAT16 bootcode: %S ==> %S\n", SrcPath, SystemRootPath->Buffer);
|
||||
Status = InstallFat16BootCodeToDisk(SrcPath, SystemRootPath->Buffer);
|
||||
|
@ -2512,10 +2503,8 @@ InstallExt2BootcodeToPartition(
|
|||
DPRINT("System path: '%wZ'\n", SystemRootPath);
|
||||
|
||||
/* Copy FreeLoader to the system partition */
|
||||
wcscpy(SrcPath, SourceRootPath->Buffer);
|
||||
wcscat(SrcPath, L"\\loader\\freeldr.sys");
|
||||
wcscpy(DstPath, SystemRootPath->Buffer);
|
||||
wcscat(DstPath, L"\\freeldr.sys");
|
||||
CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\freeldr.sys");
|
||||
CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"\\freeldr.sys");
|
||||
|
||||
DPRINT("Copy: %S ==> %S\n", SrcPath, DstPath);
|
||||
Status = SetupCopyFile(SrcPath, DstPath);
|
||||
|
@ -2526,10 +2515,9 @@ InstallExt2BootcodeToPartition(
|
|||
}
|
||||
|
||||
/* Prepare for possibly copying 'freeldr.ini' */
|
||||
wcscpy(DstPath, SystemRootPath->Buffer);
|
||||
wcscat(DstPath, L"\\freeldr.ini");
|
||||
CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"\\freeldr.ini");
|
||||
|
||||
DoesFreeLdrExist = DoesFileExist(NULL, SystemRootPath->Buffer, L"freeldr.ini");
|
||||
DoesFreeLdrExist = DoesFileExist(NULL, NULL, DstPath);
|
||||
if (DoesFreeLdrExist)
|
||||
{
|
||||
/* Update existing 'freeldr.ini' */
|
||||
|
@ -2550,8 +2538,7 @@ InstallExt2BootcodeToPartition(
|
|||
{
|
||||
/* Create new 'freeldr.ini' */
|
||||
DPRINT1("Create new 'freeldr.ini'\n");
|
||||
wcscpy(DstPath, SystemRootPath->Buffer);
|
||||
wcscat(DstPath, L"\\freeldr.ini");
|
||||
CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"\\freeldr.ini");
|
||||
|
||||
/* Certainly SysLinux, GRUB, LILO... or an unknown boot loader */
|
||||
DPRINT1("*nix or unknown boot loader found\n");
|
||||
|
@ -2569,8 +2556,7 @@ InstallExt2BootcodeToPartition(
|
|||
}
|
||||
|
||||
/* Save current bootsector */
|
||||
wcscpy(DstPath, SystemRootPath->Buffer);
|
||||
wcscat(DstPath, L"\\bootsect.old");
|
||||
CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"\\bootsect.old");
|
||||
|
||||
DPRINT1("Save bootsector: %S ==> %S\n", SystemRootPath->Buffer, DstPath);
|
||||
Status = SaveBootSector(SystemRootPath->Buffer, DstPath, sizeof(EXT2_BOOTSECTOR));
|
||||
|
@ -2594,8 +2580,7 @@ InstallExt2BootcodeToPartition(
|
|||
// if (PartitionType == PARTITION_EXT2)
|
||||
{
|
||||
/* Install EXT2 bootcode */
|
||||
wcscpy(SrcPath, SourceRootPath->Buffer);
|
||||
wcscat(SrcPath, L"\\loader\\ext2.bin");
|
||||
CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\ext2.bin");
|
||||
|
||||
DPRINT1("Install EXT2 bootcode: %S ==> %S\n", SrcPath, SystemRootPath->Buffer);
|
||||
Status = InstallExt2BootCodeToDisk(SrcPath, SystemRootPath->Buffer);
|
||||
|
@ -2684,10 +2669,9 @@ InstallFatBootcodeToFloppy(
|
|||
}
|
||||
|
||||
/* Copy FreeLoader to the boot partition */
|
||||
wcscpy(SrcPath, SourceRootPath->Buffer);
|
||||
wcscat(SrcPath, L"\\loader\\freeldr.sys");
|
||||
CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\freeldr.sys");
|
||||
|
||||
wcscpy(DstPath, L"\\Device\\Floppy0\\freeldr.sys");
|
||||
RtlStringCchCopyW(DstPath, ARRAYSIZE(DstPath), L"\\Device\\Floppy0\\freeldr.sys");
|
||||
|
||||
DPRINT("Copy: %S ==> %S\n", SrcPath, DstPath);
|
||||
Status = SetupCopyFile(SrcPath, DstPath);
|
||||
|
@ -2698,7 +2682,7 @@ InstallFatBootcodeToFloppy(
|
|||
}
|
||||
|
||||
/* Create new 'freeldr.ini' */
|
||||
wcscpy(DstPath, L"\\Device\\Floppy0\\freeldr.ini");
|
||||
RtlStringCchCopyW(DstPath, ARRAYSIZE(DstPath), L"\\Device\\Floppy0\\freeldr.ini");
|
||||
|
||||
DPRINT("Create new 'freeldr.ini'\n");
|
||||
Status = CreateFreeLoaderIniForReactOS(DstPath, DestinationArcPath->Buffer);
|
||||
|
@ -2709,10 +2693,9 @@ InstallFatBootcodeToFloppy(
|
|||
}
|
||||
|
||||
/* Install FAT12/16 boosector */
|
||||
wcscpy(SrcPath, SourceRootPath->Buffer);
|
||||
wcscat(SrcPath, L"\\loader\\fat.bin");
|
||||
CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\fat.bin");
|
||||
|
||||
wcscpy(DstPath, L"\\Device\\Floppy0");
|
||||
RtlStringCchCopyW(DstPath, ARRAYSIZE(DstPath), L"\\Device\\Floppy0");
|
||||
|
||||
DPRINT("Install FAT bootcode: %S ==> %S\n", SrcPath, DstPath);
|
||||
Status = InstallFat12BootCodeToFloppy(SrcPath, DstPath);
|
||||
|
|
|
@ -50,13 +50,13 @@ InstallDriver(
|
|||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
HANDLE hService;
|
||||
INFCONTEXT Context;
|
||||
LPWSTR Driver, ClassGuid, ImagePath, FullImagePath;
|
||||
PWSTR Driver, ClassGuid, ImagePath, FullImagePath;
|
||||
ULONG dwValue;
|
||||
ULONG Disposition;
|
||||
NTSTATUS Status;
|
||||
BOOLEAN deviceInstalled = FALSE;
|
||||
UNICODE_STRING UpperFiltersU = RTL_CONSTANT_STRING(L"UpperFilters");
|
||||
LPWSTR keyboardClass = L"kbdclass\0";
|
||||
PWSTR keyboardClass = L"kbdclass\0";
|
||||
|
||||
/* Check if we know the hardware */
|
||||
if (!SetupFindFirstLineW(hInf, L"HardwareIdsDatabase", HardwareId, &Context))
|
||||
|
@ -84,14 +84,14 @@ InstallDriver(
|
|||
|
||||
/* Prepare full driver path */
|
||||
dwValue = PathPrefix.MaximumLength + wcslen(ImagePath) * sizeof(WCHAR);
|
||||
FullImagePath = (LPWSTR)RtlAllocateHeap(ProcessHeap, 0, dwValue);
|
||||
FullImagePath = (PWSTR)RtlAllocateHeap(ProcessHeap, 0, dwValue);
|
||||
if (!FullImagePath)
|
||||
{
|
||||
DPRINT1("RtlAllocateHeap() failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
RtlCopyMemory(FullImagePath, PathPrefix.Buffer, PathPrefix.MaximumLength);
|
||||
wcscat(FullImagePath, ImagePath);
|
||||
ConcatPaths(FullImagePath, dwValue / sizeof(WCHAR), 1, ImagePath);
|
||||
|
||||
DPRINT1("Using driver '%S' for device '%S'\n", ImagePath, DeviceId);
|
||||
|
||||
|
|
|
@ -368,46 +368,32 @@ SetupCommitFileQueueW(
|
|||
while (Entry != NULL)
|
||||
{
|
||||
/* Build the full source path */
|
||||
wcscpy(FileSrcPath, Entry->SourceRootPath);
|
||||
if (Entry->SourcePath != NULL)
|
||||
wcscat(FileSrcPath, Entry->SourcePath);
|
||||
wcscat(FileSrcPath, L"\\");
|
||||
wcscat(FileSrcPath, Entry->SourceFilename);
|
||||
CombinePaths(FileSrcPath, ARRAYSIZE(FileSrcPath), 3,
|
||||
Entry->SourceRootPath, Entry->SourcePath,
|
||||
Entry->SourceFilename);
|
||||
|
||||
/* Build the full target path */
|
||||
wcscpy(FileDstPath, TargetRootPath);
|
||||
if (Entry->TargetDirectory[0] == 0)
|
||||
if (Entry->TargetDirectory[0] == UNICODE_NULL)
|
||||
{
|
||||
/* Installation path */
|
||||
|
||||
/* Add the installation path */
|
||||
if (TargetPath != NULL)
|
||||
{
|
||||
if (TargetPath[0] != L'\\')
|
||||
wcscat(FileDstPath, L"\\");
|
||||
wcscat(FileDstPath, TargetPath);
|
||||
}
|
||||
ConcatPaths(FileDstPath, ARRAYSIZE(FileDstPath), 1, TargetPath);
|
||||
}
|
||||
else if (Entry->TargetDirectory[0] == L'\\')
|
||||
{
|
||||
/* Absolute path */
|
||||
if (Entry->TargetDirectory[1] != 0)
|
||||
wcscat(FileDstPath, Entry->TargetDirectory);
|
||||
if (Entry->TargetDirectory[1] != UNICODE_NULL)
|
||||
ConcatPaths(FileDstPath, ARRAYSIZE(FileDstPath), 1, Entry->TargetDirectory);
|
||||
}
|
||||
else // if (Entry->TargetDirectory[0] != L'\\')
|
||||
{
|
||||
/* Path relative to the installation path */
|
||||
|
||||
/* Add the installation path */
|
||||
if (TargetPath != NULL)
|
||||
{
|
||||
if (TargetPath[0] != L'\\')
|
||||
wcscat(FileDstPath, L"\\");
|
||||
wcscat(FileDstPath, TargetPath);
|
||||
}
|
||||
|
||||
wcscat(FileDstPath, L"\\");
|
||||
wcscat(FileDstPath, Entry->TargetDirectory);
|
||||
ConcatPaths(FileDstPath, ARRAYSIZE(FileDstPath), 2,
|
||||
TargetPath, Entry->TargetDirectory);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -416,11 +402,10 @@ SetupCommitFileQueueW(
|
|||
*/
|
||||
if (Entry->SourceCabinet == NULL)
|
||||
{
|
||||
wcscat(FileDstPath, L"\\");
|
||||
if (Entry->TargetFilename != NULL)
|
||||
wcscat(FileDstPath, Entry->TargetFilename);
|
||||
ConcatPaths(FileDstPath, ARRAYSIZE(FileDstPath), 1, Entry->TargetFilename);
|
||||
else
|
||||
wcscat(FileDstPath, Entry->SourceFilename);
|
||||
ConcatPaths(FileDstPath, ARRAYSIZE(FileDstPath), 1, Entry->SourceFilename);
|
||||
}
|
||||
|
||||
/* FIXME: Do it! */
|
||||
|
@ -434,11 +419,9 @@ SetupCommitFileQueueW(
|
|||
if (Entry->SourceCabinet != NULL)
|
||||
{
|
||||
/* Extract the file */
|
||||
wcscpy(CabinetName, Entry->SourceRootPath);
|
||||
if (Entry->SourcePath != NULL)
|
||||
wcscat(CabinetName, Entry->SourcePath);
|
||||
wcscat(CabinetName, L"\\");
|
||||
wcscat(CabinetName, Entry->SourceCabinet);
|
||||
CombinePaths(CabinetName, ARRAYSIZE(CabinetName), 3,
|
||||
Entry->SourceRootPath, Entry->SourcePath,
|
||||
Entry->SourceCabinet);
|
||||
Status = SetupExtractFile(CabinetName, Entry->SourceFilename, FileDstPath);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -584,9 +584,8 @@ ImportRegistryFile(
|
|||
UINT ErrorLine;
|
||||
|
||||
/* Load inf file from install media. */
|
||||
wcscpy(FileNameBuffer, SourcePath.Buffer);
|
||||
wcscat(FileNameBuffer, L"\\");
|
||||
wcscat(FileNameBuffer, Filename);
|
||||
CombinePaths(FileNameBuffer, ARRAYSIZE(FileNameBuffer), 2,
|
||||
SourcePath.Buffer, Filename);
|
||||
|
||||
hInf = SetupOpenInfFileW(FileNameBuffer,
|
||||
NULL,
|
||||
|
|
|
@ -427,15 +427,14 @@ CheckUnattendedSetup(VOID)
|
|||
INT IntValue;
|
||||
PWCHAR Value;
|
||||
|
||||
if (DoesFileExist(NULL, SourcePath.Buffer, L"unattend.inf") == FALSE)
|
||||
CombinePaths(UnattendInfPath, ARRAYSIZE(UnattendInfPath), 2, SourcePath.Buffer, L"\\unattend.inf");
|
||||
|
||||
if (DoesFileExist(NULL, NULL, UnattendInfPath) == FALSE)
|
||||
{
|
||||
DPRINT("Does not exist: %S\\%S\n", SourcePath.Buffer, L"unattend.inf");
|
||||
DPRINT("Does not exist: %S\n", UnattendInfPath);
|
||||
return;
|
||||
}
|
||||
|
||||
wcscpy(UnattendInfPath, SourcePath.Buffer);
|
||||
wcscat(UnattendInfPath, L"\\unattend.inf");
|
||||
|
||||
/* Load 'unattend.inf' from install media. */
|
||||
UnattendInf = SetupOpenInfFileW(UnattendInfPath,
|
||||
NULL,
|
||||
|
@ -527,7 +526,7 @@ CheckUnattendedSetup(VOID)
|
|||
return;
|
||||
}
|
||||
|
||||
UnattendDestinationPartitionNumber = IntValue;
|
||||
UnattendDestinationPartitionNumber = (LONG)IntValue;
|
||||
|
||||
/* Search for 'InstallationDirectory' in the 'Unattend' section */
|
||||
if (!SetupFindFirstLineW(UnattendInf, L"Unattend", L"InstallationDirectory", &Context))
|
||||
|
@ -824,9 +823,7 @@ SetupStartPage(PINPUT_RECORD Ir)
|
|||
#endif
|
||||
|
||||
/* Load txtsetup.sif from install media. */
|
||||
wcscpy(FileNameBuffer, SourcePath.Buffer);
|
||||
wcscat(FileNameBuffer, L"\\txtsetup.sif");
|
||||
|
||||
CombinePaths(FileNameBuffer, ARRAYSIZE(FileNameBuffer), 2, SourcePath.Buffer, L"\\txtsetup.sif");
|
||||
SetupInf = SetupOpenInfFileW(FileNameBuffer,
|
||||
NULL,
|
||||
INF_STYLE_WIN4,
|
||||
|
@ -1379,8 +1376,8 @@ ComputerSettingsPage(PINPUT_RECORD Ir)
|
|||
|
||||
return HandleGenericList(&ListUi, DEVICE_SETTINGS_PAGE, Ir);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Displays the DisplaySettingsPage.
|
||||
*
|
||||
|
@ -3203,12 +3200,8 @@ BuildInstallPaths(PWCHAR InstallDir,
|
|||
|
||||
/* Create 'DestinationPath' string */
|
||||
RtlFreeUnicodeString(&DestinationPath);
|
||||
wcscpy(PathBuffer, DestinationRootPath.Buffer);
|
||||
|
||||
if (InstallDir[0] != L'\\')
|
||||
wcscat(PathBuffer, L"\\");
|
||||
|
||||
wcscat(PathBuffer, InstallDir);
|
||||
CombinePaths(PathBuffer, ARRAYSIZE(PathBuffer), 2,
|
||||
DestinationRootPath.Buffer, InstallDir);
|
||||
RtlCreateUnicodeString(&DestinationPath, PathBuffer);
|
||||
|
||||
/* Create 'DestinationArcPath' */
|
||||
|
@ -3217,11 +3210,7 @@ BuildInstallPaths(PWCHAR InstallDir,
|
|||
L"multi(0)disk(0)rdisk(%lu)partition(%lu)",
|
||||
DiskEntry->BiosDiskNumber,
|
||||
PartEntry->PartitionNumber);
|
||||
|
||||
if (InstallDir[0] != L'\\')
|
||||
wcscat(PathBuffer, L"\\");
|
||||
|
||||
wcscat(PathBuffer, InstallDir);
|
||||
ConcatPaths(PathBuffer, ARRAYSIZE(PathBuffer), 1, InstallDir);
|
||||
RtlCreateUnicodeString(&DestinationArcPath, PathBuffer);
|
||||
}
|
||||
|
||||
|
@ -3558,7 +3547,7 @@ AddSectionToCopyQueue(HINF InfFile,
|
|||
break;
|
||||
}
|
||||
|
||||
if ((DirKeyValue[0] == 0) || (DirKeyValue[0] == L'\\' && DirKeyValue[1] == 0))
|
||||
if ((DirKeyValue[0] == UNICODE_NULL) || (DirKeyValue[0] == L'\\' && DirKeyValue[1] == UNICODE_NULL))
|
||||
{
|
||||
/* Installation path */
|
||||
wcscpy(CompleteOrigDirName, SourceRootDir.Buffer);
|
||||
|
@ -3571,16 +3560,15 @@ AddSectionToCopyQueue(HINF InfFile,
|
|||
else // if (DirKeyValue[0] != L'\\')
|
||||
{
|
||||
/* Path relative to the installation path */
|
||||
wcscpy(CompleteOrigDirName, SourceRootDir.Buffer);
|
||||
wcscat(CompleteOrigDirName, L"\\");
|
||||
wcscat(CompleteOrigDirName, DirKeyValue);
|
||||
CombinePaths(CompleteOrigDirName, ARRAYSIZE(CompleteOrigDirName), 2,
|
||||
SourceRootDir.Buffer, DirKeyValue);
|
||||
}
|
||||
|
||||
/* Remove trailing backslash */
|
||||
Length = wcslen(CompleteOrigDirName);
|
||||
if ((Length > 0) && (CompleteOrigDirName[Length - 1] == L'\\'))
|
||||
{
|
||||
CompleteOrigDirName[Length - 1] = 0;
|
||||
CompleteOrigDirName[Length - 1] = UNICODE_NULL;
|
||||
}
|
||||
|
||||
if (!SetupQueueCopy(SetupFileQueue,
|
||||
|
@ -3647,7 +3635,7 @@ PrepareCopyPageInfFile(HINF InfFile,
|
|||
Length = wcslen(PathBuffer);
|
||||
if ((Length > 0) && (PathBuffer[Length - 1] == L'\\'))
|
||||
{
|
||||
PathBuffer[Length - 1] = 0;
|
||||
PathBuffer[Length - 1] = UNICODE_NULL;
|
||||
}
|
||||
|
||||
/* Create the install directory */
|
||||
|
@ -3683,7 +3671,7 @@ PrepareCopyPageInfFile(HINF InfFile,
|
|||
break;
|
||||
}
|
||||
|
||||
if ((DirKeyValue[0] == 0) || (DirKeyValue[0] == L'\\' && DirKeyValue[1] == 0))
|
||||
if ((DirKeyValue[0] == UNICODE_NULL) || (DirKeyValue[0] == L'\\' && DirKeyValue[1] == UNICODE_NULL))
|
||||
{
|
||||
/* Installation path */
|
||||
DPRINT("InstallationPath: '%S'\n", DirKeyValue);
|
||||
|
@ -3697,14 +3685,14 @@ PrepareCopyPageInfFile(HINF InfFile,
|
|||
/* Absolute path */
|
||||
DPRINT("Absolute Path: '%S'\n", DirKeyValue);
|
||||
|
||||
wcscpy(PathBuffer, DestinationRootPath.Buffer);
|
||||
wcscat(PathBuffer, DirKeyValue);
|
||||
CombinePaths(PathBuffer, ARRAYSIZE(PathBuffer), 2,
|
||||
DestinationRootPath.Buffer, DirKeyValue);
|
||||
|
||||
/* Remove trailing backslash */
|
||||
Length = wcslen(PathBuffer);
|
||||
if ((Length > 0) && (PathBuffer[Length - 1] == L'\\'))
|
||||
{
|
||||
PathBuffer[Length - 1] = 0;
|
||||
PathBuffer[Length - 1] = UNICODE_NULL;
|
||||
}
|
||||
|
||||
DPRINT("FullPath: '%S'\n", PathBuffer);
|
||||
|
@ -3722,15 +3710,14 @@ PrepareCopyPageInfFile(HINF InfFile,
|
|||
/* Path relative to the installation path */
|
||||
DPRINT("RelativePath: '%S'\n", DirKeyValue);
|
||||
|
||||
wcscpy(PathBuffer, DestinationPath.Buffer);
|
||||
wcscat(PathBuffer, L"\\");
|
||||
wcscat(PathBuffer, DirKeyValue);
|
||||
CombinePaths(PathBuffer, ARRAYSIZE(PathBuffer), 2,
|
||||
DestinationPath.Buffer, DirKeyValue);
|
||||
|
||||
/* Remove trailing backslash */
|
||||
Length = wcslen(PathBuffer);
|
||||
if ((Length > 0) && (PathBuffer[Length - 1] == L'\\'))
|
||||
{
|
||||
PathBuffer[Length - 1] = 0;
|
||||
PathBuffer[Length - 1] = UNICODE_NULL;
|
||||
}
|
||||
|
||||
DPRINT("FullPath: '%S'\n", PathBuffer);
|
||||
|
@ -3805,9 +3792,8 @@ PrepareCopyPage(PINPUT_RECORD Ir)
|
|||
if (!INF_GetData(&CabinetsContext, NULL, &KeyValue))
|
||||
break;
|
||||
|
||||
wcscpy(PathBuffer, SourcePath.Buffer);
|
||||
wcscat(PathBuffer, L"\\");
|
||||
wcscat(PathBuffer, KeyValue);
|
||||
CombinePaths(PathBuffer, ARRAYSIZE(PathBuffer), 2,
|
||||
SourcePath.Buffer, KeyValue);
|
||||
|
||||
CabinetInitialize();
|
||||
CabinetSetEventHandlers(NULL, NULL, NULL);
|
||||
|
@ -4387,7 +4373,7 @@ BootLoaderFloppyPage(PINPUT_RECORD Ir)
|
|||
}
|
||||
else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
|
||||
{
|
||||
if (DoesFileExist(NULL, L"\\Device\\Floppy0", L"\\") == FALSE)
|
||||
if (DoesPathExist(NULL, L"\\Device\\Floppy0\\") == FALSE)
|
||||
{
|
||||
MUIDisplayError(ERROR_NO_FLOPPY, Ir, POPUP_WAIT_ENTER);
|
||||
return BOOT_LOADER_FLOPPY_PAGE;
|
||||
|
@ -4484,14 +4470,12 @@ BootLoaderHarddiskMbrPage(PINPUT_RECORD Ir)
|
|||
L"\\Device\\Harddisk%d\\Partition0",
|
||||
PartitionList->SystemPartition->DiskEntry->DiskNumber);
|
||||
|
||||
wcscpy(SourceMbrPathBuffer, SourceRootPath.Buffer);
|
||||
wcscat(SourceMbrPathBuffer, L"\\loader\\dosmbr.bin");
|
||||
CombinePaths(SourceMbrPathBuffer, ARRAYSIZE(SourceMbrPathBuffer), 2, SourceRootPath.Buffer, L"\\loader\\dosmbr.bin");
|
||||
|
||||
if (IsThereAValidBootSector(DestinationDevicePathBuffer))
|
||||
{
|
||||
/* Save current MBR */
|
||||
wcscpy(DstPath, SystemRootPath.Buffer);
|
||||
wcscat(DstPath, L"\\mbr.old");
|
||||
CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath.Buffer, L"\\mbr.old");
|
||||
|
||||
DPRINT1("Save MBR: %S ==> %S\n", DestinationDevicePathBuffer, DstPath);
|
||||
Status = SaveBootSector(DestinationDevicePathBuffer, DstPath, sizeof(PARTITION_SECTOR));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue