Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Library:Havok

From ReverseEngineering.wiki
Library
On this wiki Facts · Code · Notes · Topics

Havok is a commercial physics, animation and behavior middleware used in many games; its data files (.hkx, .hkt, .hkb and friends) are Havok packfiles or tagfiles whose header carries a version string such as hk_2014.2.0-r1 and whose class-name table lists the serialized classes.

Identification

  • Files: .hkx (also .hkt, .hkb, .hkrg ragdoll, .hknm2 navmesh in some games) are serialized Havok object graphs. Two container formats exist: the older packfile (read below) and the newer tagfile (TAG0, see below).
  • Packfile header magic: the two little-endian words 0x57E0E057 and 0x10C0C010, so the first 8 bytes are 57 E0 E0 57 10 C0 C0 10. See Fact:Havok/magic/Packfile magic.
  • The contents version string at file offset 0x28 (16 bytes) names the SDK that wrote the file, for example hk_2014.2.0-r1 (the string the HKX2 reader writes for Breath of the Wild Wii U and Switch packfiles). Other hk_20xx.x.x-rN strings exist; the wiki has no list yet.
  • Executables: Unverified: Havok-linked games usually contain strings such as hkp/hkb/hka class names (hkpRigidBody, hkbBehaviorGraph, hkaSkeleton) in RTTI or in the .hkx class-name tables; the 'hk' prefix is the Havok naming convention.

Packfile layout

Read from the open HKX2Library (MIT): a 0x40-byte header (more on Fact:Havok/struct/Packfile header), then SectionCount (3) section headers of 0x30 bytes each, then the section data. The sections are __classnames__, __types__ (empty in the files that library writes) and __data__. Each section has local, global and virtual fixup tables that turn stored offsets into pointers; see Fact:Havok/struct/Packfile section header and Fact:Havok/struct/Packfile class name entry.

  • Pointer size (4 or 8), endianness and a padding option are in the header, so one parser handles Wii U (big endian, 4-byte pointers) and Switch/PC (little endian, 8-byte pointers) files.
  • Class signatures: every entry of the class-name table starts with a 32-bit signature followed by the class name; the signature identifies the class layout for that SDK version.

Tagfile

Unverified (from memory, not read in a source this session): newer Havok versions also write a tagfile that begins with a 32-bit size and the ASCII tag TAG0, followed by tags such as SDKV (the SDK version string) and DATA. To confirm, open a recent .hkx in a hex editor or read a tagfile reader with a license.

Tools and sources

  • HKX2Library (C#, MIT): packfile reading and writing; used for the format facts above.

Notes for reverse engineers

Unverified: because the class layouts change between SDK years, a reader must match the contents version string first; a game's Havok year can be guessed from the version string of its shipped .hkx files, not from the executable.

Code & repositories

  • https://github.com/HKX2/HKX2Library @ b833954ac38f8a412c903184174d51d3e6aba68a · license: MIT
    HKX2Library (MIT): C# Havok packfile reader/writer from DSMapStudio's HKX2; HKX2/PackFileCommon.cs holds the header, section, fixup and class-name layouts
    Tested on: source read, not run: source read only · checked 2026-10-18; last activity 2024-03-29