Skip to content

Instantly share code, notes, and snippets.

@Darksecond
Last active May 23, 2017 08:00
Show Gist options
  • Select an option

  • Save Darksecond/3706842f74ba04ceecebd5f10e89b0ec to your computer and use it in GitHub Desktop.

Select an option

Save Darksecond/3706842f74ba04ceecebd5f10e89b0ec to your computer and use it in GitHub Desktop.
patch_v3.lvl

Halo 2 patch_v3.lvl signer/checker.

The chunk checksum is just a CRC32. It seems to be a slighty weird one in that there seems to be signed/unsigned difficulties. This is fixed in the javascript for all my test cases. Right now it does nothing except check the signatures of each chunk.

It is easy to add json serialization/unserialization later.

{
"name": "patchnode-19232",
"version": "1.0.0",
"description": "",
"main": "patch.js",
"dependencies": {
"crc-32": "^1.0.1"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Tim Peters",
"license": "ISC"
}
const CRC32 = require('crc-32');
const fs = require('fs');
const buffer = fs.readFileSync('./patch_v3.lvl.3');
const header = buffer.slice(0,8);
const maps = buffer.readUInt32LE(4);
console.log(maps);
for(let index = 0; index < maps; index++) {
let chunk = buffer.slice(8+185344*index,8+185344*(index+1));
let checksum = chunk.readUInt32LE(4);
chunk[4] = 0;
chunk[5] = 0;
chunk[6] = 0;
chunk[7] = 0;
// checksum seems to be inverted.
// So invert & treat as unsigned.
let crc = ~CRC32.buf(chunk) >>> 0;
console.log(checksum.toString(16), crc.toString(16));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment