Welcome to MSDN Blogs Sign in | Join | Help

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

Published Wednesday, August 03, 2005 1:46 PM by marcpe

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# re: CAB file utility

GetFileInformationByHandle should be able to return the size of a file on a network share.
Wednesday, August 03, 2005 12:35 PM by Matt Lacey

# re: CAB file utility

What I'd really love to see is the source code...
Thursday, August 04, 2005 12:33 AM by David Resnick

# CAB file utility (v1.1)

Download v1.1
By popular demand I've updated the tool already! Now it actually extracts the files and...
Thursday, August 04, 2005 8:27 AM by Marcus Perryman's WebLog

# The Mobile Minute 108

So I decided not to blog much from O’ahu – not such a bad thing, eh?  (..and I got sick of updating...
Tuesday, August 09, 2005 12:25 AM by Nino.Mobile

# The Mobile Minute 108

So I decided not to blog much from O’ahu – not such a bad thing, eh?  (..and I got sick of updating...
Tuesday, August 09, 2005 12:29 AM by Nino.Mobile

# re: CAB file utility

Matt, thanks for the info.
David, unfortunately this is one bit of code I cant post. Sorry.

Marcus
Thursday, August 18, 2005 4:35 AM by marcpe

# re: CAB file utility

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.
Friday, August 11, 2006 3:12 AM by Kupy

# re: CAB file utility

There is usefull utility for analyzing .CAB files:

http://www.codeppc.com/telechargements/msceinf/msceinf.htm

Thursday, May 24, 2007 6:17 AM by andre

Leave a Comment

(required) 
required 
(required) 
 
Page view tracker