angr.misc.hookset¶
These classes perform some python magic that we use to implement the nesting of exploration technique methods. This process is formalized as a “hooking” of a python method - each exploration technique’s methods “hooks” a method of the same name on the simulation manager class.
- class angr.misc.hookset.HookSet¶
Bases:
objectA HookSet is a static class that provides the capability to apply many hooks to an object.
- static install_hooks(target, **hooks)¶
Given the target target, apply the hooks given as keyword arguments to it. If any targeted method has already been hooked, the hooks will not be overridden but will instead be pushed into a list of pending hooks. The final behavior should be that all hooks call each other in a nested stack.
- Parameters:
target – Any object. Its methods named as keys in hooks will be replaced by HookedMethod objects.
hooks – Any keywords will be interpreted as hooks to apply. Each method named will hooked with the corresponding function value.
- static remove_hooks(target, **hooks)¶
Remove the given hooks from the given target.
- Parameters:
target – The object from which to remove hooks. If all hooks are removed from a given method, the HookedMethod object will be removed and replaced with the original function.
hooks – Any keywords will be interpreted as hooks to remove. You must provide the exact hook that was applied so that it can it can be identified for removal among any other hooks.
- static copy_hooks(source, target, domain)¶
Copy the hooks from source onto target.
If the current callstack includes hooked methods from source, the already-called methods will not be included in the copy.
domainis a list of names that might be hooked.
- class angr.misc.hookset.HookedMethod¶
Bases:
objectHookedMethod is a callable object which provides a stack of nested hooks.
- Parameters:
func – The bottom-most function which provides the original functionality that is being hooked
- Variables:
func – Same as the eponymous parameter
pending – The stack of hooks that have yet to be called. When this object is called, it will pop the last function in this list and call it. The function should call this object again in order to request the functionality of the original method, at which point the pop-dispatch mechanism will run recursively until the stack is exhausted, at which point the original function will be called. When the call returns, the hook will be restored to the stack.
- __init__(func)¶
- copy_to(new_func)¶