CAB file utility

Have you ever built a cab file and then lost the original INF? Or ever wondered just exactly what settings a Pocket PC theme uses?

Windows XP includes shell extensions that can show you the raw files inside a CAB but at first glance what you see bears no resemblance to the original or expected content: you will see one more file than you put in with a .000 extension, and all other files are shown in 8.3 format with 001, 002 and so on as the file extension.

So what’s going on? The first file is a binary format version of the CAB install instructions containing much of the information supplied in the original INF file including copy instructions, registry keys and values, file details and other relevant information.

Someone asked me to recreate the original INF file given a CAB file but unfortunately that’s not quite possible as several pieces of information are discarded during the build process such as the source file information. Most developers use one of two tools for creating a CAB: either CabWiz.exe (for Pocket PC CAB files) or CabWizSP.exe (for compressed Smartphone CAB files). Both work in a similar way using an INF file to describes the build steps and content of the cab file, but neither tool is actually responsible for creating the CAB file. The CabWiz tools are just a front end to the MakeCab.exe utility that does the hard work. The reason we have CabWiz tools is because the input file format for MakeCab is complex and somewhat abstract - not easy to get right compared to the simple layout of an INF file!

Although the full INF can’t be recreated, it is possible to get some of the information from a CAB such as the registry keys and values, file names and path strings used. Here is a quick and dirty utility I knocked up that does exactly this. It’s not perfect by any means, but might be useful to some of you.

There are a couple of features (ok, bugs!) to be aware of:

1> It wont load cab files from a network share. The code uses GetFileSize (win32 SDK) that always returns 0 bytes for a network file - if anyone knows how I can fix this, please let me know.

2> It doesn’t load compressed cab files yet, so don’t try pointing it at a Smartphone cab or HME. Right now you get an error message and then it blows up.

I will post an update if I get some time to improve the code.

Enjoy.

Marcus