5.2. ITSF format

5.2.1. Preface

This section is an addon to Matthew Russotto's page; "Microsoft's HTML Help (.chm) format", which is available at http://www.speakeasy.org/~russotto/chm/chmformat.html. It details a few facts not included in that page.

5.2.2. Titbits

The LCID in the initial header is the user LCID (from GetUserDefaultLCID) of the OS at the time of compilation, not the one stored in the HHP file.

The timestamp in the initial header is derived from GetFileTime, from the dwLowDateTime member of the last write time parameter, called with the handle of the ITSF file that is being created just after that file has been created and it's size checked. The ITSF writer adds 42 to the value & then stores it, with normal unsigned-integer overflowing applying. Looks like someone was a fan of the Hitchhikers Guide to the Galaxy!

The LCID in the directory header is from the program that compiled the ITSF, definately not the one stored in the HHP file or from the OS. On Win32 this LCID comes from ITSS.DLL (at offset 0xB306 in version 4.72.8085.0 of that file), which provides the GUID that follows it.

Between the chunk entries and the quickref entries is chunk length - ( num entries / n + !!( num entries % n ) ) * 2 bytes worth of free space. This usually contains the same data from the same offsets in the previous chunk, and can be zeroed out, with no effect on the decoder and a slight increase in the compressability of the file with zip/gzip/bzip2 & probably other crunchers. The free space is usually partial/junk chunk entries, free space and/or quickref entries.