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
*/
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 */
#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;
}
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,
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,
#endif
+NTSTATUS
+ConcatPathsV(
+ IN OUT PWSTR PathBuffer,
+ IN SIZE_T cchPathSize,
+ 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 PathElem1,
+ IN OUT PWSTR PathBuffer,
+ IN SIZE_T cchPathSize,
+ IN ULONG NumberOfPathComponents,
+ IN /* PCWSTR */ ...);
+
+NTSTATUS
+CombinePaths(
+ OUT PWSTR PathBuffer,
IN SIZE_T cchPathSize,
- IN PCWSTR PathElem2 OPTIONAL);
+ IN ULONG NumberOfPathComponents,
+ IN /* PCWSTR */ ...);
BOOLEAN
DoesPathExist(
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 */);
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);
}
/* 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' */
{
/* 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))
}
/* 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,
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,
}
/* 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,
{
/* 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))
{
}
/* 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);
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);
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);
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);
}
/* 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' */
{
/* 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");
}
/* 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));
// 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);
}
/* 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);
}
/* 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);
}
/* 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);
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))
/* 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);
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);
}
/*
*/
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! */
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
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,
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,
return;
}
- UnattendDestinationPartitionNumber = IntValue;
+ UnattendDestinationPartitionNumber = (LONG)IntValue;
/* Search for 'InstallationDirectory' in the 'Unattend' section */
if (!SetupFindFirstLineW(UnattendInf, L"Unattend", L"InstallationDirectory", &Context))
#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,
return HandleGenericList(&ListUi, DEVICE_SETTINGS_PAGE, Ir);
}
-
-
+
+
/*
* Displays the DisplaySettingsPage.
*
/* 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' */
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);
}
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);
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,
Length = wcslen(PathBuffer);
if ((Length > 0) && (PathBuffer[Length - 1] == L'\\'))
{
- PathBuffer[Length - 1] = 0;
+ PathBuffer[Length - 1] = UNICODE_NULL;
}
/* Create the install directory */
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);
/* 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);
/* 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);
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);
}
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;
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));