Skip to content

Instantly share code, notes, and snippets.

@jrsa
Created June 23, 2017 18:52
Show Gist options
  • Save jrsa/ad1674687fdff972e9d85c6429af656a to your computer and use it in GitHub Desktop.
Save jrsa/ad1674687fdff972e9d85c6429af656a to your computer and use it in GitHub Desktop.
demonstration of function hooking inside world of warcraft, using cycript (http://www.cycript.org/)
var log = [];
var oldf = {}; // this object is used to access the original function from the hook
// address of smemalloc taken from:
// wow build 12340, macOS i386 build, md5: 1abfcf2cb17cdbe804c1c77d0525f1fa
var smemalloc = @encode(void*(int, char*, int, int))(0x9bad0)
var hook = function(a1, file, a3, a4) {
var ptr = (*oldf)(a1, file, a3, a4);
log.push([a1, file.toString(), a3, a4]);
return ptr;
}
MS.hookFunction(smemalloc, hook, oldf);
@jrsa
Copy link
Author

jrsa commented Jun 23, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment