Partager via


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

Comments

  • Anonymous
    August 03, 2005
    GetFileInformationByHandle should be able to return the size of a file on a network share.
  • Anonymous
    August 03, 2005
    What I'd really love to see is the source code...
  • Anonymous
    August 04, 2005
    Download v1.1
    By popular demand I've updated the tool already! Now it actually extracts the files and...
  • Anonymous
    August 08, 2005
    So I decided not to blog much from O’ahu – not such a bad thing, eh?  (..and I got sick of updating...
  • Anonymous
    August 08, 2005
    So I decided not to blog much from O’ahu – not such a bad thing, eh?  (..and I got sick of updating...
  • Anonymous
    August 17, 2005
    The comment has been removed
  • Anonymous
    August 10, 2006
    Have I any chance to get this MSCE binary file format? I need to do the cabwiz job but from code. I can't use any kind of dll so I have to write all the management code needed. I have allready been succesfull in creating a cab file (the makecab job is allready done) but I need to do the extra work cabwiz does.

    Is there any way to know how to do? What file transformations, what file creations, what file renames, etc...?

    Thanks in advance!
    K.
  • Anonymous
    May 23, 2007
    There is usefull utility for analyzing .CAB files: http://www.codeppc.com/telechargements/msceinf/msceinf.htm