diff options
author | Kissaki <kissaki@gmx.de> | 2013-04-21 05:32:55 +0400 |
---|---|---|
committer | Kissaki <kissaki@gmx.de> | 2013-06-05 00:37:38 +0400 |
commit | 85fa2ce57a0a2159e2065855ec6e2b1e1045671e (patch) | |
tree | aa9d2ea720a01418170e150852c0298e43762e63 /overlay/HardHook.h | |
parent | 33069f82de9929c553723038fab9cbf67b1b1b0f (diff) |
Code formatting, smaller refacs, robustness.
* Performance: Prefix increment in loops.
* Check VirtualAlloc return
* Check for successful memory allocation in cloneCode
* Swap assignment of pCode and uiCode
(if alloc were to fail and not assign, uiCode shouldn't be nulled either)
* declare statics before non-static members
* Introduce variables replacing magic constants
* Reduce varscopes
Diffstat (limited to 'overlay/HardHook.h')
-rw-r--r-- | overlay/HardHook.h | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/overlay/HardHook.h b/overlay/HardHook.h index 00ec1676c..aeb502768 100644 --- a/overlay/HardHook.h +++ b/overlay/HardHook.h @@ -47,6 +47,11 @@ typedef void *(*voidFunc)(); struct HardHook { + // Pointer to executable code page that holds all trampoline codes + static void *pCode; + // Offset to next unused addr in pCode + static unsigned int uiCode; + // Pointer to original code (which is hooked/replaced) unsigned char *baseptr; // The original instructions that are replaced by the hook @@ -59,14 +64,8 @@ struct HardHook { // Points to the (rest of the) original function when used from the injected function voidFunc call; - // Pointer to executable code page that holds all trampoline codes - static void *pCode; - // Offset to next unused addr in pCode - static unsigned int uiCode; - HardHook(); HardHook(voidFunc func, voidFunc replacement); - void *cloneCode(void **orig); void setup(voidFunc func, voidFunc replacement); void setupInterface(IUnknown *intf, LONG funcoffset, voidFunc replacement); void reset(); @@ -74,6 +73,12 @@ struct HardHook { void restore(bool force = false); void print(); void check(); + +private: + static const int CODEREPLACESIZE; + static const int CODEPROTECTSIZE; + + void *cloneCode(void **orig); }; #endif |