diff --git a/hook.md b/hook.md index c0e9c82..7928037 100644 --- a/hook.md +++ b/hook.md @@ -23,7 +23,7 @@ It is expected that most hooking operations can be performed just using the brea If a hook needs to add additional assembly code, this can be done by implementing `WriteCodeBefore`/`WriteCodeAfter` methods of the hook class. Assembly code can be inserted by calling the `WriteCode` function with the buffer containing the assembly to be inserted. Note that both `WriteCodeBefore`/`WriteCodeAfter` get called during instrumentation time (before the function gets run) and, due to how `HookBeginEnd` is implemented, `WriteCodeAfter` can be called multiple times for a single hooked function. -Once the hook classes have been implemented for each function the user wants to hook, the user can register them by calling `RegisterHook` method inside their clien's constructor. +Once the hook classes have been implemented for each function the user wants to hook, the user can register them by calling `RegisterHook` method inside their client's constructor. ### Example diff --git a/tinyinst.cpp b/tinyinst.cpp index 2474e18..ff11642 100644 --- a/tinyinst.cpp +++ b/tinyinst.cpp @@ -846,10 +846,12 @@ void TinyInst::OnModuleInstrumented(ModuleInfo* module) { } else if(hook->GetFunctionOffset()) { address = (size_t)(module->module_header) + hook->GetFunctionOffset(); } else { - FATAL("Hook specifies neithr function name nor offset"); + FATAL("Hook specifies neither function name nor offset"); } if(address) { resolved_hooks[address] = hook; + } else if (hook->GetModuleName() != std::string("*")) { + WARN("Could not resolve function %s in module %s", hook->GetFunctionName().c_str(), hook->GetModuleName().c_str()); } } } @@ -1075,9 +1077,8 @@ void TinyInst::OnInstrumentModuleLoaded(void *module, ModuleInfo *target_module) target_module->module_header && (target_module->module_header != (void *)module)) { - WARN("Instrumented module loaded on a different address than seen previously\n" - "Module will need to be re-instrumented. Expect a drop in performance."); - ClearInstrumentation(target_module); + WARN("Skipping re-instrumentation of duplicate module %s.", target_module->module_name.c_str()); + return; } target_module->module_header = (void *)module; @@ -1095,7 +1096,7 @@ void TinyInst::OnInstrumentModuleLoaded(void *module, ModuleInfo *target_module) } } -// called when a potentialy interesting module gets loaded +// called when a potentially interesting module gets loaded void TinyInst::OnModuleLoaded(void *module, char *module_name) { Debugger::OnModuleLoaded(module, module_name);