InstEd provides a minimal yet flexible interface for building and rebuilding cabs.

The interface point is the Media table. Right clicking on one or more selected Media table rows will provide two options:

  • Rebuild Selected CABs
  • Show DDF

Rebuild Selected CABs will attempt to generate a cab file for all selected Media table entries. 

InstEd uses the Microsoft utility called "makecab" that comes pre-installed on Windows 2000 and later. makecab accepts instruction files typically with a ".ddf" extension. Clicking Show DDF will display the ddf file that would be used to make the selected Media cab.

Show DDF allows the user to preview the details of a single media table entry, hence it only operates on the Media table row that has the focus.

Media to File Relationship

InstEd uses the same mechanism to build the cabs as Windows Installer does to retrieve files from the cabs.

The files that are associated with each Media table entry (and hence each cab) are designated by matching Media table "LastSequence" values with the "Sequence" values in the file table.

From the MSDN docs:
Each source disk (Media) contains all files with sequence numbers (as shown in the Sequence column of the File table) less than or equal to the value in the LastSequence column, and greater than the LastSequence value of the previous disk (or greater than 0, for the first entry in the Media table).

Media <Last>Sequence File

1 FileA

2 FileB

3 FileC
Media1 4 FileD

5 FileE
Media2 7 FileF

8 FileG
Media3 9 FileH

Source File Locations

Having determined which File table entries should be used to build the cab, the actual files to go into the cabs are found using the Directory table entry for each file's component. i.e. the files to go into the cabs must be in the same location as when using external uncompressed.

The component's Directory table entry specifies a source path relative to the msi, and the File table specifies the filename. For convenience, this source path is listed in the File table as a read only column.

Note that the Summary Information Stream (SIS) setting governing short/long filenames is respected in the source path. However when building cabs, the external source path is always used to retrieve the files, regardless of the SIS setting (or File table settings) for internal/external/compressed.

Cab Locations

The resultant cabs are either placed in the same folder as the msi, or are embedded in the msi. This is determined by whether the Media::Cabinet value begins with a '#' character.

From the MSDN docs:

If the cabinet name is preceded by the number sign, the cabinet is stored as a data stream inside the package. The character string which follows the # is an Identifier for this data stream. Note that if the cabinet is stored as a data stream, the name of a cabinet is case-sensitive.

If the cabinet name is not preceded by the number sign #, the cabinet is stored in a separate file located at the root of the source tree specified by the Directory Table. The cabinet file must use the short file name syntax consisting of an eight character name, a period, and a three character extension. The Cabinet data type cannot use the short|longname syntax for file names. If the cabinet file is stored as a separate file, the name of the cabinet file is not case-sensitive.


Hints

  • When starting with an msi that uses compressed internal or external files (cabs), you can extract the files into the appropriate source tree by performing an administrative install: msiexec -a <msi_path>.
  • Subsequently replacing a file in the source tree and rebuilding the cab will update the file in the cab, as well as the File table details (size, version, language, hash).
  • When replacing existing cabs (either internal or external) InstEd attempts to copy the existing cabs to a folder called "_CAB_Backup" in the same location as the msi. The copied cabs will have the current time in their name, to provide a history of replaced cabs.
  • Changing the cab location or name in the Media table will NOT remove the old cab.
  • All cabs are built before any are copied to their destinations. File details are only updated if all cabs are successfully generated. This should minimise the chance of a corrupted database on error.
  • You can use Show DDF on a valid Media row to get a template DDF file for other purposes.