diff options
| author | Peter LaFosse <peter@vector35.com> | 2017-03-24 11:20:39 -0400 |
|---|---|---|
| committer | Peter LaFosse <peter@vector35.com> | 2017-03-24 11:20:39 -0400 |
| commit | 435e937c9705bc71cf1e7da1e08b23345a131360 (patch) | |
| tree | 5a4d729acb0404c4c4059f0c7e8aa7c22136b649 /examples/breakpoint/src | |
| parent | 1e8e975ed8100c7a6186e8b27833a067ceaf05be (diff) | |
| parent | ddaf7506e1802cfd4f9c78bcfb14deb0180b04d8 (diff) | |
Merge branch 'dev' into staging
Diffstat (limited to 'examples/breakpoint/src')
| -rw-r--r-- | examples/breakpoint/src/breakpoint.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/examples/breakpoint/src/breakpoint.cpp b/examples/breakpoint/src/breakpoint.cpp new file mode 100644 index 00000000..4fac98ac --- /dev/null +++ b/examples/breakpoint/src/breakpoint.cpp @@ -0,0 +1,36 @@ +#include <inttypes.h> +#include "binaryninjaapi.h" + +using namespace BinaryNinja; +using namespace std; + +void write_breakpoint(BinaryNinja::BinaryView *view, uint64_t start, uint64_t length) +{ + // Sample function to show registering a plugin menu item for a range of bytes. + // Also possible: + // register + // register_for_address + // register_for_function + + Ref<Architecture> arch = view->GetDefaultArchitecture(); + string arch_name = arch->GetName(); + + if (arch_name.compare(0, 3, "x86") == 0) { + string int3s = string(length, '\xcc'); + view->Write(start, int3s.c_str(), length); + } else { + LogError("No support for breakpoint on %s", arch_name.c_str()); + } +} + +extern "C" +{ + BINARYNINJAPLUGIN bool CorePluginInit() + { + // Register the plugin with Binary Ninja + PluginCommand::RegisterForRange("Convert to breakpoint", + "Fill region with breakpoint instructions.", + &write_breakpoint); + return true; + } +}
\ No newline at end of file |
