Monday, May 23, 2011

Decompiling a CHM (Compiled HTML) File

HTMLHelp command-line

HH.EXE is distributed with HTML Help so you can rely on it being present. It lives in the Windows folder and has a limited number of command-line options. HH.EXE is associated with .CHM files. So double-click a *.CHM file and Windows will open the file using HH.EXE. Its a very small file, it mostly passes the help filename onto a HH API library. HH.EXE is not single instance, if you open a CHM file three times using HH.EXE, then three help windows will appear.

Example of using HH.EXE to decompile a CHM help file

Command line from a DOS window:
C:\HH.EXE -decompile D:/xTemp/decompile-folder C:/xTemp/XMLconvert.chm
Call from batch command file:
HH.EXE -decompile D:/xTemp/decompile-folder C:/xTemp/XMLconvert.chm
HH.EXE -decompile decompile-folder file.chm where "decompile-folder" is the directory to put the files into. This could be simply "."

Decompiling the file produces a slew of HTML and image files, together with the table of contents (.hhc) file, index (.hhk) file, and a few other supporting files.

One thing to note is that the decompile/recompile process isn't a "round-trip" process. Certain features that the help author added to the original help file can't be recovered when you decompile it, so these may no longer work properly after you've recompiled. This is especially true in the area of context-sensitive help, which may be broken in the new version of the file.

No comments: