lessmsi icon indicating copy to clipboard operation
lessmsi copied to clipboard

Support Extracting files from Windows Installer Merge Modules (.msm files)

Open adabru opened this issue 11 months ago • 1 comments

Describe the bug Dll-extraction fails for Microsoft Visual C++ Redistributable 143 Merge Module with following error:

Failed to create view with query: SELECT * FROM `Media`

Technical Detail:

   at Microsoft.Tools.WindowsInstallerXml.Msi.View..ctor(Database db, String query)
   at Microsoft.Tools.WindowsInstallerXml.Msi.Database.OpenExecuteView(String query)
   at LessMsi.Msi.Wixtracts.CabsFromMsiToDisk(Path msi, Database msidb, String outputDir)
   at LessMsi.Msi.Wixtracts.ExtractFiles(Path msi, String outputDir, MsiFile[] filesToExtract, AsyncCallback progressCallback, ExtractionMode extractionMode)
   at LessMsi.Gui.MainForm.btnExtract_Click(Object sender, EventArgs e)

To Reproduce Steps to reproduce the behavior:

  1. Install Visual Studio Installer, then the component C++ 2022 Redistributable-MSMs.
  2. Open the file C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Redist\MSVC\v143\MergeModules\Microsoft_VC143_CRT_x64.msm in LessMSI.
  3. Click on 'Extract'.
  4. See error, no dlls are extracted.

Expected behavior The extraction should succeed without an error popout and the dlls should be visible in the target directory.

Screenshots

Image

Desktop (please complete the following information):

  • OS: Windows 11
  • Version 2.4.0.0

Additional context

Here is the related file: Microsoft_VC143_CRT_x64.msm.txt

You have to remove the .txt suffix.

adabru avatar Jan 20 '25 18:01 adabru

Thanks for the report. For whomever gets to investigate this next below are a couple of notes:

  • Merge Modules are a bit different than normal msi databases. They are kind of a subset of a normal windows installer file/database and require some of their own tables and are not meant to be used standalone, but only used within the context of another installer.
  • It appears that the merge modules do not use the media table like installer databases. https://learn.microsoft.com/en-us/windows/win32/msi/merge-module-database-tables specifically indicates that the Media table (which is used in .msi files to extract files) cannot be used in a merge module.
  • The File table (which is how we build a file list in a .msi file) is present so that's good!
  • The detail about how to find the cabs that the files are in is at https://learn.microsoft.com/en-us/windows/win32/msi/generating-mergemodule-cabinet-cabinet-files (and the link from there). Apparently there is a single CAB file embedded to contain the actual binaries. So instead of querying the Media table in CabsFromMsiToDisk we need to find that stream and use it as the only cab (I think).

activescott avatar Jan 22 '25 20:01 activescott