How WinHelp Files Work quin.fyi · 10 points · 3 comments · HN thread TL;DR The a...

@best

How WinHelp Files Work quin.fyi · 10 points · 3 comments · HN thread

TL;DR The author wrote libhlp, a pure-Rust reader for Microsoft WinHelp .hlp files, after reverse-engineering a format Microsoft never documented. The post explains the file's internal structure, its two-stage compression, hashed links, font-based formatting, and the WinHelp 3.0 differences, and notes that the library is on crates.io and used by the Paperback reader.

  • A .hlp file is an internal archive with a B+ tree directory; text lives in the |TOPIC file in fixed-size blocks that are LZ77 compressed.
  • Text is compressed again with phrase tables: a simple scheme in WinHelp 3.1 and the Hall scheme in the Windows 95 compiler, where a phrase-length bug affected files using a step size of one.
  • Links store a hash of the target's context name, not a topic position; the hash is case insensitive and an empty name hashes to 1.
  • Formatting is indirect: paragraphs select a font index, and links are drawn by switching to an underlined font, so the reader must distinguish that from author underlining.
  • WinHelp 3.0 uses 2 KB uncompressed blocks, 12-byte topic headers and topic numbers for links; Borland and MS-DOS QuickHelp files sharing the extension are rejected.
  • libhlp reads text, tables, emphasis, links and pictures from WinHelp 3.0 through the Windows 95 compiler, and bounds-checks everything.

Discussion The thread is very small, with only three comments, and it is positive and light. Commenters react to the project more than the technical details: one laments that software used to document itself through a central help system that has largely disappeared, another says it is fun and that they had always wondered how .hlp files worked, and a third notes the write-up is not specific to Rust.

  • Nostalgia for built-in, centralized program documentation (a few): One commenter regrets that programs once had a standard central way to document themselves, which is no longer common. They see the loss of that system as a real decline.
  • Enjoyment of the reverse-engineering write-up (a few): A commenter found the post fun and had long wondered how .hlp files worked, but had never explored it themselves. The post gave them the answer.
  • Useful beyond Rust (a few): One commenter says the write-up is not specific to Rust, implying that the format details and reverse-engineering approach are valuable to readers in any language.

#WinHelp #reverseEngineering #Rust #fileFormats #compression