GameHack is designed to be extensible, in that the hacks it knows about are not hard-coded into the executable.  Instead GameHack reads the hack definitions from a .HAK file.

GameHack is based on DiabHack, a utility I wrote to allow hacks to be applied to Blizzard's excellent Diablo RPG. DiabHack used a similar file layout (.DAT file) to GameHack, but the .HAK file has some important differences.  If you have used DiabHack, or have a .DAT file you want to convert to a .HAK file, then see the end of this text for a list of differences.

SYNTAX

1) All fields must be delimited using whitespace (Space or Tab) characters. Any number of whitespace characters may be used to delimit the fields.
2) The maximum line length is 512 characters.
3) Fields may be made up of multiple words by enclosing the words within double or single quote characters (" or ')
4) None of the keywords are case-sensitive; start = Start = START = sTaRt

LOCATION DEFINITION

The .HAK file may optionally contain the information necessary to locate the game process, using one of the following methods:

1) The name of the game's main window.
2) The name of the window class that the main window uses. This information is not normally easy to locate without the use of development utilties such as Microsoft's Spy++, however you can use the "Picker" dialog box tolist the class names for all top-level windows ("Location\Locate Game" menu item
3) The process identifier (procid) assigned to the process by the system. This will change every time the program is started, so having it hard-coded into the .HAK file makes no sense!.
4) Interactively by the user selecting the program via a "Picker" dialog box. The user may select the program by either it's Window name, Class name or Process ID.

In order to specify how to locate the game process, use the "locateby" keyword with the desired method:

locateby windowname <window-name>
locateby classname <window-class-name>
locateby procid <process-id>
locateby picker

If no "locateby" exists in the .HAK file the user may locate the game from within GameHack using the "Picker" dialog ("Location\Locate Game" menu item)

HACK DEFINITION

The .HAK file contains zero or more hacks, each of which contains one or more modifications to the Game process in memory.  Each hack definition is started in the .HAK file using the "start" keyword, followed by information about the hack:

start <version> <description>

The <version> field contains the version of Game that the hack is known to work with. GameHack does not attempt to interpret the version information, let alone check that the currently running version of Game conforms to it.
The <description> field simply describes the hack.
The hack definition is ended in the .HAK file using the "end" keyword:

end

Each hack modification line must lie between the hack-start line and hack-end line and takes the following form:

<offset> <olddata> <newdata>

The <offset> field is the virtual address within the Game process at which to apply the modification.
The <olddata> field contains the bytes that should be present within the game process before the modification is applied.  It has two important purposes; firstly it means that modifications can be dynamically undone (deactivated), and secondly it means that GameHack is able to validate the modification before applying it.
The <newdata> field contains the bytes that are used to modify the game process.
The <olddata> and <newdata> fields should contain a stream of hex bytes, without delimiters, and they must be 1) the same length as each other, and 2) an even number (insert a leading 0 as necessary); for example "64ee345343435343".

Below is a sample .HAK file showing the various elements I have described:

start V1.02 "Invulnerable from monsters"
45de9b 75 eb
45dfae 75 eb
405cbc 75 eb
end

.DAT AND .HAK FILE DIFFERENCES

1) The .HAK files support quoted words, allowing mutiple words to be packaged as one.  This means that the description field of the "start" keyword cannot be multiple words upto the end of the line, as it was in .DAT files.Instead the multiple words that make up the description field must be quoted:
  .DAT file:
  start v1.03 time flies like an arrow
  .HAK file:
  start v1.03 "fruit flies like a banana"
2) The .HAK files may optionally contain location information ("locateby" keyword.  This is because GameHack is designed to hack any Win32 game, not just Diablo, so it needs to be told how to locate the program to hack.

Enjoy... Andy.
