Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement -ignore_duplicates_module #86

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion hook.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 5 additions & 4 deletions tinyinst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,8 @@ void TinyInst::OnModuleInstrumented(ModuleInfo* module) {
}
if(address) {
resolved_hooks[address] = hook;
} else {
WARN("Could not resolve function %s in module %s", hook->GetFunctionName().c_str(), hook->GetModuleName().c_str());
}
}
}
Expand Down Expand Up @@ -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;
Expand All @@ -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);

Expand Down