Author: hbelusca Date: Tue May 23 22:40:34 2017 New Revision: 74640
URL: http://svn.reactos.org/svn/reactos?rev=74640&view=rev Log: [USETUP]: Use the newly-introduced CombinePaths and ConcatPaths functions. Fix also few comments, and place some UNICODE_NULLs here & there.
Modified: branches/setup_improvements/base/setup/lib/arcname.c branches/setup_improvements/base/setup/usetup/bootsup.c branches/setup_improvements/base/setup/usetup/filequeue.c branches/setup_improvements/base/setup/usetup/interface/devinst.c branches/setup_improvements/base/setup/usetup/interface/usetup.c branches/setup_improvements/base/setup/usetup/registry.c
Modified: branches/setup_improvements/base/setup/lib/arcname.c URL: http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/li... ============================================================================== --- branches/setup_improvements/base/setup/lib/arcname.c [iso-8859-1] (original) +++ branches/setup_improvements/base/setup/lib/arcname.c [iso-8859-1] Tue May 23 22:40:34 2017 @@ -787,7 +787,7 @@ if (BeginOfPath && *BeginOfPath) { HRESULT hr; - hr = ConcatPaths(NtPath->Buffer, NtPath->MaximumLength / sizeof(WCHAR), BeginOfPath); + hr = ConcatPaths(NtPath->Buffer, NtPath->MaximumLength / sizeof(WCHAR), 1, BeginOfPath); if (FAILED(hr)) { /* Buffer not large enough, or whatever...: just bail out */
Modified: branches/setup_improvements/base/setup/usetup/bootsup.c URL: http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/us... ============================================================================== --- branches/setup_improvements/base/setup/usetup/bootsup.c [iso-8859-1] (original) +++ branches/setup_improvements/base/setup/usetup/bootsup.c [iso-8859-1] Tue May 23 22:40:34 2017 @@ -1272,7 +1272,10 @@ 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 */); @@ -2262,10 +2265,8 @@ 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); @@ -2276,10 +2277,9 @@ }
/* Prepare for possibly copying 'freeldr.ini' */ - wcscpy(DstPath, SystemRootPath->Buffer); - wcscat(DstPath, L"\freeldr.ini"); - - DoesFreeLdrExist = DoesFileExist(SystemRootPath->Buffer, L"freeldr.ini"); + CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"\freeldr.ini"); + + DoesFreeLdrExist = DoesFileExist(NULL, NULL, DstPath); if (DoesFreeLdrExist) { /* Update existing 'freeldr.ini' */ @@ -2296,8 +2296,8 @@ /* Check for NT and other bootloaders */
// FIXME: Check for Vista+ bootloader! - if (DoesFileExist(SystemRootPath->Buffer, L"ntldr") == TRUE || - DoesFileExist(SystemRootPath->Buffer, L"boot.ini") == TRUE) + if (DoesFileExist(NULL, SystemRootPath->Buffer, L"ntldr") == TRUE || + DoesFileExist(NULL, SystemRootPath->Buffer, L"boot.ini") == TRUE) { /* Search root directory for 'ntldr' and 'boot.ini' */ DPRINT1("Found Microsoft Windows NT/2000/XP boot loader\n"); @@ -2307,8 +2307,7 @@ { /* 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)) @@ -2318,15 +2317,13 @@ }
/* 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, @@ -2340,8 +2337,7 @@ 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, @@ -2355,8 +2351,7 @@ }
/* 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, @@ -2379,8 +2374,8 @@ PWCHAR BootSector; PWCHAR BootSectorFileName;
- if (DoesFileExist(SystemRootPath->Buffer, L"io.sys") == TRUE || - DoesFileExist(SystemRootPath->Buffer, L"msdos.sys") == TRUE) + if (DoesFileExist(NULL, SystemRootPath->Buffer, L"io.sys") == TRUE || + DoesFileExist(NULL, SystemRootPath->Buffer, L"msdos.sys") == TRUE) { /* Search for root directory for 'io.sys' and 'msdos.sys' */ DPRINT1("Found Microsoft DOS or Windows 9x boot loader\n"); @@ -2394,7 +2389,7 @@ BootSectorFileName = L"\bootsect.dos"; } else - if (DoesFileExist(SystemRootPath->Buffer, L"kernel.sys") == TRUE) + if (DoesFileExist(NULL, SystemRootPath->Buffer, L"kernel.sys") == TRUE) { /* Search for root directory for 'kernel.sys' */ DPRINT1("Found FreeDOS boot loader\n"); @@ -2426,8 +2421,7 @@ { /* 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)) { @@ -2442,8 +2436,7 @@ }
/* 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); @@ -2468,8 +2461,7 @@ 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); @@ -2482,8 +2474,7 @@ 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); @@ -2520,10 +2511,8 @@ 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); @@ -2534,10 +2523,9 @@ }
/* Prepare for possibly copying 'freeldr.ini' */ - wcscpy(DstPath, SystemRootPath->Buffer); - wcscat(DstPath, L"\freeldr.ini"); - - DoesFreeLdrExist = DoesFileExist(SystemRootPath->Buffer, L"freeldr.ini"); + CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"\freeldr.ini"); + + DoesFreeLdrExist = DoesFileExist(NULL, NULL, DstPath); if (DoesFreeLdrExist) { /* Update existing 'freeldr.ini' */ @@ -2558,8 +2546,7 @@ { /* 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"); @@ -2577,8 +2564,7 @@ }
/* 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)); @@ -2602,8 +2588,7 @@ // 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); @@ -2696,10 +2681,9 @@ }
/* Copy FreeLoader to the boot partition */ - wcscpy(SrcPath, SourceRootPath->Buffer); - wcscat(SrcPath, L"\loader\freeldr.sys"); - - wcscpy(DstPath, L"\Device\Floppy0\freeldr.sys"); + CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\loader\freeldr.sys"); + + StringCchCopyW(DstPath, ARRAYSIZE(DstPath), L"\Device\Floppy0\freeldr.sys");
DPRINT("Copy: %S ==> %S\n", SrcPath, DstPath); Status = SetupCopyFile(SrcPath, DstPath); @@ -2710,7 +2694,7 @@ }
/* Create new 'freeldr.ini' */ - wcscpy(DstPath, L"\Device\Floppy0\freeldr.ini"); + StringCchCopyW(DstPath, ARRAYSIZE(DstPath), L"\Device\Floppy0\freeldr.ini");
DPRINT("Create new 'freeldr.ini'\n"); Status = CreateFreeLoaderIniForReactOS(DstPath, DestinationArcPath->Buffer); @@ -2721,10 +2705,9 @@ }
/* Install FAT12/16 boosector */ - wcscpy(SrcPath, SourceRootPath->Buffer); - wcscat(SrcPath, L"\loader\fat.bin"); - - wcscpy(DstPath, L"\Device\Floppy0"); + CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\loader\fat.bin"); + + StringCchCopyW(DstPath, ARRAYSIZE(DstPath), L"\Device\Floppy0");
DPRINT("Install FAT bootcode: %S ==> %S\n", SrcPath, DstPath); Status = InstallFat12BootCodeToFloppy(SrcPath, DstPath);
Modified: branches/setup_improvements/base/setup/usetup/filequeue.c URL: http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/us... ============================================================================== --- branches/setup_improvements/base/setup/usetup/filequeue.c [iso-8859-1] (original) +++ branches/setup_improvements/base/setup/usetup/filequeue.c [iso-8859-1] Tue May 23 22:40:34 2017 @@ -369,46 +369,32 @@ 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); }
/* @@ -417,11 +403,10 @@ */ 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! */ @@ -435,11 +420,9 @@ 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
Modified: branches/setup_improvements/base/setup/usetup/interface/devinst.c URL: http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/us... ============================================================================== --- branches/setup_improvements/base/setup/usetup/interface/devinst.c [iso-8859-1] (original) +++ branches/setup_improvements/base/setup/usetup/interface/devinst.c [iso-8859-1] Tue May 23 22:40:34 2017 @@ -50,13 +50,13 @@ OBJECT_ATTRIBUTES ObjectAttributes; HANDLE hService; INFCONTEXT Context; - LPWSTR Driver, ImagePath, FullImagePath; + PWSTR Driver, 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"; BOOLEAN keyboardDevice = FALSE;
/* Check if we know the hardware */ @@ -70,7 +70,7 @@ if (!SetupFindFirstLineW(hInf, L"BootBusExtenders.Load", Driver, &Context) && !SetupFindFirstLineW(hInf, L"BusExtenders.Load", Driver, &Context) && !SetupFindFirstLineW(hInf, L"SCSI.Load", Driver, &Context) - && !SetupFindFirstLineW(hInf, L"InputDevicesSupport.Load", Driver, &Context)) + && !SetupFindFirstLineW(hInf, L"InputDevicesSupport.Load", Driver, &Context)) { if (!SetupFindFirstLineW(hInf, L"Keyboard.Load", Driver, &Context)) return FALSE; @@ -83,14 +83,14 @@
/* 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);
Modified: branches/setup_improvements/base/setup/usetup/interface/usetup.c URL: http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/us... ============================================================================== --- branches/setup_improvements/base/setup/usetup/interface/usetup.c [iso-8859-1] (original) +++ branches/setup_improvements/base/setup/usetup/interface/usetup.c [iso-8859-1] Tue May 23 22:40:34 2017 @@ -430,14 +430,13 @@ INT IntValue; PWCHAR Value;
- if (DoesFileExist(SourcePath.Buffer, L"unattend.inf") == FALSE) - { - DPRINT("Does not exist: %S\%S\n", SourcePath.Buffer, L"unattend.inf"); + CombinePaths(UnattendInfPath, ARRAYSIZE(UnattendInfPath), 2, SourcePath.Buffer, L"\unattend.inf"); + + if (DoesFileExist(NULL, NULL, UnattendInfPath) == FALSE) + { + 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, @@ -530,7 +529,7 @@ return; }
- UnattendDestinationPartitionNumber = IntValue; + UnattendDestinationPartitionNumber = (LONG)IntValue;
/* Search for 'InstallationDirectory' in the 'Unattend' section */ if (!SetupFindFirstLineW(UnattendInf, L"Unattend", L"InstallationDirectory", &Context)) @@ -827,9 +826,7 @@ #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, @@ -1499,8 +1496,8 @@
return HandleGenericList(&ListUi, DEVICE_SETTINGS_PAGE, Ir); } - - + + /* * Displays the DisplaySettingsPage. * @@ -1958,7 +1955,7 @@ if (Quit != NULL) *Quit = TRUE;
- PartitionSizeBuffer[0] = 0; + PartitionSizeBuffer[0] = UNICODE_NULL; break; } else if (Ir.Event.KeyEvent.wVirtualKeyCode == VK_RETURN) /* ENTER */ @@ -1970,14 +1967,14 @@ if (Cancel != NULL) *Cancel = TRUE;
- PartitionSizeBuffer[0] = 0; + PartitionSizeBuffer[0] = UNICODE_NULL; break; } else if ((Ir.Event.KeyEvent.wVirtualKeyCode == VK_BACK) && /* BACKSPACE */ (Index > 0)) { Index--; - PartitionSizeBuffer[Index] = 0; + PartitionSizeBuffer[Index] = UNICODE_NULL;
CONSOLE_SetInputTextXY(iLeft, iTop, @@ -1993,7 +1990,7 @@ { PartitionSizeBuffer[Index] = ch; Index++; - PartitionSizeBuffer[Index] = 0; + PartitionSizeBuffer[Index] = UNICODE_NULL;
CONSOLE_SetInputTextXY(iLeft, iTop, @@ -3296,12 +3293,8 @@
/* 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' */ @@ -3310,11 +3303,7 @@ 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);
return PREPARE_COPY_PAGE; @@ -3591,7 +3580,7 @@ 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); @@ -3604,16 +3593,15 @@ 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, @@ -3680,7 +3668,7 @@ Length = wcslen(PathBuffer); if ((Length > 0) && (PathBuffer[Length - 1] == L'\')) { - PathBuffer[Length - 1] = 0; + PathBuffer[Length - 1] = UNICODE_NULL; }
/* Create the install directory */ @@ -3716,7 +3704,7 @@ 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); @@ -3730,14 +3718,14 @@ /* 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); @@ -3755,15 +3743,14 @@ /* 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); @@ -3838,9 +3825,8 @@ 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);
#ifdef __REACTOS__ CabinetInitialize(); @@ -4424,7 +4410,7 @@ } else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */ { - if (DoesFileExist(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; @@ -4515,14 +4501,12 @@ 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));
Modified: branches/setup_improvements/base/setup/usetup/registry.c URL: http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/us... ============================================================================== --- branches/setup_improvements/base/setup/usetup/registry.c [iso-8859-1] (original) +++ branches/setup_improvements/base/setup/usetup/registry.c [iso-8859-1] Tue May 23 22:40:34 2017 @@ -627,9 +627,8 @@ 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,