Chromium Code Reviews| Index: chrome/installer/mini_installer/mini_installer.cc |
| diff --git a/chrome/installer/mini_installer/mini_installer.cc b/chrome/installer/mini_installer/mini_installer.cc |
| index 871ab23db434879325dabc0a177843a4986dde1c..66e38ff057efa0fd1fc7b6a3373d0891a04749eb 100644 |
| --- a/chrome/installer/mini_installer/mini_installer.cc |
| +++ b/chrome/installer/mini_installer/mini_installer.cc |
| @@ -59,6 +59,9 @@ struct Context { |
| PathString* chrome_resource_path; |
| // Second output from call back method. Full path of Setup archive/exe. |
| PathString* setup_resource_path; |
| +#if defined(SYZYASAN) |
| + PathString* syzyasan_resource_path; |
| +#endif |
| }; |
| // TODO(grt): Frame this in terms of whether or not the brand supports |
| @@ -291,6 +294,11 @@ BOOL CALLBACK OnResourceFound(HMODULE module, const wchar_t* type, |
| } else if (StrStartsWith(name, kSetupPrefix)) { |
| if (!ctx->setup_resource_path->assign(full_path.get())) |
| return FALSE; |
| +#if defined(SYZYASAN) |
| + } else if (StrStartsWith(name, kSyzyAsanRuntimePrefix)) { |
| + if (!ctx->syzyasan_resource_path->assign(full_path.get())) |
| + return FALSE; |
| +#endif |
| } else { |
| // Resources should either start with 'chrome' or 'setup'. We don't handle |
| // anything else. |
| @@ -300,7 +308,7 @@ BOOL CALLBACK OnResourceFound(HMODULE module, const wchar_t* type, |
| return TRUE; |
| } |
| -#if defined(COMPONENT_BUILD) |
| +#if defined(COMPONENT_BUILD) || defined(SYZYASAN) |
| // An EnumResNameProc callback that writes the resource |name| to disk in the |
| // directory |base_path_ptr| (which must end with a path separator). |
| BOOL CALLBACK WriteResourceToDirectory(HMODULE module, |
| @@ -331,32 +339,23 @@ BOOL CALLBACK WriteResourceToDirectory(HMODULE module, |
| // uncompressed 'BN' resources are also extracted. This is generally the set of |
| // DLLs/resources needed by setup.exe to run. |
| ProcessExitResult UnpackBinaryResources(const Configuration& configuration, |
| - HMODULE module, const wchar_t* base_path, |
| - PathString* archive_path, |
| - PathString* setup_path) { |
| + HMODULE module, |
| + Context* context) { |
| // Generate the setup.exe path where we patch/uncompress setup resource. |
| PathString setup_dest_path; |
| - if (!setup_dest_path.assign(base_path) || |
| + if (!setup_dest_path.assign(context->base_path) || |
| !setup_dest_path.append(kSetupExe)) |
| return ProcessExitResult(PATH_STRING_OVERFLOW); |
| - // Prepare the input to OnResourceFound method that needs a location where |
| - // it will write all the resources. |
| - Context context = { |
| - base_path, |
| - archive_path, |
| - setup_path, |
| - }; |
| - |
| // Get the resources of type 'B7' (7zip archive). |
| // We need a chrome archive to do the installation. So if there |
| // is a problem in fetching B7 resource, just return an error. |
| if (!::EnumResourceNames(module, kLZMAResourceType, OnResourceFound, |
| - reinterpret_cast<LONG_PTR>(&context))) { |
| + reinterpret_cast<LONG_PTR>(context))) { |
| return ProcessExitResult(UNABLE_TO_EXTRACT_CHROME_ARCHIVE, |
| ::GetLastError()); |
| } |
| - if (archive_path->length() == 0) { |
| + if (context->chrome_resource_path->length() == 0) { |
| return ProcessExitResult(UNABLE_TO_EXTRACT_CHROME_ARCHIVE); |
| } |
| @@ -365,22 +364,18 @@ ProcessExitResult UnpackBinaryResources(const Configuration& configuration, |
| // If we found setup 'B7' resource (used for differential updates), handle |
| // it. Note that this is only for Chrome; Chromium installs are always |
| // "full" installs. |
| - if (setup_path->length() > 0) { |
| + if (context->setup_resource_path->length() > 0) { |
| CommandString cmd_line; |
| PathString exe_path; |
| // Get the path to setup.exe first. |
| exit_code = GetPreviousSetupExePath(configuration, exe_path.get(), |
| exe_path.capacity()); |
| if (exit_code.IsSuccess()) { |
| - if (!cmd_line.append(exe_path.get()) || |
| - !cmd_line.append(L" --") || |
| - !cmd_line.append(kCmdUpdateSetupExe) || |
| - !cmd_line.append(L"=\"") || |
| - !cmd_line.append(setup_path->get()) || |
| - !cmd_line.append(L"\" --") || |
| - !cmd_line.append(kCmdNewSetupExe) || |
| - !cmd_line.append(L"=\"") || |
| - !cmd_line.append(setup_dest_path.get()) || |
| + if (!cmd_line.append(exe_path.get()) || !cmd_line.append(L" --") || |
| + !cmd_line.append(kCmdUpdateSetupExe) || !cmd_line.append(L"=\"") || |
| + !cmd_line.append(context->setup_resource_path->get()) || |
| + !cmd_line.append(L"\" --") || !cmd_line.append(kCmdNewSetupExe) || |
| + !cmd_line.append(L"=\"") || !cmd_line.append(setup_dest_path.get()) || |
| !cmd_line.append(L"\"")) { |
| exit_code = ProcessExitResult(COMMAND_STRING_OVERFLOW); |
| } |
| @@ -394,8 +389,8 @@ ProcessExitResult UnpackBinaryResources(const Configuration& configuration, |
| exit_code = RunProcessAndWait(exe_path.get(), cmd_line.get()); |
| if (!exit_code.IsSuccess()) |
| - DeleteFile(setup_path->get()); |
| - else if (!setup_path->assign(setup_dest_path.get())) |
| + DeleteFile(context->setup_resource_path->get()); |
| + else if (!context->setup_resource_path->assign(setup_dest_path.get())) |
| exit_code = ProcessExitResult(PATH_STRING_OVERFLOW); |
| return exit_code; |
| @@ -404,21 +399,21 @@ ProcessExitResult UnpackBinaryResources(const Configuration& configuration, |
| // setup.exe wasn't sent as 'B7', lets see if it was sent as 'BL' |
| // (compressed setup). |
| if (!::EnumResourceNames(module, kLZCResourceType, OnResourceFound, |
| - reinterpret_cast<LONG_PTR>(&context))) { |
| + reinterpret_cast<LONG_PTR>(context))) { |
| return ProcessExitResult(UNABLE_TO_EXTRACT_SETUP_BL, ::GetLastError()); |
| } |
| - if (setup_path->length() == 0) { |
| + if (context->setup_resource_path->length() == 0) { |
| // Neither setup_patch.packed.7z nor setup.ex_ was found. |
| return ProcessExitResult(UNABLE_TO_EXTRACT_SETUP); |
| } |
| // Uncompress LZ compressed resource. Setup is packed with 'MSCF' |
| // as opposed to old DOS way of 'SZDD'. Hence we don't use LZCopy. |
| - bool success = |
| - mini_installer::Expand(setup_path->get(), setup_dest_path.get()); |
| - ::DeleteFile(setup_path->get()); |
| + bool success = mini_installer::Expand(context->setup_resource_path->get(), |
| + setup_dest_path.get()); |
| + ::DeleteFile(context->setup_resource_path->get()); |
| if (success) { |
| - if (!setup_path->assign(setup_dest_path.get())) { |
| + if (!context->setup_resource_path->assign(setup_dest_path.get())) { |
| ::DeleteFile(setup_dest_path.get()); |
| exit_code = ProcessExitResult(PATH_STRING_OVERFLOW); |
| } |
| @@ -426,6 +421,26 @@ ProcessExitResult UnpackBinaryResources(const Configuration& configuration, |
| exit_code = ProcessExitResult(UNABLE_TO_EXTRACT_SETUP_EXE); |
| } |
| +#if defined(SYZYASAN) |
| + PathString syzyasan_dest_path; |
| + if (!syzyasan_dest_path.assign(context->base_path) || |
| + !syzyasan_dest_path.append(L"syzyasan_rtl.dll")) { |
| + return ProcessExitResult(PATH_STRING_OVERFLOW); |
| + } |
| + success = mini_installer::Expand(context->syzyasan_resource_path->get(), |
|
Sébastien Marchand
2017/04/05 21:07:02
This probably could be moved into a function, not
|
| + syzyasan_dest_path.get()); |
| + ::DeleteFile(context->syzyasan_resource_path->get()); |
| + if (success) { |
| + if (!context->syzyasan_resource_path->assign(syzyasan_dest_path.get())) { |
| + ::DeleteFile(syzyasan_dest_path.get()); |
| + exit_code = ProcessExitResult(PATH_STRING_OVERFLOW); |
| + } |
| + } else { |
| + // TODO(sebmarchand): Add a new exit code for syzyasan_rtl.dll? |
| + exit_code = ProcessExitResult(UNABLE_TO_EXTRACT_SETUP_EXE); |
| + } |
| +#endif |
| + |
| #if defined(COMPONENT_BUILD) |
| if (exit_code.IsSuccess()) { |
| // Extract the (uncompressed) modules required by setup.exe. |
| @@ -844,8 +859,18 @@ ProcessExitResult WMain(HMODULE module) { |
| PathString archive_path; |
| PathString setup_path; |
| - exit_code = UnpackBinaryResources(configuration, module, base_path.get(), |
| - &archive_path, &setup_path); |
| +#if defined(SYZYASAN) |
| + PathString syzyasan_rtl_path; |
| +#endif |
| + Context context = { |
| + base_path.get(), |
| + &archive_path, |
| + &setup_path, |
| +#if defined(SYZYASAN) |
| + &syzyasan_rtl_path, |
| +#endif |
| + }; |
| + exit_code = UnpackBinaryResources(configuration, module, &context); |
| // While unpacking the binaries, we paged in a whole bunch of memory that |
| // we don't need anymore. Let's give it back to the pool before running |