summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyleMiles <krm504@nyu.edu>2022-01-27 22:43:28 -0500
committerKyleMiles <krm504@nyu.edu>2022-01-28 00:24:06 -0500
commit6812c973c9fa9b4ad642ab81856c05f87bd6fcc4 (patch)
treedace4156d03148bcaf02df138ab4e0d93e61bc6f
parent519c9db22367f2659d1a54599fab47e6313be06e (diff)
Format All Files
-rw-r--r--activity.cpp7
-rw-r--r--architecture.cpp189
-rw-r--r--basicblock.cpp8
-rw-r--r--binaryninjaapi.cpp34
-rw-r--r--binaryninjaapi.h2989
-rw-r--r--binaryninjacore.h2462
-rw-r--r--binaryreader.cpp8
-rw-r--r--binaryview.cpp289
-rw-r--r--binaryviewtype.cpp20
-rw-r--r--binarywriter.cpp2
-rw-r--r--callingconvention.cpp18
-rw-r--r--database.cpp17
-rw-r--r--datarenderer.cpp27
-rw-r--r--debuginfo.cpp62
-rw-r--r--demangle.cpp34
-rw-r--r--downloadprovider.cpp44
-rw-r--r--examples/bin-info/src/bin-info.cpp154
-rw-r--r--examples/breakpoint/src/breakpoint.cpp48
-rw-r--r--examples/cmdline_disasm/src/disasm.cpp88
-rw-r--r--examples/llil_parser/src/llil_parser.cpp240
-rw-r--r--examples/mlil_parser/src/mlil_parser.cpp222
-rw-r--r--examples/print_syscalls/src/arm-syscall.cpp145
-rw-r--r--examples/triage/byte.cpp127
-rw-r--r--examples/triage/byte.h12
-rw-r--r--examples/triage/entropy.cpp5
-rw-r--r--examples/triage/entropy.h10
-rw-r--r--examples/triage/exports.cpp10
-rw-r--r--examples/triage/exports.h16
-rw-r--r--examples/triage/fileinfo.cpp128
-rw-r--r--examples/triage/fileinfo.h18
-rw-r--r--examples/triage/files.cpp15
-rw-r--r--examples/triage/files.h12
-rw-r--r--examples/triage/headers.cpp67
-rw-r--r--examples/triage/headers.h32
-rw-r--r--examples/triage/imports.cpp8
-rw-r--r--examples/triage/imports.h16
-rw-r--r--examples/triage/sections.cpp24
-rw-r--r--examples/triage/sections.h8
-rw-r--r--examples/triage/triage.cpp13
-rw-r--r--examples/triage/view.cpp20
-rw-r--r--examples/triage/view.h12
-rw-r--r--examples/uinotification/uinotification.cpp18
-rw-r--r--examples/uinotification/uinotification.h8
-rw-r--r--examples/workflows/inliner/inliner.cpp32
-rw-r--r--examples/workflows/objectivec/objectivec.cpp25
-rw-r--r--examples/workflows/tailcall/tailcall.cpp14
-rw-r--r--examples/x86_extension/src/x86_extension.cpp13
-rw-r--r--fileaccessor.cpp9
-rw-r--r--filemetadata.cpp36
-rw-r--r--flowgraph.cpp17
-rw-r--r--function.cpp181
-rw-r--r--functionrecognizer.cpp10
-rw-r--r--highlevelil.cpp36
-rw-r--r--highlevelilinstruction.cpp824
-rw-r--r--highlevelilinstruction.h891
-rw-r--r--http.cpp130
-rw-r--r--http.h123
-rw-r--r--interaction.cpp85
-rw-r--r--linearviewobject.cpp157
-rw-r--r--lowlevelil.cpp91
-rw-r--r--lowlevelilinstruction.cpp987
-rw-r--r--lowlevelilinstruction.h1159
-rw-r--r--mediumlevelil.cpp107
-rw-r--r--mediumlevelilinstruction.cpp1085
-rw-r--r--mediumlevelilinstruction.h1032
-rw-r--r--metadata.cpp2
-rw-r--r--platform.cpp26
-rw-r--r--plugin.cpp208
-rw-r--r--pluginmanager.cpp16
-rw-r--r--python/__init__.py32
-rw-r--r--python/architecture.py515
-rw-r--r--python/associateddatastore.py9
-rw-r--r--python/basicblock.py60
-rw-r--r--python/binaryview.py1360
-rw-r--r--python/bncompleter.py20
-rw-r--r--python/callingconvention.py119
-rw-r--r--python/commonil.py5
-rw-r--r--python/compatibility.py3
-rw-r--r--python/database.py512
-rw-r--r--python/databuffer.py14
-rw-r--r--python/dataclasses.py1392
-rw-r--r--python/datarender.py19
-rw-r--r--python/debuginfo.py84
-rw-r--r--python/decorators.py1
-rw-r--r--python/demangle.py40
-rw-r--r--python/downloadprovider.py43
-rw-r--r--python/enterprise.py6
-rw-r--r--python/examples/angr_plugin.py27
-rw-r--r--python/examples/arch_hook.py17
-rw-r--r--python/examples/asm_to_llil_view.py15
-rw-r--r--python/examples/breakpoint.py8
-rwxr-xr-xpython/examples/cli_dis.py5
-rwxr-xr-xpython/examples/cli_lift.py21
-rwxr-xr-xpython/examples/debug_info.py151
-rwxr-xr-xpython/examples/export_svg.py343
-rw-r--r--python/examples/helloglobalarea.py2
-rw-r--r--python/examples/hellopane.py7
-rw-r--r--python/examples/hellosidebar.py3
-rw-r--r--python/examples/instruction_iterator.py3
-rw-r--r--python/examples/jump_table.py6
-rw-r--r--python/examples/linear_mlil.py47
-rw-r--r--python/examples/mappedview.py27
-rw-r--r--python/examples/nds.py134
-rw-r--r--python/examples/nes.py552
-rw-r--r--python/examples/notification_callbacks.py2
-rw-r--r--python/examples/nsf.py9
-rwxr-xr-xpython/examples/pe_stat.py7
-rw-r--r--python/examples/print_syscalls.py4
-rwxr-xr-xpython/examples/typelib_create.py29
-rwxr-xr-xpython/examples/typelib_dump.py173
-rw-r--r--python/examples/ui_notifications.py102
-rw-r--r--python/fileaccessor.py3
-rw-r--r--python/filemetadata.py99
-rw-r--r--python/flowgraph.py58
-rw-r--r--python/function.py814
-rw-r--r--python/functionrecognizer.py16
-rw-r--r--python/generator.cpp129
-rw-r--r--python/highlevelil.py830
-rw-r--r--python/highlight.py15
-rw-r--r--python/interaction.py84
-rw-r--r--python/lineardisassembly.py117
-rw-r--r--python/log.py4
-rw-r--r--python/lowlevelil.py1420
-rw-r--r--python/mediumlevelil.py1093
-rw-r--r--python/metadata.py9
-rw-r--r--python/platform.py73
-rw-r--r--python/plugin.py337
-rw-r--r--python/pluginmanager.py7
-rw-r--r--python/scriptingprovider.py164
-rw-r--r--python/settings.py50
-rw-r--r--python/transform.py18
-rw-r--r--python/typelibrary.py5
-rw-r--r--python/types.py900
-rw-r--r--python/update.py11
-rw-r--r--python/variable.py192
-rw-r--r--python/websocketprovider.py19
-rw-r--r--python/workflow.py55
-rw-r--r--rapidjsonwrapper.h31
-rw-r--r--relocationhandler.cpp53
-rw-r--r--rust/examples/basic_script/build.rs79
-rw-r--r--rust/examples/template/build.rs79
-rw-r--r--rust/src/disassembly.rs6
-rw-r--r--rust/src/types.rs16
-rw-r--r--scriptingprovider.cpp57
-rwxr-xr-xscripts/download_headless.py22
-rwxr-xr-xscripts/install_api.py156
-rw-r--r--secretsprovider.cpp10
-rw-r--r--settings.cpp33
-rw-r--r--transform.cpp18
-rw-r--r--type.cpp199
-rw-r--r--ui/action.h109
-rw-r--r--ui/addressdialog.h37
-rw-r--r--ui/addressindicator.h6
-rw-r--r--ui/assembledialog.h11
-rw-r--r--ui/clickablelabel.h45
-rw-r--r--ui/commandpalette.h28
-rw-r--r--ui/commands.h41
-rw-r--r--ui/commentdialog.h4
-rw-r--r--ui/compiledialog.h8
-rw-r--r--ui/compileoptions.h6
-rw-r--r--ui/createstructdialog.h9
-rw-r--r--ui/createtypedialog.h15
-rw-r--r--ui/datatypelist.h8
-rw-r--r--ui/dialogtextedit.h8
-rw-r--r--ui/disassemblyview.h66
-rw-r--r--ui/dockhandler.h60
-rw-r--r--ui/expandablegroup.h10
-rw-r--r--ui/featuremap.h21
-rw-r--r--ui/filecontext.h11
-rw-r--r--ui/filter.h19
-rw-r--r--ui/flowgraphwidget.h38
-rw-r--r--ui/forminputdialog.h6
-rw-r--r--ui/getsymbolslistthread.h10
-rw-r--r--ui/globalarea.h133
-rw-r--r--ui/hexeditor.h44
-rw-r--r--ui/ilchooser.h10
-rw-r--r--ui/instructionedit.h8
-rw-r--r--ui/linearview.h64
-rw-r--r--ui/logview.h40
-rw-r--r--ui/menus.h24
-rw-r--r--ui/minigraph.h12
-rw-r--r--ui/options.h8
-rw-r--r--ui/pane.h72
-rw-r--r--ui/platformdialog.h6
-rw-r--r--ui/possiblevaluesetdialog.h7
-rw-r--r--ui/preview.h8
-rw-r--r--ui/progressindicator.h148
-rw-r--r--ui/progresstask.h363
-rw-r--r--ui/qfileaccessor.h2
-rw-r--r--ui/render.h29
-rw-r--r--ui/reportcollectionwidget.h6
-rw-r--r--ui/reportwidget.h32
-rw-r--r--ui/scriptingconsole.h51
-rw-r--r--ui/searchresult.h349
-rw-r--r--ui/settingsview.h120
-rw-r--r--ui/sidebar.h190
-rw-r--r--ui/stackview.h25
-rw-r--r--ui/statusbarwidget.h10
-rw-r--r--ui/stringsview.h39
-rw-r--r--ui/symbollist.h50
-rw-r--r--ui/symbolsview.h12
-rw-r--r--ui/syncgroup.h8
-rw-r--r--ui/tabwidget.h96
-rw-r--r--ui/taglist.h60
-rw-r--r--ui/tagtypelist.h44
-rw-r--r--ui/textbrowser.h28
-rw-r--r--ui/textdialog.h8
-rw-r--r--ui/theme.h12
-rw-r--r--ui/tokenizedtextview.h22
-rw-r--r--ui/transformparam.h8
-rw-r--r--ui/typedialog.h23
-rw-r--r--ui/typeview.h117
-rw-r--r--ui/uicomment.h18
-rw-r--r--ui/uicontext.h115
-rw-r--r--ui/uitypes.h51
-rw-r--r--ui/util.h18
-rw-r--r--ui/variablelist.h21
-rw-r--r--ui/viewframe.h163
-rw-r--r--ui/viewlist.h8
-rw-r--r--ui/viewtype.h4
-rw-r--r--ui/xreflist.h135
-rw-r--r--update.cpp17
-rw-r--r--websocketprovider.cpp28
-rw-r--r--workflow.cpp14
224 files changed, 17271 insertions, 14376 deletions
diff --git a/activity.cpp b/activity.cpp
index 31584343..ee9327de 100644
--- a/activity.cpp
+++ b/activity.cpp
@@ -5,9 +5,10 @@ using namespace BinaryNinja;
using namespace std;
-Activity::Activity(const string& name, const std::function<void(Ref<AnalysisContext> analysisContext)>& action): m_action(action)
+Activity::Activity(const string& name, const std::function<void(Ref<AnalysisContext> analysisContext)>& action) :
+ m_action(action)
{
- //LogError("API-Side Activity Constructed!");
+ // LogError("API-Side Activity Constructed!");
m_object = BNCreateActivity(name.c_str(), this, Run);
}
@@ -20,7 +21,7 @@ Activity::Activity(BNActivity* activity)
Activity::~Activity()
{
- //LogError("API-Side Activity Destructed!");
+ // LogError("API-Side Activity Destructed!");
}
diff --git a/architecture.cpp b/architecture.cpp
index cf0033a9..cd5306ea 100644
--- a/architecture.cpp
+++ b/architecture.cpp
@@ -49,7 +49,8 @@ void InstructionInfo::AddBranch(BNBranchType type, uint64_t target, Architecture
}
-InstructionTextToken::InstructionTextToken(): type(TextToken), value(0), width(WidthIsByteCount), confidence(BN_FULL_CONFIDENCE)
+InstructionTextToken::InstructionTextToken() :
+ type(TextToken), value(0), width(WidthIsByteCount), confidence(BN_FULL_CONFIDENCE)
{
if (width == WidthIsByteCount)
{
@@ -58,9 +59,11 @@ InstructionTextToken::InstructionTextToken(): type(TextToken), value(0), width(W
}
-InstructionTextToken::InstructionTextToken(BNInstructionTextTokenType t, const std::string& txt, uint64_t val,
- size_t s, size_t o, uint8_t c, const vector<string>& n, uint64_t w) : type(t), text(txt), value(val), width(w), size(s), operand(o),
- context(NoTokenContext), confidence(c), address(0), typeNames(n)
+InstructionTextToken::InstructionTextToken(BNInstructionTextTokenType t, const std::string& txt, uint64_t val, size_t s,
+ size_t o, uint8_t c, const vector<string>& n, uint64_t w) :
+ type(t),
+ text(txt), value(val), width(w), size(s), operand(o), context(NoTokenContext), confidence(c), address(0),
+ typeNames(n)
{
if (width == WidthIsByteCount)
{
@@ -70,8 +73,9 @@ InstructionTextToken::InstructionTextToken(BNInstructionTextTokenType t, const s
InstructionTextToken::InstructionTextToken(BNInstructionTextTokenType t, BNInstructionTextTokenContext ctxt,
- const string& txt, uint64_t a, uint64_t val, size_t s, size_t o, uint8_t c, const vector<string>& n, uint64_t w):
- type(t), text(txt), value(val), width(w), size(s), operand(o), context(ctxt), confidence(c), address(a), typeNames(n)
+ const string& txt, uint64_t a, uint64_t val, size_t s, size_t o, uint8_t c, const vector<string>& n, uint64_t w) :
+ type(t),
+ text(txt), value(val), width(w), size(s), operand(o), context(ctxt), confidence(c), address(a), typeNames(n)
{
if (width == WidthIsByteCount)
{
@@ -80,9 +84,9 @@ InstructionTextToken::InstructionTextToken(BNInstructionTextTokenType t, BNInstr
}
-InstructionTextToken::InstructionTextToken(const BNInstructionTextToken& token):
- type(token.type), text(token.text), value(token.value), width(token.width), size(token.size),
- operand(token.operand), context(token.context), confidence(token.confidence), address(token.address)
+InstructionTextToken::InstructionTextToken(const BNInstructionTextToken& token) :
+ type(token.type), text(token.text), value(token.value), width(token.width), size(token.size),
+ operand(token.operand), context(token.context), confidence(token.confidence), address(token.address)
{
typeNames.reserve(token.namesCount);
for (size_t j = 0; j < token.namesCount; j++)
@@ -118,7 +122,8 @@ static void ConvertInstructionTextToken(const InstructionTextToken& token, BNIns
}
-vector<InstructionTextToken> InstructionTextToken::ConvertAndFreeInstructionTextTokenList(BNInstructionTextToken* tokens, size_t count)
+vector<InstructionTextToken> InstructionTextToken::ConvertAndFreeInstructionTextTokenList(
+ BNInstructionTextToken* tokens, size_t count)
{
auto result = ConvertInstructionTextTokenList(tokens, count);
BNFreeInstructionText(tokens, count);
@@ -135,7 +140,8 @@ BNInstructionTextToken* InstructionTextToken::CreateInstructionTextTokenList(con
}
-vector<InstructionTextToken> InstructionTextToken::ConvertInstructionTextTokenList(const BNInstructionTextToken* tokens, size_t count)
+vector<InstructionTextToken> InstructionTextToken::ConvertInstructionTextTokenList(
+ const BNInstructionTextToken* tokens, size_t count)
{
vector<InstructionTextToken> result;
result.reserve(count);
@@ -151,7 +157,7 @@ Architecture::Architecture(BNArchitecture* arch)
}
-Architecture::Architecture(const string& name): m_nameForRegister(name)
+Architecture::Architecture(const string& name) : m_nameForRegister(name)
{
m_object = nullptr;
}
@@ -213,8 +219,8 @@ BNArchitecture* Architecture::GetAssociatedArchitectureByAddressCallback(void* c
}
-bool Architecture::GetInstructionInfoCallback(void* ctxt, const uint8_t* data, uint64_t addr, size_t maxLen,
- BNInstructionInfo* result)
+bool Architecture::GetInstructionInfoCallback(
+ void* ctxt, const uint8_t* data, uint64_t addr, size_t maxLen, BNInstructionInfo* result)
{
Architecture* arch = (Architecture*)ctxt;
@@ -225,8 +231,8 @@ bool Architecture::GetInstructionInfoCallback(void* ctxt, const uint8_t* data, u
}
-bool Architecture::GetInstructionTextCallback(void* ctxt, const uint8_t* data, uint64_t addr,
- size_t* len, BNInstructionTextToken** result, size_t* count)
+bool Architecture::GetInstructionTextCallback(
+ void* ctxt, const uint8_t* data, uint64_t addr, size_t* len, BNInstructionTextToken** result, size_t* count)
{
Architecture* arch = (Architecture*)ctxt;
@@ -258,8 +264,8 @@ void Architecture::FreeInstructionTextCallback(BNInstructionTextToken* tokens, s
}
-bool Architecture::GetInstructionLowLevelILCallback(void* ctxt, const uint8_t* data, uint64_t addr,
- size_t* len, BNLowLevelILFunction* il)
+bool Architecture::GetInstructionLowLevelILCallback(
+ void* ctxt, const uint8_t* data, uint64_t addr, size_t* len, BNLowLevelILFunction* il)
{
Architecture* arch = (Architecture*)ctxt;
Ref<LowLevelILFunction> func(new LowLevelILFunction(BNNewLowLevelILFunctionReference(il)));
@@ -392,8 +398,8 @@ BNFlagRole Architecture::GetFlagRoleCallback(void* ctxt, uint32_t flag, uint32_t
}
-uint32_t* Architecture::GetFlagsRequiredForFlagConditionCallback(void* ctxt, BNLowLevelILFlagCondition cond,
- uint32_t semClass, size_t* count)
+uint32_t* Architecture::GetFlagsRequiredForFlagConditionCallback(
+ void* ctxt, BNLowLevelILFlagCondition cond, uint32_t semClass, size_t* count)
{
Architecture* arch = (Architecture*)ctxt;
vector<uint32_t> flags = arch->GetFlagsRequiredForFlagCondition(cond, semClass);
@@ -419,8 +425,8 @@ uint32_t* Architecture::GetFlagsRequiredForSemanticFlagGroupCallback(void* ctxt,
}
-BNFlagConditionForSemanticClass* Architecture::GetFlagConditionsForSemanticFlagGroupCallback(void* ctxt,
- uint32_t semGroup, size_t* count)
+BNFlagConditionForSemanticClass* Architecture::GetFlagConditionsForSemanticFlagGroupCallback(
+ void* ctxt, uint32_t semGroup, size_t* count)
{
Architecture* arch = (Architecture*)ctxt;
map<uint32_t, BNLowLevelILFlagCondition> conditions = arch->GetFlagConditionsForSemanticFlagGroup(semGroup);
@@ -464,8 +470,9 @@ uint32_t Architecture::GetSemanticClassForFlagWriteTypeCallback(void* ctxt, uint
}
-size_t Architecture::GetFlagWriteLowLevelILCallback(void* ctxt, BNLowLevelILOperation op, size_t size, uint32_t flagWriteType,
- uint32_t flag, BNRegisterOrConstant* operands, size_t operandCount, BNLowLevelILFunction* il)
+size_t Architecture::GetFlagWriteLowLevelILCallback(void* ctxt, BNLowLevelILOperation op, size_t size,
+ uint32_t flagWriteType, uint32_t flag, BNRegisterOrConstant* operands, size_t operandCount,
+ BNLowLevelILFunction* il)
{
Architecture* arch = (Architecture*)ctxt;
Ref<LowLevelILFunction> func(new LowLevelILFunction(BNNewLowLevelILFunctionReference(il)));
@@ -473,8 +480,8 @@ size_t Architecture::GetFlagWriteLowLevelILCallback(void* ctxt, BNLowLevelILOper
}
-size_t Architecture::GetFlagConditionLowLevelILCallback(void* ctxt, BNLowLevelILFlagCondition cond, uint32_t semClass,
- BNLowLevelILFunction* il)
+size_t Architecture::GetFlagConditionLowLevelILCallback(
+ void* ctxt, BNLowLevelILFlagCondition cond, uint32_t semClass, BNLowLevelILFunction* il)
{
Architecture* arch = (Architecture*)ctxt;
Ref<LowLevelILFunction> func(new LowLevelILFunction(BNNewLowLevelILFunctionReference(il)));
@@ -690,7 +697,8 @@ bool Architecture::IsSkipAndReturnZeroPatchAvailableCallback(void* ctxt, const u
}
-bool Architecture::IsSkipAndReturnValuePatchAvailableCallback(void* ctxt, const uint8_t* data, uint64_t addr, size_t len)
+bool Architecture::IsSkipAndReturnValuePatchAvailableCallback(
+ void* ctxt, const uint8_t* data, uint64_t addr, size_t len)
{
Architecture* arch = (Architecture*)ctxt;
return arch->IsSkipAndReturnValuePatchAvailable(data, addr, len);
@@ -990,31 +998,31 @@ uint32_t Architecture::GetSemanticClassForFlagWriteType(uint32_t)
size_t Architecture::GetFlagWriteLowLevelIL(BNLowLevelILOperation op, size_t size, uint32_t flagWriteType,
- uint32_t flag, BNRegisterOrConstant* operands, size_t operandCount,LowLevelILFunction& il)
+ uint32_t flag, BNRegisterOrConstant* operands, size_t operandCount, LowLevelILFunction& il)
{
BNFlagRole role = GetFlagRole(flag, GetSemanticClassForFlagWriteType(flagWriteType));
- return BNGetDefaultArchitectureFlagWriteLowLevelIL(m_object, op, size, role, operands,
- operandCount, il.GetObject());
+ return BNGetDefaultArchitectureFlagWriteLowLevelIL(
+ m_object, op, size, role, operands, operandCount, il.GetObject());
}
size_t Architecture::GetDefaultFlagWriteLowLevelIL(BNLowLevelILOperation op, size_t size, BNFlagRole role,
- BNRegisterOrConstant* operands, size_t operandCount,LowLevelILFunction& il)
+ BNRegisterOrConstant* operands, size_t operandCount, LowLevelILFunction& il)
{
- return BNGetDefaultArchitectureFlagWriteLowLevelIL(m_object, op, size, role, operands,
- operandCount, il.GetObject());
+ return BNGetDefaultArchitectureFlagWriteLowLevelIL(
+ m_object, op, size, role, operands, operandCount, il.GetObject());
}
-ExprId Architecture::GetFlagConditionLowLevelIL(BNLowLevelILFlagCondition cond,
- uint32_t semClass, LowLevelILFunction& il)
+ExprId Architecture::GetFlagConditionLowLevelIL(
+ BNLowLevelILFlagCondition cond, uint32_t semClass, LowLevelILFunction& il)
{
return BNGetDefaultArchitectureFlagConditionLowLevelIL(m_object, cond, semClass, il.GetObject());
}
-ExprId Architecture::GetDefaultFlagConditionLowLevelIL(BNLowLevelILFlagCondition cond,
- uint32_t semClass, LowLevelILFunction& il)
+ExprId Architecture::GetDefaultFlagConditionLowLevelIL(
+ BNLowLevelILFlagCondition cond, uint32_t semClass, LowLevelILFunction& il)
{
return BNGetDefaultArchitectureFlagConditionLowLevelIL(m_object, cond, semClass, il.GetObject());
}
@@ -1354,9 +1362,7 @@ void Architecture::AddArchitectureRedirection(Architecture* from, Architecture*
}
-CoreArchitecture::CoreArchitecture(BNArchitecture* arch): Architecture(arch)
-{
-}
+CoreArchitecture::CoreArchitecture(BNArchitecture* arch) : Architecture(arch) {}
BNEndianness CoreArchitecture::GetEndianness() const
@@ -1407,7 +1413,8 @@ bool CoreArchitecture::GetInstructionInfo(const uint8_t* data, uint64_t addr, si
}
-bool CoreArchitecture::GetInstructionText(const uint8_t* data, uint64_t addr, size_t& len, std::vector<InstructionTextToken>& result)
+bool CoreArchitecture::GetInstructionText(
+ const uint8_t* data, uint64_t addr, size_t& len, std::vector<InstructionTextToken>& result)
{
BNInstructionTextToken* tokens = nullptr;
size_t count = 0;
@@ -1596,8 +1603,8 @@ vector<uint32_t> CoreArchitecture::GetFlagsRequiredForSemanticFlagGroup(uint32_t
map<uint32_t, BNLowLevelILFlagCondition> CoreArchitecture::GetFlagConditionsForSemanticFlagGroup(uint32_t semGroup)
{
size_t count;
- BNFlagConditionForSemanticClass* conditions = BNGetArchitectureFlagConditionsForSemanticFlagGroup(m_object,
- semGroup, &count);
+ BNFlagConditionForSemanticClass* conditions =
+ BNGetArchitectureFlagConditionsForSemanticFlagGroup(m_object, semGroup, &count);
map<uint32_t, BNLowLevelILFlagCondition> result;
for (size_t i = 0; i < count; i++)
@@ -1630,15 +1637,15 @@ uint32_t CoreArchitecture::GetSemanticClassForFlagWriteType(uint32_t writeType)
size_t CoreArchitecture::GetFlagWriteLowLevelIL(BNLowLevelILOperation op, size_t size, uint32_t flagWriteType,
- uint32_t flag, BNRegisterOrConstant* operands, size_t operandCount, LowLevelILFunction& il)
+ uint32_t flag, BNRegisterOrConstant* operands, size_t operandCount, LowLevelILFunction& il)
{
- return BNGetArchitectureFlagWriteLowLevelIL(m_object, op, size, flagWriteType, flag, operands,
- operandCount, il.GetObject());
+ return BNGetArchitectureFlagWriteLowLevelIL(
+ m_object, op, size, flagWriteType, flag, operands, operandCount, il.GetObject());
}
-ExprId CoreArchitecture::GetFlagConditionLowLevelIL(BNLowLevelILFlagCondition cond,
- uint32_t semClass, LowLevelILFunction& il)
+ExprId CoreArchitecture::GetFlagConditionLowLevelIL(
+ BNLowLevelILFlagCondition cond, uint32_t semClass, LowLevelILFunction& il)
{
return (ExprId)BNGetArchitectureFlagConditionLowLevelIL(m_object, cond, semClass, il.GetObject());
}
@@ -1758,8 +1765,8 @@ vector<NameAndType> CoreArchitecture::GetIntrinsicInputs(uint32_t intrinsic)
vector<NameAndType> result;
for (size_t i = 0; i < count; i++)
{
- result.push_back(NameAndType(inputs[i].name, Confidence<Ref<Type>>(
- new Type(BNNewTypeReference(inputs[i].type)), inputs[i].typeConfidence)));
+ result.push_back(NameAndType(inputs[i].name,
+ Confidence<Ref<Type>>(new Type(BNNewTypeReference(inputs[i].type)), inputs[i].typeConfidence)));
}
BNFreeNameAndTypeList(inputs, count);
@@ -1852,9 +1859,8 @@ bool CoreArchitecture::SkipAndReturnValue(uint8_t* data, uint64_t addr, size_t l
}
-ArchitectureExtension::ArchitectureExtension(const string& name, Architecture* base): Architecture(name), m_base(base)
-{
-}
+ArchitectureExtension::ArchitectureExtension(const string& name, Architecture* base) : Architecture(name), m_base(base)
+{}
void ArchitectureExtension::Register(BNCustomArchitecture* callbacks)
@@ -1909,20 +1915,22 @@ Ref<Architecture> ArchitectureExtension::GetAssociatedArchitectureByAddress(uint
}
-bool ArchitectureExtension::GetInstructionInfo(const uint8_t* data, uint64_t addr, size_t maxLen, InstructionInfo& result)
+bool ArchitectureExtension::GetInstructionInfo(
+ const uint8_t* data, uint64_t addr, size_t maxLen, InstructionInfo& result)
{
return m_base->GetInstructionInfo(data, addr, maxLen, result);
}
-bool ArchitectureExtension::GetInstructionText(const uint8_t* data, uint64_t addr, size_t& len,
- vector<InstructionTextToken>& result)
+bool ArchitectureExtension::GetInstructionText(
+ const uint8_t* data, uint64_t addr, size_t& len, vector<InstructionTextToken>& result)
{
return m_base->GetInstructionText(data, addr, len, result);
}
-bool ArchitectureExtension::GetInstructionLowLevelIL(const uint8_t* data, uint64_t addr, size_t& len, LowLevelILFunction& il)
+bool ArchitectureExtension::GetInstructionLowLevelIL(
+ const uint8_t* data, uint64_t addr, size_t& len, LowLevelILFunction& il)
{
return m_base->GetInstructionLowLevelIL(data, addr, len, il);
}
@@ -2000,8 +2008,8 @@ BNFlagRole ArchitectureExtension::GetFlagRole(uint32_t flag, uint32_t semClass)
}
-vector<uint32_t> ArchitectureExtension::GetFlagsRequiredForFlagCondition(BNLowLevelILFlagCondition cond,
- uint32_t semClass)
+vector<uint32_t> ArchitectureExtension::GetFlagsRequiredForFlagCondition(
+ BNLowLevelILFlagCondition cond, uint32_t semClass)
{
return m_base->GetFlagsRequiredForFlagCondition(cond, semClass);
}
@@ -2032,14 +2040,14 @@ uint32_t ArchitectureExtension::GetSemanticClassForFlagWriteType(uint32_t writeT
ExprId ArchitectureExtension::GetFlagWriteLowLevelIL(BNLowLevelILOperation op, size_t size, uint32_t flagWriteType,
- uint32_t flag, BNRegisterOrConstant* operands, size_t operandCount, LowLevelILFunction& il)
+ uint32_t flag, BNRegisterOrConstant* operands, size_t operandCount, LowLevelILFunction& il)
{
return m_base->GetFlagWriteLowLevelIL(op, size, flagWriteType, flag, operands, operandCount, il);
}
-ExprId ArchitectureExtension::GetFlagConditionLowLevelIL(BNLowLevelILFlagCondition cond,
- uint32_t semClass, LowLevelILFunction& il)
+ExprId ArchitectureExtension::GetFlagConditionLowLevelIL(
+ BNLowLevelILFlagCondition cond, uint32_t semClass, LowLevelILFunction& il)
{
return m_base->GetFlagConditionLowLevelIL(cond, semClass, il);
}
@@ -2187,7 +2195,7 @@ bool ArchitectureExtension::SkipAndReturnValue(uint8_t* data, uint64_t addr, siz
}
-ArchitectureHook::ArchitectureHook(Architecture* base): CoreArchitecture(nullptr), m_base(base)
+ArchitectureHook::ArchitectureHook(Architecture* base) : CoreArchitecture(nullptr), m_base(base)
{
// Architecture hooks allow existing architecture implementations to be extended without creating
// a new Architecture object for the changes. By deriving from the ArchitectureHook class and passing
@@ -2225,8 +2233,8 @@ void ArchitectureHook::Register(BNCustomArchitecture* callbacks)
}
-string DisassemblyTextRenderer::GetDisplayStringForInteger(Ref<BinaryView> binaryView, BNIntegerDisplayType type,
- uint64_t value, size_t inputWidth, bool isSigned)
+string DisassemblyTextRenderer::GetDisplayStringForInteger(
+ Ref<BinaryView> binaryView, BNIntegerDisplayType type, uint64_t value, size_t inputWidth, bool isSigned)
{
char* str = BNGetDisplayStringForInteger(binaryView->GetObject(), type, value, inputWidth, isSigned);
string s(str);
@@ -2249,13 +2257,15 @@ DisassemblyTextRenderer::DisassemblyTextRenderer(LowLevelILFunction* func, Disas
DisassemblyTextRenderer::DisassemblyTextRenderer(MediumLevelILFunction* func, DisassemblySettings* settings)
{
- m_object = BNCreateMediumLevelILDisassemblyTextRenderer(func->GetObject(), settings ? settings->GetObject() : nullptr);
+ m_object =
+ BNCreateMediumLevelILDisassemblyTextRenderer(func->GetObject(), settings ? settings->GetObject() : nullptr);
}
DisassemblyTextRenderer::DisassemblyTextRenderer(HighLevelILFunction* func, DisassemblySettings* settings)
{
- m_object = BNCreateHighLevelILDisassemblyTextRenderer(func->GetObject(), settings ? settings->GetObject() : nullptr);
+ m_object =
+ BNCreateHighLevelILDisassemblyTextRenderer(func->GetObject(), settings ? settings->GetObject() : nullptr);
}
@@ -2359,8 +2369,7 @@ void DisassemblyTextRenderer::GetInstructionAnnotations(vector<InstructionTextTo
}
-bool DisassemblyTextRenderer::GetInstructionText(uint64_t addr, size_t& len,
- vector<DisassemblyTextLine>& lines)
+bool DisassemblyTextRenderer::GetInstructionText(uint64_t addr, size_t& len, vector<DisassemblyTextLine>& lines)
{
BNDisassemblyTextLine* result = nullptr;
size_t count = 0;
@@ -2383,8 +2392,8 @@ bool DisassemblyTextRenderer::GetInstructionText(uint64_t addr, size_t& len,
}
-vector<DisassemblyTextLine> DisassemblyTextRenderer::PostProcessInstructionTextLines(uint64_t addr,
- size_t len, const vector<DisassemblyTextLine>& lines, const string& indentSpaces)
+vector<DisassemblyTextLine> DisassemblyTextRenderer::PostProcessInstructionTextLines(
+ uint64_t addr, size_t len, const vector<DisassemblyTextLine>& lines, const string& indentSpaces)
{
BNDisassemblyTextLine* inLines = new BNDisassemblyTextLine[lines.size()];
for (size_t i = 0; i < lines.size(); i++)
@@ -2399,8 +2408,8 @@ vector<DisassemblyTextLine> DisassemblyTextRenderer::PostProcessInstructionTextL
BNDisassemblyTextLine* result = nullptr;
size_t count = 0;
- result = BNPostProcessDisassemblyTextRendererLines(m_object, addr, len, inLines, lines.size(), &count,
- indentSpaces.c_str());
+ result = BNPostProcessDisassemblyTextRendererLines(
+ m_object, addr, len, inLines, lines.size(), &count, indentSpaces.c_str());
BNFreeDisassemblyTextLines(inLines, lines.size());
vector<DisassemblyTextLine> outLines;
@@ -2449,20 +2458,22 @@ void DisassemblyTextRenderer::ResetDeduplicatedComments()
}
-bool DisassemblyTextRenderer::AddSymbolToken(vector<InstructionTextToken>& tokens, uint64_t addr, size_t size, size_t operand)
+bool DisassemblyTextRenderer::AddSymbolToken(
+ vector<InstructionTextToken>& tokens, uint64_t addr, size_t size, size_t operand)
{
BNInstructionTextToken* result = nullptr;
size_t count = 0;
if (!BNGetDisassemblyTextRendererSymbolTokens(m_object, addr, size, operand, &result, &count))
return false;
- vector<InstructionTextToken> newTokens = InstructionTextToken::ConvertAndFreeInstructionTextTokenList(result, count);
+ vector<InstructionTextToken> newTokens =
+ InstructionTextToken::ConvertAndFreeInstructionTextTokenList(result, count);
tokens.insert(tokens.end(), newTokens.begin(), newTokens.end());
return true;
}
-void DisassemblyTextRenderer::AddStackVariableReferenceTokens(vector<InstructionTextToken>& tokens,
- const StackVariableReference& ref)
+void DisassemblyTextRenderer::AddStackVariableReferenceTokens(
+ vector<InstructionTextToken>& tokens, const StackVariableReference& ref)
{
BNStackVariableReference stackRef;
stackRef.sourceOperand = ref.sourceOperand;
@@ -2474,11 +2485,12 @@ void DisassemblyTextRenderer::AddStackVariableReferenceTokens(vector<Instruction
stackRef.size = ref.size;
size_t count = 0;
- BNInstructionTextToken* result = BNGetDisassemblyTextRendererStackVariableReferenceTokens(
- m_object, &stackRef, &count);
+ BNInstructionTextToken* result =
+ BNGetDisassemblyTextRendererStackVariableReferenceTokens(m_object, &stackRef, &count);
BNFreeString(stackRef.name);
- vector<InstructionTextToken> newTokens = InstructionTextToken::ConvertAndFreeInstructionTextTokenList(result, count);
+ vector<InstructionTextToken> newTokens =
+ InstructionTextToken::ConvertAndFreeInstructionTextTokenList(result, count);
tokens.insert(tokens.end(), newTokens.begin(), newTokens.end());
}
@@ -2489,17 +2501,18 @@ bool DisassemblyTextRenderer::IsIntegerToken(BNInstructionTextTokenType type)
}
-void DisassemblyTextRenderer::AddIntegerToken(vector<InstructionTextToken>& tokens, const InstructionTextToken& token,
- Architecture* arch, uint64_t addr)
+void DisassemblyTextRenderer::AddIntegerToken(
+ vector<InstructionTextToken>& tokens, const InstructionTextToken& token, Architecture* arch, uint64_t addr)
{
BNInstructionTextToken inToken;
ConvertInstructionTextToken(token, &inToken);
size_t count = 0;
- BNInstructionTextToken* result = BNGetDisassemblyTextRendererIntegerTokens(m_object, &inToken,
- arch ? arch->GetObject() : nullptr, addr, &count);
+ BNInstructionTextToken* result =
+ BNGetDisassemblyTextRendererIntegerTokens(m_object, &inToken, arch ? arch->GetObject() : nullptr, addr, &count);
- vector<InstructionTextToken> newTokens = InstructionTextToken::ConvertAndFreeInstructionTextTokenList(result, count);
+ vector<InstructionTextToken> newTokens =
+ InstructionTextToken::ConvertAndFreeInstructionTextTokenList(result, count);
tokens.insert(tokens.end(), newTokens.begin(), newTokens.end());
BNFreeString(inToken.text);
@@ -2510,7 +2523,7 @@ void DisassemblyTextRenderer::AddIntegerToken(vector<InstructionTextToken>& toke
void DisassemblyTextRenderer::WrapComment(DisassemblyTextLine& line, vector<DisassemblyTextLine>& lines,
- const string& comment, bool hasAutoAnnotations, const string& leadingSpaces, const string& indentSpaces)
+ const string& comment, bool hasAutoAnnotations, const string& leadingSpaces, const string& indentSpaces)
{
BNDisassemblyTextLine inLine;
inLine.addr = line.addr;
@@ -2521,8 +2534,8 @@ void DisassemblyTextRenderer::WrapComment(DisassemblyTextLine& line, vector<Disa
inLine.tags = Tag::CreateTagList(line.tags, &inLine.tagCount);
size_t count = 0;
- BNDisassemblyTextLine* result = BNDisassemblyTextRendererWrapComment(m_object, &inLine, &count,
- comment.c_str(), hasAutoAnnotations, leadingSpaces.c_str(), indentSpaces.c_str());
+ BNDisassemblyTextLine* result = BNDisassemblyTextRendererWrapComment(
+ m_object, &inLine, &count, comment.c_str(), hasAutoAnnotations, leadingSpaces.c_str(), indentSpaces.c_str());
for (size_t i = 0; i < count; i++)
{
diff --git a/basicblock.cpp b/basicblock.cpp
index 2072faa9..eb41474d 100644
--- a/basicblock.cpp
+++ b/basicblock.cpp
@@ -354,8 +354,8 @@ void BasicBlock::SetAutoBasicBlockHighlight(BNHighlightStandardColor color, uint
}
-void BasicBlock::SetAutoBasicBlockHighlight(BNHighlightStandardColor color, BNHighlightStandardColor mixColor,
- uint8_t mix, uint8_t alpha)
+void BasicBlock::SetAutoBasicBlockHighlight(
+ BNHighlightStandardColor color, BNHighlightStandardColor mixColor, uint8_t mix, uint8_t alpha)
{
BNHighlightColor hc;
hc.style = MixedHighlightColor;
@@ -406,8 +406,8 @@ void BasicBlock::SetUserBasicBlockHighlight(BNHighlightStandardColor color, uint
}
-void BasicBlock::SetUserBasicBlockHighlight(BNHighlightStandardColor color, BNHighlightStandardColor mixColor,
- uint8_t mix, uint8_t alpha)
+void BasicBlock::SetUserBasicBlockHighlight(
+ BNHighlightStandardColor color, BNHighlightStandardColor mixColor, uint8_t mix, uint8_t alpha)
{
BNHighlightColor hc;
hc.style = MixedHighlightColor;
diff --git a/binaryninjaapi.cpp b/binaryninjaapi.cpp
index b5a0f52c..610cb494 100644
--- a/binaryninjaapi.cpp
+++ b/binaryninjaapi.cpp
@@ -173,7 +173,7 @@ string BinaryNinja::GetPathRelativeToUserDirectory(const string& rel)
bool BinaryNinja::ExecuteWorkerProcess(const string& path, const vector<string>& args, const DataBuffer& input,
- string& output, string& errors, bool stdoutIsText, bool stderrIsText)
+ string& output, string& errors, bool stdoutIsText, bool stderrIsText)
{
const char** argArray = new const char*[args.size() + 1];
for (size_t i = 0; i < args.size(); i++)
@@ -182,8 +182,8 @@ bool BinaryNinja::ExecuteWorkerProcess(const string& path, const vector<string>&
char* outputStr;
char* errorStr;
- bool result = BNExecuteWorkerProcess(path.c_str(), argArray, input.GetBufferObject(), &outputStr, &errorStr,
- stdoutIsText, stderrIsText);
+ bool result = BNExecuteWorkerProcess(
+ path.c_str(), argArray, input.GetBufferObject(), &outputStr, &errorStr, stdoutIsText, stderrIsText);
output = outputStr;
errors = errorStr;
@@ -301,9 +301,7 @@ void BinaryNinja::WorkerEnqueue(RefCountObject* owner, const function<void()>& a
context.owner = owner;
context.func = action;
- WorkerEnqueue([=]() {
- context.func();
- });
+ WorkerEnqueue([=]() { context.func(); });
}
@@ -325,9 +323,7 @@ void BinaryNinja::WorkerPriorityEnqueue(RefCountObject* owner, const function<vo
context.owner = owner;
context.func = action;
- WorkerPriorityEnqueue([=]() {
- context.func();
- });
+ WorkerPriorityEnqueue([=]() { context.func(); });
}
@@ -349,9 +345,7 @@ void BinaryNinja::WorkerInteractiveEnqueue(RefCountObject* owner, const function
context.owner = owner;
context.func = action;
- WorkerInteractiveEnqueue([=]() {
- context.func();
- });
+ WorkerInteractiveEnqueue([=]() { context.func(); });
}
@@ -389,23 +383,27 @@ map<string, uint64_t> BinaryNinja::GetMemoryUsageInfo()
}
-std::function<bool(size_t, size_t)>
-BinaryNinja::SplitProgress(std::function<bool(size_t, size_t)> originalFn, size_t subpart, size_t subpartCount)
+std::function<bool(size_t, size_t)> BinaryNinja::SplitProgress(
+ std::function<bool(size_t, size_t)> originalFn, size_t subpart, size_t subpartCount)
{
return SplitProgress(originalFn, subpart, std::vector<double>(subpartCount, 1.0 / (double)subpartCount));
}
-std::function<bool(size_t, size_t)>
-BinaryNinja::SplitProgress(std::function<bool(size_t, size_t)> originalFn, size_t subpart, std::vector<double> subpartWeights)
+std::function<bool(size_t, size_t)> BinaryNinja::SplitProgress(
+ std::function<bool(size_t, size_t)> originalFn, size_t subpart, std::vector<double> subpartWeights)
{
if (!originalFn)
- return [](size_t, size_t){ return true; };
+ return [](size_t, size_t) {
+ return true;
+ };
// Normalize weights
double weightSum = std::accumulate(subpartWeights.begin(), subpartWeights.end(), 0.0);
if (weightSum < 0.0001f)
- return [](size_t, size_t){ return true; };
+ return [](size_t, size_t) {
+ return true;
+ };
// Keep a running count of weights for the start
std::vector<double> subpartStarts;
double start = 0.0;
diff --git a/binaryninjaapi.h b/binaryninjaapi.h
index 5fcebda9..2643e0a3 100644
--- a/binaryninjaapi.h
+++ b/binaryninjaapi.h
@@ -20,8 +20,8 @@
#pragma once
#ifdef WIN32
-#define NOMINMAX
-#include <windows.h>
+ #define NOMINMAX
+ #include <windows.h>
#endif
#include <stddef.h>
#include <string>
@@ -42,30 +42,26 @@
#include "json/json.h"
#ifdef _MSC_VER
-#define NOEXCEPT
+ #define NOEXCEPT
#else
-#define NOEXCEPT noexcept
+ #define NOEXCEPT noexcept
#endif
//#define BN_REF_COUNT_DEBUG // Mac OS X only, prints stack trace of leaked references
-namespace BinaryNinja
-{
+namespace BinaryNinja {
class RefCountObject
{
- public:
+ public:
std::atomic<int> m_refs;
- RefCountObject(): m_refs(0) {}
+ RefCountObject() : m_refs(0) {}
virtual ~RefCountObject() {}
RefCountObject* GetObject() { return this; }
static RefCountObject* GetObject(RefCountObject* obj) { return obj; }
- void AddRef()
- {
- m_refs.fetch_add(1);
- }
+ void AddRef() { m_refs.fetch_add(1); }
void Release()
{
@@ -77,10 +73,7 @@ namespace BinaryNinja
template <class T, T* (*AddObjectReference)(T*), void (*FreeObjectReference)(T*)>
class CoreRefCountObject
{
- void AddRefInternal()
- {
- m_refs.fetch_add(1);
- }
+ void AddRefInternal() { m_refs.fetch_add(1); }
void ReleaseInternal()
{
@@ -91,11 +84,11 @@ namespace BinaryNinja
}
}
- public:
+ public:
std::atomic<int> m_refs;
bool m_registeredRef = false;
T* m_object;
- CoreRefCountObject(): m_refs(0), m_object(nullptr) {}
+ CoreRefCountObject() : m_refs(0), m_object(nullptr) {}
virtual ~CoreRefCountObject() {}
T* GetObject() const { return m_object; }
@@ -121,10 +114,7 @@ namespace BinaryNinja
ReleaseInternal();
}
- void AddRefForRegistration()
- {
- m_registeredRef = true;
- }
+ void AddRefForRegistration() { m_registeredRef = true; }
void ReleaseForRegistration()
{
@@ -138,10 +128,7 @@ namespace BinaryNinja
template <class T>
class StaticCoreRefCountObject
{
- void AddRefInternal()
- {
- m_refs.fetch_add(1);
- }
+ void AddRefInternal() { m_refs.fetch_add(1); }
void ReleaseInternal()
{
@@ -149,10 +136,10 @@ namespace BinaryNinja
delete this;
}
- public:
+ public:
std::atomic<int> m_refs;
T* m_object;
- StaticCoreRefCountObject(): m_refs(0), m_object(nullptr) {}
+ StaticCoreRefCountObject() : m_refs(0), m_object(nullptr) {}
virtual ~StaticCoreRefCountObject() {}
T* GetObject() const { return m_object; }
@@ -164,20 +151,11 @@ namespace BinaryNinja
return obj->GetObject();
}
- void AddRef()
- {
- AddRefInternal();
- }
+ void AddRef() { AddRefInternal(); }
- void Release()
- {
- ReleaseInternal();
- }
+ void Release() { ReleaseInternal(); }
- void AddRefForRegistration()
- {
- AddRefInternal();
- }
+ void AddRefForRegistration() { AddRefInternal(); }
};
template <class T>
@@ -188,12 +166,10 @@ namespace BinaryNinja
void* m_assignmentTrace = nullptr;
#endif
- public:
- Ref<T>(): m_obj(NULL)
- {
- }
+ public:
+ Ref<T>() : m_obj(NULL) {}
- Ref<T>(T* obj): m_obj(obj)
+ Ref<T>(T* obj) : m_obj(obj)
{
if (m_obj)
{
@@ -204,7 +180,7 @@ namespace BinaryNinja
}
}
- Ref<T>(const Ref<T>& obj): m_obj(obj.m_obj)
+ Ref<T>(const Ref<T>& obj) : m_obj(obj.m_obj)
{
if (m_obj)
{
@@ -285,81 +261,43 @@ namespace BinaryNinja
return *this;
}
- operator T*() const
- {
- return m_obj;
- }
+ operator T*() const { return m_obj; }
- T* operator->() const
- {
- return m_obj;
- }
+ T* operator->() const { return m_obj; }
- T& operator*() const
- {
- return *m_obj;
- }
+ T& operator*() const { return *m_obj; }
- bool operator!() const
- {
- return m_obj == NULL;
- }
+ bool operator!() const { return m_obj == NULL; }
- bool operator==(const T* obj) const
- {
- return T::GetObject(m_obj) == T::GetObject(obj);
- }
+ bool operator==(const T* obj) const { return T::GetObject(m_obj) == T::GetObject(obj); }
- bool operator==(const Ref<T>& obj) const
- {
- return T::GetObject(m_obj) == T::GetObject(obj.m_obj);
- }
+ bool operator==(const Ref<T>& obj) const { return T::GetObject(m_obj) == T::GetObject(obj.m_obj); }
- bool operator!=(const T* obj) const
- {
- return T::GetObject(m_obj) != T::GetObject(obj);
- }
+ bool operator!=(const T* obj) const { return T::GetObject(m_obj) != T::GetObject(obj); }
- bool operator!=(const Ref<T>& obj) const
- {
- return T::GetObject(m_obj) != T::GetObject(obj.m_obj);
- }
+ bool operator!=(const Ref<T>& obj) const { return T::GetObject(m_obj) != T::GetObject(obj.m_obj); }
- bool operator<(const T* obj) const
- {
- return T::GetObject(m_obj) < T::GetObject(obj);
- }
+ bool operator<(const T* obj) const { return T::GetObject(m_obj) < T::GetObject(obj); }
- bool operator<(const Ref<T>& obj) const
- {
- return T::GetObject(m_obj) < T::GetObject(obj.m_obj);
- }
+ bool operator<(const Ref<T>& obj) const { return T::GetObject(m_obj) < T::GetObject(obj.m_obj); }
- T* GetPtr() const
- {
- return m_obj;
- }
+ T* GetPtr() const { return m_obj; }
};
class ConfidenceBase
{
- protected:
+ protected:
uint8_t m_confidence;
- public:
- ConfidenceBase(): m_confidence(0)
- {
- }
+ public:
+ ConfidenceBase() : m_confidence(0) {}
- ConfidenceBase(uint8_t conf): m_confidence(conf)
- {
- }
+ ConfidenceBase(uint8_t conf) : m_confidence(conf) {}
static uint8_t Combine(uint8_t a, uint8_t b)
{
uint8_t result = (uint8_t)(((uint32_t)a * (uint32_t)b) / BN_FULL_CONFIDENCE);
- if ((a >= BN_MINIMUM_CONFIDENCE) && (b >= BN_MINIMUM_CONFIDENCE) &&
- (result < BN_MINIMUM_CONFIDENCE))
+ if ((a >= BN_MINIMUM_CONFIDENCE) && (b >= BN_MINIMUM_CONFIDENCE) && (result < BN_MINIMUM_CONFIDENCE))
result = BN_MINIMUM_CONFIDENCE;
return result;
}
@@ -371,26 +309,18 @@ namespace BinaryNinja
};
template <class T>
- class Confidence: public ConfidenceBase
+ class Confidence : public ConfidenceBase
{
T m_value;
- public:
- Confidence()
- {
- }
+ public:
+ Confidence() {}
- Confidence(const T& value): ConfidenceBase(BN_FULL_CONFIDENCE), m_value(value)
- {
- }
+ Confidence(const T& value) : ConfidenceBase(BN_FULL_CONFIDENCE), m_value(value) {}
- Confidence(const T& value, uint8_t conf): ConfidenceBase(conf), m_value(value)
- {
- }
+ Confidence(const T& value, uint8_t conf) : ConfidenceBase(conf), m_value(value) {}
- Confidence(const Confidence<T>& v): ConfidenceBase(v.m_confidence), m_value(v.m_value)
- {
- }
+ Confidence(const Confidence<T>& v) : ConfidenceBase(v.m_confidence), m_value(v.m_value) {}
operator T() const { return m_value; }
T* operator->() { return &m_value; }
@@ -434,41 +364,26 @@ namespace BinaryNinja
return m_confidence == a.m_confidence;
}
- bool operator!=(const Confidence<T>& a) const
- {
- return !(*this == a);
- }
+ bool operator!=(const Confidence<T>& a) const { return !(*this == a); }
};
template <class T>
- class Confidence<Ref<T>>: public ConfidenceBase
+ class Confidence<Ref<T>> : public ConfidenceBase
{
Ref<T> m_value;
- public:
- Confidence()
- {
- }
+ public:
+ Confidence() {}
- Confidence(T* value): ConfidenceBase(value ? BN_FULL_CONFIDENCE : 0), m_value(value)
- {
- }
+ Confidence(T* value) : ConfidenceBase(value ? BN_FULL_CONFIDENCE : 0), m_value(value) {}
- Confidence(T* value, uint8_t conf): ConfidenceBase(conf), m_value(value)
- {
- }
+ Confidence(T* value, uint8_t conf) : ConfidenceBase(conf), m_value(value) {}
- Confidence(const Ref<T>& value): ConfidenceBase(value ? BN_FULL_CONFIDENCE : 0), m_value(value)
- {
- }
+ Confidence(const Ref<T>& value) : ConfidenceBase(value ? BN_FULL_CONFIDENCE : 0), m_value(value) {}
- Confidence(const Ref<T>& value, uint8_t conf): ConfidenceBase(conf), m_value(value)
- {
- }
+ Confidence(const Ref<T>& value, uint8_t conf) : ConfidenceBase(conf), m_value(value) {}
- Confidence(const Confidence<Ref<T>>& v): ConfidenceBase(v.m_confidence), m_value(v.m_value)
- {
- }
+ Confidence(const Confidence<Ref<T>>& v) : ConfidenceBase(v.m_confidence), m_value(v.m_value) {}
operator Ref<T>() const { return m_value; }
operator T*() const { return m_value.GetPtr(); }
@@ -516,10 +431,7 @@ namespace BinaryNinja
return m_confidence == a.m_confidence;
}
- bool operator!=(const Confidence<Ref<T>>& a) const
- {
- return !(*this == a);
- }
+ bool operator!=(const Confidence<Ref<T>>& a) const { return !(*this == a); }
};
class LogListener
@@ -528,7 +440,7 @@ namespace BinaryNinja
static void CloseLogCallback(void* ctxt);
static BNLogLevel GetLogLevelCallback(void* ctxt);
- public:
+ public:
virtual ~LogListener() {}
static void RegisterLogListener(LogListener* listener);
@@ -557,67 +469,67 @@ namespace BinaryNinja
/*! Logs to the error console with the given BNLogLevel.
- \param level BNLogLevel debug log level
- \param fmt C-style format string.
- \param ... Variable arguments corresponding to the format string.
+ \param level BNLogLevel debug log level
+ \param fmt C-style format string.
+ \param ... Variable arguments corresponding to the format string.
*/
#ifdef __GNUC__
- __attribute__ ((format (printf, 2, 3)))
+ __attribute__((format(printf, 2, 3)))
#endif
void Log(BNLogLevel level, const char* fmt, ...);
/*! LogDebug only writes text to the error console if the console is set to log level: DebugLog
- Log level DebugLog is the most verbose logging level.
+ Log level DebugLog is the most verbose logging level.
- \param fmt C-style format string.
- \param ... Variable arguments corresponding to the format string.
+ \param fmt C-style format string.
+ \param ... Variable arguments corresponding to the format string.
*/
#ifdef __GNUC__
-__attribute__ ((format (printf, 1, 2)))
+ __attribute__((format(printf, 1, 2)))
#endif
void LogDebug(const char* fmt, ...);
/*! LogInfo always writes text to the error console, and corresponds to the log level: InfoLog.
- Log level InfoLog is the second most verbose logging level.
+ Log level InfoLog is the second most verbose logging level.
- \param fmt C-style format string.
- \param ... Variable arguments corresponding to the format string.
+ \param fmt C-style format string.
+ \param ... Variable arguments corresponding to the format string.
*/
#ifdef __GNUC__
-__attribute__ ((format (printf, 1, 2)))
+ __attribute__((format(printf, 1, 2)))
#endif
void LogInfo(const char* fmt, ...);
/*! LogWarn writes text to the error console including a warning icon,
- and also shows a warning icon in the bottom pane. LogWarn corresponds to the log level: WarningLog.
+ and also shows a warning icon in the bottom pane. LogWarn corresponds to the log level: WarningLog.
- \param fmt C-style format string.
- \param ... Variable arguments corresponding to the format string.
+ \param fmt C-style format string.
+ \param ... Variable arguments corresponding to the format string.
*/
#ifdef __GNUC__
-__attribute__ ((format (printf, 1, 2)))
+ __attribute__((format(printf, 1, 2)))
#endif
void LogWarn(const char* fmt, ...);
/*! LogError writes text to the error console and pops up the error console. Additionall,
- Errors in the console log include a error icon. LogError corresponds to the log level: ErrorLog.
+ Errors in the console log include a error icon. LogError corresponds to the log level: ErrorLog.
- \param fmt C-style format string.
- \param ... Variable arguments corresponding to the format string.
+ \param fmt C-style format string.
+ \param ... Variable arguments corresponding to the format string.
*/
#ifdef __GNUC__
-__attribute__ ((format (printf, 1, 2)))
+ __attribute__((format(printf, 1, 2)))
#endif
void LogError(const char* fmt, ...);
/*! LogAlert pops up a message box displaying the alert message and logs to the error console.
- LogAlert corresponds to the log level: AlertLog.
+ LogAlert corresponds to the log level: AlertLog.
- \param fmt C-style format string.
- \param ... Variable arguments corresponding to the format string.
+ \param fmt C-style format string.
+ \param ... Variable arguments corresponding to the format string.
*/
#ifdef __GNUC__
-__attribute__ ((format (printf, 1, 2)))
+ __attribute__((format(printf, 1, 2)))
#endif
void LogAlert(const char* fmt, ...);
@@ -629,15 +541,14 @@ __attribute__ ((format (printf, 1, 2)))
std::string EscapeString(const std::string& s);
std::string UnescapeString(const std::string& s);
- bool PreprocessSource(const std::string& source, const std::string& fileName,
- std::string& output, std::string& errors,
- const std::vector<std::string>& includeDirs = std::vector<std::string>());
+ bool PreprocessSource(const std::string& source, const std::string& fileName, std::string& output,
+ std::string& errors, const std::vector<std::string>& includeDirs = std::vector<std::string>());
void DisablePlugins();
bool IsPluginsEnabled();
bool InitPlugins(bool allowUserPlugins = true);
- void InitCorePlugins(); // Deprecated, use InitPlugins
- void InitUserPlugins(); // Deprecated, use InitPlugins
+ void InitCorePlugins(); // Deprecated, use InitPlugins
+ void InitUserPlugins(); // Deprecated, use InitPlugins
void InitRepoPlugins();
std::string GetBundledPluginDirectory();
@@ -654,7 +565,7 @@ __attribute__ ((format (printf, 1, 2)))
std::string GetPathRelativeToUserDirectory(const std::string& path);
bool ExecuteWorkerProcess(const std::string& path, const std::vector<std::string>& args, const DataBuffer& input,
- std::string& output, std::string& errors, bool stdoutIsText=false, bool stderrIsText=true);
+ std::string& output, std::string& errors, bool stdoutIsText = false, bool stderrIsText = true);
std::string GetVersionString();
std::string GetLicensedUserEmail();
@@ -679,14 +590,14 @@ __attribute__ ((format (printf, 1, 2)))
class BinaryView;
- bool DemangleMS(Architecture* arch, const std::string& mangledName, Type** outType,
- QualifiedName& outVarName, const bool simplify = false);
- bool DemangleMS(Architecture* arch, const std::string& mangledName, Type** outType,
- QualifiedName& outVarName, const Ref<BinaryView>& view);
- bool DemangleGNU3(Ref<Architecture> arch, const std::string& mangledName, Type** outType,
- QualifiedName& outVarName, const bool simplify = false);
- bool DemangleGNU3(Ref<Architecture> arch, const std::string& mangledName, Type** outType,
- QualifiedName& outVarName, const Ref<BinaryView>& view);
+ bool DemangleMS(Architecture* arch, const std::string& mangledName, Type** outType, QualifiedName& outVarName,
+ const bool simplify = false);
+ bool DemangleMS(Architecture* arch, const std::string& mangledName, Type** outType, QualifiedName& outVarName,
+ const Ref<BinaryView>& view);
+ bool DemangleGNU3(Ref<Architecture> arch, const std::string& mangledName, Type** outType, QualifiedName& outVarName,
+ const bool simplify = false);
+ bool DemangleGNU3(Ref<Architecture> arch, const std::string& mangledName, Type** outType, QualifiedName& outVarName,
+ const Ref<BinaryView>& view);
void RegisterMainThread(MainThreadActionHandler* handler);
Ref<MainThreadAction> ExecuteOnMainThread(const std::function<void()>& action);
@@ -708,26 +619,24 @@ __attribute__ ((format (printf, 1, 2)))
void RegisterInteractionHandler(InteractionHandler* handler);
void ShowPlainTextReport(const std::string& title, const std::string& contents);
- void ShowMarkdownReport(const std::string& title, const std::string& contents,
- const std::string& plainText = "");
- void ShowHTMLReport(const std::string& title, const std::string& contents,
- const std::string& plainText = "");
+ void ShowMarkdownReport(const std::string& title, const std::string& contents, const std::string& plainText = "");
+ void ShowHTMLReport(const std::string& title, const std::string& contents, const std::string& plainText = "");
void ShowGraphReport(const std::string& title, FlowGraph* graph);
void ShowReportCollection(const std::string& title, ReportCollection* reports);
bool GetTextLineInput(std::string& result, const std::string& prompt, const std::string& title);
bool GetIntegerInput(int64_t& result, const std::string& prompt, const std::string& title);
bool GetAddressInput(uint64_t& result, const std::string& prompt, const std::string& title);
- bool GetChoiceInput(size_t& idx, const std::string& prompt, const std::string& title,
- const std::vector<std::string>& choices);
+ bool GetChoiceInput(
+ size_t& idx, const std::string& prompt, const std::string& title, const std::vector<std::string>& choices);
bool GetOpenFileNameInput(std::string& result, const std::string& prompt, const std::string& ext = "");
bool GetSaveFileNameInput(std::string& result, const std::string& prompt, const std::string& ext = "",
- const std::string& defaultName = "");
+ const std::string& defaultName = "");
bool GetDirectoryNameInput(std::string& result, const std::string& prompt, const std::string& defaultName = "");
bool GetFormInput(std::vector<FormInputField>& fields, const std::string& title);
BNMessageBoxButtonResult ShowMessageBox(const std::string& title, const std::string& text,
- BNMessageBoxButtonSet buttons = OKButtonSet, BNMessageBoxIcon icon = InformationIcon);
+ BNMessageBoxButtonSet buttons = OKButtonSet, BNMessageBoxIcon icon = InformationIcon);
bool OpenUrl(const std::string& url);
@@ -746,7 +655,8 @@ __attribute__ ((format (printf, 1, 2)))
\param subpartCount Total number of subparts
\return A function that will call originalFn() within a modified progress region
*/
- std::function<bool(size_t, size_t)> SplitProgress(std::function<bool(size_t, size_t)> originalFn, size_t subpart, size_t subpartCount);
+ std::function<bool(size_t, size_t)> SplitProgress(
+ std::function<bool(size_t, size_t)> originalFn, size_t subpart, size_t subpartCount);
/*!
@@ -765,7 +675,8 @@ __attribute__ ((format (printf, 1, 2)))
\param subpartWeights Weights of subparts, described above
\return A function that will call originalFn() within a modified progress region
*/
- std::function<bool(size_t, size_t)> SplitProgress(std::function<bool(size_t, size_t)> originalFn, size_t subpart, std::vector<double> subpartWeights);
+ std::function<bool(size_t, size_t)> SplitProgress(
+ std::function<bool(size_t, size_t)> originalFn, size_t subpart, std::vector<double> subpartWeights);
std::string GetUniqueIdentifierString();
@@ -775,7 +686,7 @@ __attribute__ ((format (printf, 1, 2)))
{
BNDataBuffer* m_buffer;
- public:
+ public:
DataBuffer();
DataBuffer(size_t len);
DataBuffer(const void* data, size_t len);
@@ -818,9 +729,9 @@ __attribute__ ((format (printf, 1, 2)))
bool ZlibDecompress(DataBuffer& output) const;
};
- class TemporaryFile: public CoreRefCountObject<BNTemporaryFile, BNNewTemporaryFileReference, BNFreeTemporaryFile>
+ class TemporaryFile : public CoreRefCountObject<BNTemporaryFile, BNNewTemporaryFileReference, BNFreeTemporaryFile>
{
- public:
+ public:
TemporaryFile();
TemporaryFile(const DataBuffer& contents);
TemporaryFile(const std::string& contents);
@@ -833,14 +744,14 @@ __attribute__ ((format (printf, 1, 2)))
class NavigationHandler
{
- private:
+ private:
BNNavigationHandler m_callbacks;
static char* GetCurrentViewCallback(void* ctxt);
static uint64_t GetCurrentOffsetCallback(void* ctxt);
static bool NavigateCallback(void* ctxt, const char* view, uint64_t offset);
- public:
+ public:
NavigationHandler();
virtual ~NavigationHandler() {}
@@ -853,28 +764,29 @@ __attribute__ ((format (printf, 1, 2)))
class User : public CoreRefCountObject<BNUser, BNNewUserReference, BNFreeUser>
{
- private:
- std::string m_id;
- std::string m_name;
- std::string m_email;
- public:
- User(BNUser* user);
- std::string GetName();
- std::string GetEmail();
- std::string GetId();
+ private:
+ std::string m_id;
+ std::string m_name;
+ std::string m_email;
+
+ public:
+ User(BNUser* user);
+ std::string GetName();
+ std::string GetEmail();
+ std::string GetId();
};
struct InstructionTextToken;
struct UndoEntry;
- struct DatabaseException: std::runtime_error
+ struct DatabaseException : std::runtime_error
{
- DatabaseException(const std::string& desc): std::runtime_error(desc.c_str()) {}
+ DatabaseException(const std::string& desc) : std::runtime_error(desc.c_str()) {}
};
- class KeyValueStore: public CoreRefCountObject<BNKeyValueStore, BNNewKeyValueStoreReference, BNFreeKeyValueStore>
+ class KeyValueStore : public CoreRefCountObject<BNKeyValueStore, BNNewKeyValueStoreReference, BNFreeKeyValueStore>
{
- public:
+ public:
KeyValueStore();
KeyValueStore(const DataBuffer& buffer);
KeyValueStore(BNKeyValueStore* store);
@@ -901,9 +813,9 @@ __attribute__ ((format (printf, 1, 2)))
class Database;
- class Snapshot: public CoreRefCountObject<BNSnapshot, BNNewSnapshotReference, BNFreeSnapshot>
+ class Snapshot : public CoreRefCountObject<BNSnapshot, BNNewSnapshotReference, BNFreeSnapshot>
{
- public:
+ public:
Snapshot(BNSnapshot* snapshot);
Ref<Database> GetDatabase();
@@ -926,16 +838,17 @@ __attribute__ ((format (printf, 1, 2)))
class FileMetadata;
- class Database: public CoreRefCountObject<BNDatabase, BNNewDatabaseReference, BNFreeDatabase>
+ class Database : public CoreRefCountObject<BNDatabase, BNNewDatabaseReference, BNFreeDatabase>
{
- public:
+ public:
Database(BNDatabase* database);
Ref<Snapshot> GetSnapshot(int64_t id);
std::vector<Ref<Snapshot>> GetSnapshots();
void SetCurrentSnapshot(int64_t id);
Ref<Snapshot> GetCurrentSnapshot();
- int64_t WriteSnapshotData(std::vector<int64_t> parents, Ref<BinaryView> file, const std::string& name, const Ref<KeyValueStore>& data, bool autoSave, const std::function<bool(size_t, size_t)>& progress);
+ int64_t WriteSnapshotData(std::vector<int64_t> parents, Ref<BinaryView> file, const std::string& name,
+ const Ref<KeyValueStore>& data, bool autoSave, const std::function<bool(size_t, size_t)>& progress);
void RemoveSnapshot(int64_t id);
std::vector<std::string> GetGlobalKeys() const;
@@ -975,14 +888,13 @@ __attribute__ ((format (printf, 1, 2)))
UndoAction action;
std::string hash;
- MergeResult(): status(NOT_APPLICABLE) {}
+ MergeResult() : status(NOT_APPLICABLE) {}
MergeResult(const BNMergeResult& result);
};
- class SaveSettings: public CoreRefCountObject<BNSaveSettings,
- BNNewSaveSettingsReference, BNFreeSaveSettings>
+ class SaveSettings : public CoreRefCountObject<BNSaveSettings, BNNewSaveSettingsReference, BNFreeSaveSettings>
{
- public:
+ public:
SaveSettings();
SaveSettings(BNSaveSettings* settings);
@@ -990,9 +902,9 @@ __attribute__ ((format (printf, 1, 2)))
void SetOption(BNSaveOption option, bool state = true);
};
- class FileMetadata: public CoreRefCountObject<BNFileMetadata, BNNewFileReference, BNFreeFileMetadata>
+ class FileMetadata : public CoreRefCountObject<BNFileMetadata, BNNewFileReference, BNFreeFileMetadata>
{
- public:
+ public:
FileMetadata();
FileMetadata(const std::string& filename);
FileMetadata(BNFileMetadata* file);
@@ -1017,25 +929,27 @@ __attribute__ ((format (printf, 1, 2)))
bool IsBackedByDatabase(const std::string& binaryViewType = "") const;
bool CreateDatabase(const std::string& name, BinaryView* data, Ref<SaveSettings> settings);
bool CreateDatabase(const std::string& name, BinaryView* data,
- const std::function<bool(size_t progress, size_t total)>& progressCallback, Ref<SaveSettings> settings);
+ const std::function<bool(size_t progress, size_t total)>& progressCallback, Ref<SaveSettings> settings);
Ref<BinaryView> OpenExistingDatabase(const std::string& path);
- Ref<BinaryView> OpenExistingDatabase(const std::string& path,
- const std::function<bool(size_t progress, size_t total)>& progressCallback);
+ Ref<BinaryView> OpenExistingDatabase(
+ const std::string& path, const std::function<bool(size_t progress, size_t total)>& progressCallback);
Ref<BinaryView> OpenDatabaseForConfiguration(const std::string& path);
bool SaveAutoSnapshot(BinaryView* data, Ref<SaveSettings> settings);
bool SaveAutoSnapshot(BinaryView* data,
- const std::function<bool(size_t progress, size_t total)>& progressCallback, Ref<SaveSettings> settings);
- void GetSnapshotData(Ref<KeyValueStore> data, Ref<KeyValueStore> cache,
- const std::function<bool(size_t, size_t)>& progress);
+ const std::function<bool(size_t progress, size_t total)>& progressCallback, Ref<SaveSettings> settings);
+ void GetSnapshotData(
+ Ref<KeyValueStore> data, Ref<KeyValueStore> cache, const std::function<bool(size_t, size_t)>& progress);
void ApplySnapshotData(BinaryView* file, Ref<KeyValueStore> data, Ref<KeyValueStore> cache,
- const std::function<bool(size_t, size_t)>& progress, bool openForConfiguration = false, bool restoreRawView = true);
+ const std::function<bool(size_t, size_t)>& progress, bool openForConfiguration = false,
+ bool restoreRawView = true);
Ref<Database> GetDatabase();
bool Rebase(BinaryView* data, uint64_t address);
- bool Rebase(BinaryView* data, uint64_t address, const std::function<bool(size_t progress, size_t total)>& progressCallback);
+ bool Rebase(BinaryView* data, uint64_t address,
+ const std::function<bool(size_t progress, size_t total)>& progressCallback);
MergeResult MergeUserAnalysis(const std::string& name, const std::function<bool(size_t, size_t)>& progress,
- const std::vector<std::string> excludedHashes = {} );
+ const std::vector<std::string> excludedHashes = {});
void BeginUndoActions();
void CommitUndoActions();
@@ -1068,7 +982,7 @@ __attribute__ ((format (printf, 1, 2)))
class BinaryDataNotification
{
- private:
+ private:
BNBinaryDataNotification m_callbacks;
static void DataWrittenCallback(void* ctxt, BNBinaryView* data, uint64_t offset, size_t len);
@@ -1090,57 +1004,164 @@ __attribute__ ((format (printf, 1, 2)))
static void TagUpdatedCallback(void* ctxt, BNBinaryView* object, BNTagReference* tagRef);
static void TagRemovedCallback(void* ctxt, BNBinaryView* object, BNTagReference* tagRef);
static void StringFoundCallback(void* ctxt, BNBinaryView* data, BNStringType type, uint64_t offset, size_t len);
- static void StringRemovedCallback(void* ctxt, BNBinaryView* data, BNStringType type, uint64_t offset, size_t len);
+ static void StringRemovedCallback(
+ void* ctxt, BNBinaryView* data, BNStringType type, uint64_t offset, size_t len);
static void TypeDefinedCallback(void* ctxt, BNBinaryView* data, BNQualifiedName* name, BNType* type);
static void TypeUndefinedCallback(void* ctxt, BNBinaryView* data, BNQualifiedName* name, BNType* type);
static void TypeReferenceChangedCallback(void* ctx, BNBinaryView* data, BNQualifiedName* name, BNType* type);
- static void TypeFieldReferenceChangedCallback(void* ctx, BNBinaryView* data, BNQualifiedName* name, uint64_t offset);
+ static void TypeFieldReferenceChangedCallback(
+ void* ctx, BNBinaryView* data, BNQualifiedName* name, uint64_t offset);
- public:
+ public:
BinaryDataNotification();
virtual ~BinaryDataNotification() {}
BNBinaryDataNotification* GetCallbacks() { return &m_callbacks; }
- virtual void OnBinaryDataWritten(BinaryView* view, uint64_t offset, size_t len) { (void)view; (void)offset; (void)len; }
- virtual void OnBinaryDataInserted(BinaryView* view, uint64_t offset, size_t len) { (void)view; (void)offset; (void)len; }
- virtual void OnBinaryDataRemoved(BinaryView* view, uint64_t offset, uint64_t len) { (void)view; (void)offset; (void)len; }
- virtual void OnAnalysisFunctionAdded(BinaryView* view, Function* func) { (void)view; (void)func; }
- virtual void OnAnalysisFunctionRemoved(BinaryView* view, Function* func) { (void)view; (void)func; }
- virtual void OnAnalysisFunctionUpdated(BinaryView* view, Function* func) { (void)view; (void)func; }
- virtual void OnAnalysisFunctionUpdateRequested(BinaryView* view, Function* func) { (void)view; (void)func; }
- virtual void OnDataVariableAdded(BinaryView* view, const DataVariable& var) { (void)view; (void)var; }
- virtual void OnDataVariableRemoved(BinaryView* view, const DataVariable& var) { (void)view; (void)var; }
- virtual void OnDataVariableUpdated(BinaryView* view, const DataVariable& var) { (void)view; (void)var; }
- virtual void OnDataMetadataUpdated(BinaryView* view, uint64_t offset) { (void)view; (void)offset; }
- virtual void OnTagTypeUpdated(BinaryView* view, Ref<TagType> tagTypeRef) { (void)view; (void)tagTypeRef; }
- virtual void OnTagAdded(BinaryView* view, const TagReference& tagRef) { (void)view; (void)tagRef; }
- virtual void OnTagUpdated(BinaryView* view, const TagReference& tagRef) { (void)view; (void)tagRef; }
- virtual void OnTagRemoved(BinaryView* view, const TagReference& tagRef) { (void)view; (void)tagRef; }
- virtual void OnSymbolAdded(BinaryView* view, Symbol* sym) { (void)view; (void)sym; }
- virtual void OnSymbolUpdated(BinaryView* view, Symbol* sym) { (void)view; (void)sym; }
- virtual void OnSymbolRemoved(BinaryView* view, Symbol* sym) { (void)view; (void)sym; }
- virtual void OnStringFound(BinaryView* data, BNStringType type, uint64_t offset, size_t len) { (void)data; (void)type; (void)offset; (void)len; }
- virtual void OnStringRemoved(BinaryView* data, BNStringType type, uint64_t offset, size_t len) { (void)data; (void)type; (void)offset; (void)len; }
- virtual void OnTypeDefined(BinaryView* data, const QualifiedName& name, Type* type) { (void)data; (void)name; (void)type; }
- virtual void OnTypeUndefined(BinaryView* data, const QualifiedName& name, Type* type) { (void)data; (void)name; (void)type; }
- virtual void OnTypeReferenceChanged(BinaryView* data, const QualifiedName&name, Type* type) { (void)data;
- (void)name; (void)type; }
+ virtual void OnBinaryDataWritten(BinaryView* view, uint64_t offset, size_t len)
+ {
+ (void)view;
+ (void)offset;
+ (void)len;
+ }
+ virtual void OnBinaryDataInserted(BinaryView* view, uint64_t offset, size_t len)
+ {
+ (void)view;
+ (void)offset;
+ (void)len;
+ }
+ virtual void OnBinaryDataRemoved(BinaryView* view, uint64_t offset, uint64_t len)
+ {
+ (void)view;
+ (void)offset;
+ (void)len;
+ }
+ virtual void OnAnalysisFunctionAdded(BinaryView* view, Function* func)
+ {
+ (void)view;
+ (void)func;
+ }
+ virtual void OnAnalysisFunctionRemoved(BinaryView* view, Function* func)
+ {
+ (void)view;
+ (void)func;
+ }
+ virtual void OnAnalysisFunctionUpdated(BinaryView* view, Function* func)
+ {
+ (void)view;
+ (void)func;
+ }
+ virtual void OnAnalysisFunctionUpdateRequested(BinaryView* view, Function* func)
+ {
+ (void)view;
+ (void)func;
+ }
+ virtual void OnDataVariableAdded(BinaryView* view, const DataVariable& var)
+ {
+ (void)view;
+ (void)var;
+ }
+ virtual void OnDataVariableRemoved(BinaryView* view, const DataVariable& var)
+ {
+ (void)view;
+ (void)var;
+ }
+ virtual void OnDataVariableUpdated(BinaryView* view, const DataVariable& var)
+ {
+ (void)view;
+ (void)var;
+ }
+ virtual void OnDataMetadataUpdated(BinaryView* view, uint64_t offset)
+ {
+ (void)view;
+ (void)offset;
+ }
+ virtual void OnTagTypeUpdated(BinaryView* view, Ref<TagType> tagTypeRef)
+ {
+ (void)view;
+ (void)tagTypeRef;
+ }
+ virtual void OnTagAdded(BinaryView* view, const TagReference& tagRef)
+ {
+ (void)view;
+ (void)tagRef;
+ }
+ virtual void OnTagUpdated(BinaryView* view, const TagReference& tagRef)
+ {
+ (void)view;
+ (void)tagRef;
+ }
+ virtual void OnTagRemoved(BinaryView* view, const TagReference& tagRef)
+ {
+ (void)view;
+ (void)tagRef;
+ }
+ virtual void OnSymbolAdded(BinaryView* view, Symbol* sym)
+ {
+ (void)view;
+ (void)sym;
+ }
+ virtual void OnSymbolUpdated(BinaryView* view, Symbol* sym)
+ {
+ (void)view;
+ (void)sym;
+ }
+ virtual void OnSymbolRemoved(BinaryView* view, Symbol* sym)
+ {
+ (void)view;
+ (void)sym;
+ }
+ virtual void OnStringFound(BinaryView* data, BNStringType type, uint64_t offset, size_t len)
+ {
+ (void)data;
+ (void)type;
+ (void)offset;
+ (void)len;
+ }
+ virtual void OnStringRemoved(BinaryView* data, BNStringType type, uint64_t offset, size_t len)
+ {
+ (void)data;
+ (void)type;
+ (void)offset;
+ (void)len;
+ }
+ virtual void OnTypeDefined(BinaryView* data, const QualifiedName& name, Type* type)
+ {
+ (void)data;
+ (void)name;
+ (void)type;
+ }
+ virtual void OnTypeUndefined(BinaryView* data, const QualifiedName& name, Type* type)
+ {
+ (void)data;
+ (void)name;
+ (void)type;
+ }
+ virtual void OnTypeReferenceChanged(BinaryView* data, const QualifiedName& name, Type* type)
+ {
+ (void)data;
+ (void)name;
+ (void)type;
+ }
virtual void OnTypeFieldReferenceChanged(BinaryView* data, const QualifiedName& name, uint64_t offset)
- { (void)data; (void)name; (void)offset; }
+ {
+ (void)data;
+ (void)name;
+ (void)offset;
+ }
};
class FileAccessor
{
- protected:
+ protected:
BNFileAccessor m_callbacks;
- private:
+ private:
static uint64_t GetLengthCallback(void* ctxt);
static size_t ReadCallback(void* ctxt, void* dest, uint64_t offset, size_t len);
static size_t WriteCallback(void* ctxt, uint64_t offset, const void* src, size_t len);
- public:
+ public:
FileAccessor();
FileAccessor(BNFileAccessor* accessor);
virtual ~FileAccessor() {}
@@ -1153,9 +1174,9 @@ __attribute__ ((format (printf, 1, 2)))
virtual size_t Write(uint64_t offset, const void* src, size_t len) = 0;
};
- class CoreFileAccessor: public FileAccessor
+ class CoreFileAccessor : public FileAccessor
{
- public:
+ public:
CoreFileAccessor(BNFileAccessor* accessor);
virtual bool IsValid() const override { return true; }
@@ -1168,10 +1189,11 @@ __attribute__ ((format (printf, 1, 2)))
class BasicBlock;
class NameList
{
- protected:
+ protected:
std::string m_join;
std::vector<std::string> m_name;
- public:
+
+ public:
NameList(const std::string& join);
NameList(const std::string& name, const std::string& join);
NameList(const std::vector<std::string>& name, const std::string& join);
@@ -1202,7 +1224,7 @@ __attribute__ ((format (printf, 1, 2)))
virtual const std::string& back() const;
virtual void insert(std::vector<std::string>::iterator loc, const std::string& name);
virtual void insert(std::vector<std::string>::iterator loc, std::vector<std::string>::iterator b,
- std::vector<std::string>::iterator e);
+ std::vector<std::string>::iterator e);
virtual void erase(std::vector<std::string>::iterator i);
virtual void clear();
virtual void push_back(const std::string& name);
@@ -1218,9 +1240,9 @@ __attribute__ ((format (printf, 1, 2)))
static NameList FromAPIObject(BNNameList* name);
};
- class QualifiedName: public NameList
+ class QualifiedName : public NameList
{
- public:
+ public:
QualifiedName();
QualifiedName(const std::string& name);
QualifiedName(const std::vector<std::string>& name);
@@ -1237,9 +1259,9 @@ __attribute__ ((format (printf, 1, 2)))
static QualifiedName FromAPIObject(BNQualifiedName* name);
};
- class NameSpace: public NameList
+ class NameSpace : public NameList
{
- public:
+ public:
NameSpace();
NameSpace(const std::string& name);
NameSpace(const std::vector<std::string>& name);
@@ -1257,14 +1279,14 @@ __attribute__ ((format (printf, 1, 2)))
static NameSpace FromAPIObject(const BNNameSpace* name);
};
- class Symbol: public CoreRefCountObject<BNSymbol, BNNewSymbolReference, BNFreeSymbol>
+ class Symbol : public CoreRefCountObject<BNSymbol, BNNewSymbolReference, BNFreeSymbol>
{
- public:
+ public:
Symbol(BNSymbolType type, const std::string& shortName, const std::string& fullName, const std::string& rawName,
- uint64_t addr, BNSymbolBinding binding=NoBinding, const NameSpace& nameSpace=NameSpace(DEFAULT_INTERNAL_NAMESPACE),
- uint64_t ordinal=0);
- Symbol(BNSymbolType type, const std::string& name, uint64_t addr, BNSymbolBinding binding=NoBinding,
- const NameSpace& nameSpace=NameSpace(DEFAULT_INTERNAL_NAMESPACE), uint64_t ordinal=0);
+ uint64_t addr, BNSymbolBinding binding = NoBinding,
+ const NameSpace& nameSpace = NameSpace(DEFAULT_INTERNAL_NAMESPACE), uint64_t ordinal = 0);
+ Symbol(BNSymbolType type, const std::string& name, uint64_t addr, BNSymbolBinding binding = NoBinding,
+ const NameSpace& nameSpace = NameSpace(DEFAULT_INTERNAL_NAMESPACE), uint64_t ordinal = 0);
Symbol(BNSymbol* sym);
BNSymbolType GetType() const;
@@ -1283,22 +1305,22 @@ __attribute__ ((format (printf, 1, 2)))
// TODO: This describes how the xref source references the target
enum ReferenceType
{
- UnspecifiedReferenceType = 0x0,
- ReadReferenceType = 0x1,
- WriteReferenceType = 0x2,
- ExecuteReferenceType = 0x4,
+ UnspecifiedReferenceType = 0x0,
+ ReadReferenceType = 0x1,
+ WriteReferenceType = 0x2,
+ ExecuteReferenceType = 0x4,
// A type is referenced by a data variable
- DataVariableReferenceType = 0x8,
+ DataVariableReferenceType = 0x8,
// A type is referenced by another type
- DirectTypeReferenceType = 0x10,
- IndirectTypeReferenceType = 0x20,
+ DirectTypeReferenceType = 0x10,
+ IndirectTypeReferenceType = 0x20,
};
// ReferenceSource describes code reference source; TypeReferenceSource describes type reference source.
- // When we query references, code references return vector<ReferenceSource>, data references return vector<uint64_t>,
- // type references return vector<TypeReferenceSource>.
+ // When we query references, code references return vector<ReferenceSource>, data references return
+ // vector<uint64_t>, type references return vector<TypeReferenceSource>.
struct ReferenceSource
{
@@ -1333,7 +1355,6 @@ __attribute__ ((format (printf, 1, 2)))
};
-
struct InstructionTextToken
{
enum
@@ -1354,17 +1375,20 @@ __attribute__ ((format (printf, 1, 2)))
InstructionTextToken();
InstructionTextToken(uint8_t confidence, BNInstructionTextTokenType t, const std::string& txt);
InstructionTextToken(BNInstructionTextTokenType type, const std::string& text, uint64_t value = 0,
- size_t size = 0, size_t operand = BN_INVALID_OPERAND, uint8_t confidence = BN_FULL_CONFIDENCE,
- const std::vector<std::string>& typeName={}, uint64_t width = WidthIsByteCount);
+ size_t size = 0, size_t operand = BN_INVALID_OPERAND, uint8_t confidence = BN_FULL_CONFIDENCE,
+ const std::vector<std::string>& typeName = {}, uint64_t width = WidthIsByteCount);
InstructionTextToken(BNInstructionTextTokenType type, BNInstructionTextTokenContext context,
- const std::string& text, uint64_t address, uint64_t value = 0, size_t size = 0,
- size_t operand = BN_INVALID_OPERAND, uint8_t confidence = BN_FULL_CONFIDENCE, const std::vector<std::string>& typeName={}, uint64_t width = WidthIsByteCount);
+ const std::string& text, uint64_t address, uint64_t value = 0, size_t size = 0,
+ size_t operand = BN_INVALID_OPERAND, uint8_t confidence = BN_FULL_CONFIDENCE,
+ const std::vector<std::string>& typeName = {}, uint64_t width = WidthIsByteCount);
InstructionTextToken(const BNInstructionTextToken& token);
InstructionTextToken WithConfidence(uint8_t conf);
static BNInstructionTextToken* CreateInstructionTextTokenList(const std::vector<InstructionTextToken>& tokens);
- static std::vector<InstructionTextToken> ConvertAndFreeInstructionTextTokenList(BNInstructionTextToken* tokens, size_t count);
- static std::vector<InstructionTextToken> ConvertInstructionTextTokenList(const BNInstructionTextToken* tokens, size_t count);
+ static std::vector<InstructionTextToken> ConvertAndFreeInstructionTextTokenList(
+ BNInstructionTextToken* tokens, size_t count);
+ static std::vector<InstructionTextToken> ConvertInstructionTextTokenList(
+ const BNInstructionTextToken* tokens, size_t count);
};
@@ -1376,8 +1400,7 @@ __attribute__ ((format (printf, 1, 2)))
size_t fieldIndex;
uint64_t offset;
- DisassemblyTextLineTypeInfo(): hasTypeInfo(false), parentType(nullptr), fieldIndex(-1), offset(0)
- {}
+ DisassemblyTextLineTypeInfo() : hasTypeInfo(false), parentType(nullptr), fieldIndex(-1), offset(0) {}
};
struct DisassemblyTextLine
@@ -1404,16 +1427,17 @@ __attribute__ ((format (printf, 1, 2)))
class DisassemblySettings;
- class AnalysisCompletionEvent: public CoreRefCountObject<BNAnalysisCompletionEvent,
- BNNewAnalysisCompletionEventReference, BNFreeAnalysisCompletionEvent>
+ class AnalysisCompletionEvent :
+ public CoreRefCountObject<BNAnalysisCompletionEvent, BNNewAnalysisCompletionEventReference,
+ BNFreeAnalysisCompletionEvent>
{
- protected:
+ protected:
std::function<void()> m_callback;
std::recursive_mutex m_mutex;
static void CompletionCallback(void* ctxt);
- public:
+ public:
AnalysisCompletionEvent(BinaryView* view, const std::function<void()>& callback);
void Cancel();
};
@@ -1425,9 +1449,9 @@ __attribute__ ((format (printf, 1, 2)))
size_t updateCount;
size_t submitCount;
- ActiveAnalysisInfo(Ref<Function> f, uint64_t t, size_t uc, size_t sc) : func(f), analysisTime(t), updateCount(uc), submitCount(sc)
- {
- }
+ ActiveAnalysisInfo(Ref<Function> f, uint64_t t, size_t uc, size_t sc) :
+ func(f), analysisTime(t), updateCount(uc), submitCount(sc)
+ {}
};
struct AnalysisInfo
@@ -1439,8 +1463,8 @@ __attribute__ ((format (printf, 1, 2)))
struct DataVariable
{
- DataVariable() { }
- DataVariable(uint64_t a, Type* t, bool d) : address(a), type(t), autoDiscovered(d) { }
+ DataVariable() {}
+ DataVariable(uint64_t a, Type* t, bool d) : address(a), type(t), autoDiscovered(d) {}
uint64_t address;
Confidence<Ref<Type>> type;
@@ -1449,8 +1473,10 @@ __attribute__ ((format (printf, 1, 2)))
struct DataVariableAndName
{
- DataVariableAndName() { }
- DataVariableAndName(uint64_t a, Type* t, bool d, const std::string& n) : address(a), type(t), autoDiscovered(d), name(n) { }
+ DataVariableAndName() {}
+ DataVariableAndName(uint64_t a, Type* t, bool d, const std::string& n) :
+ address(a), type(t), autoDiscovered(d), name(n)
+ {}
uint64_t address;
Confidence<Ref<Type>> type;
@@ -1458,14 +1484,15 @@ __attribute__ ((format (printf, 1, 2)))
std::string name;
};
- class TagType: public CoreRefCountObject<BNTagType, BNNewTagTypeReference, BNFreeTagType>
+ class TagType : public CoreRefCountObject<BNTagType, BNNewTagTypeReference, BNFreeTagType>
{
- public:
+ public:
typedef BNTagTypeType Type;
TagType(BNTagType* tagType);
TagType(BinaryView* view);
- TagType(BinaryView* view, const std::string& name, const std::string& icon, bool visible = true, Type type = UserTagType);
+ TagType(BinaryView* view, const std::string& name, const std::string& icon, bool visible = true,
+ Type type = UserTagType);
BinaryView* GetView() const;
std::string GetId() const;
@@ -1479,9 +1506,9 @@ __attribute__ ((format (printf, 1, 2)))
void SetType(Type type);
};
- class Tag: public CoreRefCountObject<BNTag, BNNewTagReference, BNFreeTag>
+ class Tag : public CoreRefCountObject<BNTag, BNNewTagReference, BNFreeTag>
{
- public:
+ public:
Tag(BNTag* tag);
Tag(Ref<TagType> type, const std::string& data = "");
@@ -1522,9 +1549,9 @@ __attribute__ ((format (printf, 1, 2)))
};
class Relocation;
- class Segment: public CoreRefCountObject<BNSegment, BNNewSegmentReference, BNFreeSegment>
+ class Segment : public CoreRefCountObject<BNSegment, BNNewSegmentReference, BNFreeSegment>
{
- public:
+ public:
Segment(BNSegment* seg);
uint64_t GetStart() const;
uint64_t GetLength() const;
@@ -1547,13 +1574,13 @@ __attribute__ ((format (printf, 1, 2)))
void SetFlags(uint32_t flags);
};
- class Section: public CoreRefCountObject<BNSection, BNNewSectionReference, BNFreeSection>
+ class Section : public CoreRefCountObject<BNSection, BNNewSectionReference, BNFreeSection>
{
- public:
+ public:
Section(BNSection* sec);
Section(const std::string& name, uint64_t start, uint64_t length, BNSectionSemantics semantics,
- const std::string& type, uint64_t align, uint64_t entrySize, const std::string& linkedSection,
- const std::string& infoSection, uint64_t infoData, bool autoDefined);
+ const std::string& type, uint64_t align, uint64_t entrySize, const std::string& linkedSection,
+ const std::string& infoSection, uint64_t infoData, bool autoDefined);
std::string GetName() const;
std::string GetType() const;
uint64_t GetStart() const;
@@ -1572,21 +1599,22 @@ __attribute__ ((format (printf, 1, 2)))
class Metadata;
class Structure;
- class QueryMetadataException: public std::exception
+ class QueryMetadataException : public std::exception
{
const std::string m_error;
- public:
- QueryMetadataException(const std::string& error): std::exception(), m_error(error) {}
+
+ public:
+ QueryMetadataException(const std::string& error) : std::exception(), m_error(error) {}
virtual const char* what() const NOEXCEPT { return m_error.c_str(); }
};
/*! BinaryView is the base class for creating views on binary data (e.g. ELF, PE, Mach-O).
BinaryView should be subclassed to create a new BinaryView
*/
- class BinaryView: public CoreRefCountObject<BNBinaryView, BNNewViewReference, BNFreeBinaryView>
+ class BinaryView : public CoreRefCountObject<BNBinaryView, BNNewViewReference, BNFreeBinaryView>
{
- protected:
- Ref<FileMetadata> m_file; //!< The underlying file
+ protected:
+ Ref<FileMetadata> m_file; //!< The underlying file
/*! BinaryView constructor
\param typeName name of the BinaryView (e.g. ELF, PE, Mach-O, ...)
@@ -1601,12 +1629,39 @@ __attribute__ ((format (printf, 1, 2)))
\param offset the virtual offset to find and read len bytes from
\param len the number of bytes to read from offset and write to dest
*/
- virtual size_t PerformRead(void* dest, uint64_t offset, size_t len) { (void)dest; (void)offset; (void)len; return 0; }
- virtual size_t PerformWrite(uint64_t offset, const void* data, size_t len) { (void)offset; (void)data; (void)len; return 0; }
- virtual size_t PerformInsert(uint64_t offset, const void* data, size_t len) { (void)offset; (void)data; (void)len; return 0; }
- virtual size_t PerformRemove(uint64_t offset, uint64_t len) { (void)offset; (void)len; return 0; }
+ virtual size_t PerformRead(void* dest, uint64_t offset, size_t len)
+ {
+ (void)dest;
+ (void)offset;
+ (void)len;
+ return 0;
+ }
+ virtual size_t PerformWrite(uint64_t offset, const void* data, size_t len)
+ {
+ (void)offset;
+ (void)data;
+ (void)len;
+ return 0;
+ }
+ virtual size_t PerformInsert(uint64_t offset, const void* data, size_t len)
+ {
+ (void)offset;
+ (void)data;
+ (void)len;
+ return 0;
+ }
+ virtual size_t PerformRemove(uint64_t offset, uint64_t len)
+ {
+ (void)offset;
+ (void)len;
+ return 0;
+ }
- virtual BNModificationStatus PerformGetModification(uint64_t offset) { (void)offset; return Original; }
+ virtual BNModificationStatus PerformGetModification(uint64_t offset)
+ {
+ (void)offset;
+ return Original;
+ }
virtual bool PerformIsValidOffset(uint64_t offset);
virtual bool PerformIsOffsetReadable(uint64_t offset);
virtual bool PerformIsOffsetWritable(uint64_t offset);
@@ -1628,7 +1683,7 @@ __attribute__ ((format (printf, 1, 2)))
void NotifyDataInserted(uint64_t offset, size_t len);
void NotifyDataRemoved(uint64_t offset, uint64_t len);
- private:
+ private:
static bool InitCallback(void* ctxt);
static void FreeCallback(void* ctxt);
static size_t ReadCallback(void* ctxt, void* dest, uint64_t offset, size_t len);
@@ -1650,7 +1705,8 @@ __attribute__ ((format (printf, 1, 2)))
static bool IsRelocatableCallback(void* ctxt);
static size_t GetAddressSizeCallback(void* ctxt);
static bool SaveCallback(void* ctxt, BNFileAccessor* file);
- public:
+
+ public:
BinaryView(BNBinaryView* view);
virtual bool Init() { return true; }
@@ -1663,9 +1719,11 @@ __attribute__ ((format (printf, 1, 2)))
bool IsAnalysisChanged() const;
bool CreateDatabase(const std::string& path, Ref<SaveSettings> settings = new SaveSettings());
bool CreateDatabase(const std::string& path,
- const std::function<bool(size_t progress, size_t total)>& progressCallback, Ref<SaveSettings> settings = new SaveSettings());
+ const std::function<bool(size_t progress, size_t total)>& progressCallback,
+ Ref<SaveSettings> settings = new SaveSettings());
bool SaveAutoSnapshot(Ref<SaveSettings> settings = new SaveSettings());
- bool SaveAutoSnapshot(const std::function<bool(size_t progress, size_t total)>& progressCallback, Ref<SaveSettings> settings = new SaveSettings());
+ bool SaveAutoSnapshot(const std::function<bool(size_t progress, size_t total)>& progressCallback,
+ Ref<SaveSettings> settings = new SaveSettings());
void BeginUndoActions();
void AddUndoAction(UndoAction* action);
@@ -1792,28 +1850,25 @@ __attribute__ ((format (printf, 1, 2)))
std::vector<TypeReferenceSource> GetCodeReferencesForTypeFieldFrom(ReferenceSource src, uint64_t len);
std::vector<uint64_t> GetAllFieldsReferenced(const QualifiedName& type);
- std::map<uint64_t, std::vector<size_t>> GetAllSizesReferenced(
- const QualifiedName& type);
- std::map<uint64_t, std::vector<Confidence<Ref<Type>>>>
- GetAllTypesReferenced(const QualifiedName& type);
- std::vector<size_t> GetSizesReferenced(const QualifiedName& type,
- uint64_t offset);
- std::vector<Confidence<Ref<Type>>> GetTypesReferenced(
- const QualifiedName& type, uint64_t offset);
+ std::map<uint64_t, std::vector<size_t>> GetAllSizesReferenced(const QualifiedName& type);
+ std::map<uint64_t, std::vector<Confidence<Ref<Type>>>> GetAllTypesReferenced(const QualifiedName& type);
+ std::vector<size_t> GetSizesReferenced(const QualifiedName& type, uint64_t offset);
+ std::vector<Confidence<Ref<Type>>> GetTypesReferenced(const QualifiedName& type, uint64_t offset);
Ref<Structure> CreateStructureBasedOnFieldAccesses(const QualifiedName& type);
std::vector<uint64_t> GetCallees(ReferenceSource addr);
std::vector<ReferenceSource> GetCallers(uint64_t addr);
- Ref<Symbol> GetSymbolByAddress(uint64_t addr, const NameSpace& nameSpace=NameSpace());
- Ref<Symbol> GetSymbolByRawName(const std::string& name, const NameSpace& nameSpace=NameSpace());
- std::vector<Ref<Symbol>> GetSymbolsByName(const std::string& name, const NameSpace& nameSpace=NameSpace());
- std::vector<Ref<Symbol>> GetSymbols(const NameSpace& nameSpace=NameSpace());
- std::vector<Ref<Symbol>> GetSymbols(uint64_t start, uint64_t len, const NameSpace& nameSpace=NameSpace());
- std::vector<Ref<Symbol>> GetSymbolsOfType(BNSymbolType type, const NameSpace& nameSpace=NameSpace());
- std::vector<Ref<Symbol>> GetSymbolsOfType(BNSymbolType type, uint64_t start, uint64_t len, const NameSpace& nameSpace=NameSpace());
- std::vector<Ref<Symbol>> GetVisibleSymbols(const NameSpace& nameSpace=NameSpace());
+ Ref<Symbol> GetSymbolByAddress(uint64_t addr, const NameSpace& nameSpace = NameSpace());
+ Ref<Symbol> GetSymbolByRawName(const std::string& name, const NameSpace& nameSpace = NameSpace());
+ std::vector<Ref<Symbol>> GetSymbolsByName(const std::string& name, const NameSpace& nameSpace = NameSpace());
+ std::vector<Ref<Symbol>> GetSymbols(const NameSpace& nameSpace = NameSpace());
+ std::vector<Ref<Symbol>> GetSymbols(uint64_t start, uint64_t len, const NameSpace& nameSpace = NameSpace());
+ std::vector<Ref<Symbol>> GetSymbolsOfType(BNSymbolType type, const NameSpace& nameSpace = NameSpace());
+ std::vector<Ref<Symbol>> GetSymbolsOfType(
+ BNSymbolType type, uint64_t start, uint64_t len, const NameSpace& nameSpace = NameSpace());
+ std::vector<Ref<Symbol>> GetVisibleSymbols(const NameSpace& nameSpace = NameSpace());
void DefineAutoSymbol(Ref<Symbol> sym);
Ref<Symbol> DefineAutoSymbolAndVariableOrFunction(Ref<Platform> platform, Ref<Symbol> sym, Ref<Type> type);
@@ -1868,8 +1923,10 @@ __attribute__ ((format (printf, 1, 2)))
void RemoveUserDataTagsOfType(uint64_t addr, Ref<TagType> tagType);
void RemoveTagReference(const TagReference& ref);
- Ref<Tag> CreateAutoDataTag(uint64_t addr, const std::string& tagTypeName, const std::string& data, bool unique = false);
- Ref<Tag> CreateUserDataTag(uint64_t addr, const std::string& tagTypeName, const std::string& data, bool unique = false);
+ Ref<Tag> CreateAutoDataTag(
+ uint64_t addr, const std::string& tagTypeName, const std::string& data, bool unique = false);
+ Ref<Tag> CreateUserDataTag(
+ uint64_t addr, const std::string& tagTypeName, const std::string& data, bool unique = false);
Ref<Tag> CreateAutoDataTag(uint64_t addr, Ref<TagType> tagType, const std::string& data, bool unique = false);
Ref<Tag> CreateUserDataTag(uint64_t addr, Ref<TagType> tagType, const std::string& data, bool unique = false);
@@ -1907,16 +1964,17 @@ __attribute__ ((format (printf, 1, 2)))
uint64_t GetPreviousDataBeforeAddress(uint64_t addr);
uint64_t GetPreviousDataVariableStartBeforeAddress(uint64_t addr);
- bool ParsePossibleValueSet(const std::string& value, BNRegisterValueType state, PossibleValueSet& result, uint64_t here, std::string& errors);
+ bool ParsePossibleValueSet(const std::string& value, BNRegisterValueType state, PossibleValueSet& result,
+ uint64_t here, std::string& errors);
bool ParseTypeString(const std::string& text, QualifiedNameAndType& result, std::string& errors,
- const std::set<QualifiedName>& typesAllowRedefinition = {});
+ const std::set<QualifiedName>& typesAllowRedefinition = {});
bool ParseTypeString(const std::string& text, std::map<QualifiedName, Ref<Type>>& types,
- std::map<QualifiedName, Ref<Type>>& variables, std::map<QualifiedName, Ref<Type>>& functions, std::string& errors,
- const std::set<QualifiedName>& typesAllowRedefinition = {});
+ std::map<QualifiedName, Ref<Type>>& variables, std::map<QualifiedName, Ref<Type>>& functions,
+ std::string& errors, const std::set<QualifiedName>& typesAllowRedefinition = {});
std::map<QualifiedName, Ref<Type>> GetTypes();
- std::vector<QualifiedName> GetTypeNames(const std::string& matching="");
+ std::vector<QualifiedName> GetTypeNames(const std::string& matching = "");
Ref<Type> GetTypeByName(const QualifiedName& name);
Ref<Type> GetTypeById(const std::string& id);
std::string GetTypeId(const QualifiedName& name);
@@ -1930,36 +1988,33 @@ __attribute__ ((format (printf, 1, 2)))
void RegisterPlatformTypes(Platform* platform);
- bool FindNextData(uint64_t start, const DataBuffer& data, uint64_t& result,
- BNFindFlag flags = FindCaseSensitive);
- bool FindNextText(uint64_t start, const std::string& data, uint64_t& result,
- Ref<DisassemblySettings> settings, BNFindFlag flags = FindCaseSensitive,
- BNFunctionGraphType graph = NormalFunctionGraph);
- bool FindNextConstant(uint64_t start, uint64_t constant, uint64_t& result,
- Ref<DisassemblySettings> settings, BNFunctionGraphType graph = NormalFunctionGraph);
+ bool FindNextData(
+ uint64_t start, const DataBuffer& data, uint64_t& result, BNFindFlag flags = FindCaseSensitive);
+ bool FindNextText(uint64_t start, const std::string& data, uint64_t& result, Ref<DisassemblySettings> settings,
+ BNFindFlag flags = FindCaseSensitive, BNFunctionGraphType graph = NormalFunctionGraph);
+ bool FindNextConstant(uint64_t start, uint64_t constant, uint64_t& result, Ref<DisassemblySettings> settings,
+ BNFunctionGraphType graph = NormalFunctionGraph);
- bool FindNextData(uint64_t start, uint64_t end, const DataBuffer& data, uint64_t& addr,
- BNFindFlag flags, const std::function<bool(size_t current, size_t total)>& progress);
+ bool FindNextData(uint64_t start, uint64_t end, const DataBuffer& data, uint64_t& addr, BNFindFlag flags,
+ const std::function<bool(size_t current, size_t total)>& progress);
bool FindNextText(uint64_t start, uint64_t end, const std::string& data, uint64_t& addr,
- Ref<DisassemblySettings> settings, BNFindFlag flags, BNFunctionGraphType graph,
- const std::function<bool(size_t current, size_t total)>& progress);
+ Ref<DisassemblySettings> settings, BNFindFlag flags, BNFunctionGraphType graph,
+ const std::function<bool(size_t current, size_t total)>& progress);
bool FindNextConstant(uint64_t start, uint64_t end, uint64_t constant, uint64_t& addr,
- Ref<DisassemblySettings> settings, BNFunctionGraphType graph,
- const std::function<bool(size_t current, size_t total)>& progress);
+ Ref<DisassemblySettings> settings, BNFunctionGraphType graph,
+ const std::function<bool(size_t current, size_t total)>& progress);
bool FindAllData(uint64_t start, uint64_t end, const DataBuffer& data, BNFindFlag flags,
- const std::function<bool(size_t current, size_t total)>& progress,
- const std::function<bool(uint64_t addr, const DataBuffer& match)>& matchCallback);
- bool FindAllText(uint64_t start, uint64_t end, const std::string& data,
- Ref<DisassemblySettings> settings, BNFindFlag flags, BNFunctionGraphType graph,
- const std::function<bool(size_t current, size_t total)>& progress,
- const std::function<bool(uint64_t addr, const std::string& match,
- const LinearDisassemblyLine& line)>& matchCallback);
- bool FindAllConstant(uint64_t start, uint64_t end, uint64_t constant,
- Ref<DisassemblySettings> settings, BNFunctionGraphType graph,
- const std::function<bool(size_t current, size_t total)>& progress,
- const std::function<bool(uint64_t addr,
- const LinearDisassemblyLine& line)>& matchCallback);
+ const std::function<bool(size_t current, size_t total)>& progress,
+ const std::function<bool(uint64_t addr, const DataBuffer& match)>& matchCallback);
+ bool FindAllText(uint64_t start, uint64_t end, const std::string& data, Ref<DisassemblySettings> settings,
+ BNFindFlag flags, BNFunctionGraphType graph,
+ const std::function<bool(size_t current, size_t total)>& progress,
+ const std::function<bool(uint64_t addr, const std::string& match, const LinearDisassemblyLine& line)>&
+ matchCallback);
+ bool FindAllConstant(uint64_t start, uint64_t end, uint64_t constant, Ref<DisassemblySettings> settings,
+ BNFunctionGraphType graph, const std::function<bool(size_t current, size_t total)>& progress,
+ const std::function<bool(uint64_t addr, const LinearDisassemblyLine& line)>& matchCallback);
void Reanalyze();
@@ -1970,8 +2025,8 @@ __attribute__ ((format (printf, 1, 2)))
void ShowHTMLReport(const std::string& title, const std::string& contents, const std::string& plainText);
void ShowGraphReport(const std::string& title, FlowGraph* graph);
bool GetAddressInput(uint64_t& result, const std::string& prompt, const std::string& title);
- bool GetAddressInput(uint64_t& result, const std::string& prompt, const std::string& title,
- uint64_t currentAddress);
+ bool GetAddressInput(
+ uint64_t& result, const std::string& prompt, const std::string& title, uint64_t currentAddress);
void AddAutoSegment(uint64_t start, uint64_t length, uint64_t dataOffset, uint64_t dataLength, uint32_t flags);
void RemoveAutoSegment(uint64_t start, uint64_t length);
@@ -1982,14 +2037,14 @@ __attribute__ ((format (printf, 1, 2)))
bool GetAddressForDataOffset(uint64_t offset, uint64_t& addr);
void AddAutoSection(const std::string& name, uint64_t start, uint64_t length,
- BNSectionSemantics semantics = DefaultSectionSemantics, const std::string& type = "",
- uint64_t align = 1, uint64_t entrySize = 0, const std::string& linkedSection = "",
- const std::string& infoSection = "", uint64_t infoData = 0);
+ BNSectionSemantics semantics = DefaultSectionSemantics, const std::string& type = "", uint64_t align = 1,
+ uint64_t entrySize = 0, const std::string& linkedSection = "", const std::string& infoSection = "",
+ uint64_t infoData = 0);
void RemoveAutoSection(const std::string& name);
void AddUserSection(const std::string& name, uint64_t start, uint64_t length,
- BNSectionSemantics semantics = DefaultSectionSemantics, const std::string& type = "",
- uint64_t align = 1, uint64_t entrySize = 0, const std::string& linkedSection = "",
- const std::string& infoSection = "", uint64_t infoData = 0);
+ BNSectionSemantics semantics = DefaultSectionSemantics, const std::string& type = "", uint64_t align = 1,
+ uint64_t entrySize = 0, const std::string& linkedSection = "", const std::string& infoSection = "",
+ uint64_t infoData = 0);
void RemoveUserSection(const std::string& name);
std::vector<Ref<Section>> GetSections();
std::vector<Ref<Section>> GetSectionsAt(uint64_t addr);
@@ -2025,20 +2080,19 @@ __attribute__ ((format (printf, 1, 2)))
static NameSpace GetInternalNameSpace();
static NameSpace GetExternalNameSpace();
- static bool ParseExpression(Ref<BinaryView> view, const std::string& expression, uint64_t &offset, uint64_t here, std::string& errorString);
+ static bool ParseExpression(Ref<BinaryView> view, const std::string& expression, uint64_t& offset,
+ uint64_t here, std::string& errorString);
bool HasSymbols() const;
bool HasDataVariables() const;
- Ref<Structure> CreateStructureFromOffsetAccess(const QualifiedName& type,
- bool* newMemberAdded) const;
- Confidence<Ref<Type>> CreateStructureMemberFromAccess(const QualifiedName& name,
- uint64_t offset) const;
+ Ref<Structure> CreateStructureFromOffsetAccess(const QualifiedName& type, bool* newMemberAdded) const;
+ Confidence<Ref<Type>> CreateStructureMemberFromAccess(const QualifiedName& name, uint64_t offset) const;
};
- class Relocation: public CoreRefCountObject<BNRelocation, BNNewRelocationReference, BNFreeRelocation>
+ class Relocation : public CoreRefCountObject<BNRelocation, BNNewRelocationReference, BNFreeRelocation>
{
- public:
+ public:
Relocation(BNRelocation* reloc);
BNRelocationInfo GetInfo() const;
Architecture* GetArchitecture() const;
@@ -2048,9 +2102,9 @@ __attribute__ ((format (printf, 1, 2)))
};
- class BinaryData: public BinaryView
+ class BinaryData : public BinaryView
{
- public:
+ public:
BinaryData(FileMetadata* file);
BinaryData(FileMetadata* file, const DataBuffer& data);
BinaryData(FileMetadata* file, const void* data, size_t len);
@@ -2060,7 +2114,7 @@ __attribute__ ((format (printf, 1, 2)))
class Platform;
- class BinaryViewType: public StaticCoreRefCountObject<BNBinaryViewType>
+ class BinaryViewType : public StaticCoreRefCountObject<BNBinaryViewType>
{
struct BinaryViewEvent
{
@@ -2072,7 +2126,7 @@ __attribute__ ((format (printf, 1, 2)))
std::function<Ref<Platform>(BinaryView*, Metadata*)> action;
};
- protected:
+ protected:
std::string m_nameForRegister, m_longNameForRegister;
static BNBinaryView* CreateCallback(void* ctxt, BNBinaryView* data);
@@ -2082,7 +2136,7 @@ __attribute__ ((format (printf, 1, 2)))
BinaryViewType(BNBinaryViewType* type);
- public:
+ public:
BinaryViewType(const std::string& name, const std::string& longName);
virtual ~BinaryViewType() {}
@@ -2101,7 +2155,8 @@ __attribute__ ((format (printf, 1, 2)))
void RegisterDefaultPlatform(Architecture* arch, Platform* platform);
Ref<Platform> GetPlatform(uint32_t id, Architecture* arch);
- void RegisterPlatformRecognizer(uint64_t id, BNEndianness endian, const std::function<Ref<Platform>(BinaryView* view, Metadata*)>& callback);
+ void RegisterPlatformRecognizer(uint64_t id, BNEndianness endian,
+ const std::function<Ref<Platform>(BinaryView* view, Metadata*)>& callback);
Ref<Platform> RecognizePlatform(uint64_t id, BNEndianness endian, BinaryView* view, Metadata* metadata);
std::string GetName();
@@ -2115,15 +2170,16 @@ __attribute__ ((format (printf, 1, 2)))
virtual Ref<Settings> GetLoadSettingsForData(BinaryView* data) = 0;
static void RegisterBinaryViewFinalizationEvent(const std::function<void(BinaryView* view)>& callback);
- static void RegisterBinaryViewInitialAnalysisCompletionEvent(const std::function<void(BinaryView* view)>& callback);
+ static void RegisterBinaryViewInitialAnalysisCompletionEvent(
+ const std::function<void(BinaryView* view)>& callback);
static void BinaryViewEventCallback(void* ctxt, BNBinaryView* view);
static BNPlatform* PlatformRecognizerCallback(void* ctxt, BNBinaryView* view, BNMetadata* metadata);
};
- class CoreBinaryViewType: public BinaryViewType
+ class CoreBinaryViewType : public BinaryViewType
{
- public:
+ public:
CoreBinaryViewType(BNBinaryViewType* type);
virtual BinaryView* Create(BinaryView* data) override;
virtual BinaryView* Parse(BinaryView* data) override;
@@ -2131,10 +2187,10 @@ __attribute__ ((format (printf, 1, 2)))
virtual Ref<Settings> GetLoadSettingsForData(BinaryView* data) override;
};
- class ReadException: public std::exception
+ class ReadException : public std::exception
{
- public:
- ReadException(): std::exception() {}
+ public:
+ ReadException() : std::exception() {}
virtual const char* what() const NOEXCEPT { return "read out of bounds"; }
};
@@ -2143,7 +2199,7 @@ __attribute__ ((format (printf, 1, 2)))
Ref<BinaryView> m_view;
BNBinaryReader* m_stream;
- public:
+ public:
BinaryReader(BinaryView* data, BNEndianness endian = LittleEndian);
~BinaryReader();
@@ -2152,10 +2208,12 @@ __attribute__ ((format (printf, 1, 2)))
void Read(void* dest, size_t len);
DataBuffer Read(size_t len);
- template <typename T> T Read();
- template <typename T> std::vector<T> ReadVector(size_t count);
+ template <typename T>
+ T Read();
+ template <typename T>
+ std::vector<T> ReadVector(size_t count);
std::string ReadString(size_t len);
- std::string ReadCString(size_t maxLength=-1);
+ std::string ReadCString(size_t maxLength = -1);
uint8_t Read8();
uint16_t Read16();
@@ -2189,10 +2247,10 @@ __attribute__ ((format (printf, 1, 2)))
bool IsEndOfFile() const;
};
- class WriteException: public std::exception
+ class WriteException : public std::exception
{
- public:
- WriteException(): std::exception() {}
+ public:
+ WriteException() : std::exception() {}
virtual const char* what() const NOEXCEPT { return "write out of bounds"; }
};
@@ -2201,7 +2259,7 @@ __attribute__ ((format (printf, 1, 2)))
Ref<BinaryView> m_view;
BNBinaryWriter* m_stream;
- public:
+ public:
BinaryWriter(BinaryView* data, BNEndianness endian = LittleEndian);
~BinaryWriter();
@@ -2244,12 +2302,12 @@ __attribute__ ((format (printf, 1, 2)))
struct TransformParameter
{
std::string name, longName;
- size_t fixedLength; // Variable length if zero
+ size_t fixedLength; // Variable length if zero
};
- class Transform: public StaticCoreRefCountObject<BNTransform>
+ class Transform : public StaticCoreRefCountObject<BNTransform>
{
- protected:
+ protected:
BNTransformType m_typeForRegister;
std::string m_nameForRegister, m_longNameForRegister, m_groupForRegister;
@@ -2257,13 +2315,16 @@ __attribute__ ((format (printf, 1, 2)))
static BNTransformParameterInfo* GetParametersCallback(void* ctxt, size_t* count);
static void FreeParametersCallback(BNTransformParameterInfo* params, size_t count);
- static bool DecodeCallback(void* ctxt, BNDataBuffer* input, BNDataBuffer* output, BNTransformParameter* params, size_t paramCount);
- static bool EncodeCallback(void* ctxt, BNDataBuffer* input, BNDataBuffer* output, BNTransformParameter* params, size_t paramCount);
+ static bool DecodeCallback(
+ void* ctxt, BNDataBuffer* input, BNDataBuffer* output, BNTransformParameter* params, size_t paramCount);
+ static bool EncodeCallback(
+ void* ctxt, BNDataBuffer* input, BNDataBuffer* output, BNTransformParameter* params, size_t paramCount);
static std::vector<TransformParameter> EncryptionKeyParameters(size_t fixedKeyLength = 0);
- static std::vector<TransformParameter> EncryptionKeyAndIVParameters(size_t fixedKeyLength = 0, size_t fixedIVLength = 0);
+ static std::vector<TransformParameter> EncryptionKeyAndIVParameters(
+ size_t fixedKeyLength = 0, size_t fixedIVLength = 0);
- public:
+ public:
Transform(BNTransformType type, const std::string& name, const std::string& longName, const std::string& group);
static void Register(Transform* xform);
@@ -2277,25 +2338,25 @@ __attribute__ ((format (printf, 1, 2)))
virtual std::vector<TransformParameter> GetParameters() const;
- virtual bool Decode(const DataBuffer& input, DataBuffer& output, const std::map<std::string, DataBuffer>& params =
- std::map<std::string, DataBuffer>());
- virtual bool Encode(const DataBuffer& input, DataBuffer& output, const std::map<std::string, DataBuffer>& params =
- std::map<std::string, DataBuffer>());
+ virtual bool Decode(const DataBuffer& input, DataBuffer& output,
+ const std::map<std::string, DataBuffer>& params = std::map<std::string, DataBuffer>());
+ virtual bool Encode(const DataBuffer& input, DataBuffer& output,
+ const std::map<std::string, DataBuffer>& params = std::map<std::string, DataBuffer>());
};
- class CoreTransform: public Transform
+ class CoreTransform : public Transform
{
- public:
+ public:
CoreTransform(BNTransform* xform);
virtual std::vector<TransformParameter> GetParameters() const override;
- virtual bool Decode(const DataBuffer& input, DataBuffer& output, const std::map<std::string, DataBuffer>& params =
- std::map<std::string, DataBuffer>()) override;
- virtual bool Encode(const DataBuffer& input, DataBuffer& output, const std::map<std::string, DataBuffer>& params =
- std::map<std::string, DataBuffer>()) override;
+ virtual bool Decode(const DataBuffer& input, DataBuffer& output,
+ const std::map<std::string, DataBuffer>& params = std::map<std::string, DataBuffer>()) override;
+ virtual bool Encode(const DataBuffer& input, DataBuffer& output,
+ const std::map<std::string, DataBuffer>& params = std::map<std::string, DataBuffer>()) override;
};
- struct InstructionInfo: public BNInstructionInfo
+ struct InstructionInfo : public BNInstructionInfo
{
InstructionInfo();
void AddBranch(BNBranchType type, uint64_t target = 0, Architecture* arch = nullptr, bool hasDelaySlot = false);
@@ -2307,8 +2368,8 @@ __attribute__ ((format (printf, 1, 2)))
Confidence<Ref<Type>> type;
NameAndType() {}
- NameAndType(const Confidence<Ref<Type>>& t): type(t) {}
- NameAndType(const std::string& n, const Confidence<Ref<Type>>& t): name(n), type(t) {}
+ NameAndType(const Confidence<Ref<Type>>& t) : type(t) {}
+ NameAndType(const std::string& n, const Confidence<Ref<Type>>& t) : name(n), type(t) {}
};
class Function;
@@ -2323,12 +2384,12 @@ __attribute__ ((format (printf, 1, 2)))
typedef size_t ExprId;
/*!
- The Architecture class is the base class for all CPU architectures. This provides disassembly, assembly,
- patching, and IL translation lifting for a given architecture.
+ The Architecture class is the base class for all CPU architectures. This provides disassembly, assembly,
+ patching, and IL translation lifting for a given architecture.
*/
- class Architecture: public StaticCoreRefCountObject<BNArchitecture>
+ class Architecture : public StaticCoreRefCountObject<BNArchitecture>
{
- protected:
+ protected:
std::string m_nameForRegister;
Architecture(BNArchitecture* arch);
@@ -2341,13 +2402,13 @@ __attribute__ ((format (printf, 1, 2)))
static size_t GetMaxInstructionLengthCallback(void* ctxt);
static size_t GetOpcodeDisplayLengthCallback(void* ctxt);
static BNArchitecture* GetAssociatedArchitectureByAddressCallback(void* ctxt, uint64_t* addr);
- static bool GetInstructionInfoCallback(void* ctxt, const uint8_t* data, uint64_t addr,
- size_t maxLen, BNInstructionInfo* result);
- static bool GetInstructionTextCallback(void* ctxt, const uint8_t* data, uint64_t addr,
- size_t* len, BNInstructionTextToken** result, size_t* count);
+ static bool GetInstructionInfoCallback(
+ void* ctxt, const uint8_t* data, uint64_t addr, size_t maxLen, BNInstructionInfo* result);
+ static bool GetInstructionTextCallback(void* ctxt, const uint8_t* data, uint64_t addr, size_t* len,
+ BNInstructionTextToken** result, size_t* count);
static void FreeInstructionTextCallback(BNInstructionTextToken* tokens, size_t count);
- static bool GetInstructionLowLevelILCallback(void* ctxt, const uint8_t* data, uint64_t addr,
- size_t* len, BNLowLevelILFunction* il);
+ static bool GetInstructionLowLevelILCallback(
+ void* ctxt, const uint8_t* data, uint64_t addr, size_t* len, BNLowLevelILFunction* il);
static char* GetRegisterNameCallback(void* ctxt, uint32_t reg);
static char* GetFlagNameCallback(void* ctxt, uint32_t flag);
static char* GetFlagWriteTypeNameCallback(void* ctxt, uint32_t flags);
@@ -2360,18 +2421,20 @@ __attribute__ ((format (printf, 1, 2)))
static uint32_t* GetAllSemanticFlagClassesCallback(void* ctxt, size_t* count);
static uint32_t* GetAllSemanticFlagGroupsCallback(void* ctxt, size_t* count);
static BNFlagRole GetFlagRoleCallback(void* ctxt, uint32_t flag, uint32_t semClass);
- static uint32_t* GetFlagsRequiredForFlagConditionCallback(void* ctxt, BNLowLevelILFlagCondition cond,
- uint32_t semClass, size_t* count);
+ static uint32_t* GetFlagsRequiredForFlagConditionCallback(
+ void* ctxt, BNLowLevelILFlagCondition cond, uint32_t semClass, size_t* count);
static uint32_t* GetFlagsRequiredForSemanticFlagGroupCallback(void* ctxt, uint32_t semGroup, size_t* count);
- static BNFlagConditionForSemanticClass* GetFlagConditionsForSemanticFlagGroupCallback(void* ctxt,
- uint32_t semGroup, size_t* count);
- static void FreeFlagConditionsForSemanticFlagGroupCallback(void* ctxt, BNFlagConditionForSemanticClass* conditions);
+ static BNFlagConditionForSemanticClass* GetFlagConditionsForSemanticFlagGroupCallback(
+ void* ctxt, uint32_t semGroup, size_t* count);
+ static void FreeFlagConditionsForSemanticFlagGroupCallback(
+ void* ctxt, BNFlagConditionForSemanticClass* conditions);
static uint32_t* GetFlagsWrittenByFlagWriteTypeCallback(void* ctxt, uint32_t writeType, size_t* count);
static uint32_t GetSemanticClassForFlagWriteTypeCallback(void* ctxt, uint32_t writeType);
- static size_t GetFlagWriteLowLevelILCallback(void* ctxt, BNLowLevelILOperation op, size_t size, uint32_t flagWriteType,
- uint32_t flag, BNRegisterOrConstant* operands, size_t operandCount, BNLowLevelILFunction* il);
- static size_t GetFlagConditionLowLevelILCallback(void* ctxt, BNLowLevelILFlagCondition cond,
- uint32_t semClass, BNLowLevelILFunction* il);
+ static size_t GetFlagWriteLowLevelILCallback(void* ctxt, BNLowLevelILOperation op, size_t size,
+ uint32_t flagWriteType, uint32_t flag, BNRegisterOrConstant* operands, size_t operandCount,
+ BNLowLevelILFunction* il);
+ static size_t GetFlagConditionLowLevelILCallback(
+ void* ctxt, BNLowLevelILFlagCondition cond, uint32_t semClass, BNLowLevelILFunction* il);
static size_t GetSemanticFlagGroupLowLevelILCallback(void* ctxt, uint32_t semGroup, BNLowLevelILFunction* il);
static void FreeRegisterListCallback(void* ctxt, uint32_t* regs);
static void GetRegisterInfoCallback(void* ctxt, uint32_t reg, BNRegisterInfo* result);
@@ -2396,8 +2459,10 @@ __attribute__ ((format (printf, 1, 2)))
static bool IsNeverBranchPatchAvailableCallback(void* ctxt, const uint8_t* data, uint64_t addr, size_t len);
static bool IsAlwaysBranchPatchAvailableCallback(void* ctxt, const uint8_t* data, uint64_t addr, size_t len);
static bool IsInvertBranchPatchAvailableCallback(void* ctxt, const uint8_t* data, uint64_t addr, size_t len);
- static bool IsSkipAndReturnZeroPatchAvailableCallback(void* ctxt, const uint8_t* data, uint64_t addr, size_t len);
- static bool IsSkipAndReturnValuePatchAvailableCallback(void* ctxt, const uint8_t* data, uint64_t addr, size_t len);
+ static bool IsSkipAndReturnZeroPatchAvailableCallback(
+ void* ctxt, const uint8_t* data, uint64_t addr, size_t len);
+ static bool IsSkipAndReturnValuePatchAvailableCallback(
+ void* ctxt, const uint8_t* data, uint64_t addr, size_t len);
static bool ConvertToNopCallback(void* ctxt, uint8_t* data, uint64_t addr, size_t len);
static bool AlwaysBranchCallback(void* ctxt, uint8_t* data, uint64_t addr, size_t len);
@@ -2406,7 +2471,7 @@ __attribute__ ((format (printf, 1, 2)))
virtual void Register(BNCustomArchitecture* callbacks);
- public:
+ public:
Architecture(const std::string& name);
static void Register(Architecture* arch);
@@ -2426,15 +2491,15 @@ __attribute__ ((format (printf, 1, 2)))
virtual Ref<Architecture> GetAssociatedArchitectureByAddress(uint64_t& addr);
virtual bool GetInstructionInfo(const uint8_t* data, uint64_t addr, size_t maxLen, InstructionInfo& result) = 0;
- virtual bool GetInstructionText(const uint8_t* data, uint64_t addr, size_t& len,
- std::vector<InstructionTextToken>& result) = 0;
+ virtual bool GetInstructionText(
+ const uint8_t* data, uint64_t addr, size_t& len, std::vector<InstructionTextToken>& result) = 0;
/*! GetInstructionLowLevelIL
- Translates an instruction at addr and appends it onto the LowLevelILFunction& il.
- \param data pointer to the instruction data to be translated
- \param addr address of the instruction data to be translated
- \param len length of the instruction data to be translated
- \param il the LowLevelILFunction which
+ Translates an instruction at addr and appends it onto the LowLevelILFunction& il.
+ \param data pointer to the instruction data to be translated
+ \param addr address of the instruction data to be translated
+ \param len length of the instruction data to be translated
+ \param il the LowLevelILFunction which
*/
virtual bool GetInstructionLowLevelIL(const uint8_t* data, uint64_t addr, size_t& len, LowLevelILFunction& il);
virtual std::string GetRegisterName(uint32_t reg);
@@ -2449,18 +2514,20 @@ __attribute__ ((format (printf, 1, 2)))
virtual std::vector<uint32_t> GetAllSemanticFlagClasses();
virtual std::vector<uint32_t> GetAllSemanticFlagGroups();
virtual BNFlagRole GetFlagRole(uint32_t flag, uint32_t semClass = 0);
- virtual std::vector<uint32_t> GetFlagsRequiredForFlagCondition(BNLowLevelILFlagCondition cond,
- uint32_t semClass = 0);
+ virtual std::vector<uint32_t> GetFlagsRequiredForFlagCondition(
+ BNLowLevelILFlagCondition cond, uint32_t semClass = 0);
virtual std::vector<uint32_t> GetFlagsRequiredForSemanticFlagGroup(uint32_t semGroup);
virtual std::map<uint32_t, BNLowLevelILFlagCondition> GetFlagConditionsForSemanticFlagGroup(uint32_t semGroup);
virtual std::vector<uint32_t> GetFlagsWrittenByFlagWriteType(uint32_t writeType);
virtual uint32_t GetSemanticClassForFlagWriteType(uint32_t writeType);
virtual ExprId GetFlagWriteLowLevelIL(BNLowLevelILOperation op, size_t size, uint32_t flagWriteType,
- uint32_t flag, BNRegisterOrConstant* operands, size_t operandCount, LowLevelILFunction& il);
+ uint32_t flag, BNRegisterOrConstant* operands, size_t operandCount, LowLevelILFunction& il);
ExprId GetDefaultFlagWriteLowLevelIL(BNLowLevelILOperation op, size_t size, BNFlagRole role,
- BNRegisterOrConstant* operands, size_t operandCount, LowLevelILFunction& il);
- virtual ExprId GetFlagConditionLowLevelIL(BNLowLevelILFlagCondition cond, uint32_t semClass, LowLevelILFunction& il);
- ExprId GetDefaultFlagConditionLowLevelIL(BNLowLevelILFlagCondition cond, uint32_t semClass, LowLevelILFunction& il);
+ BNRegisterOrConstant* operands, size_t operandCount, LowLevelILFunction& il);
+ virtual ExprId GetFlagConditionLowLevelIL(
+ BNLowLevelILFlagCondition cond, uint32_t semClass, LowLevelILFunction& il);
+ ExprId GetDefaultFlagConditionLowLevelIL(
+ BNLowLevelILFlagCondition cond, uint32_t semClass, LowLevelILFunction& il);
virtual ExprId GetSemanticFlagGroupLowLevelIL(uint32_t semGroup, LowLevelILFunction& il);
virtual BNRegisterInfo GetRegisterInfo(uint32_t reg);
virtual uint32_t GetStackPointerRegister();
@@ -2558,8 +2625,7 @@ __attribute__ ((format (printf, 1, 2)))
Ref<RelocationHandler> GetRelocationHandler(const std::string& viewName);
bool IsBinaryViewTypeConstantDefined(const std::string& type, const std::string& name);
- uint64_t GetBinaryViewTypeConstant(const std::string& type, const std::string& name,
- uint64_t defaultValue = 0);
+ uint64_t GetBinaryViewTypeConstant(const std::string& type, const std::string& name, uint64_t defaultValue = 0);
void SetBinaryViewTypeConstant(const std::string& type, const std::string& name, uint64_t value);
void RegisterCallingConvention(CallingConvention* cc);
@@ -2579,9 +2645,9 @@ __attribute__ ((format (printf, 1, 2)))
void AddArchitectureRedirection(Architecture* from, Architecture* to);
};
- class CoreArchitecture: public Architecture
+ class CoreArchitecture : public Architecture
{
- public:
+ public:
CoreArchitecture(BNArchitecture* arch);
virtual BNEndianness GetEndianness() const override;
virtual size_t GetAddressSize() const override;
@@ -2590,10 +2656,12 @@ __attribute__ ((format (printf, 1, 2)))
virtual size_t GetMaxInstructionLength() const override;
virtual size_t GetOpcodeDisplayLength() const override;
virtual Ref<Architecture> GetAssociatedArchitectureByAddress(uint64_t& addr) override;
- virtual bool GetInstructionInfo(const uint8_t* data, uint64_t addr, size_t maxLen, InstructionInfo& result) override;
- virtual bool GetInstructionText(const uint8_t* data, uint64_t addr, size_t& len,
- std::vector<InstructionTextToken>& result) override;
- virtual bool GetInstructionLowLevelIL(const uint8_t* data, uint64_t addr, size_t& len, LowLevelILFunction& il) override;
+ virtual bool GetInstructionInfo(
+ const uint8_t* data, uint64_t addr, size_t maxLen, InstructionInfo& result) override;
+ virtual bool GetInstructionText(
+ const uint8_t* data, uint64_t addr, size_t& len, std::vector<InstructionTextToken>& result) override;
+ virtual bool GetInstructionLowLevelIL(
+ const uint8_t* data, uint64_t addr, size_t& len, LowLevelILFunction& il) override;
virtual std::string GetRegisterName(uint32_t reg) override;
virtual std::string GetFlagName(uint32_t flag) override;
virtual std::string GetFlagWriteTypeName(uint32_t flags) override;
@@ -2607,16 +2675,17 @@ __attribute__ ((format (printf, 1, 2)))
virtual std::vector<uint32_t> GetAllSemanticFlagClasses() override;
virtual std::vector<uint32_t> GetAllSemanticFlagGroups() override;
virtual BNFlagRole GetFlagRole(uint32_t flag, uint32_t semClass = 0) override;
- virtual std::vector<uint32_t> GetFlagsRequiredForFlagCondition(BNLowLevelILFlagCondition cond,
- uint32_t semClass = 0) override;
+ virtual std::vector<uint32_t> GetFlagsRequiredForFlagCondition(
+ BNLowLevelILFlagCondition cond, uint32_t semClass = 0) override;
virtual std::vector<uint32_t> GetFlagsRequiredForSemanticFlagGroup(uint32_t semGroup) override;
- virtual std::map<uint32_t, BNLowLevelILFlagCondition> GetFlagConditionsForSemanticFlagGroup(uint32_t semGroup) override;
+ virtual std::map<uint32_t, BNLowLevelILFlagCondition> GetFlagConditionsForSemanticFlagGroup(
+ uint32_t semGroup) override;
virtual std::vector<uint32_t> GetFlagsWrittenByFlagWriteType(uint32_t writeType) override;
virtual uint32_t GetSemanticClassForFlagWriteType(uint32_t writeType) override;
virtual ExprId GetFlagWriteLowLevelIL(BNLowLevelILOperation op, size_t size, uint32_t flagWriteType,
- uint32_t flag, BNRegisterOrConstant* operands, size_t operandCount, LowLevelILFunction& il) override;
- virtual ExprId GetFlagConditionLowLevelIL(BNLowLevelILFlagCondition cond,
- uint32_t semClass, LowLevelILFunction& il) override;
+ uint32_t flag, BNRegisterOrConstant* operands, size_t operandCount, LowLevelILFunction& il) override;
+ virtual ExprId GetFlagConditionLowLevelIL(
+ BNLowLevelILFlagCondition cond, uint32_t semClass, LowLevelILFunction& il) override;
virtual ExprId GetSemanticFlagGroupLowLevelIL(uint32_t semGroup, LowLevelILFunction& il) override;
virtual BNRegisterInfo GetRegisterInfo(uint32_t reg) override;
virtual uint32_t GetStackPointerRegister() override;
@@ -2648,14 +2717,14 @@ __attribute__ ((format (printf, 1, 2)))
virtual bool SkipAndReturnValue(uint8_t* data, uint64_t addr, size_t len, uint64_t value) override;
};
- class ArchitectureExtension: public Architecture
+ class ArchitectureExtension : public Architecture
{
- protected:
+ protected:
Ref<Architecture> m_base;
virtual void Register(BNCustomArchitecture* callbacks) override;
- public:
+ public:
ArchitectureExtension(const std::string& name, Architecture* base);
Ref<Architecture> GetBaseArchitecture() const { return m_base; }
@@ -2667,10 +2736,12 @@ __attribute__ ((format (printf, 1, 2)))
virtual size_t GetMaxInstructionLength() const override;
virtual size_t GetOpcodeDisplayLength() const override;
virtual Ref<Architecture> GetAssociatedArchitectureByAddress(uint64_t& addr) override;
- virtual bool GetInstructionInfo(const uint8_t* data, uint64_t addr, size_t maxLen, InstructionInfo& result) override;
- virtual bool GetInstructionText(const uint8_t* data, uint64_t addr, size_t& len,
- std::vector<InstructionTextToken>& result) override;
- virtual bool GetInstructionLowLevelIL(const uint8_t* data, uint64_t addr, size_t& len, LowLevelILFunction& il) override;
+ virtual bool GetInstructionInfo(
+ const uint8_t* data, uint64_t addr, size_t maxLen, InstructionInfo& result) override;
+ virtual bool GetInstructionText(
+ const uint8_t* data, uint64_t addr, size_t& len, std::vector<InstructionTextToken>& result) override;
+ virtual bool GetInstructionLowLevelIL(
+ const uint8_t* data, uint64_t addr, size_t& len, LowLevelILFunction& il) override;
virtual std::string GetRegisterName(uint32_t reg) override;
virtual std::string GetFlagName(uint32_t flag) override;
virtual std::string GetFlagWriteTypeName(uint32_t flags) override;
@@ -2683,16 +2754,17 @@ __attribute__ ((format (printf, 1, 2)))
virtual std::vector<uint32_t> GetAllSemanticFlagClasses() override;
virtual std::vector<uint32_t> GetAllSemanticFlagGroups() override;
virtual BNFlagRole GetFlagRole(uint32_t flag, uint32_t semClass = 0) override;
- virtual std::vector<uint32_t> GetFlagsRequiredForFlagCondition(BNLowLevelILFlagCondition cond,
- uint32_t semClass = 0) override;
+ virtual std::vector<uint32_t> GetFlagsRequiredForFlagCondition(
+ BNLowLevelILFlagCondition cond, uint32_t semClass = 0) override;
virtual std::vector<uint32_t> GetFlagsRequiredForSemanticFlagGroup(uint32_t semGroup) override;
- virtual std::map<uint32_t, BNLowLevelILFlagCondition> GetFlagConditionsForSemanticFlagGroup(uint32_t semGroup) override;
+ virtual std::map<uint32_t, BNLowLevelILFlagCondition> GetFlagConditionsForSemanticFlagGroup(
+ uint32_t semGroup) override;
virtual std::vector<uint32_t> GetFlagsWrittenByFlagWriteType(uint32_t writeType) override;
virtual uint32_t GetSemanticClassForFlagWriteType(uint32_t writeType) override;
virtual ExprId GetFlagWriteLowLevelIL(BNLowLevelILOperation op, size_t size, uint32_t flagWriteType,
- uint32_t flag, BNRegisterOrConstant* operands, size_t operandCount, LowLevelILFunction& il) override;
- virtual ExprId GetFlagConditionLowLevelIL(BNLowLevelILFlagCondition cond,
- uint32_t semClass, LowLevelILFunction& il) override;
+ uint32_t flag, BNRegisterOrConstant* operands, size_t operandCount, LowLevelILFunction& il) override;
+ virtual ExprId GetFlagConditionLowLevelIL(
+ BNLowLevelILFlagCondition cond, uint32_t semClass, LowLevelILFunction& il) override;
virtual ExprId GetSemanticFlagGroupLowLevelIL(uint32_t semGroup, LowLevelILFunction& il) override;
virtual BNRegisterInfo GetRegisterInfo(uint32_t reg) override;
virtual uint32_t GetStackPointerRegister() override;
@@ -2724,14 +2796,14 @@ __attribute__ ((format (printf, 1, 2)))
virtual bool SkipAndReturnValue(uint8_t* data, uint64_t addr, size_t len, uint64_t value) override;
};
- class ArchitectureHook: public CoreArchitecture
+ class ArchitectureHook : public CoreArchitecture
{
- protected:
+ protected:
Ref<Architecture> m_base;
virtual void Register(BNCustomArchitecture* callbacks) override;
- public:
+ public:
ArchitectureHook(Architecture* base);
};
@@ -2739,7 +2811,7 @@ __attribute__ ((format (printf, 1, 2)))
class NamedTypeReference;
class Enumeration;
- struct Variable: public BNVariable
+ struct Variable : public BNVariable
{
Variable();
Variable(BNVariableSourceType type, uint32_t index, uint64_t storage);
@@ -2777,9 +2849,9 @@ __attribute__ ((format (printf, 1, 2)))
Ref<Type> type;
};
- class Type: public CoreRefCountObject<BNType, BNNewTypeReference, BNFreeType>
+ class Type : public CoreRefCountObject<BNType, BNNewTypeReference, BNFreeType>
{
- public:
+ public:
Type(BNType* type);
bool operator==(const Type& other);
@@ -2817,12 +2889,12 @@ __attribute__ ((format (printf, 1, 2)))
std::string GetStringBeforeName(Platform* platform = nullptr) const;
std::string GetStringAfterName(Platform* platform = nullptr) const;
- std::vector<InstructionTextToken> GetTokens(Platform* platform = nullptr,
- uint8_t baseConfidence = BN_FULL_CONFIDENCE) const;
- std::vector<InstructionTextToken> GetTokensBeforeName(Platform* platform = nullptr,
- uint8_t baseConfidence = BN_FULL_CONFIDENCE) const;
- std::vector<InstructionTextToken> GetTokensAfterName(Platform* platform = nullptr,
- uint8_t baseConfidence = BN_FULL_CONFIDENCE) const;
+ std::vector<InstructionTextToken> GetTokens(
+ Platform* platform = nullptr, uint8_t baseConfidence = BN_FULL_CONFIDENCE) const;
+ std::vector<InstructionTextToken> GetTokensBeforeName(
+ Platform* platform = nullptr, uint8_t baseConfidence = BN_FULL_CONFIDENCE) const;
+ std::vector<InstructionTextToken> GetTokensAfterName(
+ Platform* platform = nullptr, uint8_t baseConfidence = BN_FULL_CONFIDENCE) const;
Ref<Type> Duplicate() const;
@@ -2833,25 +2905,28 @@ __attribute__ ((format (printf, 1, 2)))
static Ref<Type> WideCharType(size_t width, const std::string& altName = "");
static Ref<Type> StructureType(Structure* strct);
static Ref<Type> NamedType(NamedTypeReference* ref, size_t width = 0, size_t align = 1,
- const Confidence<bool>& cnst = Confidence<bool>(false, 0), const Confidence<bool>& vltl = Confidence<bool>(false, 0));
+ const Confidence<bool>& cnst = Confidence<bool>(false, 0),
+ const Confidence<bool>& vltl = Confidence<bool>(false, 0));
static Ref<Type> NamedType(const QualifiedName& name, Type* type);
static Ref<Type> NamedType(const std::string& id, const QualifiedName& name, Type* type);
static Ref<Type> NamedType(BinaryView* view, const QualifiedName& name);
- static Ref<Type> EnumerationType(Architecture* arch, Enumeration* enm, size_t width = 0, const Confidence<bool>& isSigned = Confidence<bool>(false, 0));
- static Ref<Type> EnumerationType(Enumeration* enm, size_t width, const Confidence<bool>& isSigned = Confidence<bool>(false, 0));
+ static Ref<Type> EnumerationType(Architecture* arch, Enumeration* enm, size_t width = 0,
+ const Confidence<bool>& isSigned = Confidence<bool>(false, 0));
+ static Ref<Type> EnumerationType(
+ Enumeration* enm, size_t width, const Confidence<bool>& isSigned = Confidence<bool>(false, 0));
static Ref<Type> PointerType(Architecture* arch, const Confidence<Ref<Type>>& type,
- const Confidence<bool>& cnst = Confidence<bool>(false, 0),
- const Confidence<bool>& vltl = Confidence<bool>(false, 0), BNReferenceType refType = PointerReferenceType);
+ const Confidence<bool>& cnst = Confidence<bool>(false, 0),
+ const Confidence<bool>& vltl = Confidence<bool>(false, 0), BNReferenceType refType = PointerReferenceType);
static Ref<Type> PointerType(size_t width, const Confidence<Ref<Type>>& type,
- const Confidence<bool>& cnst = Confidence<bool>(false, 0),
- const Confidence<bool>& vltl = Confidence<bool>(false, 0), BNReferenceType refType = PointerReferenceType);
+ const Confidence<bool>& cnst = Confidence<bool>(false, 0),
+ const Confidence<bool>& vltl = Confidence<bool>(false, 0), BNReferenceType refType = PointerReferenceType);
static Ref<Type> ArrayType(const Confidence<Ref<Type>>& type, uint64_t elem);
static Ref<Type> FunctionType(const Confidence<Ref<Type>>& returnValue,
- const Confidence<Ref<CallingConvention>>& callingConvention,
- const std::vector<FunctionParameter>& params, const Confidence<bool>& varArg = Confidence<bool>(false, 0),
- const Confidence<int64_t>& stackAdjust = Confidence<int64_t>(0, 0));
+ const Confidence<Ref<CallingConvention>>& callingConvention, const std::vector<FunctionParameter>& params,
+ const Confidence<bool>& varArg = Confidence<bool>(false, 0),
+ const Confidence<int64_t>& stackAdjust = Confidence<int64_t>(0, 0));
- static std::string GenerateAutoTypeId(const std::string& source, const QualifiedName& name);
+ static std::string GenerateAutoTypeId(const std::string& source, const QualifiedName& name);
static std::string GenerateAutoDemangledTypeId(const QualifiedName& name);
static std::string GetAutoDemangledTypeIdSource();
static std::string GenerateAutoDebugTypeId(const QualifiedName& name);
@@ -2865,7 +2940,10 @@ __attribute__ ((format (printf, 1, 2)))
bool IsUnionReference() { return IsReferenceOfType(UnionNamedTypeClass); }
bool IsClassReference() { return IsReferenceOfType(ClassNamedTypeClass); }
bool IsTypedefReference() { return IsReferenceOfType(TypedefNamedTypeClass); }
- bool IsStructOrClassReference() { return IsReferenceOfType(StructNamedTypeClass) || IsReferenceOfType(ClassNamedTypeClass); }
+ bool IsStructOrClassReference()
+ {
+ return IsReferenceOfType(StructNamedTypeClass) || IsReferenceOfType(ClassNamedTypeClass);
+ }
bool IsVoid() const { return GetClass() == VoidTypeClass; }
bool IsBool() const { return GetClass() == BoolTypeClass; }
@@ -2886,7 +2964,7 @@ __attribute__ ((format (printf, 1, 2)))
Ref<Type> WithReplacedNamedTypeReference(NamedTypeReference* from, NamedTypeReference* to);
bool AddTypeMemberTokens(BinaryView* data, std::vector<InstructionTextToken>& tokens, int64_t offset,
- std::vector<std::string>& nameList, size_t size = 0, bool indirect = false);
+ std::vector<std::string>& nameList, size_t size = 0, bool indirect = false);
static std::string GetSizeSuffix(size_t size);
};
@@ -2898,7 +2976,7 @@ __attribute__ ((format (printf, 1, 2)))
{
BNTypeBuilder* m_object;
- public:
+ public:
TypeBuilder();
TypeBuilder(BNTypeBuilder* type);
TypeBuilder(const TypeBuilder& type);
@@ -2952,12 +3030,12 @@ __attribute__ ((format (printf, 1, 2)))
std::string GetStringBeforeName(Platform* platform = nullptr) const;
std::string GetStringAfterName(Platform* platform = nullptr) const;
- std::vector<InstructionTextToken> GetTokens(Platform* platform = nullptr,
- uint8_t baseConfidence = BN_FULL_CONFIDENCE) const;
- std::vector<InstructionTextToken> GetTokensBeforeName(Platform* platform = nullptr,
- uint8_t baseConfidence = BN_FULL_CONFIDENCE) const;
- std::vector<InstructionTextToken> GetTokensAfterName(Platform* platform = nullptr,
- uint8_t baseConfidence = BN_FULL_CONFIDENCE) const;
+ std::vector<InstructionTextToken> GetTokens(
+ Platform* platform = nullptr, uint8_t baseConfidence = BN_FULL_CONFIDENCE) const;
+ std::vector<InstructionTextToken> GetTokensBeforeName(
+ Platform* platform = nullptr, uint8_t baseConfidence = BN_FULL_CONFIDENCE) const;
+ std::vector<InstructionTextToken> GetTokensAfterName(
+ Platform* platform = nullptr, uint8_t baseConfidence = BN_FULL_CONFIDENCE) const;
static TypeBuilder VoidType();
static TypeBuilder BoolType();
@@ -2967,25 +3045,29 @@ __attribute__ ((format (printf, 1, 2)))
static TypeBuilder StructureType(Structure* strct);
static TypeBuilder StructureType(StructureBuilder* strct);
static TypeBuilder NamedType(NamedTypeReference* ref, size_t width = 0, size_t align = 1,
- const Confidence<bool>& cnst = Confidence<bool>(false, 0), const Confidence<bool>& vltl = Confidence<bool>(false, 0));
+ const Confidence<bool>& cnst = Confidence<bool>(false, 0),
+ const Confidence<bool>& vltl = Confidence<bool>(false, 0));
static TypeBuilder NamedType(NamedTypeReferenceBuilder* ref, size_t width = 0, size_t align = 1,
- const Confidence<bool>& cnst = Confidence<bool>(false, 0), const Confidence<bool>& vltl = Confidence<bool>(false, 0));
+ const Confidence<bool>& cnst = Confidence<bool>(false, 0),
+ const Confidence<bool>& vltl = Confidence<bool>(false, 0));
static TypeBuilder NamedType(const QualifiedName& name, Type* type);
static TypeBuilder NamedType(const std::string& id, const QualifiedName& name, Type* type);
static TypeBuilder NamedType(BinaryView* view, const QualifiedName& name);
- static TypeBuilder EnumerationType(Architecture* arch, Enumeration* enm, size_t width = 0, const Confidence<bool>& issigned = Confidence<bool>(false, 0));
- static TypeBuilder EnumerationType(Architecture* arch, EnumerationBuilder* enm, size_t width = 0, const Confidence<bool>& issigned = Confidence<bool>(false, 0));
+ static TypeBuilder EnumerationType(Architecture* arch, Enumeration* enm, size_t width = 0,
+ const Confidence<bool>& issigned = Confidence<bool>(false, 0));
+ static TypeBuilder EnumerationType(Architecture* arch, EnumerationBuilder* enm, size_t width = 0,
+ const Confidence<bool>& issigned = Confidence<bool>(false, 0));
static TypeBuilder PointerType(Architecture* arch, const Confidence<Ref<Type>>& type,
- const Confidence<bool>& cnst = Confidence<bool>(false, 0),
- const Confidence<bool>& vltl = Confidence<bool>(false, 0), BNReferenceType refType = PointerReferenceType);
+ const Confidence<bool>& cnst = Confidence<bool>(false, 0),
+ const Confidence<bool>& vltl = Confidence<bool>(false, 0), BNReferenceType refType = PointerReferenceType);
static TypeBuilder PointerType(size_t width, const Confidence<Ref<Type>>& type,
- const Confidence<bool>& cnst = Confidence<bool>(false, 0),
- const Confidence<bool>& vltl = Confidence<bool>(false, 0), BNReferenceType refType = PointerReferenceType);
+ const Confidence<bool>& cnst = Confidence<bool>(false, 0),
+ const Confidence<bool>& vltl = Confidence<bool>(false, 0), BNReferenceType refType = PointerReferenceType);
static TypeBuilder ArrayType(const Confidence<Ref<Type>>& type, uint64_t elem);
static TypeBuilder FunctionType(const Confidence<Ref<Type>>& returnValue,
- const Confidence<Ref<CallingConvention>>& callingConvention,
- const std::vector<FunctionParameter>& params, const Confidence<bool>& varArg = Confidence<bool>(false, 0),
- const Confidence<int64_t>& stackAdjust = Confidence<int64_t>(0, 0));
+ const Confidence<Ref<CallingConvention>>& callingConvention, const std::vector<FunctionParameter>& params,
+ const Confidence<bool>& varArg = Confidence<bool>(false, 0),
+ const Confidence<int64_t>& stackAdjust = Confidence<int64_t>(0, 0));
bool IsReferenceOfType(BNNamedTypeReferenceClass refType);
bool IsStructReference() { return IsReferenceOfType(StructNamedTypeClass); }
@@ -2993,7 +3075,10 @@ __attribute__ ((format (printf, 1, 2)))
bool IsUnionReference() { return IsReferenceOfType(UnionNamedTypeClass); }
bool IsClassReference() { return IsReferenceOfType(ClassNamedTypeClass); }
bool IsTypedefReference() { return IsReferenceOfType(TypedefNamedTypeClass); }
- bool IsStructOrClassReference() { return IsReferenceOfType(StructNamedTypeClass) || IsReferenceOfType(ClassNamedTypeClass); }
+ bool IsStructOrClassReference()
+ {
+ return IsReferenceOfType(StructNamedTypeClass) || IsReferenceOfType(ClassNamedTypeClass);
+ }
bool IsVoid() const { return GetClass() == VoidTypeClass; }
bool IsBool() const { return GetClass() == BoolTypeClass; }
@@ -3010,32 +3095,33 @@ __attribute__ ((format (printf, 1, 2)))
bool IsWideChar() const { return GetClass() == WideCharTypeClass; }
};
- class NamedTypeReference: public CoreRefCountObject<BNNamedTypeReference, BNNewNamedTypeReference,
- BNFreeNamedTypeReference>
+ class NamedTypeReference :
+ public CoreRefCountObject<BNNamedTypeReference, BNNewNamedTypeReference, BNFreeNamedTypeReference>
{
- public:
+ public:
NamedTypeReference(BNNamedTypeReference* nt);
NamedTypeReference(BNNamedTypeReferenceClass cls = UnknownNamedTypeClass, const std::string& id = "",
- const QualifiedName& name = QualifiedName());
+ const QualifiedName& name = QualifiedName());
BNNamedTypeReferenceClass GetTypeReferenceClass() const;
std::string GetTypeId() const;
QualifiedName GetName() const;
- static Ref<NamedTypeReference> GenerateAutoTypeReference(BNNamedTypeReferenceClass cls,
- const std::string& source, const QualifiedName& name);
- static Ref<NamedTypeReference> GenerateAutoDemangledTypeReference(BNNamedTypeReferenceClass cls,
- const QualifiedName& name);
- static Ref<NamedTypeReference> GenerateAutoDebugTypeReference(BNNamedTypeReferenceClass cls,
- const QualifiedName& name);
+ static Ref<NamedTypeReference> GenerateAutoTypeReference(
+ BNNamedTypeReferenceClass cls, const std::string& source, const QualifiedName& name);
+ static Ref<NamedTypeReference> GenerateAutoDemangledTypeReference(
+ BNNamedTypeReferenceClass cls, const QualifiedName& name);
+ static Ref<NamedTypeReference> GenerateAutoDebugTypeReference(
+ BNNamedTypeReferenceClass cls, const QualifiedName& name);
};
class NamedTypeReferenceBuilder
{
BNNamedTypeReferenceBuilder* m_object;
- public:
+
+ public:
NamedTypeReferenceBuilder(BNNamedTypeReferenceBuilder* nt);
NamedTypeReferenceBuilder(BNNamedTypeReferenceClass cls = UnknownNamedTypeClass, const std::string& id = "",
- const QualifiedName& name = QualifiedName());
+ const QualifiedName& name = QualifiedName());
~NamedTypeReferenceBuilder();
BNNamedTypeReferenceBuilder* GetObject() { return m_object; };
BNNamedTypeReferenceClass GetTypeReferenceClass() const;
@@ -3058,9 +3144,9 @@ __attribute__ ((format (printf, 1, 2)))
BNMemberScope scope;
};
- class Structure: public CoreRefCountObject<BNStructure, BNNewStructureReference, BNFreeStructure>
+ class Structure : public CoreRefCountObject<BNStructure, BNNewStructureReference, BNFreeStructure>
{
- public:
+ public:
Structure(BNStructure* s);
std::vector<StructureMember> GetMembers() const;
@@ -3082,7 +3168,7 @@ __attribute__ ((format (printf, 1, 2)))
{
BNStructureBuilder* m_object;
- public:
+ public:
StructureBuilder();
StructureBuilder(BNStructureBuilder* s);
StructureBuilder(BNStructureVariant type, bool packed = false);
@@ -3111,12 +3197,12 @@ __attribute__ ((format (printf, 1, 2)))
StructureBuilder& SetStructureType(BNStructureVariant type);
BNStructureVariant GetStructureType() const;
StructureBuilder& AddMember(const Confidence<Ref<Type>>& type, const std::string& name,
- BNMemberAccess access = NoAccess, BNMemberScope scope = NoScope);
- StructureBuilder& AddMemberAtOffset(const Confidence<Ref<Type>>& type,
- const std::string& name, uint64_t offset, bool overwriteExisting = true,
- BNMemberAccess access = NoAccess, BNMemberScope scope = NoScope);
+ BNMemberAccess access = NoAccess, BNMemberScope scope = NoScope);
+ StructureBuilder& AddMemberAtOffset(const Confidence<Ref<Type>>& type, const std::string& name, uint64_t offset,
+ bool overwriteExisting = true, BNMemberAccess access = NoAccess, BNMemberScope scope = NoScope);
StructureBuilder& RemoveMember(size_t idx);
- StructureBuilder& ReplaceMember(size_t idx, const Confidence<Ref<Type>>& type, const std::string& name, bool overwriteExisting = true);
+ StructureBuilder& ReplaceMember(
+ size_t idx, const Confidence<Ref<Type>>& type, const std::string& name, bool overwriteExisting = true);
};
struct EnumerationMember
@@ -3126,9 +3212,9 @@ __attribute__ ((format (printf, 1, 2)))
bool isDefault;
};
- class Enumeration: public CoreRefCountObject<BNEnumeration, BNNewEnumerationReference, BNFreeEnumeration>
+ class Enumeration : public CoreRefCountObject<BNEnumeration, BNNewEnumerationReference, BNFreeEnumeration>
{
- public:
+ public:
Enumeration(BNEnumeration* e);
std::vector<EnumerationMember> GetMembers() const;
@@ -3138,7 +3224,7 @@ __attribute__ ((format (printf, 1, 2)))
{
BNEnumerationBuilder* m_object;
- public:
+ public:
EnumerationBuilder();
EnumerationBuilder(BNEnumerationBuilder* e);
EnumerationBuilder(const EnumerationBuilder& e);
@@ -3160,17 +3246,23 @@ __attribute__ ((format (printf, 1, 2)))
EnumerationBuilder& ReplaceMember(size_t idx, const std::string& name, uint64_t value);
};
- #if ((__cplusplus >= 201403L) || (_MSVC_LANG >= 201703L))
- template <class... Ts> struct overload : Ts... { using Ts::operator()...; };
- template <class... Ts> overload(Ts...) -> overload<Ts...>;
- #endif
+#if ((__cplusplus >= 201403L) || (_MSVC_LANG >= 201703L))
+ template <class... Ts>
+ struct overload : Ts...
+ {
+ using Ts::operator()...;
+ };
+ template <class... Ts>
+ overload(Ts...) -> overload<Ts...>;
+#endif
- class AnalysisContext: public CoreRefCountObject<BNAnalysisContext, BNNewAnalysisContextReference, BNFreeAnalysisContext>
+ class AnalysisContext :
+ public CoreRefCountObject<BNAnalysisContext, BNNewAnalysisContextReference, BNFreeAnalysisContext>
{
std::unique_ptr<Json::CharReader> m_reader;
Json::StreamWriterBuilder m_builder;
- public:
+ public:
AnalysisContext(BNAnalysisContext* analysisContext);
virtual ~AnalysisContext();
@@ -3187,34 +3279,35 @@ __attribute__ ((format (printf, 1, 2)))
bool Inform(const std::string& request);
- #if ((__cplusplus >= 201403L) || (_MSVC_LANG >= 201703L))
+#if ((__cplusplus >= 201403L) || (_MSVC_LANG >= 201703L))
template <typename... Args>
bool Inform(Args... args)
{
- //using T = std::variant<Args...>; // FIXME: remove type duplicates
+ // using T = std::variant<Args...>; // FIXME: remove type duplicates
using T = std::variant<std::string, const char*, uint64_t, Ref<Architecture>>;
std::vector<T> unpackedArgs {args...};
Json::Value request(Json::arrayValue);
for (auto& arg : unpackedArgs)
- std::visit(overload {
- [&](Ref<Architecture> arch) { request.append(Json::Value(arch->GetName())); },
- [&](uint64_t val) { request.append(Json::Value(val)); },
- [&](auto& val) { request.append(Json::Value(std::forward<decltype(val)>(val))); }
- }, arg);
+ std::visit(overload {[&](Ref<Architecture> arch) { request.append(Json::Value(arch->GetName())); },
+ [&](uint64_t val) { request.append(Json::Value(val)); },
+ [&](auto& val) {
+ request.append(Json::Value(std::forward<decltype(val)>(val)));
+ }},
+ arg);
return Inform(Json::writeString(m_builder, request));
}
- #endif
+#endif
};
- class Activity: public CoreRefCountObject<BNActivity, BNNewActivityReference, BNFreeActivity>
+ class Activity : public CoreRefCountObject<BNActivity, BNNewActivityReference, BNFreeActivity>
{
- protected:
+ protected:
std::function<void(Ref<AnalysisContext> analysisContext)> m_action;
static void Run(void* ctxt, BNAnalysisContext* analysisContext);
- public:
+ public:
Activity(const std::string& name, const std::function<void(Ref<AnalysisContext>)>& action);
Activity(BNActivity* activity);
virtual ~Activity();
@@ -3222,12 +3315,12 @@ __attribute__ ((format (printf, 1, 2)))
std::string GetName() const;
};
- class Workflow: public CoreRefCountObject<BNWorkflow, BNNewWorkflowReference, BNFreeWorkflow>
+ class Workflow : public CoreRefCountObject<BNWorkflow, BNNewWorkflowReference, BNFreeWorkflow>
{
- public:
+ public:
Workflow(const std::string& name = "");
Workflow(BNWorkflow* workflow);
- virtual ~Workflow() { }
+ virtual ~Workflow() {}
static std::vector<Ref<Workflow>> GetList();
static Ref<Workflow> Instance(const std::string& name = "");
@@ -3235,8 +3328,12 @@ __attribute__ ((format (printf, 1, 2)))
Ref<Workflow> Clone(const std::string& name, const std::string& activity = "");
bool RegisterActivity(Ref<Activity> activity, const std::string& description = "");
- bool RegisterActivity(Ref<Activity> activity, std::initializer_list<const char*> initializer) { return RegisterActivity(activity, std::vector<std::string>(initializer.begin(), initializer.end())); }
- bool RegisterActivity(Ref<Activity> activity, const std::vector<std::string>& subactivities, const std::string& description = "");
+ bool RegisterActivity(Ref<Activity> activity, std::initializer_list<const char*> initializer)
+ {
+ return RegisterActivity(activity, std::vector<std::string>(initializer.begin(), initializer.end()));
+ }
+ bool RegisterActivity(
+ Ref<Activity> activity, const std::vector<std::string>& subactivities, const std::string& description = "");
bool Contains(const std::string& activity);
std::string GetConfiguration(const std::string& activity = "");
@@ -3257,13 +3354,13 @@ __attribute__ ((format (printf, 1, 2)))
Ref<FlowGraph> GetGraph(const std::string& activity = "", bool sequential = false);
void ShowReport(const std::string& name);
- //bool Run(const std::string& activity, Ref<AnalysisContext> analysisContext);
+ // bool Run(const std::string& activity, Ref<AnalysisContext> analysisContext);
};
- class DisassemblySettings: public CoreRefCountObject<BNDisassemblySettings,
- BNNewDisassemblySettingsReference, BNFreeDisassemblySettings>
+ class DisassemblySettings :
+ public CoreRefCountObject<BNDisassemblySettings, BNNewDisassemblySettingsReference, BNFreeDisassemblySettings>
{
- public:
+ public:
DisassemblySettings();
DisassemblySettings(BNDisassemblySettings* settings);
@@ -3286,9 +3383,9 @@ __attribute__ ((format (printf, 1, 2)))
bool fallThrough;
};
- class BasicBlock: public CoreRefCountObject<BNBasicBlock, BNNewBasicBlockReference, BNFreeBasicBlock>
+ class BasicBlock : public CoreRefCountObject<BNBasicBlock, BNNewBasicBlockReference, BNFreeBasicBlock>
{
- public:
+ public:
BasicBlock(BNBasicBlock* block);
Ref<Function> GetFunction() const;
@@ -3322,13 +3419,13 @@ __attribute__ ((format (printf, 1, 2)))
BNHighlightColor GetBasicBlockHighlight();
void SetAutoBasicBlockHighlight(BNHighlightColor color);
void SetAutoBasicBlockHighlight(BNHighlightStandardColor color, uint8_t alpha = 255);
- void SetAutoBasicBlockHighlight(BNHighlightStandardColor color, BNHighlightStandardColor mixColor,
- uint8_t mix, uint8_t alpha = 255);
+ void SetAutoBasicBlockHighlight(
+ BNHighlightStandardColor color, BNHighlightStandardColor mixColor, uint8_t mix, uint8_t alpha = 255);
void SetAutoBasicBlockHighlight(uint8_t r, uint8_t g, uint8_t b, uint8_t alpha = 255);
void SetUserBasicBlockHighlight(BNHighlightColor color);
void SetUserBasicBlockHighlight(BNHighlightStandardColor color, uint8_t alpha = 255);
- void SetUserBasicBlockHighlight(BNHighlightStandardColor color, BNHighlightStandardColor mixColor,
- uint8_t mix, uint8_t alpha = 255);
+ void SetUserBasicBlockHighlight(
+ BNHighlightStandardColor color, BNHighlightStandardColor mixColor, uint8_t mix, uint8_t alpha = 255);
void SetUserBasicBlockHighlight(uint8_t r, uint8_t g, uint8_t b, uint8_t alpha = 255);
static bool IsBackEdge(BasicBlock* source, BasicBlock* target);
@@ -3378,24 +3475,21 @@ __attribute__ ((format (printf, 1, 2)))
ArchAndAddr& operator=(const ArchAndAddr& a)
{
- arch = a.arch;
- address = a.address;
- return *this;
- }
- bool operator==(const ArchAndAddr& a) const
- {
- return (arch == a.arch) && (address == a.address);
+ arch = a.arch;
+ address = a.address;
+ return *this;
}
+ bool operator==(const ArchAndAddr& a) const { return (arch == a.arch) && (address == a.address); }
bool operator<(const ArchAndAddr& a) const
{
- if (arch < a.arch)
- return true;
- if (arch > a.arch)
- return false;
- return address < a.address;
+ if (arch < a.arch)
+ return true;
+ if (arch > a.arch)
+ return false;
+ return address < a.address;
}
- ArchAndAddr(): arch(nullptr), address(0) {}
- ArchAndAddr(Architecture* a, uint64_t addr): arch(a), address(addr) {}
+ ArchAndAddr() : arch(nullptr), address(0) {}
+ ArchAndAddr(Architecture* a, uint64_t addr) : arch(a), address(addr) {}
};
struct LookupTableEntry
@@ -3435,11 +3529,11 @@ __attribute__ ((format (printf, 1, 2)))
class FlowGraph;
struct SSAVariable;
- class Function: public CoreRefCountObject<BNFunction, BNNewFunctionReference, BNFreeFunction>
+ class Function : public CoreRefCountObject<BNFunction, BNNewFunctionReference, BNFreeFunction>
{
int m_advancedAnalysisRequests;
- public:
+ public:
Function(BNFunction* func);
virtual ~Function();
@@ -3470,10 +3564,10 @@ __attribute__ ((format (printf, 1, 2)))
void RemoveUserCodeReference(Architecture* fromArch, uint64_t fromAddr, uint64_t toAddr);
void AddUserTypeReference(Architecture* fromArch, uint64_t fromAddr, const QualifiedName& name);
void RemoveUserTypeReference(Architecture* fromArch, uint64_t fromAddr, const QualifiedName& name);
- void AddUserTypeFieldReference(Architecture* fromArch, uint64_t fromAddr,
- const QualifiedName& name, uint64_t offset, size_t size = 0);
- void RemoveUserTypeFieldReference(Architecture* fromArch, uint64_t fromAddr,
- const QualifiedName& name, uint64_t offset, size_t size = 0);
+ void AddUserTypeFieldReference(
+ Architecture* fromArch, uint64_t fromAddr, const QualifiedName& name, uint64_t offset, size_t size = 0);
+ void RemoveUserTypeFieldReference(
+ Architecture* fromArch, uint64_t fromAddr, const QualifiedName& name, uint64_t offset, size_t size = 0);
Ref<LowLevelILFunction> GetLowLevelIL() const;
Ref<LowLevelILFunction> GetLowLevelILIfAvailable() const;
@@ -3493,17 +3587,23 @@ __attribute__ ((format (printf, 1, 2)))
std::vector<ILReferenceSource> GetMediumLevelILVariableReferences(const Variable& var);
std::vector<VariableReferenceSource> GetMediumLevelILVariableReferencesFrom(Architecture* arch, uint64_t addr);
- std::vector<VariableReferenceSource> GetMediumLevelILVariableReferencesInRange(Architecture* arch, uint64_t addr, uint64_t len);
+ std::vector<VariableReferenceSource> GetMediumLevelILVariableReferencesInRange(
+ Architecture* arch, uint64_t addr, uint64_t len);
std::vector<ILReferenceSource> GetMediumLevelILVariableReferencesIfAvailable(const Variable& var);
- std::vector<VariableReferenceSource> GetMediumLevelILVariableReferencesFromIfAvailable(Architecture* arch, uint64_t addr);
- std::vector<VariableReferenceSource> GetMediumLevelILVariableReferencesInRangeIfAvailable(Architecture* arch, uint64_t addr, uint64_t len);
+ std::vector<VariableReferenceSource> GetMediumLevelILVariableReferencesFromIfAvailable(
+ Architecture* arch, uint64_t addr);
+ std::vector<VariableReferenceSource> GetMediumLevelILVariableReferencesInRangeIfAvailable(
+ Architecture* arch, uint64_t addr, uint64_t len);
std::vector<ILReferenceSource> GetHighLevelILVariableReferences(const Variable& var);
std::vector<VariableReferenceSource> GetHighLevelILVariableReferencesFrom(Architecture* arch, uint64_t addr);
- std::vector<VariableReferenceSource> GetHighLevelILVariableReferencesInRange(Architecture* arch, uint64_t addr, uint64_t len);
+ std::vector<VariableReferenceSource> GetHighLevelILVariableReferencesInRange(
+ Architecture* arch, uint64_t addr, uint64_t len);
std::vector<ILReferenceSource> GetHighLevelILVariableReferencesIfAvailable(const Variable& var);
- std::vector<VariableReferenceSource> GetHighLevelILVariableReferencesFromIfAvailable(Architecture* arch, uint64_t addr);
- std::vector<VariableReferenceSource> GetHighLevelILVariableReferencesInRangeIfAvailable(Architecture* arch, uint64_t addr, uint64_t len);
+ std::vector<VariableReferenceSource> GetHighLevelILVariableReferencesFromIfAvailable(
+ Architecture* arch, uint64_t addr);
+ std::vector<VariableReferenceSource> GetHighLevelILVariableReferencesInRangeIfAvailable(
+ Architecture* arch, uint64_t addr, uint64_t len);
Ref<LowLevelILFunction> GetLiftedIL() const;
Ref<LowLevelILFunction> GetLiftedILIfAvailable() const;
@@ -3582,17 +3682,19 @@ __attribute__ ((format (printf, 1, 2)))
std::set<SSAVariable> GetHighLevelILSSAVariablesIfAvailable();
void CreateAutoVariable(const Variable& var, const Confidence<Ref<Type>>& type, const std::string& name,
- bool ignoreDisjointUses = false);
+ bool ignoreDisjointUses = false);
void CreateUserVariable(const Variable& var, const Confidence<Ref<Type>>& type, const std::string& name,
- bool ignoreDisjointUses = false);
+ bool ignoreDisjointUses = false);
void DeleteAutoVariable(const Variable& var);
void DeleteUserVariable(const Variable& var);
bool IsVariableUserDefinded(const Variable& var);
Confidence<Ref<Type>> GetVariableType(const Variable& var);
std::string GetVariableName(const Variable& var);
- void SetAutoIndirectBranches(Architecture* sourceArch, uint64_t source, const std::vector<ArchAndAddr>& branches);
- void SetUserIndirectBranches(Architecture* sourceArch, uint64_t source, const std::vector<ArchAndAddr>& branches);
+ void SetAutoIndirectBranches(
+ Architecture* sourceArch, uint64_t source, const std::vector<ArchAndAddr>& branches);
+ void SetUserIndirectBranches(
+ Architecture* sourceArch, uint64_t source, const std::vector<ArchAndAddr>& branches);
std::vector<IndirectBranchInfo> GetIndirectBranches();
std::vector<IndirectBranchInfo> GetIndirectBranchesAt(Architecture* arch, uint64_t addr);
@@ -3602,16 +3704,16 @@ __attribute__ ((format (printf, 1, 2)))
void SetAutoCallTypeAdjustment(Architecture* arch, uint64_t addr, const Confidence<Ref<Type>>& adjust);
void SetAutoCallStackAdjustment(Architecture* arch, uint64_t addr, const Confidence<int64_t>& adjust);
- void SetAutoCallRegisterStackAdjustment(Architecture* arch, uint64_t addr,
- const std::map<uint32_t, Confidence<int32_t>>& adjust);
- void SetAutoCallRegisterStackAdjustment(Architecture* arch, uint64_t addr, uint32_t regStack,
- const Confidence<int32_t>& adjust);
+ void SetAutoCallRegisterStackAdjustment(
+ Architecture* arch, uint64_t addr, const std::map<uint32_t, Confidence<int32_t>>& adjust);
+ void SetAutoCallRegisterStackAdjustment(
+ Architecture* arch, uint64_t addr, uint32_t regStack, const Confidence<int32_t>& adjust);
void SetUserCallTypeAdjustment(Architecture* arch, uint64_t addr, const Confidence<Ref<Type>>& adjust);
void SetUserCallStackAdjustment(Architecture* arch, uint64_t addr, const Confidence<int64_t>& adjust);
- void SetUserCallRegisterStackAdjustment(Architecture* arch, uint64_t addr,
- const std::map<uint32_t, Confidence<int32_t>>& adjust);
- void SetUserCallRegisterStackAdjustment(Architecture* arch, uint64_t addr, uint32_t regStack,
- const Confidence<int32_t>& adjust);
+ void SetUserCallRegisterStackAdjustment(
+ Architecture* arch, uint64_t addr, const std::map<uint32_t, Confidence<int32_t>>& adjust);
+ void SetUserCallRegisterStackAdjustment(
+ Architecture* arch, uint64_t addr, uint32_t regStack, const Confidence<int32_t>& adjust);
Confidence<Ref<Type>> GetCallTypeAdjustment(Architecture* arch, uint64_t addr);
Confidence<int64_t> GetCallStackAdjustment(Architecture* arch, uint64_t addr);
@@ -3621,26 +3723,26 @@ __attribute__ ((format (printf, 1, 2)))
std::vector<std::vector<InstructionTextToken>> GetBlockAnnotations(Architecture* arch, uint64_t addr);
- BNIntegerDisplayType GetIntegerConstantDisplayType(Architecture* arch, uint64_t instrAddr, uint64_t value,
- size_t operand);
- void SetIntegerConstantDisplayType(Architecture* arch, uint64_t instrAddr, uint64_t value, size_t operand,
- BNIntegerDisplayType type);
+ BNIntegerDisplayType GetIntegerConstantDisplayType(
+ Architecture* arch, uint64_t instrAddr, uint64_t value, size_t operand);
+ void SetIntegerConstantDisplayType(
+ Architecture* arch, uint64_t instrAddr, uint64_t value, size_t operand, BNIntegerDisplayType type);
BNHighlightColor GetInstructionHighlight(Architecture* arch, uint64_t addr);
void SetAutoInstructionHighlight(Architecture* arch, uint64_t addr, BNHighlightColor color);
+ void SetAutoInstructionHighlight(
+ Architecture* arch, uint64_t addr, BNHighlightStandardColor color, uint8_t alpha = 255);
void SetAutoInstructionHighlight(Architecture* arch, uint64_t addr, BNHighlightStandardColor color,
- uint8_t alpha = 255);
- void SetAutoInstructionHighlight(Architecture* arch, uint64_t addr, BNHighlightStandardColor color,
- BNHighlightStandardColor mixColor, uint8_t mix, uint8_t alpha = 255);
- void SetAutoInstructionHighlight(Architecture* arch, uint64_t addr, uint8_t r, uint8_t g, uint8_t b,
- uint8_t alpha = 255);
+ BNHighlightStandardColor mixColor, uint8_t mix, uint8_t alpha = 255);
+ void SetAutoInstructionHighlight(
+ Architecture* arch, uint64_t addr, uint8_t r, uint8_t g, uint8_t b, uint8_t alpha = 255);
void SetUserInstructionHighlight(Architecture* arch, uint64_t addr, BNHighlightColor color);
+ void SetUserInstructionHighlight(
+ Architecture* arch, uint64_t addr, BNHighlightStandardColor color, uint8_t alpha = 255);
void SetUserInstructionHighlight(Architecture* arch, uint64_t addr, BNHighlightStandardColor color,
- uint8_t alpha = 255);
- void SetUserInstructionHighlight(Architecture* arch, uint64_t addr, BNHighlightStandardColor color,
- BNHighlightStandardColor mixColor, uint8_t mix, uint8_t alpha = 255);
- void SetUserInstructionHighlight(Architecture* arch, uint64_t addr, uint8_t r, uint8_t g, uint8_t b,
- uint8_t alpha = 255);
+ BNHighlightStandardColor mixColor, uint8_t mix, uint8_t alpha = 255);
+ void SetUserInstructionHighlight(
+ Architecture* arch, uint64_t addr, uint8_t r, uint8_t g, uint8_t b, uint8_t alpha = 255);
std::vector<TagReference> GetAllTagReferences();
std::vector<TagReference> GetTagReferencesOfType(Ref<TagType> tagType);
@@ -3680,13 +3782,17 @@ __attribute__ ((format (printf, 1, 2)))
void RemoveUserFunctionTag(Ref<Tag> tag);
void RemoveUserFunctionTagsOfType(Ref<TagType> tagType);
- Ref<Tag> CreateAutoAddressTag(Architecture* arch, uint64_t addr, const std::string& tagTypeName, const std::string& data, bool unique = false);
- Ref<Tag> CreateUserAddressTag(Architecture* arch, uint64_t addr, const std::string& tagTypeName, const std::string& data, bool unique = false);
+ Ref<Tag> CreateAutoAddressTag(Architecture* arch, uint64_t addr, const std::string& tagTypeName,
+ const std::string& data, bool unique = false);
+ Ref<Tag> CreateUserAddressTag(Architecture* arch, uint64_t addr, const std::string& tagTypeName,
+ const std::string& data, bool unique = false);
Ref<Tag> CreateAutoFunctionTag(const std::string& tagTypeName, const std::string& data, bool unique = false);
Ref<Tag> CreateUserFunctionTag(const std::string& tagTypeName, const std::string& data, bool unique = false);
- Ref<Tag> CreateAutoAddressTag(Architecture* arch, uint64_t addr, Ref<TagType> tagType, const std::string& data, bool unique = false);
- Ref<Tag> CreateUserAddressTag(Architecture* arch, uint64_t addr, Ref<TagType> tagType, const std::string& data, bool unique = false);
+ Ref<Tag> CreateAutoAddressTag(
+ Architecture* arch, uint64_t addr, Ref<TagType> tagType, const std::string& data, bool unique = false);
+ Ref<Tag> CreateUserAddressTag(
+ Architecture* arch, uint64_t addr, Ref<TagType> tagType, const std::string& data, bool unique = false);
Ref<Tag> CreateAutoFunctionTag(Ref<TagType> tagType, const std::string& data, bool unique = false);
Ref<Tag> CreateUserFunctionTag(Ref<TagType> tagType, const std::string& data, bool unique = false);
@@ -3737,7 +3843,7 @@ __attribute__ ((format (printf, 1, 2)))
{
Ref<Function> m_func;
- public:
+ public:
AdvancedFunctionAnalysisDataRequestor(Function* func = nullptr);
AdvancedFunctionAnalysisDataRequestor(const AdvancedFunctionAnalysisDataRequestor& req);
~AdvancedFunctionAnalysisDataRequestor();
@@ -3758,14 +3864,13 @@ __attribute__ ((format (printf, 1, 2)))
BNEdgeStyle style;
};
- class FlowGraphNode: public CoreRefCountObject<BNFlowGraphNode,
- BNNewFlowGraphNodeReference, BNFreeFlowGraphNode>
+ class FlowGraphNode : public CoreRefCountObject<BNFlowGraphNode, BNNewFlowGraphNodeReference, BNFreeFlowGraphNode>
{
std::vector<DisassemblyTextLine> m_cachedLines;
std::vector<FlowGraphEdge> m_cachedEdges, m_cachedIncomingEdges;
bool m_cachedLinesValid, m_cachedEdgesValid, m_cachedIncomingEdgesValid;
- public:
+ public:
FlowGraphNode(FlowGraph* graph);
FlowGraphNode(BNFlowGraphNode* node);
@@ -3789,14 +3894,14 @@ __attribute__ ((format (printf, 1, 2)))
bool IsValidForGraph(FlowGraph* graph) const;
};
- class FlowGraphLayoutRequest: public RefCountObject
+ class FlowGraphLayoutRequest : public RefCountObject
{
BNFlowGraphLayoutRequest* m_object;
std::function<void()> m_completeFunc;
static void CompleteCallback(void* ctxt);
- public:
+ public:
FlowGraphLayoutRequest(FlowGraph* graph, const std::function<void()>& completeFunc);
virtual ~FlowGraphLayoutRequest();
@@ -3807,7 +3912,7 @@ __attribute__ ((format (printf, 1, 2)))
void Abort();
};
- class FlowGraph: public CoreRefCountObject<BNFlowGraph, BNNewFlowGraphReference, BNFreeFlowGraph>
+ class FlowGraph : public CoreRefCountObject<BNFlowGraph, BNNewFlowGraphReference, BNFreeFlowGraph>
{
std::map<BNFlowGraphNode*, Ref<FlowGraphNode>> m_cachedNodes;
@@ -3817,7 +3922,7 @@ __attribute__ ((format (printf, 1, 2)))
static BNFlowGraph* UpdateCallback(void* ctxt);
static void FreeObjectCallback(void* ctxt);
- protected:
+ protected:
bool m_queryMode = false;
FlowGraph(BNFlowGraph* graph);
@@ -3827,7 +3932,7 @@ __attribute__ ((format (printf, 1, 2)))
virtual void PopulateNodes();
virtual void CompleteLayout();
- public:
+ public:
FlowGraph();
Ref<Function> GetFunction() const;
@@ -3872,15 +3977,15 @@ __attribute__ ((format (printf, 1, 2)))
bool IsOptionSet(BNFlowGraphOption option);
};
- class CoreFlowGraph: public FlowGraph
+ class CoreFlowGraph : public FlowGraph
{
- public:
+ public:
CoreFlowGraph(BNFlowGraph* graph);
virtual bool HasUpdates() const override;
virtual Ref<FlowGraph> Update() override;
};
- struct LowLevelILLabel: public BNLowLevelILLabel
+ struct LowLevelILLabel : public BNLowLevelILLabel
{
LowLevelILLabel();
};
@@ -3891,28 +3996,21 @@ __attribute__ ((format (printf, 1, 2)))
uint32_t sourceOperand;
bool valid;
- ILSourceLocation(): valid(false)
- {
- }
+ ILSourceLocation() : valid(false) {}
- ILSourceLocation(uint64_t addr, uint32_t operand): address(addr), sourceOperand(operand), valid(true)
- {
- }
+ ILSourceLocation(uint64_t addr, uint32_t operand) : address(addr), sourceOperand(operand), valid(true) {}
- ILSourceLocation(const BNLowLevelILInstruction& instr):
- address(instr.address), sourceOperand(instr.sourceOperand), valid(true)
- {
- }
+ ILSourceLocation(const BNLowLevelILInstruction& instr) :
+ address(instr.address), sourceOperand(instr.sourceOperand), valid(true)
+ {}
- ILSourceLocation(const BNMediumLevelILInstruction& instr):
- address(instr.address), sourceOperand(instr.sourceOperand), valid(true)
- {
- }
+ ILSourceLocation(const BNMediumLevelILInstruction& instr) :
+ address(instr.address), sourceOperand(instr.sourceOperand), valid(true)
+ {}
- ILSourceLocation(const BNHighLevelILInstruction& instr):
- address(instr.address), sourceOperand(instr.sourceOperand), valid(true)
- {
- }
+ ILSourceLocation(const BNHighLevelILInstruction& instr) :
+ address(instr.address), sourceOperand(instr.sourceOperand), valid(true)
+ {}
};
struct LowLevelILInstruction;
@@ -3922,10 +4020,10 @@ __attribute__ ((format (printf, 1, 2)))
struct SSAFlag;
struct SSARegisterOrFlag;
- class LowLevelILFunction: public CoreRefCountObject<BNLowLevelILFunction,
- BNNewLowLevelILFunctionReference, BNFreeLowLevelILFunction>
+ class LowLevelILFunction :
+ public CoreRefCountObject<BNLowLevelILFunction, BNNewLowLevelILFunctionReference, BNFreeLowLevelILFunction>
{
- public:
+ public:
LowLevelILFunction(Architecture* arch, Function* func = nullptr);
LowLevelILFunction(BNLowLevelILFunction* func);
@@ -3943,214 +4041,207 @@ __attribute__ ((format (printf, 1, 2)))
void ClearIndirectBranches();
void SetIndirectBranches(const std::vector<ArchAndAddr>& branches);
- ExprId AddExpr(BNLowLevelILOperation operation, size_t size, uint32_t flags,
- ExprId a = 0, ExprId b = 0, ExprId c = 0, ExprId d = 0);
- ExprId AddExprWithLocation(BNLowLevelILOperation operation, uint64_t addr, uint32_t sourceOperand,
- size_t size, uint32_t flags, ExprId a = 0, ExprId b = 0, ExprId c = 0, ExprId d = 0);
- ExprId AddExprWithLocation(BNLowLevelILOperation operation, const ILSourceLocation& loc,
- size_t size, uint32_t flags, ExprId a = 0, ExprId b = 0, ExprId c = 0, ExprId d = 0);
+ ExprId AddExpr(BNLowLevelILOperation operation, size_t size, uint32_t flags, ExprId a = 0, ExprId b = 0,
+ ExprId c = 0, ExprId d = 0);
+ ExprId AddExprWithLocation(BNLowLevelILOperation operation, uint64_t addr, uint32_t sourceOperand, size_t size,
+ uint32_t flags, ExprId a = 0, ExprId b = 0, ExprId c = 0, ExprId d = 0);
+ ExprId AddExprWithLocation(BNLowLevelILOperation operation, const ILSourceLocation& loc, size_t size,
+ uint32_t flags, ExprId a = 0, ExprId b = 0, ExprId c = 0, ExprId d = 0);
ExprId AddInstruction(ExprId expr);
ExprId Nop(const ILSourceLocation& loc = ILSourceLocation());
ExprId SetRegister(size_t size, uint32_t reg, ExprId val, uint32_t flags = 0,
- const ILSourceLocation& loc = ILSourceLocation());
+ const ILSourceLocation& loc = ILSourceLocation());
ExprId SetRegisterSplit(size_t size, uint32_t high, uint32_t low, ExprId val, uint32_t flags = 0,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId SetRegisterSSA(size_t size, const SSARegister& reg, ExprId val,
- const ILSourceLocation& loc = ILSourceLocation());
+ const ILSourceLocation& loc = ILSourceLocation());
+ ExprId SetRegisterSSA(
+ size_t size, const SSARegister& reg, ExprId val, const ILSourceLocation& loc = ILSourceLocation());
ExprId SetRegisterSSAPartial(size_t size, const SSARegister& fullReg, uint32_t partialReg, ExprId val,
- const ILSourceLocation& loc = ILSourceLocation());
+ const ILSourceLocation& loc = ILSourceLocation());
ExprId SetRegisterSplitSSA(size_t size, const SSARegister& high, const SSARegister& low, ExprId val,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId SetRegisterStackTopRelative(size_t size, uint32_t regStack, ExprId entry, ExprId val,
- uint32_t flags = 0, const ILSourceLocation& loc = ILSourceLocation());
+ const ILSourceLocation& loc = ILSourceLocation());
+ ExprId SetRegisterStackTopRelative(size_t size, uint32_t regStack, ExprId entry, ExprId val, uint32_t flags = 0,
+ const ILSourceLocation& loc = ILSourceLocation());
ExprId RegisterStackPush(size_t size, uint32_t regStack, ExprId val, uint32_t flags = 0,
- const ILSourceLocation& loc = ILSourceLocation());
+ const ILSourceLocation& loc = ILSourceLocation());
ExprId SetRegisterStackTopRelativeSSA(size_t size, uint32_t regStack, size_t destVersion, size_t srcVersion,
- ExprId entry, const SSARegister& top, ExprId val, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId entry, const SSARegister& top, ExprId val, const ILSourceLocation& loc = ILSourceLocation());
ExprId SetRegisterStackAbsoluteSSA(size_t size, uint32_t regStack, size_t destVersion, size_t srcVersion,
- uint32_t reg, ExprId val, const ILSourceLocation& loc = ILSourceLocation());
+ uint32_t reg, ExprId val, const ILSourceLocation& loc = ILSourceLocation());
ExprId SetFlag(uint32_t flag, ExprId val, const ILSourceLocation& loc = ILSourceLocation());
ExprId SetFlagSSA(const SSAFlag& flag, ExprId val, const ILSourceLocation& loc = ILSourceLocation());
- ExprId Load(size_t size, ExprId addr, uint32_t flags = 0,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId LoadSSA(size_t size, ExprId addr, size_t sourceMemoryVer,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId Store(size_t size, ExprId addr, ExprId val, uint32_t flags = 0,
- const ILSourceLocation& loc = ILSourceLocation());
+ ExprId Load(size_t size, ExprId addr, uint32_t flags = 0, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId LoadSSA(
+ size_t size, ExprId addr, size_t sourceMemoryVer, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId Store(
+ size_t size, ExprId addr, ExprId val, uint32_t flags = 0, const ILSourceLocation& loc = ILSourceLocation());
ExprId StoreSSA(size_t size, ExprId addr, ExprId val, size_t newMemoryVer, size_t prevMemoryVer,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId Push(size_t size, ExprId val, uint32_t flags = 0,
- const ILSourceLocation& loc = ILSourceLocation());
+ const ILSourceLocation& loc = ILSourceLocation());
+ ExprId Push(size_t size, ExprId val, uint32_t flags = 0, const ILSourceLocation& loc = ILSourceLocation());
ExprId Pop(size_t size, uint32_t flags = 0, const ILSourceLocation& loc = ILSourceLocation());
ExprId Register(size_t size, uint32_t reg, const ILSourceLocation& loc = ILSourceLocation());
ExprId RegisterSSA(size_t size, const SSARegister& reg, const ILSourceLocation& loc = ILSourceLocation());
ExprId RegisterSSAPartial(size_t size, const SSARegister& fullReg, uint32_t partialReg,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId RegisterSplit(size_t size, uint32_t high, uint32_t low, const ILSourceLocation& loc = ILSourceLocation());
+ const ILSourceLocation& loc = ILSourceLocation());
+ ExprId RegisterSplit(
+ size_t size, uint32_t high, uint32_t low, const ILSourceLocation& loc = ILSourceLocation());
ExprId RegisterSplitSSA(size_t size, const SSARegister& high, const SSARegister& low,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId RegisterStackTopRelative(size_t size, uint32_t regStack, ExprId entry,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId RegisterStackPop(size_t size, uint32_t regStack, uint32_t flags = 0,
- const ILSourceLocation& loc = ILSourceLocation());
+ const ILSourceLocation& loc = ILSourceLocation());
+ ExprId RegisterStackTopRelative(
+ size_t size, uint32_t regStack, ExprId entry, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId RegisterStackPop(
+ size_t size, uint32_t regStack, uint32_t flags = 0, const ILSourceLocation& loc = ILSourceLocation());
ExprId RegisterStackFreeReg(uint32_t reg, const ILSourceLocation& loc = ILSourceLocation());
- ExprId RegisterStackFreeTopRelative(uint32_t regStack, ExprId entry,
- const ILSourceLocation& loc = ILSourceLocation());
+ ExprId RegisterStackFreeTopRelative(
+ uint32_t regStack, ExprId entry, const ILSourceLocation& loc = ILSourceLocation());
ExprId RegisterStackTopRelativeSSA(size_t size, const SSARegisterStack& regStack, ExprId entry,
- const SSARegister& top, const ILSourceLocation& loc = ILSourceLocation());
+ const SSARegister& top, const ILSourceLocation& loc = ILSourceLocation());
ExprId RegisterStackAbsoluteSSA(size_t size, const SSARegisterStack& regStack, uint32_t reg,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId RegisterStackFreeTopRelativeSSA(uint32_t regStack, size_t destVersion, size_t srcVersion,
- ExprId entry, const SSARegister& top, const ILSourceLocation& loc = ILSourceLocation());
- ExprId RegisterStackFreeAbsoluteSSA(uint32_t regStack, size_t destVersion, size_t srcVersion,
- uint32_t reg, const ILSourceLocation& loc = ILSourceLocation());
+ const ILSourceLocation& loc = ILSourceLocation());
+ ExprId RegisterStackFreeTopRelativeSSA(uint32_t regStack, size_t destVersion, size_t srcVersion, ExprId entry,
+ const SSARegister& top, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId RegisterStackFreeAbsoluteSSA(uint32_t regStack, size_t destVersion, size_t srcVersion, uint32_t reg,
+ const ILSourceLocation& loc = ILSourceLocation());
ExprId Const(size_t size, uint64_t val, const ILSourceLocation& loc = ILSourceLocation());
ExprId ConstPointer(size_t size, uint64_t val, const ILSourceLocation& loc = ILSourceLocation());
- ExprId ExternPointer(size_t size, uint64_t val, uint64_t offset, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId ExternPointer(
+ size_t size, uint64_t val, uint64_t offset, const ILSourceLocation& loc = ILSourceLocation());
ExprId FloatConstRaw(size_t size, uint64_t val, const ILSourceLocation& loc = ILSourceLocation());
ExprId FloatConstSingle(float val, const ILSourceLocation& loc = ILSourceLocation());
ExprId FloatConstDouble(double val, const ILSourceLocation& loc = ILSourceLocation());
ExprId Flag(uint32_t flag, const ILSourceLocation& loc = ILSourceLocation());
ExprId FlagSSA(const SSAFlag& flag, const ILSourceLocation& loc = ILSourceLocation());
- ExprId FlagBit(size_t size, uint32_t flag, size_t bitIndex,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId FlagBitSSA(size_t size, const SSAFlag& flag, size_t bitIndex,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId Add(size_t size, ExprId a, ExprId b, uint32_t flags = 0,
- const ILSourceLocation& loc = ILSourceLocation());
+ ExprId FlagBit(size_t size, uint32_t flag, size_t bitIndex, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId FlagBitSSA(
+ size_t size, const SSAFlag& flag, size_t bitIndex, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId Add(
+ size_t size, ExprId a, ExprId b, uint32_t flags = 0, const ILSourceLocation& loc = ILSourceLocation());
ExprId AddCarry(size_t size, ExprId a, ExprId b, ExprId carry, uint32_t flags = 0,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId Sub(size_t size, ExprId a, ExprId b, uint32_t flags = 0,
- const ILSourceLocation& loc = ILSourceLocation());
+ const ILSourceLocation& loc = ILSourceLocation());
+ ExprId Sub(
+ size_t size, ExprId a, ExprId b, uint32_t flags = 0, const ILSourceLocation& loc = ILSourceLocation());
ExprId SubBorrow(size_t size, ExprId a, ExprId b, ExprId carry, uint32_t flags = 0,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId And(size_t size, ExprId a, ExprId b, uint32_t flags = 0,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId Or(size_t size, ExprId a, ExprId b, uint32_t flags = 0,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId Xor(size_t size, ExprId a, ExprId b, uint32_t flags = 0,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId ShiftLeft(size_t size, ExprId a, ExprId b, uint32_t flags = 0,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId LogicalShiftRight(size_t size, ExprId a, ExprId b, uint32_t flags = 0,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId ArithShiftRight(size_t size, ExprId a, ExprId b, uint32_t flags = 0,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId RotateLeft(size_t size, ExprId a, ExprId b, uint32_t flags = 0,
- const ILSourceLocation& loc = ILSourceLocation());
+ const ILSourceLocation& loc = ILSourceLocation());
+ ExprId And(
+ size_t size, ExprId a, ExprId b, uint32_t flags = 0, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId Or(
+ size_t size, ExprId a, ExprId b, uint32_t flags = 0, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId Xor(
+ size_t size, ExprId a, ExprId b, uint32_t flags = 0, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId ShiftLeft(
+ size_t size, ExprId a, ExprId b, uint32_t flags = 0, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId LogicalShiftRight(
+ size_t size, ExprId a, ExprId b, uint32_t flags = 0, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId ArithShiftRight(
+ size_t size, ExprId a, ExprId b, uint32_t flags = 0, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId RotateLeft(
+ size_t size, ExprId a, ExprId b, uint32_t flags = 0, const ILSourceLocation& loc = ILSourceLocation());
ExprId RotateLeftCarry(size_t size, ExprId a, ExprId b, ExprId carry, uint32_t flags = 0,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId RotateRight(size_t size, ExprId a, ExprId b, uint32_t flags = 0,
- const ILSourceLocation& loc = ILSourceLocation());
+ const ILSourceLocation& loc = ILSourceLocation());
+ ExprId RotateRight(
+ size_t size, ExprId a, ExprId b, uint32_t flags = 0, const ILSourceLocation& loc = ILSourceLocation());
ExprId RotateRightCarry(size_t size, ExprId a, ExprId b, ExprId carry, uint32_t flags = 0,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId Mult(size_t size, ExprId a, ExprId b, uint32_t flags = 0,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId MultDoublePrecUnsigned(size_t size, ExprId a, ExprId b, uint32_t flags = 0,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId MultDoublePrecSigned(size_t size, ExprId a, ExprId b, uint32_t flags = 0,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId DivUnsigned(size_t size, ExprId a, ExprId b, uint32_t flags = 0,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId DivDoublePrecUnsigned(size_t size, ExprId a, ExprId b, uint32_t flags = 0,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId DivSigned(size_t size, ExprId a, ExprId b, uint32_t flags = 0,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId DivDoublePrecSigned(size_t size, ExprId a, ExprId b, uint32_t flags = 0,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId ModUnsigned(size_t size, ExprId a, ExprId b, uint32_t flags = 0,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId ModDoublePrecUnsigned(size_t size, ExprId a, ExprId b, uint32_t flags = 0,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId ModSigned(size_t size, ExprId a, ExprId b, uint32_t flags = 0,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId ModDoublePrecSigned(size_t size, ExprId a, ExprId b, uint32_t flags = 0,
- const ILSourceLocation& loc = ILSourceLocation());
+ const ILSourceLocation& loc = ILSourceLocation());
+ ExprId Mult(
+ size_t size, ExprId a, ExprId b, uint32_t flags = 0, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId MultDoublePrecUnsigned(
+ size_t size, ExprId a, ExprId b, uint32_t flags = 0, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId MultDoublePrecSigned(
+ size_t size, ExprId a, ExprId b, uint32_t flags = 0, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId DivUnsigned(
+ size_t size, ExprId a, ExprId b, uint32_t flags = 0, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId DivDoublePrecUnsigned(
+ size_t size, ExprId a, ExprId b, uint32_t flags = 0, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId DivSigned(
+ size_t size, ExprId a, ExprId b, uint32_t flags = 0, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId DivDoublePrecSigned(
+ size_t size, ExprId a, ExprId b, uint32_t flags = 0, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId ModUnsigned(
+ size_t size, ExprId a, ExprId b, uint32_t flags = 0, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId ModDoublePrecUnsigned(
+ size_t size, ExprId a, ExprId b, uint32_t flags = 0, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId ModSigned(
+ size_t size, ExprId a, ExprId b, uint32_t flags = 0, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId ModDoublePrecSigned(
+ size_t size, ExprId a, ExprId b, uint32_t flags = 0, const ILSourceLocation& loc = ILSourceLocation());
ExprId Neg(size_t size, ExprId a, uint32_t flags = 0, const ILSourceLocation& loc = ILSourceLocation());
ExprId Not(size_t size, ExprId a, uint32_t flags = 0, const ILSourceLocation& loc = ILSourceLocation());
- ExprId SignExtend(size_t size, ExprId a, uint32_t flags = 0,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId ZeroExtend(size_t size, ExprId a, uint32_t flags = 0,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId LowPart(size_t size, ExprId a, uint32_t flags = 0,
- const ILSourceLocation& loc = ILSourceLocation());
+ ExprId SignExtend(size_t size, ExprId a, uint32_t flags = 0, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId ZeroExtend(size_t size, ExprId a, uint32_t flags = 0, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId LowPart(size_t size, ExprId a, uint32_t flags = 0, const ILSourceLocation& loc = ILSourceLocation());
ExprId Jump(ExprId dest, const ILSourceLocation& loc = ILSourceLocation());
ExprId JumpTo(ExprId dest, const std::map<uint64_t, BNLowLevelILLabel*>& targets,
- const ILSourceLocation& loc = ILSourceLocation());
+ const ILSourceLocation& loc = ILSourceLocation());
ExprId Call(ExprId dest, const ILSourceLocation& loc = ILSourceLocation());
ExprId CallStackAdjust(ExprId dest, int64_t adjust, const std::map<uint32_t, int32_t>& regStackAdjust,
- const ILSourceLocation& loc = ILSourceLocation());
+ const ILSourceLocation& loc = ILSourceLocation());
ExprId TailCall(ExprId dest, const ILSourceLocation& loc = ILSourceLocation());
ExprId CallSSA(const std::vector<SSARegister>& output, ExprId dest, const std::vector<ExprId>& params,
- const SSARegister& stack, size_t newMemoryVer, size_t prevMemoryVer,
- const ILSourceLocation& loc = ILSourceLocation());
+ const SSARegister& stack, size_t newMemoryVer, size_t prevMemoryVer,
+ const ILSourceLocation& loc = ILSourceLocation());
ExprId SystemCallSSA(const std::vector<SSARegister>& output, const std::vector<ExprId>& params,
- const SSARegister& stack, size_t newMemoryVer, size_t prevMemoryVer,
- const ILSourceLocation& loc = ILSourceLocation());
+ const SSARegister& stack, size_t newMemoryVer, size_t prevMemoryVer,
+ const ILSourceLocation& loc = ILSourceLocation());
ExprId TailCallSSA(const std::vector<SSARegister>& output, ExprId dest, const std::vector<ExprId>& params,
- const SSARegister& stack, size_t newMemoryVer, size_t prevMemoryVer,
- const ILSourceLocation& loc = ILSourceLocation());
+ const SSARegister& stack, size_t newMemoryVer, size_t prevMemoryVer,
+ const ILSourceLocation& loc = ILSourceLocation());
ExprId Return(size_t dest, const ILSourceLocation& loc = ILSourceLocation());
ExprId NoReturn(const ILSourceLocation& loc = ILSourceLocation());
- ExprId FlagCondition(BNLowLevelILFlagCondition cond, uint32_t semClass = 0,
- const ILSourceLocation& loc = ILSourceLocation());
+ ExprId FlagCondition(
+ BNLowLevelILFlagCondition cond, uint32_t semClass = 0, const ILSourceLocation& loc = ILSourceLocation());
ExprId FlagGroup(uint32_t semGroup, const ILSourceLocation& loc = ILSourceLocation());
- ExprId CompareEqual(size_t size, ExprId a, ExprId b,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId CompareNotEqual(size_t size, ExprId a, ExprId b,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId CompareSignedLessThan(size_t size, ExprId a, ExprId b,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId CompareUnsignedLessThan(size_t size, ExprId a, ExprId b,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId CompareSignedLessEqual(size_t size, ExprId a, ExprId b,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId CompareUnsignedLessEqual(size_t size, ExprId a, ExprId b,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId CompareSignedGreaterEqual(size_t size, ExprId a, ExprId b,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId CompareUnsignedGreaterEqual(size_t size, ExprId a, ExprId b,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId CompareSignedGreaterThan(size_t size, ExprId a, ExprId b,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId CompareUnsignedGreaterThan(size_t size, ExprId a, ExprId b,
- const ILSourceLocation& loc = ILSourceLocation());
+ ExprId CompareEqual(size_t size, ExprId a, ExprId b, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId CompareNotEqual(size_t size, ExprId a, ExprId b, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId CompareSignedLessThan(size_t size, ExprId a, ExprId b, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId CompareUnsignedLessThan(
+ size_t size, ExprId a, ExprId b, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId CompareSignedLessEqual(
+ size_t size, ExprId a, ExprId b, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId CompareUnsignedLessEqual(
+ size_t size, ExprId a, ExprId b, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId CompareSignedGreaterEqual(
+ size_t size, ExprId a, ExprId b, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId CompareUnsignedGreaterEqual(
+ size_t size, ExprId a, ExprId b, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId CompareSignedGreaterThan(
+ size_t size, ExprId a, ExprId b, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId CompareUnsignedGreaterThan(
+ size_t size, ExprId a, ExprId b, const ILSourceLocation& loc = ILSourceLocation());
ExprId TestBit(size_t size, ExprId a, ExprId b, const ILSourceLocation& loc = ILSourceLocation());
ExprId BoolToInt(size_t size, ExprId a, const ILSourceLocation& loc = ILSourceLocation());
ExprId SystemCall(const ILSourceLocation& loc = ILSourceLocation());
ExprId Intrinsic(const std::vector<RegisterOrFlag>& outputs, uint32_t intrinsic,
- const std::vector<ExprId>& params, uint32_t flags = 0,
- const ILSourceLocation& loc = ILSourceLocation());
+ const std::vector<ExprId>& params, uint32_t flags = 0, const ILSourceLocation& loc = ILSourceLocation());
ExprId IntrinsicSSA(const std::vector<SSARegisterOrFlag>& outputs, uint32_t intrinsic,
- const std::vector<ExprId>& params, const ILSourceLocation& loc = ILSourceLocation());
+ const std::vector<ExprId>& params, const ILSourceLocation& loc = ILSourceLocation());
ExprId Breakpoint(const ILSourceLocation& loc = ILSourceLocation());
ExprId Trap(int64_t num, const ILSourceLocation& loc = ILSourceLocation());
ExprId Undefined(const ILSourceLocation& loc = ILSourceLocation());
ExprId Unimplemented(const ILSourceLocation& loc = ILSourceLocation());
ExprId UnimplementedMemoryRef(size_t size, ExprId addr, const ILSourceLocation& loc = ILSourceLocation());
ExprId RegisterPhi(const SSARegister& dest, const std::vector<SSARegister>& sources,
- const ILSourceLocation& loc = ILSourceLocation());
+ const ILSourceLocation& loc = ILSourceLocation());
ExprId RegisterStackPhi(const SSARegisterStack& dest, const std::vector<SSARegisterStack>& sources,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId FlagPhi(const SSAFlag& dest, const std::vector<SSAFlag>& sources,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId MemoryPhi(size_t dest, const std::vector<size_t>& sources,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId FloatAdd(size_t size, ExprId a, ExprId b, uint32_t flags = 0,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId FloatSub(size_t size, ExprId a, ExprId b, uint32_t flags = 0,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId FloatMult(size_t size, ExprId a, ExprId b, uint32_t flags = 0,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId FloatDiv(size_t size, ExprId a, ExprId b, uint32_t flags = 0,
- const ILSourceLocation& loc = ILSourceLocation());
+ const ILSourceLocation& loc = ILSourceLocation());
+ ExprId FlagPhi(
+ const SSAFlag& dest, const std::vector<SSAFlag>& sources, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId MemoryPhi(
+ size_t dest, const std::vector<size_t>& sources, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId FloatAdd(
+ size_t size, ExprId a, ExprId b, uint32_t flags = 0, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId FloatSub(
+ size_t size, ExprId a, ExprId b, uint32_t flags = 0, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId FloatMult(
+ size_t size, ExprId a, ExprId b, uint32_t flags = 0, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId FloatDiv(
+ size_t size, ExprId a, ExprId b, uint32_t flags = 0, const ILSourceLocation& loc = ILSourceLocation());
ExprId FloatSqrt(size_t size, ExprId a, uint32_t flags = 0, const ILSourceLocation& loc = ILSourceLocation());
ExprId FloatNeg(size_t size, ExprId a, uint32_t flags = 0, const ILSourceLocation& loc = ILSourceLocation());
ExprId FloatAbs(size_t size, ExprId a, uint32_t flags = 0, const ILSourceLocation& loc = ILSourceLocation());
ExprId FloatToInt(size_t size, ExprId a, uint32_t flags = 0, const ILSourceLocation& loc = ILSourceLocation());
ExprId IntToFloat(size_t size, ExprId a, uint32_t flags = 0, const ILSourceLocation& loc = ILSourceLocation());
- ExprId FloatConvert(size_t size, ExprId a, uint32_t flags = 0, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId FloatConvert(
+ size_t size, ExprId a, uint32_t flags = 0, const ILSourceLocation& loc = ILSourceLocation());
ExprId RoundToInt(size_t size, ExprId a, uint32_t flags = 0, const ILSourceLocation& loc = ILSourceLocation());
ExprId Floor(size_t size, ExprId a, uint32_t flags = 0, const ILSourceLocation& loc = ILSourceLocation());
ExprId Ceil(size_t size, ExprId a, uint32_t flags = 0, const ILSourceLocation& loc = ILSourceLocation());
@@ -4159,14 +4250,16 @@ __attribute__ ((format (printf, 1, 2)))
ExprId FloatCompareNotEqual(size_t size, ExprId a, ExprId b, const ILSourceLocation& loc = ILSourceLocation());
ExprId FloatCompareLessThan(size_t size, ExprId a, ExprId b, const ILSourceLocation& loc = ILSourceLocation());
ExprId FloatCompareLessEqual(size_t size, ExprId a, ExprId b, const ILSourceLocation& loc = ILSourceLocation());
- ExprId FloatCompareGreaterEqual(size_t size, ExprId a, ExprId b, const ILSourceLocation& loc = ILSourceLocation());
- ExprId FloatCompareGreaterThan(size_t size, ExprId a, ExprId b, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId FloatCompareGreaterEqual(
+ size_t size, ExprId a, ExprId b, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId FloatCompareGreaterThan(
+ size_t size, ExprId a, ExprId b, const ILSourceLocation& loc = ILSourceLocation());
ExprId FloatCompareOrdered(size_t size, ExprId a, ExprId b, const ILSourceLocation& loc = ILSourceLocation());
ExprId FloatCompareUnordered(size_t size, ExprId a, ExprId b, const ILSourceLocation& loc = ILSourceLocation());
ExprId Goto(BNLowLevelILLabel& label, const ILSourceLocation& loc = ILSourceLocation());
ExprId If(ExprId operand, BNLowLevelILLabel& t, BNLowLevelILLabel& f,
- const ILSourceLocation& loc = ILSourceLocation());
+ const ILSourceLocation& loc = ILSourceLocation());
void MarkLabel(BNLowLevelILLabel& label);
std::vector<uint64_t> GetOperandList(ExprId i, size_t listOperand);
@@ -4182,8 +4275,8 @@ __attribute__ ((format (printf, 1, 2)))
ExprId GetExprForRegisterOrConstant(const BNRegisterOrConstant& operand, size_t size);
ExprId GetNegExprForRegisterOrConstant(const BNRegisterOrConstant& operand, size_t size);
ExprId GetExprForFlagOrConstant(const BNRegisterOrConstant& operand);
- ExprId GetExprForRegisterOrConstantOperation(BNLowLevelILOperation op, size_t size,
- BNRegisterOrConstant* operands, size_t operandCount);
+ ExprId GetExprForRegisterOrConstantOperation(
+ BNLowLevelILOperation op, size_t size, BNRegisterOrConstant* operands, size_t operandCount);
ExprId Operand(size_t n, ExprId expr);
@@ -4206,8 +4299,8 @@ __attribute__ ((format (printf, 1, 2)))
void GenerateSSAForm();
bool GetExprText(Architecture* arch, ExprId expr, std::vector<InstructionTextToken>& tokens);
- bool GetInstructionText(Function* func, Architecture* arch, size_t i,
- std::vector<InstructionTextToken>& tokens);
+ bool GetInstructionText(
+ Function* func, Architecture* arch, size_t i, std::vector<InstructionTextToken>& tokens);
uint32_t GetTemporaryRegisterCount();
uint32_t GetTemporaryFlagCount();
@@ -4234,29 +4327,29 @@ __attribute__ ((format (printf, 1, 2)))
RegisterValue GetExprValue(size_t expr);
RegisterValue GetExprValue(const LowLevelILInstruction& expr);
- PossibleValueSet GetPossibleExprValues(size_t expr,
- const std::set<BNDataFlowQueryOption>& options = std::set<BNDataFlowQueryOption>());
+ PossibleValueSet GetPossibleExprValues(
+ size_t expr, const std::set<BNDataFlowQueryOption>& options = std::set<BNDataFlowQueryOption>());
PossibleValueSet GetPossibleExprValues(const LowLevelILInstruction& expr,
- const std::set<BNDataFlowQueryOption>& options = std::set<BNDataFlowQueryOption>());
+ const std::set<BNDataFlowQueryOption>& options = std::set<BNDataFlowQueryOption>());
RegisterValue GetRegisterValueAtInstruction(uint32_t reg, size_t instr);
RegisterValue GetRegisterValueAfterInstruction(uint32_t reg, size_t instr);
PossibleValueSet GetPossibleRegisterValuesAtInstruction(uint32_t reg, size_t instr,
- const std::set<BNDataFlowQueryOption>& options = std::set<BNDataFlowQueryOption>());
+ const std::set<BNDataFlowQueryOption>& options = std::set<BNDataFlowQueryOption>());
PossibleValueSet GetPossibleRegisterValuesAfterInstruction(uint32_t reg, size_t instr,
- const std::set<BNDataFlowQueryOption>& options = std::set<BNDataFlowQueryOption>());
+ const std::set<BNDataFlowQueryOption>& options = std::set<BNDataFlowQueryOption>());
RegisterValue GetFlagValueAtInstruction(uint32_t flag, size_t instr);
RegisterValue GetFlagValueAfterInstruction(uint32_t flag, size_t instr);
PossibleValueSet GetPossibleFlagValuesAtInstruction(uint32_t flag, size_t instr,
- const std::set<BNDataFlowQueryOption>& options = std::set<BNDataFlowQueryOption>());
+ const std::set<BNDataFlowQueryOption>& options = std::set<BNDataFlowQueryOption>());
PossibleValueSet GetPossibleFlagValuesAfterInstruction(uint32_t flag, size_t instr,
- const std::set<BNDataFlowQueryOption>& options = std::set<BNDataFlowQueryOption>());
+ const std::set<BNDataFlowQueryOption>& options = std::set<BNDataFlowQueryOption>());
RegisterValue GetStackContentsAtInstruction(int32_t offset, size_t len, size_t instr);
RegisterValue GetStackContentsAfterInstruction(int32_t offset, size_t len, size_t instr);
PossibleValueSet GetPossibleStackContentsAtInstruction(int32_t offset, size_t len, size_t instr,
- const std::set<BNDataFlowQueryOption>& options = std::set<BNDataFlowQueryOption>());
+ const std::set<BNDataFlowQueryOption>& options = std::set<BNDataFlowQueryOption>());
PossibleValueSet GetPossibleStackContentsAfterInstruction(int32_t offset, size_t len, size_t instr,
- const std::set<BNDataFlowQueryOption>& options = std::set<BNDataFlowQueryOption>());
+ const std::set<BNDataFlowQueryOption>& options = std::set<BNDataFlowQueryOption>());
Ref<MediumLevelILFunction> GetMediumLevelIL() const;
Ref<MediumLevelILFunction> GetMappedMediumLevelIL() const;
@@ -4266,22 +4359,26 @@ __attribute__ ((format (printf, 1, 2)))
size_t GetMappedMediumLevelILInstructionIndex(size_t instr) const;
size_t GetMappedMediumLevelILExprIndex(size_t expr) const;
- static bool IsConstantType(BNLowLevelILOperation type) { return type == LLIL_CONST || type == LLIL_CONST_PTR || type == LLIL_EXTERN_PTR; }
+ static bool IsConstantType(BNLowLevelILOperation type)
+ {
+ return type == LLIL_CONST || type == LLIL_CONST_PTR || type == LLIL_EXTERN_PTR;
+ }
Ref<FlowGraph> CreateFunctionGraph(DisassemblySettings* settings = nullptr);
};
- struct MediumLevelILLabel: public BNMediumLevelILLabel
+ struct MediumLevelILLabel : public BNMediumLevelILLabel
{
MediumLevelILLabel();
};
struct MediumLevelILInstruction;
- class MediumLevelILFunction: public CoreRefCountObject<BNMediumLevelILFunction,
- BNNewMediumLevelILFunctionReference, BNFreeMediumLevelILFunction>
+ class MediumLevelILFunction :
+ public CoreRefCountObject<BNMediumLevelILFunction, BNNewMediumLevelILFunctionReference,
+ BNFreeMediumLevelILFunction>
{
- public:
+ public:
MediumLevelILFunction(Architecture* arch, Function* func = nullptr);
MediumLevelILFunction(BNMediumLevelILFunction* func);
@@ -4296,113 +4393,102 @@ __attribute__ ((format (printf, 1, 2)))
void PrepareToCopyBlock(BasicBlock* block);
BNMediumLevelILLabel* GetLabelForSourceInstruction(size_t i);
- ExprId AddExpr(BNMediumLevelILOperation operation, size_t size,
- ExprId a = 0, ExprId b = 0, ExprId c = 0, ExprId d = 0, ExprId e = 0);
+ ExprId AddExpr(BNMediumLevelILOperation operation, size_t size, ExprId a = 0, ExprId b = 0, ExprId c = 0,
+ ExprId d = 0, ExprId e = 0);
ExprId AddExprWithLocation(BNMediumLevelILOperation operation, uint64_t addr, uint32_t sourceOperand,
- size_t size, ExprId a = 0, ExprId b = 0, ExprId c = 0, ExprId d = 0, ExprId e = 0);
- ExprId AddExprWithLocation(BNMediumLevelILOperation operation, const ILSourceLocation& loc,
- size_t size, ExprId a = 0, ExprId b = 0, ExprId c = 0, ExprId d = 0, ExprId e = 0);
+ size_t size, ExprId a = 0, ExprId b = 0, ExprId c = 0, ExprId d = 0, ExprId e = 0);
+ ExprId AddExprWithLocation(BNMediumLevelILOperation operation, const ILSourceLocation& loc, size_t size,
+ ExprId a = 0, ExprId b = 0, ExprId c = 0, ExprId d = 0, ExprId e = 0);
ExprId Nop(const ILSourceLocation& loc = ILSourceLocation());
- ExprId SetVar(size_t size, const Variable& dest, ExprId src,
- const ILSourceLocation& loc = ILSourceLocation());
+ ExprId SetVar(size_t size, const Variable& dest, ExprId src, const ILSourceLocation& loc = ILSourceLocation());
ExprId SetVarField(size_t size, const Variable& dest, uint64_t offset, ExprId src,
- const ILSourceLocation& loc = ILSourceLocation());
+ const ILSourceLocation& loc = ILSourceLocation());
ExprId SetVarSplit(size_t size, const Variable& high, const Variable& low, ExprId src,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId SetVarSSA(size_t size, const SSAVariable& dest, ExprId src,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId SetVarSSAField(size_t size, const Variable& dest, size_t newVersion, size_t prevVersion,
- uint64_t offset, ExprId src, const ILSourceLocation& loc = ILSourceLocation());
+ const ILSourceLocation& loc = ILSourceLocation());
+ ExprId SetVarSSA(
+ size_t size, const SSAVariable& dest, ExprId src, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId SetVarSSAField(size_t size, const Variable& dest, size_t newVersion, size_t prevVersion, uint64_t offset,
+ ExprId src, const ILSourceLocation& loc = ILSourceLocation());
ExprId SetVarSSASplit(size_t size, const SSAVariable& high, const SSAVariable& low, ExprId src,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId SetVarAliased(size_t size, const Variable& dest, size_t newMemVersion, size_t prevMemVersion,
- ExprId src, const ILSourceLocation& loc = ILSourceLocation());
+ const ILSourceLocation& loc = ILSourceLocation());
+ ExprId SetVarAliased(size_t size, const Variable& dest, size_t newMemVersion, size_t prevMemVersion, ExprId src,
+ const ILSourceLocation& loc = ILSourceLocation());
ExprId SetVarAliasedField(size_t size, const Variable& dest, size_t newMemVersion, size_t prevMemVersion,
- uint64_t offset, ExprId src, const ILSourceLocation& loc = ILSourceLocation());
+ uint64_t offset, ExprId src, const ILSourceLocation& loc = ILSourceLocation());
ExprId Load(size_t size, ExprId src, const ILSourceLocation& loc = ILSourceLocation());
- ExprId LoadStruct(size_t size, ExprId src, uint64_t offset,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId LoadSSA(size_t size, ExprId src, size_t memVersion,
- const ILSourceLocation& loc = ILSourceLocation());
+ ExprId LoadStruct(size_t size, ExprId src, uint64_t offset, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId LoadSSA(size_t size, ExprId src, size_t memVersion, const ILSourceLocation& loc = ILSourceLocation());
ExprId LoadStructSSA(size_t size, ExprId src, uint64_t offset, size_t memVersion,
- const ILSourceLocation& loc = ILSourceLocation());
+ const ILSourceLocation& loc = ILSourceLocation());
ExprId Store(size_t size, ExprId dest, ExprId src, const ILSourceLocation& loc = ILSourceLocation());
- ExprId StoreStruct(size_t size, ExprId dest, uint64_t offset, ExprId src,
- const ILSourceLocation& loc = ILSourceLocation());
+ ExprId StoreStruct(
+ size_t size, ExprId dest, uint64_t offset, ExprId src, const ILSourceLocation& loc = ILSourceLocation());
ExprId StoreSSA(size_t size, ExprId dest, size_t newMemVersion, size_t prevMemVersion, ExprId src,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId StoreStructSSA(size_t size, ExprId dest, uint64_t offset,
- size_t newMemVersion, size_t prevMemVersion, ExprId src,
- const ILSourceLocation& loc = ILSourceLocation());
+ const ILSourceLocation& loc = ILSourceLocation());
+ ExprId StoreStructSSA(size_t size, ExprId dest, uint64_t offset, size_t newMemVersion, size_t prevMemVersion,
+ ExprId src, const ILSourceLocation& loc = ILSourceLocation());
ExprId Var(size_t size, const Variable& src, const ILSourceLocation& loc = ILSourceLocation());
- ExprId VarField(size_t size, const Variable& src, uint64_t offset,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId VarSplit(size_t size, const Variable& high, const Variable& low,
- const ILSourceLocation& loc = ILSourceLocation());
+ ExprId VarField(
+ size_t size, const Variable& src, uint64_t offset, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId VarSplit(
+ size_t size, const Variable& high, const Variable& low, const ILSourceLocation& loc = ILSourceLocation());
ExprId VarSSA(size_t size, const SSAVariable& src, const ILSourceLocation& loc = ILSourceLocation());
- ExprId VarSSAField(size_t size, const SSAVariable& src, uint64_t offset,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId VarAliased(size_t size, const Variable& src, size_t memVersion,
- const ILSourceLocation& loc = ILSourceLocation());
+ ExprId VarSSAField(
+ size_t size, const SSAVariable& src, uint64_t offset, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId VarAliased(
+ size_t size, const Variable& src, size_t memVersion, const ILSourceLocation& loc = ILSourceLocation());
ExprId VarAliasedField(size_t size, const Variable& src, size_t memVersion, uint64_t offset,
- const ILSourceLocation& loc = ILSourceLocation());
+ const ILSourceLocation& loc = ILSourceLocation());
ExprId VarSplitSSA(size_t size, const SSAVariable& high, const SSAVariable& low,
- const ILSourceLocation& loc = ILSourceLocation());
+ const ILSourceLocation& loc = ILSourceLocation());
ExprId AddressOf(const Variable& var, const ILSourceLocation& loc = ILSourceLocation());
- ExprId AddressOfField(const Variable& var, uint64_t offset,
- const ILSourceLocation& loc = ILSourceLocation());
+ ExprId AddressOfField(const Variable& var, uint64_t offset, const ILSourceLocation& loc = ILSourceLocation());
ExprId Const(size_t size, uint64_t val, const ILSourceLocation& loc = ILSourceLocation());
ExprId ConstPointer(size_t size, uint64_t val, const ILSourceLocation& loc = ILSourceLocation());
- ExprId ExternPointer(size_t size, uint64_t val, uint64_t offset, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId ExternPointer(
+ size_t size, uint64_t val, uint64_t offset, const ILSourceLocation& loc = ILSourceLocation());
ExprId FloatConstRaw(size_t size, uint64_t val, const ILSourceLocation& loc = ILSourceLocation());
ExprId FloatConstSingle(float val, const ILSourceLocation& loc = ILSourceLocation());
ExprId FloatConstDouble(double val, const ILSourceLocation& loc = ILSourceLocation());
ExprId ImportedAddress(size_t size, uint64_t val, const ILSourceLocation& loc = ILSourceLocation());
ExprId Add(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
- ExprId AddWithCarry(size_t size, ExprId left, ExprId right, ExprId carry,
- const ILSourceLocation& loc = ILSourceLocation());
+ ExprId AddWithCarry(
+ size_t size, ExprId left, ExprId right, ExprId carry, const ILSourceLocation& loc = ILSourceLocation());
ExprId Sub(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
- ExprId SubWithBorrow(size_t size, ExprId left, ExprId right, ExprId carry,
- const ILSourceLocation& loc = ILSourceLocation());
+ ExprId SubWithBorrow(
+ size_t size, ExprId left, ExprId right, ExprId carry, const ILSourceLocation& loc = ILSourceLocation());
ExprId And(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
ExprId Or(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
ExprId Xor(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
- ExprId ShiftLeft(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId LogicalShiftRight(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId ArithShiftRight(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId RotateLeft(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId RotateLeftCarry(size_t size, ExprId left, ExprId right, ExprId carry,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId RotateRight(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId RotateRightCarry(size_t size, ExprId left, ExprId right, ExprId carry,
- const ILSourceLocation& loc = ILSourceLocation());
+ ExprId ShiftLeft(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId LogicalShiftRight(
+ size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId ArithShiftRight(
+ size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId RotateLeft(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId RotateLeftCarry(
+ size_t size, ExprId left, ExprId right, ExprId carry, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId RotateRight(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId RotateRightCarry(
+ size_t size, ExprId left, ExprId right, ExprId carry, const ILSourceLocation& loc = ILSourceLocation());
ExprId Mult(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
- ExprId MultDoublePrecSigned(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId MultDoublePrecUnsigned(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId DivSigned(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId DivUnsigned(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId DivDoublePrecSigned(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId DivDoublePrecUnsigned(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId ModSigned(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId ModUnsigned(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId ModDoublePrecSigned(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId ModDoublePrecUnsigned(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
+ ExprId MultDoublePrecSigned(
+ size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId MultDoublePrecUnsigned(
+ size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId DivSigned(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId DivUnsigned(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId DivDoublePrecSigned(
+ size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId DivDoublePrecUnsigned(
+ size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId ModSigned(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId ModUnsigned(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId ModDoublePrecSigned(
+ size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId ModDoublePrecUnsigned(
+ size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
ExprId Neg(size_t size, ExprId src, const ILSourceLocation& loc = ILSourceLocation());
ExprId Not(size_t size, ExprId src, const ILSourceLocation& loc = ILSourceLocation());
ExprId SignExtend(size_t size, ExprId src, const ILSourceLocation& loc = ILSourceLocation());
@@ -4410,79 +4496,75 @@ __attribute__ ((format (printf, 1, 2)))
ExprId LowPart(size_t size, ExprId src, const ILSourceLocation& loc = ILSourceLocation());
ExprId Jump(ExprId dest, const ILSourceLocation& loc = ILSourceLocation());
ExprId JumpTo(ExprId dest, const std::map<uint64_t, BNMediumLevelILLabel*>& targets,
- const ILSourceLocation& loc = ILSourceLocation());
+ const ILSourceLocation& loc = ILSourceLocation());
ExprId ReturnHint(ExprId dest, const ILSourceLocation& loc = ILSourceLocation());
ExprId Call(const std::vector<Variable>& output, ExprId dest, const std::vector<ExprId>& params,
- const ILSourceLocation& loc = ILSourceLocation());
+ const ILSourceLocation& loc = ILSourceLocation());
ExprId CallUntyped(const std::vector<Variable>& output, ExprId dest, const std::vector<Variable>& params,
- ExprId stack, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId stack, const ILSourceLocation& loc = ILSourceLocation());
ExprId Syscall(const std::vector<Variable>& output, const std::vector<ExprId>& params,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId SyscallUntyped(const std::vector<Variable>& output, const std::vector<Variable>& params,
- ExprId stack, const ILSourceLocation& loc = ILSourceLocation());
+ const ILSourceLocation& loc = ILSourceLocation());
+ ExprId SyscallUntyped(const std::vector<Variable>& output, const std::vector<Variable>& params, ExprId stack,
+ const ILSourceLocation& loc = ILSourceLocation());
ExprId TailCall(const std::vector<Variable>& output, ExprId dest, const std::vector<ExprId>& params,
- const ILSourceLocation& loc = ILSourceLocation());
+ const ILSourceLocation& loc = ILSourceLocation());
ExprId TailCallUntyped(const std::vector<Variable>& output, ExprId dest, const std::vector<Variable>& params,
- ExprId stack, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId stack, const ILSourceLocation& loc = ILSourceLocation());
ExprId CallSSA(const std::vector<SSAVariable>& output, ExprId dest, const std::vector<ExprId>& params,
- size_t newMemVersion, size_t prevMemVersion, const ILSourceLocation& loc = ILSourceLocation());
+ size_t newMemVersion, size_t prevMemVersion, const ILSourceLocation& loc = ILSourceLocation());
ExprId CallUntypedSSA(const std::vector<SSAVariable>& output, ExprId dest,
- const std::vector<SSAVariable>& params, size_t newMemVersion, size_t prevMemVersion,
- ExprId stack, const ILSourceLocation& loc = ILSourceLocation());
+ const std::vector<SSAVariable>& params, size_t newMemVersion, size_t prevMemVersion, ExprId stack,
+ const ILSourceLocation& loc = ILSourceLocation());
ExprId SyscallSSA(const std::vector<SSAVariable>& output, const std::vector<ExprId>& params,
- size_t newMemVersion, size_t prevMemVersion, const ILSourceLocation& loc = ILSourceLocation());
- ExprId SyscallUntypedSSA(const std::vector<SSAVariable>& output,
- const std::vector<SSAVariable>& params, size_t newMemVersion, size_t prevMemVersion,
- ExprId stack, const ILSourceLocation& loc = ILSourceLocation());
+ size_t newMemVersion, size_t prevMemVersion, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId SyscallUntypedSSA(const std::vector<SSAVariable>& output, const std::vector<SSAVariable>& params,
+ size_t newMemVersion, size_t prevMemVersion, ExprId stack,
+ const ILSourceLocation& loc = ILSourceLocation());
ExprId TailCallSSA(const std::vector<SSAVariable>& output, ExprId dest, const std::vector<ExprId>& params,
- size_t newMemVersion, size_t prevMemVersion, const ILSourceLocation& loc = ILSourceLocation());
+ size_t newMemVersion, size_t prevMemVersion, const ILSourceLocation& loc = ILSourceLocation());
ExprId TailCallUntypedSSA(const std::vector<SSAVariable>& output, ExprId dest,
- const std::vector<SSAVariable>& params, size_t newMemVersion, size_t prevMemVersion,
- ExprId stack, const ILSourceLocation& loc = ILSourceLocation());
+ const std::vector<SSAVariable>& params, size_t newMemVersion, size_t prevMemVersion, ExprId stack,
+ const ILSourceLocation& loc = ILSourceLocation());
ExprId Return(const std::vector<ExprId>& sources, const ILSourceLocation& loc = ILSourceLocation());
ExprId NoReturn(const ILSourceLocation& loc = ILSourceLocation());
- ExprId CompareEqual(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId CompareNotEqual(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId CompareSignedLessThan(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId CompareUnsignedLessThan(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId CompareSignedLessEqual(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId CompareUnsignedLessEqual(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId CompareSignedGreaterEqual(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId CompareUnsignedGreaterEqual(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId CompareSignedGreaterThan(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId CompareUnsignedGreaterThan(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId TestBit(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
+ ExprId CompareEqual(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId CompareNotEqual(
+ size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId CompareSignedLessThan(
+ size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId CompareUnsignedLessThan(
+ size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId CompareSignedLessEqual(
+ size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId CompareUnsignedLessEqual(
+ size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId CompareSignedGreaterEqual(
+ size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId CompareUnsignedGreaterEqual(
+ size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId CompareSignedGreaterThan(
+ size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId CompareUnsignedGreaterThan(
+ size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId TestBit(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
ExprId BoolToInt(size_t size, ExprId src, const ILSourceLocation& loc = ILSourceLocation());
- ExprId AddOverflow(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
+ ExprId AddOverflow(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
ExprId Breakpoint(const ILSourceLocation& loc = ILSourceLocation());
ExprId Trap(int64_t vector, const ILSourceLocation& loc = ILSourceLocation());
- ExprId Intrinsic(const std::vector<Variable>& outputs, uint32_t intrinsic,
- const std::vector<ExprId>& params, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId Intrinsic(const std::vector<Variable>& outputs, uint32_t intrinsic, const std::vector<ExprId>& params,
+ const ILSourceLocation& loc = ILSourceLocation());
ExprId IntrinsicSSA(const std::vector<SSAVariable>& outputs, uint32_t intrinsic,
- const std::vector<ExprId>& params, const ILSourceLocation& loc = ILSourceLocation());
+ const std::vector<ExprId>& params, const ILSourceLocation& loc = ILSourceLocation());
ExprId FreeVarSlot(const Variable& var, const ILSourceLocation& loc = ILSourceLocation());
ExprId FreeVarSlotSSA(const Variable& var, size_t newVersion, size_t prevVersion,
- const ILSourceLocation& loc = ILSourceLocation());
+ const ILSourceLocation& loc = ILSourceLocation());
ExprId Undefined(const ILSourceLocation& loc = ILSourceLocation());
ExprId Unimplemented(const ILSourceLocation& loc = ILSourceLocation());
- ExprId UnimplementedMemoryRef(size_t size, ExprId target,
- const ILSourceLocation& loc = ILSourceLocation());
+ ExprId UnimplementedMemoryRef(size_t size, ExprId target, const ILSourceLocation& loc = ILSourceLocation());
ExprId VarPhi(const SSAVariable& dest, const std::vector<SSAVariable>& sources,
- const ILSourceLocation& loc = ILSourceLocation());
+ const ILSourceLocation& loc = ILSourceLocation());
ExprId MemoryPhi(size_t destMemVersion, const std::vector<size_t>& sourceMemVersions,
- const ILSourceLocation& loc = ILSourceLocation());
+ const ILSourceLocation& loc = ILSourceLocation());
ExprId FloatAdd(size_t size, ExprId a, ExprId b, const ILSourceLocation& loc = ILSourceLocation());
ExprId FloatSub(size_t size, ExprId a, ExprId b, const ILSourceLocation& loc = ILSourceLocation());
ExprId FloatMult(size_t size, ExprId a, ExprId b, const ILSourceLocation& loc = ILSourceLocation());
@@ -4501,14 +4583,16 @@ __attribute__ ((format (printf, 1, 2)))
ExprId FloatCompareNotEqual(size_t size, ExprId a, ExprId b, const ILSourceLocation& loc = ILSourceLocation());
ExprId FloatCompareLessThan(size_t size, ExprId a, ExprId b, const ILSourceLocation& loc = ILSourceLocation());
ExprId FloatCompareLessEqual(size_t size, ExprId a, ExprId b, const ILSourceLocation& loc = ILSourceLocation());
- ExprId FloatCompareGreaterEqual(size_t size, ExprId a, ExprId b, const ILSourceLocation& loc = ILSourceLocation());
- ExprId FloatCompareGreaterThan(size_t size, ExprId a, ExprId b, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId FloatCompareGreaterEqual(
+ size_t size, ExprId a, ExprId b, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId FloatCompareGreaterThan(
+ size_t size, ExprId a, ExprId b, const ILSourceLocation& loc = ILSourceLocation());
ExprId FloatCompareOrdered(size_t size, ExprId a, ExprId b, const ILSourceLocation& loc = ILSourceLocation());
ExprId FloatCompareUnordered(size_t size, ExprId a, ExprId b, const ILSourceLocation& loc = ILSourceLocation());
ExprId Goto(BNMediumLevelILLabel& label, const ILSourceLocation& loc = ILSourceLocation());
ExprId If(ExprId operand, BNMediumLevelILLabel& t, BNMediumLevelILLabel& f,
- const ILSourceLocation& loc = ILSourceLocation());
+ const ILSourceLocation& loc = ILSourceLocation());
void MarkLabel(BNMediumLevelILLabel& label);
ExprId AddInstruction(ExprId expr);
@@ -4536,16 +4620,16 @@ __attribute__ ((format (printf, 1, 2)))
void Finalize();
void GenerateSSAForm(bool analyzeConditionals = true, bool handleAliases = true,
- const std::set<Variable>& knownNotAliases = std::set<Variable>(),
- const std::set<Variable>& knownAliases = std::set<Variable>());
+ const std::set<Variable>& knownNotAliases = std::set<Variable>(),
+ const std::set<Variable>& knownAliases = std::set<Variable>());
- bool GetExprText(Architecture* arch, ExprId expr,
- std::vector<InstructionTextToken>& tokens,
- DisassemblySettings* settings = nullptr);
- bool GetInstructionText(Function* func, Architecture* arch, size_t i,
- std::vector<InstructionTextToken>& tokens, DisassemblySettings* settings = nullptr);
+ bool GetExprText(Architecture* arch, ExprId expr, std::vector<InstructionTextToken>& tokens,
+ DisassemblySettings* settings = nullptr);
+ bool GetInstructionText(Function* func, Architecture* arch, size_t i, std::vector<InstructionTextToken>& tokens,
+ DisassemblySettings* settings = nullptr);
- void VisitInstructions(const std::function<void(BasicBlock* block, const MediumLevelILInstruction& instr)>& func);
+ void VisitInstructions(
+ const std::function<void(BasicBlock* block, const MediumLevelILInstruction& instr)>& func);
void VisitAllExprs(const std::function<bool(BasicBlock* block, const MediumLevelILInstruction& expr)>& func);
std::vector<Ref<BasicBlock>> GetBasicBlocks() const;
@@ -4571,11 +4655,11 @@ __attribute__ ((format (printf, 1, 2)))
RegisterValue GetExprValue(size_t expr);
RegisterValue GetExprValue(const MediumLevelILInstruction& expr);
PossibleValueSet GetPossibleSSAVarValues(const SSAVariable& var, size_t instr,
- const std::set<BNDataFlowQueryOption>& options = std::set<BNDataFlowQueryOption>());
- PossibleValueSet GetPossibleExprValues(size_t expr,
- const std::set<BNDataFlowQueryOption>& options = std::set<BNDataFlowQueryOption>());
+ const std::set<BNDataFlowQueryOption>& options = std::set<BNDataFlowQueryOption>());
+ PossibleValueSet GetPossibleExprValues(
+ size_t expr, const std::set<BNDataFlowQueryOption>& options = std::set<BNDataFlowQueryOption>());
PossibleValueSet GetPossibleExprValues(const MediumLevelILInstruction& expr,
- const std::set<BNDataFlowQueryOption>& options = std::set<BNDataFlowQueryOption>());
+ const std::set<BNDataFlowQueryOption>& options = std::set<BNDataFlowQueryOption>());
size_t GetSSAVarVersionAtInstruction(const Variable& var, size_t instr) const;
size_t GetSSAMemoryVersionAtInstruction(size_t instr) const;
@@ -4586,21 +4670,21 @@ __attribute__ ((format (printf, 1, 2)))
RegisterValue GetRegisterValueAtInstruction(uint32_t reg, size_t instr);
RegisterValue GetRegisterValueAfterInstruction(uint32_t reg, size_t instr);
PossibleValueSet GetPossibleRegisterValuesAtInstruction(uint32_t reg, size_t instr,
- const std::set<BNDataFlowQueryOption>& options = std::set<BNDataFlowQueryOption>());
+ const std::set<BNDataFlowQueryOption>& options = std::set<BNDataFlowQueryOption>());
PossibleValueSet GetPossibleRegisterValuesAfterInstruction(uint32_t reg, size_t instr,
- const std::set<BNDataFlowQueryOption>& options = std::set<BNDataFlowQueryOption>());
+ const std::set<BNDataFlowQueryOption>& options = std::set<BNDataFlowQueryOption>());
RegisterValue GetFlagValueAtInstruction(uint32_t flag, size_t instr);
RegisterValue GetFlagValueAfterInstruction(uint32_t flag, size_t instr);
PossibleValueSet GetPossibleFlagValuesAtInstruction(uint32_t flag, size_t instr,
- const std::set<BNDataFlowQueryOption>& options = std::set<BNDataFlowQueryOption>());
+ const std::set<BNDataFlowQueryOption>& options = std::set<BNDataFlowQueryOption>());
PossibleValueSet GetPossibleFlagValuesAfterInstruction(uint32_t flag, size_t instr,
- const std::set<BNDataFlowQueryOption>& options = std::set<BNDataFlowQueryOption>());
+ const std::set<BNDataFlowQueryOption>& options = std::set<BNDataFlowQueryOption>());
RegisterValue GetStackContentsAtInstruction(int32_t offset, size_t len, size_t instr);
RegisterValue GetStackContentsAfterInstruction(int32_t offset, size_t len, size_t instr);
PossibleValueSet GetPossibleStackContentsAtInstruction(int32_t offset, size_t len, size_t instr,
- const std::set<BNDataFlowQueryOption>& options = std::set<BNDataFlowQueryOption>());
+ const std::set<BNDataFlowQueryOption>& options = std::set<BNDataFlowQueryOption>());
PossibleValueSet GetPossibleStackContentsAfterInstruction(int32_t offset, size_t len, size_t instr,
- const std::set<BNDataFlowQueryOption>& options = std::set<BNDataFlowQueryOption>());
+ const std::set<BNDataFlowQueryOption>& options = std::set<BNDataFlowQueryOption>());
BNILBranchDependence GetBranchDependenceAtInstruction(size_t curInstr, size_t branchInstr) const;
std::unordered_map<size_t, BNILBranchDependence> GetAllBranchDependenceAtInstruction(size_t instr) const;
@@ -4617,17 +4701,20 @@ __attribute__ ((format (printf, 1, 2)))
Confidence<Ref<Type>> GetExprType(size_t expr);
Confidence<Ref<Type>> GetExprType(const MediumLevelILInstruction& expr);
- static bool IsConstantType(BNMediumLevelILOperation op) { return op == MLIL_CONST || op == MLIL_CONST_PTR || op == MLIL_EXTERN_PTR; }
+ static bool IsConstantType(BNMediumLevelILOperation op)
+ {
+ return op == MLIL_CONST || op == MLIL_CONST_PTR || op == MLIL_EXTERN_PTR;
+ }
Ref<FlowGraph> CreateFunctionGraph(DisassemblySettings* settings = nullptr);
};
struct HighLevelILInstruction;
- class HighLevelILFunction: public CoreRefCountObject<BNHighLevelILFunction,
- BNNewHighLevelILFunctionReference, BNFreeHighLevelILFunction>
+ class HighLevelILFunction :
+ public CoreRefCountObject<BNHighLevelILFunction, BNNewHighLevelILFunctionReference, BNFreeHighLevelILFunction>
{
- public:
+ public:
HighLevelILFunction(Architecture* arch, Function* func = nullptr);
HighLevelILFunction(BNHighLevelILFunction* func);
@@ -4641,31 +4728,31 @@ __attribute__ ((format (printf, 1, 2)))
void SetRootExpr(ExprId expr);
void SetRootExpr(const HighLevelILInstruction& expr);
- ExprId AddExpr(BNHighLevelILOperation operation, size_t size,
- ExprId a = 0, ExprId b = 0, ExprId c = 0, ExprId d = 0, ExprId e = 0);
- ExprId AddExprWithLocation(BNHighLevelILOperation operation, uint64_t addr, uint32_t sourceOperand,
- size_t size, ExprId a = 0, ExprId b = 0, ExprId c = 0, ExprId d = 0, ExprId e = 0);
- ExprId AddExprWithLocation(BNHighLevelILOperation operation, const ILSourceLocation& loc,
- size_t size, ExprId a = 0, ExprId b = 0, ExprId c = 0, ExprId d = 0, ExprId e = 0);
+ ExprId AddExpr(BNHighLevelILOperation operation, size_t size, ExprId a = 0, ExprId b = 0, ExprId c = 0,
+ ExprId d = 0, ExprId e = 0);
+ ExprId AddExprWithLocation(BNHighLevelILOperation operation, uint64_t addr, uint32_t sourceOperand, size_t size,
+ ExprId a = 0, ExprId b = 0, ExprId c = 0, ExprId d = 0, ExprId e = 0);
+ ExprId AddExprWithLocation(BNHighLevelILOperation operation, const ILSourceLocation& loc, size_t size,
+ ExprId a = 0, ExprId b = 0, ExprId c = 0, ExprId d = 0, ExprId e = 0);
ExprId Nop(const ILSourceLocation& loc = ILSourceLocation());
ExprId Block(const std::vector<ExprId>& exprs, const ILSourceLocation& loc = ILSourceLocation());
- ExprId If(ExprId condition, ExprId trueExpr, ExprId falseExpr,
- const ILSourceLocation& loc = ILSourceLocation());
+ ExprId If(
+ ExprId condition, ExprId trueExpr, ExprId falseExpr, const ILSourceLocation& loc = ILSourceLocation());
ExprId While(ExprId condition, ExprId loopExpr, const ILSourceLocation& loc = ILSourceLocation());
- ExprId WhileSSA(ExprId conditionPhi, ExprId condition, ExprId loopExpr,
- const ILSourceLocation& loc = ILSourceLocation());
+ ExprId WhileSSA(
+ ExprId conditionPhi, ExprId condition, ExprId loopExpr, const ILSourceLocation& loc = ILSourceLocation());
ExprId DoWhile(ExprId loopExpr, ExprId condition, const ILSourceLocation& loc = ILSourceLocation());
- ExprId DoWhileSSA(ExprId loopExpr, ExprId conditionPhi, ExprId condition,
- const ILSourceLocation& loc = ILSourceLocation());
+ ExprId DoWhileSSA(
+ ExprId loopExpr, ExprId conditionPhi, ExprId condition, const ILSourceLocation& loc = ILSourceLocation());
ExprId For(ExprId initExpr, ExprId condition, ExprId updateExpr, ExprId loopExpr,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId ForSSA(ExprId initExpr, ExprId conditionPhi, ExprId condition, ExprId updateExpr,
- ExprId loopExpr, const ILSourceLocation& loc = ILSourceLocation());
+ const ILSourceLocation& loc = ILSourceLocation());
+ ExprId ForSSA(ExprId initExpr, ExprId conditionPhi, ExprId condition, ExprId updateExpr, ExprId loopExpr,
+ const ILSourceLocation& loc = ILSourceLocation());
ExprId Switch(ExprId condition, ExprId defaultExpr, const std::vector<ExprId>& cases,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId Case(const std::vector<ExprId>& condition, ExprId expr,
- const ILSourceLocation& loc = ILSourceLocation());
+ const ILSourceLocation& loc = ILSourceLocation());
+ ExprId Case(
+ const std::vector<ExprId>& condition, ExprId expr, const ILSourceLocation& loc = ILSourceLocation());
ExprId Break(const ILSourceLocation& loc = ILSourceLocation());
ExprId Continue(const ILSourceLocation& loc = ILSourceLocation());
ExprId Jump(ExprId dest, const ILSourceLocation& loc = ILSourceLocation());
@@ -4674,137 +4761,125 @@ __attribute__ ((format (printf, 1, 2)))
ExprId Goto(uint64_t target, const ILSourceLocation& loc = ILSourceLocation());
ExprId Label(uint64_t target, const ILSourceLocation& loc = ILSourceLocation());
ExprId VarDeclare(const Variable& var, const ILSourceLocation& loc = ILSourceLocation());
- ExprId VarInit(size_t size, const Variable& dest, ExprId src,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId VarInitSSA(size_t size, const SSAVariable& dest, ExprId src,
- const ILSourceLocation& loc = ILSourceLocation());
+ ExprId VarInit(size_t size, const Variable& dest, ExprId src, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId VarInitSSA(
+ size_t size, const SSAVariable& dest, ExprId src, const ILSourceLocation& loc = ILSourceLocation());
ExprId Assign(size_t size, ExprId dest, ExprId src, const ILSourceLocation& loc = ILSourceLocation());
- ExprId AssignUnpack(const std::vector<ExprId>& output, ExprId src,
- const ILSourceLocation& loc = ILSourceLocation());
+ ExprId AssignUnpack(
+ const std::vector<ExprId>& output, ExprId src, const ILSourceLocation& loc = ILSourceLocation());
ExprId AssignMemSSA(size_t size, ExprId dest, size_t destMemVersion, ExprId src, size_t srcMemVersion,
- const ILSourceLocation& loc = ILSourceLocation());
+ const ILSourceLocation& loc = ILSourceLocation());
ExprId AssignUnpackMemSSA(const std::vector<ExprId>& output, size_t destMemVersion, ExprId src,
- size_t srcMemVersion, const ILSourceLocation& loc = ILSourceLocation());
+ size_t srcMemVersion, const ILSourceLocation& loc = ILSourceLocation());
ExprId Var(size_t size, const Variable& src, const ILSourceLocation& loc = ILSourceLocation());
ExprId VarSSA(size_t size, const SSAVariable& src, const ILSourceLocation& loc = ILSourceLocation());
ExprId VarPhi(const SSAVariable& dest, const std::vector<SSAVariable>& sources,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId MemPhi(size_t dest, const std::vector<size_t>& sources,
- const ILSourceLocation& loc = ILSourceLocation());
+ const ILSourceLocation& loc = ILSourceLocation());
+ ExprId MemPhi(
+ size_t dest, const std::vector<size_t>& sources, const ILSourceLocation& loc = ILSourceLocation());
ExprId StructField(size_t size, ExprId src, uint64_t offset, size_t memberIndex,
- const ILSourceLocation& loc = ILSourceLocation());
+ const ILSourceLocation& loc = ILSourceLocation());
ExprId ArrayIndex(size_t size, ExprId src, ExprId idx, const ILSourceLocation& loc = ILSourceLocation());
ExprId ArrayIndexSSA(size_t size, ExprId src, size_t srcMemVersion, ExprId idx,
- const ILSourceLocation& loc = ILSourceLocation());
+ const ILSourceLocation& loc = ILSourceLocation());
ExprId Split(size_t size, ExprId high, ExprId low, const ILSourceLocation& loc = ILSourceLocation());
ExprId Deref(size_t size, ExprId src, const ILSourceLocation& loc = ILSourceLocation());
ExprId DerefField(size_t size, ExprId src, uint64_t offset, size_t memberIndex,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId DerefSSA(size_t size, ExprId src, size_t srcMemVersion,
- const ILSourceLocation& loc = ILSourceLocation());
+ const ILSourceLocation& loc = ILSourceLocation());
+ ExprId DerefSSA(
+ size_t size, ExprId src, size_t srcMemVersion, const ILSourceLocation& loc = ILSourceLocation());
ExprId DerefFieldSSA(size_t size, ExprId src, size_t srcMemVersion, uint64_t offset, size_t memberIndex,
- const ILSourceLocation& loc = ILSourceLocation());
+ const ILSourceLocation& loc = ILSourceLocation());
ExprId AddressOf(ExprId src, const ILSourceLocation& loc = ILSourceLocation());
ExprId Const(size_t size, uint64_t val, const ILSourceLocation& loc = ILSourceLocation());
ExprId ConstPointer(size_t size, uint64_t val, const ILSourceLocation& loc = ILSourceLocation());
- ExprId ExternPointer(size_t size, uint64_t val, uint64_t offset, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId ExternPointer(
+ size_t size, uint64_t val, uint64_t offset, const ILSourceLocation& loc = ILSourceLocation());
ExprId FloatConstRaw(size_t size, uint64_t val, const ILSourceLocation& loc = ILSourceLocation());
ExprId FloatConstSingle(float val, const ILSourceLocation& loc = ILSourceLocation());
ExprId FloatConstDouble(double val, const ILSourceLocation& loc = ILSourceLocation());
ExprId ImportedAddress(size_t size, uint64_t val, const ILSourceLocation& loc = ILSourceLocation());
ExprId Add(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
- ExprId AddWithCarry(size_t size, ExprId left, ExprId right, ExprId carry,
- const ILSourceLocation& loc = ILSourceLocation());
+ ExprId AddWithCarry(
+ size_t size, ExprId left, ExprId right, ExprId carry, const ILSourceLocation& loc = ILSourceLocation());
ExprId Sub(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
- ExprId SubWithBorrow(size_t size, ExprId left, ExprId right, ExprId carry,
- const ILSourceLocation& loc = ILSourceLocation());
+ ExprId SubWithBorrow(
+ size_t size, ExprId left, ExprId right, ExprId carry, const ILSourceLocation& loc = ILSourceLocation());
ExprId And(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
ExprId Or(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
ExprId Xor(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
- ExprId ShiftLeft(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId LogicalShiftRight(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId ArithShiftRight(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId RotateLeft(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId RotateLeftCarry(size_t size, ExprId left, ExprId right, ExprId carry,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId RotateRight(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId RotateRightCarry(size_t size, ExprId left, ExprId right, ExprId carry,
- const ILSourceLocation& loc = ILSourceLocation());
+ ExprId ShiftLeft(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId LogicalShiftRight(
+ size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId ArithShiftRight(
+ size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId RotateLeft(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId RotateLeftCarry(
+ size_t size, ExprId left, ExprId right, ExprId carry, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId RotateRight(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId RotateRightCarry(
+ size_t size, ExprId left, ExprId right, ExprId carry, const ILSourceLocation& loc = ILSourceLocation());
ExprId Mult(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
- ExprId MultDoublePrecSigned(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId MultDoublePrecUnsigned(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId DivSigned(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId DivUnsigned(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId DivDoublePrecSigned(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId DivDoublePrecUnsigned(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId ModSigned(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId ModUnsigned(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId ModDoublePrecSigned(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId ModDoublePrecUnsigned(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
+ ExprId MultDoublePrecSigned(
+ size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId MultDoublePrecUnsigned(
+ size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId DivSigned(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId DivUnsigned(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId DivDoublePrecSigned(
+ size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId DivDoublePrecUnsigned(
+ size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId ModSigned(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId ModUnsigned(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId ModDoublePrecSigned(
+ size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId ModDoublePrecUnsigned(
+ size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
ExprId Neg(size_t size, ExprId src, const ILSourceLocation& loc = ILSourceLocation());
ExprId Not(size_t size, ExprId src, const ILSourceLocation& loc = ILSourceLocation());
ExprId SignExtend(size_t size, ExprId src, const ILSourceLocation& loc = ILSourceLocation());
ExprId ZeroExtend(size_t size, ExprId src, const ILSourceLocation& loc = ILSourceLocation());
ExprId LowPart(size_t size, ExprId src, const ILSourceLocation& loc = ILSourceLocation());
- ExprId Call(ExprId dest, const std::vector<ExprId>& params,
- const ILSourceLocation& loc = ILSourceLocation());
+ ExprId Call(ExprId dest, const std::vector<ExprId>& params, const ILSourceLocation& loc = ILSourceLocation());
ExprId Syscall(const std::vector<ExprId>& params, const ILSourceLocation& loc = ILSourceLocation());
- ExprId TailCall(ExprId dest, const std::vector<ExprId>& params,
- const ILSourceLocation& loc = ILSourceLocation());
+ ExprId TailCall(
+ ExprId dest, const std::vector<ExprId>& params, const ILSourceLocation& loc = ILSourceLocation());
ExprId CallSSA(ExprId dest, const std::vector<ExprId>& params, size_t destMemVersion, size_t srcMemVersion,
- const ILSourceLocation& loc = ILSourceLocation());
+ const ILSourceLocation& loc = ILSourceLocation());
ExprId SyscallSSA(const std::vector<ExprId>& params, size_t destMemVersion, size_t srcMemVersion,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId CompareEqual(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId CompareNotEqual(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId CompareSignedLessThan(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId CompareUnsignedLessThan(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId CompareSignedLessEqual(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId CompareUnsignedLessEqual(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId CompareSignedGreaterEqual(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId CompareUnsignedGreaterEqual(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId CompareSignedGreaterThan(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId CompareUnsignedGreaterThan(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
- ExprId TestBit(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
+ const ILSourceLocation& loc = ILSourceLocation());
+ ExprId CompareEqual(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId CompareNotEqual(
+ size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId CompareSignedLessThan(
+ size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId CompareUnsignedLessThan(
+ size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId CompareSignedLessEqual(
+ size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId CompareUnsignedLessEqual(
+ size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId CompareSignedGreaterEqual(
+ size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId CompareUnsignedGreaterEqual(
+ size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId CompareSignedGreaterThan(
+ size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId CompareUnsignedGreaterThan(
+ size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId TestBit(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
ExprId BoolToInt(size_t size, ExprId src, const ILSourceLocation& loc = ILSourceLocation());
- ExprId AddOverflow(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc = ILSourceLocation());
+ ExprId AddOverflow(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc = ILSourceLocation());
ExprId Breakpoint(const ILSourceLocation& loc = ILSourceLocation());
ExprId Trap(int64_t vector, const ILSourceLocation& loc = ILSourceLocation());
- ExprId Intrinsic(uint32_t intrinsic, const std::vector<ExprId>& params,
- const ILSourceLocation& loc = ILSourceLocation());
+ ExprId Intrinsic(
+ uint32_t intrinsic, const std::vector<ExprId>& params, const ILSourceLocation& loc = ILSourceLocation());
ExprId IntrinsicSSA(uint32_t intrinsic, const std::vector<ExprId>& params, size_t destMemVersion,
- size_t srcMemVersion, const ILSourceLocation& loc = ILSourceLocation());
+ size_t srcMemVersion, const ILSourceLocation& loc = ILSourceLocation());
ExprId Undefined(const ILSourceLocation& loc = ILSourceLocation());
ExprId Unimplemented(const ILSourceLocation& loc = ILSourceLocation());
- ExprId UnimplementedMemoryRef(size_t size, ExprId target,
- const ILSourceLocation& loc = ILSourceLocation());
+ ExprId UnimplementedMemoryRef(size_t size, ExprId target, const ILSourceLocation& loc = ILSourceLocation());
ExprId FloatAdd(size_t size, ExprId a, ExprId b, const ILSourceLocation& loc = ILSourceLocation());
ExprId FloatSub(size_t size, ExprId a, ExprId b, const ILSourceLocation& loc = ILSourceLocation());
ExprId FloatMult(size_t size, ExprId a, ExprId b, const ILSourceLocation& loc = ILSourceLocation());
@@ -4823,8 +4898,10 @@ __attribute__ ((format (printf, 1, 2)))
ExprId FloatCompareNotEqual(size_t size, ExprId a, ExprId b, const ILSourceLocation& loc = ILSourceLocation());
ExprId FloatCompareLessThan(size_t size, ExprId a, ExprId b, const ILSourceLocation& loc = ILSourceLocation());
ExprId FloatCompareLessEqual(size_t size, ExprId a, ExprId b, const ILSourceLocation& loc = ILSourceLocation());
- ExprId FloatCompareGreaterEqual(size_t size, ExprId a, ExprId b, const ILSourceLocation& loc = ILSourceLocation());
- ExprId FloatCompareGreaterThan(size_t size, ExprId a, ExprId b, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId FloatCompareGreaterEqual(
+ size_t size, ExprId a, ExprId b, const ILSourceLocation& loc = ILSourceLocation());
+ ExprId FloatCompareGreaterThan(
+ size_t size, ExprId a, ExprId b, const ILSourceLocation& loc = ILSourceLocation());
ExprId FloatCompareOrdered(size_t size, ExprId a, ExprId b, const ILSourceLocation& loc = ILSourceLocation());
ExprId FloatCompareUnordered(size_t size, ExprId a, ExprId b, const ILSourceLocation& loc = ILSourceLocation());
@@ -4875,12 +4952,12 @@ __attribute__ ((format (printf, 1, 2)))
void Finalize();
- std::vector<DisassemblyTextLine> GetExprText(ExprId expr,
- bool asFullAst = true, DisassemblySettings* settings = nullptr);
- std::vector<DisassemblyTextLine> GetExprText(const HighLevelILInstruction& instr,
- bool asFullAst = true, DisassemblySettings* settings = nullptr);
- std::vector<DisassemblyTextLine> GetInstructionText(size_t i,
- bool asFullAst = true, DisassemblySettings* settings = nullptr);
+ std::vector<DisassemblyTextLine> GetExprText(
+ ExprId expr, bool asFullAst = true, DisassemblySettings* settings = nullptr);
+ std::vector<DisassemblyTextLine> GetExprText(
+ const HighLevelILInstruction& instr, bool asFullAst = true, DisassemblySettings* settings = nullptr);
+ std::vector<DisassemblyTextLine> GetInstructionText(
+ size_t i, bool asFullAst = true, DisassemblySettings* settings = nullptr);
Confidence<Ref<Type>> GetExprType(size_t expr);
Confidence<Ref<Type>> GetExprType(const HighLevelILInstruction& expr);
@@ -4893,20 +4970,23 @@ __attribute__ ((format (printf, 1, 2)))
std::set<size_t> GetUsesForLabel(uint64_t label);
};
- class LanguageRepresentationFunction: public CoreRefCountObject<BNLanguageRepresentationFunction,
- BNNewLanguageRepresentationFunctionReference, BNFreeLanguageRepresentationFunction>
+ class LanguageRepresentationFunction :
+ public CoreRefCountObject<BNLanguageRepresentationFunction, BNNewLanguageRepresentationFunctionReference,
+ BNFreeLanguageRepresentationFunction>
{
- public:
+ public:
LanguageRepresentationFunction(Architecture* arch, Function* func = nullptr);
LanguageRepresentationFunction(BNLanguageRepresentationFunction* func);
};
class FunctionRecognizer
{
- static bool RecognizeLowLevelILCallback(void* ctxt, BNBinaryView* data, BNFunction* func, BNLowLevelILFunction* il);
- static bool RecognizeMediumLevelILCallback(void* ctxt, BNBinaryView* data, BNFunction* func, BNMediumLevelILFunction* il);
+ static bool RecognizeLowLevelILCallback(
+ void* ctxt, BNBinaryView* data, BNFunction* func, BNLowLevelILFunction* il);
+ static bool RecognizeMediumLevelILCallback(
+ void* ctxt, BNBinaryView* data, BNFunction* func, BNMediumLevelILFunction* il);
- public:
+ public:
FunctionRecognizer();
static void RegisterGlobalRecognizer(FunctionRecognizer* recog);
@@ -4916,44 +4996,48 @@ __attribute__ ((format (printf, 1, 2)))
virtual bool RecognizeMediumLevelIL(BinaryView* data, Function* func, MediumLevelILFunction* il);
};
- class RelocationHandler: public CoreRefCountObject<BNRelocationHandler,
- BNNewRelocationHandlerReference, BNFreeRelocationHandler>
+ class RelocationHandler :
+ public CoreRefCountObject<BNRelocationHandler, BNNewRelocationHandlerReference, BNFreeRelocationHandler>
{
- static bool GetRelocationInfoCallback(void* ctxt, BNBinaryView* view, BNArchitecture* arch,
- BNRelocationInfo* result, size_t resultCount);
- static bool ApplyRelocationCallback(void* ctxt, BNBinaryView* view, BNArchitecture* arch, BNRelocation* reloc,
- uint8_t* dest, size_t len);
+ static bool GetRelocationInfoCallback(
+ void* ctxt, BNBinaryView* view, BNArchitecture* arch, BNRelocationInfo* result, size_t resultCount);
+ static bool ApplyRelocationCallback(
+ void* ctxt, BNBinaryView* view, BNArchitecture* arch, BNRelocation* reloc, uint8_t* dest, size_t len);
static size_t GetOperandForExternalRelocationCallback(void* ctxt, const uint8_t* data, uint64_t addr,
- size_t length, BNLowLevelILFunction* il, BNRelocation* relocation);
- protected:
+ size_t length, BNLowLevelILFunction* il, BNRelocation* relocation);
+
+ protected:
RelocationHandler();
RelocationHandler(BNRelocationHandler* handler);
static void FreeCallback(void* ctxt);
- public:
- virtual bool GetRelocationInfo(Ref<BinaryView> view, Ref<Architecture> arch, std::vector<BNRelocationInfo>& result);
- virtual bool ApplyRelocation(Ref<BinaryView> view, Ref<Architecture> arch, Ref<Relocation> reloc, uint8_t* dest,
- size_t len);
- virtual size_t GetOperandForExternalRelocation(const uint8_t* data, uint64_t addr, size_t length,
- Ref<LowLevelILFunction> il, Ref<Relocation> relocation);
+ public:
+ virtual bool GetRelocationInfo(
+ Ref<BinaryView> view, Ref<Architecture> arch, std::vector<BNRelocationInfo>& result);
+ virtual bool ApplyRelocation(
+ Ref<BinaryView> view, Ref<Architecture> arch, Ref<Relocation> reloc, uint8_t* dest, size_t len);
+ virtual size_t GetOperandForExternalRelocation(
+ const uint8_t* data, uint64_t addr, size_t length, Ref<LowLevelILFunction> il, Ref<Relocation> relocation);
};
- class CoreRelocationHandler: public RelocationHandler
+ class CoreRelocationHandler : public RelocationHandler
{
- public:
+ public:
CoreRelocationHandler(BNRelocationHandler* handler);
- virtual bool GetRelocationInfo(Ref<BinaryView> view, Ref<Architecture> arch, std::vector<BNRelocationInfo>& result) override;
- virtual bool ApplyRelocation(Ref<BinaryView> view, Ref<Architecture> arch, Ref<Relocation> reloc, uint8_t* dest,
- size_t len) override;
+ virtual bool GetRelocationInfo(
+ Ref<BinaryView> view, Ref<Architecture> arch, std::vector<BNRelocationInfo>& result) override;
+ virtual bool ApplyRelocation(
+ Ref<BinaryView> view, Ref<Architecture> arch, Ref<Relocation> reloc, uint8_t* dest, size_t len) override;
virtual size_t GetOperandForExternalRelocation(const uint8_t* data, uint64_t addr, size_t length,
- Ref<LowLevelILFunction> il, Ref<Relocation> relocation) override;
+ Ref<LowLevelILFunction> il, Ref<Relocation> relocation) override;
};
- class UpdateException: public std::exception
+ class UpdateException : public std::exception
{
const std::string m_desc;
- public:
- UpdateException(const std::string& desc): std::exception(), m_desc(desc) {}
+
+ public:
+ UpdateException(const std::string& desc) : std::exception(), m_desc(desc) {}
virtual const char* what() const NOEXCEPT { return m_desc.c_str(); }
};
@@ -4968,14 +5052,14 @@ __attribute__ ((format (printf, 1, 2)))
bool AreUpdatesAvailable(uint64_t* expireTime, uint64_t* serverTime);
BNUpdateResult UpdateToVersion(const std::string& version);
- BNUpdateResult UpdateToVersion(const std::string& version,
- const std::function<bool(uint64_t progress, uint64_t total)>& progress);
+ BNUpdateResult UpdateToVersion(
+ const std::string& version, const std::function<bool(uint64_t progress, uint64_t total)>& progress);
BNUpdateResult UpdateToLatestVersion();
BNUpdateResult UpdateToLatestVersion(const std::function<bool(uint64_t progress, uint64_t total)>& progress);
};
/*! UpdateVersion documentation
- */
+ */
struct UpdateVersion
{
std::string version;
@@ -5066,37 +5150,37 @@ __attribute__ ((format (printf, 1, 2)))
static void AddressPluginCommandActionCallback(void* ctxt, BNBinaryView* view, uint64_t addr);
static void RangePluginCommandActionCallback(void* ctxt, BNBinaryView* view, uint64_t addr, uint64_t len);
static void FunctionPluginCommandActionCallback(void* ctxt, BNBinaryView* view, BNFunction* func);
- static void LowLevelILFunctionPluginCommandActionCallback(void* ctxt, BNBinaryView* view,
- BNLowLevelILFunction* func);
- static void LowLevelILInstructionPluginCommandActionCallback(void* ctxt, BNBinaryView* view,
- BNLowLevelILFunction* func, size_t instr);
- static void MediumLevelILFunctionPluginCommandActionCallback(void* ctxt, BNBinaryView* view,
- BNMediumLevelILFunction* func);
- static void MediumLevelILInstructionPluginCommandActionCallback(void* ctxt, BNBinaryView* view,
- BNMediumLevelILFunction* func, size_t instr);
- static void HighLevelILFunctionPluginCommandActionCallback(void* ctxt, BNBinaryView* view,
- BNHighLevelILFunction* func);
- static void HighLevelILInstructionPluginCommandActionCallback(void* ctxt, BNBinaryView* view,
- BNHighLevelILFunction* func, size_t instr);
+ static void LowLevelILFunctionPluginCommandActionCallback(
+ void* ctxt, BNBinaryView* view, BNLowLevelILFunction* func);
+ static void LowLevelILInstructionPluginCommandActionCallback(
+ void* ctxt, BNBinaryView* view, BNLowLevelILFunction* func, size_t instr);
+ static void MediumLevelILFunctionPluginCommandActionCallback(
+ void* ctxt, BNBinaryView* view, BNMediumLevelILFunction* func);
+ static void MediumLevelILInstructionPluginCommandActionCallback(
+ void* ctxt, BNBinaryView* view, BNMediumLevelILFunction* func, size_t instr);
+ static void HighLevelILFunctionPluginCommandActionCallback(
+ void* ctxt, BNBinaryView* view, BNHighLevelILFunction* func);
+ static void HighLevelILInstructionPluginCommandActionCallback(
+ void* ctxt, BNBinaryView* view, BNHighLevelILFunction* func, size_t instr);
static bool DefaultPluginCommandIsValidCallback(void* ctxt, BNBinaryView* view);
static bool AddressPluginCommandIsValidCallback(void* ctxt, BNBinaryView* view, uint64_t addr);
static bool RangePluginCommandIsValidCallback(void* ctxt, BNBinaryView* view, uint64_t addr, uint64_t len);
static bool FunctionPluginCommandIsValidCallback(void* ctxt, BNBinaryView* view, BNFunction* func);
- static bool LowLevelILFunctionPluginCommandIsValidCallback(void* ctxt, BNBinaryView* view,
- BNLowLevelILFunction* func);
- static bool LowLevelILInstructionPluginCommandIsValidCallback(void* ctxt, BNBinaryView* view,
- BNLowLevelILFunction* func, size_t instr);
- static bool MediumLevelILFunctionPluginCommandIsValidCallback(void* ctxt, BNBinaryView* view,
- BNMediumLevelILFunction* func);
- static bool MediumLevelILInstructionPluginCommandIsValidCallback(void* ctxt, BNBinaryView* view,
- BNMediumLevelILFunction* func, size_t instr);
- static bool HighLevelILFunctionPluginCommandIsValidCallback(void* ctxt, BNBinaryView* view,
- BNHighLevelILFunction* func);
- static bool HighLevelILInstructionPluginCommandIsValidCallback(void* ctxt, BNBinaryView* view,
- BNHighLevelILFunction* func, size_t instr);
+ static bool LowLevelILFunctionPluginCommandIsValidCallback(
+ void* ctxt, BNBinaryView* view, BNLowLevelILFunction* func);
+ static bool LowLevelILInstructionPluginCommandIsValidCallback(
+ void* ctxt, BNBinaryView* view, BNLowLevelILFunction* func, size_t instr);
+ static bool MediumLevelILFunctionPluginCommandIsValidCallback(
+ void* ctxt, BNBinaryView* view, BNMediumLevelILFunction* func);
+ static bool MediumLevelILInstructionPluginCommandIsValidCallback(
+ void* ctxt, BNBinaryView* view, BNMediumLevelILFunction* func, size_t instr);
+ static bool HighLevelILFunctionPluginCommandIsValidCallback(
+ void* ctxt, BNBinaryView* view, BNHighLevelILFunction* func);
+ static bool HighLevelILInstructionPluginCommandIsValidCallback(
+ void* ctxt, BNBinaryView* view, BNHighLevelILFunction* func, size_t instr);
- public:
+ public:
PluginCommand(const BNPluginCommand& cmd);
PluginCommand(const PluginCommand& cmd);
~PluginCommand();
@@ -5104,55 +5188,54 @@ __attribute__ ((format (printf, 1, 2)))
PluginCommand& operator=(const PluginCommand& cmd);
static void Register(const std::string& name, const std::string& description,
- const std::function<void(BinaryView* view)>& action);
+ const std::function<void(BinaryView* view)>& action);
static void Register(const std::string& name, const std::string& description,
- const std::function<void(BinaryView* view)>& action,
- const std::function<bool(BinaryView* view)>& isValid);
+ const std::function<void(BinaryView* view)>& action, const std::function<bool(BinaryView* view)>& isValid);
static void RegisterForAddress(const std::string& name, const std::string& description,
- const std::function<void(BinaryView* view, uint64_t addr)>& action);
+ const std::function<void(BinaryView* view, uint64_t addr)>& action);
static void RegisterForAddress(const std::string& name, const std::string& description,
- const std::function<void(BinaryView* view, uint64_t addr)>& action,
- const std::function<bool(BinaryView* view, uint64_t addr)>& isValid);
+ const std::function<void(BinaryView* view, uint64_t addr)>& action,
+ const std::function<bool(BinaryView* view, uint64_t addr)>& isValid);
static void RegisterForRange(const std::string& name, const std::string& description,
- const std::function<void(BinaryView* view, uint64_t addr, uint64_t len)>& action);
+ const std::function<void(BinaryView* view, uint64_t addr, uint64_t len)>& action);
static void RegisterForRange(const std::string& name, const std::string& description,
- const std::function<void(BinaryView* view, uint64_t addr, uint64_t len)>& action,
- const std::function<bool(BinaryView* view, uint64_t addr, uint64_t len)>& isValid);
+ const std::function<void(BinaryView* view, uint64_t addr, uint64_t len)>& action,
+ const std::function<bool(BinaryView* view, uint64_t addr, uint64_t len)>& isValid);
static void RegisterForFunction(const std::string& name, const std::string& description,
- const std::function<void(BinaryView* view, Function* func)>& action);
+ const std::function<void(BinaryView* view, Function* func)>& action);
static void RegisterForFunction(const std::string& name, const std::string& description,
- const std::function<void(BinaryView* view, Function* func)>& action,
- const std::function<bool(BinaryView* view, Function* func)>& isValid);
+ const std::function<void(BinaryView* view, Function* func)>& action,
+ const std::function<bool(BinaryView* view, Function* func)>& isValid);
static void RegisterForLowLevelILFunction(const std::string& name, const std::string& description,
- const std::function<void(BinaryView* view, LowLevelILFunction* func)>& action);
+ const std::function<void(BinaryView* view, LowLevelILFunction* func)>& action);
static void RegisterForLowLevelILFunction(const std::string& name, const std::string& description,
- const std::function<void(BinaryView* view, LowLevelILFunction* func)>& action,
- const std::function<bool(BinaryView* view, LowLevelILFunction* func)>& isValid);
+ const std::function<void(BinaryView* view, LowLevelILFunction* func)>& action,
+ const std::function<bool(BinaryView* view, LowLevelILFunction* func)>& isValid);
static void RegisterForLowLevelILInstruction(const std::string& name, const std::string& description,
- const std::function<void(BinaryView* view, const LowLevelILInstruction& instr)>& action);
+ const std::function<void(BinaryView* view, const LowLevelILInstruction& instr)>& action);
static void RegisterForLowLevelILInstruction(const std::string& name, const std::string& description,
- const std::function<void(BinaryView* view, const LowLevelILInstruction& instr)>& action,
- const std::function<bool(BinaryView* view, const LowLevelILInstruction& instr)>& isValid);
+ const std::function<void(BinaryView* view, const LowLevelILInstruction& instr)>& action,
+ const std::function<bool(BinaryView* view, const LowLevelILInstruction& instr)>& isValid);
static void RegisterForMediumLevelILFunction(const std::string& name, const std::string& description,
- const std::function<void(BinaryView* view, MediumLevelILFunction* func)>& action);
+ const std::function<void(BinaryView* view, MediumLevelILFunction* func)>& action);
static void RegisterForMediumLevelILFunction(const std::string& name, const std::string& description,
- const std::function<void(BinaryView* view, MediumLevelILFunction* func)>& action,
- const std::function<bool(BinaryView* view, MediumLevelILFunction* func)>& isValid);
+ const std::function<void(BinaryView* view, MediumLevelILFunction* func)>& action,
+ const std::function<bool(BinaryView* view, MediumLevelILFunction* func)>& isValid);
static void RegisterForMediumLevelILInstruction(const std::string& name, const std::string& description,
- const std::function<void(BinaryView* view, const MediumLevelILInstruction& instr)>& action);
+ const std::function<void(BinaryView* view, const MediumLevelILInstruction& instr)>& action);
static void RegisterForMediumLevelILInstruction(const std::string& name, const std::string& description,
- const std::function<void(BinaryView* view, const MediumLevelILInstruction& instr)>& action,
- const std::function<bool(BinaryView* view, const MediumLevelILInstruction& instr)>& isValid);
+ const std::function<void(BinaryView* view, const MediumLevelILInstruction& instr)>& action,
+ const std::function<bool(BinaryView* view, const MediumLevelILInstruction& instr)>& isValid);
static void RegisterForHighLevelILFunction(const std::string& name, const std::string& description,
- const std::function<void(BinaryView* view, HighLevelILFunction* func)>& action);
+ const std::function<void(BinaryView* view, HighLevelILFunction* func)>& action);
static void RegisterForHighLevelILFunction(const std::string& name, const std::string& description,
- const std::function<void(BinaryView* view, HighLevelILFunction* func)>& action,
- const std::function<bool(BinaryView* view, HighLevelILFunction* func)>& isValid);
+ const std::function<void(BinaryView* view, HighLevelILFunction* func)>& action,
+ const std::function<bool(BinaryView* view, HighLevelILFunction* func)>& isValid);
static void RegisterForHighLevelILInstruction(const std::string& name, const std::string& description,
- const std::function<void(BinaryView* view, const HighLevelILInstruction& instr)>& action);
+ const std::function<void(BinaryView* view, const HighLevelILInstruction& instr)>& action);
static void RegisterForHighLevelILInstruction(const std::string& name, const std::string& description,
- const std::function<void(BinaryView* view, const HighLevelILInstruction& instr)>& action,
- const std::function<bool(BinaryView* view, const HighLevelILInstruction& instr)>& isValid);
+ const std::function<void(BinaryView* view, const HighLevelILInstruction& instr)>& action,
+ const std::function<bool(BinaryView* view, const HighLevelILInstruction& instr)>& isValid);
static std::vector<PluginCommand> GetList();
static std::vector<PluginCommand> GetValidList(const PluginCommandContext& ctxt);
@@ -5166,10 +5249,10 @@ __attribute__ ((format (printf, 1, 2)))
void Execute(const PluginCommandContext& ctxt) const;
};
- class CallingConvention: public CoreRefCountObject<BNCallingConvention,
- BNNewCallingConventionReference, BNFreeCallingConvention>
+ class CallingConvention :
+ public CoreRefCountObject<BNCallingConvention, BNNewCallingConventionReference, BNFreeCallingConvention>
{
- protected:
+ protected:
CallingConvention(BNCallingConvention* cc);
CallingConvention(Architecture* arch, const std::string& name);
@@ -5193,15 +5276,16 @@ __attribute__ ((format (printf, 1, 2)))
static uint32_t GetGlobalPointerRegisterCallback(void* ctxt);
static uint32_t* GetImplicitlyDefinedRegistersCallback(void* ctxt, size_t* count);
- static void GetIncomingRegisterValueCallback(void* ctxt, uint32_t reg, BNFunction* func, BNRegisterValue* result);
+ static void GetIncomingRegisterValueCallback(
+ void* ctxt, uint32_t reg, BNFunction* func, BNRegisterValue* result);
static void GetIncomingFlagValueCallback(void* ctxt, uint32_t reg, BNFunction* func, BNRegisterValue* result);
- static void GetIncomingVariableForParameterVariableCallback(void* ctxt, const BNVariable* var,
- BNFunction* func, BNVariable* result);
- static void GetParameterVariableForIncomingVariableCallback(void* ctxt, const BNVariable* var,
- BNFunction* func, BNVariable* result);
+ static void GetIncomingVariableForParameterVariableCallback(
+ void* ctxt, const BNVariable* var, BNFunction* func, BNVariable* result);
+ static void GetParameterVariableForIncomingVariableCallback(
+ void* ctxt, const BNVariable* var, BNFunction* func, BNVariable* result);
- public:
+ public:
Ref<Architecture> GetArchitecture() const;
std::string GetName() const;
@@ -5229,9 +5313,9 @@ __attribute__ ((format (printf, 1, 2)))
virtual Variable GetParameterVariableForIncomingVariable(const Variable& var, Function* func);
};
- class CoreCallingConvention: public CallingConvention
+ class CoreCallingConvention : public CallingConvention
{
- public:
+ public:
CoreCallingConvention(BNCallingConvention* cc);
virtual std::vector<uint32_t> GetCallerSavedRegisters() override;
@@ -5259,15 +5343,16 @@ __attribute__ ((format (printf, 1, 2)))
};
/*!
- Platform base class. This should be subclassed when creating a new platform
+ Platform base class. This should be subclassed when creating a new platform
*/
- class Platform: public CoreRefCountObject<BNPlatform, BNNewPlatformReference, BNFreePlatform>
+ class Platform : public CoreRefCountObject<BNPlatform, BNNewPlatformReference, BNFreePlatform>
{
- protected:
+ protected:
Platform(Architecture* arch, const std::string& name);
- Platform(Architecture* arch, const std::string& name, const std::string& typeFile, const std::vector<std::string>& includeDirs = std::vector<std::string>());
+ Platform(Architecture* arch, const std::string& name, const std::string& typeFile,
+ const std::vector<std::string>& includeDirs = std::vector<std::string>());
- public:
+ public:
Platform(BNPlatform* platform);
Ref<Architecture> GetArchitecture() const;
@@ -5310,43 +5395,42 @@ __attribute__ ((format (printf, 1, 2)))
Ref<Type> GetSystemCallType(uint32_t n);
std::string GenerateAutoPlatformTypeId(const QualifiedName& name);
- Ref<NamedTypeReference> GenerateAutoPlatformTypeReference(BNNamedTypeReferenceClass cls,
- const QualifiedName& name);
+ Ref<NamedTypeReference> GenerateAutoPlatformTypeReference(
+ BNNamedTypeReferenceClass cls, const QualifiedName& name);
std::string GetAutoPlatformTypeIdSource();
bool ParseTypesFromSource(const std::string& source, const std::string& fileName,
- std::map<QualifiedName, Ref<Type>>& types,
- std::map<QualifiedName, Ref<Type>>& variables,
- std::map<QualifiedName, Ref<Type>>& functions, std::string& errors,
- const std::vector<std::string>& includeDirs = std::vector<std::string>(),
- const std::string& autoTypeSource = "");
- bool ParseTypesFromSourceFile(const std::string& fileName,
- std::map<QualifiedName, Ref<Type>>& types,
- std::map<QualifiedName, Ref<Type>>& variables,
- std::map<QualifiedName, Ref<Type>>& functions, std::string& errors,
- const std::vector<std::string>& includeDirs = std::vector<std::string>(),
- const std::string& autoTypeSource = "");
+ std::map<QualifiedName, Ref<Type>>& types, std::map<QualifiedName, Ref<Type>>& variables,
+ std::map<QualifiedName, Ref<Type>>& functions, std::string& errors,
+ const std::vector<std::string>& includeDirs = std::vector<std::string>(),
+ const std::string& autoTypeSource = "");
+ bool ParseTypesFromSourceFile(const std::string& fileName, std::map<QualifiedName, Ref<Type>>& types,
+ std::map<QualifiedName, Ref<Type>>& variables, std::map<QualifiedName, Ref<Type>>& functions,
+ std::string& errors, const std::vector<std::string>& includeDirs = std::vector<std::string>(),
+ const std::string& autoTypeSource = "");
};
// DownloadProvider
class DownloadProvider;
- class DownloadInstance: public CoreRefCountObject<BNDownloadInstance, BNNewDownloadInstanceReference, BNFreeDownloadInstance>
+ class DownloadInstance :
+ public CoreRefCountObject<BNDownloadInstance, BNNewDownloadInstanceReference, BNFreeDownloadInstance>
{
- public:
+ public:
struct Response
{
uint16_t statusCode;
std::unordered_map<std::string, std::string> headers;
};
- protected:
+ protected:
DownloadInstance(DownloadProvider* provider);
DownloadInstance(BNDownloadInstance* instance);
static void DestroyInstanceCallback(void* ctxt);
static int PerformRequestCallback(void* ctxt, const char* url);
- static int PerformCustomRequestCallback(void* ctxt, const char* method, const char* url, uint64_t headerCount, const char* const* headerKeys, const char* const* headerValues, BNDownloadInstanceResponse** response);
+ static int PerformCustomRequestCallback(void* ctxt, const char* method, const char* url, uint64_t headerCount,
+ const char* const* headerKeys, const char* const* headerValues, BNDownloadInstanceResponse** response);
static void PerformFreeResponse(void* ctxt, BNDownloadInstanceResponse* response);
/*!
Cleanup any resources created by the instance
@@ -5366,14 +5450,15 @@ __attribute__ ((format (printf, 1, 2)))
\param response Structure into which the response status code and headers should be stored
\return Zero or greater on success
*/
- virtual int PerformCustomRequest(const std::string& method, const std::string& url, const std::unordered_map<std::string, std::string>& headers, Response& response) = 0;
+ virtual int PerformCustomRequest(const std::string& method, const std::string& url,
+ const std::unordered_map<std::string, std::string>& headers, Response& response) = 0;
int64_t ReadDataCallback(uint8_t* data, uint64_t len);
uint64_t WriteDataCallback(uint8_t* data, uint64_t len);
bool NotifyProgressCallback(uint64_t progress, uint64_t total);
void SetError(const std::string& error);
- public:
+ public:
/*!
Send a GET request to a url, synchronously
\param url Full url to request
@@ -5390,34 +5475,37 @@ __attribute__ ((format (printf, 1, 2)))
\param callbacks Structure with callback functions for input and output data
\return Zero or greater on success
*/
- int PerformCustomRequest(const std::string& method, const std::string& url, const std::unordered_map<std::string, std::string>& headers, Response& response, BNDownloadInstanceInputOutputCallbacks* callbacks);
+ int PerformCustomRequest(const std::string& method, const std::string& url,
+ const std::unordered_map<std::string, std::string>& headers, Response& response,
+ BNDownloadInstanceInputOutputCallbacks* callbacks);
/*!
Retrieve the error from the last request sent by this instance
*/
std::string GetError() const;
};
- class CoreDownloadInstance: public DownloadInstance
+ class CoreDownloadInstance : public DownloadInstance
{
- public:
+ public:
CoreDownloadInstance(BNDownloadInstance* instance);
virtual ~CoreDownloadInstance() {};
virtual int PerformRequest(const std::string& url) override;
- virtual int PerformCustomRequest(const std::string& method, const std::string& url, const std::unordered_map<std::string, std::string>& headers, DownloadInstance::Response& response) override;
+ virtual int PerformCustomRequest(const std::string& method, const std::string& url,
+ const std::unordered_map<std::string, std::string>& headers, DownloadInstance::Response& response) override;
};
- class DownloadProvider: public StaticCoreRefCountObject<BNDownloadProvider>
+ class DownloadProvider : public StaticCoreRefCountObject<BNDownloadProvider>
{
std::string m_nameForRegister;
- protected:
+ protected:
DownloadProvider(const std::string& name);
DownloadProvider(BNDownloadProvider* provider);
static BNDownloadInstance* CreateInstanceCallback(void* ctxt);
- public:
+ public:
virtual Ref<DownloadInstance> CreateNewInstance() = 0;
static std::vector<Ref<DownloadProvider>> GetList();
@@ -5425,9 +5513,9 @@ __attribute__ ((format (printf, 1, 2)))
static void Register(DownloadProvider* provider);
};
- class CoreDownloadProvider: public DownloadProvider
+ class CoreDownloadProvider : public DownloadProvider
{
- public:
+ public:
CoreDownloadProvider(BNDownloadProvider* provider);
virtual Ref<DownloadInstance> CreateNewInstance() override;
};
@@ -5435,14 +5523,16 @@ __attribute__ ((format (printf, 1, 2)))
// WebsocketProvider
class WebsocketProvider;
- class WebsocketClient: public CoreRefCountObject<BNWebsocketClient, BNNewWebsocketClientReference, BNFreeWebsocketClient>
+ class WebsocketClient :
+ public CoreRefCountObject<BNWebsocketClient, BNNewWebsocketClientReference, BNFreeWebsocketClient>
{
- protected:
+ protected:
WebsocketClient(WebsocketProvider* provider);
WebsocketClient(BNWebsocketClient* instance);
static void DestroyClientCallback(void* ctxt);
- static bool ConnectCallback(void* ctxt, const char* host, uint64_t headerCount, const char* const* headerKeys, const char* const* headerValues);
+ static bool ConnectCallback(void* ctxt, const char* host, uint64_t headerCount, const char* const* headerKeys,
+ const char* const* headerValues);
static bool WriteCallback(const uint8_t* data, uint64_t len, void* ctxt);
static bool DisconnectCallback(void* ctxt);
static void ErrorCallback(const char* msg, void* ctxt);
@@ -5459,16 +5549,19 @@ __attribute__ ((format (printf, 1, 2)))
\return True if the connection has started, but not necessarily if it succeeded
*/
virtual bool Connect(const std::string& host, const std::unordered_map<std::string, std::string>& headers) = 0;
- public:
+
+ public:
/*!
- Connect to a given url, asynchronously. The connection will be run in a separate thread managed by the websocket provider.
+ Connect to a given url, asynchronously. The connection will be run in a separate thread managed by the
+ websocket provider.
- Callbacks will be called **on the thread of the connection**, so be sure to ExecuteOnMainThread any long-running
- or gui operations in the callbacks.
+ Callbacks will be called **on the thread of the connection**, so be sure to ExecuteOnMainThread any
+ long-running or gui operations in the callbacks.
- If the connection succeeds, connectedCallback will be called. On normal termination, disconnectedCallback will be called.
- If the connection succeeds, but later fails, disconnectedCallback will not be called, and errorCallback will be called instead.
- If the connection fails, neither connectedCallback nor disconnectedCallback will be called, and errorCallback will be called instead.
+ If the connection succeeds, connectedCallback will be called. On normal termination, disconnectedCallback
+ will be called. If the connection succeeds, but later fails, disconnectedCallback will not be called, and
+ errorCallback will be called instead. If the connection fails, neither connectedCallback nor
+ disconnectedCallback will be called, and errorCallback will be called instead.
If connectedCallback or readCallback return false, the connection will be aborted.
@@ -5477,7 +5570,8 @@ __attribute__ ((format (printf, 1, 2)))
\param callbacks Structure with callbacks for various websocket events
\return True if the connection has started, but not necessarily if it succeeded
*/
- bool Connect(const std::string& host, const std::unordered_map<std::string, std::string>& headers, BNWebsocketClientOutputCallbacks* callbacks);
+ bool Connect(const std::string& host, const std::unordered_map<std::string, std::string>& headers,
+ BNWebsocketClientOutputCallbacks* callbacks);
/*!
Write some data to the websocket
@@ -5492,28 +5586,29 @@ __attribute__ ((format (printf, 1, 2)))
virtual bool Disconnect() = 0;
};
- class CoreWebsocketClient: public WebsocketClient
+ class CoreWebsocketClient : public WebsocketClient
{
- public:
+ public:
CoreWebsocketClient(BNWebsocketClient* instance);
virtual ~CoreWebsocketClient() {};
- virtual bool Connect(const std::string& host, const std::unordered_map<std::string, std::string>& headers) override;
+ virtual bool Connect(
+ const std::string& host, const std::unordered_map<std::string, std::string>& headers) override;
virtual bool Write(const std::vector<uint8_t>& data) override;
virtual bool Disconnect() override;
};
- class WebsocketProvider: public StaticCoreRefCountObject<BNWebsocketProvider>
+ class WebsocketProvider : public StaticCoreRefCountObject<BNWebsocketProvider>
{
std::string m_nameForRegister;
- protected:
+ protected:
WebsocketProvider(const std::string& name);
WebsocketProvider(BNWebsocketProvider* provider);
static BNWebsocketClient* CreateClientCallback(void* ctxt);
- public:
+ public:
virtual Ref<WebsocketClient> CreateNewClient() = 0;
static std::vector<Ref<WebsocketProvider>> GetList();
@@ -5521,9 +5616,9 @@ __attribute__ ((format (printf, 1, 2)))
static void Register(WebsocketProvider* provider);
};
- class CoreWebsocketProvider: public WebsocketProvider
+ class CoreWebsocketProvider : public WebsocketProvider
{
- public:
+ public:
CoreWebsocketProvider(BNWebsocketProvider* provider);
virtual Ref<WebsocketClient> CreateNewClient() override;
};
@@ -5537,7 +5632,7 @@ __attribute__ ((format (printf, 1, 2)))
static void ErrorCallback(void* ctxt, const char* text);
static void InputReadyStateChangedCallback(void* ctxt, BNScriptingProviderInputReadyState state);
- public:
+ public:
ScriptingOutputListener();
BNScriptingOutputListener& GetCallbacks() { return m_callbacks; }
@@ -5548,10 +5643,10 @@ __attribute__ ((format (printf, 1, 2)))
class ScriptingProvider;
- class ScriptingInstance: public CoreRefCountObject<BNScriptingInstance,
- BNNewScriptingInstanceReference, BNFreeScriptingInstance>
+ class ScriptingInstance :
+ public CoreRefCountObject<BNScriptingInstance, BNNewScriptingInstanceReference, BNFreeScriptingInstance>
{
- protected:
+ protected:
ScriptingInstance(ScriptingProvider* provider);
ScriptingInstance(BNScriptingInstance* instance);
@@ -5568,7 +5663,7 @@ __attribute__ ((format (printf, 1, 2)))
virtual void DestroyInstance();
- public:
+ public:
virtual BNScriptingProviderExecuteResult ExecuteScriptInput(const std::string& input) = 0;
virtual void CancelScriptInput();
virtual void SetCurrentBinaryView(BinaryView* view);
@@ -5591,9 +5686,9 @@ __attribute__ ((format (printf, 1, 2)))
void SetDelimiters(const std::string& delimiters);
};
- class CoreScriptingInstance: public ScriptingInstance
+ class CoreScriptingInstance : public ScriptingInstance
{
- public:
+ public:
CoreScriptingInstance(BNScriptingInstance* instance);
virtual ~CoreScriptingInstance() {};
@@ -5608,12 +5703,12 @@ __attribute__ ((format (printf, 1, 2)))
virtual void Stop() override;
};
- class ScriptingProvider: public StaticCoreRefCountObject<BNScriptingProvider>
+ class ScriptingProvider : public StaticCoreRefCountObject<BNScriptingProvider>
{
std::string m_nameForRegister;
std::string m_apiNameForRegister;
- protected:
+ protected:
ScriptingProvider(const std::string& name, const std::string& apiName);
ScriptingProvider(BNScriptingProvider* provider);
@@ -5621,7 +5716,7 @@ __attribute__ ((format (printf, 1, 2)))
static bool LoadModuleCallback(void* ctxt, const char* repository, const char* module, bool force);
static bool InstallModulesCallback(void* ctxt, const char* modules);
- public:
+ public:
virtual Ref<ScriptingInstance> CreateNewInstance() = 0;
virtual bool LoadModule(const std::string& repository, const std::string& module, bool force) = 0;
virtual bool InstallModules(const std::string& modules) = 0;
@@ -5635,19 +5730,19 @@ __attribute__ ((format (printf, 1, 2)))
static void Register(ScriptingProvider* provider);
};
- class CoreScriptingProvider: public ScriptingProvider
+ class CoreScriptingProvider : public ScriptingProvider
{
- public:
+ public:
CoreScriptingProvider(BNScriptingProvider* provider);
virtual Ref<ScriptingInstance> CreateNewInstance() override;
virtual bool LoadModule(const std::string& repository, const std::string& module, bool force) override;
virtual bool InstallModules(const std::string& modules) override;
};
- class MainThreadAction: public CoreRefCountObject<BNMainThreadAction,
- BNNewMainThreadActionReference, BNFreeMainThreadAction>
+ class MainThreadAction :
+ public CoreRefCountObject<BNMainThreadAction, BNNewMainThreadActionReference, BNFreeMainThreadAction>
{
- public:
+ public:
MainThreadAction(BNMainThreadAction* action);
void Execute();
bool IsDone() const;
@@ -5656,14 +5751,14 @@ __attribute__ ((format (printf, 1, 2)))
class MainThreadActionHandler
{
- public:
+ public:
virtual void AddMainThreadAction(MainThreadAction* action) = 0;
};
- class BackgroundTask: public CoreRefCountObject<BNBackgroundTask,
- BNNewBackgroundTaskReference, BNFreeBackgroundTask>
+ class BackgroundTask :
+ public CoreRefCountObject<BNBackgroundTask, BNNewBackgroundTaskReference, BNFreeBackgroundTask>
{
- public:
+ public:
BackgroundTask(BNBackgroundTask* task);
BackgroundTask(const std::string& initialText, bool canCancel);
@@ -5683,11 +5778,11 @@ __attribute__ ((format (printf, 1, 2)))
{
BNFormInputFieldType type;
std::string prompt;
- Ref<BinaryView> view; // For AddressFormField
- uint64_t currentAddress; // For AddressFormField
- std::vector<std::string> choices; // For ChoiceFormField
- std::string ext; // For OpenFileNameFormField, SaveFileNameFormField
- std::string defaultName; // For SaveFileNameFormField
+ Ref<BinaryView> view; // For AddressFormField
+ uint64_t currentAddress; // For AddressFormField
+ std::vector<std::string> choices; // For ChoiceFormField
+ std::string ext; // For OpenFileNameFormField, SaveFileNameFormField
+ std::string defaultName; // For SaveFileNameFormField
int64_t intResult;
uint64_t addressResult;
std::string stringResult;
@@ -5703,18 +5798,19 @@ __attribute__ ((format (printf, 1, 2)))
static FormInputField TextLine(const std::string& prompt);
static FormInputField MultilineText(const std::string& prompt);
static FormInputField Integer(const std::string& prompt);
- static FormInputField Address(const std::string& prompt, BinaryView* view = nullptr, uint64_t currentAddress = 0);
+ static FormInputField Address(
+ const std::string& prompt, BinaryView* view = nullptr, uint64_t currentAddress = 0);
static FormInputField Choice(const std::string& prompt, const std::vector<std::string>& choices);
static FormInputField OpenFileName(const std::string& prompt, const std::string& ext);
- static FormInputField SaveFileName(const std::string& prompt, const std::string& ext,
- const std::string& defaultName = "");
+ static FormInputField SaveFileName(
+ const std::string& prompt, const std::string& ext, const std::string& defaultName = "");
static FormInputField DirectoryName(const std::string& prompt, const std::string& defaultName = "");
};
- class ReportCollection: public CoreRefCountObject<BNReportCollection,
- BNNewReportCollectionReference, BNFreeReportCollection>
+ class ReportCollection :
+ public CoreRefCountObject<BNReportCollection, BNNewReportCollectionReference, BNFreeReportCollection>
{
- public:
+ public:
ReportCollection();
ReportCollection(BNReportCollection* reports);
@@ -5728,9 +5824,9 @@ __attribute__ ((format (printf, 1, 2)))
void AddPlainTextReport(Ref<BinaryView> view, const std::string& title, const std::string& contents);
void AddMarkdownReport(Ref<BinaryView> view, const std::string& title, const std::string& contents,
- const std::string& plainText = "");
+ const std::string& plainText = "");
void AddHTMLReport(Ref<BinaryView> view, const std::string& title, const std::string& contents,
- const std::string& plainText = "");
+ const std::string& plainText = "");
void AddGraphReport(Ref<BinaryView> view, const std::string& title, Ref<FlowGraph> graph);
void UpdateFlowGraph(size_t i, Ref<FlowGraph> graph);
@@ -5738,30 +5834,31 @@ __attribute__ ((format (printf, 1, 2)))
class InteractionHandler
{
- public:
- virtual void ShowPlainTextReport(Ref<BinaryView> view, const std::string& title, const std::string& contents) = 0;
- virtual void ShowMarkdownReport(Ref<BinaryView> view, const std::string& title, const std::string& contents,
- const std::string& plainText);
- virtual void ShowHTMLReport(Ref<BinaryView> view, const std::string& title, const std::string& contents,
- const std::string& plainText);
+ public:
+ virtual void ShowPlainTextReport(
+ Ref<BinaryView> view, const std::string& title, const std::string& contents) = 0;
+ virtual void ShowMarkdownReport(
+ Ref<BinaryView> view, const std::string& title, const std::string& contents, const std::string& plainText);
+ virtual void ShowHTMLReport(
+ Ref<BinaryView> view, const std::string& title, const std::string& contents, const std::string& plainText);
virtual void ShowGraphReport(Ref<BinaryView> view, const std::string& title, Ref<FlowGraph> graph);
virtual void ShowReportCollection(const std::string& title, Ref<ReportCollection> reports);
virtual bool GetTextLineInput(std::string& result, const std::string& prompt, const std::string& title) = 0;
virtual bool GetIntegerInput(int64_t& result, const std::string& prompt, const std::string& title);
virtual bool GetAddressInput(uint64_t& result, const std::string& prompt, const std::string& title,
- Ref<BinaryView> view, uint64_t currentAddr);
+ Ref<BinaryView> view, uint64_t currentAddr);
virtual bool GetChoiceInput(size_t& idx, const std::string& prompt, const std::string& title,
- const std::vector<std::string>& choices) = 0;
+ const std::vector<std::string>& choices) = 0;
virtual bool GetOpenFileNameInput(std::string& result, const std::string& prompt, const std::string& ext = "");
- virtual bool GetSaveFileNameInput(std::string& result, const std::string& prompt,
- const std::string& ext = "", const std::string& defaultName = "");
- virtual bool GetDirectoryNameInput(std::string& result, const std::string& prompt,
- const std::string& defaultName = "");
+ virtual bool GetSaveFileNameInput(std::string& result, const std::string& prompt, const std::string& ext = "",
+ const std::string& defaultName = "");
+ virtual bool GetDirectoryNameInput(
+ std::string& result, const std::string& prompt, const std::string& defaultName = "");
virtual bool GetFormInput(std::vector<FormInputField>& fields, const std::string& title) = 0;
virtual BNMessageBoxButtonResult ShowMessageBox(const std::string& title, const std::string& text,
- BNMessageBoxButtonSet buttons = OKButtonSet, BNMessageBoxIcon icon = InformationIcon) = 0;
+ BNMessageBoxButtonSet buttons = OKButtonSet, BNMessageBoxIcon icon = InformationIcon) = 0;
virtual bool OpenUrl(const std::string& url) = 0;
};
@@ -5769,9 +5866,9 @@ __attribute__ ((format (printf, 1, 2)))
typedef BNPluginStatus PluginStatus;
typedef BNPluginType PluginType;
- class RepoPlugin: public CoreRefCountObject<BNRepoPlugin, BNNewPluginReference, BNFreePlugin>
+ class RepoPlugin : public CoreRefCountObject<BNRepoPlugin, BNNewPluginReference, BNFreePlugin>
{
- public:
+ public:
RepoPlugin(BNRepoPlugin* plugin);
PluginStatus GetPluginStatus() const;
std::vector<std::string> GetApis() const;
@@ -5817,9 +5914,9 @@ __attribute__ ((format (printf, 1, 2)))
bool Update();
};
- class Repository: public CoreRefCountObject<BNRepository, BNNewRepositoryReference, BNFreeRepository>
+ class Repository : public CoreRefCountObject<BNRepository, BNNewRepositoryReference, BNFreeRepository>
{
- public:
+ public:
Repository(BNRepository* repository);
std::string GetUrl() const;
std::string GetRepoPath() const;
@@ -5831,28 +5928,29 @@ __attribute__ ((format (printf, 1, 2)))
std::string GetFullPath() const;
};
- class RepositoryManager: public CoreRefCountObject<BNRepositoryManager, BNNewRepositoryManagerReference, BNFreeRepositoryManager>
+ class RepositoryManager :
+ public CoreRefCountObject<BNRepositoryManager, BNNewRepositoryManagerReference, BNFreeRepositoryManager>
{
- public:
+ public:
RepositoryManager(const std::string& enabledPluginsPath);
RepositoryManager(BNRepositoryManager* repoManager);
RepositoryManager();
bool CheckForUpdates();
std::vector<Ref<Repository>> GetRepositories();
Ref<Repository> GetRepositoryByPath(const std::string& repoName);
- bool AddRepository(const std::string& url, // URL to raw plugins.json file
- const std::string& repoPath); // Relative path within the repositories directory
+ bool AddRepository(const std::string& url, // URL to raw plugins.json file
+ const std::string& repoPath); // Relative path within the repositories directory
Ref<Repository> GetDefaultRepository();
};
- class Settings: public CoreRefCountObject<BNSettings, BNNewSettingsReference, BNFreeSettings>
+ class Settings : public CoreRefCountObject<BNSettings, BNNewSettingsReference, BNFreeSettings>
{
std::string m_instanceId;
Settings() = delete;
Settings(const std::string& m_instanceId);
- public:
+ public:
Settings(BNSettings* settings);
static Ref<Settings> Instance(const std::string& schemaId = "");
virtual ~Settings() {}
@@ -5865,7 +5963,8 @@ __attribute__ ((format (printf, 1, 2)))
bool IsEmpty();
std::vector<std::string> Keys();
- template<typename T> T QueryProperty(const std::string& key, const std::string& property);
+ template <typename T>
+ T QueryProperty(const std::string& key, const std::string& property);
bool UpdateProperty(const std::string& key, const std::string& property);
bool UpdateProperty(const std::string& key, const std::string& property, bool value);
@@ -5879,40 +5978,61 @@ __attribute__ ((format (printf, 1, 2)))
bool DeserializeSchema(const std::string& schema, BNSettingsScope scope = SettingsAutoScope, bool merge = true);
std::string SerializeSchema();
- bool DeserializeSettings(const std::string& contents, Ref<BinaryView> view = nullptr, BNSettingsScope scope = SettingsAutoScope);
+ bool DeserializeSettings(
+ const std::string& contents, Ref<BinaryView> view = nullptr, BNSettingsScope scope = SettingsAutoScope);
std::string SerializeSettings(Ref<BinaryView> view = nullptr, BNSettingsScope scope = SettingsAutoScope);
bool Reset(const std::string& key, Ref<BinaryView> view = nullptr, BNSettingsScope scope = SettingsAutoScope);
- bool ResetAll(Ref<BinaryView> view = nullptr, BNSettingsScope scope = SettingsAutoScope, bool schemaOnly = true);
+ bool ResetAll(
+ Ref<BinaryView> view = nullptr, BNSettingsScope scope = SettingsAutoScope, bool schemaOnly = true);
- template<typename T> T Get(const std::string& key, Ref<BinaryView> view = nullptr, BNSettingsScope* scope = nullptr);
+ template <typename T>
+ T Get(const std::string& key, Ref<BinaryView> view = nullptr, BNSettingsScope* scope = nullptr);
std::string GetJson(const std::string& key, Ref<BinaryView> view = nullptr, BNSettingsScope* scope = nullptr);
- bool Set(const std::string& key, bool value, Ref<BinaryView> view = nullptr, BNSettingsScope scope = SettingsAutoScope);
- bool Set(const std::string& key, double value, Ref<BinaryView> view = nullptr, BNSettingsScope scope = SettingsAutoScope);
- bool Set(const std::string& key, int value, Ref<BinaryView> view = nullptr, BNSettingsScope scope = SettingsAutoScope);
- bool Set(const std::string& key, int64_t value, Ref<BinaryView> view = nullptr, BNSettingsScope scope = SettingsAutoScope);
- bool Set(const std::string& key, uint64_t value, Ref<BinaryView> view = nullptr, BNSettingsScope scope = SettingsAutoScope);
- bool Set(const std::string& key, const char* value, Ref<BinaryView> view = nullptr, BNSettingsScope scope = SettingsAutoScope);
- bool Set(const std::string& key, const std::string& value, Ref<BinaryView> view = nullptr, BNSettingsScope scope = SettingsAutoScope);
- bool Set(const std::string& key, const std::vector<std::string>& value, Ref<BinaryView> view = nullptr, BNSettingsScope scope = SettingsAutoScope);
- bool SetJson(const std::string& key, const std::string& value, Ref<BinaryView> view = nullptr, BNSettingsScope scope = SettingsAutoScope);
+ bool Set(const std::string& key, bool value, Ref<BinaryView> view = nullptr,
+ BNSettingsScope scope = SettingsAutoScope);
+ bool Set(const std::string& key, double value, Ref<BinaryView> view = nullptr,
+ BNSettingsScope scope = SettingsAutoScope);
+ bool Set(const std::string& key, int value, Ref<BinaryView> view = nullptr,
+ BNSettingsScope scope = SettingsAutoScope);
+ bool Set(const std::string& key, int64_t value, Ref<BinaryView> view = nullptr,
+ BNSettingsScope scope = SettingsAutoScope);
+ bool Set(const std::string& key, uint64_t value, Ref<BinaryView> view = nullptr,
+ BNSettingsScope scope = SettingsAutoScope);
+ bool Set(const std::string& key, const char* value, Ref<BinaryView> view = nullptr,
+ BNSettingsScope scope = SettingsAutoScope);
+ bool Set(const std::string& key, const std::string& value, Ref<BinaryView> view = nullptr,
+ BNSettingsScope scope = SettingsAutoScope);
+ bool Set(const std::string& key, const std::vector<std::string>& value, Ref<BinaryView> view = nullptr,
+ BNSettingsScope scope = SettingsAutoScope);
+ bool SetJson(const std::string& key, const std::string& value, Ref<BinaryView> view = nullptr,
+ BNSettingsScope scope = SettingsAutoScope);
};
// explicit specializations
- template<> std::vector<std::string> Settings::QueryProperty<std::vector<std::string>>(const std::string& key, const std::string& property);
- template<> bool Settings::Get<bool>(const std::string& key, Ref<BinaryView> view, BNSettingsScope* scope);
- template<> double Settings::Get<double>(const std::string& key, Ref<BinaryView> view, BNSettingsScope* scope);
- template<> int64_t Settings::Get<int64_t>(const std::string& key, Ref<BinaryView> view, BNSettingsScope* scope);
- template<> uint64_t Settings::Get<uint64_t>(const std::string& key, Ref<BinaryView> view, BNSettingsScope* scope);
- template<> std::string Settings::Get<std::string>(const std::string& key, Ref<BinaryView> view, BNSettingsScope* scope);
- template<> std::vector<std::string> Settings::Get<std::vector<std::string>>(const std::string& key, Ref<BinaryView> view, BNSettingsScope* scope);
+ template <>
+ std::vector<std::string> Settings::QueryProperty<std::vector<std::string>>(
+ const std::string& key, const std::string& property);
+ template <>
+ bool Settings::Get<bool>(const std::string& key, Ref<BinaryView> view, BNSettingsScope* scope);
+ template <>
+ double Settings::Get<double>(const std::string& key, Ref<BinaryView> view, BNSettingsScope* scope);
+ template <>
+ int64_t Settings::Get<int64_t>(const std::string& key, Ref<BinaryView> view, BNSettingsScope* scope);
+ template <>
+ uint64_t Settings::Get<uint64_t>(const std::string& key, Ref<BinaryView> view, BNSettingsScope* scope);
+ template <>
+ std::string Settings::Get<std::string>(const std::string& key, Ref<BinaryView> view, BNSettingsScope* scope);
+ template <>
+ std::vector<std::string> Settings::Get<std::vector<std::string>>(
+ const std::string& key, Ref<BinaryView> view, BNSettingsScope* scope);
typedef BNMetadataType MetadataType;
- class Metadata: public CoreRefCountObject<BNMetadata, BNNewMetadataReference, BNFreeMetadata>
+ class Metadata : public CoreRefCountObject<BNMetadata, BNNewMetadataReference, BNFreeMetadata>
{
- public:
+ public:
explicit Metadata(BNMetadata* structuredData);
explicit Metadata(bool data);
explicit Metadata(const std::string& data);
@@ -5949,12 +6069,12 @@ __attribute__ ((format (printf, 1, 2)))
std::vector<Ref<Metadata>> GetArray();
std::map<std::string, Ref<Metadata>> GetKeyValueStore();
- //For key-value data only
+ // For key-value data only
Ref<Metadata> Get(const std::string& key);
bool SetValueForKey(const std::string& key, Ref<Metadata> data);
void RemoveKey(const std::string& key);
- //For array data only
+ // For array data only
Ref<Metadata> Get(size_t index);
bool Append(Ref<Metadata> data);
void RemoveIndex(size_t index);
@@ -5975,38 +6095,45 @@ __attribute__ ((format (printf, 1, 2)))
bool IsKeyValueStore() const;
};
- class DataRenderer: public CoreRefCountObject<BNDataRenderer, BNNewDataRendererReference, BNFreeDataRenderer>
+ class DataRenderer : public CoreRefCountObject<BNDataRenderer, BNNewDataRendererReference, BNFreeDataRenderer>
{
- static bool IsValidForDataCallback(void* ctxt, BNBinaryView* data, uint64_t addr, BNType* type,
- BNTypeContext* typeCtx, size_t ctxCount);
- static BNDisassemblyTextLine* GetLinesForDataCallback(void* ctxt, BNBinaryView* data, uint64_t addr, BNType* type,
- const BNInstructionTextToken* prefix, size_t prefixCount, size_t width, size_t* count, BNTypeContext* typeCxt,
- size_t ctxCount);
+ static bool IsValidForDataCallback(
+ void* ctxt, BNBinaryView* data, uint64_t addr, BNType* type, BNTypeContext* typeCtx, size_t ctxCount);
+ static BNDisassemblyTextLine* GetLinesForDataCallback(void* ctxt, BNBinaryView* data, uint64_t addr,
+ BNType* type, const BNInstructionTextToken* prefix, size_t prefixCount, size_t width, size_t* count,
+ BNTypeContext* typeCxt, size_t ctxCount);
static void FreeCallback(void* ctxt);
- public:
+
+ public:
DataRenderer();
DataRenderer(BNDataRenderer* renderer);
- virtual bool IsValidForData(BinaryView* data, uint64_t addr, Type* type, std::vector<std::pair<Type*, size_t>>& context);
+ virtual bool IsValidForData(
+ BinaryView* data, uint64_t addr, Type* type, std::vector<std::pair<Type*, size_t>>& context);
virtual std::vector<DisassemblyTextLine> GetLinesForData(BinaryView* data, uint64_t addr, Type* type,
- const std::vector<InstructionTextToken>& prefix, size_t width, std::vector<std::pair<Type*, size_t>>& context);
+ const std::vector<InstructionTextToken>& prefix, size_t width,
+ std::vector<std::pair<Type*, size_t>>& context);
std::vector<DisassemblyTextLine> RenderLinesForData(BinaryView* data, uint64_t addr, Type* type,
- const std::vector<InstructionTextToken>& prefix, size_t width, std::vector<std::pair<Type*, size_t>>& context);
+ const std::vector<InstructionTextToken>& prefix, size_t width,
+ std::vector<std::pair<Type*, size_t>>& context);
- static bool IsStructOfTypeName(Type* type, const QualifiedName& name, std::vector<std::pair<Type*, size_t>>& context);
- static bool IsStructOfTypeName(Type* type, const std::string& name, std::vector<std::pair<Type*, size_t>>& context);
+ static bool IsStructOfTypeName(
+ Type* type, const QualifiedName& name, std::vector<std::pair<Type*, size_t>>& context);
+ static bool IsStructOfTypeName(
+ Type* type, const std::string& name, std::vector<std::pair<Type*, size_t>>& context);
};
class DataRendererContainer
{
- public:
+ public:
static void RegisterGenericDataRenderer(DataRenderer* renderer);
static void RegisterTypeSpecificDataRenderer(DataRenderer* renderer);
};
- class DisassemblyTextRenderer: public CoreRefCountObject<BNDisassemblyTextRenderer,
- BNNewDisassemblyTextRendererReference, BNFreeDisassemblyTextRenderer>
+ class DisassemblyTextRenderer :
+ public CoreRefCountObject<BNDisassemblyTextRenderer, BNNewDisassemblyTextRendererReference,
+ BNFreeDisassemblyTextRenderer>
{
- public:
+ public:
DisassemblyTextRenderer(Function* func, DisassemblySettings* settings = nullptr);
DisassemblyTextRenderer(LowLevelILFunction* func, DisassemblySettings* settings = nullptr);
DisassemblyTextRenderer(MediumLevelILFunction* func, DisassemblySettings* settings = nullptr);
@@ -6030,28 +6157,24 @@ __attribute__ ((format (printf, 1, 2)))
virtual void GetInstructionAnnotations(std::vector<InstructionTextToken>& tokens, uint64_t addr);
virtual bool GetInstructionText(uint64_t addr, size_t& len, std::vector<DisassemblyTextLine>& lines);
- std::vector<DisassemblyTextLine> PostProcessInstructionTextLines(uint64_t addr,
- size_t len, const std::vector<DisassemblyTextLine>& lines, const std::string& indentSpaces = "");
+ std::vector<DisassemblyTextLine> PostProcessInstructionTextLines(uint64_t addr, size_t len,
+ const std::vector<DisassemblyTextLine>& lines, const std::string& indentSpaces = "");
virtual bool GetDisassemblyText(uint64_t addr, size_t& len, std::vector<DisassemblyTextLine>& lines);
void ResetDeduplicatedComments();
bool AddSymbolToken(std::vector<InstructionTextToken>& tokens, uint64_t addr, size_t size, size_t operand);
- void AddStackVariableReferenceTokens(std::vector<InstructionTextToken>& tokens,
- const StackVariableReference& ref);
+ void AddStackVariableReferenceTokens(
+ std::vector<InstructionTextToken>& tokens, const StackVariableReference& ref);
static bool IsIntegerToken(BNInstructionTextTokenType type);
void AddIntegerToken(std::vector<InstructionTextToken>& tokens, const InstructionTextToken& token,
- Architecture* arch, uint64_t addr);
+ Architecture* arch, uint64_t addr);
- void WrapComment(DisassemblyTextLine& line,
- std::vector<DisassemblyTextLine>& lines,
- const std::string& comment,
- bool hasAutoAnnotations,
- const std::string& leadingSpaces=" ",
- const std::string& indentSpaces="");
+ void WrapComment(DisassemblyTextLine& line, std::vector<DisassemblyTextLine>& lines, const std::string& comment,
+ bool hasAutoAnnotations, const std::string& leadingSpaces = " ", const std::string& indentSpaces = "");
static std::string GetDisplayStringForInteger(Ref<BinaryView> binaryView, BNIntegerDisplayType type,
- uint64_t value, size_t inputWidth, bool isSigned = true);
+ uint64_t value, size_t inputWidth, bool isSigned = true);
};
struct LinearViewObjectIdentifier
@@ -6067,10 +6190,10 @@ __attribute__ ((format (printf, 1, 2)))
LinearViewObjectIdentifier(const LinearViewObjectIdentifier& other);
};
- class LinearViewObject: public CoreRefCountObject<BNLinearViewObject,
- BNNewLinearViewObjectReference, BNFreeLinearViewObject>
+ class LinearViewObject :
+ public CoreRefCountObject<BNLinearViewObject, BNNewLinearViewObjectReference, BNFreeLinearViewObject>
{
- public:
+ public:
LinearViewObject(BNLinearViewObject* obj);
Ref<LinearViewObject> GetFirstChild();
@@ -6109,20 +6232,26 @@ __attribute__ ((format (printf, 1, 2)))
static Ref<LinearViewObject> CreateSingleFunctionDisassembly(Function* func, DisassemblySettings* settings);
static Ref<LinearViewObject> CreateSingleFunctionLiftedIL(Function* func, DisassemblySettings* settings);
static Ref<LinearViewObject> CreateSingleFunctionLowLevelIL(Function* func, DisassemblySettings* settings);
- static Ref<LinearViewObject> CreateSingleFunctionLowLevelILSSAForm(Function* func, DisassemblySettings* settings);
+ static Ref<LinearViewObject> CreateSingleFunctionLowLevelILSSAForm(
+ Function* func, DisassemblySettings* settings);
static Ref<LinearViewObject> CreateSingleFunctionMediumLevelIL(Function* func, DisassemblySettings* settings);
- static Ref<LinearViewObject> CreateSingleFunctionMediumLevelILSSAForm(Function* func, DisassemblySettings* settings);
- static Ref<LinearViewObject> CreateSingleFunctionMappedMediumLevelIL(Function* func, DisassemblySettings* settings);
- static Ref<LinearViewObject> CreateSingleFunctionMappedMediumLevelILSSAForm(Function* func, DisassemblySettings* settings);
+ static Ref<LinearViewObject> CreateSingleFunctionMediumLevelILSSAForm(
+ Function* func, DisassemblySettings* settings);
+ static Ref<LinearViewObject> CreateSingleFunctionMappedMediumLevelIL(
+ Function* func, DisassemblySettings* settings);
+ static Ref<LinearViewObject> CreateSingleFunctionMappedMediumLevelILSSAForm(
+ Function* func, DisassemblySettings* settings);
static Ref<LinearViewObject> CreateSingleFunctionHighLevelIL(Function* func, DisassemblySettings* settings);
- static Ref<LinearViewObject> CreateSingleFunctionHighLevelILSSAForm(Function* func, DisassemblySettings* settings);
- static Ref<LinearViewObject> CreateSingleFunctionLanguageRepresentation(Function* func, DisassemblySettings* settings);
+ static Ref<LinearViewObject> CreateSingleFunctionHighLevelILSSAForm(
+ Function* func, DisassemblySettings* settings);
+ static Ref<LinearViewObject> CreateSingleFunctionLanguageRepresentation(
+ Function* func, DisassemblySettings* settings);
};
- class LinearViewCursor: public CoreRefCountObject<BNLinearViewCursor,
- BNNewLinearViewCursorReference, BNFreeLinearViewCursor>
+ class LinearViewCursor :
+ public CoreRefCountObject<BNLinearViewCursor, BNNewLinearViewCursorReference, BNFreeLinearViewCursor>
{
- public:
+ public:
LinearViewCursor(LinearViewObject* root);
LinearViewCursor(BNLinearViewCursor* cursor);
@@ -6156,10 +6285,10 @@ __attribute__ ((format (printf, 1, 2)))
class SimplifyName
{
- public:
+ public:
// Use these functions to interface with the simplifier
- static std::string to_string(const std::string& input);
- static std::string to_string(const QualifiedName& input);
+ static std::string to_string(const std::string& input);
+ static std::string to_string(const QualifiedName& input);
static QualifiedName to_qualified_name(const std::string& input, bool simplify);
static QualifiedName to_qualified_name(const QualifiedName& input);
@@ -6176,8 +6305,8 @@ __attribute__ ((format (printf, 1, 2)))
operator std::string() const;
operator QualifiedName();
- private:
- const char* m_rust_string;
+ private:
+ const char* m_rust_string;
const char** m_rust_array;
uint64_t m_length;
};
@@ -6210,30 +6339,18 @@ __attribute__ ((format (printf, 1, 2)))
Ref<CallingConvention> callingConvention;
Ref<Platform> platform;
- DebugFunctionInfo(std::string shortName,
- std::string fullName,
- std::string rawName,
- uint64_t address,
- Ref<Type> returnType,
- std::vector<std::tuple<std::string, Ref<Type>>> parameters,
- bool variableParameters,
- Ref<CallingConvention> callingConvention,
- Ref<Platform> platform) :
- shortName(shortName),
- fullName(fullName),
- rawName(rawName),
- address(address),
- returnType(returnType),
- parameters(parameters),
- variableParameters(variableParameters),
- callingConvention(callingConvention),
- platform(platform)
+ DebugFunctionInfo(std::string shortName, std::string fullName, std::string rawName, uint64_t address,
+ Ref<Type> returnType, std::vector<std::tuple<std::string, Ref<Type>>> parameters, bool variableParameters,
+ Ref<CallingConvention> callingConvention, Ref<Platform> platform) :
+ shortName(shortName),
+ fullName(fullName), rawName(rawName), address(address), returnType(returnType), parameters(parameters),
+ variableParameters(variableParameters), callingConvention(callingConvention), platform(platform)
{}
};
class DebugInfo : public CoreRefCountObject<BNDebugInfo, BNNewDebugInfoReference, BNFreeDebugInfoReference>
{
- public:
+ public:
DebugInfo(BNDebugInfo* debugInfo);
std::vector<NameAndType> GetTypes(const std::string& parserName = "");
@@ -6245,19 +6362,20 @@ __attribute__ ((format (printf, 1, 2)))
bool AddDataVariable(uint64_t address, Ref<Type> type, const std::string& name = "");
};
- class DebugInfoParser : public CoreRefCountObject<BNDebugInfoParser, BNNewDebugInfoParserReference, BNFreeDebugInfoParserReference>
+ class DebugInfoParser :
+ public CoreRefCountObject<BNDebugInfoParser, BNNewDebugInfoParserReference, BNFreeDebugInfoParserReference>
{
- public:
- DebugInfoParser(BNDebugInfoParser* parser);
+ public:
+ DebugInfoParser(BNDebugInfoParser* parser);
- static Ref<DebugInfoParser> GetByName(const std::string& name);
- static std::vector<Ref<DebugInfoParser>> GetList();
- static std::vector<Ref<DebugInfoParser>> GetListForView(const Ref<BinaryView> data);
+ static Ref<DebugInfoParser> GetByName(const std::string& name);
+ static std::vector<Ref<DebugInfoParser>> GetList();
+ static std::vector<Ref<DebugInfoParser>> GetListForView(const Ref<BinaryView> data);
- std::string GetName() const;
- Ref<DebugInfo> Parse(Ref<BinaryView> view, Ref<DebugInfo> existingDebugInfo = nullptr) const;
+ std::string GetName() const;
+ Ref<DebugInfo> Parse(Ref<BinaryView> view, Ref<DebugInfo> existingDebugInfo = nullptr) const;
- bool IsValidForView(const Ref<BinaryView> view) const;
+ bool IsValidForView(const Ref<BinaryView> view) const;
};
class CustomDebugInfoParser : public DebugInfoParser
@@ -6266,22 +6384,22 @@ __attribute__ ((format (printf, 1, 2)))
static void ParseCallback(void* ctxt, BNDebugInfo* debugInfo, BNBinaryView* view);
BNDebugInfoParser* Register(const std::string& name);
- public:
- CustomDebugInfoParser(const std::string& name);
- virtual ~CustomDebugInfoParser() {}
+ public:
+ CustomDebugInfoParser(const std::string& name);
+ virtual ~CustomDebugInfoParser() {}
- virtual bool IsValid(Ref<BinaryView>) = 0;
- virtual void ParseInfo(Ref<DebugInfo>, Ref<BinaryView>) = 0;
+ virtual bool IsValid(Ref<BinaryView>) = 0;
+ virtual void ParseInfo(Ref<DebugInfo>, Ref<BinaryView>) = 0;
};
/*!
Class for storing secrets (e.g. tokens) in a system-specific manner
*/
- class SecretsProvider: public StaticCoreRefCountObject<BNSecretsProvider>
+ class SecretsProvider : public StaticCoreRefCountObject<BNSecretsProvider>
{
std::string m_nameForRegister;
- protected:
+ protected:
SecretsProvider(const std::string& name);
SecretsProvider(BNSecretsProvider* provider);
@@ -6290,7 +6408,7 @@ __attribute__ ((format (printf, 1, 2)))
static bool StoreDataCallback(void* ctxt, const char* key, const char* data);
static bool DeleteDataCallback(void* ctxt, const char* key);
- public:
+ public:
/*!
Check if data for a specific key exists, but do not retrieve it
\param key Key for data
@@ -6336,9 +6454,9 @@ __attribute__ ((format (printf, 1, 2)))
static void Register(SecretsProvider* provider);
};
- class CoreSecretsProvider: public SecretsProvider
+ class CoreSecretsProvider : public SecretsProvider
{
- public:
+ public:
CoreSecretsProvider(BNSecretsProvider* provider);
virtual bool HasData(const std::string& key) override;
@@ -6346,5 +6464,4 @@ __attribute__ ((format (printf, 1, 2)))
virtual bool StoreData(const std::string& key, const std::string& data) override;
virtual bool DeleteData(const std::string& key) override;
};
-}
-
+} // namespace BinaryNinja
diff --git a/binaryninjacore.h b/binaryninjacore.h
index 257e98d5..4033a457 100644
--- a/binaryninjacore.h
+++ b/binaryninjacore.h
@@ -38,72 +38,72 @@
#define BN_MINIMUM_CORE_ABI_VERSION 13
#ifdef __GNUC__
-# ifdef BINARYNINJACORE_LIBRARY
-# define BINARYNINJACOREAPI __attribute__((visibility("default")))
-# else
-# define BINARYNINJACOREAPI
-# endif
-# define BINARYNINJAPLUGIN __attribute__((visibility("default")))
+ #ifdef BINARYNINJACORE_LIBRARY
+ #define BINARYNINJACOREAPI __attribute__((visibility("default")))
+ #else
+ #define BINARYNINJACOREAPI
+ #endif
+ #define BINARYNINJAPLUGIN __attribute__((visibility("default")))
#else
-#ifdef _MSC_VER
-# ifdef BINARYNINJACORE_LIBRARY
-# define BINARYNINJACOREAPI __declspec(dllexport)
-# else
-# define BINARYNINJACOREAPI
-# endif
-# define BINARYNINJAPLUGIN __declspec(dllexport)
-#else
-#define BINARYNINJACOREAPI
-#endif
+ #ifdef _MSC_VER
+ #ifdef BINARYNINJACORE_LIBRARY
+ #define BINARYNINJACOREAPI __declspec(dllexport)
+ #else
+ #define BINARYNINJACOREAPI
+ #endif
+ #define BINARYNINJAPLUGIN __declspec(dllexport)
+ #else
+ #define BINARYNINJACOREAPI
+ #endif
#endif
#ifdef WIN32
-#define PATH_SEP "\\"
+ #define PATH_SEP "\\"
#else
-#define PATH_SEP "/"
+ #define PATH_SEP "/"
#endif
-#define BN_MAX_INSTRUCTION_LENGTH 256
+#define BN_MAX_INSTRUCTION_LENGTH 256
#define BN_DEFAULT_INSTRUCTION_LENGTH 16
-#define BN_DEFAULT_OPCODE_DISPLAY 8
-#define BN_MAX_INSTRUCTION_BRANCHES 3
+#define BN_DEFAULT_OPCODE_DISPLAY 8
+#define BN_MAX_INSTRUCTION_BRANCHES 3
-#define BN_MAX_STORED_DATA_LENGTH 0x3fffffff
-#define BN_NULL_ID -1
+#define BN_MAX_STORED_DATA_LENGTH 0x3fffffff
+#define BN_NULL_ID -1
-#define LLIL_TEMP(n) (0x80000000 | (uint32_t)(n))
-#define LLIL_REG_IS_TEMP(n) (((n) & 0x80000000) != 0)
-#define LLIL_GET_TEMP_REG_INDEX(n) ((n) & 0x7fffffff)
-#define BN_INVALID_REGISTER 0xffffffff
+#define LLIL_TEMP(n) (0x80000000 | (uint32_t)(n))
+#define LLIL_REG_IS_TEMP(n) (((n)&0x80000000) != 0)
+#define LLIL_GET_TEMP_REG_INDEX(n) ((n)&0x7fffffff)
+#define BN_INVALID_REGISTER 0xffffffff
-#define BN_AUTOCOERCE_EXTERN_PTR 0xfffffffd
-#define BN_NOCOERCE_EXTERN_PTR 0xfffffffe
-#define BN_INVALID_OPERAND 0xffffffff
+#define BN_AUTOCOERCE_EXTERN_PTR 0xfffffffd
+#define BN_NOCOERCE_EXTERN_PTR 0xfffffffe
+#define BN_INVALID_OPERAND 0xffffffff
-#define BN_INVALID_EXPR ((size_t)-1)
+#define BN_INVALID_EXPR ((size_t)-1)
-#define BN_MAX_STRING_LENGTH 128
+#define BN_MAX_STRING_LENGTH 128
-#define LLVM_SVCS_CB_NOTE 0
+#define LLVM_SVCS_CB_NOTE 0
#define LLVM_SVCS_CB_WARNING 1
-#define LLVM_SVCS_CB_ERROR 2
+#define LLVM_SVCS_CB_ERROR 2
#define LLVM_SVCS_DIALECT_UNSPEC 0
-#define LLVM_SVCS_DIALECT_ATT 1
-#define LLVM_SVCS_DIALECT_INTEL 2
+#define LLVM_SVCS_DIALECT_ATT 1
+#define LLVM_SVCS_DIALECT_INTEL 2
#define LLVM_SVCS_CM_DEFAULT 0
-#define LLVM_SVCS_CM_SMALL 1
-#define LLVM_SVCS_CM_KERNEL 2
-#define LLVM_SVCS_CM_MEDIUM 3
-#define LLVM_SVCS_CM_LARGE 4
+#define LLVM_SVCS_CM_SMALL 1
+#define LLVM_SVCS_CM_KERNEL 2
+#define LLVM_SVCS_CM_MEDIUM 3
+#define LLVM_SVCS_CM_LARGE 4
-#define LLVM_SVCS_RM_STATIC 0
-#define LLVM_SVCS_RM_PIC 1
+#define LLVM_SVCS_RM_STATIC 0
+#define LLVM_SVCS_RM_PIC 1
#define LLVM_SVCS_RM_DYNAMIC_NO_PIC 2
-#define BN_MAX_VARIABLE_OFFSET 0x7fffffffffLL
-#define BN_MAX_VARIABLE_INDEX 0xfffff
+#define BN_MAX_VARIABLE_OFFSET 0x7fffffffffLL
+#define BN_MAX_VARIABLE_INDEX 0xfffff
#define BN_FULL_CONFIDENCE 255
#define BN_MINIMUM_CONFIDENCE 1
@@ -118,16 +118,13 @@
// The BN_DECLARE_CORE_ABI_VERSION must be included in native plugin modules. If
// the ABI version is not declared, the core will not load the plugin.
#ifdef DEMO_VERSION
-#define BN_DECLARE_CORE_ABI_VERSION
+ #define BN_DECLARE_CORE_ABI_VERSION
#else
-#define BN_DECLARE_CORE_ABI_VERSION \
- extern "C" \
- { \
- BINARYNINJAPLUGIN uint32_t CorePluginABIVersion() \
+ #define BN_DECLARE_CORE_ABI_VERSION \
+ extern "C" \
{ \
- return BN_CURRENT_CORE_ABI_VERSION; \
- } \
- }
+ BINARYNINJAPLUGIN uint32_t CorePluginABIVersion() { return BN_CURRENT_CORE_ABI_VERSION; } \
+ }
#endif
@@ -142,7 +139,8 @@ extern "C"
LatePluginLoadOrder
};
- enum PluginLoadStatus {
+ enum PluginLoadStatus
+ {
NotAttemptedStatus,
LoadSucceededStatus,
LoadFailedStatus
@@ -229,11 +227,11 @@ extern "C"
//! Console log levels
enum BNLogLevel
{
- DebugLog = 0, //! Debug logging level, most verbose logging level
- InfoLog = 1, //! Information logging level, default logging level
- WarningLog = 2, //! Warning logging level, messages show with warning icon in the UI
- ErrorLog = 3, //! Error logging level, messages show with error icon in the UI
- AlertLog = 4 //! Alert logging level, messages are displayed with popup message box in the UI
+ DebugLog = 0, //! Debug logging level, most verbose logging level
+ InfoLog = 1, //! Information logging level, default logging level
+ WarningLog = 2, //! Warning logging level, messages show with warning icon in the UI
+ ErrorLog = 3, //! Error logging level, messages show with error icon in the UI
+ AlertLog = 4 //! Alert logging level, messages are displayed with popup message box in the UI
};
enum BNEndianness
@@ -251,15 +249,15 @@ extern "C"
enum BNTransformType
{
- BinaryCodecTransform = 0, // Two-way transform of data, binary input/output
- TextCodecTransform = 1, // Two-way transform of data, encoder output is text
- UnicodeCodecTransform = 2, // Two-way transform of data, encoder output is Unicode string (as UTF8)
- DecodeTransform = 3, // One-way decode only
- BinaryEncodeTransform = 4, // One-way encode only, output is binary
- TextEncodeTransform = 5, // One-way encode only, output is text
- EncryptTransform = 6, // Two-way encryption
- InvertingTransform = 7, // Transform that can be undone by performing twice
- HashTransform = 8 // Hash function
+ BinaryCodecTransform = 0, // Two-way transform of data, binary input/output
+ TextCodecTransform = 1, // Two-way transform of data, encoder output is text
+ UnicodeCodecTransform = 2, // Two-way transform of data, encoder output is Unicode string (as UTF8)
+ DecodeTransform = 3, // One-way decode only
+ BinaryEncodeTransform = 4, // One-way encode only, output is binary
+ TextEncodeTransform = 5, // One-way encode only, output is text
+ EncryptTransform = 6, // Two-way encryption
+ InvertingTransform = 7, // Transform that can be undone by performing twice
+ HashTransform = 8 // Hash function
};
enum BNBranchType
@@ -395,27 +393,28 @@ extern "C"
enum BNLowLevelILOperation
{
LLIL_NOP,
- LLIL_SET_REG, // Not valid in SSA form (see LLIL_SET_REG_SSA)
- LLIL_SET_REG_SPLIT, // Not valid in SSA form (see LLIL_SET_REG_SPLIT_SSA)
- LLIL_SET_FLAG, // Not valid in SSA form (see LLIL_SET_FLAG_SSA)
- LLIL_SET_REG_STACK_REL, // Not valid in SSA form (see LLIL_SET_REG_STACK_REL_SSA)
- LLIL_REG_STACK_PUSH, // Not valid in SSA form (expanded)
- LLIL_LOAD, // Not valid in SSA form (see LLIL_LOAD_SSA)
- LLIL_STORE, // Not valid in SSA form (see LLIL_STORE_SSA)
- LLIL_PUSH, // Not valid in SSA form (expanded)
- LLIL_POP, // Not valid in SSA form (expanded)
- LLIL_REG, // Not valid in SSA form (see LLIL_REG_SSA)
- LLIL_REG_SPLIT, // Not valid in SSA form (see LLIL_REG_SPLIT_SSA)
- LLIL_REG_STACK_REL, // Not valid in SSA form (see LLIL_REG_STACK_REL_SSA)
- LLIL_REG_STACK_POP, // Not valid in SSA form (expanded)
- LLIL_REG_STACK_FREE_REG, // Not valid in SSA form (see LLIL_REG_STACK_FREE_REL_SSA, LLIL_REG_STACK_FREE_ABS_SSA)
- LLIL_REG_STACK_FREE_REL, // Not valid in SSA from (see LLIL_REG_STACK_FREE_REL_SSA)
+ LLIL_SET_REG, // Not valid in SSA form (see LLIL_SET_REG_SSA)
+ LLIL_SET_REG_SPLIT, // Not valid in SSA form (see LLIL_SET_REG_SPLIT_SSA)
+ LLIL_SET_FLAG, // Not valid in SSA form (see LLIL_SET_FLAG_SSA)
+ LLIL_SET_REG_STACK_REL, // Not valid in SSA form (see LLIL_SET_REG_STACK_REL_SSA)
+ LLIL_REG_STACK_PUSH, // Not valid in SSA form (expanded)
+ LLIL_LOAD, // Not valid in SSA form (see LLIL_LOAD_SSA)
+ LLIL_STORE, // Not valid in SSA form (see LLIL_STORE_SSA)
+ LLIL_PUSH, // Not valid in SSA form (expanded)
+ LLIL_POP, // Not valid in SSA form (expanded)
+ LLIL_REG, // Not valid in SSA form (see LLIL_REG_SSA)
+ LLIL_REG_SPLIT, // Not valid in SSA form (see LLIL_REG_SPLIT_SSA)
+ LLIL_REG_STACK_REL, // Not valid in SSA form (see LLIL_REG_STACK_REL_SSA)
+ LLIL_REG_STACK_POP, // Not valid in SSA form (expanded)
+ LLIL_REG_STACK_FREE_REG, // Not valid in SSA form (see LLIL_REG_STACK_FREE_REL_SSA,
+ // LLIL_REG_STACK_FREE_ABS_SSA)
+ LLIL_REG_STACK_FREE_REL, // Not valid in SSA from (see LLIL_REG_STACK_FREE_REL_SSA)
LLIL_CONST,
LLIL_CONST_PTR,
LLIL_EXTERN_PTR,
LLIL_FLOAT_CONST,
- LLIL_FLAG, // Not valid in SSA form (see LLIL_FLAG_SSA)
- LLIL_FLAG_BIT, // Not valid in SSA form (see LLIL_FLAG_BIT_SSA)
+ LLIL_FLAG, // Not valid in SSA form (see LLIL_FLAG_SSA)
+ LLIL_FLAG_BIT, // Not valid in SSA form (see LLIL_FLAG_BIT_SSA)
LLIL_ADD,
LLIL_ADC,
LLIL_SUB,
@@ -455,8 +454,8 @@ extern "C"
LLIL_NORET,
LLIL_IF,
LLIL_GOTO,
- LLIL_FLAG_COND, // Valid only in Lifted IL
- LLIL_FLAG_GROUP, // Valid only in Lifted IL
+ LLIL_FLAG_COND, // Valid only in Lifted IL
+ LLIL_FLAG_GROUP, // Valid only in Lifted IL
LLIL_CMP_E,
LLIL_CMP_NE,
LLIL_CMP_SLT,
@@ -508,8 +507,8 @@ extern "C"
LLIL_SET_REG_SPLIT_SSA,
LLIL_SET_REG_STACK_REL_SSA,
LLIL_SET_REG_STACK_ABS_SSA,
- LLIL_REG_SPLIT_DEST_SSA, // Only valid within an LLIL_SET_REG_SPLIT_SSA instruction
- LLIL_REG_STACK_DEST_SSA, // Only valid within LLIL_SET_REG_STACK_REL_SSA or LLIL_SET_REG_STACK_ABS_SSA
+ LLIL_REG_SPLIT_DEST_SSA, // Only valid within an LLIL_SET_REG_SPLIT_SSA instruction
+ LLIL_REG_STACK_DEST_SSA, // Only valid within LLIL_SET_REG_STACK_REL_SSA or LLIL_SET_REG_STACK_ABS_SSA
LLIL_REG_SSA,
LLIL_REG_SSA_PARTIAL,
LLIL_REG_SPLIT_SSA,
@@ -523,9 +522,10 @@ extern "C"
LLIL_CALL_SSA,
LLIL_SYSCALL_SSA,
LLIL_TAILCALL_SSA,
- LLIL_CALL_PARAM, // Only valid within the LLIL_CALL_SSA, LLIL_SYSCALL_SSA, LLIL_INTRINSIC, LLIL_INTRINSIC_SSA instructions
- LLIL_CALL_STACK_SSA, // Only valid within the LLIL_CALL_SSA or LLIL_SYSCALL_SSA instructions
- LLIL_CALL_OUTPUT_SSA, // Only valid within the LLIL_CALL_SSA or LLIL_SYSCALL_SSA instructions
+ LLIL_CALL_PARAM, // Only valid within the LLIL_CALL_SSA, LLIL_SYSCALL_SSA, LLIL_INTRINSIC, LLIL_INTRINSIC_SSA
+ // instructions
+ LLIL_CALL_STACK_SSA, // Only valid within the LLIL_CALL_SSA or LLIL_SYSCALL_SSA instructions
+ LLIL_CALL_OUTPUT_SSA, // Only valid within the LLIL_CALL_SSA or LLIL_SYSCALL_SSA instructions
LLIL_LOAD_SSA,
LLIL_STORE_SSA,
LLIL_INTRINSIC_SSA,
@@ -649,7 +649,8 @@ extern "C"
UnionStructureType = 2
};
- enum BNMemberScope {
+ enum BNMemberScope
+ {
NoScope,
StaticScope,
VirtualScope,
@@ -873,7 +874,8 @@ extern "C"
enum BNDataFlowQueryOption
{
- FromAddressesInLookupTableQueryOption // Use addresses instead of index in the from list within LookupTableValue results
+ FromAddressesInLookupTableQueryOption // Use addresses instead of index in the from list within
+ // LookupTableValue results
};
enum BNPluginOrigin
@@ -885,17 +887,17 @@ extern "C"
enum BNPluginStatus
{
- NotInstalledPluginStatus = 0x00000000,
- InstalledPluginStatus = 0x00000001,
- EnabledPluginStatus = 0x00000002,
- UpdateAvailablePluginStatus = 0x00000010,
- DeletePendingPluginStatus = 0x00000020,
- UpdatePendingPluginStatus = 0x00000040,
- DisablePendingPluginStatus = 0x00000080,
- PendingRestartPluginStatus = 0x00000200,
- BeingUpdatedPluginStatus = 0x00000400,
- BeingDeletedPluginStatus = 0x00000800,
- DependenciesBeingInstalledStatus = 0x00001000
+ NotInstalledPluginStatus = 0x00000000,
+ InstalledPluginStatus = 0x00000001,
+ EnabledPluginStatus = 0x00000002,
+ UpdateAvailablePluginStatus = 0x00000010,
+ DeletePendingPluginStatus = 0x00000020,
+ UpdatePendingPluginStatus = 0x00000040,
+ DisablePendingPluginStatus = 0x00000080,
+ PendingRestartPluginStatus = 0x00000200,
+ BeingUpdatedPluginStatus = 0x00000400,
+ BeingDeletedPluginStatus = 0x00000800,
+ DependenciesBeingInstalledStatus = 0x00001000
};
enum BNPluginType
@@ -971,16 +973,16 @@ extern "C"
enum BNMediumLevelILOperation
{
MLIL_NOP,
- MLIL_SET_VAR, // Not valid in SSA form (see MLIL_SET_VAR_SSA)
- MLIL_SET_VAR_FIELD, // Not valid in SSA form (see MLIL_SET_VAR_FIELD)
- MLIL_SET_VAR_SPLIT, // Not valid in SSA form (see MLIL_SET_VAR_SPLIT_SSA)
- MLIL_LOAD, // Not valid in SSA form (see MLIL_LOAD_SSA)
- MLIL_LOAD_STRUCT, // Not valid in SSA form (see MLIL_LOAD_STRUCT_SSA)
- MLIL_STORE, // Not valid in SSA form (see MLIL_STORE_SSA)
- MLIL_STORE_STRUCT, // Not valid in SSA form (see MLIL_STORE_STRUCT_SSA)
- MLIL_VAR, // Not valid in SSA form (see MLIL_VAR_SSA)
- MLIL_VAR_FIELD, // Not valid in SSA form (see MLIL_VAR_SSA_FIELD)
- MLIL_VAR_SPLIT, // Not valid in SSA form (see MLIL_VAR_SPLIT_SSA)
+ MLIL_SET_VAR, // Not valid in SSA form (see MLIL_SET_VAR_SSA)
+ MLIL_SET_VAR_FIELD, // Not valid in SSA form (see MLIL_SET_VAR_FIELD)
+ MLIL_SET_VAR_SPLIT, // Not valid in SSA form (see MLIL_SET_VAR_SPLIT_SSA)
+ MLIL_LOAD, // Not valid in SSA form (see MLIL_LOAD_SSA)
+ MLIL_LOAD_STRUCT, // Not valid in SSA form (see MLIL_LOAD_STRUCT_SSA)
+ MLIL_STORE, // Not valid in SSA form (see MLIL_STORE_SSA)
+ MLIL_STORE_STRUCT, // Not valid in SSA form (see MLIL_STORE_STRUCT_SSA)
+ MLIL_VAR, // Not valid in SSA form (see MLIL_VAR_SSA)
+ MLIL_VAR_FIELD, // Not valid in SSA form (see MLIL_VAR_SSA_FIELD)
+ MLIL_VAR_SPLIT, // Not valid in SSA form (see MLIL_VAR_SPLIT_SSA)
MLIL_ADDRESS_OF,
MLIL_ADDRESS_OF_FIELD,
MLIL_CONST,
@@ -1020,11 +1022,11 @@ extern "C"
MLIL_LOW_PART,
MLIL_JUMP,
MLIL_JUMP_TO,
- MLIL_RET_HINT, // Intermediate stages, does not appear in final forms
- MLIL_CALL, // Not valid in SSA form (see MLIL_CALL_SSA)
- MLIL_CALL_UNTYPED, // Not valid in SSA form (see MLIL_CALL_UNTYPED_SSA)
- MLIL_CALL_OUTPUT, // Only valid within MLIL_CALL, MLIL_SYSCALL, MLIL_TAILCALL family instructions
- MLIL_CALL_PARAM, // Only valid within MLIL_CALL, MLIL_SYSCALL, MLIL_TAILCALL family instructions
+ MLIL_RET_HINT, // Intermediate stages, does not appear in final forms
+ MLIL_CALL, // Not valid in SSA form (see MLIL_CALL_SSA)
+ MLIL_CALL_UNTYPED, // Not valid in SSA form (see MLIL_CALL_UNTYPED_SSA)
+ MLIL_CALL_OUTPUT, // Only valid within MLIL_CALL, MLIL_SYSCALL, MLIL_TAILCALL family instructions
+ MLIL_CALL_PARAM, // Only valid within MLIL_CALL, MLIL_SYSCALL, MLIL_TAILCALL family instructions
MLIL_RET,
MLIL_NORET,
MLIL_IF,
@@ -1042,12 +1044,12 @@ extern "C"
MLIL_TEST_BIT,
MLIL_BOOL_TO_INT,
MLIL_ADD_OVERFLOW,
- MLIL_SYSCALL, // Not valid in SSA form (see MLIL_SYSCALL_SSA)
- MLIL_SYSCALL_UNTYPED, // Not valid in SSA form (see MLIL_SYSCALL_UNTYPED_SSA)
- MLIL_TAILCALL, // Not valid in SSA form (see MLIL_TAILCALL_SSA)
- MLIL_TAILCALL_UNTYPED, // Not valid in SSA form (see MLIL_TAILCALL_UNTYPED_SSA)
- MLIL_INTRINSIC, // Not valid in SSA form (see MLIL_INTRINSIC_SSA)
- MLIL_FREE_VAR_SLOT, // Not valid in SSA from (see MLIL_FREE_VAR_SLOT_SSA)
+ MLIL_SYSCALL, // Not valid in SSA form (see MLIL_SYSCALL_SSA)
+ MLIL_SYSCALL_UNTYPED, // Not valid in SSA form (see MLIL_SYSCALL_UNTYPED_SSA)
+ MLIL_TAILCALL, // Not valid in SSA form (see MLIL_TAILCALL_SSA)
+ MLIL_TAILCALL_UNTYPED, // Not valid in SSA form (see MLIL_TAILCALL_UNTYPED_SSA)
+ MLIL_INTRINSIC, // Not valid in SSA form (see MLIL_INTRINSIC_SSA)
+ MLIL_FREE_VAR_SLOT, // Not valid in SSA from (see MLIL_FREE_VAR_SLOT_SSA)
MLIL_BP,
MLIL_TRAP,
MLIL_UNDEF,
@@ -1095,8 +1097,10 @@ extern "C"
MLIL_SYSCALL_UNTYPED_SSA,
MLIL_TAILCALL_SSA,
MLIL_TAILCALL_UNTYPED_SSA,
- MLIL_CALL_PARAM_SSA, // Only valid within the MLIL_CALL_SSA, MLIL_SYSCALL_SSA, MLIL_TAILCALL_SSA family instructions
- MLIL_CALL_OUTPUT_SSA, // Only valid within the MLIL_CALL_SSA or MLIL_SYSCALL_SSA, MLIL_TAILCALL_SSA family instructions
+ MLIL_CALL_PARAM_SSA, // Only valid within the MLIL_CALL_SSA, MLIL_SYSCALL_SSA, MLIL_TAILCALL_SSA family
+ // instructions
+ MLIL_CALL_OUTPUT_SSA, // Only valid within the MLIL_CALL_SSA or MLIL_SYSCALL_SSA, MLIL_TAILCALL_SSA family
+ // instructions
MLIL_LOAD_SSA,
MLIL_LOAD_STRUCT_SSA,
MLIL_STORE_SSA,
@@ -1393,7 +1397,7 @@ extern "C"
{
char* name;
char* longName;
- size_t fixedLength; // Variable length if zero
+ size_t fixedLength; // Variable length if zero
};
struct BNTransformParameter
@@ -1407,8 +1411,10 @@ extern "C"
void* context;
BNTransformParameterInfo* (*getParameters)(void* ctxt, size_t* count);
void (*freeParameters)(BNTransformParameterInfo* params, size_t count);
- bool (*decode)(void* ctxt, BNDataBuffer* input, BNDataBuffer* output, BNTransformParameter* params, size_t paramCount);
- bool (*encode)(void* ctxt, BNDataBuffer* input, BNDataBuffer* output, BNTransformParameter* params, size_t paramCount);
+ bool (*decode)(
+ void* ctxt, BNDataBuffer* input, BNDataBuffer* output, BNTransformParameter* params, size_t paramCount);
+ bool (*encode)(
+ void* ctxt, BNDataBuffer* input, BNDataBuffer* output, BNTransformParameter* params, size_t paramCount);
};
struct BNInstructionInfo
@@ -1419,7 +1425,7 @@ extern "C"
bool branchDelay;
BNBranchType branchType[BN_MAX_INSTRUCTION_BRANCHES];
uint64_t branchTarget[BN_MAX_INSTRUCTION_BRANCHES];
- BNArchitecture* branchArch[BN_MAX_INSTRUCTION_BRANCHES]; // If null, same architecture as instruction
+ BNArchitecture* branchArch[BN_MAX_INSTRUCTION_BRANCHES]; // If null, same architecture as instruction
};
enum BNRelocationType
@@ -1431,28 +1437,28 @@ extern "C"
IgnoredRelocation,
UnhandledRelocation
};
- #define MAX_RELOCATION_SIZE 8
+#define MAX_RELOCATION_SIZE 8
struct BNRelocationInfo
{
- BNRelocationType type; // BinaryNinja Relocation Type
- bool pcRelative; // PC Relative or Absolute (subtract address from relocation)
- bool baseRelative; // Relative to start of module (Add module base to relocation)
- uint64_t base; // Base address for this binary view
- size_t size; // Size of the data to be written
- size_t truncateSize; // After addition/subtraction truncate to
- uint64_t nativeType; // Base type from relocation entry
- size_t addend; // Addend value from relocation entry
- bool hasSign; // Addend should be subtracted
- bool implicitAddend; // Addend should be read from the BinaryView
- bool external; // Relocation entry points to external symbol
- size_t symbolIndex; // Index into symbol table
- size_t sectionIndex; // Index into the section table
- uint64_t address; // Absolute address or segment offset
- uint64_t target; // Target (set automatically)
- bool dataRelocation; // This relocation is effecting data not code
+ BNRelocationType type; // BinaryNinja Relocation Type
+ bool pcRelative; // PC Relative or Absolute (subtract address from relocation)
+ bool baseRelative; // Relative to start of module (Add module base to relocation)
+ uint64_t base; // Base address for this binary view
+ size_t size; // Size of the data to be written
+ size_t truncateSize; // After addition/subtraction truncate to
+ uint64_t nativeType; // Base type from relocation entry
+ size_t addend; // Addend value from relocation entry
+ bool hasSign; // Addend should be subtracted
+ bool implicitAddend; // Addend should be read from the BinaryView
+ bool external; // Relocation entry points to external symbol
+ size_t symbolIndex; // Index into symbol table
+ size_t sectionIndex; // Index into the section table
+ uint64_t address; // Absolute address or segment offset
+ uint64_t target; // Target (set automatically)
+ bool dataRelocation; // This relocation is effecting data not code
uint8_t relocationDataCache[MAX_RELOCATION_SIZE];
- struct BNRelocationInfo* prev; // Link to relocation another related relocation
- struct BNRelocationInfo* next; // Link to relocation another related relocation
+ struct BNRelocationInfo* prev; // Link to relocation another related relocation
+ struct BNRelocationInfo* next; // Link to relocation another related relocation
};
struct BNInstructionTextToken
@@ -1505,11 +1511,13 @@ extern "C"
size_t (*getMaxInstructionLength)(void* ctxt);
size_t (*getOpcodeDisplayLength)(void* ctxt);
BNArchitecture* (*getAssociatedArchitectureByAddress)(void* ctxt, uint64_t* addr);
- bool (*getInstructionInfo)(void* ctxt, const uint8_t* data, uint64_t addr, size_t maxLen, BNInstructionInfo* result);
+ bool (*getInstructionInfo)(
+ void* ctxt, const uint8_t* data, uint64_t addr, size_t maxLen, BNInstructionInfo* result);
bool (*getInstructionText)(void* ctxt, const uint8_t* data, uint64_t addr, size_t* len,
- BNInstructionTextToken** result, size_t* count);
+ BNInstructionTextToken** result, size_t* count);
void (*freeInstructionText)(BNInstructionTextToken* tokens, size_t count);
- bool (*getInstructionLowLevelIL)(void* ctxt, const uint8_t* data, uint64_t addr, size_t* len, BNLowLevelILFunction* il);
+ bool (*getInstructionLowLevelIL)(
+ void* ctxt, const uint8_t* data, uint64_t addr, size_t* len, BNLowLevelILFunction* il);
char* (*getRegisterName)(void* ctxt, uint32_t reg);
char* (*getFlagName)(void* ctxt, uint32_t flag);
char* (*getFlagWriteTypeName)(void* ctxt, uint32_t flags);
@@ -1522,17 +1530,18 @@ extern "C"
uint32_t* (*getAllSemanticFlagClasses)(void* ctxt, size_t* count);
uint32_t* (*getAllSemanticFlagGroups)(void* ctxt, size_t* count);
BNFlagRole (*getFlagRole)(void* ctxt, uint32_t flag, uint32_t semClass);
- uint32_t* (*getFlagsRequiredForFlagCondition)(void* ctxt, BNLowLevelILFlagCondition cond,
- uint32_t semClass, size_t* count);
+ uint32_t* (*getFlagsRequiredForFlagCondition)(
+ void* ctxt, BNLowLevelILFlagCondition cond, uint32_t semClass, size_t* count);
uint32_t* (*getFlagsRequiredForSemanticFlagGroup)(void* ctxt, uint32_t semGroup, size_t* count);
- BNFlagConditionForSemanticClass* (*getFlagConditionsForSemanticFlagGroup)(void* ctxt, uint32_t semGroup, size_t* count);
+ BNFlagConditionForSemanticClass* (*getFlagConditionsForSemanticFlagGroup)(
+ void* ctxt, uint32_t semGroup, size_t* count);
void (*freeFlagConditionsForSemanticFlagGroup)(void* ctxt, BNFlagConditionForSemanticClass* conditions);
uint32_t* (*getFlagsWrittenByFlagWriteType)(void* ctxt, uint32_t writeType, size_t* count);
uint32_t (*getSemanticClassForFlagWriteType)(void* ctxt, uint32_t writeType);
size_t (*getFlagWriteLowLevelIL)(void* ctxt, BNLowLevelILOperation op, size_t size, uint32_t flagWriteType,
- uint32_t flag, BNRegisterOrConstant* operands, size_t operandCount, BNLowLevelILFunction* il);
- size_t (*getFlagConditionLowLevelIL)(void* ctxt, BNLowLevelILFlagCondition cond,
- uint32_t semClass, BNLowLevelILFunction* il);
+ uint32_t flag, BNRegisterOrConstant* operands, size_t operandCount, BNLowLevelILFunction* il);
+ size_t (*getFlagConditionLowLevelIL)(
+ void* ctxt, BNLowLevelILFlagCondition cond, uint32_t semClass, BNLowLevelILFunction* il);
size_t (*getSemanticFlagGroupLowLevelIL)(void* ctxt, uint32_t semGroup, BNLowLevelILFunction* il);
void (*freeRegisterList)(void* ctxt, uint32_t* regs);
void (*getRegisterInfo)(void* ctxt, uint32_t reg, BNRegisterInfo* result);
@@ -1684,12 +1693,12 @@ extern "C"
// The following edge styles map to Qt's Qt::PenStyle enumeration
enum BNEdgePenStyle
{
- NoPen = 0, // no line at all.
- SolidLine = 1, // A plain line (default)
- DashLine = 2, // Dashes separated by a few pixels.
- DotLine = 3, // Dots separated by a few pixels.
- DashDotLine = 4, // Alternate dots and dashes.
- DashDotDotLine = 5, // One dash, two dots, one dash, two dots.
+ NoPen = 0, // no line at all.
+ SolidLine = 1, // A plain line (default)
+ DashLine = 2, // Dashes separated by a few pixels.
+ DotLine = 3, // Dots separated by a few pixels.
+ DashDotLine = 4, // Alternate dots and dashes.
+ DashDotDotLine = 5, // One dash, two dots, one dash, two dots.
};
struct BNEdgeStyle
@@ -1966,12 +1975,12 @@ extern "C"
void* context;
void (*freeObject)(void* ctxt);
- bool (*getRelocationInfo)(void* ctxt, BNBinaryView* view, BNArchitecture* arch, BNRelocationInfo* result,
- size_t resultCount);
- bool (*applyRelocation)(void* ctxt, BNBinaryView* view, BNArchitecture* arch, BNRelocation* reloc, uint8_t* dest,
- size_t len);
+ bool (*getRelocationInfo)(
+ void* ctxt, BNBinaryView* view, BNArchitecture* arch, BNRelocationInfo* result, size_t resultCount);
+ bool (*applyRelocation)(
+ void* ctxt, BNBinaryView* view, BNArchitecture* arch, BNRelocation* reloc, uint8_t* dest, size_t len);
size_t (*getOperandForExternalRelocation)(void* ctxt, const uint8_t* data, uint64_t addr, size_t length,
- BNLowLevelILFunction* il, BNRelocation* relocation);
+ BNLowLevelILFunction* il, BNRelocation* relocation);
};
struct BNTypeParserResult
@@ -2045,9 +2054,11 @@ extern "C"
void (*lowLevelILFunctionCommand)(void* ctxt, BNBinaryView* view, BNLowLevelILFunction* func);
void (*lowLevelILInstructionCommand)(void* ctxt, BNBinaryView* view, BNLowLevelILFunction* func, size_t instr);
void (*mediumLevelILFunctionCommand)(void* ctxt, BNBinaryView* view, BNMediumLevelILFunction* func);
- void (*mediumLevelILInstructionCommand)(void* ctxt, BNBinaryView* view, BNMediumLevelILFunction* func, size_t instr);
+ void (*mediumLevelILInstructionCommand)(
+ void* ctxt, BNBinaryView* view, BNMediumLevelILFunction* func, size_t instr);
void (*highLevelILFunctionCommand)(void* ctxt, BNBinaryView* view, BNHighLevelILFunction* func);
- void (*highLevelILInstructionCommand)(void* ctxt, BNBinaryView* view, BNHighLevelILFunction* func, size_t instr);
+ void (*highLevelILInstructionCommand)(
+ void* ctxt, BNBinaryView* view, BNHighLevelILFunction* func, size_t instr);
bool (*defaultIsValid)(void* ctxt, BNBinaryView* view);
bool (*addressIsValid)(void* ctxt, BNBinaryView* view, uint64_t addr);
@@ -2056,9 +2067,11 @@ extern "C"
bool (*lowLevelILFunctionIsValid)(void* ctxt, BNBinaryView* view, BNLowLevelILFunction* func);
bool (*lowLevelILInstructionIsValid)(void* ctxt, BNBinaryView* view, BNLowLevelILFunction* func, size_t instr);
bool (*mediumLevelILFunctionIsValid)(void* ctxt, BNBinaryView* view, BNMediumLevelILFunction* func);
- bool (*mediumLevelILInstructionIsValid)(void* ctxt, BNBinaryView* view, BNMediumLevelILFunction* func, size_t instr);
+ bool (*mediumLevelILInstructionIsValid)(
+ void* ctxt, BNBinaryView* view, BNMediumLevelILFunction* func, size_t instr);
bool (*highLevelILFunctionIsValid)(void* ctxt, BNBinaryView* view, BNHighLevelILFunction* func);
- bool (*highLevelILInstructionIsValid)(void* ctxt, BNBinaryView* view, BNHighLevelILFunction* func, size_t instr);
+ bool (*highLevelILInstructionIsValid)(
+ void* ctxt, BNBinaryView* view, BNHighLevelILFunction* func, size_t instr);
};
struct BNCustomCallingConvention
@@ -2087,10 +2100,10 @@ extern "C"
void (*getIncomingRegisterValue)(void* ctxt, uint32_t reg, BNFunction* func, BNRegisterValue* result);
void (*getIncomingFlagValue)(void* ctxt, uint32_t flag, BNFunction* func, BNRegisterValue* result);
- void (*getIncomingVariableForParameterVariable)(void* ctxt, const BNVariable* var,
- BNFunction* func, BNVariable* result);
- void (*getParameterVariableForIncomingVariable)(void* ctxt, const BNVariable* var,
- BNFunction* func, BNVariable* result);
+ void (*getIncomingVariableForParameterVariable)(
+ void* ctxt, const BNVariable* var, BNFunction* func, BNVariable* result);
+ void (*getParameterVariableForIncomingVariable)(
+ void* ctxt, const BNVariable* var, BNFunction* func, BNVariable* result);
bool (*areArgumentRegistersUsedForVarArgs)(void* ctxt);
};
@@ -2231,7 +2244,8 @@ extern "C"
void* context;
void (*destroyInstance)(void* ctxt);
int (*performRequest)(void* ctxt, const char* url);
- int (*performCustomRequest)(void* ctxt, const char* method, const char* url, uint64_t headerCount, const char* const* headerKeys, const char* const* headerValues, BNDownloadInstanceResponse** response);
+ int (*performCustomRequest)(void* ctxt, const char* method, const char* url, uint64_t headerCount,
+ const char* const* headerKeys, const char* const* headerValues, BNDownloadInstanceResponse** response);
void (*freeResponse)(void* ctxt, BNDownloadInstanceResponse* response);
};
@@ -2254,7 +2268,8 @@ extern "C"
{
void* context;
void (*destroyClient)(void* ctxt);
- bool (*connect)(void* ctxt, const char* host, uint64_t headerCount, const char* const* headerKeys, const char* const* headerValues);
+ bool (*connect)(void* ctxt, const char* host, uint64_t headerCount, const char* const* headerKeys,
+ const char* const* headerValues);
bool (*write)(const uint8_t* data, uint64_t len, void* ctxt);
bool (*disconnect)(void* ctxt);
};
@@ -2403,12 +2418,12 @@ extern "C"
{
BNFormInputFieldType type;
const char* prompt;
- BNBinaryView* view; // For AddressFormField
- uint64_t currentAddress; // For AddressFormField
- const char** choices; // For ChoiceFormField
- size_t count; // For ChoiceFormField
- const char* ext; // For OpenFileNameFormField, SaveFileNameFormField
- const char* defaultName; // For SaveFileNameFormField
+ BNBinaryView* view; // For AddressFormField
+ uint64_t currentAddress; // For AddressFormField
+ const char** choices; // For ChoiceFormField
+ size_t count; // For ChoiceFormField
+ const char* ext; // For OpenFileNameFormField, SaveFileNameFormField
+ const char* defaultName; // For SaveFileNameFormField
int64_t intResult;
uint64_t addressResult;
char* stringResult;
@@ -2424,25 +2439,25 @@ extern "C"
{
void* context;
void (*showPlainTextReport)(void* ctxt, BNBinaryView* view, const char* title, const char* contents);
- void (*showMarkdownReport)(void* ctxt, BNBinaryView* view, const char* title, const char* contents,
- const char* plaintext);
- void (*showHTMLReport)(void* ctxt, BNBinaryView* view, const char* title, const char* contents,
- const char* plaintext);
+ void (*showMarkdownReport)(
+ void* ctxt, BNBinaryView* view, const char* title, const char* contents, const char* plaintext);
+ void (*showHTMLReport)(
+ void* ctxt, BNBinaryView* view, const char* title, const char* contents, const char* plaintext);
void (*showGraphReport)(void* ctxt, BNBinaryView* view, const char* title, BNFlowGraph* graph);
void (*showReportCollection)(void* ctxt, const char* title, BNReportCollection* reports);
bool (*getTextLineInput)(void* ctxt, char** result, const char* prompt, const char* title);
bool (*getIntegerInput)(void* ctxt, int64_t* result, const char* prompt, const char* title);
- bool (*getAddressInput)(void* ctxt, uint64_t* result, const char* prompt, const char* title,
- BNBinaryView* view, uint64_t currentAddr);
- bool (*getChoiceInput)(void* ctxt, size_t* result, const char* prompt, const char* title,
- const char** choices, size_t count);
+ bool (*getAddressInput)(void* ctxt, uint64_t* result, const char* prompt, const char* title, BNBinaryView* view,
+ uint64_t currentAddr);
+ bool (*getChoiceInput)(
+ void* ctxt, size_t* result, const char* prompt, const char* title, const char** choices, size_t count);
bool (*getOpenFileNameInput)(void* ctxt, char** result, const char* prompt, const char* ext);
- bool (*getSaveFileNameInput)(void* ctxt, char** result, const char* prompt, const char* ext,
- const char* defaultName);
+ bool (*getSaveFileNameInput)(
+ void* ctxt, char** result, const char* prompt, const char* ext, const char* defaultName);
bool (*getDirectoryNameInput)(void* ctxt, char** result, const char* prompt, const char* defaultName);
bool (*getFormInput)(void* ctxt, BNFormInputField* fields, size_t count, const char* title);
- BNMessageBoxButtonResult (*showMessageBox)(void* ctxt, const char* title, const char* text,
- BNMessageBoxButtonSet buttons, BNMessageBoxIcon icon);
+ BNMessageBoxButtonResult (*showMessageBox)(
+ void* ctxt, const char* title, const char* text, BNMessageBoxButtonSet buttons, BNMessageBoxIcon icon);
bool (*openUrl)(void* ctxt, const char* url);
};
@@ -2467,11 +2482,11 @@ extern "C"
{
void* context;
void (*freeObject)(void* ctxt);
- bool (*isValidForData)(void* ctxt, BNBinaryView* view, uint64_t addr, BNType* type, BNTypeContext* typeCtx,
- size_t ctxCount);
+ bool (*isValidForData)(
+ void* ctxt, BNBinaryView* view, uint64_t addr, BNType* type, BNTypeContext* typeCtx, size_t ctxCount);
BNDisassemblyTextLine* (*getLinesForData)(void* ctxt, BNBinaryView* view, uint64_t addr, BNType* type,
- const BNInstructionTextToken* prefix, size_t prefixCount, size_t width, size_t* count, BNTypeContext* typeCtx,
- size_t ctxCount);
+ const BNInstructionTextToken* prefix, size_t prefixCount, size_t width, size_t* count,
+ BNTypeContext* typeCtx, size_t ctxCount);
};
enum BNSegmentFlag
@@ -2688,7 +2703,8 @@ extern "C"
BINARYNINJACOREAPI bool BNIsUIEnabled(void);
BINARYNINJACOREAPI void BNSetLicense(const char* licenseData);
- BINARYNINJACOREAPI bool BNAuthenticateEnterpriseServerWithCredentials(const char* username, const char* password, bool remember);
+ BINARYNINJACOREAPI bool BNAuthenticateEnterpriseServerWithCredentials(
+ const char* username, const char* password, bool remember);
BINARYNINJACOREAPI bool BNAuthenticateEnterpriseServerWithMethod(const char* method, bool remember);
BINARYNINJACOREAPI size_t BNGetEnterpriseServerAuthenticationMethods(char*** methods, char*** names);
BINARYNINJACOREAPI bool BNDeauthenticateEnterpriseServer(void);
@@ -2720,10 +2736,10 @@ extern "C"
// Plugin initialization
BINARYNINJACOREAPI bool BNInitPlugins(bool allowUserPlugins);
- BINARYNINJACOREAPI bool BNInitCorePlugins(void); // Deprecated, use BNInitPlugins
+ BINARYNINJACOREAPI bool BNInitCorePlugins(void); // Deprecated, use BNInitPlugins
BINARYNINJACOREAPI void BNDisablePlugins(void);
BINARYNINJACOREAPI bool BNIsPluginsEnabled(void);
- BINARYNINJACOREAPI void BNInitUserPlugins(void); // Deprecated, use BNInitPlugins
+ BINARYNINJACOREAPI void BNInitUserPlugins(void); // Deprecated, use BNInitPlugins
BINARYNINJACOREAPI void BNInitRepoPlugins(void);
BINARYNINJACOREAPI char* BNGetInstallDirectory(void);
@@ -2739,9 +2755,8 @@ extern "C"
BINARYNINJACOREAPI char* BNGetPathRelativeToUserPluginDirectory(const char* path);
BINARYNINJACOREAPI char* BNGetPathRelativeToUserDirectory(const char* path);
- BINARYNINJACOREAPI bool BNExecuteWorkerProcess(const char* path, const char* args[],
- BNDataBuffer* input, char** output, char** error,
- bool stdoutIsText, bool stderrIsText);
+ BINARYNINJACOREAPI bool BNExecuteWorkerProcess(const char* path, const char* args[], BNDataBuffer* input,
+ char** output, char** error, bool stdoutIsText, bool stderrIsText);
BINARYNINJACOREAPI void BNSetCurrentPluginLoadOrder(BNPluginLoadOrder order);
BINARYNINJACOREAPI void BNAddRequiredPluginDependency(const char* name);
@@ -2749,34 +2764,40 @@ extern "C"
// Logging
#ifdef __GNUC__
-__attribute__ ((format (printf, 2, 3)))
+ __attribute__((format(printf, 2, 3)))
#endif
- BINARYNINJACOREAPI void BNLog(BNLogLevel level, const char* fmt, ...);
+ BINARYNINJACOREAPI void
+ BNLog(BNLogLevel level, const char* fmt, ...);
#ifdef __GNUC__
-__attribute__ ((format (printf, 1, 2)))
+ __attribute__((format(printf, 1, 2)))
#endif
- BINARYNINJACOREAPI void BNLogDebug(const char* fmt, ...);
+ BINARYNINJACOREAPI void
+ BNLogDebug(const char* fmt, ...);
#ifdef __GNUC__
-__attribute__ ((format (printf, 1, 2)))
+ __attribute__((format(printf, 1, 2)))
#endif
- BINARYNINJACOREAPI void BNLogInfo(const char* fmt, ...);
+ BINARYNINJACOREAPI void
+ BNLogInfo(const char* fmt, ...);
#ifdef __GNUC__
-__attribute__ ((format (printf, 1, 2)))
+ __attribute__((format(printf, 1, 2)))
#endif
- BINARYNINJACOREAPI void BNLogWarn(const char* fmt, ...);
+ BINARYNINJACOREAPI void
+ BNLogWarn(const char* fmt, ...);
#ifdef __GNUC__
-__attribute__ ((format (printf, 1, 2)))
+ __attribute__((format(printf, 1, 2)))
#endif
- BINARYNINJACOREAPI void BNLogError(const char* fmt, ...);
+ BINARYNINJACOREAPI void
+ BNLogError(const char* fmt, ...);
#ifdef __GNUC__
-__attribute__ ((format (printf, 1, 2)))
+ __attribute__((format(printf, 1, 2)))
#endif
- BINARYNINJACOREAPI void BNLogAlert(const char* fmt, ...);
+ BINARYNINJACOREAPI void
+ BNLogAlert(const char* fmt, ...);
BINARYNINJACOREAPI void BNLogString(BNLogLevel level, const char* str);
@@ -2829,10 +2850,8 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI BNSaveSettings* BNNewSaveSettingsReference(BNSaveSettings* settings);
BINARYNINJACOREAPI void BNFreeSaveSettings(BNSaveSettings* settings);
- BINARYNINJACOREAPI bool BNIsSaveSettingsOptionSet(BNSaveSettings* settings,
- BNSaveOption option);
- BINARYNINJACOREAPI void BNSetSaveSettingsOption(BNSaveSettings* settings,
- BNSaveOption option, bool state);
+ BINARYNINJACOREAPI bool BNIsSaveSettingsOptionSet(BNSaveSettings* settings, BNSaveOption option);
+ BINARYNINJACOREAPI void BNSetSaveSettingsOption(BNSaveSettings* settings, BNSaveOption option, bool state);
// File metadata object
BINARYNINJACOREAPI BNFileMetadata* BNCreateFileMetadata(void);
@@ -2848,17 +2867,20 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI bool BNIsBackedByDatabase(BNFileMetadata* file, const char* binaryViewType);
BINARYNINJACOREAPI bool BNCreateDatabase(BNBinaryView* data, const char* path, BNSaveSettings* settings);
- BINARYNINJACOREAPI bool BNCreateDatabaseWithProgress(BNBinaryView* data, const char* path,
- void* ctxt, bool (*progress)(void* ctxt, size_t progress, size_t total), BNSaveSettings* settings);
+ BINARYNINJACOREAPI bool BNCreateDatabaseWithProgress(BNBinaryView* data, const char* path, void* ctxt,
+ bool (*progress)(void* ctxt, size_t progress, size_t total), BNSaveSettings* settings);
BINARYNINJACOREAPI BNBinaryView* BNOpenExistingDatabase(BNFileMetadata* file, const char* path);
BINARYNINJACOREAPI BNBinaryView* BNOpenExistingDatabaseWithProgress(BNFileMetadata* file, const char* path,
- void* ctxt, bool (*progress)(void* ctxt, size_t progress, size_t total));
+ void* ctxt, bool (*progress)(void* ctxt, size_t progress, size_t total));
BINARYNINJACOREAPI BNBinaryView* BNOpenDatabaseForConfiguration(BNFileMetadata* file, const char* path);
BINARYNINJACOREAPI bool BNSaveAutoSnapshot(BNBinaryView* data, BNSaveSettings* settings);
BINARYNINJACOREAPI bool BNSaveAutoSnapshotWithProgress(BNBinaryView* data, void* ctxt,
- bool (*progress)(void* ctxt, size_t progress, size_t total), BNSaveSettings* settings);
- BINARYNINJACOREAPI void BNGetSnapshotData(BNFileMetadata* file, BNKeyValueStore* data, BNKeyValueStore* cache, void* ctxt, bool (*progress)(void* ctxt, size_t current, size_t total));
- BINARYNINJACOREAPI void BNApplySnapshotData(BNFileMetadata* file, BNBinaryView* view, BNKeyValueStore* data, BNKeyValueStore* cache, void* ctxt, bool (*progress)(void* ctxt, size_t current, size_t total), bool openForConfiguration, bool restoreRawView);
+ bool (*progress)(void* ctxt, size_t progress, size_t total), BNSaveSettings* settings);
+ BINARYNINJACOREAPI void BNGetSnapshotData(BNFileMetadata* file, BNKeyValueStore* data, BNKeyValueStore* cache,
+ void* ctxt, bool (*progress)(void* ctxt, size_t current, size_t total));
+ BINARYNINJACOREAPI void BNApplySnapshotData(BNFileMetadata* file, BNBinaryView* view, BNKeyValueStore* data,
+ BNKeyValueStore* cache, void* ctxt, bool (*progress)(void* ctxt, size_t current, size_t total),
+ bool openForConfiguration, bool restoreRawView);
BINARYNINJACOREAPI BNDatabase* BNGetFileMetadataDatabase(BNFileMetadata* file);
// Key value store
@@ -2872,7 +2894,8 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI char* BNGetKeyValueStoreValue(BNKeyValueStore* store, const char* name);
BINARYNINJACOREAPI BNDataBuffer* BNGetKeyValueStoreBuffer(BNKeyValueStore* store, const char* name);
BINARYNINJACOREAPI bool BNSetKeyValueStoreValue(BNKeyValueStore* store, const char* name, const char* value);
- BINARYNINJACOREAPI bool BNSetKeyValueStoreBuffer(BNKeyValueStore* store, const char* name, const BNDataBuffer* value);
+ BINARYNINJACOREAPI bool BNSetKeyValueStoreBuffer(
+ BNKeyValueStore* store, const char* name, const BNDataBuffer* value);
BINARYNINJACOREAPI BNDataBuffer* BNGetKeyValueStoreSerializedData(BNKeyValueStore* store);
BINARYNINJACOREAPI void BNBeginKeyValueStoreNamespace(BNKeyValueStore* store, const char* name);
BINARYNINJACOREAPI void BNEndKeyValueStoreNamespace(BNKeyValueStore* store);
@@ -2889,7 +2912,9 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI BNSnapshot* BNGetDatabaseCurrentSnapshot(BNDatabase* database);
BINARYNINJACOREAPI BNSnapshot** BNGetDatabaseSnapshots(BNDatabase* database, size_t* count);
BINARYNINJACOREAPI BNSnapshot* BNGetDatabaseSnapshot(BNDatabase* database, int64_t id);
- BINARYNINJACOREAPI int64_t BNWriteDatabaseSnapshotData(BNDatabase* database, int64_t* parents, size_t parentCount, BNBinaryView* file, const char* name, BNKeyValueStore* data, bool autoSave, void* ctxt, bool(*progress)(void*, size_t, size_t));
+ BINARYNINJACOREAPI int64_t BNWriteDatabaseSnapshotData(BNDatabase* database, int64_t* parents, size_t parentCount,
+ BNBinaryView* file, const char* name, BNKeyValueStore* data, bool autoSave, void* ctxt,
+ bool (*progress)(void*, size_t, size_t));
BINARYNINJACOREAPI bool BNRemoveDatabaseSnapshot(BNDatabase* database, int64_t id);
BINARYNINJACOREAPI char** BNGetDatabaseGlobalKeys(BNDatabase* database, size_t* count);
BINARYNINJACOREAPI int BNDatabaseHasGlobal(BNDatabase* database, const char* key);
@@ -2917,17 +2942,20 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI BNDataBuffer* BNGetSnapshotFileContents(BNSnapshot* snapshot);
BINARYNINJACOREAPI BNDataBuffer* BNGetSnapshotFileContentsHash(BNSnapshot* snapshot);
BINARYNINJACOREAPI BNKeyValueStore* BNReadSnapshotData(BNSnapshot* snapshot);
- BINARYNINJACOREAPI BNKeyValueStore* BNReadSnapshotDataWithProgress(BNSnapshot* snapshot, void* ctxt, bool (*progress)(void* ctxt, size_t progress, size_t total));
+ BINARYNINJACOREAPI BNKeyValueStore* BNReadSnapshotDataWithProgress(
+ BNSnapshot* snapshot, void* ctxt, bool (*progress)(void* ctxt, size_t progress, size_t total));
BINARYNINJACOREAPI BNUndoEntry* BNGetSnapshotUndoEntries(BNSnapshot* snapshot, size_t* count);
- BINARYNINJACOREAPI BNUndoEntry* BNGetSnapshotUndoEntriesWithProgress(BNSnapshot* snapshot, void* ctxt, bool (*progress)(void* ctxt, size_t progress, size_t total), size_t* count);
+ BINARYNINJACOREAPI BNUndoEntry* BNGetSnapshotUndoEntriesWithProgress(
+ BNSnapshot* snapshot, void* ctxt, bool (*progress)(void* ctxt, size_t progress, size_t total), size_t* count);
BINARYNINJACOREAPI bool BNSnapshotHasAncestor(BNSnapshot* snapshot, BNSnapshot* other);
BINARYNINJACOREAPI bool BNRebase(BNBinaryView* data, uint64_t address);
- BINARYNINJACOREAPI bool BNRebaseWithProgress(BNBinaryView* data, uint64_t address, void* ctxt, bool (*progress)(void* ctxt, size_t progress, size_t total));
+ BINARYNINJACOREAPI bool BNRebaseWithProgress(
+ BNBinaryView* data, uint64_t address, void* ctxt, bool (*progress)(void* ctxt, size_t progress, size_t total));
- BINARYNINJACOREAPI BNMergeResult BNMergeUserAnalysis(BNFileMetadata* file, const char* name, void* ctxt, bool (*progress)(void* ctxt, size_t progress, size_t total),
- char** excludedHashes, size_t excludedHashesCount);
+ BINARYNINJACOREAPI BNMergeResult BNMergeUserAnalysis(BNFileMetadata* file, const char* name, void* ctxt,
+ bool (*progress)(void* ctxt, size_t progress, size_t total), char** excludedHashes, size_t excludedHashesCount);
BINARYNINJACOREAPI char* BNGetOriginalFilename(BNFileMetadata* file);
BINARYNINJACOREAPI void BNSetOriginalFilename(BNFileMetadata* file, const char* name);
@@ -2988,10 +3016,12 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI void BNNotifyDataInserted(BNBinaryView* view, uint64_t offset, size_t len);
BINARYNINJACOREAPI void BNNotifyDataRemoved(BNBinaryView* view, uint64_t offset, uint64_t len);
- BINARYNINJACOREAPI size_t BNGetEntropy(BNBinaryView* view, uint64_t offset, size_t len, size_t blockSize, float* result);
+ BINARYNINJACOREAPI size_t BNGetEntropy(
+ BNBinaryView* view, uint64_t offset, size_t len, size_t blockSize, float* result);
BINARYNINJACOREAPI BNModificationStatus BNGetModification(BNBinaryView* view, uint64_t offset);
- BINARYNINJACOREAPI size_t BNGetModificationArray(BNBinaryView* view, uint64_t offset, BNModificationStatus* result, size_t len);
+ BINARYNINJACOREAPI size_t BNGetModificationArray(
+ BNBinaryView* view, uint64_t offset, BNModificationStatus* result, size_t len);
BINARYNINJACOREAPI bool BNIsValidOffset(BNBinaryView* view, uint64_t offset);
BINARYNINJACOREAPI bool BNIsOffsetReadable(BNBinaryView* view, uint64_t offset);
@@ -3020,10 +3050,10 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI bool BNSaveToFile(BNBinaryView* view, BNFileAccessor* file);
BINARYNINJACOREAPI bool BNSaveToFilename(BNBinaryView* view, const char* filename);
- BINARYNINJACOREAPI void BNDefineRelocation(BNBinaryView* view, BNArchitecture* arch, BNRelocationInfo* info,
- uint64_t target, uint64_t reloc);
- BINARYNINJACOREAPI void BNDefineSymbolRelocation(BNBinaryView* view, BNArchitecture* arch, BNRelocationInfo* info,
- BNSymbol* target, uint64_t reloc);
+ BINARYNINJACOREAPI void BNDefineRelocation(
+ BNBinaryView* view, BNArchitecture* arch, BNRelocationInfo* info, uint64_t target, uint64_t reloc);
+ BINARYNINJACOREAPI void BNDefineSymbolRelocation(
+ BNBinaryView* view, BNArchitecture* arch, BNRelocationInfo* info, BNSymbol* target, uint64_t reloc);
BINARYNINJACOREAPI BNRange* BNGetRelocationRanges(BNBinaryView* view, size_t* count);
BINARYNINJACOREAPI BNRange* BNGetRelocationRangesAtAddress(BNBinaryView* view, uint64_t addr, size_t* count);
BINARYNINJACOREAPI bool BNRangeContainsRelocation(BNBinaryView* view, uint64_t addr, size_t size);
@@ -3036,63 +3066,53 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI bool BNIsNeverBranchPatchAvailable(BNBinaryView* view, BNArchitecture* arch, uint64_t addr);
BINARYNINJACOREAPI bool BNIsAlwaysBranchPatchAvailable(BNBinaryView* view, BNArchitecture* arch, uint64_t addr);
BINARYNINJACOREAPI bool BNIsInvertBranchPatchAvailable(BNBinaryView* view, BNArchitecture* arch, uint64_t addr);
- BINARYNINJACOREAPI bool BNIsSkipAndReturnZeroPatchAvailable(BNBinaryView* view, BNArchitecture* arch, uint64_t addr);
- BINARYNINJACOREAPI bool BNIsSkipAndReturnValuePatchAvailable(BNBinaryView* view, BNArchitecture* arch, uint64_t addr);
+ BINARYNINJACOREAPI bool BNIsSkipAndReturnZeroPatchAvailable(
+ BNBinaryView* view, BNArchitecture* arch, uint64_t addr);
+ BINARYNINJACOREAPI bool BNIsSkipAndReturnValuePatchAvailable(
+ BNBinaryView* view, BNArchitecture* arch, uint64_t addr);
BINARYNINJACOREAPI bool BNConvertToNop(BNBinaryView* view, BNArchitecture* arch, uint64_t addr);
BINARYNINJACOREAPI bool BNAlwaysBranch(BNBinaryView* view, BNArchitecture* arch, uint64_t addr);
BINARYNINJACOREAPI bool BNInvertBranch(BNBinaryView* view, BNArchitecture* arch, uint64_t addr);
- BINARYNINJACOREAPI bool BNSkipAndReturnValue(BNBinaryView* view, BNArchitecture* arch, uint64_t addr, uint64_t value);
+ BINARYNINJACOREAPI bool BNSkipAndReturnValue(
+ BNBinaryView* view, BNArchitecture* arch, uint64_t addr, uint64_t value);
BINARYNINJACOREAPI size_t BNGetInstructionLength(BNBinaryView* view, BNArchitecture* arch, uint64_t addr);
- BINARYNINJACOREAPI bool BNFindNextData(BNBinaryView* view, uint64_t start,
- BNDataBuffer* data, uint64_t* result, BNFindFlag flags);
- BINARYNINJACOREAPI bool BNFindNextText(BNBinaryView* view, uint64_t start, const char* data,
- uint64_t* result, BNDisassemblySettings* settings, BNFindFlag flags,
- BNFunctionGraphType graph);
- BINARYNINJACOREAPI bool BNFindNextConstant(BNBinaryView* view, uint64_t start,
- uint64_t constant, uint64_t* result, BNDisassemblySettings* settings,
- BNFunctionGraphType graph);
+ BINARYNINJACOREAPI bool BNFindNextData(
+ BNBinaryView* view, uint64_t start, BNDataBuffer* data, uint64_t* result, BNFindFlag flags);
+ BINARYNINJACOREAPI bool BNFindNextText(BNBinaryView* view, uint64_t start, const char* data, uint64_t* result,
+ BNDisassemblySettings* settings, BNFindFlag flags, BNFunctionGraphType graph);
+ BINARYNINJACOREAPI bool BNFindNextConstant(BNBinaryView* view, uint64_t start, uint64_t constant, uint64_t* result,
+ BNDisassemblySettings* settings, BNFunctionGraphType graph);
- BINARYNINJACOREAPI bool BNFindNextDataWithProgress(BNBinaryView* view, uint64_t start,
- uint64_t end, BNDataBuffer* data, uint64_t* result, BNFindFlag flags,
- void* ctxt, bool (*progress)(void* ctxt, size_t current, size_t total));
- BINARYNINJACOREAPI bool BNFindNextTextWithProgress(BNBinaryView* view, uint64_t start,
- uint64_t end, const char* data, uint64_t* result, BNDisassemblySettings* settings,
- BNFindFlag flags, BNFunctionGraphType graph, void* ctxt,
- bool (*progress)(void* ctxt, size_t current, size_t total));
- BINARYNINJACOREAPI bool BNFindNextConstantWithProgress(BNBinaryView* view, uint64_t start,
- uint64_t end, uint64_t constant, uint64_t* result, BNDisassemblySettings* settings,
- BNFunctionGraphType graph, void* ctxt,
- bool (*progress)(void* ctxt, size_t current, size_t total));
+ BINARYNINJACOREAPI bool BNFindNextDataWithProgress(BNBinaryView* view, uint64_t start, uint64_t end,
+ BNDataBuffer* data, uint64_t* result, BNFindFlag flags, void* ctxt,
+ bool (*progress)(void* ctxt, size_t current, size_t total));
+ BINARYNINJACOREAPI bool BNFindNextTextWithProgress(BNBinaryView* view, uint64_t start, uint64_t end,
+ const char* data, uint64_t* result, BNDisassemblySettings* settings, BNFindFlag flags,
+ BNFunctionGraphType graph, void* ctxt, bool (*progress)(void* ctxt, size_t current, size_t total));
+ BINARYNINJACOREAPI bool BNFindNextConstantWithProgress(BNBinaryView* view, uint64_t start, uint64_t end,
+ uint64_t constant, uint64_t* result, BNDisassemblySettings* settings, BNFunctionGraphType graph, void* ctxt,
+ bool (*progress)(void* ctxt, size_t current, size_t total));
- BINARYNINJACOREAPI bool BNFindAllDataWithProgress(BNBinaryView* view, uint64_t start,
- uint64_t end, BNDataBuffer* data, BNFindFlag flags,
- void* ctxt, bool (*progress)(void* ctxt, size_t current, size_t total),
- void* matchCtxt,
- bool (*matchCallback)(void* matchCtxt, uint64_t addr, BNDataBuffer* match));
- BINARYNINJACOREAPI bool BNFindAllTextWithProgress(BNBinaryView* view, uint64_t start,
- uint64_t end, const char* data, BNDisassemblySettings* settings, BNFindFlag flags,
- BNFunctionGraphType graph, void* ctxt,
- bool (*progress)(void* ctxt, size_t current, size_t total),
- void* matchCtxt,
- bool (*matchCallback)(void* matchCtxt, uint64_t addr, const char* match,
- BNLinearDisassemblyLine* line));
- BINARYNINJACOREAPI bool BNFindAllConstantWithProgress(BNBinaryView* view, uint64_t start,
- uint64_t end, uint64_t constant, BNDisassemblySettings* settings,
- BNFunctionGraphType graph,
- void* ctxt,
- bool (*progress)(void* ctxt, size_t current, size_t total),
- void* matchCtxt,
- bool (*matchCallback)(void* matchCtxt, uint64_t addr,
- BNLinearDisassemblyLine* line));
+ BINARYNINJACOREAPI bool BNFindAllDataWithProgress(BNBinaryView* view, uint64_t start, uint64_t end,
+ BNDataBuffer* data, BNFindFlag flags, void* ctxt, bool (*progress)(void* ctxt, size_t current, size_t total),
+ void* matchCtxt, bool (*matchCallback)(void* matchCtxt, uint64_t addr, BNDataBuffer* match));
+ BINARYNINJACOREAPI bool BNFindAllTextWithProgress(BNBinaryView* view, uint64_t start, uint64_t end,
+ const char* data, BNDisassemblySettings* settings, BNFindFlag flags, BNFunctionGraphType graph, void* ctxt,
+ bool (*progress)(void* ctxt, size_t current, size_t total), void* matchCtxt,
+ bool (*matchCallback)(void* matchCtxt, uint64_t addr, const char* match, BNLinearDisassemblyLine* line));
+ BINARYNINJACOREAPI bool BNFindAllConstantWithProgress(BNBinaryView* view, uint64_t start, uint64_t end,
+ uint64_t constant, BNDisassemblySettings* settings, BNFunctionGraphType graph, void* ctxt,
+ bool (*progress)(void* ctxt, size_t current, size_t total), void* matchCtxt,
+ bool (*matchCallback)(void* matchCtxt, uint64_t addr, BNLinearDisassemblyLine* line));
- BINARYNINJACOREAPI void BNAddAutoSegment(BNBinaryView* view, uint64_t start, uint64_t length,
- uint64_t dataOffset, uint64_t dataLength, uint32_t flags);
+ BINARYNINJACOREAPI void BNAddAutoSegment(
+ BNBinaryView* view, uint64_t start, uint64_t length, uint64_t dataOffset, uint64_t dataLength, uint32_t flags);
BINARYNINJACOREAPI void BNRemoveAutoSegment(BNBinaryView* view, uint64_t start, uint64_t length);
- BINARYNINJACOREAPI void BNAddUserSegment(BNBinaryView* view, uint64_t start, uint64_t length,
- uint64_t dataOffset, uint64_t dataLength, uint32_t flags);
+ BINARYNINJACOREAPI void BNAddUserSegment(
+ BNBinaryView* view, uint64_t start, uint64_t length, uint64_t dataOffset, uint64_t dataLength, uint32_t flags);
BINARYNINJACOREAPI void BNRemoveUserSegment(BNBinaryView* view, uint64_t start, uint64_t length);
BINARYNINJACOREAPI BNSegment** BNGetSegments(BNBinaryView* view, size_t* count);
BINARYNINJACOREAPI void BNFreeSegmentList(BNSegment** segments, size_t count);
@@ -3100,12 +3120,12 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI bool BNGetAddressForDataOffset(BNBinaryView* view, uint64_t offset, uint64_t* addr);
BINARYNINJACOREAPI void BNAddAutoSection(BNBinaryView* view, const char* name, uint64_t start, uint64_t length,
- BNSectionSemantics semantics, const char* type, uint64_t align, uint64_t entrySize,
- const char* linkedSection, const char* infoSection, uint64_t infoData);
+ BNSectionSemantics semantics, const char* type, uint64_t align, uint64_t entrySize, const char* linkedSection,
+ const char* infoSection, uint64_t infoData);
BINARYNINJACOREAPI void BNRemoveAutoSection(BNBinaryView* view, const char* name);
BINARYNINJACOREAPI void BNAddUserSection(BNBinaryView* view, const char* name, uint64_t start, uint64_t length,
- BNSectionSemantics semantics, const char* type, uint64_t align, uint64_t entrySize,
- const char* linkedSection, const char* infoSection, uint64_t infoData);
+ BNSectionSemantics semantics, const char* type, uint64_t align, uint64_t entrySize, const char* linkedSection,
+ const char* infoSection, uint64_t infoData);
BINARYNINJACOREAPI void BNRemoveUserSection(BNBinaryView* view, const char* name);
BINARYNINJACOREAPI BNSection** BNGetSections(BNBinaryView* view, size_t* count);
BINARYNINJACOREAPI BNSection** BNGetSectionsAt(BNBinaryView* view, uint64_t addr, size_t* count);
@@ -3133,7 +3153,8 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI BNBinaryView* BNCreateBinaryDataViewFromFile(BNFileMetadata* file, BNFileAccessor* accessor);
// Creation of new types of binary views
- BINARYNINJACOREAPI BNBinaryView* BNCreateCustomBinaryView(const char* name, BNFileMetadata* file, BNBinaryView* parent, BNCustomBinaryView* view);
+ BINARYNINJACOREAPI BNBinaryView* BNCreateCustomBinaryView(
+ const char* name, BNFileMetadata* file, BNBinaryView* parent, BNCustomBinaryView* view);
BINARYNINJACOREAPI BNBinaryViewType* BNGetBinaryViewTypeByName(const char* name);
BINARYNINJACOREAPI BNBinaryViewType** BNGetBinaryViewTypes(size_t* count);
@@ -3145,24 +3166,25 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI BNBinaryView* BNCreateBinaryViewOfType(BNBinaryViewType* type, BNBinaryView* data);
BINARYNINJACOREAPI BNBinaryView* BNParseBinaryViewOfType(BNBinaryViewType* type, BNBinaryView* data);
BINARYNINJACOREAPI bool BNIsBinaryViewTypeValidForData(BNBinaryViewType* type, BNBinaryView* data);
- BINARYNINJACOREAPI BNSettings* BNGetBinaryViewDefaultLoadSettingsForData(BNBinaryViewType* type, BNBinaryView* data);
+ BINARYNINJACOREAPI BNSettings* BNGetBinaryViewDefaultLoadSettingsForData(
+ BNBinaryViewType* type, BNBinaryView* data);
BINARYNINJACOREAPI BNSettings* BNGetBinaryViewLoadSettingsForData(BNBinaryViewType* type, BNBinaryView* data);
- BINARYNINJACOREAPI BNBinaryViewType* BNRegisterBinaryViewType(const char* name, const char* longName,
- BNCustomBinaryViewType* type);
+ BINARYNINJACOREAPI BNBinaryViewType* BNRegisterBinaryViewType(
+ const char* name, const char* longName, BNCustomBinaryViewType* type);
- BINARYNINJACOREAPI void BNRegisterArchitectureForViewType(BNBinaryViewType* type, uint32_t id,
- BNEndianness endian, BNArchitecture* arch); // Deprecated, use BNRegisterPlatformRecognizerForViewType
+ BINARYNINJACOREAPI void BNRegisterArchitectureForViewType(BNBinaryViewType* type, uint32_t id, BNEndianness endian,
+ BNArchitecture* arch); // Deprecated, use BNRegisterPlatformRecognizerForViewType
BINARYNINJACOREAPI BNArchitecture* BNGetArchitectureForViewType(BNBinaryViewType* type, uint32_t id,
- BNEndianness endian); // Deprecated, use BNRecognizePlatformForViewType
+ BNEndianness endian); // Deprecated, use BNRecognizePlatformForViewType
- BINARYNINJACOREAPI void BNRegisterPlatformForViewType(BNBinaryViewType* type, uint32_t id,
- BNArchitecture* arch, BNPlatform* platform); // Deprecated, use BNRegisterPlatformRecognizerForViewType
- BINARYNINJACOREAPI BNPlatform* BNGetPlatformForViewType(BNBinaryViewType* type,
- uint32_t id, BNArchitecture* arch); // Deprecated, use BNRecognizePlatformForViewType
+ BINARYNINJACOREAPI void BNRegisterPlatformForViewType(BNBinaryViewType* type, uint32_t id, BNArchitecture* arch,
+ BNPlatform* platform); // Deprecated, use BNRegisterPlatformRecognizerForViewType
+ BINARYNINJACOREAPI BNPlatform* BNGetPlatformForViewType(
+ BNBinaryViewType* type, uint32_t id, BNArchitecture* arch); // Deprecated, use BNRecognizePlatformForViewType
- BINARYNINJACOREAPI void BNRegisterDefaultPlatformForViewType(BNBinaryViewType* type, BNArchitecture* arch,
- BNPlatform* platform);
+ BINARYNINJACOREAPI void BNRegisterDefaultPlatformForViewType(
+ BNBinaryViewType* type, BNArchitecture* arch, BNPlatform* platform);
// Expanded identification of Platform for BinaryViewTypes. Supersedes BNRegisterArchitectureForViewType
// and BNRegisterPlatformForViewType, as these have certain edge cases (overloaded elf families, for example)
@@ -3182,21 +3204,22 @@ __attribute__ ((format (printf, 1, 2)))
// are invoked.
//
// Support for this API tentatively requires explicit support in the BinaryView implementation.
- BINARYNINJACOREAPI void BNRegisterPlatformRecognizerForViewType(BNBinaryViewType* type, uint64_t id, BNEndianness endian,
- BNPlatform* (*callback)(void* ctx, BNBinaryView* view, BNMetadata* metadata), void* ctx);
+ BINARYNINJACOREAPI void BNRegisterPlatformRecognizerForViewType(BNBinaryViewType* type, uint64_t id,
+ BNEndianness endian, BNPlatform* (*callback)(void* ctx, BNBinaryView* view, BNMetadata* metadata), void* ctx);
- // BinaryView* passed in here should be the parent view (not the partially constructed object!), and this function should
- // be called from the BNCustomBinaryView::init implementation.
+ // BinaryView* passed in here should be the parent view (not the partially constructed object!), and this function
+ // should be called from the BNCustomBinaryView::init implementation.
//
- // 'id' and 'endianness' are used to determine which registered callbacks are actually invoked to eliminate some common sources
- // of boilerplate that all callbacks would have to implement otherwise. If these aren't applicable to your binaryviewtype just
- // use constants here and document them so that people registering Platform recognizers for your view type know what to use.
- BINARYNINJACOREAPI BNPlatform* BNRecognizePlatformForViewType(BNBinaryViewType* type, uint64_t id, BNEndianness endian,
- BNBinaryView* view, BNMetadata* metadata);
+ // 'id' and 'endianness' are used to determine which registered callbacks are actually invoked to eliminate some
+ // common sources of boilerplate that all callbacks would have to implement otherwise. If these aren't applicable to
+ // your binaryviewtype just use constants here and document them so that people registering Platform recognizers for
+ // your view type know what to use.
+ BINARYNINJACOREAPI BNPlatform* BNRecognizePlatformForViewType(
+ BNBinaryViewType* type, uint64_t id, BNEndianness endian, BNBinaryView* view, BNMetadata* metadata);
- BINARYNINJACOREAPI void BNRegisterBinaryViewEvent(BNBinaryViewEventType type,
- void (*callback)(void* ctx, BNBinaryView* view), void* ctx);
+ BINARYNINJACOREAPI void BNRegisterBinaryViewEvent(
+ BNBinaryViewEventType type, void (*callback)(void* ctx, BNBinaryView* view), void* ctx);
// Stream reader object
BINARYNINJACOREAPI BNBinaryReader* BNCreateBinaryReader(BNBinaryView* view);
@@ -3247,8 +3270,8 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI BNTransform* BNGetTransformByName(const char* name);
BINARYNINJACOREAPI BNTransform** BNGetTransformTypeList(size_t* count);
BINARYNINJACOREAPI void BNFreeTransformTypeList(BNTransform** xforms);
- BINARYNINJACOREAPI BNTransform* BNRegisterTransformType(BNTransformType type, const char* name, const char* longName,
- const char* group, BNCustomTransform* xform);
+ BINARYNINJACOREAPI BNTransform* BNRegisterTransformType(
+ BNTransformType type, const char* name, const char* longName, const char* group, BNCustomTransform* xform);
BINARYNINJACOREAPI BNTransformType BNGetTransformType(BNTransform* xform);
BINARYNINJACOREAPI char* BNGetTransformName(BNTransform* xform);
@@ -3256,19 +3279,20 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI char* BNGetTransformGroup(BNTransform* xform);
BINARYNINJACOREAPI BNTransformParameterInfo* BNGetTransformParameterList(BNTransform* xform, size_t* count);
BINARYNINJACOREAPI void BNFreeTransformParameterList(BNTransformParameterInfo* params, size_t count);
- BINARYNINJACOREAPI bool BNDecode(BNTransform* xform, BNDataBuffer* input, BNDataBuffer* output,
- BNTransformParameter* params, size_t paramCount);
- BINARYNINJACOREAPI bool BNEncode(BNTransform* xform, BNDataBuffer* input, BNDataBuffer* output,
- BNTransformParameter* params, size_t paramCount);
+ BINARYNINJACOREAPI bool BNDecode(
+ BNTransform* xform, BNDataBuffer* input, BNDataBuffer* output, BNTransformParameter* params, size_t paramCount);
+ BINARYNINJACOREAPI bool BNEncode(
+ BNTransform* xform, BNDataBuffer* input, BNDataBuffer* output, BNTransformParameter* params, size_t paramCount);
// Architectures
BINARYNINJACOREAPI BNArchitecture* BNGetArchitectureByName(const char* name);
BINARYNINJACOREAPI BNArchitecture** BNGetArchitectureList(size_t* count);
BINARYNINJACOREAPI void BNFreeArchitectureList(BNArchitecture** archs);
BINARYNINJACOREAPI BNArchitecture* BNRegisterArchitecture(const char* name, BNCustomArchitecture* arch);
- BINARYNINJACOREAPI BNArchitecture* BNRegisterArchitectureExtension(const char* name,
- BNArchitecture* base, BNCustomArchitecture* arch);
- BINARYNINJACOREAPI void BNAddArchitectureRedirection(BNArchitecture* arch, BNArchitecture* from, BNArchitecture* to);
+ BINARYNINJACOREAPI BNArchitecture* BNRegisterArchitectureExtension(
+ const char* name, BNArchitecture* base, BNCustomArchitecture* arch);
+ BINARYNINJACOREAPI void BNAddArchitectureRedirection(
+ BNArchitecture* arch, BNArchitecture* from, BNArchitecture* to);
BINARYNINJACOREAPI BNArchitecture* BNRegisterArchitectureHook(BNArchitecture* base, BNCustomArchitecture* arch);
BINARYNINJACOREAPI void BNFinalizeArchitectureHook(BNArchitecture* base);
BINARYNINJACOREAPI BNArchitecture* BNGetNativeTypeParserArchitecture();
@@ -3281,12 +3305,12 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI size_t BNGetArchitectureMaxInstructionLength(BNArchitecture* arch);
BINARYNINJACOREAPI size_t BNGetArchitectureOpcodeDisplayLength(BNArchitecture* arch);
BINARYNINJACOREAPI BNArchitecture* BNGetAssociatedArchitectureByAddress(BNArchitecture* arch, uint64_t* addr);
- BINARYNINJACOREAPI bool BNGetInstructionInfo(BNArchitecture* arch, const uint8_t* data, uint64_t addr,
- size_t maxLen, BNInstructionInfo* result);
- BINARYNINJACOREAPI bool BNGetInstructionText(BNArchitecture* arch, const uint8_t* data, uint64_t addr,
- size_t* len, BNInstructionTextToken** result, size_t* count);
- BINARYNINJACOREAPI bool BNGetInstructionLowLevelIL(BNArchitecture* arch, const uint8_t* data, uint64_t addr,
- size_t* len, BNLowLevelILFunction* il);
+ BINARYNINJACOREAPI bool BNGetInstructionInfo(
+ BNArchitecture* arch, const uint8_t* data, uint64_t addr, size_t maxLen, BNInstructionInfo* result);
+ BINARYNINJACOREAPI bool BNGetInstructionText(BNArchitecture* arch, const uint8_t* data, uint64_t addr, size_t* len,
+ BNInstructionTextToken** result, size_t* count);
+ BINARYNINJACOREAPI bool BNGetInstructionLowLevelIL(
+ BNArchitecture* arch, const uint8_t* data, uint64_t addr, size_t* len, BNLowLevelILFunction* il);
BINARYNINJACOREAPI void BNFreeInstructionText(BNInstructionTextToken* tokens, size_t count);
BINARYNINJACOREAPI void BNFreeInstructionTextLines(BNInstructionTextLine* lines, size_t count);
BINARYNINJACOREAPI char* BNGetArchitectureRegisterName(BNArchitecture* arch, uint32_t reg);
@@ -3301,28 +3325,31 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI uint32_t* BNGetAllArchitectureSemanticFlagClasses(BNArchitecture* arch, size_t* count);
BINARYNINJACOREAPI uint32_t* BNGetAllArchitectureSemanticFlagGroups(BNArchitecture* arch, size_t* count);
BINARYNINJACOREAPI BNFlagRole BNGetArchitectureFlagRole(BNArchitecture* arch, uint32_t flag, uint32_t semClass);
- BINARYNINJACOREAPI uint32_t* BNGetArchitectureFlagsRequiredForFlagCondition(BNArchitecture* arch, BNLowLevelILFlagCondition cond,
- uint32_t semClass, size_t* count);
- BINARYNINJACOREAPI uint32_t* BNGetArchitectureFlagsRequiredForSemanticFlagGroup(BNArchitecture* arch,
- uint32_t semGroup, size_t* count);
- BINARYNINJACOREAPI BNFlagConditionForSemanticClass* BNGetArchitectureFlagConditionsForSemanticFlagGroup(BNArchitecture* arch,
- uint32_t semGroup, size_t* count);
+ BINARYNINJACOREAPI uint32_t* BNGetArchitectureFlagsRequiredForFlagCondition(
+ BNArchitecture* arch, BNLowLevelILFlagCondition cond, uint32_t semClass, size_t* count);
+ BINARYNINJACOREAPI uint32_t* BNGetArchitectureFlagsRequiredForSemanticFlagGroup(
+ BNArchitecture* arch, uint32_t semGroup, size_t* count);
+ BINARYNINJACOREAPI BNFlagConditionForSemanticClass* BNGetArchitectureFlagConditionsForSemanticFlagGroup(
+ BNArchitecture* arch, uint32_t semGroup, size_t* count);
BINARYNINJACOREAPI void BNFreeFlagConditionsForSemanticFlagGroup(BNFlagConditionForSemanticClass* conditions);
- BINARYNINJACOREAPI uint32_t* BNGetArchitectureFlagsWrittenByFlagWriteType(BNArchitecture* arch, uint32_t writeType,
- size_t* count);
- BINARYNINJACOREAPI uint32_t BNGetArchitectureSemanticClassForFlagWriteType(BNArchitecture* arch, uint32_t writeType);
+ BINARYNINJACOREAPI uint32_t* BNGetArchitectureFlagsWrittenByFlagWriteType(
+ BNArchitecture* arch, uint32_t writeType, size_t* count);
+ BINARYNINJACOREAPI uint32_t BNGetArchitectureSemanticClassForFlagWriteType(
+ BNArchitecture* arch, uint32_t writeType);
BINARYNINJACOREAPI size_t BNGetArchitectureFlagWriteLowLevelIL(BNArchitecture* arch, BNLowLevelILOperation op,
- size_t size, uint32_t flagWriteType, uint32_t flag, BNRegisterOrConstant* operands, size_t operandCount,
- BNLowLevelILFunction* il);
- BINARYNINJACOREAPI size_t BNGetDefaultArchitectureFlagWriteLowLevelIL(BNArchitecture* arch, BNLowLevelILOperation op,
- size_t size, BNFlagRole role, BNRegisterOrConstant* operands, size_t operandCount, BNLowLevelILFunction* il);
- BINARYNINJACOREAPI size_t BNGetArchitectureFlagConditionLowLevelIL(BNArchitecture* arch, BNLowLevelILFlagCondition cond,
- uint32_t semClass, BNLowLevelILFunction* il);
- BINARYNINJACOREAPI size_t BNGetDefaultArchitectureFlagConditionLowLevelIL(BNArchitecture* arch, BNLowLevelILFlagCondition cond,
- uint32_t semClass, BNLowLevelILFunction* il);
- BINARYNINJACOREAPI size_t BNGetArchitectureSemanticFlagGroupLowLevelIL(BNArchitecture* arch,
- uint32_t semGroup, BNLowLevelILFunction* il);
- BINARYNINJACOREAPI uint32_t* BNGetModifiedArchitectureRegistersOnWrite(BNArchitecture* arch, uint32_t reg, size_t* count);
+ size_t size, uint32_t flagWriteType, uint32_t flag, BNRegisterOrConstant* operands, size_t operandCount,
+ BNLowLevelILFunction* il);
+ BINARYNINJACOREAPI size_t BNGetDefaultArchitectureFlagWriteLowLevelIL(BNArchitecture* arch,
+ BNLowLevelILOperation op, size_t size, BNFlagRole role, BNRegisterOrConstant* operands, size_t operandCount,
+ BNLowLevelILFunction* il);
+ BINARYNINJACOREAPI size_t BNGetArchitectureFlagConditionLowLevelIL(
+ BNArchitecture* arch, BNLowLevelILFlagCondition cond, uint32_t semClass, BNLowLevelILFunction* il);
+ BINARYNINJACOREAPI size_t BNGetDefaultArchitectureFlagConditionLowLevelIL(
+ BNArchitecture* arch, BNLowLevelILFlagCondition cond, uint32_t semClass, BNLowLevelILFunction* il);
+ BINARYNINJACOREAPI size_t BNGetArchitectureSemanticFlagGroupLowLevelIL(
+ BNArchitecture* arch, uint32_t semGroup, BNLowLevelILFunction* il);
+ BINARYNINJACOREAPI uint32_t* BNGetModifiedArchitectureRegistersOnWrite(
+ BNArchitecture* arch, uint32_t reg, size_t* count);
BINARYNINJACOREAPI void BNFreeRegisterList(uint32_t* regs);
BINARYNINJACOREAPI BNRegisterInfo BNGetArchitectureRegisterInfo(BNArchitecture* arch, uint32_t reg);
BINARYNINJACOREAPI uint32_t BNGetArchitectureStackPointerRegister(BNArchitecture* arch);
@@ -3340,53 +3367,56 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI char* BNGetArchitectureIntrinsicName(BNArchitecture* arch, uint32_t intrinsic);
BINARYNINJACOREAPI uint32_t* BNGetAllArchitectureIntrinsics(BNArchitecture* arch, size_t* count);
- BINARYNINJACOREAPI BNNameAndType* BNGetArchitectureIntrinsicInputs(BNArchitecture* arch, uint32_t intrinsic, size_t* count);
+ BINARYNINJACOREAPI BNNameAndType* BNGetArchitectureIntrinsicInputs(
+ BNArchitecture* arch, uint32_t intrinsic, size_t* count);
BINARYNINJACOREAPI void BNFreeNameAndTypeList(BNNameAndType* nt, size_t count);
- BINARYNINJACOREAPI BNTypeWithConfidence* BNGetArchitectureIntrinsicOutputs(BNArchitecture* arch, uint32_t intrinsic,
- size_t* count);
+ BINARYNINJACOREAPI BNTypeWithConfidence* BNGetArchitectureIntrinsicOutputs(
+ BNArchitecture* arch, uint32_t intrinsic, size_t* count);
BINARYNINJACOREAPI void BNFreeOutputTypeList(BNTypeWithConfidence* types, size_t count);
BINARYNINJACOREAPI bool BNCanArchitectureAssemble(BNArchitecture* arch);
- BINARYNINJACOREAPI bool BNAssemble(BNArchitecture* arch, const char* code, uint64_t addr, BNDataBuffer* result, char** errors);
+ BINARYNINJACOREAPI bool BNAssemble(
+ BNArchitecture* arch, const char* code, uint64_t addr, BNDataBuffer* result, char** errors);
- BINARYNINJACOREAPI bool BNIsArchitectureNeverBranchPatchAvailable(BNArchitecture* arch, const uint8_t* data,
- uint64_t addr, size_t len);
- BINARYNINJACOREAPI bool BNIsArchitectureAlwaysBranchPatchAvailable(BNArchitecture* arch, const uint8_t* data,
- uint64_t addr, size_t len);
- BINARYNINJACOREAPI bool BNIsArchitectureInvertBranchPatchAvailable(BNArchitecture* arch, const uint8_t* data,
- uint64_t addr, size_t len);
- BINARYNINJACOREAPI bool BNIsArchitectureSkipAndReturnZeroPatchAvailable(BNArchitecture* arch, const uint8_t* data,
- uint64_t addr, size_t len);
- BINARYNINJACOREAPI bool BNIsArchitectureSkipAndReturnValuePatchAvailable(BNArchitecture* arch, const uint8_t* data,
- uint64_t addr, size_t len);
+ BINARYNINJACOREAPI bool BNIsArchitectureNeverBranchPatchAvailable(
+ BNArchitecture* arch, const uint8_t* data, uint64_t addr, size_t len);
+ BINARYNINJACOREAPI bool BNIsArchitectureAlwaysBranchPatchAvailable(
+ BNArchitecture* arch, const uint8_t* data, uint64_t addr, size_t len);
+ BINARYNINJACOREAPI bool BNIsArchitectureInvertBranchPatchAvailable(
+ BNArchitecture* arch, const uint8_t* data, uint64_t addr, size_t len);
+ BINARYNINJACOREAPI bool BNIsArchitectureSkipAndReturnZeroPatchAvailable(
+ BNArchitecture* arch, const uint8_t* data, uint64_t addr, size_t len);
+ BINARYNINJACOREAPI bool BNIsArchitectureSkipAndReturnValuePatchAvailable(
+ BNArchitecture* arch, const uint8_t* data, uint64_t addr, size_t len);
BINARYNINJACOREAPI bool BNArchitectureConvertToNop(BNArchitecture* arch, uint8_t* data, uint64_t addr, size_t len);
BINARYNINJACOREAPI bool BNArchitectureAlwaysBranch(BNArchitecture* arch, uint8_t* data, uint64_t addr, size_t len);
BINARYNINJACOREAPI bool BNArchitectureInvertBranch(BNArchitecture* arch, uint8_t* data, uint64_t addr, size_t len);
- BINARYNINJACOREAPI bool BNArchitectureSkipAndReturnValue(BNArchitecture* arch, uint8_t* data, uint64_t addr,
- size_t len, uint64_t value);
+ BINARYNINJACOREAPI bool BNArchitectureSkipAndReturnValue(
+ BNArchitecture* arch, uint8_t* data, uint64_t addr, size_t len, uint64_t value);
BINARYNINJACOREAPI void BNRegisterArchitectureFunctionRecognizer(BNArchitecture* arch, BNFunctionRecognizer* rec);
- BINARYNINJACOREAPI bool BNIsBinaryViewTypeArchitectureConstantDefined(BNArchitecture* arch, const char* type,
- const char* name);
- BINARYNINJACOREAPI uint64_t BNGetBinaryViewTypeArchitectureConstant(BNArchitecture* arch, const char* type,
- const char* name, uint64_t defaultValue);
- BINARYNINJACOREAPI void BNSetBinaryViewTypeArchitectureConstant(BNArchitecture* arch, const char* type,
- const char* name, uint64_t value);
+ BINARYNINJACOREAPI bool BNIsBinaryViewTypeArchitectureConstantDefined(
+ BNArchitecture* arch, const char* type, const char* name);
+ BINARYNINJACOREAPI uint64_t BNGetBinaryViewTypeArchitectureConstant(
+ BNArchitecture* arch, const char* type, const char* name, uint64_t defaultValue);
+ BINARYNINJACOREAPI void BNSetBinaryViewTypeArchitectureConstant(
+ BNArchitecture* arch, const char* type, const char* name, uint64_t value);
- BINARYNINJACOREAPI void BNArchitectureRegisterRelocationHandler(BNArchitecture* arch, const char* viewName,
- BNRelocationHandler* handler);
+ BINARYNINJACOREAPI void BNArchitectureRegisterRelocationHandler(
+ BNArchitecture* arch, const char* viewName, BNRelocationHandler* handler);
BINARYNINJACOREAPI BNRelocationHandler* BNCreateRelocationHandler(BNCustomRelocationHandler* handler);
- BINARYNINJACOREAPI BNRelocationHandler* BNArchitectureGetRelocationHandler(BNArchitecture* arch, const char* viewName);
+ BINARYNINJACOREAPI BNRelocationHandler* BNArchitectureGetRelocationHandler(
+ BNArchitecture* arch, const char* viewName);
BINARYNINJACOREAPI BNRelocationHandler* BNNewRelocationHandlerReference(BNRelocationHandler* handler);
BINARYNINJACOREAPI void BNFreeRelocationHandler(BNRelocationHandler* handler);
BINARYNINJACOREAPI bool BNRelocationHandlerGetRelocationInfo(BNRelocationHandler* handler, BNBinaryView* data,
- BNArchitecture* arch, BNRelocationInfo* info, size_t infoCount);
+ BNArchitecture* arch, BNRelocationInfo* info, size_t infoCount);
BINARYNINJACOREAPI bool BNRelocationHandlerApplyRelocation(BNRelocationHandler* handler, BNBinaryView* view,
- BNArchitecture* arch, BNRelocation* reloc, uint8_t* dest, size_t len);
+ BNArchitecture* arch, BNRelocation* reloc, uint8_t* dest, size_t len);
BINARYNINJACOREAPI bool BNRelocationHandlerDefaultApplyRelocation(BNRelocationHandler* handler, BNBinaryView* view,
- BNArchitecture* arch, BNRelocation* reloc, uint8_t* dest, size_t len);
+ BNArchitecture* arch, BNRelocation* reloc, uint8_t* dest, size_t len);
BINARYNINJACOREAPI size_t BNRelocationHandlerGetOperandForExternalRelocation(BNRelocationHandler* handler,
- const uint8_t* data, uint64_t addr, size_t length, const BNLowLevelILFunction* il, BNRelocation* relocation);
+ const uint8_t* data, uint64_t addr, size_t length, const BNLowLevelILFunction* il, BNRelocation* relocation);
// Analysis
BINARYNINJACOREAPI void BNAddAnalysisOption(BNBinaryView* view, const char* name);
BINARYNINJACOREAPI void BNAddFunctionForAnalysis(BNBinaryView* view, BNPlatform* platform, uint64_t addr);
@@ -3414,7 +3444,8 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI BNFunction* BNGetAnalysisFunction(BNBinaryView* view, BNPlatform* platform, uint64_t addr);
BINARYNINJACOREAPI BNFunction* BNGetRecentAnalysisFunctionForAddress(BNBinaryView* view, uint64_t addr);
BINARYNINJACOREAPI BNFunction** BNGetAnalysisFunctionsForAddress(BNBinaryView* view, uint64_t addr, size_t* count);
- BINARYNINJACOREAPI BNFunction** BNGetAnalysisFunctionsContainingAddress(BNBinaryView* view, uint64_t addr, size_t* count);
+ BINARYNINJACOREAPI BNFunction** BNGetAnalysisFunctionsContainingAddress(
+ BNBinaryView* view, uint64_t addr, size_t* count);
BINARYNINJACOREAPI BNFunction* BNGetAnalysisEntryPoint(BNBinaryView* view);
BINARYNINJACOREAPI char* BNGetGlobalCommentForAddress(BNBinaryView* view, uint64_t addr);
@@ -3439,26 +3470,30 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI void BNSetFunctionComment(BNFunction* func, const char* comment);
BINARYNINJACOREAPI void BNSetCommentForAddress(BNFunction* func, uint64_t addr, const char* comment);
- BINARYNINJACOREAPI void BNAddUserCodeReference(BNFunction* func, BNArchitecture* fromArch, uint64_t fromAddr, uint64_t toAddr);
- BINARYNINJACOREAPI void BNRemoveUserCodeReference(BNFunction* func, BNArchitecture* fromArch, uint64_t fromAddr, uint64_t toAddr);
+ BINARYNINJACOREAPI void BNAddUserCodeReference(
+ BNFunction* func, BNArchitecture* fromArch, uint64_t fromAddr, uint64_t toAddr);
+ BINARYNINJACOREAPI void BNRemoveUserCodeReference(
+ BNFunction* func, BNArchitecture* fromArch, uint64_t fromAddr, uint64_t toAddr);
- BINARYNINJACOREAPI void BNAddUserTypeReference(BNFunction* func, BNArchitecture* fromArch, uint64_t fromAddr, BNQualifiedName* name);
- BINARYNINJACOREAPI void BNRemoveUserTypeReference(BNFunction* func, BNArchitecture* fromArch, uint64_t fromAddr, BNQualifiedName* name);
- BINARYNINJACOREAPI void BNAddUserTypeFieldReference(BNFunction* func,
- BNArchitecture* fromArch, uint64_t fromAddr, BNQualifiedName* name, uint64_t offset,
- size_t size);
- BINARYNINJACOREAPI void BNRemoveUserTypeFieldReference(BNFunction* func,
- BNArchitecture* fromArch, uint64_t fromAddr, BNQualifiedName* name, uint64_t offset,
- size_t size);
+ BINARYNINJACOREAPI void BNAddUserTypeReference(
+ BNFunction* func, BNArchitecture* fromArch, uint64_t fromAddr, BNQualifiedName* name);
+ BINARYNINJACOREAPI void BNRemoveUserTypeReference(
+ BNFunction* func, BNArchitecture* fromArch, uint64_t fromAddr, BNQualifiedName* name);
+ BINARYNINJACOREAPI void BNAddUserTypeFieldReference(BNFunction* func, BNArchitecture* fromArch, uint64_t fromAddr,
+ BNQualifiedName* name, uint64_t offset, size_t size);
+ BINARYNINJACOREAPI void BNRemoveUserTypeFieldReference(BNFunction* func, BNArchitecture* fromArch,
+ uint64_t fromAddr, BNQualifiedName* name, uint64_t offset, size_t size);
BINARYNINJACOREAPI BNBasicBlock* BNNewBasicBlockReference(BNBasicBlock* block);
BINARYNINJACOREAPI void BNFreeBasicBlock(BNBasicBlock* block);
BINARYNINJACOREAPI BNBasicBlock** BNGetFunctionBasicBlockList(BNFunction* func, size_t* count);
BINARYNINJACOREAPI void BNFreeBasicBlockList(BNBasicBlock** blocks, size_t count);
- BINARYNINJACOREAPI BNBasicBlock* BNGetFunctionBasicBlockAtAddress(BNFunction* func, BNArchitecture* arch, uint64_t addr);
+ BINARYNINJACOREAPI BNBasicBlock* BNGetFunctionBasicBlockAtAddress(
+ BNFunction* func, BNArchitecture* arch, uint64_t addr);
BINARYNINJACOREAPI BNBasicBlock* BNGetRecentBasicBlockForAddress(BNBinaryView* view, uint64_t addr);
BINARYNINJACOREAPI BNBasicBlock** BNGetBasicBlocksForAddress(BNBinaryView* view, uint64_t addr, size_t* count);
- BINARYNINJACOREAPI BNBasicBlock** BNGetBasicBlocksStartingAtAddress(BNBinaryView* view, uint64_t addr, size_t* count);
+ BINARYNINJACOREAPI BNBasicBlock** BNGetBasicBlocksStartingAtAddress(
+ BNBinaryView* view, uint64_t addr, size_t* count);
BINARYNINJACOREAPI uint64_t BNGetFunctionHighestAddress(BNFunction* func);
BINARYNINJACOREAPI uint64_t BNGetFunctionLowestAddress(BNFunction* func);
@@ -3467,8 +3502,10 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI BNLowLevelILFunction* BNGetFunctionLowLevelIL(BNFunction* func);
BINARYNINJACOREAPI BNLowLevelILFunction* BNGetFunctionLowLevelILIfAvailable(BNFunction* func);
BINARYNINJACOREAPI size_t BNGetLowLevelILForInstruction(BNFunction* func, BNArchitecture* arch, uint64_t addr);
- BINARYNINJACOREAPI size_t* BNGetLowLevelILInstructionsForAddress(BNFunction* func, BNArchitecture* arch, uint64_t addr, size_t* count);
- BINARYNINJACOREAPI size_t* BNGetLowLevelILExitsForInstruction(BNFunction* func, BNArchitecture* arch, uint64_t addr, size_t* count);
+ BINARYNINJACOREAPI size_t* BNGetLowLevelILInstructionsForAddress(
+ BNFunction* func, BNArchitecture* arch, uint64_t addr, size_t* count);
+ BINARYNINJACOREAPI size_t* BNGetLowLevelILExitsForInstruction(
+ BNFunction* func, BNArchitecture* arch, uint64_t addr, size_t* count);
BINARYNINJACOREAPI void BNFreeILInstructionList(size_t* list);
BINARYNINJACOREAPI BNMediumLevelILFunction* BNGetFunctionMediumLevelIL(BNFunction* func);
BINARYNINJACOREAPI BNMediumLevelILFunction* BNGetFunctionMediumLevelILIfAvailable(BNFunction* func);
@@ -3477,36 +3514,39 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI BNHighLevelILFunction* BNGetFunctionHighLevelIL(BNFunction* func);
BINARYNINJACOREAPI BNHighLevelILFunction* BNGetFunctionHighLevelILIfAvailable(BNFunction* func);
BINARYNINJACOREAPI BNLanguageRepresentationFunction* BNGetFunctionLanguageRepresentation(BNFunction* func);
- BINARYNINJACOREAPI BNRegisterValue BNGetRegisterValueAtInstruction(BNFunction* func, BNArchitecture* arch,
- uint64_t addr, uint32_t reg);
- BINARYNINJACOREAPI BNRegisterValue BNGetRegisterValueAfterInstruction(BNFunction* func, BNArchitecture* arch,
- uint64_t addr, uint32_t reg);
- BINARYNINJACOREAPI BNRegisterValue BNGetStackContentsAtInstruction(BNFunction* func, BNArchitecture* arch,
- uint64_t addr, int64_t offset, size_t size);
- BINARYNINJACOREAPI BNRegisterValue BNGetStackContentsAfterInstruction(BNFunction* func, BNArchitecture* arch,
- uint64_t addr, int64_t offset, size_t size);
- BINARYNINJACOREAPI BNRegisterValue BNGetParameterValueAtInstruction(BNFunction* func, BNArchitecture* arch,
- uint64_t addr, BNType* functionType, size_t i);
- BINARYNINJACOREAPI BNRegisterValue BNGetParameterValueAtLowLevelILInstruction(BNFunction* func, size_t instr,
- BNType* functionType, size_t i);
+ BINARYNINJACOREAPI BNRegisterValue BNGetRegisterValueAtInstruction(
+ BNFunction* func, BNArchitecture* arch, uint64_t addr, uint32_t reg);
+ BINARYNINJACOREAPI BNRegisterValue BNGetRegisterValueAfterInstruction(
+ BNFunction* func, BNArchitecture* arch, uint64_t addr, uint32_t reg);
+ BINARYNINJACOREAPI BNRegisterValue BNGetStackContentsAtInstruction(
+ BNFunction* func, BNArchitecture* arch, uint64_t addr, int64_t offset, size_t size);
+ BINARYNINJACOREAPI BNRegisterValue BNGetStackContentsAfterInstruction(
+ BNFunction* func, BNArchitecture* arch, uint64_t addr, int64_t offset, size_t size);
+ BINARYNINJACOREAPI BNRegisterValue BNGetParameterValueAtInstruction(
+ BNFunction* func, BNArchitecture* arch, uint64_t addr, BNType* functionType, size_t i);
+ BINARYNINJACOREAPI BNRegisterValue BNGetParameterValueAtLowLevelILInstruction(
+ BNFunction* func, size_t instr, BNType* functionType, size_t i);
BINARYNINJACOREAPI void BNFreePossibleValueSet(BNPossibleValueSet* value);
- BINARYNINJACOREAPI uint32_t* BNGetRegistersReadByInstruction(BNFunction* func, BNArchitecture* arch, uint64_t addr,
- size_t* count);
- BINARYNINJACOREAPI uint32_t* BNGetRegistersWrittenByInstruction(BNFunction* func, BNArchitecture* arch, uint64_t addr,
- size_t* count);
- BINARYNINJACOREAPI BNStackVariableReference* BNGetStackVariablesReferencedByInstruction(BNFunction* func, BNArchitecture* arch,
- uint64_t addr, size_t* count);
+ BINARYNINJACOREAPI uint32_t* BNGetRegistersReadByInstruction(
+ BNFunction* func, BNArchitecture* arch, uint64_t addr, size_t* count);
+ BINARYNINJACOREAPI uint32_t* BNGetRegistersWrittenByInstruction(
+ BNFunction* func, BNArchitecture* arch, uint64_t addr, size_t* count);
+ BINARYNINJACOREAPI BNStackVariableReference* BNGetStackVariablesReferencedByInstruction(
+ BNFunction* func, BNArchitecture* arch, uint64_t addr, size_t* count);
BINARYNINJACOREAPI void BNFreeStackVariableReferenceList(BNStackVariableReference* refs, size_t count);
- BINARYNINJACOREAPI BNConstantReference* BNGetConstantsReferencedByInstruction(BNFunction* func,
- BNArchitecture* arch, uint64_t addr, size_t* count);
+ BINARYNINJACOREAPI BNConstantReference* BNGetConstantsReferencedByInstruction(
+ BNFunction* func, BNArchitecture* arch, uint64_t addr, size_t* count);
BINARYNINJACOREAPI void BNFreeConstantReferenceList(BNConstantReference* refs);
BINARYNINJACOREAPI BNLowLevelILFunction* BNGetFunctionLiftedIL(BNFunction* func);
BINARYNINJACOREAPI BNLowLevelILFunction* BNGetFunctionLiftedILIfAvailable(BNFunction* func);
BINARYNINJACOREAPI size_t BNGetLiftedILForInstruction(BNFunction* func, BNArchitecture* arch, uint64_t addr);
- BINARYNINJACOREAPI size_t* BNGetLiftedILInstructionsForAddress(BNFunction* func, BNArchitecture* arch, uint64_t addr, size_t* count);
- BINARYNINJACOREAPI size_t* BNGetLiftedILFlagUsesForDefinition(BNFunction* func, size_t i, uint32_t flag, size_t* count);
- BINARYNINJACOREAPI size_t* BNGetLiftedILFlagDefinitionsForUse(BNFunction* func, size_t i, uint32_t flag, size_t* count);
+ BINARYNINJACOREAPI size_t* BNGetLiftedILInstructionsForAddress(
+ BNFunction* func, BNArchitecture* arch, uint64_t addr, size_t* count);
+ BINARYNINJACOREAPI size_t* BNGetLiftedILFlagUsesForDefinition(
+ BNFunction* func, size_t i, uint32_t flag, size_t* count);
+ BINARYNINJACOREAPI size_t* BNGetLiftedILFlagDefinitionsForUse(
+ BNFunction* func, size_t i, uint32_t flag, size_t* count);
BINARYNINJACOREAPI uint32_t* BNGetFlagsReadByLiftedILInstruction(BNFunction* func, size_t i, size_t* count);
BINARYNINJACOREAPI uint32_t* BNGetFlagsWrittenByLiftedILInstruction(BNFunction* func, size_t i, size_t* count);
@@ -3518,45 +3558,50 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI void BNFreeParameterVariables(BNParameterVariablesWithConfidence* vars);
BINARYNINJACOREAPI BNBoolWithConfidence BNFunctionHasVariableArguments(BNFunction* func);
BINARYNINJACOREAPI BNOffsetWithConfidence BNGetFunctionStackAdjustment(BNFunction* func);
- BINARYNINJACOREAPI BNRegisterStackAdjustment* BNGetFunctionRegisterStackAdjustments(BNFunction* func, size_t* count);
+ BINARYNINJACOREAPI BNRegisterStackAdjustment* BNGetFunctionRegisterStackAdjustments(
+ BNFunction* func, size_t* count);
BINARYNINJACOREAPI void BNFreeRegisterStackAdjustments(BNRegisterStackAdjustment* adjustments);
BINARYNINJACOREAPI BNRegisterSetWithConfidence BNGetFunctionClobberedRegisters(BNFunction* func);
BINARYNINJACOREAPI void BNFreeRegisterSet(BNRegisterSetWithConfidence* regs);
BINARYNINJACOREAPI void BNSetAutoFunctionReturnType(BNFunction* func, BNTypeWithConfidence* type);
BINARYNINJACOREAPI void BNSetAutoFunctionReturnRegisters(BNFunction* func, BNRegisterSetWithConfidence* regs);
- BINARYNINJACOREAPI void BNSetAutoFunctionCallingConvention(BNFunction* func, BNCallingConventionWithConfidence* convention);
- BINARYNINJACOREAPI void BNSetAutoFunctionParameterVariables(BNFunction* func, BNParameterVariablesWithConfidence* vars);
+ BINARYNINJACOREAPI void BNSetAutoFunctionCallingConvention(
+ BNFunction* func, BNCallingConventionWithConfidence* convention);
+ BINARYNINJACOREAPI void BNSetAutoFunctionParameterVariables(
+ BNFunction* func, BNParameterVariablesWithConfidence* vars);
BINARYNINJACOREAPI void BNSetAutoFunctionHasVariableArguments(BNFunction* func, BNBoolWithConfidence* varArgs);
BINARYNINJACOREAPI void BNSetAutoFunctionCanReturn(BNFunction* func, BNBoolWithConfidence* returns);
BINARYNINJACOREAPI void BNSetAutoFunctionStackAdjustment(BNFunction* func, BNOffsetWithConfidence* stackAdjust);
- BINARYNINJACOREAPI void BNSetAutoFunctionRegisterStackAdjustments(BNFunction* func,
- BNRegisterStackAdjustment* adjustments, size_t count);
+ BINARYNINJACOREAPI void BNSetAutoFunctionRegisterStackAdjustments(
+ BNFunction* func, BNRegisterStackAdjustment* adjustments, size_t count);
BINARYNINJACOREAPI void BNSetAutoFunctionClobberedRegisters(BNFunction* func, BNRegisterSetWithConfidence* regs);
BINARYNINJACOREAPI void BNSetUserFunctionReturnType(BNFunction* func, BNTypeWithConfidence* type);
BINARYNINJACOREAPI void BNSetUserFunctionReturnRegisters(BNFunction* func, BNRegisterSetWithConfidence* regs);
- BINARYNINJACOREAPI void BNSetUserFunctionCallingConvention(BNFunction* func, BNCallingConventionWithConfidence* convention);
- BINARYNINJACOREAPI void BNSetUserFunctionParameterVariables(BNFunction* func, BNParameterVariablesWithConfidence* vars);
+ BINARYNINJACOREAPI void BNSetUserFunctionCallingConvention(
+ BNFunction* func, BNCallingConventionWithConfidence* convention);
+ BINARYNINJACOREAPI void BNSetUserFunctionParameterVariables(
+ BNFunction* func, BNParameterVariablesWithConfidence* vars);
BINARYNINJACOREAPI void BNSetUserFunctionHasVariableArguments(BNFunction* func, BNBoolWithConfidence* varArgs);
BINARYNINJACOREAPI void BNSetUserFunctionCanReturn(BNFunction* func, BNBoolWithConfidence* returns);
BINARYNINJACOREAPI void BNSetUserFunctionStackAdjustment(BNFunction* func, BNOffsetWithConfidence* stackAdjust);
- BINARYNINJACOREAPI void BNSetUserFunctionRegisterStackAdjustments(BNFunction* func,
- BNRegisterStackAdjustment* adjustments, size_t count);
+ BINARYNINJACOREAPI void BNSetUserFunctionRegisterStackAdjustments(
+ BNFunction* func, BNRegisterStackAdjustment* adjustments, size_t count);
BINARYNINJACOREAPI void BNSetUserFunctionClobberedRegisters(BNFunction* func, BNRegisterSetWithConfidence* regs);
BINARYNINJACOREAPI void BNApplyImportedTypes(BNFunction* func, BNSymbol* sym, BNType* type);
BINARYNINJACOREAPI void BNApplyAutoDiscoveredFunctionType(BNFunction* func, BNType* type);
BINARYNINJACOREAPI bool BNFunctionHasExplicitlyDefinedType(BNFunction* func);
- BINARYNINJACOREAPI BNDisassemblyTextLine* BNGetFunctionTypeTokens(BNFunction* func,
- BNDisassemblySettings* settings, size_t* count);
+ BINARYNINJACOREAPI BNDisassemblyTextLine* BNGetFunctionTypeTokens(
+ BNFunction* func, BNDisassemblySettings* settings, size_t* count);
BINARYNINJACOREAPI BNRegisterValueWithConfidence BNGetFunctionGlobalPointerValue(BNFunction* func);
BINARYNINJACOREAPI BNRegisterValueWithConfidence BNGetFunctionRegisterValueAtExit(BNFunction* func, uint32_t reg);
- BINARYNINJACOREAPI bool BNGetInstructionContainingAddress(BNFunction* func,
- BNArchitecture* arch, uint64_t addr, uint64_t* start);
+ BINARYNINJACOREAPI bool BNGetInstructionContainingAddress(
+ BNFunction* func, BNArchitecture* arch, uint64_t addr, uint64_t* start);
BINARYNINJACOREAPI BNFunction* BNGetBasicBlockFunction(BNBasicBlock* block);
BINARYNINJACOREAPI BNArchitecture* BNGetBasicBlockArchitecture(BNBasicBlock* block);
@@ -3575,10 +3620,11 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI BNBasicBlock** BNGetBasicBlockDominators(BNBasicBlock* block, size_t* count, bool post);
BINARYNINJACOREAPI BNBasicBlock** BNGetBasicBlockStrictDominators(BNBasicBlock* block, size_t* count, bool post);
BINARYNINJACOREAPI BNBasicBlock* BNGetBasicBlockImmediateDominator(BNBasicBlock* block, bool post);
- BINARYNINJACOREAPI BNBasicBlock** BNGetBasicBlockDominatorTreeChildren(BNBasicBlock* block, size_t* count, bool post);
+ BINARYNINJACOREAPI BNBasicBlock** BNGetBasicBlockDominatorTreeChildren(
+ BNBasicBlock* block, size_t* count, bool post);
BINARYNINJACOREAPI BNBasicBlock** BNGetBasicBlockDominanceFrontier(BNBasicBlock* block, size_t* count, bool post);
- BINARYNINJACOREAPI BNBasicBlock** BNGetBasicBlockIteratedDominanceFrontier(BNBasicBlock** blocks,
- size_t incomingCount, size_t* outputCount);
+ BINARYNINJACOREAPI BNBasicBlock** BNGetBasicBlockIteratedDominanceFrontier(
+ BNBasicBlock** blocks, size_t incomingCount, size_t* outputCount);
BINARYNINJACOREAPI bool BNIsILBasicBlock(BNBasicBlock* block);
BINARYNINJACOREAPI bool BNIsLowLevelILBasicBlock(BNBasicBlock* block);
BINARYNINJACOREAPI bool BNIsMediumLevelILBasicBlock(BNBasicBlock* block);
@@ -3587,140 +3633,155 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI BNLowLevelILFunction* BNGetBasicBlockLowLevelILFunction(BNBasicBlock* block);
BINARYNINJACOREAPI BNMediumLevelILFunction* BNGetBasicBlockMediumLevelILFunction(BNBasicBlock* block);
BINARYNINJACOREAPI BNHighLevelILFunction* BNGetBasicBlockHighLevelILFunction(BNBasicBlock* block);
- BINARYNINJACOREAPI bool BNGetBasicBlockInstructionContainingAddress(BNBasicBlock* block,
- uint64_t addr, uint64_t* start);
+ BINARYNINJACOREAPI bool BNGetBasicBlockInstructionContainingAddress(
+ BNBasicBlock* block, uint64_t addr, uint64_t* start);
BINARYNINJACOREAPI BNBasicBlock* BNGetBasicBlockSourceBlock(BNBasicBlock* block);
- BINARYNINJACOREAPI BNDisassemblyTextLine* BNGetBasicBlockDisassemblyText(BNBasicBlock* block,
- BNDisassemblySettings* settings, size_t* count);
+ BINARYNINJACOREAPI BNDisassemblyTextLine* BNGetBasicBlockDisassemblyText(
+ BNBasicBlock* block, BNDisassemblySettings* settings, size_t* count);
BINARYNINJACOREAPI void BNFreeDisassemblyTextLines(BNDisassemblyTextLine* lines, size_t count);
- BINARYNINJACOREAPI char* BNGetDisplayStringForInteger(BNBinaryView* binaryView, BNIntegerDisplayType type,
- uint64_t value, size_t inputWidth, bool isSigned);
- BINARYNINJACOREAPI BNDisassemblyTextRenderer* BNCreateDisassemblyTextRenderer(BNFunction* func,
- BNDisassemblySettings* settings);
- BINARYNINJACOREAPI BNDisassemblyTextRenderer* BNCreateLowLevelILDisassemblyTextRenderer(BNLowLevelILFunction* func,
- BNDisassemblySettings* settings);
- BINARYNINJACOREAPI BNDisassemblyTextRenderer* BNCreateMediumLevelILDisassemblyTextRenderer(BNMediumLevelILFunction* func,
- BNDisassemblySettings* settings);
- BINARYNINJACOREAPI BNDisassemblyTextRenderer* BNCreateHighLevelILDisassemblyTextRenderer(BNHighLevelILFunction* func,
- BNDisassemblySettings* settings);
- BINARYNINJACOREAPI BNDisassemblyTextRenderer* BNNewDisassemblyTextRendererReference(BNDisassemblyTextRenderer* renderer);
+ BINARYNINJACOREAPI char* BNGetDisplayStringForInteger(
+ BNBinaryView* binaryView, BNIntegerDisplayType type, uint64_t value, size_t inputWidth, bool isSigned);
+ BINARYNINJACOREAPI BNDisassemblyTextRenderer* BNCreateDisassemblyTextRenderer(
+ BNFunction* func, BNDisassemblySettings* settings);
+ BINARYNINJACOREAPI BNDisassemblyTextRenderer* BNCreateLowLevelILDisassemblyTextRenderer(
+ BNLowLevelILFunction* func, BNDisassemblySettings* settings);
+ BINARYNINJACOREAPI BNDisassemblyTextRenderer* BNCreateMediumLevelILDisassemblyTextRenderer(
+ BNMediumLevelILFunction* func, BNDisassemblySettings* settings);
+ BINARYNINJACOREAPI BNDisassemblyTextRenderer* BNCreateHighLevelILDisassemblyTextRenderer(
+ BNHighLevelILFunction* func, BNDisassemblySettings* settings);
+ BINARYNINJACOREAPI BNDisassemblyTextRenderer* BNNewDisassemblyTextRendererReference(
+ BNDisassemblyTextRenderer* renderer);
BINARYNINJACOREAPI void BNFreeDisassemblyTextRenderer(BNDisassemblyTextRenderer* renderer);
BINARYNINJACOREAPI BNFunction* BNGetDisassemblyTextRendererFunction(BNDisassemblyTextRenderer* renderer);
- BINARYNINJACOREAPI BNLowLevelILFunction* BNGetDisassemblyTextRendererLowLevelILFunction(BNDisassemblyTextRenderer* renderer);
- BINARYNINJACOREAPI BNMediumLevelILFunction* BNGetDisassemblyTextRendererMediumLevelILFunction(BNDisassemblyTextRenderer* renderer);
- BINARYNINJACOREAPI BNHighLevelILFunction* BNGetDisassemblyTextRendererHighLevelILFunction(BNDisassemblyTextRenderer* renderer);
+ BINARYNINJACOREAPI BNLowLevelILFunction* BNGetDisassemblyTextRendererLowLevelILFunction(
+ BNDisassemblyTextRenderer* renderer);
+ BINARYNINJACOREAPI BNMediumLevelILFunction* BNGetDisassemblyTextRendererMediumLevelILFunction(
+ BNDisassemblyTextRenderer* renderer);
+ BINARYNINJACOREAPI BNHighLevelILFunction* BNGetDisassemblyTextRendererHighLevelILFunction(
+ BNDisassemblyTextRenderer* renderer);
BINARYNINJACOREAPI BNBasicBlock* BNGetDisassemblyTextRendererBasicBlock(BNDisassemblyTextRenderer* renderer);
BINARYNINJACOREAPI BNArchitecture* BNGetDisassemblyTextRendererArchitecture(BNDisassemblyTextRenderer* renderer);
BINARYNINJACOREAPI BNDisassemblySettings* BNGetDisassemblyTextRendererSettings(BNDisassemblyTextRenderer* renderer);
- BINARYNINJACOREAPI void BNSetDisassemblyTextRendererBasicBlock(BNDisassemblyTextRenderer* renderer, BNBasicBlock* block);
- BINARYNINJACOREAPI void BNSetDisassemblyTextRendererArchitecture(BNDisassemblyTextRenderer* renderer, BNArchitecture* arch);
- BINARYNINJACOREAPI void BNSetDisassemblyTextRendererSettings(BNDisassemblyTextRenderer* renderer, BNDisassemblySettings* settings);
+ BINARYNINJACOREAPI void BNSetDisassemblyTextRendererBasicBlock(
+ BNDisassemblyTextRenderer* renderer, BNBasicBlock* block);
+ BINARYNINJACOREAPI void BNSetDisassemblyTextRendererArchitecture(
+ BNDisassemblyTextRenderer* renderer, BNArchitecture* arch);
+ BINARYNINJACOREAPI void BNSetDisassemblyTextRendererSettings(
+ BNDisassemblyTextRenderer* renderer, BNDisassemblySettings* settings);
BINARYNINJACOREAPI bool BNIsILDisassemblyTextRenderer(BNDisassemblyTextRenderer* renderer);
BINARYNINJACOREAPI bool BNDisassemblyTextRendererHasDataFlow(BNDisassemblyTextRenderer* renderer);
BINARYNINJACOREAPI BNInstructionTextToken* BNGetDisassemblyTextRendererInstructionAnnotations(
- BNDisassemblyTextRenderer* renderer, uint64_t addr, size_t* count);
- BINARYNINJACOREAPI bool BNGetDisassemblyTextRendererInstructionText(BNDisassemblyTextRenderer* renderer,
- uint64_t addr, size_t* len, BNDisassemblyTextLine** result, size_t* count);
- BINARYNINJACOREAPI bool BNGetDisassemblyTextRendererLines(BNDisassemblyTextRenderer* renderer,
- uint64_t addr, size_t* len, BNDisassemblyTextLine** result, size_t* count);
- BINARYNINJACOREAPI BNDisassemblyTextLine* BNPostProcessDisassemblyTextRendererLines(BNDisassemblyTextRenderer* renderer,
- uint64_t addr, size_t len, BNDisassemblyTextLine* inLines, size_t inCount, size_t* outCount, const char* indentSpaces);
+ BNDisassemblyTextRenderer* renderer, uint64_t addr, size_t* count);
+ BINARYNINJACOREAPI bool BNGetDisassemblyTextRendererInstructionText(
+ BNDisassemblyTextRenderer* renderer, uint64_t addr, size_t* len, BNDisassemblyTextLine** result, size_t* count);
+ BINARYNINJACOREAPI bool BNGetDisassemblyTextRendererLines(
+ BNDisassemblyTextRenderer* renderer, uint64_t addr, size_t* len, BNDisassemblyTextLine** result, size_t* count);
+ BINARYNINJACOREAPI BNDisassemblyTextLine* BNPostProcessDisassemblyTextRendererLines(
+ BNDisassemblyTextRenderer* renderer, uint64_t addr, size_t len, BNDisassemblyTextLine* inLines, size_t inCount,
+ size_t* outCount, const char* indentSpaces);
BINARYNINJACOREAPI void BNResetDisassemblyTextRendererDeduplicatedComments(BNDisassemblyTextRenderer* renderer);
BINARYNINJACOREAPI bool BNGetDisassemblyTextRendererSymbolTokens(BNDisassemblyTextRenderer* renderer, uint64_t addr,
- size_t size, size_t operand, BNInstructionTextToken** result, size_t* count);
+ size_t size, size_t operand, BNInstructionTextToken** result, size_t* count);
BINARYNINJACOREAPI BNInstructionTextToken* BNGetDisassemblyTextRendererStackVariableReferenceTokens(
- BNDisassemblyTextRenderer* renderer, BNStackVariableReference* ref, size_t* count);
+ BNDisassemblyTextRenderer* renderer, BNStackVariableReference* ref, size_t* count);
BINARYNINJACOREAPI bool BNIsIntegerToken(BNInstructionTextTokenType type);
- BINARYNINJACOREAPI BNInstructionTextToken* BNGetDisassemblyTextRendererIntegerTokens(BNDisassemblyTextRenderer* renderer,
- BNInstructionTextToken* token, BNArchitecture* arch, uint64_t addr, size_t* count);
+ BINARYNINJACOREAPI BNInstructionTextToken* BNGetDisassemblyTextRendererIntegerTokens(
+ BNDisassemblyTextRenderer* renderer, BNInstructionTextToken* token, BNArchitecture* arch, uint64_t addr,
+ size_t* count);
BINARYNINJACOREAPI BNDisassemblyTextLine* BNDisassemblyTextRendererWrapComment(BNDisassemblyTextRenderer* renderer,
- const BNDisassemblyTextLine* inLine, size_t* outLineCount, const char* comment, bool hasAutoAnnotations,
- const char* leadingSpaces, const char* indentSpaces);
+ const BNDisassemblyTextLine* inLine, size_t* outLineCount, const char* comment, bool hasAutoAnnotations,
+ const char* leadingSpaces, const char* indentSpaces);
BINARYNINJACOREAPI void BNMarkFunctionAsRecentlyUsed(BNFunction* func);
BINARYNINJACOREAPI void BNMarkBasicBlockAsRecentlyUsed(BNBasicBlock* block);
BINARYNINJACOREAPI BNReferenceSource* BNGetCodeReferences(BNBinaryView* view, uint64_t addr, size_t* count);
- BINARYNINJACOREAPI BNReferenceSource* BNGetCodeReferencesInRange(BNBinaryView* view, uint64_t addr,
- uint64_t len, size_t* count);
+ BINARYNINJACOREAPI BNReferenceSource* BNGetCodeReferencesInRange(
+ BNBinaryView* view, uint64_t addr, uint64_t len, size_t* count);
BINARYNINJACOREAPI void BNFreeCodeReferences(BNReferenceSource* refs, size_t count);
BINARYNINJACOREAPI void BNFreeTypeFieldReferences(BNTypeFieldReference* refs, size_t count);
BINARYNINJACOREAPI void BNFreeILReferences(BNILReferenceSource* refs, size_t count);
BINARYNINJACOREAPI uint64_t* BNGetCodeReferencesFrom(BNBinaryView* view, BNReferenceSource* src, size_t* count);
- BINARYNINJACOREAPI uint64_t* BNGetCodeReferencesFromInRange(BNBinaryView* view, BNReferenceSource* src, uint64_t len, size_t* count);
+ BINARYNINJACOREAPI uint64_t* BNGetCodeReferencesFromInRange(
+ BNBinaryView* view, BNReferenceSource* src, uint64_t len, size_t* count);
BINARYNINJACOREAPI uint64_t* BNGetDataReferences(BNBinaryView* view, uint64_t addr, size_t* count);
- BINARYNINJACOREAPI uint64_t* BNGetDataReferencesInRange(BNBinaryView* view, uint64_t addr, uint64_t len, size_t* count);
+ BINARYNINJACOREAPI uint64_t* BNGetDataReferencesInRange(
+ BNBinaryView* view, uint64_t addr, uint64_t len, size_t* count);
BINARYNINJACOREAPI uint64_t* BNGetDataReferencesFrom(BNBinaryView* view, uint64_t addr, size_t* count);
- BINARYNINJACOREAPI uint64_t* BNGetDataReferencesFromInRange(BNBinaryView* view, uint64_t addr, uint64_t len, size_t* count);
+ BINARYNINJACOREAPI uint64_t* BNGetDataReferencesFromInRange(
+ BNBinaryView* view, uint64_t addr, uint64_t len, size_t* count);
BINARYNINJACOREAPI void BNAddUserDataReference(BNBinaryView* view, uint64_t fromAddr, uint64_t toAddr);
BINARYNINJACOREAPI void BNRemoveUserDataReference(BNBinaryView* view, uint64_t fromAddr, uint64_t toAddr);
BINARYNINJACOREAPI void BNFreeDataReferences(uint64_t* refs);
BINARYNINJACOREAPI void BNFreeTypeReferences(BNTypeReferenceSource* refs, size_t count);
- BINARYNINJACOREAPI void BNFreeTypeFieldReferenceSizeInfo(
- BNTypeFieldReferenceSizeInfo* refs, size_t count);
- BINARYNINJACOREAPI void BNFreeTypeFieldReferenceTypeInfo(
- BNTypeFieldReferenceTypeInfo* refs, size_t count);
+ BINARYNINJACOREAPI void BNFreeTypeFieldReferenceSizeInfo(BNTypeFieldReferenceSizeInfo* refs, size_t count);
+ BINARYNINJACOREAPI void BNFreeTypeFieldReferenceTypeInfo(BNTypeFieldReferenceTypeInfo* refs, size_t count);
BINARYNINJACOREAPI void BNFreeTypeFieldReferenceSizes(size_t* refs, size_t count);
- BINARYNINJACOREAPI void BNFreeTypeFieldReferenceTypes(BNTypeWithConfidence* refs,
- size_t count);
+ BINARYNINJACOREAPI void BNFreeTypeFieldReferenceTypes(BNTypeWithConfidence* refs, size_t count);
// References to type
- BINARYNINJACOREAPI BNReferenceSource* BNGetCodeReferencesForType(BNBinaryView* view, BNQualifiedName* type, size_t* count);
+ BINARYNINJACOREAPI BNReferenceSource* BNGetCodeReferencesForType(
+ BNBinaryView* view, BNQualifiedName* type, size_t* count);
BINARYNINJACOREAPI uint64_t* BNGetDataReferencesForType(BNBinaryView* view, BNQualifiedName* type, size_t* count);
- BINARYNINJACOREAPI BNTypeReferenceSource* BNGetTypeReferencesForType(BNBinaryView* view, BNQualifiedName* type, size_t* count);
+ BINARYNINJACOREAPI BNTypeReferenceSource* BNGetTypeReferencesForType(
+ BNBinaryView* view, BNQualifiedName* type, size_t* count);
// References to type field
- BINARYNINJACOREAPI BNTypeFieldReference* BNGetCodeReferencesForTypeField(BNBinaryView* view,
- BNQualifiedName* type, uint64_t offset, size_t* count);
- BINARYNINJACOREAPI uint64_t* BNGetDataReferencesForTypeField(BNBinaryView* view,
- BNQualifiedName* type, uint64_t offset, size_t* count);
- BINARYNINJACOREAPI BNTypeReferenceSource* BNGetTypeReferencesForTypeField(BNBinaryView* view,
- BNQualifiedName* type, uint64_t offset, size_t* count);
+ BINARYNINJACOREAPI BNTypeFieldReference* BNGetCodeReferencesForTypeField(
+ BNBinaryView* view, BNQualifiedName* type, uint64_t offset, size_t* count);
+ BINARYNINJACOREAPI uint64_t* BNGetDataReferencesForTypeField(
+ BNBinaryView* view, BNQualifiedName* type, uint64_t offset, size_t* count);
+ BINARYNINJACOREAPI BNTypeReferenceSource* BNGetTypeReferencesForTypeField(
+ BNBinaryView* view, BNQualifiedName* type, uint64_t offset, size_t* count);
- BINARYNINJACOREAPI BNTypeReferenceSource* BNGetCodeReferencesForTypeFrom(BNBinaryView* view, BNReferenceSource* addr, size_t* count);
- BINARYNINJACOREAPI BNTypeReferenceSource* BNGetCodeReferencesForTypeFromInRange(BNBinaryView* view, BNReferenceSource* addr, uint64_t len, size_t* count);
- BINARYNINJACOREAPI BNTypeReferenceSource* BNGetCodeReferencesForTypeFieldsFrom(BNBinaryView* view, BNReferenceSource* addr, size_t* count);
- BINARYNINJACOREAPI BNTypeReferenceSource* BNGetCodeReferencesForTypeFieldsFromInRange(BNBinaryView* view, BNReferenceSource* addr, uint64_t len, size_t* count);
+ BINARYNINJACOREAPI BNTypeReferenceSource* BNGetCodeReferencesForTypeFrom(
+ BNBinaryView* view, BNReferenceSource* addr, size_t* count);
+ BINARYNINJACOREAPI BNTypeReferenceSource* BNGetCodeReferencesForTypeFromInRange(
+ BNBinaryView* view, BNReferenceSource* addr, uint64_t len, size_t* count);
+ BINARYNINJACOREAPI BNTypeReferenceSource* BNGetCodeReferencesForTypeFieldsFrom(
+ BNBinaryView* view, BNReferenceSource* addr, size_t* count);
+ BINARYNINJACOREAPI BNTypeReferenceSource* BNGetCodeReferencesForTypeFieldsFromInRange(
+ BNBinaryView* view, BNReferenceSource* addr, uint64_t len, size_t* count);
- BINARYNINJACOREAPI uint64_t* BNGetAllFieldsReferenced(BNBinaryView* view,
- BNQualifiedName* type, size_t* count);
+ BINARYNINJACOREAPI uint64_t* BNGetAllFieldsReferenced(BNBinaryView* view, BNQualifiedName* type, size_t* count);
BINARYNINJACOREAPI BNTypeFieldReferenceSizeInfo* BNGetAllSizesReferenced(
- BNBinaryView* view, BNQualifiedName* type, size_t* count);
+ BNBinaryView* view, BNQualifiedName* type, size_t* count);
BINARYNINJACOREAPI BNTypeFieldReferenceTypeInfo* BNGetAllTypesReferenced(
- BNBinaryView* view, BNQualifiedName* type, size_t* count);
+ BNBinaryView* view, BNQualifiedName* type, size_t* count);
BINARYNINJACOREAPI size_t* BNGetSizesReferenced(
- BNBinaryView* view, BNQualifiedName* type, uint64_t offset, size_t* count);
+ BNBinaryView* view, BNQualifiedName* type, uint64_t offset, size_t* count);
BINARYNINJACOREAPI BNTypeWithConfidence* BNGetTypesReferenced(
- BNBinaryView* view, BNQualifiedName* type, uint64_t offset, size_t* count);
+ BNBinaryView* view, BNQualifiedName* type, uint64_t offset, size_t* count);
BINARYNINJACOREAPI void BNRegisterGlobalFunctionRecognizer(BNFunctionRecognizer* rec);
BINARYNINJACOREAPI bool BNGetStringAtAddress(BNBinaryView* view, uint64_t addr, BNStringReference* strRef);
BINARYNINJACOREAPI BNStringReference* BNGetStrings(BNBinaryView* view, size_t* count);
- BINARYNINJACOREAPI BNStringReference* BNGetStringsInRange(BNBinaryView* view, uint64_t start, uint64_t len, size_t* count);
+ BINARYNINJACOREAPI BNStringReference* BNGetStringsInRange(
+ BNBinaryView* view, uint64_t start, uint64_t len, size_t* count);
BINARYNINJACOREAPI void BNFreeStringReferenceList(BNStringReference* strings);
BINARYNINJACOREAPI BNVariableNameAndType* BNGetStackLayout(BNFunction* func, size_t* count);
BINARYNINJACOREAPI void BNFreeVariableNameAndTypeList(BNVariableNameAndType* vars, size_t count);
- BINARYNINJACOREAPI void BNCreateAutoStackVariable(BNFunction* func, int64_t offset,
- BNTypeWithConfidence* type, const char* name);
- BINARYNINJACOREAPI void BNCreateUserStackVariable(BNFunction* func, int64_t offset,
- BNTypeWithConfidence* type, const char* name);
+ BINARYNINJACOREAPI void BNCreateAutoStackVariable(
+ BNFunction* func, int64_t offset, BNTypeWithConfidence* type, const char* name);
+ BINARYNINJACOREAPI void BNCreateUserStackVariable(
+ BNFunction* func, int64_t offset, BNTypeWithConfidence* type, const char* name);
BINARYNINJACOREAPI void BNDeleteAutoStackVariable(BNFunction* func, int64_t offset);
BINARYNINJACOREAPI void BNDeleteUserStackVariable(BNFunction* func, int64_t offset);
- BINARYNINJACOREAPI bool BNGetStackVariableAtFrameOffset(BNFunction* func, BNArchitecture* arch, uint64_t addr,
- int64_t offset, BNVariableNameAndType* var);
+ BINARYNINJACOREAPI bool BNGetStackVariableAtFrameOffset(
+ BNFunction* func, BNArchitecture* arch, uint64_t addr, int64_t offset, BNVariableNameAndType* var);
BINARYNINJACOREAPI void BNFreeVariableNameAndType(BNVariableNameAndType* var);
BINARYNINJACOREAPI BNVariableNameAndType* BNGetFunctionVariables(BNFunction* func, size_t* count);
- BINARYNINJACOREAPI void BNCreateAutoVariable(BNFunction* func, const BNVariable* var, BNTypeWithConfidence* type,
- const char* name, bool ignoreDisjointUses);
- BINARYNINJACOREAPI void BNCreateUserVariable(BNFunction* func, const BNVariable* var, BNTypeWithConfidence* type,
- const char* name, bool ignoreDisjointUses);
+ BINARYNINJACOREAPI void BNCreateAutoVariable(
+ BNFunction* func, const BNVariable* var, BNTypeWithConfidence* type, const char* name, bool ignoreDisjointUses);
+ BINARYNINJACOREAPI void BNCreateUserVariable(
+ BNFunction* func, const BNVariable* var, BNTypeWithConfidence* type, const char* name, bool ignoreDisjointUses);
BINARYNINJACOREAPI void BNDeleteUserVariable(BNFunction* func, const BNVariable* var);
BINARYNINJACOREAPI bool BNIsVariableUserDefined(BNFunction* func, const BNVariable* var);
BINARYNINJACOREAPI BNTypeWithConfidence BNGetVariableType(BNFunction* func, const BNVariable* var);
@@ -3728,60 +3789,62 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI char* BNGetRealVariableName(BNFunction* func, BNArchitecture* arch, const BNVariable* var);
BINARYNINJACOREAPI uint64_t BNToVariableIdentifier(const BNVariable* var);
BINARYNINJACOREAPI BNVariable BNFromVariableIdentifier(uint64_t id);
- BINARYNINJACOREAPI BNDeadStoreElimination BNGetFunctionVariableDeadStoreElimination(BNFunction* func,
- const BNVariable* var);
- BINARYNINJACOREAPI void BNSetFunctionVariableDeadStoreElimination(BNFunction* func,
- const BNVariable* var, BNDeadStoreElimination mode);
+ BINARYNINJACOREAPI BNDeadStoreElimination BNGetFunctionVariableDeadStoreElimination(
+ BNFunction* func, const BNVariable* var);
+ BINARYNINJACOREAPI void BNSetFunctionVariableDeadStoreElimination(
+ BNFunction* func, const BNVariable* var, BNDeadStoreElimination mode);
BINARYNINJACOREAPI BNReferenceSource* BNGetFunctionCallSites(BNFunction* func, size_t* count);
BINARYNINJACOREAPI uint64_t* BNGetCallees(BNBinaryView* view, BNReferenceSource* callSite, size_t* count);
BINARYNINJACOREAPI BNReferenceSource* BNGetCallers(BNBinaryView* view, uint64_t callee, size_t* count);
BINARYNINJACOREAPI void BNSetAutoIndirectBranches(BNFunction* func, BNArchitecture* sourceArch, uint64_t source,
- BNArchitectureAndAddress* branches, size_t count);
+ BNArchitectureAndAddress* branches, size_t count);
BINARYNINJACOREAPI void BNSetUserIndirectBranches(BNFunction* func, BNArchitecture* sourceArch, uint64_t source,
- BNArchitectureAndAddress* branches, size_t count);
+ BNArchitectureAndAddress* branches, size_t count);
BINARYNINJACOREAPI BNIndirectBranchInfo* BNGetIndirectBranches(BNFunction* func, size_t* count);
- BINARYNINJACOREAPI BNIndirectBranchInfo* BNGetIndirectBranchesAt(BNFunction* func, BNArchitecture* arch,
- uint64_t addr, size_t* count);
+ BINARYNINJACOREAPI BNIndirectBranchInfo* BNGetIndirectBranchesAt(
+ BNFunction* func, BNArchitecture* arch, uint64_t addr, size_t* count);
BINARYNINJACOREAPI void BNFreeIndirectBranchList(BNIndirectBranchInfo* branches);
BINARYNINJACOREAPI uint64_t* BNGetUnresolvedIndirectBranches(BNFunction* func, size_t* count);
BINARYNINJACOREAPI bool BNHasUnresolvedIndirectBranches(BNFunction* func);
- BINARYNINJACOREAPI void BNSetAutoCallTypeAdjustment(BNFunction* func, BNArchitecture* arch, uint64_t addr,
- BNTypeWithConfidence* type);
- BINARYNINJACOREAPI void BNSetUserCallTypeAdjustment(BNFunction* func, BNArchitecture* arch, uint64_t addr,
- BNTypeWithConfidence* type);
- BINARYNINJACOREAPI void BNSetAutoCallStackAdjustment(BNFunction* func, BNArchitecture* arch, uint64_t addr,
- int64_t adjust, uint8_t confidence);
- BINARYNINJACOREAPI void BNSetUserCallStackAdjustment(BNFunction* func, BNArchitecture* arch, uint64_t addr,
- int64_t adjust, uint8_t confidence);
- BINARYNINJACOREAPI void BNSetAutoCallRegisterStackAdjustment(BNFunction* func, BNArchitecture* arch, uint64_t addr,
- BNRegisterStackAdjustment* adjust, size_t count);
- BINARYNINJACOREAPI void BNSetUserCallRegisterStackAdjustment(BNFunction* func, BNArchitecture* arch, uint64_t addr,
- BNRegisterStackAdjustment* adjust, size_t count);
- BINARYNINJACOREAPI void BNSetAutoCallRegisterStackAdjustmentForRegisterStack(BNFunction* func,
- BNArchitecture* arch, uint64_t addr, uint32_t regStack, int32_t adjust, uint8_t confidence);
- BINARYNINJACOREAPI void BNSetUserCallRegisterStackAdjustmentForRegisterStack(BNFunction* func,
- BNArchitecture* arch, uint64_t addr, uint32_t regStack, int32_t adjust, uint8_t confidence);
+ BINARYNINJACOREAPI void BNSetAutoCallTypeAdjustment(
+ BNFunction* func, BNArchitecture* arch, uint64_t addr, BNTypeWithConfidence* type);
+ BINARYNINJACOREAPI void BNSetUserCallTypeAdjustment(
+ BNFunction* func, BNArchitecture* arch, uint64_t addr, BNTypeWithConfidence* type);
+ BINARYNINJACOREAPI void BNSetAutoCallStackAdjustment(
+ BNFunction* func, BNArchitecture* arch, uint64_t addr, int64_t adjust, uint8_t confidence);
+ BINARYNINJACOREAPI void BNSetUserCallStackAdjustment(
+ BNFunction* func, BNArchitecture* arch, uint64_t addr, int64_t adjust, uint8_t confidence);
+ BINARYNINJACOREAPI void BNSetAutoCallRegisterStackAdjustment(
+ BNFunction* func, BNArchitecture* arch, uint64_t addr, BNRegisterStackAdjustment* adjust, size_t count);
+ BINARYNINJACOREAPI void BNSetUserCallRegisterStackAdjustment(
+ BNFunction* func, BNArchitecture* arch, uint64_t addr, BNRegisterStackAdjustment* adjust, size_t count);
+ BINARYNINJACOREAPI void BNSetAutoCallRegisterStackAdjustmentForRegisterStack(
+ BNFunction* func, BNArchitecture* arch, uint64_t addr, uint32_t regStack, int32_t adjust, uint8_t confidence);
+ BINARYNINJACOREAPI void BNSetUserCallRegisterStackAdjustmentForRegisterStack(
+ BNFunction* func, BNArchitecture* arch, uint64_t addr, uint32_t regStack, int32_t adjust, uint8_t confidence);
- BINARYNINJACOREAPI BNTypeWithConfidence BNGetCallTypeAdjustment(BNFunction* func, BNArchitecture* arch, uint64_t addr);
- BINARYNINJACOREAPI BNOffsetWithConfidence BNGetCallStackAdjustment(BNFunction* func, BNArchitecture* arch, uint64_t addr);
- BINARYNINJACOREAPI BNRegisterStackAdjustment* BNGetCallRegisterStackAdjustment(BNFunction* func,
- BNArchitecture* arch, uint64_t addr, size_t* count);
- BINARYNINJACOREAPI BNRegisterStackAdjustment BNGetCallRegisterStackAdjustmentForRegisterStack(BNFunction* func,
- BNArchitecture* arch, uint64_t addr, uint32_t regStack);
+ BINARYNINJACOREAPI BNTypeWithConfidence BNGetCallTypeAdjustment(
+ BNFunction* func, BNArchitecture* arch, uint64_t addr);
+ BINARYNINJACOREAPI BNOffsetWithConfidence BNGetCallStackAdjustment(
+ BNFunction* func, BNArchitecture* arch, uint64_t addr);
+ BINARYNINJACOREAPI BNRegisterStackAdjustment* BNGetCallRegisterStackAdjustment(
+ BNFunction* func, BNArchitecture* arch, uint64_t addr, size_t* count);
+ BINARYNINJACOREAPI BNRegisterStackAdjustment BNGetCallRegisterStackAdjustmentForRegisterStack(
+ BNFunction* func, BNArchitecture* arch, uint64_t addr, uint32_t regStack);
BINARYNINJACOREAPI bool BNIsCallInstruction(BNFunction* func, BNArchitecture* arch, uint64_t addr);
- BINARYNINJACOREAPI BNInstructionTextLine* BNGetFunctionBlockAnnotations(BNFunction* func, BNArchitecture* arch,
- uint64_t addr, size_t* count);
+ BINARYNINJACOREAPI BNInstructionTextLine* BNGetFunctionBlockAnnotations(
+ BNFunction* func, BNArchitecture* arch, uint64_t addr, size_t* count);
- BINARYNINJACOREAPI BNIntegerDisplayType BNGetIntegerConstantDisplayType(BNFunction* func, BNArchitecture* arch,
- uint64_t instrAddr, uint64_t value, size_t operand);
- BINARYNINJACOREAPI void BNSetIntegerConstantDisplayType(BNFunction* func, BNArchitecture* arch,
- uint64_t instrAddr, uint64_t value, size_t operand, BNIntegerDisplayType type);
+ BINARYNINJACOREAPI BNIntegerDisplayType BNGetIntegerConstantDisplayType(
+ BNFunction* func, BNArchitecture* arch, uint64_t instrAddr, uint64_t value, size_t operand);
+ BINARYNINJACOREAPI void BNSetIntegerConstantDisplayType(BNFunction* func, BNArchitecture* arch, uint64_t instrAddr,
+ uint64_t value, size_t operand, BNIntegerDisplayType type);
BINARYNINJACOREAPI bool BNIsFunctionTooLarge(BNFunction* func);
BINARYNINJACOREAPI bool BNIsFunctionAnalysisSkipped(BNFunction* func);
@@ -3799,9 +3862,10 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI bool BNGetNewAutoFunctionAnalysisSuppressed(BNBinaryView* view);
BINARYNINJACOREAPI void BNSetNewAutoFunctionAnalysisSuppressed(BNBinaryView* view, bool suppress);
- BINARYNINJACOREAPI BNAnalysisCompletionEvent* BNAddAnalysisCompletionEvent(BNBinaryView* view, void* ctxt,
- void (*callback)(void* ctxt));
- BINARYNINJACOREAPI BNAnalysisCompletionEvent* BNNewAnalysisCompletionEventReference(BNAnalysisCompletionEvent* event);
+ BINARYNINJACOREAPI BNAnalysisCompletionEvent* BNAddAnalysisCompletionEvent(
+ BNBinaryView* view, void* ctxt, void (*callback)(void* ctxt));
+ BINARYNINJACOREAPI BNAnalysisCompletionEvent* BNNewAnalysisCompletionEventReference(
+ BNAnalysisCompletionEvent* event);
BINARYNINJACOREAPI void BNFreeAnalysisCompletionEvent(BNAnalysisCompletionEvent* event);
BINARYNINJACOREAPI void BNCancelAnalysisCompletionEvent(BNAnalysisCompletionEvent* event);
@@ -3820,78 +3884,78 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI uint64_t BNGetPreviousDataBeforeAddress(BNBinaryView* view, uint64_t addr);
BINARYNINJACOREAPI uint64_t BNGetPreviousDataVariableStartBeforeAddress(BNBinaryView* view, uint64_t addr);
- BINARYNINJACOREAPI BNLinearViewObject* BNCreateLinearViewDisassembly(BNBinaryView* view,
- BNDisassemblySettings* settings);
- BINARYNINJACOREAPI BNLinearViewObject* BNCreateLinearViewLiftedIL(BNBinaryView* view,
- BNDisassemblySettings* settings);
- BINARYNINJACOREAPI BNLinearViewObject* BNCreateLinearViewLowLevelIL(BNBinaryView* view,
- BNDisassemblySettings* settings);
- BINARYNINJACOREAPI BNLinearViewObject* BNCreateLinearViewLowLevelILSSAForm(BNBinaryView* view,
- BNDisassemblySettings* settings);
- BINARYNINJACOREAPI BNLinearViewObject* BNCreateLinearViewMediumLevelIL(BNBinaryView* view,
- BNDisassemblySettings* settings);
- BINARYNINJACOREAPI BNLinearViewObject* BNCreateLinearViewMediumLevelILSSAForm(BNBinaryView* view,
- BNDisassemblySettings* settings);
- BINARYNINJACOREAPI BNLinearViewObject* BNCreateLinearViewMappedMediumLevelIL(BNBinaryView* view,
- BNDisassemblySettings* settings);
- BINARYNINJACOREAPI BNLinearViewObject* BNCreateLinearViewMappedMediumLevelILSSAForm(BNBinaryView* view,
- BNDisassemblySettings* settings);
- BINARYNINJACOREAPI BNLinearViewObject* BNCreateLinearViewHighLevelIL(BNBinaryView* view,
- BNDisassemblySettings* settings);
- BINARYNINJACOREAPI BNLinearViewObject* BNCreateLinearViewHighLevelILSSAForm(BNBinaryView* view,
- BNDisassemblySettings* settings);
- BINARYNINJACOREAPI BNLinearViewObject* BNCreateLinearViewLanguageRepresentation(BNBinaryView* view,
- BNDisassemblySettings* settings);
- BINARYNINJACOREAPI BNLinearViewObject* BNCreateLinearViewDataOnly(BNBinaryView* view,
- BNDisassemblySettings* settings);
+ BINARYNINJACOREAPI BNLinearViewObject* BNCreateLinearViewDisassembly(
+ BNBinaryView* view, BNDisassemblySettings* settings);
+ BINARYNINJACOREAPI BNLinearViewObject* BNCreateLinearViewLiftedIL(
+ BNBinaryView* view, BNDisassemblySettings* settings);
+ BINARYNINJACOREAPI BNLinearViewObject* BNCreateLinearViewLowLevelIL(
+ BNBinaryView* view, BNDisassemblySettings* settings);
+ BINARYNINJACOREAPI BNLinearViewObject* BNCreateLinearViewLowLevelILSSAForm(
+ BNBinaryView* view, BNDisassemblySettings* settings);
+ BINARYNINJACOREAPI BNLinearViewObject* BNCreateLinearViewMediumLevelIL(
+ BNBinaryView* view, BNDisassemblySettings* settings);
+ BINARYNINJACOREAPI BNLinearViewObject* BNCreateLinearViewMediumLevelILSSAForm(
+ BNBinaryView* view, BNDisassemblySettings* settings);
+ BINARYNINJACOREAPI BNLinearViewObject* BNCreateLinearViewMappedMediumLevelIL(
+ BNBinaryView* view, BNDisassemblySettings* settings);
+ BINARYNINJACOREAPI BNLinearViewObject* BNCreateLinearViewMappedMediumLevelILSSAForm(
+ BNBinaryView* view, BNDisassemblySettings* settings);
+ BINARYNINJACOREAPI BNLinearViewObject* BNCreateLinearViewHighLevelIL(
+ BNBinaryView* view, BNDisassemblySettings* settings);
+ BINARYNINJACOREAPI BNLinearViewObject* BNCreateLinearViewHighLevelILSSAForm(
+ BNBinaryView* view, BNDisassemblySettings* settings);
+ BINARYNINJACOREAPI BNLinearViewObject* BNCreateLinearViewLanguageRepresentation(
+ BNBinaryView* view, BNDisassemblySettings* settings);
+ BINARYNINJACOREAPI BNLinearViewObject* BNCreateLinearViewDataOnly(
+ BNBinaryView* view, BNDisassemblySettings* settings);
BINARYNINJACOREAPI BNLinearViewObject* BNCreateLinearViewSingleFunctionDisassembly(
- BNFunction* func, BNDisassemblySettings* settings);
+ BNFunction* func, BNDisassemblySettings* settings);
BINARYNINJACOREAPI BNLinearViewObject* BNCreateLinearViewSingleFunctionLiftedIL(
- BNFunction* func, BNDisassemblySettings* settings);
+ BNFunction* func, BNDisassemblySettings* settings);
BINARYNINJACOREAPI BNLinearViewObject* BNCreateLinearViewSingleFunctionLowLevelIL(
- BNFunction* func, BNDisassemblySettings* settings);
+ BNFunction* func, BNDisassemblySettings* settings);
BINARYNINJACOREAPI BNLinearViewObject* BNCreateLinearViewSingleFunctionLowLevelILSSAForm(
- BNFunction* func, BNDisassemblySettings* settings);
+ BNFunction* func, BNDisassemblySettings* settings);
BINARYNINJACOREAPI BNLinearViewObject* BNCreateLinearViewSingleFunctionMediumLevelIL(
- BNFunction* func, BNDisassemblySettings* settings);
+ BNFunction* func, BNDisassemblySettings* settings);
BINARYNINJACOREAPI BNLinearViewObject* BNCreateLinearViewSingleFunctionMediumLevelILSSAForm(
- BNFunction* func, BNDisassemblySettings* settings);
+ BNFunction* func, BNDisassemblySettings* settings);
BINARYNINJACOREAPI BNLinearViewObject* BNCreateLinearViewSingleFunctionMappedMediumLevelIL(
- BNFunction* func, BNDisassemblySettings* settings);
+ BNFunction* func, BNDisassemblySettings* settings);
BINARYNINJACOREAPI BNLinearViewObject* BNCreateLinearViewSingleFunctionMappedMediumLevelILSSAForm(
- BNFunction* func, BNDisassemblySettings* settings);
+ BNFunction* func, BNDisassemblySettings* settings);
BINARYNINJACOREAPI BNLinearViewObject* BNCreateLinearViewSingleFunctionHighLevelIL(
- BNFunction* func, BNDisassemblySettings* settings);
+ BNFunction* func, BNDisassemblySettings* settings);
BINARYNINJACOREAPI BNLinearViewObject* BNCreateLinearViewSingleFunctionHighLevelILSSAForm(
- BNFunction* func, BNDisassemblySettings* settings);
+ BNFunction* func, BNDisassemblySettings* settings);
BINARYNINJACOREAPI BNLinearViewObject* BNCreateLinearViewSingleFunctionLanguageRepresentation(
- BNFunction* func, BNDisassemblySettings* settings);
+ BNFunction* func, BNDisassemblySettings* settings);
BINARYNINJACOREAPI BNLinearViewObject* BNNewLinearViewObjectReference(BNLinearViewObject* obj);
BINARYNINJACOREAPI void BNFreeLinearViewObject(BNLinearViewObject* obj);
BINARYNINJACOREAPI BNLinearViewObject* BNGetFirstLinearViewObjectChild(BNLinearViewObject* obj);
BINARYNINJACOREAPI BNLinearViewObject* BNGetLastLinearViewObjectChild(BNLinearViewObject* obj);
- BINARYNINJACOREAPI BNLinearViewObject* BNGetPreviousLinearViewObjectChild(BNLinearViewObject* parent,
- BNLinearViewObject* child);
- BINARYNINJACOREAPI BNLinearViewObject* BNGetNextLinearViewObjectChild(BNLinearViewObject* parent,
- BNLinearViewObject* child);
- BINARYNINJACOREAPI BNLinearViewObject* BNGetLinearViewObjectChildForAddress(BNLinearViewObject* parent,
- uint64_t addr);
- BINARYNINJACOREAPI BNLinearViewObject* BNGetLinearViewObjectChildForIdentifier(BNLinearViewObject* parent,
- BNLinearViewObjectIdentifier* id);
- BINARYNINJACOREAPI BNLinearDisassemblyLine* BNGetLinearViewObjectLines(BNLinearViewObject* obj,
- BNLinearViewObject* prev, BNLinearViewObject* next, size_t* count);
+ BINARYNINJACOREAPI BNLinearViewObject* BNGetPreviousLinearViewObjectChild(
+ BNLinearViewObject* parent, BNLinearViewObject* child);
+ BINARYNINJACOREAPI BNLinearViewObject* BNGetNextLinearViewObjectChild(
+ BNLinearViewObject* parent, BNLinearViewObject* child);
+ BINARYNINJACOREAPI BNLinearViewObject* BNGetLinearViewObjectChildForAddress(
+ BNLinearViewObject* parent, uint64_t addr);
+ BINARYNINJACOREAPI BNLinearViewObject* BNGetLinearViewObjectChildForIdentifier(
+ BNLinearViewObject* parent, BNLinearViewObjectIdentifier* id);
+ BINARYNINJACOREAPI BNLinearDisassemblyLine* BNGetLinearViewObjectLines(
+ BNLinearViewObject* obj, BNLinearViewObject* prev, BNLinearViewObject* next, size_t* count);
BINARYNINJACOREAPI void BNFreeLinearDisassemblyLines(BNLinearDisassemblyLine* lines, size_t count);
BINARYNINJACOREAPI uint64_t BNGetLinearViewObjectStart(BNLinearViewObject* obj);
BINARYNINJACOREAPI uint64_t BNGetLinearViewObjectEnd(BNLinearViewObject* obj);
BINARYNINJACOREAPI BNLinearViewObjectIdentifier BNGetLinearViewObjectIdentifier(BNLinearViewObject* obj);
BINARYNINJACOREAPI void BNFreeLinearViewObjectIdentifier(BNLinearViewObjectIdentifier* id);
- BINARYNINJACOREAPI int BNCompareLinearViewObjectChildren(BNLinearViewObject* obj,
- BNLinearViewObject* a, BNLinearViewObject* b);
+ BINARYNINJACOREAPI int BNCompareLinearViewObjectChildren(
+ BNLinearViewObject* obj, BNLinearViewObject* a, BNLinearViewObject* b);
BINARYNINJACOREAPI uint64_t BNGetLinearViewObjectOrderingIndexTotal(BNLinearViewObject* obj);
- BINARYNINJACOREAPI uint64_t BNGetLinearViewObjectOrderingIndexForChild(BNLinearViewObject* parent,
- BNLinearViewObject* child);
- BINARYNINJACOREAPI BNLinearViewObject* BNGetLinearViewObjectChildForOrderingIndex(BNLinearViewObject* parent,
- uint64_t idx);
+ BINARYNINJACOREAPI uint64_t BNGetLinearViewObjectOrderingIndexForChild(
+ BNLinearViewObject* parent, BNLinearViewObject* child);
+ BINARYNINJACOREAPI BNLinearViewObject* BNGetLinearViewObjectChildForOrderingIndex(
+ BNLinearViewObject* parent, uint64_t idx);
BINARYNINJACOREAPI BNLinearViewCursor* BNCreateLinearViewCursor(BNLinearViewObject* root);
BINARYNINJACOREAPI BNLinearViewCursor* BNDuplicateLinearViewCursor(BNLinearViewCursor* cursor);
@@ -3900,7 +3964,8 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI bool BNIsLinearViewCursorBeforeBegin(BNLinearViewCursor* cursor);
BINARYNINJACOREAPI bool BNIsLinearViewCursorAfterEnd(BNLinearViewCursor* cursor);
BINARYNINJACOREAPI BNLinearViewObject* BNGetLinearViewCursorCurrentObject(BNLinearViewCursor* cursor);
- BINARYNINJACOREAPI BNLinearViewObjectIdentifier* BNGetLinearViewCursorPath(BNLinearViewCursor* cursor, size_t* count);
+ BINARYNINJACOREAPI BNLinearViewObjectIdentifier* BNGetLinearViewCursorPath(
+ BNLinearViewCursor* cursor, size_t* count);
BINARYNINJACOREAPI void BNFreeLinearViewCursorPath(BNLinearViewObjectIdentifier* objs, size_t count);
BINARYNINJACOREAPI BNLinearViewObject** BNGetLinearViewCursorPathObjects(BNLinearViewCursor* cursor, size_t* count);
BINARYNINJACOREAPI void BNFreeLinearViewCursorPathObjects(BNLinearViewObject** objs, size_t count);
@@ -3909,13 +3974,13 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI void BNSeekLinearViewCursorToBegin(BNLinearViewCursor* cursor);
BINARYNINJACOREAPI void BNSeekLinearViewCursorToEnd(BNLinearViewCursor* cursor);
BINARYNINJACOREAPI void BNSeekLinearViewCursorToAddress(BNLinearViewCursor* cursor, uint64_t addr);
- BINARYNINJACOREAPI bool BNSeekLinearViewCursorToPath(BNLinearViewCursor* cursor,
- BNLinearViewObjectIdentifier* ids, size_t count);
- BINARYNINJACOREAPI bool BNSeekLinearViewCursorToPathAndAddress(BNLinearViewCursor* cursor,
- BNLinearViewObjectIdentifier* ids, size_t count, uint64_t addr);
+ BINARYNINJACOREAPI bool BNSeekLinearViewCursorToPath(
+ BNLinearViewCursor* cursor, BNLinearViewObjectIdentifier* ids, size_t count);
+ BINARYNINJACOREAPI bool BNSeekLinearViewCursorToPathAndAddress(
+ BNLinearViewCursor* cursor, BNLinearViewObjectIdentifier* ids, size_t count, uint64_t addr);
BINARYNINJACOREAPI bool BNSeekLinearViewCursorToCursorPath(BNLinearViewCursor* cursor, BNLinearViewCursor* path);
- BINARYNINJACOREAPI bool BNSeekLinearViewCursorToCursorPathAndAddress(BNLinearViewCursor* cursor,
- BNLinearViewCursor* path, uint64_t addr);
+ BINARYNINJACOREAPI bool BNSeekLinearViewCursorToCursorPathAndAddress(
+ BNLinearViewCursor* cursor, BNLinearViewCursor* path, uint64_t addr);
BINARYNINJACOREAPI void BNSeekLinearViewCursorToOrderingIndex(BNLinearViewCursor* cursor, uint64_t idx);
BINARYNINJACOREAPI bool BNLinearViewCursorNext(BNLinearViewCursor* cursor);
BINARYNINJACOREAPI bool BNLinearViewCursorPrevious(BNLinearViewCursor* cursor);
@@ -3931,10 +3996,10 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI void BNFreeDataVariablesAndName(BNDataVariableAndName* vars, size_t count);
BINARYNINJACOREAPI bool BNGetDataVariableAtAddress(BNBinaryView* view, uint64_t addr, BNDataVariable* var);
- BINARYNINJACOREAPI bool BNParseTypeString(BNBinaryView* view, const char* text,
- BNQualifiedNameAndType* result, char** errors, BNQualifiedNameList* typesAllowRedefinition);
+ BINARYNINJACOREAPI bool BNParseTypeString(BNBinaryView* view, const char* text, BNQualifiedNameAndType* result,
+ char** errors, BNQualifiedNameList* typesAllowRedefinition);
BINARYNINJACOREAPI bool BNParseTypesString(BNBinaryView* view, const char* text, BNTypeParserResult* result,
- char** errors, BNQualifiedNameList* typesAllowRedefinition);
+ char** errors, BNQualifiedNameList* typesAllowRedefinition);
BINARYNINJACOREAPI void BNFreeQualifiedNameAndType(BNQualifiedNameAndType* obj);
BINARYNINJACOREAPI void BNFreeQualifiedNameAndTypeArray(BNQualifiedNameAndType* obj, size_t count);
@@ -3947,12 +4012,13 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI char* BNGetAnalysisTypeId(BNBinaryView* view, BNQualifiedName* name);
BINARYNINJACOREAPI BNQualifiedName BNGetAnalysisTypeNameById(BNBinaryView* view, const char* id);
BINARYNINJACOREAPI bool BNIsAnalysisTypeAutoDefined(BNBinaryView* view, BNQualifiedName* name);
- BINARYNINJACOREAPI BNQualifiedName BNDefineAnalysisType(BNBinaryView* view, const char* id,
- BNQualifiedName* defaultName, BNType* type);
+ BINARYNINJACOREAPI BNQualifiedName BNDefineAnalysisType(
+ BNBinaryView* view, const char* id, BNQualifiedName* defaultName, BNType* type);
BINARYNINJACOREAPI void BNDefineUserAnalysisType(BNBinaryView* view, BNQualifiedName* name, BNType* type);
BINARYNINJACOREAPI void BNUndefineAnalysisType(BNBinaryView* view, const char* id);
BINARYNINJACOREAPI void BNUndefineUserAnalysisType(BNBinaryView* view, BNQualifiedName* name);
- BINARYNINJACOREAPI void BNRenameAnalysisType(BNBinaryView* view, BNQualifiedName* oldName, BNQualifiedName* newName);
+ BINARYNINJACOREAPI void BNRenameAnalysisType(
+ BNBinaryView* view, BNQualifiedName* oldName, BNQualifiedName* newName);
BINARYNINJACOREAPI char* BNGenerateAutoTypeId(const char* source, BNQualifiedName* name);
BINARYNINJACOREAPI char* BNGenerateAutoPlatformTypeId(BNPlatform* platform, BNQualifiedName* name);
BINARYNINJACOREAPI char* BNGenerateAutoDemangledTypeId(BNQualifiedName* name);
@@ -3969,11 +4035,12 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI BNWorkflow* BNGetWorkflowForBinaryView(BNBinaryView* view);
BINARYNINJACOREAPI BNWorkflow* BNGetWorkflowForFunction(BNFunction* func);
- BINARYNINJACOREAPI BNHighlightColor BNGetInstructionHighlight(BNFunction* func, BNArchitecture* arch, uint64_t addr);
- BINARYNINJACOREAPI void BNSetAutoInstructionHighlight(BNFunction* func, BNArchitecture* arch, uint64_t addr,
- BNHighlightColor color);
- BINARYNINJACOREAPI void BNSetUserInstructionHighlight(BNFunction* func, BNArchitecture* arch, uint64_t addr,
- BNHighlightColor color);
+ BINARYNINJACOREAPI BNHighlightColor BNGetInstructionHighlight(
+ BNFunction* func, BNArchitecture* arch, uint64_t addr);
+ BINARYNINJACOREAPI void BNSetAutoInstructionHighlight(
+ BNFunction* func, BNArchitecture* arch, uint64_t addr, BNHighlightColor color);
+ BINARYNINJACOREAPI void BNSetUserInstructionHighlight(
+ BNFunction* func, BNArchitecture* arch, uint64_t addr, BNHighlightColor color);
BINARYNINJACOREAPI BNHighlightColor BNGetBasicBlockHighlight(BNBasicBlock* block);
BINARYNINJACOREAPI void BNSetAutoBasicBlockHighlight(BNBasicBlock* block, BNHighlightColor color);
BINARYNINJACOREAPI void BNSetUserBasicBlockHighlight(BNBasicBlock* block, BNHighlightColor color);
@@ -4017,7 +4084,8 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI BNTagReference* BNGetAllTagReferences(BNBinaryView* view, size_t* count);
BINARYNINJACOREAPI BNTagReference* BNGetAllAddressTagReferences(BNBinaryView* view, size_t* count);
BINARYNINJACOREAPI BNTagReference* BNGetAllFunctionTagReferences(BNBinaryView* view, size_t* count);
- BINARYNINJACOREAPI BNTagReference* BNGetAllTagReferencesOfType(BNBinaryView* view, BNTagType* tagType, size_t* count);
+ BINARYNINJACOREAPI BNTagReference* BNGetAllTagReferencesOfType(
+ BNBinaryView* view, BNTagType* tagType, size_t* count);
BINARYNINJACOREAPI BNTagReference* BNGetTagReferencesOfType(BNBinaryView* view, BNTagType* tagType, size_t* count);
BINARYNINJACOREAPI BNTagReference* BNGetDataTagReferences(BNBinaryView* view, size_t* count);
BINARYNINJACOREAPI BNTagReference* BNGetAutoDataTagReferences(BNBinaryView* view, size_t* count);
@@ -4027,12 +4095,18 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI BNTag** BNGetDataTags(BNBinaryView* view, uint64_t addr, size_t* count);
BINARYNINJACOREAPI BNTag** BNGetAutoDataTags(BNBinaryView* view, uint64_t addr, size_t* count);
BINARYNINJACOREAPI BNTag** BNGetUserDataTags(BNBinaryView* view, uint64_t addr, size_t* count);
- BINARYNINJACOREAPI BNTag** BNGetDataTagsOfType(BNBinaryView* view, uint64_t addr, BNTagType* tagType, size_t* count);
- BINARYNINJACOREAPI BNTag** BNGetAutoDataTagsOfType(BNBinaryView* view, uint64_t addr, BNTagType* tagType, size_t* count);
- BINARYNINJACOREAPI BNTag** BNGetUserDataTagsOfType(BNBinaryView* view, uint64_t addr, BNTagType* tagType, size_t* count);
- BINARYNINJACOREAPI BNTagReference* BNGetDataTagsInRange(BNBinaryView* view, uint64_t start, uint64_t end, size_t* count);
- BINARYNINJACOREAPI BNTagReference* BNGetAutoDataTagsInRange(BNBinaryView* view, uint64_t start, uint64_t end, size_t* count);
- BINARYNINJACOREAPI BNTagReference* BNGetUserDataTagsInRange(BNBinaryView* view, uint64_t start, uint64_t end, size_t* count);
+ BINARYNINJACOREAPI BNTag** BNGetDataTagsOfType(
+ BNBinaryView* view, uint64_t addr, BNTagType* tagType, size_t* count);
+ BINARYNINJACOREAPI BNTag** BNGetAutoDataTagsOfType(
+ BNBinaryView* view, uint64_t addr, BNTagType* tagType, size_t* count);
+ BINARYNINJACOREAPI BNTag** BNGetUserDataTagsOfType(
+ BNBinaryView* view, uint64_t addr, BNTagType* tagType, size_t* count);
+ BINARYNINJACOREAPI BNTagReference* BNGetDataTagsInRange(
+ BNBinaryView* view, uint64_t start, uint64_t end, size_t* count);
+ BINARYNINJACOREAPI BNTagReference* BNGetAutoDataTagsInRange(
+ BNBinaryView* view, uint64_t start, uint64_t end, size_t* count);
+ BINARYNINJACOREAPI BNTagReference* BNGetUserDataTagsInRange(
+ BNBinaryView* view, uint64_t start, uint64_t end, size_t* count);
BINARYNINJACOREAPI void BNAddAutoDataTag(BNBinaryView* view, uint64_t addr, BNTag* tag);
BINARYNINJACOREAPI void BNRemoveAutoDataTag(BNBinaryView* view, uint64_t addr, BNTag* tag);
BINARYNINJACOREAPI void BNRemoveAutoDataTagsOfType(BNBinaryView* view, uint64_t addr, BNTagType* tagType);
@@ -4042,30 +4116,42 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI size_t BNGetTagReferencesOfTypeCount(BNBinaryView* view, BNTagType* tagType);
BINARYNINJACOREAPI size_t BNGetAllTagReferencesOfTypeCount(BNBinaryView* view, BNTagType* tagType);
- BINARYNINJACOREAPI void BNGetAllTagReferenceTypeCounts(BNBinaryView* view, BNTagType*** tagTypes, size_t** counts, size_t* count);
+ BINARYNINJACOREAPI void BNGetAllTagReferenceTypeCounts(
+ BNBinaryView* view, BNTagType*** tagTypes, size_t** counts, size_t* count);
BINARYNINJACOREAPI void BNFreeTagReferenceTypeCounts(BNTagType** tagTypes, size_t* counts);
BINARYNINJACOREAPI BNTagReference* BNGetFunctionAllTagReferences(BNFunction* func, size_t* count);
- BINARYNINJACOREAPI BNTagReference* BNGetFunctionTagReferencesOfType(BNFunction* func, BNTagType* tagType, size_t* count);
+ BINARYNINJACOREAPI BNTagReference* BNGetFunctionTagReferencesOfType(
+ BNFunction* func, BNTagType* tagType, size_t* count);
BINARYNINJACOREAPI BNTagReference* BNGetAddressTagReferences(BNFunction* func, size_t* count);
BINARYNINJACOREAPI BNTagReference* BNGetAutoAddressTagReferences(BNFunction* func, size_t* count);
BINARYNINJACOREAPI BNTagReference* BNGetUserAddressTagReferences(BNFunction* func, size_t* count);
BINARYNINJACOREAPI BNTag** BNGetAddressTags(BNFunction* func, BNArchitecture* arch, uint64_t addr, size_t* count);
- BINARYNINJACOREAPI BNTag** BNGetAutoAddressTags(BNFunction* func, BNArchitecture* arch, uint64_t addr, size_t* count);
- BINARYNINJACOREAPI BNTag** BNGetUserAddressTags(BNFunction* func, BNArchitecture* arch, uint64_t addr, size_t* count);
- BINARYNINJACOREAPI BNTag** BNGetAddressTagsOfType(BNFunction* func, BNArchitecture* arch, uint64_t addr, BNTagType* tagType, size_t* count);
- BINARYNINJACOREAPI BNTag** BNGetAutoAddressTagsOfType(BNFunction* func, BNArchitecture* arch, uint64_t addr, BNTagType* tagType, size_t* count);
- BINARYNINJACOREAPI BNTag** BNGetUserAddressTagsOfType(BNFunction* func, BNArchitecture* arch, uint64_t addr, BNTagType* tagType, size_t* count);
- BINARYNINJACOREAPI BNTagReference* BNGetAddressTagsInRange(BNFunction* func, BNArchitecture* arch, uint64_t start, uint64_t end, size_t* count);
- BINARYNINJACOREAPI BNTagReference* BNGetAutoAddressTagsInRange(BNFunction* func, BNArchitecture* arch, uint64_t start, uint64_t end, size_t* count);
- BINARYNINJACOREAPI BNTagReference* BNGetUserAddressTagsInRange(BNFunction* func, BNArchitecture* arch, uint64_t start, uint64_t end, size_t* count);
+ BINARYNINJACOREAPI BNTag** BNGetAutoAddressTags(
+ BNFunction* func, BNArchitecture* arch, uint64_t addr, size_t* count);
+ BINARYNINJACOREAPI BNTag** BNGetUserAddressTags(
+ BNFunction* func, BNArchitecture* arch, uint64_t addr, size_t* count);
+ BINARYNINJACOREAPI BNTag** BNGetAddressTagsOfType(
+ BNFunction* func, BNArchitecture* arch, uint64_t addr, BNTagType* tagType, size_t* count);
+ BINARYNINJACOREAPI BNTag** BNGetAutoAddressTagsOfType(
+ BNFunction* func, BNArchitecture* arch, uint64_t addr, BNTagType* tagType, size_t* count);
+ BINARYNINJACOREAPI BNTag** BNGetUserAddressTagsOfType(
+ BNFunction* func, BNArchitecture* arch, uint64_t addr, BNTagType* tagType, size_t* count);
+ BINARYNINJACOREAPI BNTagReference* BNGetAddressTagsInRange(
+ BNFunction* func, BNArchitecture* arch, uint64_t start, uint64_t end, size_t* count);
+ BINARYNINJACOREAPI BNTagReference* BNGetAutoAddressTagsInRange(
+ BNFunction* func, BNArchitecture* arch, uint64_t start, uint64_t end, size_t* count);
+ BINARYNINJACOREAPI BNTagReference* BNGetUserAddressTagsInRange(
+ BNFunction* func, BNArchitecture* arch, uint64_t start, uint64_t end, size_t* count);
BINARYNINJACOREAPI void BNAddAutoAddressTag(BNFunction* func, BNArchitecture* arch, uint64_t addr, BNTag* tag);
BINARYNINJACOREAPI void BNRemoveAutoAddressTag(BNFunction* func, BNArchitecture* arch, uint64_t addr, BNTag* tag);
- BINARYNINJACOREAPI void BNRemoveAutoAddressTagsOfType(BNFunction* func, BNArchitecture* arch, uint64_t addr, BNTagType* tagType);
+ BINARYNINJACOREAPI void BNRemoveAutoAddressTagsOfType(
+ BNFunction* func, BNArchitecture* arch, uint64_t addr, BNTagType* tagType);
BINARYNINJACOREAPI void BNAddUserAddressTag(BNFunction* func, BNArchitecture* arch, uint64_t addr, BNTag* tag);
BINARYNINJACOREAPI void BNRemoveUserAddressTag(BNFunction* func, BNArchitecture* arch, uint64_t addr, BNTag* tag);
- BINARYNINJACOREAPI void BNRemoveUserAddressTagsOfType(BNFunction* func, BNArchitecture* arch, uint64_t addr, BNTagType* tagType);
+ BINARYNINJACOREAPI void BNRemoveUserAddressTagsOfType(
+ BNFunction* func, BNArchitecture* arch, uint64_t addr, BNTagType* tagType);
BINARYNINJACOREAPI BNTagReference* BNGetFunctionTagReferences(BNFunction* func, size_t* count);
BINARYNINJACOREAPI BNTagReference* BNGetAutoFunctionTagReferences(BNFunction* func, size_t* count);
@@ -4088,36 +4174,42 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI BNFlowGraph* BNGetUnresolvedStackAdjustmentGraph(BNFunction* func);
- BINARYNINJACOREAPI void BNSetUserVariableValue(BNFunction* func, const BNVariable* var, const BNArchitectureAndAddress* defSite, const BNPossibleValueSet* value);
- BINARYNINJACOREAPI void BNClearUserVariableValue(BNFunction* func, const BNVariable* var, const BNArchitectureAndAddress* defSite);
- BINARYNINJACOREAPI BNUserVariableValue* BNGetAllUserVariableValues(BNFunction *func, size_t* count);
+ BINARYNINJACOREAPI void BNSetUserVariableValue(BNFunction* func, const BNVariable* var,
+ const BNArchitectureAndAddress* defSite, const BNPossibleValueSet* value);
+ BINARYNINJACOREAPI void BNClearUserVariableValue(
+ BNFunction* func, const BNVariable* var, const BNArchitectureAndAddress* defSite);
+ BINARYNINJACOREAPI BNUserVariableValue* BNGetAllUserVariableValues(BNFunction* func, size_t* count);
BINARYNINJACOREAPI void BNFreeUserVariableValues(BNUserVariableValue* result);
- BINARYNINJACOREAPI bool BNParsePossibleValueSet(BNBinaryView* view, const char* valueText, BNRegisterValueType state,
- BNPossibleValueSet* result, uint64_t here, char** errors);
+ BINARYNINJACOREAPI bool BNParsePossibleValueSet(BNBinaryView* view, const char* valueText,
+ BNRegisterValueType state, BNPossibleValueSet* result, uint64_t here, char** errors);
BINARYNINJACOREAPI void BNRequestFunctionDebugReport(BNFunction* func, const char* name);
- BINARYNINJACOREAPI BNILReferenceSource* BNGetMediumLevelILVariableReferences(BNFunction* func, BNVariable* var, size_t * count);
- BINARYNINJACOREAPI BNVariableReferenceSource* BNGetMediumLevelILVariableReferencesFrom(BNFunction* func, BNArchitecture* arch,
- uint64_t address, size_t* count);
- BINARYNINJACOREAPI BNVariableReferenceSource* BNGetMediumLevelILVariableReferencesInRange(BNFunction* func, BNArchitecture* arch,
- uint64_t address, uint64_t len, size_t* count);
- BINARYNINJACOREAPI BNILReferenceSource* BNGetMediumLevelILVariableReferencesIfAvailable(BNFunction* func, BNVariable* var, size_t * count);
- BINARYNINJACOREAPI BNVariableReferenceSource* BNGetMediumLevelILVariableReferencesFromIfAvailable(BNFunction* func, BNArchitecture* arch,
- uint64_t address, size_t* count);
- BINARYNINJACOREAPI BNVariableReferenceSource* BNGetMediumLevelILVariableReferencesInRangeIfAvailable(BNFunction* func, BNArchitecture* arch,
- uint64_t address, uint64_t len, size_t* count);
+ BINARYNINJACOREAPI BNILReferenceSource* BNGetMediumLevelILVariableReferences(
+ BNFunction* func, BNVariable* var, size_t* count);
+ BINARYNINJACOREAPI BNVariableReferenceSource* BNGetMediumLevelILVariableReferencesFrom(
+ BNFunction* func, BNArchitecture* arch, uint64_t address, size_t* count);
+ BINARYNINJACOREAPI BNVariableReferenceSource* BNGetMediumLevelILVariableReferencesInRange(
+ BNFunction* func, BNArchitecture* arch, uint64_t address, uint64_t len, size_t* count);
+ BINARYNINJACOREAPI BNILReferenceSource* BNGetMediumLevelILVariableReferencesIfAvailable(
+ BNFunction* func, BNVariable* var, size_t* count);
+ BINARYNINJACOREAPI BNVariableReferenceSource* BNGetMediumLevelILVariableReferencesFromIfAvailable(
+ BNFunction* func, BNArchitecture* arch, uint64_t address, size_t* count);
+ BINARYNINJACOREAPI BNVariableReferenceSource* BNGetMediumLevelILVariableReferencesInRangeIfAvailable(
+ BNFunction* func, BNArchitecture* arch, uint64_t address, uint64_t len, size_t* count);
- BINARYNINJACOREAPI BNILReferenceSource* BNGetHighLevelILVariableReferences(BNFunction* func, BNVariable* var, size_t * count);
- BINARYNINJACOREAPI BNVariableReferenceSource* BNGetHighLevelILVariableReferencesFrom(BNFunction* func, BNArchitecture* arch,
- uint64_t address, size_t* count);
- BINARYNINJACOREAPI BNVariableReferenceSource* BNGetHighLevelILVariableReferencesInRange(BNFunction* func, BNArchitecture* arch,
- uint64_t address, uint64_t len, size_t* count);
- BINARYNINJACOREAPI BNILReferenceSource* BNGetHighLevelILVariableReferencesIfAvailable(BNFunction* func, BNVariable* var, size_t * count);
- BINARYNINJACOREAPI BNVariableReferenceSource* BNGetHighLevelILVariableReferencesFromIfAvailable(BNFunction* func, BNArchitecture* arch,
- uint64_t address, size_t* count);
- BINARYNINJACOREAPI BNVariableReferenceSource* BNGetHighLevelILVariableReferencesInRangeIfAvailable(BNFunction* func, BNArchitecture* arch,
- uint64_t address, uint64_t len, size_t* count);
+ BINARYNINJACOREAPI BNILReferenceSource* BNGetHighLevelILVariableReferences(
+ BNFunction* func, BNVariable* var, size_t* count);
+ BINARYNINJACOREAPI BNVariableReferenceSource* BNGetHighLevelILVariableReferencesFrom(
+ BNFunction* func, BNArchitecture* arch, uint64_t address, size_t* count);
+ BINARYNINJACOREAPI BNVariableReferenceSource* BNGetHighLevelILVariableReferencesInRange(
+ BNFunction* func, BNArchitecture* arch, uint64_t address, uint64_t len, size_t* count);
+ BINARYNINJACOREAPI BNILReferenceSource* BNGetHighLevelILVariableReferencesIfAvailable(
+ BNFunction* func, BNVariable* var, size_t* count);
+ BINARYNINJACOREAPI BNVariableReferenceSource* BNGetHighLevelILVariableReferencesFromIfAvailable(
+ BNFunction* func, BNArchitecture* arch, uint64_t address, size_t* count);
+ BINARYNINJACOREAPI BNVariableReferenceSource* BNGetHighLevelILVariableReferencesInRangeIfAvailable(
+ BNFunction* func, BNArchitecture* arch, uint64_t address, uint64_t len, size_t* count);
BINARYNINJACOREAPI void BNFreeVariableList(BNVariable* vars);
BINARYNINJACOREAPI void BNFreeVariableReferenceSourceList(BNVariableReferenceSource* vars, size_t count);
@@ -4128,18 +4220,25 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI void BNFreeAnalysisContext(BNAnalysisContext* analysisContext);
BINARYNINJACOREAPI BNFunction* BNAnalysisContextGetFunction(BNAnalysisContext* analysisContext);
BINARYNINJACOREAPI BNLowLevelILFunction* BNAnalysisContextGetLowLevelILFunction(BNAnalysisContext* analysisContext);
- BINARYNINJACOREAPI BNMediumLevelILFunction* BNAnalysisContextGetMediumLevelILFunction(BNAnalysisContext* analysisContext);
- BINARYNINJACOREAPI BNHighLevelILFunction* BNAnalysisContextGetHighLevelILFunction(BNAnalysisContext* analysisContext);
+ BINARYNINJACOREAPI BNMediumLevelILFunction* BNAnalysisContextGetMediumLevelILFunction(
+ BNAnalysisContext* analysisContext);
+ BINARYNINJACOREAPI BNHighLevelILFunction* BNAnalysisContextGetHighLevelILFunction(
+ BNAnalysisContext* analysisContext);
- BINARYNINJACOREAPI void BNSetBasicBlockList(BNAnalysisContext* analysisContext, BNBasicBlock** basicBlocks, size_t count);
+ BINARYNINJACOREAPI void BNSetBasicBlockList(
+ BNAnalysisContext* analysisContext, BNBasicBlock** basicBlocks, size_t count);
BINARYNINJACOREAPI void BNSetLiftedILFunction(BNAnalysisContext* analysisContext, BNLowLevelILFunction* liftedIL);
- BINARYNINJACOREAPI void BNSetLowLevelILFunction(BNAnalysisContext* analysisContext, BNLowLevelILFunction* lowLevelIL);
- BINARYNINJACOREAPI void BNSetMediumLevelILFunction(BNAnalysisContext* analysisContext, BNMediumLevelILFunction* mediumLevelIL);
- BINARYNINJACOREAPI void BNSetHighLevelILFunction(BNAnalysisContext* analysisContext, BNHighLevelILFunction* highLevelIL);
+ BINARYNINJACOREAPI void BNSetLowLevelILFunction(
+ BNAnalysisContext* analysisContext, BNLowLevelILFunction* lowLevelIL);
+ BINARYNINJACOREAPI void BNSetMediumLevelILFunction(
+ BNAnalysisContext* analysisContext, BNMediumLevelILFunction* mediumLevelIL);
+ BINARYNINJACOREAPI void BNSetHighLevelILFunction(
+ BNAnalysisContext* analysisContext, BNHighLevelILFunction* highLevelIL);
BINARYNINJACOREAPI bool BNAnalysisContextInform(BNAnalysisContext* analysisContext, const char* request);
// Activity
- BINARYNINJACOREAPI BNActivity* BNCreateActivity(const char* name, void* ctxt, void (*action)(void*, BNAnalysisContext*));
+ BINARYNINJACOREAPI BNActivity* BNCreateActivity(
+ const char* name, void* ctxt, void (*action)(void*, BNAnalysisContext*));
BINARYNINJACOREAPI BNActivity* BNNewActivityReference(BNActivity* activity);
BINARYNINJACOREAPI void BNFreeActivity(BNActivity* activity);
@@ -4156,7 +4255,8 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI bool BNRegisterWorkflow(BNWorkflow* workflow, const char* description);
BINARYNINJACOREAPI BNWorkflow* BNWorkflowClone(BNWorkflow* workflow, const char* name, const char* activity);
- BINARYNINJACOREAPI bool BNWorkflowRegisterActivity(BNWorkflow* workflow, BNActivity* activity, const char** subactivities, size_t size, const char* description);
+ BINARYNINJACOREAPI bool BNWorkflowRegisterActivity(
+ BNWorkflow* workflow, BNActivity* activity, const char** subactivities, size_t size, const char* description);
BINARYNINJACOREAPI bool BNWorkflowContains(BNWorkflow* workflow, const char* activity);
BINARYNINJACOREAPI char* BNWorkflowGetConfiguration(BNWorkflow* workflow, const char* activity);
@@ -4165,28 +4265,32 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI size_t BNWorkflowSize(BNWorkflow* workflow);
BINARYNINJACOREAPI BNActivity* BNWorkflowGetActivity(BNWorkflow* workflow, const char* activity);
- BINARYNINJACOREAPI const char** BNWorkflowGetActivityRoots(BNWorkflow* workflow, const char* activity, size_t* inoutSize);
- BINARYNINJACOREAPI const char** BNWorkflowGetSubactivities(BNWorkflow* workflow, const char* activity, bool immediate, size_t* inoutSize);
- BINARYNINJACOREAPI bool BNWorkflowAssignSubactivities(BNWorkflow* workflow, const char* activity, const char** activities, size_t size);
+ BINARYNINJACOREAPI const char** BNWorkflowGetActivityRoots(
+ BNWorkflow* workflow, const char* activity, size_t* inoutSize);
+ BINARYNINJACOREAPI const char** BNWorkflowGetSubactivities(
+ BNWorkflow* workflow, const char* activity, bool immediate, size_t* inoutSize);
+ BINARYNINJACOREAPI bool BNWorkflowAssignSubactivities(
+ BNWorkflow* workflow, const char* activity, const char** activities, size_t size);
BINARYNINJACOREAPI bool BNWorkflowClear(BNWorkflow* workflow);
- BINARYNINJACOREAPI bool BNWorkflowInsert(BNWorkflow* workflow, const char* activity, const char** activities, size_t size);
+ BINARYNINJACOREAPI bool BNWorkflowInsert(
+ BNWorkflow* workflow, const char* activity, const char** activities, size_t size);
BINARYNINJACOREAPI bool BNWorkflowRemove(BNWorkflow* workflow, const char* activity);
BINARYNINJACOREAPI bool BNWorkflowReplace(BNWorkflow* workflow, const char* activity, const char* newActivity);
BINARYNINJACOREAPI BNFlowGraph* BNWorkflowGetGraph(BNWorkflow* workflow, const char* activity, bool sequential);
BINARYNINJACOREAPI void BNWorkflowShowReport(BNWorkflow* workflow, const char* name);
- //BINARYNINJACOREAPI bool BNWorkflowRun(const char* activity, BNAnalysisContext* analysisContext);
+ // BINARYNINJACOREAPI bool BNWorkflowRun(const char* activity, BNAnalysisContext* analysisContext);
// Disassembly settings
BINARYNINJACOREAPI BNDisassemblySettings* BNCreateDisassemblySettings(void);
BINARYNINJACOREAPI BNDisassemblySettings* BNNewDisassemblySettingsReference(BNDisassemblySettings* settings);
BINARYNINJACOREAPI void BNFreeDisassemblySettings(BNDisassemblySettings* settings);
- BINARYNINJACOREAPI bool BNIsDisassemblySettingsOptionSet(BNDisassemblySettings* settings,
- BNDisassemblyOption option);
- BINARYNINJACOREAPI void BNSetDisassemblySettingsOption(BNDisassemblySettings* settings,
- BNDisassemblyOption option, bool state);
+ BINARYNINJACOREAPI bool BNIsDisassemblySettingsOptionSet(
+ BNDisassemblySettings* settings, BNDisassemblyOption option);
+ BINARYNINJACOREAPI void BNSetDisassemblySettingsOption(
+ BNDisassemblySettings* settings, BNDisassemblyOption option, bool state);
BINARYNINJACOREAPI size_t BNGetDisassemblyWidth(BNDisassemblySettings* settings);
BINARYNINJACOREAPI void BNSetDisassemblyWidth(BNDisassemblySettings* settings, size_t width);
@@ -4197,14 +4301,14 @@ __attribute__ ((format (printf, 1, 2)))
// Flow graphs
BINARYNINJACOREAPI BNFlowGraph* BNCreateFlowGraph();
- BINARYNINJACOREAPI BNFlowGraph* BNCreateFunctionGraph(BNFunction* func, BNFunctionGraphType type,
- BNDisassemblySettings* settings);
- BINARYNINJACOREAPI BNFlowGraph* BNCreateLowLevelILFunctionGraph(BNLowLevelILFunction* func,
- BNDisassemblySettings* settings);
- BINARYNINJACOREAPI BNFlowGraph* BNCreateMediumLevelILFunctionGraph(BNMediumLevelILFunction* func,
- BNDisassemblySettings* settings);
- BINARYNINJACOREAPI BNFlowGraph* BNCreateHighLevelILFunctionGraph(BNHighLevelILFunction* func,
- BNDisassemblySettings* settings);
+ BINARYNINJACOREAPI BNFlowGraph* BNCreateFunctionGraph(
+ BNFunction* func, BNFunctionGraphType type, BNDisassemblySettings* settings);
+ BINARYNINJACOREAPI BNFlowGraph* BNCreateLowLevelILFunctionGraph(
+ BNLowLevelILFunction* func, BNDisassemblySettings* settings);
+ BINARYNINJACOREAPI BNFlowGraph* BNCreateMediumLevelILFunctionGraph(
+ BNMediumLevelILFunction* func, BNDisassemblySettings* settings);
+ BINARYNINJACOREAPI BNFlowGraph* BNCreateHighLevelILFunctionGraph(
+ BNHighLevelILFunction* func, BNDisassemblySettings* settings);
BINARYNINJACOREAPI BNFlowGraph* BNCreateCustomFlowGraph(BNCustomFlowGraph* callbacks);
BINARYNINJACOREAPI BNFlowGraph* BNNewFlowGraphReference(BNFlowGraph* graph);
BINARYNINJACOREAPI void BNFreeFlowGraph(BNFlowGraph* graph);
@@ -4217,7 +4321,8 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI int BNGetVerticalFlowGraphNodeMargin(BNFlowGraph* graph);
BINARYNINJACOREAPI void BNSetFlowGraphNodeMargins(BNFlowGraph* graph, int horiz, int vert);
- BINARYNINJACOREAPI BNFlowGraphLayoutRequest* BNStartFlowGraphLayout(BNFlowGraph* graph, void* ctxt, void (*func)(void* ctxt));
+ BINARYNINJACOREAPI BNFlowGraphLayoutRequest* BNStartFlowGraphLayout(
+ BNFlowGraph* graph, void* ctxt, void (*func)(void* ctxt));
BINARYNINJACOREAPI bool BNIsFlowGraphLayoutComplete(BNFlowGraph* graph);
BINARYNINJACOREAPI BNFlowGraphLayoutRequest* BNNewFlowGraphLayoutRequestReference(BNFlowGraphLayoutRequest* layout);
BINARYNINJACOREAPI void BNFreeFlowGraphLayoutRequest(BNFlowGraphLayoutRequest* layout);
@@ -4238,7 +4343,7 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI BNFlowGraphNode** BNGetFlowGraphNodes(BNFlowGraph* graph, size_t* count);
BINARYNINJACOREAPI BNFlowGraphNode* BNGetFlowGraphNode(BNFlowGraph* graph, size_t i);
BINARYNINJACOREAPI BNFlowGraphNode** BNGetFlowGraphNodesInRegion(
- BNFlowGraph* graph, int left, int top, int right, int bottom, size_t* count);
+ BNFlowGraph* graph, int left, int top, int right, int bottom, size_t* count);
BINARYNINJACOREAPI void BNFreeFlowGraphNodeList(BNFlowGraphNode** nodes, size_t count);
BINARYNINJACOREAPI bool BNFlowGraphHasNodes(BNFlowGraph* graph);
BINARYNINJACOREAPI size_t BNAddFlowGraphNode(BNFlowGraph* graph, BNFlowGraphNode* node);
@@ -4263,7 +4368,8 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI BNFlowGraphEdge* BNGetFlowGraphNodeOutgoingEdges(BNFlowGraphNode* node, size_t* count);
BINARYNINJACOREAPI BNFlowGraphEdge* BNGetFlowGraphNodeIncomingEdges(BNFlowGraphNode* node, size_t* count);
BINARYNINJACOREAPI void BNFreeFlowGraphNodeEdgeList(BNFlowGraphEdge* edges, size_t count);
- BINARYNINJACOREAPI void BNAddFlowGraphNodeOutgoingEdge(BNFlowGraphNode* node, BNBranchType type, BNFlowGraphNode* target, BNEdgeStyle edgeStyle);
+ BINARYNINJACOREAPI void BNAddFlowGraphNodeOutgoingEdge(
+ BNFlowGraphNode* node, BNBranchType type, BNFlowGraphNode* target, BNEdgeStyle edgeStyle);
BINARYNINJACOREAPI BNHighlightColor BNGetFlowGraphNodeHighlight(BNFlowGraphNode* node);
BINARYNINJACOREAPI void BNSetFlowGraphNodeHighlight(BNFlowGraphNode* node, BNHighlightColor color);
@@ -4282,7 +4388,7 @@ __attribute__ ((format (printf, 1, 2)))
// Symbols
BINARYNINJACOREAPI BNSymbol* BNCreateSymbol(BNSymbolType type, const char* shortName, const char* fullName,
- const char* rawName, uint64_t addr, BNSymbolBinding binding, const BNNameSpace* nameSpace, uint64_t ordinal);
+ const char* rawName, uint64_t addr, BNSymbolBinding binding, const BNNameSpace* nameSpace, uint64_t ordinal);
BINARYNINJACOREAPI BNSymbol* BNNewSymbolReference(BNSymbol* sym);
BINARYNINJACOREAPI void BNFreeSymbol(BNSymbol* sym);
BINARYNINJACOREAPI BNSymbolType BNGetSymbolType(BNSymbol* sym);
@@ -4299,14 +4405,19 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI bool BNIsSymbolAutoDefined(BNSymbol* sym);
BINARYNINJACOREAPI BNSymbol* BNGetSymbolByAddress(BNBinaryView* view, uint64_t addr, const BNNameSpace* nameSpace);
- BINARYNINJACOREAPI BNSymbol* BNGetSymbolByRawName(BNBinaryView* view, const char* name, const BNNameSpace* nameSpace);
- BINARYNINJACOREAPI BNSymbol** BNGetSymbolsByName(BNBinaryView* view, const char* name, size_t* count, const BNNameSpace* nameSpace);
- BINARYNINJACOREAPI BNSymbol** BNGetSymbolsByRawName(BNBinaryView* view, const char* name, size_t* count, const BNNameSpace* nameSpace);
+ BINARYNINJACOREAPI BNSymbol* BNGetSymbolByRawName(
+ BNBinaryView* view, const char* name, const BNNameSpace* nameSpace);
+ BINARYNINJACOREAPI BNSymbol** BNGetSymbolsByName(
+ BNBinaryView* view, const char* name, size_t* count, const BNNameSpace* nameSpace);
+ BINARYNINJACOREAPI BNSymbol** BNGetSymbolsByRawName(
+ BNBinaryView* view, const char* name, size_t* count, const BNNameSpace* nameSpace);
BINARYNINJACOREAPI BNSymbol** BNGetSymbols(BNBinaryView* view, size_t* count, const BNNameSpace* nameSpace);
- BINARYNINJACOREAPI BNSymbol** BNGetSymbolsInRange(BNBinaryView* view, uint64_t start, uint64_t len, size_t* count, const BNNameSpace* nameSpace);
- BINARYNINJACOREAPI BNSymbol** BNGetSymbolsOfType(BNBinaryView* view, BNSymbolType type, size_t* count, const BNNameSpace* nameSpace);
- BINARYNINJACOREAPI BNSymbol** BNGetSymbolsOfTypeInRange(BNBinaryView* view, BNSymbolType type,
- uint64_t start, uint64_t len, size_t* count, const BNNameSpace* nameSpace);
+ BINARYNINJACOREAPI BNSymbol** BNGetSymbolsInRange(
+ BNBinaryView* view, uint64_t start, uint64_t len, size_t* count, const BNNameSpace* nameSpace);
+ BINARYNINJACOREAPI BNSymbol** BNGetSymbolsOfType(
+ BNBinaryView* view, BNSymbolType type, size_t* count, const BNNameSpace* nameSpace);
+ BINARYNINJACOREAPI BNSymbol** BNGetSymbolsOfTypeInRange(BNBinaryView* view, BNSymbolType type, uint64_t start,
+ uint64_t len, size_t* count, const BNNameSpace* nameSpace);
BINARYNINJACOREAPI void BNFreeSymbolList(BNSymbol** syms, size_t count);
BINARYNINJACOREAPI BNSymbol** BNGetVisibleSymbols(BNBinaryView* view, size_t* count, const BNNameSpace* nameSpace);
@@ -4314,8 +4425,10 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI void BNUndefineAutoSymbol(BNBinaryView* view, BNSymbol* sym);
BINARYNINJACOREAPI void BNDefineUserSymbol(BNBinaryView* view, BNSymbol* sym);
BINARYNINJACOREAPI void BNUndefineUserSymbol(BNBinaryView* view, BNSymbol* sym);
- BINARYNINJACOREAPI void BNDefineImportedFunction(BNBinaryView* view, BNSymbol* importAddressSym, BNFunction* func, BNType* type);
- BINARYNINJACOREAPI BNSymbol* BNDefineAutoSymbolAndVariableOrFunction(BNBinaryView* view, BNPlatform* platform, BNSymbol* sym, BNType* type);
+ BINARYNINJACOREAPI void BNDefineImportedFunction(
+ BNBinaryView* view, BNSymbol* importAddressSym, BNFunction* func, BNType* type);
+ BINARYNINJACOREAPI BNSymbol* BNDefineAutoSymbolAndVariableOrFunction(
+ BNBinaryView* view, BNPlatform* platform, BNSymbol* sym, BNType* type);
BINARYNINJACOREAPI BNDebugInfo* BNGetDebugInfo(BNBinaryView* view);
BINARYNINJACOREAPI void BNApplyDebugInfo(BNBinaryView* view, BNDebugInfo* newDebugInfo);
@@ -4329,26 +4442,28 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI void BNFreeLowLevelILFunction(BNLowLevelILFunction* func);
BINARYNINJACOREAPI BNFunction* BNGetLowLevelILOwnerFunction(BNLowLevelILFunction* func);
BINARYNINJACOREAPI uint64_t BNLowLevelILGetCurrentAddress(BNLowLevelILFunction* func);
- BINARYNINJACOREAPI void BNLowLevelILSetCurrentAddress(BNLowLevelILFunction* func,
- BNArchitecture* arch, uint64_t addr);
+ BINARYNINJACOREAPI void BNLowLevelILSetCurrentAddress(
+ BNLowLevelILFunction* func, BNArchitecture* arch, uint64_t addr);
BINARYNINJACOREAPI void BNLowLevelILSetCurrentSourceBlock(BNLowLevelILFunction* func, BNBasicBlock* source);
- BINARYNINJACOREAPI size_t BNLowLevelILGetInstructionStart(BNLowLevelILFunction* func,
- BNArchitecture* arch, uint64_t addr);
+ BINARYNINJACOREAPI size_t BNLowLevelILGetInstructionStart(
+ BNLowLevelILFunction* func, BNArchitecture* arch, uint64_t addr);
BINARYNINJACOREAPI void BNLowLevelILClearIndirectBranches(BNLowLevelILFunction* func);
- BINARYNINJACOREAPI void BNLowLevelILSetIndirectBranches(BNLowLevelILFunction* func, BNArchitectureAndAddress* branches,
- size_t count);
- BINARYNINJACOREAPI size_t BNLowLevelILAddExpr(BNLowLevelILFunction* func, BNLowLevelILOperation operation, size_t size,
- uint32_t flags, uint64_t a, uint64_t b, uint64_t c, uint64_t d);
- BINARYNINJACOREAPI size_t BNLowLevelILAddExprWithLocation(BNLowLevelILFunction* func, uint64_t addr, uint32_t sourceOperand,
- BNLowLevelILOperation operation, size_t size, uint32_t flags, uint64_t a, uint64_t b, uint64_t c, uint64_t d);
+ BINARYNINJACOREAPI void BNLowLevelILSetIndirectBranches(
+ BNLowLevelILFunction* func, BNArchitectureAndAddress* branches, size_t count);
+ BINARYNINJACOREAPI size_t BNLowLevelILAddExpr(BNLowLevelILFunction* func, BNLowLevelILOperation operation,
+ size_t size, uint32_t flags, uint64_t a, uint64_t b, uint64_t c, uint64_t d);
+ BINARYNINJACOREAPI size_t BNLowLevelILAddExprWithLocation(BNLowLevelILFunction* func, uint64_t addr,
+ uint32_t sourceOperand, BNLowLevelILOperation operation, size_t size, uint32_t flags, uint64_t a, uint64_t b,
+ uint64_t c, uint64_t d);
BINARYNINJACOREAPI void BNLowLevelILSetExprSourceOperand(BNLowLevelILFunction* func, size_t expr, uint32_t operand);
BINARYNINJACOREAPI size_t BNLowLevelILAddInstruction(BNLowLevelILFunction* func, size_t expr);
BINARYNINJACOREAPI size_t BNLowLevelILGoto(BNLowLevelILFunction* func, BNLowLevelILLabel* label);
- BINARYNINJACOREAPI size_t BNLowLevelILGotoWithLocation(BNLowLevelILFunction* func, BNLowLevelILLabel* label,
- uint64_t addr, uint32_t sourceOperand);
- BINARYNINJACOREAPI size_t BNLowLevelILIf(BNLowLevelILFunction* func, uint64_t op, BNLowLevelILLabel* t, BNLowLevelILLabel* f);
- BINARYNINJACOREAPI size_t BNLowLevelILIfWithLocation(BNLowLevelILFunction* func, uint64_t op,
- BNLowLevelILLabel* t, BNLowLevelILLabel* f, uint64_t addr, uint32_t sourceOperand);
+ BINARYNINJACOREAPI size_t BNLowLevelILGotoWithLocation(
+ BNLowLevelILFunction* func, BNLowLevelILLabel* label, uint64_t addr, uint32_t sourceOperand);
+ BINARYNINJACOREAPI size_t BNLowLevelILIf(
+ BNLowLevelILFunction* func, uint64_t op, BNLowLevelILLabel* t, BNLowLevelILLabel* f);
+ BINARYNINJACOREAPI size_t BNLowLevelILIfWithLocation(BNLowLevelILFunction* func, uint64_t op, BNLowLevelILLabel* t,
+ BNLowLevelILLabel* f, uint64_t addr, uint32_t sourceOperand);
BINARYNINJACOREAPI void BNLowLevelILInitLabel(BNLowLevelILLabel* label);
BINARYNINJACOREAPI void BNLowLevelILMarkLabel(BNLowLevelILFunction* func, BNLowLevelILLabel* label);
BINARYNINJACOREAPI void BNFinalizeLowLevelILFunction(BNLowLevelILFunction* func);
@@ -4356,13 +4471,14 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI void BNPrepareToCopyLowLevelILFunction(BNLowLevelILFunction* func, BNLowLevelILFunction* src);
BINARYNINJACOREAPI void BNPrepareToCopyLowLevelILBasicBlock(BNLowLevelILFunction* func, BNBasicBlock* block);
- BINARYNINJACOREAPI BNLowLevelILLabel* BNGetLabelForLowLevelILSourceInstruction(BNLowLevelILFunction* func, size_t instr);
+ BINARYNINJACOREAPI BNLowLevelILLabel* BNGetLabelForLowLevelILSourceInstruction(
+ BNLowLevelILFunction* func, size_t instr);
- BINARYNINJACOREAPI size_t BNLowLevelILAddLabelMap(BNLowLevelILFunction* func, uint64_t* values,
- BNLowLevelILLabel** labels, size_t count);
+ BINARYNINJACOREAPI size_t BNLowLevelILAddLabelMap(
+ BNLowLevelILFunction* func, uint64_t* values, BNLowLevelILLabel** labels, size_t count);
BINARYNINJACOREAPI size_t BNLowLevelILAddOperandList(BNLowLevelILFunction* func, uint64_t* operands, size_t count);
- BINARYNINJACOREAPI uint64_t* BNLowLevelILGetOperandList(BNLowLevelILFunction* func, size_t expr, size_t operand,
- size_t* count);
+ BINARYNINJACOREAPI uint64_t* BNLowLevelILGetOperandList(
+ BNLowLevelILFunction* func, size_t expr, size_t operand, size_t* count);
BINARYNINJACOREAPI void BNLowLevelILFreeOperandList(uint64_t* operands);
BINARYNINJACOREAPI BNLowLevelILInstruction BNGetLowLevelILByIndex(BNLowLevelILFunction* func, size_t i);
@@ -4371,18 +4487,19 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI size_t BNGetLowLevelILInstructionCount(BNLowLevelILFunction* func);
BINARYNINJACOREAPI size_t BNGetLowLevelILExprCount(BNLowLevelILFunction* func);
- BINARYNINJACOREAPI void BNUpdateLowLevelILOperand(BNLowLevelILFunction* func, size_t instr,
- size_t operandIndex, uint64_t value);
+ BINARYNINJACOREAPI void BNUpdateLowLevelILOperand(
+ BNLowLevelILFunction* func, size_t instr, size_t operandIndex, uint64_t value);
BINARYNINJACOREAPI void BNReplaceLowLevelILExpr(BNLowLevelILFunction* func, size_t expr, size_t newExpr);
- BINARYNINJACOREAPI void BNAddLowLevelILLabelForAddress(BNLowLevelILFunction* func, BNArchitecture* arch, uint64_t addr);
- BINARYNINJACOREAPI BNLowLevelILLabel* BNGetLowLevelILLabelForAddress(BNLowLevelILFunction* func,
- BNArchitecture* arch, uint64_t addr);
+ BINARYNINJACOREAPI void BNAddLowLevelILLabelForAddress(
+ BNLowLevelILFunction* func, BNArchitecture* arch, uint64_t addr);
+ BINARYNINJACOREAPI BNLowLevelILLabel* BNGetLowLevelILLabelForAddress(
+ BNLowLevelILFunction* func, BNArchitecture* arch, uint64_t addr);
- BINARYNINJACOREAPI bool BNGetLowLevelILExprText(BNLowLevelILFunction* func, BNArchitecture* arch, size_t i,
- BNInstructionTextToken** tokens, size_t* count);
+ BINARYNINJACOREAPI bool BNGetLowLevelILExprText(
+ BNLowLevelILFunction* func, BNArchitecture* arch, size_t i, BNInstructionTextToken** tokens, size_t* count);
BINARYNINJACOREAPI bool BNGetLowLevelILInstructionText(BNLowLevelILFunction* il, BNFunction* func,
- BNArchitecture* arch, size_t i, BNInstructionTextToken** tokens, size_t* count);
+ BNArchitecture* arch, size_t i, BNInstructionTextToken** tokens, size_t* count);
BINARYNINJACOREAPI uint32_t BNGetLowLevelILTemporaryRegisterCount(BNLowLevelILFunction* func);
BINARYNINJACOREAPI uint32_t BNGetLowLevelILTemporaryFlagCount(BNLowLevelILFunction* func);
@@ -4397,58 +4514,62 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI size_t BNGetLowLevelILSSAExprIndex(BNLowLevelILFunction* func, size_t expr);
BINARYNINJACOREAPI size_t BNGetLowLevelILNonSSAExprIndex(BNLowLevelILFunction* func, size_t expr);
- BINARYNINJACOREAPI size_t BNGetLowLevelILSSARegisterDefinition(BNLowLevelILFunction* func,
- uint32_t reg, size_t version);
- BINARYNINJACOREAPI size_t BNGetLowLevelILSSAFlagDefinition(BNLowLevelILFunction* func,
- uint32_t reg, size_t version);
+ BINARYNINJACOREAPI size_t BNGetLowLevelILSSARegisterDefinition(
+ BNLowLevelILFunction* func, uint32_t reg, size_t version);
+ BINARYNINJACOREAPI size_t BNGetLowLevelILSSAFlagDefinition(
+ BNLowLevelILFunction* func, uint32_t reg, size_t version);
BINARYNINJACOREAPI size_t BNGetLowLevelILSSAMemoryDefinition(BNLowLevelILFunction* func, size_t version);
- BINARYNINJACOREAPI size_t* BNGetLowLevelILSSARegisterUses(BNLowLevelILFunction* func,
- uint32_t reg, size_t version, size_t* count);
- BINARYNINJACOREAPI size_t* BNGetLowLevelILSSAFlagUses(BNLowLevelILFunction* func, uint32_t reg, size_t version,
- size_t* count);
+ BINARYNINJACOREAPI size_t* BNGetLowLevelILSSARegisterUses(
+ BNLowLevelILFunction* func, uint32_t reg, size_t version, size_t* count);
+ BINARYNINJACOREAPI size_t* BNGetLowLevelILSSAFlagUses(
+ BNLowLevelILFunction* func, uint32_t reg, size_t version, size_t* count);
BINARYNINJACOREAPI size_t* BNGetLowLevelILSSAMemoryUses(BNLowLevelILFunction* func, size_t version, size_t* count);
- BINARYNINJACOREAPI BNRegisterValue BNGetLowLevelILSSARegisterValue(BNLowLevelILFunction* func,
- uint32_t reg, size_t version);
- BINARYNINJACOREAPI BNRegisterValue BNGetLowLevelILSSAFlagValue(BNLowLevelILFunction* func,
- uint32_t flag, size_t version);
+ BINARYNINJACOREAPI BNRegisterValue BNGetLowLevelILSSARegisterValue(
+ BNLowLevelILFunction* func, uint32_t reg, size_t version);
+ BINARYNINJACOREAPI BNRegisterValue BNGetLowLevelILSSAFlagValue(
+ BNLowLevelILFunction* func, uint32_t flag, size_t version);
BINARYNINJACOREAPI BNRegisterValue BNGetLowLevelILExprValue(BNLowLevelILFunction* func, size_t expr);
- BINARYNINJACOREAPI BNPossibleValueSet BNGetLowLevelILPossibleExprValues(BNLowLevelILFunction* func, size_t expr,
- BNDataFlowQueryOption* options, size_t optionCount);
+ BINARYNINJACOREAPI BNPossibleValueSet BNGetLowLevelILPossibleExprValues(
+ BNLowLevelILFunction* func, size_t expr, BNDataFlowQueryOption* options, size_t optionCount);
- BINARYNINJACOREAPI BNRegisterValue BNGetLowLevelILRegisterValueAtInstruction(BNLowLevelILFunction* func,
- uint32_t reg, size_t instr);
- BINARYNINJACOREAPI BNRegisterValue BNGetLowLevelILRegisterValueAfterInstruction(BNLowLevelILFunction* func,
- uint32_t reg, size_t instr);
- BINARYNINJACOREAPI BNPossibleValueSet BNGetLowLevelILPossibleRegisterValuesAtInstruction(BNLowLevelILFunction* func,
- uint32_t reg, size_t instr, BNDataFlowQueryOption* options, size_t optionCount);
- BINARYNINJACOREAPI BNPossibleValueSet BNGetLowLevelILPossibleRegisterValuesAfterInstruction(BNLowLevelILFunction* func,
- uint32_t reg, size_t instr, BNDataFlowQueryOption* options, size_t optionCount);
- BINARYNINJACOREAPI BNRegisterValue BNGetLowLevelILFlagValueAtInstruction(BNLowLevelILFunction* func,
- uint32_t flag, size_t instr);
- BINARYNINJACOREAPI BNRegisterValue BNGetLowLevelILFlagValueAfterInstruction(BNLowLevelILFunction* func,
- uint32_t flag, size_t instr);
- BINARYNINJACOREAPI BNPossibleValueSet BNGetLowLevelILPossibleFlagValuesAtInstruction(BNLowLevelILFunction* func,
- uint32_t flag, size_t instr, BNDataFlowQueryOption* options, size_t optionCount);
- BINARYNINJACOREAPI BNPossibleValueSet BNGetLowLevelILPossibleFlagValuesAfterInstruction(BNLowLevelILFunction* func,
- uint32_t flag, size_t instr, BNDataFlowQueryOption* options, size_t optionCount);
- BINARYNINJACOREAPI BNRegisterValue BNGetLowLevelILStackContentsAtInstruction(BNLowLevelILFunction* func,
- int64_t offset, size_t len, size_t instr);
- BINARYNINJACOREAPI BNRegisterValue BNGetLowLevelILStackContentsAfterInstruction(BNLowLevelILFunction* func,
- int64_t offset, size_t len, size_t instr);
+ BINARYNINJACOREAPI BNRegisterValue BNGetLowLevelILRegisterValueAtInstruction(
+ BNLowLevelILFunction* func, uint32_t reg, size_t instr);
+ BINARYNINJACOREAPI BNRegisterValue BNGetLowLevelILRegisterValueAfterInstruction(
+ BNLowLevelILFunction* func, uint32_t reg, size_t instr);
+ BINARYNINJACOREAPI BNPossibleValueSet BNGetLowLevelILPossibleRegisterValuesAtInstruction(
+ BNLowLevelILFunction* func, uint32_t reg, size_t instr, BNDataFlowQueryOption* options, size_t optionCount);
+ BINARYNINJACOREAPI BNPossibleValueSet BNGetLowLevelILPossibleRegisterValuesAfterInstruction(
+ BNLowLevelILFunction* func, uint32_t reg, size_t instr, BNDataFlowQueryOption* options, size_t optionCount);
+ BINARYNINJACOREAPI BNRegisterValue BNGetLowLevelILFlagValueAtInstruction(
+ BNLowLevelILFunction* func, uint32_t flag, size_t instr);
+ BINARYNINJACOREAPI BNRegisterValue BNGetLowLevelILFlagValueAfterInstruction(
+ BNLowLevelILFunction* func, uint32_t flag, size_t instr);
+ BINARYNINJACOREAPI BNPossibleValueSet BNGetLowLevelILPossibleFlagValuesAtInstruction(
+ BNLowLevelILFunction* func, uint32_t flag, size_t instr, BNDataFlowQueryOption* options, size_t optionCount);
+ BINARYNINJACOREAPI BNPossibleValueSet BNGetLowLevelILPossibleFlagValuesAfterInstruction(
+ BNLowLevelILFunction* func, uint32_t flag, size_t instr, BNDataFlowQueryOption* options, size_t optionCount);
+ BINARYNINJACOREAPI BNRegisterValue BNGetLowLevelILStackContentsAtInstruction(
+ BNLowLevelILFunction* func, int64_t offset, size_t len, size_t instr);
+ BINARYNINJACOREAPI BNRegisterValue BNGetLowLevelILStackContentsAfterInstruction(
+ BNLowLevelILFunction* func, int64_t offset, size_t len, size_t instr);
BINARYNINJACOREAPI BNPossibleValueSet BNGetLowLevelILPossibleStackContentsAtInstruction(BNLowLevelILFunction* func,
- int64_t offset, size_t len, size_t instr, BNDataFlowQueryOption* options, size_t optionCount);
- BINARYNINJACOREAPI BNPossibleValueSet BNGetLowLevelILPossibleStackContentsAfterInstruction(BNLowLevelILFunction* func,
- int64_t offset, size_t len, size_t instr, BNDataFlowQueryOption* options, size_t optionCount);
+ int64_t offset, size_t len, size_t instr, BNDataFlowQueryOption* options, size_t optionCount);
+ BINARYNINJACOREAPI BNPossibleValueSet BNGetLowLevelILPossibleStackContentsAfterInstruction(
+ BNLowLevelILFunction* func, int64_t offset, size_t len, size_t instr, BNDataFlowQueryOption* options,
+ size_t optionCount);
BINARYNINJACOREAPI uint32_t* BNGetLowLevelRegisters(BNLowLevelILFunction* func, size_t* count);
BINARYNINJACOREAPI uint32_t* BNGetLowLevelRegisterStacks(BNLowLevelILFunction* func, size_t* count);
BINARYNINJACOREAPI uint32_t* BNGetLowLevelFlags(BNLowLevelILFunction* func, size_t* count);
- BINARYNINJACOREAPI size_t* BNGetLowLevelRegisterSSAVersions(BNLowLevelILFunction* func, const uint32_t var, size_t* count);
- BINARYNINJACOREAPI size_t* BNGetLowLevelRegisterStackSSAVersions(BNLowLevelILFunction* func, const uint32_t var, size_t* count);
- BINARYNINJACOREAPI size_t* BNGetLowLevelFlagSSAVersions(BNLowLevelILFunction* func, const uint32_t var, size_t* count);
+ BINARYNINJACOREAPI size_t* BNGetLowLevelRegisterSSAVersions(
+ BNLowLevelILFunction* func, const uint32_t var, size_t* count);
+ BINARYNINJACOREAPI size_t* BNGetLowLevelRegisterStackSSAVersions(
+ BNLowLevelILFunction* func, const uint32_t var, size_t* count);
+ BINARYNINJACOREAPI size_t* BNGetLowLevelFlagSSAVersions(
+ BNLowLevelILFunction* func, const uint32_t var, size_t* count);
BINARYNINJACOREAPI size_t* BNGetLowLevelMemoryVersions(BNLowLevelILFunction* func, size_t* count);
@@ -4469,42 +4590,42 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI void BNFreeMediumLevelILFunction(BNMediumLevelILFunction* func);
BINARYNINJACOREAPI BNFunction* BNGetMediumLevelILOwnerFunction(BNMediumLevelILFunction* func);
BINARYNINJACOREAPI uint64_t BNMediumLevelILGetCurrentAddress(BNMediumLevelILFunction* func);
- BINARYNINJACOREAPI void BNMediumLevelILSetCurrentAddress(BNMediumLevelILFunction* func,
- BNArchitecture* arch, uint64_t addr);
- BINARYNINJACOREAPI size_t BNMediumLevelILGetInstructionStart(BNMediumLevelILFunction* func,
- BNArchitecture* arch, uint64_t addr);
+ BINARYNINJACOREAPI void BNMediumLevelILSetCurrentAddress(
+ BNMediumLevelILFunction* func, BNArchitecture* arch, uint64_t addr);
+ BINARYNINJACOREAPI size_t BNMediumLevelILGetInstructionStart(
+ BNMediumLevelILFunction* func, BNArchitecture* arch, uint64_t addr);
BINARYNINJACOREAPI size_t BNMediumLevelILAddExpr(BNMediumLevelILFunction* func, BNMediumLevelILOperation operation,
- size_t size, uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e);
+ size_t size, uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e);
BINARYNINJACOREAPI size_t BNMediumLevelILAddExprWithLocation(BNMediumLevelILFunction* func,
- BNMediumLevelILOperation operation, uint64_t addr, uint32_t sourceOperand, size_t size,
- uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e);
+ BNMediumLevelILOperation operation, uint64_t addr, uint32_t sourceOperand, size_t size, uint64_t a, uint64_t b,
+ uint64_t c, uint64_t d, uint64_t e);
BINARYNINJACOREAPI size_t BNMediumLevelILAddInstruction(BNMediumLevelILFunction* func, size_t expr);
BINARYNINJACOREAPI size_t BNMediumLevelILGoto(BNMediumLevelILFunction* func, BNMediumLevelILLabel* label);
- BINARYNINJACOREAPI size_t BNMediumLevelILGotoWithLocation(BNMediumLevelILFunction* func, BNMediumLevelILLabel* label,
- uint64_t addr, uint32_t sourceOperand);
- BINARYNINJACOREAPI size_t BNMediumLevelILIf(BNMediumLevelILFunction* func, uint64_t op,
- BNMediumLevelILLabel* t, BNMediumLevelILLabel* f);
+ BINARYNINJACOREAPI size_t BNMediumLevelILGotoWithLocation(
+ BNMediumLevelILFunction* func, BNMediumLevelILLabel* label, uint64_t addr, uint32_t sourceOperand);
+ BINARYNINJACOREAPI size_t BNMediumLevelILIf(
+ BNMediumLevelILFunction* func, uint64_t op, BNMediumLevelILLabel* t, BNMediumLevelILLabel* f);
BINARYNINJACOREAPI size_t BNMediumLevelILIfWithLocation(BNMediumLevelILFunction* func, uint64_t op,
- BNMediumLevelILLabel* t, BNMediumLevelILLabel* f, uint64_t addr, uint32_t sourceOperand);
+ BNMediumLevelILLabel* t, BNMediumLevelILLabel* f, uint64_t addr, uint32_t sourceOperand);
BINARYNINJACOREAPI void BNMediumLevelILInitLabel(BNMediumLevelILLabel* label);
BINARYNINJACOREAPI void BNMediumLevelILMarkLabel(BNMediumLevelILFunction* func, BNMediumLevelILLabel* label);
BINARYNINJACOREAPI void BNFinalizeMediumLevelILFunction(BNMediumLevelILFunction* func);
- BINARYNINJACOREAPI void BNGenerateMediumLevelILSSAForm(BNMediumLevelILFunction* func,
- bool analyzeConditionals, bool handleAliases, BNVariable* knownNotAliases, size_t knownNotAliasCount,
- BNVariable* knownAliases, size_t knownAliasCount);
+ BINARYNINJACOREAPI void BNGenerateMediumLevelILSSAForm(BNMediumLevelILFunction* func, bool analyzeConditionals,
+ bool handleAliases, BNVariable* knownNotAliases, size_t knownNotAliasCount, BNVariable* knownAliases,
+ size_t knownAliasCount);
- BINARYNINJACOREAPI void BNPrepareToCopyMediumLevelILFunction(BNMediumLevelILFunction* func,
- BNMediumLevelILFunction* src);
+ BINARYNINJACOREAPI void BNPrepareToCopyMediumLevelILFunction(
+ BNMediumLevelILFunction* func, BNMediumLevelILFunction* src);
BINARYNINJACOREAPI void BNPrepareToCopyMediumLevelILBasicBlock(BNMediumLevelILFunction* func, BNBasicBlock* block);
- BINARYNINJACOREAPI BNMediumLevelILLabel* BNGetLabelForMediumLevelILSourceInstruction(BNMediumLevelILFunction* func,
- size_t instr);
+ BINARYNINJACOREAPI BNMediumLevelILLabel* BNGetLabelForMediumLevelILSourceInstruction(
+ BNMediumLevelILFunction* func, size_t instr);
- BINARYNINJACOREAPI size_t BNMediumLevelILAddLabelMap(BNMediumLevelILFunction* func,
- uint64_t* values, BNMediumLevelILLabel** labels, size_t count);
- BINARYNINJACOREAPI size_t BNMediumLevelILAddOperandList(BNMediumLevelILFunction* func,
- uint64_t* operands, size_t count);
- BINARYNINJACOREAPI uint64_t* BNMediumLevelILGetOperandList(BNMediumLevelILFunction* func, size_t expr,
- size_t operand, size_t* count);
+ BINARYNINJACOREAPI size_t BNMediumLevelILAddLabelMap(
+ BNMediumLevelILFunction* func, uint64_t* values, BNMediumLevelILLabel** labels, size_t count);
+ BINARYNINJACOREAPI size_t BNMediumLevelILAddOperandList(
+ BNMediumLevelILFunction* func, uint64_t* operands, size_t count);
+ BINARYNINJACOREAPI uint64_t* BNMediumLevelILGetOperandList(
+ BNMediumLevelILFunction* func, size_t expr, size_t operand, size_t* count);
BINARYNINJACOREAPI void BNMediumLevelILFreeOperandList(uint64_t* operands);
BINARYNINJACOREAPI BNMediumLevelILInstruction BNGetMediumLevelILByIndex(BNMediumLevelILFunction* func, size_t i);
@@ -4513,20 +4634,21 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI size_t BNGetMediumLevelILInstructionCount(BNMediumLevelILFunction* func);
BINARYNINJACOREAPI size_t BNGetMediumLevelILExprCount(BNMediumLevelILFunction* func);
- BINARYNINJACOREAPI void BNUpdateMediumLevelILOperand(BNMediumLevelILFunction* func, size_t instr,
- size_t operandIndex, uint64_t value);
+ BINARYNINJACOREAPI void BNUpdateMediumLevelILOperand(
+ BNMediumLevelILFunction* func, size_t instr, size_t operandIndex, uint64_t value);
BINARYNINJACOREAPI void BNMarkMediumLevelILInstructionForRemoval(BNMediumLevelILFunction* func, size_t instr);
BINARYNINJACOREAPI void BNReplaceMediumLevelILInstruction(BNMediumLevelILFunction* func, size_t instr, size_t expr);
BINARYNINJACOREAPI void BNReplaceMediumLevelILExpr(BNMediumLevelILFunction* func, size_t expr, size_t newExpr);
BINARYNINJACOREAPI bool BNGetMediumLevelILExprText(BNMediumLevelILFunction* func, BNArchitecture* arch, size_t i,
- BNInstructionTextToken** tokens, size_t* count,
- BNDisassemblySettings* settings);
+ BNInstructionTextToken** tokens, size_t* count, BNDisassemblySettings* settings);
BINARYNINJACOREAPI bool BNGetMediumLevelILInstructionText(BNMediumLevelILFunction* il, BNFunction* func,
- BNArchitecture* arch, size_t i, BNInstructionTextToken** tokens, size_t* count, BNDisassemblySettings* settings);
+ BNArchitecture* arch, size_t i, BNInstructionTextToken** tokens, size_t* count,
+ BNDisassemblySettings* settings);
BINARYNINJACOREAPI BNBasicBlock** BNGetMediumLevelILBasicBlockList(BNMediumLevelILFunction* func, size_t* count);
- BINARYNINJACOREAPI BNBasicBlock* BNGetMediumLevelILBasicBlockForInstruction(BNMediumLevelILFunction* func, size_t i);
+ BINARYNINJACOREAPI BNBasicBlock* BNGetMediumLevelILBasicBlockForInstruction(
+ BNMediumLevelILFunction* func, size_t i);
BINARYNINJACOREAPI BNMediumLevelILFunction* BNGetMediumLevelILSSAForm(BNMediumLevelILFunction* func);
BINARYNINJACOREAPI BNMediumLevelILFunction* BNGetMediumLevelILNonSSAForm(BNMediumLevelILFunction* func);
@@ -4535,73 +4657,76 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI size_t BNGetMediumLevelILSSAExprIndex(BNMediumLevelILFunction* func, size_t expr);
BINARYNINJACOREAPI size_t BNGetMediumLevelILNonSSAExprIndex(BNMediumLevelILFunction* func, size_t expr);
- BINARYNINJACOREAPI size_t BNGetMediumLevelILSSAVarDefinition(BNMediumLevelILFunction* func,
- const BNVariable* var, size_t version);
+ BINARYNINJACOREAPI size_t BNGetMediumLevelILSSAVarDefinition(
+ BNMediumLevelILFunction* func, const BNVariable* var, size_t version);
BINARYNINJACOREAPI size_t BNGetMediumLevelILSSAMemoryDefinition(BNMediumLevelILFunction* func, size_t version);
- BINARYNINJACOREAPI size_t* BNGetMediumLevelILSSAVarUses(BNMediumLevelILFunction* func, const BNVariable* var,
- size_t version, size_t* count);
- BINARYNINJACOREAPI size_t* BNGetMediumLevelILSSAMemoryUses(BNMediumLevelILFunction* func,
- size_t version, size_t* count);
- BINARYNINJACOREAPI bool BNIsMediumLevelILSSAVarLive(BNMediumLevelILFunction* func,
- const BNVariable* var, size_t version);
+ BINARYNINJACOREAPI size_t* BNGetMediumLevelILSSAVarUses(
+ BNMediumLevelILFunction* func, const BNVariable* var, size_t version, size_t* count);
+ BINARYNINJACOREAPI size_t* BNGetMediumLevelILSSAMemoryUses(
+ BNMediumLevelILFunction* func, size_t version, size_t* count);
+ BINARYNINJACOREAPI bool BNIsMediumLevelILSSAVarLive(
+ BNMediumLevelILFunction* func, const BNVariable* var, size_t version);
- BINARYNINJACOREAPI BNVariable* BNGetMediumLevelILVariables(BNMediumLevelILFunction* func, size_t * count);
+ BINARYNINJACOREAPI BNVariable* BNGetMediumLevelILVariables(BNMediumLevelILFunction* func, size_t* count);
BINARYNINJACOREAPI BNVariable* BNGetMediumLevelILAliasedVariables(BNMediumLevelILFunction* func, size_t* count);
- BINARYNINJACOREAPI size_t* BNGetMediumLevelILVariableSSAVersions(BNMediumLevelILFunction* func, const BNVariable* var, size_t * count);
+ BINARYNINJACOREAPI size_t* BNGetMediumLevelILVariableSSAVersions(
+ BNMediumLevelILFunction* func, const BNVariable* var, size_t* count);
- BINARYNINJACOREAPI size_t* BNGetMediumLevelILVariableDefinitions(BNMediumLevelILFunction* func,
- const BNVariable* var, size_t* count);
- BINARYNINJACOREAPI size_t* BNGetMediumLevelILVariableUses(BNMediumLevelILFunction* func,
- const BNVariable* var, size_t* count);
+ BINARYNINJACOREAPI size_t* BNGetMediumLevelILVariableDefinitions(
+ BNMediumLevelILFunction* func, const BNVariable* var, size_t* count);
+ BINARYNINJACOREAPI size_t* BNGetMediumLevelILVariableUses(
+ BNMediumLevelILFunction* func, const BNVariable* var, size_t* count);
- BINARYNINJACOREAPI BNRegisterValue BNGetMediumLevelILSSAVarValue(BNMediumLevelILFunction* func,
- const BNVariable* var, size_t version);
+ BINARYNINJACOREAPI BNRegisterValue BNGetMediumLevelILSSAVarValue(
+ BNMediumLevelILFunction* func, const BNVariable* var, size_t version);
BINARYNINJACOREAPI BNRegisterValue BNGetMediumLevelILExprValue(BNMediumLevelILFunction* func, size_t expr);
BINARYNINJACOREAPI BNPossibleValueSet BNGetMediumLevelILPossibleSSAVarValues(BNMediumLevelILFunction* func,
- const BNVariable* var, size_t version, size_t instr, BNDataFlowQueryOption* options, size_t optionCount);
- BINARYNINJACOREAPI BNPossibleValueSet BNGetMediumLevelILPossibleExprValues(BNMediumLevelILFunction* func, size_t expr,
- BNDataFlowQueryOption* options, size_t optionCount);
+ const BNVariable* var, size_t version, size_t instr, BNDataFlowQueryOption* options, size_t optionCount);
+ BINARYNINJACOREAPI BNPossibleValueSet BNGetMediumLevelILPossibleExprValues(
+ BNMediumLevelILFunction* func, size_t expr, BNDataFlowQueryOption* options, size_t optionCount);
- BINARYNINJACOREAPI size_t BNGetMediumLevelILSSAVarVersionAtILInstruction(BNMediumLevelILFunction* func,
- const BNVariable* var, size_t instr);
- BINARYNINJACOREAPI size_t BNGetMediumLevelILSSAMemoryVersionAtILInstruction(BNMediumLevelILFunction* func,
- size_t instr);
- BINARYNINJACOREAPI BNVariable BNGetMediumLevelILVariableForRegisterAtInstruction(BNMediumLevelILFunction* func,
- uint32_t reg, size_t instr);
- BINARYNINJACOREAPI BNVariable BNGetMediumLevelILVariableForFlagAtInstruction(BNMediumLevelILFunction* func,
- uint32_t flag, size_t instr);
- BINARYNINJACOREAPI BNVariable BNGetMediumLevelILVariableForStackLocationAtInstruction(BNMediumLevelILFunction* func,
- int64_t offset, size_t instr);
+ BINARYNINJACOREAPI size_t BNGetMediumLevelILSSAVarVersionAtILInstruction(
+ BNMediumLevelILFunction* func, const BNVariable* var, size_t instr);
+ BINARYNINJACOREAPI size_t BNGetMediumLevelILSSAMemoryVersionAtILInstruction(
+ BNMediumLevelILFunction* func, size_t instr);
+ BINARYNINJACOREAPI BNVariable BNGetMediumLevelILVariableForRegisterAtInstruction(
+ BNMediumLevelILFunction* func, uint32_t reg, size_t instr);
+ BINARYNINJACOREAPI BNVariable BNGetMediumLevelILVariableForFlagAtInstruction(
+ BNMediumLevelILFunction* func, uint32_t flag, size_t instr);
+ BINARYNINJACOREAPI BNVariable BNGetMediumLevelILVariableForStackLocationAtInstruction(
+ BNMediumLevelILFunction* func, int64_t offset, size_t instr);
- BINARYNINJACOREAPI BNRegisterValue BNGetMediumLevelILRegisterValueAtInstruction(BNMediumLevelILFunction* func,
- uint32_t reg, size_t instr);
- BINARYNINJACOREAPI BNRegisterValue BNGetMediumLevelILRegisterValueAfterInstruction(BNMediumLevelILFunction* func,
- uint32_t reg, size_t instr);
- BINARYNINJACOREAPI BNPossibleValueSet BNGetMediumLevelILPossibleRegisterValuesAtInstruction(BNMediumLevelILFunction* func,
- uint32_t reg, size_t instr, BNDataFlowQueryOption* options, size_t optionCount);
- BINARYNINJACOREAPI BNPossibleValueSet BNGetMediumLevelILPossibleRegisterValuesAfterInstruction(BNMediumLevelILFunction* func,
- uint32_t reg, size_t instr, BNDataFlowQueryOption* options, size_t optionCount);
- BINARYNINJACOREAPI BNRegisterValue BNGetMediumLevelILFlagValueAtInstruction(BNMediumLevelILFunction* func,
- uint32_t flag, size_t instr);
- BINARYNINJACOREAPI BNRegisterValue BNGetMediumLevelILFlagValueAfterInstruction(BNMediumLevelILFunction* func,
- uint32_t flag, size_t instr);
- BINARYNINJACOREAPI BNPossibleValueSet BNGetMediumLevelILPossibleFlagValuesAtInstruction(BNMediumLevelILFunction* func,
- uint32_t flag, size_t instr, BNDataFlowQueryOption* options, size_t optionCount);
- BINARYNINJACOREAPI BNPossibleValueSet BNGetMediumLevelILPossibleFlagValuesAfterInstruction(BNMediumLevelILFunction* func,
- uint32_t flag, size_t instr, BNDataFlowQueryOption* options, size_t optionCount);
- BINARYNINJACOREAPI BNRegisterValue BNGetMediumLevelILStackContentsAtInstruction(BNMediumLevelILFunction* func,
- int64_t offset, size_t len, size_t instr);
- BINARYNINJACOREAPI BNRegisterValue BNGetMediumLevelILStackContentsAfterInstruction(BNMediumLevelILFunction* func,
- int64_t offset, size_t len, size_t instr);
- BINARYNINJACOREAPI BNPossibleValueSet BNGetMediumLevelILPossibleStackContentsAtInstruction(BNMediumLevelILFunction* func,
- int64_t offset, size_t len, size_t instr, BNDataFlowQueryOption* options, size_t optionCount);
- BINARYNINJACOREAPI BNPossibleValueSet BNGetMediumLevelILPossibleStackContentsAfterInstruction(BNMediumLevelILFunction* func,
- int64_t offset, size_t len, size_t instr, BNDataFlowQueryOption* options, size_t optionCount);
+ BINARYNINJACOREAPI BNRegisterValue BNGetMediumLevelILRegisterValueAtInstruction(
+ BNMediumLevelILFunction* func, uint32_t reg, size_t instr);
+ BINARYNINJACOREAPI BNRegisterValue BNGetMediumLevelILRegisterValueAfterInstruction(
+ BNMediumLevelILFunction* func, uint32_t reg, size_t instr);
+ BINARYNINJACOREAPI BNPossibleValueSet BNGetMediumLevelILPossibleRegisterValuesAtInstruction(
+ BNMediumLevelILFunction* func, uint32_t reg, size_t instr, BNDataFlowQueryOption* options, size_t optionCount);
+ BINARYNINJACOREAPI BNPossibleValueSet BNGetMediumLevelILPossibleRegisterValuesAfterInstruction(
+ BNMediumLevelILFunction* func, uint32_t reg, size_t instr, BNDataFlowQueryOption* options, size_t optionCount);
+ BINARYNINJACOREAPI BNRegisterValue BNGetMediumLevelILFlagValueAtInstruction(
+ BNMediumLevelILFunction* func, uint32_t flag, size_t instr);
+ BINARYNINJACOREAPI BNRegisterValue BNGetMediumLevelILFlagValueAfterInstruction(
+ BNMediumLevelILFunction* func, uint32_t flag, size_t instr);
+ BINARYNINJACOREAPI BNPossibleValueSet BNGetMediumLevelILPossibleFlagValuesAtInstruction(
+ BNMediumLevelILFunction* func, uint32_t flag, size_t instr, BNDataFlowQueryOption* options, size_t optionCount);
+ BINARYNINJACOREAPI BNPossibleValueSet BNGetMediumLevelILPossibleFlagValuesAfterInstruction(
+ BNMediumLevelILFunction* func, uint32_t flag, size_t instr, BNDataFlowQueryOption* options, size_t optionCount);
+ BINARYNINJACOREAPI BNRegisterValue BNGetMediumLevelILStackContentsAtInstruction(
+ BNMediumLevelILFunction* func, int64_t offset, size_t len, size_t instr);
+ BINARYNINJACOREAPI BNRegisterValue BNGetMediumLevelILStackContentsAfterInstruction(
+ BNMediumLevelILFunction* func, int64_t offset, size_t len, size_t instr);
+ BINARYNINJACOREAPI BNPossibleValueSet BNGetMediumLevelILPossibleStackContentsAtInstruction(
+ BNMediumLevelILFunction* func, int64_t offset, size_t len, size_t instr, BNDataFlowQueryOption* options,
+ size_t optionCount);
+ BINARYNINJACOREAPI BNPossibleValueSet BNGetMediumLevelILPossibleStackContentsAfterInstruction(
+ BNMediumLevelILFunction* func, int64_t offset, size_t len, size_t instr, BNDataFlowQueryOption* options,
+ size_t optionCount);
- BINARYNINJACOREAPI BNILBranchDependence BNGetMediumLevelILBranchDependence(BNMediumLevelILFunction* func,
- size_t curInstr, size_t branchInstr);
+ BINARYNINJACOREAPI BNILBranchDependence BNGetMediumLevelILBranchDependence(
+ BNMediumLevelILFunction* func, size_t curInstr, size_t branchInstr);
BINARYNINJACOREAPI BNILBranchInstructionAndDependence* BNGetAllMediumLevelILBranchDependence(
- BNMediumLevelILFunction* func, size_t instr, size_t* count);
+ BNMediumLevelILFunction* func, size_t instr, size_t* count);
BINARYNINJACOREAPI void BNFreeILBranchDependenceList(BNILBranchInstructionAndDependence* branches);
BINARYNINJACOREAPI BNLowLevelILFunction* BNGetLowLevelILForMediumLevelIL(BNMediumLevelILFunction* func);
@@ -4623,20 +4748,25 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI BNFunction* BNGetHighLevelILOwnerFunction(BNHighLevelILFunction* func);
BINARYNINJACOREAPI uint64_t BNHighLevelILGetCurrentAddress(BNHighLevelILFunction* func);
- BINARYNINJACOREAPI void BNHighLevelILSetCurrentAddress(BNHighLevelILFunction* func, BNArchitecture* arch, uint64_t addr);
- BINARYNINJACOREAPI size_t BNHighLevelILAddExpr(BNHighLevelILFunction* func, BNHighLevelILOperation operation, size_t size,
- uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e);
- BINARYNINJACOREAPI size_t BNHighLevelILAddExprWithLocation(BNHighLevelILFunction* func, BNHighLevelILOperation operation,
- uint64_t addr, uint32_t sourceOperand, size_t size, uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e);
+ BINARYNINJACOREAPI void BNHighLevelILSetCurrentAddress(
+ BNHighLevelILFunction* func, BNArchitecture* arch, uint64_t addr);
+ BINARYNINJACOREAPI size_t BNHighLevelILAddExpr(BNHighLevelILFunction* func, BNHighLevelILOperation operation,
+ size_t size, uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e);
+ BINARYNINJACOREAPI size_t BNHighLevelILAddExprWithLocation(BNHighLevelILFunction* func,
+ BNHighLevelILOperation operation, uint64_t addr, uint32_t sourceOperand, size_t size, uint64_t a, uint64_t b,
+ uint64_t c, uint64_t d, uint64_t e);
BINARYNINJACOREAPI size_t BNGetHighLevelILRootExpr(BNHighLevelILFunction* func);
BINARYNINJACOREAPI void BNSetHighLevelILRootExpr(BNHighLevelILFunction* func, size_t expr);
BINARYNINJACOREAPI void BNFinalizeHighLevelILFunction(BNHighLevelILFunction* func);
- BINARYNINJACOREAPI size_t BNHighLevelILAddOperandList(BNHighLevelILFunction* func, uint64_t* operands, size_t count);
- BINARYNINJACOREAPI uint64_t* BNHighLevelILGetOperandList(BNHighLevelILFunction* func, size_t expr, size_t operand, size_t* count);
+ BINARYNINJACOREAPI size_t BNHighLevelILAddOperandList(
+ BNHighLevelILFunction* func, uint64_t* operands, size_t count);
+ BINARYNINJACOREAPI uint64_t* BNHighLevelILGetOperandList(
+ BNHighLevelILFunction* func, size_t expr, size_t operand, size_t* count);
BINARYNINJACOREAPI void BNHighLevelILFreeOperandList(uint64_t* operands);
- BINARYNINJACOREAPI BNHighLevelILInstruction BNGetHighLevelILByIndex(BNHighLevelILFunction* func, size_t i, bool asFullAst);
+ BINARYNINJACOREAPI BNHighLevelILInstruction BNGetHighLevelILByIndex(
+ BNHighLevelILFunction* func, size_t i, bool asFullAst);
BINARYNINJACOREAPI size_t BNGetHighLevelILIndexForInstruction(BNHighLevelILFunction* func, size_t i);
BINARYNINJACOREAPI size_t BNGetHighLevelILInstructionForExpr(BNHighLevelILFunction* func, size_t expr);
BINARYNINJACOREAPI size_t BNGetHighLevelILInstructionCount(BNHighLevelILFunction* func);
@@ -4644,13 +4774,15 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI BNMediumLevelILFunction* BNGetMediumLevelILForHighLevelILFunction(BNHighLevelILFunction* func);
BINARYNINJACOREAPI size_t BNGetMediumLevelILExprIndexFromHighLevelIL(BNHighLevelILFunction* func, size_t expr);
- BINARYNINJACOREAPI size_t* BNGetMediumLevelILExprIndexesFromHighLevelIL(BNHighLevelILFunction* func, size_t expr, size_t* count);
+ BINARYNINJACOREAPI size_t* BNGetMediumLevelILExprIndexesFromHighLevelIL(
+ BNHighLevelILFunction* func, size_t expr, size_t* count);
- BINARYNINJACOREAPI void BNUpdateHighLevelILOperand(BNHighLevelILFunction* func, size_t instr, size_t operandIndex, uint64_t value);
+ BINARYNINJACOREAPI void BNUpdateHighLevelILOperand(
+ BNHighLevelILFunction* func, size_t instr, size_t operandIndex, uint64_t value);
BINARYNINJACOREAPI void BNReplaceHighLevelILExpr(BNHighLevelILFunction* func, size_t expr, size_t newExpr);
- BINARYNINJACOREAPI BNDisassemblyTextLine* BNGetHighLevelILExprText(BNHighLevelILFunction* func, size_t expr,
- bool asFullAst, size_t* count, BNDisassemblySettings* settings);
+ BINARYNINJACOREAPI BNDisassemblyTextLine* BNGetHighLevelILExprText(
+ BNHighLevelILFunction* func, size_t expr, bool asFullAst, size_t* count, BNDisassemblySettings* settings);
BINARYNINJACOREAPI BNTypeWithConfidence BNGetHighLevelILExprType(BNHighLevelILFunction* func, size_t expr);
@@ -4664,40 +4796,41 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI size_t BNGetHighLevelILSSAExprIndex(BNHighLevelILFunction* func, size_t expr);
BINARYNINJACOREAPI size_t BNGetHighLevelILNonSSAExprIndex(BNHighLevelILFunction* func, size_t expr);
- BINARYNINJACOREAPI size_t BNGetHighLevelILSSAVarDefinition(BNHighLevelILFunction* func,
- const BNVariable* var, size_t version);
+ BINARYNINJACOREAPI size_t BNGetHighLevelILSSAVarDefinition(
+ BNHighLevelILFunction* func, const BNVariable* var, size_t version);
BINARYNINJACOREAPI size_t BNGetHighLevelILSSAMemoryDefinition(BNHighLevelILFunction* func, size_t version);
- BINARYNINJACOREAPI size_t* BNGetHighLevelILSSAVarUses(BNHighLevelILFunction* func, const BNVariable* var,
- size_t version, size_t* count);
- BINARYNINJACOREAPI size_t* BNGetHighLevelILSSAMemoryUses(BNHighLevelILFunction* func,
- size_t version, size_t* count);
- BINARYNINJACOREAPI bool BNIsHighLevelILSSAVarLive(BNHighLevelILFunction* func,
- const BNVariable* var, size_t version);
- BINARYNINJACOREAPI bool BNIsHighLevelILSSAVarLiveAt(BNHighLevelILFunction* func,
- const BNVariable* var, const size_t version, const size_t instr);
- BINARYNINJACOREAPI bool BNIsHighLevelILVarLiveAt(BNHighLevelILFunction* func,
- const BNVariable* var, const size_t instr);
+ BINARYNINJACOREAPI size_t* BNGetHighLevelILSSAVarUses(
+ BNHighLevelILFunction* func, const BNVariable* var, size_t version, size_t* count);
+ BINARYNINJACOREAPI size_t* BNGetHighLevelILSSAMemoryUses(
+ BNHighLevelILFunction* func, size_t version, size_t* count);
+ BINARYNINJACOREAPI bool BNIsHighLevelILSSAVarLive(
+ BNHighLevelILFunction* func, const BNVariable* var, size_t version);
+ BINARYNINJACOREAPI bool BNIsHighLevelILSSAVarLiveAt(
+ BNHighLevelILFunction* func, const BNVariable* var, const size_t version, const size_t instr);
+ BINARYNINJACOREAPI bool BNIsHighLevelILVarLiveAt(
+ BNHighLevelILFunction* func, const BNVariable* var, const size_t instr);
BINARYNINJACOREAPI BNVariable* BNGetHighLevelILVariables(BNHighLevelILFunction* func, size_t* count);
BINARYNINJACOREAPI BNVariable* BNGetHighLevelILAliasedVariables(BNHighLevelILFunction* func, size_t* count);
- BINARYNINJACOREAPI size_t* BNGetHighLevelILVariableSSAVersions(BNHighLevelILFunction* func, const BNVariable* var, size_t * count);
+ BINARYNINJACOREAPI size_t* BNGetHighLevelILVariableSSAVersions(
+ BNHighLevelILFunction* func, const BNVariable* var, size_t* count);
- BINARYNINJACOREAPI size_t* BNGetHighLevelILVariableDefinitions(BNHighLevelILFunction* func,
- const BNVariable* var, size_t* count);
- BINARYNINJACOREAPI size_t* BNGetHighLevelILVariableUses(BNHighLevelILFunction* func,
- const BNVariable* var, size_t* count);
- BINARYNINJACOREAPI size_t BNGetHighLevelILSSAVarVersionAtILInstruction(BNHighLevelILFunction* func,
- const BNVariable* var, size_t instr);
- BINARYNINJACOREAPI size_t BNGetHighLevelILSSAMemoryVersionAtILInstruction(BNHighLevelILFunction* func,
- size_t instr);
+ BINARYNINJACOREAPI size_t* BNGetHighLevelILVariableDefinitions(
+ BNHighLevelILFunction* func, const BNVariable* var, size_t* count);
+ BINARYNINJACOREAPI size_t* BNGetHighLevelILVariableUses(
+ BNHighLevelILFunction* func, const BNVariable* var, size_t* count);
+ BINARYNINJACOREAPI size_t BNGetHighLevelILSSAVarVersionAtILInstruction(
+ BNHighLevelILFunction* func, const BNVariable* var, size_t instr);
+ BINARYNINJACOREAPI size_t BNGetHighLevelILSSAMemoryVersionAtILInstruction(
+ BNHighLevelILFunction* func, size_t instr);
BINARYNINJACOREAPI size_t BNGetHighLevelILExprIndexForLabel(BNHighLevelILFunction* func, uint64_t label);
BINARYNINJACOREAPI size_t* BNGetHighLevelILUsesForLabel(BNHighLevelILFunction* func, uint64_t label, size_t* count);
- BINARYNINJACOREAPI bool BNHighLevelILExprLessThan(BNHighLevelILFunction* leftFunc, size_t leftExpr,
- BNHighLevelILFunction* rightFunc, size_t rightExpr);
- BINARYNINJACOREAPI bool BNHighLevelILExprEqual(BNHighLevelILFunction* leftFunc, size_t leftExpr,
- BNHighLevelILFunction* rightFunc, size_t rightExpr);
+ BINARYNINJACOREAPI bool BNHighLevelILExprLessThan(
+ BNHighLevelILFunction* leftFunc, size_t leftExpr, BNHighLevelILFunction* rightFunc, size_t rightExpr);
+ BINARYNINJACOREAPI bool BNHighLevelILExprEqual(
+ BNHighLevelILFunction* leftFunc, size_t leftExpr, BNHighLevelILFunction* rightFunc, size_t rightExpr);
// Type Libraries
BINARYNINJACOREAPI BNTypeLibrary* BNNewTypeLibrary(BNArchitecture* arch, const char* name);
@@ -4720,7 +4853,7 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI char* BNGetTypeLibraryName(BNTypeLibrary* lib);
BINARYNINJACOREAPI void BNAddTypeLibraryAlternateName(BNTypeLibrary* lib, const char* name);
- BINARYNINJACOREAPI char** BNGetTypeLibraryAlternateNames(BNTypeLibrary* lib, size_t* count); // BNFreeStringList
+ BINARYNINJACOREAPI char** BNGetTypeLibraryAlternateNames(BNTypeLibrary* lib, size_t* count); // BNFreeStringList
BINARYNINJACOREAPI void BNSetTypeLibraryDependencyName(BNTypeLibrary* lib, const char* name);
BINARYNINJACOREAPI char* BNGetTypeLibraryDependencyName(BNTypeLibrary* lib);
@@ -4730,7 +4863,7 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI void BNClearTypeLibraryPlatforms(BNTypeLibrary* lib);
BINARYNINJACOREAPI void BNAddTypeLibraryPlatform(BNTypeLibrary* lib, BNPlatform* platform);
- BINARYNINJACOREAPI char** BNGetTypeLibraryPlatforms(BNTypeLibrary* lib, size_t* count); // BNFreeStringList
+ BINARYNINJACOREAPI char** BNGetTypeLibraryPlatforms(BNTypeLibrary* lib, size_t* count); // BNFreeStringList
BINARYNINJACOREAPI void BNTypeLibraryStoreMetadata(BNTypeLibrary* lib, const char* key, BNMetadata* value);
BINARYNINJACOREAPI BNMetadata* BNTypeLibraryQueryMetadata(BNTypeLibrary* lib, const char* key);
@@ -4751,15 +4884,21 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI BNTypeLibrary* BNGetBinaryViewTypeLibrary(BNBinaryView* view, const char* name);
BINARYNINJACOREAPI BNTypeLibrary** BNGetBinaryViewTypeLibraries(BNBinaryView* view, size_t* count);
- BINARYNINJACOREAPI BNType* BNBinaryViewImportTypeLibraryType(BNBinaryView* view, BNTypeLibrary* lib, BNQualifiedName* name);
- BINARYNINJACOREAPI BNType* BNBinaryViewImportTypeLibraryObject(BNBinaryView* view, BNTypeLibrary* lib, BNQualifiedName* name);
+ BINARYNINJACOREAPI BNType* BNBinaryViewImportTypeLibraryType(
+ BNBinaryView* view, BNTypeLibrary* lib, BNQualifiedName* name);
+ BINARYNINJACOREAPI BNType* BNBinaryViewImportTypeLibraryObject(
+ BNBinaryView* view, BNTypeLibrary* lib, BNQualifiedName* name);
- BINARYNINJACOREAPI void BNBinaryViewExportTypeToTypeLibrary(BNBinaryView* view, BNTypeLibrary* lib, BNQualifiedName* name, BNType* type);
- BINARYNINJACOREAPI void BNBinaryViewExportObjectToTypeLibrary(BNBinaryView* view, BNTypeLibrary* lib, BNQualifiedName* name, BNType* type);
+ BINARYNINJACOREAPI void BNBinaryViewExportTypeToTypeLibrary(
+ BNBinaryView* view, BNTypeLibrary* lib, BNQualifiedName* name, BNType* type);
+ BINARYNINJACOREAPI void BNBinaryViewExportObjectToTypeLibrary(
+ BNBinaryView* view, BNTypeLibrary* lib, BNQualifiedName* name, BNType* type);
// Language Representation
- BINARYNINJACOREAPI BNLanguageRepresentationFunction* BNCreateLanguageRepresentationFunction(BNArchitecture* arch, BNFunction* func);
- BINARYNINJACOREAPI BNLanguageRepresentationFunction* BNNewLanguageRepresentationFunctionReference(BNLanguageRepresentationFunction* func);
+ BINARYNINJACOREAPI BNLanguageRepresentationFunction* BNCreateLanguageRepresentationFunction(
+ BNArchitecture* arch, BNFunction* func);
+ BINARYNINJACOREAPI BNLanguageRepresentationFunction* BNNewLanguageRepresentationFunctionReference(
+ BNLanguageRepresentationFunction* func);
BINARYNINJACOREAPI void BNFreeLanguageRepresentationFunction(BNLanguageRepresentationFunction* func);
BINARYNINJACOREAPI BNFunction* BNGetLanguageRepresentationOwnerFunction(BNLanguageRepresentationFunction* func);
@@ -4772,16 +4911,18 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI BNType* BNCreateFloatType(size_t width, const char* altName);
BINARYNINJACOREAPI BNType* BNCreateWideCharType(size_t width, const char* altName);
BINARYNINJACOREAPI BNType* BNCreateStructureType(BNStructure* s);
- BINARYNINJACOREAPI BNType* BNCreateEnumerationType(BNArchitecture* arch, BNEnumeration* e, size_t width, BNBoolWithConfidence* isSigned);
- BINARYNINJACOREAPI BNType* BNCreateEnumerationTypeOfWidth(BNEnumeration* e, size_t width, BNBoolWithConfidence* isSigned);
+ BINARYNINJACOREAPI BNType* BNCreateEnumerationType(
+ BNArchitecture* arch, BNEnumeration* e, size_t width, BNBoolWithConfidence* isSigned);
+ BINARYNINJACOREAPI BNType* BNCreateEnumerationTypeOfWidth(
+ BNEnumeration* e, size_t width, BNBoolWithConfidence* isSigned);
BINARYNINJACOREAPI BNType* BNCreatePointerType(BNArchitecture* arch, const BNTypeWithConfidence* const type,
- BNBoolWithConfidence* cnst, BNBoolWithConfidence* vltl, BNReferenceType refType);
+ BNBoolWithConfidence* cnst, BNBoolWithConfidence* vltl, BNReferenceType refType);
BINARYNINJACOREAPI BNType* BNCreatePointerTypeOfWidth(size_t width, const BNTypeWithConfidence* const type,
- BNBoolWithConfidence* cnst, BNBoolWithConfidence* vltl, BNReferenceType refType);
+ BNBoolWithConfidence* cnst, BNBoolWithConfidence* vltl, BNReferenceType refType);
BINARYNINJACOREAPI BNType* BNCreateArrayType(const BNTypeWithConfidence* const type, uint64_t elem);
BINARYNINJACOREAPI BNType* BNCreateFunctionType(BNTypeWithConfidence* returnValue,
- BNCallingConventionWithConfidence* callingConvention, BNFunctionParameter* params,
- size_t paramCount, BNBoolWithConfidence* varArg, BNOffsetWithConfidence* stackAdjust);
+ BNCallingConventionWithConfidence* callingConvention, BNFunctionParameter* params, size_t paramCount,
+ BNBoolWithConfidence* varArg, BNOffsetWithConfidence* stackAdjust);
BINARYNINJACOREAPI BNType* BNNewTypeReference(BNType* type);
BINARYNINJACOREAPI BNType* BNDuplicateType(BNType* type);
BINARYNINJACOREAPI char* BNGetTypeAndName(BNType* type, BNQualifiedName* name);
@@ -4790,21 +4931,26 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI BNTypeBuilder* BNCreateTypeBuilderFromType(BNType* type);
BINARYNINJACOREAPI BNTypeBuilder* BNCreateVoidTypeBuilder(void);
BINARYNINJACOREAPI BNTypeBuilder* BNCreateBoolTypeBuilder(void);
- BINARYNINJACOREAPI BNTypeBuilder* BNCreateIntegerTypeBuilder(size_t width, BNBoolWithConfidence* sign, const char* altName);
+ BINARYNINJACOREAPI BNTypeBuilder* BNCreateIntegerTypeBuilder(
+ size_t width, BNBoolWithConfidence* sign, const char* altName);
BINARYNINJACOREAPI BNTypeBuilder* BNCreateFloatTypeBuilder(size_t width, const char* altName);
BINARYNINJACOREAPI BNTypeBuilder* BNCreateWideCharTypeBuilder(size_t width, const char* altName);
BINARYNINJACOREAPI BNTypeBuilder* BNCreateStructureTypeBuilder(BNStructure* s);
BINARYNINJACOREAPI BNTypeBuilder* BNCreateStructureTypeBuilderWithBuilder(BNStructureBuilder* s);
- BINARYNINJACOREAPI BNTypeBuilder* BNCreateEnumerationTypeBuilder(BNArchitecture* arch, BNEnumeration* e, size_t width, BNBoolWithConfidence* isSigned);
- BINARYNINJACOREAPI BNTypeBuilder* BNCreateEnumerationTypeBuilderWithBuilder(BNArchitecture* arch, BNEnumerationBuilder* e, size_t width, BNBoolWithConfidence* isSigned);
- BINARYNINJACOREAPI BNTypeBuilder* BNCreatePointerTypeBuilder(BNArchitecture* arch, const BNTypeWithConfidence* const type,
- BNBoolWithConfidence* cnst, BNBoolWithConfidence* vltl, BNReferenceType refType);
- BINARYNINJACOREAPI BNTypeBuilder* BNCreatePointerTypeBuilderOfWidth(size_t width, const BNTypeWithConfidence* const type,
- BNBoolWithConfidence* cnst, BNBoolWithConfidence* vltl, BNReferenceType refType);
+ BINARYNINJACOREAPI BNTypeBuilder* BNCreateEnumerationTypeBuilder(
+ BNArchitecture* arch, BNEnumeration* e, size_t width, BNBoolWithConfidence* isSigned);
+ BINARYNINJACOREAPI BNTypeBuilder* BNCreateEnumerationTypeBuilderWithBuilder(
+ BNArchitecture* arch, BNEnumerationBuilder* e, size_t width, BNBoolWithConfidence* isSigned);
+ BINARYNINJACOREAPI BNTypeBuilder* BNCreatePointerTypeBuilder(BNArchitecture* arch,
+ const BNTypeWithConfidence* const type, BNBoolWithConfidence* cnst, BNBoolWithConfidence* vltl,
+ BNReferenceType refType);
+ BINARYNINJACOREAPI BNTypeBuilder* BNCreatePointerTypeBuilderOfWidth(size_t width,
+ const BNTypeWithConfidence* const type, BNBoolWithConfidence* cnst, BNBoolWithConfidence* vltl,
+ BNReferenceType refType);
BINARYNINJACOREAPI BNTypeBuilder* BNCreateArrayTypeBuilder(const BNTypeWithConfidence* const type, uint64_t elem);
BINARYNINJACOREAPI BNTypeBuilder* BNCreateFunctionTypeBuilder(BNTypeWithConfidence* returnValue,
- BNCallingConventionWithConfidence* callingConvention, BNFunctionParameter* params,
- size_t paramCount, BNBoolWithConfidence* varArg, BNOffsetWithConfidence* stackAdjust);
+ BNCallingConventionWithConfidence* callingConvention, BNFunctionParameter* params, size_t paramCount,
+ BNBoolWithConfidence* varArg, BNOffsetWithConfidence* stackAdjust);
BINARYNINJACOREAPI BNType* BNFinalizeTypeBuilder(BNTypeBuilder* type);
BINARYNINJACOREAPI BNTypeBuilder* BNDuplicateTypeBuilder(BNTypeBuilder* type);
BINARYNINJACOREAPI char* BNGetTypeBuilderTypeAndName(BNTypeBuilder* type, BNQualifiedName* name);
@@ -4842,19 +4988,20 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI char* BNGetTypeString(BNType* type, BNPlatform* platform);
BINARYNINJACOREAPI char* BNGetTypeStringBeforeName(BNType* type, BNPlatform* platform);
BINARYNINJACOREAPI char* BNGetTypeStringAfterName(BNType* type, BNPlatform* platform);
- BINARYNINJACOREAPI BNInstructionTextToken* BNGetTypeTokens(BNType* type, BNPlatform* platform,
- uint8_t baseConfidence, size_t* count);
- BINARYNINJACOREAPI BNInstructionTextToken* BNGetTypeTokensBeforeName(BNType* type, BNPlatform* platform,
- uint8_t baseConfidence, size_t* count);
- BINARYNINJACOREAPI BNInstructionTextToken* BNGetTypeTokensAfterName(BNType* type, BNPlatform* platform,
- uint8_t baseConfidence, size_t* count);
+ BINARYNINJACOREAPI BNInstructionTextToken* BNGetTypeTokens(
+ BNType* type, BNPlatform* platform, uint8_t baseConfidence, size_t* count);
+ BINARYNINJACOREAPI BNInstructionTextToken* BNGetTypeTokensBeforeName(
+ BNType* type, BNPlatform* platform, uint8_t baseConfidence, size_t* count);
+ BINARYNINJACOREAPI BNInstructionTextToken* BNGetTypeTokensAfterName(
+ BNType* type, BNPlatform* platform, uint8_t baseConfidence, size_t* count);
BINARYNINJACOREAPI BNType* BNTypeWithReplacedStructure(BNType* type, BNStructure* from, BNStructure* to);
BINARYNINJACOREAPI BNType* BNTypeWithReplacedEnumeration(BNType* type, BNEnumeration* from, BNEnumeration* to);
- BINARYNINJACOREAPI BNType* BNTypeWithReplacedNamedTypeReference(BNType* type, BNNamedTypeReference* from, BNNamedTypeReference* to);
+ BINARYNINJACOREAPI BNType* BNTypeWithReplacedNamedTypeReference(
+ BNType* type, BNNamedTypeReference* from, BNNamedTypeReference* to);
- BINARYNINJACOREAPI bool BNAddTypeMemberTokens(BNType* type, BNBinaryView* data, BNInstructionTextToken** tokens, size_t* tokenCount,
- int64_t offset, char*** nameList, size_t* nameCount, size_t size, bool indirect);
+ BINARYNINJACOREAPI bool BNAddTypeMemberTokens(BNType* type, BNBinaryView* data, BNInstructionTextToken** tokens,
+ size_t* tokenCount, int64_t offset, char*** nameList, size_t* nameCount, size_t size, bool indirect);
BINARYNINJACOREAPI BNQualifiedName BNTypeBuilderGetTypeName(BNTypeBuilder* nt);
BINARYNINJACOREAPI void BNTypeBuilderSetTypeName(BNTypeBuilder* type, BNQualifiedName* name);
@@ -4878,7 +5025,8 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI uint64_t BNGetTypeBuilderElementCount(BNTypeBuilder* type);
BINARYNINJACOREAPI uint64_t BNGetTypeBuilderOffset(BNTypeBuilder* type);
BINARYNINJACOREAPI void BNSetFunctionTypeBuilderCanReturn(BNTypeBuilder* type, BNBoolWithConfidence* canReturn);
- BINARYNINJACOREAPI void BNSetFunctionTypeBuilderParameters(BNTypeBuilder* type, BNFunctionParameter* params, size_t paramCount);
+ BINARYNINJACOREAPI void BNSetFunctionTypeBuilderParameters(
+ BNTypeBuilder* type, BNFunctionParameter* params, size_t paramCount);
BINARYNINJACOREAPI void BNTypeBuilderSetConst(BNTypeBuilder* type, BNBoolWithConfidence* cnst);
BINARYNINJACOREAPI void BNTypeBuilderSetVolatile(BNTypeBuilder* type, BNBoolWithConfidence* vltl);
BINARYNINJACOREAPI void BNTypeBuilderSetSigned(BNTypeBuilder* type, BNBoolWithConfidence* sign);
@@ -4893,21 +5041,28 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI char* BNGetTypeBuilderString(BNTypeBuilder* type, BNPlatform* platform);
BINARYNINJACOREAPI char* BNGetTypeBuilderStringBeforeName(BNTypeBuilder* type, BNPlatform* platform);
BINARYNINJACOREAPI char* BNGetTypeBuilderStringAfterName(BNTypeBuilder* type, BNPlatform* platform);
- BINARYNINJACOREAPI BNInstructionTextToken* BNGetTypeBuilderTokens(BNTypeBuilder* type, BNPlatform* platform,
- uint8_t baseConfidence, size_t* count);
- BINARYNINJACOREAPI BNInstructionTextToken* BNGetTypeBuilderTokensBeforeName(BNTypeBuilder* type, BNPlatform* platform,
- uint8_t baseConfidence, size_t* count);
- BINARYNINJACOREAPI BNInstructionTextToken* BNGetTypeBuilderTokensAfterName(BNTypeBuilder* type, BNPlatform* platform,
- uint8_t baseConfidence, size_t* count);
+ BINARYNINJACOREAPI BNInstructionTextToken* BNGetTypeBuilderTokens(
+ BNTypeBuilder* type, BNPlatform* platform, uint8_t baseConfidence, size_t* count);
+ BINARYNINJACOREAPI BNInstructionTextToken* BNGetTypeBuilderTokensBeforeName(
+ BNTypeBuilder* type, BNPlatform* platform, uint8_t baseConfidence, size_t* count);
+ BINARYNINJACOREAPI BNInstructionTextToken* BNGetTypeBuilderTokensAfterName(
+ BNTypeBuilder* type, BNPlatform* platform, uint8_t baseConfidence, size_t* count);
- BINARYNINJACOREAPI BNType* BNCreateNamedTypeReference(BNNamedTypeReference* nt, size_t width, size_t align, BNBoolWithConfidence* cnst, BNBoolWithConfidence* vltl);
- BINARYNINJACOREAPI BNType* BNCreateNamedTypeReferenceFromTypeAndId(const char* id, BNQualifiedName* name, BNType* type);
+ BINARYNINJACOREAPI BNType* BNCreateNamedTypeReference(
+ BNNamedTypeReference* nt, size_t width, size_t align, BNBoolWithConfidence* cnst, BNBoolWithConfidence* vltl);
+ BINARYNINJACOREAPI BNType* BNCreateNamedTypeReferenceFromTypeAndId(
+ const char* id, BNQualifiedName* name, BNType* type);
BINARYNINJACOREAPI BNType* BNCreateNamedTypeReferenceFromType(BNBinaryView* view, BNQualifiedName* name);
- BINARYNINJACOREAPI BNTypeBuilder* BNCreateNamedTypeReferenceBuilder(BNNamedTypeReference* nt, size_t width, size_t align, BNBoolWithConfidence* cnst, BNBoolWithConfidence* vltl);
- BINARYNINJACOREAPI BNTypeBuilder* BNCreateNamedTypeReferenceBuilderWithBuilder(BNNamedTypeReferenceBuilder* nt, size_t width, size_t align, BNBoolWithConfidence* cnst, BNBoolWithConfidence* vltl);
- BINARYNINJACOREAPI BNTypeBuilder* BNCreateNamedTypeReferenceBuilderFromTypeAndId(const char* id, BNQualifiedName* name, BNType* type);
- BINARYNINJACOREAPI BNTypeBuilder* BNCreateNamedTypeReferenceBuilderFromType(BNBinaryView* view, BNQualifiedName* name);
- BINARYNINJACOREAPI BNNamedTypeReference* BNCreateNamedType(BNNamedTypeReferenceClass cls, const char* id, BNQualifiedName* name);
+ BINARYNINJACOREAPI BNTypeBuilder* BNCreateNamedTypeReferenceBuilder(
+ BNNamedTypeReference* nt, size_t width, size_t align, BNBoolWithConfidence* cnst, BNBoolWithConfidence* vltl);
+ BINARYNINJACOREAPI BNTypeBuilder* BNCreateNamedTypeReferenceBuilderWithBuilder(BNNamedTypeReferenceBuilder* nt,
+ size_t width, size_t align, BNBoolWithConfidence* cnst, BNBoolWithConfidence* vltl);
+ BINARYNINJACOREAPI BNTypeBuilder* BNCreateNamedTypeReferenceBuilderFromTypeAndId(
+ const char* id, BNQualifiedName* name, BNType* type);
+ BINARYNINJACOREAPI BNTypeBuilder* BNCreateNamedTypeReferenceBuilderFromType(
+ BNBinaryView* view, BNQualifiedName* name);
+ BINARYNINJACOREAPI BNNamedTypeReference* BNCreateNamedType(
+ BNNamedTypeReferenceClass cls, const char* id, BNQualifiedName* name);
BINARYNINJACOREAPI BNNamedTypeReferenceClass BNGetTypeReferenceClass(BNNamedTypeReference* nt);
BINARYNINJACOREAPI char* BNGetTypeReferenceId(BNNamedTypeReference* nt);
BINARYNINJACOREAPI BNQualifiedName BNGetTypeReferenceName(BNNamedTypeReference* nt);
@@ -4915,9 +5070,11 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI void BNFreeNamedTypeReference(BNNamedTypeReference* nt);
BINARYNINJACOREAPI BNNamedTypeReference* BNNewNamedTypeReference(BNNamedTypeReference* nt);
- BINARYNINJACOREAPI BNNamedTypeReferenceBuilder* BNCreateNamedTypeBuilder(BNNamedTypeReferenceClass cls, const char* id, BNQualifiedName* name);
+ BINARYNINJACOREAPI BNNamedTypeReferenceBuilder* BNCreateNamedTypeBuilder(
+ BNNamedTypeReferenceClass cls, const char* id, BNQualifiedName* name);
BINARYNINJACOREAPI void BNFreeNamedTypeReferenceBuilder(BNNamedTypeReferenceBuilder* s);
- BINARYNINJACOREAPI void BNSetNamedTypeReferenceBuilderTypeClass(BNNamedTypeReferenceBuilder* s, BNNamedTypeReferenceClass type);
+ BINARYNINJACOREAPI void BNSetNamedTypeReferenceBuilderTypeClass(
+ BNNamedTypeReferenceBuilder* s, BNNamedTypeReferenceClass type);
BINARYNINJACOREAPI void BNSetNamedTypeReferenceBuilderTypeId(BNNamedTypeReferenceBuilder* s, const char* id);
BINARYNINJACOREAPI void BNSetNamedTypeReferenceBuilderName(BNNamedTypeReferenceBuilder* s, BNQualifiedName* name);
BINARYNINJACOREAPI BNNamedTypeReference* BNFinalizeNamedTypeReferenceBuilder(BNNamedTypeReferenceBuilder* s);
@@ -4945,13 +5102,16 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI bool BNIsStructureUnion(BNStructure* s);
BINARYNINJACOREAPI BNStructureVariant BNGetStructureType(BNStructure* s);
- BINARYNINJACOREAPI BNStructure* BNStructureWithReplacedStructure(BNStructure* s, BNStructure* from, BNStructure* to);
- BINARYNINJACOREAPI BNStructure* BNStructureWithReplacedEnumeration(BNStructure* s, BNEnumeration* from, BNEnumeration* to);
- BINARYNINJACOREAPI BNStructure* BNStructureWithReplacedNamedTypeReference(BNStructure* s,
- BNNamedTypeReference* from, BNNamedTypeReference* to);
+ BINARYNINJACOREAPI BNStructure* BNStructureWithReplacedStructure(
+ BNStructure* s, BNStructure* from, BNStructure* to);
+ BINARYNINJACOREAPI BNStructure* BNStructureWithReplacedEnumeration(
+ BNStructure* s, BNEnumeration* from, BNEnumeration* to);
+ BINARYNINJACOREAPI BNStructure* BNStructureWithReplacedNamedTypeReference(
+ BNStructure* s, BNNamedTypeReference* from, BNNamedTypeReference* to);
BINARYNINJACOREAPI BNStructureMember* BNGetStructureBuilderMemberByName(BNStructureBuilder* s, const char* name);
- BINARYNINJACOREAPI BNStructureMember* BNGetStructureBuilderMemberAtOffset(BNStructureBuilder* s, int64_t offset, size_t* idx);
+ BINARYNINJACOREAPI BNStructureMember* BNGetStructureBuilderMemberAtOffset(
+ BNStructureBuilder* s, int64_t offset, size_t* idx);
BINARYNINJACOREAPI BNStructureMember* BNGetStructureBuilderMembers(BNStructureBuilder* s, size_t* count);
BINARYNINJACOREAPI uint64_t BNGetStructureBuilderWidth(BNStructureBuilder* s);
BINARYNINJACOREAPI void BNSetStructureBuilderWidth(BNStructureBuilder* s, uint64_t width);
@@ -4964,13 +5124,13 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI BNStructureVariant BNGetStructureBuilderType(BNStructureBuilder* s);
BINARYNINJACOREAPI void BNAddStructureBuilderMember(BNStructureBuilder* s, const BNTypeWithConfidence* const type,
- const char* name, BNMemberAccess access, BNMemberScope scope);
+ const char* name, BNMemberAccess access, BNMemberScope scope);
BINARYNINJACOREAPI void BNAddStructureBuilderMemberAtOffset(BNStructureBuilder* s,
- const BNTypeWithConfidence* const type, const char* name, uint64_t offset,
- bool overwriteExisting, BNMemberAccess access, BNMemberScope scope);
+ const BNTypeWithConfidence* const type, const char* name, uint64_t offset, bool overwriteExisting,
+ BNMemberAccess access, BNMemberScope scope);
BINARYNINJACOREAPI void BNRemoveStructureBuilderMember(BNStructureBuilder* s, size_t idx);
BINARYNINJACOREAPI void BNReplaceStructureBuilderMember(BNStructureBuilder* s, size_t idx,
- const BNTypeWithConfidence* const type, const char* name, bool overwriteExisting);
+ const BNTypeWithConfidence* const type, const char* name, bool overwriteExisting);
BINARYNINJACOREAPI BNEnumerationBuilder* BNCreateEnumerationBuilder(void);
BINARYNINJACOREAPI BNEnumerationBuilder* BNCreateEnumerationBuilderFromEnumeration(BNEnumeration* e);
@@ -4986,24 +5146,26 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI BNEnumerationMember* BNGetEnumerationBuilderMembers(BNEnumerationBuilder* e, size_t* count);
BINARYNINJACOREAPI void BNAddEnumerationBuilderMember(BNEnumerationBuilder* e, const char* name);
- BINARYNINJACOREAPI void BNAddEnumerationBuilderMemberWithValue(BNEnumerationBuilder* e, const char* name, uint64_t value);
+ BINARYNINJACOREAPI void BNAddEnumerationBuilderMemberWithValue(
+ BNEnumerationBuilder* e, const char* name, uint64_t value);
BINARYNINJACOREAPI void BNRemoveEnumerationBuilderMember(BNEnumerationBuilder* e, size_t idx);
- BINARYNINJACOREAPI void BNReplaceEnumerationBuilderMember(BNEnumerationBuilder* e, size_t idx, const char* name, uint64_t value);
+ BINARYNINJACOREAPI void BNReplaceEnumerationBuilderMember(
+ BNEnumerationBuilder* e, size_t idx, const char* name, uint64_t value);
- BINARYNINJACOREAPI BNStructure* BNCreateStructureFromOffsetAccess(BNBinaryView* view,
- BNQualifiedName* name, bool* newMember);
+ BINARYNINJACOREAPI BNStructure* BNCreateStructureFromOffsetAccess(
+ BNBinaryView* view, BNQualifiedName* name, bool* newMember);
BINARYNINJACOREAPI BNTypeWithConfidence BNCreateStructureMemberFromAccess(
- BNBinaryView* view, BNQualifiedName* name, uint64_t offset);
+ BNBinaryView* view, BNQualifiedName* name, uint64_t offset);
// Source code processing
BINARYNINJACOREAPI bool BNPreprocessSource(const char* source, const char* fileName, char** output, char** errors,
- const char** includeDirs, size_t includeDirCount);
+ const char** includeDirs, size_t includeDirCount);
BINARYNINJACOREAPI bool BNParseTypesFromSource(BNPlatform* platform, const char* source, const char* fileName,
- BNTypeParserResult* result, char** errors, const char** includeDirs, size_t includeDirCount,
- const char* autoTypeSource);
+ BNTypeParserResult* result, char** errors, const char** includeDirs, size_t includeDirCount,
+ const char* autoTypeSource);
BINARYNINJACOREAPI bool BNParseTypesFromSourceFile(BNPlatform* platform, const char* fileName,
- BNTypeParserResult* result, char** errors, const char** includeDirs, size_t includeDirCount,
- const char* autoTypeSource);
+ BNTypeParserResult* result, char** errors, const char** includeDirs, size_t includeDirCount,
+ const char* autoTypeSource);
BINARYNINJACOREAPI void BNFreeTypeParserResult(BNTypeParserResult* result);
// Updates
@@ -5012,14 +5174,13 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI BNUpdateVersion* BNGetUpdateChannelVersions(const char* channel, size_t* count, char** errors);
BINARYNINJACOREAPI void BNFreeUpdateChannelVersionList(BNUpdateVersion* list, size_t count);
- BINARYNINJACOREAPI bool BNAreUpdatesAvailable(const char* channel, uint64_t* expireTime, uint64_t* serverTime, char** errors);
+ BINARYNINJACOREAPI bool BNAreUpdatesAvailable(
+ const char* channel, uint64_t* expireTime, uint64_t* serverTime, char** errors);
BINARYNINJACOREAPI BNUpdateResult BNUpdateToVersion(const char* channel, const char* version, char** errors,
- bool (*progress)(void* ctxt, uint64_t progress, uint64_t total),
- void* context);
+ bool (*progress)(void* ctxt, uint64_t progress, uint64_t total), void* context);
BINARYNINJACOREAPI BNUpdateResult BNUpdateToLatestVersion(const char* channel, char** errors,
- bool (*progress)(void* ctxt, uint64_t progress, uint64_t total),
- void* context);
+ bool (*progress)(void* ctxt, uint64_t progress, uint64_t total), void* context);
BINARYNINJACOREAPI bool BNAreAutoUpdatesEnabled(void);
BINARYNINJACOREAPI void BNSetAutoUpdatesEnabled(bool enabled);
@@ -5034,68 +5195,69 @@ __attribute__ ((format (printf, 1, 2)))
// Plugin commands
BINARYNINJACOREAPI void BNRegisterPluginCommand(const char* name, const char* description,
- void (*action)(void* ctxt, BNBinaryView* view), bool (*isValid)(void* ctxt, BNBinaryView* view), void* context);
+ void (*action)(void* ctxt, BNBinaryView* view), bool (*isValid)(void* ctxt, BNBinaryView* view), void* context);
BINARYNINJACOREAPI void BNRegisterPluginCommandForAddress(const char* name, const char* description,
- void (*action)(void* ctxt, BNBinaryView* view, uint64_t addr),
- bool (*isValid)(void* ctxt, BNBinaryView* view, uint64_t addr), void* context);
+ void (*action)(void* ctxt, BNBinaryView* view, uint64_t addr),
+ bool (*isValid)(void* ctxt, BNBinaryView* view, uint64_t addr), void* context);
BINARYNINJACOREAPI void BNRegisterPluginCommandForRange(const char* name, const char* description,
- void (*action)(void* ctxt, BNBinaryView* view, uint64_t addr, uint64_t len),
- bool (*isValid)(void* ctxt, BNBinaryView* view, uint64_t addr, uint64_t len), void* context);
+ void (*action)(void* ctxt, BNBinaryView* view, uint64_t addr, uint64_t len),
+ bool (*isValid)(void* ctxt, BNBinaryView* view, uint64_t addr, uint64_t len), void* context);
BINARYNINJACOREAPI void BNRegisterPluginCommandForFunction(const char* name, const char* description,
- void (*action)(void* ctxt, BNBinaryView* view, BNFunction* func),
- bool (*isValid)(void* ctxt, BNBinaryView* view, BNFunction* func), void* context);
+ void (*action)(void* ctxt, BNBinaryView* view, BNFunction* func),
+ bool (*isValid)(void* ctxt, BNBinaryView* view, BNFunction* func), void* context);
BINARYNINJACOREAPI void BNRegisterPluginCommandForLowLevelILFunction(const char* name, const char* description,
- void (*action)(void* ctxt, BNBinaryView* view, BNLowLevelILFunction* func),
- bool (*isValid)(void* ctxt, BNBinaryView* view, BNLowLevelILFunction* func), void* context);
+ void (*action)(void* ctxt, BNBinaryView* view, BNLowLevelILFunction* func),
+ bool (*isValid)(void* ctxt, BNBinaryView* view, BNLowLevelILFunction* func), void* context);
BINARYNINJACOREAPI void BNRegisterPluginCommandForLowLevelILInstruction(const char* name, const char* description,
- void (*action)(void* ctxt, BNBinaryView* view, BNLowLevelILFunction* func, size_t instr),
- bool (*isValid)(void* ctxt, BNBinaryView* view, BNLowLevelILFunction* func, size_t instr), void* context);
+ void (*action)(void* ctxt, BNBinaryView* view, BNLowLevelILFunction* func, size_t instr),
+ bool (*isValid)(void* ctxt, BNBinaryView* view, BNLowLevelILFunction* func, size_t instr), void* context);
BINARYNINJACOREAPI void BNRegisterPluginCommandForMediumLevelILFunction(const char* name, const char* description,
- void (*action)(void* ctxt, BNBinaryView* view, BNMediumLevelILFunction* func),
- bool (*isValid)(void* ctxt, BNBinaryView* view, BNMediumLevelILFunction* func), void* context);
- BINARYNINJACOREAPI void BNRegisterPluginCommandForMediumLevelILInstruction(const char* name, const char* description,
- void (*action)(void* ctxt, BNBinaryView* view, BNMediumLevelILFunction* func, size_t instr),
- bool (*isValid)(void* ctxt, BNBinaryView* view, BNMediumLevelILFunction* func, size_t instr), void* context);
+ void (*action)(void* ctxt, BNBinaryView* view, BNMediumLevelILFunction* func),
+ bool (*isValid)(void* ctxt, BNBinaryView* view, BNMediumLevelILFunction* func), void* context);
+ BINARYNINJACOREAPI void BNRegisterPluginCommandForMediumLevelILInstruction(const char* name,
+ const char* description,
+ void (*action)(void* ctxt, BNBinaryView* view, BNMediumLevelILFunction* func, size_t instr),
+ bool (*isValid)(void* ctxt, BNBinaryView* view, BNMediumLevelILFunction* func, size_t instr), void* context);
BINARYNINJACOREAPI void BNRegisterPluginCommandForHighLevelILFunction(const char* name, const char* description,
- void (*action)(void* ctxt, BNBinaryView* view, BNHighLevelILFunction* func),
- bool (*isValid)(void* ctxt, BNBinaryView* view, BNHighLevelILFunction* func), void* context);
+ void (*action)(void* ctxt, BNBinaryView* view, BNHighLevelILFunction* func),
+ bool (*isValid)(void* ctxt, BNBinaryView* view, BNHighLevelILFunction* func), void* context);
BINARYNINJACOREAPI void BNRegisterPluginCommandForHighLevelILInstruction(const char* name, const char* description,
- void (*action)(void* ctxt, BNBinaryView* view, BNHighLevelILFunction* func, size_t instr),
- bool (*isValid)(void* ctxt, BNBinaryView* view, BNHighLevelILFunction* func, size_t instr), void* context);
+ void (*action)(void* ctxt, BNBinaryView* view, BNHighLevelILFunction* func, size_t instr),
+ bool (*isValid)(void* ctxt, BNBinaryView* view, BNHighLevelILFunction* func, size_t instr), void* context);
BINARYNINJACOREAPI BNPluginCommand* BNGetAllPluginCommands(size_t* count);
BINARYNINJACOREAPI BNPluginCommand* BNGetValidPluginCommands(BNBinaryView* view, size_t* count);
- BINARYNINJACOREAPI BNPluginCommand* BNGetValidPluginCommandsForAddress(BNBinaryView* view, uint64_t addr,
- size_t* count);
- BINARYNINJACOREAPI BNPluginCommand* BNGetValidPluginCommandsForRange(BNBinaryView* view, uint64_t addr,
- uint64_t len, size_t* count);
- BINARYNINJACOREAPI BNPluginCommand* BNGetValidPluginCommandsForFunction(BNBinaryView* view, BNFunction* func,
- size_t* count);
- BINARYNINJACOREAPI BNPluginCommand* BNGetValidPluginCommandsForLowLevelILFunction(BNBinaryView* view,
- BNLowLevelILFunction* func, size_t* count);
- BINARYNINJACOREAPI BNPluginCommand* BNGetValidPluginCommandsForLowLevelILInstruction(BNBinaryView* view,
- BNLowLevelILFunction* func, size_t instr, size_t* count);
- BINARYNINJACOREAPI BNPluginCommand* BNGetValidPluginCommandsForMediumLevelILFunction(BNBinaryView* view,
- BNMediumLevelILFunction* func, size_t* count);
- BINARYNINJACOREAPI BNPluginCommand* BNGetValidPluginCommandsForMediumLevelILInstruction(BNBinaryView* view,
- BNMediumLevelILFunction* func, size_t instr, size_t* count);
- BINARYNINJACOREAPI BNPluginCommand* BNGetValidPluginCommandsForHighLevelILFunction(BNBinaryView* view,
- BNHighLevelILFunction* func, size_t* count);
- BINARYNINJACOREAPI BNPluginCommand* BNGetValidPluginCommandsForHighLevelILInstruction(BNBinaryView* view,
- BNHighLevelILFunction* func, size_t instr, size_t* count);
+ BINARYNINJACOREAPI BNPluginCommand* BNGetValidPluginCommandsForAddress(
+ BNBinaryView* view, uint64_t addr, size_t* count);
+ BINARYNINJACOREAPI BNPluginCommand* BNGetValidPluginCommandsForRange(
+ BNBinaryView* view, uint64_t addr, uint64_t len, size_t* count);
+ BINARYNINJACOREAPI BNPluginCommand* BNGetValidPluginCommandsForFunction(
+ BNBinaryView* view, BNFunction* func, size_t* count);
+ BINARYNINJACOREAPI BNPluginCommand* BNGetValidPluginCommandsForLowLevelILFunction(
+ BNBinaryView* view, BNLowLevelILFunction* func, size_t* count);
+ BINARYNINJACOREAPI BNPluginCommand* BNGetValidPluginCommandsForLowLevelILInstruction(
+ BNBinaryView* view, BNLowLevelILFunction* func, size_t instr, size_t* count);
+ BINARYNINJACOREAPI BNPluginCommand* BNGetValidPluginCommandsForMediumLevelILFunction(
+ BNBinaryView* view, BNMediumLevelILFunction* func, size_t* count);
+ BINARYNINJACOREAPI BNPluginCommand* BNGetValidPluginCommandsForMediumLevelILInstruction(
+ BNBinaryView* view, BNMediumLevelILFunction* func, size_t instr, size_t* count);
+ BINARYNINJACOREAPI BNPluginCommand* BNGetValidPluginCommandsForHighLevelILFunction(
+ BNBinaryView* view, BNHighLevelILFunction* func, size_t* count);
+ BINARYNINJACOREAPI BNPluginCommand* BNGetValidPluginCommandsForHighLevelILInstruction(
+ BNBinaryView* view, BNHighLevelILFunction* func, size_t instr, size_t* count);
BINARYNINJACOREAPI void BNFreePluginCommandList(BNPluginCommand* commands);
// Calling conventions
- BINARYNINJACOREAPI BNCallingConvention* BNCreateCallingConvention(BNArchitecture* arch, const char* name,
- BNCustomCallingConvention* cc);
+ BINARYNINJACOREAPI BNCallingConvention* BNCreateCallingConvention(
+ BNArchitecture* arch, const char* name, BNCustomCallingConvention* cc);
BINARYNINJACOREAPI void BNRegisterCallingConvention(BNArchitecture* arch, BNCallingConvention* cc);
BINARYNINJACOREAPI BNCallingConvention* BNNewCallingConventionReference(BNCallingConvention* cc);
BINARYNINJACOREAPI void BNFreeCallingConvention(BNCallingConvention* cc);
BINARYNINJACOREAPI BNCallingConvention** BNGetArchitectureCallingConventions(BNArchitecture* arch, size_t* count);
BINARYNINJACOREAPI void BNFreeCallingConventionList(BNCallingConvention** list, size_t count);
- BINARYNINJACOREAPI BNCallingConvention* BNGetArchitectureCallingConventionByName(BNArchitecture* arch,
- const char* name);
+ BINARYNINJACOREAPI BNCallingConvention* BNGetArchitectureCallingConventionByName(
+ BNArchitecture* arch, const char* name);
BINARYNINJACOREAPI BNArchitecture* BNGetCallingConventionArchitecture(BNCallingConvention* cc);
BINARYNINJACOREAPI char* BNGetCallingConventionName(BNCallingConvention* cc);
@@ -5116,17 +5278,18 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI uint32_t BNGetGlobalPointerRegister(BNCallingConvention* cc);
BINARYNINJACOREAPI uint32_t* BNGetImplicitlyDefinedRegisters(BNCallingConvention* cc, size_t* count);
- BINARYNINJACOREAPI BNRegisterValue BNGetIncomingRegisterValue(BNCallingConvention* cc, uint32_t reg, BNFunction* func);
+ BINARYNINJACOREAPI BNRegisterValue BNGetIncomingRegisterValue(
+ BNCallingConvention* cc, uint32_t reg, BNFunction* func);
BINARYNINJACOREAPI BNRegisterValue BNGetIncomingFlagValue(BNCallingConvention* cc, uint32_t reg, BNFunction* func);
- BINARYNINJACOREAPI BNVariable BNGetIncomingVariableForParameterVariable(BNCallingConvention* cc,
- const BNVariable* var, BNFunction* func);
- BINARYNINJACOREAPI BNVariable BNGetParameterVariableForIncomingVariable(BNCallingConvention* cc,
- const BNVariable* var, BNFunction* func);
- BINARYNINJACOREAPI BNVariable BNGetDefaultIncomingVariableForParameterVariable(BNCallingConvention* cc,
- const BNVariable* var);
- BINARYNINJACOREAPI BNVariable BNGetDefaultParameterVariableForIncomingVariable(BNCallingConvention* cc,
- const BNVariable* var);
+ BINARYNINJACOREAPI BNVariable BNGetIncomingVariableForParameterVariable(
+ BNCallingConvention* cc, const BNVariable* var, BNFunction* func);
+ BINARYNINJACOREAPI BNVariable BNGetParameterVariableForIncomingVariable(
+ BNCallingConvention* cc, const BNVariable* var, BNFunction* func);
+ BINARYNINJACOREAPI BNVariable BNGetDefaultIncomingVariableForParameterVariable(
+ BNCallingConvention* cc, const BNVariable* var);
+ BINARYNINJACOREAPI BNVariable BNGetDefaultParameterVariableForIncomingVariable(
+ BNCallingConvention* cc, const BNVariable* var);
BINARYNINJACOREAPI BNCallingConvention* BNGetArchitectureDefaultCallingConvention(BNArchitecture* arch);
BINARYNINJACOREAPI BNCallingConvention* BNGetArchitectureCdeclCallingConvention(BNArchitecture* arch);
@@ -5139,8 +5302,8 @@ __attribute__ ((format (printf, 1, 2)))
// Platforms
BINARYNINJACOREAPI BNPlatform* BNCreatePlatform(BNArchitecture* arch, const char* name);
- BINARYNINJACOREAPI BNPlatform* BNCreatePlatformWithTypes(BNArchitecture* arch, const char* name,
- const char* typeFile, const char** includeDirs, size_t includeDirCount);
+ BINARYNINJACOREAPI BNPlatform* BNCreatePlatformWithTypes(
+ BNArchitecture* arch, const char* name, const char* typeFile, const char** includeDirs, size_t includeDirCount);
BINARYNINJACOREAPI void BNRegisterPlatform(const char* os, BNPlatform* platform);
BINARYNINJACOREAPI BNPlatform* BNNewPlatformReference(BNPlatform* platform);
BINARYNINJACOREAPI void BNFreePlatform(BNPlatform* platform);
@@ -5152,8 +5315,8 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI BNPlatform** BNGetPlatformList(size_t* count);
BINARYNINJACOREAPI BNPlatform** BNGetPlatformListByArchitecture(BNArchitecture* arch, size_t* count);
BINARYNINJACOREAPI BNPlatform** BNGetPlatformListByOS(const char* os, size_t* count);
- BINARYNINJACOREAPI BNPlatform** BNGetPlatformListByOSAndArchitecture(const char* os, BNArchitecture* arch,
- size_t* count);
+ BINARYNINJACOREAPI BNPlatform** BNGetPlatformListByOSAndArchitecture(
+ const char* os, BNArchitecture* arch, size_t* count);
BINARYNINJACOREAPI void BNFreePlatformList(BNPlatform** platform, size_t count);
BINARYNINJACOREAPI char** BNGetPlatformOSList(size_t* count);
BINARYNINJACOREAPI void BNFreePlatformOSList(char** list, size_t count);
@@ -5185,21 +5348,24 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI void BNFreeSystemCallList(BNSystemCallInfo* syscalls, size_t count);
BINARYNINJACOREAPI BNType* BNGetPlatformTypeByName(BNPlatform* platform, BNQualifiedName* name);
BINARYNINJACOREAPI BNType* BNGetPlatformVariableByName(BNPlatform* platform, BNQualifiedName* name);
- BINARYNINJACOREAPI BNType* BNGetPlatformFunctionByName(BNPlatform* platform, BNQualifiedName* name, bool exactMatch);
+ BINARYNINJACOREAPI BNType* BNGetPlatformFunctionByName(
+ BNPlatform* platform, BNQualifiedName* name, bool exactMatch);
BINARYNINJACOREAPI char* BNGetPlatformSystemCallName(BNPlatform* platform, uint32_t number);
BINARYNINJACOREAPI BNType* BNGetPlatformSystemCallType(BNPlatform* platform, uint32_t number);
BINARYNINJACOREAPI BNTypeLibrary** BNGetPlatformTypeLibraries(BNPlatform* platform, size_t* count);
- BINARYNINJACOREAPI BNTypeLibrary** BNGetPlatformTypeLibrariesByName(BNPlatform* platform, char* depName, size_t* count);
+ BINARYNINJACOREAPI BNTypeLibrary** BNGetPlatformTypeLibrariesByName(
+ BNPlatform* platform, char* depName, size_t* count);
- //Demangler
- BINARYNINJACOREAPI bool BNDemangleMS(BNArchitecture* arch, const char* mangledName, BNType** outType, char*** outVarName,
- size_t* outVarNameElements, const bool simplify);
- BINARYNINJACOREAPI bool BNDemangleMSWithOptions(BNArchitecture* arch, const char* mangledName, BNType** outType, char*** outVarName,
- size_t* outVarNameElements, const BNBinaryView* const view);
+ // Demangler
+ BINARYNINJACOREAPI bool BNDemangleMS(BNArchitecture* arch, const char* mangledName, BNType** outType,
+ char*** outVarName, size_t* outVarNameElements, const bool simplify);
+ BINARYNINJACOREAPI bool BNDemangleMSWithOptions(BNArchitecture* arch, const char* mangledName, BNType** outType,
+ char*** outVarName, size_t* outVarNameElements, const BNBinaryView* const view);
// Download providers
- BINARYNINJACOREAPI BNDownloadProvider* BNRegisterDownloadProvider(const char* name, BNDownloadProviderCallbacks* callbacks);
+ BINARYNINJACOREAPI BNDownloadProvider* BNRegisterDownloadProvider(
+ const char* name, BNDownloadProviderCallbacks* callbacks);
BINARYNINJACOREAPI BNDownloadProvider** BNGetDownloadProviderList(size_t* count);
BINARYNINJACOREAPI void BNFreeDownloadProviderList(BNDownloadProvider** providers);
BINARYNINJACOREAPI BNDownloadProvider* BNGetDownloadProviderByName(const char* name);
@@ -5207,20 +5373,27 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI char* BNGetDownloadProviderName(BNDownloadProvider* provider);
BINARYNINJACOREAPI BNDownloadInstance* BNCreateDownloadProviderInstance(BNDownloadProvider* provider);
- BINARYNINJACOREAPI BNDownloadInstance* BNInitDownloadInstance(BNDownloadProvider* provider, BNDownloadInstanceCallbacks* callbacks);
+ BINARYNINJACOREAPI BNDownloadInstance* BNInitDownloadInstance(
+ BNDownloadProvider* provider, BNDownloadInstanceCallbacks* callbacks);
BINARYNINJACOREAPI BNDownloadInstance* BNNewDownloadInstanceReference(BNDownloadInstance* instance);
BINARYNINJACOREAPI void BNFreeDownloadInstance(BNDownloadInstance* instance);
BINARYNINJACOREAPI void BNFreeDownloadInstanceResponse(BNDownloadInstanceResponse* response);
- BINARYNINJACOREAPI int BNPerformDownloadRequest(BNDownloadInstance* instance, const char* url, BNDownloadInstanceOutputCallbacks* callbacks);
- BINARYNINJACOREAPI int BNPerformCustomRequest(BNDownloadInstance* instance, const char* method, const char* url, uint64_t headerCount, const char* const* headerKeys, const char* const* headerValues, BNDownloadInstanceResponse** response, BNDownloadInstanceInputOutputCallbacks* callbacks);
+ BINARYNINJACOREAPI int BNPerformDownloadRequest(
+ BNDownloadInstance* instance, const char* url, BNDownloadInstanceOutputCallbacks* callbacks);
+ BINARYNINJACOREAPI int BNPerformCustomRequest(BNDownloadInstance* instance, const char* method, const char* url,
+ uint64_t headerCount, const char* const* headerKeys, const char* const* headerValues,
+ BNDownloadInstanceResponse** response, BNDownloadInstanceInputOutputCallbacks* callbacks);
BINARYNINJACOREAPI int64_t BNReadDataForDownloadInstance(BNDownloadInstance* instance, uint8_t* data, uint64_t len);
- BINARYNINJACOREAPI uint64_t BNWriteDataForDownloadInstance(BNDownloadInstance* instance, uint8_t* data, uint64_t len);
- BINARYNINJACOREAPI bool BNNotifyProgressForDownloadInstance(BNDownloadInstance* instance, uint64_t progress, uint64_t total);
+ BINARYNINJACOREAPI uint64_t BNWriteDataForDownloadInstance(
+ BNDownloadInstance* instance, uint8_t* data, uint64_t len);
+ BINARYNINJACOREAPI bool BNNotifyProgressForDownloadInstance(
+ BNDownloadInstance* instance, uint64_t progress, uint64_t total);
BINARYNINJACOREAPI char* BNGetErrorForDownloadInstance(BNDownloadInstance* instance);
BINARYNINJACOREAPI void BNSetErrorForDownloadInstance(BNDownloadInstance* instance, const char* error);
// Websocket providers
- BINARYNINJACOREAPI BNWebsocketProvider* BNRegisterWebsocketProvider(const char* name, BNWebsocketProviderCallbacks* callbacks);
+ BINARYNINJACOREAPI BNWebsocketProvider* BNRegisterWebsocketProvider(
+ const char* name, BNWebsocketProviderCallbacks* callbacks);
BINARYNINJACOREAPI BNWebsocketProvider** BNGetWebsocketProviderList(size_t* count);
BINARYNINJACOREAPI void BNFreeWebsocketProviderList(BNWebsocketProvider** providers);
BINARYNINJACOREAPI BNWebsocketProvider* BNGetWebsocketProviderByName(const char* name);
@@ -5228,20 +5401,23 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI char* BNGetWebsocketProviderName(BNWebsocketProvider* provider);
BINARYNINJACOREAPI BNWebsocketClient* BNCreateWebsocketProviderClient(BNWebsocketProvider* provider);
- BINARYNINJACOREAPI BNWebsocketClient* BNInitWebsocketClient(BNWebsocketProvider* provider, BNWebsocketClientCallbacks* callbacks);
+ BINARYNINJACOREAPI BNWebsocketClient* BNInitWebsocketClient(
+ BNWebsocketProvider* provider, BNWebsocketClientCallbacks* callbacks);
BINARYNINJACOREAPI BNWebsocketClient* BNNewWebsocketClientReference(BNWebsocketClient* client);
BINARYNINJACOREAPI void BNFreeWebsocketClient(BNWebsocketClient* client);
- BINARYNINJACOREAPI bool BNConnectWebsocketClient(BNWebsocketClient* client, const char* url, uint64_t headerCount, const char* const* headerKeys, const char* const* headerValues, BNWebsocketClientOutputCallbacks* callbacks);
+ BINARYNINJACOREAPI bool BNConnectWebsocketClient(BNWebsocketClient* client, const char* url, uint64_t headerCount,
+ const char* const* headerKeys, const char* const* headerValues, BNWebsocketClientOutputCallbacks* callbacks);
BINARYNINJACOREAPI bool BNNotifyWebsocketClientConnect(BNWebsocketClient* client);
BINARYNINJACOREAPI void BNNotifyWebsocketClientDisconnect(BNWebsocketClient* client);
BINARYNINJACOREAPI void BNNotifyWebsocketClientError(BNWebsocketClient* client, const char* msg);
BINARYNINJACOREAPI bool BNNotifyWebsocketClientReadData(BNWebsocketClient* client, uint8_t* data, uint64_t len);
- BINARYNINJACOREAPI uint64_t BNWriteWebsocketClientData(BNWebsocketClient* client, const uint8_t* data, uint64_t len);
+ BINARYNINJACOREAPI uint64_t BNWriteWebsocketClientData(
+ BNWebsocketClient* client, const uint8_t* data, uint64_t len);
BINARYNINJACOREAPI bool BNDisconnectWebsocketClient(BNWebsocketClient* client);
// Scripting providers
- BINARYNINJACOREAPI BNScriptingProvider* BNRegisterScriptingProvider(const char* name, const char* apiName,
- BNScriptingProviderCallbacks* callbacks);
+ BINARYNINJACOREAPI BNScriptingProvider* BNRegisterScriptingProvider(
+ const char* name, const char* apiName, BNScriptingProviderCallbacks* callbacks);
BINARYNINJACOREAPI BNScriptingProvider** BNGetScriptingProviderList(size_t* count);
BINARYNINJACOREAPI void BNFreeScriptingProviderList(BNScriptingProvider** providers);
BINARYNINJACOREAPI BNScriptingProvider* BNGetScriptingProviderByName(const char* name);
@@ -5250,38 +5426,40 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI char* BNGetScriptingProviderName(BNScriptingProvider* provider);
BINARYNINJACOREAPI char* BNGetScriptingProviderAPIName(BNScriptingProvider* provider);
BINARYNINJACOREAPI BNScriptingInstance* BNCreateScriptingProviderInstance(BNScriptingProvider* provider);
- BINARYNINJACOREAPI bool BNLoadScriptingProviderModule(BNScriptingProvider* provider, const char* repository, const char* module, bool force);
+ BINARYNINJACOREAPI bool BNLoadScriptingProviderModule(
+ BNScriptingProvider* provider, const char* repository, const char* module, bool force);
BINARYNINJACOREAPI bool BNInstallScriptingProviderModules(BNScriptingProvider* provider, const char* modules);
- BINARYNINJACOREAPI BNScriptingInstance* BNInitScriptingInstance(BNScriptingProvider* provider,
- BNScriptingInstanceCallbacks* callbacks);
+ BINARYNINJACOREAPI BNScriptingInstance* BNInitScriptingInstance(
+ BNScriptingProvider* provider, BNScriptingInstanceCallbacks* callbacks);
BINARYNINJACOREAPI BNScriptingInstance* BNNewScriptingInstanceReference(BNScriptingInstance* instance);
BINARYNINJACOREAPI void BNFreeScriptingInstance(BNScriptingInstance* instance);
BINARYNINJACOREAPI void BNNotifyOutputForScriptingInstance(BNScriptingInstance* instance, const char* text);
BINARYNINJACOREAPI void BNNotifyErrorForScriptingInstance(BNScriptingInstance* instance, const char* text);
- BINARYNINJACOREAPI void BNNotifyInputReadyStateForScriptingInstance(BNScriptingInstance* instance,
- BNScriptingProviderInputReadyState state);
+ BINARYNINJACOREAPI void BNNotifyInputReadyStateForScriptingInstance(
+ BNScriptingInstance* instance, BNScriptingProviderInputReadyState state);
- BINARYNINJACOREAPI void BNRegisterScriptingInstanceOutputListener(BNScriptingInstance* instance,
- BNScriptingOutputListener* callbacks);
- BINARYNINJACOREAPI void BNUnregisterScriptingInstanceOutputListener(BNScriptingInstance* instance,
- BNScriptingOutputListener* callbacks);
+ BINARYNINJACOREAPI void BNRegisterScriptingInstanceOutputListener(
+ BNScriptingInstance* instance, BNScriptingOutputListener* callbacks);
+ BINARYNINJACOREAPI void BNUnregisterScriptingInstanceOutputListener(
+ BNScriptingInstance* instance, BNScriptingOutputListener* callbacks);
BINARYNINJACOREAPI const char* BNGetScriptingInstanceDelimiters(BNScriptingInstance* instance);
BINARYNINJACOREAPI void BNSetScriptingInstanceDelimiters(BNScriptingInstance* instance, const char* delimiters);
BINARYNINJACOREAPI BNScriptingProviderInputReadyState BNGetScriptingInstanceInputReadyState(
- BNScriptingInstance* instance);
- BINARYNINJACOREAPI BNScriptingProviderExecuteResult BNExecuteScriptInput(BNScriptingInstance* instance,
- const char* input);
+ BNScriptingInstance* instance);
+ BINARYNINJACOREAPI BNScriptingProviderExecuteResult BNExecuteScriptInput(
+ BNScriptingInstance* instance, const char* input);
BINARYNINJACOREAPI void BNCancelScriptInput(BNScriptingInstance* instance);
BINARYNINJACOREAPI void BNSetScriptingInstanceCurrentBinaryView(BNScriptingInstance* instance, BNBinaryView* view);
BINARYNINJACOREAPI void BNSetScriptingInstanceCurrentFunction(BNScriptingInstance* instance, BNFunction* func);
BINARYNINJACOREAPI void BNSetScriptingInstanceCurrentBasicBlock(BNScriptingInstance* instance, BNBasicBlock* block);
BINARYNINJACOREAPI void BNSetScriptingInstanceCurrentAddress(BNScriptingInstance* instance, uint64_t addr);
- BINARYNINJACOREAPI void BNSetScriptingInstanceCurrentSelection(BNScriptingInstance* instance,
- uint64_t begin, uint64_t end);
- BINARYNINJACOREAPI char* BNScriptingInstanceCompleteInput(BNScriptingInstance* instance, const char* text, uint64_t state);
+ BINARYNINJACOREAPI void BNSetScriptingInstanceCurrentSelection(
+ BNScriptingInstance* instance, uint64_t begin, uint64_t end);
+ BINARYNINJACOREAPI char* BNScriptingInstanceCompleteInput(
+ BNScriptingInstance* instance, const char* text, uint64_t state);
BINARYNINJACOREAPI void BNStopScriptingInstance(BNScriptingInstance* instance);
// Main thread actions
@@ -5322,26 +5500,26 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI void BNRegisterInteractionHandler(BNInteractionHandlerCallbacks* callbacks);
BINARYNINJACOREAPI char* BNMarkdownToHTML(const char* contents);
BINARYNINJACOREAPI void BNShowPlainTextReport(BNBinaryView* view, const char* title, const char* contents);
- BINARYNINJACOREAPI void BNShowMarkdownReport(BNBinaryView* view, const char* title, const char* contents,
- const char* plaintext);
- BINARYNINJACOREAPI void BNShowHTMLReport(BNBinaryView* view, const char* title, const char* contents,
- const char* plaintext);
+ BINARYNINJACOREAPI void BNShowMarkdownReport(
+ BNBinaryView* view, const char* title, const char* contents, const char* plaintext);
+ BINARYNINJACOREAPI void BNShowHTMLReport(
+ BNBinaryView* view, const char* title, const char* contents, const char* plaintext);
BINARYNINJACOREAPI void BNShowGraphReport(BNBinaryView* view, const char* title, BNFlowGraph* graph);
BINARYNINJACOREAPI void BNShowReportCollection(const char* title, BNReportCollection* reports);
BINARYNINJACOREAPI bool BNGetTextLineInput(char** result, const char* prompt, const char* title);
BINARYNINJACOREAPI bool BNGetIntegerInput(int64_t* result, const char* prompt, const char* title);
- BINARYNINJACOREAPI bool BNGetAddressInput(uint64_t* result, const char* prompt, const char* title,
- BNBinaryView* view, uint64_t currentAddr);
- BINARYNINJACOREAPI bool BNGetChoiceInput(size_t* result, const char* prompt, const char* title,
- const char** choices, size_t count);
+ BINARYNINJACOREAPI bool BNGetAddressInput(
+ uint64_t* result, const char* prompt, const char* title, BNBinaryView* view, uint64_t currentAddr);
+ BINARYNINJACOREAPI bool BNGetChoiceInput(
+ size_t* result, const char* prompt, const char* title, const char** choices, size_t count);
BINARYNINJACOREAPI bool BNGetOpenFileNameInput(char** result, const char* prompt, const char* ext);
- BINARYNINJACOREAPI bool BNGetSaveFileNameInput(char** result, const char* prompt, const char* ext,
- const char* defaultName);
+ BINARYNINJACOREAPI bool BNGetSaveFileNameInput(
+ char** result, const char* prompt, const char* ext, const char* defaultName);
BINARYNINJACOREAPI bool BNGetDirectoryNameInput(char** result, const char* prompt, const char* defaultName);
BINARYNINJACOREAPI bool BNGetFormInput(BNFormInputField* fields, size_t count, const char* title);
BINARYNINJACOREAPI void BNFreeFormInputResults(BNFormInputField* fields, size_t count);
- BINARYNINJACOREAPI BNMessageBoxButtonResult BNShowMessageBox(const char* title, const char* text,
- BNMessageBoxButtonSet buttons, BNMessageBoxIcon icon);
+ BINARYNINJACOREAPI BNMessageBoxButtonResult BNShowMessageBox(
+ const char* title, const char* text, BNMessageBoxButtonSet buttons, BNMessageBoxIcon icon);
BINARYNINJACOREAPI bool BNOpenUrl(const char* url);
BINARYNINJACOREAPI BNReportCollection* BNCreateReportCollection(void);
@@ -5354,21 +5532,21 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI char* BNGetReportContents(BNReportCollection* reports, size_t i);
BINARYNINJACOREAPI char* BNGetReportPlainText(BNReportCollection* reports, size_t i);
BINARYNINJACOREAPI BNFlowGraph* BNGetReportFlowGraph(BNReportCollection* reports, size_t i);
- BINARYNINJACOREAPI void BNAddPlainTextReportToCollection(BNReportCollection* reports, BNBinaryView* view,
- const char* title, const char* contents);
+ BINARYNINJACOREAPI void BNAddPlainTextReportToCollection(
+ BNReportCollection* reports, BNBinaryView* view, const char* title, const char* contents);
BINARYNINJACOREAPI void BNAddMarkdownReportToCollection(BNReportCollection* reports, BNBinaryView* view,
- const char* title, const char* contents, const char* plaintext);
+ const char* title, const char* contents, const char* plaintext);
BINARYNINJACOREAPI void BNAddHTMLReportToCollection(BNReportCollection* reports, BNBinaryView* view,
- const char* title, const char* contents, const char* plaintext);
- BINARYNINJACOREAPI void BNAddGraphReportToCollection(BNReportCollection* reports, BNBinaryView* view,
- const char* title, BNFlowGraph* graph);
+ const char* title, const char* contents, const char* plaintext);
+ BINARYNINJACOREAPI void BNAddGraphReportToCollection(
+ BNReportCollection* reports, BNBinaryView* view, const char* title, BNFlowGraph* graph);
BINARYNINJACOREAPI void BNUpdateReportFlowGraph(BNReportCollection* reports, size_t i, BNFlowGraph* graph);
BINARYNINJACOREAPI bool BNIsGNU3MangledString(const char* mangledName);
BINARYNINJACOREAPI bool BNDemangleGNU3(BNArchitecture* arch, const char* mangledName, BNType** outType,
- char*** outVarName, size_t* outVarNameElements, const bool simplify);
+ char*** outVarName, size_t* outVarNameElements, const bool simplify);
BINARYNINJACOREAPI bool BNDemangleGNU3WithOptions(BNArchitecture* arch, const char* mangledName, BNType** outType,
- char*** outVarName, size_t* outVarNameElements, const BNBinaryView* const view);
+ char*** outVarName, size_t* outVarNameElements, const BNBinaryView* const view);
BINARYNINJACOREAPI void BNFreeDemangledName(char*** name, size_t nameElements);
// Plugin repository APIs
@@ -5433,9 +5611,8 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI bool BNRepositoryManagerCheckForUpdates(BNRepositoryManager* r);
BINARYNINJACOREAPI BNRepository** BNRepositoryManagerGetRepositories(BNRepositoryManager* r, size_t* count);
BINARYNINJACOREAPI void BNFreeRepositoryManagerRepositoriesList(BNRepository** r);
- BINARYNINJACOREAPI bool BNRepositoryManagerAddRepository(BNRepositoryManager* r,
- const char* url,
- const char* repoPath);
+ BINARYNINJACOREAPI bool BNRepositoryManagerAddRepository(
+ BNRepositoryManager* r, const char* url, const char* repoPath);
BINARYNINJACOREAPI BNRepository* BNRepositoryGetRepositoryByPath(BNRepositoryManager* r, const char* repoPath);
BINARYNINJACOREAPI BNRepositoryManager* BNGetRepositoryManager();
@@ -5444,10 +5621,10 @@ __attribute__ ((format (printf, 1, 2)))
// LLVM Services APIs
BINARYNINJACOREAPI void BNLlvmServicesInit(void);
- BINARYNINJACOREAPI int BNLlvmServicesAssemble(const char *src, int dialect, const char *triplet,
- int codeModel, int relocMode, char **outBytes, int *outBytesLen, char **err, int *errLen);
+ BINARYNINJACOREAPI int BNLlvmServicesAssemble(const char* src, int dialect, const char* triplet, int codeModel,
+ int relocMode, char** outBytes, int* outBytesLen, char** err, int* errLen);
- BINARYNINJACOREAPI void BNLlvmServicesAssembleFree(char *outBytes, char *err);
+ BINARYNINJACOREAPI void BNLlvmServicesAssembleFree(char* outBytes, char* err);
// Filesystem functionality
BINARYNINJACOREAPI int BNDeleteFile(const char* path);
@@ -5476,40 +5653,65 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI bool BNSettingsContains(BNSettings* settings, const char* key);
BINARYNINJACOREAPI bool BNSettingsIsEmpty(BNSettings* settings);
BINARYNINJACOREAPI const char** BNSettingsKeysList(BNSettings* settings, size_t* inoutSize);
- BINARYNINJACOREAPI const char** BNSettingsQueryPropertyStringList(BNSettings* settings, const char* key, const char* property, size_t* inoutSize);
+ BINARYNINJACOREAPI const char** BNSettingsQueryPropertyStringList(
+ BNSettings* settings, const char* key, const char* property, size_t* inoutSize);
BINARYNINJACOREAPI bool BNSettingsUpdateProperty(BNSettings* settings, const char* key, const char* property);
- BINARYNINJACOREAPI bool BNSettingsUpdateBoolProperty(BNSettings* settings, const char* key, const char* property, bool value);
- BINARYNINJACOREAPI bool BNSettingsUpdateDoubleProperty(BNSettings* settings, const char* key, const char* property, double value);
- BINARYNINJACOREAPI bool BNSettingsUpdateInt64Property(BNSettings* settings, const char* key, const char* property, int64_t value);
- BINARYNINJACOREAPI bool BNSettingsUpdateUInt64Property(BNSettings* settings, const char* key, const char* property, uint64_t value);
- BINARYNINJACOREAPI bool BNSettingsUpdateStringProperty(BNSettings* settings, const char* key, const char* property, const char* value);
- BINARYNINJACOREAPI bool BNSettingsUpdateStringListProperty(BNSettings* settings, const char* key, const char* property, const char** value, size_t size);
+ BINARYNINJACOREAPI bool BNSettingsUpdateBoolProperty(
+ BNSettings* settings, const char* key, const char* property, bool value);
+ BINARYNINJACOREAPI bool BNSettingsUpdateDoubleProperty(
+ BNSettings* settings, const char* key, const char* property, double value);
+ BINARYNINJACOREAPI bool BNSettingsUpdateInt64Property(
+ BNSettings* settings, const char* key, const char* property, int64_t value);
+ BINARYNINJACOREAPI bool BNSettingsUpdateUInt64Property(
+ BNSettings* settings, const char* key, const char* property, uint64_t value);
+ BINARYNINJACOREAPI bool BNSettingsUpdateStringProperty(
+ BNSettings* settings, const char* key, const char* property, const char* value);
+ BINARYNINJACOREAPI bool BNSettingsUpdateStringListProperty(
+ BNSettings* settings, const char* key, const char* property, const char** value, size_t size);
- BINARYNINJACOREAPI bool BNSettingsDeserializeSchema(BNSettings* settings, const char* schema, BNSettingsScope scope, bool merge);
+ BINARYNINJACOREAPI bool BNSettingsDeserializeSchema(
+ BNSettings* settings, const char* schema, BNSettingsScope scope, bool merge);
BINARYNINJACOREAPI char* BNSettingsSerializeSchema(BNSettings* settings);
- BINARYNINJACOREAPI bool BNDeserializeSettings(BNSettings* settings, const char* contents, BNBinaryView* view, BNSettingsScope scope);
+ BINARYNINJACOREAPI bool BNDeserializeSettings(
+ BNSettings* settings, const char* contents, BNBinaryView* view, BNSettingsScope scope);
BINARYNINJACOREAPI char* BNSerializeSettings(BNSettings* settings, BNBinaryView* view, BNSettingsScope scope);
- BINARYNINJACOREAPI bool BNSettingsReset(BNSettings* settings, const char* key, BNBinaryView* view, BNSettingsScope scope);
- BINARYNINJACOREAPI bool BNSettingsResetAll(BNSettings* settings, BNBinaryView* view, BNSettingsScope scope, bool schemaOnly);
+ BINARYNINJACOREAPI bool BNSettingsReset(
+ BNSettings* settings, const char* key, BNBinaryView* view, BNSettingsScope scope);
+ BINARYNINJACOREAPI bool BNSettingsResetAll(
+ BNSettings* settings, BNBinaryView* view, BNSettingsScope scope, bool schemaOnly);
- BINARYNINJACOREAPI bool BNSettingsGetBool(BNSettings* settings, const char* key, BNBinaryView* view, BNSettingsScope* scope);
- BINARYNINJACOREAPI double BNSettingsGetDouble(BNSettings* settings, const char* key, BNBinaryView* view, BNSettingsScope* scope);
- BINARYNINJACOREAPI int64_t BNSettingsGetInt64(BNSettings* settings, const char* key, BNBinaryView* view, BNSettingsScope* scope);
- BINARYNINJACOREAPI uint64_t BNSettingsGetUInt64(BNSettings* settings, const char* key, BNBinaryView* view, BNSettingsScope* scope);
- BINARYNINJACOREAPI char* BNSettingsGetString(BNSettings* settings, const char* key, BNBinaryView* view, BNSettingsScope* scope);
- BINARYNINJACOREAPI const char** BNSettingsGetStringList(BNSettings* settings, const char* key, BNBinaryView* view, BNSettingsScope* scope, size_t* inoutSize);
- BINARYNINJACOREAPI char* BNSettingsGetJson(BNSettings* settings, const char* key, BNBinaryView* view, BNSettingsScope* scope);
+ BINARYNINJACOREAPI bool BNSettingsGetBool(
+ BNSettings* settings, const char* key, BNBinaryView* view, BNSettingsScope* scope);
+ BINARYNINJACOREAPI double BNSettingsGetDouble(
+ BNSettings* settings, const char* key, BNBinaryView* view, BNSettingsScope* scope);
+ BINARYNINJACOREAPI int64_t BNSettingsGetInt64(
+ BNSettings* settings, const char* key, BNBinaryView* view, BNSettingsScope* scope);
+ BINARYNINJACOREAPI uint64_t BNSettingsGetUInt64(
+ BNSettings* settings, const char* key, BNBinaryView* view, BNSettingsScope* scope);
+ BINARYNINJACOREAPI char* BNSettingsGetString(
+ BNSettings* settings, const char* key, BNBinaryView* view, BNSettingsScope* scope);
+ BINARYNINJACOREAPI const char** BNSettingsGetStringList(
+ BNSettings* settings, const char* key, BNBinaryView* view, BNSettingsScope* scope, size_t* inoutSize);
+ BINARYNINJACOREAPI char* BNSettingsGetJson(
+ BNSettings* settings, const char* key, BNBinaryView* view, BNSettingsScope* scope);
- BINARYNINJACOREAPI bool BNSettingsSetBool(BNSettings* settings, BNBinaryView* view, BNSettingsScope scope, const char* key, bool value);
- BINARYNINJACOREAPI bool BNSettingsSetDouble(BNSettings* settings, BNBinaryView* view, BNSettingsScope scope, const char* key, double value);
- BINARYNINJACOREAPI bool BNSettingsSetInt64(BNSettings* settings, BNBinaryView* view, BNSettingsScope scope, const char* key, int64_t value);
- BINARYNINJACOREAPI bool BNSettingsSetUInt64(BNSettings* settings, BNBinaryView* view, BNSettingsScope scope, const char* key, uint64_t value);
- BINARYNINJACOREAPI bool BNSettingsSetString(BNSettings* settings, BNBinaryView* view, BNSettingsScope scope, const char* key, const char* value);
- BINARYNINJACOREAPI bool BNSettingsSetStringList(BNSettings* settings, BNBinaryView* view, BNSettingsScope scope, const char* key, const char** value, size_t size);
- BINARYNINJACOREAPI bool BNSettingsSetJson(BNSettings* settings, BNBinaryView* view, BNSettingsScope scope, const char* key, const char* value);
+ BINARYNINJACOREAPI bool BNSettingsSetBool(
+ BNSettings* settings, BNBinaryView* view, BNSettingsScope scope, const char* key, bool value);
+ BINARYNINJACOREAPI bool BNSettingsSetDouble(
+ BNSettings* settings, BNBinaryView* view, BNSettingsScope scope, const char* key, double value);
+ BINARYNINJACOREAPI bool BNSettingsSetInt64(
+ BNSettings* settings, BNBinaryView* view, BNSettingsScope scope, const char* key, int64_t value);
+ BINARYNINJACOREAPI bool BNSettingsSetUInt64(
+ BNSettings* settings, BNBinaryView* view, BNSettingsScope scope, const char* key, uint64_t value);
+ BINARYNINJACOREAPI bool BNSettingsSetString(
+ BNSettings* settings, BNBinaryView* view, BNSettingsScope scope, const char* key, const char* value);
+ BINARYNINJACOREAPI bool BNSettingsSetStringList(BNSettings* settings, BNBinaryView* view, BNSettingsScope scope,
+ const char* key, const char** value, size_t size);
+ BINARYNINJACOREAPI bool BNSettingsSetJson(
+ BNSettings* settings, BNBinaryView* view, BNSettingsScope scope, const char* key, const char* value);
- //Metadata APIs
+ // Metadata APIs
// Create Metadata of various types
BINARYNINJACOREAPI BNMetadata* BNNewMetadataReference(BNMetadata* data);
@@ -5547,7 +5749,7 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI BNMetadata** BNMetadataGetArray(BNMetadata* data, size_t* size);
BINARYNINJACOREAPI BNMetadataValueStore* BNMetadataGetValueStore(BNMetadata* data);
- //Query type of Metadata
+ // Query type of Metadata
BINARYNINJACOREAPI BNMetadataType BNMetadataGetType(BNMetadata* data);
BINARYNINJACOREAPI bool BNMetadataIsBoolean(BNMetadata* data);
BINARYNINJACOREAPI bool BNMetadataIsString(BNMetadata* data);
@@ -5559,8 +5761,8 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI bool BNMetadataIsKeyValueStore(BNMetadata* data);
// Store/Query structured data to/from a BinaryView
- BINARYNINJACOREAPI void BNBinaryViewStoreMetadata(BNBinaryView* view, const char* key,
- BNMetadata* value, bool isAuto);
+ BINARYNINJACOREAPI void BNBinaryViewStoreMetadata(
+ BNBinaryView* view, const char* key, BNMetadata* value, bool isAuto);
BINARYNINJACOREAPI BNMetadata* BNBinaryViewQueryMetadata(BNBinaryView* view, const char* key);
BINARYNINJACOREAPI void BNBinaryViewRemoveMetadata(BNBinaryView* view, const char* key);
@@ -5577,8 +5779,8 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI uint64_t BNRelocationGetReloc(BNRelocation* reloc);
BINARYNINJACOREAPI BNSymbol* BNRelocationGetSymbol(BNRelocation* reloc);
// Segment object methods
- BINARYNINJACOREAPI BNSegment* BNCreateSegment(uint64_t start, uint64_t length, uint64_t dataOffset, uint64_t dataLength, uint32_t flags,
- bool autoDefined);
+ BINARYNINJACOREAPI BNSegment* BNCreateSegment(
+ uint64_t start, uint64_t length, uint64_t dataOffset, uint64_t dataLength, uint32_t flags, bool autoDefined);
BINARYNINJACOREAPI BNSegment* BNNewSegmentReference(BNSegment* seg);
BINARYNINJACOREAPI void BNFreeSegment(BNSegment* seg);
@@ -5619,20 +5821,22 @@ __attribute__ ((format (printf, 1, 2)))
// Custom Data Render methods
BINARYNINJACOREAPI BNDataRenderer* BNCreateDataRenderer(BNCustomDataRenderer* renderer);
BINARYNINJACOREAPI BNDataRenderer* BNNewDataRendererReference(BNDataRenderer* renderer);
- BINARYNINJACOREAPI bool BNIsValidForData(void* ctxt, BNBinaryView* view, uint64_t addr, BNType* type,
- BNTypeContext* typeCtx, size_t ctxCount);
+ BINARYNINJACOREAPI bool BNIsValidForData(
+ void* ctxt, BNBinaryView* view, uint64_t addr, BNType* type, BNTypeContext* typeCtx, size_t ctxCount);
BINARYNINJACOREAPI BNDisassemblyTextLine* BNGetLinesForData(void* ctxt, BNBinaryView* view, uint64_t addr,
- BNType* type, const BNInstructionTextToken* prefix, size_t prefixCount, size_t width, size_t* count,
- BNTypeContext* typeCtx, size_t ctxCount);
+ BNType* type, const BNInstructionTextToken* prefix, size_t prefixCount, size_t width, size_t* count,
+ BNTypeContext* typeCtx, size_t ctxCount);
BINARYNINJACOREAPI BNDisassemblyTextLine* BNRenderLinesForData(BNBinaryView* data, uint64_t addr, BNType* type,
- const BNInstructionTextToken* prefix, size_t prefixCount, size_t width, size_t* count, BNTypeContext* typeCtx,
- size_t ctxCount);
+ const BNInstructionTextToken* prefix, size_t prefixCount, size_t width, size_t* count, BNTypeContext* typeCtx,
+ size_t ctxCount);
BINARYNINJACOREAPI void BNFreeDataRenderer(BNDataRenderer* renderer);
BINARYNINJACOREAPI BNDataRendererContainer* BNGetDataRendererContainer();
BINARYNINJACOREAPI void BNRegisterGenericDataRenderer(BNDataRendererContainer* container, BNDataRenderer* renderer);
- BINARYNINJACOREAPI void BNRegisterTypeSpecificDataRenderer(BNDataRendererContainer* container, BNDataRenderer* renderer);
+ BINARYNINJACOREAPI void BNRegisterTypeSpecificDataRenderer(
+ BNDataRendererContainer* container, BNDataRenderer* renderer);
- BINARYNINJACOREAPI bool BNParseExpression(BNBinaryView* view, const char* expression, uint64_t* offset, uint64_t here, char** errorString);
+ BINARYNINJACOREAPI bool BNParseExpression(
+ BNBinaryView* view, const char* expression, uint64_t* offset, uint64_t here, char** errorString);
BINARYNINJACOREAPI void BNFreeParseError(char* errorString);
BINARYNINJACOREAPI void* BNRegisterObjectRefDebugTrace(const char* typeName);
@@ -5647,31 +5851,39 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI char** BNRustSimplifyStrToFQN(const char* const, bool);
BINARYNINJACOREAPI char* BNRustSimplifyStrToStr(const char* const);
- BINARYNINJACOREAPI BNDebugInfoParser* BNRegisterDebugInfoParser(const char* name, bool (*isValid)(void*, BNBinaryView*), void (*parseInfo)(void*, BNDebugInfo*, BNBinaryView*), void* context);
+ BINARYNINJACOREAPI BNDebugInfoParser* BNRegisterDebugInfoParser(const char* name,
+ bool (*isValid)(void*, BNBinaryView*), void (*parseInfo)(void*, BNDebugInfo*, BNBinaryView*), void* context);
BINARYNINJACOREAPI void BNUnregisterDebugInfoParser(const char* rawName);
BINARYNINJACOREAPI BNDebugInfoParser* BNGetDebugInfoParserByName(const char* name);
BINARYNINJACOREAPI BNDebugInfoParser** BNGetDebugInfoParsers(size_t* count);
BINARYNINJACOREAPI BNDebugInfoParser** BNGetDebugInfoParsersForView(BNBinaryView* view, size_t* count);
BINARYNINJACOREAPI char* BNGetDebugInfoParserName(BNDebugInfoParser* parser);
BINARYNINJACOREAPI bool BNIsDebugInfoParserValidForView(BNDebugInfoParser* parser, BNBinaryView* view);
- BINARYNINJACOREAPI BNDebugInfo* BNParseDebugInfo(BNDebugInfoParser* parser, BNBinaryView* view, BNDebugInfo* existingDebugInfo);
+ BINARYNINJACOREAPI BNDebugInfo* BNParseDebugInfo(
+ BNDebugInfoParser* parser, BNBinaryView* view, BNDebugInfo* existingDebugInfo);
BINARYNINJACOREAPI BNDebugInfoParser* BNNewDebugInfoParserReference(BNDebugInfoParser* parser);
BINARYNINJACOREAPI void BNFreeDebugInfoParserReference(BNDebugInfoParser* parser);
BINARYNINJACOREAPI void BNFreeDebugInfoParserList(BNDebugInfoParser** parsers, size_t count);
BINARYNINJACOREAPI BNDebugInfo* BNNewDebugInfoReference(BNDebugInfo* debugInfo);
BINARYNINJACOREAPI void BNFreeDebugInfoReference(BNDebugInfo* debugInfo);
- BINARYNINJACOREAPI bool BNAddDebugType(BNDebugInfo* const debugInfo, const char* const name, const BNType* const type);
- BINARYNINJACOREAPI BNNameAndType* BNGetDebugTypes(BNDebugInfo* const debugInfo, const char* const name, size_t* count);
+ BINARYNINJACOREAPI bool BNAddDebugType(
+ BNDebugInfo* const debugInfo, const char* const name, const BNType* const type);
+ BINARYNINJACOREAPI BNNameAndType* BNGetDebugTypes(
+ BNDebugInfo* const debugInfo, const char* const name, size_t* count);
BINARYNINJACOREAPI void BNFreeDebugTypes(BNNameAndType* types, size_t count);
BINARYNINJACOREAPI bool BNAddDebugFunction(BNDebugInfo* const debugInfo, BNDebugFunctionInfo* func);
- BINARYNINJACOREAPI BNDebugFunctionInfo* BNGetDebugFunctions(BNDebugInfo* const debugInfo, const char* const name, size_t* count);
+ BINARYNINJACOREAPI BNDebugFunctionInfo* BNGetDebugFunctions(
+ BNDebugInfo* const debugInfo, const char* const name, size_t* count);
BINARYNINJACOREAPI void BNFreeDebugFunctions(BNDebugFunctionInfo* functions, size_t count);
- BINARYNINJACOREAPI bool BNAddDebugDataVariable(BNDebugInfo* const debugInfo, uint64_t address, const BNType* const type, const char* name);
- BINARYNINJACOREAPI BNDataVariableAndName* BNGetDebugDataVariables(BNDebugInfo* const debugInfo, const char* const name, size_t* count);
+ BINARYNINJACOREAPI bool BNAddDebugDataVariable(
+ BNDebugInfo* const debugInfo, uint64_t address, const BNType* const type, const char* name);
+ BINARYNINJACOREAPI BNDataVariableAndName* BNGetDebugDataVariables(
+ BNDebugInfo* const debugInfo, const char* const name, size_t* count);
// Secrets providers
- BINARYNINJACOREAPI BNSecretsProvider* BNRegisterSecretsProvider(const char* name, BNSecretsProviderCallbacks* callbacks);
+ BINARYNINJACOREAPI BNSecretsProvider* BNRegisterSecretsProvider(
+ const char* name, BNSecretsProviderCallbacks* callbacks);
BINARYNINJACOREAPI BNSecretsProvider** BNGetSecretsProviderList(size_t* count);
BINARYNINJACOREAPI void BNFreeSecretsProviderList(BNSecretsProvider** providers);
BINARYNINJACOREAPI BNSecretsProvider* BNGetSecretsProviderByName(const char* name);
diff --git a/binaryreader.cpp b/binaryreader.cpp
index 0c580aa2..f4574820 100644
--- a/binaryreader.cpp
+++ b/binaryreader.cpp
@@ -24,7 +24,7 @@ using namespace BinaryNinja;
using namespace std;
-BinaryReader::BinaryReader(BinaryView* data, BNEndianness endian): m_view(data)
+BinaryReader::BinaryReader(BinaryView* data, BNEndianness endian) : m_view(data)
{
m_stream = BNCreateBinaryReader(data->GetObject());
BNSetBinaryReaderEndianness(m_stream, endian);
@@ -276,7 +276,7 @@ T BinaryReader::Read()
return value;
}
-template<typename T>
+template <typename T>
vector<T> BinaryReader::ReadVector(size_t count)
{
T* buff = new T[count];
@@ -300,6 +300,8 @@ string BinaryReader::ReadCString(size_t maxSize)
}
}
catch (ReadException&)
- {;}
+ {
+ ;
+ }
return result;
}
diff --git a/binaryview.cpp b/binaryview.cpp
index 5ab24694..62bb6f2b 100644
--- a/binaryview.cpp
+++ b/binaryview.cpp
@@ -91,7 +91,8 @@ void BinaryDataNotification::DataVariableAddedCallback(void* ctxt, BNBinaryView*
{
BinaryDataNotification* notify = (BinaryDataNotification*)ctxt;
Ref<BinaryView> view = new BinaryView(BNNewViewReference(object));
- DataVariable varObj(var->address, Confidence<Ref<Type>>(new Type(BNNewTypeReference(var->type)), var->typeConfidence), var->autoDiscovered);
+ DataVariable varObj(var->address,
+ Confidence<Ref<Type>>(new Type(BNNewTypeReference(var->type)), var->typeConfidence), var->autoDiscovered);
notify->OnDataVariableAdded(view, varObj);
}
@@ -100,7 +101,8 @@ void BinaryDataNotification::DataVariableRemovedCallback(void* ctxt, BNBinaryVie
{
BinaryDataNotification* notify = (BinaryDataNotification*)ctxt;
Ref<BinaryView> view = new BinaryView(BNNewViewReference(object));
- DataVariable varObj(var->address, Confidence<Ref<Type>>(new Type(BNNewTypeReference(var->type)), var->typeConfidence), var->autoDiscovered);
+ DataVariable varObj(var->address,
+ Confidence<Ref<Type>>(new Type(BNNewTypeReference(var->type)), var->typeConfidence), var->autoDiscovered);
notify->OnDataVariableRemoved(view, varObj);
}
@@ -109,7 +111,8 @@ void BinaryDataNotification::DataVariableUpdatedCallback(void* ctxt, BNBinaryVie
{
BinaryDataNotification* notify = (BinaryDataNotification*)ctxt;
Ref<BinaryView> view = new BinaryView(BNNewViewReference(object));
- DataVariable varObj(var->address, Confidence<Ref<Type>>(new Type(BNNewTypeReference(var->type)), var->typeConfidence), var->autoDiscovered);
+ DataVariable varObj(var->address,
+ Confidence<Ref<Type>>(new Type(BNNewTypeReference(var->type)), var->typeConfidence), var->autoDiscovered);
notify->OnDataVariableUpdated(view, varObj);
}
@@ -182,7 +185,8 @@ void BinaryDataNotification::SymbolRemovedCallback(void* ctxt, BNBinaryView* obj
}
-void BinaryDataNotification::StringFoundCallback(void* ctxt, BNBinaryView* object, BNStringType type, uint64_t offset, size_t len)
+void BinaryDataNotification::StringFoundCallback(
+ void* ctxt, BNBinaryView* object, BNStringType type, uint64_t offset, size_t len)
{
BinaryDataNotification* notify = (BinaryDataNotification*)ctxt;
Ref<BinaryView> view = new BinaryView(BNNewViewReference(object));
@@ -190,7 +194,8 @@ void BinaryDataNotification::StringFoundCallback(void* ctxt, BNBinaryView* objec
}
-void BinaryDataNotification::StringRemovedCallback(void* ctxt, BNBinaryView* object, BNStringType type, uint64_t offset, size_t len)
+void BinaryDataNotification::StringRemovedCallback(
+ void* ctxt, BNBinaryView* object, BNStringType type, uint64_t offset, size_t len)
{
BinaryDataNotification* notify = (BinaryDataNotification*)ctxt;
Ref<BinaryView> view = new BinaryView(BNNewViewReference(object));
@@ -216,7 +221,8 @@ void BinaryDataNotification::TypeUndefinedCallback(void* ctxt, BNBinaryView* dat
}
-void BinaryDataNotification::TypeReferenceChangedCallback(void* ctxt, BNBinaryView* data, BNQualifiedName* name, BNType* type)
+void BinaryDataNotification::TypeReferenceChangedCallback(
+ void* ctxt, BNBinaryView* data, BNQualifiedName* name, BNType* type)
{
BinaryDataNotification* notify = (BinaryDataNotification*)ctxt;
Ref<BinaryView> view = new BinaryView(BNNewViewReference(data));
@@ -225,7 +231,8 @@ void BinaryDataNotification::TypeReferenceChangedCallback(void* ctxt, BNBinaryVi
}
-void BinaryDataNotification::TypeFieldReferenceChangedCallback(void* ctxt, BNBinaryView* data, BNQualifiedName* name, uint64_t offset)
+void BinaryDataNotification::TypeFieldReferenceChangedCallback(
+ void* ctxt, BNBinaryView* data, BNQualifiedName* name, uint64_t offset)
{
BinaryDataNotification* notify = (BinaryDataNotification*)ctxt;
Ref<BinaryView> view = new BinaryView(BNNewViewReference(data));
@@ -233,7 +240,6 @@ void BinaryDataNotification::TypeFieldReferenceChangedCallback(void* ctxt, BNBin
}
-
BinaryDataNotification::BinaryDataNotification()
{
m_callbacks.context = this;
@@ -265,7 +271,7 @@ BinaryDataNotification::BinaryDataNotification()
Symbol::Symbol(BNSymbolType type, const string& shortName, const string& fullName, const string& rawName, uint64_t addr,
- BNSymbolBinding binding, const NameSpace& nameSpace, uint64_t ordinal)
+ BNSymbolBinding binding, const NameSpace& nameSpace, uint64_t ordinal)
{
BNNameSpace ns = nameSpace.GetAPIObject();
m_object = BNCreateSymbol(type, shortName.c_str(), fullName.c_str(), rawName.c_str(), addr, binding, &ns, ordinal);
@@ -274,12 +280,11 @@ Symbol::Symbol(BNSymbolType type, const string& shortName, const string& fullNam
Symbol::Symbol(BNSymbolType type, const std::string& name, uint64_t addr, BNSymbolBinding binding,
- const NameSpace& nameSpace, uint64_t ordinal)
+ const NameSpace& nameSpace, uint64_t ordinal)
{
BNNameSpace ns = nameSpace.GetAPIObject();
m_object = BNCreateSymbol(type, name.c_str(), name.c_str(), name.c_str(), addr, binding, &ns, ordinal);
NameSpace::FreeAPIObject(&ns);
-
}
@@ -361,8 +366,8 @@ Ref<Symbol> Symbol::ImportedFunctionFromImportAddressSymbol(Symbol* sym, uint64_
}
-AnalysisCompletionEvent::AnalysisCompletionEvent(BinaryView* view, const std::function<void()>& callback):
- m_callback(callback)
+AnalysisCompletionEvent::AnalysisCompletionEvent(BinaryView* view, const std::function<void()>& callback) :
+ m_callback(callback)
{
m_object = BNAddAnalysisCompletionEvent(view->GetObject(), this, CompletionCallback);
}
@@ -374,14 +379,16 @@ void AnalysisCompletionEvent::CompletionCallback(void* ctxt)
unique_lock<recursive_mutex> lock(event->m_mutex);
event->m_callback();
- event->m_callback = []() {};
+ event->m_callback = []() {
+ };
}
void AnalysisCompletionEvent::Cancel()
{
unique_lock<recursive_mutex> lock(m_mutex);
- m_callback = []() {};
+ m_callback = []() {
+ };
// This allows the API side to free the BinaryNinja::AnalysisCompletionEvent object
BNCancelAnalysisCompletionEvent(m_object);
}
@@ -542,9 +549,7 @@ std::vector<Ref<Tag>> Tag::ConvertAndFreeTagList(BNTag** tags, size_t count)
}
-TagReference::TagReference()
-{
-}
+TagReference::TagReference() {}
TagReference::TagReference(const BNTagReference& ref)
@@ -568,14 +573,14 @@ bool TagReference::operator==(const TagReference& other) const
return false;
switch (refType)
{
- case AddressTagReference:
- return func == other.func && arch == other.arch && addr == other.addr;
- case FunctionTagReference:
- return func == other.func;
- case DataTagReference:
- return addr == other.addr;
- default:
- return false;
+ case AddressTagReference:
+ return func == other.func && arch == other.arch && addr == other.addr;
+ case FunctionTagReference:
+ return func == other.func;
+ case DataTagReference:
+ return addr == other.addr;
+ default:
+ return false;
}
}
@@ -605,7 +610,7 @@ BNTagReference* TagReference::CreateTagReferenceList(const std::vector<TagRefere
BNTagReference* refs = new BNTagReference[*count];
- for (size_t i = 0; i < *count; i ++)
+ for (size_t i = 0; i < *count; i++)
{
refs[i] = tags[i];
}
@@ -618,7 +623,7 @@ std::vector<TagReference> TagReference::ConvertTagReferenceList(BNTagReference*
{
std::vector<TagReference> result;
result.reserve(count);
- for (size_t i = 0; i < count; i ++)
+ for (size_t i = 0; i < count; i++)
{
result.emplace_back(tags[i]);
}
@@ -853,8 +858,8 @@ BinaryView::BinaryView(const std::string& typeName, FileMetadata* file, BinaryVi
view.save = SaveCallback;
m_file = file;
AddRefForRegistration();
- m_object = BNCreateCustomBinaryView(typeName.c_str(), m_file->GetObject(),
- parentView ? parentView->GetObject() : nullptr, &view);
+ m_object = BNCreateCustomBinaryView(
+ typeName.c_str(), m_file->GetObject(), parentView ? parentView->GetObject() : nullptr, &view);
}
@@ -1156,7 +1161,7 @@ bool BinaryView::CreateDatabase(const string& path, Ref<SaveSettings> settings)
bool BinaryView::CreateDatabase(const string& path,
- const function<bool(size_t progress, size_t total)>& progressCallback, Ref<SaveSettings> settings)
+ const function<bool(size_t progress, size_t total)>& progressCallback, Ref<SaveSettings> settings)
{
auto parent = GetParentView();
if (parent)
@@ -1171,7 +1176,8 @@ bool BinaryView::SaveAutoSnapshot(Ref<SaveSettings> settings)
}
-bool BinaryView::SaveAutoSnapshot(const function<bool(size_t progress, size_t total)>& progressCallback, Ref<SaveSettings> settings)
+bool BinaryView::SaveAutoSnapshot(
+ const function<bool(size_t progress, size_t total)>& progressCallback, Ref<SaveSettings> settings)
{
return m_file->SaveAutoSnapshot(this, progressCallback, settings);
}
@@ -1614,7 +1620,9 @@ map<uint64_t, DataVariable> BinaryView::GetDataVariables()
for (size_t i = 0; i < count; i++)
{
result.emplace(piecewise_construct, forward_as_tuple(vars[i].address),
- forward_as_tuple(vars[i].address, Confidence<Ref<Type>>(new Type(BNNewTypeReference(vars[i].type)), vars[i].typeConfidence), vars[i].autoDiscovered));
+ forward_as_tuple(vars[i].address,
+ Confidence<Ref<Type>>(new Type(BNNewTypeReference(vars[i].type)), vars[i].typeConfidence),
+ vars[i].autoDiscovered));
}
BNFreeDataVariables(vars, count);
@@ -1664,7 +1672,7 @@ AnalysisInfo BinaryView::GetAnalysisInfo()
result.activeInfo.reserve(info->count);
for (size_t i = 0; i < info->count; i++)
result.activeInfo.emplace_back(new Function(BNNewFunctionReference(info->activeInfo[i].func)),
- info->activeInfo[i].analysisTime, info->activeInfo[i].submitCount, info->activeInfo[i].updateCount);
+ info->activeInfo[i].analysisTime, info->activeInfo[i].submitCount, info->activeInfo[i].updateCount);
BNFreeAnalysisInfo(info);
return result;
}
@@ -1829,7 +1837,7 @@ vector<ReferenceSource> BinaryView::GetCodeReferences(uint64_t addr, uint64_t le
vector<uint64_t> BinaryView::GetCodeReferencesFrom(ReferenceSource src)
{
size_t count;
- BNReferenceSource _src{ src.func->m_object, src.arch->m_object, src.addr };
+ BNReferenceSource _src {src.func->m_object, src.arch->m_object, src.addr};
uint64_t* refs = BNGetCodeReferencesFrom(m_object, &_src, &count);
vector<uint64_t> result(refs, &refs[count]);
BNFreeAddressList(refs);
@@ -1840,7 +1848,7 @@ vector<uint64_t> BinaryView::GetCodeReferencesFrom(ReferenceSource src)
vector<uint64_t> BinaryView::GetCodeReferencesFrom(ReferenceSource src, uint64_t len)
{
size_t count;
- BNReferenceSource _src{ src.func->m_object, src.arch->m_object, src.addr };
+ BNReferenceSource _src {src.func->m_object, src.arch->m_object, src.addr};
uint64_t* refs = BNGetCodeReferencesFromInRange(m_object, &_src, len, &count);
vector<uint64_t> result(refs, &refs[count]);
BNFreeAddressList(refs);
@@ -2027,7 +2035,7 @@ vector<TypeReferenceSource> BinaryView::GetTypeReferencesForTypeField(const Qual
vector<TypeReferenceSource> BinaryView::GetCodeReferencesForTypeFrom(ReferenceSource src)
{
size_t count;
- BNReferenceSource _src{ src.func->m_object, src.arch->m_object, src.addr };
+ BNReferenceSource _src {src.func->m_object, src.arch->m_object, src.addr};
BNTypeReferenceSource* refs = BNGetCodeReferencesForTypeFrom(m_object, &_src, &count);
vector<TypeReferenceSource> result;
@@ -2049,7 +2057,7 @@ vector<TypeReferenceSource> BinaryView::GetCodeReferencesForTypeFrom(ReferenceSo
vector<TypeReferenceSource> BinaryView::GetCodeReferencesForTypeFrom(ReferenceSource src, uint64_t len)
{
size_t count;
- BNReferenceSource _src{ src.func->m_object, src.arch->m_object, src.addr };
+ BNReferenceSource _src {src.func->m_object, src.arch->m_object, src.addr};
BNTypeReferenceSource* refs = BNGetCodeReferencesForTypeFromInRange(m_object, &_src, len, &count);
vector<TypeReferenceSource> result;
@@ -2070,7 +2078,7 @@ vector<TypeReferenceSource> BinaryView::GetCodeReferencesForTypeFrom(ReferenceSo
vector<TypeReferenceSource> BinaryView::GetCodeReferencesForTypeFieldFrom(ReferenceSource src)
{
size_t count;
- BNReferenceSource _src{ src.func->m_object, src.arch->m_object, src.addr };
+ BNReferenceSource _src {src.func->m_object, src.arch->m_object, src.addr};
BNTypeReferenceSource* refs = BNGetCodeReferencesForTypeFieldsFrom(m_object, &_src, &count);
vector<TypeReferenceSource> result;
@@ -2092,7 +2100,7 @@ vector<TypeReferenceSource> BinaryView::GetCodeReferencesForTypeFieldFrom(Refere
vector<TypeReferenceSource> BinaryView::GetCodeReferencesForTypeFieldFrom(ReferenceSource src, uint64_t len)
{
size_t count;
- BNReferenceSource _src{ src.func->m_object, src.arch->m_object, src.addr };
+ BNReferenceSource _src {src.func->m_object, src.arch->m_object, src.addr};
BNTypeReferenceSource* refs = BNGetCodeReferencesForTypeFieldsFromInRange(m_object, &_src, len, &count);
vector<TypeReferenceSource> result;
@@ -2125,13 +2133,11 @@ vector<uint64_t> BinaryView::GetAllFieldsReferenced(const QualifiedName& type)
}
-std::map<uint64_t, std::vector<size_t>> BinaryView::GetAllSizesReferenced(
- const QualifiedName& type)
+std::map<uint64_t, std::vector<size_t>> BinaryView::GetAllSizesReferenced(const QualifiedName& type)
{
size_t count;
BNQualifiedName nameObj = type.GetAPIObject();
- BNTypeFieldReferenceSizeInfo* fields = BNGetAllSizesReferenced(m_object,
- &nameObj, &count);
+ BNTypeFieldReferenceSizeInfo* fields = BNGetAllSizesReferenced(m_object, &nameObj, &count);
std::map<uint64_t, std::vector<size_t>> result;
for (size_t i = 0; i < count; i++)
@@ -2148,13 +2154,11 @@ std::map<uint64_t, std::vector<size_t>> BinaryView::GetAllSizesReferenced(
}
-std::map<uint64_t, std::vector<Confidence<Ref<Type>>>>
- BinaryView::GetAllTypesReferenced(const QualifiedName& type)
+std::map<uint64_t, std::vector<Confidence<Ref<Type>>>> BinaryView::GetAllTypesReferenced(const QualifiedName& type)
{
size_t count;
BNQualifiedName nameObj = type.GetAPIObject();
- BNTypeFieldReferenceTypeInfo* fields = BNGetAllTypesReferenced(m_object,
- &nameObj, &count);
+ BNTypeFieldReferenceTypeInfo* fields = BNGetAllTypesReferenced(m_object, &nameObj, &count);
std::map<uint64_t, std::vector<Confidence<Ref<Type>>>> result;
for (size_t i = 0; i < count; i++)
@@ -2173,8 +2177,7 @@ std::map<uint64_t, std::vector<Confidence<Ref<Type>>>>
}
-std::vector<size_t> BinaryView::GetSizesReferenced(const QualifiedName& type,
- uint64_t offset)
+std::vector<size_t> BinaryView::GetSizesReferenced(const QualifiedName& type, uint64_t offset)
{
size_t count;
BNQualifiedName nameObj = type.GetAPIObject();
@@ -2190,13 +2193,11 @@ std::vector<size_t> BinaryView::GetSizesReferenced(const QualifiedName& type,
}
-std::vector<Confidence<Ref<Type>>> BinaryView::GetTypesReferenced(
- const QualifiedName& type, uint64_t offset)
+std::vector<Confidence<Ref<Type>>> BinaryView::GetTypesReferenced(const QualifiedName& type, uint64_t offset)
{
size_t count;
BNQualifiedName nameObj = type.GetAPIObject();
- BNTypeWithConfidence* types = BNGetTypesReferenced(m_object, &nameObj, offset,
- &count);
+ BNTypeWithConfidence* types = BNGetTypesReferenced(m_object, &nameObj, offset, &count);
std::vector<Confidence<Ref<Type>>> result;
result.reserve(count);
@@ -2215,7 +2216,7 @@ std::vector<Confidence<Ref<Type>>> BinaryView::GetTypesReferenced(
vector<uint64_t> BinaryView::GetCallees(ReferenceSource callSite)
{
size_t count;
- BNReferenceSource src { callSite.func->m_object, callSite.arch->m_object, callSite.addr };
+ BNReferenceSource src {callSite.func->m_object, callSite.arch->m_object, callSite.addr};
uint64_t* refs = BNGetCallees(m_object, &src, &count);
vector<uint64_t> result(refs, &refs[count]);
BNFreeAddressList(refs);
@@ -2334,7 +2335,8 @@ vector<Ref<Symbol>> BinaryView::GetSymbolsOfType(BNSymbolType type, const NameSp
}
-vector<Ref<Symbol>> BinaryView::GetSymbolsOfType(BNSymbolType type, uint64_t start, uint64_t len, const NameSpace& nameSpace)
+vector<Ref<Symbol>> BinaryView::GetSymbolsOfType(
+ BNSymbolType type, uint64_t start, uint64_t len, const NameSpace& nameSpace)
{
size_t count;
BNNameSpace ns = nameSpace.GetAPIObject();
@@ -2376,7 +2378,8 @@ void BinaryView::DefineAutoSymbol(Ref<Symbol> sym)
Ref<Symbol> BinaryView::DefineAutoSymbolAndVariableOrFunction(Ref<Platform> platform, Ref<Symbol> sym, Ref<Type> type)
{
- BNSymbol* result = BNDefineAutoSymbolAndVariableOrFunction(m_object, platform ? platform->GetObject() : nullptr, sym->GetObject(), type ? type->GetObject() : nullptr);
+ BNSymbol* result = BNDefineAutoSymbolAndVariableOrFunction(
+ m_object, platform ? platform->GetObject() : nullptr, sym->GetObject(), type ? type->GetObject() : nullptr);
if (!result)
return nullptr;
return new Symbol(result);
@@ -2403,7 +2406,8 @@ void BinaryView::UndefineUserSymbol(Ref<Symbol> sym)
void BinaryView::DefineImportedFunction(Ref<Symbol> importAddressSym, Ref<Function> func, Ref<Type> type)
{
- BNDefineImportedFunction(m_object, importAddressSym->GetObject(), func->GetObject(), type ? type->GetObject() : nullptr);
+ BNDefineImportedFunction(
+ m_object, importAddressSym->GetObject(), func->GetObject(), type ? type->GetObject() : nullptr);
}
@@ -2478,7 +2482,7 @@ std::vector<Ref<TagType>> BinaryView::GetTagTypes()
std::vector<Ref<TagType>> result;
result.reserve(count);
- for (size_t i = 0; i < count; i ++)
+ for (size_t i = 0; i < count; i++)
{
result.push_back(new TagType(BNNewTagTypeReference(tagTypes[i])));
}
@@ -2564,7 +2568,7 @@ std::map<Ref<TagType>, size_t> BinaryView::GetAllTagReferenceTypeCounts()
BNGetAllTagReferenceTypeCounts(m_object, &types, &counts, &count);
std::map<Ref<TagType>, size_t> result;
- for (size_t i = 0; i < count; i ++)
+ for (size_t i = 0; i < count; i++)
{
result[new TagType(BNNewTagTypeReference(types[i]))] = counts[i];
}
@@ -2718,7 +2722,8 @@ void BinaryView::RemoveTagReference(const TagReference& ref)
}
-Ref<Tag> BinaryView::CreateAutoDataTag(uint64_t addr, const std::string& tagTypeName, const std::string& data, bool unique)
+Ref<Tag> BinaryView::CreateAutoDataTag(
+ uint64_t addr, const std::string& tagTypeName, const std::string& data, bool unique)
{
Ref<TagType> tagType = GetTagTypeByName(tagTypeName);
if (!tagType)
@@ -2728,7 +2733,8 @@ Ref<Tag> BinaryView::CreateAutoDataTag(uint64_t addr, const std::string& tagType
}
-Ref<Tag> BinaryView::CreateUserDataTag(uint64_t addr, const std::string& tagTypeName, const std::string& data, bool unique)
+Ref<Tag> BinaryView::CreateUserDataTag(
+ uint64_t addr, const std::string& tagTypeName, const std::string& data, bool unique)
{
Ref<TagType> tagType = GetTagTypeByName(tagTypeName);
if (!tagType)
@@ -2780,7 +2786,6 @@ Ref<Tag> BinaryView::CreateUserDataTag(uint64_t addr, Ref<TagType> tagType, cons
bool BinaryView::CanAssemble(Architecture* arch)
{
return BNCanAssemble(m_object, arch->GetObject());
-
}
bool BinaryView::IsNeverBranchPatchAvailable(Architecture* arch, uint64_t addr)
@@ -2946,7 +2951,8 @@ uint64_t BinaryView::GetPreviousDataVariableStartBeforeAddress(uint64_t addr)
}
-bool BinaryView::ParsePossibleValueSet(const string& value, BNRegisterValueType state, PossibleValueSet& result, uint64_t here, string& errors)
+bool BinaryView::ParsePossibleValueSet(
+ const string& value, BNRegisterValueType state, PossibleValueSet& result, uint64_t here, string& errors)
{
BNPossibleValueSet res;
char* errorStr = nullptr;
@@ -2968,7 +2974,7 @@ bool BinaryView::ParsePossibleValueSet(const string& value, BNRegisterValueType
bool BinaryView::ParseTypeString(const string& text, QualifiedNameAndType& result, string& errors,
- const std::set<QualifiedName>& typesAllowRedefinition)
+ const std::set<QualifiedName>& typesAllowRedefinition)
{
BNQualifiedNameAndType nt;
char* errorStr;
@@ -2977,10 +2983,10 @@ bool BinaryView::ParseTypeString(const string& text, QualifiedNameAndType& resul
typesList.count = typesAllowRedefinition.size();
typesList.names = new BNQualifiedName[typesList.count];
size_t i = 0;
- for(auto& type : typesAllowRedefinition)
+ for (auto& type : typesAllowRedefinition)
{
typesList.names[i] = type.GetAPIObject();
- i ++;
+ i++;
}
if (!BNParseTypeString(m_object, text.c_str(), &nt, &errorStr, &typesList))
@@ -3001,8 +3007,8 @@ bool BinaryView::ParseTypeString(const string& text, QualifiedNameAndType& resul
bool BinaryView::ParseTypeString(const string& source, map<QualifiedName, Ref<Type>>& types,
- map<QualifiedName, Ref<Type>>& variables, map<QualifiedName, Ref<Type>>& functions, string& errors,
- const std::set<QualifiedName>& typesAllowRedefinition)
+ map<QualifiedName, Ref<Type>>& variables, map<QualifiedName, Ref<Type>>& functions, string& errors,
+ const std::set<QualifiedName>& typesAllowRedefinition)
{
BNTypeParserResult result;
char* errorStr = nullptr;
@@ -3015,10 +3021,10 @@ bool BinaryView::ParseTypeString(const string& source, map<QualifiedName, Ref<Ty
typesList.count = typesAllowRedefinition.size();
typesList.names = new BNQualifiedName[typesList.count];
size_t i = 0;
- for(auto& type : typesAllowRedefinition)
+ for (auto& type : typesAllowRedefinition)
{
typesList.names[i] = type.GetAPIObject();
- i ++;
+ i++;
}
bool ok = BNParseTypesString(m_object, source.c_str(), &result, &errorStr, &typesList);
@@ -3183,20 +3189,19 @@ void BinaryView::RegisterPlatformTypes(Platform* platform)
}
-bool BinaryView::FindNextData(uint64_t start, const DataBuffer& data, uint64_t& result,
- BNFindFlag flags)
+bool BinaryView::FindNextData(uint64_t start, const DataBuffer& data, uint64_t& result, BNFindFlag flags)
{
return BNFindNextData(m_object, start, data.GetBufferObject(), &result, flags);
}
bool BinaryView::FindNextText(uint64_t start, const std::string& data, uint64_t& result,
- Ref<DisassemblySettings> settings, BNFindFlag flags, BNFunctionGraphType graph)
+ Ref<DisassemblySettings> settings, BNFindFlag flags, BNFunctionGraphType graph)
{
return BNFindNextText(m_object, start, data.c_str(), &result, settings->GetObject(), flags, graph);
}
-bool BinaryView::FindNextConstant(uint64_t start, uint64_t constant, uint64_t& result,
- Ref<DisassemblySettings> settings, BNFunctionGraphType graph)
+bool BinaryView::FindNextConstant(
+ uint64_t start, uint64_t constant, uint64_t& result, Ref<DisassemblySettings> settings, BNFunctionGraphType graph)
{
return BNFindNextConstant(m_object, start, constant, &result, settings->GetObject(), graph);
}
@@ -3234,8 +3239,7 @@ struct MatchCallbackContextForText
};
-static bool MatchCallbackForText(void* ctxt, uint64_t addr, const char* buffer,
- BNLinearDisassemblyLine* line)
+static bool MatchCallbackForText(void* ctxt, uint64_t addr, const char* buffer, BNLinearDisassemblyLine* line)
{
MatchCallbackContextForText* cb = (MatchCallbackContextForText*)ctxt;
@@ -3264,76 +3268,74 @@ static bool MatchCallbackForConstant(void* ctxt, uint64_t addr, BNLinearDisassem
bool BinaryView::FindNextData(uint64_t start, uint64_t end, const DataBuffer& data, uint64_t& addr, BNFindFlag flags,
- const std::function<bool(size_t current, size_t total)>& progress)
+ const std::function<bool(size_t current, size_t total)>& progress)
{
FindProgressCallbackContext fp;
fp.func = progress;
- return BNFindNextDataWithProgress(m_object, start, end, data.GetBufferObject(), &addr, flags, &fp, FindProgressCallback);
+ return BNFindNextDataWithProgress(
+ m_object, start, end, data.GetBufferObject(), &addr, flags, &fp, FindProgressCallback);
}
-bool BinaryView::FindNextText(uint64_t start, uint64_t end, const std::string& data,
- uint64_t& addr, Ref<DisassemblySettings> settings, BNFindFlag flags, BNFunctionGraphType graph,
- const std::function<bool(size_t current, size_t total)>& progress)
+bool BinaryView::FindNextText(uint64_t start, uint64_t end, const std::string& data, uint64_t& addr,
+ Ref<DisassemblySettings> settings, BNFindFlag flags, BNFunctionGraphType graph,
+ const std::function<bool(size_t current, size_t total)>& progress)
{
FindProgressCallbackContext fp;
fp.func = progress;
- return BNFindNextTextWithProgress(m_object, start, end, data.c_str(), &addr,
- settings->GetObject(), flags, graph, &fp, FindProgressCallback);
+ return BNFindNextTextWithProgress(
+ m_object, start, end, data.c_str(), &addr, settings->GetObject(), flags, graph, &fp, FindProgressCallback);
}
bool BinaryView::FindNextConstant(uint64_t start, uint64_t end, uint64_t constant, uint64_t& addr,
- Ref<DisassemblySettings> settings, BNFunctionGraphType graph,
- const std::function<bool(size_t current, size_t total)>& progress)
+ Ref<DisassemblySettings> settings, BNFunctionGraphType graph,
+ const std::function<bool(size_t current, size_t total)>& progress)
{
FindProgressCallbackContext fp;
fp.func = progress;
- return BNFindNextConstantWithProgress(m_object, start, end, constant, &addr,
- settings->GetObject(), graph, &fp, FindProgressCallback);
+ return BNFindNextConstantWithProgress(
+ m_object, start, end, constant, &addr, settings->GetObject(), graph, &fp, FindProgressCallback);
}
-bool BinaryView::FindAllData(uint64_t start, uint64_t end, const DataBuffer& data,
- BNFindFlag flags, const std::function<bool(size_t current, size_t total)>& progress,
- const std::function<bool(uint64_t addr, const DataBuffer& match)>& matchCallback)
+bool BinaryView::FindAllData(uint64_t start, uint64_t end, const DataBuffer& data, BNFindFlag flags,
+ const std::function<bool(size_t current, size_t total)>& progress,
+ const std::function<bool(uint64_t addr, const DataBuffer& match)>& matchCallback)
{
FindProgressCallbackContext fp;
fp.func = progress;
MatchCallbackContextForDataBuffer mc;
mc.func = matchCallback;
- return BNFindAllDataWithProgress(m_object, start, end, data.GetBufferObject(),
- flags, &fp, FindProgressCallback, &mc, MatchCallbackForDataBuffer);
+ return BNFindAllDataWithProgress(m_object, start, end, data.GetBufferObject(), flags, &fp, FindProgressCallback,
+ &mc, MatchCallbackForDataBuffer);
}
-bool BinaryView::FindAllText(uint64_t start, uint64_t end, const std::string& data,
- Ref<DisassemblySettings> settings, BNFindFlag flags, BNFunctionGraphType graph,
- const std::function<bool(size_t current, size_t total)>& progress,
- const std::function<bool(uint64_t addr, const std::string& match,
- const LinearDisassemblyLine& line)>& matchCallback)
+bool BinaryView::FindAllText(uint64_t start, uint64_t end, const std::string& data, Ref<DisassemblySettings> settings,
+ BNFindFlag flags, BNFunctionGraphType graph, const std::function<bool(size_t current, size_t total)>& progress,
+ const std::function<bool(uint64_t addr, const std::string& match, const LinearDisassemblyLine& line)>&
+ matchCallback)
{
FindProgressCallbackContext fp;
fp.func = progress;
MatchCallbackContextForText mc;
mc.func = matchCallback;
- return BNFindAllTextWithProgress(m_object, start, end, data.c_str(), settings->GetObject(),
- flags, graph, &fp, FindProgressCallback, &mc, MatchCallbackForText);
+ return BNFindAllTextWithProgress(m_object, start, end, data.c_str(), settings->GetObject(), flags, graph, &fp,
+ FindProgressCallback, &mc, MatchCallbackForText);
}
-bool BinaryView::FindAllConstant(uint64_t start, uint64_t end, uint64_t constant,
- Ref<DisassemblySettings> settings, BNFunctionGraphType graph,
- const std::function<bool(size_t current, size_t total)>& progress,
- const std::function<bool(uint64_t addr, const LinearDisassemblyLine& line)>&
- matchCallback)
+bool BinaryView::FindAllConstant(uint64_t start, uint64_t end, uint64_t constant, Ref<DisassemblySettings> settings,
+ BNFunctionGraphType graph, const std::function<bool(size_t current, size_t total)>& progress,
+ const std::function<bool(uint64_t addr, const LinearDisassemblyLine& line)>& matchCallback)
{
FindProgressCallbackContext fp;
fp.func = progress;
MatchCallbackContextForConstant mc;
mc.func = matchCallback;
- return BNFindAllConstantWithProgress(m_object, start, end, constant, settings->GetObject(),
- graph, &fp, FindProgressCallback, &mc, MatchCallbackForConstant);
+ return BNFindAllConstantWithProgress(m_object, start, end, constant, settings->GetObject(), graph, &fp,
+ FindProgressCallback, &mc, MatchCallbackForConstant);
}
@@ -3391,8 +3393,8 @@ bool BinaryView::GetAddressInput(uint64_t& result, const string& prompt, const s
}
-void BinaryView::AddAutoSegment(uint64_t start, uint64_t length, uint64_t dataOffset, uint64_t dataLength,
- uint32_t flags)
+void BinaryView::AddAutoSegment(
+ uint64_t start, uint64_t length, uint64_t dataOffset, uint64_t dataLength, uint32_t flags)
{
BNAddAutoSegment(m_object, start, length, dataOffset, dataLength, flags);
}
@@ -3404,8 +3406,8 @@ void BinaryView::RemoveAutoSegment(uint64_t start, uint64_t length)
}
-void BinaryView::AddUserSegment(uint64_t start, uint64_t length, uint64_t dataOffset, uint64_t dataLength,
- uint32_t flags)
+void BinaryView::AddUserSegment(
+ uint64_t start, uint64_t length, uint64_t dataOffset, uint64_t dataLength, uint32_t flags)
{
BNAddUserSegment(m_object, start, length, dataOffset, dataLength, flags);
}
@@ -3449,11 +3451,11 @@ bool BinaryView::GetAddressForDataOffset(uint64_t offset, uint64_t& addr)
void BinaryView::AddAutoSection(const string& name, uint64_t start, uint64_t length, BNSectionSemantics semantics,
- const string& type, uint64_t align, uint64_t entrySize, const string& linkedSection,
- const string& infoSection, uint64_t infoData)
+ const string& type, uint64_t align, uint64_t entrySize, const string& linkedSection, const string& infoSection,
+ uint64_t infoData)
{
BNAddAutoSection(m_object, name.c_str(), start, length, semantics, type.c_str(), align, entrySize,
- linkedSection.c_str(), infoSection.c_str(), infoData);
+ linkedSection.c_str(), infoSection.c_str(), infoData);
}
@@ -3464,11 +3466,11 @@ void BinaryView::RemoveAutoSection(const string& name)
void BinaryView::AddUserSection(const string& name, uint64_t start, uint64_t length, BNSectionSemantics semantics,
- const string& type, uint64_t align, uint64_t entrySize, const string& linkedSection,
- const string& infoSection, uint64_t infoData)
+ const string& type, uint64_t align, uint64_t entrySize, const string& linkedSection, const string& infoSection,
+ uint64_t infoData)
{
BNAddUserSection(m_object, name.c_str(), start, length, semantics, type.c_str(), align, entrySize,
- linkedSection.c_str(), infoSection.c_str(), infoData);
+ linkedSection.c_str(), infoSection.c_str(), infoData);
}
@@ -3484,7 +3486,7 @@ vector<Ref<Section>> BinaryView::GetSections()
BNSection** sections = BNGetSections(m_object, &count);
vector<Ref<Section>> result;
- result.reserve(count);
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
result.push_back(new Section(BNNewSectionReference(sections[i])));
@@ -3499,7 +3501,7 @@ vector<Ref<Section>> BinaryView::GetSectionsAt(uint64_t addr)
BNSection** sections = BNGetSectionsAt(m_object, addr, &count);
vector<Ref<Section>> result;
- result.reserve(count);
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
{
result.push_back(new Section(BNNewSectionReference(sections[i])));
@@ -3719,7 +3721,8 @@ NameSpace BinaryView::GetExternalNameSpace()
}
-bool BinaryView::ParseExpression(Ref<BinaryView> view, const string& expression, uint64_t &offset, uint64_t here, string& errorString)
+bool BinaryView::ParseExpression(
+ Ref<BinaryView> view, const string& expression, uint64_t& offset, uint64_t here, string& errorString)
{
char* err = nullptr;
if (!BNParseExpression(view ? view->GetObject() : nullptr, expression.c_str(), &offset, here, &err))
@@ -3735,22 +3738,18 @@ bool BinaryView::ParseExpression(Ref<BinaryView> view, const string& expression,
}
-Ref<Structure> BinaryView::CreateStructureFromOffsetAccess(const QualifiedName& type,
- bool* newMemberAdded) const
+Ref<Structure> BinaryView::CreateStructureFromOffsetAccess(const QualifiedName& type, bool* newMemberAdded) const
{
BNQualifiedName typeObj = type.GetAPIObject();
- BNStructure* result = BNCreateStructureFromOffsetAccess(m_object, &typeObj,
- newMemberAdded);
+ BNStructure* result = BNCreateStructureFromOffsetAccess(m_object, &typeObj, newMemberAdded);
return new Structure(result);
}
-Confidence<Ref<Type>> BinaryView::CreateStructureMemberFromAccess(
- const QualifiedName& name, uint64_t offset) const
+Confidence<Ref<Type>> BinaryView::CreateStructureMemberFromAccess(const QualifiedName& name, uint64_t offset) const
{
BNQualifiedName typeObj = name.GetAPIObject();
- BNTypeWithConfidence type = BNCreateStructureMemberFromAccess(m_object, &typeObj,
- offset);
+ BNTypeWithConfidence type = BNCreateStructureMemberFromAccess(m_object, &typeObj, offset);
if (type.type)
return Confidence<Ref<Type>>(new Type(type.type), type.confidence);
@@ -3797,30 +3796,24 @@ Ref<Symbol> Relocation::GetSymbol() const
}
-BinaryData::BinaryData(FileMetadata* file): BinaryView(BNCreateBinaryDataView(file->GetObject()))
-{
-}
+BinaryData::BinaryData(FileMetadata* file) : BinaryView(BNCreateBinaryDataView(file->GetObject())) {}
-BinaryData::BinaryData(FileMetadata* file, const DataBuffer& data):
- BinaryView(BNCreateBinaryDataViewFromBuffer(file->GetObject(), data.GetBufferObject()))
-{
-}
+BinaryData::BinaryData(FileMetadata* file, const DataBuffer& data) :
+ BinaryView(BNCreateBinaryDataViewFromBuffer(file->GetObject(), data.GetBufferObject()))
+{}
-BinaryData::BinaryData(FileMetadata* file, const void* data, size_t len):
- BinaryView(BNCreateBinaryDataViewFromData(file->GetObject(), data, len))
-{
-}
+BinaryData::BinaryData(FileMetadata* file, const void* data, size_t len) :
+ BinaryView(BNCreateBinaryDataViewFromData(file->GetObject(), data, len))
+{}
-BinaryData::BinaryData(FileMetadata* file, const string& path):
- BinaryView(BNCreateBinaryDataViewFromFilename(file->GetObject(), path.c_str()))
-{
-}
+BinaryData::BinaryData(FileMetadata* file, const string& path) :
+ BinaryView(BNCreateBinaryDataViewFromFilename(file->GetObject(), path.c_str()))
+{}
-BinaryData::BinaryData(FileMetadata* file, FileAccessor* accessor):
- BinaryView(BNCreateBinaryDataViewFromFile(file->GetObject(), accessor->GetCallbacks()))
-{
-}
+BinaryData::BinaryData(FileMetadata* file, FileAccessor* accessor) :
+ BinaryView(BNCreateBinaryDataViewFromFile(file->GetObject(), accessor->GetCallbacks()))
+{}
diff --git a/binaryviewtype.cpp b/binaryviewtype.cpp
index af6fd290..cb8abea8 100644
--- a/binaryviewtype.cpp
+++ b/binaryviewtype.cpp
@@ -71,8 +71,8 @@ BinaryViewType::BinaryViewType(BNBinaryViewType* type)
}
-BinaryViewType::BinaryViewType(const string& name, const string& longName):
- m_nameForRegister(name), m_longNameForRegister(longName)
+BinaryViewType::BinaryViewType(const string& name, const string& longName) :
+ m_nameForRegister(name), m_longNameForRegister(longName)
{
m_object = nullptr;
}
@@ -88,8 +88,8 @@ void BinaryViewType::Register(BinaryViewType* type)
callbacks.getLoadSettingsForData = GetSettingsCallback;
type->AddRefForRegistration();
- type->m_object = BNRegisterBinaryViewType(type->m_nameForRegister.c_str(),
- type->m_longNameForRegister.c_str(), &callbacks);
+ type->m_object =
+ BNRegisterBinaryViewType(type->m_nameForRegister.c_str(), type->m_longNameForRegister.c_str(), &callbacks);
}
@@ -197,7 +197,8 @@ Ref<Platform> BinaryViewType::GetPlatform(uint32_t id, Architecture* arch)
}
-void BinaryViewType::RegisterPlatformRecognizer(uint64_t id, BNEndianness endian, const std::function<Ref<Platform>(BinaryView* view, Metadata* metadata)>& callback)
+void BinaryViewType::RegisterPlatformRecognizer(uint64_t id, BNEndianness endian,
+ const std::function<Ref<Platform>(BinaryView* view, Metadata* metadata)>& callback)
{
PlatformRecognizerFunction* ctxt = new PlatformRecognizerFunction;
ctxt->action = callback;
@@ -207,7 +208,8 @@ void BinaryViewType::RegisterPlatformRecognizer(uint64_t id, BNEndianness endian
Ref<Platform> BinaryViewType::RecognizePlatform(uint64_t id, BNEndianness endian, BinaryView* view, Metadata* metadata)
{
- BNPlatform* platform = BNRecognizePlatformForViewType(m_object, id, endian, view->GetObject(), metadata->GetObject());
+ BNPlatform* platform =
+ BNRecognizePlatformForViewType(m_object, id, endian, view->GetObject(), metadata->GetObject());
if (!platform)
return nullptr;
return new Platform(platform);
@@ -263,7 +265,7 @@ void BinaryViewType::BinaryViewEventCallback(void* ctxt, BNBinaryView* view)
BNPlatform* BinaryViewType::PlatformRecognizerCallback(void* ctxt, BNBinaryView* view, BNMetadata* metadata)
{
- PlatformRecognizerFunction* callback = (PlatformRecognizerFunction*) ctxt;
+ PlatformRecognizerFunction* callback = (PlatformRecognizerFunction*)ctxt;
Ref<BinaryView> viewObject = new BinaryView(BNNewViewReference(view));
Ref<Metadata> metadataObject = new Metadata(BNNewMetadataReference(metadata));
Ref<Platform> result = callback->action(viewObject, metadataObject);
@@ -273,9 +275,7 @@ BNPlatform* BinaryViewType::PlatformRecognizerCallback(void* ctxt, BNBinaryView*
}
-CoreBinaryViewType::CoreBinaryViewType(BNBinaryViewType* type): BinaryViewType(type)
-{
-}
+CoreBinaryViewType::CoreBinaryViewType(BNBinaryViewType* type) : BinaryViewType(type) {}
BinaryView* CoreBinaryViewType::Create(BinaryView* data)
diff --git a/binarywriter.cpp b/binarywriter.cpp
index c644573b..dcac3589 100644
--- a/binarywriter.cpp
+++ b/binarywriter.cpp
@@ -24,7 +24,7 @@ using namespace BinaryNinja;
using namespace std;
-BinaryWriter::BinaryWriter(BinaryView* data, BNEndianness endian): m_view(data)
+BinaryWriter::BinaryWriter(BinaryView* data, BNEndianness endian) : m_view(data)
{
m_stream = BNCreateBinaryWriter(data->GetObject());
BNSetBinaryWriterEndianness(m_stream, endian);
diff --git a/callingconvention.cpp b/callingconvention.cpp
index 331caf87..0e8bc56c 100644
--- a/callingconvention.cpp
+++ b/callingconvention.cpp
@@ -201,7 +201,8 @@ uint32_t* CallingConvention::GetImplicitlyDefinedRegistersCallback(void* ctxt, s
}
-void CallingConvention::GetIncomingRegisterValueCallback(void* ctxt, uint32_t reg, BNFunction* func, BNRegisterValue* result)
+void CallingConvention::GetIncomingRegisterValueCallback(
+ void* ctxt, uint32_t reg, BNFunction* func, BNRegisterValue* result)
{
CallingConvention* cc = (CallingConvention*)ctxt;
Ref<Function> funcObj;
@@ -211,7 +212,8 @@ void CallingConvention::GetIncomingRegisterValueCallback(void* ctxt, uint32_t re
}
-void CallingConvention::GetIncomingFlagValueCallback(void* ctxt, uint32_t reg, BNFunction* func, BNRegisterValue* result)
+void CallingConvention::GetIncomingFlagValueCallback(
+ void* ctxt, uint32_t reg, BNFunction* func, BNRegisterValue* result)
{
CallingConvention* cc = (CallingConvention*)ctxt;
Ref<Function> funcObj;
@@ -221,8 +223,8 @@ void CallingConvention::GetIncomingFlagValueCallback(void* ctxt, uint32_t reg, B
}
-void CallingConvention::GetIncomingVariableForParameterVariableCallback(void* ctxt, const BNVariable* var,
- BNFunction* func, BNVariable* result)
+void CallingConvention::GetIncomingVariableForParameterVariableCallback(
+ void* ctxt, const BNVariable* var, BNFunction* func, BNVariable* result)
{
CallingConvention* cc = (CallingConvention*)ctxt;
Ref<Function> funcObj;
@@ -232,8 +234,8 @@ void CallingConvention::GetIncomingVariableForParameterVariableCallback(void* ct
}
-void CallingConvention::GetParameterVariableForIncomingVariableCallback(void* ctxt, const BNVariable* var,
- BNFunction* func, BNVariable* result)
+void CallingConvention::GetParameterVariableForIncomingVariableCallback(
+ void* ctxt, const BNVariable* var, BNFunction* func, BNVariable* result)
{
CallingConvention* cc = (CallingConvention*)ctxt;
Ref<Function> funcObj;
@@ -368,9 +370,7 @@ Variable CallingConvention::GetParameterVariableForIncomingVariable(const Variab
}
-CoreCallingConvention::CoreCallingConvention(BNCallingConvention* cc): CallingConvention(cc)
-{
-}
+CoreCallingConvention::CoreCallingConvention(BNCallingConvention* cc) : CallingConvention(cc) {}
vector<uint32_t> CoreCallingConvention::GetCallerSavedRegisters()
diff --git a/database.cpp b/database.cpp
index 3d1a5cb6..0a846f09 100644
--- a/database.cpp
+++ b/database.cpp
@@ -91,8 +91,7 @@ Json::Value KeyValueStore::GetValue(const std::string& name) const
std::unique_ptr<Json::CharReader> reader(Json::CharReaderBuilder().newCharReader());
std::string errors;
if (!reader->parse(static_cast<const char*>(value.GetData()),
- static_cast<const char*>(value.GetDataAt(value.GetLength())),
- &json, &errors))
+ static_cast<const char*>(value.GetDataAt(value.GetLength())), &json, &errors))
{
throw DatabaseException(errors);
}
@@ -201,7 +200,7 @@ int64_t Snapshot::GetId()
std::string Snapshot::GetName()
{
char* cstr = BNGetSnapshotName(m_object);
- std::string str{cstr};
+ std::string str {cstr};
BNFreeString(cstr);
return str;
}
@@ -286,7 +285,7 @@ DataBuffer Snapshot::GetFileContentsHash()
vector<UndoEntry> Snapshot::GetUndoEntries()
{
- return GetUndoEntries([](size_t, size_t){ return true; });
+ return GetUndoEntries([](size_t, size_t) { return true; });
}
@@ -325,7 +324,7 @@ vector<UndoEntry> Snapshot::GetUndoEntries(const std::function<bool(size_t, size
Ref<KeyValueStore> Snapshot::ReadData()
{
- return ReadData([](size_t, size_t){ return true; });
+ return ReadData([](size_t, size_t) { return true; });
}
@@ -389,11 +388,13 @@ Ref<Snapshot> Database::GetCurrentSnapshot()
}
-int64_t Database::WriteSnapshotData(std::vector<int64_t> parents, Ref<BinaryView> file, const std::string& name, const Ref<KeyValueStore>& data, bool autoSave, const std::function<bool(size_t, size_t)>& progress)
+int64_t Database::WriteSnapshotData(std::vector<int64_t> parents, Ref<BinaryView> file, const std::string& name,
+ const Ref<KeyValueStore>& data, bool autoSave, const std::function<bool(size_t, size_t)>& progress)
{
ProgressContext pctxt;
pctxt.callback = progress;
- int64_t result = BNWriteDatabaseSnapshotData(m_object, parents.data(), parents.size(), file->GetObject(), name.c_str(), data->GetObject(), autoSave, &pctxt, ProgressCallback);
+ int64_t result = BNWriteDatabaseSnapshotData(m_object, parents.data(), parents.size(), file->GetObject(),
+ name.c_str(), data->GetObject(), autoSave, &pctxt, ProgressCallback);
if (result < 0)
{
throw DatabaseException("BNWriteDatabaseSnapshotData");
@@ -421,7 +422,7 @@ std::vector<std::string> Database::GetGlobalKeys() const
}
std::vector<std::string> result;
- for (size_t i = 0; i < count; i ++)
+ for (size_t i = 0; i < count; i++)
{
result.push_back(value[i]);
}
diff --git a/datarenderer.cpp b/datarenderer.cpp
index 4d3b38ae..b6dd6ec9 100644
--- a/datarenderer.cpp
+++ b/datarenderer.cpp
@@ -24,10 +24,9 @@ DataRenderer::DataRenderer()
bool DataRenderer::IsStructOfTypeName(Type* type, const QualifiedName& name, vector<pair<Type*, size_t>>& context)
{
- return (type->GetClass() == StructureTypeClass) &&
- (context.size() > 0) &&
- (context[context.size() - 1].first->GetClass() == NamedTypeReferenceClass) &&
- (context[context.size() - 1].first->GetNamedTypeReference()->GetName() == name);
+ return (type->GetClass() == StructureTypeClass) && (context.size() > 0)
+ && (context[context.size() - 1].first->GetClass() == NamedTypeReferenceClass)
+ && (context[context.size() - 1].first->GetNamedTypeReference()->GetName() == name);
}
@@ -37,8 +36,8 @@ bool DataRenderer::IsStructOfTypeName(Type* type, const string& name, vector<pai
}
-bool DataRenderer::IsValidForDataCallback(void* ctxt, BNBinaryView* view, uint64_t addr, BNType* type,
- BNTypeContext* typeCtx, size_t ctxCount)
+bool DataRenderer::IsValidForDataCallback(
+ void* ctxt, BNBinaryView* view, uint64_t addr, BNType* type, BNTypeContext* typeCtx, size_t ctxCount)
{
DataRenderer* renderer = (DataRenderer*)ctxt;
Ref<BinaryView> viewObj = new BinaryView(BNNewViewReference(view));
@@ -52,9 +51,9 @@ bool DataRenderer::IsValidForDataCallback(void* ctxt, BNBinaryView* view, uint64
}
-BNDisassemblyTextLine* DataRenderer::GetLinesForDataCallback(void* ctxt, BNBinaryView* view, uint64_t addr, BNType* type,
- const BNInstructionTextToken* prefix, size_t prefixCount, size_t width, size_t* count, BNTypeContext* typeCtx,
- size_t ctxCount)
+BNDisassemblyTextLine* DataRenderer::GetLinesForDataCallback(void* ctxt, BNBinaryView* view, uint64_t addr,
+ BNType* type, const BNInstructionTextToken* prefix, size_t prefixCount, size_t width, size_t* count,
+ BNTypeContext* typeCtx, size_t ctxCount)
{
DataRenderer* renderer = (DataRenderer*)ctxt;
Ref<BinaryView> viewObj = new BinaryView(BNNewViewReference(view));
@@ -104,7 +103,7 @@ bool DataRenderer::IsValidForData(BinaryView* data, uint64_t addr, Type* type, v
vector<DisassemblyTextLine> DataRenderer::GetLinesForData(BinaryView* data, uint64_t addr, Type* type,
- const std::vector<InstructionTextToken>& prefix, size_t width, vector<pair<Type*, size_t>>& context)
+ const std::vector<InstructionTextToken>& prefix, size_t width, vector<pair<Type*, size_t>>& context)
{
BNInstructionTextToken* prefixes = InstructionTextToken::CreateInstructionTextTokenList(prefix);
BNTypeContext* typeCtx = new BNTypeContext[context.size()];
@@ -115,7 +114,7 @@ vector<DisassemblyTextLine> DataRenderer::GetLinesForData(BinaryView* data, uint
}
size_t count = 0;
BNDisassemblyTextLine* lines = BNGetLinesForData(m_object, data->GetObject(), addr, type->GetObject(), prefixes,
- prefix.size(), width, &count, typeCtx, context.size());
+ prefix.size(), width, &count, typeCtx, context.size());
delete[] typeCtx;
for (size_t i = 0; i < prefix.size(); i++)
@@ -144,7 +143,7 @@ vector<DisassemblyTextLine> DataRenderer::GetLinesForData(BinaryView* data, uint
vector<DisassemblyTextLine> DataRenderer::RenderLinesForData(BinaryView* data, uint64_t addr, Type* type,
- const std::vector<InstructionTextToken>& prefix, size_t width, vector<pair<Type*, size_t>>& context)
+ const std::vector<InstructionTextToken>& prefix, size_t width, vector<pair<Type*, size_t>>& context)
{
BNInstructionTextToken* prefixes = InstructionTextToken::CreateInstructionTextTokenList(prefix);
BNTypeContext* typeCtx = new BNTypeContext[context.size()];
@@ -154,8 +153,8 @@ vector<DisassemblyTextLine> DataRenderer::RenderLinesForData(BinaryView* data, u
typeCtx[i].offset = context[i].second;
}
size_t count = 0;
- BNDisassemblyTextLine* lines = BNRenderLinesForData(data->GetObject(), addr, type->GetObject(), prefixes,
- prefix.size(), width, &count, typeCtx, context.size());
+ BNDisassemblyTextLine* lines = BNRenderLinesForData(
+ data->GetObject(), addr, type->GetObject(), prefixes, prefix.size(), width, &count, typeCtx, context.size());
delete[] typeCtx;
for (size_t i = 0; i < prefix.size(); i++)
diff --git a/debuginfo.cpp b/debuginfo.cpp
index 3003bde7..e8450399 100644
--- a/debuginfo.cpp
+++ b/debuginfo.cpp
@@ -41,15 +41,14 @@ DebugInfo::DebugInfo(BNDebugInfo* debugInfo)
vector<NameAndType> DebugInfo::GetTypes(const string& parserName)
{
size_t count;
- BNNameAndType* nameAndTypes = BNGetDebugTypes(m_object, parserName.size() == 0 ? nullptr : parserName.c_str(), &count);
+ BNNameAndType* nameAndTypes =
+ BNGetDebugTypes(m_object, parserName.size() == 0 ? nullptr : parserName.c_str(), &count);
vector<NameAndType> result;
for (size_t i = 0; i < count; ++i)
{
result.emplace_back(nameAndTypes[i].name,
- Confidence<Ref<Type>>(
- new Type(BNNewTypeReference(nameAndTypes[i].type)),
- nameAndTypes[i].typeConfidence));
+ Confidence<Ref<Type>>(new Type(BNNewTypeReference(nameAndTypes[i].type)), nameAndTypes[i].typeConfidence));
}
BNFreeDebugTypes(nameAndTypes, count);
@@ -60,24 +59,26 @@ vector<NameAndType> DebugInfo::GetTypes(const string& parserName)
vector<DebugFunctionInfo> DebugInfo::GetFunctions(const string& parserName)
{
size_t count;
- BNDebugFunctionInfo* functions = BNGetDebugFunctions(m_object, parserName.size() == 0 ? nullptr : parserName.c_str(), &count);
+ BNDebugFunctionInfo* functions =
+ BNGetDebugFunctions(m_object, parserName.size() == 0 ? nullptr : parserName.c_str(), &count);
vector<DebugFunctionInfo> result;
for (size_t i = 0; i < count; ++i)
{
vector<tuple<string, Ref<Type>>> parameters;
for (size_t j = 0; j < functions[i].parameterCount; ++j)
- parameters.emplace_back(functions[i].parameterNames[j], new Type(BNNewTypeReference(functions[i].parameterTypes[j])));
+ parameters.emplace_back(
+ functions[i].parameterNames[j], new Type(BNNewTypeReference(functions[i].parameterTypes[j])));
result.emplace_back(functions[i].shortName ? functions[i].shortName : "",
- functions[i].fullName ? functions[i].fullName : "",
- functions[i].rawName ? functions[i].rawName : "",
- functions[i].address,
- functions[i].returnType ? new Type(BNNewTypeReference(functions[i].returnType)) : nullptr,
- parameters,
- functions[i].variableParameters,
- functions[i].callingConvention ? new CoreCallingConvention(BNNewCallingConventionReference(functions[i].callingConvention)) : nullptr,
- functions[i].platform ? new Platform(BNNewPlatformReference(functions[i].platform)) : nullptr);
+ functions[i].fullName ? functions[i].fullName : "", functions[i].rawName ? functions[i].rawName : "",
+ functions[i].address,
+ functions[i].returnType ? new Type(BNNewTypeReference(functions[i].returnType)) : nullptr, parameters,
+ functions[i].variableParameters,
+ functions[i].callingConvention ?
+ new CoreCallingConvention(BNNewCallingConventionReference(functions[i].callingConvention)) :
+ nullptr,
+ functions[i].platform ? new Platform(BNNewPlatformReference(functions[i].platform)) : nullptr);
}
BNFreeDebugFunctions(functions, count);
@@ -88,15 +89,15 @@ vector<DebugFunctionInfo> DebugInfo::GetFunctions(const string& parserName)
vector<DataVariableAndName> DebugInfo::GetDataVariables(const string& parserName)
{
size_t count;
- BNDataVariableAndName* variableAndNames = BNGetDebugDataVariables(m_object, parserName.size() == 0 ? nullptr : parserName.c_str(), &count);
+ BNDataVariableAndName* variableAndNames =
+ BNGetDebugDataVariables(m_object, parserName.size() == 0 ? nullptr : parserName.c_str(), &count);
vector<DataVariableAndName> result;
for (size_t i = 0; i < count; ++i)
{
result.emplace_back(variableAndNames[i].address,
- Confidence(new Type(BNNewTypeReference(variableAndNames[i].type)), variableAndNames[i].typeConfidence),
- variableAndNames[i].autoDiscovered,
- variableAndNames[i].name);
+ Confidence(new Type(BNNewTypeReference(variableAndNames[i].type)), variableAndNames[i].typeConfidence),
+ variableAndNames[i].autoDiscovered, variableAndNames[i].name);
}
BNFreeDataVariablesAndName(variableAndNames, count);
@@ -114,14 +115,14 @@ bool DebugInfo::AddFunction(const DebugFunctionInfo& function)
{
BNDebugFunctionInfo* input = new BNDebugFunctionInfo();
- input->shortName = function.shortName.size() ? BNAllocString(function.shortName.c_str()) : nullptr;
- input->fullName = function.fullName.size() ? BNAllocString(function.fullName.c_str()) : nullptr;
- input->rawName = function.rawName.size() ? BNAllocString(function.rawName.c_str()) : nullptr;
- input->address = function.address;
- input->returnType = function.returnType ? function.returnType->GetObject() : nullptr;
+ input->shortName = function.shortName.size() ? BNAllocString(function.shortName.c_str()) : nullptr;
+ input->fullName = function.fullName.size() ? BNAllocString(function.fullName.c_str()) : nullptr;
+ input->rawName = function.rawName.size() ? BNAllocString(function.rawName.c_str()) : nullptr;
+ input->address = function.address;
+ input->returnType = function.returnType ? function.returnType->GetObject() : nullptr;
input->variableParameters = function.variableParameters;
- input->callingConvention = function.callingConvention ? function.callingConvention->GetObject() : nullptr;
- input->platform = function.platform ? function.platform->GetObject() : nullptr;
+ input->callingConvention = function.callingConvention ? function.callingConvention->GetObject() : nullptr;
+ input->platform = function.platform ? function.platform->GetObject() : nullptr;
size_t parameterCount = function.parameters.size();
input->parameterCount = parameterCount;
@@ -176,7 +177,7 @@ Ref<DebugInfoParser> DebugInfoParser::GetByName(const string& name)
vector<Ref<DebugInfoParser>> DebugInfoParser::GetList()
{
- size_t count = 0;
+ size_t count = 0;
BNDebugInfoParser** parsers = BNGetDebugInfoParsers(&count);
vector<Ref<DebugInfoParser>> result;
@@ -192,7 +193,7 @@ vector<Ref<DebugInfoParser>> DebugInfoParser::GetList()
vector<Ref<DebugInfoParser>> DebugInfoParser::GetListForView(const Ref<BinaryView> data)
{
- size_t count = 0;
+ size_t count = 0;
BNDebugInfoParser** parsers = BNGetDebugInfoParsersForView(data->GetObject(), &count);
vector<Ref<DebugInfoParser>> result;
@@ -215,7 +216,8 @@ string DebugInfoParser::GetName() const
Ref<DebugInfo> DebugInfoParser::Parse(Ref<BinaryView> view, Ref<DebugInfo> existingDebugInfo) const
{
if (existingDebugInfo)
- return new DebugInfo(BNNewDebugInfoReference(BNParseDebugInfo(m_object, view->GetObject(), existingDebugInfo->GetObject())));
+ return new DebugInfo(
+ BNNewDebugInfoReference(BNParseDebugInfo(m_object, view->GetObject(), existingDebugInfo->GetObject())));
return new DebugInfo(BNParseDebugInfo(m_object, view->GetObject(), nullptr));
}
@@ -246,4 +248,6 @@ void CustomDebugInfoParser::ParseCallback(void* ctxt, BNDebugInfo* debugInfo, BN
CustomDebugInfoParser::CustomDebugInfoParser(const string& name) :
- DebugInfoParser(BNNewDebugInfoParserReference(BNRegisterDebugInfoParser(name.c_str(), IsValidCallback, ParseCallback, this))) {}
+ DebugInfoParser(
+ BNNewDebugInfoParserReference(BNRegisterDebugInfoParser(name.c_str(), IsValidCallback, ParseCallback, this)))
+{}
diff --git a/demangle.cpp b/demangle.cpp
index 616a4b68..f79b2a7b 100644
--- a/demangle.cpp
+++ b/demangle.cpp
@@ -2,17 +2,16 @@
#include <string>
using namespace std;
-namespace BinaryNinja
-{
- bool DemangleMS(Architecture* arch, const std::string& mangledName, Type** outType,
- QualifiedName& outVarName, const Ref<BinaryView>& view)
+namespace BinaryNinja {
+ bool DemangleMS(Architecture* arch, const std::string& mangledName, Type** outType, QualifiedName& outVarName,
+ const Ref<BinaryView>& view)
{
const bool simplify = Settings::Instance()->Get<bool>("analysis.types.TemplateSimplifier", view);
return DemangleMS(arch, mangledName, outType, outVarName, simplify);
}
- bool DemangleMS(Architecture* arch, const std::string& mangledName, Type** outType,
- QualifiedName& outVarName, const bool simplify)
+ bool DemangleMS(Architecture* arch, const std::string& mangledName, Type** outType, QualifiedName& outVarName,
+ const bool simplify)
{
BNType* localType = nullptr;
char** localVarName = nullptr;
@@ -27,19 +26,19 @@ namespace BinaryNinja
outVarName.push_back(localVarName[i]);
BNFreeString(localVarName[i]);
}
- delete [] localVarName;
+ delete[] localVarName;
return true;
}
- bool DemangleGNU3(Ref<Architecture> arch, const std::string& mangledName, Type** outType,
- QualifiedName& outVarName, const Ref<BinaryView>& view)
+ bool DemangleGNU3(Ref<Architecture> arch, const std::string& mangledName, Type** outType, QualifiedName& outVarName,
+ const Ref<BinaryView>& view)
{
const bool simplify = Settings::Instance()->Get<bool>("analysis.types.TemplateSimplifier", view);
return DemangleGNU3(arch, mangledName, outType, outVarName, simplify);
}
- bool DemangleGNU3(Ref<Architecture> arch, const std::string& mangledName, Type** outType,
- QualifiedName& outVarName, const bool simplify)
+ bool DemangleGNU3(Ref<Architecture> arch, const std::string& mangledName, Type** outType, QualifiedName& outVarName,
+ const bool simplify)
{
BNType* localType;
char** localVarName = nullptr;
@@ -54,7 +53,7 @@ namespace BinaryNinja
outVarName.push_back(localVarName[i]);
BNFreeString(localVarName[i]);
}
- delete [] localVarName;
+ delete[] localVarName;
return true;
}
@@ -84,7 +83,7 @@ namespace BinaryNinja
SimplifyName::SimplifyName(const string& input, const SimplifierDest dest, const bool simplify) :
- m_rust_string(nullptr), m_rust_array(nullptr), m_length(0)
+ m_rust_string(nullptr), m_rust_array(nullptr), m_length(0)
{
if (dest == SimplifierDest::str)
m_rust_string = BNRustSimplifyStrToStr(input.c_str());
@@ -113,16 +112,13 @@ namespace BinaryNinja
}
- SimplifyName::operator string() const
- {
- return string(m_rust_string);
- }
+ SimplifyName::operator string() const { return string(m_rust_string); }
SimplifyName::operator QualifiedName()
{
QualifiedName result;
- uint64_t index = 0;
+ uint64_t index = 0;
while (m_rust_array[index][0] != 0x0)
{
result.push_back(string(m_rust_array[index++]));
@@ -130,4 +126,4 @@ namespace BinaryNinja
m_length = index;
return result;
}
-}
+} // namespace BinaryNinja
diff --git a/downloadprovider.cpp b/downloadprovider.cpp
index 5e0e46bd..bd99fe51 100644
--- a/downloadprovider.cpp
+++ b/downloadprovider.cpp
@@ -57,11 +57,13 @@ int DownloadInstance::PerformRequestCallback(void* ctxt, const char* url)
}
-int DownloadInstance::PerformCustomRequestCallback(void* ctxt, const char* method, const char* url, uint64_t headerCount, const char* const* headerKeys, const char* const* headerValues, BNDownloadInstanceResponse** response)
+int DownloadInstance::PerformCustomRequestCallback(void* ctxt, const char* method, const char* url,
+ uint64_t headerCount, const char* const* headerKeys, const char* const* headerValues,
+ BNDownloadInstanceResponse** response)
{
DownloadInstance* instance = (DownloadInstance*)ctxt;
unordered_map<string, string> headers;
- for (uint64_t i = 0; i < headerCount; i ++)
+ for (uint64_t i = 0; i < headerCount; i++)
{
headers[headerKeys[i]] = headerValues[i];
}
@@ -77,7 +79,7 @@ int DownloadInstance::PerformCustomRequestCallback(void* ctxt, const char* metho
{
keys[i] = BNAllocString(pair.first.c_str());
values[i] = BNAllocString(pair.second.c_str());
- i ++;
+ i++;
}
*response = new BNDownloadInstanceResponse;
@@ -92,14 +94,14 @@ int DownloadInstance::PerformCustomRequestCallback(void* ctxt, const char* metho
void DownloadInstance::PerformFreeResponse(void* ctxt, BNDownloadInstanceResponse* response)
{
- for (uint64_t i = 0; i < response->headerCount; i ++)
+ for (uint64_t i = 0; i < response->headerCount; i++)
{
BNFreeString(response->headerKeys[i]);
BNFreeString(response->headerValues[i]);
}
- delete [] response->headerKeys;
- delete [] response->headerValues;
+ delete[] response->headerKeys;
+ delete[] response->headerValues;
delete response;
}
@@ -144,7 +146,9 @@ int DownloadInstance::PerformRequest(const string& url, BNDownloadInstanceOutput
}
-int DownloadInstance::PerformCustomRequest(const string& method, const string& url, const std::unordered_map<std::string, std::string>& headers, Response& response, BNDownloadInstanceInputOutputCallbacks* callbacks)
+int DownloadInstance::PerformCustomRequest(const string& method, const string& url,
+ const std::unordered_map<std::string, std::string>& headers, Response& response,
+ BNDownloadInstanceInputOutputCallbacks* callbacks)
{
const char** headerKeys = new const char*[headers.size()];
const char** headerValues = new const char*[headers.size()];
@@ -154,23 +158,24 @@ int DownloadInstance::PerformCustomRequest(const string& method, const string& u
{
headerKeys[i] = it->first.c_str();
headerValues[i] = it->second.c_str();
- i ++;
+ i++;
}
BNDownloadInstanceResponse* bnResponse;
- int result = BNPerformCustomRequest(m_object, method.c_str(), url.c_str(), headers.size(), headerKeys, headerValues, &bnResponse, callbacks);
+ int result = BNPerformCustomRequest(
+ m_object, method.c_str(), url.c_str(), headers.size(), headerKeys, headerValues, &bnResponse, callbacks);
response.statusCode = bnResponse->statusCode;
- for (uint64_t i = 0; i < bnResponse->headerCount; i ++)
+ for (uint64_t i = 0; i < bnResponse->headerCount; i++)
{
response.headers[bnResponse->headerKeys[i]] = bnResponse->headerValues[i];
}
BNFreeDownloadInstanceResponse(bnResponse);
- delete [] headerKeys;
- delete [] headerValues;
+ delete[] headerKeys;
+ delete[] headerValues;
return result;
}
@@ -182,9 +187,7 @@ void DownloadInstance::DestroyInstance()
}
-CoreDownloadInstance::CoreDownloadInstance(BNDownloadInstance* instance): DownloadInstance(instance)
-{
-}
+CoreDownloadInstance::CoreDownloadInstance(BNDownloadInstance* instance) : DownloadInstance(instance) {}
int CoreDownloadInstance::PerformRequest(const std::string& url)
@@ -194,7 +197,8 @@ int CoreDownloadInstance::PerformRequest(const std::string& url)
}
-int CoreDownloadInstance::PerformCustomRequest(const std::string& method, const std::string& url, const std::unordered_map<std::string, std::string>& headers, Response& response)
+int CoreDownloadInstance::PerformCustomRequest(const std::string& method, const std::string& url,
+ const std::unordered_map<std::string, std::string>& headers, Response& response)
{
(void)method;
(void)url;
@@ -204,9 +208,7 @@ int CoreDownloadInstance::PerformCustomRequest(const std::string& method, const
}
-DownloadProvider::DownloadProvider(const string& name): m_nameForRegister(name)
-{
-}
+DownloadProvider::DownloadProvider(const string& name) : m_nameForRegister(name) {}
DownloadProvider::DownloadProvider(BNDownloadProvider* provider)
@@ -253,9 +255,7 @@ void DownloadProvider::Register(DownloadProvider* provider)
}
-CoreDownloadProvider::CoreDownloadProvider(BNDownloadProvider* provider): DownloadProvider(provider)
-{
-}
+CoreDownloadProvider::CoreDownloadProvider(BNDownloadProvider* provider) : DownloadProvider(provider) {}
Ref<DownloadInstance> CoreDownloadProvider::CreateNewInstance()
diff --git a/examples/bin-info/src/bin-info.cpp b/examples/bin-info/src/bin-info.cpp
index 33f84f7d..9503c734 100644
--- a/examples/bin-info/src/bin-info.cpp
+++ b/examples/bin-info/src/bin-info.cpp
@@ -16,107 +16,109 @@ using namespace BinaryNinja;
using namespace std;
#ifndef _WIN32
-#include <libgen.h>
-#include <dlfcn.h>
+ #include <libgen.h>
+ #include <dlfcn.h>
string get_plugins_directory()
{
- Dl_info info;
- if (!dladdr((void *)BNGetBundledPluginDirectory, &info))
- return NULL;
+ Dl_info info;
+ if (!dladdr((void*)BNGetBundledPluginDirectory, &info))
+ return NULL;
- stringstream ss;
- ss << dirname((char *)info.dli_fname) << "/plugins/";
- return ss.str();
+ stringstream ss;
+ ss << dirname((char*)info.dli_fname) << "/plugins/";
+ return ss.str();
}
#else
string get_plugins_directory()
{
- return "C:\\Program Files\\Vector35\\BinaryNinja\\plugins\\";
+ return "C:\\Program Files\\Vector35\\BinaryNinja\\plugins\\";
}
#endif
-bool is_file(char *fname)
+bool is_file(char* fname)
{
- struct stat buf;
- if (stat(fname, &buf) == 0 && (buf.st_mode & S_IFREG) == S_IFREG)
- return true;
+ struct stat buf;
+ if (stat(fname, &buf) == 0 && (buf.st_mode & S_IFREG) == S_IFREG)
+ return true;
- return false;
+ return false;
}
-int main(int argc, char *argv[])
+int main(int argc, char* argv[])
{
- if (argc != 2) {
- cerr << "USAGE: " << argv[0] << " <file_name>" << endl;
- exit(-1);
- }
+ if (argc != 2)
+ {
+ cerr << "USAGE: " << argv[0] << " <file_name>" << endl;
+ exit(-1);
+ }
- char *fname = argv[1];
- if (!is_file(fname)) {
- cerr << "Error: " << fname << " is not a regular file" << endl;
- exit(-1);
- }
+ char* fname = argv[1];
+ if (!is_file(fname))
+ {
+ cerr << "Error: " << fname << " is not a regular file" << endl;
+ exit(-1);
+ }
- /* In order to initiate the bundled plugins properly, the location
- * of where bundled plugins directory is must be set. Since
- * libbinaryninjacore is in the path get the path to it and use it to
- * determine the plugins directory */
- SetBundledPluginDirectory(get_plugins_directory());
- InitPlugins();
+ /* In order to initiate the bundled plugins properly, the location
+ * of where bundled plugins directory is must be set. Since
+ * libbinaryninjacore is in the path get the path to it and use it to
+ * determine the plugins directory */
+ SetBundledPluginDirectory(get_plugins_directory());
+ InitPlugins();
- Ref<BinaryData> bd = new BinaryData(new FileMetadata(), argv[1]);
- Ref<BinaryView> bv;
- for (auto type : BinaryViewType::GetViewTypes())
- {
- if (type->IsTypeValidForData(bd) && type->GetName() != "Raw")
- {
- bv = type->Create(bd);
- break;
- }
- }
+ Ref<BinaryData> bd = new BinaryData(new FileMetadata(), argv[1]);
+ Ref<BinaryView> bv;
+ for (auto type : BinaryViewType::GetViewTypes())
+ {
+ if (type->IsTypeValidForData(bd) && type->GetName() != "Raw")
+ {
+ bv = type->Create(bd);
+ break;
+ }
+ }
- if (!bv || bv->GetTypeName() == "Raw")
- {
- fprintf(stderr, "Input file does not appear to be an exectuable\n");
- return -1;
- }
+ if (!bv || bv->GetTypeName() == "Raw")
+ {
+ fprintf(stderr, "Input file does not appear to be an exectuable\n");
+ return -1;
+ }
- bv->UpdateAnalysisAndWait();
+ bv->UpdateAnalysisAndWait();
- cout << "Target: " << fname << endl << endl;
- cout << "TYPE: " << bv->GetTypeName() << endl;
- cout << "START: 0x" << hex << bv->GetStart() << endl;
- cout << "ENTRY: 0x" << hex << bv->GetEntryPoint() << endl;
- cout << "PLATFORM: " << bv->GetDefaultPlatform()->GetName() << endl;
- cout << endl;
+ cout << "Target: " << fname << endl << endl;
+ cout << "TYPE: " << bv->GetTypeName() << endl;
+ cout << "START: 0x" << hex << bv->GetStart() << endl;
+ cout << "ENTRY: 0x" << hex << bv->GetEntryPoint() << endl;
+ cout << "PLATFORM: " << bv->GetDefaultPlatform()->GetName() << endl;
+ cout << endl;
- cout << "---------- 10 Functions ----------" << endl;
- int x = 0;
- for (auto func : bv->GetAnalysisFunctionList()) {
- cout << hex << func->GetStart() << " " << func->GetSymbol()->GetFullName() << endl;
- if (++x >= 10)
- break;
- }
- cout << endl;
+ cout << "---------- 10 Functions ----------" << endl;
+ int x = 0;
+ for (auto func : bv->GetAnalysisFunctionList())
+ {
+ cout << hex << func->GetStart() << " " << func->GetSymbol()->GetFullName() << endl;
+ if (++x >= 10)
+ break;
+ }
+ cout << endl;
- cout << "---------- 10 Strings ----------" << endl;
- x = 0;
- for (auto str_ref : bv->GetStrings()) {
- char *str = (char *)malloc(str_ref.length+1);
- bv->Read(str, str_ref.start, str_ref.length);
- str[str_ref.length] = 0;
+ cout << "---------- 10 Strings ----------" << endl;
+ x = 0;
+ for (auto str_ref : bv->GetStrings())
+ {
+ char* str = (char*)malloc(str_ref.length + 1);
+ bv->Read(str, str_ref.start, str_ref.length);
+ str[str_ref.length] = 0;
- cout << hex << str_ref.start << " ("
- << dec << str_ref.length << ") "
- << str << endl;
- free(str);
+ cout << hex << str_ref.start << " (" << dec << str_ref.length << ") " << str << endl;
+ free(str);
- if (++x >= 10)
- break;
- }
+ if (++x >= 10)
+ break;
+ }
- // Shutting down is required to allow for clean exit of the core
- BNShutdown();
+ // Shutting down is required to allow for clean exit of the core
+ BNShutdown();
- return 0;
+ return 0;
}
diff --git a/examples/breakpoint/src/breakpoint.cpp b/examples/breakpoint/src/breakpoint.cpp
index 65c8d018..75156e1d 100644
--- a/examples/breakpoint/src/breakpoint.cpp
+++ b/examples/breakpoint/src/breakpoint.cpp
@@ -4,35 +4,37 @@
using namespace BinaryNinja;
using namespace std;
-void write_breakpoint(BinaryNinja::BinaryView *view, uint64_t start, uint64_t length)
+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
+ // 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();
+ 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());
- }
+ 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"
{
- BN_DECLARE_CORE_ABI_VERSION
+ BN_DECLARE_CORE_ABI_VERSION
- BINARYNINJAPLUGIN bool CorePluginInit()
- {
- // Register the plugin with Binary Ninja
- PluginCommand::RegisterForRange("Convert to breakpoint",
- "Fill region with breakpoint instructions.",
- &write_breakpoint);
- return true;
- }
+ 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
diff --git a/examples/cmdline_disasm/src/disasm.cpp b/examples/cmdline_disasm/src/disasm.cpp
index 6d350526..49d4d650 100644
--- a/examples/cmdline_disasm/src/disasm.cpp
+++ b/examples/cmdline_disasm/src/disasm.cpp
@@ -12,14 +12,14 @@
using namespace BinaryNinja;
/* forward declarations */
-int parse_nib(const char *str, uint8_t *val);
-int parse_uint8_hex(const char *str, uint8_t *result);
+int parse_nib(const char* str, uint8_t* val);
+int parse_uint8_hex(const char* str, uint8_t* result);
/******************************************************************************
MAIN
******************************************************************************/
-void usage(int ac, char **av)
+void usage(int ac, char** av)
{
(void)ac;
printf(" syntax: %s <arch+mode> <byte0> <byte1> ...\n", av[0]);
@@ -36,23 +36,23 @@ void usage(int ac, char **av)
printf(" %s mipsel32 f0 ff bd 27\n", av[0]);
}
-int main(int ac, char **av)
+int main(int ac, char** av)
{
int rc = -1;
unsigned int i;
- char *archmode;
- BNArchitecture *arch;
+ char* archmode;
+ BNArchitecture* arch;
- size_t nBytesDisasm;
+ size_t nBytesDisasm;
- uint8_t input[64];
- unsigned int input_n;
+ uint8_t input[64];
+ unsigned int input_n;
- BNInstructionTextToken *ttResult = NULL;
- size_t ttCount;
+ BNInstructionTextToken* ttResult = NULL;
+ size_t ttCount;
- char *path_bundled_plugins;
+ char* path_bundled_plugins;
/* plugin path */
path_bundled_plugins = BNGetBundledPluginDirectory();
@@ -61,13 +61,17 @@ int main(int ac, char **av)
BNInitPlugins(true);
/* parse architecture argument */
- if(ac < 2)
- { usage(ac, av); goto cleanup; }
+ if (ac < 2)
+ {
+ usage(ac, av);
+ goto cleanup;
+ }
archmode = av[1];
printf("looking up architecture \"%s\"\n", archmode);
arch = BNGetArchitectureByName(archmode);
- if(!arch) {
+ if (!arch)
+ {
printf("ERROR: BNGetArchitectureByName() (is \"%s\" valid?)\n", archmode);
usage(ac, av);
goto cleanup;
@@ -75,32 +79,33 @@ int main(int ac, char **av)
/* parse bytes argument */
input_n = ac - 2;
- for(i=0; i<input_n && i<sizeof(input); ++i) {
- if(parse_uint8_hex(av[i+2], input+i)) {
- printf("ERROR: can't parse byte: %s\n", av[i+2]);
+ for (i = 0; i < input_n && i < sizeof(input); ++i)
+ {
+ if (parse_uint8_hex(av[i + 2], input + i))
+ {
+ printf("ERROR: can't parse byte: %s\n", av[i + 2]);
goto cleanup;
}
}
printf("parsed bytes: ");
- for(i=0; i<input_n; ++i)
+ for (i = 0; i < input_n; ++i)
printf("%02X ", input[i]);
printf("\n");
/* actually disassemble now */
nBytesDisasm = input_n;
- BNGetInstructionText(arch, (const uint8_t *)input, 0, &nBytesDisasm,
- &ttResult, &ttCount);
+ BNGetInstructionText(arch, (const uint8_t*)input, 0, &nBytesDisasm, &ttResult, &ttCount);
- //printf("%zu text tokens\n", ttCount);
+ // printf("%zu text tokens\n", ttCount);
- for(i=0; i<ttCount; ++i)
+ for (i = 0; i < ttCount; ++i)
printf("%s", ttResult[i].text);
printf("\n");
- /* done! */
- cleanup:
- if(ttResult)
+/* done! */
+cleanup:
+ if (ttResult)
BNFreeInstructionText(ttResult, ttCount);
// Shutting down is required to allow for clean exit of the core
@@ -113,44 +118,47 @@ int main(int ac, char **av)
PARSING
******************************************************************************/
-int parse_nib(const char *str, uint8_t *val)
+int parse_nib(const char* str, uint8_t* val)
{
int rc = -1;
char c = *str;
- if(c>='0' && c<='9') {
- *val = c-'0';
+ if (c >= '0' && c <= '9')
+ {
+ *val = c - '0';
rc = 0;
}
- else if(c>='a' && c<='f') {
- *val = 10 + (c-'a');
+ else if (c >= 'a' && c <= 'f')
+ {
+ *val = 10 + (c - 'a');
rc = 0;
}
- else if(c>='A' && c<='F') {
- *val = 10 + (c-'A');
+ else if (c >= 'A' && c <= 'F')
+ {
+ *val = 10 + (c - 'A');
rc = 0;
}
- else {
+ else
+ {
printf("ERROR: %s('%c', ...)\n", __func__, c);
}
return rc;
}
-int parse_uint8_hex(const char *str, uint8_t *result)
+int parse_uint8_hex(const char* str, uint8_t* result)
{
- int rc=-1;
+ int rc = -1;
uint8_t v1, v2;
- if(parse_nib(str, &v1))
+ if (parse_nib(str, &v1))
goto cleanup;
- if(parse_nib(str+1, &v2))
+ if (parse_nib(str + 1, &v2))
goto cleanup;
*result = (v1 << 4) | v2;
rc = 0;
- cleanup:
+cleanup:
return rc;
}
-
diff --git a/examples/llil_parser/src/llil_parser.cpp b/examples/llil_parser/src/llil_parser.cpp
index b7c96c22..d700e7ce 100644
--- a/examples/llil_parser/src/llil_parser.cpp
+++ b/examples/llil_parser/src/llil_parser.cpp
@@ -9,16 +9,16 @@ using namespace std;
#ifndef _WIN32
-#include <libgen.h>
-#include <dlfcn.h>
+ #include <libgen.h>
+ #include <dlfcn.h>
static string GetPluginsDirectory()
{
Dl_info info;
- if (!dladdr((void *)BNGetBundledPluginDirectory, &info))
+ if (!dladdr((void*)BNGetBundledPluginDirectory, &info))
return NULL;
stringstream ss;
- ss << dirname((char *)info.dli_fname) << "/plugins/";
+ ss << dirname((char*)info.dli_fname) << "/plugins/";
return ss.str();
}
#else
@@ -45,99 +45,99 @@ static void PrintOperation(BNLowLevelILOperation operation)
switch (operation)
{
- ENUM_PRINTER(LLIL_NOP)
- ENUM_PRINTER(LLIL_SET_REG)
- ENUM_PRINTER(LLIL_SET_REG_SPLIT)
- ENUM_PRINTER(LLIL_SET_FLAG)
- ENUM_PRINTER(LLIL_LOAD)
- ENUM_PRINTER(LLIL_STORE)
- ENUM_PRINTER(LLIL_PUSH)
- ENUM_PRINTER(LLIL_POP)
- ENUM_PRINTER(LLIL_REG)
- ENUM_PRINTER(LLIL_CONST)
- ENUM_PRINTER(LLIL_CONST_PTR)
- ENUM_PRINTER(LLIL_EXTERN_PTR)
- ENUM_PRINTER(LLIL_FLAG)
- ENUM_PRINTER(LLIL_FLAG_BIT)
- ENUM_PRINTER(LLIL_ADD)
- ENUM_PRINTER(LLIL_ADC)
- ENUM_PRINTER(LLIL_SUB)
- ENUM_PRINTER(LLIL_SBB)
- ENUM_PRINTER(LLIL_AND)
- ENUM_PRINTER(LLIL_OR)
- ENUM_PRINTER(LLIL_XOR)
- ENUM_PRINTER(LLIL_LSL)
- ENUM_PRINTER(LLIL_LSR)
- ENUM_PRINTER(LLIL_ASR)
- ENUM_PRINTER(LLIL_ROL)
- ENUM_PRINTER(LLIL_RLC)
- ENUM_PRINTER(LLIL_ROR)
- ENUM_PRINTER(LLIL_RRC)
- ENUM_PRINTER(LLIL_MUL)
- ENUM_PRINTER(LLIL_MULU_DP)
- ENUM_PRINTER(LLIL_MULS_DP)
- ENUM_PRINTER(LLIL_DIVU)
- ENUM_PRINTER(LLIL_DIVU_DP)
- ENUM_PRINTER(LLIL_DIVS)
- ENUM_PRINTER(LLIL_DIVS_DP)
- ENUM_PRINTER(LLIL_MODU)
- ENUM_PRINTER(LLIL_MODU_DP)
- ENUM_PRINTER(LLIL_MODS)
- ENUM_PRINTER(LLIL_MODS_DP)
- ENUM_PRINTER(LLIL_NEG)
- ENUM_PRINTER(LLIL_NOT)
- ENUM_PRINTER(LLIL_SX)
- ENUM_PRINTER(LLIL_ZX)
- ENUM_PRINTER(LLIL_LOW_PART)
- ENUM_PRINTER(LLIL_JUMP)
- ENUM_PRINTER(LLIL_JUMP_TO)
- ENUM_PRINTER(LLIL_CALL)
- ENUM_PRINTER(LLIL_CALL_STACK_ADJUST)
- ENUM_PRINTER(LLIL_TAILCALL)
- ENUM_PRINTER(LLIL_RET)
- ENUM_PRINTER(LLIL_NORET)
- ENUM_PRINTER(LLIL_IF)
- ENUM_PRINTER(LLIL_GOTO)
- ENUM_PRINTER(LLIL_FLAG_COND)
- ENUM_PRINTER(LLIL_CMP_E)
- ENUM_PRINTER(LLIL_CMP_NE)
- ENUM_PRINTER(LLIL_CMP_SLT)
- ENUM_PRINTER(LLIL_CMP_ULT)
- ENUM_PRINTER(LLIL_CMP_SLE)
- ENUM_PRINTER(LLIL_CMP_ULE)
- ENUM_PRINTER(LLIL_CMP_SGE)
- ENUM_PRINTER(LLIL_CMP_UGE)
- ENUM_PRINTER(LLIL_CMP_SGT)
- ENUM_PRINTER(LLIL_CMP_UGT)
- ENUM_PRINTER(LLIL_TEST_BIT)
- ENUM_PRINTER(LLIL_BOOL_TO_INT)
- ENUM_PRINTER(LLIL_ADD_OVERFLOW)
- ENUM_PRINTER(LLIL_SYSCALL)
- ENUM_PRINTER(LLIL_BP)
- ENUM_PRINTER(LLIL_TRAP)
- ENUM_PRINTER(LLIL_UNDEF)
- ENUM_PRINTER(LLIL_UNIMPL)
- ENUM_PRINTER(LLIL_UNIMPL_MEM)
- ENUM_PRINTER(LLIL_SET_REG_SSA)
- ENUM_PRINTER(LLIL_SET_REG_SSA_PARTIAL)
- ENUM_PRINTER(LLIL_SET_REG_SPLIT_SSA)
- ENUM_PRINTER(LLIL_REG_SPLIT_DEST_SSA)
- ENUM_PRINTER(LLIL_REG_SSA)
- ENUM_PRINTER(LLIL_REG_SSA_PARTIAL)
- ENUM_PRINTER(LLIL_SET_FLAG_SSA)
- ENUM_PRINTER(LLIL_FLAG_SSA)
- ENUM_PRINTER(LLIL_FLAG_BIT_SSA)
- ENUM_PRINTER(LLIL_CALL_SSA)
- ENUM_PRINTER(LLIL_SYSCALL_SSA)
- ENUM_PRINTER(LLIL_TAILCALL_SSA)
- ENUM_PRINTER(LLIL_CALL_PARAM)
- ENUM_PRINTER(LLIL_CALL_STACK_SSA)
- ENUM_PRINTER(LLIL_CALL_OUTPUT_SSA)
- ENUM_PRINTER(LLIL_LOAD_SSA)
- ENUM_PRINTER(LLIL_STORE_SSA)
- ENUM_PRINTER(LLIL_REG_PHI)
- ENUM_PRINTER(LLIL_FLAG_PHI)
- ENUM_PRINTER(LLIL_MEM_PHI)
+ ENUM_PRINTER(LLIL_NOP)
+ ENUM_PRINTER(LLIL_SET_REG)
+ ENUM_PRINTER(LLIL_SET_REG_SPLIT)
+ ENUM_PRINTER(LLIL_SET_FLAG)
+ ENUM_PRINTER(LLIL_LOAD)
+ ENUM_PRINTER(LLIL_STORE)
+ ENUM_PRINTER(LLIL_PUSH)
+ ENUM_PRINTER(LLIL_POP)
+ ENUM_PRINTER(LLIL_REG)
+ ENUM_PRINTER(LLIL_CONST)
+ ENUM_PRINTER(LLIL_CONST_PTR)
+ ENUM_PRINTER(LLIL_EXTERN_PTR)
+ ENUM_PRINTER(LLIL_FLAG)
+ ENUM_PRINTER(LLIL_FLAG_BIT)
+ ENUM_PRINTER(LLIL_ADD)
+ ENUM_PRINTER(LLIL_ADC)
+ ENUM_PRINTER(LLIL_SUB)
+ ENUM_PRINTER(LLIL_SBB)
+ ENUM_PRINTER(LLIL_AND)
+ ENUM_PRINTER(LLIL_OR)
+ ENUM_PRINTER(LLIL_XOR)
+ ENUM_PRINTER(LLIL_LSL)
+ ENUM_PRINTER(LLIL_LSR)
+ ENUM_PRINTER(LLIL_ASR)
+ ENUM_PRINTER(LLIL_ROL)
+ ENUM_PRINTER(LLIL_RLC)
+ ENUM_PRINTER(LLIL_ROR)
+ ENUM_PRINTER(LLIL_RRC)
+ ENUM_PRINTER(LLIL_MUL)
+ ENUM_PRINTER(LLIL_MULU_DP)
+ ENUM_PRINTER(LLIL_MULS_DP)
+ ENUM_PRINTER(LLIL_DIVU)
+ ENUM_PRINTER(LLIL_DIVU_DP)
+ ENUM_PRINTER(LLIL_DIVS)
+ ENUM_PRINTER(LLIL_DIVS_DP)
+ ENUM_PRINTER(LLIL_MODU)
+ ENUM_PRINTER(LLIL_MODU_DP)
+ ENUM_PRINTER(LLIL_MODS)
+ ENUM_PRINTER(LLIL_MODS_DP)
+ ENUM_PRINTER(LLIL_NEG)
+ ENUM_PRINTER(LLIL_NOT)
+ ENUM_PRINTER(LLIL_SX)
+ ENUM_PRINTER(LLIL_ZX)
+ ENUM_PRINTER(LLIL_LOW_PART)
+ ENUM_PRINTER(LLIL_JUMP)
+ ENUM_PRINTER(LLIL_JUMP_TO)
+ ENUM_PRINTER(LLIL_CALL)
+ ENUM_PRINTER(LLIL_CALL_STACK_ADJUST)
+ ENUM_PRINTER(LLIL_TAILCALL)
+ ENUM_PRINTER(LLIL_RET)
+ ENUM_PRINTER(LLIL_NORET)
+ ENUM_PRINTER(LLIL_IF)
+ ENUM_PRINTER(LLIL_GOTO)
+ ENUM_PRINTER(LLIL_FLAG_COND)
+ ENUM_PRINTER(LLIL_CMP_E)
+ ENUM_PRINTER(LLIL_CMP_NE)
+ ENUM_PRINTER(LLIL_CMP_SLT)
+ ENUM_PRINTER(LLIL_CMP_ULT)
+ ENUM_PRINTER(LLIL_CMP_SLE)
+ ENUM_PRINTER(LLIL_CMP_ULE)
+ ENUM_PRINTER(LLIL_CMP_SGE)
+ ENUM_PRINTER(LLIL_CMP_UGE)
+ ENUM_PRINTER(LLIL_CMP_SGT)
+ ENUM_PRINTER(LLIL_CMP_UGT)
+ ENUM_PRINTER(LLIL_TEST_BIT)
+ ENUM_PRINTER(LLIL_BOOL_TO_INT)
+ ENUM_PRINTER(LLIL_ADD_OVERFLOW)
+ ENUM_PRINTER(LLIL_SYSCALL)
+ ENUM_PRINTER(LLIL_BP)
+ ENUM_PRINTER(LLIL_TRAP)
+ ENUM_PRINTER(LLIL_UNDEF)
+ ENUM_PRINTER(LLIL_UNIMPL)
+ ENUM_PRINTER(LLIL_UNIMPL_MEM)
+ ENUM_PRINTER(LLIL_SET_REG_SSA)
+ ENUM_PRINTER(LLIL_SET_REG_SSA_PARTIAL)
+ ENUM_PRINTER(LLIL_SET_REG_SPLIT_SSA)
+ ENUM_PRINTER(LLIL_REG_SPLIT_DEST_SSA)
+ ENUM_PRINTER(LLIL_REG_SSA)
+ ENUM_PRINTER(LLIL_REG_SSA_PARTIAL)
+ ENUM_PRINTER(LLIL_SET_FLAG_SSA)
+ ENUM_PRINTER(LLIL_FLAG_SSA)
+ ENUM_PRINTER(LLIL_FLAG_BIT_SSA)
+ ENUM_PRINTER(LLIL_CALL_SSA)
+ ENUM_PRINTER(LLIL_SYSCALL_SSA)
+ ENUM_PRINTER(LLIL_TAILCALL_SSA)
+ ENUM_PRINTER(LLIL_CALL_PARAM)
+ ENUM_PRINTER(LLIL_CALL_STACK_SSA)
+ ENUM_PRINTER(LLIL_CALL_OUTPUT_SSA)
+ ENUM_PRINTER(LLIL_LOAD_SSA)
+ ENUM_PRINTER(LLIL_STORE_SSA)
+ ENUM_PRINTER(LLIL_REG_PHI)
+ ENUM_PRINTER(LLIL_FLAG_PHI)
+ ENUM_PRINTER(LLIL_MEM_PHI)
default:
printf("<invalid operation %" PRId32 ">", operation);
break;
@@ -149,20 +149,20 @@ static void PrintFlagCondition(BNLowLevelILFlagCondition cond)
{
switch (cond)
{
- ENUM_PRINTER(LLFC_E)
- ENUM_PRINTER(LLFC_NE)
- ENUM_PRINTER(LLFC_SLT)
- ENUM_PRINTER(LLFC_ULT)
- ENUM_PRINTER(LLFC_SLE)
- ENUM_PRINTER(LLFC_ULE)
- ENUM_PRINTER(LLFC_SGE)
- ENUM_PRINTER(LLFC_UGE)
- ENUM_PRINTER(LLFC_SGT)
- ENUM_PRINTER(LLFC_UGT)
- ENUM_PRINTER(LLFC_NEG)
- ENUM_PRINTER(LLFC_POS)
- ENUM_PRINTER(LLFC_O)
- ENUM_PRINTER(LLFC_NO)
+ ENUM_PRINTER(LLFC_E)
+ ENUM_PRINTER(LLFC_NE)
+ ENUM_PRINTER(LLFC_SLT)
+ ENUM_PRINTER(LLFC_ULT)
+ ENUM_PRINTER(LLFC_SLE)
+ ENUM_PRINTER(LLFC_ULE)
+ ENUM_PRINTER(LLFC_SGE)
+ ENUM_PRINTER(LLFC_UGE)
+ ENUM_PRINTER(LLFC_SGT)
+ ENUM_PRINTER(LLFC_UGT)
+ ENUM_PRINTER(LLFC_NEG)
+ ENUM_PRINTER(LLFC_POS)
+ ENUM_PRINTER(LLFC_O)
+ ENUM_PRINTER(LLFC_NO)
default:
printf("<invalid condition>");
break;
@@ -300,7 +300,7 @@ static void PrintILExpr(const LowLevelILInstruction& instr, size_t indent)
}
-int main(int argc, char *argv[])
+int main(int argc, char* argv[])
{
if (argc != 2)
{
@@ -365,7 +365,7 @@ int main(int argc, char *argv[])
vector<InstructionTextToken> tokens;
il->GetInstructionText(func, func->GetArchitecture(), instrIndex, tokens);
printf(" %" PRIdPTR " @ 0x%" PRIx64 " ", instrIndex, instr.address);
- for (auto& token: tokens)
+ for (auto& token : tokens)
printf("%s", token.text.c_str());
printf("\n");
@@ -380,11 +380,11 @@ int main(int argc, char *argv[])
case LLIL_CONST_PTR:
case LLIL_EXTERN_PTR:
printf(" Found constant 0x%" PRIx64 "\n", expr.GetConstant());
- return false; // Done parsing this
+ return false; // Done parsing this
default:
break;
}
- return true; // Parse any subexpressions
+ return true; // Parse any subexpressions
});
// Example of using the templated accessors for efficiently parsing load instructions
@@ -395,20 +395,20 @@ int main(int argc, char *argv[])
if (expr.GetSourceExpr<LLIL_LOAD>().operation == LLIL_CONST_PTR)
{
printf(" Loading from address 0x%" PRIx64 "\n",
- expr.GetSourceExpr<LLIL_LOAD>().GetConstant<LLIL_CONST_PTR>());
- return false; // Done parsing this
+ expr.GetSourceExpr<LLIL_LOAD>().GetConstant<LLIL_CONST_PTR>());
+ return false; // Done parsing this
}
else if (expr.GetSourceExpr<LLIL_LOAD>().operation == LLIL_EXTERN_PTR)
{
printf(" Loading from address 0x%" PRIx64 "\n",
- expr.GetSourceExpr<LLIL_LOAD>().GetConstant<LLIL_EXTERN_PTR>());
- return false; // Done parsing this
+ expr.GetSourceExpr<LLIL_LOAD>().GetConstant<LLIL_EXTERN_PTR>());
+ return false; // Done parsing this
}
break;
default:
break;
}
- return true; // Parse any subexpressions
+ return true; // Parse any subexpressions
});
}
}
diff --git a/examples/mlil_parser/src/mlil_parser.cpp b/examples/mlil_parser/src/mlil_parser.cpp
index e14c9317..c31ec035 100644
--- a/examples/mlil_parser/src/mlil_parser.cpp
+++ b/examples/mlil_parser/src/mlil_parser.cpp
@@ -9,16 +9,16 @@ using namespace std;
#ifndef _WIN32
-#include <libgen.h>
-#include <dlfcn.h>
+ #include <libgen.h>
+ #include <dlfcn.h>
static string GetPluginsDirectory()
{
Dl_info info;
- if (!dladdr((void *)BNGetBundledPluginDirectory, &info))
+ if (!dladdr((void*)BNGetBundledPluginDirectory, &info))
return NULL;
stringstream ss;
- ss << dirname((char *)info.dli_fname) << "/plugins/";
+ ss << dirname((char*)info.dli_fname) << "/plugins/";
return ss.str();
}
#else
@@ -45,106 +45,106 @@ static void PrintOperation(BNMediumLevelILOperation operation)
switch (operation)
{
- ENUM_PRINTER(MLIL_NOP)
- ENUM_PRINTER(MLIL_SET_VAR)
- ENUM_PRINTER(MLIL_SET_VAR_FIELD)
- ENUM_PRINTER(MLIL_SET_VAR_SPLIT)
- ENUM_PRINTER(MLIL_LOAD)
- ENUM_PRINTER(MLIL_LOAD_STRUCT)
- ENUM_PRINTER(MLIL_STORE)
- ENUM_PRINTER(MLIL_STORE_STRUCT)
- ENUM_PRINTER(MLIL_VAR)
- ENUM_PRINTER(MLIL_VAR_FIELD)
- ENUM_PRINTER(MLIL_ADDRESS_OF)
- ENUM_PRINTER(MLIL_ADDRESS_OF_FIELD)
- ENUM_PRINTER(MLIL_CONST)
- ENUM_PRINTER(MLIL_CONST_PTR)
- ENUM_PRINTER(MLIL_EXTERN_PTR)
- ENUM_PRINTER(MLIL_ADD)
- ENUM_PRINTER(MLIL_ADC)
- ENUM_PRINTER(MLIL_SUB)
- ENUM_PRINTER(MLIL_SBB)
- ENUM_PRINTER(MLIL_AND)
- ENUM_PRINTER(MLIL_OR)
- ENUM_PRINTER(MLIL_XOR)
- ENUM_PRINTER(MLIL_LSL)
- ENUM_PRINTER(MLIL_LSR)
- ENUM_PRINTER(MLIL_ASR)
- ENUM_PRINTER(MLIL_ROL)
- ENUM_PRINTER(MLIL_RLC)
- ENUM_PRINTER(MLIL_ROR)
- ENUM_PRINTER(MLIL_RRC)
- ENUM_PRINTER(MLIL_MUL)
- ENUM_PRINTER(MLIL_MULU_DP)
- ENUM_PRINTER(MLIL_MULS_DP)
- ENUM_PRINTER(MLIL_DIVU)
- ENUM_PRINTER(MLIL_DIVU_DP)
- ENUM_PRINTER(MLIL_DIVS)
- ENUM_PRINTER(MLIL_DIVS_DP)
- ENUM_PRINTER(MLIL_MODU)
- ENUM_PRINTER(MLIL_MODU_DP)
- ENUM_PRINTER(MLIL_MODS)
- ENUM_PRINTER(MLIL_MODS_DP)
- ENUM_PRINTER(MLIL_NEG)
- ENUM_PRINTER(MLIL_NOT)
- ENUM_PRINTER(MLIL_SX)
- ENUM_PRINTER(MLIL_ZX)
- ENUM_PRINTER(MLIL_LOW_PART)
- ENUM_PRINTER(MLIL_JUMP)
- ENUM_PRINTER(MLIL_JUMP_TO)
- ENUM_PRINTER(MLIL_CALL)
- ENUM_PRINTER(MLIL_CALL_UNTYPED)
- ENUM_PRINTER(MLIL_CALL_OUTPUT)
- ENUM_PRINTER(MLIL_CALL_PARAM)
- ENUM_PRINTER(MLIL_RET)
- ENUM_PRINTER(MLIL_NORET)
- ENUM_PRINTER(MLIL_IF)
- ENUM_PRINTER(MLIL_GOTO)
- ENUM_PRINTER(MLIL_CMP_E)
- ENUM_PRINTER(MLIL_CMP_NE)
- ENUM_PRINTER(MLIL_CMP_SLT)
- ENUM_PRINTER(MLIL_CMP_ULT)
- ENUM_PRINTER(MLIL_CMP_SLE)
- ENUM_PRINTER(MLIL_CMP_ULE)
- ENUM_PRINTER(MLIL_CMP_SGE)
- ENUM_PRINTER(MLIL_CMP_UGE)
- ENUM_PRINTER(MLIL_CMP_SGT)
- ENUM_PRINTER(MLIL_CMP_UGT)
- ENUM_PRINTER(MLIL_TEST_BIT)
- ENUM_PRINTER(MLIL_BOOL_TO_INT)
- ENUM_PRINTER(MLIL_ADD_OVERFLOW)
- ENUM_PRINTER(MLIL_SYSCALL)
- ENUM_PRINTER(MLIL_SYSCALL_UNTYPED)
- ENUM_PRINTER(MLIL_TAILCALL)
- ENUM_PRINTER(MLIL_TAILCALL_UNTYPED)
- ENUM_PRINTER(MLIL_BP)
- ENUM_PRINTER(MLIL_TRAP)
- ENUM_PRINTER(MLIL_UNDEF)
- ENUM_PRINTER(MLIL_UNIMPL)
- ENUM_PRINTER(MLIL_UNIMPL_MEM)
- ENUM_PRINTER(MLIL_SET_VAR_SSA)
- ENUM_PRINTER(MLIL_SET_VAR_SSA_FIELD)
- ENUM_PRINTER(MLIL_SET_VAR_SPLIT_SSA)
- ENUM_PRINTER(MLIL_SET_VAR_ALIASED)
- ENUM_PRINTER(MLIL_SET_VAR_ALIASED_FIELD)
- ENUM_PRINTER(MLIL_VAR_SSA)
- ENUM_PRINTER(MLIL_VAR_SSA_FIELD)
- ENUM_PRINTER(MLIL_VAR_ALIASED)
- ENUM_PRINTER(MLIL_VAR_ALIASED_FIELD)
- ENUM_PRINTER(MLIL_CALL_SSA)
- ENUM_PRINTER(MLIL_CALL_UNTYPED_SSA)
- ENUM_PRINTER(MLIL_SYSCALL_SSA)
- ENUM_PRINTER(MLIL_SYSCALL_UNTYPED_SSA)
- ENUM_PRINTER(MLIL_TAILCALL_SSA)
- ENUM_PRINTER(MLIL_TAILCALL_UNTYPED_SSA)
- ENUM_PRINTER(MLIL_CALL_PARAM_SSA)
- ENUM_PRINTER(MLIL_CALL_OUTPUT_SSA)
- ENUM_PRINTER(MLIL_LOAD_SSA)
- ENUM_PRINTER(MLIL_LOAD_STRUCT_SSA)
- ENUM_PRINTER(MLIL_STORE_SSA)
- ENUM_PRINTER(MLIL_STORE_STRUCT_SSA)
- ENUM_PRINTER(MLIL_VAR_PHI)
- ENUM_PRINTER(MLIL_MEM_PHI)
+ ENUM_PRINTER(MLIL_NOP)
+ ENUM_PRINTER(MLIL_SET_VAR)
+ ENUM_PRINTER(MLIL_SET_VAR_FIELD)
+ ENUM_PRINTER(MLIL_SET_VAR_SPLIT)
+ ENUM_PRINTER(MLIL_LOAD)
+ ENUM_PRINTER(MLIL_LOAD_STRUCT)
+ ENUM_PRINTER(MLIL_STORE)
+ ENUM_PRINTER(MLIL_STORE_STRUCT)
+ ENUM_PRINTER(MLIL_VAR)
+ ENUM_PRINTER(MLIL_VAR_FIELD)
+ ENUM_PRINTER(MLIL_ADDRESS_OF)
+ ENUM_PRINTER(MLIL_ADDRESS_OF_FIELD)
+ ENUM_PRINTER(MLIL_CONST)
+ ENUM_PRINTER(MLIL_CONST_PTR)
+ ENUM_PRINTER(MLIL_EXTERN_PTR)
+ ENUM_PRINTER(MLIL_ADD)
+ ENUM_PRINTER(MLIL_ADC)
+ ENUM_PRINTER(MLIL_SUB)
+ ENUM_PRINTER(MLIL_SBB)
+ ENUM_PRINTER(MLIL_AND)
+ ENUM_PRINTER(MLIL_OR)
+ ENUM_PRINTER(MLIL_XOR)
+ ENUM_PRINTER(MLIL_LSL)
+ ENUM_PRINTER(MLIL_LSR)
+ ENUM_PRINTER(MLIL_ASR)
+ ENUM_PRINTER(MLIL_ROL)
+ ENUM_PRINTER(MLIL_RLC)
+ ENUM_PRINTER(MLIL_ROR)
+ ENUM_PRINTER(MLIL_RRC)
+ ENUM_PRINTER(MLIL_MUL)
+ ENUM_PRINTER(MLIL_MULU_DP)
+ ENUM_PRINTER(MLIL_MULS_DP)
+ ENUM_PRINTER(MLIL_DIVU)
+ ENUM_PRINTER(MLIL_DIVU_DP)
+ ENUM_PRINTER(MLIL_DIVS)
+ ENUM_PRINTER(MLIL_DIVS_DP)
+ ENUM_PRINTER(MLIL_MODU)
+ ENUM_PRINTER(MLIL_MODU_DP)
+ ENUM_PRINTER(MLIL_MODS)
+ ENUM_PRINTER(MLIL_MODS_DP)
+ ENUM_PRINTER(MLIL_NEG)
+ ENUM_PRINTER(MLIL_NOT)
+ ENUM_PRINTER(MLIL_SX)
+ ENUM_PRINTER(MLIL_ZX)
+ ENUM_PRINTER(MLIL_LOW_PART)
+ ENUM_PRINTER(MLIL_JUMP)
+ ENUM_PRINTER(MLIL_JUMP_TO)
+ ENUM_PRINTER(MLIL_CALL)
+ ENUM_PRINTER(MLIL_CALL_UNTYPED)
+ ENUM_PRINTER(MLIL_CALL_OUTPUT)
+ ENUM_PRINTER(MLIL_CALL_PARAM)
+ ENUM_PRINTER(MLIL_RET)
+ ENUM_PRINTER(MLIL_NORET)
+ ENUM_PRINTER(MLIL_IF)
+ ENUM_PRINTER(MLIL_GOTO)
+ ENUM_PRINTER(MLIL_CMP_E)
+ ENUM_PRINTER(MLIL_CMP_NE)
+ ENUM_PRINTER(MLIL_CMP_SLT)
+ ENUM_PRINTER(MLIL_CMP_ULT)
+ ENUM_PRINTER(MLIL_CMP_SLE)
+ ENUM_PRINTER(MLIL_CMP_ULE)
+ ENUM_PRINTER(MLIL_CMP_SGE)
+ ENUM_PRINTER(MLIL_CMP_UGE)
+ ENUM_PRINTER(MLIL_CMP_SGT)
+ ENUM_PRINTER(MLIL_CMP_UGT)
+ ENUM_PRINTER(MLIL_TEST_BIT)
+ ENUM_PRINTER(MLIL_BOOL_TO_INT)
+ ENUM_PRINTER(MLIL_ADD_OVERFLOW)
+ ENUM_PRINTER(MLIL_SYSCALL)
+ ENUM_PRINTER(MLIL_SYSCALL_UNTYPED)
+ ENUM_PRINTER(MLIL_TAILCALL)
+ ENUM_PRINTER(MLIL_TAILCALL_UNTYPED)
+ ENUM_PRINTER(MLIL_BP)
+ ENUM_PRINTER(MLIL_TRAP)
+ ENUM_PRINTER(MLIL_UNDEF)
+ ENUM_PRINTER(MLIL_UNIMPL)
+ ENUM_PRINTER(MLIL_UNIMPL_MEM)
+ ENUM_PRINTER(MLIL_SET_VAR_SSA)
+ ENUM_PRINTER(MLIL_SET_VAR_SSA_FIELD)
+ ENUM_PRINTER(MLIL_SET_VAR_SPLIT_SSA)
+ ENUM_PRINTER(MLIL_SET_VAR_ALIASED)
+ ENUM_PRINTER(MLIL_SET_VAR_ALIASED_FIELD)
+ ENUM_PRINTER(MLIL_VAR_SSA)
+ ENUM_PRINTER(MLIL_VAR_SSA_FIELD)
+ ENUM_PRINTER(MLIL_VAR_ALIASED)
+ ENUM_PRINTER(MLIL_VAR_ALIASED_FIELD)
+ ENUM_PRINTER(MLIL_CALL_SSA)
+ ENUM_PRINTER(MLIL_CALL_UNTYPED_SSA)
+ ENUM_PRINTER(MLIL_SYSCALL_SSA)
+ ENUM_PRINTER(MLIL_SYSCALL_UNTYPED_SSA)
+ ENUM_PRINTER(MLIL_TAILCALL_SSA)
+ ENUM_PRINTER(MLIL_TAILCALL_UNTYPED_SSA)
+ ENUM_PRINTER(MLIL_CALL_PARAM_SSA)
+ ENUM_PRINTER(MLIL_CALL_OUTPUT_SSA)
+ ENUM_PRINTER(MLIL_LOAD_SSA)
+ ENUM_PRINTER(MLIL_LOAD_STRUCT_SSA)
+ ENUM_PRINTER(MLIL_STORE_SSA)
+ ENUM_PRINTER(MLIL_STORE_STRUCT_SSA)
+ ENUM_PRINTER(MLIL_VAR_PHI)
+ ENUM_PRINTER(MLIL_MEM_PHI)
default:
printf("<invalid operation %" PRId32 ">", operation);
break;
@@ -248,7 +248,7 @@ static void PrintILExpr(const MediumLevelILInstruction& instr, size_t indent)
}
-int main(int argc, char *argv[])
+int main(int argc, char* argv[])
{
if (argc != 2)
{
@@ -313,7 +313,7 @@ int main(int argc, char *argv[])
vector<InstructionTextToken> tokens;
il->GetInstructionText(func, func->GetArchitecture(), instrIndex, tokens);
printf(" %" PRIdPTR " @ 0x%" PRIx64 " ", instrIndex, instr.address);
- for (auto& token: tokens)
+ for (auto& token : tokens)
printf("%s", token.text.c_str());
printf("\n");
@@ -336,20 +336,20 @@ int main(int argc, char *argv[])
if (expr.GetSourceExpr<MLIL_LOAD>().operation == MLIL_CONST_PTR)
{
printf(" Loading from address 0x%" PRIx64 "\n",
- expr.GetSourceExpr<MLIL_LOAD>().GetConstant<MLIL_CONST_PTR>());
- return false; // Done parsing this
+ expr.GetSourceExpr<MLIL_LOAD>().GetConstant<MLIL_CONST_PTR>());
+ return false; // Done parsing this
}
else if (expr.GetSourceExpr<MLIL_LOAD>().operation == MLIL_EXTERN_PTR)
{
printf(" Loading from address 0x%" PRIx64 "\n",
- expr.GetSourceExpr<MLIL_LOAD>().GetConstant<MLIL_EXTERN_PTR>());
- return false; // Done parsing this
+ expr.GetSourceExpr<MLIL_LOAD>().GetConstant<MLIL_EXTERN_PTR>());
+ return false; // Done parsing this
}
break;
default:
break;
}
- return true; // Parse any subexpressions
+ return true; // Parse any subexpressions
});
}
}
diff --git a/examples/print_syscalls/src/arm-syscall.cpp b/examples/print_syscalls/src/arm-syscall.cpp
index e291f30a..e74f8324 100644
--- a/examples/print_syscalls/src/arm-syscall.cpp
+++ b/examples/print_syscalls/src/arm-syscall.cpp
@@ -15,105 +15,106 @@ using namespace BinaryNinja;
using namespace std;
#ifndef _WIN32
-#include <libgen.h>
-#include <dlfcn.h>
+ #include <libgen.h>
+ #include <dlfcn.h>
string get_plugins_directory()
{
- Dl_info info;
- if (!dladdr((void *)BNGetBundledPluginDirectory, &info))
- return NULL;
+ Dl_info info;
+ if (!dladdr((void*)BNGetBundledPluginDirectory, &info))
+ return NULL;
- stringstream ss;
- ss << dirname((char *)info.dli_fname) << "/plugins/";
- return ss.str();
+ stringstream ss;
+ ss << dirname((char*)info.dli_fname) << "/plugins/";
+ return ss.str();
}
#else
string get_plugins_directory()
{
- return "C:\\Program Files\\Vector35\\BinaryNinja\\plugins\\";
+ return "C:\\Program Files\\Vector35\\BinaryNinja\\plugins\\";
}
#endif
-bool is_file(char *fname)
+bool is_file(char* fname)
{
- struct stat buf;
- if (stat(fname, &buf) == 0 && (buf.st_mode & S_IFREG) == S_IFREG)
- return true;
+ struct stat buf;
+ if (stat(fname, &buf) == 0 && (buf.st_mode & S_IFREG) == S_IFREG)
+ return true;
- return false;
+ return false;
}
-int main(int argc, char *argv[])
+int main(int argc, char* argv[])
{
- if (argc != 2) {
- cerr << "USAGE: " << argv[0] << " <file_name>" << endl;
- exit(-1);
- }
+ if (argc != 2)
+ {
+ cerr << "USAGE: " << argv[0] << " <file_name>" << endl;
+ exit(-1);
+ }
- char *fname = argv[1];
- if (!is_file(fname)) {
- cerr << "Error: " << fname << " is not a regular file" << endl;
- exit(-1);
- }
+ char* fname = argv[1];
+ if (!is_file(fname))
+ {
+ cerr << "Error: " << fname << " is not a regular file" << endl;
+ exit(-1);
+ }
- /* In order to initiate the bundled plugins properly, the location
- * of where bundled plugins directory is must be set. Since
- * libbinaryninjacore is in the path get the path to it and use it to
- * determine the plugins directory */
- SetBundledPluginDirectory(get_plugins_directory());
- InitPlugins();
+ /* In order to initiate the bundled plugins properly, the location
+ * of where bundled plugins directory is must be set. Since
+ * libbinaryninjacore is in the path get the path to it and use it to
+ * determine the plugins directory */
+ SetBundledPluginDirectory(get_plugins_directory());
+ InitPlugins();
- Ref<BinaryData> bd = new BinaryData(new FileMetadata(), argv[1]);
- Ref<BinaryView> bv;
- for (auto type : BinaryViewType::GetViewTypes())
- {
- if (type->IsTypeValidForData(bd) && type->GetName() != "Raw")
- {
- bv = type->Create(bd);
- break;
- }
- }
+ Ref<BinaryData> bd = new BinaryData(new FileMetadata(), argv[1]);
+ Ref<BinaryView> bv;
+ for (auto type : BinaryViewType::GetViewTypes())
+ {
+ if (type->IsTypeValidForData(bd) && type->GetName() != "Raw")
+ {
+ bv = type->Create(bd);
+ break;
+ }
+ }
- if (!bv || bv->GetTypeName() == "Raw")
- {
- fprintf(stderr, "Input file does not appear to be an exectuable\n");
- return -1;
- }
+ if (!bv || bv->GetTypeName() == "Raw")
+ {
+ fprintf(stderr, "Input file does not appear to be an exectuable\n");
+ return -1;
+ }
- bv->UpdateAnalysisAndWait();
+ bv->UpdateAnalysisAndWait();
- auto arch = bv->GetDefaultArchitecture();
- auto platform = bv->GetDefaultPlatform();
+ auto arch = bv->GetDefaultArchitecture();
+ auto platform = bv->GetDefaultPlatform();
- auto cc = platform->GetSystemCallConvention();
- if (!cc) {
- cerr << "Error: No system call conventions found for "
- << platform->GetName() << endl;
- exit(-1);
- }
+ auto cc = platform->GetSystemCallConvention();
+ if (!cc)
+ {
+ cerr << "Error: No system call conventions found for " << platform->GetName() << endl;
+ exit(-1);
+ }
- auto reg = cc->GetIntegerArgumentRegisters()[0];
+ auto reg = cc->GetIntegerArgumentRegisters()[0];
- for (Function *func : bv->GetAnalysisFunctionList()) {
- auto il_func = func->GetLowLevelIL();
+ for (Function* func : bv->GetAnalysisFunctionList())
+ {
+ auto il_func = func->GetLowLevelIL();
- for (size_t i = 0; i < il_func->GetInstructionCount(); i++) {
- auto instr = (*il_func)[il_func->GetIndexForInstruction(i)];
+ for (size_t i = 0; i < il_func->GetInstructionCount(); i++)
+ {
+ auto instr = (*il_func)[il_func->GetIndexForInstruction(i)];
- if (instr.operation == LLIL_SYSCALL) {
- auto reg_value = il_func->GetRegisterValueAtInstruction(reg, i);
+ if (instr.operation == LLIL_SYSCALL)
+ {
+ auto reg_value = il_func->GetRegisterValueAtInstruction(reg, i);
- cout << "System call address: 0x"
- << hex << instr.address
- << " - "
- << dec << reg_value.value
- << endl;
- }
- }
- }
+ cout << "System call address: 0x" << hex << instr.address << " - " << dec << reg_value.value << endl;
+ }
+ }
+ }
- // Shutting down is required to allow for clean exit of the core
- BNShutdown();
+ // Shutting down is required to allow for clean exit of the core
+ BNShutdown();
- return 0;
+ return 0;
}
diff --git a/examples/triage/byte.cpp b/examples/triage/byte.cpp
index be25368a..b6318d1e 100644
--- a/examples/triage/byte.cpp
+++ b/examples/triage/byte.cpp
@@ -5,28 +5,21 @@
#include "theme.h"
-static const char* g_byteMapping[] =
-{
- " ", "☺", "☻", "♥", "♦", "♣", "♠", "•", "◘", "○", "◙", "♂", "♀", "♪", "♫", "☼",
- "▸", "◂", "↕", "‼", "¶", "§", "▬", "↨", "↑", "↓", "→", "←", "∟", "↔", "▴", "▾",
- " ", "!", "\"", "#", "$", "%", "&", "'", "(", ")", "*", "+", ",", "-", ".", "/",
- "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ":", ";", "<", "=", ">", "?",
- "@", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O",
- "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "[", "\\", "]", "^", "_",
- "`", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o",
- "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "{", "|", "}", "~", "⌂",
- "Ç", "ü", "é", "â", "ä", "à", "å", "ç", "ê", "ë", "è", "ï", "î", "ì", "Ä", "Å",
- "É", "æ", "Æ", "ô", "ö", "ò", "û", "ù", "ÿ", "Ö", "Ü", "¢", "£", "¥", "₧", "ƒ",
- "á", "í", "ó", "ú", "ñ", "Ñ", "ª", "º", "¿", "⌐", "¬", "½", "¼", "¡", "«", "»",
- "░", "▒", "▓", "│", "┤", "╡", "╢", "╖", "╕", "╣", "║", "╗", "╝", "╜", "╛", "┐",
- "└", "┴", "┬", "├", "─", "┼", "╞", "╟", "╚", "╔", "╩", "╦", "╠", "═", "╬", "╧",
- "╨", "╤", "╥", "╙", "╘", "╒", "╓", "╫", "╪", "┘", "┌", "█", "▄", "▌", "▐", "▀",
- "α", "ß", "Γ", "π", "Σ", "σ", "µ", "τ", "Φ", "Θ", "Ω", "δ", "∞", "φ", "ε", "∩",
- "≡", "±", "≥", "≤", "⌠", "⌡", "÷", "≈", "°", "∙", "·", "√", "ⁿ", "²", "■", " "
-};
+static const char* g_byteMapping[] = {" ", "☺", "☻", "♥", "♦", "♣", "♠", "•", "◘", "○", "◙", "♂", "♀", "♪", "♫", "☼",
+ "▸", "◂", "↕", "‼", "¶", "§", "▬", "↨", "↑", "↓", "→", "←", "∟", "↔", "▴", "▾", " ", "!", "\"", "#", "$", "%", "&",
+ "'", "(", ")", "*", "+", ",", "-", ".", "/", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ":", ";", "<", "=",
+ ">", "?", "@", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T",
+ "U", "V", "W", "X", "Y", "Z", "[", "\\", "]", "^", "_", "`", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k",
+ "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "{", "|", "}", "~", "⌂", "Ç", "ü", "é",
+ "â", "ä", "à", "å", "ç", "ê", "ë", "è", "ï", "î", "ì", "Ä", "Å", "É", "æ", "Æ", "ô", "ö", "ò", "û", "ù", "ÿ", "Ö",
+ "Ü", "¢", "£", "¥", "₧", "ƒ", "á", "í", "ó", "ú", "ñ", "Ñ", "ª", "º", "¿", "⌐", "¬", "½", "¼", "¡", "«", "»", "░",
+ "▒", "▓", "│", "┤", "╡", "╢", "╖", "╕", "╣", "║", "╗", "╝", "╜", "╛", "┐", "└", "┴", "┬", "├", "─", "┼", "╞", "╟",
+ "╚", "╔", "╩", "╦", "╠", "═", "╬", "╧", "╨", "╤", "╥", "╙", "╘", "╒", "╓", "╫", "╪", "┘", "┌", "█", "▄", "▌", "▐",
+ "▀", "α", "ß", "Γ", "π", "Σ", "σ", "µ", "τ", "Φ", "Θ", "Ω", "δ", "∞", "φ", "ε", "∩", "≡", "±", "≥", "≤", "⌠", "⌡",
+ "÷", "≈", "°", "∙", "·", "√", "ⁿ", "²", "■", " "};
-ByteView::ByteView(QWidget* parent, BinaryViewRef data): QAbstractScrollArea(parent), m_render(this)
+ByteView::ByteView(QWidget* parent, BinaryViewRef data) : QAbstractScrollArea(parent), m_render(this)
{
setBinaryDataNavigable(true);
setupView(this);
@@ -72,7 +65,7 @@ ByteView::ByteView(QWidget* parent, BinaryViewRef data): QAbstractScrollArea(par
m_updateTimer = new QTimer(this);
m_updateTimer->setInterval(200);
m_updateTimer->setSingleShot(false);
- //connect(m_updateTimer, &QTimer::timeout, this, &ByteView::updateTimerEvent);
+ // connect(m_updateTimer, &QTimer::timeout, this, &ByteView::updateTimerEvent);
actionHandler()->bindAction("Move Cursor Up", UIAction([=]() { up(false); }));
actionHandler()->bindAction("Move Cursor Down", UIAction([=]() { down(false); }));
@@ -155,7 +148,7 @@ BNAddressRange ByteView::getSelectionOffsets()
start = end;
end = t;
}
- return { start, end };
+ return {start, end};
}
void ByteView::setSelectionOffsets(BNAddressRange range)
@@ -169,11 +162,11 @@ void ByteView::updateRanges()
{
m_ranges = m_data->GetAllocatedRanges();
// Remove regions not backed by the file
- for (auto& i: m_data->GetSegments())
+ for (auto& i : m_data->GetSegments())
if (i->GetDataLength() < i->GetLength())
removeRange(i->GetStart() + i->GetDataLength(), i->GetEnd());
m_allocatedLength = 0;
- for (auto& i: m_ranges)
+ for (auto& i : m_ranges)
m_allocatedLength += i.end - i.start;
}
@@ -181,7 +174,7 @@ void ByteView::updateRanges()
void ByteView::removeRange(uint64_t begin, uint64_t end)
{
std::vector<BNAddressRange> newRanges;
- for (auto& i: m_ranges)
+ for (auto& i : m_ranges)
{
if ((end <= i.start) || (begin >= i.end))
{
@@ -193,16 +186,16 @@ void ByteView::removeRange(uint64_t begin, uint64_t end)
}
else if ((begin <= i.start) && (end < i.end))
{
- newRanges.push_back(BNAddressRange { end, i.end });
+ newRanges.push_back(BNAddressRange {end, i.end});
}
else if ((begin > i.start) && (end >= i.end))
{
- newRanges.push_back(BNAddressRange { i.start, begin });
+ newRanges.push_back(BNAddressRange {i.start, begin});
}
else
{
- newRanges.push_back(BNAddressRange { i.start, begin });
- newRanges.push_back(BNAddressRange { end, i.end });
+ newRanges.push_back(BNAddressRange {i.start, begin});
+ newRanges.push_back(BNAddressRange {end, i.end});
}
}
m_ranges = newRanges;
@@ -211,7 +204,7 @@ void ByteView::removeRange(uint64_t begin, uint64_t end)
void ByteView::setTopToAddress(uint64_t addr)
{
- for (auto& i: m_ranges)
+ for (auto& i : m_ranges)
{
if ((addr >= i.start) && (addr <= i.end))
{
@@ -237,7 +230,7 @@ bool ByteView::navigate(uint64_t addr)
if (addr > getEnd())
return false;
m_cursorAddr = getStart();
- for (auto& i: m_ranges)
+ for (auto& i : m_ranges)
{
if (i.start > addr)
break;
@@ -293,7 +286,7 @@ void ByteView::adjustSize(int width, int height)
uint64_t ByteView::getContiguousOffsetForAddress(uint64_t addr)
{
uint64_t offset = 0;
- for (auto& i: m_ranges)
+ for (auto& i : m_ranges)
{
if ((addr >= i.start) && (addr <= i.end))
{
@@ -309,7 +302,7 @@ uint64_t ByteView::getContiguousOffsetForAddress(uint64_t addr)
uint64_t ByteView::getAddressForContiguousOffset(uint64_t offset)
{
uint64_t cur = 0;
- for (auto& i: m_ranges)
+ for (auto& i : m_ranges)
{
if (offset < (cur + (i.end - i.start)))
return i.start + (offset - cur);
@@ -352,7 +345,7 @@ ByteViewLine ByteView::createLine(uint64_t addr, size_t length, bool separator)
{
if (separator)
{
- return ByteViewLine { addr, length, "", true };
+ return ByteViewLine {addr, length, "", true};
}
else
{
@@ -360,7 +353,7 @@ ByteViewLine ByteView::createLine(uint64_t addr, size_t length, bool separator)
QString line;
for (size_t i = 0; i < data.GetLength(); i++)
line.append(QString(g_byteMapping[data[i]]));
- return ByteViewLine { addr, length, line, false };
+ return ByteViewLine {addr, length, line, false};
}
}
@@ -369,7 +362,7 @@ bool ByteView::cachePreviousLines()
{
bool prevEndValid = false;
uint64_t prevEnd = 0;
- for (auto& i: m_ranges)
+ for (auto& i : m_ranges)
{
if ((m_topAddr > i.start) && (m_topAddr <= i.end))
{
@@ -410,7 +403,7 @@ bool ByteView::cachePreviousLines()
bool ByteView::cacheNextLines()
{
uint64_t lastAddr = m_data->GetStart();
- for (auto& i: m_ranges)
+ for (auto& i : m_ranges)
{
if ((m_bottomAddr >= i.start) && (m_bottomAddr < i.end))
{
@@ -519,8 +512,8 @@ void ByteView::repositionCaret()
bool found = false;
for (size_t i = 0; i < m_lines.size(); i++)
{
- if (((m_cursorAddr >= m_lines[i].address) && (m_cursorAddr < (m_lines[i].address + m_lines[i].length))) ||
- (((i + 1) == m_lines.size()) && (m_cursorAddr == (m_lines[i].address + m_lines[i].length))))
+ if (((m_cursorAddr >= m_lines[i].address) && (m_cursorAddr < (m_lines[i].address + m_lines[i].length)))
+ || (((i + 1) == m_lines.size()) && (m_cursorAddr == (m_lines[i].address + m_lines[i].length))))
{
if (i < m_topLine)
m_topLine = i;
@@ -557,11 +550,11 @@ void ByteView::updateCaret()
// Rerender both the old caret position and the new caret position
for (size_t i = m_topLine; (i < m_lines.size()) && (i < (m_topLine + m_visibleRows)); i++)
{
- if (((m_prevCursorAddr >= m_lines[i].address) && (m_prevCursorAddr <= (m_lines[i].address + m_lines[i].length))) ||
- ((m_cursorAddr >= m_lines[i].address) && (m_cursorAddr <= (m_lines[i].address + m_lines[i].length))))
+ if (((m_prevCursorAddr >= m_lines[i].address) && (m_prevCursorAddr <= (m_lines[i].address + m_lines[i].length)))
+ || ((m_cursorAddr >= m_lines[i].address) && (m_cursorAddr <= (m_lines[i].address + m_lines[i].length))))
{
- viewport()->update(0, (int)(i - m_topLine) * m_render.getFontHeight(),
- viewport()->size().width(), m_render.getFontHeight() + 3);
+ viewport()->update(0, (int)(i - m_topLine) * m_render.getFontHeight(), viewport()->size().width(),
+ m_render.getFontHeight() + 3);
}
}
}
@@ -628,22 +621,22 @@ void ByteView::paintEvent(QPaintEvent* event)
if (startY == endY)
{
p.drawRect(2 + ((int)m_addrWidth + 2 + startX) * charWidth, 2 + startY * charHeight,
- (endX - startX) * charWidth, charHeight + 1);
+ (endX - startX) * charWidth, charHeight + 1);
}
else
{
p.drawRect(2 + ((int)m_addrWidth + 2 + startX) * charWidth, 2 + startY * charHeight,
- ((int)m_cols - startX) * charWidth, charHeight + 1);
+ ((int)m_cols - startX) * charWidth, charHeight + 1);
if (endX > 0)
{
- p.drawRect(2 + ((int)m_addrWidth + 2) * charWidth, 2 + endY * charHeight,
- endX * charWidth, charHeight + 1);
+ p.drawRect(2 + ((int)m_addrWidth + 2) * charWidth, 2 + endY * charHeight, endX * charWidth,
+ charHeight + 1);
}
}
if ((endY - startY) > 1)
{
p.drawRect(2 + ((int)m_addrWidth + 2) * charWidth, 2 + (startY + 1) * charHeight,
- (int)m_cols * charWidth, ((endY - startY) - 1) * charHeight + 1);
+ (int)m_cols * charWidth, ((endY - startY) - 1) * charHeight + 1);
}
}
}
@@ -658,8 +651,8 @@ void ByteView::paintEvent(QPaintEvent* event)
break;
if (m_lines[y + m_topLine].separator)
{
- m_render.drawLinearDisassemblyLineBackground(p, NonContiguousSeparatorLineType,
- QRect(0, 2 + y * charHeight, event->rect().width(), charHeight), 0);
+ m_render.drawLinearDisassemblyLineBackground(
+ p, NonContiguousSeparatorLineType, QRect(0, 2 + y * charHeight, event->rect().width(), charHeight), 0);
continue;
}
@@ -670,8 +663,8 @@ void ByteView::paintEvent(QPaintEvent* event)
bool hasCursor = false;
int cursorCol = 0;
- if (((m_cursorAddr >= lineStartAddr) && (m_cursorAddr < (lineStartAddr + length))) ||
- (((y + (int)m_topLine + 1) >= (int)m_lines.size()) && (m_cursorAddr == (lineStartAddr + length))))
+ if (((m_cursorAddr >= lineStartAddr) && (m_cursorAddr < (lineStartAddr + length)))
+ || (((y + (int)m_topLine + 1) >= (int)m_lines.size()) && (m_cursorAddr == (lineStartAddr + length))))
{
cursorCol = (int)(m_cursorAddr - lineStartAddr);
hasCursor = true;
@@ -684,13 +677,15 @@ void ByteView::paintEvent(QPaintEvent* event)
{
p.setPen(Qt::NoPen);
p.setBrush(palette().color(QPalette::WindowText));
- p.drawRect(2 + ((int)m_addrWidth + 2 + cursorCol) * charWidth, 2 + y * charHeight, charWidth, charHeight + 1);
+ p.drawRect(
+ 2 + ((int)m_addrWidth + 2 + cursorCol) * charWidth, 2 + y * charHeight, charWidth, charHeight + 1);
QColor caretTextColor = palette().color(QPalette::Base);
BinaryNinja::DataBuffer byteValue = m_data->ReadBuffer(lineStartAddr + cursorCol, 1);
if (byteValue.GetLength() == 1)
{
QString byteStr = g_byteMapping[byteValue[0]];
- m_render.drawText(p, 2 + ((int)m_addrWidth + 2 + cursorCol) * charWidth, 2 + y * charHeight, caretTextColor, byteStr);
+ m_render.drawText(
+ p, 2 + ((int)m_addrWidth + 2 + cursorCol) * charWidth, 2 + y * charHeight, caretTextColor, byteStr);
}
}
}
@@ -699,7 +694,7 @@ void ByteView::paintEvent(QPaintEvent* event)
void ByteView::wheelEvent(QWheelEvent* event)
{
- if (event->angleDelta().x()) // ignore horizontal scrolling
+ if (event->angleDelta().x()) // ignore horizontal scrolling
return;
m_wheelDelta -= event->angleDelta().y();
@@ -796,7 +791,7 @@ void ByteView::focusOutEvent(QFocusEvent*)
void ByteView::selectNone()
{
- for (auto& i: m_lines)
+ for (auto& i : m_lines)
{
if ((m_cursorAddr >= i.address) && (m_cursorAddr < (i.address + i.length)) && i.separator)
{
@@ -825,7 +820,7 @@ void ByteView::selectAll()
void ByteView::adjustAddressAfterBackwardMovement()
{
uint64_t lastAddr = getStart();
- for (auto& i: m_ranges)
+ for (auto& i : m_ranges)
{
if ((m_cursorAddr >= i.start) && (m_cursorAddr < i.end))
break;
@@ -841,7 +836,7 @@ void ByteView::adjustAddressAfterBackwardMovement()
void ByteView::adjustAddressAfterForwardMovement()
{
- for (auto& i: m_ranges)
+ for (auto& i : m_ranges)
{
if ((m_cursorAddr >= i.start) && (m_cursorAddr < i.end))
break;
@@ -900,8 +895,8 @@ void ByteView::pageUp(bool selecting)
{
for (size_t i = 0; i < m_lines.size(); i++)
{
- if (((m_cursorAddr >= m_lines[i].address) && (m_cursorAddr < (m_lines[i].address + m_lines[i].length))) ||
- (((i + 1) == m_lines.size()) && (m_cursorAddr == (m_lines[i].address + m_lines[i].length))))
+ if (((m_cursorAddr >= m_lines[i].address) && (m_cursorAddr < (m_lines[i].address + m_lines[i].length)))
+ || (((i + 1) == m_lines.size()) && (m_cursorAddr == (m_lines[i].address + m_lines[i].length))))
{
if (i < m_visibleRows)
{
@@ -942,8 +937,8 @@ void ByteView::pageDown(bool selecting)
{
for (size_t i = 0; i < m_lines.size(); i++)
{
- if (((m_cursorAddr >= m_lines[i].address) && (m_cursorAddr < (m_lines[i].address + m_lines[i].length))) ||
- (((i + 1) == m_lines.size()) && (m_cursorAddr == (m_lines[i].address + m_lines[i].length))))
+ if (((m_cursorAddr >= m_lines[i].address) && (m_cursorAddr < (m_lines[i].address + m_lines[i].length)))
+ || (((i + 1) == m_lines.size()) && (m_cursorAddr == (m_lines[i].address + m_lines[i].length))))
{
if (i >= (m_lines.size() - m_visibleRows))
{
@@ -982,7 +977,7 @@ void ByteView::pageDown(bool selecting)
void ByteView::moveToStartOfLine(bool selecting)
{
- for (auto& i: m_lines)
+ for (auto& i : m_lines)
{
if ((m_cursorAddr >= i.address) && (m_cursorAddr < (i.address + i.length)))
{
@@ -1000,7 +995,7 @@ void ByteView::moveToStartOfLine(bool selecting)
void ByteView::moveToEndOfLine(bool selecting)
{
- for (auto& i: m_lines)
+ for (auto& i : m_lines)
{
if ((m_cursorAddr >= i.address) && (m_cursorAddr < (i.address + i.length)))
{
@@ -1095,9 +1090,7 @@ void ByteView::mouseMoveEvent(QMouseEvent* event)
}
-ByteViewType::ByteViewType(): ViewType("Bytes", "Byte Overview")
-{
-}
+ByteViewType::ByteViewType() : ViewType("Bytes", "Byte Overview") {}
int ByteViewType::getPriority(BinaryViewRef, const QString&)
diff --git a/examples/triage/byte.h b/examples/triage/byte.h
index 61cb51a4..1c8c20f8 100644
--- a/examples/triage/byte.h
+++ b/examples/triage/byte.h
@@ -14,7 +14,7 @@ struct ByteViewLine
};
-class ByteView: public QAbstractScrollArea, public View
+class ByteView : public QAbstractScrollArea, public View
{
BinaryViewRef m_data;
RenderContext m_render;
@@ -76,7 +76,7 @@ class ByteView: public QAbstractScrollArea, public View
uint64_t addressFromLocation(int x, int y);
-public:
+ public:
ByteView(QWidget* parent, BinaryViewRef data);
virtual BinaryViewRef getData() override;
@@ -93,7 +93,7 @@ public:
uint64_t getEnd();
uint64_t getLength();
-protected:
+ protected:
virtual void resizeEvent(QResizeEvent* event) override;
virtual void paintEvent(QPaintEvent* event) override;
virtual void wheelEvent(QWheelEvent* event) override;
@@ -102,16 +102,16 @@ protected:
virtual void mousePressEvent(QMouseEvent* event) override;
virtual void mouseMoveEvent(QMouseEvent* event) override;
-private Q_SLOTS:
+ private Q_SLOTS:
void scrollBarMoved(int value);
void scrollBarAction(int action);
void cursorTimerEvent();
};
-class ByteViewType: public ViewType
+class ByteViewType : public ViewType
{
-public:
+ public:
ByteViewType();
virtual int getPriority(BinaryViewRef data, const QString& filename) override;
virtual QWidget* create(BinaryViewRef data, ViewFrame* frame) override;
diff --git a/examples/triage/entropy.cpp b/examples/triage/entropy.cpp
index 72ca0a92..b43350cd 100644
--- a/examples/triage/entropy.cpp
+++ b/examples/triage/entropy.cpp
@@ -30,7 +30,8 @@ void EntropyThread::Run()
{
if (!m_running)
break;
- std::vector<float> entropy = m_data->GetEntropy(m_data->GetStart() + ((uint64_t)i * m_blockSize), m_blockSize, m_blockSize);
+ std::vector<float> entropy =
+ m_data->GetEntropy(m_data->GetStart() + ((uint64_t)i * m_blockSize), m_blockSize, m_blockSize);
int v;
if (entropy.size() == 0)
v = 0;
@@ -53,7 +54,7 @@ void EntropyThread::Run()
}
-EntropyWidget::EntropyWidget(QWidget* parent, TriageView* view, BinaryViewRef data): QWidget(parent)
+EntropyWidget::EntropyWidget(QWidget* parent, TriageView* view, BinaryViewRef data) : QWidget(parent)
{
m_view = view;
m_data = data;
diff --git a/examples/triage/entropy.h b/examples/triage/entropy.h
index eb75cfee..a48097c4 100644
--- a/examples/triage/entropy.h
+++ b/examples/triage/entropy.h
@@ -14,7 +14,7 @@ class EntropyThread
bool m_updated, m_running;
std::thread m_thread;
-public:
+ public:
EntropyThread(BinaryViewRef data, size_t blockSize, QImage* image);
~EntropyThread();
@@ -26,7 +26,7 @@ public:
class TriageView;
-class EntropyWidget: public QWidget
+class EntropyWidget : public QWidget
{
TriageView* m_view;
BinaryViewRef m_data, m_rawData;
@@ -35,16 +35,16 @@ class EntropyWidget: public QWidget
QImage m_image;
EntropyThread* m_thread;
-public:
+ public:
EntropyWidget(QWidget* parent, TriageView* view, BinaryViewRef data);
virtual ~EntropyWidget();
virtual QSize sizeHint() const override;
-protected:
+ protected:
virtual void paintEvent(QPaintEvent* event) override;
virtual void mousePressEvent(QMouseEvent* event) override;
-private Q_SLOTS:
+ private Q_SLOTS:
void timerExpired();
};
diff --git a/examples/triage/exports.cpp b/examples/triage/exports.cpp
index bc5b970e..5ad63613 100644
--- a/examples/triage/exports.cpp
+++ b/examples/triage/exports.cpp
@@ -12,12 +12,12 @@ GenericExportsModel::GenericExportsModel(BinaryViewRef data)
m_totalCols = 2;
m_sortCol = 0;
m_sortOrder = Qt::AscendingOrder;
- for (auto& sym: data->GetSymbolsOfType(FunctionSymbol))
+ for (auto& sym : data->GetSymbolsOfType(FunctionSymbol))
{
if ((sym->GetBinding() == GlobalBinding) || (sym->GetBinding() == WeakBinding))
m_allEntries.push_back(sym);
}
- for (auto& sym: data->GetSymbolsOfType(DataSymbol))
+ for (auto& sym : data->GetSymbolsOfType(DataSymbol))
{
if ((sym->GetBinding() == GlobalBinding) || (sym->GetBinding() == WeakBinding))
m_allEntries.push_back(sym);
@@ -148,7 +148,7 @@ void GenericExportsModel::setFilter(const std::string& filterText)
{
beginResetModel();
m_entries.clear();
- for (auto& entry: m_allEntries)
+ for (auto& entry : m_allEntries)
{
if (FilteredView::match(entry->GetFullName(), filterText))
m_entries.push_back(entry);
@@ -158,7 +158,7 @@ void GenericExportsModel::setFilter(const std::string& filterText)
}
-ExportsTreeView::ExportsTreeView(ExportsWidget* parent, TriageView* view, BinaryViewRef data): QTreeView(parent)
+ExportsTreeView::ExportsTreeView(ExportsWidget* parent, TriageView* view, BinaryViewRef data) : QTreeView(parent)
{
m_data = data;
m_parent = parent;
@@ -262,7 +262,7 @@ void ExportsTreeView::keyPressEvent(QKeyEvent* event)
}
-ExportsWidget::ExportsWidget(QWidget* parent, TriageView* view, BinaryViewRef data): QWidget(parent)
+ExportsWidget::ExportsWidget(QWidget* parent, TriageView* view, BinaryViewRef data) : QWidget(parent)
{
QVBoxLayout* layout = new QVBoxLayout();
layout->setContentsMargins(0, 0, 0, 0);
diff --git a/examples/triage/exports.h b/examples/triage/exports.h
index e79fe7eb..bb0c4411 100644
--- a/examples/triage/exports.h
+++ b/examples/triage/exports.h
@@ -5,7 +5,7 @@
#include "filter.h"
-class GenericExportsModel: public QAbstractItemModel
+class GenericExportsModel : public QAbstractItemModel
{
std::vector<SymbolRef> m_allEntries, m_entries;
int m_addrCol, m_nameCol, m_ordinalCol;
@@ -14,7 +14,7 @@ class GenericExportsModel: public QAbstractItemModel
void performSort(int col, Qt::SortOrder order);
-public:
+ public:
GenericExportsModel(BinaryViewRef data);
virtual int columnCount(const QModelIndex& parent) const override;
@@ -36,7 +36,7 @@ public:
class TriageView;
class ExportsWidget;
-class ExportsTreeView: public QTreeView, public FilterTarget
+class ExportsTreeView : public QTreeView, public FilterTarget
{
BinaryViewRef m_data;
ExportsWidget* m_parent;
@@ -44,7 +44,7 @@ class ExportsTreeView: public QTreeView, public FilterTarget
UIActionHandler m_actionHandler;
GenericExportsModel* m_model;
-public:
+ public:
ExportsTreeView(ExportsWidget* parent, TriageView* view, BinaryViewRef data);
virtual void setFilter(const std::string& filterText) override;
@@ -54,20 +54,20 @@ public:
virtual void activateFirstItem() override;
virtual void closeFilter() override;
-protected:
+ protected:
virtual void keyPressEvent(QKeyEvent* event) override;
-private Q_SLOTS:
+ private Q_SLOTS:
void exportSelected(const QModelIndex& cur, const QModelIndex& prev);
void exportDoubleClicked(const QModelIndex& cur);
};
-class ExportsWidget: public QWidget
+class ExportsWidget : public QWidget
{
FilteredView* m_filter;
-public:
+ public:
ExportsWidget(QWidget* parent, TriageView* view, BinaryViewRef data);
void showFilter(const QString& filter);
};
diff --git a/examples/triage/fileinfo.cpp b/examples/triage/fileinfo.cpp
index 2ff7cf38..ddb94897 100644
--- a/examples/triage/fileinfo.cpp
+++ b/examples/triage/fileinfo.cpp
@@ -6,94 +6,92 @@
#include <QToolTip>
#include <QPainter>
-class CopyableLabel: public QLabel
+class CopyableLabel : public QLabel
{
- QColor m_desiredColor{};
+ QColor m_desiredColor {};
-public:
- CopyableLabel(const QString& text, const QColor& color)
- : QLabel(text), m_desiredColor(color)
- {
- this->setMouseTracking(true);
- auto style = QPalette(palette());
- style.setColor(QPalette::WindowText, m_desiredColor);
- setPalette(style);
- this->setToolTip("Copy");
- }
+ public:
+ CopyableLabel(const QString& text, const QColor& color) : QLabel(text), m_desiredColor(color)
+ {
+ this->setMouseTracking(true);
+ auto style = QPalette(palette());
+ style.setColor(QPalette::WindowText, m_desiredColor);
+ setPalette(style);
+ this->setToolTip("Copy");
+ }
- void enterEvent(QEnterEvent* event) override
- {
- auto font = this->font();
- font.setBold(true);
- this->setFont(font);
- QToolTip::showText(event->globalPosition().toPoint(), this->toolTip());
- }
+ void enterEvent(QEnterEvent* event) override
+ {
+ auto font = this->font();
+ font.setBold(true);
+ this->setFont(font);
+ QToolTip::showText(event->globalPosition().toPoint(), this->toolTip());
+ }
- void leaveEvent(QEvent* event) override
- {
- auto font = this->font();
- font.setBold(false);
- this->setFont(font);
- QToolTip::hideText();
- }
+ void leaveEvent(QEvent* event) override
+ {
+ auto font = this->font();
+ font.setBold(false);
+ this->setFont(font);
+ QToolTip::hideText();
+ }
- void mousePressEvent(QMouseEvent* event) override
- {
- if (event->button() == Qt::LeftButton)
- QApplication::clipboard()->setText(this->text());
- }
+ void mousePressEvent(QMouseEvent* event) override
+ {
+ if (event->button() == Qt::LeftButton)
+ QApplication::clipboard()->setText(this->text());
+ }
};
void FileInfoWidget::addField(const QString& name, const QVariant& value)
{
- auto& [row, column] = this->m_fieldPosition;
+ auto& [row, column] = this->m_fieldPosition;
- const auto valueLabel = new QLabel(value.toString());
- valueLabel->setFont(getMonospaceFont(this));
+ const auto valueLabel = new QLabel(value.toString());
+ valueLabel->setFont(getMonospaceFont(this));
- this->m_layout->addWidget(new QLabel(name), row, column);
- this->m_layout->addWidget(valueLabel, row++, column + 1);
+ this->m_layout->addWidget(new QLabel(name), row, column);
+ this->m_layout->addWidget(valueLabel, row++, column + 1);
}
-void FileInfoWidget::addHashField(const QString& hashName,
- const QCryptographicHash::Algorithm& algorithm,
- const QByteArray& data)
+void FileInfoWidget::addHashField(
+ const QString& hashName, const QCryptographicHash::Algorithm& algorithm, const QByteArray& data)
{
- auto& [row, column] = this->m_fieldPosition;
+ auto& [row, column] = this->m_fieldPosition;
- const auto hashFieldColor = getThemeColor(AlphanumericHighlightColor);
- const auto crypto = QCryptographicHash::hash(data, algorithm);
- const auto hashLabel = new CopyableLabel(crypto.toHex(), hashFieldColor);
- hashLabel->setFont(getMonospaceFont(this));
+ const auto hashFieldColor = getThemeColor(AlphanumericHighlightColor);
+ const auto crypto = QCryptographicHash::hash(data, algorithm);
+ const auto hashLabel = new CopyableLabel(crypto.toHex(), hashFieldColor);
+ hashLabel->setFont(getMonospaceFont(this));
- this->m_layout->addWidget(new QLabel(hashName), row, column);
- this->m_layout->addWidget(hashLabel, row++, column + 1);
+ this->m_layout->addWidget(new QLabel(hashName), row, column);
+ this->m_layout->addWidget(hashLabel, row++, column + 1);
}
FileInfoWidget::FileInfoWidget(QWidget* parent, BinaryViewRef bv)
{
- this->m_layout = new QGridLayout();
- this->m_layout->setContentsMargins(0, 0, 0, 0);
- this->m_layout->setVerticalSpacing(1);
+ this->m_layout = new QGridLayout();
+ this->m_layout->setContentsMargins(0, 0, 0, 0);
+ this->m_layout->setVerticalSpacing(1);
- const auto view = bv->GetParentView() ? bv->GetParentView() : bv;
- const auto filePath = bv->GetFile()->GetOriginalFilename();
- this->addField("Path: ", filePath.c_str());
+ const auto view = bv->GetParentView() ? bv->GetParentView() : bv;
+ const auto filePath = bv->GetFile()->GetOriginalFilename();
+ this->addField("Path: ", filePath.c_str());
- const auto fileSize = QString::number(view->GetLength(), 16).prepend("0x");
- this->addField("Size: ", fileSize);
+ const auto fileSize = QString::number(view->GetLength(), 16).prepend("0x");
+ this->addField("Size: ", fileSize);
- const auto bufferSize = fileSize.toUInt(nullptr, 16);
- const auto fileBuffer = std::make_unique<char[]>(bufferSize);
- view->Read(fileBuffer.get(), 0, bufferSize);
+ const auto bufferSize = fileSize.toUInt(nullptr, 16);
+ const auto fileBuffer = std::make_unique<char[]>(bufferSize);
+ view->Read(fileBuffer.get(), 0, bufferSize);
- const auto fileBytes = QByteArray(fileBuffer.get(), bufferSize);
- this->addHashField("MD5: ", QCryptographicHash::Md5, fileBytes);
- this->addHashField("SHA-1: ", QCryptographicHash::Sha1, fileBytes);
- this->addHashField("SHA-256: ", QCryptographicHash::Sha256, fileBytes);
+ const auto fileBytes = QByteArray(fileBuffer.get(), bufferSize);
+ this->addHashField("MD5: ", QCryptographicHash::Md5, fileBytes);
+ this->addHashField("SHA-1: ", QCryptographicHash::Sha1, fileBytes);
+ this->addHashField("SHA-256: ", QCryptographicHash::Sha256, fileBytes);
- const auto scaledWidth = UIContext::getScaledWindowSize(20, 20).width();
- this->m_layout->setColumnMinimumWidth(FileInfoWidget::m_maxColumns * 3 - 1, scaledWidth);
- this->m_layout->setColumnStretch(FileInfoWidget::m_maxColumns * 3 - 1, 1);
- setLayout(this->m_layout);
+ const auto scaledWidth = UIContext::getScaledWindowSize(20, 20).width();
+ this->m_layout->setColumnMinimumWidth(FileInfoWidget::m_maxColumns * 3 - 1, scaledWidth);
+ this->m_layout->setColumnStretch(FileInfoWidget::m_maxColumns * 3 - 1, 1);
+ setLayout(this->m_layout);
} \ No newline at end of file
diff --git a/examples/triage/fileinfo.h b/examples/triage/fileinfo.h
index 02cc154d..14a7ec3c 100644
--- a/examples/triage/fileinfo.h
+++ b/examples/triage/fileinfo.h
@@ -5,17 +5,15 @@
#include "uitypes.h"
#include "viewframe.h"
-class FileInfoWidget: public QWidget
+class FileInfoWidget : public QWidget
{
- static constexpr std::int32_t m_maxColumns{2};
- std::pair<std::int32_t, std::int32_t> m_fieldPosition{}; // row, column
- QGridLayout* m_layout{};
+ static constexpr std::int32_t m_maxColumns {2};
+ std::pair<std::int32_t, std::int32_t> m_fieldPosition {}; // row, column
+ QGridLayout* m_layout {};
- void addField(const QString& name, const QVariant& value);
- void addHashField(const QString& hashName,
- const QCryptographicHash::Algorithm& algorithm,
- const QByteArray& data);
+ void addField(const QString& name, const QVariant& value);
+ void addHashField(const QString& hashName, const QCryptographicHash::Algorithm& algorithm, const QByteArray& data);
-public:
- FileInfoWidget(QWidget* parent, BinaryViewRef bv);
+ public:
+ FileInfoWidget(QWidget* parent, BinaryViewRef bv);
};
diff --git a/examples/triage/files.cpp b/examples/triage/files.cpp
index fcb71cd0..d70b61cd 100644
--- a/examples/triage/files.cpp
+++ b/examples/triage/files.cpp
@@ -18,7 +18,7 @@ TriageFilePicker::TriageFilePicker(UIContext* context)
m_model = new QFileSystemModel();
m_model->setRootPath("");
if (hiddenFiles)
- m_model->setFilter(QDir::Hidden | QDir::AllEntries | QDir::System );
+ m_model->setFilter(QDir::Hidden | QDir::AllEntries | QDir::System);
m_tree = new QTreeView(this);
m_tree->setModel(m_model);
m_tree->setSelectionMode(QAbstractItemView::ExtendedSelection);
@@ -45,9 +45,8 @@ TriageFilePicker::TriageFilePicker(UIContext* context)
recentFile = parentDir;
}
- m_actionHandler.bindAction("Open Selected Files", UIAction(
- [=]() { openSelectedFiles(); },
- [=]() { return areFilesSelected(); }));
+ m_actionHandler.bindAction(
+ "Open Selected Files", UIAction([=]() { openSelectedFiles(); }, [=]() { return areFilesSelected(); }));
m_contextMenu.addAction("Open Selected Files", "Open");
}
@@ -70,11 +69,11 @@ void TriageFilePicker::openSelectedFiles()
std::set<QString> files;
SettingsRef settings = BinaryNinja::Settings::Instance();
- for (auto& index: m_tree->selectionModel()->selectedIndexes())
+ for (auto& index : m_tree->selectionModel()->selectedIndexes())
if (m_model->fileInfo(index).isFile())
files.insert(m_model->fileInfo(index).absoluteFilePath());
- for (auto& filename: files)
+ for (auto& filename : files)
{
QSettings().setValue("triage/recentFile", filename);
@@ -85,7 +84,7 @@ void TriageFilePicker::openSelectedFiles()
continue;
}
- for (auto data: f->getAllDataViews())
+ for (auto data : f->getAllDataViews())
{
settings->Set("analysis.mode", settings->Get<std::string>("triage.analysisMode"), data);
settings->Set("triage.preferSummaryView", true, data);
@@ -118,7 +117,7 @@ void TriageFilePicker::openSelectedFiles()
if (failedToOpen.size() > 0)
{
QString message = "Unable to open:\n";
- for (auto& name: failedToOpen)
+ for (auto& name : failedToOpen)
message += name + "\n";
QMessageBox::critical(this, "Error", message);
}
diff --git a/examples/triage/files.h b/examples/triage/files.h
index e371d869..01d8e75e 100644
--- a/examples/triage/files.h
+++ b/examples/triage/files.h
@@ -3,15 +3,15 @@
#include <QtWidgets/QWidget>
#include <QtWidgets/QTreeView>
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
-#include <QtWidgets/QFileSystemModel>
+ #include <QtWidgets/QFileSystemModel>
#else
-#include <QtGui/QFileSystemModel>
+ #include <QtGui/QFileSystemModel>
#endif
#include "action.h"
#include "menus.h"
-class TriageFilePicker: public QWidget
+class TriageFilePicker : public QWidget
{
UIContext* m_context;
UIActionHandler m_actionHandler;
@@ -24,12 +24,12 @@ class TriageFilePicker: public QWidget
void openSelectedFiles();
bool areFilesSelected();
-public:
+ public:
TriageFilePicker(UIContext* context);
-protected:
+ protected:
virtual void contextMenuEvent(QContextMenuEvent*) override;
-private Q_SLOTS:
+ private Q_SLOTS:
void onDoubleClick(const QModelIndex& idx);
};
diff --git a/examples/triage/headers.cpp b/examples/triage/headers.cpp
index 7b8de78e..e327153e 100644
--- a/examples/triage/headers.cpp
+++ b/examples/triage/headers.cpp
@@ -6,8 +6,8 @@
#include "viewframe.h"
-NavigationLabel::NavigationLabel(const QString& text, QColor color, const std::function<void()>& func):
- QLabel(text), m_func(func)
+NavigationLabel::NavigationLabel(const QString& text, QColor color, const std::function<void()>& func) :
+ QLabel(text), m_func(func)
{
QPalette style(palette());
style.setColor(QPalette::WindowText, color);
@@ -22,8 +22,8 @@ void NavigationLabel::mousePressEvent(QMouseEvent*)
}
-NavigationAddressLabel::NavigationAddressLabel(const QString& text):
- NavigationLabel(text, getThemeColor(AddressColor), [this]() { clickEvent(); })
+NavigationAddressLabel::NavigationAddressLabel(const QString& text) :
+ NavigationLabel(text, getThemeColor(AddressColor), [this]() { clickEvent(); })
{
m_address = text.toULongLong(nullptr, 0);
}
@@ -37,8 +37,8 @@ void NavigationAddressLabel::clickEvent()
}
-NavigationCodeLabel::NavigationCodeLabel(const QString& text):
- NavigationLabel(text, getThemeColor(CodeSymbolColor), [this]() { clickEvent(); })
+NavigationCodeLabel::NavigationCodeLabel(const QString& text) :
+ NavigationLabel(text, getThemeColor(CodeSymbolColor), [this]() { clickEvent(); })
{
m_address = text.toULongLong(nullptr, 0);
}
@@ -52,20 +52,18 @@ void NavigationCodeLabel::clickEvent()
}
-Headers::Headers(): m_columns(1), m_rowsPerColumn(8)
-{
-}
+Headers::Headers() : m_columns(1), m_rowsPerColumn(8) {}
void Headers::AddField(const QString& title, const QString& value, HeaderFieldType type)
{
- m_fields.push_back(HeaderField { title, {value}, type });
+ m_fields.push_back(HeaderField {title, {value}, type});
}
void Headers::AddField(const QString& title, const std::vector<QString>& values, HeaderFieldType type)
{
- m_fields.push_back(HeaderField { title, values, type });
+ m_fields.push_back(HeaderField {title, values, type});
}
@@ -174,40 +172,39 @@ PEHeaders::PEHeaders(BinaryViewRef data)
uint64_t stackCommit = GetValueOfStructMember(data, optHeaderName, optHeaderStart, "sizeOfStackCommit");
uint64_t stackReserve = GetValueOfStructMember(data, optHeaderName, optHeaderStart, "sizeOfStackReserve");
- AddField("Stack Size", QString("0x") + QString::number(stackCommit, 16) + QString(" / 0x") +
- QString::number(stackReserve, 16));
+ AddField("Stack Size",
+ QString("0x") + QString::number(stackCommit, 16) + QString(" / 0x") + QString::number(stackReserve, 16));
uint64_t heapCommit = GetValueOfStructMember(data, optHeaderName, optHeaderStart, "sizeOfHeapCommit");
uint64_t heapReserve = GetValueOfStructMember(data, optHeaderName, optHeaderStart, "sizeOfHeapReserve");
- AddField("Heap Size", QString("0x") + QString::number(heapCommit, 16) + QString(" / 0x") +
- QString::number(heapReserve, 16));
+ AddField("Heap Size",
+ QString("0x") + QString::number(heapCommit, 16) + QString(" / 0x") + QString::number(heapReserve, 16));
uint64_t linkerMajor = GetValueOfStructMember(data, optHeaderName, optHeaderStart, "majorLinkerVersion");
uint64_t linkerMinor = GetValueOfStructMember(data, optHeaderName, optHeaderStart, "minorLinkerVersion");
- AddField("Linker Version", QString::number(linkerMajor) + QString(".") +
- QString::number(linkerMinor).rightJustified(2, '0'));
+ AddField("Linker Version",
+ QString::number(linkerMajor) + QString(".") + QString::number(linkerMinor).rightJustified(2, '0'));
uint64_t imageMajor = GetValueOfStructMember(data, optHeaderName, optHeaderStart, "majorImageVersion");
uint64_t imageMinor = GetValueOfStructMember(data, optHeaderName, optHeaderStart, "minorImageVersion");
- AddField("Image Version", QString::number(imageMajor) + QString(".") +
- QString::number(imageMinor).rightJustified(2, '0'));
+ AddField("Image Version",
+ QString::number(imageMajor) + QString(".") + QString::number(imageMinor).rightJustified(2, '0'));
uint64_t osMajor = GetValueOfStructMember(data, optHeaderName, optHeaderStart, "majorOperatingSystemVersion");
uint64_t osMinor = GetValueOfStructMember(data, optHeaderName, optHeaderStart, "minorOperatingSystemVersion");
- AddField("OS Version", QString::number(osMajor) + QString(".") +
- QString::number(osMinor).rightJustified(2, '0'));
+ AddField("OS Version", QString::number(osMajor) + QString(".") + QString::number(osMinor).rightJustified(2, '0'));
uint64_t subMajor = GetValueOfStructMember(data, optHeaderName, optHeaderStart, "majorSubsystemVersion");
uint64_t subMinor = GetValueOfStructMember(data, optHeaderName, optHeaderStart, "minorSubsystemVersion");
- AddField("Subsystem Version", QString::number(subMajor) + QString(".") +
- QString::number(subMinor).rightJustified(2, '0'));
+ AddField("Subsystem Version",
+ QString::number(subMajor) + QString(".") + QString::number(subMinor).rightJustified(2, '0'));
uint64_t coffCharValue = GetValueOfStructMember(data, "COFF_Header", peOffset, "characteristics");
TypeRef coffCharEnum = data->GetTypeByName(BinaryNinja::QualifiedName("coff_characteristics"));
if (coffCharEnum && (coffCharEnum->GetClass() == EnumerationTypeClass))
{
std::vector<QString> coffCharValues;
- for (auto& member: coffCharEnum->GetEnumeration()->GetMembers())
+ for (auto& member : coffCharEnum->GetEnumeration()->GetMembers())
{
if (coffCharValue & member.value)
{
@@ -226,12 +223,13 @@ PEHeaders::PEHeaders(BinaryViewRef data)
if (dllCharEnum && (dllCharEnum->GetClass() == EnumerationTypeClass))
{
std::vector<QString> dllCharValues;
- for (auto& member: dllCharEnum->GetEnumeration()->GetMembers())
+ for (auto& member : dllCharEnum->GetEnumeration()->GetMembers())
{
if (dllCharValue & member.value)
{
if (QString::fromStdString(member.name).startsWith("IMAGE_DLLCHARACTERISTICS_"))
- dllCharValues.push_back(QString::fromStdString(member.name).mid((int)strlen("IMAGE_DLLCHARACTERISTICS_")));
+ dllCharValues.push_back(
+ QString::fromStdString(member.name).mid((int)strlen("IMAGE_DLLCHARACTERISTICS_")));
else
dllCharValues.push_back(QString::fromStdString(member.name));
}
@@ -245,8 +243,8 @@ PEHeaders::PEHeaders(BinaryViewRef data)
}
-uint64_t PEHeaders::GetValueOfStructMember(BinaryViewRef data, const std::string& structName, uint64_t structStart,
- const std::string& fieldName)
+uint64_t PEHeaders::GetValueOfStructMember(
+ BinaryViewRef data, const std::string& structName, uint64_t structStart, const std::string& fieldName)
{
TypeRef type = data->GetTypeByName(structName);
if (!type)
@@ -254,7 +252,7 @@ uint64_t PEHeaders::GetValueOfStructMember(BinaryViewRef data, const std::string
if (type->GetClass() != StructureTypeClass)
return 0;
StructureRef s = type->GetStructure();
- for (auto& member: s->GetMembers())
+ for (auto& member : s->GetMembers())
{
if (member.name == fieldName)
{
@@ -285,7 +283,7 @@ QString PEHeaders::GetNameOfEnumerationMember(BinaryViewRef data, const std::str
TypeRef type = data->GetTypeByName(enumName);
if (type && (type->GetClass() == EnumerationTypeClass))
{
- for (auto& member: type->GetEnumeration()->GetMembers())
+ for (auto& member : type->GetEnumeration()->GetMembers())
{
if (member.value == value)
return QString::fromStdString(member.name);
@@ -295,17 +293,17 @@ QString PEHeaders::GetNameOfEnumerationMember(BinaryViewRef data, const std::str
}
-HeaderWidget::HeaderWidget(QWidget* parent, const Headers& header): QWidget(parent)
+HeaderWidget::HeaderWidget(QWidget* parent, const Headers& header) : QWidget(parent)
{
QGridLayout* layout = new QGridLayout();
layout->setContentsMargins(0, 0, 0, 0);
layout->setVerticalSpacing(1);
int row = 0;
int col = 0;
- for (auto& field: header.GetFields())
+ for (auto& field : header.GetFields())
{
layout->addWidget(new QLabel(field.title + ": "), row, col * 3);
- for (auto& value: field.values)
+ for (auto& value : field.values)
{
QWidget* label;
if (field.type == AddressHeaderField)
@@ -324,7 +322,8 @@ HeaderWidget::HeaderWidget(QWidget* parent, const Headers& header): QWidget(pare
layout->addWidget(label, row, col * 3 + 1);
row++;
}
- if ((header.GetColumns() > 1) && (row >= (int)header.GetRowsPerColumn()) && ((col + 1) < (int)header.GetColumns()))
+ if ((header.GetColumns() > 1) && (row >= (int)header.GetRowsPerColumn())
+ && ((col + 1) < (int)header.GetColumns()))
{
row = 0;
col++;
diff --git a/examples/triage/headers.h b/examples/triage/headers.h
index 0a9af5ff..a8348401 100644
--- a/examples/triage/headers.h
+++ b/examples/triage/headers.h
@@ -6,36 +6,36 @@
#include "uitypes.h"
-class NavigationLabel: public QLabel
+class NavigationLabel : public QLabel
{
std::function<void()> m_func;
-public:
+ public:
NavigationLabel(const QString& text, QColor color, const std::function<void()>& func);
-protected:
+ protected:
virtual void mousePressEvent(QMouseEvent* event) override;
};
-class NavigationAddressLabel: public NavigationLabel
+class NavigationAddressLabel : public NavigationLabel
{
uint64_t m_address;
void clickEvent();
-public:
+ public:
NavigationAddressLabel(const QString& text);
};
-class NavigationCodeLabel: public NavigationLabel
+class NavigationCodeLabel : public NavigationLabel
{
uint64_t m_address;
void clickEvent();
-public:
+ public:
NavigationCodeLabel(const QString& text);
};
@@ -61,7 +61,7 @@ class Headers
std::vector<HeaderField> m_fields;
size_t m_columns, m_rowsPerColumn;
-public:
+ public:
Headers();
void AddField(const QString& title, const QString& value, HeaderFieldType type = TextHeaderField);
void AddField(const QString& title, const std::vector<QString>& values, HeaderFieldType type = TextHeaderField);
@@ -73,27 +73,27 @@ public:
};
-class GenericHeaders: public Headers
+class GenericHeaders : public Headers
{
-public:
+ public:
GenericHeaders(BinaryViewRef data);
};
-class PEHeaders: public Headers
+class PEHeaders : public Headers
{
- uint64_t GetValueOfStructMember(BinaryViewRef data, const std::string& structName, uint64_t structStart,
- const std::string& fieldName);
+ uint64_t GetValueOfStructMember(
+ BinaryViewRef data, const std::string& structName, uint64_t structStart, const std::string& fieldName);
uint64_t GetAddressAfterStruct(BinaryViewRef data, const std::string& structName, uint64_t structStart);
QString GetNameOfEnumerationMember(BinaryViewRef data, const std::string& enumName, uint64_t value);
-public:
+ public:
PEHeaders(BinaryViewRef data);
};
-class HeaderWidget: public QWidget
+class HeaderWidget : public QWidget
{
-public:
+ public:
HeaderWidget(QWidget* parent, const Headers& headers);
};
diff --git a/examples/triage/imports.cpp b/examples/triage/imports.cpp
index 7a0c0d2a..79c1f35e 100644
--- a/examples/triage/imports.cpp
+++ b/examples/triage/imports.cpp
@@ -14,7 +14,7 @@ GenericImportsModel::GenericImportsModel(BinaryViewRef data)
m_sortCol = 0;
m_sortOrder = Qt::AscendingOrder;
m_allEntries = data->GetSymbolsOfType(ImportAddressSymbol);
- for (auto& sym: m_allEntries)
+ for (auto& sym : m_allEntries)
{
if ((sym->GetNameSpace().size() != 1) || (sym->GetNameSpace()[0] != "BNINTERNALNAMESPACE"))
{
@@ -168,7 +168,7 @@ void GenericImportsModel::setFilter(const std::string& filterText)
{
beginResetModel();
m_entries.clear();
- for (auto& entry: m_allEntries)
+ for (auto& entry : m_allEntries)
{
if (FilteredView::match(entry->GetFullName(), filterText))
m_entries.push_back(entry);
@@ -180,7 +180,7 @@ void GenericImportsModel::setFilter(const std::string& filterText)
}
-ImportsTreeView::ImportsTreeView(ImportsWidget* parent, TriageView* view, BinaryViewRef data): QTreeView(parent)
+ImportsTreeView::ImportsTreeView(ImportsWidget* parent, TriageView* view, BinaryViewRef data) : QTreeView(parent)
{
m_data = data;
m_parent = parent;
@@ -279,7 +279,7 @@ void ImportsTreeView::keyPressEvent(QKeyEvent* event)
}
-ImportsWidget::ImportsWidget(QWidget* parent, TriageView* view, BinaryViewRef data): QWidget(parent)
+ImportsWidget::ImportsWidget(QWidget* parent, TriageView* view, BinaryViewRef data) : QWidget(parent)
{
QVBoxLayout* layout = new QVBoxLayout();
layout->setContentsMargins(0, 0, 0, 0);
diff --git a/examples/triage/imports.h b/examples/triage/imports.h
index cacda087..2199aa47 100644
--- a/examples/triage/imports.h
+++ b/examples/triage/imports.h
@@ -5,7 +5,7 @@
#include "filter.h"
-class GenericImportsModel: public QAbstractItemModel
+class GenericImportsModel : public QAbstractItemModel
{
std::vector<SymbolRef> m_allEntries, m_entries;
bool m_hasModules;
@@ -16,7 +16,7 @@ class GenericImportsModel: public QAbstractItemModel
QString getNamespace(SymbolRef sym) const;
void performSort(int col, Qt::SortOrder order);
-public:
+ public:
GenericImportsModel(BinaryViewRef data);
virtual int columnCount(const QModelIndex& parent) const override;
@@ -38,7 +38,7 @@ public:
class TriageView;
class ImportsWidget;
-class ImportsTreeView: public QTreeView, public FilterTarget
+class ImportsTreeView : public QTreeView, public FilterTarget
{
BinaryViewRef m_data;
ImportsWidget* m_parent;
@@ -46,7 +46,7 @@ class ImportsTreeView: public QTreeView, public FilterTarget
UIActionHandler m_actionHandler;
GenericImportsModel* m_model;
-public:
+ public:
ImportsTreeView(ImportsWidget* parent, TriageView* view, BinaryViewRef data);
virtual void setFilter(const std::string& filterText) override;
@@ -56,20 +56,20 @@ public:
virtual void activateFirstItem() override;
virtual void closeFilter() override;
-protected:
+ protected:
virtual void keyPressEvent(QKeyEvent* event) override;
-private Q_SLOTS:
+ private Q_SLOTS:
void importSelected(const QModelIndex& cur, const QModelIndex& prev);
void importDoubleClicked(const QModelIndex& cur);
};
-class ImportsWidget: public QWidget
+class ImportsWidget : public QWidget
{
FilteredView* m_filter;
-public:
+ public:
ImportsWidget(QWidget* parent, TriageView* view, BinaryViewRef data);
void showFilter(const QString& filter);
};
diff --git a/examples/triage/sections.cpp b/examples/triage/sections.cpp
index 026b3d7b..95993031 100644
--- a/examples/triage/sections.cpp
+++ b/examples/triage/sections.cpp
@@ -7,22 +7,21 @@
#include "fontsettings.h"
-SegmentsWidget::SegmentsWidget(QWidget* parent, BinaryViewRef data): QWidget(parent)
+SegmentsWidget::SegmentsWidget(QWidget* parent, BinaryViewRef data) : QWidget(parent)
{
QGridLayout* layout = new QGridLayout();
layout->setContentsMargins(0, 0, 0, 0);
layout->setVerticalSpacing(1);
layout->setHorizontalSpacing(UIContext::getScaledWindowSize(16, 16).width());
- for (auto& segment: data->GetSegments())
+ for (auto& segment : data->GetSegments())
if ((segment->GetFlags() & (SegmentReadable | SegmentWritable | SegmentExecutable)) != 0)
m_segments.push_back(segment);
- sort(m_segments.begin(), m_segments.end(), [&](SegmentRef a, SegmentRef b) {
- return a->GetStart() < b->GetStart();
- });
+ sort(m_segments.begin(), m_segments.end(),
+ [&](SegmentRef a, SegmentRef b) { return a->GetStart() < b->GetStart(); });
int row = 0;
- for (auto& segment: m_segments)
+ for (auto& segment : m_segments)
{
QString begin = QString("0x") + QString::number(segment->GetStart(), 16);
QString end = QString("0x") + QString::number(segment->GetEnd(), 16);
@@ -64,7 +63,7 @@ SegmentsWidget::SegmentsWidget(QWidget* parent, BinaryViewRef data): QWidget(par
}
-SectionsWidget::SectionsWidget(QWidget* parent, BinaryViewRef data): QWidget(parent)
+SectionsWidget::SectionsWidget(QWidget* parent, BinaryViewRef data) : QWidget(parent)
{
QGridLayout* layout = new QGridLayout();
layout->setContentsMargins(0, 0, 0, 0);
@@ -72,21 +71,20 @@ SectionsWidget::SectionsWidget(QWidget* parent, BinaryViewRef data): QWidget(par
layout->setHorizontalSpacing(UIContext::getScaledWindowSize(16, 16).width());
size_t maxNameLen = 0;
- for (auto& section: data->GetSections())
+ for (auto& section : data->GetSections())
if (section->GetName().size() > maxNameLen)
maxNameLen = section->GetName().size();
if (maxNameLen > 32)
maxNameLen = 32;
- for (auto& section: data->GetSections())
+ for (auto& section : data->GetSections())
if (section->GetSemantics() != ExternalSectionSemantics)
m_sections.push_back(section);
- sort(m_sections.begin(), m_sections.end(), [&](SectionRef a, SectionRef b) {
- return a->GetStart() < b->GetStart();
- });
+ sort(m_sections.begin(), m_sections.end(),
+ [&](SectionRef a, SectionRef b) { return a->GetStart() < b->GetStart(); });
int row = 0;
- for (auto& section: m_sections)
+ for (auto& section : m_sections)
{
std::string name = section->GetName();
if (name.size() > maxNameLen)
diff --git a/examples/triage/sections.h b/examples/triage/sections.h
index 09c9ea63..00285df8 100644
--- a/examples/triage/sections.h
+++ b/examples/triage/sections.h
@@ -4,21 +4,21 @@
#include "uitypes.h"
-class SegmentsWidget: public QWidget
+class SegmentsWidget : public QWidget
{
std::vector<SegmentRef> m_segments;
-public:
+ public:
SegmentsWidget(QWidget* parent, BinaryViewRef data);
const std::vector<SegmentRef>& GetSegments() const { return m_segments; }
};
-class SectionsWidget: public QWidget
+class SectionsWidget : public QWidget
{
std::vector<SectionRef> m_sections;
-public:
+ public:
SectionsWidget(QWidget* parent, BinaryViewRef data);
const std::vector<SectionRef>& GetSections() const { return m_sections; }
};
diff --git a/examples/triage/triage.cpp b/examples/triage/triage.cpp
index 5d0dc1d5..b268f069 100644
--- a/examples/triage/triage.cpp
+++ b/examples/triage/triage.cpp
@@ -17,7 +17,7 @@ extern "C"
SettingsRef settings = BinaryNinja::Settings::Instance();
settings->RegisterGroup("triage", "Triage");
settings->RegisterSetting("triage.preferSummaryView",
- R"({
+ R"({
"title" : "Always Prefer Triage Summary View",
"type" : "boolean",
"default" : false,
@@ -25,7 +25,7 @@ extern "C"
})");
settings->RegisterSetting("triage.preferSummaryViewForRaw",
- R"({
+ R"({
"title" : "Prefer Triage Summary View for Raw Files",
"type" : "boolean",
"default" : false,
@@ -35,7 +35,7 @@ extern "C"
ViewType::registerViewType(new TriageViewType());
settings->RegisterSetting("triage.analysisMode",
- R"({
+ R"({
"title" : "Triage Analysis Mode",
"type" : "string",
"default" : "basic",
@@ -48,7 +48,7 @@ extern "C"
})");
settings->RegisterSetting("triage.linearSweep",
- R"({
+ R"({
"title" : "Triage Linear Sweep Mode",
"type" : "string",
"default" : "partial",
@@ -61,7 +61,7 @@ extern "C"
})");
settings->RegisterSetting("triage.hiddenFiles",
- R"({
+ R"({
"title" : "Triage Shows Hidden Files",
"type" : "boolean",
"default" : false,
@@ -85,7 +85,8 @@ extern "C"
Menu::mainMenu("File")->addAction("Open for Triage...", "Open");
- UIContext::registerFileOpenMode("Triage...", "Open file(s) for quick analysis in the Triage Summary view.", "Open for Triage...");
+ UIContext::registerFileOpenMode(
+ "Triage...", "Open file(s) for quick analysis in the Triage Summary view.", "Open for Triage...");
ViewType::registerViewType(new ByteViewType());
return true;
diff --git a/examples/triage/view.cpp b/examples/triage/view.cpp
index 2c5f7b9b..8a85ba26 100644
--- a/examples/triage/view.cpp
+++ b/examples/triage/view.cpp
@@ -11,7 +11,7 @@
#include "fontsettings.h"
#include <binaryninjacore.h>
-TriageView::TriageView(QWidget* parent, BinaryViewRef data): QScrollArea(parent)
+TriageView::TriageView(QWidget* parent, BinaryViewRef data) : QScrollArea(parent)
{
setBinaryDataNavigable(true);
setupView(this);
@@ -26,11 +26,11 @@ TriageView::TriageView(QWidget* parent, BinaryViewRef data): QScrollArea(parent)
entropyGroup->setLayout(entropyLayout);
layout->addWidget(entropyGroup);
- QGroupBox* fileInfoGroup = new QGroupBox("File Info", container);
- QVBoxLayout* fileInfoLayout = new QVBoxLayout();
- fileInfoLayout->addWidget(new FileInfoWidget(fileInfoGroup, m_data));
- fileInfoGroup->setLayout(fileInfoLayout);
- layout->addWidget(fileInfoGroup);
+ QGroupBox* fileInfoGroup = new QGroupBox("File Info", container);
+ QVBoxLayout* fileInfoLayout = new QVBoxLayout();
+ fileInfoLayout->addWidget(new FileInfoWidget(fileInfoGroup, m_data));
+ fileInfoGroup->setLayout(fileInfoLayout);
+ layout->addWidget(fileInfoGroup);
Headers* hdr = nullptr;
if (m_data->GetTypeName() == "PE")
@@ -129,7 +129,7 @@ BNAddressRange TriageView::getSelectionOffsets()
{
if (m_byteView)
return m_byteView->getSelectionOffsets();
- return { m_currentOffset, m_currentOffset };
+ return {m_currentOffset, m_currentOffset};
}
void TriageView::setSelectionOffsets(BNAddressRange range)
@@ -164,7 +164,7 @@ bool TriageView::navigate(uint64_t addr)
void TriageView::startFullAnalysis()
{
BinaryNinja::Settings::Instance()->Set("analysis.mode", "full", m_data);
- for (auto& f: m_data->GetAnalysisFunctionList())
+ for (auto& f : m_data->GetAnalysisFunctionList())
{
if (f->IsAnalysisSkipped())
f->Reanalyze();
@@ -223,9 +223,7 @@ void TriageView::focusInEvent(QFocusEvent*)
}
-TriageViewType::TriageViewType(): ViewType("Triage", "Triage Summary")
-{
-}
+TriageViewType::TriageViewType() : ViewType("Triage", "Triage Summary") {}
int TriageViewType::getPriority(BinaryViewRef data, const QString&)
diff --git a/examples/triage/view.h b/examples/triage/view.h
index 37e53e7c..354091fb 100644
--- a/examples/triage/view.h
+++ b/examples/triage/view.h
@@ -6,14 +6,14 @@
#include "byte.h"
-class TriageView: public QScrollArea, public View
+class TriageView : public QScrollArea, public View
{
BinaryViewRef m_data;
uint64_t m_currentOffset = 0;
ByteView* m_byteView = nullptr;
QPushButton* m_fullAnalysisButton = nullptr;
-public:
+ public:
TriageView(QWidget* parent, BinaryViewRef data);
virtual BinaryViewRef getData() override;
@@ -26,17 +26,17 @@ public:
void setCurrentOffset(uint64_t offset);
void navigateToFileOffset(uint64_t offset);
-protected:
+ protected:
virtual void focusInEvent(QFocusEvent* event) override;
-private Q_SLOTS:
+ private Q_SLOTS:
void startFullAnalysis();
};
-class TriageViewType: public ViewType
+class TriageViewType : public ViewType
{
-public:
+ public:
TriageViewType();
virtual int getPriority(BinaryViewRef data, const QString& filename) override;
virtual QWidget* create(BinaryViewRef data, ViewFrame* frame) override;
diff --git a/examples/uinotification/uinotification.cpp b/examples/uinotification/uinotification.cpp
index d9eada8e..5072d98a 100644
--- a/examples/uinotification/uinotification.cpp
+++ b/examples/uinotification/uinotification.cpp
@@ -31,21 +31,24 @@ void NotificationListener::OnContextClose(UIContext* context)
bool NotificationListener::OnBeforeOpenDatabase(UIContext* context, FileMetadataRef metadata)
{
LogInfo("OnBeforeOpenDatabase");
- return QMessageBox::question(context->mainWindow(), "OnBeforeOpenDatabase", "OnBeforeOpenDatabase") == QMessageBox::StandardButton::Yes;
+ return QMessageBox::question(context->mainWindow(), "OnBeforeOpenDatabase", "OnBeforeOpenDatabase")
+ == QMessageBox::StandardButton::Yes;
}
bool NotificationListener::OnAfterOpenDatabase(UIContext* context, FileMetadataRef metadata, BinaryViewRef data)
{
LogInfo("OnAfterOpenDatabase");
- return QMessageBox::question(context->mainWindow(), "OnAfterOpenDatabase", "OnAfterOpenDatabase") == QMessageBox::StandardButton::Yes;
+ return QMessageBox::question(context->mainWindow(), "OnAfterOpenDatabase", "OnAfterOpenDatabase")
+ == QMessageBox::StandardButton::Yes;
}
bool NotificationListener::OnBeforeOpenFile(UIContext* context, FileContext* file)
{
LogInfo("OnBeforeOpenFile");
- return QMessageBox::question(context->mainWindow(), "OnBeforeOpenFile", "OnBeforeOpenFile") == QMessageBox::StandardButton::Yes;
+ return QMessageBox::question(context->mainWindow(), "OnBeforeOpenFile", "OnBeforeOpenFile")
+ == QMessageBox::StandardButton::Yes;
}
@@ -58,7 +61,8 @@ void NotificationListener::OnAfterOpenFile(UIContext* context, FileContext* file
bool NotificationListener::OnBeforeSaveFile(UIContext* context, FileContext* file, ViewFrame* frame)
{
LogInfo("OnBeforeSaveFile");
- return QMessageBox::question(context->mainWindow(), "OnBeforeSaveFile", "OnBeforeSaveFile") == QMessageBox::StandardButton::Yes;
+ return QMessageBox::question(context->mainWindow(), "OnBeforeSaveFile", "OnBeforeSaveFile")
+ == QMessageBox::StandardButton::Yes;
}
@@ -71,7 +75,8 @@ void NotificationListener::OnAfterSaveFile(UIContext* context, FileContext* file
bool NotificationListener::OnBeforeCloseFile(UIContext* context, FileContext* file, ViewFrame* frame)
{
LogInfo("OnBeforeCloseFile");
- return QMessageBox::question(context->mainWindow(), "OnBeforeCloseFile", "OnBeforeCloseFile") == QMessageBox::StandardButton::Yes;
+ return QMessageBox::question(context->mainWindow(), "OnBeforeCloseFile", "OnBeforeCloseFile")
+ == QMessageBox::StandardButton::Yes;
}
@@ -87,7 +92,8 @@ void NotificationListener::OnViewChange(UIContext* context, ViewFrame* frame, co
}
-void NotificationListener::OnAddressChange(UIContext* context, ViewFrame* frame, View* view, const ViewLocation& location)
+void NotificationListener::OnAddressChange(
+ UIContext* context, ViewFrame* frame, View* view, const ViewLocation& location)
{
LogInfo("OnAddressChange: 0x%" PRIx64, location.getOffset());
}
diff --git a/examples/uinotification/uinotification.h b/examples/uinotification/uinotification.h
index 31ffbc34..a359a35a 100644
--- a/examples/uinotification/uinotification.h
+++ b/examples/uinotification/uinotification.h
@@ -2,10 +2,11 @@
#include "uicontext.h"
-class NotificationListener: UIContextNotification
+class NotificationListener : UIContextNotification
{
static NotificationListener* m_instance;
-public:
+
+ public:
virtual void OnContextOpen(UIContext* context) override;
virtual void OnContextClose(UIContext* context) override;
virtual bool OnBeforeOpenDatabase(UIContext* context, FileMetadataRef metadata) override;
@@ -17,7 +18,8 @@ public:
virtual bool OnBeforeCloseFile(UIContext* context, FileContext* file, ViewFrame* frame) override;
virtual void OnAfterCloseFile(UIContext* context, FileContext* file, ViewFrame* frame) override;
virtual void OnViewChange(UIContext* context, ViewFrame* frame, const QString& type) override;
- virtual void OnAddressChange(UIContext* context, ViewFrame* frame, View* view, const ViewLocation& location) override;
+ virtual void OnAddressChange(
+ UIContext* context, ViewFrame* frame, View* view, const ViewLocation& location) override;
virtual bool GetNameForFile(UIContext* context, FileContext* file, QString& name) override;
virtual bool GetNameForPath(UIContext* context, const QString& path, QString& name) override;
diff --git a/examples/workflows/inliner/inliner.cpp b/examples/workflows/inliner/inliner.cpp
index 4ce05a31..da54fbc2 100644
--- a/examples/workflows/inliner/inliner.cpp
+++ b/examples/workflows/inliner/inliner.cpp
@@ -18,7 +18,7 @@ using namespace BinaryNinja;
using namespace std;
#if defined(_MSC_VER)
-#define snprintf _snprintf
+ #define snprintf _snprintf
#endif
@@ -68,7 +68,8 @@ extern "C"
if (instr.operation != LLIL_CALL)
{
- LogWarn("Failed to inline function at: 0x%" PRIx64 ". Mapping to LLIL_CALL Failed!", instr.address);
+ LogWarn(
+ "Failed to inline function at: 0x%" PRIx64 ". Mapping to LLIL_CALL Failed!", instr.address);
continue;
}
@@ -79,14 +80,17 @@ extern "C"
platformAddr = target.value;
else
{
- LogWarn("Failed to inline function at: 0x%" PRIx64 ". Destination not Constant!", instr.address);
+ LogWarn(
+ "Failed to inline function at: 0x%" PRIx64 ". Destination not Constant!", instr.address);
continue;
}
size_t opLen = data->Read(opcode, instr.address, arch->GetMaxInstructionLength());
if (!opLen || !arch->GetInstructionInfo(opcode, instr.address, opLen, iInfo))
continue;
- Ref<Platform> platform = iInfo.archTransitionByTargetAddr ? function->GetPlatform()->GetAssociatedPlatformByAddress(platformAddr) : function->GetPlatform();
+ Ref<Platform> platform = iInfo.archTransitionByTargetAddr ?
+ function->GetPlatform()->GetAssociatedPlatformByAddress(platformAddr) :
+ function->GetPlatform();
if (platform)
{
Ref<Function> targetFunc = data->GetAnalysisFunction(platform, platformAddr);
@@ -145,21 +149,21 @@ extern "C"
// }, inlinerIsValid);
PluginCommand::RegisterForFunction(
- "Optimizer\\Inline Function at Current Call Site",
- "Inline function call at current call site.",
- [](BinaryView* view, Function* func) {
- // TODO func->Inform("inlinedCallSites")
- // TODO resolve multiple embedded inlines
- std::lock_guard<std::mutex> lock(g_mutex);
- g_callSiteInlines[view->GetObject()][func->GetStart()].insert(view->GetCurrentOffset());
- func->Reanalyze();
- }, inlinerIsValid);
+ "Optimizer\\Inline Function at Current Call Site", "Inline function call at current call site.",
+ [](BinaryView* view, Function* func) {
+ // TODO func->Inform("inlinedCallSites")
+ // TODO resolve multiple embedded inlines
+ std::lock_guard<std::mutex> lock(g_mutex);
+ g_callSiteInlines[view->GetObject()][func->GetStart()].insert(view->GetCurrentOffset());
+ func->Reanalyze();
+ },
+ inlinerIsValid);
Ref<Workflow> inlinerWorkflow = Workflow::Instance()->Clone("InlinerWorkflow");
inlinerWorkflow->RegisterActivity(new Activity("extension.functionInliner", &FunctionInliner));
inlinerWorkflow->Insert("core.function.translateTailCalls", "extension.functionInliner");
Workflow::RegisterWorkflow(inlinerWorkflow,
- R"#({
+ R"#({
"title" : "Function Inliner (Example)",
"description" : "This analysis stands in as an example to demonstrate Binary Ninja's extensible analysis APIs. ***Note** this feature is under active development and subject to change without notice.",
"capabilities" : []
diff --git a/examples/workflows/objectivec/objectivec.cpp b/examples/workflows/objectivec/objectivec.cpp
index b3272f94..b5ce26c1 100644
--- a/examples/workflows/objectivec/objectivec.cpp
+++ b/examples/workflows/objectivec/objectivec.cpp
@@ -17,7 +17,7 @@ using namespace BinaryNinja;
using namespace std;
#if defined(_MSC_VER)
-#define snprintf _snprintf
+ #define snprintf _snprintf
#endif
@@ -46,7 +46,7 @@ extern "C"
return;
BinaryReader reader(data);
- reader.SetEndianness(data->GetDefaultEndianness()); // TODO fix GetDefaultEndianness for non-elf formats
+ reader.SetEndianness(data->GetDefaultEndianness()); // TODO fix GetDefaultEndianness for non-elf formats
reader.Seek(constSection->GetStart());
reader.Read32();
@@ -62,13 +62,13 @@ extern "C"
reader.Read64();
uint32_t methodListFlags = reader.Read32();
uint32_t methodListCount = reader.Read32();
- for (uint32_t i = 0; i < methodListCount; i++) // section end/symbol validation
+ for (uint32_t i = 0; i < methodListCount; i++) // section end/symbol validation
{
uint64_t selector = reader.Read64();
uint64_t typePtr = reader.Read64();
uint64_t impPtr = reader.Read64();
- //string methodName = reader.ReadCString(selector);
- string typeEncoding = "";//reader.ReadCString(typePtr);
+ // string methodName = reader.ReadCString(selector);
+ string typeEncoding = ""; // reader.ReadCString(typePtr);
g_classData[data->GetObject()].insert_or_assign(selector, std::forward_as_tuple(typeEncoding, impPtr));
}
@@ -118,11 +118,13 @@ extern "C"
if (msgSendAddr == (uint64_t)destExpr.GetValue().value)
{
auto params = instr.GetParameterExprs<LLIL_CALL_SSA>();
- if ((params.size() >= 2) && (params[0].operation == LLIL_REG_SSA) && (params[1].operation == LLIL_REG_SSA))
+ if ((params.size() >= 2) && (params[0].operation == LLIL_REG_SSA)
+ && (params[1].operation == LLIL_REG_SSA))
{
auto selfSSAReg = params[0].GetSourceSSARegister<LLIL_REG_SSA>();
auto selSSAReg = params[1].GetSourceSSARegister<LLIL_REG_SSA>();
- if (auto itr = classData.find(ssa->GetSSARegisterValue(selSSAReg).value); itr != classData.end())
+ if (auto itr = classData.find(ssa->GetSSARegisterValue(selSSAReg).value);
+ itr != classData.end())
{
size_t llilIndex = ssa->GetNonSSAInstructionIndex(instrIndex);
LowLevelILInstruction llilInstr = llilFunc->GetInstruction(llilIndex);
@@ -130,12 +132,13 @@ extern "C"
const auto& [typeEncoding, impPtr] = itr->second;
destExpr.Replace(llilFunc->ConstPointer(destExpr.size, impPtr, destExpr));
llilInstr.Replace(llilFunc->Call(destExpr.exprIndex, llilInstr));
- analysisContext->Inform("directRefs", "insert", impPtr, i->GetArchitecture(), instr.address);
+ analysisContext->Inform(
+ "directRefs", "insert", impPtr, i->GetArchitecture(), instr.address);
updated = true;
}
// else
- // LogError("ObjectiveC Workflow: missing classData for __objc_methname entry: 0x%" PRIx64 " at: 0x%" PRIx64,
- // ssa->GetSSARegisterValue(selSSAReg).value, instr.address);
+ // LogError("ObjectiveC Workflow: missing classData for __objc_methname entry: 0x%" PRIx64 "
+ // at: 0x%" PRIx64, ssa->GetSSARegisterValue(selSSAReg).value, instr.address);
}
// else
// LogError("Unhandled _objc_msgSend: 0x%" PRIx64, instr.address);
@@ -157,7 +160,7 @@ extern "C"
objectiveCWorkflow->RegisterActivity(new Activity("extension.objectiveC", &ObjectiveCAnalysis));
objectiveCWorkflow->Insert("core.function.translateTailCalls", "extension.objectiveC");
Workflow::RegisterWorkflow(objectiveCWorkflow,
- R"#({
+ R"#({
"title" : "Objective C Meta-Analysis (Example)",
"description" : "This analysis stands in as an example to demonstrate Binary Ninja's extensible analysis APIs. ***Note** this feature is under active development and subject to change without notice.",
"capabilities" : []
diff --git a/examples/workflows/tailcall/tailcall.cpp b/examples/workflows/tailcall/tailcall.cpp
index 3d8613c4..01190987 100644
--- a/examples/workflows/tailcall/tailcall.cpp
+++ b/examples/workflows/tailcall/tailcall.cpp
@@ -17,7 +17,7 @@ using namespace BinaryNinja;
using namespace std;
#if defined(_MSC_VER)
-#define snprintf _snprintf
+ #define snprintf _snprintf
#endif
@@ -52,7 +52,8 @@ extern "C"
RegisterValue target = destExpr.GetValue();
if (target.IsConstant())
platformAddr = target.value;
- else if (target.state == ImportedAddressValue) // Call to imported function, look up type from import symbol
+ else if (target.state
+ == ImportedAddressValue) // Call to imported function, look up type from import symbol
platformAddr = target.value;
else if (target.state == ExternalPointerValue && target.offset == 0)
platformAddr = target.value;
@@ -62,7 +63,9 @@ extern "C"
size_t opLen = data->Read(opcode, instr.address, arch->GetMaxInstructionLength());
if (!opLen || !arch->GetInstructionInfo(opcode, instr.address, opLen, iInfo))
continue;
- Ref<Platform> platform = iInfo.archTransitionByTargetAddr ? function->GetPlatform()->GetAssociatedPlatformByAddress(platformAddr) : function->GetPlatform();
+ Ref<Platform> platform = iInfo.archTransitionByTargetAddr ?
+ function->GetPlatform()->GetAssociatedPlatformByAddress(platformAddr) :
+ function->GetPlatform();
if (platform)
{
bool canReturn = true;
@@ -72,7 +75,8 @@ extern "C"
DataVariable var;
if (data->GetDataVariableAtAddress(target.value, var))
{
- if (var.type && (var.type->GetClass() == PointerTypeClass) && (var.type->GetChildType()->GetClass() == FunctionTypeClass))
+ if (var.type && (var.type->GetClass() == PointerTypeClass)
+ && (var.type->GetChildType()->GetClass() == FunctionTypeClass))
canReturn = var.type->GetChildType()->CanReturn().GetValue();
}
}
@@ -119,7 +123,7 @@ extern "C"
customTailCallWorkflow->Replace("core.function.translateTailCalls", "extension.translateTailCalls");
customTailCallWorkflow->Remove("core.function.translateTailCalls");
Workflow::RegisterWorkflow(customTailCallWorkflow,
- R"#({
+ R"#({
"title" : "Tail Call Translation (Example)",
"description" : "This analysis stands in as an example to demonstrate Binary Ninja's extensible analysis APIs. ***Note** this feature is under active development and subject to change without notice.",
"capabilities" : []
diff --git a/examples/x86_extension/src/x86_extension.cpp b/examples/x86_extension/src/x86_extension.cpp
index ada7c801..80043287 100644
--- a/examples/x86_extension/src/x86_extension.cpp
+++ b/examples/x86_extension/src/x86_extension.cpp
@@ -12,14 +12,13 @@ using namespace asmx86;
// This is a wrapper for the x86 architecture. Its useful for extending and improving
// the existing core x86 architecture.
-class x86ArchitectureExtension: public ArchitectureHook
+class x86ArchitectureExtension : public ArchitectureHook
{
-public:
- x86ArchitectureExtension(Architecture* x86) : ArchitectureHook(x86)
- {
- }
+ public:
+ x86ArchitectureExtension(Architecture* x86) : ArchitectureHook(x86) {}
- virtual bool GetInstructionLowLevelIL(const uint8_t* data, uint64_t addr, size_t& len, LowLevelILFunction& il) override
+ virtual bool GetInstructionLowLevelIL(
+ const uint8_t* data, uint64_t addr, size_t& len, LowLevelILFunction& il) override
{
Instruction instr;
if (asmx86::Disassemble32(data, addr, len, &instr))
@@ -29,7 +28,7 @@ public:
case CPUID:
// The default implementation of CPUID doesn't set registers to constant values
// Here we'll emulate a Intel(R) Core(TM) i5-6267U CPU @ 2.90GHz with _eax set to 1
- il.AddInstruction(il.Register(4, REG_EAX)); // Reference the register so we know it is read
+ il.AddInstruction(il.Register(4, REG_EAX)); // Reference the register so we know it is read
il.AddInstruction(il.SetRegister(4, REG_EAX, il.Const(4, 0x000406e3)));
il.AddInstruction(il.SetRegister(4, REG_EBX, il.Const(4, 0x03100800)));
il.AddInstruction(il.SetRegister(4, REG_ECX, il.Const(4, 0x7ffafbbf)));
diff --git a/fileaccessor.cpp b/fileaccessor.cpp
index 12c4c4ef..a1454133 100644
--- a/fileaccessor.cpp
+++ b/fileaccessor.cpp
@@ -54,14 +54,10 @@ FileAccessor::FileAccessor()
}
-FileAccessor::FileAccessor(BNFileAccessor* accessor): m_callbacks(*accessor)
-{
-}
+FileAccessor::FileAccessor(BNFileAccessor* accessor) : m_callbacks(*accessor) {}
-CoreFileAccessor::CoreFileAccessor(BNFileAccessor* accessor): FileAccessor(accessor)
-{
-}
+CoreFileAccessor::CoreFileAccessor(BNFileAccessor* accessor) : FileAccessor(accessor) {}
uint64_t CoreFileAccessor::GetLength() const
@@ -80,4 +76,3 @@ size_t CoreFileAccessor::Write(uint64_t offset, const void* src, size_t len)
{
return m_callbacks.write(m_callbacks.context, offset, src, len);
}
-
diff --git a/filemetadata.cpp b/filemetadata.cpp
index 17de62ef..2b8dd553 100644
--- a/filemetadata.cpp
+++ b/filemetadata.cpp
@@ -170,11 +170,12 @@ bool FileMetadata::CreateDatabase(const string& name, BinaryView* data, Ref<Save
bool FileMetadata::CreateDatabase(const string& name, BinaryView* data,
- const function<bool(size_t progress, size_t total)>& progressCallback, Ref<SaveSettings> settings)
+ const function<bool(size_t progress, size_t total)>& progressCallback, Ref<SaveSettings> settings)
{
DatabaseProgressCallbackContext cb;
cb.func = progressCallback;
- return BNCreateDatabaseWithProgress(data->GetObject(), name.c_str(), &cb, DatabaseProgressCallback, settings ? settings->GetObject() : nullptr);
+ return BNCreateDatabaseWithProgress(
+ data->GetObject(), name.c_str(), &cb, DatabaseProgressCallback, settings ? settings->GetObject() : nullptr);
}
@@ -187,8 +188,8 @@ Ref<BinaryView> FileMetadata::OpenExistingDatabase(const string& path)
}
-Ref<BinaryView> FileMetadata::OpenExistingDatabase(const string& path,
- const function<bool(size_t progress, size_t total)>& progressCallback)
+Ref<BinaryView> FileMetadata::OpenExistingDatabase(
+ const string& path, const function<bool(size_t progress, size_t total)>& progressCallback)
{
DatabaseProgressCallbackContext cb;
cb.func = progressCallback;
@@ -214,17 +215,18 @@ bool FileMetadata::SaveAutoSnapshot(BinaryView* data, Ref<SaveSettings> settings
}
-bool FileMetadata::SaveAutoSnapshot(BinaryView* data,
- const function<bool(size_t progress, size_t total)>& progressCallback, Ref<SaveSettings> settings)
+bool FileMetadata::SaveAutoSnapshot(
+ BinaryView* data, const function<bool(size_t progress, size_t total)>& progressCallback, Ref<SaveSettings> settings)
{
DatabaseProgressCallbackContext cb;
cb.func = progressCallback;
- return BNSaveAutoSnapshotWithProgress(data->GetObject(), &cb, DatabaseProgressCallback, settings ? settings->GetObject() : nullptr);
+ return BNSaveAutoSnapshotWithProgress(
+ data->GetObject(), &cb, DatabaseProgressCallback, settings ? settings->GetObject() : nullptr);
}
-void FileMetadata::GetSnapshotData(Ref<KeyValueStore> data, Ref<KeyValueStore> cache,
- const std::function<bool(size_t, size_t)>& progress)
+void FileMetadata::GetSnapshotData(
+ Ref<KeyValueStore> data, Ref<KeyValueStore> cache, const std::function<bool(size_t, size_t)>& progress)
{
DatabaseProgressCallbackContext cb;
cb.func = progress;
@@ -233,11 +235,12 @@ void FileMetadata::GetSnapshotData(Ref<KeyValueStore> data, Ref<KeyValueStore> c
void FileMetadata::ApplySnapshotData(BinaryView* file, Ref<KeyValueStore> data, Ref<KeyValueStore> cache,
- const std::function<bool(size_t, size_t)>& progress, bool openForConfiguration, bool restoreRawView)
+ const std::function<bool(size_t, size_t)>& progress, bool openForConfiguration, bool restoreRawView)
{
DatabaseProgressCallbackContext cb;
cb.func = progress;
- BNApplySnapshotData(GetObject(), file->GetObject(), data->GetObject(), cache->GetObject(), &cb, DatabaseProgressCallback, openForConfiguration, restoreRawView);
+ BNApplySnapshotData(GetObject(), file->GetObject(), data->GetObject(), cache->GetObject(), &cb,
+ DatabaseProgressCallback, openForConfiguration, restoreRawView);
}
@@ -256,7 +259,8 @@ bool FileMetadata::Rebase(BinaryView* data, uint64_t address)
}
-bool FileMetadata::Rebase(BinaryView* data, uint64_t address, const function<bool(size_t progress, size_t total)>& progressCallback)
+bool FileMetadata::Rebase(
+ BinaryView* data, uint64_t address, const function<bool(size_t progress, size_t total)>& progressCallback)
{
DatabaseProgressCallbackContext cb;
cb.func = progressCallback;
@@ -264,7 +268,8 @@ bool FileMetadata::Rebase(BinaryView* data, uint64_t address, const function<boo
}
-MergeResult FileMetadata::MergeUserAnalysis(const std::string& name, const std::function<bool(size_t, size_t)>& progress, std::vector<string> excludedHashes)
+MergeResult FileMetadata::MergeUserAnalysis(
+ const std::string& name, const std::function<bool(size_t, size_t)>& progress, std::vector<string> excludedHashes)
{
size_t numHashes = excludedHashes.size();
char** tempList = new char*[numHashes];
@@ -274,7 +279,8 @@ MergeResult FileMetadata::MergeUserAnalysis(const std::string& name, const std::
DatabaseProgressCallbackContext cb;
cb.func = progress;
- BNMergeResult bnResult = BNMergeUserAnalysis(m_object, name.c_str(), &cb, DatabaseProgressCallback, tempList, numHashes);
+ BNMergeResult bnResult =
+ BNMergeUserAnalysis(m_object, name.c_str(), &cb, DatabaseProgressCallback, tempList, numHashes);
MergeResult result(bnResult);
BNFreeStringList(tempList, numHashes);
@@ -341,7 +347,7 @@ vector<UndoEntry> FileMetadata::GetUndoEntries()
result.push_back(temp);
}
- //BNFreeUndoEntries(entries, count);
+ // BNFreeUndoEntries(entries, count);
return result;
}
diff --git a/flowgraph.cpp b/flowgraph.cpp
index f4164110..204e3d19 100644
--- a/flowgraph.cpp
+++ b/flowgraph.cpp
@@ -24,8 +24,8 @@ using namespace BinaryNinja;
using namespace std;
-FlowGraphLayoutRequest::FlowGraphLayoutRequest(FlowGraph* graph, const std::function<void()>& completeFunc):
- m_completeFunc(completeFunc)
+FlowGraphLayoutRequest::FlowGraphLayoutRequest(FlowGraph* graph, const std::function<void()>& completeFunc) :
+ m_completeFunc(completeFunc)
{
m_object = BNStartFlowGraphLayout(graph->GetObject(), this, CompleteCallback);
}
@@ -65,7 +65,8 @@ void FlowGraphLayoutRequest::Abort()
// Must clear the callback with the core before clearing our own function object, as until it
// is cleared in the core it can be called at any time from a different thread.
BNAbortFlowGraphLayoutRequest(m_object);
- m_completeFunc = []() {};
+ m_completeFunc = []() {
+ };
}
@@ -141,14 +142,10 @@ void FlowGraph::PrepareForLayout()
}
-void FlowGraph::PopulateNodes()
-{
-}
+void FlowGraph::PopulateNodes() {}
-void FlowGraph::CompleteLayout()
-{
-}
+void FlowGraph::CompleteLayout() {}
Ref<Function> FlowGraph::GetFunction() const
@@ -410,7 +407,7 @@ bool FlowGraph::IsOptionSet(BNFlowGraphOption option)
}
-CoreFlowGraph::CoreFlowGraph(BNFlowGraph* graph): FlowGraph(graph)
+CoreFlowGraph::CoreFlowGraph(BNFlowGraph* graph) : FlowGraph(graph)
{
m_queryMode = BNFlowGraphUpdateQueryMode(GetObject());
}
diff --git a/function.cpp b/function.cpp
index 5b1d2ba4..e962c1ba 100644
--- a/function.cpp
+++ b/function.cpp
@@ -101,9 +101,7 @@ Variable Variable::FromIdentifier(uint64_t id)
}
-RegisterValue::RegisterValue(): state(UndeterminedValue), value(0), offset(0)
-{
-}
+RegisterValue::RegisterValue() : state(UndeterminedValue), value(0), offset(0) {}
bool RegisterValue::IsConstant() const
@@ -315,20 +313,19 @@ void Function::RemoveUserTypeReference(Architecture* fromArch, uint64_t fromAddr
}
-void Function::AddUserTypeFieldReference(Architecture* fromArch, uint64_t fromAddr, const QualifiedName& name, uint64_t offset, size_t size)
+void Function::AddUserTypeFieldReference(
+ Architecture* fromArch, uint64_t fromAddr, const QualifiedName& name, uint64_t offset, size_t size)
{
BNQualifiedName nameObj = name.GetAPIObject();
- BNAddUserTypeFieldReference(m_object, fromArch->GetObject(), fromAddr, &nameObj, offset,
- size);
+ BNAddUserTypeFieldReference(m_object, fromArch->GetObject(), fromAddr, &nameObj, offset, size);
}
-void Function::RemoveUserTypeFieldReference(Architecture* fromArch, uint64_t fromAddr,
- const QualifiedName& name, uint64_t offset, size_t size)
+void Function::RemoveUserTypeFieldReference(
+ Architecture* fromArch, uint64_t fromAddr, const QualifiedName& name, uint64_t offset, size_t size)
{
BNQualifiedName nameObj = name.GetAPIObject();
- BNRemoveUserTypeFieldReference(m_object, fromArch->GetObject(), fromAddr, &nameObj,
- offset, size);
+ BNRemoveUserTypeFieldReference(m_object, fromArch->GetObject(), fromAddr, &nameObj, offset, size);
}
@@ -401,7 +398,7 @@ PossibleValueSet PossibleValueSet::FromAPIObject(BNPossibleValueSet& value)
{
LookupTableEntry entry;
entry.fromValues.insert(entry.fromValues.end(), &value.table[i].fromValues[0],
- &value.table[i].fromValues[value.table[i].fromCount]);
+ &value.table[i].fromValues[value.table[i].fromCount]);
entry.toValue = value.table[i].toValue;
result.table.push_back(entry);
}
@@ -423,7 +420,7 @@ PossibleValueSet PossibleValueSet::FromAPIObject(BNPossibleValueSet& value)
}
-BNPossibleValueSet PossibleValueSet::ToAPIObject ()
+BNPossibleValueSet PossibleValueSet::ToAPIObject()
{
BNPossibleValueSet result;
result.state = state;
@@ -450,8 +447,7 @@ BNPossibleValueSet PossibleValueSet::ToAPIObject ()
for (size_t i = 0; i < table.size(); i++)
{
result.table[i].fromValues = new int64_t[table[i].fromValues.size()];
- memcpy(result.table[i].fromValues, &table[i].fromValues[0], sizeof(int64_t) *
- table[i].fromValues.size());
+ memcpy(result.table[i].fromValues, &table[i].fromValues[0], sizeof(int64_t) * table[i].fromValues.size());
result.table[i].fromCount = table[i].fromValues.size();
result.table[i].toValue = table[i].toValue;
}
@@ -508,16 +504,16 @@ RegisterValue Function::GetStackContentsAfterInstruction(Architecture* arch, uin
RegisterValue Function::GetParameterValueAtInstruction(Architecture* arch, uint64_t addr, Type* functionType, size_t i)
{
- BNRegisterValue value = BNGetParameterValueAtInstruction(m_object, arch->GetObject(), addr,
- functionType ? functionType->GetObject() : nullptr, i);
+ BNRegisterValue value = BNGetParameterValueAtInstruction(
+ m_object, arch->GetObject(), addr, functionType ? functionType->GetObject() : nullptr, i);
return RegisterValue::FromAPIObject(value);
}
RegisterValue Function::GetParameterValueAtLowLevelILInstruction(size_t instr, Type* functionType, size_t i)
{
- BNRegisterValue value = BNGetParameterValueAtLowLevelILInstruction(m_object, instr,
- functionType ? functionType->GetObject() : nullptr, i);
+ BNRegisterValue value = BNGetParameterValueAtLowLevelILInstruction(
+ m_object, instr, functionType ? functionType->GetObject() : nullptr, i);
return RegisterValue::FromAPIObject(value);
}
@@ -551,7 +547,8 @@ vector<uint32_t> Function::GetRegistersWrittenByInstruction(Architecture* arch,
vector<StackVariableReference> Function::GetStackVariablesReferencedByInstruction(Architecture* arch, uint64_t addr)
{
size_t count;
- BNStackVariableReference* refs = BNGetStackVariablesReferencedByInstruction(m_object, arch->GetObject(), addr, &count);
+ BNStackVariableReference* refs =
+ BNGetStackVariablesReferencedByInstruction(m_object, arch->GetObject(), addr, &count);
vector<StackVariableReference> result;
result.reserve(count);
@@ -559,8 +556,8 @@ vector<StackVariableReference> Function::GetStackVariablesReferencedByInstructio
{
StackVariableReference ref;
ref.sourceOperand = refs[i].sourceOperand;
- ref.type = Confidence<Ref<Type>>(refs[i].type ? new Type(BNNewTypeReference(refs[i].type)) : nullptr,
- refs[i].typeConfidence);
+ ref.type = Confidence<Ref<Type>>(
+ refs[i].type ? new Type(BNNewTypeReference(refs[i].type)) : nullptr, refs[i].typeConfidence);
ref.name = refs[i].name;
ref.var = Variable::FromIdentifier(refs[i].varIdentifier);
ref.referencedOffset = refs[i].referencedOffset;
@@ -787,7 +784,8 @@ map<uint32_t, Confidence<int32_t>> Function::GetRegisterStackAdjustments() const
BNRegisterStackAdjustment* regStackAdjust = BNGetFunctionRegisterStackAdjustments(m_object, &count);
map<uint32_t, Confidence<int32_t>> result;
for (size_t i = 0; i < count; i++)
- result[regStackAdjust[i].regStack] = Confidence<int32_t>(regStackAdjust[i].adjustment, regStackAdjust[i].confidence);
+ result[regStackAdjust[i].regStack] =
+ Confidence<int32_t>(regStackAdjust[i].adjustment, regStackAdjust[i].confidence);
BNFreeRegisterStackAdjustments(regStackAdjust);
return result;
}
@@ -1102,8 +1100,8 @@ void Function::DeleteUserStackVariable(int64_t offset)
}
-bool Function::GetStackVariableAtFrameOffset(Architecture* arch, uint64_t addr,
- int64_t offset, VariableNameAndType& result)
+bool Function::GetStackVariableAtFrameOffset(
+ Architecture* arch, uint64_t addr, int64_t offset, VariableNameAndType& result)
{
BNVariableNameAndType var;
if (!BNGetStackVariableAtFrameOffset(m_object, arch->GetObject(), addr, offset, &var))
@@ -1380,8 +1378,8 @@ set<SSAVariable> Function::GetHighLevelILSSAVariablesIfAvailable()
}
-void Function::CreateAutoVariable(const Variable& var, const Confidence<Ref<Type>>& type,
- const string& name, bool ignoreDisjointUses)
+void Function::CreateAutoVariable(
+ const Variable& var, const Confidence<Ref<Type>>& type, const string& name, bool ignoreDisjointUses)
{
BNTypeWithConfidence tc;
tc.type = type->GetObject();
@@ -1390,8 +1388,8 @@ void Function::CreateAutoVariable(const Variable& var, const Confidence<Ref<Type
}
-void Function::CreateUserVariable(const Variable& var, const Confidence<Ref<Type>>& type,
- const string& name, bool ignoreDisjointUses)
+void Function::CreateUserVariable(
+ const Variable& var, const Confidence<Ref<Type>>& type, const string& name, bool ignoreDisjointUses)
{
BNTypeWithConfidence tc;
tc.type = type->GetObject();
@@ -1430,7 +1428,8 @@ string Function::GetVariableName(const Variable& var)
}
-void Function::SetAutoIndirectBranches(Architecture* sourceArch, uint64_t source, const std::vector<ArchAndAddr>& branches)
+void Function::SetAutoIndirectBranches(
+ Architecture* sourceArch, uint64_t source, const std::vector<ArchAndAddr>& branches)
{
BNArchitectureAndAddress* branchList = new BNArchitectureAndAddress[branches.size()];
for (size_t i = 0; i < branches.size(); i++)
@@ -1443,7 +1442,8 @@ void Function::SetAutoIndirectBranches(Architecture* sourceArch, uint64_t source
}
-void Function::SetUserIndirectBranches(Architecture* sourceArch, uint64_t source, const std::vector<ArchAndAddr>& branches)
+void Function::SetUserIndirectBranches(
+ Architecture* sourceArch, uint64_t source, const std::vector<ArchAndAddr>& branches)
{
BNArchitectureAndAddress* branchList = new BNArchitectureAndAddress[branches.size()];
for (size_t i = 0; i < branches.size(); i++)
@@ -1534,8 +1534,8 @@ void Function::SetAutoCallStackAdjustment(Architecture* arch, uint64_t addr, con
}
-void Function::SetAutoCallRegisterStackAdjustment(Architecture* arch, uint64_t addr,
- const map<uint32_t, Confidence<int32_t>>& adjust)
+void Function::SetAutoCallRegisterStackAdjustment(
+ Architecture* arch, uint64_t addr, const map<uint32_t, Confidence<int32_t>>& adjust)
{
BNRegisterStackAdjustment* values = new BNRegisterStackAdjustment[adjust.size()];
size_t i = 0;
@@ -1551,11 +1551,11 @@ void Function::SetAutoCallRegisterStackAdjustment(Architecture* arch, uint64_t a
}
-void Function::SetAutoCallRegisterStackAdjustment(Architecture* arch, uint64_t addr, uint32_t regStack,
- const Confidence<int32_t>& adjust)
+void Function::SetAutoCallRegisterStackAdjustment(
+ Architecture* arch, uint64_t addr, uint32_t regStack, const Confidence<int32_t>& adjust)
{
- BNSetAutoCallRegisterStackAdjustmentForRegisterStack(m_object, arch->GetObject(), addr, regStack,
- adjust.GetValue(), adjust.GetConfidence());
+ BNSetAutoCallRegisterStackAdjustmentForRegisterStack(
+ m_object, arch->GetObject(), addr, regStack, adjust.GetValue(), adjust.GetConfidence());
}
@@ -1574,8 +1574,8 @@ void Function::SetUserCallStackAdjustment(Architecture* arch, uint64_t addr, con
}
-void Function::SetUserCallRegisterStackAdjustment(Architecture* arch, uint64_t addr,
- const map<uint32_t, Confidence<int32_t>>& adjust)
+void Function::SetUserCallRegisterStackAdjustment(
+ Architecture* arch, uint64_t addr, const map<uint32_t, Confidence<int32_t>>& adjust)
{
BNRegisterStackAdjustment* values = new BNRegisterStackAdjustment[adjust.size()];
size_t i = 0;
@@ -1591,11 +1591,11 @@ void Function::SetUserCallRegisterStackAdjustment(Architecture* arch, uint64_t a
}
-void Function::SetUserCallRegisterStackAdjustment(Architecture* arch, uint64_t addr, uint32_t regStack,
- const Confidence<int32_t>& adjust)
+void Function::SetUserCallRegisterStackAdjustment(
+ Architecture* arch, uint64_t addr, uint32_t regStack, const Confidence<int32_t>& adjust)
{
- BNSetUserCallRegisterStackAdjustmentForRegisterStack(m_object, arch->GetObject(), addr, regStack,
- adjust.GetValue(), adjust.GetConfidence());
+ BNSetUserCallRegisterStackAdjustmentForRegisterStack(
+ m_object, arch->GetObject(), addr, regStack, adjust.GetValue(), adjust.GetConfidence());
}
@@ -1628,8 +1628,8 @@ map<uint32_t, Confidence<int32_t>> Function::GetCallRegisterStackAdjustment(Arch
Confidence<int32_t> Function::GetCallRegisterStackAdjustment(Architecture* arch, uint64_t addr, uint32_t regStack)
{
- BNRegisterStackAdjustment result = BNGetCallRegisterStackAdjustmentForRegisterStack(m_object,
- arch->GetObject(), addr, regStack);
+ BNRegisterStackAdjustment result =
+ BNGetCallRegisterStackAdjustmentForRegisterStack(m_object, arch->GetObject(), addr, regStack);
return Confidence<int32_t>(result.adjustment, result.confidence);
}
@@ -1655,15 +1655,15 @@ vector<vector<InstructionTextToken>> Function::GetBlockAnnotations(Architecture*
}
-BNIntegerDisplayType Function::GetIntegerConstantDisplayType(Architecture* arch, uint64_t instrAddr, uint64_t value,
- size_t operand)
+BNIntegerDisplayType Function::GetIntegerConstantDisplayType(
+ Architecture* arch, uint64_t instrAddr, uint64_t value, size_t operand)
{
return BNGetIntegerConstantDisplayType(m_object, arch->GetObject(), instrAddr, value, operand);
}
-void Function::SetIntegerConstantDisplayType(Architecture* arch, uint64_t instrAddr, uint64_t value, size_t operand,
- BNIntegerDisplayType type)
+void Function::SetIntegerConstantDisplayType(
+ Architecture* arch, uint64_t instrAddr, uint64_t value, size_t operand, BNIntegerDisplayType type)
{
BNSetIntegerConstantDisplayType(m_object, arch->GetObject(), instrAddr, value, operand, type);
}
@@ -1681,8 +1681,8 @@ void Function::SetAutoInstructionHighlight(Architecture* arch, uint64_t addr, BN
}
-void Function::SetAutoInstructionHighlight(Architecture* arch, uint64_t addr, BNHighlightStandardColor color,
- uint8_t alpha)
+void Function::SetAutoInstructionHighlight(
+ Architecture* arch, uint64_t addr, BNHighlightStandardColor color, uint8_t alpha)
{
BNHighlightColor hc;
hc.style = StandardHighlightColor;
@@ -1698,7 +1698,7 @@ void Function::SetAutoInstructionHighlight(Architecture* arch, uint64_t addr, BN
void Function::SetAutoInstructionHighlight(Architecture* arch, uint64_t addr, BNHighlightStandardColor color,
- BNHighlightStandardColor mixColor, uint8_t mix, uint8_t alpha)
+ BNHighlightStandardColor mixColor, uint8_t mix, uint8_t alpha)
{
BNHighlightColor hc;
hc.style = MixedHighlightColor;
@@ -1713,8 +1713,8 @@ void Function::SetAutoInstructionHighlight(Architecture* arch, uint64_t addr, BN
}
-void Function::SetAutoInstructionHighlight(Architecture* arch, uint64_t addr, uint8_t r, uint8_t g, uint8_t b,
- uint8_t alpha)
+void Function::SetAutoInstructionHighlight(
+ Architecture* arch, uint64_t addr, uint8_t r, uint8_t g, uint8_t b, uint8_t alpha)
{
BNHighlightColor hc;
hc.style = CustomHighlightColor;
@@ -1735,8 +1735,8 @@ void Function::SetUserInstructionHighlight(Architecture* arch, uint64_t addr, BN
}
-void Function::SetUserInstructionHighlight(Architecture* arch, uint64_t addr, BNHighlightStandardColor color,
- uint8_t alpha)
+void Function::SetUserInstructionHighlight(
+ Architecture* arch, uint64_t addr, BNHighlightStandardColor color, uint8_t alpha)
{
BNHighlightColor hc;
hc.style = StandardHighlightColor;
@@ -1752,7 +1752,7 @@ void Function::SetUserInstructionHighlight(Architecture* arch, uint64_t addr, BN
void Function::SetUserInstructionHighlight(Architecture* arch, uint64_t addr, BNHighlightStandardColor color,
- BNHighlightStandardColor mixColor, uint8_t mix, uint8_t alpha)
+ BNHighlightStandardColor mixColor, uint8_t mix, uint8_t alpha)
{
BNHighlightColor hc;
hc.style = MixedHighlightColor;
@@ -1767,8 +1767,8 @@ void Function::SetUserInstructionHighlight(Architecture* arch, uint64_t addr, BN
}
-void Function::SetUserInstructionHighlight(Architecture* arch, uint64_t addr, uint8_t r, uint8_t g, uint8_t b,
- uint8_t alpha)
+void Function::SetUserInstructionHighlight(
+ Architecture* arch, uint64_t addr, uint8_t r, uint8_t g, uint8_t b, uint8_t alpha)
{
BNHighlightColor hc;
hc.style = CustomHighlightColor;
@@ -2039,7 +2039,8 @@ void Function::RemoveUserFunctionTagsOfType(Ref<TagType> tagType)
}
-Ref<Tag> Function::CreateAutoAddressTag(Architecture* arch, uint64_t addr, const std::string& tagTypeName, const std::string& data, bool unique)
+Ref<Tag> Function::CreateAutoAddressTag(
+ Architecture* arch, uint64_t addr, const std::string& tagTypeName, const std::string& data, bool unique)
{
Ref<TagType> tagType = GetView()->GetTagTypeByName(tagTypeName);
if (!tagType)
@@ -2049,7 +2050,8 @@ Ref<Tag> Function::CreateAutoAddressTag(Architecture* arch, uint64_t addr, const
}
-Ref<Tag> Function::CreateAutoAddressTag(Architecture* arch, uint64_t addr, Ref<TagType> tagType, const std::string& data, bool unique)
+Ref<Tag> Function::CreateAutoAddressTag(
+ Architecture* arch, uint64_t addr, Ref<TagType> tagType, const std::string& data, bool unique)
{
if (unique)
{
@@ -2069,7 +2071,8 @@ Ref<Tag> Function::CreateAutoAddressTag(Architecture* arch, uint64_t addr, Ref<T
}
-Ref<Tag> Function::CreateUserAddressTag(Architecture* arch, uint64_t addr, const std::string& tagTypeName, const std::string& data, bool unique)
+Ref<Tag> Function::CreateUserAddressTag(
+ Architecture* arch, uint64_t addr, const std::string& tagTypeName, const std::string& data, bool unique)
{
Ref<TagType> tagType = GetView()->GetTagTypeByName(tagTypeName);
if (!tagType)
@@ -2079,7 +2082,8 @@ Ref<Tag> Function::CreateUserAddressTag(Architecture* arch, uint64_t addr, const
}
-Ref<Tag> Function::CreateUserAddressTag(Architecture* arch, uint64_t addr, Ref<TagType> tagType, const std::string& data, bool unique)
+Ref<Tag> Function::CreateUserAddressTag(
+ Architecture* arch, uint64_t addr, Ref<TagType> tagType, const std::string& data, bool unique)
{
if (unique)
{
@@ -2225,8 +2229,8 @@ map<string, double> Function::GetAnalysisPerformanceInfo()
vector<DisassemblyTextLine> Function::GetTypeTokens(DisassemblySettings* settings)
{
size_t count;
- BNDisassemblyTextLine* lines = BNGetFunctionTypeTokens(m_object,
- settings ? settings->GetObject() : nullptr, &count);
+ BNDisassemblyTextLine* lines =
+ BNGetFunctionTypeTokens(m_object, settings ? settings->GetObject() : nullptr, &count);
vector<DisassemblyTextLine> result;
result.reserve(count);
@@ -2466,7 +2470,8 @@ vector<ILReferenceSource> Function::GetMediumLevelILVariableReferences(const Var
vector<VariableReferenceSource> Function::GetMediumLevelILVariableReferencesFrom(Architecture* arch, uint64_t addr)
{
size_t count;
- BNVariableReferenceSource* refs = BNGetMediumLevelILVariableReferencesFrom(m_object, arch->GetObject(), addr, &count);
+ BNVariableReferenceSource* refs =
+ BNGetMediumLevelILVariableReferencesFrom(m_object, arch->GetObject(), addr, &count);
vector<VariableReferenceSource> result;
result.reserve(count);
@@ -2491,10 +2496,12 @@ vector<VariableReferenceSource> Function::GetMediumLevelILVariableReferencesFrom
}
-vector<VariableReferenceSource> Function::GetMediumLevelILVariableReferencesInRange(Architecture* arch, uint64_t addr, uint64_t len)
+vector<VariableReferenceSource> Function::GetMediumLevelILVariableReferencesInRange(
+ Architecture* arch, uint64_t addr, uint64_t len)
{
size_t count;
- BNVariableReferenceSource* refs = BNGetMediumLevelILVariableReferencesInRange(m_object, arch->GetObject(), addr, len, &count);
+ BNVariableReferenceSource* refs =
+ BNGetMediumLevelILVariableReferencesInRange(m_object, arch->GetObject(), addr, len, &count);
vector<VariableReferenceSource> result;
result.reserve(count);
@@ -2576,10 +2583,12 @@ vector<VariableReferenceSource> Function::GetHighLevelILVariableReferencesFrom(A
}
-vector<VariableReferenceSource> Function::GetHighLevelILVariableReferencesInRange(Architecture* arch, uint64_t addr, uint64_t len)
+vector<VariableReferenceSource> Function::GetHighLevelILVariableReferencesInRange(
+ Architecture* arch, uint64_t addr, uint64_t len)
{
size_t count;
- BNVariableReferenceSource* refs = BNGetHighLevelILVariableReferencesInRange(m_object, arch->GetObject(), addr, len, &count);
+ BNVariableReferenceSource* refs =
+ BNGetHighLevelILVariableReferencesInRange(m_object, arch->GetObject(), addr, len, &count);
vector<VariableReferenceSource> result;
result.reserve(count);
@@ -2633,10 +2642,12 @@ vector<ILReferenceSource> Function::GetMediumLevelILVariableReferencesIfAvailabl
}
-vector<VariableReferenceSource> Function::GetMediumLevelILVariableReferencesFromIfAvailable(Architecture* arch, uint64_t addr)
+vector<VariableReferenceSource> Function::GetMediumLevelILVariableReferencesFromIfAvailable(
+ Architecture* arch, uint64_t addr)
{
size_t count;
- BNVariableReferenceSource* refs = BNGetMediumLevelILVariableReferencesFromIfAvailable(m_object, arch->GetObject(), addr, &count);
+ BNVariableReferenceSource* refs =
+ BNGetMediumLevelILVariableReferencesFromIfAvailable(m_object, arch->GetObject(), addr, &count);
vector<VariableReferenceSource> result;
result.reserve(count);
@@ -2661,10 +2672,12 @@ vector<VariableReferenceSource> Function::GetMediumLevelILVariableReferencesFrom
}
-vector<VariableReferenceSource> Function::GetMediumLevelILVariableReferencesInRangeIfAvailable(Architecture* arch, uint64_t addr, uint64_t len)
+vector<VariableReferenceSource> Function::GetMediumLevelILVariableReferencesInRangeIfAvailable(
+ Architecture* arch, uint64_t addr, uint64_t len)
{
size_t count;
- BNVariableReferenceSource* refs = BNGetMediumLevelILVariableReferencesInRangeIfAvailable(m_object, arch->GetObject(), addr, len, &count);
+ BNVariableReferenceSource* refs =
+ BNGetMediumLevelILVariableReferencesInRangeIfAvailable(m_object, arch->GetObject(), addr, len, &count);
vector<VariableReferenceSource> result;
result.reserve(count);
@@ -2718,10 +2731,12 @@ vector<ILReferenceSource> Function::GetHighLevelILVariableReferencesIfAvailable(
}
-vector<VariableReferenceSource> Function::GetHighLevelILVariableReferencesFromIfAvailable(Architecture* arch, uint64_t addr)
+vector<VariableReferenceSource> Function::GetHighLevelILVariableReferencesFromIfAvailable(
+ Architecture* arch, uint64_t addr)
{
size_t count;
- BNVariableReferenceSource* refs = BNGetHighLevelILVariableReferencesFromIfAvailable(m_object, arch->GetObject(), addr, &count);
+ BNVariableReferenceSource* refs =
+ BNGetHighLevelILVariableReferencesFromIfAvailable(m_object, arch->GetObject(), addr, &count);
vector<VariableReferenceSource> result;
result.reserve(count);
@@ -2746,10 +2761,12 @@ vector<VariableReferenceSource> Function::GetHighLevelILVariableReferencesFromIf
}
-vector<VariableReferenceSource> Function::GetHighLevelILVariableReferencesInRangeIfAvailable(Architecture* arch, uint64_t addr, uint64_t len)
+vector<VariableReferenceSource> Function::GetHighLevelILVariableReferencesInRangeIfAvailable(
+ Architecture* arch, uint64_t addr, uint64_t len)
{
size_t count;
- BNVariableReferenceSource* refs = BNGetHighLevelILVariableReferencesInRangeIfAvailable(m_object, arch->GetObject(), addr, len, &count);
+ BNVariableReferenceSource* refs =
+ BNGetHighLevelILVariableReferencesInRangeIfAvailable(m_object, arch->GetObject(), addr, len, &count);
vector<VariableReferenceSource> result;
result.reserve(count);
@@ -2798,21 +2815,21 @@ std::vector<BNAddressRange> Function::GetAddressRanges()
}
-bool Function::GetInstructionContainingAddress(Architecture* arch,
- uint64_t addr, uint64_t* start)
+bool Function::GetInstructionContainingAddress(Architecture* arch, uint64_t addr, uint64_t* start)
{
return BNGetInstructionContainingAddress(m_object, arch->GetObject(), addr, start);
}
-AdvancedFunctionAnalysisDataRequestor::AdvancedFunctionAnalysisDataRequestor(Function* func): m_func(func)
+AdvancedFunctionAnalysisDataRequestor::AdvancedFunctionAnalysisDataRequestor(Function* func) : m_func(func)
{
if (m_func)
m_func->RequestAdvancedAnalysisData();
}
-AdvancedFunctionAnalysisDataRequestor::AdvancedFunctionAnalysisDataRequestor(const AdvancedFunctionAnalysisDataRequestor& req)
+AdvancedFunctionAnalysisDataRequestor::AdvancedFunctionAnalysisDataRequestor(
+ const AdvancedFunctionAnalysisDataRequestor& req)
{
m_func = req.m_func;
if (m_func)
@@ -2828,7 +2845,7 @@ AdvancedFunctionAnalysisDataRequestor::~AdvancedFunctionAnalysisDataRequestor()
AdvancedFunctionAnalysisDataRequestor& AdvancedFunctionAnalysisDataRequestor::operator=(
- const AdvancedFunctionAnalysisDataRequestor& req)
+ const AdvancedFunctionAnalysisDataRequestor& req)
{
SetFunction(req.m_func);
return *this;
diff --git a/functionrecognizer.cpp b/functionrecognizer.cpp
index 7faa465e..b5479987 100644
--- a/functionrecognizer.cpp
+++ b/functionrecognizer.cpp
@@ -23,12 +23,11 @@
using namespace BinaryNinja;
-FunctionRecognizer::FunctionRecognizer()
-{
-}
+FunctionRecognizer::FunctionRecognizer() {}
-bool FunctionRecognizer::RecognizeLowLevelILCallback(void* ctxt, BNBinaryView* data, BNFunction* func, BNLowLevelILFunction* il)
+bool FunctionRecognizer::RecognizeLowLevelILCallback(
+ void* ctxt, BNBinaryView* data, BNFunction* func, BNLowLevelILFunction* il)
{
FunctionRecognizer* recog = (FunctionRecognizer*)ctxt;
Ref<BinaryView> dataObj = new BinaryView(BNNewViewReference(data));
@@ -38,7 +37,8 @@ bool FunctionRecognizer::RecognizeLowLevelILCallback(void* ctxt, BNBinaryView* d
}
-bool FunctionRecognizer::RecognizeMediumLevelILCallback(void* ctxt, BNBinaryView* data, BNFunction* func, BNMediumLevelILFunction* il)
+bool FunctionRecognizer::RecognizeMediumLevelILCallback(
+ void* ctxt, BNBinaryView* data, BNFunction* func, BNMediumLevelILFunction* il)
{
FunctionRecognizer* recog = (FunctionRecognizer*)ctxt;
Ref<BinaryView> dataObj = new BinaryView(BNNewViewReference(data));
diff --git a/highlevelil.cpp b/highlevelil.cpp
index 8856b551..5bebcca8 100644
--- a/highlevelil.cpp
+++ b/highlevelil.cpp
@@ -85,27 +85,27 @@ void HighLevelILFunction::SetRootExpr(const HighLevelILInstruction& expr)
}
-ExprId HighLevelILFunction::AddExpr(BNHighLevelILOperation operation, size_t size,
- ExprId a, ExprId b, ExprId c, ExprId d, ExprId e)
+ExprId HighLevelILFunction::AddExpr(
+ BNHighLevelILOperation operation, size_t size, ExprId a, ExprId b, ExprId c, ExprId d, ExprId e)
{
return BNHighLevelILAddExpr(m_object, operation, size, a, b, c, d, e);
}
-ExprId HighLevelILFunction::AddExprWithLocation(BNHighLevelILOperation operation, uint64_t addr,
- uint32_t sourceOperand, size_t size, ExprId a, ExprId b, ExprId c, ExprId d, ExprId e)
+ExprId HighLevelILFunction::AddExprWithLocation(BNHighLevelILOperation operation, uint64_t addr, uint32_t sourceOperand,
+ size_t size, ExprId a, ExprId b, ExprId c, ExprId d, ExprId e)
{
return BNHighLevelILAddExprWithLocation(m_object, operation, addr, sourceOperand, size, a, b, c, d, e);
}
ExprId HighLevelILFunction::AddExprWithLocation(BNHighLevelILOperation operation, const ILSourceLocation& loc,
- size_t size, ExprId a, ExprId b, ExprId c, ExprId d, ExprId e)
+ size_t size, ExprId a, ExprId b, ExprId c, ExprId d, ExprId e)
{
if (loc.valid)
{
- return BNHighLevelILAddExprWithLocation(m_object, operation, loc.address, loc.sourceOperand,
- size, a, b, c, d, e);
+ return BNHighLevelILAddExprWithLocation(
+ m_object, operation, loc.address, loc.sourceOperand, size, a, b, c, d, e);
}
return BNHighLevelILAddExpr(m_object, operation, size, a, b, c, d, e);
}
@@ -428,12 +428,11 @@ void HighLevelILFunction::Finalize()
}
-vector<DisassemblyTextLine> HighLevelILFunction::GetExprText(ExprId expr,
- bool asFullAst, DisassemblySettings* settings)
+vector<DisassemblyTextLine> HighLevelILFunction::GetExprText(ExprId expr, bool asFullAst, DisassemblySettings* settings)
{
size_t count;
- BNDisassemblyTextLine* lines = BNGetHighLevelILExprText(m_object, expr, asFullAst, &count,
- settings ? settings->GetObject() : nullptr);
+ BNDisassemblyTextLine* lines =
+ BNGetHighLevelILExprText(m_object, expr, asFullAst, &count, settings ? settings->GetObject() : nullptr);
vector<DisassemblyTextLine> result;
result.reserve(count);
@@ -453,15 +452,15 @@ vector<DisassemblyTextLine> HighLevelILFunction::GetExprText(ExprId expr,
}
-vector<DisassemblyTextLine> HighLevelILFunction::GetExprText(const HighLevelILInstruction& instr,
- bool asFullAst, DisassemblySettings* settings)
+vector<DisassemblyTextLine> HighLevelILFunction::GetExprText(
+ const HighLevelILInstruction& instr, bool asFullAst, DisassemblySettings* settings)
{
return GetExprText(instr.exprIndex, asFullAst, settings);
}
-vector<DisassemblyTextLine> HighLevelILFunction::GetInstructionText(size_t i,
- bool asFullAst, DisassemblySettings* settings)
+vector<DisassemblyTextLine> HighLevelILFunction::GetInstructionText(
+ size_t i, bool asFullAst, DisassemblySettings* settings)
{
HighLevelILInstruction instr = GetInstruction(i);
return GetExprText(instr, asFullAst, settings);
@@ -483,12 +482,9 @@ Confidence<Ref<Type>> HighLevelILFunction::GetExprType(const HighLevelILInstruct
}
-void HighLevelILFunction::VisitAllExprs(
- const function<bool(const HighLevelILInstruction& expr)>& func)
+void HighLevelILFunction::VisitAllExprs(const function<bool(const HighLevelILInstruction& expr)>& func)
{
- GetRootExpr().VisitExprs([&](const HighLevelILInstruction& expr) {
- return func(expr);
- });
+ GetRootExpr().VisitExprs([&](const HighLevelILInstruction& expr) { return func(expr); });
}
diff --git a/highlevelilinstruction.cpp b/highlevelilinstruction.cpp
index 2469f800..5f8777e1 100644
--- a/highlevelilinstruction.cpp
+++ b/highlevelilinstruction.cpp
@@ -19,15 +19,15 @@
// IN THE SOFTWARE.
#ifdef BINARYNINJACORE_LIBRARY
-#include "highlevelilfunction.h"
-#include "highlevelilssafunction.h"
-#include "mediumlevelilfunction.h"
-#include "mediumlevelilssafunction.h"
+ #include "highlevelilfunction.h"
+ #include "highlevelilssafunction.h"
+ #include "mediumlevelilfunction.h"
+ #include "mediumlevelilssafunction.h"
using namespace BinaryNinjaCore;
#else
-#include "binaryninjaapi.h"
-#include "highlevelilinstruction.h"
-#include "mediumlevelilinstruction.h"
+ #include "binaryninjaapi.h"
+ #include "highlevelilinstruction.h"
+ #include "mediumlevelilinstruction.h"
using namespace BinaryNinja;
#endif
@@ -36,193 +36,155 @@ using namespace std;
#endif
-unordered_map<HighLevelILOperandUsage, HighLevelILOperandType>
- HighLevelILInstructionBase::operandTypeForUsage = {
- {SourceExprHighLevelOperandUsage, ExprHighLevelOperand},
- {VariableHighLevelOperandUsage, VariableHighLevelOperand},
- {DestVariableHighLevelOperandUsage, VariableHighLevelOperand},
- {SSAVariableHighLevelOperandUsage, SSAVariableHighLevelOperand},
- {DestSSAVariableHighLevelOperandUsage, SSAVariableHighLevelOperand},
- {DestExprHighLevelOperandUsage, ExprHighLevelOperand},
- {LeftExprHighLevelOperandUsage, ExprHighLevelOperand},
- {RightExprHighLevelOperandUsage, ExprHighLevelOperand},
- {CarryExprHighLevelOperandUsage, ExprHighLevelOperand},
- {IndexExprHighLevelOperandUsage, ExprHighLevelOperand},
- {ConditionExprHighLevelOperandUsage, ExprHighLevelOperand},
- {ConditionPhiExprHighLevelOperandUsage, ExprHighLevelOperand},
- {TrueExprHighLevelOperandUsage, ExprHighLevelOperand},
- {FalseExprHighLevelOperandUsage, ExprHighLevelOperand},
- {LoopExprHighLevelOperandUsage, ExprHighLevelOperand},
- {InitExprHighLevelOperandUsage, ExprHighLevelOperand},
- {UpdateExprHighLevelOperandUsage, ExprHighLevelOperand},
- {DefaultExprHighLevelOperandUsage, ExprHighLevelOperand},
- {HighExprHighLevelOperandUsage, ExprHighLevelOperand},
- {LowExprHighLevelOperandUsage, ExprHighLevelOperand},
- {OffsetHighLevelOperandUsage, IntegerHighLevelOperand},
- {MemberIndexHighLevelOperandUsage, IndexHighLevelOperand},
- {ConstantHighLevelOperandUsage, IntegerHighLevelOperand},
- {VectorHighLevelOperandUsage, IntegerHighLevelOperand},
- {IntrinsicHighLevelOperandUsage, IntrinsicHighLevelOperand},
- {TargetHighLevelOperandUsage, IndexHighLevelOperand},
- {ParameterExprsHighLevelOperandUsage, ExprListHighLevelOperand},
- {SourceExprsHighLevelOperandUsage, ExprListHighLevelOperand},
- {DestExprsHighLevelOperandUsage, ExprListHighLevelOperand},
- {BlockExprsHighLevelOperandUsage, ExprListHighLevelOperand},
- {CasesHighLevelOperandUsage, ExprListHighLevelOperand},
- {ValueExprsHighLevelOperandUsage, ExprListHighLevelOperand},
- {SourceSSAVariablesHighLevelOperandUsage, SSAVariableListHighLevelOperand},
- {SourceMemoryVersionHighLevelOperandUsage, IndexHighLevelOperand},
- {SourceMemoryVersionsHighLevelOperandUsage, IndexListHighLevelOperand},
- {DestMemoryVersionHighLevelOperandUsage, IndexHighLevelOperand}
- };
+unordered_map<HighLevelILOperandUsage, HighLevelILOperandType> HighLevelILInstructionBase::operandTypeForUsage = {
+ {SourceExprHighLevelOperandUsage, ExprHighLevelOperand}, {VariableHighLevelOperandUsage, VariableHighLevelOperand},
+ {DestVariableHighLevelOperandUsage, VariableHighLevelOperand},
+ {SSAVariableHighLevelOperandUsage, SSAVariableHighLevelOperand},
+ {DestSSAVariableHighLevelOperandUsage, SSAVariableHighLevelOperand},
+ {DestExprHighLevelOperandUsage, ExprHighLevelOperand}, {LeftExprHighLevelOperandUsage, ExprHighLevelOperand},
+ {RightExprHighLevelOperandUsage, ExprHighLevelOperand}, {CarryExprHighLevelOperandUsage, ExprHighLevelOperand},
+ {IndexExprHighLevelOperandUsage, ExprHighLevelOperand}, {ConditionExprHighLevelOperandUsage, ExprHighLevelOperand},
+ {ConditionPhiExprHighLevelOperandUsage, ExprHighLevelOperand},
+ {TrueExprHighLevelOperandUsage, ExprHighLevelOperand}, {FalseExprHighLevelOperandUsage, ExprHighLevelOperand},
+ {LoopExprHighLevelOperandUsage, ExprHighLevelOperand}, {InitExprHighLevelOperandUsage, ExprHighLevelOperand},
+ {UpdateExprHighLevelOperandUsage, ExprHighLevelOperand}, {DefaultExprHighLevelOperandUsage, ExprHighLevelOperand},
+ {HighExprHighLevelOperandUsage, ExprHighLevelOperand}, {LowExprHighLevelOperandUsage, ExprHighLevelOperand},
+ {OffsetHighLevelOperandUsage, IntegerHighLevelOperand}, {MemberIndexHighLevelOperandUsage, IndexHighLevelOperand},
+ {ConstantHighLevelOperandUsage, IntegerHighLevelOperand}, {VectorHighLevelOperandUsage, IntegerHighLevelOperand},
+ {IntrinsicHighLevelOperandUsage, IntrinsicHighLevelOperand}, {TargetHighLevelOperandUsage, IndexHighLevelOperand},
+ {ParameterExprsHighLevelOperandUsage, ExprListHighLevelOperand},
+ {SourceExprsHighLevelOperandUsage, ExprListHighLevelOperand},
+ {DestExprsHighLevelOperandUsage, ExprListHighLevelOperand},
+ {BlockExprsHighLevelOperandUsage, ExprListHighLevelOperand}, {CasesHighLevelOperandUsage, ExprListHighLevelOperand},
+ {ValueExprsHighLevelOperandUsage, ExprListHighLevelOperand},
+ {SourceSSAVariablesHighLevelOperandUsage, SSAVariableListHighLevelOperand},
+ {SourceMemoryVersionHighLevelOperandUsage, IndexHighLevelOperand},
+ {SourceMemoryVersionsHighLevelOperandUsage, IndexListHighLevelOperand},
+ {DestMemoryVersionHighLevelOperandUsage, IndexHighLevelOperand}};
unordered_map<BNHighLevelILOperation, vector<HighLevelILOperandUsage>>
- HighLevelILInstructionBase::operationOperandUsage = {
- {HLIL_NOP, {}},
- {HLIL_BREAK, {}},
- {HLIL_CONTINUE, {}},
- {HLIL_NORET, {}},
- {HLIL_BP, {}},
- {HLIL_UNDEF, {}},
- {HLIL_UNIMPL, {}},
- {HLIL_BLOCK, {BlockExprsHighLevelOperandUsage}},
- {HLIL_IF, {ConditionExprHighLevelOperandUsage, TrueExprHighLevelOperandUsage,
- FalseExprHighLevelOperandUsage}},
- {HLIL_WHILE, {ConditionExprHighLevelOperandUsage, LoopExprHighLevelOperandUsage}},
- {HLIL_WHILE_SSA, {ConditionPhiExprHighLevelOperandUsage,
- ConditionExprHighLevelOperandUsage, LoopExprHighLevelOperandUsage}},
- {HLIL_DO_WHILE, {LoopExprHighLevelOperandUsage, ConditionExprHighLevelOperandUsage}},
- {HLIL_DO_WHILE_SSA, {LoopExprHighLevelOperandUsage, ConditionPhiExprHighLevelOperandUsage,
- ConditionExprHighLevelOperandUsage}},
- {HLIL_FOR, {InitExprHighLevelOperandUsage, ConditionExprHighLevelOperandUsage,
- UpdateExprHighLevelOperandUsage, LoopExprHighLevelOperandUsage}},
- {HLIL_FOR_SSA, {InitExprHighLevelOperandUsage, ConditionPhiExprHighLevelOperandUsage,
- ConditionExprHighLevelOperandUsage, UpdateExprHighLevelOperandUsage,
- LoopExprHighLevelOperandUsage}},
- {HLIL_SWITCH, {ConditionExprHighLevelOperandUsage, DefaultExprHighLevelOperandUsage,
- CasesHighLevelOperandUsage}},
- {HLIL_CASE, {ValueExprsHighLevelOperandUsage, TrueExprHighLevelOperandUsage}},
- {HLIL_JUMP, {DestExprHighLevelOperandUsage}},
- {HLIL_RET, {SourceExprsHighLevelOperandUsage}},
- {HLIL_GOTO, {TargetHighLevelOperandUsage}},
- {HLIL_LABEL, {TargetHighLevelOperandUsage}},
- {HLIL_VAR_DECLARE, {VariableHighLevelOperandUsage}},
- {HLIL_VAR_INIT, {DestVariableHighLevelOperandUsage, SourceExprHighLevelOperandUsage}},
- {HLIL_VAR_INIT_SSA, {DestSSAVariableHighLevelOperandUsage, SourceExprHighLevelOperandUsage}},
- {HLIL_ASSIGN, {DestExprHighLevelOperandUsage, SourceExprHighLevelOperandUsage}},
- {HLIL_ASSIGN_UNPACK, {DestExprsHighLevelOperandUsage, SourceExprHighLevelOperandUsage}},
- {HLIL_ASSIGN_MEM_SSA, {DestExprHighLevelOperandUsage, DestMemoryVersionHighLevelOperandUsage,
- SourceExprHighLevelOperandUsage, SourceMemoryVersionHighLevelOperandUsage}},
- {HLIL_ASSIGN_UNPACK, {DestExprsHighLevelOperandUsage, DestMemoryVersionHighLevelOperandUsage,
- SourceExprHighLevelOperandUsage, SourceMemoryVersionHighLevelOperandUsage}},
- {HLIL_VAR, {VariableHighLevelOperandUsage}},
- {HLIL_VAR_SSA, {SSAVariableHighLevelOperandUsage}},
- {HLIL_VAR_PHI, {DestSSAVariableHighLevelOperandUsage, SourceSSAVariablesHighLevelOperandUsage}},
- {HLIL_MEM_PHI, {DestMemoryVersionHighLevelOperandUsage, SourceMemoryVersionsHighLevelOperandUsage}},
- {HLIL_STRUCT_FIELD, {SourceExprHighLevelOperandUsage, OffsetHighLevelOperandUsage,
- MemberIndexHighLevelOperandUsage}},
- {HLIL_ARRAY_INDEX, {SourceExprHighLevelOperandUsage, IndexExprHighLevelOperandUsage}},
- {HLIL_ARRAY_INDEX_SSA, {SourceExprHighLevelOperandUsage, SourceMemoryVersionHighLevelOperandUsage,
- IndexExprHighLevelOperandUsage}},
- {HLIL_SPLIT, {HighExprHighLevelOperandUsage, LowExprHighLevelOperandUsage}},
- {HLIL_DEREF, {SourceExprHighLevelOperandUsage}},
- {HLIL_DEREF_FIELD, {SourceExprHighLevelOperandUsage, OffsetHighLevelOperandUsage,
- MemberIndexHighLevelOperandUsage}},
- {HLIL_DEREF_SSA, {SourceExprHighLevelOperandUsage, SourceMemoryVersionHighLevelOperandUsage}},
- {HLIL_DEREF_FIELD_SSA, {SourceExprHighLevelOperandUsage, SourceMemoryVersionHighLevelOperandUsage,
- OffsetHighLevelOperandUsage, MemberIndexHighLevelOperandUsage}},
- {HLIL_ADDRESS_OF, {SourceExprHighLevelOperandUsage}},
- {HLIL_CALL, {DestExprHighLevelOperandUsage, ParameterExprsHighLevelOperandUsage}},
- {HLIL_SYSCALL, {ParameterExprsHighLevelOperandUsage}},
- {HLIL_TAILCALL, {DestExprHighLevelOperandUsage, ParameterExprsHighLevelOperandUsage}},
- {HLIL_INTRINSIC, {IntrinsicHighLevelOperandUsage, ParameterExprsHighLevelOperandUsage}},
- {HLIL_CALL_SSA, {DestExprHighLevelOperandUsage, ParameterExprsHighLevelOperandUsage,
- DestMemoryVersionHighLevelOperandUsage, SourceMemoryVersionHighLevelOperandUsage}},
- {HLIL_SYSCALL_SSA, {ParameterExprsHighLevelOperandUsage, DestMemoryVersionHighLevelOperandUsage,
- SourceMemoryVersionHighLevelOperandUsage}},
- {HLIL_INTRINSIC_SSA, {IntrinsicHighLevelOperandUsage, ParameterExprsHighLevelOperandUsage,
- DestMemoryVersionHighLevelOperandUsage, SourceMemoryVersionHighLevelOperandUsage}},
- {HLIL_TRAP, {VectorHighLevelOperandUsage}},
- {HLIL_CONST, {ConstantHighLevelOperandUsage}},
- {HLIL_CONST_PTR, {ConstantHighLevelOperandUsage}},
- {HLIL_EXTERN_PTR, {ConstantHighLevelOperandUsage, OffsetHighLevelOperandUsage}},
- {HLIL_FLOAT_CONST, {ConstantHighLevelOperandUsage}},
- {HLIL_IMPORT, {ConstantHighLevelOperandUsage}},
- {HLIL_ADD, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
- {HLIL_SUB, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
- {HLIL_AND, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
- {HLIL_OR, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
- {HLIL_XOR, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
- {HLIL_LSL, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
- {HLIL_LSR, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
- {HLIL_ASR, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
- {HLIL_ROL, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
- {HLIL_ROR, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
- {HLIL_MUL, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
- {HLIL_MULU_DP, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
- {HLIL_MULS_DP, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
- {HLIL_DIVU, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
- {HLIL_DIVS, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
- {HLIL_MODU, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
- {HLIL_MODS, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
- {HLIL_CMP_E, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
- {HLIL_CMP_NE, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
- {HLIL_CMP_SLT, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
- {HLIL_CMP_ULT, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
- {HLIL_CMP_SLE, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
- {HLIL_CMP_ULE, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
- {HLIL_CMP_SGE, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
- {HLIL_CMP_UGE, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
- {HLIL_CMP_SGT, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
- {HLIL_CMP_UGT, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
- {HLIL_TEST_BIT, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
- {HLIL_ADD_OVERFLOW, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
- {HLIL_ADC, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage,
- CarryExprHighLevelOperandUsage}},
- {HLIL_SBB, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage,
- CarryExprHighLevelOperandUsage}},
- {HLIL_RLC, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage,
- CarryExprHighLevelOperandUsage}},
- {HLIL_RRC, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage,
- CarryExprHighLevelOperandUsage}},
- {HLIL_DIVU_DP, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
- {HLIL_DIVS_DP, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
- {HLIL_MODU_DP, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
- {HLIL_MODS_DP, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
- {HLIL_NEG, {SourceExprHighLevelOperandUsage}},
- {HLIL_NOT, {SourceExprHighLevelOperandUsage}},
- {HLIL_SX, {SourceExprHighLevelOperandUsage}},
- {HLIL_ZX, {SourceExprHighLevelOperandUsage}},
- {HLIL_LOW_PART, {SourceExprHighLevelOperandUsage}},
- {HLIL_BOOL_TO_INT, {SourceExprHighLevelOperandUsage}},
- {HLIL_UNIMPL_MEM, {SourceExprHighLevelOperandUsage}},
- {HLIL_FADD, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
- {HLIL_FSUB, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
- {HLIL_FMUL, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
- {HLIL_FDIV, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
- {HLIL_FSQRT, {SourceExprHighLevelOperandUsage}},
- {HLIL_FNEG, {SourceExprHighLevelOperandUsage}},
- {HLIL_FABS, {SourceExprHighLevelOperandUsage}},
- {HLIL_FLOAT_TO_INT, {SourceExprHighLevelOperandUsage}},
- {HLIL_INT_TO_FLOAT, {SourceExprHighLevelOperandUsage}},
- {HLIL_FLOAT_CONV, {SourceExprHighLevelOperandUsage}},
- {HLIL_ROUND_TO_INT, {SourceExprHighLevelOperandUsage}},
- {HLIL_FLOOR, {SourceExprHighLevelOperandUsage}},
- {HLIL_CEIL, {SourceExprHighLevelOperandUsage}},
- {HLIL_FTRUNC, {SourceExprHighLevelOperandUsage}},
- {HLIL_FCMP_E, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
- {HLIL_FCMP_NE, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
- {HLIL_FCMP_LT, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
- {HLIL_FCMP_LE, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
- {HLIL_FCMP_GE, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
- {HLIL_FCMP_GT, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
- {HLIL_FCMP_O, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
- {HLIL_FCMP_UO, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}}
- };
+ HighLevelILInstructionBase::operationOperandUsage = {{HLIL_NOP, {}}, {HLIL_BREAK, {}}, {HLIL_CONTINUE, {}},
+ {HLIL_NORET, {}}, {HLIL_BP, {}}, {HLIL_UNDEF, {}}, {HLIL_UNIMPL, {}},
+ {HLIL_BLOCK, {BlockExprsHighLevelOperandUsage}},
+ {HLIL_IF, {ConditionExprHighLevelOperandUsage, TrueExprHighLevelOperandUsage, FalseExprHighLevelOperandUsage}},
+ {HLIL_WHILE, {ConditionExprHighLevelOperandUsage, LoopExprHighLevelOperandUsage}},
+ {HLIL_WHILE_SSA,
+ {ConditionPhiExprHighLevelOperandUsage, ConditionExprHighLevelOperandUsage, LoopExprHighLevelOperandUsage}},
+ {HLIL_DO_WHILE, {LoopExprHighLevelOperandUsage, ConditionExprHighLevelOperandUsage}},
+ {HLIL_DO_WHILE_SSA,
+ {LoopExprHighLevelOperandUsage, ConditionPhiExprHighLevelOperandUsage, ConditionExprHighLevelOperandUsage}},
+ {HLIL_FOR, {InitExprHighLevelOperandUsage, ConditionExprHighLevelOperandUsage, UpdateExprHighLevelOperandUsage,
+ LoopExprHighLevelOperandUsage}},
+ {HLIL_FOR_SSA,
+ {InitExprHighLevelOperandUsage, ConditionPhiExprHighLevelOperandUsage, ConditionExprHighLevelOperandUsage,
+ UpdateExprHighLevelOperandUsage, LoopExprHighLevelOperandUsage}},
+ {HLIL_SWITCH,
+ {ConditionExprHighLevelOperandUsage, DefaultExprHighLevelOperandUsage, CasesHighLevelOperandUsage}},
+ {HLIL_CASE, {ValueExprsHighLevelOperandUsage, TrueExprHighLevelOperandUsage}},
+ {HLIL_JUMP, {DestExprHighLevelOperandUsage}}, {HLIL_RET, {SourceExprsHighLevelOperandUsage}},
+ {HLIL_GOTO, {TargetHighLevelOperandUsage}}, {HLIL_LABEL, {TargetHighLevelOperandUsage}},
+ {HLIL_VAR_DECLARE, {VariableHighLevelOperandUsage}},
+ {HLIL_VAR_INIT, {DestVariableHighLevelOperandUsage, SourceExprHighLevelOperandUsage}},
+ {HLIL_VAR_INIT_SSA, {DestSSAVariableHighLevelOperandUsage, SourceExprHighLevelOperandUsage}},
+ {HLIL_ASSIGN, {DestExprHighLevelOperandUsage, SourceExprHighLevelOperandUsage}},
+ {HLIL_ASSIGN_UNPACK, {DestExprsHighLevelOperandUsage, SourceExprHighLevelOperandUsage}},
+ {HLIL_ASSIGN_MEM_SSA, {DestExprHighLevelOperandUsage, DestMemoryVersionHighLevelOperandUsage,
+ SourceExprHighLevelOperandUsage, SourceMemoryVersionHighLevelOperandUsage}},
+ {HLIL_ASSIGN_UNPACK, {DestExprsHighLevelOperandUsage, DestMemoryVersionHighLevelOperandUsage,
+ SourceExprHighLevelOperandUsage, SourceMemoryVersionHighLevelOperandUsage}},
+ {HLIL_VAR, {VariableHighLevelOperandUsage}}, {HLIL_VAR_SSA, {SSAVariableHighLevelOperandUsage}},
+ {HLIL_VAR_PHI, {DestSSAVariableHighLevelOperandUsage, SourceSSAVariablesHighLevelOperandUsage}},
+ {HLIL_MEM_PHI, {DestMemoryVersionHighLevelOperandUsage, SourceMemoryVersionsHighLevelOperandUsage}},
+ {HLIL_STRUCT_FIELD,
+ {SourceExprHighLevelOperandUsage, OffsetHighLevelOperandUsage, MemberIndexHighLevelOperandUsage}},
+ {HLIL_ARRAY_INDEX, {SourceExprHighLevelOperandUsage, IndexExprHighLevelOperandUsage}},
+ {HLIL_ARRAY_INDEX_SSA, {SourceExprHighLevelOperandUsage, SourceMemoryVersionHighLevelOperandUsage,
+ IndexExprHighLevelOperandUsage}},
+ {HLIL_SPLIT, {HighExprHighLevelOperandUsage, LowExprHighLevelOperandUsage}},
+ {HLIL_DEREF, {SourceExprHighLevelOperandUsage}},
+ {HLIL_DEREF_FIELD,
+ {SourceExprHighLevelOperandUsage, OffsetHighLevelOperandUsage, MemberIndexHighLevelOperandUsage}},
+ {HLIL_DEREF_SSA, {SourceExprHighLevelOperandUsage, SourceMemoryVersionHighLevelOperandUsage}},
+ {HLIL_DEREF_FIELD_SSA, {SourceExprHighLevelOperandUsage, SourceMemoryVersionHighLevelOperandUsage,
+ OffsetHighLevelOperandUsage, MemberIndexHighLevelOperandUsage}},
+ {HLIL_ADDRESS_OF, {SourceExprHighLevelOperandUsage}},
+ {HLIL_CALL, {DestExprHighLevelOperandUsage, ParameterExprsHighLevelOperandUsage}},
+ {HLIL_SYSCALL, {ParameterExprsHighLevelOperandUsage}},
+ {HLIL_TAILCALL, {DestExprHighLevelOperandUsage, ParameterExprsHighLevelOperandUsage}},
+ {HLIL_INTRINSIC, {IntrinsicHighLevelOperandUsage, ParameterExprsHighLevelOperandUsage}},
+ {HLIL_CALL_SSA, {DestExprHighLevelOperandUsage, ParameterExprsHighLevelOperandUsage,
+ DestMemoryVersionHighLevelOperandUsage, SourceMemoryVersionHighLevelOperandUsage}},
+ {HLIL_SYSCALL_SSA, {ParameterExprsHighLevelOperandUsage, DestMemoryVersionHighLevelOperandUsage,
+ SourceMemoryVersionHighLevelOperandUsage}},
+ {HLIL_INTRINSIC_SSA, {IntrinsicHighLevelOperandUsage, ParameterExprsHighLevelOperandUsage,
+ DestMemoryVersionHighLevelOperandUsage, SourceMemoryVersionHighLevelOperandUsage}},
+ {HLIL_TRAP, {VectorHighLevelOperandUsage}}, {HLIL_CONST, {ConstantHighLevelOperandUsage}},
+ {HLIL_CONST_PTR, {ConstantHighLevelOperandUsage}},
+ {HLIL_EXTERN_PTR, {ConstantHighLevelOperandUsage, OffsetHighLevelOperandUsage}},
+ {HLIL_FLOAT_CONST, {ConstantHighLevelOperandUsage}}, {HLIL_IMPORT, {ConstantHighLevelOperandUsage}},
+ {HLIL_ADD, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
+ {HLIL_SUB, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
+ {HLIL_AND, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
+ {HLIL_OR, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
+ {HLIL_XOR, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
+ {HLIL_LSL, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
+ {HLIL_LSR, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
+ {HLIL_ASR, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
+ {HLIL_ROL, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
+ {HLIL_ROR, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
+ {HLIL_MUL, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
+ {HLIL_MULU_DP, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
+ {HLIL_MULS_DP, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
+ {HLIL_DIVU, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
+ {HLIL_DIVS, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
+ {HLIL_MODU, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
+ {HLIL_MODS, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
+ {HLIL_CMP_E, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
+ {HLIL_CMP_NE, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
+ {HLIL_CMP_SLT, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
+ {HLIL_CMP_ULT, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
+ {HLIL_CMP_SLE, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
+ {HLIL_CMP_ULE, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
+ {HLIL_CMP_SGE, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
+ {HLIL_CMP_UGE, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
+ {HLIL_CMP_SGT, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
+ {HLIL_CMP_UGT, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
+ {HLIL_TEST_BIT, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
+ {HLIL_ADD_OVERFLOW, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
+ {HLIL_ADC, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage, CarryExprHighLevelOperandUsage}},
+ {HLIL_SBB, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage, CarryExprHighLevelOperandUsage}},
+ {HLIL_RLC, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage, CarryExprHighLevelOperandUsage}},
+ {HLIL_RRC, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage, CarryExprHighLevelOperandUsage}},
+ {HLIL_DIVU_DP, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
+ {HLIL_DIVS_DP, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
+ {HLIL_MODU_DP, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
+ {HLIL_MODS_DP, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
+ {HLIL_NEG, {SourceExprHighLevelOperandUsage}}, {HLIL_NOT, {SourceExprHighLevelOperandUsage}},
+ {HLIL_SX, {SourceExprHighLevelOperandUsage}}, {HLIL_ZX, {SourceExprHighLevelOperandUsage}},
+ {HLIL_LOW_PART, {SourceExprHighLevelOperandUsage}}, {HLIL_BOOL_TO_INT, {SourceExprHighLevelOperandUsage}},
+ {HLIL_UNIMPL_MEM, {SourceExprHighLevelOperandUsage}},
+ {HLIL_FADD, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
+ {HLIL_FSUB, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
+ {HLIL_FMUL, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
+ {HLIL_FDIV, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
+ {HLIL_FSQRT, {SourceExprHighLevelOperandUsage}}, {HLIL_FNEG, {SourceExprHighLevelOperandUsage}},
+ {HLIL_FABS, {SourceExprHighLevelOperandUsage}}, {HLIL_FLOAT_TO_INT, {SourceExprHighLevelOperandUsage}},
+ {HLIL_INT_TO_FLOAT, {SourceExprHighLevelOperandUsage}}, {HLIL_FLOAT_CONV, {SourceExprHighLevelOperandUsage}},
+ {HLIL_ROUND_TO_INT, {SourceExprHighLevelOperandUsage}}, {HLIL_FLOOR, {SourceExprHighLevelOperandUsage}},
+ {HLIL_CEIL, {SourceExprHighLevelOperandUsage}}, {HLIL_FTRUNC, {SourceExprHighLevelOperandUsage}},
+ {HLIL_FCMP_E, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
+ {HLIL_FCMP_NE, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
+ {HLIL_FCMP_LT, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
+ {HLIL_FCMP_LE, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
+ {HLIL_FCMP_GE, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
+ {HLIL_FCMP_GT, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
+ {HLIL_FCMP_O, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}},
+ {HLIL_FCMP_UO, {LeftExprHighLevelOperandUsage, RightExprHighLevelOperandUsage}}};
-static unordered_map<BNHighLevelILOperation, unordered_map<HighLevelILOperandUsage, size_t>> GetOperandIndexForOperandUsages()
+static unordered_map<BNHighLevelILOperation, unordered_map<HighLevelILOperandUsage, size_t>>
+ GetOperandIndexForOperandUsages()
{
unordered_map<BNHighLevelILOperation, unordered_map<HighLevelILOperandUsage, size_t>> result;
result.reserve(HighLevelILInstructionBase::operationOperandUsage.size());
@@ -254,7 +216,7 @@ static unordered_map<BNHighLevelILOperation, unordered_map<HighLevelILOperandUsa
unordered_map<BNHighLevelILOperation, unordered_map<HighLevelILOperandUsage, size_t>>
- HighLevelILInstructionBase::operationOperandIndex = GetOperandIndexForOperandUsages();
+ HighLevelILInstructionBase::operationOperandIndex = GetOperandIndexForOperandUsages();
bool HighLevelILIntegerList::ListIterator::operator==(const ListIterator& a) const
@@ -297,8 +259,8 @@ uint64_t HighLevelILIntegerList::ListIterator::operator*()
}
-HighLevelILIntegerList::HighLevelILIntegerList(HighLevelILFunction* func,
- const BNHighLevelILInstruction& instr, size_t count)
+HighLevelILIntegerList::HighLevelILIntegerList(
+ HighLevelILFunction* func, const BNHighLevelILInstruction& instr, size_t count)
{
m_start.function = func;
m_start.instr = instr;
@@ -355,10 +317,10 @@ size_t HighLevelILIndexList::ListIterator::operator*()
}
-HighLevelILIndexList::HighLevelILIndexList(HighLevelILFunction* func,
- const BNHighLevelILInstruction& instr, size_t count): m_list(func, instr, count)
-{
-}
+HighLevelILIndexList::HighLevelILIndexList(
+ HighLevelILFunction* func, const BNHighLevelILInstruction& instr, size_t count) :
+ m_list(func, instr, count)
+{}
HighLevelILIndexList::const_iterator HighLevelILIndexList::begin() const
@@ -407,20 +369,19 @@ const HighLevelILInstruction HighLevelILInstructionList::ListIterator::operator*
{
if (ast)
{
- return HighLevelILInstruction(pos.GetFunction(), pos.GetFunction()->GetRawExpr((size_t)*pos),
- (size_t)*pos, true, instructionIndex);
+ return HighLevelILInstruction(
+ pos.GetFunction(), pos.GetFunction()->GetRawExpr((size_t)*pos), (size_t)*pos, true, instructionIndex);
}
- return HighLevelILInstruction(pos.GetFunction(), pos.GetFunction()->GetRawNonASTExpr((size_t)*pos),
- (size_t)*pos, false, instructionIndex);
+ return HighLevelILInstruction(
+ pos.GetFunction(), pos.GetFunction()->GetRawNonASTExpr((size_t)*pos), (size_t)*pos, false, instructionIndex);
}
-HighLevelILInstructionList::HighLevelILInstructionList(HighLevelILFunction* func,
- const BNHighLevelILInstruction& instr, size_t count, bool asFullAst,
- size_t instructionIndex): m_list(func, instr, count), m_ast(asFullAst),
- m_instructionIndex(instructionIndex)
-{
-}
+HighLevelILInstructionList::HighLevelILInstructionList(HighLevelILFunction* func, const BNHighLevelILInstruction& instr,
+ size_t count, bool asFullAst, size_t instructionIndex) :
+ m_list(func, instr, count),
+ m_ast(asFullAst), m_instructionIndex(instructionIndex)
+{}
HighLevelILInstructionList::const_iterator HighLevelILInstructionList::begin() const
@@ -479,10 +440,10 @@ const SSAVariable HighLevelILSSAVariableList::ListIterator::operator*()
}
-HighLevelILSSAVariableList::HighLevelILSSAVariableList(HighLevelILFunction* func,
- const BNHighLevelILInstruction& instr, size_t count): m_list(func, instr, count & (~1))
-{
-}
+HighLevelILSSAVariableList::HighLevelILSSAVariableList(
+ HighLevelILFunction* func, const BNHighLevelILInstruction& instr, size_t count) :
+ m_list(func, instr, count & (~1))
+{}
HighLevelILSSAVariableList::const_iterator HighLevelILSSAVariableList::begin() const
@@ -527,9 +488,10 @@ HighLevelILSSAVariableList::operator vector<SSAVariable>() const
}
-HighLevelILOperand::HighLevelILOperand(const HighLevelILInstruction& instr,
- HighLevelILOperandUsage usage, size_t operandIndex):
- m_instr(instr), m_usage(usage), m_operandIndex(operandIndex)
+HighLevelILOperand::HighLevelILOperand(
+ const HighLevelILInstruction& instr, HighLevelILOperandUsage usage, size_t operandIndex) :
+ m_instr(instr),
+ m_usage(usage), m_operandIndex(operandIndex)
{
auto i = HighLevelILInstructionBase::operandTypeForUsage.find(m_usage);
if (i == HighLevelILInstructionBase::operandTypeForUsage.end())
@@ -621,11 +583,11 @@ const HighLevelILOperand HighLevelILOperandList::ListIterator::operator*()
HighLevelILOperandList::HighLevelILOperandList(const HighLevelILInstruction& instr,
- const vector<HighLevelILOperandUsage>& usageList,
- const unordered_map<HighLevelILOperandUsage, size_t>& operandIndexMap):
- m_instr(instr), m_usageList(usageList), m_operandIndexMap(operandIndexMap)
-{
-}
+ const vector<HighLevelILOperandUsage>& usageList,
+ const unordered_map<HighLevelILOperandUsage, size_t>& operandIndexMap) :
+ m_instr(instr),
+ m_usageList(usageList), m_operandIndexMap(operandIndexMap)
+{}
HighLevelILOperandList::const_iterator HighLevelILOperandList::begin() const
@@ -683,8 +645,8 @@ HighLevelILInstruction::HighLevelILInstruction()
}
-HighLevelILInstruction::HighLevelILInstruction(HighLevelILFunction* func,
- const BNHighLevelILInstruction& instr, size_t expr, bool asFullAst, size_t instrIdx)
+HighLevelILInstruction::HighLevelILInstruction(
+ HighLevelILFunction* func, const BNHighLevelILInstruction& instr, size_t expr, bool asFullAst, size_t instrIdx)
{
operation = instr.operation;
sourceOperand = instr.sourceOperand;
@@ -750,11 +712,11 @@ HighLevelILInstruction HighLevelILInstructionBase::GetRawOperandAsExpr(size_t op
{
if (ast)
{
- return HighLevelILInstruction(function, function->GetRawExpr(operands[operand]),
- operands[operand], true, instructionIndex);
+ return HighLevelILInstruction(
+ function, function->GetRawExpr(operands[operand]), operands[operand], true, instructionIndex);
}
- return HighLevelILInstruction(function, function->GetRawNonASTExpr(operands[operand]),
- operands[operand], false, instructionIndex);
+ return HighLevelILInstruction(
+ function, function->GetRawNonASTExpr(operands[operand]), operands[operand], false, instructionIndex);
}
@@ -772,8 +734,8 @@ SSAVariable HighLevelILInstructionBase::GetRawOperandAsSSAVariable(size_t operan
HighLevelILInstructionList HighLevelILInstructionBase::GetRawOperandAsExprList(size_t operand) const
{
- return HighLevelILInstructionList(function, function->GetRawExpr(operands[operand + 1]),
- operands[operand], ast, instructionIndex);
+ return HighLevelILInstructionList(
+ function, function->GetRawExpr(operands[operand + 1]), operands[operand], ast, instructionIndex);
}
@@ -803,7 +765,8 @@ void HighLevelILInstructionBase::UpdateRawOperandAsInteger(size_t operandIndex,
}
-void HighLevelILInstructionBase::UpdateRawOperandAsExprList(size_t operandIndex, const vector<HighLevelILInstruction>& exprs)
+void HighLevelILInstructionBase::UpdateRawOperandAsExprList(
+ size_t operandIndex, const vector<HighLevelILInstruction>& exprs)
{
vector<ExprId> exprIndexList;
for (auto& i : exprs)
@@ -1222,14 +1185,12 @@ void HighLevelILInstruction::VisitExprs(const std::function<bool(const HighLevel
ExprId HighLevelILInstruction::CopyTo(HighLevelILFunction* dest) const
{
- return CopyTo(dest, [&](const HighLevelILInstruction& subExpr) {
- return subExpr.CopyTo(dest);
- });
+ return CopyTo(dest, [&](const HighLevelILInstruction& subExpr) { return subExpr.CopyTo(dest); });
}
-ExprId HighLevelILInstruction::CopyTo(HighLevelILFunction* dest,
- const std::function<ExprId(const HighLevelILInstruction& subExpr)>& subExprHandler) const
+ExprId HighLevelILInstruction::CopyTo(
+ HighLevelILFunction* dest, const std::function<ExprId(const HighLevelILInstruction& subExpr)>& subExprHandler) const
{
vector<ExprId> output, params;
switch (operation)
@@ -1241,37 +1202,33 @@ ExprId HighLevelILInstruction::CopyTo(HighLevelILFunction* dest,
params.push_back(subExprHandler(i));
return dest->Block(params, *this);
case HLIL_IF:
- return dest->If(subExprHandler(GetConditionExpr<HLIL_IF>()),
- subExprHandler(GetTrueExpr<HLIL_IF>()), subExprHandler(GetFalseExpr<HLIL_IF>()), *this);
+ return dest->If(subExprHandler(GetConditionExpr<HLIL_IF>()), subExprHandler(GetTrueExpr<HLIL_IF>()),
+ subExprHandler(GetFalseExpr<HLIL_IF>()), *this);
case HLIL_WHILE:
- return dest->While(subExprHandler(GetConditionExpr<HLIL_WHILE>()),
- subExprHandler(GetLoopExpr<HLIL_WHILE>()), *this);
+ return dest->While(
+ subExprHandler(GetConditionExpr<HLIL_WHILE>()), subExprHandler(GetLoopExpr<HLIL_WHILE>()), *this);
case HLIL_WHILE_SSA:
return dest->WhileSSA(subExprHandler(GetConditionPhiExpr<HLIL_WHILE_SSA>()),
- subExprHandler(GetConditionExpr<HLIL_WHILE_SSA>()),
- subExprHandler(GetLoopExpr<HLIL_WHILE_SSA>()), *this);
+ subExprHandler(GetConditionExpr<HLIL_WHILE_SSA>()), subExprHandler(GetLoopExpr<HLIL_WHILE_SSA>()), *this);
case HLIL_DO_WHILE:
- return dest->DoWhile(subExprHandler(GetLoopExpr<HLIL_DO_WHILE>()),
- subExprHandler(GetConditionExpr<HLIL_DO_WHILE>()), *this);
+ return dest->DoWhile(
+ subExprHandler(GetLoopExpr<HLIL_DO_WHILE>()), subExprHandler(GetConditionExpr<HLIL_DO_WHILE>()), *this);
case HLIL_DO_WHILE_SSA:
return dest->DoWhileSSA(subExprHandler(GetLoopExpr<HLIL_DO_WHILE_SSA>()),
- subExprHandler(GetConditionPhiExpr<HLIL_DO_WHILE_SSA>()),
- subExprHandler(GetConditionExpr<HLIL_DO_WHILE_SSA>()), *this);
+ subExprHandler(GetConditionPhiExpr<HLIL_DO_WHILE_SSA>()),
+ subExprHandler(GetConditionExpr<HLIL_DO_WHILE_SSA>()), *this);
case HLIL_FOR:
- return dest->For(subExprHandler(GetInitExpr<HLIL_FOR>()),
- subExprHandler(GetConditionExpr<HLIL_FOR>()), subExprHandler(GetUpdateExpr<HLIL_FOR>()),
- subExprHandler(GetLoopExpr<HLIL_FOR>()), *this);
+ return dest->For(subExprHandler(GetInitExpr<HLIL_FOR>()), subExprHandler(GetConditionExpr<HLIL_FOR>()),
+ subExprHandler(GetUpdateExpr<HLIL_FOR>()), subExprHandler(GetLoopExpr<HLIL_FOR>()), *this);
case HLIL_FOR_SSA:
return dest->ForSSA(subExprHandler(GetInitExpr<HLIL_FOR_SSA>()),
- subExprHandler(GetConditionPhiExpr<HLIL_FOR_SSA>()),
- subExprHandler(GetConditionExpr<HLIL_FOR_SSA>()),
- subExprHandler(GetUpdateExpr<HLIL_FOR_SSA>()),
- subExprHandler(GetLoopExpr<HLIL_FOR_SSA>()), *this);
+ subExprHandler(GetConditionPhiExpr<HLIL_FOR_SSA>()), subExprHandler(GetConditionExpr<HLIL_FOR_SSA>()),
+ subExprHandler(GetUpdateExpr<HLIL_FOR_SSA>()), subExprHandler(GetLoopExpr<HLIL_FOR_SSA>()), *this);
case HLIL_SWITCH:
for (auto i : GetCases<HLIL_SWITCH>())
params.push_back(subExprHandler(i));
return dest->Switch(subExprHandler(GetConditionExpr<HLIL_SWITCH>()),
- subExprHandler(GetDefaultExpr<HLIL_SWITCH>()), params, *this);
+ subExprHandler(GetDefaultExpr<HLIL_SWITCH>()), params, *this);
case HLIL_CASE:
for (auto i : GetValueExprs<HLIL_CASE>())
params.push_back(subExprHandler(i));
@@ -1287,29 +1244,28 @@ ExprId HighLevelILInstruction::CopyTo(HighLevelILFunction* dest,
case HLIL_VAR_DECLARE:
return dest->VarDeclare(GetVariable<HLIL_VAR_DECLARE>(), *this);
case HLIL_VAR_INIT:
- return dest->VarInit(size, GetDestVariable<HLIL_VAR_INIT>(),
- subExprHandler(GetSourceExpr<HLIL_VAR_INIT>()), *this);
+ return dest->VarInit(
+ size, GetDestVariable<HLIL_VAR_INIT>(), subExprHandler(GetSourceExpr<HLIL_VAR_INIT>()), *this);
case HLIL_VAR_INIT_SSA:
- return dest->VarInitSSA(size, GetDestSSAVariable<HLIL_VAR_INIT_SSA>(),
- subExprHandler(GetSourceExpr<HLIL_VAR_INIT_SSA>()), *this);
+ return dest->VarInitSSA(
+ size, GetDestSSAVariable<HLIL_VAR_INIT_SSA>(), subExprHandler(GetSourceExpr<HLIL_VAR_INIT_SSA>()), *this);
case HLIL_ASSIGN:
- return dest->Assign(size, subExprHandler(GetDestExpr<HLIL_ASSIGN>()),
- subExprHandler(GetSourceExpr<HLIL_ASSIGN>()), *this);
+ return dest->Assign(
+ size, subExprHandler(GetDestExpr<HLIL_ASSIGN>()), subExprHandler(GetSourceExpr<HLIL_ASSIGN>()), *this);
case HLIL_ASSIGN_UNPACK:
for (auto i : GetDestExprs<HLIL_ASSIGN_UNPACK>())
output.push_back(subExprHandler(i));
- return dest->AssignUnpack(output,
- subExprHandler(GetSourceExpr<HLIL_ASSIGN_UNPACK>()), *this);
+ return dest->AssignUnpack(output, subExprHandler(GetSourceExpr<HLIL_ASSIGN_UNPACK>()), *this);
case HLIL_ASSIGN_MEM_SSA:
return dest->AssignMemSSA(size, subExprHandler(GetDestExpr<HLIL_ASSIGN_MEM_SSA>()),
- GetDestMemoryVersion<HLIL_ASSIGN_MEM_SSA>(), subExprHandler(GetSourceExpr<HLIL_ASSIGN_MEM_SSA>()),
- GetSourceMemoryVersion<HLIL_ASSIGN_MEM_SSA>(), *this);
+ GetDestMemoryVersion<HLIL_ASSIGN_MEM_SSA>(), subExprHandler(GetSourceExpr<HLIL_ASSIGN_MEM_SSA>()),
+ GetSourceMemoryVersion<HLIL_ASSIGN_MEM_SSA>(), *this);
case HLIL_ASSIGN_UNPACK_MEM_SSA:
for (auto i : GetDestExprs<HLIL_ASSIGN_UNPACK_MEM_SSA>())
output.push_back(subExprHandler(i));
return dest->AssignUnpackMemSSA(output, GetDestMemoryVersion<HLIL_ASSIGN_UNPACK_MEM_SSA>(),
- subExprHandler(GetSourceExpr<HLIL_ASSIGN_UNPACK_MEM_SSA>()),
- GetSourceMemoryVersion<HLIL_ASSIGN_UNPACK_MEM_SSA>(), *this);
+ subExprHandler(GetSourceExpr<HLIL_ASSIGN_UNPACK_MEM_SSA>()),
+ GetSourceMemoryVersion<HLIL_ASSIGN_UNPACK_MEM_SSA>(), *this);
case HLIL_VAR:
return dest->Var(size, GetVariable<HLIL_VAR>(), *this);
case HLIL_VAR_SSA:
@@ -1320,29 +1276,29 @@ ExprId HighLevelILInstruction::CopyTo(HighLevelILFunction* dest,
return dest->MemPhi(GetDestMemoryVersion<HLIL_MEM_PHI>(), GetSourceMemoryVersions<HLIL_MEM_PHI>(), *this);
case HLIL_STRUCT_FIELD:
return dest->StructField(size, subExprHandler(GetSourceExpr<HLIL_STRUCT_FIELD>()),
- GetOffset<HLIL_STRUCT_FIELD>(), GetMemberIndex<HLIL_STRUCT_FIELD>(), *this);
+ GetOffset<HLIL_STRUCT_FIELD>(), GetMemberIndex<HLIL_STRUCT_FIELD>(), *this);
case HLIL_ARRAY_INDEX:
return dest->ArrayIndex(size, subExprHandler(GetSourceExpr<HLIL_ARRAY_INDEX>()),
- subExprHandler(GetIndexExpr<HLIL_ARRAY_INDEX>()), *this);
+ subExprHandler(GetIndexExpr<HLIL_ARRAY_INDEX>()), *this);
case HLIL_ARRAY_INDEX_SSA:
return dest->ArrayIndexSSA(size, subExprHandler(GetSourceExpr<HLIL_ARRAY_INDEX_SSA>()),
- GetSourceMemoryVersion<HLIL_ARRAY_INDEX_SSA>(),
- subExprHandler(GetIndexExpr<HLIL_ARRAY_INDEX_SSA>()), *this);
+ GetSourceMemoryVersion<HLIL_ARRAY_INDEX_SSA>(), subExprHandler(GetIndexExpr<HLIL_ARRAY_INDEX_SSA>()),
+ *this);
case HLIL_SPLIT:
- return dest->Split(size, subExprHandler(GetHighExpr<HLIL_SPLIT>()),
- subExprHandler(GetLowExpr<HLIL_SPLIT>()), *this);
+ return dest->Split(
+ size, subExprHandler(GetHighExpr<HLIL_SPLIT>()), subExprHandler(GetLowExpr<HLIL_SPLIT>()), *this);
case HLIL_DEREF:
return dest->Deref(size, subExprHandler(GetSourceExpr<HLIL_DEREF>()), *this);
case HLIL_DEREF_FIELD:
- return dest->DerefField(size, subExprHandler(GetSourceExpr<HLIL_DEREF_FIELD>()),
- GetOffset<HLIL_DEREF_FIELD>(), GetMemberIndex<HLIL_DEREF_FIELD>(), *this);
+ return dest->DerefField(size, subExprHandler(GetSourceExpr<HLIL_DEREF_FIELD>()), GetOffset<HLIL_DEREF_FIELD>(),
+ GetMemberIndex<HLIL_DEREF_FIELD>(), *this);
case HLIL_DEREF_SSA:
- return dest->DerefSSA(size, subExprHandler(GetSourceExpr<HLIL_DEREF_SSA>()),
- GetSourceMemoryVersion<HLIL_DEREF_SSA>(), *this);
+ return dest->DerefSSA(
+ size, subExprHandler(GetSourceExpr<HLIL_DEREF_SSA>()), GetSourceMemoryVersion<HLIL_DEREF_SSA>(), *this);
case HLIL_DEREF_FIELD_SSA:
return dest->DerefFieldSSA(size, subExprHandler(GetSourceExpr<HLIL_DEREF_FIELD_SSA>()),
- GetSourceMemoryVersion<HLIL_DEREF_FIELD_SSA>(), GetOffset<HLIL_DEREF_FIELD_SSA>(),
- GetMemberIndex<HLIL_DEREF_FIELD_SSA>(), *this);
+ GetSourceMemoryVersion<HLIL_DEREF_FIELD_SSA>(), GetOffset<HLIL_DEREF_FIELD_SSA>(),
+ GetMemberIndex<HLIL_DEREF_FIELD_SSA>(), *this);
case HLIL_ADDRESS_OF:
return dest->AddressOf(subExprHandler(GetSourceExpr<HLIL_ADDRESS_OF>()), *this);
case HLIL_CALL:
@@ -1361,12 +1317,12 @@ ExprId HighLevelILInstruction::CopyTo(HighLevelILFunction* dest,
for (auto i : GetParameterExprs<HLIL_CALL_SSA>())
params.push_back(subExprHandler(i));
return dest->CallSSA(subExprHandler(GetDestExpr<HLIL_CALL_SSA>()), params,
- GetDestMemoryVersion<HLIL_CALL_SSA>(), GetSourceMemoryVersion<HLIL_CALL_SSA>(), *this);
+ GetDestMemoryVersion<HLIL_CALL_SSA>(), GetSourceMemoryVersion<HLIL_CALL_SSA>(), *this);
case HLIL_SYSCALL_SSA:
for (auto i : GetParameterExprs<HLIL_SYSCALL_SSA>())
params.push_back(subExprHandler(i));
- return dest->SyscallSSA(params, GetDestMemoryVersion<HLIL_SYSCALL_SSA>(),
- GetSourceMemoryVersion<HLIL_SYSCALL_SSA>(), *this);
+ return dest->SyscallSSA(
+ params, GetDestMemoryVersion<HLIL_SYSCALL_SSA>(), GetSourceMemoryVersion<HLIL_SYSCALL_SSA>(), *this);
case HLIL_RET:
for (auto i : GetSourceExprs<HLIL_RET>())
params.push_back(subExprHandler(i));
@@ -1391,8 +1347,7 @@ ExprId HighLevelILInstruction::CopyTo(HighLevelILFunction* dest,
case HLIL_FLOOR:
case HLIL_CEIL:
case HLIL_FTRUNC:
- return dest->AddExprWithLocation(operation, *this, size,
- subExprHandler(AsOneOperand().GetSourceExpr()));
+ return dest->AddExprWithLocation(operation, *this, size, subExprHandler(AsOneOperand().GetSourceExpr()));
case HLIL_ADD:
case HLIL_SUB:
case HLIL_AND:
@@ -1438,16 +1393,15 @@ ExprId HighLevelILInstruction::CopyTo(HighLevelILFunction* dest,
case HLIL_FCMP_GT:
case HLIL_FCMP_O:
case HLIL_FCMP_UO:
- return dest->AddExprWithLocation(operation, *this, size,
- subExprHandler(AsTwoOperand().GetLeftExpr()), subExprHandler(AsTwoOperand().GetRightExpr()));
+ return dest->AddExprWithLocation(operation, *this, size, subExprHandler(AsTwoOperand().GetLeftExpr()),
+ subExprHandler(AsTwoOperand().GetRightExpr()));
case HLIL_ADC:
case HLIL_SBB:
case HLIL_RLC:
case HLIL_RRC:
- return dest->AddExprWithLocation(operation, *this, size,
- subExprHandler(AsTwoOperandWithCarry().GetLeftExpr()),
- subExprHandler(AsTwoOperandWithCarry().GetRightExpr()),
- subExprHandler(AsTwoOperandWithCarry().GetCarryExpr()));
+ return dest->AddExprWithLocation(operation, *this, size, subExprHandler(AsTwoOperandWithCarry().GetLeftExpr()),
+ subExprHandler(AsTwoOperandWithCarry().GetRightExpr()),
+ subExprHandler(AsTwoOperandWithCarry().GetCarryExpr()));
case HLIL_CONST:
return dest->Const(size, GetConstant<HLIL_CONST>(), *this);
case HLIL_CONST_PTR:
@@ -1470,7 +1424,7 @@ ExprId HighLevelILInstruction::CopyTo(HighLevelILFunction* dest,
for (auto i : GetParameterExprs<HLIL_INTRINSIC_SSA>())
params.push_back(subExprHandler(i));
return dest->IntrinsicSSA(GetIntrinsic<HLIL_INTRINSIC_SSA>(), params,
- GetDestMemoryVersion<HLIL_INTRINSIC_SSA>(), GetSourceMemoryVersion<HLIL_INTRINSIC_SSA>(), *this);
+ GetDestMemoryVersion<HLIL_INTRINSIC_SSA>(), GetSourceMemoryVersion<HLIL_INTRINSIC_SSA>(), *this);
case HLIL_UNDEF:
return dest->Undefined(*this);
case HLIL_UNIMPL:
@@ -1666,19 +1620,24 @@ bool HighLevelILInstruction::operator<(const HighLevelILInstruction& other) cons
return false;
return GetSourceMemoryVersion<HLIL_ASSIGN_MEM_SSA>() < other.GetSourceMemoryVersion<HLIL_ASSIGN_MEM_SSA>();
case HLIL_ASSIGN_UNPACK_MEM_SSA:
- if (GetDestMemoryVersion<HLIL_ASSIGN_UNPACK_MEM_SSA>() < other.GetDestMemoryVersion<HLIL_ASSIGN_UNPACK_MEM_SSA>())
+ if (GetDestMemoryVersion<HLIL_ASSIGN_UNPACK_MEM_SSA>()
+ < other.GetDestMemoryVersion<HLIL_ASSIGN_UNPACK_MEM_SSA>())
return true;
- if (other.GetDestMemoryVersion<HLIL_ASSIGN_UNPACK_MEM_SSA>() < GetDestMemoryVersion<HLIL_ASSIGN_UNPACK_MEM_SSA>())
+ if (other.GetDestMemoryVersion<HLIL_ASSIGN_UNPACK_MEM_SSA>()
+ < GetDestMemoryVersion<HLIL_ASSIGN_UNPACK_MEM_SSA>())
return false;
if (GetSourceExpr<HLIL_ASSIGN_UNPACK_MEM_SSA>() < other.GetSourceExpr<HLIL_ASSIGN_UNPACK_MEM_SSA>())
return true;
if (other.GetSourceExpr<HLIL_ASSIGN_UNPACK_MEM_SSA>() < GetSourceExpr<HLIL_ASSIGN_UNPACK_MEM_SSA>())
return false;
- if (GetSourceMemoryVersion<HLIL_ASSIGN_UNPACK_MEM_SSA>() < other.GetSourceMemoryVersion<HLIL_ASSIGN_UNPACK_MEM_SSA>())
+ if (GetSourceMemoryVersion<HLIL_ASSIGN_UNPACK_MEM_SSA>()
+ < other.GetSourceMemoryVersion<HLIL_ASSIGN_UNPACK_MEM_SSA>())
return true;
- if (other.GetSourceMemoryVersion<HLIL_ASSIGN_UNPACK_MEM_SSA>() < GetSourceMemoryVersion<HLIL_ASSIGN_UNPACK_MEM_SSA>())
+ if (other.GetSourceMemoryVersion<HLIL_ASSIGN_UNPACK_MEM_SSA>()
+ < GetSourceMemoryVersion<HLIL_ASSIGN_UNPACK_MEM_SSA>())
return false;
- return CompareExprList(GetDestExprs<HLIL_ASSIGN_UNPACK_MEM_SSA>(), other.GetDestExprs<HLIL_ASSIGN_UNPACK_MEM_SSA>());
+ return CompareExprList(
+ GetDestExprs<HLIL_ASSIGN_UNPACK_MEM_SSA>(), other.GetDestExprs<HLIL_ASSIGN_UNPACK_MEM_SSA>());
case HLIL_VAR:
if (size < other.size)
return true;
@@ -1949,51 +1908,51 @@ bool HighLevelILInstruction::operator<(const HighLevelILInstruction& other) cons
return false;
return AsOneOperand().GetSourceExpr() < other.AsOneOperand().GetSourceExpr();
case HLIL_VAR_PHI:
+ {
+ if (GetDestSSAVariable<HLIL_VAR_PHI>() < other.GetDestSSAVariable<HLIL_VAR_PHI>())
+ return true;
+ if (other.GetDestSSAVariable<HLIL_VAR_PHI>() < GetDestSSAVariable<HLIL_VAR_PHI>())
+ return false;
+ HighLevelILSSAVariableList list = GetSourceSSAVariables<HLIL_VAR_PHI>();
+ HighLevelILSSAVariableList otherList = other.GetSourceSSAVariables<HLIL_VAR_PHI>();
+ if (list.size() < otherList.size())
+ return true;
+ if (list.size() > otherList.size())
+ return false;
+ auto i = list.begin();
+ auto j = otherList.begin();
+ for (; i != list.end(); ++i, ++j)
{
- if (GetDestSSAVariable<HLIL_VAR_PHI>() < other.GetDestSSAVariable<HLIL_VAR_PHI>())
- return true;
- if (other.GetDestSSAVariable<HLIL_VAR_PHI>() < GetDestSSAVariable<HLIL_VAR_PHI>())
- return false;
- HighLevelILSSAVariableList list = GetSourceSSAVariables<HLIL_VAR_PHI>();
- HighLevelILSSAVariableList otherList = other.GetSourceSSAVariables<HLIL_VAR_PHI>();
- if (list.size() < otherList.size())
+ if (*i < *j)
return true;
- if (list.size() > otherList.size())
+ if (*j < *i)
return false;
- auto i = list.begin();
- auto j = otherList.begin();
- for (; i != list.end(); ++i, ++j)
- {
- if (*i < *j)
- return true;
- if (*j < *i)
- return false;
- }
- return false;
}
+ return false;
+ }
case HLIL_MEM_PHI:
+ {
+ if (GetDestMemoryVersion<HLIL_MEM_PHI>() < other.GetDestMemoryVersion<HLIL_MEM_PHI>())
+ return true;
+ if (other.GetDestMemoryVersion<HLIL_MEM_PHI>() < GetDestMemoryVersion<HLIL_MEM_PHI>())
+ return false;
+ HighLevelILIndexList list = GetSourceMemoryVersions<HLIL_MEM_PHI>();
+ HighLevelILIndexList otherList = other.GetSourceMemoryVersions<HLIL_MEM_PHI>();
+ if (list.size() < otherList.size())
+ return true;
+ if (list.size() > otherList.size())
+ return false;
+ auto i = list.begin();
+ auto j = otherList.begin();
+ for (; i != list.end(); ++i, ++j)
{
- if (GetDestMemoryVersion<HLIL_MEM_PHI>() < other.GetDestMemoryVersion<HLIL_MEM_PHI>())
- return true;
- if (other.GetDestMemoryVersion<HLIL_MEM_PHI>() < GetDestMemoryVersion<HLIL_MEM_PHI>())
- return false;
- HighLevelILIndexList list = GetSourceMemoryVersions<HLIL_MEM_PHI>();
- HighLevelILIndexList otherList = other.GetSourceMemoryVersions<HLIL_MEM_PHI>();
- if (list.size() < otherList.size())
+ if (*i < *j)
return true;
- if (list.size() > otherList.size())
+ if (*j < *i)
return false;
- auto i = list.begin();
- auto j = otherList.begin();
- for (; i != list.end(); ++i, ++j)
- {
- if (*i < *j)
- return true;
- if (*j < *i)
- return false;
- }
- return false;
}
+ return false;
+ }
default:
return false;
}
@@ -2361,8 +2320,7 @@ ExprId HighLevelILFunction::Block(const vector<ExprId>& exprs, const ILSourceLoc
}
-ExprId HighLevelILFunction::If(ExprId condition, ExprId trueExpr, ExprId falseExpr,
- const ILSourceLocation& loc)
+ExprId HighLevelILFunction::If(ExprId condition, ExprId trueExpr, ExprId falseExpr, const ILSourceLocation& loc)
{
return AddExprWithLocation(HLIL_IF, loc, 0, condition, trueExpr, falseExpr);
}
@@ -2374,8 +2332,8 @@ ExprId HighLevelILFunction::While(ExprId condition, ExprId loopExpr, const ILSou
}
-ExprId HighLevelILFunction::WhileSSA(ExprId conditionPhi, ExprId condition, ExprId loopExpr,
- const ILSourceLocation& loc)
+ExprId HighLevelILFunction::WhileSSA(
+ ExprId conditionPhi, ExprId condition, ExprId loopExpr, const ILSourceLocation& loc)
{
return AddExprWithLocation(HLIL_WHILE_SSA, loc, 0, conditionPhi, condition, loopExpr);
}
@@ -2387,32 +2345,31 @@ ExprId HighLevelILFunction::DoWhile(ExprId loopExpr, ExprId condition, const ILS
}
-ExprId HighLevelILFunction::DoWhileSSA(ExprId loopExpr, ExprId conditionPhi, ExprId condition,
- const ILSourceLocation& loc)
+ExprId HighLevelILFunction::DoWhileSSA(
+ ExprId loopExpr, ExprId conditionPhi, ExprId condition, const ILSourceLocation& loc)
{
return AddExprWithLocation(HLIL_DO_WHILE_SSA, loc, 0, loopExpr, conditionPhi, condition);
}
-ExprId HighLevelILFunction::For(ExprId initExpr, ExprId condition, ExprId updateExpr, ExprId loopExpr,
- const ILSourceLocation& loc)
+ExprId HighLevelILFunction::For(
+ ExprId initExpr, ExprId condition, ExprId updateExpr, ExprId loopExpr, const ILSourceLocation& loc)
{
return AddExprWithLocation(HLIL_FOR, loc, 0, initExpr, condition, updateExpr, loopExpr);
}
-ExprId HighLevelILFunction::ForSSA(ExprId initExpr, ExprId conditionPhi, ExprId condition,
- ExprId updateExpr, ExprId loopExpr, const ILSourceLocation& loc)
+ExprId HighLevelILFunction::ForSSA(ExprId initExpr, ExprId conditionPhi, ExprId condition, ExprId updateExpr,
+ ExprId loopExpr, const ILSourceLocation& loc)
{
return AddExprWithLocation(HLIL_FOR_SSA, loc, 0, initExpr, conditionPhi, condition, updateExpr, loopExpr);
}
-ExprId HighLevelILFunction::Switch(ExprId condition, ExprId defaultExpr, const vector<ExprId>& cases,
- const ILSourceLocation& loc)
+ExprId HighLevelILFunction::Switch(
+ ExprId condition, ExprId defaultExpr, const vector<ExprId>& cases, const ILSourceLocation& loc)
{
- return AddExprWithLocation(HLIL_SWITCH, loc, 0, condition, defaultExpr,
- cases.size(), AddOperandList(cases));
+ return AddExprWithLocation(HLIL_SWITCH, loc, 0, condition, defaultExpr, cases.size(), AddOperandList(cases));
}
@@ -2488,46 +2445,44 @@ ExprId HighLevelILFunction::Assign(size_t size, ExprId dest, ExprId src, const I
}
-ExprId HighLevelILFunction::AssignUnpack(const vector<ExprId>& output, ExprId src,
- const ILSourceLocation& loc)
+ExprId HighLevelILFunction::AssignUnpack(const vector<ExprId>& output, ExprId src, const ILSourceLocation& loc)
{
return AddExprWithLocation(HLIL_ASSIGN_UNPACK, loc, 0, output.size(), AddOperandList(output), src);
}
-ExprId HighLevelILFunction::AssignMemSSA(size_t size, ExprId dest, size_t destMemVersion, ExprId src,
- size_t srcMemVersion, const ILSourceLocation& loc)
+ExprId HighLevelILFunction::AssignMemSSA(
+ size_t size, ExprId dest, size_t destMemVersion, ExprId src, size_t srcMemVersion, const ILSourceLocation& loc)
{
return AddExprWithLocation(HLIL_ASSIGN_MEM_SSA, loc, size, dest, destMemVersion, src, srcMemVersion);
}
-ExprId HighLevelILFunction::AssignUnpackMemSSA(const vector<ExprId>& output, size_t destMemVersion, ExprId src,
- size_t srcMemVersion, const ILSourceLocation& loc)
+ExprId HighLevelILFunction::AssignUnpackMemSSA(
+ const vector<ExprId>& output, size_t destMemVersion, ExprId src, size_t srcMemVersion, const ILSourceLocation& loc)
{
- return AddExprWithLocation(HLIL_ASSIGN_UNPACK_MEM_SSA, loc, 0, output.size(), AddOperandList(output),
- destMemVersion, src, srcMemVersion);
+ return AddExprWithLocation(
+ HLIL_ASSIGN_UNPACK_MEM_SSA, loc, 0, output.size(), AddOperandList(output), destMemVersion, src, srcMemVersion);
}
-ExprId HighLevelILFunction::Var(size_t size, const Variable& src,
- const ILSourceLocation& loc)
+ExprId HighLevelILFunction::Var(size_t size, const Variable& src, const ILSourceLocation& loc)
{
return AddExprWithLocation(HLIL_VAR, loc, size, src.ToIdentifier());
}
-ExprId HighLevelILFunction::VarSSA(size_t size, const SSAVariable& src,
- const ILSourceLocation& loc)
+ExprId HighLevelILFunction::VarSSA(size_t size, const SSAVariable& src, const ILSourceLocation& loc)
{
return AddExprWithLocation(HLIL_VAR_SSA, loc, size, src.var.ToIdentifier(), src.version);
}
-ExprId HighLevelILFunction::VarPhi(const SSAVariable& dest, const vector<SSAVariable>& sources, const ILSourceLocation& loc)
+ExprId HighLevelILFunction::VarPhi(
+ const SSAVariable& dest, const vector<SSAVariable>& sources, const ILSourceLocation& loc)
{
- return AddExprWithLocation(HLIL_VAR_PHI, loc, 0, dest.var.ToIdentifier(), dest.version,
- sources.size() * 2, AddSSAVariableList(sources));
+ return AddExprWithLocation(
+ HLIL_VAR_PHI, loc, 0, dest.var.ToIdentifier(), dest.version, sources.size() * 2, AddSSAVariableList(sources));
}
@@ -2537,8 +2492,8 @@ ExprId HighLevelILFunction::MemPhi(size_t dest, const vector<size_t>& sources, c
}
-ExprId HighLevelILFunction::StructField(size_t size, ExprId src, uint64_t offset, size_t memberIndex,
- const ILSourceLocation& loc)
+ExprId HighLevelILFunction::StructField(
+ size_t size, ExprId src, uint64_t offset, size_t memberIndex, const ILSourceLocation& loc)
{
return AddExprWithLocation(HLIL_STRUCT_FIELD, loc, size, src, offset, memberIndex);
}
@@ -2556,8 +2511,8 @@ ExprId HighLevelILFunction::ArrayIndex(size_t size, ExprId src, ExprId idx, cons
}
-ExprId HighLevelILFunction::ArrayIndexSSA(size_t size, ExprId src, size_t srcMemVersion, ExprId idx,
- const ILSourceLocation& loc)
+ExprId HighLevelILFunction::ArrayIndexSSA(
+ size_t size, ExprId src, size_t srcMemVersion, ExprId idx, const ILSourceLocation& loc)
{
return AddExprWithLocation(HLIL_ARRAY_INDEX_SSA, loc, size, src, srcMemVersion, idx);
}
@@ -2569,8 +2524,8 @@ ExprId HighLevelILFunction::Deref(size_t size, ExprId src, const ILSourceLocatio
}
-ExprId HighLevelILFunction::DerefField(size_t size, ExprId src, uint64_t offset, size_t memberIndex,
- const ILSourceLocation& loc)
+ExprId HighLevelILFunction::DerefField(
+ size_t size, ExprId src, uint64_t offset, size_t memberIndex, const ILSourceLocation& loc)
{
return AddExprWithLocation(HLIL_DEREF_FIELD, loc, size, src, offset, memberIndex);
}
@@ -2582,8 +2537,8 @@ ExprId HighLevelILFunction::DerefSSA(size_t size, ExprId src, size_t srcMemVersi
}
-ExprId HighLevelILFunction::DerefFieldSSA(size_t size, ExprId src, size_t srcMemVersion,
- uint64_t offset, size_t memberIndex, const ILSourceLocation& loc)
+ExprId HighLevelILFunction::DerefFieldSSA(
+ size_t size, ExprId src, size_t srcMemVersion, uint64_t offset, size_t memberIndex, const ILSourceLocation& loc)
{
return AddExprWithLocation(HLIL_DEREF_FIELD_SSA, loc, size, src, srcMemVersion, offset, memberIndex);
}
@@ -2655,8 +2610,8 @@ ExprId HighLevelILFunction::Add(size_t size, ExprId left, ExprId right, const IL
}
-ExprId HighLevelILFunction::AddWithCarry(size_t size, ExprId left, ExprId right, ExprId carry,
- const ILSourceLocation& loc)
+ExprId HighLevelILFunction::AddWithCarry(
+ size_t size, ExprId left, ExprId right, ExprId carry, const ILSourceLocation& loc)
{
return AddExprWithLocation(HLIL_ADC, loc, size, left, right, carry);
}
@@ -2668,8 +2623,8 @@ ExprId HighLevelILFunction::Sub(size_t size, ExprId left, ExprId right, const IL
}
-ExprId HighLevelILFunction::SubWithBorrow(size_t size, ExprId left, ExprId right, ExprId carry,
- const ILSourceLocation& loc)
+ExprId HighLevelILFunction::SubWithBorrow(
+ size_t size, ExprId left, ExprId right, ExprId carry, const ILSourceLocation& loc)
{
return AddExprWithLocation(HLIL_SBB, loc, size, left, right, carry);
}
@@ -2693,127 +2648,111 @@ ExprId HighLevelILFunction::Xor(size_t size, ExprId left, ExprId right, const IL
}
-ExprId HighLevelILFunction::ShiftLeft(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId HighLevelILFunction::ShiftLeft(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(HLIL_LSL, loc, size, left, right);
}
-ExprId HighLevelILFunction::LogicalShiftRight(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId HighLevelILFunction::LogicalShiftRight(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(HLIL_LSR, loc, size, left, right);
}
-ExprId HighLevelILFunction::ArithShiftRight(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId HighLevelILFunction::ArithShiftRight(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(HLIL_ASR, loc, size, left, right);
}
-ExprId HighLevelILFunction::RotateLeft(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId HighLevelILFunction::RotateLeft(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(HLIL_ROL, loc, size, left, right);
}
-ExprId HighLevelILFunction::RotateLeftCarry(size_t size, ExprId left, ExprId right, ExprId carry,
- const ILSourceLocation& loc)
+ExprId HighLevelILFunction::RotateLeftCarry(
+ size_t size, ExprId left, ExprId right, ExprId carry, const ILSourceLocation& loc)
{
return AddExprWithLocation(HLIL_RLC, loc, size, left, right, carry);
}
-ExprId HighLevelILFunction::RotateRight(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId HighLevelILFunction::RotateRight(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(HLIL_ROR, loc, size, left, right);
}
-ExprId HighLevelILFunction::RotateRightCarry(size_t size, ExprId left, ExprId right, ExprId carry,
- const ILSourceLocation& loc)
+ExprId HighLevelILFunction::RotateRightCarry(
+ size_t size, ExprId left, ExprId right, ExprId carry, const ILSourceLocation& loc)
{
return AddExprWithLocation(HLIL_RRC, loc, size, left, right, carry);
}
-ExprId HighLevelILFunction::Mult(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId HighLevelILFunction::Mult(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(HLIL_MUL, loc, size, left, right);
}
-ExprId HighLevelILFunction::MultDoublePrecSigned(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId HighLevelILFunction::MultDoublePrecSigned(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(HLIL_MULS_DP, loc, size, left, right);
}
-ExprId HighLevelILFunction::MultDoublePrecUnsigned(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId HighLevelILFunction::MultDoublePrecUnsigned(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(HLIL_MULU_DP, loc, size, left, right);
}
-ExprId HighLevelILFunction::DivSigned(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId HighLevelILFunction::DivSigned(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(HLIL_DIVS, loc, size, left, right);
}
-ExprId HighLevelILFunction::DivUnsigned(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId HighLevelILFunction::DivUnsigned(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(HLIL_DIVU, loc, size, left, right);
}
-ExprId HighLevelILFunction::DivDoublePrecSigned(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId HighLevelILFunction::DivDoublePrecSigned(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(HLIL_DIVS_DP, loc, size, left, right);
}
-ExprId HighLevelILFunction::DivDoublePrecUnsigned(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId HighLevelILFunction::DivDoublePrecUnsigned(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(HLIL_DIVU_DP, loc, size, left, right);
}
-ExprId HighLevelILFunction::ModSigned(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId HighLevelILFunction::ModSigned(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(HLIL_MODS, loc, size, left, right);
}
-ExprId HighLevelILFunction::ModUnsigned(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId HighLevelILFunction::ModUnsigned(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(HLIL_MODU, loc, size, left, right);
}
-ExprId HighLevelILFunction::ModDoublePrecSigned(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId HighLevelILFunction::ModDoublePrecSigned(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(HLIL_MODS_DP, loc, size, left, right);
}
-ExprId HighLevelILFunction::ModDoublePrecUnsigned(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId HighLevelILFunction::ModDoublePrecUnsigned(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(HLIL_MODU_DP, loc, size, left, right);
}
@@ -2855,8 +2794,7 @@ ExprId HighLevelILFunction::Call(ExprId dest, const vector<ExprId>& params, cons
}
-ExprId HighLevelILFunction::Syscall(const vector<ExprId>& params,
- const ILSourceLocation& loc)
+ExprId HighLevelILFunction::Syscall(const vector<ExprId>& params, const ILSourceLocation& loc)
{
return AddExprWithLocation(HLIL_SYSCALL, loc, 0, params.size(), AddOperandList(params));
}
@@ -2868,94 +2806,88 @@ ExprId HighLevelILFunction::TailCall(ExprId dest, const vector<ExprId>& params,
}
-ExprId HighLevelILFunction::CallSSA(ExprId dest, const vector<ExprId>& params, size_t destMemVersion,
- size_t srcMemVersion, const ILSourceLocation& loc)
+ExprId HighLevelILFunction::CallSSA(
+ ExprId dest, const vector<ExprId>& params, size_t destMemVersion, size_t srcMemVersion, const ILSourceLocation& loc)
{
- return AddExprWithLocation(HLIL_CALL_SSA, loc, 0, dest, params.size(), AddOperandList(params),
- destMemVersion, srcMemVersion);
+ return AddExprWithLocation(
+ HLIL_CALL_SSA, loc, 0, dest, params.size(), AddOperandList(params), destMemVersion, srcMemVersion);
}
-ExprId HighLevelILFunction::SyscallSSA(const vector<ExprId>& params, size_t destMemVersion,
- size_t srcMemVersion, const ILSourceLocation& loc)
+ExprId HighLevelILFunction::SyscallSSA(
+ const vector<ExprId>& params, size_t destMemVersion, size_t srcMemVersion, const ILSourceLocation& loc)
{
- return AddExprWithLocation(HLIL_SYSCALL_SSA, loc, 0, params.size(), AddOperandList(params),
- destMemVersion, srcMemVersion);
+ return AddExprWithLocation(
+ HLIL_SYSCALL_SSA, loc, 0, params.size(), AddOperandList(params), destMemVersion, srcMemVersion);
}
-ExprId HighLevelILFunction::CompareEqual(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId HighLevelILFunction::CompareEqual(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(HLIL_CMP_E, loc, size, left, right);
}
-ExprId HighLevelILFunction::CompareNotEqual(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId HighLevelILFunction::CompareNotEqual(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(HLIL_CMP_NE, loc, size, left, right);
}
-ExprId HighLevelILFunction::CompareSignedLessThan(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId HighLevelILFunction::CompareSignedLessThan(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(HLIL_CMP_SLT, loc, size, left, right);
}
-ExprId HighLevelILFunction::CompareUnsignedLessThan(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId HighLevelILFunction::CompareUnsignedLessThan(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(HLIL_CMP_ULT, loc, size, left, right);
}
-ExprId HighLevelILFunction::CompareSignedLessEqual(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId HighLevelILFunction::CompareSignedLessEqual(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(HLIL_CMP_SLE, loc, size, left, right);
}
-ExprId HighLevelILFunction::CompareUnsignedLessEqual(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId HighLevelILFunction::CompareUnsignedLessEqual(
+ size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(HLIL_CMP_ULE, loc, size, left, right);
}
-ExprId HighLevelILFunction::CompareSignedGreaterEqual(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId HighLevelILFunction::CompareSignedGreaterEqual(
+ size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(HLIL_CMP_SGE, loc, size, left, right);
}
-ExprId HighLevelILFunction::CompareUnsignedGreaterEqual(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId HighLevelILFunction::CompareUnsignedGreaterEqual(
+ size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(HLIL_CMP_UGE, loc, size, left, right);
}
-ExprId HighLevelILFunction::CompareSignedGreaterThan(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId HighLevelILFunction::CompareSignedGreaterThan(
+ size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(HLIL_CMP_SGT, loc, size, left, right);
}
-ExprId HighLevelILFunction::CompareUnsignedGreaterThan(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId HighLevelILFunction::CompareUnsignedGreaterThan(
+ size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(HLIL_CMP_UGT, loc, size, left, right);
}
-ExprId HighLevelILFunction::TestBit(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId HighLevelILFunction::TestBit(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(HLIL_TEST_BIT, loc, size, left, right);
}
@@ -2967,8 +2899,7 @@ ExprId HighLevelILFunction::BoolToInt(size_t size, ExprId src, const ILSourceLoc
}
-ExprId HighLevelILFunction::AddOverflow(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId HighLevelILFunction::AddOverflow(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(HLIL_ADD_OVERFLOW, loc, size, left, right);
}
@@ -2986,19 +2917,17 @@ ExprId HighLevelILFunction::Trap(int64_t vector, const ILSourceLocation& loc)
}
-ExprId HighLevelILFunction::Intrinsic(uint32_t intrinsic, const vector<ExprId>& params,
- const ILSourceLocation& loc)
+ExprId HighLevelILFunction::Intrinsic(uint32_t intrinsic, const vector<ExprId>& params, const ILSourceLocation& loc)
{
- return AddExprWithLocation(HLIL_INTRINSIC, loc, 0, intrinsic,
- params.size(), AddOperandList(params));
+ return AddExprWithLocation(HLIL_INTRINSIC, loc, 0, intrinsic, params.size(), AddOperandList(params));
}
-ExprId HighLevelILFunction::IntrinsicSSA(uint32_t intrinsic, const vector<ExprId>& params,
- size_t destMemVersion, size_t srcMemVersion, const ILSourceLocation& loc)
+ExprId HighLevelILFunction::IntrinsicSSA(uint32_t intrinsic, const vector<ExprId>& params, size_t destMemVersion,
+ size_t srcMemVersion, const ILSourceLocation& loc)
{
- return AddExprWithLocation(HLIL_INTRINSIC_SSA, loc, 0, intrinsic,
- params.size(), AddOperandList(params), destMemVersion, srcMemVersion);
+ return AddExprWithLocation(
+ HLIL_INTRINSIC_SSA, loc, 0, intrinsic, params.size(), AddOperandList(params), destMemVersion, srcMemVersion);
}
@@ -3014,8 +2943,7 @@ ExprId HighLevelILFunction::Unimplemented(const ILSourceLocation& loc)
}
-ExprId HighLevelILFunction::UnimplementedMemoryRef(size_t size, ExprId target,
- const ILSourceLocation& loc)
+ExprId HighLevelILFunction::UnimplementedMemoryRef(size_t size, ExprId target, const ILSourceLocation& loc)
{
return AddExprWithLocation(HLIL_UNIMPL_MEM, loc, size, target);
}
diff --git a/highlevelilinstruction.h b/highlevelilinstruction.h
index 763c8221..6947479c 100644
--- a/highlevelilinstruction.h
+++ b/highlevelilinstruction.h
@@ -24,9 +24,9 @@
#include <unordered_map>
#include <vector>
#ifdef BINARYNINJACORE_LIBRARY
-#include "variable.h"
+ #include "variable.h"
#else
-#include "binaryninjaapi.h"
+ #include "binaryninjaapi.h"
#endif
#include "mediumlevelilinstruction.h"
@@ -39,7 +39,8 @@ namespace BinaryNinja
class HighLevelILFunction;
template <BNHighLevelILOperation N>
- struct HighLevelILInstructionAccessor {};
+ struct HighLevelILInstructionAccessor
+ {};
struct HighLevelILInstruction;
struct HighLevelILConstantInstruction;
@@ -103,24 +104,23 @@ namespace BinaryNinja
SourceMemoryVersionsHighLevelOperandUsage,
DestMemoryVersionHighLevelOperandUsage
};
-}
+} // namespace BinaryNinjaCore
-namespace std
-{
- template<> struct hash<BNHighLevelILOperation>
+namespace std {
+ template <>
+ struct hash<BNHighLevelILOperation>
{
typedef BNHighLevelILOperation argument_type;
typedef int result_type;
- result_type operator()(argument_type const& value) const
- {
- return (result_type)value;
- }
+ result_type operator()(argument_type const& value) const { return (result_type)value; }
};
#ifdef BINARYNINJACORE_LIBRARY
- template<> struct hash<BinaryNinjaCore::HighLevelILOperandUsage>
+ template <>
+ struct hash<BinaryNinjaCore::HighLevelILOperandUsage>
#else
- template<> struct hash<BinaryNinja::HighLevelILOperandUsage>
+ template <>
+ struct hash<BinaryNinja::HighLevelILOperandUsage>
#endif
{
#ifdef BINARYNINJACORE_LIBRARY
@@ -129,12 +129,9 @@ namespace std
typedef BinaryNinja::HighLevelILOperandUsage argument_type;
#endif
typedef int result_type;
- result_type operator()(argument_type const& value) const
- {
- return (result_type)value;
- }
+ result_type operator()(argument_type const& value) const { return (result_type)value; }
};
-}
+} // namespace std
#ifdef BINARYNINJACORE_LIBRARY
namespace BinaryNinjaCore
@@ -143,19 +140,19 @@ namespace BinaryNinja
#endif
{
#ifdef BINARYNINJACORE_LIBRARY
-#define _STD_VECTOR vector
-#define _STD_SET set
-#define _STD_UNORDERED_MAP unordered_map
+ #define _STD_VECTOR vector
+ #define _STD_SET set
+ #define _STD_UNORDERED_MAP unordered_map
#else
-#define _STD_VECTOR std::vector
-#define _STD_SET std::set
-#define _STD_UNORDERED_MAP std::unordered_map
+ #define _STD_VECTOR std::vector
+ #define _STD_SET std::set
+ #define _STD_UNORDERED_MAP std::unordered_map
#endif
- class HighLevelILInstructionAccessException: public std::exception
+ class HighLevelILInstructionAccessException : public std::exception
{
- public:
- HighLevelILInstructionAccessException(): std::exception() {}
+ public:
+ HighLevelILInstructionAccessException() : std::exception() {}
virtual const char* what() const NOEXCEPT { return "invalid access to HLIL instruction"; }
};
@@ -181,7 +178,7 @@ namespace BinaryNinja
ListIterator m_start;
- public:
+ public:
typedef ListIterator const_iterator;
HighLevelILIntegerList(HighLevelILFunction* func, const BNHighLevelILInstruction& instr, size_t count);
@@ -202,13 +199,17 @@ namespace BinaryNinja
bool operator==(const ListIterator& a) const { return pos == a.pos; }
bool operator!=(const ListIterator& a) const { return pos != a.pos; }
bool operator<(const ListIterator& a) const { return pos < a.pos; }
- ListIterator& operator++() { ++pos; return *this; }
+ ListIterator& operator++()
+ {
+ ++pos;
+ return *this;
+ }
size_t operator*();
};
HighLevelILIntegerList m_list;
- public:
+ public:
typedef ListIterator const_iterator;
HighLevelILIndexList(HighLevelILFunction* func, const BNHighLevelILInstruction& instr, size_t count);
@@ -231,7 +232,11 @@ namespace BinaryNinja
bool operator==(const ListIterator& a) const { return pos == a.pos; }
bool operator!=(const ListIterator& a) const { return pos != a.pos; }
bool operator<(const ListIterator& a) const { return pos < a.pos; }
- ListIterator& operator++() { ++pos; return *this; }
+ ListIterator& operator++()
+ {
+ ++pos;
+ return *this;
+ }
const HighLevelILInstruction operator*();
};
@@ -239,11 +244,11 @@ namespace BinaryNinja
bool m_ast;
size_t m_instructionIndex;
- public:
+ public:
typedef ListIterator const_iterator;
- HighLevelILInstructionList(HighLevelILFunction* func, const BNHighLevelILInstruction& instr,
- size_t count, bool asFullAst, size_t instructionIndex);
+ HighLevelILInstructionList(HighLevelILFunction* func, const BNHighLevelILInstruction& instr, size_t count,
+ bool asFullAst, size_t instructionIndex);
const_iterator begin() const;
const_iterator end() const;
@@ -261,13 +266,18 @@ namespace BinaryNinja
bool operator==(const ListIterator& a) const { return pos == a.pos; }
bool operator!=(const ListIterator& a) const { return pos != a.pos; }
bool operator<(const ListIterator& a) const { return pos < a.pos; }
- ListIterator& operator++() { ++pos; ++pos; return *this; }
+ ListIterator& operator++()
+ {
+ ++pos;
+ ++pos;
+ return *this;
+ }
const SSAVariable operator*();
};
HighLevelILIntegerList m_list;
- public:
+ public:
typedef ListIterator const_iterator;
HighLevelILSSAVariableList(HighLevelILFunction* func, const BNHighLevelILInstruction& instr, size_t count);
@@ -280,7 +290,7 @@ namespace BinaryNinja
operator _STD_VECTOR<SSAVariable>() const;
};
- struct HighLevelILInstructionBase: public BNHighLevelILInstruction
+ struct HighLevelILInstructionBase : public BNHighLevelILInstruction
{
#ifdef BINARYNINJACORE_LIBRARY
HighLevelILFunction* function;
@@ -291,10 +301,9 @@ namespace BinaryNinja
bool ast;
static _STD_UNORDERED_MAP<HighLevelILOperandUsage, HighLevelILOperandType> operandTypeForUsage;
- static _STD_UNORDERED_MAP<BNHighLevelILOperation,
- _STD_VECTOR<HighLevelILOperandUsage>> operationOperandUsage;
- static _STD_UNORDERED_MAP<BNHighLevelILOperation,
- _STD_UNORDERED_MAP<HighLevelILOperandUsage, size_t>> operationOperandIndex;
+ static _STD_UNORDERED_MAP<BNHighLevelILOperation, _STD_VECTOR<HighLevelILOperandUsage>> operationOperandUsage;
+ static _STD_UNORDERED_MAP<BNHighLevelILOperation, _STD_UNORDERED_MAP<HighLevelILOperandUsage, size_t>>
+ operationOperandIndex;
HighLevelILOperandList GetOperands() const;
@@ -314,8 +323,8 @@ namespace BinaryNinja
void UpdateRawOperandAsExprList(size_t operandIndex, const _STD_VECTOR<size_t>& exprs);
RegisterValue GetValue() const;
- PossibleValueSet GetPossibleValues(const _STD_SET<BNDataFlowQueryOption>& options =
- _STD_SET<BNDataFlowQueryOption>()) const;
+ PossibleValueSet GetPossibleValues(
+ const _STD_SET<BNDataFlowQueryOption>& options = _STD_SET<BNDataFlowQueryOption>()) const;
Confidence<Ref<Type>> GetType() const;
size_t GetSSAExprIndex() const;
@@ -347,14 +356,8 @@ namespace BinaryNinja
throw HighLevelILInstructionAccessException();
return *(HighLevelILInstructionAccessor<N>*)this;
}
- HighLevelILOneOperandInstruction& AsOneOperand()
- {
- return *(HighLevelILOneOperandInstruction*)this;
- }
- HighLevelILTwoOperandInstruction& AsTwoOperand()
- {
- return *(HighLevelILTwoOperandInstruction*)this;
- }
+ HighLevelILOneOperandInstruction& AsOneOperand() { return *(HighLevelILOneOperandInstruction*)this; }
+ HighLevelILTwoOperandInstruction& AsTwoOperand() { return *(HighLevelILTwoOperandInstruction*)this; }
HighLevelILTwoOperandWithCarryInstruction& AsTwoOperandWithCarry()
{
return *(HighLevelILTwoOperandWithCarryInstruction*)this;
@@ -385,77 +388,285 @@ namespace BinaryNinja
}
};
- struct HighLevelILInstruction: public HighLevelILInstructionBase
+ struct HighLevelILInstruction : public HighLevelILInstructionBase
{
HighLevelILInstruction();
- HighLevelILInstruction(HighLevelILFunction* func, const BNHighLevelILInstruction& instr,
- size_t expr, bool asFullAst, size_t instructionIndex);
+ HighLevelILInstruction(HighLevelILFunction* func, const BNHighLevelILInstruction& instr, size_t expr,
+ bool asFullAst, size_t instructionIndex);
HighLevelILInstruction(const HighLevelILInstructionBase& instr);
void VisitExprs(const std::function<bool(const HighLevelILInstruction& expr)>& func) const;
ExprId CopyTo(HighLevelILFunction* dest) const;
ExprId CopyTo(HighLevelILFunction* dest,
- const std::function<ExprId(const HighLevelILInstruction& subExpr)>& subExprHandler) const;
+ const std::function<ExprId(const HighLevelILInstruction& subExpr)>& subExprHandler) const;
bool operator<(const HighLevelILInstruction& other) const;
bool operator==(const HighLevelILInstruction& other) const;
bool operator!=(const HighLevelILInstruction& other) const;
// Templated accessors for instruction operands, use these for efficient access to a known instruction
- template <BNHighLevelILOperation N> HighLevelILInstruction GetSourceExpr() const { return As<N>().GetSourceExpr(); }
- template <BNHighLevelILOperation N> Variable GetVariable() const { return As<N>().GetVariable(); }
- template <BNHighLevelILOperation N> Variable GetDestVariable() const { return As<N>().GetDestVariable(); }
- template <BNHighLevelILOperation N> SSAVariable GetSSAVariable() const { return As<N>().GetSSAVariable(); }
- template <BNHighLevelILOperation N> SSAVariable GetDestSSAVariable() const { return As<N>().GetDestSSAVariable(); }
- template <BNHighLevelILOperation N> HighLevelILInstruction GetDestExpr() const { return As<N>().GetDestExpr(); }
- template <BNHighLevelILOperation N> HighLevelILInstruction GetLeftExpr() const { return As<N>().GetLeftExpr(); }
- template <BNHighLevelILOperation N> HighLevelILInstruction GetRightExpr() const { return As<N>().GetRightExpr(); }
- template <BNHighLevelILOperation N> HighLevelILInstruction GetCarryExpr() const { return As<N>().GetCarryExpr(); }
- template <BNHighLevelILOperation N> HighLevelILInstruction GetIndexExpr() const { return As<N>().GetIndexExpr(); }
- template <BNHighLevelILOperation N> HighLevelILInstruction GetConditionPhiExpr() const { return As<N>().GetConditionPhiExpr(); }
- template <BNHighLevelILOperation N> HighLevelILInstruction GetConditionExpr() const { return As<N>().GetConditionExpr(); }
- template <BNHighLevelILOperation N> HighLevelILInstruction GetTrueExpr() const { return As<N>().GetTrueExpr(); }
- template <BNHighLevelILOperation N> HighLevelILInstruction GetFalseExpr() const { return As<N>().GetFalseExpr(); }
- template <BNHighLevelILOperation N> HighLevelILInstruction GetLoopExpr() const { return As<N>().GetLoopExpr(); }
- template <BNHighLevelILOperation N> HighLevelILInstruction GetInitExpr() const { return As<N>().GetInitExpr(); }
- template <BNHighLevelILOperation N> HighLevelILInstruction GetUpdateExpr() const { return As<N>().GetUpdateExpr(); }
- template <BNHighLevelILOperation N> HighLevelILInstruction GetDefaultExpr() const { return As<N>().GetDefaultExpr(); }
- template <BNHighLevelILOperation N> HighLevelILInstruction GetHighExpr() const { return As<N>().GetHighExpr(); }
- template <BNHighLevelILOperation N> HighLevelILInstruction GetLowExpr() const { return As<N>().GetLowExpr(); }
- template <BNHighLevelILOperation N> uint64_t GetOffset() const { return As<N>().GetOffset(); }
- template <BNHighLevelILOperation N> size_t GetMemberIndex() const { return As<N>().GetMemberIndex(); }
- template <BNHighLevelILOperation N> int64_t GetConstant() const { return As<N>().GetConstant(); }
- template <BNHighLevelILOperation N> int64_t GetVector() const { return As<N>().GetVector(); }
- template <BNHighLevelILOperation N> uint32_t GetIntrinsic() const { return As<N>().GetIntrinsic(); }
- template <BNHighLevelILOperation N> uint64_t GetTarget() const { return As<N>().GetTarget(); }
- template <BNHighLevelILOperation N> HighLevelILInstructionList GetParameterExprs() const { return As<N>().GetParameterExprs(); }
- template <BNHighLevelILOperation N> HighLevelILInstructionList GetSourceExprs() const { return As<N>().GetSourceExprs(); }
- template <BNHighLevelILOperation N> HighLevelILInstructionList GetDestExprs() const { return As<N>().GetDestExprs(); }
- template <BNHighLevelILOperation N> HighLevelILInstructionList GetBlockExprs() const { return As<N>().GetBlockExprs(); }
- template <BNHighLevelILOperation N> HighLevelILInstructionList GetCases() const { return As<N>().GetCases(); }
- template <BNHighLevelILOperation N> HighLevelILInstructionList GetValueExprs() const { return As<N>().GetValueExprs(); }
- template <BNHighLevelILOperation N> HighLevelILSSAVariableList GetSourceSSAVariables() const { return As<N>().GetSourceSSAVariables(); }
- template <BNHighLevelILOperation N> size_t GetSourceMemoryVersion() const { return As<N>().GetSourceMemoryVersion(); }
- template <BNHighLevelILOperation N> HighLevelILIndexList GetSourceMemoryVersions() const { return As<N>().GetSourceMemoryVersions(); }
- template <BNHighLevelILOperation N> size_t GetDestMemoryVersion() const { return As<N>().GetDestMemoryVersion(); }
+ template <BNHighLevelILOperation N>
+ HighLevelILInstruction GetSourceExpr() const
+ {
+ return As<N>().GetSourceExpr();
+ }
+ template <BNHighLevelILOperation N>
+ Variable GetVariable() const
+ {
+ return As<N>().GetVariable();
+ }
+ template <BNHighLevelILOperation N>
+ Variable GetDestVariable() const
+ {
+ return As<N>().GetDestVariable();
+ }
+ template <BNHighLevelILOperation N>
+ SSAVariable GetSSAVariable() const
+ {
+ return As<N>().GetSSAVariable();
+ }
+ template <BNHighLevelILOperation N>
+ SSAVariable GetDestSSAVariable() const
+ {
+ return As<N>().GetDestSSAVariable();
+ }
+ template <BNHighLevelILOperation N>
+ HighLevelILInstruction GetDestExpr() const
+ {
+ return As<N>().GetDestExpr();
+ }
+ template <BNHighLevelILOperation N>
+ HighLevelILInstruction GetLeftExpr() const
+ {
+ return As<N>().GetLeftExpr();
+ }
+ template <BNHighLevelILOperation N>
+ HighLevelILInstruction GetRightExpr() const
+ {
+ return As<N>().GetRightExpr();
+ }
+ template <BNHighLevelILOperation N>
+ HighLevelILInstruction GetCarryExpr() const
+ {
+ return As<N>().GetCarryExpr();
+ }
+ template <BNHighLevelILOperation N>
+ HighLevelILInstruction GetIndexExpr() const
+ {
+ return As<N>().GetIndexExpr();
+ }
+ template <BNHighLevelILOperation N>
+ HighLevelILInstruction GetConditionPhiExpr() const
+ {
+ return As<N>().GetConditionPhiExpr();
+ }
+ template <BNHighLevelILOperation N>
+ HighLevelILInstruction GetConditionExpr() const
+ {
+ return As<N>().GetConditionExpr();
+ }
+ template <BNHighLevelILOperation N>
+ HighLevelILInstruction GetTrueExpr() const
+ {
+ return As<N>().GetTrueExpr();
+ }
+ template <BNHighLevelILOperation N>
+ HighLevelILInstruction GetFalseExpr() const
+ {
+ return As<N>().GetFalseExpr();
+ }
+ template <BNHighLevelILOperation N>
+ HighLevelILInstruction GetLoopExpr() const
+ {
+ return As<N>().GetLoopExpr();
+ }
+ template <BNHighLevelILOperation N>
+ HighLevelILInstruction GetInitExpr() const
+ {
+ return As<N>().GetInitExpr();
+ }
+ template <BNHighLevelILOperation N>
+ HighLevelILInstruction GetUpdateExpr() const
+ {
+ return As<N>().GetUpdateExpr();
+ }
+ template <BNHighLevelILOperation N>
+ HighLevelILInstruction GetDefaultExpr() const
+ {
+ return As<N>().GetDefaultExpr();
+ }
+ template <BNHighLevelILOperation N>
+ HighLevelILInstruction GetHighExpr() const
+ {
+ return As<N>().GetHighExpr();
+ }
+ template <BNHighLevelILOperation N>
+ HighLevelILInstruction GetLowExpr() const
+ {
+ return As<N>().GetLowExpr();
+ }
+ template <BNHighLevelILOperation N>
+ uint64_t GetOffset() const
+ {
+ return As<N>().GetOffset();
+ }
+ template <BNHighLevelILOperation N>
+ size_t GetMemberIndex() const
+ {
+ return As<N>().GetMemberIndex();
+ }
+ template <BNHighLevelILOperation N>
+ int64_t GetConstant() const
+ {
+ return As<N>().GetConstant();
+ }
+ template <BNHighLevelILOperation N>
+ int64_t GetVector() const
+ {
+ return As<N>().GetVector();
+ }
+ template <BNHighLevelILOperation N>
+ uint32_t GetIntrinsic() const
+ {
+ return As<N>().GetIntrinsic();
+ }
+ template <BNHighLevelILOperation N>
+ uint64_t GetTarget() const
+ {
+ return As<N>().GetTarget();
+ }
+ template <BNHighLevelILOperation N>
+ HighLevelILInstructionList GetParameterExprs() const
+ {
+ return As<N>().GetParameterExprs();
+ }
+ template <BNHighLevelILOperation N>
+ HighLevelILInstructionList GetSourceExprs() const
+ {
+ return As<N>().GetSourceExprs();
+ }
+ template <BNHighLevelILOperation N>
+ HighLevelILInstructionList GetDestExprs() const
+ {
+ return As<N>().GetDestExprs();
+ }
+ template <BNHighLevelILOperation N>
+ HighLevelILInstructionList GetBlockExprs() const
+ {
+ return As<N>().GetBlockExprs();
+ }
+ template <BNHighLevelILOperation N>
+ HighLevelILInstructionList GetCases() const
+ {
+ return As<N>().GetCases();
+ }
+ template <BNHighLevelILOperation N>
+ HighLevelILInstructionList GetValueExprs() const
+ {
+ return As<N>().GetValueExprs();
+ }
+ template <BNHighLevelILOperation N>
+ HighLevelILSSAVariableList GetSourceSSAVariables() const
+ {
+ return As<N>().GetSourceSSAVariables();
+ }
+ template <BNHighLevelILOperation N>
+ size_t GetSourceMemoryVersion() const
+ {
+ return As<N>().GetSourceMemoryVersion();
+ }
+ template <BNHighLevelILOperation N>
+ HighLevelILIndexList GetSourceMemoryVersions() const
+ {
+ return As<N>().GetSourceMemoryVersions();
+ }
+ template <BNHighLevelILOperation N>
+ size_t GetDestMemoryVersion() const
+ {
+ return As<N>().GetDestMemoryVersion();
+ }
- template <BNHighLevelILOperation N> void SetSSAVersion(size_t version) { As<N>().SetSSAVersion(version); }
- template <BNHighLevelILOperation N> void SetDestSSAVersion(size_t version) { As<N>().SetDestSSAVersion(version); }
- template <BNHighLevelILOperation N> void SetParameterExprs(const _STD_VECTOR<MediumLevelILInstruction>& params) { As<N>().SetParameterExprs(params); }
- template <BNHighLevelILOperation N> void SetParameterExprs(const _STD_VECTOR<ExprId>& params) { As<N>().SetParameterExprs(params); }
- template <BNHighLevelILOperation N> void SetSourceExprs(const _STD_VECTOR<MediumLevelILInstruction>& params) { As<N>().SetSourceExprs(params); }
- template <BNHighLevelILOperation N> void SetSourceExprs(const _STD_VECTOR<ExprId>& params) { As<N>().SetSourceExprs(params); }
- template <BNHighLevelILOperation N> void SetDestExprs(const _STD_VECTOR<MediumLevelILInstruction>& params) { As<N>().SetDestExprs(params); }
- template <BNHighLevelILOperation N> void SetDestExprs(const _STD_VECTOR<ExprId>& params) { As<N>().SetDestExprs(params); }
- template <BNHighLevelILOperation N> void SetBlockExprs(const _STD_VECTOR<MediumLevelILInstruction>& params) { As<N>().SetBlockExprs(params); }
- template <BNHighLevelILOperation N> void SetBlockExprs(const _STD_VECTOR<ExprId>& params) { As<N>().SetBlockExprs(params); }
- template <BNHighLevelILOperation N> void SetCases(const _STD_VECTOR<MediumLevelILInstruction>& params) { As<N>().SetCases(params); }
- template <BNHighLevelILOperation N> void SetCases(const _STD_VECTOR<ExprId>& params) { As<N>().SetCases(params); }
- template <BNHighLevelILOperation N> void SetSourceSSAVariables(const _STD_VECTOR<SSAVariable>& vars) { As<N>().SetSourceSSAVariables(vars); }
- template <BNHighLevelILOperation N> void SetSourceMemoryVersion(size_t version) { return As<N>().SetSourceMemoryVersion(version); }
- template <BNHighLevelILOperation N> void SetDestMemoryVersion(size_t version) { return As<N>().SetDestMemoryVersion(version); }
- template <BNHighLevelILOperation N> void SetTarget(uint64_t target) { As<N>().SetTarget(target); }
+ template <BNHighLevelILOperation N>
+ void SetSSAVersion(size_t version)
+ {
+ As<N>().SetSSAVersion(version);
+ }
+ template <BNHighLevelILOperation N>
+ void SetDestSSAVersion(size_t version)
+ {
+ As<N>().SetDestSSAVersion(version);
+ }
+ template <BNHighLevelILOperation N>
+ void SetParameterExprs(const _STD_VECTOR<MediumLevelILInstruction>& params)
+ {
+ As<N>().SetParameterExprs(params);
+ }
+ template <BNHighLevelILOperation N>
+ void SetParameterExprs(const _STD_VECTOR<ExprId>& params)
+ {
+ As<N>().SetParameterExprs(params);
+ }
+ template <BNHighLevelILOperation N>
+ void SetSourceExprs(const _STD_VECTOR<MediumLevelILInstruction>& params)
+ {
+ As<N>().SetSourceExprs(params);
+ }
+ template <BNHighLevelILOperation N>
+ void SetSourceExprs(const _STD_VECTOR<ExprId>& params)
+ {
+ As<N>().SetSourceExprs(params);
+ }
+ template <BNHighLevelILOperation N>
+ void SetDestExprs(const _STD_VECTOR<MediumLevelILInstruction>& params)
+ {
+ As<N>().SetDestExprs(params);
+ }
+ template <BNHighLevelILOperation N>
+ void SetDestExprs(const _STD_VECTOR<ExprId>& params)
+ {
+ As<N>().SetDestExprs(params);
+ }
+ template <BNHighLevelILOperation N>
+ void SetBlockExprs(const _STD_VECTOR<MediumLevelILInstruction>& params)
+ {
+ As<N>().SetBlockExprs(params);
+ }
+ template <BNHighLevelILOperation N>
+ void SetBlockExprs(const _STD_VECTOR<ExprId>& params)
+ {
+ As<N>().SetBlockExprs(params);
+ }
+ template <BNHighLevelILOperation N>
+ void SetCases(const _STD_VECTOR<MediumLevelILInstruction>& params)
+ {
+ As<N>().SetCases(params);
+ }
+ template <BNHighLevelILOperation N>
+ void SetCases(const _STD_VECTOR<ExprId>& params)
+ {
+ As<N>().SetCases(params);
+ }
+ template <BNHighLevelILOperation N>
+ void SetSourceSSAVariables(const _STD_VECTOR<SSAVariable>& vars)
+ {
+ As<N>().SetSourceSSAVariables(vars);
+ }
+ template <BNHighLevelILOperation N>
+ void SetSourceMemoryVersion(size_t version)
+ {
+ return As<N>().SetSourceMemoryVersion(version);
+ }
+ template <BNHighLevelILOperation N>
+ void SetDestMemoryVersion(size_t version)
+ {
+ return As<N>().SetDestMemoryVersion(version);
+ }
+ template <BNHighLevelILOperation N>
+ void SetTarget(uint64_t target)
+ {
+ As<N>().SetTarget(target);
+ }
bool GetOperandIndexForUsage(HighLevelILOperandUsage usage, size_t& operandIndex) const;
@@ -506,9 +717,8 @@ namespace BinaryNinja
HighLevelILOperandType m_type;
size_t m_operandIndex;
- public:
- HighLevelILOperand(const HighLevelILInstruction& instr, HighLevelILOperandUsage usage,
- size_t operandIndex);
+ public:
+ HighLevelILOperand(const HighLevelILInstruction& instr, HighLevelILOperandUsage usage, size_t operandIndex);
HighLevelILOperandType GetType() const { return m_type; }
HighLevelILOperandUsage GetUsage() const { return m_usage; }
@@ -533,7 +743,11 @@ namespace BinaryNinja
bool operator==(const ListIterator& a) const { return pos == a.pos; }
bool operator!=(const ListIterator& a) const { return pos != a.pos; }
bool operator<(const ListIterator& a) const { return pos < a.pos; }
- ListIterator& operator++() { ++pos; return *this; }
+ ListIterator& operator++()
+ {
+ ++pos;
+ return *this;
+ }
const HighLevelILOperand operator*();
};
@@ -541,12 +755,12 @@ namespace BinaryNinja
const _STD_VECTOR<HighLevelILOperandUsage>& m_usageList;
const _STD_UNORDERED_MAP<HighLevelILOperandUsage, size_t>& m_operandIndexMap;
- public:
+ public:
typedef ListIterator const_iterator;
HighLevelILOperandList(const HighLevelILInstruction& instr,
- const _STD_VECTOR<HighLevelILOperandUsage>& usageList,
- const _STD_UNORDERED_MAP<HighLevelILOperandUsage, size_t>& operandIndexMap);
+ const _STD_VECTOR<HighLevelILOperandUsage>& usageList,
+ const _STD_UNORDERED_MAP<HighLevelILOperandUsage, size_t>& operandIndexMap);
const_iterator begin() const;
const_iterator end() const;
@@ -556,23 +770,23 @@ namespace BinaryNinja
operator _STD_VECTOR<HighLevelILOperand>() const;
};
- struct HighLevelILConstantInstruction: public HighLevelILInstructionBase
+ struct HighLevelILConstantInstruction : public HighLevelILInstructionBase
{
int64_t GetConstant() const { return GetRawOperandAsInteger(0); }
};
- struct HighLevelILOneOperandInstruction: public HighLevelILInstructionBase
+ struct HighLevelILOneOperandInstruction : public HighLevelILInstructionBase
{
HighLevelILInstruction GetSourceExpr() const { return GetRawOperandAsExpr(0); }
};
- struct HighLevelILTwoOperandInstruction: public HighLevelILInstructionBase
+ struct HighLevelILTwoOperandInstruction : public HighLevelILInstructionBase
{
HighLevelILInstruction GetLeftExpr() const { return GetRawOperandAsExpr(0); }
HighLevelILInstruction GetRightExpr() const { return GetRawOperandAsExpr(1); }
};
- struct HighLevelILTwoOperandWithCarryInstruction: public HighLevelILInstructionBase
+ struct HighLevelILTwoOperandWithCarryInstruction : public HighLevelILInstructionBase
{
HighLevelILInstruction GetLeftExpr() const { return GetRawOperandAsExpr(0); }
HighLevelILInstruction GetRightExpr() const { return GetRawOperandAsExpr(1); }
@@ -582,46 +796,54 @@ namespace BinaryNinja
// Implementations of each instruction to fetch the correct operand value for the valid operands, these
// are derived from HighLevelILInstructionBase so that invalid operand accessor functions will generate
// a compiler error.
- template <> struct HighLevelILInstructionAccessor<HLIL_BLOCK>: public HighLevelILInstructionBase
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_BLOCK> : public HighLevelILInstructionBase
{
HighLevelILInstructionList GetBlockExprs() const { return GetRawOperandAsExprList(0); }
};
- template <> struct HighLevelILInstructionAccessor<HLIL_IF>: public HighLevelILInstructionBase
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_IF> : public HighLevelILInstructionBase
{
HighLevelILInstruction GetConditionExpr() const { return GetRawOperandAsExpr(0); }
HighLevelILInstruction GetTrueExpr() const { return GetRawOperandAsExpr(1); }
HighLevelILInstruction GetFalseExpr() const { return GetRawOperandAsExpr(2); }
};
- template <> struct HighLevelILInstructionAccessor<HLIL_WHILE>: public HighLevelILInstructionBase
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_WHILE> : public HighLevelILInstructionBase
{
HighLevelILInstruction GetConditionExpr() const { return GetRawOperandAsExpr(0); }
HighLevelILInstruction GetLoopExpr() const { return GetRawOperandAsExpr(1); }
};
- template <> struct HighLevelILInstructionAccessor<HLIL_WHILE_SSA>: public HighLevelILInstructionBase
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_WHILE_SSA> : public HighLevelILInstructionBase
{
HighLevelILInstruction GetConditionPhiExpr() const { return GetRawOperandAsExpr(0); }
HighLevelILInstruction GetConditionExpr() const { return GetRawOperandAsExpr(1); }
HighLevelILInstruction GetLoopExpr() const { return GetRawOperandAsExpr(2); }
};
- template <> struct HighLevelILInstructionAccessor<HLIL_DO_WHILE>: public HighLevelILInstructionBase
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_DO_WHILE> : public HighLevelILInstructionBase
{
HighLevelILInstruction GetLoopExpr() const { return GetRawOperandAsExpr(0); }
HighLevelILInstruction GetConditionExpr() const { return GetRawOperandAsExpr(1); }
};
- template <> struct HighLevelILInstructionAccessor<HLIL_DO_WHILE_SSA>: public HighLevelILInstructionBase
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_DO_WHILE_SSA> : public HighLevelILInstructionBase
{
HighLevelILInstruction GetLoopExpr() const { return GetRawOperandAsExpr(0); }
HighLevelILInstruction GetConditionPhiExpr() const { return GetRawOperandAsExpr(1); }
HighLevelILInstruction GetConditionExpr() const { return GetRawOperandAsExpr(2); }
};
- template <> struct HighLevelILInstructionAccessor<HLIL_FOR>: public HighLevelILInstructionBase
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_FOR> : public HighLevelILInstructionBase
{
HighLevelILInstruction GetInitExpr() const { return GetRawOperandAsExpr(0); }
HighLevelILInstruction GetConditionExpr() const { return GetRawOperandAsExpr(1); }
HighLevelILInstruction GetUpdateExpr() const { return GetRawOperandAsExpr(2); }
HighLevelILInstruction GetLoopExpr() const { return GetRawOperandAsExpr(3); }
};
- template <> struct HighLevelILInstructionAccessor<HLIL_FOR_SSA>: public HighLevelILInstructionBase
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_FOR_SSA> : public HighLevelILInstructionBase
{
HighLevelILInstruction GetInitExpr() const { return GetRawOperandAsExpr(0); }
HighLevelILInstruction GetConditionPhiExpr() const { return GetRawOperandAsExpr(1); }
@@ -629,60 +851,71 @@ namespace BinaryNinja
HighLevelILInstruction GetUpdateExpr() const { return GetRawOperandAsExpr(3); }
HighLevelILInstruction GetLoopExpr() const { return GetRawOperandAsExpr(4); }
};
- template <> struct HighLevelILInstructionAccessor<HLIL_SWITCH>: public HighLevelILInstructionBase
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_SWITCH> : public HighLevelILInstructionBase
{
HighLevelILInstruction GetConditionExpr() const { return GetRawOperandAsExpr(0); }
HighLevelILInstruction GetDefaultExpr() const { return GetRawOperandAsExpr(1); }
HighLevelILInstructionList GetCases() const { return GetRawOperandAsExprList(2); }
};
- template <> struct HighLevelILInstructionAccessor<HLIL_CASE>: public HighLevelILInstructionBase
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_CASE> : public HighLevelILInstructionBase
{
HighLevelILInstructionList GetValueExprs() const { return GetRawOperandAsExprList(0); }
HighLevelILInstruction GetTrueExpr() const { return GetRawOperandAsExpr(2); }
};
- template <> struct HighLevelILInstructionAccessor<HLIL_GOTO>: public HighLevelILInstructionBase
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_GOTO> : public HighLevelILInstructionBase
{
uint64_t GetTarget() const { return GetRawOperandAsInteger(0); }
void SetTarget(uint64_t target) { UpdateRawOperandAsInteger(0, target); }
};
- template <> struct HighLevelILInstructionAccessor<HLIL_LABEL>: public HighLevelILInstructionBase
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_LABEL> : public HighLevelILInstructionBase
{
uint64_t GetTarget() const { return GetRawOperandAsInteger(0); }
void SetTarget(uint64_t target) { UpdateRawOperandAsInteger(0, target); }
};
- template <> struct HighLevelILInstructionAccessor<HLIL_RET>: public HighLevelILInstructionBase
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_RET> : public HighLevelILInstructionBase
{
HighLevelILInstructionList GetSourceExprs() const { return GetRawOperandAsExprList(0); }
void SetSourceExprs(const _STD_VECTOR<ExprId>& exprs) { UpdateRawOperandAsExprList(0, exprs); }
};
- template <> struct HighLevelILInstructionAccessor<HLIL_VAR_DECLARE>: public HighLevelILInstructionBase
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_VAR_DECLARE> : public HighLevelILInstructionBase
{
Variable GetVariable() const { return GetRawOperandAsVariable(0); }
};
- template <> struct HighLevelILInstructionAccessor<HLIL_VAR_INIT>: public HighLevelILInstructionBase
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_VAR_INIT> : public HighLevelILInstructionBase
{
Variable GetDestVariable() const { return GetRawOperandAsVariable(0); }
HighLevelILInstruction GetSourceExpr() const { return GetRawOperandAsExpr(1); }
};
- template <> struct HighLevelILInstructionAccessor<HLIL_VAR_INIT_SSA>: public HighLevelILInstructionBase
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_VAR_INIT_SSA> : public HighLevelILInstructionBase
{
SSAVariable GetDestSSAVariable() const { return GetRawOperandAsSSAVariable(0); }
void SetDestSSAVersion(size_t version) { UpdateRawOperand(1, version); }
HighLevelILInstruction GetSourceExpr() const { return GetRawOperandAsExpr(2); }
};
- template <> struct HighLevelILInstructionAccessor<HLIL_ASSIGN>: public HighLevelILInstructionBase
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_ASSIGN> : public HighLevelILInstructionBase
{
HighLevelILInstruction GetDestExpr() const { return GetRawOperandAsExpr(0); }
HighLevelILInstruction GetSourceExpr() const { return GetRawOperandAsExpr(1); }
};
- template <> struct HighLevelILInstructionAccessor<HLIL_ASSIGN_UNPACK>: public HighLevelILInstructionBase
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_ASSIGN_UNPACK> : public HighLevelILInstructionBase
{
HighLevelILInstructionList GetDestExprs() const { return GetRawOperandAsExprList(0); }
HighLevelILInstruction GetSourceExpr() const { return GetRawOperandAsExpr(2); }
};
- template <> struct HighLevelILInstructionAccessor<HLIL_ASSIGN_MEM_SSA>: public HighLevelILInstructionBase
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_ASSIGN_MEM_SSA> : public HighLevelILInstructionBase
{
HighLevelILInstruction GetDestExpr() const { return GetRawOperandAsExpr(0); }
size_t GetDestMemoryVersion() const { return GetRawOperandAsIndex(1); }
@@ -691,7 +924,8 @@ namespace BinaryNinja
size_t GetSourceMemoryVersion() const { return GetRawOperandAsIndex(3); }
void SetSourceMemoryVersion(size_t version) { UpdateRawOperand(3, version); }
};
- template <> struct HighLevelILInstructionAccessor<HLIL_ASSIGN_UNPACK_MEM_SSA>: public HighLevelILInstructionBase
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_ASSIGN_UNPACK_MEM_SSA> : public HighLevelILInstructionBase
{
HighLevelILInstructionList GetDestExprs() const { return GetRawOperandAsExprList(0); }
size_t GetDestMemoryVersion() const { return GetRawOperandAsIndex(2); }
@@ -701,25 +935,29 @@ namespace BinaryNinja
void SetSourceMemoryVersion(size_t version) { UpdateRawOperand(4, version); }
};
- template <> struct HighLevelILInstructionAccessor<HLIL_STRUCT_FIELD>: public HighLevelILInstructionBase
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_STRUCT_FIELD> : public HighLevelILInstructionBase
{
HighLevelILInstruction GetSourceExpr() const { return GetRawOperandAsExpr(0); }
uint64_t GetOffset() const { return GetRawOperandAsInteger(1); }
size_t GetMemberIndex() const { return GetRawOperandAsIndex(2); }
};
- template <> struct HighLevelILInstructionAccessor<HLIL_DEREF_FIELD>: public HighLevelILInstructionBase
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_DEREF_FIELD> : public HighLevelILInstructionBase
{
HighLevelILInstruction GetSourceExpr() const { return GetRawOperandAsExpr(0); }
uint64_t GetOffset() const { return GetRawOperandAsInteger(1); }
size_t GetMemberIndex() const { return GetRawOperandAsIndex(2); }
};
- template <> struct HighLevelILInstructionAccessor<HLIL_DEREF_SSA>: public HighLevelILInstructionBase
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_DEREF_SSA> : public HighLevelILInstructionBase
{
HighLevelILInstruction GetSourceExpr() const { return GetRawOperandAsExpr(0); }
size_t GetSourceMemoryVersion() const { return GetRawOperandAsIndex(1); }
void SetSourceMemoryVersion(size_t version) { UpdateRawOperand(1, version); }
};
- template <> struct HighLevelILInstructionAccessor<HLIL_DEREF_FIELD_SSA>: public HighLevelILInstructionBase
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_DEREF_FIELD_SSA> : public HighLevelILInstructionBase
{
HighLevelILInstruction GetSourceExpr() const { return GetRawOperandAsExpr(0); }
size_t GetSourceMemoryVersion() const { return GetRawOperandAsIndex(1); }
@@ -727,66 +965,78 @@ namespace BinaryNinja
uint64_t GetOffset() const { return GetRawOperandAsInteger(2); }
size_t GetMemberIndex() const { return GetRawOperandAsIndex(3); }
};
- template <> struct HighLevelILInstructionAccessor<HLIL_ARRAY_INDEX>: public HighLevelILInstructionBase
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_ARRAY_INDEX> : public HighLevelILInstructionBase
{
HighLevelILInstruction GetSourceExpr() const { return GetRawOperandAsExpr(0); }
HighLevelILInstruction GetIndexExpr() const { return GetRawOperandAsExpr(1); }
};
- template <> struct HighLevelILInstructionAccessor<HLIL_ARRAY_INDEX_SSA>: public HighLevelILInstructionBase
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_ARRAY_INDEX_SSA> : public HighLevelILInstructionBase
{
HighLevelILInstruction GetSourceExpr() const { return GetRawOperandAsExpr(0); }
size_t GetSourceMemoryVersion() const { return GetRawOperandAsIndex(1); }
void SetSourceMemoryVersion(size_t version) { UpdateRawOperand(1, version); }
HighLevelILInstruction GetIndexExpr() const { return GetRawOperandAsExpr(2); }
};
- template <> struct HighLevelILInstructionAccessor<HLIL_SPLIT>: public HighLevelILInstructionBase
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_SPLIT> : public HighLevelILInstructionBase
{
HighLevelILInstruction GetHighExpr() const { return GetRawOperandAsExpr(0); }
HighLevelILInstruction GetLowExpr() const { return GetRawOperandAsExpr(1); }
};
- template <> struct HighLevelILInstructionAccessor<HLIL_VAR>: public HighLevelILInstructionBase
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_VAR> : public HighLevelILInstructionBase
{
Variable GetVariable() const { return GetRawOperandAsVariable(0); }
};
- template <> struct HighLevelILInstructionAccessor<HLIL_VAR_SSA>: public HighLevelILInstructionBase
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_VAR_SSA> : public HighLevelILInstructionBase
{
SSAVariable GetSSAVariable() const { return GetRawOperandAsSSAVariable(0); }
void SetSSAVersion(size_t version) { UpdateRawOperand(1, version); }
};
- template <> struct HighLevelILInstructionAccessor<HLIL_VAR_PHI>: public HighLevelILInstructionBase
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_VAR_PHI> : public HighLevelILInstructionBase
{
SSAVariable GetDestSSAVariable() const { return GetRawOperandAsSSAVariable(0); }
HighLevelILSSAVariableList GetSourceSSAVariables() const { return GetRawOperandAsSSAVariableList(2); }
void SetSourceSSAVariables(const _STD_VECTOR<SSAVariable>& vars) { UpdateRawOperandAsSSAVariableList(2, vars); }
};
- template <> struct HighLevelILInstructionAccessor<HLIL_MEM_PHI>: public HighLevelILInstructionBase
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_MEM_PHI> : public HighLevelILInstructionBase
{
size_t GetDestMemoryVersion() const { return GetRawOperandAsIndex(0); }
void SetDestMemoryVersion(size_t version) { UpdateRawOperand(0, version); }
HighLevelILIndexList GetSourceMemoryVersions() const { return GetRawOperandAsIndexList(1); }
};
- template <> struct HighLevelILInstructionAccessor<HLIL_JUMP>: public HighLevelILInstructionBase
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_JUMP> : public HighLevelILInstructionBase
{
HighLevelILInstruction GetDestExpr() const { return GetRawOperandAsExpr(0); }
};
- template <> struct HighLevelILInstructionAccessor<HLIL_CALL>: public HighLevelILInstructionBase
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_CALL> : public HighLevelILInstructionBase
{
HighLevelILInstruction GetDestExpr() const { return GetRawOperandAsExpr(0); }
HighLevelILInstructionList GetParameterExprs() const { return GetRawOperandAsExprList(1); }
};
- template <> struct HighLevelILInstructionAccessor<HLIL_SYSCALL>: public HighLevelILInstructionBase
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_SYSCALL> : public HighLevelILInstructionBase
{
HighLevelILInstructionList GetParameterExprs() const { return GetRawOperandAsExprList(0); }
};
- template <> struct HighLevelILInstructionAccessor<HLIL_TAILCALL>: public HighLevelILInstructionBase
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_TAILCALL> : public HighLevelILInstructionBase
{
HighLevelILInstruction GetDestExpr() const { return GetRawOperandAsExpr(0); }
HighLevelILInstructionList GetParameterExprs() const { return GetRawOperandAsExprList(1); }
};
- template <> struct HighLevelILInstructionAccessor<HLIL_CALL_SSA>: public HighLevelILInstructionBase
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_CALL_SSA> : public HighLevelILInstructionBase
{
HighLevelILInstruction GetDestExpr() const { return GetRawOperandAsExpr(0); }
HighLevelILInstructionList GetParameterExprs() const { return GetRawOperandAsExprList(1); }
@@ -795,7 +1045,8 @@ namespace BinaryNinja
size_t GetSourceMemoryVersion() const { return GetRawOperandAsIndex(4); }
void SetSourceMemoryVersion(size_t version) { UpdateRawOperand(4, version); }
};
- template <> struct HighLevelILInstructionAccessor<HLIL_SYSCALL_SSA>: public HighLevelILInstructionBase
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_SYSCALL_SSA> : public HighLevelILInstructionBase
{
HighLevelILInstructionList GetParameterExprs() const { return GetRawOperandAsExprList(0); }
size_t GetDestMemoryVersion() const { return GetRawOperandAsIndex(2); }
@@ -804,12 +1055,14 @@ namespace BinaryNinja
void SetSourceMemoryVersion(size_t version) { UpdateRawOperand(3, version); }
};
- template <> struct HighLevelILInstructionAccessor<HLIL_INTRINSIC>: public HighLevelILInstructionBase
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_INTRINSIC> : public HighLevelILInstructionBase
{
uint32_t GetIntrinsic() const { return (uint32_t)GetRawOperandAsInteger(0); }
HighLevelILInstructionList GetParameterExprs() const { return GetRawOperandAsExprList(1); }
};
- template <> struct HighLevelILInstructionAccessor<HLIL_INTRINSIC_SSA>: public HighLevelILInstructionBase
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_INTRINSIC_SSA> : public HighLevelILInstructionBase
{
uint32_t GetIntrinsic() const { return (uint32_t)GetRawOperandAsInteger(0); }
HighLevelILInstructionList GetParameterExprs() const { return GetRawOperandAsExprList(1); }
@@ -819,102 +1072,262 @@ namespace BinaryNinja
void SetSourceMemoryVersion(size_t version) { UpdateRawOperand(4, version); }
};
- template <> struct HighLevelILInstructionAccessor<HLIL_TRAP>: public HighLevelILInstructionBase
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_TRAP> : public HighLevelILInstructionBase
{
int64_t GetVector() const { return GetRawOperandAsInteger(0); }
};
- template <> struct HighLevelILInstructionAccessor<HLIL_EXTERN_PTR>: public HighLevelILConstantInstruction
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_EXTERN_PTR> : public HighLevelILConstantInstruction
{
int64_t GetConstant() const { return GetRawOperandAsInteger(0); }
int64_t GetOffset() const { return GetRawOperandAsInteger(1); }
};
- template <> struct HighLevelILInstructionAccessor<HLIL_NOP>: public HighLevelILInstructionBase {};
- template <> struct HighLevelILInstructionAccessor<HLIL_BREAK>: public HighLevelILInstructionBase {};
- template <> struct HighLevelILInstructionAccessor<HLIL_CONTINUE>: public HighLevelILInstructionBase {};
- template <> struct HighLevelILInstructionAccessor<HLIL_NORET>: public HighLevelILInstructionBase {};
- template <> struct HighLevelILInstructionAccessor<HLIL_BP>: public HighLevelILInstructionBase {};
- template <> struct HighLevelILInstructionAccessor<HLIL_UNDEF>: public HighLevelILInstructionBase {};
- template <> struct HighLevelILInstructionAccessor<HLIL_UNIMPL>: public HighLevelILInstructionBase {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_NOP> : public HighLevelILInstructionBase
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_BREAK> : public HighLevelILInstructionBase
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_CONTINUE> : public HighLevelILInstructionBase
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_NORET> : public HighLevelILInstructionBase
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_BP> : public HighLevelILInstructionBase
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_UNDEF> : public HighLevelILInstructionBase
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_UNIMPL> : public HighLevelILInstructionBase
+ {};
- template <> struct HighLevelILInstructionAccessor<HLIL_CONST>: public HighLevelILConstantInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_CONST_PTR>: public HighLevelILConstantInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_FLOAT_CONST>: public HighLevelILConstantInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_IMPORT>: public HighLevelILConstantInstruction {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_CONST> : public HighLevelILConstantInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_CONST_PTR> : public HighLevelILConstantInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_FLOAT_CONST> : public HighLevelILConstantInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_IMPORT> : public HighLevelILConstantInstruction
+ {};
- template <> struct HighLevelILInstructionAccessor<HLIL_ADD>: public HighLevelILTwoOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_SUB>: public HighLevelILTwoOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_AND>: public HighLevelILTwoOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_OR>: public HighLevelILTwoOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_XOR>: public HighLevelILTwoOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_LSL>: public HighLevelILTwoOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_LSR>: public HighLevelILTwoOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_ASR>: public HighLevelILTwoOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_ROL>: public HighLevelILTwoOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_ROR>: public HighLevelILTwoOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_MUL>: public HighLevelILTwoOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_MULU_DP>: public HighLevelILTwoOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_MULS_DP>: public HighLevelILTwoOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_DIVU>: public HighLevelILTwoOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_DIVS>: public HighLevelILTwoOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_MODU>: public HighLevelILTwoOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_MODS>: public HighLevelILTwoOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_DIVU_DP>: public HighLevelILTwoOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_DIVS_DP>: public HighLevelILTwoOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_MODU_DP>: public HighLevelILTwoOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_MODS_DP>: public HighLevelILTwoOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_CMP_E>: public HighLevelILTwoOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_CMP_NE>: public HighLevelILTwoOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_CMP_SLT>: public HighLevelILTwoOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_CMP_ULT>: public HighLevelILTwoOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_CMP_SLE>: public HighLevelILTwoOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_CMP_ULE>: public HighLevelILTwoOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_CMP_SGE>: public HighLevelILTwoOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_CMP_UGE>: public HighLevelILTwoOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_CMP_SGT>: public HighLevelILTwoOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_CMP_UGT>: public HighLevelILTwoOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_TEST_BIT>: public HighLevelILTwoOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_ADD_OVERFLOW>: public HighLevelILTwoOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_FADD>: public HighLevelILTwoOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_FSUB>: public HighLevelILTwoOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_FMUL>: public HighLevelILTwoOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_FDIV>: public HighLevelILTwoOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_FCMP_E>: public HighLevelILTwoOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_FCMP_NE>: public HighLevelILTwoOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_FCMP_LT>: public HighLevelILTwoOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_FCMP_LE>: public HighLevelILTwoOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_FCMP_GE>: public HighLevelILTwoOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_FCMP_GT>: public HighLevelILTwoOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_FCMP_O>: public HighLevelILTwoOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_FCMP_UO>: public HighLevelILTwoOperandInstruction {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_ADD> : public HighLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_SUB> : public HighLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_AND> : public HighLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_OR> : public HighLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_XOR> : public HighLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_LSL> : public HighLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_LSR> : public HighLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_ASR> : public HighLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_ROL> : public HighLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_ROR> : public HighLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_MUL> : public HighLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_MULU_DP> : public HighLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_MULS_DP> : public HighLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_DIVU> : public HighLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_DIVS> : public HighLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_MODU> : public HighLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_MODS> : public HighLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_DIVU_DP> : public HighLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_DIVS_DP> : public HighLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_MODU_DP> : public HighLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_MODS_DP> : public HighLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_CMP_E> : public HighLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_CMP_NE> : public HighLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_CMP_SLT> : public HighLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_CMP_ULT> : public HighLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_CMP_SLE> : public HighLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_CMP_ULE> : public HighLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_CMP_SGE> : public HighLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_CMP_UGE> : public HighLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_CMP_SGT> : public HighLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_CMP_UGT> : public HighLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_TEST_BIT> : public HighLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_ADD_OVERFLOW> : public HighLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_FADD> : public HighLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_FSUB> : public HighLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_FMUL> : public HighLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_FDIV> : public HighLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_FCMP_E> : public HighLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_FCMP_NE> : public HighLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_FCMP_LT> : public HighLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_FCMP_LE> : public HighLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_FCMP_GE> : public HighLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_FCMP_GT> : public HighLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_FCMP_O> : public HighLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_FCMP_UO> : public HighLevelILTwoOperandInstruction
+ {};
- template <> struct HighLevelILInstructionAccessor<HLIL_ADC>: public HighLevelILTwoOperandWithCarryInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_SBB>: public HighLevelILTwoOperandWithCarryInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_RLC>: public HighLevelILTwoOperandWithCarryInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_RRC>: public HighLevelILTwoOperandWithCarryInstruction {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_ADC> : public HighLevelILTwoOperandWithCarryInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_SBB> : public HighLevelILTwoOperandWithCarryInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_RLC> : public HighLevelILTwoOperandWithCarryInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_RRC> : public HighLevelILTwoOperandWithCarryInstruction
+ {};
- template <> struct HighLevelILInstructionAccessor<HLIL_DEREF>: public HighLevelILOneOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_ADDRESS_OF>: public HighLevelILOneOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_NEG>: public HighLevelILOneOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_NOT>: public HighLevelILOneOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_SX>: public HighLevelILOneOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_ZX>: public HighLevelILOneOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_LOW_PART>: public HighLevelILOneOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_BOOL_TO_INT>: public HighLevelILOneOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_UNIMPL_MEM>: public HighLevelILOneOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_FSQRT>: public HighLevelILOneOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_FNEG>: public HighLevelILOneOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_FABS>: public HighLevelILOneOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_FLOAT_TO_INT>: public HighLevelILOneOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_INT_TO_FLOAT>: public HighLevelILOneOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_FLOAT_CONV>: public HighLevelILOneOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_ROUND_TO_INT>: public HighLevelILOneOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_FLOOR>: public HighLevelILOneOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_CEIL>: public HighLevelILOneOperandInstruction {};
- template <> struct HighLevelILInstructionAccessor<HLIL_FTRUNC>: public HighLevelILOneOperandInstruction {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_DEREF> : public HighLevelILOneOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_ADDRESS_OF> : public HighLevelILOneOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_NEG> : public HighLevelILOneOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_NOT> : public HighLevelILOneOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_SX> : public HighLevelILOneOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_ZX> : public HighLevelILOneOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_LOW_PART> : public HighLevelILOneOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_BOOL_TO_INT> : public HighLevelILOneOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_UNIMPL_MEM> : public HighLevelILOneOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_FSQRT> : public HighLevelILOneOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_FNEG> : public HighLevelILOneOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_FABS> : public HighLevelILOneOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_FLOAT_TO_INT> : public HighLevelILOneOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_INT_TO_FLOAT> : public HighLevelILOneOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_FLOAT_CONV> : public HighLevelILOneOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_ROUND_TO_INT> : public HighLevelILOneOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_FLOOR> : public HighLevelILOneOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_CEIL> : public HighLevelILOneOperandInstruction
+ {};
+ template <>
+ struct HighLevelILInstructionAccessor<HLIL_FTRUNC> : public HighLevelILOneOperandInstruction
+ {};
#undef _STD_VECTOR
#undef _STD_SET
#undef _STD_UNORDERED_MAP
-}
+} // namespace BinaryNinjaCore
diff --git a/http.cpp b/http.cpp
index bae17543..08bdc275 100644
--- a/http.cpp
+++ b/http.cpp
@@ -25,7 +25,7 @@
#include "http.h"
#ifdef BINARYNINJACORE_LIBRARY
-#include "log.h"
+ #include "log.h"
#endif
#ifdef BINARYNINJACORE_LIBRARY
@@ -41,8 +41,8 @@ namespace BinaryNinjaCore::Http
namespace BinaryNinja::Http
#endif
{
- #define HTTP_MAX_RETRIES 3
- #define HTTP_BACKOFF_FACTOR 1
+#define HTTP_MAX_RETRIES 3
+#define HTTP_BACKOFF_FACTOR 1
struct RequestContext
{
@@ -52,11 +52,9 @@ namespace BinaryNinja::Http
const Request& request;
Response& response;
- RequestContext(const Request& request, Response& response):
- uploadOffset(0), downloadLength(0), cancelled(false), request(request), response(response)
- {
-
- }
+ RequestContext(const Request& request, Response& response) :
+ uploadOffset(0), downloadLength(0), cancelled(false), request(request), response(response)
+ {}
};
@@ -139,7 +137,7 @@ namespace BinaryNinja::Http
{
string outStr;
outStr.reserve(str.size());
- for (auto& ch: str)
+ for (auto& ch : str)
{
if (isalnum(ch))
{
@@ -161,7 +159,7 @@ namespace BinaryNinja::Http
string outStr;
bool first = true;
- for (auto& field: fields)
+ for (auto& field : fields)
{
if (!first)
{
@@ -187,13 +185,13 @@ namespace BinaryNinja::Http
vector<uint8_t> result;
size_t expectedSize = boundaryVec.size() * fields.size();
- for (const auto& field: fields)
+ for (const auto& field : fields)
{
expectedSize += field.name.size() + field.content.size();
}
result.reserve(expectedSize);
- for (const auto& field: fields)
+ for (const auto& field : fields)
{
result.push_back('-');
result.push_back('-');
@@ -203,9 +201,8 @@ namespace BinaryNinja::Http
string disposition;
if (field.filename)
{
- disposition =
- string("Content-Disposition: form-data; name=\"") + field.name + "\"; filename=\"" +
- *field.filename + "\"";
+ disposition = string("Content-Disposition: form-data; name=\"") + field.name + "\"; filename=\""
+ + *field.filename + "\"";
disposition += string("\r\nContent-Type: application/octet-stream");
}
else
@@ -232,13 +229,11 @@ namespace BinaryNinja::Http
}
- Request::Request(string method, string url,
- unordered_map<string, string> headers,
- vector<pair<string, string>> params,
- std::function<bool(size_t, size_t)> downloadProgress,
- std::function<bool(size_t, size_t)> uploadProgress):
- m_method(method), m_url(url), m_headers(headers),
- m_downloadProgress(downloadProgress), m_uploadProgress(uploadProgress)
+ Request::Request(string method, string url, unordered_map<string, string> headers,
+ vector<pair<string, string>> params, std::function<bool(size_t, size_t)> downloadProgress,
+ std::function<bool(size_t, size_t)> uploadProgress) :
+ m_method(method),
+ m_url(url), m_headers(headers), m_downloadProgress(downloadProgress), m_uploadProgress(uploadProgress)
{
if (!params.empty())
{
@@ -257,14 +252,12 @@ namespace BinaryNinja::Http
}
- Request::Request(string method, string url,
- unordered_map<string, string> headers,
- vector<pair<string, string>> params,
- vector<uint8_t> body,
- std::function<bool(size_t, size_t)> downloadProgress,
- std::function<bool(size_t, size_t)> uploadProgress):
- m_method(method), m_url(url), m_headers(headers), m_body(body),
- m_downloadProgress(downloadProgress), m_uploadProgress(uploadProgress)
+ Request::Request(string method, string url, unordered_map<string, string> headers,
+ vector<pair<string, string>> params, vector<uint8_t> body, std::function<bool(size_t, size_t)> downloadProgress,
+ std::function<bool(size_t, size_t)> uploadProgress) :
+ m_method(method),
+ m_url(url), m_headers(headers), m_body(body), m_downloadProgress(downloadProgress),
+ m_uploadProgress(uploadProgress)
{
if (!params.empty())
{
@@ -283,14 +276,11 @@ namespace BinaryNinja::Http
}
- Request::Request(string method, string url,
- unordered_map<string, string> headers,
- vector<pair<string, string>> params,
- vector<pair<string, string>> formFields,
- std::function<bool(size_t, size_t)> downloadProgress,
- std::function<bool(size_t, size_t)> uploadProgress):
- m_method(method), m_url(url), m_headers(headers),
- m_downloadProgress(downloadProgress), m_uploadProgress(uploadProgress)
+ Request::Request(string method, string url, unordered_map<string, string> headers,
+ vector<pair<string, string>> params, vector<pair<string, string>> formFields,
+ std::function<bool(size_t, size_t)> downloadProgress, std::function<bool(size_t, size_t)> uploadProgress) :
+ m_method(method),
+ m_url(url), m_headers(headers), m_downloadProgress(downloadProgress), m_uploadProgress(uploadProgress)
{
if (!params.empty())
{
@@ -313,14 +303,11 @@ namespace BinaryNinja::Http
}
- Request::Request(string method, string url,
- unordered_map<string, string> headers,
- vector<pair<string, string>> params,
- vector<MultipartField> formFields,
- std::function<bool(size_t, size_t)> downloadProgress,
- std::function<bool(size_t, size_t)> uploadProgress):
- m_method(method), m_url(url), m_headers(headers),
- m_downloadProgress(downloadProgress), m_uploadProgress(uploadProgress)
+ Request::Request(string method, string url, unordered_map<string, string> headers,
+ vector<pair<string, string>> params, vector<MultipartField> formFields,
+ std::function<bool(size_t, size_t)> downloadProgress, std::function<bool(size_t, size_t)> uploadProgress) :
+ m_method(method),
+ m_url(url), m_headers(headers), m_downloadProgress(downloadProgress), m_uploadProgress(uploadProgress)
{
if (!params.empty())
{
@@ -344,44 +331,32 @@ namespace BinaryNinja::Http
}
- Request Request::Get(string url,
- unordered_map<string, string> headers,
- vector<pair<string, string>> params,
- std::function<bool(size_t, size_t)> downloadProgress,
- std::function<bool(size_t, size_t)> uploadProgress)
+ Request Request::Get(string url, unordered_map<string, string> headers, vector<pair<string, string>> params,
+ std::function<bool(size_t, size_t)> downloadProgress, std::function<bool(size_t, size_t)> uploadProgress)
{
return Request("GET", url, headers, params, downloadProgress, uploadProgress);
}
- Request Request::Post(string url,
- unordered_map<string, string> headers,
- vector<pair<string, string>> params,
- vector<uint8_t> body,
- std::function<bool(size_t, size_t)> downloadProgress,
- std::function<bool(size_t, size_t)> uploadProgress)
+ Request Request::Post(string url, unordered_map<string, string> headers, vector<pair<string, string>> params,
+ vector<uint8_t> body, std::function<bool(size_t, size_t)> downloadProgress,
+ std::function<bool(size_t, size_t)> uploadProgress)
{
return Request("POST", url, headers, params, body, downloadProgress, uploadProgress);
}
- Request Request::Post(string url,
- unordered_map<string, string> headers,
- vector<pair<string, string>> params,
- vector<pair<string, string>> formFields,
- std::function<bool(size_t, size_t)> downloadProgress,
- std::function<bool(size_t, size_t)> uploadProgress)
+ Request Request::Post(string url, unordered_map<string, string> headers, vector<pair<string, string>> params,
+ vector<pair<string, string>> formFields, std::function<bool(size_t, size_t)> downloadProgress,
+ std::function<bool(size_t, size_t)> uploadProgress)
{
return Request("POST", url, headers, params, formFields, downloadProgress, uploadProgress);
}
- Request Request::Post(string url,
- unordered_map<string, string> headers,
- vector<pair<string, string>> params,
- vector<MultipartField> formFields,
- std::function<bool(size_t, size_t)> downloadProgress,
- std::function<bool(size_t, size_t)> uploadProgress)
+ Request Request::Post(string url, unordered_map<string, string> headers, vector<pair<string, string>> params,
+ vector<MultipartField> formFields, std::function<bool(size_t, size_t)> downloadProgress,
+ std::function<bool(size_t, size_t)> uploadProgress)
{
return Request("POST", url, headers, params, formFields, downloadProgress, uploadProgress);
}
@@ -398,14 +373,15 @@ namespace BinaryNinja::Http
response.body.clear();
response.error.clear();
- RequestContext context{request, response};
- BNDownloadInstanceInputOutputCallbacks callbacks{};
+ RequestContext context {request, response};
+ BNDownloadInstanceInputOutputCallbacks callbacks {};
memset(&callbacks, 0, sizeof(BNDownloadInstanceInputOutputCallbacks));
callbacks.readContext = &context;
callbacks.readCallback = &HttpReadCallback;
callbacks.writeContext = &context;
callbacks.writeCallback = &HttpWriteCallback;
- result = instance->PerformCustomRequest(request.m_method, request.m_url, request.m_headers, response.response, &callbacks);
+ result = instance->PerformCustomRequest(
+ request.m_method, request.m_url, request.m_headers, response.response, &callbacks);
if (result >= 0)
break;
@@ -415,16 +391,14 @@ namespace BinaryNinja::Http
break;
size_t backoff = 1000 * HTTP_BACKOFF_FACTOR * (2 * pow(2, retry - 1));
retry += 1;
- LogWarn("Attempt %d to %s %s failed, trying again in %zums\n", retry, request.m_method.data(), request.m_url.data(), backoff);
+ LogWarn("Attempt %d to %s %s failed, trying again in %zums\n", retry, request.m_method.data(),
+ request.m_url.data(), backoff);
std::this_thread::sleep_for(std::chrono::milliseconds(backoff));
}
return result;
}
- vector<uint8_t> Response::GetRaw() const noexcept
- {
- return body;
- }
+ vector<uint8_t> Response::GetRaw() const noexcept { return body; }
string Response::GetString() const noexcept
@@ -458,4 +432,4 @@ namespace BinaryNinja::Http
string errors;
return reader->parse(str.data(), str.data() + str.size(), &value, &errors);
}
-}
+} // namespace BinaryNinjaCore::Http
diff --git a/http.h b/http.h
index acee1cf3..da9cbeb2 100644
--- a/http.h
+++ b/http.h
@@ -29,10 +29,10 @@
#include <stdint.h>
#ifdef BINARYNINJACORE_LIBRARY
-#include "downloadprovider.h"
-#include "json/json.h"
+ #include "downloadprovider.h"
+ #include "json/json.h"
#else
-#include "binaryninjaapi.h"
+ #include "binaryninjaapi.h"
#endif
@@ -44,13 +44,13 @@ namespace BinaryNinja::Http
{
#ifdef BINARYNINJACORE_LIBRARY
-#define _STD_STRING string
-#define _STD_VECTOR vector
-#define _STD_UNORDERED_MAP unordered_map
+ #define _STD_STRING string
+ #define _STD_VECTOR vector
+ #define _STD_UNORDERED_MAP unordered_map
#else
-#define _STD_STRING std::string
-#define _STD_VECTOR std::vector
-#define _STD_UNORDERED_MAP std::unordered_map
+ #define _STD_STRING std::string
+ #define _STD_VECTOR std::vector
+ #define _STD_UNORDERED_MAP std::unordered_map
#endif
enum ResponseCode
@@ -147,8 +147,7 @@ namespace BinaryNinja::Http
\param name Name of the field to be sent in a POST request
\param content Contents of the field
*/
- MultipartField(_STD_STRING name, const _STD_STRING& content):
- name(std::move(name)), content({}), filename({})
+ MultipartField(_STD_STRING name, const _STD_STRING& content) : name(std::move(name)), content({}), filename({})
{
std::copy(content.begin(), content.end(), std::back_inserter(this->content));
}
@@ -159,8 +158,8 @@ namespace BinaryNinja::Http
\param content Contents of the field
\param filename Filename associated with the contents
*/
- MultipartField(_STD_STRING name, const _STD_STRING& content, _STD_STRING filename):
- name(std::move(name)), content({}), filename(std::move(filename))
+ MultipartField(_STD_STRING name, const _STD_STRING& content, _STD_STRING filename) :
+ name(std::move(name)), content({}), filename(std::move(filename))
{
std::copy(content.begin(), content.end(), std::back_inserter(this->content));
}
@@ -170,11 +169,9 @@ namespace BinaryNinja::Http
\param name Name of the field to be sent in a POST request
\param content Contents of the field
*/
- MultipartField(_STD_STRING name, _STD_VECTOR<uint8_t> content):
- name(std::move(name)), content(std::move(content)), filename({})
- {
-
- }
+ MultipartField(_STD_STRING name, _STD_VECTOR<uint8_t> content) :
+ name(std::move(name)), content(std::move(content)), filename({})
+ {}
/*!
Construct a Multipart Field structure for a file with a binary blob body
@@ -182,11 +179,9 @@ namespace BinaryNinja::Http
\param content Contents of the field
\param filename Filename associated with the contents
*/
- MultipartField(_STD_STRING name, _STD_VECTOR<uint8_t> content, _STD_STRING filename):
- name(std::move(name)), content(std::move(content)), filename(std::move(filename))
- {
-
- }
+ MultipartField(_STD_STRING name, _STD_VECTOR<uint8_t> content, _STD_STRING filename) :
+ name(std::move(name)), content(std::move(content)), filename(std::move(filename))
+ {}
};
@@ -212,11 +207,10 @@ namespace BinaryNinja::Http
\param downloadProgress Function to call for download progress updates
\param uploadProgress Function to call for upload progress updates
*/
- Request(_STD_STRING method, _STD_STRING url,
- _STD_UNORDERED_MAP<_STD_STRING, _STD_STRING> headers = {},
- _STD_VECTOR<std::pair<_STD_STRING, _STD_STRING>> params = {},
- std::function<bool(size_t, size_t)> downloadProgress = {},
- std::function<bool(size_t, size_t)> uploadProgress = {});
+ Request(_STD_STRING method, _STD_STRING url, _STD_UNORDERED_MAP<_STD_STRING, _STD_STRING> headers = {},
+ _STD_VECTOR<std::pair<_STD_STRING, _STD_STRING>> params = {},
+ std::function<bool(size_t, size_t)> downloadProgress = {},
+ std::function<bool(size_t, size_t)> uploadProgress = {});
/*!
@@ -229,12 +223,10 @@ namespace BinaryNinja::Http
\param downloadProgress Function to call for download progress updates
\param uploadProgress Function to call for upload progress updates
*/
- Request(_STD_STRING method, _STD_STRING url,
- _STD_UNORDERED_MAP<_STD_STRING, _STD_STRING> headers,
- _STD_VECTOR<std::pair<_STD_STRING, _STD_STRING>> params,
- _STD_VECTOR<uint8_t> body,
- std::function<bool(size_t, size_t)> downloadProgress = {},
- std::function<bool(size_t, size_t)> uploadProgress = {});
+ Request(_STD_STRING method, _STD_STRING url, _STD_UNORDERED_MAP<_STD_STRING, _STD_STRING> headers,
+ _STD_VECTOR<std::pair<_STD_STRING, _STD_STRING>> params, _STD_VECTOR<uint8_t> body,
+ std::function<bool(size_t, size_t)> downloadProgress = {},
+ std::function<bool(size_t, size_t)> uploadProgress = {});
/*!
@@ -247,12 +239,11 @@ namespace BinaryNinja::Http
\param downloadProgress Function to call for download progress updates
\param uploadProgress Function to call for upload progress updates
*/
- Request(_STD_STRING method, _STD_STRING url,
- _STD_UNORDERED_MAP<_STD_STRING, _STD_STRING> headers,
- _STD_VECTOR<std::pair<_STD_STRING, _STD_STRING>> params,
- _STD_VECTOR<std::pair<_STD_STRING, _STD_STRING>> formFields,
- std::function<bool(size_t, size_t)> downloadProgress = {},
- std::function<bool(size_t, size_t)> uploadProgress = {});
+ Request(_STD_STRING method, _STD_STRING url, _STD_UNORDERED_MAP<_STD_STRING, _STD_STRING> headers,
+ _STD_VECTOR<std::pair<_STD_STRING, _STD_STRING>> params,
+ _STD_VECTOR<std::pair<_STD_STRING, _STD_STRING>> formFields,
+ std::function<bool(size_t, size_t)> downloadProgress = {},
+ std::function<bool(size_t, size_t)> uploadProgress = {});
/*!
@@ -265,12 +256,10 @@ namespace BinaryNinja::Http
\param downloadProgress Function to call for download progress updates
\param uploadProgress Function to call for upload progress updates
*/
- Request(_STD_STRING method, _STD_STRING url,
- _STD_UNORDERED_MAP<_STD_STRING, _STD_STRING> headers,
- _STD_VECTOR<std::pair<_STD_STRING, _STD_STRING>> params,
- _STD_VECTOR<MultipartField> formFields,
- std::function<bool(size_t, size_t)> downloadProgress = {},
- std::function<bool(size_t, size_t)> uploadProgress = {});
+ Request(_STD_STRING method, _STD_STRING url, _STD_UNORDERED_MAP<_STD_STRING, _STD_STRING> headers,
+ _STD_VECTOR<std::pair<_STD_STRING, _STD_STRING>> params, _STD_VECTOR<MultipartField> formFields,
+ std::function<bool(size_t, size_t)> downloadProgress = {},
+ std::function<bool(size_t, size_t)> uploadProgress = {});
/*!
@@ -282,11 +271,10 @@ namespace BinaryNinja::Http
\param uploadProgress Function to call for upload progress updates
\return Request structure with specified fields
*/
- static Request Get(_STD_STRING url,
- _STD_UNORDERED_MAP<_STD_STRING, _STD_STRING> headers = {},
- _STD_VECTOR<std::pair<_STD_STRING, _STD_STRING>> params = {},
- std::function<bool(size_t, size_t)> downloadProgress = {},
- std::function<bool(size_t, size_t)> uploadProgress = {});
+ static Request Get(_STD_STRING url, _STD_UNORDERED_MAP<_STD_STRING, _STD_STRING> headers = {},
+ _STD_VECTOR<std::pair<_STD_STRING, _STD_STRING>> params = {},
+ std::function<bool(size_t, size_t)> downloadProgress = {},
+ std::function<bool(size_t, size_t)> uploadProgress = {});
/*!
@@ -299,12 +287,10 @@ namespace BinaryNinja::Http
\param uploadProgress Function to call for upload progress updates
\return Request structure with specified fields
*/
- static Request Post(_STD_STRING url,
- _STD_UNORDERED_MAP<_STD_STRING, _STD_STRING> headers = {},
- _STD_VECTOR<std::pair<_STD_STRING, _STD_STRING>> params = {},
- _STD_VECTOR<uint8_t> body = {},
- std::function<bool(size_t, size_t)> downloadProgress = {},
- std::function<bool(size_t, size_t)> uploadProgress = {});
+ static Request Post(_STD_STRING url, _STD_UNORDERED_MAP<_STD_STRING, _STD_STRING> headers = {},
+ _STD_VECTOR<std::pair<_STD_STRING, _STD_STRING>> params = {}, _STD_VECTOR<uint8_t> body = {},
+ std::function<bool(size_t, size_t)> downloadProgress = {},
+ std::function<bool(size_t, size_t)> uploadProgress = {});
/*!
@@ -317,12 +303,11 @@ namespace BinaryNinja::Http
\param uploadProgress Function to call for upload progress updates
\return Request structure with specified fields
*/
- static Request Post(_STD_STRING url,
- _STD_UNORDERED_MAP<_STD_STRING, _STD_STRING> headers,
- _STD_VECTOR<std::pair<_STD_STRING, _STD_STRING>> params,
- _STD_VECTOR<std::pair<_STD_STRING, _STD_STRING>> formFields,
- std::function<bool(size_t, size_t)> downloadProgress = {},
- std::function<bool(size_t, size_t)> uploadProgress = {});
+ static Request Post(_STD_STRING url, _STD_UNORDERED_MAP<_STD_STRING, _STD_STRING> headers,
+ _STD_VECTOR<std::pair<_STD_STRING, _STD_STRING>> params,
+ _STD_VECTOR<std::pair<_STD_STRING, _STD_STRING>> formFields,
+ std::function<bool(size_t, size_t)> downloadProgress = {},
+ std::function<bool(size_t, size_t)> uploadProgress = {});
/*!
@@ -335,12 +320,10 @@ namespace BinaryNinja::Http
\param uploadProgress Function to call for upload progress updates
\return Request structure with specified fields
*/
- static Request Post(_STD_STRING url,
- _STD_UNORDERED_MAP<_STD_STRING, _STD_STRING> headers,
- _STD_VECTOR<std::pair<_STD_STRING, _STD_STRING>> params,
- _STD_VECTOR<MultipartField> formFields,
- std::function<bool(size_t, size_t)> downloadProgress = {},
- std::function<bool(size_t, size_t)> uploadProgress = {});
+ static Request Post(_STD_STRING url, _STD_UNORDERED_MAP<_STD_STRING, _STD_STRING> headers,
+ _STD_VECTOR<std::pair<_STD_STRING, _STD_STRING>> params, _STD_VECTOR<MultipartField> formFields,
+ std::function<bool(size_t, size_t)> downloadProgress = {},
+ std::function<bool(size_t, size_t)> uploadProgress = {});
};
@@ -383,4 +366,4 @@ namespace BinaryNinja::Http
#undef _STD_SET
#undef _STD_UNORDERED_MAP
#undef _STD_MAP
-} \ No newline at end of file
+} // namespace BinaryNinjaCore::Http \ No newline at end of file
diff --git a/interaction.cpp b/interaction.cpp
index 2f808067..580e2a39 100644
--- a/interaction.cpp
+++ b/interaction.cpp
@@ -112,8 +112,8 @@ FormInputField FormInputField::DirectoryName(const string& prompt, const string&
}
-void InteractionHandler::ShowMarkdownReport(Ref<BinaryView> view, const string& title, const string& contents,
- const string& plainText)
+void InteractionHandler::ShowMarkdownReport(
+ Ref<BinaryView> view, const string& title, const string& contents, const string& plainText)
{
(void)contents;
if (plainText.size() != 0)
@@ -121,22 +121,18 @@ void InteractionHandler::ShowMarkdownReport(Ref<BinaryView> view, const string&
}
-void InteractionHandler::ShowHTMLReport(Ref<BinaryView> view, const string& title, const string&,
- const string& plainText)
+void InteractionHandler::ShowHTMLReport(
+ Ref<BinaryView> view, const string& title, const string&, const string& plainText)
{
if (plainText.size() != 0)
ShowPlainTextReport(view, title, plainText);
}
-void InteractionHandler::ShowGraphReport(Ref<BinaryView>, const std::string&, Ref<FlowGraph>)
-{
-}
+void InteractionHandler::ShowGraphReport(Ref<BinaryView>, const std::string&, Ref<FlowGraph>) {}
-void InteractionHandler::ShowReportCollection(const string&, Ref<ReportCollection>)
-{
-}
+void InteractionHandler::ShowReportCollection(const string&, Ref<ReportCollection>) {}
bool InteractionHandler::GetIntegerInput(int64_t& result, const string& prompt, const string& title)
@@ -164,8 +160,8 @@ bool InteractionHandler::GetIntegerInput(int64_t& result, const string& prompt,
}
-bool InteractionHandler::GetAddressInput(uint64_t& result, const string& prompt, const string& title,
- Ref<BinaryView>, uint64_t)
+bool InteractionHandler::GetAddressInput(
+ uint64_t& result, const string& prompt, const string& title, Ref<BinaryView>, uint64_t)
{
int64_t value;
if (!GetIntegerInput(value, prompt, title))
@@ -200,16 +196,16 @@ static void ShowPlainTextReportCallback(void* ctxt, BNBinaryView* view, const ch
}
-static void ShowMarkdownReportCallback(void* ctxt, BNBinaryView* view, const char* title, const char* contents,
- const char* plaintext)
+static void ShowMarkdownReportCallback(
+ void* ctxt, BNBinaryView* view, const char* title, const char* contents, const char* plaintext)
{
InteractionHandler* handler = (InteractionHandler*)ctxt;
handler->ShowMarkdownReport(view ? new BinaryView(BNNewViewReference(view)) : nullptr, title, contents, plaintext);
}
-static void ShowHTMLReportCallback(void* ctxt, BNBinaryView* view, const char* title, const char* contents,
- const char* plaintext)
+static void ShowHTMLReportCallback(
+ void* ctxt, BNBinaryView* view, const char* title, const char* contents, const char* plaintext)
{
InteractionHandler* handler = (InteractionHandler*)ctxt;
handler->ShowHTMLReport(view ? new BinaryView(BNNewViewReference(view)) : nullptr, title, contents, plaintext);
@@ -220,7 +216,7 @@ static void ShowGraphReportCallback(void* ctxt, BNBinaryView* view, const char*
{
InteractionHandler* handler = (InteractionHandler*)ctxt;
handler->ShowGraphReport(view ? new BinaryView(BNNewViewReference(view)) : nullptr, title,
- new CoreFlowGraph(BNNewFlowGraphReference(graph)));
+ new CoreFlowGraph(BNNewFlowGraphReference(graph)));
}
@@ -249,17 +245,17 @@ static bool GetIntegerInputCallback(void* ctxt, int64_t* result, const char* pro
}
-static bool GetAddressInputCallback(void* ctxt, uint64_t* result, const char* prompt, const char* title,
- BNBinaryView* view, uint64_t currentAddr)
+static bool GetAddressInputCallback(
+ void* ctxt, uint64_t* result, const char* prompt, const char* title, BNBinaryView* view, uint64_t currentAddr)
{
InteractionHandler* handler = (InteractionHandler*)ctxt;
- return handler->GetAddressInput(*result, prompt, title, view ? new BinaryView(BNNewViewReference(view)) : nullptr,
- currentAddr);
+ return handler->GetAddressInput(
+ *result, prompt, title, view ? new BinaryView(BNNewViewReference(view)) : nullptr, currentAddr);
}
-static bool GetChoiceInputCallback(void* ctxt, size_t* result, const char* prompt, const char* title,
- const char** choices, size_t count)
+static bool GetChoiceInputCallback(
+ void* ctxt, size_t* result, const char* prompt, const char* title, const char** choices, size_t count)
{
InteractionHandler* handler = (InteractionHandler*)ctxt;
vector<string> choiceStrs;
@@ -280,8 +276,8 @@ static bool GetOpenFileNameInputCallback(void* ctxt, char** result, const char*
}
-static bool GetSaveFileNameInputCallback(void* ctxt, char** result, const char* prompt, const char* ext,
- const char* defaultName)
+static bool GetSaveFileNameInputCallback(
+ void* ctxt, char** result, const char* prompt, const char* ext, const char* defaultName)
{
InteractionHandler* handler = (InteractionHandler*)ctxt;
string value;
@@ -327,8 +323,9 @@ static bool GetFormInputCallback(void* ctxt, BNFormInputField* fieldBuf, size_t
fields.push_back(FormInputField::Integer(fieldBuf[i].prompt));
break;
case AddressFormField:
- fields.push_back(FormInputField::Address(fieldBuf[i].prompt, fieldBuf[i].view ?
- new BinaryView(BNNewViewReference(fieldBuf[i].view)) : nullptr, fieldBuf[i].currentAddress));
+ fields.push_back(FormInputField::Address(fieldBuf[i].prompt,
+ fieldBuf[i].view ? new BinaryView(BNNewViewReference(fieldBuf[i].view)) : nullptr,
+ fieldBuf[i].currentAddress));
break;
case ChoiceFormField:
for (size_t j = 0; j < fieldBuf[i].count; j++)
@@ -339,7 +336,8 @@ static bool GetFormInputCallback(void* ctxt, BNFormInputField* fieldBuf, size_t
fields.push_back(FormInputField::OpenFileName(fieldBuf[i].prompt, fieldBuf[i].ext));
break;
case SaveFileNameFormField:
- fields.push_back(FormInputField::SaveFileName(fieldBuf[i].prompt, fieldBuf[i].ext, fieldBuf[i].defaultName));
+ fields.push_back(
+ FormInputField::SaveFileName(fieldBuf[i].prompt, fieldBuf[i].ext, fieldBuf[i].defaultName));
break;
case DirectoryNameFormField:
fields.push_back(FormInputField::DirectoryName(fieldBuf[i].prompt, fieldBuf[i].defaultName));
@@ -407,8 +405,8 @@ static bool GetFormInputCallback(void* ctxt, BNFormInputField* fieldBuf, size_t
}
-static BNMessageBoxButtonResult ShowMessageBoxCallback(void* ctxt, const char* title, const char* text,
- BNMessageBoxButtonSet buttons, BNMessageBoxIcon icon)
+static BNMessageBoxButtonResult ShowMessageBoxCallback(
+ void* ctxt, const char* title, const char* text, BNMessageBoxButtonSet buttons, BNMessageBoxIcon icon)
{
InteractionHandler* handler = (InteractionHandler*)ctxt;
return handler->ShowMessageBox(title, text, buttons, icon);
@@ -511,8 +509,7 @@ bool BinaryNinja::GetAddressInput(uint64_t& result, const string& prompt, const
}
-bool BinaryNinja::GetChoiceInput(size_t& idx, const string& prompt, const string& title,
- const vector<string>& choices)
+bool BinaryNinja::GetChoiceInput(size_t& idx, const string& prompt, const string& title, const vector<string>& choices)
{
const char** choiceStrs = new const char*[choices.size()];
for (size_t i = 0; i < choices.size(); i++)
@@ -534,8 +531,8 @@ bool BinaryNinja::GetOpenFileNameInput(string& result, const string& prompt, con
}
-bool BinaryNinja::GetSaveFileNameInput(string& result, const string& prompt, const string& ext,
- const string& defaultName)
+bool BinaryNinja::GetSaveFileNameInput(
+ string& result, const string& prompt, const string& ext, const string& defaultName)
{
char* value = nullptr;
if (!BNGetSaveFileNameInput(&value, prompt.c_str(), ext.c_str(), defaultName.c_str()))
@@ -661,8 +658,8 @@ bool BinaryNinja::GetFormInput(vector<FormInputField>& fields, const string& tit
}
-BNMessageBoxButtonResult BinaryNinja::ShowMessageBox(const string& title, const string& text,
- BNMessageBoxButtonSet buttons, BNMessageBoxIcon icon)
+BNMessageBoxButtonResult BinaryNinja::ShowMessageBox(
+ const string& title, const string& text, BNMessageBoxButtonSet buttons, BNMessageBoxIcon icon)
{
return BNShowMessageBox(title.c_str(), text.c_str(), buttons, icon);
}
@@ -749,19 +746,19 @@ void ReportCollection::AddPlainTextReport(Ref<BinaryView> view, const string& ti
}
-void ReportCollection::AddMarkdownReport(Ref<BinaryView> view, const string& title, const string& contents,
- const string& plainText)
+void ReportCollection::AddMarkdownReport(
+ Ref<BinaryView> view, const string& title, const string& contents, const string& plainText)
{
- BNAddMarkdownReportToCollection(m_object, view ? view->GetObject() : nullptr, title.c_str(), contents.c_str(),
- plainText.c_str());
+ BNAddMarkdownReportToCollection(
+ m_object, view ? view->GetObject() : nullptr, title.c_str(), contents.c_str(), plainText.c_str());
}
-void ReportCollection::AddHTMLReport(Ref<BinaryView> view, const string& title, const string& contents,
- const string& plainText)
+void ReportCollection::AddHTMLReport(
+ Ref<BinaryView> view, const string& title, const string& contents, const string& plainText)
{
- BNAddHTMLReportToCollection(m_object, view ? view->GetObject() : nullptr, title.c_str(), contents.c_str(),
- plainText.c_str());
+ BNAddHTMLReportToCollection(
+ m_object, view ? view->GetObject() : nullptr, title.c_str(), contents.c_str(), plainText.c_str());
}
diff --git a/linearviewobject.cpp b/linearviewobject.cpp
index 17df452b..34693e44 100644
--- a/linearviewobject.cpp
+++ b/linearviewobject.cpp
@@ -33,45 +33,39 @@ LinearDisassemblyLine LinearDisassemblyLine::FromAPIObject(BNLinearDisassemblyLi
result.contents.addr = line->contents.addr;
result.contents.instrIndex = line->contents.instrIndex;
result.contents.highlight = line->contents.highlight;
- result.contents.tokens = InstructionTextToken::ConvertInstructionTextTokenList(line->contents.tokens, line->contents.count);
+ result.contents.tokens =
+ InstructionTextToken::ConvertInstructionTextTokenList(line->contents.tokens, line->contents.count);
result.contents.tags = Tag::ConvertTagList(line->contents.tags, line->contents.tagCount);
result.contents.typeInfo.hasTypeInfo = line->contents.typeInfo.hasTypeInfo;
result.contents.typeInfo.fieldIndex = line->contents.typeInfo.fieldIndex;
- result.contents.typeInfo.parentType = line->contents.typeInfo.parentType ?
- new Type(BNNewTypeReference(line->contents.typeInfo.parentType)) : nullptr;
+ result.contents.typeInfo.parentType =
+ line->contents.typeInfo.parentType ? new Type(BNNewTypeReference(line->contents.typeInfo.parentType)) : nullptr;
result.contents.typeInfo.offset = line->contents.typeInfo.offset;
return result;
}
-LinearViewObjectIdentifier::LinearViewObjectIdentifier():
- type(SingleLinearViewObject), start(0), end(0)
-{
-}
+LinearViewObjectIdentifier::LinearViewObjectIdentifier() : type(SingleLinearViewObject), start(0), end(0) {}
-LinearViewObjectIdentifier::LinearViewObjectIdentifier(const string& _name):
- name(_name), type(SingleLinearViewObject), start(0), end(0)
-{
-}
+LinearViewObjectIdentifier::LinearViewObjectIdentifier(const string& _name) :
+ name(_name), type(SingleLinearViewObject), start(0), end(0)
+{}
-LinearViewObjectIdentifier::LinearViewObjectIdentifier(const string& _name, uint64_t addr):
- name(_name), type(AddressLinearViewObject), start(addr), end(addr)
-{
-}
+LinearViewObjectIdentifier::LinearViewObjectIdentifier(const string& _name, uint64_t addr) :
+ name(_name), type(AddressLinearViewObject), start(addr), end(addr)
+{}
-LinearViewObjectIdentifier::LinearViewObjectIdentifier(const string& _name, uint64_t _start, uint64_t _end):
- name(_name), type(AddressRangeLinearViewObject), start(_start), end(_end)
-{
-}
+LinearViewObjectIdentifier::LinearViewObjectIdentifier(const string& _name, uint64_t _start, uint64_t _end) :
+ name(_name), type(AddressRangeLinearViewObject), start(_start), end(_end)
+{}
-LinearViewObjectIdentifier::LinearViewObjectIdentifier(const LinearViewObjectIdentifier& other):
- name(other.name), type(other.type), start(other.start), end(other.end)
-{
-}
+LinearViewObjectIdentifier::LinearViewObjectIdentifier(const LinearViewObjectIdentifier& other) :
+ name(other.name), type(other.type), start(other.start), end(other.end)
+{}
LinearViewObject::LinearViewObject(BNLinearViewObject* obj)
@@ -149,8 +143,8 @@ int LinearViewObject::CompareChildren(LinearViewObject* a, LinearViewObject* b)
vector<LinearDisassemblyLine> LinearViewObject::GetLines(LinearViewObject* prev, LinearViewObject* next)
{
size_t count;
- BNLinearDisassemblyLine* lines = BNGetLinearViewObjectLines(m_object, prev ? prev->GetObject() : nullptr,
- next ? next->GetObject() : nullptr, &count);
+ BNLinearDisassemblyLine* lines = BNGetLinearViewObjectLines(
+ m_object, prev ? prev->GetObject() : nullptr, next ? next->GetObject() : nullptr, &count);
vector<LinearDisassemblyLine> result;
result.reserve(count);
@@ -210,160 +204,167 @@ Ref<LinearViewObject> LinearViewObject::GetChildForOrderingIndex(uint64_t idx)
Ref<LinearViewObject> LinearViewObject::CreateDisassembly(BinaryView* view, DisassemblySettings* settings)
{
- return new LinearViewObject(BNCreateLinearViewDisassembly(view->GetObject(),
- settings ? settings->GetObject() : nullptr));
+ return new LinearViewObject(
+ BNCreateLinearViewDisassembly(view->GetObject(), settings ? settings->GetObject() : nullptr));
}
Ref<LinearViewObject> LinearViewObject::CreateLiftedIL(BinaryView* view, DisassemblySettings* settings)
{
- return new LinearViewObject(BNCreateLinearViewLiftedIL(view->GetObject(),
- settings ? settings->GetObject() : nullptr));
+ return new LinearViewObject(
+ BNCreateLinearViewLiftedIL(view->GetObject(), settings ? settings->GetObject() : nullptr));
}
Ref<LinearViewObject> LinearViewObject::CreateLowLevelIL(BinaryView* view, DisassemblySettings* settings)
{
- return new LinearViewObject(BNCreateLinearViewLowLevelIL(view->GetObject(),
- settings ? settings->GetObject() : nullptr));
+ return new LinearViewObject(
+ BNCreateLinearViewLowLevelIL(view->GetObject(), settings ? settings->GetObject() : nullptr));
}
Ref<LinearViewObject> LinearViewObject::CreateLowLevelILSSAForm(BinaryView* view, DisassemblySettings* settings)
{
- return new LinearViewObject(BNCreateLinearViewLowLevelILSSAForm(view->GetObject(),
- settings ? settings->GetObject() : nullptr));
+ return new LinearViewObject(
+ BNCreateLinearViewLowLevelILSSAForm(view->GetObject(), settings ? settings->GetObject() : nullptr));
}
Ref<LinearViewObject> LinearViewObject::CreateMediumLevelIL(BinaryView* view, DisassemblySettings* settings)
{
- return new LinearViewObject(BNCreateLinearViewMediumLevelIL(view->GetObject(),
- settings ? settings->GetObject() : nullptr));
+ return new LinearViewObject(
+ BNCreateLinearViewMediumLevelIL(view->GetObject(), settings ? settings->GetObject() : nullptr));
}
Ref<LinearViewObject> LinearViewObject::CreateMediumLevelILSSAForm(BinaryView* view, DisassemblySettings* settings)
{
- return new LinearViewObject(BNCreateLinearViewMediumLevelILSSAForm(view->GetObject(),
- settings ? settings->GetObject() : nullptr));
+ return new LinearViewObject(
+ BNCreateLinearViewMediumLevelILSSAForm(view->GetObject(), settings ? settings->GetObject() : nullptr));
}
Ref<LinearViewObject> LinearViewObject::CreateMappedMediumLevelIL(BinaryView* view, DisassemblySettings* settings)
{
- return new LinearViewObject(BNCreateLinearViewMappedMediumLevelIL(view->GetObject(),
- settings ? settings->GetObject() : nullptr));
+ return new LinearViewObject(
+ BNCreateLinearViewMappedMediumLevelIL(view->GetObject(), settings ? settings->GetObject() : nullptr));
}
-Ref<LinearViewObject> LinearViewObject::CreateMappedMediumLevelILSSAForm(BinaryView* view, DisassemblySettings* settings)
+Ref<LinearViewObject> LinearViewObject::CreateMappedMediumLevelILSSAForm(
+ BinaryView* view, DisassemblySettings* settings)
{
- return new LinearViewObject(BNCreateLinearViewMappedMediumLevelILSSAForm(view->GetObject(),
- settings ? settings->GetObject() : nullptr));
+ return new LinearViewObject(
+ BNCreateLinearViewMappedMediumLevelILSSAForm(view->GetObject(), settings ? settings->GetObject() : nullptr));
}
Ref<LinearViewObject> LinearViewObject::CreateHighLevelIL(BinaryView* view, DisassemblySettings* settings)
{
- return new LinearViewObject(BNCreateLinearViewHighLevelIL(view->GetObject(),
- settings ? settings->GetObject() : nullptr));
+ return new LinearViewObject(
+ BNCreateLinearViewHighLevelIL(view->GetObject(), settings ? settings->GetObject() : nullptr));
}
Ref<LinearViewObject> LinearViewObject::CreateHighLevelILSSAForm(BinaryView* view, DisassemblySettings* settings)
{
- return new LinearViewObject(BNCreateLinearViewHighLevelILSSAForm(view->GetObject(),
- settings ? settings->GetObject() : nullptr));
+ return new LinearViewObject(
+ BNCreateLinearViewHighLevelILSSAForm(view->GetObject(), settings ? settings->GetObject() : nullptr));
}
Ref<LinearViewObject> LinearViewObject::CreateLanguageRepresentation(BinaryView* view, DisassemblySettings* settings)
{
- return new LinearViewObject(BNCreateLinearViewLanguageRepresentation(view->GetObject(),
- settings ? settings->GetObject() : nullptr));
+ return new LinearViewObject(
+ BNCreateLinearViewLanguageRepresentation(view->GetObject(), settings ? settings->GetObject() : nullptr));
}
Ref<LinearViewObject> LinearViewObject::CreateDataOnly(BinaryView* view, DisassemblySettings* settings)
{
- return new LinearViewObject(BNCreateLinearViewDataOnly(view->GetObject(),
- settings ? settings->GetObject() : nullptr));
+ return new LinearViewObject(
+ BNCreateLinearViewDataOnly(view->GetObject(), settings ? settings->GetObject() : nullptr));
}
Ref<LinearViewObject> LinearViewObject::CreateSingleFunctionDisassembly(Function* func, DisassemblySettings* settings)
{
- return new LinearViewObject(BNCreateLinearViewSingleFunctionDisassembly(func->GetObject(),
- settings ? settings->GetObject() : nullptr));
+ return new LinearViewObject(
+ BNCreateLinearViewSingleFunctionDisassembly(func->GetObject(), settings ? settings->GetObject() : nullptr));
}
Ref<LinearViewObject> LinearViewObject::CreateSingleFunctionLiftedIL(Function* func, DisassemblySettings* settings)
{
- return new LinearViewObject(BNCreateLinearViewSingleFunctionLiftedIL(func->GetObject(),
- settings ? settings->GetObject() : nullptr));
+ return new LinearViewObject(
+ BNCreateLinearViewSingleFunctionLiftedIL(func->GetObject(), settings ? settings->GetObject() : nullptr));
}
Ref<LinearViewObject> LinearViewObject::CreateSingleFunctionLowLevelIL(Function* func, DisassemblySettings* settings)
{
- return new LinearViewObject(BNCreateLinearViewSingleFunctionLowLevelIL(func->GetObject(),
- settings ? settings->GetObject() : nullptr));
+ return new LinearViewObject(
+ BNCreateLinearViewSingleFunctionLowLevelIL(func->GetObject(), settings ? settings->GetObject() : nullptr));
}
-Ref<LinearViewObject> LinearViewObject::CreateSingleFunctionLowLevelILSSAForm(Function* func, DisassemblySettings* settings)
+Ref<LinearViewObject> LinearViewObject::CreateSingleFunctionLowLevelILSSAForm(
+ Function* func, DisassemblySettings* settings)
{
- return new LinearViewObject(BNCreateLinearViewSingleFunctionLowLevelILSSAForm(func->GetObject(),
- settings ? settings->GetObject() : nullptr));
+ return new LinearViewObject(BNCreateLinearViewSingleFunctionLowLevelILSSAForm(
+ func->GetObject(), settings ? settings->GetObject() : nullptr));
}
Ref<LinearViewObject> LinearViewObject::CreateSingleFunctionMediumLevelIL(Function* func, DisassemblySettings* settings)
{
- return new LinearViewObject(BNCreateLinearViewSingleFunctionMediumLevelIL(func->GetObject(),
- settings ? settings->GetObject() : nullptr));
+ return new LinearViewObject(
+ BNCreateLinearViewSingleFunctionMediumLevelIL(func->GetObject(), settings ? settings->GetObject() : nullptr));
}
-Ref<LinearViewObject> LinearViewObject::CreateSingleFunctionMediumLevelILSSAForm(Function* func, DisassemblySettings* settings)
+Ref<LinearViewObject> LinearViewObject::CreateSingleFunctionMediumLevelILSSAForm(
+ Function* func, DisassemblySettings* settings)
{
- return new LinearViewObject(BNCreateLinearViewSingleFunctionMediumLevelILSSAForm(func->GetObject(),
- settings ? settings->GetObject() : nullptr));
+ return new LinearViewObject(BNCreateLinearViewSingleFunctionMediumLevelILSSAForm(
+ func->GetObject(), settings ? settings->GetObject() : nullptr));
}
-Ref<LinearViewObject> LinearViewObject::CreateSingleFunctionMappedMediumLevelIL(Function* func, DisassemblySettings* settings)
+Ref<LinearViewObject> LinearViewObject::CreateSingleFunctionMappedMediumLevelIL(
+ Function* func, DisassemblySettings* settings)
{
- return new LinearViewObject(BNCreateLinearViewSingleFunctionMappedMediumLevelIL(func->GetObject(),
- settings ? settings->GetObject() : nullptr));
+ return new LinearViewObject(BNCreateLinearViewSingleFunctionMappedMediumLevelIL(
+ func->GetObject(), settings ? settings->GetObject() : nullptr));
}
-Ref<LinearViewObject> LinearViewObject::CreateSingleFunctionMappedMediumLevelILSSAForm(Function* func, DisassemblySettings* settings)
+Ref<LinearViewObject> LinearViewObject::CreateSingleFunctionMappedMediumLevelILSSAForm(
+ Function* func, DisassemblySettings* settings)
{
- return new LinearViewObject(BNCreateLinearViewSingleFunctionMappedMediumLevelILSSAForm(func->GetObject(),
- settings ? settings->GetObject() : nullptr));
+ return new LinearViewObject(BNCreateLinearViewSingleFunctionMappedMediumLevelILSSAForm(
+ func->GetObject(), settings ? settings->GetObject() : nullptr));
}
Ref<LinearViewObject> LinearViewObject::CreateSingleFunctionHighLevelIL(Function* func, DisassemblySettings* settings)
{
- return new LinearViewObject(BNCreateLinearViewSingleFunctionHighLevelIL(func->GetObject(),
- settings ? settings->GetObject() : nullptr));
+ return new LinearViewObject(
+ BNCreateLinearViewSingleFunctionHighLevelIL(func->GetObject(), settings ? settings->GetObject() : nullptr));
}
-Ref<LinearViewObject> LinearViewObject::CreateSingleFunctionHighLevelILSSAForm(Function* func, DisassemblySettings* settings)
+Ref<LinearViewObject> LinearViewObject::CreateSingleFunctionHighLevelILSSAForm(
+ Function* func, DisassemblySettings* settings)
{
- return new LinearViewObject(BNCreateLinearViewSingleFunctionHighLevelILSSAForm(func->GetObject(),
- settings ? settings->GetObject() : nullptr));
+ return new LinearViewObject(BNCreateLinearViewSingleFunctionHighLevelILSSAForm(
+ func->GetObject(), settings ? settings->GetObject() : nullptr));
}
-Ref<LinearViewObject> LinearViewObject::CreateSingleFunctionLanguageRepresentation(Function* func, DisassemblySettings* settings)
+Ref<LinearViewObject> LinearViewObject::CreateSingleFunctionLanguageRepresentation(
+ Function* func, DisassemblySettings* settings)
{
- return new LinearViewObject(BNCreateLinearViewSingleFunctionLanguageRepresentation(func->GetObject(),
- settings ? settings->GetObject() : nullptr));
+ return new LinearViewObject(BNCreateLinearViewSingleFunctionLanguageRepresentation(
+ func->GetObject(), settings ? settings->GetObject() : nullptr));
}
diff --git a/lowlevelil.cpp b/lowlevelil.cpp
index c10c178e..4e0743b3 100644
--- a/lowlevelil.cpp
+++ b/lowlevelil.cpp
@@ -116,27 +116,27 @@ void LowLevelILFunction::SetIndirectBranches(const vector<ArchAndAddr>& branches
}
-ExprId LowLevelILFunction::AddExpr(BNLowLevelILOperation operation, size_t size, uint32_t flags,
- ExprId a, ExprId b, ExprId c, ExprId d)
+ExprId LowLevelILFunction::AddExpr(
+ BNLowLevelILOperation operation, size_t size, uint32_t flags, ExprId a, ExprId b, ExprId c, ExprId d)
{
return BNLowLevelILAddExpr(m_object, operation, size, flags, a, b, c, d);
}
-ExprId LowLevelILFunction::AddExprWithLocation(BNLowLevelILOperation operation, uint64_t addr,
- uint32_t sourceOperand, size_t size, uint32_t flags, ExprId a, ExprId b, ExprId c, ExprId d)
+ExprId LowLevelILFunction::AddExprWithLocation(BNLowLevelILOperation operation, uint64_t addr, uint32_t sourceOperand,
+ size_t size, uint32_t flags, ExprId a, ExprId b, ExprId c, ExprId d)
{
return BNLowLevelILAddExprWithLocation(m_object, addr, sourceOperand, operation, size, flags, a, b, c, d);
}
ExprId LowLevelILFunction::AddExprWithLocation(BNLowLevelILOperation operation, const ILSourceLocation& loc,
- size_t size, uint32_t flags, ExprId a, ExprId b, ExprId c, ExprId d)
+ size_t size, uint32_t flags, ExprId a, ExprId b, ExprId c, ExprId d)
{
if (loc.valid)
{
- return BNLowLevelILAddExprWithLocation(m_object, loc.address, loc.sourceOperand, operation,
- size, flags, a, b, c, d);
+ return BNLowLevelILAddExprWithLocation(
+ m_object, loc.address, loc.sourceOperand, operation, size, flags, a, b, c, d);
}
return BNLowLevelILAddExpr(m_object, operation, size, flags, a, b, c, d);
}
@@ -156,8 +156,7 @@ ExprId LowLevelILFunction::Goto(BNLowLevelILLabel& label, const ILSourceLocation
}
-ExprId LowLevelILFunction::If(ExprId operand, BNLowLevelILLabel& t, BNLowLevelILLabel& f,
- const ILSourceLocation& loc)
+ExprId LowLevelILFunction::If(ExprId operand, BNLowLevelILLabel& t, BNLowLevelILLabel& f, const ILSourceLocation& loc)
{
if (loc.valid)
return BNLowLevelILIfWithLocation(m_object, operand, &t, &f, loc.address, loc.sourceOperand);
@@ -314,8 +313,8 @@ ExprId LowLevelILFunction::GetExprForFlagOrConstant(const BNRegisterOrConstant&
}
-ExprId LowLevelILFunction::GetExprForRegisterOrConstantOperation(BNLowLevelILOperation op, size_t size,
- BNRegisterOrConstant* operands, size_t operandCount)
+ExprId LowLevelILFunction::GetExprForRegisterOrConstantOperation(
+ BNLowLevelILOperation op, size_t size, BNRegisterOrConstant* operands, size_t operandCount)
{
if (operandCount == 0)
return AddExpr(op, size, 0);
@@ -328,21 +327,21 @@ ExprId LowLevelILFunction::GetExprForRegisterOrConstantOperation(BNLowLevelILOpe
if (operandCount == 2)
{
return AddExpr(op, size, 0, GetExprForRegisterOrConstant(operands[0], size),
- GetExprForRegisterOrConstant(operands[1], size));
+ GetExprForRegisterOrConstant(operands[1], size));
}
if (operandCount == 3)
{
if ((op == LLIL_ADC) || (op == LLIL_SBB) || (op == LLIL_RLC) || (op == LLIL_RRC))
{
return AddExpr(op, size, 0, GetExprForRegisterOrConstant(operands[0], size),
- GetExprForRegisterOrConstant(operands[1], size), GetExprForFlagOrConstant(operands[2]));
+ GetExprForRegisterOrConstant(operands[1], size), GetExprForFlagOrConstant(operands[2]));
}
return AddExpr(op, size, 0, GetExprForRegisterOrConstant(operands[0], size),
- GetExprForRegisterOrConstant(operands[1], size), GetExprForRegisterOrConstant(operands[2], size));
+ GetExprForRegisterOrConstant(operands[1], size), GetExprForRegisterOrConstant(operands[2], size));
}
return AddExpr(op, size, 0, GetExprForRegisterOrConstant(operands[0], size),
- GetExprForRegisterOrConstant(operands[1], size), GetExprForRegisterOrConstant(operands[2], size),
- GetExprForRegisterOrConstant(operands[3], size));
+ GetExprForRegisterOrConstant(operands[1], size), GetExprForRegisterOrConstant(operands[2], size),
+ GetExprForRegisterOrConstant(operands[3], size));
}
@@ -450,13 +449,13 @@ bool LowLevelILFunction::GetExprText(Architecture* arch, ExprId expr, vector<Ins
}
-bool LowLevelILFunction::GetInstructionText(Function* func, Architecture* arch, size_t instr,
- vector<InstructionTextToken>& tokens)
+bool LowLevelILFunction::GetInstructionText(
+ Function* func, Architecture* arch, size_t instr, vector<InstructionTextToken>& tokens)
{
size_t count;
BNInstructionTextToken* list;
- if (!BNGetLowLevelILInstructionText(m_object, func ? func->GetObject() : nullptr, arch->GetObject(),
- instr, &list, &count))
+ if (!BNGetLowLevelILInstructionText(
+ m_object, func ? func->GetObject() : nullptr, arch->GetObject(), instr, &list, &count))
return false;
tokens = InstructionTextToken::ConvertAndFreeInstructionTextTokenList(list, count);
@@ -641,8 +640,8 @@ PossibleValueSet LowLevelILFunction::GetPossibleExprValues(size_t expr, const se
}
-PossibleValueSet LowLevelILFunction::GetPossibleExprValues(const LowLevelILInstruction& expr,
- const set<BNDataFlowQueryOption>& options)
+PossibleValueSet LowLevelILFunction::GetPossibleExprValues(
+ const LowLevelILInstruction& expr, const set<BNDataFlowQueryOption>& options)
{
return GetPossibleExprValues(expr.exprIndex, options);
}
@@ -662,29 +661,29 @@ RegisterValue LowLevelILFunction::GetRegisterValueAfterInstruction(uint32_t reg,
}
-PossibleValueSet LowLevelILFunction::GetPossibleRegisterValuesAtInstruction(uint32_t reg, size_t instr,
- const set<BNDataFlowQueryOption>& options)
+PossibleValueSet LowLevelILFunction::GetPossibleRegisterValuesAtInstruction(
+ uint32_t reg, size_t instr, const set<BNDataFlowQueryOption>& options)
{
BNDataFlowQueryOption* optionArray = new BNDataFlowQueryOption[options.size()];
size_t idx = 0;
for (auto i : options)
optionArray[idx++] = i;
- BNPossibleValueSet value = BNGetLowLevelILPossibleRegisterValuesAtInstruction(m_object, reg, instr,
- optionArray, options.size());
+ BNPossibleValueSet value =
+ BNGetLowLevelILPossibleRegisterValuesAtInstruction(m_object, reg, instr, optionArray, options.size());
delete[] optionArray;
return PossibleValueSet::FromAPIObject(value);
}
-PossibleValueSet LowLevelILFunction::GetPossibleRegisterValuesAfterInstruction(uint32_t reg, size_t instr,
- const set<BNDataFlowQueryOption>& options)
+PossibleValueSet LowLevelILFunction::GetPossibleRegisterValuesAfterInstruction(
+ uint32_t reg, size_t instr, const set<BNDataFlowQueryOption>& options)
{
BNDataFlowQueryOption* optionArray = new BNDataFlowQueryOption[options.size()];
size_t idx = 0;
for (auto i : options)
optionArray[idx++] = i;
- BNPossibleValueSet value = BNGetLowLevelILPossibleRegisterValuesAfterInstruction(m_object, reg, instr,
- optionArray, options.size());
+ BNPossibleValueSet value =
+ BNGetLowLevelILPossibleRegisterValuesAfterInstruction(m_object, reg, instr, optionArray, options.size());
delete[] optionArray;
return PossibleValueSet::FromAPIObject(value);
}
@@ -704,29 +703,29 @@ RegisterValue LowLevelILFunction::GetFlagValueAfterInstruction(uint32_t flag, si
}
-PossibleValueSet LowLevelILFunction::GetPossibleFlagValuesAtInstruction(uint32_t flag, size_t instr,
- const set<BNDataFlowQueryOption>& options)
+PossibleValueSet LowLevelILFunction::GetPossibleFlagValuesAtInstruction(
+ uint32_t flag, size_t instr, const set<BNDataFlowQueryOption>& options)
{
BNDataFlowQueryOption* optionArray = new BNDataFlowQueryOption[options.size()];
size_t idx = 0;
for (auto i : options)
optionArray[idx++] = i;
- BNPossibleValueSet value = BNGetLowLevelILPossibleFlagValuesAtInstruction(m_object, flag, instr,
- optionArray, options.size());
+ BNPossibleValueSet value =
+ BNGetLowLevelILPossibleFlagValuesAtInstruction(m_object, flag, instr, optionArray, options.size());
delete[] optionArray;
return PossibleValueSet::FromAPIObject(value);
}
-PossibleValueSet LowLevelILFunction::GetPossibleFlagValuesAfterInstruction(uint32_t flag, size_t instr,
- const set<BNDataFlowQueryOption>& options)
+PossibleValueSet LowLevelILFunction::GetPossibleFlagValuesAfterInstruction(
+ uint32_t flag, size_t instr, const set<BNDataFlowQueryOption>& options)
{
BNDataFlowQueryOption* optionArray = new BNDataFlowQueryOption[options.size()];
size_t idx = 0;
for (auto i : options)
optionArray[idx++] = i;
- BNPossibleValueSet value = BNGetLowLevelILPossibleFlagValuesAfterInstruction(m_object, flag, instr,
- optionArray, options.size());
+ BNPossibleValueSet value =
+ BNGetLowLevelILPossibleFlagValuesAfterInstruction(m_object, flag, instr, optionArray, options.size());
delete[] optionArray;
return PossibleValueSet::FromAPIObject(value);
}
@@ -746,29 +745,29 @@ RegisterValue LowLevelILFunction::GetStackContentsAfterInstruction(int32_t offse
}
-PossibleValueSet LowLevelILFunction::GetPossibleStackContentsAtInstruction(int32_t offset, size_t len, size_t instr,
- const set<BNDataFlowQueryOption>& options)
+PossibleValueSet LowLevelILFunction::GetPossibleStackContentsAtInstruction(
+ int32_t offset, size_t len, size_t instr, const set<BNDataFlowQueryOption>& options)
{
BNDataFlowQueryOption* optionArray = new BNDataFlowQueryOption[options.size()];
size_t idx = 0;
for (auto i : options)
optionArray[idx++] = i;
- BNPossibleValueSet value = BNGetLowLevelILPossibleStackContentsAtInstruction(m_object, offset, len, instr,
- optionArray, options.size());
+ BNPossibleValueSet value =
+ BNGetLowLevelILPossibleStackContentsAtInstruction(m_object, offset, len, instr, optionArray, options.size());
delete[] optionArray;
return PossibleValueSet::FromAPIObject(value);
}
-PossibleValueSet LowLevelILFunction::GetPossibleStackContentsAfterInstruction(int32_t offset, size_t len, size_t instr,
- const set<BNDataFlowQueryOption>& options)
+PossibleValueSet LowLevelILFunction::GetPossibleStackContentsAfterInstruction(
+ int32_t offset, size_t len, size_t instr, const set<BNDataFlowQueryOption>& options)
{
BNDataFlowQueryOption* optionArray = new BNDataFlowQueryOption[options.size()];
size_t idx = 0;
for (auto i : options)
optionArray[idx++] = i;
- BNPossibleValueSet value = BNGetLowLevelILPossibleStackContentsAfterInstruction(m_object, offset, len, instr,
- optionArray, options.size());
+ BNPossibleValueSet value =
+ BNGetLowLevelILPossibleStackContentsAfterInstruction(m_object, offset, len, instr, optionArray, options.size());
delete[] optionArray;
return PossibleValueSet::FromAPIObject(value);
}
diff --git a/lowlevelilinstruction.cpp b/lowlevelilinstruction.cpp
index d0f7137d..59a3ad55 100644
--- a/lowlevelilinstruction.cpp
+++ b/lowlevelilinstruction.cpp
@@ -19,14 +19,14 @@
// IN THE SOFTWARE.
#ifdef BINARYNINJACORE_LIBRARY
-#include "lowlevelilfunction.h"
-#include "lowlevelilssafunction.h"
-#include "mediumlevelilfunction.h"
+ #include "lowlevelilfunction.h"
+ #include "lowlevelilssafunction.h"
+ #include "mediumlevelilfunction.h"
using namespace BinaryNinjaCore;
#else
-#include "binaryninjaapi.h"
-#include "lowlevelilinstruction.h"
-#include "mediumlevelilinstruction.h"
+ #include "binaryninjaapi.h"
+ #include "lowlevelilinstruction.h"
+ #include "mediumlevelilinstruction.h"
using namespace BinaryNinja;
#endif
@@ -35,220 +35,192 @@ using namespace std;
#endif
-unordered_map<LowLevelILOperandUsage, LowLevelILOperandType>
- LowLevelILInstructionBase::operandTypeForUsage = {
- {SourceExprLowLevelOperandUsage, ExprLowLevelOperand},
- {SourceRegisterLowLevelOperandUsage, RegisterLowLevelOperand},
- {SourceRegisterStackLowLevelOperandUsage, RegisterStackLowLevelOperand},
- {SourceFlagLowLevelOperandUsage, FlagLowLevelOperand},
- {SourceSSARegisterLowLevelOperandUsage, SSARegisterLowLevelOperand},
- {SourceSSARegisterStackLowLevelOperandUsage, SSARegisterStackLowLevelOperand},
- {SourceSSAFlagLowLevelOperandUsage, SSAFlagLowLevelOperand},
- {DestExprLowLevelOperandUsage, ExprLowLevelOperand},
- {DestRegisterLowLevelOperandUsage, RegisterLowLevelOperand},
- {DestRegisterStackLowLevelOperandUsage, RegisterStackLowLevelOperand},
- {DestFlagLowLevelOperandUsage, FlagLowLevelOperand},
- {DestSSARegisterLowLevelOperandUsage, SSARegisterLowLevelOperand},
- {DestSSARegisterStackLowLevelOperandUsage, SSARegisterStackLowLevelOperand},
- {DestSSAFlagLowLevelOperandUsage, SSAFlagLowLevelOperand},
- {SemanticFlagClassLowLevelOperandUsage, SemanticFlagClassLowLevelOperand},
- {SemanticFlagGroupLowLevelOperandUsage, SemanticFlagGroupLowLevelOperand},
- {PartialRegisterLowLevelOperandUsage, RegisterLowLevelOperand},
- {PartialSSARegisterStackSourceLowLevelOperandUsage, SSARegisterStackLowLevelOperand},
- {StackSSARegisterLowLevelOperandUsage, SSARegisterLowLevelOperand},
- {StackMemoryVersionLowLevelOperandUsage, IndexLowLevelOperand},
- {TopSSARegisterLowLevelOperandUsage, SSARegisterLowLevelOperand},
- {LeftExprLowLevelOperandUsage, ExprLowLevelOperand},
- {RightExprLowLevelOperandUsage, ExprLowLevelOperand},
- {CarryExprLowLevelOperandUsage, ExprLowLevelOperand},
- {ConditionExprLowLevelOperandUsage, ExprLowLevelOperand},
- {HighRegisterLowLevelOperandUsage, RegisterLowLevelOperand},
- {HighSSARegisterLowLevelOperandUsage, SSARegisterLowLevelOperand},
- {LowRegisterLowLevelOperandUsage, RegisterLowLevelOperand},
- {LowSSARegisterLowLevelOperandUsage, SSARegisterLowLevelOperand},
- {IntrinsicLowLevelOperandUsage, IntrinsicLowLevelOperand},
- {ConstantLowLevelOperandUsage, IntegerLowLevelOperand},
- {VectorLowLevelOperandUsage, IntegerLowLevelOperand},
- {StackAdjustmentLowLevelOperandUsage, IntegerLowLevelOperand},
- {TargetLowLevelOperandUsage, IndexLowLevelOperand},
- {TrueTargetLowLevelOperandUsage, IndexLowLevelOperand},
- {FalseTargetLowLevelOperandUsage, IndexLowLevelOperand},
- {BitIndexLowLevelOperandUsage, IndexLowLevelOperand},
- {SourceMemoryVersionLowLevelOperandUsage, IndexLowLevelOperand},
- {DestMemoryVersionLowLevelOperandUsage, IndexLowLevelOperand},
- {FlagConditionLowLevelOperandUsage, FlagConditionLowLevelOperand},
- {OutputSSARegistersLowLevelOperandUsage, SSARegisterListLowLevelOperand},
- {OutputMemoryVersionLowLevelOperandUsage, IndexLowLevelOperand},
- {ParameterExprsLowLevelOperandUsage, ExprListLowLevelOperand},
- {SourceSSARegistersLowLevelOperandUsage, SSARegisterListLowLevelOperand},
- {SourceSSARegisterStacksLowLevelOperandUsage, SSARegisterStackListLowLevelOperand},
- {SourceSSAFlagsLowLevelOperandUsage, SSAFlagListLowLevelOperand},
- {OutputRegisterOrFlagListLowLevelOperandUsage, RegisterOrFlagListLowLevelOperand},
- {OutputSSARegisterOrFlagListLowLevelOperandUsage, SSARegisterOrFlagListLowLevelOperand},
- {SourceMemoryVersionsLowLevelOperandUsage, IndexListLowLevelOperand},
- {TargetsLowLevelOperandUsage, IndexMapLowLevelOperand},
- {RegisterStackAdjustmentsLowLevelOperandUsage, RegisterStackAdjustmentsLowLevelOperand}
- };
+unordered_map<LowLevelILOperandUsage, LowLevelILOperandType> LowLevelILInstructionBase::operandTypeForUsage = {
+ {SourceExprLowLevelOperandUsage, ExprLowLevelOperand},
+ {SourceRegisterLowLevelOperandUsage, RegisterLowLevelOperand},
+ {SourceRegisterStackLowLevelOperandUsage, RegisterStackLowLevelOperand},
+ {SourceFlagLowLevelOperandUsage, FlagLowLevelOperand},
+ {SourceSSARegisterLowLevelOperandUsage, SSARegisterLowLevelOperand},
+ {SourceSSARegisterStackLowLevelOperandUsage, SSARegisterStackLowLevelOperand},
+ {SourceSSAFlagLowLevelOperandUsage, SSAFlagLowLevelOperand}, {DestExprLowLevelOperandUsage, ExprLowLevelOperand},
+ {DestRegisterLowLevelOperandUsage, RegisterLowLevelOperand},
+ {DestRegisterStackLowLevelOperandUsage, RegisterStackLowLevelOperand},
+ {DestFlagLowLevelOperandUsage, FlagLowLevelOperand},
+ {DestSSARegisterLowLevelOperandUsage, SSARegisterLowLevelOperand},
+ {DestSSARegisterStackLowLevelOperandUsage, SSARegisterStackLowLevelOperand},
+ {DestSSAFlagLowLevelOperandUsage, SSAFlagLowLevelOperand},
+ {SemanticFlagClassLowLevelOperandUsage, SemanticFlagClassLowLevelOperand},
+ {SemanticFlagGroupLowLevelOperandUsage, SemanticFlagGroupLowLevelOperand},
+ {PartialRegisterLowLevelOperandUsage, RegisterLowLevelOperand},
+ {PartialSSARegisterStackSourceLowLevelOperandUsage, SSARegisterStackLowLevelOperand},
+ {StackSSARegisterLowLevelOperandUsage, SSARegisterLowLevelOperand},
+ {StackMemoryVersionLowLevelOperandUsage, IndexLowLevelOperand},
+ {TopSSARegisterLowLevelOperandUsage, SSARegisterLowLevelOperand},
+ {LeftExprLowLevelOperandUsage, ExprLowLevelOperand}, {RightExprLowLevelOperandUsage, ExprLowLevelOperand},
+ {CarryExprLowLevelOperandUsage, ExprLowLevelOperand}, {ConditionExprLowLevelOperandUsage, ExprLowLevelOperand},
+ {HighRegisterLowLevelOperandUsage, RegisterLowLevelOperand},
+ {HighSSARegisterLowLevelOperandUsage, SSARegisterLowLevelOperand},
+ {LowRegisterLowLevelOperandUsage, RegisterLowLevelOperand},
+ {LowSSARegisterLowLevelOperandUsage, SSARegisterLowLevelOperand},
+ {IntrinsicLowLevelOperandUsage, IntrinsicLowLevelOperand}, {ConstantLowLevelOperandUsage, IntegerLowLevelOperand},
+ {VectorLowLevelOperandUsage, IntegerLowLevelOperand}, {StackAdjustmentLowLevelOperandUsage, IntegerLowLevelOperand},
+ {TargetLowLevelOperandUsage, IndexLowLevelOperand}, {TrueTargetLowLevelOperandUsage, IndexLowLevelOperand},
+ {FalseTargetLowLevelOperandUsage, IndexLowLevelOperand}, {BitIndexLowLevelOperandUsage, IndexLowLevelOperand},
+ {SourceMemoryVersionLowLevelOperandUsage, IndexLowLevelOperand},
+ {DestMemoryVersionLowLevelOperandUsage, IndexLowLevelOperand},
+ {FlagConditionLowLevelOperandUsage, FlagConditionLowLevelOperand},
+ {OutputSSARegistersLowLevelOperandUsage, SSARegisterListLowLevelOperand},
+ {OutputMemoryVersionLowLevelOperandUsage, IndexLowLevelOperand},
+ {ParameterExprsLowLevelOperandUsage, ExprListLowLevelOperand},
+ {SourceSSARegistersLowLevelOperandUsage, SSARegisterListLowLevelOperand},
+ {SourceSSARegisterStacksLowLevelOperandUsage, SSARegisterStackListLowLevelOperand},
+ {SourceSSAFlagsLowLevelOperandUsage, SSAFlagListLowLevelOperand},
+ {OutputRegisterOrFlagListLowLevelOperandUsage, RegisterOrFlagListLowLevelOperand},
+ {OutputSSARegisterOrFlagListLowLevelOperandUsage, SSARegisterOrFlagListLowLevelOperand},
+ {SourceMemoryVersionsLowLevelOperandUsage, IndexListLowLevelOperand},
+ {TargetsLowLevelOperandUsage, IndexMapLowLevelOperand},
+ {RegisterStackAdjustmentsLowLevelOperandUsage, RegisterStackAdjustmentsLowLevelOperand}};
-unordered_map<BNLowLevelILOperation, vector<LowLevelILOperandUsage>>
- LowLevelILInstructionBase::operationOperandUsage = {
- {LLIL_NOP, {}},
- {LLIL_POP, {}},
- {LLIL_NORET, {}},
- {LLIL_SYSCALL, {}},
- {LLIL_BP, {}},
- {LLIL_UNDEF, {}},
- {LLIL_UNIMPL, {}},
- {LLIL_SET_REG, {DestRegisterLowLevelOperandUsage, SourceExprLowLevelOperandUsage}},
- {LLIL_SET_REG_SPLIT, {HighRegisterLowLevelOperandUsage, LowRegisterLowLevelOperandUsage,
- SourceExprLowLevelOperandUsage}},
- {LLIL_SET_REG_SSA, {DestSSARegisterLowLevelOperandUsage, SourceExprLowLevelOperandUsage}},
- {LLIL_SET_REG_SSA_PARTIAL, {DestSSARegisterLowLevelOperandUsage, PartialRegisterLowLevelOperandUsage,
- SourceExprLowLevelOperandUsage}},
- {LLIL_SET_REG_SPLIT_SSA, {HighSSARegisterLowLevelOperandUsage,
- LowSSARegisterLowLevelOperandUsage, SourceExprLowLevelOperandUsage}},
- {LLIL_SET_REG_STACK_REL, {DestRegisterStackLowLevelOperandUsage, DestExprLowLevelOperandUsage,
- SourceExprLowLevelOperandUsage}},
- {LLIL_REG_STACK_PUSH, {DestRegisterStackLowLevelOperandUsage, SourceExprLowLevelOperandUsage}},
- {LLIL_SET_REG_STACK_REL_SSA, {DestSSARegisterStackLowLevelOperandUsage,
- PartialSSARegisterStackSourceLowLevelOperandUsage, DestExprLowLevelOperandUsage,
- TopSSARegisterLowLevelOperandUsage, SourceExprLowLevelOperandUsage}},
- {LLIL_SET_REG_STACK_ABS_SSA, {DestSSARegisterStackLowLevelOperandUsage,
- PartialSSARegisterStackSourceLowLevelOperandUsage, DestRegisterLowLevelOperandUsage,
- SourceExprLowLevelOperandUsage}},
- {LLIL_SET_FLAG, {DestFlagLowLevelOperandUsage, SourceExprLowLevelOperandUsage}},
- {LLIL_SET_FLAG_SSA, {DestSSAFlagLowLevelOperandUsage, SourceExprLowLevelOperandUsage}},
- {LLIL_LOAD, {SourceExprLowLevelOperandUsage}},
- {LLIL_LOAD_SSA, {SourceExprLowLevelOperandUsage, SourceMemoryVersionLowLevelOperandUsage}},
- {LLIL_STORE, {DestExprLowLevelOperandUsage, SourceExprLowLevelOperandUsage}},
- {LLIL_STORE_SSA, {DestExprLowLevelOperandUsage, DestMemoryVersionLowLevelOperandUsage,
- SourceMemoryVersionLowLevelOperandUsage, SourceExprLowLevelOperandUsage}},
- {LLIL_REG, {SourceRegisterLowLevelOperandUsage}},
- {LLIL_REG_SSA, {SourceSSARegisterLowLevelOperandUsage}},
- {LLIL_REG_SSA_PARTIAL, {SourceSSARegisterLowLevelOperandUsage, PartialRegisterLowLevelOperandUsage}},
- {LLIL_REG_SPLIT, {HighRegisterLowLevelOperandUsage, LowRegisterLowLevelOperandUsage}},
- {LLIL_REG_SPLIT_SSA, {HighSSARegisterLowLevelOperandUsage, LowSSARegisterLowLevelOperandUsage}},
- {LLIL_REG_STACK_REL, {SourceRegisterStackLowLevelOperandUsage, SourceExprLowLevelOperandUsage}},
- {LLIL_REG_STACK_POP, {SourceRegisterStackLowLevelOperandUsage}},
- {LLIL_REG_STACK_FREE_REG, {DestRegisterLowLevelOperandUsage}},
- {LLIL_REG_STACK_FREE_REL, {DestRegisterStackLowLevelOperandUsage, DestExprLowLevelOperandUsage}},
- {LLIL_REG_STACK_REL_SSA, {SourceSSARegisterStackLowLevelOperandUsage, TopSSARegisterLowLevelOperandUsage,
- SourceExprLowLevelOperandUsage}},
- {LLIL_REG_STACK_ABS_SSA, {SourceSSARegisterStackLowLevelOperandUsage, SourceRegisterLowLevelOperandUsage}},
- {LLIL_REG_STACK_FREE_REL_SSA, {DestSSARegisterStackLowLevelOperandUsage,
- PartialSSARegisterStackSourceLowLevelOperandUsage, DestExprLowLevelOperandUsage,
- TopSSARegisterLowLevelOperandUsage}},
- {LLIL_REG_STACK_FREE_ABS_SSA, {DestSSARegisterStackLowLevelOperandUsage,
- PartialSSARegisterStackSourceLowLevelOperandUsage, DestRegisterLowLevelOperandUsage}},
- {LLIL_FLAG, {SourceFlagLowLevelOperandUsage}},
- {LLIL_FLAG_BIT, {SourceFlagLowLevelOperandUsage, BitIndexLowLevelOperandUsage}},
- {LLIL_FLAG_SSA, {SourceSSAFlagLowLevelOperandUsage}},
- {LLIL_FLAG_BIT_SSA, {SourceSSAFlagLowLevelOperandUsage, BitIndexLowLevelOperandUsage}},
- {LLIL_JUMP, {DestExprLowLevelOperandUsage}},
- {LLIL_JUMP_TO, {DestExprLowLevelOperandUsage, TargetsLowLevelOperandUsage}},
- {LLIL_CALL, {DestExprLowLevelOperandUsage}},
- {LLIL_CALL_STACK_ADJUST, {DestExprLowLevelOperandUsage, StackAdjustmentLowLevelOperandUsage,
- RegisterStackAdjustmentsLowLevelOperandUsage}},
- {LLIL_TAILCALL, {DestExprLowLevelOperandUsage}},
- {LLIL_RET, {DestExprLowLevelOperandUsage}},
- {LLIL_IF, {ConditionExprLowLevelOperandUsage, TrueTargetLowLevelOperandUsage,
- FalseTargetLowLevelOperandUsage}},
- {LLIL_GOTO, {TargetLowLevelOperandUsage}},
- {LLIL_FLAG_COND, {FlagConditionLowLevelOperandUsage, SemanticFlagClassLowLevelOperandUsage}},
- {LLIL_FLAG_GROUP, {SemanticFlagGroupLowLevelOperandUsage}},
- {LLIL_TRAP, {VectorLowLevelOperandUsage}},
- {LLIL_CALL_SSA, {OutputSSARegistersLowLevelOperandUsage, OutputMemoryVersionLowLevelOperandUsage,
- DestExprLowLevelOperandUsage, StackSSARegisterLowLevelOperandUsage,
- StackMemoryVersionLowLevelOperandUsage, ParameterExprsLowLevelOperandUsage}},
- {LLIL_SYSCALL_SSA, {OutputSSARegistersLowLevelOperandUsage, OutputMemoryVersionLowLevelOperandUsage,
- StackSSARegisterLowLevelOperandUsage, StackMemoryVersionLowLevelOperandUsage,
- ParameterExprsLowLevelOperandUsage}},
- {LLIL_TAILCALL_SSA, {OutputSSARegistersLowLevelOperandUsage, OutputMemoryVersionLowLevelOperandUsage,
- DestExprLowLevelOperandUsage, StackSSARegisterLowLevelOperandUsage,
- StackMemoryVersionLowLevelOperandUsage, ParameterExprsLowLevelOperandUsage}},
- {LLIL_REG_PHI, {DestSSARegisterLowLevelOperandUsage, SourceSSARegistersLowLevelOperandUsage}},
- {LLIL_REG_STACK_PHI, {DestSSARegisterStackLowLevelOperandUsage, SourceSSARegisterStacksLowLevelOperandUsage}},
- {LLIL_FLAG_PHI, {DestSSAFlagLowLevelOperandUsage, SourceSSAFlagsLowLevelOperandUsage}},
- {LLIL_MEM_PHI, {DestMemoryVersionLowLevelOperandUsage, SourceMemoryVersionsLowLevelOperandUsage}},
- {LLIL_CONST, {ConstantLowLevelOperandUsage}},
- {LLIL_CONST_PTR, {ConstantLowLevelOperandUsage}},
- {LLIL_EXTERN_PTR, {ConstantLowLevelOperandUsage, OffsetLowLevelOperandUsage}},
- {LLIL_FLOAT_CONST, {ConstantLowLevelOperandUsage}},
- {LLIL_ADD, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
- {LLIL_SUB, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
- {LLIL_AND, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
- {LLIL_OR, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
- {LLIL_XOR, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
- {LLIL_LSL, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
- {LLIL_LSR, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
- {LLIL_ASR, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
- {LLIL_ROL, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
- {LLIL_ROR, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
- {LLIL_MUL, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
- {LLIL_MULU_DP, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
- {LLIL_MULS_DP, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
- {LLIL_DIVU, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
- {LLIL_DIVS, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
- {LLIL_MODU, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
- {LLIL_MODS, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
- {LLIL_CMP_E, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
- {LLIL_CMP_NE, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
- {LLIL_CMP_SLT, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
- {LLIL_CMP_ULT, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
- {LLIL_CMP_SLE, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
- {LLIL_CMP_ULE, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
- {LLIL_CMP_SGE, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
- {LLIL_CMP_UGE, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
- {LLIL_CMP_SGT, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
- {LLIL_CMP_UGT, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
- {LLIL_TEST_BIT, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
- {LLIL_ADD_OVERFLOW, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
- {LLIL_ADC, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage, CarryExprLowLevelOperandUsage}},
- {LLIL_SBB, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage, CarryExprLowLevelOperandUsage}},
- {LLIL_RLC, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage, CarryExprLowLevelOperandUsage}},
- {LLIL_RRC, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage, CarryExprLowLevelOperandUsage}},
- {LLIL_DIVU_DP, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
- {LLIL_DIVS_DP, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
- {LLIL_MODU_DP, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
- {LLIL_MODS_DP, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
- {LLIL_PUSH, {SourceExprLowLevelOperandUsage}},
- {LLIL_NEG, {SourceExprLowLevelOperandUsage}},
- {LLIL_NOT, {SourceExprLowLevelOperandUsage}},
- {LLIL_SX, {SourceExprLowLevelOperandUsage}},
- {LLIL_ZX, {SourceExprLowLevelOperandUsage}},
- {LLIL_LOW_PART, {SourceExprLowLevelOperandUsage}},
- {LLIL_BOOL_TO_INT, {SourceExprLowLevelOperandUsage}},
- {LLIL_INTRINSIC, {OutputRegisterOrFlagListLowLevelOperandUsage, IntrinsicLowLevelOperandUsage,
- ParameterExprsLowLevelOperandUsage}},
- {LLIL_INTRINSIC_SSA, {OutputSSARegisterOrFlagListLowLevelOperandUsage, IntrinsicLowLevelOperandUsage,
- ParameterExprsLowLevelOperandUsage}},
- {LLIL_UNIMPL_MEM, {SourceExprLowLevelOperandUsage}},
- {LLIL_FADD, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
- {LLIL_FSUB, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
- {LLIL_FMUL, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
- {LLIL_FDIV, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
- {LLIL_FSQRT, {SourceExprLowLevelOperandUsage}},
- {LLIL_FNEG, {SourceExprLowLevelOperandUsage}},
- {LLIL_FABS, {SourceExprLowLevelOperandUsage}},
- {LLIL_FLOAT_TO_INT, {SourceExprLowLevelOperandUsage}},
- {LLIL_INT_TO_FLOAT, {SourceExprLowLevelOperandUsage}},
- {LLIL_FLOAT_CONV, {SourceExprLowLevelOperandUsage}},
- {LLIL_ROUND_TO_INT, {SourceExprLowLevelOperandUsage}},
- {LLIL_FLOOR, {SourceExprLowLevelOperandUsage}},
- {LLIL_CEIL, {SourceExprLowLevelOperandUsage}},
- {LLIL_FTRUNC, {SourceExprLowLevelOperandUsage}},
- {LLIL_FCMP_E, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
- {LLIL_FCMP_NE, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
- {LLIL_FCMP_LT, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
- {LLIL_FCMP_LE, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
- {LLIL_FCMP_GE, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
- {LLIL_FCMP_GT, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
- {LLIL_FCMP_UO, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}}
- };
+unordered_map<BNLowLevelILOperation, vector<LowLevelILOperandUsage>> LowLevelILInstructionBase::operationOperandUsage =
+ {{LLIL_NOP, {}}, {LLIL_POP, {}}, {LLIL_NORET, {}}, {LLIL_SYSCALL, {}}, {LLIL_BP, {}}, {LLIL_UNDEF, {}},
+ {LLIL_UNIMPL, {}}, {LLIL_SET_REG, {DestRegisterLowLevelOperandUsage, SourceExprLowLevelOperandUsage}},
+ {LLIL_SET_REG_SPLIT,
+ {HighRegisterLowLevelOperandUsage, LowRegisterLowLevelOperandUsage, SourceExprLowLevelOperandUsage}},
+ {LLIL_SET_REG_SSA, {DestSSARegisterLowLevelOperandUsage, SourceExprLowLevelOperandUsage}},
+ {LLIL_SET_REG_SSA_PARTIAL,
+ {DestSSARegisterLowLevelOperandUsage, PartialRegisterLowLevelOperandUsage, SourceExprLowLevelOperandUsage}},
+ {LLIL_SET_REG_SPLIT_SSA,
+ {HighSSARegisterLowLevelOperandUsage, LowSSARegisterLowLevelOperandUsage, SourceExprLowLevelOperandUsage}},
+ {LLIL_SET_REG_STACK_REL,
+ {DestRegisterStackLowLevelOperandUsage, DestExprLowLevelOperandUsage, SourceExprLowLevelOperandUsage}},
+ {LLIL_REG_STACK_PUSH, {DestRegisterStackLowLevelOperandUsage, SourceExprLowLevelOperandUsage}},
+ {LLIL_SET_REG_STACK_REL_SSA,
+ {DestSSARegisterStackLowLevelOperandUsage, PartialSSARegisterStackSourceLowLevelOperandUsage,
+ DestExprLowLevelOperandUsage, TopSSARegisterLowLevelOperandUsage, SourceExprLowLevelOperandUsage}},
+ {LLIL_SET_REG_STACK_ABS_SSA,
+ {DestSSARegisterStackLowLevelOperandUsage, PartialSSARegisterStackSourceLowLevelOperandUsage,
+ DestRegisterLowLevelOperandUsage, SourceExprLowLevelOperandUsage}},
+ {LLIL_SET_FLAG, {DestFlagLowLevelOperandUsage, SourceExprLowLevelOperandUsage}},
+ {LLIL_SET_FLAG_SSA, {DestSSAFlagLowLevelOperandUsage, SourceExprLowLevelOperandUsage}},
+ {LLIL_LOAD, {SourceExprLowLevelOperandUsage}},
+ {LLIL_LOAD_SSA, {SourceExprLowLevelOperandUsage, SourceMemoryVersionLowLevelOperandUsage}},
+ {LLIL_STORE, {DestExprLowLevelOperandUsage, SourceExprLowLevelOperandUsage}},
+ {LLIL_STORE_SSA, {DestExprLowLevelOperandUsage, DestMemoryVersionLowLevelOperandUsage,
+ SourceMemoryVersionLowLevelOperandUsage, SourceExprLowLevelOperandUsage}},
+ {LLIL_REG, {SourceRegisterLowLevelOperandUsage}}, {LLIL_REG_SSA, {SourceSSARegisterLowLevelOperandUsage}},
+ {LLIL_REG_SSA_PARTIAL, {SourceSSARegisterLowLevelOperandUsage, PartialRegisterLowLevelOperandUsage}},
+ {LLIL_REG_SPLIT, {HighRegisterLowLevelOperandUsage, LowRegisterLowLevelOperandUsage}},
+ {LLIL_REG_SPLIT_SSA, {HighSSARegisterLowLevelOperandUsage, LowSSARegisterLowLevelOperandUsage}},
+ {LLIL_REG_STACK_REL, {SourceRegisterStackLowLevelOperandUsage, SourceExprLowLevelOperandUsage}},
+ {LLIL_REG_STACK_POP, {SourceRegisterStackLowLevelOperandUsage}},
+ {LLIL_REG_STACK_FREE_REG, {DestRegisterLowLevelOperandUsage}},
+ {LLIL_REG_STACK_FREE_REL, {DestRegisterStackLowLevelOperandUsage, DestExprLowLevelOperandUsage}},
+ {LLIL_REG_STACK_REL_SSA, {SourceSSARegisterStackLowLevelOperandUsage, TopSSARegisterLowLevelOperandUsage,
+ SourceExprLowLevelOperandUsage}},
+ {LLIL_REG_STACK_ABS_SSA, {SourceSSARegisterStackLowLevelOperandUsage, SourceRegisterLowLevelOperandUsage}},
+ {LLIL_REG_STACK_FREE_REL_SSA,
+ {DestSSARegisterStackLowLevelOperandUsage, PartialSSARegisterStackSourceLowLevelOperandUsage,
+ DestExprLowLevelOperandUsage, TopSSARegisterLowLevelOperandUsage}},
+ {LLIL_REG_STACK_FREE_ABS_SSA,
+ {DestSSARegisterStackLowLevelOperandUsage, PartialSSARegisterStackSourceLowLevelOperandUsage,
+ DestRegisterLowLevelOperandUsage}},
+ {LLIL_FLAG, {SourceFlagLowLevelOperandUsage}},
+ {LLIL_FLAG_BIT, {SourceFlagLowLevelOperandUsage, BitIndexLowLevelOperandUsage}},
+ {LLIL_FLAG_SSA, {SourceSSAFlagLowLevelOperandUsage}},
+ {LLIL_FLAG_BIT_SSA, {SourceSSAFlagLowLevelOperandUsage, BitIndexLowLevelOperandUsage}},
+ {LLIL_JUMP, {DestExprLowLevelOperandUsage}},
+ {LLIL_JUMP_TO, {DestExprLowLevelOperandUsage, TargetsLowLevelOperandUsage}},
+ {LLIL_CALL, {DestExprLowLevelOperandUsage}},
+ {LLIL_CALL_STACK_ADJUST, {DestExprLowLevelOperandUsage, StackAdjustmentLowLevelOperandUsage,
+ RegisterStackAdjustmentsLowLevelOperandUsage}},
+ {LLIL_TAILCALL, {DestExprLowLevelOperandUsage}}, {LLIL_RET, {DestExprLowLevelOperandUsage}},
+ {LLIL_IF, {ConditionExprLowLevelOperandUsage, TrueTargetLowLevelOperandUsage, FalseTargetLowLevelOperandUsage}},
+ {LLIL_GOTO, {TargetLowLevelOperandUsage}},
+ {LLIL_FLAG_COND, {FlagConditionLowLevelOperandUsage, SemanticFlagClassLowLevelOperandUsage}},
+ {LLIL_FLAG_GROUP, {SemanticFlagGroupLowLevelOperandUsage}}, {LLIL_TRAP, {VectorLowLevelOperandUsage}},
+ {LLIL_CALL_SSA, {OutputSSARegistersLowLevelOperandUsage, OutputMemoryVersionLowLevelOperandUsage,
+ DestExprLowLevelOperandUsage, StackSSARegisterLowLevelOperandUsage,
+ StackMemoryVersionLowLevelOperandUsage, ParameterExprsLowLevelOperandUsage}},
+ {LLIL_SYSCALL_SSA, {OutputSSARegistersLowLevelOperandUsage, OutputMemoryVersionLowLevelOperandUsage,
+ StackSSARegisterLowLevelOperandUsage, StackMemoryVersionLowLevelOperandUsage,
+ ParameterExprsLowLevelOperandUsage}},
+ {LLIL_TAILCALL_SSA, {OutputSSARegistersLowLevelOperandUsage, OutputMemoryVersionLowLevelOperandUsage,
+ DestExprLowLevelOperandUsage, StackSSARegisterLowLevelOperandUsage,
+ StackMemoryVersionLowLevelOperandUsage, ParameterExprsLowLevelOperandUsage}},
+ {LLIL_REG_PHI, {DestSSARegisterLowLevelOperandUsage, SourceSSARegistersLowLevelOperandUsage}},
+ {LLIL_REG_STACK_PHI, {DestSSARegisterStackLowLevelOperandUsage, SourceSSARegisterStacksLowLevelOperandUsage}},
+ {LLIL_FLAG_PHI, {DestSSAFlagLowLevelOperandUsage, SourceSSAFlagsLowLevelOperandUsage}},
+ {LLIL_MEM_PHI, {DestMemoryVersionLowLevelOperandUsage, SourceMemoryVersionsLowLevelOperandUsage}},
+ {LLIL_CONST, {ConstantLowLevelOperandUsage}}, {LLIL_CONST_PTR, {ConstantLowLevelOperandUsage}},
+ {LLIL_EXTERN_PTR, {ConstantLowLevelOperandUsage, OffsetLowLevelOperandUsage}},
+ {LLIL_FLOAT_CONST, {ConstantLowLevelOperandUsage}},
+ {LLIL_ADD, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
+ {LLIL_SUB, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
+ {LLIL_AND, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
+ {LLIL_OR, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
+ {LLIL_XOR, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
+ {LLIL_LSL, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
+ {LLIL_LSR, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
+ {LLIL_ASR, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
+ {LLIL_ROL, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
+ {LLIL_ROR, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
+ {LLIL_MUL, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
+ {LLIL_MULU_DP, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
+ {LLIL_MULS_DP, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
+ {LLIL_DIVU, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
+ {LLIL_DIVS, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
+ {LLIL_MODU, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
+ {LLIL_MODS, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
+ {LLIL_CMP_E, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
+ {LLIL_CMP_NE, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
+ {LLIL_CMP_SLT, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
+ {LLIL_CMP_ULT, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
+ {LLIL_CMP_SLE, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
+ {LLIL_CMP_ULE, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
+ {LLIL_CMP_SGE, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
+ {LLIL_CMP_UGE, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
+ {LLIL_CMP_SGT, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
+ {LLIL_CMP_UGT, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
+ {LLIL_TEST_BIT, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
+ {LLIL_ADD_OVERFLOW, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
+ {LLIL_ADC, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage, CarryExprLowLevelOperandUsage}},
+ {LLIL_SBB, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage, CarryExprLowLevelOperandUsage}},
+ {LLIL_RLC, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage, CarryExprLowLevelOperandUsage}},
+ {LLIL_RRC, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage, CarryExprLowLevelOperandUsage}},
+ {LLIL_DIVU_DP, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
+ {LLIL_DIVS_DP, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
+ {LLIL_MODU_DP, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
+ {LLIL_MODS_DP, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
+ {LLIL_PUSH, {SourceExprLowLevelOperandUsage}}, {LLIL_NEG, {SourceExprLowLevelOperandUsage}},
+ {LLIL_NOT, {SourceExprLowLevelOperandUsage}}, {LLIL_SX, {SourceExprLowLevelOperandUsage}},
+ {LLIL_ZX, {SourceExprLowLevelOperandUsage}}, {LLIL_LOW_PART, {SourceExprLowLevelOperandUsage}},
+ {LLIL_BOOL_TO_INT, {SourceExprLowLevelOperandUsage}},
+ {LLIL_INTRINSIC, {OutputRegisterOrFlagListLowLevelOperandUsage, IntrinsicLowLevelOperandUsage,
+ ParameterExprsLowLevelOperandUsage}},
+ {LLIL_INTRINSIC_SSA, {OutputSSARegisterOrFlagListLowLevelOperandUsage, IntrinsicLowLevelOperandUsage,
+ ParameterExprsLowLevelOperandUsage}},
+ {LLIL_UNIMPL_MEM, {SourceExprLowLevelOperandUsage}},
+ {LLIL_FADD, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
+ {LLIL_FSUB, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
+ {LLIL_FMUL, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
+ {LLIL_FDIV, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
+ {LLIL_FSQRT, {SourceExprLowLevelOperandUsage}}, {LLIL_FNEG, {SourceExprLowLevelOperandUsage}},
+ {LLIL_FABS, {SourceExprLowLevelOperandUsage}}, {LLIL_FLOAT_TO_INT, {SourceExprLowLevelOperandUsage}},
+ {LLIL_INT_TO_FLOAT, {SourceExprLowLevelOperandUsage}}, {LLIL_FLOAT_CONV, {SourceExprLowLevelOperandUsage}},
+ {LLIL_ROUND_TO_INT, {SourceExprLowLevelOperandUsage}}, {LLIL_FLOOR, {SourceExprLowLevelOperandUsage}},
+ {LLIL_CEIL, {SourceExprLowLevelOperandUsage}}, {LLIL_FTRUNC, {SourceExprLowLevelOperandUsage}},
+ {LLIL_FCMP_E, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
+ {LLIL_FCMP_NE, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
+ {LLIL_FCMP_LT, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
+ {LLIL_FCMP_LE, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
+ {LLIL_FCMP_GE, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
+ {LLIL_FCMP_GT, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}},
+ {LLIL_FCMP_UO, {LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage}}};
-static unordered_map<BNLowLevelILOperation, unordered_map<LowLevelILOperandUsage, size_t>> GetOperandIndexForOperandUsages()
+static unordered_map<BNLowLevelILOperation, unordered_map<LowLevelILOperandUsage, size_t>>
+ GetOperandIndexForOperandUsages()
{
unordered_map<BNLowLevelILOperation, unordered_map<LowLevelILOperandUsage, size_t>> result;
result.reserve(LowLevelILInstructionBase::operationOperandUsage.size());
@@ -313,22 +285,16 @@ static unordered_map<BNLowLevelILOperation, unordered_map<LowLevelILOperandUsage
unordered_map<BNLowLevelILOperation, unordered_map<LowLevelILOperandUsage, size_t>>
- LowLevelILInstructionBase::operationOperandIndex = GetOperandIndexForOperandUsages();
+ LowLevelILInstructionBase::operationOperandIndex = GetOperandIndexForOperandUsages();
-RegisterOrFlag::RegisterOrFlag(): isFlag(false), index(BN_INVALID_REGISTER)
-{
-}
+RegisterOrFlag::RegisterOrFlag() : isFlag(false), index(BN_INVALID_REGISTER) {}
-RegisterOrFlag::RegisterOrFlag(bool flag, uint32_t i): isFlag(flag), index(i)
-{
-}
+RegisterOrFlag::RegisterOrFlag(bool flag, uint32_t i) : isFlag(flag), index(i) {}
-RegisterOrFlag::RegisterOrFlag(const RegisterOrFlag& v): isFlag(v.isFlag), index(v.index)
-{
-}
+RegisterOrFlag::RegisterOrFlag(const RegisterOrFlag& v) : isFlag(v.isFlag), index(v.index) {}
uint32_t RegisterOrFlag::GetRegister() const
@@ -387,19 +353,13 @@ RegisterOrFlag RegisterOrFlag::FromIdentifier(uint64_t id)
}
-SSARegister::SSARegister(): reg(BN_INVALID_REGISTER), version(0)
-{
-}
+SSARegister::SSARegister() : reg(BN_INVALID_REGISTER), version(0) {}
-SSARegister::SSARegister(const uint32_t r, size_t i): reg(r), version(i)
-{
-}
+SSARegister::SSARegister(const uint32_t r, size_t i) : reg(r), version(i) {}
-SSARegister::SSARegister(const SSARegister& v): reg(v.reg), version(v.version)
-{
-}
+SSARegister::SSARegister(const SSARegister& v) : reg(v.reg), version(v.version) {}
SSARegister& SSARegister::operator=(const SSARegister& v)
@@ -434,19 +394,13 @@ bool SSARegister::operator<(const SSARegister& v) const
}
-SSARegisterStack::SSARegisterStack(): regStack(BN_INVALID_REGISTER), version(0)
-{
-}
+SSARegisterStack::SSARegisterStack() : regStack(BN_INVALID_REGISTER), version(0) {}
-SSARegisterStack::SSARegisterStack(const uint32_t r, size_t i): regStack(r), version(i)
-{
-}
+SSARegisterStack::SSARegisterStack(const uint32_t r, size_t i) : regStack(r), version(i) {}
-SSARegisterStack::SSARegisterStack(const SSARegisterStack& v): regStack(v.regStack), version(v.version)
-{
-}
+SSARegisterStack::SSARegisterStack(const SSARegisterStack& v) : regStack(v.regStack), version(v.version) {}
SSARegisterStack& SSARegisterStack::operator=(const SSARegisterStack& v)
@@ -481,19 +435,13 @@ bool SSARegisterStack::operator<(const SSARegisterStack& v) const
}
-SSAFlag::SSAFlag(): flag(BN_INVALID_REGISTER), version(0)
-{
-}
+SSAFlag::SSAFlag() : flag(BN_INVALID_REGISTER), version(0) {}
-SSAFlag::SSAFlag(const uint32_t f, size_t i): flag(f), version(i)
-{
-}
+SSAFlag::SSAFlag(const uint32_t f, size_t i) : flag(f), version(i) {}
-SSAFlag::SSAFlag(const SSAFlag& v): flag(v.flag), version(v.version)
-{
-}
+SSAFlag::SSAFlag(const SSAFlag& v) : flag(v.flag), version(v.version) {}
SSAFlag& SSAFlag::operator=(const SSAFlag& v)
@@ -528,29 +476,19 @@ bool SSAFlag::operator<(const SSAFlag& v) const
}
-SSARegisterOrFlag::SSARegisterOrFlag(): version(0)
-{
-}
+SSARegisterOrFlag::SSARegisterOrFlag() : version(0) {}
-SSARegisterOrFlag::SSARegisterOrFlag(const RegisterOrFlag& rf, size_t i): regOrFlag(rf), version(i)
-{
-}
+SSARegisterOrFlag::SSARegisterOrFlag(const RegisterOrFlag& rf, size_t i) : regOrFlag(rf), version(i) {}
-SSARegisterOrFlag::SSARegisterOrFlag(const SSARegister& v): regOrFlag(false, v.reg), version(v.version)
-{
-}
+SSARegisterOrFlag::SSARegisterOrFlag(const SSARegister& v) : regOrFlag(false, v.reg), version(v.version) {}
-SSARegisterOrFlag::SSARegisterOrFlag(const SSAFlag& v): regOrFlag(true, v.flag), version(v.version)
-{
-}
+SSARegisterOrFlag::SSARegisterOrFlag(const SSAFlag& v) : regOrFlag(true, v.flag), version(v.version) {}
-SSARegisterOrFlag::SSARegisterOrFlag(const SSARegisterOrFlag& v): regOrFlag(v.regOrFlag), version(v.version)
-{
-}
+SSARegisterOrFlag::SSARegisterOrFlag(const SSARegisterOrFlag& v) : regOrFlag(v.regOrFlag), version(v.version) {}
SSARegisterOrFlag& SSARegisterOrFlag::operator=(const SSARegisterOrFlag& v)
@@ -633,8 +571,8 @@ uint64_t LowLevelILIntegerList::ListIterator::operator*()
}
-LowLevelILIntegerList::LowLevelILIntegerList(LowLevelILFunction* func,
-const BNLowLevelILInstruction& instr, size_t count)
+LowLevelILIntegerList::LowLevelILIntegerList(
+ LowLevelILFunction* func, const BNLowLevelILInstruction& instr, size_t count)
{
m_start.function = func;
#ifdef BINARYNINJACORE_LIBRARY
@@ -695,10 +633,9 @@ size_t LowLevelILIndexList::ListIterator::operator*()
}
-LowLevelILIndexList::LowLevelILIndexList(LowLevelILFunction* func,
- const BNLowLevelILInstruction& instr, size_t count): m_list(func, instr, count)
-{
-}
+LowLevelILIndexList::LowLevelILIndexList(LowLevelILFunction* func, const BNLowLevelILInstruction& instr, size_t count) :
+ m_list(func, instr, count)
+{}
LowLevelILIndexList::const_iterator LowLevelILIndexList::begin() const
@@ -753,10 +690,9 @@ const pair<uint64_t, size_t> LowLevelILIndexMap::ListIterator::operator*()
}
-LowLevelILIndexMap::LowLevelILIndexMap(LowLevelILFunction* func,
- const BNLowLevelILInstruction& instr, size_t count): m_list(func, instr, count & (~1))
-{
-}
+LowLevelILIndexMap::LowLevelILIndexMap(LowLevelILFunction* func, const BNLowLevelILInstruction& instr, size_t count) :
+ m_list(func, instr, count & (~1))
+{}
LowLevelILIndexMap::const_iterator LowLevelILIndexMap::begin() const
@@ -803,16 +739,16 @@ LowLevelILIndexMap::operator map<uint64_t, size_t>() const
const LowLevelILInstruction LowLevelILInstructionList::ListIterator::operator*()
{
- return LowLevelILInstruction(pos.GetFunction(), pos.GetFunction()->GetRawExpr((size_t)*pos),
- (size_t)*pos, instructionIndex);
+ return LowLevelILInstruction(
+ pos.GetFunction(), pos.GetFunction()->GetRawExpr((size_t)*pos), (size_t)*pos, instructionIndex);
}
-LowLevelILInstructionList::LowLevelILInstructionList(LowLevelILFunction* func,
- const BNLowLevelILInstruction& instr, size_t count, size_t instrIndex):
- m_list(func, instr, count), m_instructionIndex(instrIndex)
-{
-}
+LowLevelILInstructionList::LowLevelILInstructionList(
+ LowLevelILFunction* func, const BNLowLevelILInstruction& instr, size_t count, size_t instrIndex) :
+ m_list(func, instr, count),
+ m_instructionIndex(instrIndex)
+{}
LowLevelILInstructionList::const_iterator LowLevelILInstructionList::begin() const
@@ -865,10 +801,10 @@ const RegisterOrFlag LowLevelILRegisterOrFlagList::ListIterator::operator*()
}
-LowLevelILRegisterOrFlagList::LowLevelILRegisterOrFlagList(LowLevelILFunction* func,
- const BNLowLevelILInstruction& instr, size_t count): m_list(func, instr, count)
-{
-}
+LowLevelILRegisterOrFlagList::LowLevelILRegisterOrFlagList(
+ LowLevelILFunction* func, const BNLowLevelILInstruction& instr, size_t count) :
+ m_list(func, instr, count)
+{}
LowLevelILRegisterOrFlagList::const_iterator LowLevelILRegisterOrFlagList::begin() const
@@ -923,10 +859,10 @@ const SSARegister LowLevelILSSARegisterList::ListIterator::operator*()
}
-LowLevelILSSARegisterList::LowLevelILSSARegisterList(LowLevelILFunction* func,
- const BNLowLevelILInstruction& instr, size_t count): m_list(func, instr, count & (~1))
-{
-}
+LowLevelILSSARegisterList::LowLevelILSSARegisterList(
+ LowLevelILFunction* func, const BNLowLevelILInstruction& instr, size_t count) :
+ m_list(func, instr, count & (~1))
+{}
LowLevelILSSARegisterList::const_iterator LowLevelILSSARegisterList::begin() const
@@ -981,10 +917,10 @@ const SSARegisterStack LowLevelILSSARegisterStackList::ListIterator::operator*()
}
-LowLevelILSSARegisterStackList::LowLevelILSSARegisterStackList(LowLevelILFunction* func,
- const BNLowLevelILInstruction& instr, size_t count): m_list(func, instr, count & (~1))
-{
-}
+LowLevelILSSARegisterStackList::LowLevelILSSARegisterStackList(
+ LowLevelILFunction* func, const BNLowLevelILInstruction& instr, size_t count) :
+ m_list(func, instr, count & (~1))
+{}
LowLevelILSSARegisterStackList::const_iterator LowLevelILSSARegisterStackList::begin() const
@@ -1039,10 +975,10 @@ const SSAFlag LowLevelILSSAFlagList::ListIterator::operator*()
}
-LowLevelILSSAFlagList::LowLevelILSSAFlagList(LowLevelILFunction* func,
- const BNLowLevelILInstruction& instr, size_t count): m_list(func, instr, count & (~1))
-{
-}
+LowLevelILSSAFlagList::LowLevelILSSAFlagList(
+ LowLevelILFunction* func, const BNLowLevelILInstruction& instr, size_t count) :
+ m_list(func, instr, count & (~1))
+{}
LowLevelILSSAFlagList::const_iterator LowLevelILSSAFlagList::begin() const
@@ -1097,10 +1033,10 @@ const SSARegisterOrFlag LowLevelILSSARegisterOrFlagList::ListIterator::operator*
}
-LowLevelILSSARegisterOrFlagList::LowLevelILSSARegisterOrFlagList(LowLevelILFunction* func,
- const BNLowLevelILInstruction& instr, size_t count): m_list(func, instr, count & (~1))
-{
-}
+LowLevelILSSARegisterOrFlagList::LowLevelILSSARegisterOrFlagList(
+ LowLevelILFunction* func, const BNLowLevelILInstruction& instr, size_t count) :
+ m_list(func, instr, count & (~1))
+{}
LowLevelILSSARegisterOrFlagList::const_iterator LowLevelILSSARegisterOrFlagList::begin() const
@@ -1145,9 +1081,10 @@ LowLevelILSSARegisterOrFlagList::operator vector<SSARegisterOrFlag>() const
}
-LowLevelILOperand::LowLevelILOperand(const LowLevelILInstruction& instr,
- LowLevelILOperandUsage usage, size_t operandIndex):
- m_instr(instr), m_usage(usage), m_operandIndex(operandIndex)
+LowLevelILOperand::LowLevelILOperand(
+ const LowLevelILInstruction& instr, LowLevelILOperandUsage usage, size_t operandIndex) :
+ m_instr(instr),
+ m_usage(usage), m_operandIndex(operandIndex)
{
auto i = LowLevelILInstructionBase::operandTypeForUsage.find(m_usage);
if (i == LowLevelILInstructionBase::operandTypeForUsage.end())
@@ -1244,8 +1181,8 @@ SSARegister LowLevelILOperand::GetSSARegister() const
{
if (m_type != SSARegisterLowLevelOperand)
throw LowLevelILInstructionAccessException();
- if ((m_usage == HighSSARegisterLowLevelOperandUsage) || (m_usage == LowSSARegisterLowLevelOperandUsage) ||
- (m_usage == StackSSARegisterLowLevelOperandUsage) || (m_usage == TopSSARegisterLowLevelOperandUsage))
+ if ((m_usage == HighSSARegisterLowLevelOperandUsage) || (m_usage == LowSSARegisterLowLevelOperandUsage)
+ || (m_usage == StackSSARegisterLowLevelOperandUsage) || (m_usage == TopSSARegisterLowLevelOperandUsage))
return m_instr.GetRawOperandAsExpr(m_operandIndex).GetRawOperandAsSSARegister(0);
return m_instr.GetRawOperandAsSSARegister(m_operandIndex);
}
@@ -1356,11 +1293,11 @@ const LowLevelILOperand LowLevelILOperandList::ListIterator::operator*()
LowLevelILOperandList::LowLevelILOperandList(const LowLevelILInstruction& instr,
- const vector<LowLevelILOperandUsage>& usageList,
- const unordered_map<LowLevelILOperandUsage, size_t>& operandIndexMap):
- m_instr(instr), m_usageList(usageList), m_operandIndexMap(operandIndexMap)
-{
-}
+ const vector<LowLevelILOperandUsage>& usageList,
+ const unordered_map<LowLevelILOperandUsage, size_t>& operandIndexMap) :
+ m_instr(instr),
+ m_usageList(usageList), m_operandIndexMap(operandIndexMap)
+{}
LowLevelILOperandList::const_iterator LowLevelILOperandList::begin() const
@@ -1419,8 +1356,8 @@ LowLevelILInstruction::LowLevelILInstruction()
}
-LowLevelILInstruction::LowLevelILInstruction(LowLevelILFunction* func,
- const BNLowLevelILInstruction& instr, size_t expr, size_t instrIdx)
+LowLevelILInstruction::LowLevelILInstruction(
+ LowLevelILFunction* func, const BNLowLevelILInstruction& instr, size_t expr, size_t instrIdx)
{
operation = instr.operation;
sourceOperand = instr.sourceOperand;
@@ -1492,7 +1429,8 @@ BNLowLevelILFlagCondition LowLevelILInstructionBase::GetRawOperandAsFlagConditio
LowLevelILInstruction LowLevelILInstructionBase::GetRawOperandAsExpr(size_t operand) const
{
- return LowLevelILInstruction(function, function->GetRawExpr(operands[operand]), operands[operand], instructionIndex);
+ return LowLevelILInstruction(
+ function, function->GetRawExpr(operands[operand]), operands[operand], instructionIndex);
}
@@ -1534,8 +1472,8 @@ LowLevelILIndexMap LowLevelILInstructionBase::GetRawOperandAsIndexMap(size_t ope
LowLevelILInstructionList LowLevelILInstructionBase::GetRawOperandAsExprList(size_t operand) const
{
- return LowLevelILInstructionList(function, function->GetRawExpr(operands[operand + 1]), operands[operand],
- instructionIndex);
+ return LowLevelILInstructionList(
+ function, function->GetRawExpr(operands[operand + 1]), operands[operand], instructionIndex);
}
@@ -1573,7 +1511,7 @@ map<uint32_t, int32_t> LowLevelILInstructionBase::GetRawOperandAsRegisterStackAd
{
LowLevelILIntegerList list(function, function->GetRawExpr(operands[operand + 1]), operands[operand]);
map<uint32_t, int32_t> result;
- for (auto i = list.begin(); i != list.end(); )
+ for (auto i = list.begin(); i != list.end();)
{
uint32_t regStack = (uint32_t)*i;
++i;
@@ -1601,8 +1539,8 @@ void LowLevelILInstructionBase::UpdateRawOperandAsSSARegisterList(size_t operand
}
-void LowLevelILInstructionBase::UpdateRawOperandAsSSARegisterOrFlagList(size_t operandIndex,
- const vector<SSARegisterOrFlag>& outputs)
+void LowLevelILInstructionBase::UpdateRawOperandAsSSARegisterOrFlagList(
+ size_t operandIndex, const vector<SSARegisterOrFlag>& outputs)
{
UpdateRawOperand(operandIndex, outputs.size() * 2);
UpdateRawOperand(operandIndex + 1, function->AddSSARegisterOrFlagList(outputs));
@@ -2004,14 +1942,12 @@ void LowLevelILInstruction::VisitExprs(const std::function<bool(const LowLevelIL
ExprId LowLevelILInstruction::CopyTo(LowLevelILFunction* dest) const
{
- return CopyTo(dest, [&](const LowLevelILInstruction& subExpr) {
- return subExpr.CopyTo(dest);
- });
+ return CopyTo(dest, [&](const LowLevelILInstruction& subExpr) { return subExpr.CopyTo(dest); });
}
-ExprId LowLevelILInstruction::CopyTo(LowLevelILFunction* dest,
- const std::function<ExprId(const LowLevelILInstruction& subExpr)>& subExprHandler) const
+ExprId LowLevelILInstruction::CopyTo(
+ LowLevelILFunction* dest, const std::function<ExprId(const LowLevelILInstruction& subExpr)>& subExprHandler) const
{
vector<ExprId> params;
BNLowLevelILLabel* labelA;
@@ -2021,99 +1957,99 @@ ExprId LowLevelILInstruction::CopyTo(LowLevelILFunction* dest,
case LLIL_NOP:
return dest->Nop();
case LLIL_SET_REG:
- return dest->SetRegister(size, GetDestRegister<LLIL_SET_REG>(),
- subExprHandler(GetSourceExpr<LLIL_SET_REG>()), flags, *this);
+ return dest->SetRegister(
+ size, GetDestRegister<LLIL_SET_REG>(), subExprHandler(GetSourceExpr<LLIL_SET_REG>()), flags, *this);
case LLIL_SET_REG_SPLIT:
return dest->SetRegisterSplit(size, GetHighRegister<LLIL_SET_REG_SPLIT>(), GetLowRegister<LLIL_SET_REG_SPLIT>(),
- subExprHandler(GetSourceExpr<LLIL_SET_REG_SPLIT>()), flags, *this);
+ subExprHandler(GetSourceExpr<LLIL_SET_REG_SPLIT>()), flags, *this);
case LLIL_SET_REG_SSA:
- return dest->SetRegisterSSA(size, GetDestSSARegister<LLIL_SET_REG_SSA>(),
- subExprHandler(GetSourceExpr<LLIL_SET_REG_SSA>()), *this);
+ return dest->SetRegisterSSA(
+ size, GetDestSSARegister<LLIL_SET_REG_SSA>(), subExprHandler(GetSourceExpr<LLIL_SET_REG_SSA>()), *this);
case LLIL_SET_REG_SSA_PARTIAL:
return dest->SetRegisterSSAPartial(size, GetDestSSARegister<LLIL_SET_REG_SSA_PARTIAL>(),
- GetPartialRegister<LLIL_SET_REG_SSA_PARTIAL>(),
- subExprHandler(GetSourceExpr<LLIL_SET_REG_SSA_PARTIAL>()), *this);
+ GetPartialRegister<LLIL_SET_REG_SSA_PARTIAL>(), subExprHandler(GetSourceExpr<LLIL_SET_REG_SSA_PARTIAL>()),
+ *this);
case LLIL_SET_REG_SPLIT_SSA:
return dest->SetRegisterSplitSSA(size, GetHighSSARegister<LLIL_SET_REG_SPLIT_SSA>(),
- GetLowSSARegister<LLIL_SET_REG_SPLIT_SSA>(),
- subExprHandler(GetSourceExpr<LLIL_SET_REG_SPLIT_SSA>()), *this);
+ GetLowSSARegister<LLIL_SET_REG_SPLIT_SSA>(), subExprHandler(GetSourceExpr<LLIL_SET_REG_SPLIT_SSA>()),
+ *this);
case LLIL_SET_REG_STACK_REL:
return dest->SetRegisterStackTopRelative(size, GetDestRegisterStack<LLIL_SET_REG_STACK_REL>(),
- subExprHandler(GetDestExpr<LLIL_SET_REG_STACK_REL>()),
- subExprHandler(GetSourceExpr<LLIL_SET_REG_STACK_REL>()), flags, *this);
+ subExprHandler(GetDestExpr<LLIL_SET_REG_STACK_REL>()),
+ subExprHandler(GetSourceExpr<LLIL_SET_REG_STACK_REL>()), flags, *this);
case LLIL_REG_STACK_PUSH:
return dest->RegisterStackPush(size, GetDestRegisterStack<LLIL_REG_STACK_PUSH>(),
- subExprHandler(GetSourceExpr<LLIL_REG_STACK_PUSH>()), flags, *this);
+ subExprHandler(GetSourceExpr<LLIL_REG_STACK_PUSH>()), flags, *this);
case LLIL_SET_REG_STACK_REL_SSA:
- return dest->SetRegisterStackTopRelativeSSA(size, GetDestSSARegisterStack<LLIL_SET_REG_STACK_REL_SSA>().regStack,
- GetDestSSARegisterStack<LLIL_SET_REG_STACK_REL_SSA>().version,
- GetSourceSSARegisterStack<LLIL_SET_REG_STACK_REL_SSA>().version,
- subExprHandler(GetDestExpr<LLIL_SET_REG_STACK_REL_SSA>()), GetTopSSARegister<LLIL_SET_REG_STACK_REL_SSA>(),
- subExprHandler(GetSourceExpr<LLIL_SET_REG_STACK_REL_SSA>()), *this);
+ return dest->SetRegisterStackTopRelativeSSA(size,
+ GetDestSSARegisterStack<LLIL_SET_REG_STACK_REL_SSA>().regStack,
+ GetDestSSARegisterStack<LLIL_SET_REG_STACK_REL_SSA>().version,
+ GetSourceSSARegisterStack<LLIL_SET_REG_STACK_REL_SSA>().version,
+ subExprHandler(GetDestExpr<LLIL_SET_REG_STACK_REL_SSA>()), GetTopSSARegister<LLIL_SET_REG_STACK_REL_SSA>(),
+ subExprHandler(GetSourceExpr<LLIL_SET_REG_STACK_REL_SSA>()), *this);
case LLIL_SET_REG_STACK_ABS_SSA:
return dest->SetRegisterStackAbsoluteSSA(size, GetDestSSARegisterStack<LLIL_SET_REG_STACK_ABS_SSA>().regStack,
- GetDestSSARegisterStack<LLIL_SET_REG_STACK_ABS_SSA>().version,
- GetSourceSSARegisterStack<LLIL_SET_REG_STACK_ABS_SSA>().version,
- GetDestRegister<LLIL_SET_REG_STACK_ABS_SSA>(),
- subExprHandler(GetSourceExpr<LLIL_SET_REG_STACK_ABS_SSA>()), *this);
+ GetDestSSARegisterStack<LLIL_SET_REG_STACK_ABS_SSA>().version,
+ GetSourceSSARegisterStack<LLIL_SET_REG_STACK_ABS_SSA>().version,
+ GetDestRegister<LLIL_SET_REG_STACK_ABS_SSA>(), subExprHandler(GetSourceExpr<LLIL_SET_REG_STACK_ABS_SSA>()),
+ *this);
case LLIL_SET_FLAG:
return dest->SetFlag(GetDestFlag<LLIL_SET_FLAG>(), subExprHandler(GetSourceExpr<LLIL_SET_FLAG>()), *this);
case LLIL_SET_FLAG_SSA:
- return dest->SetFlagSSA(GetDestSSAFlag<LLIL_SET_FLAG_SSA>(),
- subExprHandler(GetSourceExpr<LLIL_SET_FLAG_SSA>()), *this);
+ return dest->SetFlagSSA(
+ GetDestSSAFlag<LLIL_SET_FLAG_SSA>(), subExprHandler(GetSourceExpr<LLIL_SET_FLAG_SSA>()), *this);
case LLIL_LOAD:
return dest->Load(size, subExprHandler(GetSourceExpr<LLIL_LOAD>()), flags, *this);
case LLIL_LOAD_SSA:
- return dest->LoadSSA(size, subExprHandler(GetSourceExpr<LLIL_LOAD_SSA>()),
- GetSourceMemoryVersion<LLIL_LOAD_SSA>(), *this);
+ return dest->LoadSSA(
+ size, subExprHandler(GetSourceExpr<LLIL_LOAD_SSA>()), GetSourceMemoryVersion<LLIL_LOAD_SSA>(), *this);
case LLIL_STORE:
- return dest->Store(size, subExprHandler(GetDestExpr<LLIL_STORE>()),
- subExprHandler(GetSourceExpr<LLIL_STORE>()), flags, *this);
+ return dest->Store(
+ size, subExprHandler(GetDestExpr<LLIL_STORE>()), subExprHandler(GetSourceExpr<LLIL_STORE>()), flags, *this);
case LLIL_STORE_SSA:
return dest->StoreSSA(size, subExprHandler(GetDestExpr<LLIL_STORE_SSA>()),
- subExprHandler(GetSourceExpr<LLIL_STORE_SSA>()),
- GetDestMemoryVersion<LLIL_STORE_SSA>(), GetSourceMemoryVersion<LLIL_STORE_SSA>(), *this);
+ subExprHandler(GetSourceExpr<LLIL_STORE_SSA>()), GetDestMemoryVersion<LLIL_STORE_SSA>(),
+ GetSourceMemoryVersion<LLIL_STORE_SSA>(), *this);
case LLIL_REG:
return dest->Register(size, GetSourceRegister<LLIL_REG>(), *this);
case LLIL_REG_SSA:
return dest->RegisterSSA(size, GetSourceSSARegister<LLIL_REG_SSA>(), *this);
case LLIL_REG_SSA_PARTIAL:
- return dest->RegisterSSAPartial(size, GetSourceSSARegister<LLIL_REG_SSA_PARTIAL>(),
- GetPartialRegister<LLIL_REG_SSA_PARTIAL>(), *this);
+ return dest->RegisterSSAPartial(
+ size, GetSourceSSARegister<LLIL_REG_SSA_PARTIAL>(), GetPartialRegister<LLIL_REG_SSA_PARTIAL>(), *this);
case LLIL_REG_SPLIT:
- return dest->RegisterSplit(size, GetHighRegister<LLIL_REG_SPLIT>(),
- GetLowRegister<LLIL_REG_SPLIT>(), *this);
+ return dest->RegisterSplit(size, GetHighRegister<LLIL_REG_SPLIT>(), GetLowRegister<LLIL_REG_SPLIT>(), *this);
case LLIL_REG_SPLIT_SSA:
- return dest->RegisterSplitSSA(size, GetHighSSARegister<LLIL_REG_SPLIT_SSA>(),
- GetLowSSARegister<LLIL_REG_SPLIT_SSA>(), *this);
+ return dest->RegisterSplitSSA(
+ size, GetHighSSARegister<LLIL_REG_SPLIT_SSA>(), GetLowSSARegister<LLIL_REG_SPLIT_SSA>(), *this);
case LLIL_REG_STACK_REL:
return dest->RegisterStackTopRelative(size, GetSourceRegisterStack<LLIL_REG_STACK_REL>(),
- subExprHandler(GetSourceExpr<LLIL_REG_STACK_REL>()), *this);
+ subExprHandler(GetSourceExpr<LLIL_REG_STACK_REL>()), *this);
case LLIL_REG_STACK_POP:
return dest->RegisterStackPop(size, GetSourceRegisterStack<LLIL_REG_STACK_POP>(), flags, *this);
case LLIL_REG_STACK_FREE_REG:
return dest->RegisterStackFreeReg(GetDestRegister<LLIL_REG_STACK_FREE_REG>(), *this);
case LLIL_REG_STACK_FREE_REL:
return dest->RegisterStackFreeTopRelative(GetDestRegisterStack<LLIL_REG_STACK_FREE_REL>(),
- subExprHandler(GetDestExpr<LLIL_REG_STACK_FREE_REL>()), *this);
+ subExprHandler(GetDestExpr<LLIL_REG_STACK_FREE_REL>()), *this);
case LLIL_REG_STACK_REL_SSA:
return dest->RegisterStackTopRelativeSSA(size, GetSourceSSARegisterStack<LLIL_REG_STACK_REL_SSA>(),
- subExprHandler(GetSourceExpr<LLIL_REG_STACK_REL_SSA>()),
- GetTopSSARegister<LLIL_REG_STACK_REL_SSA>(), *this);
+ subExprHandler(GetSourceExpr<LLIL_REG_STACK_REL_SSA>()), GetTopSSARegister<LLIL_REG_STACK_REL_SSA>(),
+ *this);
case LLIL_REG_STACK_ABS_SSA:
return dest->RegisterStackAbsoluteSSA(size, GetSourceSSARegisterStack<LLIL_REG_STACK_ABS_SSA>(),
- GetSourceRegister<LLIL_REG_STACK_ABS_SSA>(), *this);
+ GetSourceRegister<LLIL_REG_STACK_ABS_SSA>(), *this);
case LLIL_REG_STACK_FREE_REL_SSA:
return dest->RegisterStackFreeTopRelativeSSA(GetDestSSARegisterStack<LLIL_REG_STACK_FREE_REL_SSA>().regStack,
- GetDestSSARegisterStack<LLIL_REG_STACK_FREE_REL_SSA>().version,
- GetSourceSSARegisterStack<LLIL_REG_STACK_FREE_REL_SSA>().version,
- subExprHandler(GetDestExpr<LLIL_REG_STACK_FREE_REL_SSA>()),
- GetTopSSARegister<LLIL_REG_STACK_FREE_REL_SSA>(), *this);
+ GetDestSSARegisterStack<LLIL_REG_STACK_FREE_REL_SSA>().version,
+ GetSourceSSARegisterStack<LLIL_REG_STACK_FREE_REL_SSA>().version,
+ subExprHandler(GetDestExpr<LLIL_REG_STACK_FREE_REL_SSA>()),
+ GetTopSSARegister<LLIL_REG_STACK_FREE_REL_SSA>(), *this);
case LLIL_REG_STACK_FREE_ABS_SSA:
return dest->RegisterStackFreeAbsoluteSSA(GetDestSSARegisterStack<LLIL_REG_STACK_FREE_ABS_SSA>().regStack,
- GetDestSSARegisterStack<LLIL_REG_STACK_FREE_ABS_SSA>().version,
- GetSourceSSARegisterStack<LLIL_REG_STACK_FREE_ABS_SSA>().version,
- GetDestRegister<LLIL_REG_STACK_FREE_ABS_SSA>(), *this);
+ GetDestSSARegisterStack<LLIL_REG_STACK_FREE_ABS_SSA>().version,
+ GetSourceSSARegisterStack<LLIL_REG_STACK_FREE_ABS_SSA>().version,
+ GetDestRegister<LLIL_REG_STACK_FREE_ABS_SSA>(), *this);
case LLIL_FLAG:
return dest->Flag(GetSourceFlag<LLIL_FLAG>(), *this);
case LLIL_FLAG_SSA:
@@ -2128,29 +2064,30 @@ ExprId LowLevelILInstruction::CopyTo(LowLevelILFunction* dest,
return dest->Call(subExprHandler(GetDestExpr<LLIL_CALL>()), *this);
case LLIL_CALL_STACK_ADJUST:
return dest->CallStackAdjust(subExprHandler(GetDestExpr<LLIL_CALL_STACK_ADJUST>()),
- GetStackAdjustment<LLIL_CALL_STACK_ADJUST>(), GetRegisterStackAdjustments<LLIL_CALL_STACK_ADJUST>(), *this);
+ GetStackAdjustment<LLIL_CALL_STACK_ADJUST>(), GetRegisterStackAdjustments<LLIL_CALL_STACK_ADJUST>(), *this);
case LLIL_TAILCALL:
return dest->TailCall(subExprHandler(GetDestExpr<LLIL_TAILCALL>()), *this);
case LLIL_RET:
return dest->Return(subExprHandler(GetDestExpr<LLIL_RET>()), *this);
case LLIL_JUMP_TO:
+ {
+ map<uint64_t, BNLowLevelILLabel*> labelList;
+ for (auto target : GetTargets<LLIL_JUMP_TO>())
{
- map<uint64_t, BNLowLevelILLabel*> labelList;
- for (auto target : GetTargets<LLIL_JUMP_TO>())
- {
- labelA = dest->GetLabelForSourceInstruction(target.second);
- if (!labelA)
- return dest->Jump(subExprHandler(GetDestExpr<LLIL_JUMP_TO>()), *this);
- labelList[target.first] = labelA;
- }
- return dest->JumpTo(subExprHandler(GetDestExpr<LLIL_JUMP_TO>()), labelList, *this);
+ labelA = dest->GetLabelForSourceInstruction(target.second);
+ if (!labelA)
+ return dest->Jump(subExprHandler(GetDestExpr<LLIL_JUMP_TO>()), *this);
+ labelList[target.first] = labelA;
}
+ return dest->JumpTo(subExprHandler(GetDestExpr<LLIL_JUMP_TO>()), labelList, *this);
+ }
case LLIL_GOTO:
labelA = dest->GetLabelForSourceInstruction(GetTarget<LLIL_GOTO>());
if (!labelA)
{
return dest->Jump(dest->ConstPointer(function->GetArchitecture()->GetAddressSize(),
- function->GetInstruction(GetTarget<LLIL_GOTO>()).address), *this);
+ function->GetInstruction(GetTarget<LLIL_GOTO>()).address),
+ *this);
}
return dest->Goto(*labelA, *this);
case LLIL_IF:
@@ -2169,25 +2106,25 @@ ExprId LowLevelILInstruction::CopyTo(LowLevelILFunction* dest,
for (auto i : GetParameterExprs<LLIL_CALL_SSA>())
params.push_back(subExprHandler(i));
return dest->CallSSA(GetOutputSSARegisters<LLIL_CALL_SSA>(), subExprHandler(GetDestExpr<LLIL_CALL_SSA>()),
- params, GetStackSSARegister<LLIL_CALL_SSA>(), GetDestMemoryVersion<LLIL_CALL_SSA>(),
- GetSourceMemoryVersion<LLIL_CALL_SSA>(), *this);
+ params, GetStackSSARegister<LLIL_CALL_SSA>(), GetDestMemoryVersion<LLIL_CALL_SSA>(),
+ GetSourceMemoryVersion<LLIL_CALL_SSA>(), *this);
case LLIL_SYSCALL_SSA:
for (auto i : GetParameterExprs<LLIL_SYSCALL_SSA>())
params.push_back(subExprHandler(i));
- return dest->SystemCallSSA(GetOutputSSARegisters<LLIL_SYSCALL_SSA>(),
- params, GetStackSSARegister<LLIL_SYSCALL_SSA>(), GetDestMemoryVersion<LLIL_SYSCALL_SSA>(),
- GetSourceMemoryVersion<LLIL_SYSCALL_SSA>(), *this);
+ return dest->SystemCallSSA(GetOutputSSARegisters<LLIL_SYSCALL_SSA>(), params,
+ GetStackSSARegister<LLIL_SYSCALL_SSA>(), GetDestMemoryVersion<LLIL_SYSCALL_SSA>(),
+ GetSourceMemoryVersion<LLIL_SYSCALL_SSA>(), *this);
case LLIL_TAILCALL_SSA:
for (auto i : GetParameterExprs<LLIL_TAILCALL_SSA>())
params.push_back(subExprHandler(i));
- return dest->TailCallSSA(GetOutputSSARegisters<LLIL_TAILCALL_SSA>(), subExprHandler(GetDestExpr<LLIL_TAILCALL_SSA>()),
- params, GetStackSSARegister<LLIL_TAILCALL_SSA>(), GetDestMemoryVersion<LLIL_TAILCALL_SSA>(),
- GetSourceMemoryVersion<LLIL_TAILCALL_SSA>(), *this);
+ return dest->TailCallSSA(GetOutputSSARegisters<LLIL_TAILCALL_SSA>(),
+ subExprHandler(GetDestExpr<LLIL_TAILCALL_SSA>()), params, GetStackSSARegister<LLIL_TAILCALL_SSA>(),
+ GetDestMemoryVersion<LLIL_TAILCALL_SSA>(), GetSourceMemoryVersion<LLIL_TAILCALL_SSA>(), *this);
case LLIL_REG_PHI:
return dest->RegisterPhi(GetDestSSARegister<LLIL_REG_PHI>(), GetSourceSSARegisters<LLIL_REG_PHI>(), *this);
case LLIL_REG_STACK_PHI:
- return dest->RegisterStackPhi(GetDestSSARegisterStack<LLIL_REG_STACK_PHI>(),
- GetSourceSSARegisterStacks<LLIL_REG_STACK_PHI>(), *this);
+ return dest->RegisterStackPhi(
+ GetDestSSARegisterStack<LLIL_REG_STACK_PHI>(), GetSourceSSARegisterStacks<LLIL_REG_STACK_PHI>(), *this);
case LLIL_FLAG_PHI:
return dest->FlagPhi(GetDestSSAFlag<LLIL_FLAG_PHI>(), GetSourceSSAFlags<LLIL_FLAG_PHI>(), *this);
case LLIL_MEM_PHI:
@@ -2225,8 +2162,7 @@ ExprId LowLevelILInstruction::CopyTo(LowLevelILFunction* dest,
case LLIL_FLOOR:
case LLIL_CEIL:
case LLIL_FTRUNC:
- return dest->AddExprWithLocation(operation, *this, size, flags,
- subExprHandler(AsOneOperand().GetSourceExpr()));
+ return dest->AddExprWithLocation(operation, *this, size, flags, subExprHandler(AsOneOperand().GetSourceExpr()));
case LLIL_ADD:
case LLIL_SUB:
case LLIL_AND:
@@ -2272,26 +2208,26 @@ ExprId LowLevelILInstruction::CopyTo(LowLevelILFunction* dest,
case LLIL_FCMP_GT:
case LLIL_FCMP_O:
case LLIL_FCMP_UO:
- return dest->AddExprWithLocation(operation, *this, size, flags,
- subExprHandler(AsTwoOperand().GetLeftExpr()), subExprHandler(AsTwoOperand().GetRightExpr()));
+ return dest->AddExprWithLocation(operation, *this, size, flags, subExprHandler(AsTwoOperand().GetLeftExpr()),
+ subExprHandler(AsTwoOperand().GetRightExpr()));
case LLIL_ADC:
case LLIL_SBB:
case LLIL_RLC:
case LLIL_RRC:
return dest->AddExprWithLocation(operation, *this, size, flags,
- subExprHandler(AsTwoOperandWithCarry().GetLeftExpr()),
- subExprHandler(AsTwoOperandWithCarry().GetRightExpr()),
- subExprHandler(AsTwoOperandWithCarry().GetCarryExpr()));
+ subExprHandler(AsTwoOperandWithCarry().GetLeftExpr()),
+ subExprHandler(AsTwoOperandWithCarry().GetRightExpr()),
+ subExprHandler(AsTwoOperandWithCarry().GetCarryExpr()));
case LLIL_INTRINSIC:
for (auto i : GetParameterExprs<LLIL_INTRINSIC>())
params.push_back(subExprHandler(i));
- return dest->Intrinsic(GetOutputRegisterOrFlagList<LLIL_INTRINSIC>(), GetIntrinsic<LLIL_INTRINSIC>(),
- params, flags, *this);
+ return dest->Intrinsic(
+ GetOutputRegisterOrFlagList<LLIL_INTRINSIC>(), GetIntrinsic<LLIL_INTRINSIC>(), params, flags, *this);
case LLIL_INTRINSIC_SSA:
for (auto i : GetParameterExprs<LLIL_INTRINSIC_SSA>())
params.push_back(subExprHandler(i));
- return dest->IntrinsicSSA(GetOutputSSARegisterOrFlagList<LLIL_INTRINSIC_SSA>(), GetIntrinsic<LLIL_INTRINSIC_SSA>(),
- params, *this);
+ return dest->IntrinsicSSA(
+ GetOutputSSARegisterOrFlagList<LLIL_INTRINSIC_SSA>(), GetIntrinsic<LLIL_INTRINSIC_SSA>(), params, *this);
default:
throw LowLevelILInstructionAccessException();
}
@@ -2764,73 +2700,70 @@ ExprId LowLevelILFunction::Nop(const ILSourceLocation& loc)
}
-ExprId LowLevelILFunction::SetRegister(size_t size, uint32_t reg, ExprId val, uint32_t flags,
- const ILSourceLocation& loc)
+ExprId LowLevelILFunction::SetRegister(
+ size_t size, uint32_t reg, ExprId val, uint32_t flags, const ILSourceLocation& loc)
{
return AddExprWithLocation(LLIL_SET_REG, loc, size, flags, reg, val);
}
-ExprId LowLevelILFunction::SetRegisterSplit(size_t size, uint32_t high, uint32_t low, ExprId val, uint32_t flags,
- const ILSourceLocation& loc)
+ExprId LowLevelILFunction::SetRegisterSplit(
+ size_t size, uint32_t high, uint32_t low, ExprId val, uint32_t flags, const ILSourceLocation& loc)
{
return AddExprWithLocation(LLIL_SET_REG_SPLIT, loc, size, flags, high, low, val);
}
-ExprId LowLevelILFunction::SetRegisterSSA(size_t size, const SSARegister& reg, ExprId val,
- const ILSourceLocation& loc)
+ExprId LowLevelILFunction::SetRegisterSSA(size_t size, const SSARegister& reg, ExprId val, const ILSourceLocation& loc)
{
return AddExprWithLocation(LLIL_SET_REG_SSA, loc, size, 0, reg.reg, reg.version, val);
}
-ExprId LowLevelILFunction::SetRegisterSSAPartial(size_t size, const SSARegister& fullReg, uint32_t partialReg,
- ExprId val, const ILSourceLocation& loc)
+ExprId LowLevelILFunction::SetRegisterSSAPartial(
+ size_t size, const SSARegister& fullReg, uint32_t partialReg, ExprId val, const ILSourceLocation& loc)
{
return AddExprWithLocation(LLIL_SET_REG_SSA_PARTIAL, loc, size, 0, fullReg.reg, fullReg.version, partialReg, val);
}
-ExprId LowLevelILFunction::SetRegisterSplitSSA(size_t size, const SSARegister& high, const SSARegister& low,
- ExprId val, const ILSourceLocation& loc)
+ExprId LowLevelILFunction::SetRegisterSplitSSA(
+ size_t size, const SSARegister& high, const SSARegister& low, ExprId val, const ILSourceLocation& loc)
{
return AddExprWithLocation(LLIL_SET_REG_SPLIT_SSA, loc, size, 0,
- AddExprWithLocation(LLIL_REG_SPLIT_DEST_SSA, loc, size, 0, high.reg, high.version),
- AddExprWithLocation(LLIL_REG_SPLIT_DEST_SSA, loc, size, 0, low.reg, low.version), val);
+ AddExprWithLocation(LLIL_REG_SPLIT_DEST_SSA, loc, size, 0, high.reg, high.version),
+ AddExprWithLocation(LLIL_REG_SPLIT_DEST_SSA, loc, size, 0, low.reg, low.version), val);
}
-ExprId LowLevelILFunction::SetRegisterStackTopRelative(size_t size, uint32_t regStack, ExprId entry,
- ExprId val, uint32_t flags, const ILSourceLocation& loc)
+ExprId LowLevelILFunction::SetRegisterStackTopRelative(
+ size_t size, uint32_t regStack, ExprId entry, ExprId val, uint32_t flags, const ILSourceLocation& loc)
{
return AddExprWithLocation(LLIL_SET_REG_STACK_REL, loc, size, flags, regStack, entry, val);
}
-ExprId LowLevelILFunction::RegisterStackPush(size_t size, uint32_t regStack, ExprId val,
- uint32_t flags, const ILSourceLocation& loc)
+ExprId LowLevelILFunction::RegisterStackPush(
+ size_t size, uint32_t regStack, ExprId val, uint32_t flags, const ILSourceLocation& loc)
{
return AddExprWithLocation(LLIL_REG_STACK_PUSH, loc, size, flags, regStack, val);
}
-ExprId LowLevelILFunction::SetRegisterStackTopRelativeSSA(size_t size, uint32_t regStack,
- size_t destVersion, size_t srcVersion, ExprId entry, const SSARegister& top,
- ExprId val, const ILSourceLocation& loc)
+ExprId LowLevelILFunction::SetRegisterStackTopRelativeSSA(size_t size, uint32_t regStack, size_t destVersion,
+ size_t srcVersion, ExprId entry, const SSARegister& top, ExprId val, const ILSourceLocation& loc)
{
return AddExprWithLocation(LLIL_SET_REG_STACK_REL_SSA, loc, size, 0,
- AddExprWithLocation(LLIL_REG_STACK_DEST_SSA, loc, size, 0, regStack, destVersion, srcVersion),
- entry, AddExprWithLocation(LLIL_REG_SSA, loc, 0, 0, top.reg, top.version), val);
+ AddExprWithLocation(LLIL_REG_STACK_DEST_SSA, loc, size, 0, regStack, destVersion, srcVersion), entry,
+ AddExprWithLocation(LLIL_REG_SSA, loc, 0, 0, top.reg, top.version), val);
}
-ExprId LowLevelILFunction::SetRegisterStackAbsoluteSSA(size_t size, uint32_t regStack,
- size_t destVersion, size_t srcVersion, uint32_t reg, ExprId val, const ILSourceLocation& loc)
+ExprId LowLevelILFunction::SetRegisterStackAbsoluteSSA(size_t size, uint32_t regStack, size_t destVersion,
+ size_t srcVersion, uint32_t reg, ExprId val, const ILSourceLocation& loc)
{
return AddExprWithLocation(LLIL_SET_REG_STACK_ABS_SSA, loc, size, 0,
- AddExprWithLocation(LLIL_REG_STACK_DEST_SSA, loc, size, 0, regStack, destVersion, srcVersion),
- reg, val);
+ AddExprWithLocation(LLIL_REG_STACK_DEST_SSA, loc, size, 0, regStack, destVersion, srcVersion), reg, val);
}
@@ -2852,22 +2785,20 @@ ExprId LowLevelILFunction::Load(size_t size, ExprId addr, uint32_t flags, const
}
-ExprId LowLevelILFunction::LoadSSA(size_t size, ExprId addr, size_t sourceMemoryVer,
- const ILSourceLocation& loc)
+ExprId LowLevelILFunction::LoadSSA(size_t size, ExprId addr, size_t sourceMemoryVer, const ILSourceLocation& loc)
{
return AddExprWithLocation(LLIL_LOAD_SSA, loc, size, 0, addr, sourceMemoryVer);
}
-ExprId LowLevelILFunction::Store(size_t size, ExprId addr, ExprId val, uint32_t flags,
- const ILSourceLocation& loc)
+ExprId LowLevelILFunction::Store(size_t size, ExprId addr, ExprId val, uint32_t flags, const ILSourceLocation& loc)
{
return AddExprWithLocation(LLIL_STORE, loc, size, flags, addr, val);
}
-ExprId LowLevelILFunction::StoreSSA(size_t size, ExprId addr, ExprId val, size_t newMemoryVer, size_t prevMemoryVer,
- const ILSourceLocation& loc)
+ExprId LowLevelILFunction::StoreSSA(
+ size_t size, ExprId addr, ExprId val, size_t newMemoryVer, size_t prevMemoryVer, const ILSourceLocation& loc)
{
return AddExprWithLocation(LLIL_STORE_SSA, loc, size, 0, addr, newMemoryVer, prevMemoryVer, val);
}
@@ -2891,15 +2822,14 @@ ExprId LowLevelILFunction::Register(size_t size, uint32_t reg, const ILSourceLoc
}
-ExprId LowLevelILFunction::RegisterSSA(size_t size, const SSARegister& reg,
- const ILSourceLocation& loc)
+ExprId LowLevelILFunction::RegisterSSA(size_t size, const SSARegister& reg, const ILSourceLocation& loc)
{
return AddExprWithLocation(LLIL_REG_SSA, loc, size, 0, reg.reg, reg.version);
}
-ExprId LowLevelILFunction::RegisterSSAPartial(size_t size, const SSARegister& fullReg, uint32_t partialReg,
- const ILSourceLocation& loc)
+ExprId LowLevelILFunction::RegisterSSAPartial(
+ size_t size, const SSARegister& fullReg, uint32_t partialReg, const ILSourceLocation& loc)
{
return AddExprWithLocation(LLIL_REG_SSA_PARTIAL, loc, size, 0, fullReg.reg, fullReg.version, partialReg);
}
@@ -2911,15 +2841,15 @@ ExprId LowLevelILFunction::RegisterSplit(size_t size, uint32_t high, uint32_t lo
}
-ExprId LowLevelILFunction::RegisterSplitSSA(size_t size, const SSARegister& high, const SSARegister& low,
- const ILSourceLocation& loc)
+ExprId LowLevelILFunction::RegisterSplitSSA(
+ size_t size, const SSARegister& high, const SSARegister& low, const ILSourceLocation& loc)
{
return AddExprWithLocation(LLIL_REG_SPLIT_SSA, loc, size, 0, high.reg, high.version, low.reg, low.version);
}
-ExprId LowLevelILFunction::RegisterStackTopRelative(size_t size, uint32_t regStack, ExprId entry,
- const ILSourceLocation& loc)
+ExprId LowLevelILFunction::RegisterStackTopRelative(
+ size_t size, uint32_t regStack, ExprId entry, const ILSourceLocation& loc)
{
return AddExprWithLocation(LLIL_REG_STACK_REL, loc, size, 0, regStack, entry);
}
@@ -2943,36 +2873,35 @@ ExprId LowLevelILFunction::RegisterStackFreeTopRelative(uint32_t regStack, ExprI
}
-ExprId LowLevelILFunction::RegisterStackTopRelativeSSA(size_t size, const SSARegisterStack& regStack, ExprId entry,
- const SSARegister& top, const ILSourceLocation& loc)
+ExprId LowLevelILFunction::RegisterStackTopRelativeSSA(
+ size_t size, const SSARegisterStack& regStack, ExprId entry, const SSARegister& top, const ILSourceLocation& loc)
{
return AddExprWithLocation(LLIL_REG_STACK_REL_SSA, loc, size, 0, regStack.regStack, regStack.version, entry,
- AddExprWithLocation(LLIL_REG_SSA, loc, 0, 0, top.reg, top.version));
+ AddExprWithLocation(LLIL_REG_SSA, loc, 0, 0, top.reg, top.version));
}
-ExprId LowLevelILFunction::RegisterStackAbsoluteSSA(size_t size, const SSARegisterStack& regStack, uint32_t reg,
- const ILSourceLocation& loc)
+ExprId LowLevelILFunction::RegisterStackAbsoluteSSA(
+ size_t size, const SSARegisterStack& regStack, uint32_t reg, const ILSourceLocation& loc)
{
return AddExprWithLocation(LLIL_REG_STACK_ABS_SSA, loc, size, 0, regStack.regStack, regStack.version, reg);
}
-ExprId LowLevelILFunction::RegisterStackFreeTopRelativeSSA(uint32_t regStack,
- size_t destVersion, size_t srcVersion, ExprId entry, const SSARegister& top,
- const ILSourceLocation& loc)
+ExprId LowLevelILFunction::RegisterStackFreeTopRelativeSSA(uint32_t regStack, size_t destVersion, size_t srcVersion,
+ ExprId entry, const SSARegister& top, const ILSourceLocation& loc)
{
return AddExprWithLocation(LLIL_REG_STACK_FREE_REL_SSA, loc, 0, 0,
- AddExprWithLocation(LLIL_REG_STACK_DEST_SSA, loc, 0, 0, regStack, destVersion, srcVersion),
- entry, AddExprWithLocation(LLIL_REG_SSA, loc, 0, 0, top.reg, top.version));
+ AddExprWithLocation(LLIL_REG_STACK_DEST_SSA, loc, 0, 0, regStack, destVersion, srcVersion), entry,
+ AddExprWithLocation(LLIL_REG_SSA, loc, 0, 0, top.reg, top.version));
}
-ExprId LowLevelILFunction::RegisterStackFreeAbsoluteSSA(uint32_t regStack,
- size_t destVersion, size_t srcVersion, uint32_t reg, const ILSourceLocation& loc)
+ExprId LowLevelILFunction::RegisterStackFreeAbsoluteSSA(
+ uint32_t regStack, size_t destVersion, size_t srcVersion, uint32_t reg, const ILSourceLocation& loc)
{
return AddExprWithLocation(LLIL_REG_STACK_FREE_ABS_SSA, loc, 0, 0,
- AddExprWithLocation(LLIL_REG_STACK_DEST_SSA, loc, 0, 0, regStack, destVersion, srcVersion), reg);
+ AddExprWithLocation(LLIL_REG_STACK_DEST_SSA, loc, 0, 0, regStack, destVersion, srcVersion), reg);
}
@@ -3042,8 +2971,7 @@ ExprId LowLevelILFunction::FlagBit(size_t size, uint32_t flag, size_t bitIndex,
}
-ExprId LowLevelILFunction::FlagBitSSA(size_t size, const SSAFlag& flag, size_t bitIndex,
- const ILSourceLocation& loc)
+ExprId LowLevelILFunction::FlagBitSSA(size_t size, const SSAFlag& flag, size_t bitIndex, const ILSourceLocation& loc)
{
return AddExprWithLocation(LLIL_FLAG_BIT_SSA, loc, size, 0, flag.flag, flag.version, bitIndex);
}
@@ -3055,8 +2983,8 @@ ExprId LowLevelILFunction::Add(size_t size, ExprId a, ExprId b, uint32_t flags,
}
-ExprId LowLevelILFunction::AddCarry(size_t size, ExprId a, ExprId b, ExprId carry, uint32_t flags,
- const ILSourceLocation& loc)
+ExprId LowLevelILFunction::AddCarry(
+ size_t size, ExprId a, ExprId b, ExprId carry, uint32_t flags, const ILSourceLocation& loc)
{
return AddExprWithLocation(LLIL_ADC, loc, size, flags, a, b, carry);
}
@@ -3068,8 +2996,8 @@ ExprId LowLevelILFunction::Sub(size_t size, ExprId a, ExprId b, uint32_t flags,
}
-ExprId LowLevelILFunction::SubBorrow(size_t size, ExprId a, ExprId b, ExprId carry, uint32_t flags,
- const ILSourceLocation& loc)
+ExprId LowLevelILFunction::SubBorrow(
+ size_t size, ExprId a, ExprId b, ExprId carry, uint32_t flags, const ILSourceLocation& loc)
{
return AddExprWithLocation(LLIL_SBB, loc, size, flags, a, b, carry);
}
@@ -3093,22 +3021,20 @@ ExprId LowLevelILFunction::Xor(size_t size, ExprId a, ExprId b, uint32_t flags,
}
-ExprId LowLevelILFunction::ShiftLeft(size_t size, ExprId a, ExprId b, uint32_t flags,
- const ILSourceLocation& loc)
+ExprId LowLevelILFunction::ShiftLeft(size_t size, ExprId a, ExprId b, uint32_t flags, const ILSourceLocation& loc)
{
return AddExprWithLocation(LLIL_LSL, loc, size, flags, a, b);
}
-ExprId LowLevelILFunction::LogicalShiftRight(size_t size, ExprId a, ExprId b, uint32_t flags,
- const ILSourceLocation& loc)
+ExprId LowLevelILFunction::LogicalShiftRight(
+ size_t size, ExprId a, ExprId b, uint32_t flags, const ILSourceLocation& loc)
{
return AddExprWithLocation(LLIL_LSR, loc, size, flags, a, b);
}
-ExprId LowLevelILFunction::ArithShiftRight(size_t size, ExprId a, ExprId b, uint32_t flags,
- const ILSourceLocation& loc)
+ExprId LowLevelILFunction::ArithShiftRight(size_t size, ExprId a, ExprId b, uint32_t flags, const ILSourceLocation& loc)
{
return AddExprWithLocation(LLIL_ASR, loc, size, flags, a, b);
}
@@ -3120,8 +3046,8 @@ ExprId LowLevelILFunction::RotateLeft(size_t size, ExprId a, ExprId b, uint32_t
}
-ExprId LowLevelILFunction::RotateLeftCarry(size_t size, ExprId a, ExprId b, ExprId carry, uint32_t flags,
- const ILSourceLocation& loc)
+ExprId LowLevelILFunction::RotateLeftCarry(
+ size_t size, ExprId a, ExprId b, ExprId carry, uint32_t flags, const ILSourceLocation& loc)
{
return AddExprWithLocation(LLIL_RLC, loc, size, flags, a, b, carry);
}
@@ -3133,8 +3059,8 @@ ExprId LowLevelILFunction::RotateRight(size_t size, ExprId a, ExprId b, uint32_t
}
-ExprId LowLevelILFunction::RotateRightCarry(size_t size, ExprId a, ExprId b, ExprId carry, uint32_t flags,
- const ILSourceLocation& loc)
+ExprId LowLevelILFunction::RotateRightCarry(
+ size_t size, ExprId a, ExprId b, ExprId carry, uint32_t flags, const ILSourceLocation& loc)
{
return AddExprWithLocation(LLIL_RRC, loc, size, flags, a, b, carry);
}
@@ -3146,29 +3072,28 @@ ExprId LowLevelILFunction::Mult(size_t size, ExprId a, ExprId b, uint32_t flags,
}
-ExprId LowLevelILFunction::MultDoublePrecUnsigned(size_t size, ExprId a, ExprId b, uint32_t flags,
- const ILSourceLocation& loc)
+ExprId LowLevelILFunction::MultDoublePrecUnsigned(
+ size_t size, ExprId a, ExprId b, uint32_t flags, const ILSourceLocation& loc)
{
return AddExprWithLocation(LLIL_MULU_DP, loc, size, flags, a, b);
}
-ExprId LowLevelILFunction::MultDoublePrecSigned(size_t size, ExprId a, ExprId b, uint32_t flags,
- const ILSourceLocation& loc)
+ExprId LowLevelILFunction::MultDoublePrecSigned(
+ size_t size, ExprId a, ExprId b, uint32_t flags, const ILSourceLocation& loc)
{
return AddExprWithLocation(LLIL_MULS_DP, loc, size, flags, a, b);
}
-ExprId LowLevelILFunction::DivUnsigned(size_t size, ExprId a, ExprId b, uint32_t flags,
- const ILSourceLocation& loc)
+ExprId LowLevelILFunction::DivUnsigned(size_t size, ExprId a, ExprId b, uint32_t flags, const ILSourceLocation& loc)
{
return AddExprWithLocation(LLIL_DIVU, loc, size, flags, a, b);
}
-ExprId LowLevelILFunction::DivDoublePrecUnsigned(size_t size, ExprId a, ExprId b, uint32_t flags,
- const ILSourceLocation& loc)
+ExprId LowLevelILFunction::DivDoublePrecUnsigned(
+ size_t size, ExprId a, ExprId b, uint32_t flags, const ILSourceLocation& loc)
{
return AddExprWithLocation(LLIL_DIVU_DP, loc, size, flags, a, b);
}
@@ -3180,22 +3105,21 @@ ExprId LowLevelILFunction::DivSigned(size_t size, ExprId a, ExprId b, uint32_t f
}
-ExprId LowLevelILFunction::DivDoublePrecSigned(size_t size, ExprId a, ExprId b, uint32_t flags,
- const ILSourceLocation& loc)
+ExprId LowLevelILFunction::DivDoublePrecSigned(
+ size_t size, ExprId a, ExprId b, uint32_t flags, const ILSourceLocation& loc)
{
return AddExprWithLocation(LLIL_DIVS_DP, loc, size, flags, a, b);
}
-ExprId LowLevelILFunction::ModUnsigned(size_t size, ExprId a, ExprId b, uint32_t flags,
- const ILSourceLocation& loc)
+ExprId LowLevelILFunction::ModUnsigned(size_t size, ExprId a, ExprId b, uint32_t flags, const ILSourceLocation& loc)
{
return AddExprWithLocation(LLIL_MODU, loc, size, flags, a, b);
}
-ExprId LowLevelILFunction::ModDoublePrecUnsigned(size_t size, ExprId a, ExprId b, uint32_t flags,
- const ILSourceLocation& loc)
+ExprId LowLevelILFunction::ModDoublePrecUnsigned(
+ size_t size, ExprId a, ExprId b, uint32_t flags, const ILSourceLocation& loc)
{
return AddExprWithLocation(LLIL_MODU_DP, loc, size, flags, a, b);
}
@@ -3207,8 +3131,8 @@ ExprId LowLevelILFunction::ModSigned(size_t size, ExprId a, ExprId b, uint32_t f
}
-ExprId LowLevelILFunction::ModDoublePrecSigned(size_t size, ExprId a, ExprId b, uint32_t flags,
- const ILSourceLocation& loc)
+ExprId LowLevelILFunction::ModDoublePrecSigned(
+ size_t size, ExprId a, ExprId b, uint32_t flags, const ILSourceLocation& loc)
{
return AddExprWithLocation(LLIL_MODS_DP, loc, size, flags, a, b);
}
@@ -3250,8 +3174,8 @@ ExprId LowLevelILFunction::Jump(ExprId dest, const ILSourceLocation& loc)
}
-ExprId LowLevelILFunction::JumpTo(ExprId dest, const map<uint64_t, BNLowLevelILLabel*>& targets,
- const ILSourceLocation& loc)
+ExprId LowLevelILFunction::JumpTo(
+ ExprId dest, const map<uint64_t, BNLowLevelILLabel*>& targets, const ILSourceLocation& loc)
{
return AddExprWithLocation(LLIL_JUMP_TO, loc, 0, 0, dest, targets.size() * 2, AddLabelMap(targets));
}
@@ -3263,8 +3187,8 @@ ExprId LowLevelILFunction::Call(ExprId dest, const ILSourceLocation& loc)
}
-ExprId LowLevelILFunction::CallStackAdjust(ExprId dest, int64_t adjust,
- const map<uint32_t, int32_t>& regStackAdjust, const ILSourceLocation& loc)
+ExprId LowLevelILFunction::CallStackAdjust(
+ ExprId dest, int64_t adjust, const map<uint32_t, int32_t>& regStackAdjust, const ILSourceLocation& loc)
{
vector<size_t> list;
for (auto& i : regStackAdjust)
@@ -3272,8 +3196,7 @@ ExprId LowLevelILFunction::CallStackAdjust(ExprId dest, int64_t adjust,
list.push_back(i.first);
list.push_back(i.second);
}
- return AddExprWithLocation(LLIL_CALL_STACK_ADJUST, loc, 0, 0, dest, adjust, list.size(),
- AddIndexList(list));
+ return AddExprWithLocation(LLIL_CALL_STACK_ADJUST, loc, 0, 0, dest, adjust, list.size(), AddIndexList(list));
}
@@ -3284,38 +3207,35 @@ ExprId LowLevelILFunction::TailCall(ExprId dest, const ILSourceLocation& loc)
ExprId LowLevelILFunction::CallSSA(const vector<SSARegister>& output, ExprId dest, const vector<ExprId>& params,
- const SSARegister& stack, size_t newMemoryVer, size_t prevMemoryVer, const ILSourceLocation& loc)
+ const SSARegister& stack, size_t newMemoryVer, size_t prevMemoryVer, const ILSourceLocation& loc)
{
return AddExprWithLocation(LLIL_CALL_SSA, loc, 0, 0,
- AddExprWithLocation(LLIL_CALL_OUTPUT_SSA, loc, 0, 0, newMemoryVer,
- output.size() * 2, AddSSARegisterList(output)), dest,
- AddExprWithLocation(LLIL_CALL_STACK_SSA, loc, 0, 0, stack.reg, stack.version, prevMemoryVer),
- AddExprWithLocation(LLIL_CALL_PARAM, loc, 0, 0,
- params.size(), AddOperandList(params)));
+ AddExprWithLocation(
+ LLIL_CALL_OUTPUT_SSA, loc, 0, 0, newMemoryVer, output.size() * 2, AddSSARegisterList(output)),
+ dest, AddExprWithLocation(LLIL_CALL_STACK_SSA, loc, 0, 0, stack.reg, stack.version, prevMemoryVer),
+ AddExprWithLocation(LLIL_CALL_PARAM, loc, 0, 0, params.size(), AddOperandList(params)));
}
ExprId LowLevelILFunction::SystemCallSSA(const vector<SSARegister>& output, const vector<ExprId>& params,
- const SSARegister& stack, size_t newMemoryVer, size_t prevMemoryVer, const ILSourceLocation& loc)
+ const SSARegister& stack, size_t newMemoryVer, size_t prevMemoryVer, const ILSourceLocation& loc)
{
return AddExprWithLocation(LLIL_SYSCALL_SSA, loc, 0, 0,
- AddExprWithLocation(LLIL_CALL_OUTPUT_SSA, loc, 0, 0, newMemoryVer,
- output.size() * 2, AddSSARegisterList(output)),
- AddExprWithLocation(LLIL_CALL_STACK_SSA, loc, 0, 0, stack.reg, stack.version, prevMemoryVer),
- AddExprWithLocation(LLIL_CALL_PARAM, loc, 0, 0,
- params.size(), AddOperandList(params)));
+ AddExprWithLocation(
+ LLIL_CALL_OUTPUT_SSA, loc, 0, 0, newMemoryVer, output.size() * 2, AddSSARegisterList(output)),
+ AddExprWithLocation(LLIL_CALL_STACK_SSA, loc, 0, 0, stack.reg, stack.version, prevMemoryVer),
+ AddExprWithLocation(LLIL_CALL_PARAM, loc, 0, 0, params.size(), AddOperandList(params)));
}
ExprId LowLevelILFunction::TailCallSSA(const vector<SSARegister>& output, ExprId dest, const vector<ExprId>& params,
- const SSARegister& stack, size_t newMemoryVer, size_t prevMemoryVer, const ILSourceLocation& loc)
+ const SSARegister& stack, size_t newMemoryVer, size_t prevMemoryVer, const ILSourceLocation& loc)
{
return AddExprWithLocation(LLIL_TAILCALL_SSA, loc, 0, 0,
- AddExprWithLocation(LLIL_CALL_OUTPUT_SSA, loc, 0, 0, newMemoryVer,
- output.size() * 2, AddSSARegisterList(output)), dest,
- AddExprWithLocation(LLIL_CALL_STACK_SSA, loc, 0, 0, stack.reg, stack.version, prevMemoryVer),
- AddExprWithLocation(LLIL_CALL_PARAM, loc, 0, 0,
- params.size(), AddOperandList(params)));
+ AddExprWithLocation(
+ LLIL_CALL_OUTPUT_SSA, loc, 0, 0, newMemoryVer, output.size() * 2, AddSSARegisterList(output)),
+ dest, AddExprWithLocation(LLIL_CALL_STACK_SSA, loc, 0, 0, stack.reg, stack.version, prevMemoryVer),
+ AddExprWithLocation(LLIL_CALL_PARAM, loc, 0, 0, params.size(), AddOperandList(params)));
}
@@ -3422,20 +3342,18 @@ ExprId LowLevelILFunction::SystemCall(const ILSourceLocation& loc)
ExprId LowLevelILFunction::Intrinsic(const vector<RegisterOrFlag>& outputs, uint32_t intrinsic,
- const vector<ExprId>& params, uint32_t flags, const ILSourceLocation& loc)
+ const vector<ExprId>& params, uint32_t flags, const ILSourceLocation& loc)
{
- return AddExprWithLocation(LLIL_INTRINSIC, loc, 0, flags,
- outputs.size(), AddRegisterOrFlagList(outputs), intrinsic,
- AddExprWithLocation(LLIL_CALL_PARAM, loc, 0, 0, params.size(), AddOperandList(params)));
+ return AddExprWithLocation(LLIL_INTRINSIC, loc, 0, flags, outputs.size(), AddRegisterOrFlagList(outputs), intrinsic,
+ AddExprWithLocation(LLIL_CALL_PARAM, loc, 0, 0, params.size(), AddOperandList(params)));
}
ExprId LowLevelILFunction::IntrinsicSSA(const vector<SSARegisterOrFlag>& outputs, uint32_t intrinsic,
- const vector<ExprId>& params, const ILSourceLocation& loc)
+ const vector<ExprId>& params, const ILSourceLocation& loc)
{
- return AddExprWithLocation(LLIL_INTRINSIC_SSA, loc, 0, 0,
- outputs.size() * 2, AddSSARegisterOrFlagList(outputs), intrinsic,
- AddExprWithLocation(LLIL_CALL_PARAM, loc, 0, 0, params.size(), AddOperandList(params)));
+ return AddExprWithLocation(LLIL_INTRINSIC_SSA, loc, 0, 0, outputs.size() * 2, AddSSARegisterOrFlagList(outputs),
+ intrinsic, AddExprWithLocation(LLIL_CALL_PARAM, loc, 0, 0, params.size(), AddOperandList(params)));
}
@@ -3469,27 +3387,26 @@ ExprId LowLevelILFunction::UnimplementedMemoryRef(size_t size, ExprId addr, cons
}
-ExprId LowLevelILFunction::RegisterPhi(const SSARegister& dest, const vector<SSARegister>& sources,
- const ILSourceLocation& loc)
+ExprId LowLevelILFunction::RegisterPhi(
+ const SSARegister& dest, const vector<SSARegister>& sources, const ILSourceLocation& loc)
{
- return AddExprWithLocation(LLIL_REG_PHI, loc, 0, 0, dest.reg, dest.version,
- sources.size() * 2, AddSSARegisterList(sources));
+ return AddExprWithLocation(
+ LLIL_REG_PHI, loc, 0, 0, dest.reg, dest.version, sources.size() * 2, AddSSARegisterList(sources));
}
-ExprId LowLevelILFunction::RegisterStackPhi(const SSARegisterStack& dest, const vector<SSARegisterStack>& sources,
- const ILSourceLocation& loc)
+ExprId LowLevelILFunction::RegisterStackPhi(
+ const SSARegisterStack& dest, const vector<SSARegisterStack>& sources, const ILSourceLocation& loc)
{
- return AddExprWithLocation(LLIL_REG_STACK_PHI, loc, 0, 0, dest.regStack, dest.version,
- sources.size() * 2, AddSSARegisterStackList(sources));
+ return AddExprWithLocation(LLIL_REG_STACK_PHI, loc, 0, 0, dest.regStack, dest.version, sources.size() * 2,
+ AddSSARegisterStackList(sources));
}
-ExprId LowLevelILFunction::FlagPhi(const SSAFlag& dest, const vector<SSAFlag>& sources,
- const ILSourceLocation& loc)
+ExprId LowLevelILFunction::FlagPhi(const SSAFlag& dest, const vector<SSAFlag>& sources, const ILSourceLocation& loc)
{
- return AddExprWithLocation(LLIL_FLAG_PHI, loc, 0, 0, dest.flag, dest.version,
- sources.size() * 2, AddSSAFlagList(sources));
+ return AddExprWithLocation(
+ LLIL_FLAG_PHI, loc, 0, 0, dest.flag, dest.version, sources.size() * 2, AddSSAFlagList(sources));
}
diff --git a/lowlevelilinstruction.h b/lowlevelilinstruction.h
index e11efa51..033b98b7 100644
--- a/lowlevelilinstruction.h
+++ b/lowlevelilinstruction.h
@@ -24,9 +24,9 @@
#include <unordered_map>
#include <vector>
#ifdef BINARYNINJACORE_LIBRARY
-#include "type.h"
+ #include "type.h"
#else
-#include "binaryninjaapi.h"
+ #include "binaryninjaapi.h"
#endif
#ifdef BINARYNINJACORE_LIBRARY
@@ -42,7 +42,8 @@ namespace BinaryNinja
class LowLevelILFunction;
template <BNLowLevelILOperation N>
- struct LowLevelILInstructionAccessor {};
+ struct LowLevelILInstructionAccessor
+ {};
struct LowLevelILInstruction;
struct LowLevelILConstantInstruction;
@@ -223,14 +224,15 @@ namespace BinaryNinja
RegisterStackAdjustmentsLowLevelOperandUsage,
OffsetLowLevelOperandUsage
};
-}
+} // namespace BinaryNinjaCore
-namespace std
-{
+namespace std {
#ifdef BINARYNINJACORE_LIBRARY
- template<> struct hash<BinaryNinjaCore::SSARegister>
+ template <>
+ struct hash<BinaryNinjaCore::SSARegister>
#else
- template<> struct hash<BinaryNinja::SSARegister>
+ template <>
+ struct hash<BinaryNinja::SSARegister>
#endif
{
#ifdef BINARYNINJACORE_LIBRARY
@@ -246,9 +248,11 @@ namespace std
};
#ifdef BINARYNINJACORE_LIBRARY
- template<> struct hash<BinaryNinjaCore::SSARegisterStack>
+ template <>
+ struct hash<BinaryNinjaCore::SSARegisterStack>
#else
- template<> struct hash<BinaryNinja::SSARegisterStack>
+ template <>
+ struct hash<BinaryNinja::SSARegisterStack>
#endif
{
#ifdef BINARYNINJACORE_LIBRARY
@@ -264,9 +268,11 @@ namespace std
};
#ifdef BINARYNINJACORE_LIBRARY
- template<> struct hash<BinaryNinjaCore::SSAFlag>
+ template <>
+ struct hash<BinaryNinjaCore::SSAFlag>
#else
- template<> struct hash<BinaryNinja::SSAFlag>
+ template <>
+ struct hash<BinaryNinja::SSAFlag>
#endif
{
#ifdef BINARYNINJACORE_LIBRARY
@@ -281,20 +287,20 @@ namespace std
}
};
- template<> struct hash<BNLowLevelILOperation>
+ template <>
+ struct hash<BNLowLevelILOperation>
{
typedef BNLowLevelILOperation argument_type;
typedef int result_type;
- result_type operator()(argument_type const& value) const
- {
- return (result_type)value;
- }
+ result_type operator()(argument_type const& value) const { return (result_type)value; }
};
#ifdef BINARYNINJACORE_LIBRARY
- template<> struct hash<BinaryNinjaCore::LowLevelILOperandUsage>
+ template <>
+ struct hash<BinaryNinjaCore::LowLevelILOperandUsage>
#else
- template<> struct hash<BinaryNinja::LowLevelILOperandUsage>
+ template <>
+ struct hash<BinaryNinja::LowLevelILOperandUsage>
#endif
{
#ifdef BINARYNINJACORE_LIBRARY
@@ -303,12 +309,9 @@ namespace std
typedef BinaryNinja::LowLevelILOperandUsage argument_type;
#endif
typedef int result_type;
- result_type operator()(argument_type const& value) const
- {
- return (result_type)value;
- }
+ result_type operator()(argument_type const& value) const { return (result_type)value; }
};
-}
+} // namespace std
#ifdef BINARYNINJACORE_LIBRARY
namespace BinaryNinjaCore
@@ -317,21 +320,21 @@ namespace BinaryNinja
#endif
{
#ifdef BINARYNINJACORE_LIBRARY
-#define _STD_VECTOR vector
-#define _STD_SET set
-#define _STD_UNORDERED_MAP unordered_map
-#define _STD_MAP map
+ #define _STD_VECTOR vector
+ #define _STD_SET set
+ #define _STD_UNORDERED_MAP unordered_map
+ #define _STD_MAP map
#else
-#define _STD_VECTOR std::vector
-#define _STD_SET std::set
-#define _STD_UNORDERED_MAP std::unordered_map
-#define _STD_MAP std::map
+ #define _STD_VECTOR std::vector
+ #define _STD_SET std::set
+ #define _STD_UNORDERED_MAP std::unordered_map
+ #define _STD_MAP std::map
#endif
- class LowLevelILInstructionAccessException: public std::exception
+ class LowLevelILInstructionAccessException : public std::exception
{
- public:
- LowLevelILInstructionAccessException(): std::exception() {}
+ public:
+ LowLevelILInstructionAccessException() : std::exception() {}
virtual const char* what() const NOEXCEPT { return "invalid access to LLIL instruction"; }
};
@@ -358,7 +361,7 @@ namespace BinaryNinja
ListIterator m_start;
- public:
+ public:
typedef ListIterator const_iterator;
LowLevelILIntegerList(LowLevelILFunction* func, const BNLowLevelILInstruction& instr, size_t count);
@@ -379,13 +382,17 @@ namespace BinaryNinja
bool operator==(const ListIterator& a) const { return pos == a.pos; }
bool operator!=(const ListIterator& a) const { return pos != a.pos; }
bool operator<(const ListIterator& a) const { return pos < a.pos; }
- ListIterator& operator++() { ++pos; return *this; }
+ ListIterator& operator++()
+ {
+ ++pos;
+ return *this;
+ }
size_t operator*();
};
LowLevelILIntegerList m_list;
- public:
+ public:
typedef ListIterator const_iterator;
LowLevelILIndexList(LowLevelILFunction* func, const BNLowLevelILInstruction& instr, size_t count);
@@ -406,13 +413,18 @@ namespace BinaryNinja
bool operator==(const ListIterator& a) const { return pos == a.pos; }
bool operator!=(const ListIterator& a) const { return pos != a.pos; }
bool operator<(const ListIterator& a) const { return pos < a.pos; }
- ListIterator& operator++() { ++pos; ++pos; return *this; }
+ ListIterator& operator++()
+ {
+ ++pos;
+ ++pos;
+ return *this;
+ }
const std::pair<uint64_t, size_t> operator*();
};
LowLevelILIntegerList m_list;
- public:
+ public:
typedef ListIterator const_iterator;
LowLevelILIndexMap(LowLevelILFunction* func, const BNLowLevelILInstruction& instr, size_t count);
@@ -434,18 +446,22 @@ namespace BinaryNinja
bool operator==(const ListIterator& a) const { return pos == a.pos; }
bool operator!=(const ListIterator& a) const { return pos != a.pos; }
bool operator<(const ListIterator& a) const { return pos < a.pos; }
- ListIterator& operator++() { ++pos; return *this; }
+ ListIterator& operator++()
+ {
+ ++pos;
+ return *this;
+ }
const LowLevelILInstruction operator*();
};
LowLevelILIntegerList m_list;
size_t m_instructionIndex;
- public:
+ public:
typedef ListIterator const_iterator;
- LowLevelILInstructionList(LowLevelILFunction* func, const BNLowLevelILInstruction& instr,
- size_t count, size_t instrIndex);
+ LowLevelILInstructionList(
+ LowLevelILFunction* func, const BNLowLevelILInstruction& instr, size_t count, size_t instrIndex);
const_iterator begin() const;
const_iterator end() const;
@@ -463,13 +479,17 @@ namespace BinaryNinja
bool operator==(const ListIterator& a) const { return pos == a.pos; }
bool operator!=(const ListIterator& a) const { return pos != a.pos; }
bool operator<(const ListIterator& a) const { return pos < a.pos; }
- ListIterator& operator++() { ++pos; return *this; }
+ ListIterator& operator++()
+ {
+ ++pos;
+ return *this;
+ }
const RegisterOrFlag operator*();
};
LowLevelILIntegerList m_list;
- public:
+ public:
typedef ListIterator const_iterator;
LowLevelILRegisterOrFlagList(LowLevelILFunction* func, const BNLowLevelILInstruction& instr, size_t count);
@@ -490,13 +510,18 @@ namespace BinaryNinja
bool operator==(const ListIterator& a) const { return pos == a.pos; }
bool operator!=(const ListIterator& a) const { return pos != a.pos; }
bool operator<(const ListIterator& a) const { return pos < a.pos; }
- ListIterator& operator++() { ++pos; ++pos; return *this; }
+ ListIterator& operator++()
+ {
+ ++pos;
+ ++pos;
+ return *this;
+ }
const SSARegister operator*();
};
LowLevelILIntegerList m_list;
- public:
+ public:
typedef ListIterator const_iterator;
LowLevelILSSARegisterList(LowLevelILFunction* func, const BNLowLevelILInstruction& instr, size_t count);
@@ -517,13 +542,18 @@ namespace BinaryNinja
bool operator==(const ListIterator& a) const { return pos == a.pos; }
bool operator!=(const ListIterator& a) const { return pos != a.pos; }
bool operator<(const ListIterator& a) const { return pos < a.pos; }
- ListIterator& operator++() { ++pos; ++pos; return *this; }
+ ListIterator& operator++()
+ {
+ ++pos;
+ ++pos;
+ return *this;
+ }
const SSARegisterStack operator*();
};
LowLevelILIntegerList m_list;
- public:
+ public:
typedef ListIterator const_iterator;
LowLevelILSSARegisterStackList(LowLevelILFunction* func, const BNLowLevelILInstruction& instr, size_t count);
@@ -544,13 +574,18 @@ namespace BinaryNinja
bool operator==(const ListIterator& a) const { return pos == a.pos; }
bool operator!=(const ListIterator& a) const { return pos != a.pos; }
bool operator<(const ListIterator& a) const { return pos < a.pos; }
- ListIterator& operator++() { ++pos; ++pos; return *this; }
+ ListIterator& operator++()
+ {
+ ++pos;
+ ++pos;
+ return *this;
+ }
const SSAFlag operator*();
};
LowLevelILIntegerList m_list;
- public:
+ public:
typedef ListIterator const_iterator;
LowLevelILSSAFlagList(LowLevelILFunction* func, const BNLowLevelILInstruction& instr, size_t count);
@@ -571,13 +606,18 @@ namespace BinaryNinja
bool operator==(const ListIterator& a) const { return pos == a.pos; }
bool operator!=(const ListIterator& a) const { return pos != a.pos; }
bool operator<(const ListIterator& a) const { return pos < a.pos; }
- ListIterator& operator++() { ++pos; ++pos; return *this; }
+ ListIterator& operator++()
+ {
+ ++pos;
+ ++pos;
+ return *this;
+ }
const SSARegisterOrFlag operator*();
};
LowLevelILIntegerList m_list;
- public:
+ public:
typedef ListIterator const_iterator;
LowLevelILSSARegisterOrFlagList(LowLevelILFunction* func, const BNLowLevelILInstruction& instr, size_t count);
@@ -590,7 +630,7 @@ namespace BinaryNinja
operator _STD_VECTOR<SSARegisterOrFlag>() const;
};
- struct LowLevelILInstructionBase: public BNLowLevelILInstruction
+ struct LowLevelILInstructionBase : public BNLowLevelILInstruction
{
#ifdef BINARYNINJACORE_LIBRARY
LowLevelILFunction* function;
@@ -600,10 +640,9 @@ namespace BinaryNinja
size_t exprIndex, instructionIndex;
static _STD_UNORDERED_MAP<LowLevelILOperandUsage, LowLevelILOperandType> operandTypeForUsage;
- static _STD_UNORDERED_MAP<BNLowLevelILOperation,
- _STD_VECTOR<LowLevelILOperandUsage>> operationOperandUsage;
- static _STD_UNORDERED_MAP<BNLowLevelILOperation,
- _STD_UNORDERED_MAP<LowLevelILOperandUsage, size_t>> operationOperandIndex;
+ static _STD_UNORDERED_MAP<BNLowLevelILOperation, _STD_VECTOR<LowLevelILOperandUsage>> operationOperandUsage;
+ static _STD_UNORDERED_MAP<BNLowLevelILOperation, _STD_UNORDERED_MAP<LowLevelILOperandUsage, size_t>>
+ operationOperandIndex;
LowLevelILOperandList GetOperands() const;
@@ -628,11 +667,12 @@ namespace BinaryNinja
void UpdateRawOperand(size_t operandIndex, ExprId value);
void UpdateRawOperandAsSSARegisterList(size_t operandIndex, const _STD_VECTOR<SSARegister>& regs);
- void UpdateRawOperandAsSSARegisterOrFlagList(size_t operandIndex, const _STD_VECTOR<SSARegisterOrFlag>& outputs);
+ void UpdateRawOperandAsSSARegisterOrFlagList(
+ size_t operandIndex, const _STD_VECTOR<SSARegisterOrFlag>& outputs);
RegisterValue GetValue() const;
- PossibleValueSet GetPossibleValues(const _STD_SET<BNDataFlowQueryOption>& options =
- _STD_SET<BNDataFlowQueryOption>()) const;
+ PossibleValueSet GetPossibleValues(
+ const _STD_SET<BNDataFlowQueryOption>& options = _STD_SET<BNDataFlowQueryOption>()) const;
RegisterValue GetRegisterValue(uint32_t reg);
RegisterValue GetRegisterValueAfter(uint32_t reg);
@@ -674,14 +714,8 @@ namespace BinaryNinja
throw LowLevelILInstructionAccessException();
return *(LowLevelILInstructionAccessor<N>*)this;
}
- LowLevelILOneOperandInstruction& AsOneOperand()
- {
- return *(LowLevelILOneOperandInstruction*)this;
- }
- LowLevelILTwoOperandInstruction& AsTwoOperand()
- {
- return *(LowLevelILTwoOperandInstruction*)this;
- }
+ LowLevelILOneOperandInstruction& AsOneOperand() { return *(LowLevelILOneOperandInstruction*)this; }
+ LowLevelILTwoOperandInstruction& AsTwoOperand() { return *(LowLevelILTwoOperandInstruction*)this; }
LowLevelILTwoOperandWithCarryInstruction& AsTwoOperandWithCarry()
{
return *(LowLevelILTwoOperandWithCarryInstruction*)this;
@@ -694,10 +728,7 @@ namespace BinaryNinja
throw LowLevelILInstructionAccessException();
return *(const LowLevelILInstructionAccessor<N>*)this;
}
- const LowLevelILConstantInstruction& AsConstant() const
- {
- return *(const LowLevelILConstantInstruction*)this;
- }
+ const LowLevelILConstantInstruction& AsConstant() const { return *(const LowLevelILConstantInstruction*)this; }
const LowLevelILOneOperandInstruction& AsOneOperand() const
{
return *(const LowLevelILOneOperandInstruction*)this;
@@ -712,80 +743,316 @@ namespace BinaryNinja
}
};
- struct LowLevelILInstruction: public LowLevelILInstructionBase
+ struct LowLevelILInstruction : public LowLevelILInstructionBase
{
LowLevelILInstruction();
- LowLevelILInstruction(LowLevelILFunction* func, const BNLowLevelILInstruction& instr,
- size_t expr, size_t instrIdx);
+ LowLevelILInstruction(
+ LowLevelILFunction* func, const BNLowLevelILInstruction& instr, size_t expr, size_t instrIdx);
LowLevelILInstruction(const LowLevelILInstructionBase& instr);
void VisitExprs(const std::function<bool(const LowLevelILInstruction& expr)>& func) const;
ExprId CopyTo(LowLevelILFunction* dest) const;
ExprId CopyTo(LowLevelILFunction* dest,
- const std::function<ExprId(const LowLevelILInstruction& subExpr)>& subExprHandler) const;
+ const std::function<ExprId(const LowLevelILInstruction& subExpr)>& subExprHandler) const;
// Templated accessors for instruction operands, use these for efficient access to a known instruction
- template <BNLowLevelILOperation N> LowLevelILInstruction GetSourceExpr() const { return As<N>().GetSourceExpr(); }
- template <BNLowLevelILOperation N> uint32_t GetSourceRegister() const { return As<N>().GetSourceRegister(); }
- template <BNLowLevelILOperation N> uint32_t GetSourceRegisterStack() const { return As<N>().GetSourceRegisterStack(); }
- template <BNLowLevelILOperation N> uint32_t GetSourceFlag() const { return As<N>().GetSourceFlag(); }
- template <BNLowLevelILOperation N> SSARegister GetSourceSSARegister() const { return As<N>().GetSourceSSARegister(); }
- template <BNLowLevelILOperation N> SSARegisterStack GetSourceSSARegisterStack() const { return As<N>().GetSourceSSARegisterStack(); }
- template <BNLowLevelILOperation N> SSAFlag GetSourceSSAFlag() const { return As<N>().GetSourceSSAFlag(); }
- template <BNLowLevelILOperation N> LowLevelILInstruction GetDestExpr() const { return As<N>().GetDestExpr(); }
- template <BNLowLevelILOperation N> uint32_t GetDestRegister() const { return As<N>().GetDestRegister(); }
- template <BNLowLevelILOperation N> uint32_t GetDestRegisterStack() const { return As<N>().GetDestRegisterStack(); }
- template <BNLowLevelILOperation N> uint32_t GetDestFlag() const { return As<N>().GetDestFlag(); }
- template <BNLowLevelILOperation N> SSARegister GetDestSSARegister() const { return As<N>().GetDestSSARegister(); }
- template <BNLowLevelILOperation N> SSARegisterStack GetDestSSARegisterStack() const { return As<N>().GetDestSSARegisterStack(); }
- template <BNLowLevelILOperation N> SSAFlag GetDestSSAFlag() const { return As<N>().GetDestSSAFlag(); }
- template <BNLowLevelILOperation N> uint32_t GetSemanticFlagClass() const { return As<N>().GetSemanticFlagClass(); }
- template <BNLowLevelILOperation N> uint32_t GetSemanticFlagGroup() const { return As<N>().GetSemanticFlagGroup(); }
- template <BNLowLevelILOperation N> uint32_t GetPartialRegister() const { return As<N>().GetPartialRegister(); }
- template <BNLowLevelILOperation N> SSARegister GetStackSSARegister() const { return As<N>().GetStackSSARegister(); }
- template <BNLowLevelILOperation N> SSARegister GetTopSSARegister() const { return As<N>().GetTopSSARegister(); }
- template <BNLowLevelILOperation N> LowLevelILInstruction GetLeftExpr() const { return As<N>().GetLeftExpr(); }
- template <BNLowLevelILOperation N> LowLevelILInstruction GetRightExpr() const { return As<N>().GetRightExpr(); }
- template <BNLowLevelILOperation N> LowLevelILInstruction GetCarryExpr() const { return As<N>().GetCarryExpr(); }
- template <BNLowLevelILOperation N> LowLevelILInstruction GetConditionExpr() const { return As<N>().GetConditionExpr(); }
- template <BNLowLevelILOperation N> uint32_t GetHighRegister() const { return As<N>().GetHighRegister(); }
- template <BNLowLevelILOperation N> SSARegister GetHighSSARegister() const { return As<N>().GetHighSSARegister(); }
- template <BNLowLevelILOperation N> uint32_t GetLowRegister() const { return As<N>().GetLowRegister(); }
- template <BNLowLevelILOperation N> SSARegister GetLowSSARegister() const { return As<N>().GetLowSSARegister(); }
- template <BNLowLevelILOperation N> uint32_t GetIntrinsic() const { return As<N>().GetIntrinsic(); }
- template <BNLowLevelILOperation N> int64_t GetConstant() const { return As<N>().GetConstant(); }
- template <BNLowLevelILOperation N> uint64_t GetOffset() const { return As<N>().GetOffset(); }
- template <BNLowLevelILOperation N> int64_t GetVector() const { return As<N>().GetVector(); }
- template <BNLowLevelILOperation N> int64_t GetStackAdjustment() const { return As<N>().GetStackAdjustment(); }
- template <BNLowLevelILOperation N> size_t GetTarget() const { return As<N>().GetTarget(); }
- template <BNLowLevelILOperation N> size_t GetTrueTarget() const { return As<N>().GetTrueTarget(); }
- template <BNLowLevelILOperation N> size_t GetFalseTarget() const { return As<N>().GetFalseTarget(); }
- template <BNLowLevelILOperation N> size_t GetBitIndex() const { return As<N>().GetBitIndex(); }
- template <BNLowLevelILOperation N> size_t GetSourceMemoryVersion() const { return As<N>().GetSourceMemoryVersion(); }
- template <BNLowLevelILOperation N> size_t GetDestMemoryVersion() const { return As<N>().GetDestMemoryVersion(); }
- template <BNLowLevelILOperation N> BNLowLevelILFlagCondition GetFlagCondition() const { return As<N>().GetFlagCondition(); }
- template <BNLowLevelILOperation N> LowLevelILSSARegisterList GetOutputSSARegisters() const { return As<N>().GetOutputSSARegisters(); }
- template <BNLowLevelILOperation N> LowLevelILInstructionList GetParameterExprs() const { return As<N>().GetParameterExprs(); }
- template <BNLowLevelILOperation N> LowLevelILSSARegisterList GetSourceSSARegisters() const { return As<N>().GetSourceSSARegisters(); }
- template <BNLowLevelILOperation N> LowLevelILSSARegisterStackList GetSourceSSARegisterStacks() const { return As<N>().GetSourceSSARegisterStacks(); }
- template <BNLowLevelILOperation N> LowLevelILSSAFlagList GetSourceSSAFlags() const { return As<N>().GetSourceSSAFlags(); }
- template <BNLowLevelILOperation N> LowLevelILRegisterOrFlagList GetOutputRegisterOrFlagList() const { return As<N>().GetOutputRegisterOrFlagList(); }
- template <BNLowLevelILOperation N> LowLevelILSSARegisterOrFlagList GetOutputSSARegisterOrFlagList() const { return As<N>().GetOutputSSARegisterOrFlagList(); }
- template <BNLowLevelILOperation N> LowLevelILIndexList GetSourceMemoryVersions() const { return As<N>().GetSourceMemoryVersions(); }
- template <BNLowLevelILOperation N> LowLevelILIndexMap GetTargets() const { return As<N>().GetTargets(); }
- template <BNLowLevelILOperation N> _STD_MAP<uint32_t, int32_t> GetRegisterStackAdjustments() const { return As<N>().GetRegisterStackAdjustments(); }
+ template <BNLowLevelILOperation N>
+ LowLevelILInstruction GetSourceExpr() const
+ {
+ return As<N>().GetSourceExpr();
+ }
+ template <BNLowLevelILOperation N>
+ uint32_t GetSourceRegister() const
+ {
+ return As<N>().GetSourceRegister();
+ }
+ template <BNLowLevelILOperation N>
+ uint32_t GetSourceRegisterStack() const
+ {
+ return As<N>().GetSourceRegisterStack();
+ }
+ template <BNLowLevelILOperation N>
+ uint32_t GetSourceFlag() const
+ {
+ return As<N>().GetSourceFlag();
+ }
+ template <BNLowLevelILOperation N>
+ SSARegister GetSourceSSARegister() const
+ {
+ return As<N>().GetSourceSSARegister();
+ }
+ template <BNLowLevelILOperation N>
+ SSARegisterStack GetSourceSSARegisterStack() const
+ {
+ return As<N>().GetSourceSSARegisterStack();
+ }
+ template <BNLowLevelILOperation N>
+ SSAFlag GetSourceSSAFlag() const
+ {
+ return As<N>().GetSourceSSAFlag();
+ }
+ template <BNLowLevelILOperation N>
+ LowLevelILInstruction GetDestExpr() const
+ {
+ return As<N>().GetDestExpr();
+ }
+ template <BNLowLevelILOperation N>
+ uint32_t GetDestRegister() const
+ {
+ return As<N>().GetDestRegister();
+ }
+ template <BNLowLevelILOperation N>
+ uint32_t GetDestRegisterStack() const
+ {
+ return As<N>().GetDestRegisterStack();
+ }
+ template <BNLowLevelILOperation N>
+ uint32_t GetDestFlag() const
+ {
+ return As<N>().GetDestFlag();
+ }
+ template <BNLowLevelILOperation N>
+ SSARegister GetDestSSARegister() const
+ {
+ return As<N>().GetDestSSARegister();
+ }
+ template <BNLowLevelILOperation N>
+ SSARegisterStack GetDestSSARegisterStack() const
+ {
+ return As<N>().GetDestSSARegisterStack();
+ }
+ template <BNLowLevelILOperation N>
+ SSAFlag GetDestSSAFlag() const
+ {
+ return As<N>().GetDestSSAFlag();
+ }
+ template <BNLowLevelILOperation N>
+ uint32_t GetSemanticFlagClass() const
+ {
+ return As<N>().GetSemanticFlagClass();
+ }
+ template <BNLowLevelILOperation N>
+ uint32_t GetSemanticFlagGroup() const
+ {
+ return As<N>().GetSemanticFlagGroup();
+ }
+ template <BNLowLevelILOperation N>
+ uint32_t GetPartialRegister() const
+ {
+ return As<N>().GetPartialRegister();
+ }
+ template <BNLowLevelILOperation N>
+ SSARegister GetStackSSARegister() const
+ {
+ return As<N>().GetStackSSARegister();
+ }
+ template <BNLowLevelILOperation N>
+ SSARegister GetTopSSARegister() const
+ {
+ return As<N>().GetTopSSARegister();
+ }
+ template <BNLowLevelILOperation N>
+ LowLevelILInstruction GetLeftExpr() const
+ {
+ return As<N>().GetLeftExpr();
+ }
+ template <BNLowLevelILOperation N>
+ LowLevelILInstruction GetRightExpr() const
+ {
+ return As<N>().GetRightExpr();
+ }
+ template <BNLowLevelILOperation N>
+ LowLevelILInstruction GetCarryExpr() const
+ {
+ return As<N>().GetCarryExpr();
+ }
+ template <BNLowLevelILOperation N>
+ LowLevelILInstruction GetConditionExpr() const
+ {
+ return As<N>().GetConditionExpr();
+ }
+ template <BNLowLevelILOperation N>
+ uint32_t GetHighRegister() const
+ {
+ return As<N>().GetHighRegister();
+ }
+ template <BNLowLevelILOperation N>
+ SSARegister GetHighSSARegister() const
+ {
+ return As<N>().GetHighSSARegister();
+ }
+ template <BNLowLevelILOperation N>
+ uint32_t GetLowRegister() const
+ {
+ return As<N>().GetLowRegister();
+ }
+ template <BNLowLevelILOperation N>
+ SSARegister GetLowSSARegister() const
+ {
+ return As<N>().GetLowSSARegister();
+ }
+ template <BNLowLevelILOperation N>
+ uint32_t GetIntrinsic() const
+ {
+ return As<N>().GetIntrinsic();
+ }
+ template <BNLowLevelILOperation N>
+ int64_t GetConstant() const
+ {
+ return As<N>().GetConstant();
+ }
+ template <BNLowLevelILOperation N>
+ uint64_t GetOffset() const
+ {
+ return As<N>().GetOffset();
+ }
+ template <BNLowLevelILOperation N>
+ int64_t GetVector() const
+ {
+ return As<N>().GetVector();
+ }
+ template <BNLowLevelILOperation N>
+ int64_t GetStackAdjustment() const
+ {
+ return As<N>().GetStackAdjustment();
+ }
+ template <BNLowLevelILOperation N>
+ size_t GetTarget() const
+ {
+ return As<N>().GetTarget();
+ }
+ template <BNLowLevelILOperation N>
+ size_t GetTrueTarget() const
+ {
+ return As<N>().GetTrueTarget();
+ }
+ template <BNLowLevelILOperation N>
+ size_t GetFalseTarget() const
+ {
+ return As<N>().GetFalseTarget();
+ }
+ template <BNLowLevelILOperation N>
+ size_t GetBitIndex() const
+ {
+ return As<N>().GetBitIndex();
+ }
+ template <BNLowLevelILOperation N>
+ size_t GetSourceMemoryVersion() const
+ {
+ return As<N>().GetSourceMemoryVersion();
+ }
+ template <BNLowLevelILOperation N>
+ size_t GetDestMemoryVersion() const
+ {
+ return As<N>().GetDestMemoryVersion();
+ }
+ template <BNLowLevelILOperation N>
+ BNLowLevelILFlagCondition GetFlagCondition() const
+ {
+ return As<N>().GetFlagCondition();
+ }
+ template <BNLowLevelILOperation N>
+ LowLevelILSSARegisterList GetOutputSSARegisters() const
+ {
+ return As<N>().GetOutputSSARegisters();
+ }
+ template <BNLowLevelILOperation N>
+ LowLevelILInstructionList GetParameterExprs() const
+ {
+ return As<N>().GetParameterExprs();
+ }
+ template <BNLowLevelILOperation N>
+ LowLevelILSSARegisterList GetSourceSSARegisters() const
+ {
+ return As<N>().GetSourceSSARegisters();
+ }
+ template <BNLowLevelILOperation N>
+ LowLevelILSSARegisterStackList GetSourceSSARegisterStacks() const
+ {
+ return As<N>().GetSourceSSARegisterStacks();
+ }
+ template <BNLowLevelILOperation N>
+ LowLevelILSSAFlagList GetSourceSSAFlags() const
+ {
+ return As<N>().GetSourceSSAFlags();
+ }
+ template <BNLowLevelILOperation N>
+ LowLevelILRegisterOrFlagList GetOutputRegisterOrFlagList() const
+ {
+ return As<N>().GetOutputRegisterOrFlagList();
+ }
+ template <BNLowLevelILOperation N>
+ LowLevelILSSARegisterOrFlagList GetOutputSSARegisterOrFlagList() const
+ {
+ return As<N>().GetOutputSSARegisterOrFlagList();
+ }
+ template <BNLowLevelILOperation N>
+ LowLevelILIndexList GetSourceMemoryVersions() const
+ {
+ return As<N>().GetSourceMemoryVersions();
+ }
+ template <BNLowLevelILOperation N>
+ LowLevelILIndexMap GetTargets() const
+ {
+ return As<N>().GetTargets();
+ }
+ template <BNLowLevelILOperation N>
+ _STD_MAP<uint32_t, int32_t> GetRegisterStackAdjustments() const
+ {
+ return As<N>().GetRegisterStackAdjustments();
+ }
- template <BNLowLevelILOperation N> void SetDestSSAVersion(size_t version) { As<N>().SetDestSSAVersion(version); }
- template <BNLowLevelILOperation N> void SetSourceSSAVersion(size_t version) { As<N>().SetSourceSSAVersion(version); }
- template <BNLowLevelILOperation N> void SetHighSSAVersion(size_t version) { As<N>().SetHighSSAVersion(version); }
- template <BNLowLevelILOperation N> void SetLowSSAVersion(size_t version) { As<N>().SetLowSSAVersion(version); }
- template <BNLowLevelILOperation N> void SetStackSSAVersion(size_t version) { As<N>().SetStackSSAVersion(version); }
- template <BNLowLevelILOperation N> void SetTopSSAVersion(size_t version) { As<N>().SetTopSSAVersion(version); }
- template <BNLowLevelILOperation N> void SetDestMemoryVersion(size_t version) { As<N>().SetDestMemoryVersion(version); }
- template <BNLowLevelILOperation N> void SetSourceMemoryVersion(size_t version) { As<N>().SetSourceMemoryVersion(version); }
- template <BNLowLevelILOperation N> void SetOutputSSARegisters(const _STD_VECTOR<SSARegister>& regs) { As<N>().SetOutputSSARegisters(regs); }
- template <BNLowLevelILOperation N> void SetOutputSSARegisterOrFlagList(const _STD_VECTOR<SSARegisterOrFlag>& outputs) { As<N>().SetOutputSSARegisterOrFlagList(outputs); }
+ template <BNLowLevelILOperation N>
+ void SetDestSSAVersion(size_t version)
+ {
+ As<N>().SetDestSSAVersion(version);
+ }
+ template <BNLowLevelILOperation N>
+ void SetSourceSSAVersion(size_t version)
+ {
+ As<N>().SetSourceSSAVersion(version);
+ }
+ template <BNLowLevelILOperation N>
+ void SetHighSSAVersion(size_t version)
+ {
+ As<N>().SetHighSSAVersion(version);
+ }
+ template <BNLowLevelILOperation N>
+ void SetLowSSAVersion(size_t version)
+ {
+ As<N>().SetLowSSAVersion(version);
+ }
+ template <BNLowLevelILOperation N>
+ void SetStackSSAVersion(size_t version)
+ {
+ As<N>().SetStackSSAVersion(version);
+ }
+ template <BNLowLevelILOperation N>
+ void SetTopSSAVersion(size_t version)
+ {
+ As<N>().SetTopSSAVersion(version);
+ }
+ template <BNLowLevelILOperation N>
+ void SetDestMemoryVersion(size_t version)
+ {
+ As<N>().SetDestMemoryVersion(version);
+ }
+ template <BNLowLevelILOperation N>
+ void SetSourceMemoryVersion(size_t version)
+ {
+ As<N>().SetSourceMemoryVersion(version);
+ }
+ template <BNLowLevelILOperation N>
+ void SetOutputSSARegisters(const _STD_VECTOR<SSARegister>& regs)
+ {
+ As<N>().SetOutputSSARegisters(regs);
+ }
+ template <BNLowLevelILOperation N>
+ void SetOutputSSARegisterOrFlagList(const _STD_VECTOR<SSARegisterOrFlag>& outputs)
+ {
+ As<N>().SetOutputSSARegisterOrFlagList(outputs);
+ }
bool GetOperandIndexForUsage(LowLevelILOperandUsage usage, size_t& operandIndex) const;
@@ -849,9 +1116,8 @@ namespace BinaryNinja
LowLevelILOperandType m_type;
size_t m_operandIndex;
- public:
- LowLevelILOperand(const LowLevelILInstruction& instr, LowLevelILOperandUsage usage,
- size_t operandIndex);
+ public:
+ LowLevelILOperand(const LowLevelILInstruction& instr, LowLevelILOperandUsage usage, size_t operandIndex);
LowLevelILOperandType GetType() const { return m_type; }
LowLevelILOperandUsage GetUsage() const { return m_usage; }
@@ -889,7 +1155,11 @@ namespace BinaryNinja
bool operator==(const ListIterator& a) const { return pos == a.pos; }
bool operator!=(const ListIterator& a) const { return pos != a.pos; }
bool operator<(const ListIterator& a) const { return pos < a.pos; }
- ListIterator& operator++() { ++pos; return *this; }
+ ListIterator& operator++()
+ {
+ ++pos;
+ return *this;
+ }
const LowLevelILOperand operator*();
};
@@ -897,12 +1167,11 @@ namespace BinaryNinja
const _STD_VECTOR<LowLevelILOperandUsage>& m_usageList;
const _STD_UNORDERED_MAP<LowLevelILOperandUsage, size_t>& m_operandIndexMap;
- public:
+ public:
typedef ListIterator const_iterator;
- LowLevelILOperandList(const LowLevelILInstruction& instr,
- const _STD_VECTOR<LowLevelILOperandUsage>& usageList,
- const _STD_UNORDERED_MAP<LowLevelILOperandUsage, size_t>& operandIndexMap);
+ LowLevelILOperandList(const LowLevelILInstruction& instr, const _STD_VECTOR<LowLevelILOperandUsage>& usageList,
+ const _STD_UNORDERED_MAP<LowLevelILOperandUsage, size_t>& operandIndexMap);
const_iterator begin() const;
const_iterator end() const;
@@ -912,28 +1181,28 @@ namespace BinaryNinja
operator _STD_VECTOR<LowLevelILOperand>() const;
};
- struct LowLevelILConstantInstruction: public LowLevelILInstructionBase
+ struct LowLevelILConstantInstruction : public LowLevelILInstructionBase
{
int64_t GetConstant() const { return GetRawOperandAsInteger(0); }
};
- struct LowLevelILOffsetInstruction: public LowLevelILInstructionBase
+ struct LowLevelILOffsetInstruction : public LowLevelILInstructionBase
{
int64_t GetOffset() const { return GetRawOperandAsInteger(1); }
};
- struct LowLevelILOneOperandInstruction: public LowLevelILInstructionBase
+ struct LowLevelILOneOperandInstruction : public LowLevelILInstructionBase
{
LowLevelILInstruction GetSourceExpr() const { return GetRawOperandAsExpr(0); }
};
- struct LowLevelILTwoOperandInstruction: public LowLevelILInstructionBase
+ struct LowLevelILTwoOperandInstruction : public LowLevelILInstructionBase
{
LowLevelILInstruction GetLeftExpr() const { return GetRawOperandAsExpr(0); }
LowLevelILInstruction GetRightExpr() const { return GetRawOperandAsExpr(1); }
};
- struct LowLevelILTwoOperandWithCarryInstruction: public LowLevelILInstructionBase
+ struct LowLevelILTwoOperandWithCarryInstruction : public LowLevelILInstructionBase
{
LowLevelILInstruction GetLeftExpr() const { return GetRawOperandAsExpr(0); }
LowLevelILInstruction GetRightExpr() const { return GetRawOperandAsExpr(1); }
@@ -943,31 +1212,36 @@ namespace BinaryNinja
// Implementations of each instruction to fetch the correct operand value for the valid operands, these
// are derived from LowLevelILInstructionBase so that invalid operand accessor functions will generate
// a compiler error.
- template <> struct LowLevelILInstructionAccessor<LLIL_SET_REG>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_SET_REG> : public LowLevelILInstructionBase
{
uint32_t GetDestRegister() const { return GetRawOperandAsRegister(0); }
LowLevelILInstruction GetSourceExpr() const { return GetRawOperandAsExpr(1); }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_SET_REG_SPLIT>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_SET_REG_SPLIT> : public LowLevelILInstructionBase
{
uint32_t GetHighRegister() const { return GetRawOperandAsRegister(0); }
uint32_t GetLowRegister() const { return GetRawOperandAsRegister(1); }
LowLevelILInstruction GetSourceExpr() const { return GetRawOperandAsExpr(2); }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_SET_REG_SSA>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_SET_REG_SSA> : public LowLevelILInstructionBase
{
SSARegister GetDestSSARegister() const { return GetRawOperandAsSSARegister(0); }
LowLevelILInstruction GetSourceExpr() const { return GetRawOperandAsExpr(2); }
void SetDestSSAVersion(size_t version) { UpdateRawOperand(1, version); }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_SET_REG_SSA_PARTIAL>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_SET_REG_SSA_PARTIAL> : public LowLevelILInstructionBase
{
SSARegister GetDestSSARegister() const { return GetRawOperandAsSSARegister(0); }
uint32_t GetPartialRegister() const { return GetRawOperandAsRegister(2); }
LowLevelILInstruction GetSourceExpr() const { return GetRawOperandAsExpr(3); }
void SetDestSSAVersion(size_t version) { UpdateRawOperand(1, version); }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_SET_REG_SPLIT_SSA>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_SET_REG_SPLIT_SSA> : public LowLevelILInstructionBase
{
SSARegister GetHighSSARegister() const { return GetRawOperandAsExpr(0).GetRawOperandAsSSARegister(0); }
SSARegister GetLowSSARegister() const { return GetRawOperandAsExpr(1).GetRawOperandAsSSARegister(0); }
@@ -975,21 +1249,30 @@ namespace BinaryNinja
void SetHighSSAVersion(size_t version) { GetRawOperandAsExpr(0).UpdateRawOperand(1, version); }
void SetLowSSAVersion(size_t version) { GetRawOperandAsExpr(1).UpdateRawOperand(1, version); }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_SET_REG_STACK_REL>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_SET_REG_STACK_REL> : public LowLevelILInstructionBase
{
uint32_t GetDestRegisterStack() const { return GetRawOperandAsRegister(0); }
LowLevelILInstruction GetDestExpr() const { return GetRawOperandAsExpr(1); }
LowLevelILInstruction GetSourceExpr() const { return GetRawOperandAsExpr(2); }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_REG_STACK_PUSH>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_REG_STACK_PUSH> : public LowLevelILInstructionBase
{
uint32_t GetDestRegisterStack() const { return GetRawOperandAsRegister(0); }
LowLevelILInstruction GetSourceExpr() const { return GetRawOperandAsExpr(1); }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_SET_REG_STACK_REL_SSA>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_SET_REG_STACK_REL_SSA> : public LowLevelILInstructionBase
{
- SSARegisterStack GetDestSSARegisterStack() const { return GetRawOperandAsExpr(0).GetRawOperandAsSSARegisterStack(0); }
- SSARegisterStack GetSourceSSARegisterStack() const { return GetRawOperandAsExpr(0).GetRawOperandAsPartialSSARegisterStackSource(0); }
+ SSARegisterStack GetDestSSARegisterStack() const
+ {
+ return GetRawOperandAsExpr(0).GetRawOperandAsSSARegisterStack(0);
+ }
+ SSARegisterStack GetSourceSSARegisterStack() const
+ {
+ return GetRawOperandAsExpr(0).GetRawOperandAsPartialSSARegisterStackSource(0);
+ }
LowLevelILInstruction GetDestExpr() const { return GetRawOperandAsExpr(1); }
SSARegister GetTopSSARegister() const { return GetRawOperandAsExpr(2).GetRawOperandAsSSARegister(0); }
LowLevelILInstruction GetSourceExpr() const { return GetRawOperandAsExpr(3); }
@@ -997,41 +1280,55 @@ namespace BinaryNinja
void SetSourceSSAVersion(size_t version) { GetRawOperandAsExpr(0).UpdateRawOperand(2, version); }
void SetTopSSAVersion(size_t version) { GetRawOperandAsExpr(2).UpdateRawOperand(1, version); }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_SET_REG_STACK_ABS_SSA>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_SET_REG_STACK_ABS_SSA> : public LowLevelILInstructionBase
{
- SSARegisterStack GetDestSSARegisterStack() const { return GetRawOperandAsExpr(0).GetRawOperandAsSSARegisterStack(0); }
- SSARegisterStack GetSourceSSARegisterStack() const { return GetRawOperandAsExpr(0).GetRawOperandAsPartialSSARegisterStackSource(0); }
+ SSARegisterStack GetDestSSARegisterStack() const
+ {
+ return GetRawOperandAsExpr(0).GetRawOperandAsSSARegisterStack(0);
+ }
+ SSARegisterStack GetSourceSSARegisterStack() const
+ {
+ return GetRawOperandAsExpr(0).GetRawOperandAsPartialSSARegisterStackSource(0);
+ }
uint32_t GetDestRegister() const { return GetRawOperandAsRegister(1); }
LowLevelILInstruction GetSourceExpr() const { return GetRawOperandAsExpr(2); }
void SetDestSSAVersion(size_t version) { GetRawOperandAsExpr(0).UpdateRawOperand(1, version); }
void SetSourceSSAVersion(size_t version) { GetRawOperandAsExpr(0).UpdateRawOperand(2, version); }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_SET_FLAG>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_SET_FLAG> : public LowLevelILInstructionBase
{
uint32_t GetDestFlag() const { return GetRawOperandAsRegister(0); }
LowLevelILInstruction GetSourceExpr() const { return GetRawOperandAsExpr(1); }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_SET_FLAG_SSA>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_SET_FLAG_SSA> : public LowLevelILInstructionBase
{
SSAFlag GetDestSSAFlag() const { return GetRawOperandAsSSAFlag(0); }
LowLevelILInstruction GetSourceExpr() const { return GetRawOperandAsExpr(2); }
void SetDestSSAVersion(size_t version) { UpdateRawOperand(1, version); }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_LOAD>: public LowLevelILOneOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_LOAD_SSA>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_LOAD> : public LowLevelILOneOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_LOAD_SSA> : public LowLevelILInstructionBase
{
LowLevelILInstruction GetSourceExpr() const { return GetRawOperandAsExpr(0); }
size_t GetSourceMemoryVersion() const { return GetRawOperandAsIndex(1); }
void SetSourceMemoryVersion(size_t version) { UpdateRawOperand(1, version); }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_STORE>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_STORE> : public LowLevelILInstructionBase
{
LowLevelILInstruction GetDestExpr() const { return GetRawOperandAsExpr(0); }
LowLevelILInstruction GetSourceExpr() const { return GetRawOperandAsExpr(1); }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_STORE_SSA>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_STORE_SSA> : public LowLevelILInstructionBase
{
LowLevelILInstruction GetDestExpr() const { return GetRawOperandAsExpr(0); }
size_t GetDestMemoryVersion() const { return GetRawOperandAsIndex(1); }
@@ -1041,40 +1338,48 @@ namespace BinaryNinja
void SetSourceMemoryVersion(size_t version) { UpdateRawOperand(2, version); }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_REG>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_REG> : public LowLevelILInstructionBase
{
uint32_t GetSourceRegister() const { return GetRawOperandAsRegister(0); }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_REG_SSA>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_REG_SSA> : public LowLevelILInstructionBase
{
SSARegister GetSourceSSARegister() const { return GetRawOperandAsSSARegister(0); }
void SetSourceSSAVersion(size_t version) { UpdateRawOperand(1, version); }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_REG_SSA_PARTIAL>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_REG_SSA_PARTIAL> : public LowLevelILInstructionBase
{
SSARegister GetSourceSSARegister() const { return GetRawOperandAsSSARegister(0); }
uint32_t GetPartialRegister() const { return GetRawOperandAsRegister(2); }
void SetSourceSSAVersion(size_t version) { UpdateRawOperand(1, version); }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_REG_STACK_REL>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_REG_STACK_REL> : public LowLevelILInstructionBase
{
uint32_t GetSourceRegisterStack() const { return GetRawOperandAsRegister(0); }
LowLevelILInstruction GetSourceExpr() const { return GetRawOperandAsExpr(1); }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_REG_STACK_POP>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_REG_STACK_POP> : public LowLevelILInstructionBase
{
uint32_t GetSourceRegisterStack() const { return GetRawOperandAsRegister(0); }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_REG_STACK_FREE_REG>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_REG_STACK_FREE_REG> : public LowLevelILInstructionBase
{
uint32_t GetDestRegister() const { return GetRawOperandAsRegister(0); }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_REG_STACK_FREE_REL>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_REG_STACK_FREE_REL> : public LowLevelILInstructionBase
{
uint32_t GetDestRegisterStack() const { return GetRawOperandAsRegister(0); }
LowLevelILInstruction GetDestExpr() const { return GetRawOperandAsExpr(1); }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_REG_STACK_REL_SSA>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_REG_STACK_REL_SSA> : public LowLevelILInstructionBase
{
SSARegisterStack GetSourceSSARegisterStack() const { return GetRawOperandAsSSARegisterStack(0); }
LowLevelILInstruction GetSourceExpr() const { return GetRawOperandAsExpr(2); }
@@ -1082,57 +1387,78 @@ namespace BinaryNinja
void SetSourceSSAVersion(size_t version) { UpdateRawOperand(1, version); }
void SetTopSSAVersion(size_t version) { GetRawOperandAsExpr(3).UpdateRawOperand(1, version); }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_REG_STACK_ABS_SSA>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_REG_STACK_ABS_SSA> : public LowLevelILInstructionBase
{
SSARegisterStack GetSourceSSARegisterStack() const { return GetRawOperandAsSSARegisterStack(0); }
uint32_t GetSourceRegister() const { return GetRawOperandAsRegister(2); }
void SetSourceSSAVersion(size_t version) { UpdateRawOperand(1, version); }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_REG_STACK_FREE_REL_SSA>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_REG_STACK_FREE_REL_SSA> : public LowLevelILInstructionBase
{
- SSARegisterStack GetDestSSARegisterStack() const { return GetRawOperandAsExpr(0).GetRawOperandAsSSARegisterStack(0); }
- SSARegisterStack GetSourceSSARegisterStack() const { return GetRawOperandAsExpr(0).GetRawOperandAsPartialSSARegisterStackSource(0); }
+ SSARegisterStack GetDestSSARegisterStack() const
+ {
+ return GetRawOperandAsExpr(0).GetRawOperandAsSSARegisterStack(0);
+ }
+ SSARegisterStack GetSourceSSARegisterStack() const
+ {
+ return GetRawOperandAsExpr(0).GetRawOperandAsPartialSSARegisterStackSource(0);
+ }
LowLevelILInstruction GetDestExpr() const { return GetRawOperandAsExpr(1); }
SSARegister GetTopSSARegister() const { return GetRawOperandAsExpr(2).GetRawOperandAsSSARegister(0); }
void SetDestSSAVersion(size_t version) { GetRawOperandAsExpr(0).UpdateRawOperand(1, version); }
void SetSourceSSAVersion(size_t version) { GetRawOperandAsExpr(0).UpdateRawOperand(2, version); }
void SetTopSSAVersion(size_t version) { GetRawOperandAsExpr(2).UpdateRawOperand(1, version); }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_REG_STACK_FREE_ABS_SSA>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_REG_STACK_FREE_ABS_SSA> : public LowLevelILInstructionBase
{
- SSARegisterStack GetDestSSARegisterStack() const { return GetRawOperandAsExpr(0).GetRawOperandAsSSARegisterStack(0); }
- SSARegisterStack GetSourceSSARegisterStack() const { return GetRawOperandAsExpr(0).GetRawOperandAsPartialSSARegisterStackSource(0); }
+ SSARegisterStack GetDestSSARegisterStack() const
+ {
+ return GetRawOperandAsExpr(0).GetRawOperandAsSSARegisterStack(0);
+ }
+ SSARegisterStack GetSourceSSARegisterStack() const
+ {
+ return GetRawOperandAsExpr(0).GetRawOperandAsPartialSSARegisterStackSource(0);
+ }
uint32_t GetDestRegister() const { return GetRawOperandAsRegister(1); }
void SetDestSSAVersion(size_t version) { GetRawOperandAsExpr(0).UpdateRawOperand(1, version); }
void SetSourceSSAVersion(size_t version) { GetRawOperandAsExpr(0).UpdateRawOperand(2, version); }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_FLAG>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_FLAG> : public LowLevelILInstructionBase
{
uint32_t GetSourceFlag() const { return GetRawOperandAsRegister(0); }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_FLAG_BIT>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_FLAG_BIT> : public LowLevelILInstructionBase
{
uint32_t GetSourceFlag() const { return GetRawOperandAsRegister(0); }
size_t GetBitIndex() const { return GetRawOperandAsIndex(1); }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_FLAG_SSA>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_FLAG_SSA> : public LowLevelILInstructionBase
{
SSAFlag GetSourceSSAFlag() const { return GetRawOperandAsSSAFlag(0); }
void SetSourceSSAVersion(size_t version) { UpdateRawOperand(1, version); }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_FLAG_BIT_SSA>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_FLAG_BIT_SSA> : public LowLevelILInstructionBase
{
SSAFlag GetSourceSSAFlag() const { return GetRawOperandAsSSAFlag(0); }
size_t GetBitIndex() const { return GetRawOperandAsIndex(2); }
void SetSourceSSAVersion(size_t version) { UpdateRawOperand(1, version); }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_REG_SPLIT>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_REG_SPLIT> : public LowLevelILInstructionBase
{
uint32_t GetHighRegister() const { return GetRawOperandAsRegister(0); }
uint32_t GetLowRegister() const { return GetRawOperandAsRegister(1); }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_REG_SPLIT_SSA>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_REG_SPLIT_SSA> : public LowLevelILInstructionBase
{
SSARegister GetHighSSARegister() const { return GetRawOperandAsSSARegister(0); }
SSARegister GetLowSSARegister() const { return GetRawOperandAsSSARegister(2); }
@@ -1140,224 +1466,447 @@ namespace BinaryNinja
void SetLowSSAVersion(size_t version) { UpdateRawOperand(3, version); }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_JUMP>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_JUMP> : public LowLevelILInstructionBase
{
LowLevelILInstruction GetDestExpr() const { return GetRawOperandAsExpr(0); }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_JUMP_TO>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_JUMP_TO> : public LowLevelILInstructionBase
{
LowLevelILInstruction GetDestExpr() const { return GetRawOperandAsExpr(0); }
LowLevelILIndexMap GetTargets() const { return GetRawOperandAsIndexMap(1); }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_CALL>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_CALL> : public LowLevelILInstructionBase
{
LowLevelILInstruction GetDestExpr() const { return GetRawOperandAsExpr(0); }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_CALL_STACK_ADJUST>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_CALL_STACK_ADJUST> : public LowLevelILInstructionBase
{
LowLevelILInstruction GetDestExpr() const { return GetRawOperandAsExpr(0); }
int64_t GetStackAdjustment() const { return GetRawOperandAsInteger(1); }
- _STD_MAP<uint32_t, int32_t> GetRegisterStackAdjustments() const { return GetRawOperandAsRegisterStackAdjustments(2); }
+ _STD_MAP<uint32_t, int32_t> GetRegisterStackAdjustments() const
+ {
+ return GetRawOperandAsRegisterStackAdjustments(2);
+ }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_TAILCALL>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_TAILCALL> : public LowLevelILInstructionBase
{
LowLevelILInstruction GetDestExpr() const { return GetRawOperandAsExpr(0); }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_RET>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_RET> : public LowLevelILInstructionBase
{
LowLevelILInstruction GetDestExpr() const { return GetRawOperandAsExpr(0); }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_IF>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_IF> : public LowLevelILInstructionBase
{
LowLevelILInstruction GetConditionExpr() const { return GetRawOperandAsExpr(0); }
size_t GetTrueTarget() const { return GetRawOperandAsIndex(1); }
size_t GetFalseTarget() const { return GetRawOperandAsIndex(2); }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_GOTO>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_GOTO> : public LowLevelILInstructionBase
{
size_t GetTarget() const { return GetRawOperandAsIndex(0); }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_FLAG_COND>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_FLAG_COND> : public LowLevelILInstructionBase
{
BNLowLevelILFlagCondition GetFlagCondition() const { return GetRawOperandAsFlagCondition(0); }
uint32_t GetSemanticFlagClass() const { return GetRawOperandAsRegister(1); }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_FLAG_GROUP>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_FLAG_GROUP> : public LowLevelILInstructionBase
{
uint32_t GetSemanticFlagGroup() const { return GetRawOperandAsRegister(0); }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_TRAP>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_TRAP> : public LowLevelILInstructionBase
{
int64_t GetVector() const { return GetRawOperandAsInteger(0); }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_CALL_SSA>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_CALL_SSA> : public LowLevelILInstructionBase
{
- LowLevelILSSARegisterList GetOutputSSARegisters() const { return GetRawOperandAsExpr(0).GetRawOperandAsSSARegisterList(1); }
+ LowLevelILSSARegisterList GetOutputSSARegisters() const
+ {
+ return GetRawOperandAsExpr(0).GetRawOperandAsSSARegisterList(1);
+ }
size_t GetDestMemoryVersion() const { return GetRawOperandAsExpr(0).GetRawOperandAsIndex(0); }
LowLevelILInstruction GetDestExpr() const { return GetRawOperandAsExpr(1); }
SSARegister GetStackSSARegister() const { return GetRawOperandAsExpr(2).GetRawOperandAsSSARegister(0); }
size_t GetSourceMemoryVersion() const { return GetRawOperandAsExpr(2).GetRawOperandAsIndex(2); }
- LowLevelILInstructionList GetParameterExprs() const { return GetRawOperandAsExpr(3).GetRawOperandAsExprList(0); }
+ LowLevelILInstructionList GetParameterExprs() const
+ {
+ return GetRawOperandAsExpr(3).GetRawOperandAsExprList(0);
+ }
void SetDestMemoryVersion(size_t version) { GetRawOperandAsExpr(0).UpdateRawOperand(0, version); }
void SetSourceMemoryVersion(size_t version) { GetRawOperandAsExpr(2).UpdateRawOperand(2, version); }
void SetStackSSAVersion(size_t version) { GetRawOperandAsExpr(2).UpdateRawOperand(1, version); }
- void SetOutputSSARegisters(const _STD_VECTOR<SSARegister>& regs) { GetRawOperandAsExpr(0).UpdateRawOperandAsSSARegisterList(1, regs); }
+ void SetOutputSSARegisters(const _STD_VECTOR<SSARegister>& regs)
+ {
+ GetRawOperandAsExpr(0).UpdateRawOperandAsSSARegisterList(1, regs);
+ }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_SYSCALL_SSA>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_SYSCALL_SSA> : public LowLevelILInstructionBase
{
- LowLevelILSSARegisterList GetOutputSSARegisters() const { return GetRawOperandAsExpr(0).GetRawOperandAsSSARegisterList(1); }
+ LowLevelILSSARegisterList GetOutputSSARegisters() const
+ {
+ return GetRawOperandAsExpr(0).GetRawOperandAsSSARegisterList(1);
+ }
size_t GetDestMemoryVersion() const { return GetRawOperandAsExpr(0).GetRawOperandAsIndex(0); }
SSARegister GetStackSSARegister() const { return GetRawOperandAsExpr(1).GetRawOperandAsSSARegister(0); }
size_t GetSourceMemoryVersion() const { return GetRawOperandAsExpr(1).GetRawOperandAsIndex(2); }
- LowLevelILInstructionList GetParameterExprs() const { return GetRawOperandAsExpr(2).GetRawOperandAsExprList(0); }
+ LowLevelILInstructionList GetParameterExprs() const
+ {
+ return GetRawOperandAsExpr(2).GetRawOperandAsExprList(0);
+ }
void SetDestMemoryVersion(size_t version) { GetRawOperandAsExpr(0).UpdateRawOperand(0, version); }
void SetSourceMemoryVersion(size_t version) { GetRawOperandAsExpr(1).UpdateRawOperand(2, version); }
void SetStackSSAVersion(size_t version) { GetRawOperandAsExpr(1).UpdateRawOperand(1, version); }
- void SetOutputSSARegisters(const _STD_VECTOR<SSARegister>& regs) { GetRawOperandAsExpr(0).UpdateRawOperandAsSSARegisterList(1, regs); }
+ void SetOutputSSARegisters(const _STD_VECTOR<SSARegister>& regs)
+ {
+ GetRawOperandAsExpr(0).UpdateRawOperandAsSSARegisterList(1, regs);
+ }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_TAILCALL_SSA>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_TAILCALL_SSA> : public LowLevelILInstructionBase
{
- LowLevelILSSARegisterList GetOutputSSARegisters() const { return GetRawOperandAsExpr(0).GetRawOperandAsSSARegisterList(1); }
+ LowLevelILSSARegisterList GetOutputSSARegisters() const
+ {
+ return GetRawOperandAsExpr(0).GetRawOperandAsSSARegisterList(1);
+ }
size_t GetDestMemoryVersion() const { return GetRawOperandAsExpr(0).GetRawOperandAsIndex(0); }
LowLevelILInstruction GetDestExpr() const { return GetRawOperandAsExpr(1); }
SSARegister GetStackSSARegister() const { return GetRawOperandAsExpr(2).GetRawOperandAsSSARegister(0); }
size_t GetSourceMemoryVersion() const { return GetRawOperandAsExpr(2).GetRawOperandAsIndex(2); }
- LowLevelILInstructionList GetParameterExprs() const { return GetRawOperandAsExpr(3).GetRawOperandAsExprList(0); }
+ LowLevelILInstructionList GetParameterExprs() const
+ {
+ return GetRawOperandAsExpr(3).GetRawOperandAsExprList(0);
+ }
void SetDestMemoryVersion(size_t version) { GetRawOperandAsExpr(0).UpdateRawOperand(0, version); }
void SetSourceMemoryVersion(size_t version) { GetRawOperandAsExpr(2).UpdateRawOperand(2, version); }
void SetStackSSAVersion(size_t version) { GetRawOperandAsExpr(2).UpdateRawOperand(1, version); }
- void SetOutputSSARegisters(const _STD_VECTOR<SSARegister>& regs) { GetRawOperandAsExpr(0).UpdateRawOperandAsSSARegisterList(1, regs); }
+ void SetOutputSSARegisters(const _STD_VECTOR<SSARegister>& regs)
+ {
+ GetRawOperandAsExpr(0).UpdateRawOperandAsSSARegisterList(1, regs);
+ }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_INTRINSIC>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_INTRINSIC> : public LowLevelILInstructionBase
{
- LowLevelILRegisterOrFlagList GetOutputRegisterOrFlagList() const { return GetRawOperandAsRegisterOrFlagList(0); }
+ LowLevelILRegisterOrFlagList GetOutputRegisterOrFlagList() const
+ {
+ return GetRawOperandAsRegisterOrFlagList(0);
+ }
uint32_t GetIntrinsic() const { return GetRawOperandAsRegister(2); }
- LowLevelILInstructionList GetParameterExprs() const { return GetRawOperandAsExpr(3).GetRawOperandAsExprList(0); }
+ LowLevelILInstructionList GetParameterExprs() const
+ {
+ return GetRawOperandAsExpr(3).GetRawOperandAsExprList(0);
+ }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_INTRINSIC_SSA>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_INTRINSIC_SSA> : public LowLevelILInstructionBase
{
- LowLevelILSSARegisterOrFlagList GetOutputSSARegisterOrFlagList() const { return GetRawOperandAsSSARegisterOrFlagList(0); }
+ LowLevelILSSARegisterOrFlagList GetOutputSSARegisterOrFlagList() const
+ {
+ return GetRawOperandAsSSARegisterOrFlagList(0);
+ }
uint32_t GetIntrinsic() const { return GetRawOperandAsRegister(2); }
- LowLevelILInstructionList GetParameterExprs() const { return GetRawOperandAsExpr(3).GetRawOperandAsExprList(0); }
- void SetOutputSSARegisterOrFlagList(const _STD_VECTOR<SSARegisterOrFlag>& outputs) { UpdateRawOperandAsSSARegisterOrFlagList(0, outputs); }
+ LowLevelILInstructionList GetParameterExprs() const
+ {
+ return GetRawOperandAsExpr(3).GetRawOperandAsExprList(0);
+ }
+ void SetOutputSSARegisterOrFlagList(const _STD_VECTOR<SSARegisterOrFlag>& outputs)
+ {
+ UpdateRawOperandAsSSARegisterOrFlagList(0, outputs);
+ }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_REG_PHI>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_REG_PHI> : public LowLevelILInstructionBase
{
SSARegister GetDestSSARegister() const { return GetRawOperandAsSSARegister(0); }
LowLevelILSSARegisterList GetSourceSSARegisters() const { return GetRawOperandAsSSARegisterList(2); }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_REG_STACK_PHI>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_REG_STACK_PHI> : public LowLevelILInstructionBase
{
SSARegisterStack GetDestSSARegisterStack() const { return GetRawOperandAsSSARegisterStack(0); }
- LowLevelILSSARegisterStackList GetSourceSSARegisterStacks() const { return GetRawOperandAsSSARegisterStackList(2); }
+ LowLevelILSSARegisterStackList GetSourceSSARegisterStacks() const
+ {
+ return GetRawOperandAsSSARegisterStackList(2);
+ }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_FLAG_PHI>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_FLAG_PHI> : public LowLevelILInstructionBase
{
SSAFlag GetDestSSAFlag() const { return GetRawOperandAsSSAFlag(0); }
LowLevelILSSAFlagList GetSourceSSAFlags() const { return GetRawOperandAsSSAFlagList(2); }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_MEM_PHI>: public LowLevelILInstructionBase
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_MEM_PHI> : public LowLevelILInstructionBase
{
size_t GetDestMemoryVersion() const { return GetRawOperandAsIndex(0); }
LowLevelILIndexList GetSourceMemoryVersions() const { return GetRawOperandAsIndexList(1); }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_EXTERN_PTR>: public LowLevelILConstantInstruction
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_EXTERN_PTR> : public LowLevelILConstantInstruction
{
size_t GetConstant() const { return GetRawOperandAsIndex(0); }
size_t GetOffset() const { return GetRawOperandAsIndex(1); }
};
- template <> struct LowLevelILInstructionAccessor<LLIL_NOP>: public LowLevelILInstructionBase {};
- template <> struct LowLevelILInstructionAccessor<LLIL_POP>: public LowLevelILInstructionBase {};
- template <> struct LowLevelILInstructionAccessor<LLIL_NORET>: public LowLevelILInstructionBase {};
- template <> struct LowLevelILInstructionAccessor<LLIL_SYSCALL>: public LowLevelILInstructionBase {};
- template <> struct LowLevelILInstructionAccessor<LLIL_BP>: public LowLevelILInstructionBase {};
- template <> struct LowLevelILInstructionAccessor<LLIL_UNDEF>: public LowLevelILInstructionBase {};
- template <> struct LowLevelILInstructionAccessor<LLIL_UNIMPL>: public LowLevelILInstructionBase {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_NOP> : public LowLevelILInstructionBase
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_POP> : public LowLevelILInstructionBase
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_NORET> : public LowLevelILInstructionBase
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_SYSCALL> : public LowLevelILInstructionBase
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_BP> : public LowLevelILInstructionBase
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_UNDEF> : public LowLevelILInstructionBase
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_UNIMPL> : public LowLevelILInstructionBase
+ {};
- template <> struct LowLevelILInstructionAccessor<LLIL_CONST>: public LowLevelILConstantInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_CONST_PTR>: public LowLevelILConstantInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_FLOAT_CONST>: public LowLevelILConstantInstruction {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_CONST> : public LowLevelILConstantInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_CONST_PTR> : public LowLevelILConstantInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_FLOAT_CONST> : public LowLevelILConstantInstruction
+ {};
- template <> struct LowLevelILInstructionAccessor<LLIL_ADD>: public LowLevelILTwoOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_SUB>: public LowLevelILTwoOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_AND>: public LowLevelILTwoOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_OR>: public LowLevelILTwoOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_XOR>: public LowLevelILTwoOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_LSL>: public LowLevelILTwoOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_LSR>: public LowLevelILTwoOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_ASR>: public LowLevelILTwoOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_ROL>: public LowLevelILTwoOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_ROR>: public LowLevelILTwoOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_MUL>: public LowLevelILTwoOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_MULU_DP>: public LowLevelILTwoOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_MULS_DP>: public LowLevelILTwoOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_DIVU>: public LowLevelILTwoOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_DIVS>: public LowLevelILTwoOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_MODU>: public LowLevelILTwoOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_MODS>: public LowLevelILTwoOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_DIVU_DP>: public LowLevelILTwoOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_DIVS_DP>: public LowLevelILTwoOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_MODU_DP>: public LowLevelILTwoOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_MODS_DP>: public LowLevelILTwoOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_CMP_E>: public LowLevelILTwoOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_CMP_NE>: public LowLevelILTwoOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_CMP_SLT>: public LowLevelILTwoOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_CMP_ULT>: public LowLevelILTwoOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_CMP_SLE>: public LowLevelILTwoOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_CMP_ULE>: public LowLevelILTwoOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_CMP_SGE>: public LowLevelILTwoOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_CMP_UGE>: public LowLevelILTwoOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_CMP_SGT>: public LowLevelILTwoOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_CMP_UGT>: public LowLevelILTwoOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_TEST_BIT>: public LowLevelILTwoOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_ADD_OVERFLOW>: public LowLevelILTwoOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_FADD>: public LowLevelILTwoOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_FSUB>: public LowLevelILTwoOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_FMUL>: public LowLevelILTwoOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_FDIV>: public LowLevelILTwoOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_FCMP_E>: public LowLevelILTwoOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_FCMP_NE>: public LowLevelILTwoOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_FCMP_LT>: public LowLevelILTwoOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_FCMP_LE>: public LowLevelILTwoOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_FCMP_GE>: public LowLevelILTwoOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_FCMP_GT>: public LowLevelILTwoOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_FCMP_O>: public LowLevelILTwoOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_FCMP_UO>: public LowLevelILTwoOperandInstruction {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_ADD> : public LowLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_SUB> : public LowLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_AND> : public LowLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_OR> : public LowLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_XOR> : public LowLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_LSL> : public LowLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_LSR> : public LowLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_ASR> : public LowLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_ROL> : public LowLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_ROR> : public LowLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_MUL> : public LowLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_MULU_DP> : public LowLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_MULS_DP> : public LowLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_DIVU> : public LowLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_DIVS> : public LowLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_MODU> : public LowLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_MODS> : public LowLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_DIVU_DP> : public LowLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_DIVS_DP> : public LowLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_MODU_DP> : public LowLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_MODS_DP> : public LowLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_CMP_E> : public LowLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_CMP_NE> : public LowLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_CMP_SLT> : public LowLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_CMP_ULT> : public LowLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_CMP_SLE> : public LowLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_CMP_ULE> : public LowLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_CMP_SGE> : public LowLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_CMP_UGE> : public LowLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_CMP_SGT> : public LowLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_CMP_UGT> : public LowLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_TEST_BIT> : public LowLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_ADD_OVERFLOW> : public LowLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_FADD> : public LowLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_FSUB> : public LowLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_FMUL> : public LowLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_FDIV> : public LowLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_FCMP_E> : public LowLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_FCMP_NE> : public LowLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_FCMP_LT> : public LowLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_FCMP_LE> : public LowLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_FCMP_GE> : public LowLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_FCMP_GT> : public LowLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_FCMP_O> : public LowLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_FCMP_UO> : public LowLevelILTwoOperandInstruction
+ {};
- template <> struct LowLevelILInstructionAccessor<LLIL_ADC>: public LowLevelILTwoOperandWithCarryInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_SBB>: public LowLevelILTwoOperandWithCarryInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_RLC>: public LowLevelILTwoOperandWithCarryInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_RRC>: public LowLevelILTwoOperandWithCarryInstruction {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_ADC> : public LowLevelILTwoOperandWithCarryInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_SBB> : public LowLevelILTwoOperandWithCarryInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_RLC> : public LowLevelILTwoOperandWithCarryInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_RRC> : public LowLevelILTwoOperandWithCarryInstruction
+ {};
- template <> struct LowLevelILInstructionAccessor<LLIL_PUSH>: public LowLevelILOneOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_NEG>: public LowLevelILOneOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_NOT>: public LowLevelILOneOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_SX>: public LowLevelILOneOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_ZX>: public LowLevelILOneOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_LOW_PART>: public LowLevelILOneOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_BOOL_TO_INT>: public LowLevelILOneOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_UNIMPL_MEM>: public LowLevelILOneOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_FSQRT>: public LowLevelILOneOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_FNEG>: public LowLevelILOneOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_FABS>: public LowLevelILOneOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_FLOAT_TO_INT>: public LowLevelILOneOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_INT_TO_FLOAT>: public LowLevelILOneOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_FLOAT_CONV>: public LowLevelILOneOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_ROUND_TO_INT>: public LowLevelILOneOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_FLOOR>: public LowLevelILOneOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_CEIL>: public LowLevelILOneOperandInstruction {};
- template <> struct LowLevelILInstructionAccessor<LLIL_FTRUNC>: public LowLevelILOneOperandInstruction {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_PUSH> : public LowLevelILOneOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_NEG> : public LowLevelILOneOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_NOT> : public LowLevelILOneOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_SX> : public LowLevelILOneOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_ZX> : public LowLevelILOneOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_LOW_PART> : public LowLevelILOneOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_BOOL_TO_INT> : public LowLevelILOneOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_UNIMPL_MEM> : public LowLevelILOneOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_FSQRT> : public LowLevelILOneOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_FNEG> : public LowLevelILOneOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_FABS> : public LowLevelILOneOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_FLOAT_TO_INT> : public LowLevelILOneOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_INT_TO_FLOAT> : public LowLevelILOneOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_FLOAT_CONV> : public LowLevelILOneOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_ROUND_TO_INT> : public LowLevelILOneOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_FLOOR> : public LowLevelILOneOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_CEIL> : public LowLevelILOneOperandInstruction
+ {};
+ template <>
+ struct LowLevelILInstructionAccessor<LLIL_FTRUNC> : public LowLevelILOneOperandInstruction
+ {};
#undef _STD_VECTOR
#undef _STD_SET
#undef _STD_UNORDERED_MAP
#undef _STD_MAP
-}
+} // namespace BinaryNinjaCore
diff --git a/mediumlevelil.cpp b/mediumlevelil.cpp
index 04fcb0c0..4d606c41 100644
--- a/mediumlevelil.cpp
+++ b/mediumlevelil.cpp
@@ -97,27 +97,27 @@ BNMediumLevelILLabel* MediumLevelILFunction::GetLabelForSourceInstruction(size_t
}
-ExprId MediumLevelILFunction::AddExpr(BNMediumLevelILOperation operation, size_t size,
- ExprId a, ExprId b, ExprId c, ExprId d, ExprId e)
+ExprId MediumLevelILFunction::AddExpr(
+ BNMediumLevelILOperation operation, size_t size, ExprId a, ExprId b, ExprId c, ExprId d, ExprId e)
{
return BNMediumLevelILAddExpr(m_object, operation, size, a, b, c, d, e);
}
ExprId MediumLevelILFunction::AddExprWithLocation(BNMediumLevelILOperation operation, uint64_t addr,
- uint32_t sourceOperand, size_t size, ExprId a, ExprId b, ExprId c, ExprId d, ExprId e)
+ uint32_t sourceOperand, size_t size, ExprId a, ExprId b, ExprId c, ExprId d, ExprId e)
{
return BNMediumLevelILAddExprWithLocation(m_object, operation, addr, sourceOperand, size, a, b, c, d, e);
}
ExprId MediumLevelILFunction::AddExprWithLocation(BNMediumLevelILOperation operation, const ILSourceLocation& loc,
- size_t size, ExprId a, ExprId b, ExprId c, ExprId d, ExprId e)
+ size_t size, ExprId a, ExprId b, ExprId c, ExprId d, ExprId e)
{
if (loc.valid)
{
- return BNMediumLevelILAddExprWithLocation(m_object, operation, loc.address, loc.sourceOperand,
- size, a, b, c, d, e);
+ return BNMediumLevelILAddExprWithLocation(
+ m_object, operation, loc.address, loc.sourceOperand, size, a, b, c, d, e);
}
return BNMediumLevelILAddExpr(m_object, operation, size, a, b, c, d, e);
}
@@ -137,8 +137,8 @@ ExprId MediumLevelILFunction::Goto(BNMediumLevelILLabel& label, const ILSourceLo
}
-ExprId MediumLevelILFunction::If(ExprId operand, BNMediumLevelILLabel& t, BNMediumLevelILLabel& f,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::If(
+ ExprId operand, BNMediumLevelILLabel& t, BNMediumLevelILLabel& f, const ILSourceLocation& loc)
{
if (loc.valid)
return BNMediumLevelILIfWithLocation(m_object, operand, &t, &f, loc.address, loc.sourceOperand);
@@ -310,7 +310,7 @@ void MediumLevelILFunction::Finalize()
void MediumLevelILFunction::GenerateSSAForm(bool analyzeConditionals, bool handleAliases,
- const set<Variable>& knownNotAliases, const set<Variable>& knownAliases)
+ const set<Variable>& knownNotAliases, const set<Variable>& knownAliases)
{
BNVariable* knownNotAlias = new BNVariable[knownNotAliases.size()];
BNVariable* knownAlias = new BNVariable[knownAliases.size()];
@@ -332,18 +332,19 @@ void MediumLevelILFunction::GenerateSSAForm(bool analyzeConditionals, bool handl
}
BNGenerateMediumLevelILSSAForm(m_object, analyzeConditionals, handleAliases, knownNotAlias, knownNotAliases.size(),
- knownAlias, knownAliases.size());
+ knownAlias, knownAliases.size());
delete[] knownNotAlias;
delete[] knownAlias;
}
-bool MediumLevelILFunction::GetExprText(Architecture* arch, ExprId expr, vector<InstructionTextToken>& tokens, DisassemblySettings* settings)
+bool MediumLevelILFunction::GetExprText(
+ Architecture* arch, ExprId expr, vector<InstructionTextToken>& tokens, DisassemblySettings* settings)
{
size_t count;
BNInstructionTextToken* list;
- if (!BNGetMediumLevelILExprText(m_object, arch->GetObject(), expr, &list, &count,
- settings ? settings->GetObject() : nullptr))
+ if (!BNGetMediumLevelILExprText(
+ m_object, arch->GetObject(), expr, &list, &count, settings ? settings->GetObject() : nullptr))
return false;
tokens = InstructionTextToken::ConvertAndFreeInstructionTextTokenList(list, count);
@@ -352,12 +353,12 @@ bool MediumLevelILFunction::GetExprText(Architecture* arch, ExprId expr, vector<
bool MediumLevelILFunction::GetInstructionText(Function* func, Architecture* arch, size_t instr,
- vector<InstructionTextToken>& tokens, DisassemblySettings* settings)
+ vector<InstructionTextToken>& tokens, DisassemblySettings* settings)
{
size_t count;
BNInstructionTextToken* list;
- if (!BNGetMediumLevelILInstructionText(m_object, func ? func->GetObject() : nullptr, arch->GetObject(), instr, &list, &count,
- settings ? settings->GetObject() : nullptr))
+ if (!BNGetMediumLevelILInstructionText(m_object, func ? func->GetObject() : nullptr, arch->GetObject(), instr,
+ &list, &count, settings ? settings->GetObject() : nullptr))
return false;
tokens = InstructionTextToken::ConvertAndFreeInstructionTextTokenList(list, count);
@@ -366,7 +367,7 @@ bool MediumLevelILFunction::GetInstructionText(Function* func, Architecture* arc
void MediumLevelILFunction::VisitInstructions(
- const function<void(BasicBlock* block, const MediumLevelILInstruction& instr)>& func)
+ const function<void(BasicBlock* block, const MediumLevelILInstruction& instr)>& func)
{
for (auto& i : GetBasicBlocks())
for (size_t j = i->GetStart(); j < i->GetEnd(); j++)
@@ -375,12 +376,10 @@ void MediumLevelILFunction::VisitInstructions(
void MediumLevelILFunction::VisitAllExprs(
- const function<bool(BasicBlock* block, const MediumLevelILInstruction& expr)>& func)
+ const function<bool(BasicBlock* block, const MediumLevelILInstruction& expr)>& func)
{
VisitInstructions([&](BasicBlock* block, const MediumLevelILInstruction& instr) {
- instr.VisitExprs([&](const MediumLevelILInstruction& expr) {
- return func(block, expr);
- });
+ instr.VisitExprs([&](const MediumLevelILInstruction& expr) { return func(block, expr); });
});
}
@@ -545,22 +544,21 @@ RegisterValue MediumLevelILFunction::GetExprValue(const MediumLevelILInstruction
}
-PossibleValueSet MediumLevelILFunction::GetPossibleSSAVarValues(const SSAVariable& var, size_t instr,
- const set<BNDataFlowQueryOption>& options)
+PossibleValueSet MediumLevelILFunction::GetPossibleSSAVarValues(
+ const SSAVariable& var, size_t instr, const set<BNDataFlowQueryOption>& options)
{
BNDataFlowQueryOption* optionArray = new BNDataFlowQueryOption[options.size()];
size_t idx = 0;
for (auto i : options)
optionArray[idx++] = i;
- BNPossibleValueSet value = BNGetMediumLevelILPossibleSSAVarValues(m_object, &var.var, var.version, instr,
- optionArray, options.size());
+ BNPossibleValueSet value =
+ BNGetMediumLevelILPossibleSSAVarValues(m_object, &var.var, var.version, instr, optionArray, options.size());
delete[] optionArray;
return PossibleValueSet::FromAPIObject(value);
}
-PossibleValueSet MediumLevelILFunction::GetPossibleExprValues(size_t expr,
- const set<BNDataFlowQueryOption>& options)
+PossibleValueSet MediumLevelILFunction::GetPossibleExprValues(size_t expr, const set<BNDataFlowQueryOption>& options)
{
BNDataFlowQueryOption* optionArray = new BNDataFlowQueryOption[options.size()];
size_t idx = 0;
@@ -572,8 +570,8 @@ PossibleValueSet MediumLevelILFunction::GetPossibleExprValues(size_t expr,
}
-PossibleValueSet MediumLevelILFunction::GetPossibleExprValues(const MediumLevelILInstruction& expr,
- const set<BNDataFlowQueryOption>& options)
+PossibleValueSet MediumLevelILFunction::GetPossibleExprValues(
+ const MediumLevelILInstruction& expr, const set<BNDataFlowQueryOption>& options)
{
return GetPossibleExprValues(expr.exprIndex, options);
}
@@ -623,29 +621,29 @@ RegisterValue MediumLevelILFunction::GetRegisterValueAfterInstruction(uint32_t r
}
-PossibleValueSet MediumLevelILFunction::GetPossibleRegisterValuesAtInstruction(uint32_t reg, size_t instr,
- const set<BNDataFlowQueryOption>& options)
+PossibleValueSet MediumLevelILFunction::GetPossibleRegisterValuesAtInstruction(
+ uint32_t reg, size_t instr, const set<BNDataFlowQueryOption>& options)
{
BNDataFlowQueryOption* optionArray = new BNDataFlowQueryOption[options.size()];
size_t idx = 0;
for (auto i : options)
optionArray[idx++] = i;
- BNPossibleValueSet value = BNGetMediumLevelILPossibleRegisterValuesAtInstruction(m_object, reg, instr,
- optionArray, options.size());
+ BNPossibleValueSet value =
+ BNGetMediumLevelILPossibleRegisterValuesAtInstruction(m_object, reg, instr, optionArray, options.size());
delete[] optionArray;
return PossibleValueSet::FromAPIObject(value);
}
-PossibleValueSet MediumLevelILFunction::GetPossibleRegisterValuesAfterInstruction(uint32_t reg, size_t instr,
- const set<BNDataFlowQueryOption>& options)
+PossibleValueSet MediumLevelILFunction::GetPossibleRegisterValuesAfterInstruction(
+ uint32_t reg, size_t instr, const set<BNDataFlowQueryOption>& options)
{
BNDataFlowQueryOption* optionArray = new BNDataFlowQueryOption[options.size()];
size_t idx = 0;
for (auto i : options)
optionArray[idx++] = i;
- BNPossibleValueSet value = BNGetMediumLevelILPossibleRegisterValuesAfterInstruction(m_object, reg, instr,
- optionArray, options.size());
+ BNPossibleValueSet value =
+ BNGetMediumLevelILPossibleRegisterValuesAfterInstruction(m_object, reg, instr, optionArray, options.size());
delete[] optionArray;
return PossibleValueSet::FromAPIObject(value);
}
@@ -665,29 +663,29 @@ RegisterValue MediumLevelILFunction::GetFlagValueAfterInstruction(uint32_t flag,
}
-PossibleValueSet MediumLevelILFunction::GetPossibleFlagValuesAtInstruction(uint32_t flag, size_t instr,
- const set<BNDataFlowQueryOption>& options)
+PossibleValueSet MediumLevelILFunction::GetPossibleFlagValuesAtInstruction(
+ uint32_t flag, size_t instr, const set<BNDataFlowQueryOption>& options)
{
BNDataFlowQueryOption* optionArray = new BNDataFlowQueryOption[options.size()];
size_t idx = 0;
for (auto i : options)
optionArray[idx++] = i;
- BNPossibleValueSet value = BNGetMediumLevelILPossibleFlagValuesAtInstruction(m_object, flag, instr,
- optionArray, options.size());
+ BNPossibleValueSet value =
+ BNGetMediumLevelILPossibleFlagValuesAtInstruction(m_object, flag, instr, optionArray, options.size());
delete[] optionArray;
return PossibleValueSet::FromAPIObject(value);
}
-PossibleValueSet MediumLevelILFunction::GetPossibleFlagValuesAfterInstruction(uint32_t flag, size_t instr,
- const set<BNDataFlowQueryOption>& options)
+PossibleValueSet MediumLevelILFunction::GetPossibleFlagValuesAfterInstruction(
+ uint32_t flag, size_t instr, const set<BNDataFlowQueryOption>& options)
{
BNDataFlowQueryOption* optionArray = new BNDataFlowQueryOption[options.size()];
size_t idx = 0;
for (auto i : options)
optionArray[idx++] = i;
- BNPossibleValueSet value = BNGetMediumLevelILPossibleFlagValuesAfterInstruction(m_object, flag, instr,
- optionArray, options.size());
+ BNPossibleValueSet value =
+ BNGetMediumLevelILPossibleFlagValuesAfterInstruction(m_object, flag, instr, optionArray, options.size());
delete[] optionArray;
return PossibleValueSet::FromAPIObject(value);
}
@@ -707,29 +705,29 @@ RegisterValue MediumLevelILFunction::GetStackContentsAfterInstruction(int32_t of
}
-PossibleValueSet MediumLevelILFunction::GetPossibleStackContentsAtInstruction(int32_t offset, size_t len, size_t instr,
- const set<BNDataFlowQueryOption>& options)
+PossibleValueSet MediumLevelILFunction::GetPossibleStackContentsAtInstruction(
+ int32_t offset, size_t len, size_t instr, const set<BNDataFlowQueryOption>& options)
{
BNDataFlowQueryOption* optionArray = new BNDataFlowQueryOption[options.size()];
size_t idx = 0;
for (auto i : options)
optionArray[idx++] = i;
- BNPossibleValueSet value = BNGetMediumLevelILPossibleStackContentsAtInstruction(m_object, offset, len, instr,
- optionArray, options.size());
+ BNPossibleValueSet value =
+ BNGetMediumLevelILPossibleStackContentsAtInstruction(m_object, offset, len, instr, optionArray, options.size());
delete[] optionArray;
return PossibleValueSet::FromAPIObject(value);
}
-PossibleValueSet MediumLevelILFunction::GetPossibleStackContentsAfterInstruction(int32_t offset, size_t len, size_t instr,
- const set<BNDataFlowQueryOption>& options)
+PossibleValueSet MediumLevelILFunction::GetPossibleStackContentsAfterInstruction(
+ int32_t offset, size_t len, size_t instr, const set<BNDataFlowQueryOption>& options)
{
BNDataFlowQueryOption* optionArray = new BNDataFlowQueryOption[options.size()];
size_t idx = 0;
for (auto i : options)
optionArray[idx++] = i;
- BNPossibleValueSet value = BNGetMediumLevelILPossibleStackContentsAfterInstruction(m_object, offset, len, instr,
- optionArray, options.size());
+ BNPossibleValueSet value = BNGetMediumLevelILPossibleStackContentsAfterInstruction(
+ m_object, offset, len, instr, optionArray, options.size());
delete[] optionArray;
return PossibleValueSet::FromAPIObject(value);
}
@@ -741,7 +739,8 @@ BNILBranchDependence MediumLevelILFunction::GetBranchDependenceAtInstruction(siz
}
-unordered_map<size_t, BNILBranchDependence> MediumLevelILFunction::GetAllBranchDependenceAtInstruction(size_t instr) const
+unordered_map<size_t, BNILBranchDependence> MediumLevelILFunction::GetAllBranchDependenceAtInstruction(
+ size_t instr) const
{
size_t count;
BNILBranchInstructionAndDependence* deps = BNGetAllMediumLevelILBranchDependence(m_object, instr, &count);
diff --git a/mediumlevelilinstruction.cpp b/mediumlevelilinstruction.cpp
index 7235687b..29a58de7 100644
--- a/mediumlevelilinstruction.cpp
+++ b/mediumlevelilinstruction.cpp
@@ -19,14 +19,14 @@
// IN THE SOFTWARE.
#ifdef BINARYNINJACORE_LIBRARY
-#include "mediumlevelilfunction.h"
-#include "mediumlevelilssafunction.h"
-#include "lowlevelilfunction.h"
+ #include "mediumlevelilfunction.h"
+ #include "mediumlevelilssafunction.h"
+ #include "lowlevelilfunction.h"
using namespace BinaryNinjaCore;
#else
-#include "binaryninjaapi.h"
-#include "mediumlevelilinstruction.h"
-#include "lowlevelilinstruction.h"
+ #include "binaryninjaapi.h"
+ #include "mediumlevelilinstruction.h"
+ #include "lowlevelilinstruction.h"
using namespace BinaryNinja;
#endif
@@ -35,219 +35,208 @@ using namespace std;
#endif
-unordered_map<MediumLevelILOperandUsage, MediumLevelILOperandType>
- MediumLevelILInstructionBase::operandTypeForUsage = {
- {SourceExprMediumLevelOperandUsage, ExprMediumLevelOperand},
- {SourceVariableMediumLevelOperandUsage, VariableMediumLevelOperand},
- {SourceSSAVariableMediumLevelOperandUsage, SSAVariableMediumLevelOperand},
- {PartialSSAVariableSourceMediumLevelOperandUsage, SSAVariableMediumLevelOperand},
- {DestExprMediumLevelOperandUsage, ExprMediumLevelOperand},
- {DestVariableMediumLevelOperandUsage, VariableMediumLevelOperand},
- {DestSSAVariableMediumLevelOperandUsage, SSAVariableMediumLevelOperand},
- {LeftExprMediumLevelOperandUsage, ExprMediumLevelOperand},
- {RightExprMediumLevelOperandUsage, ExprMediumLevelOperand},
- {CarryExprMediumLevelOperandUsage, ExprMediumLevelOperand},
- {StackExprMediumLevelOperandUsage, ExprMediumLevelOperand},
- {ConditionExprMediumLevelOperandUsage, ExprMediumLevelOperand},
- {HighVariableMediumLevelOperandUsage, VariableMediumLevelOperand},
- {LowVariableMediumLevelOperandUsage, VariableMediumLevelOperand},
- {HighSSAVariableMediumLevelOperandUsage, VariableMediumLevelOperand},
- {LowSSAVariableMediumLevelOperandUsage, VariableMediumLevelOperand},
- {OffsetMediumLevelOperandUsage, IntegerMediumLevelOperand},
- {ConstantMediumLevelOperandUsage, IntegerMediumLevelOperand},
- {VectorMediumLevelOperandUsage, IntegerMediumLevelOperand},
- {IntrinsicMediumLevelOperandUsage, IntrinsicMediumLevelOperand},
- {TargetMediumLevelOperandUsage, IndexMediumLevelOperand},
- {TrueTargetMediumLevelOperandUsage, IndexMediumLevelOperand},
- {FalseTargetMediumLevelOperandUsage, IndexMediumLevelOperand},
- {DestMemoryVersionMediumLevelOperandUsage, IndexMediumLevelOperand},
- {SourceMemoryVersionMediumLevelOperandUsage, IndexMediumLevelOperand},
- {TargetsMediumLevelOperandUsage, IndexMapMediumLevelOperand},
- {SourceMemoryVersionsMediumLevelOperandUsage, IndexListMediumLevelOperand},
- {OutputVariablesMediumLevelOperandUsage, VariableListMediumLevelOperand},
- {OutputVariablesSubExprMediumLevelOperandUsage, VariableListMediumLevelOperand},
- {OutputSSAVariablesMediumLevelOperandUsage, SSAVariableListMediumLevelOperand},
- {OutputSSAVariablesSubExprMediumLevelOperandUsage, SSAVariableListMediumLevelOperand},
- {OutputSSAMemoryVersionMediumLevelOperandUsage, IndexMediumLevelOperand},
- {ParameterExprsMediumLevelOperandUsage, ExprListMediumLevelOperand},
- {SourceExprsMediumLevelOperandUsage, ExprListMediumLevelOperand},
- {ParameterVariablesMediumLevelOperandUsage, VariableListMediumLevelOperand},
- {ParameterSSAVariablesMediumLevelOperandUsage, SSAVariableListMediumLevelOperand},
- {ParameterSSAMemoryVersionMediumLevelOperandUsage, IndexMediumLevelOperand},
- {SourceSSAVariablesMediumLevelOperandUsages, SSAVariableListMediumLevelOperand}
- };
+unordered_map<MediumLevelILOperandUsage, MediumLevelILOperandType> MediumLevelILInstructionBase::operandTypeForUsage = {
+ {SourceExprMediumLevelOperandUsage, ExprMediumLevelOperand},
+ {SourceVariableMediumLevelOperandUsage, VariableMediumLevelOperand},
+ {SourceSSAVariableMediumLevelOperandUsage, SSAVariableMediumLevelOperand},
+ {PartialSSAVariableSourceMediumLevelOperandUsage, SSAVariableMediumLevelOperand},
+ {DestExprMediumLevelOperandUsage, ExprMediumLevelOperand},
+ {DestVariableMediumLevelOperandUsage, VariableMediumLevelOperand},
+ {DestSSAVariableMediumLevelOperandUsage, SSAVariableMediumLevelOperand},
+ {LeftExprMediumLevelOperandUsage, ExprMediumLevelOperand},
+ {RightExprMediumLevelOperandUsage, ExprMediumLevelOperand},
+ {CarryExprMediumLevelOperandUsage, ExprMediumLevelOperand},
+ {StackExprMediumLevelOperandUsage, ExprMediumLevelOperand},
+ {ConditionExprMediumLevelOperandUsage, ExprMediumLevelOperand},
+ {HighVariableMediumLevelOperandUsage, VariableMediumLevelOperand},
+ {LowVariableMediumLevelOperandUsage, VariableMediumLevelOperand},
+ {HighSSAVariableMediumLevelOperandUsage, VariableMediumLevelOperand},
+ {LowSSAVariableMediumLevelOperandUsage, VariableMediumLevelOperand},
+ {OffsetMediumLevelOperandUsage, IntegerMediumLevelOperand},
+ {ConstantMediumLevelOperandUsage, IntegerMediumLevelOperand},
+ {VectorMediumLevelOperandUsage, IntegerMediumLevelOperand},
+ {IntrinsicMediumLevelOperandUsage, IntrinsicMediumLevelOperand},
+ {TargetMediumLevelOperandUsage, IndexMediumLevelOperand},
+ {TrueTargetMediumLevelOperandUsage, IndexMediumLevelOperand},
+ {FalseTargetMediumLevelOperandUsage, IndexMediumLevelOperand},
+ {DestMemoryVersionMediumLevelOperandUsage, IndexMediumLevelOperand},
+ {SourceMemoryVersionMediumLevelOperandUsage, IndexMediumLevelOperand},
+ {TargetsMediumLevelOperandUsage, IndexMapMediumLevelOperand},
+ {SourceMemoryVersionsMediumLevelOperandUsage, IndexListMediumLevelOperand},
+ {OutputVariablesMediumLevelOperandUsage, VariableListMediumLevelOperand},
+ {OutputVariablesSubExprMediumLevelOperandUsage, VariableListMediumLevelOperand},
+ {OutputSSAVariablesMediumLevelOperandUsage, SSAVariableListMediumLevelOperand},
+ {OutputSSAVariablesSubExprMediumLevelOperandUsage, SSAVariableListMediumLevelOperand},
+ {OutputSSAMemoryVersionMediumLevelOperandUsage, IndexMediumLevelOperand},
+ {ParameterExprsMediumLevelOperandUsage, ExprListMediumLevelOperand},
+ {SourceExprsMediumLevelOperandUsage, ExprListMediumLevelOperand},
+ {ParameterVariablesMediumLevelOperandUsage, VariableListMediumLevelOperand},
+ {ParameterSSAVariablesMediumLevelOperandUsage, SSAVariableListMediumLevelOperand},
+ {ParameterSSAMemoryVersionMediumLevelOperandUsage, IndexMediumLevelOperand},
+ {SourceSSAVariablesMediumLevelOperandUsages, SSAVariableListMediumLevelOperand}};
unordered_map<BNMediumLevelILOperation, vector<MediumLevelILOperandUsage>>
- MediumLevelILInstructionBase::operationOperandUsage = {
- {MLIL_NOP, {}},
- {MLIL_NORET, {}},
- {MLIL_BP, {}},
- {MLIL_UNDEF, {}},
- {MLIL_UNIMPL, {}},
- {MLIL_SET_VAR, {DestVariableMediumLevelOperandUsage, SourceExprMediumLevelOperandUsage}},
- {MLIL_SET_VAR_FIELD, {DestVariableMediumLevelOperandUsage, OffsetMediumLevelOperandUsage,
- SourceExprMediumLevelOperandUsage}},
- {MLIL_SET_VAR_SPLIT, {HighVariableMediumLevelOperandUsage, LowVariableMediumLevelOperandUsage,
- SourceExprMediumLevelOperandUsage}},
- {MLIL_SET_VAR_SSA, {DestSSAVariableMediumLevelOperandUsage, SourceExprMediumLevelOperandUsage}},
- {MLIL_SET_VAR_SSA_FIELD, {DestSSAVariableMediumLevelOperandUsage, PartialSSAVariableSourceMediumLevelOperandUsage,
- OffsetMediumLevelOperandUsage, SourceExprMediumLevelOperandUsage}},
- {MLIL_SET_VAR_SPLIT_SSA, {HighSSAVariableMediumLevelOperandUsage, LowSSAVariableMediumLevelOperandUsage,
- SourceExprMediumLevelOperandUsage}},
- {MLIL_SET_VAR_ALIASED, {DestSSAVariableMediumLevelOperandUsage, PartialSSAVariableSourceMediumLevelOperandUsage,
- SourceExprMediumLevelOperandUsage}},
- {MLIL_SET_VAR_ALIASED_FIELD, {DestSSAVariableMediumLevelOperandUsage, PartialSSAVariableSourceMediumLevelOperandUsage,
- OffsetMediumLevelOperandUsage, SourceExprMediumLevelOperandUsage}},
- {MLIL_LOAD, {SourceExprMediumLevelOperandUsage}},
- {MLIL_LOAD_STRUCT, {SourceExprMediumLevelOperandUsage, OffsetMediumLevelOperandUsage}},
- {MLIL_LOAD_SSA, {SourceExprMediumLevelOperandUsage, SourceMemoryVersionMediumLevelOperandUsage}},
- {MLIL_LOAD_STRUCT_SSA, {SourceExprMediumLevelOperandUsage, OffsetMediumLevelOperandUsage,
- SourceMemoryVersionMediumLevelOperandUsage}},
- {MLIL_STORE, {DestExprMediumLevelOperandUsage, SourceExprMediumLevelOperandUsage}},
- {MLIL_STORE_STRUCT, {DestExprMediumLevelOperandUsage, OffsetMediumLevelOperandUsage,
- SourceExprMediumLevelOperandUsage}},
- {MLIL_STORE_SSA, {DestExprMediumLevelOperandUsage, DestMemoryVersionMediumLevelOperandUsage,
- SourceMemoryVersionMediumLevelOperandUsage, SourceExprMediumLevelOperandUsage}},
- {MLIL_STORE_STRUCT_SSA, {DestExprMediumLevelOperandUsage, OffsetMediumLevelOperandUsage,
- DestMemoryVersionMediumLevelOperandUsage, SourceMemoryVersionMediumLevelOperandUsage,
- SourceExprMediumLevelOperandUsage}},
- {MLIL_VAR, {SourceVariableMediumLevelOperandUsage}},
- {MLIL_VAR_FIELD, {SourceVariableMediumLevelOperandUsage, OffsetMediumLevelOperandUsage}},
- {MLIL_VAR_SPLIT, {HighVariableMediumLevelOperandUsage, LowVariableMediumLevelOperandUsage}},
- {MLIL_VAR_SSA, {SourceSSAVariableMediumLevelOperandUsage}},
- {MLIL_VAR_SSA_FIELD, {SourceSSAVariableMediumLevelOperandUsage, OffsetMediumLevelOperandUsage}},
- {MLIL_VAR_ALIASED, {SourceSSAVariableMediumLevelOperandUsage}},
- {MLIL_VAR_ALIASED_FIELD, {SourceSSAVariableMediumLevelOperandUsage, OffsetMediumLevelOperandUsage}},
- {MLIL_VAR_SPLIT_SSA, {HighSSAVariableMediumLevelOperandUsage, LowSSAVariableMediumLevelOperandUsage}},
- {MLIL_ADDRESS_OF, {SourceVariableMediumLevelOperandUsage}},
- {MLIL_ADDRESS_OF_FIELD, {SourceVariableMediumLevelOperandUsage, OffsetMediumLevelOperandUsage}},
- {MLIL_JUMP, {DestExprMediumLevelOperandUsage}},
- {MLIL_JUMP_TO, {DestExprMediumLevelOperandUsage, TargetsMediumLevelOperandUsage}},
- {MLIL_RET_HINT, {DestExprMediumLevelOperandUsage}},
- {MLIL_CALL, {OutputVariablesMediumLevelOperandUsage, DestExprMediumLevelOperandUsage,
- ParameterExprsMediumLevelOperandUsage}},
- {MLIL_CALL_UNTYPED, {OutputVariablesSubExprMediumLevelOperandUsage, DestExprMediumLevelOperandUsage,
- ParameterVariablesMediumLevelOperandUsage}},
- {MLIL_SYSCALL, {OutputVariablesMediumLevelOperandUsage, ParameterExprsMediumLevelOperandUsage}},
- {MLIL_SYSCALL_UNTYPED, {OutputVariablesSubExprMediumLevelOperandUsage,
- ParameterVariablesMediumLevelOperandUsage, StackExprMediumLevelOperandUsage}},
- {MLIL_TAILCALL, {OutputVariablesMediumLevelOperandUsage, DestExprMediumLevelOperandUsage,
- ParameterExprsMediumLevelOperandUsage}},
- {MLIL_TAILCALL_UNTYPED, {OutputVariablesSubExprMediumLevelOperandUsage, DestExprMediumLevelOperandUsage,
- ParameterVariablesMediumLevelOperandUsage}},
- {MLIL_CALL_SSA, {OutputSSAVariablesSubExprMediumLevelOperandUsage,
- OutputSSAMemoryVersionMediumLevelOperandUsage, DestExprMediumLevelOperandUsage,
- ParameterExprsMediumLevelOperandUsage, SourceMemoryVersionMediumLevelOperandUsage}},
- {MLIL_CALL_UNTYPED_SSA, {OutputSSAVariablesSubExprMediumLevelOperandUsage,
- OutputSSAMemoryVersionMediumLevelOperandUsage, DestExprMediumLevelOperandUsage,
- ParameterSSAVariablesMediumLevelOperandUsage, ParameterSSAMemoryVersionMediumLevelOperandUsage,
- StackExprMediumLevelOperandUsage}},
- {MLIL_SYSCALL_SSA, {OutputSSAVariablesSubExprMediumLevelOperandUsage,
- OutputSSAMemoryVersionMediumLevelOperandUsage, ParameterExprsMediumLevelOperandUsage,
- SourceMemoryVersionMediumLevelOperandUsage}},
- {MLIL_SYSCALL_UNTYPED_SSA, {OutputSSAVariablesSubExprMediumLevelOperandUsage,
- OutputSSAMemoryVersionMediumLevelOperandUsage, ParameterSSAVariablesMediumLevelOperandUsage,
- ParameterSSAMemoryVersionMediumLevelOperandUsage, StackExprMediumLevelOperandUsage}},
- {MLIL_TAILCALL_SSA, {OutputSSAVariablesSubExprMediumLevelOperandUsage,
- OutputSSAMemoryVersionMediumLevelOperandUsage, DestExprMediumLevelOperandUsage,
- ParameterExprsMediumLevelOperandUsage, SourceMemoryVersionMediumLevelOperandUsage}},
- {MLIL_TAILCALL_UNTYPED_SSA, {OutputSSAVariablesSubExprMediumLevelOperandUsage,
- OutputSSAMemoryVersionMediumLevelOperandUsage, DestExprMediumLevelOperandUsage,
- ParameterSSAVariablesMediumLevelOperandUsage, ParameterSSAMemoryVersionMediumLevelOperandUsage,
- StackExprMediumLevelOperandUsage}},
- {MLIL_RET, {SourceExprsMediumLevelOperandUsage}},
- {MLIL_IF, {ConditionExprMediumLevelOperandUsage, TrueTargetMediumLevelOperandUsage,
- FalseTargetMediumLevelOperandUsage}},
- {MLIL_GOTO, {TargetMediumLevelOperandUsage}},
- {MLIL_INTRINSIC, {OutputVariablesMediumLevelOperandUsage, IntrinsicMediumLevelOperandUsage,
- ParameterExprsMediumLevelOperandUsage}},
- {MLIL_INTRINSIC_SSA, {OutputSSAVariablesMediumLevelOperandUsage, IntrinsicMediumLevelOperandUsage,
- ParameterExprsMediumLevelOperandUsage}},
- {MLIL_FREE_VAR_SLOT, {DestVariableMediumLevelOperandUsage}},
- {MLIL_FREE_VAR_SLOT_SSA, {DestSSAVariableMediumLevelOperandUsage, PartialSSAVariableSourceMediumLevelOperandUsage}},
- {MLIL_TRAP, {VectorMediumLevelOperandUsage}},
- {MLIL_VAR_PHI, {DestSSAVariableMediumLevelOperandUsage, SourceSSAVariablesMediumLevelOperandUsages}},
- {MLIL_MEM_PHI, {DestMemoryVersionMediumLevelOperandUsage, SourceMemoryVersionsMediumLevelOperandUsage}},
- {MLIL_CONST, {ConstantMediumLevelOperandUsage}},
- {MLIL_CONST_PTR, {ConstantMediumLevelOperandUsage}},
- {MLIL_EXTERN_PTR, {ConstantMediumLevelOperandUsage, OffsetMediumLevelOperandUsage}},
- {MLIL_FLOAT_CONST, {ConstantMediumLevelOperandUsage}},
- {MLIL_IMPORT, {ConstantMediumLevelOperandUsage}},
- {MLIL_ADD, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
- {MLIL_SUB, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
- {MLIL_AND, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
- {MLIL_OR, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
- {MLIL_XOR, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
- {MLIL_LSL, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
- {MLIL_LSR, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
- {MLIL_ASR, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
- {MLIL_ROL, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
- {MLIL_ROR, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
- {MLIL_MUL, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
- {MLIL_MULU_DP, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
- {MLIL_MULS_DP, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
- {MLIL_DIVU, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
- {MLIL_DIVS, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
- {MLIL_MODU, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
- {MLIL_MODS, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
- {MLIL_CMP_E, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
- {MLIL_CMP_NE, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
- {MLIL_CMP_SLT, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
- {MLIL_CMP_ULT, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
- {MLIL_CMP_SLE, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
- {MLIL_CMP_ULE, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
- {MLIL_CMP_SGE, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
- {MLIL_CMP_UGE, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
- {MLIL_CMP_SGT, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
- {MLIL_CMP_UGT, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
- {MLIL_TEST_BIT, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
- {MLIL_ADD_OVERFLOW, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
- {MLIL_ADC, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage,
- CarryExprMediumLevelOperandUsage}},
- {MLIL_SBB, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage,
- CarryExprMediumLevelOperandUsage}},
- {MLIL_RLC, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage,
- CarryExprMediumLevelOperandUsage}},
- {MLIL_RRC, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage,
- CarryExprMediumLevelOperandUsage}},
- {MLIL_DIVU_DP, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
- {MLIL_DIVS_DP, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
- {MLIL_MODU_DP, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
- {MLIL_MODS_DP, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
- {MLIL_NEG, {SourceExprMediumLevelOperandUsage}},
- {MLIL_NOT, {SourceExprMediumLevelOperandUsage}},
- {MLIL_SX, {SourceExprMediumLevelOperandUsage}},
- {MLIL_ZX, {SourceExprMediumLevelOperandUsage}},
- {MLIL_LOW_PART, {SourceExprMediumLevelOperandUsage}},
- {MLIL_BOOL_TO_INT, {SourceExprMediumLevelOperandUsage}},
- {MLIL_UNIMPL_MEM, {SourceExprMediumLevelOperandUsage}},
- {MLIL_FADD, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
- {MLIL_FSUB, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
- {MLIL_FMUL, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
- {MLIL_FDIV, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
- {MLIL_FSQRT, {SourceExprMediumLevelOperandUsage}},
- {MLIL_FNEG, {SourceExprMediumLevelOperandUsage}},
- {MLIL_FABS, {SourceExprMediumLevelOperandUsage}},
- {MLIL_FLOAT_TO_INT, {SourceExprMediumLevelOperandUsage}},
- {MLIL_INT_TO_FLOAT, {SourceExprMediumLevelOperandUsage}},
- {MLIL_FLOAT_CONV, {SourceExprMediumLevelOperandUsage}},
- {MLIL_ROUND_TO_INT, {SourceExprMediumLevelOperandUsage}},
- {MLIL_FLOOR, {SourceExprMediumLevelOperandUsage}},
- {MLIL_CEIL, {SourceExprMediumLevelOperandUsage}},
- {MLIL_FTRUNC, {SourceExprMediumLevelOperandUsage}},
- {MLIL_FCMP_E, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
- {MLIL_FCMP_NE, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
- {MLIL_FCMP_LT, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
- {MLIL_FCMP_LE, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
- {MLIL_FCMP_GE, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
- {MLIL_FCMP_GT, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
- {MLIL_FCMP_O, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
- {MLIL_FCMP_UO, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}}
- };
+ MediumLevelILInstructionBase::operationOperandUsage = {{MLIL_NOP, {}}, {MLIL_NORET, {}}, {MLIL_BP, {}},
+ {MLIL_UNDEF, {}}, {MLIL_UNIMPL, {}},
+ {MLIL_SET_VAR, {DestVariableMediumLevelOperandUsage, SourceExprMediumLevelOperandUsage}},
+ {MLIL_SET_VAR_FIELD,
+ {DestVariableMediumLevelOperandUsage, OffsetMediumLevelOperandUsage, SourceExprMediumLevelOperandUsage}},
+ {MLIL_SET_VAR_SPLIT, {HighVariableMediumLevelOperandUsage, LowVariableMediumLevelOperandUsage,
+ SourceExprMediumLevelOperandUsage}},
+ {MLIL_SET_VAR_SSA, {DestSSAVariableMediumLevelOperandUsage, SourceExprMediumLevelOperandUsage}},
+ {MLIL_SET_VAR_SSA_FIELD,
+ {DestSSAVariableMediumLevelOperandUsage, PartialSSAVariableSourceMediumLevelOperandUsage,
+ OffsetMediumLevelOperandUsage, SourceExprMediumLevelOperandUsage}},
+ {MLIL_SET_VAR_SPLIT_SSA, {HighSSAVariableMediumLevelOperandUsage, LowSSAVariableMediumLevelOperandUsage,
+ SourceExprMediumLevelOperandUsage}},
+ {MLIL_SET_VAR_ALIASED, {DestSSAVariableMediumLevelOperandUsage, PartialSSAVariableSourceMediumLevelOperandUsage,
+ SourceExprMediumLevelOperandUsage}},
+ {MLIL_SET_VAR_ALIASED_FIELD,
+ {DestSSAVariableMediumLevelOperandUsage, PartialSSAVariableSourceMediumLevelOperandUsage,
+ OffsetMediumLevelOperandUsage, SourceExprMediumLevelOperandUsage}},
+ {MLIL_LOAD, {SourceExprMediumLevelOperandUsage}},
+ {MLIL_LOAD_STRUCT, {SourceExprMediumLevelOperandUsage, OffsetMediumLevelOperandUsage}},
+ {MLIL_LOAD_SSA, {SourceExprMediumLevelOperandUsage, SourceMemoryVersionMediumLevelOperandUsage}},
+ {MLIL_LOAD_STRUCT_SSA, {SourceExprMediumLevelOperandUsage, OffsetMediumLevelOperandUsage,
+ SourceMemoryVersionMediumLevelOperandUsage}},
+ {MLIL_STORE, {DestExprMediumLevelOperandUsage, SourceExprMediumLevelOperandUsage}},
+ {MLIL_STORE_STRUCT,
+ {DestExprMediumLevelOperandUsage, OffsetMediumLevelOperandUsage, SourceExprMediumLevelOperandUsage}},
+ {MLIL_STORE_SSA, {DestExprMediumLevelOperandUsage, DestMemoryVersionMediumLevelOperandUsage,
+ SourceMemoryVersionMediumLevelOperandUsage, SourceExprMediumLevelOperandUsage}},
+ {MLIL_STORE_STRUCT_SSA,
+ {DestExprMediumLevelOperandUsage, OffsetMediumLevelOperandUsage, DestMemoryVersionMediumLevelOperandUsage,
+ SourceMemoryVersionMediumLevelOperandUsage, SourceExprMediumLevelOperandUsage}},
+ {MLIL_VAR, {SourceVariableMediumLevelOperandUsage}},
+ {MLIL_VAR_FIELD, {SourceVariableMediumLevelOperandUsage, OffsetMediumLevelOperandUsage}},
+ {MLIL_VAR_SPLIT, {HighVariableMediumLevelOperandUsage, LowVariableMediumLevelOperandUsage}},
+ {MLIL_VAR_SSA, {SourceSSAVariableMediumLevelOperandUsage}},
+ {MLIL_VAR_SSA_FIELD, {SourceSSAVariableMediumLevelOperandUsage, OffsetMediumLevelOperandUsage}},
+ {MLIL_VAR_ALIASED, {SourceSSAVariableMediumLevelOperandUsage}},
+ {MLIL_VAR_ALIASED_FIELD, {SourceSSAVariableMediumLevelOperandUsage, OffsetMediumLevelOperandUsage}},
+ {MLIL_VAR_SPLIT_SSA, {HighSSAVariableMediumLevelOperandUsage, LowSSAVariableMediumLevelOperandUsage}},
+ {MLIL_ADDRESS_OF, {SourceVariableMediumLevelOperandUsage}},
+ {MLIL_ADDRESS_OF_FIELD, {SourceVariableMediumLevelOperandUsage, OffsetMediumLevelOperandUsage}},
+ {MLIL_JUMP, {DestExprMediumLevelOperandUsage}},
+ {MLIL_JUMP_TO, {DestExprMediumLevelOperandUsage, TargetsMediumLevelOperandUsage}},
+ {MLIL_RET_HINT, {DestExprMediumLevelOperandUsage}},
+ {MLIL_CALL, {OutputVariablesMediumLevelOperandUsage, DestExprMediumLevelOperandUsage,
+ ParameterExprsMediumLevelOperandUsage}},
+ {MLIL_CALL_UNTYPED, {OutputVariablesSubExprMediumLevelOperandUsage, DestExprMediumLevelOperandUsage,
+ ParameterVariablesMediumLevelOperandUsage}},
+ {MLIL_SYSCALL, {OutputVariablesMediumLevelOperandUsage, ParameterExprsMediumLevelOperandUsage}},
+ {MLIL_SYSCALL_UNTYPED, {OutputVariablesSubExprMediumLevelOperandUsage,
+ ParameterVariablesMediumLevelOperandUsage, StackExprMediumLevelOperandUsage}},
+ {MLIL_TAILCALL, {OutputVariablesMediumLevelOperandUsage, DestExprMediumLevelOperandUsage,
+ ParameterExprsMediumLevelOperandUsage}},
+ {MLIL_TAILCALL_UNTYPED, {OutputVariablesSubExprMediumLevelOperandUsage, DestExprMediumLevelOperandUsage,
+ ParameterVariablesMediumLevelOperandUsage}},
+ {MLIL_CALL_SSA, {OutputSSAVariablesSubExprMediumLevelOperandUsage,
+ OutputSSAMemoryVersionMediumLevelOperandUsage, DestExprMediumLevelOperandUsage,
+ ParameterExprsMediumLevelOperandUsage, SourceMemoryVersionMediumLevelOperandUsage}},
+ {MLIL_CALL_UNTYPED_SSA,
+ {OutputSSAVariablesSubExprMediumLevelOperandUsage, OutputSSAMemoryVersionMediumLevelOperandUsage,
+ DestExprMediumLevelOperandUsage, ParameterSSAVariablesMediumLevelOperandUsage,
+ ParameterSSAMemoryVersionMediumLevelOperandUsage, StackExprMediumLevelOperandUsage}},
+ {MLIL_SYSCALL_SSA,
+ {OutputSSAVariablesSubExprMediumLevelOperandUsage, OutputSSAMemoryVersionMediumLevelOperandUsage,
+ ParameterExprsMediumLevelOperandUsage, SourceMemoryVersionMediumLevelOperandUsage}},
+ {MLIL_SYSCALL_UNTYPED_SSA,
+ {OutputSSAVariablesSubExprMediumLevelOperandUsage, OutputSSAMemoryVersionMediumLevelOperandUsage,
+ ParameterSSAVariablesMediumLevelOperandUsage, ParameterSSAMemoryVersionMediumLevelOperandUsage,
+ StackExprMediumLevelOperandUsage}},
+ {MLIL_TAILCALL_SSA, {OutputSSAVariablesSubExprMediumLevelOperandUsage,
+ OutputSSAMemoryVersionMediumLevelOperandUsage, DestExprMediumLevelOperandUsage,
+ ParameterExprsMediumLevelOperandUsage, SourceMemoryVersionMediumLevelOperandUsage}},
+ {MLIL_TAILCALL_UNTYPED_SSA,
+ {OutputSSAVariablesSubExprMediumLevelOperandUsage, OutputSSAMemoryVersionMediumLevelOperandUsage,
+ DestExprMediumLevelOperandUsage, ParameterSSAVariablesMediumLevelOperandUsage,
+ ParameterSSAMemoryVersionMediumLevelOperandUsage, StackExprMediumLevelOperandUsage}},
+ {MLIL_RET, {SourceExprsMediumLevelOperandUsage}},
+ {MLIL_IF, {ConditionExprMediumLevelOperandUsage, TrueTargetMediumLevelOperandUsage,
+ FalseTargetMediumLevelOperandUsage}},
+ {MLIL_GOTO, {TargetMediumLevelOperandUsage}},
+ {MLIL_INTRINSIC, {OutputVariablesMediumLevelOperandUsage, IntrinsicMediumLevelOperandUsage,
+ ParameterExprsMediumLevelOperandUsage}},
+ {MLIL_INTRINSIC_SSA, {OutputSSAVariablesMediumLevelOperandUsage, IntrinsicMediumLevelOperandUsage,
+ ParameterExprsMediumLevelOperandUsage}},
+ {MLIL_FREE_VAR_SLOT, {DestVariableMediumLevelOperandUsage}},
+ {MLIL_FREE_VAR_SLOT_SSA,
+ {DestSSAVariableMediumLevelOperandUsage, PartialSSAVariableSourceMediumLevelOperandUsage}},
+ {MLIL_TRAP, {VectorMediumLevelOperandUsage}},
+ {MLIL_VAR_PHI, {DestSSAVariableMediumLevelOperandUsage, SourceSSAVariablesMediumLevelOperandUsages}},
+ {MLIL_MEM_PHI, {DestMemoryVersionMediumLevelOperandUsage, SourceMemoryVersionsMediumLevelOperandUsage}},
+ {MLIL_CONST, {ConstantMediumLevelOperandUsage}}, {MLIL_CONST_PTR, {ConstantMediumLevelOperandUsage}},
+ {MLIL_EXTERN_PTR, {ConstantMediumLevelOperandUsage, OffsetMediumLevelOperandUsage}},
+ {MLIL_FLOAT_CONST, {ConstantMediumLevelOperandUsage}}, {MLIL_IMPORT, {ConstantMediumLevelOperandUsage}},
+ {MLIL_ADD, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
+ {MLIL_SUB, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
+ {MLIL_AND, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
+ {MLIL_OR, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
+ {MLIL_XOR, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
+ {MLIL_LSL, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
+ {MLIL_LSR, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
+ {MLIL_ASR, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
+ {MLIL_ROL, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
+ {MLIL_ROR, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
+ {MLIL_MUL, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
+ {MLIL_MULU_DP, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
+ {MLIL_MULS_DP, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
+ {MLIL_DIVU, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
+ {MLIL_DIVS, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
+ {MLIL_MODU, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
+ {MLIL_MODS, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
+ {MLIL_CMP_E, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
+ {MLIL_CMP_NE, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
+ {MLIL_CMP_SLT, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
+ {MLIL_CMP_ULT, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
+ {MLIL_CMP_SLE, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
+ {MLIL_CMP_ULE, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
+ {MLIL_CMP_SGE, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
+ {MLIL_CMP_UGE, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
+ {MLIL_CMP_SGT, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
+ {MLIL_CMP_UGT, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
+ {MLIL_TEST_BIT, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
+ {MLIL_ADD_OVERFLOW, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
+ {MLIL_ADC,
+ {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage, CarryExprMediumLevelOperandUsage}},
+ {MLIL_SBB,
+ {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage, CarryExprMediumLevelOperandUsage}},
+ {MLIL_RLC,
+ {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage, CarryExprMediumLevelOperandUsage}},
+ {MLIL_RRC,
+ {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage, CarryExprMediumLevelOperandUsage}},
+ {MLIL_DIVU_DP, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
+ {MLIL_DIVS_DP, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
+ {MLIL_MODU_DP, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
+ {MLIL_MODS_DP, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
+ {MLIL_NEG, {SourceExprMediumLevelOperandUsage}}, {MLIL_NOT, {SourceExprMediumLevelOperandUsage}},
+ {MLIL_SX, {SourceExprMediumLevelOperandUsage}}, {MLIL_ZX, {SourceExprMediumLevelOperandUsage}},
+ {MLIL_LOW_PART, {SourceExprMediumLevelOperandUsage}}, {MLIL_BOOL_TO_INT, {SourceExprMediumLevelOperandUsage}},
+ {MLIL_UNIMPL_MEM, {SourceExprMediumLevelOperandUsage}},
+ {MLIL_FADD, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
+ {MLIL_FSUB, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
+ {MLIL_FMUL, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
+ {MLIL_FDIV, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
+ {MLIL_FSQRT, {SourceExprMediumLevelOperandUsage}}, {MLIL_FNEG, {SourceExprMediumLevelOperandUsage}},
+ {MLIL_FABS, {SourceExprMediumLevelOperandUsage}}, {MLIL_FLOAT_TO_INT, {SourceExprMediumLevelOperandUsage}},
+ {MLIL_INT_TO_FLOAT, {SourceExprMediumLevelOperandUsage}},
+ {MLIL_FLOAT_CONV, {SourceExprMediumLevelOperandUsage}},
+ {MLIL_ROUND_TO_INT, {SourceExprMediumLevelOperandUsage}}, {MLIL_FLOOR, {SourceExprMediumLevelOperandUsage}},
+ {MLIL_CEIL, {SourceExprMediumLevelOperandUsage}}, {MLIL_FTRUNC, {SourceExprMediumLevelOperandUsage}},
+ {MLIL_FCMP_E, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
+ {MLIL_FCMP_NE, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
+ {MLIL_FCMP_LT, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
+ {MLIL_FCMP_LE, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
+ {MLIL_FCMP_GE, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
+ {MLIL_FCMP_GT, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
+ {MLIL_FCMP_O, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
+ {MLIL_FCMP_UO, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}}};
-static unordered_map<BNMediumLevelILOperation, unordered_map<MediumLevelILOperandUsage, size_t>> GetOperandIndexForOperandUsages()
+static unordered_map<BNMediumLevelILOperation, unordered_map<MediumLevelILOperandUsage, size_t>>
+ GetOperandIndexForOperandUsages()
{
unordered_map<BNMediumLevelILOperation, unordered_map<MediumLevelILOperandUsage, size_t>> result;
result.reserve(MediumLevelILInstructionBase::operationOperandUsage.size());
@@ -302,22 +291,16 @@ static unordered_map<BNMediumLevelILOperation, unordered_map<MediumLevelILOperan
unordered_map<BNMediumLevelILOperation, unordered_map<MediumLevelILOperandUsage, size_t>>
- MediumLevelILInstructionBase::operationOperandIndex = GetOperandIndexForOperandUsages();
+ MediumLevelILInstructionBase::operationOperandIndex = GetOperandIndexForOperandUsages();
-SSAVariable::SSAVariable(): version(0)
-{
-}
+SSAVariable::SSAVariable() : version(0) {}
-SSAVariable::SSAVariable(const Variable& v, size_t i): var(v), version(i)
-{
-}
+SSAVariable::SSAVariable(const Variable& v, size_t i) : var(v), version(i) {}
-SSAVariable::SSAVariable(const SSAVariable& v): var(v.var), version(v.version)
-{
-}
+SSAVariable::SSAVariable(const SSAVariable& v) : var(v.var), version(v.version) {}
SSAVariable& SSAVariable::operator=(const SSAVariable& v)
@@ -392,8 +375,8 @@ uint64_t MediumLevelILIntegerList::ListIterator::operator*()
}
-MediumLevelILIntegerList::MediumLevelILIntegerList(MediumLevelILFunction* func,
- const BNMediumLevelILInstruction& instr, size_t count)
+MediumLevelILIntegerList::MediumLevelILIntegerList(
+ MediumLevelILFunction* func, const BNMediumLevelILInstruction& instr, size_t count)
{
m_start.function = func;
m_start.instr = instr;
@@ -450,10 +433,10 @@ size_t MediumLevelILIndexList::ListIterator::operator*()
}
-MediumLevelILIndexList::MediumLevelILIndexList(MediumLevelILFunction* func,
- const BNMediumLevelILInstruction& instr, size_t count): m_list(func, instr, count)
-{
-}
+MediumLevelILIndexList::MediumLevelILIndexList(
+ MediumLevelILFunction* func, const BNMediumLevelILInstruction& instr, size_t count) :
+ m_list(func, instr, count)
+{}
MediumLevelILIndexList::const_iterator MediumLevelILIndexList::begin() const
@@ -508,10 +491,10 @@ const pair<uint64_t, size_t> MediumLevelILIndexMap::ListIterator::operator*()
}
-MediumLevelILIndexMap::MediumLevelILIndexMap(MediumLevelILFunction* func,
- const BNMediumLevelILInstruction& instr, size_t count): m_list(func, instr, count & (~1))
-{
-}
+MediumLevelILIndexMap::MediumLevelILIndexMap(
+ MediumLevelILFunction* func, const BNMediumLevelILInstruction& instr, size_t count) :
+ m_list(func, instr, count & (~1))
+{}
MediumLevelILIndexMap::const_iterator MediumLevelILIndexMap::begin() const
@@ -562,10 +545,10 @@ const Variable MediumLevelILVariableList::ListIterator::operator*()
}
-MediumLevelILVariableList::MediumLevelILVariableList(MediumLevelILFunction* func,
- const BNMediumLevelILInstruction& instr, size_t count): m_list(func, instr, count)
-{
-}
+MediumLevelILVariableList::MediumLevelILVariableList(
+ MediumLevelILFunction* func, const BNMediumLevelILInstruction& instr, size_t count) :
+ m_list(func, instr, count)
+{}
MediumLevelILVariableList::const_iterator MediumLevelILVariableList::begin() const
@@ -620,10 +603,10 @@ const SSAVariable MediumLevelILSSAVariableList::ListIterator::operator*()
}
-MediumLevelILSSAVariableList::MediumLevelILSSAVariableList(MediumLevelILFunction* func,
- const BNMediumLevelILInstruction& instr, size_t count): m_list(func, instr, count & (~1))
-{
-}
+MediumLevelILSSAVariableList::MediumLevelILSSAVariableList(
+ MediumLevelILFunction* func, const BNMediumLevelILInstruction& instr, size_t count) :
+ m_list(func, instr, count & (~1))
+{}
MediumLevelILSSAVariableList::const_iterator MediumLevelILSSAVariableList::begin() const
@@ -670,16 +653,16 @@ MediumLevelILSSAVariableList::operator vector<SSAVariable>() const
const MediumLevelILInstruction MediumLevelILInstructionList::ListIterator::operator*()
{
- return MediumLevelILInstruction(pos.GetFunction(), pos.GetFunction()->GetRawExpr((size_t)*pos),
- (size_t)*pos, instructionIndex);
+ return MediumLevelILInstruction(
+ pos.GetFunction(), pos.GetFunction()->GetRawExpr((size_t)*pos), (size_t)*pos, instructionIndex);
}
-MediumLevelILInstructionList::MediumLevelILInstructionList(MediumLevelILFunction* func,
- const BNMediumLevelILInstruction& instr, size_t count, size_t instrIndex):
- m_list(func, instr, count), m_instructionIndex(instrIndex)
-{
-}
+MediumLevelILInstructionList::MediumLevelILInstructionList(
+ MediumLevelILFunction* func, const BNMediumLevelILInstruction& instr, size_t count, size_t instrIndex) :
+ m_list(func, instr, count),
+ m_instructionIndex(instrIndex)
+{}
MediumLevelILInstructionList::const_iterator MediumLevelILInstructionList::begin() const
@@ -726,9 +709,10 @@ MediumLevelILInstructionList::operator vector<MediumLevelILInstruction>() const
}
-MediumLevelILOperand::MediumLevelILOperand(const MediumLevelILInstruction& instr,
- MediumLevelILOperandUsage usage, size_t operandIndex):
- m_instr(instr), m_usage(usage), m_operandIndex(operandIndex)
+MediumLevelILOperand::MediumLevelILOperand(
+ const MediumLevelILInstruction& instr, MediumLevelILOperandUsage usage, size_t operandIndex) :
+ m_instr(instr),
+ m_usage(usage), m_operandIndex(operandIndex)
{
auto i = MediumLevelILInstructionBase::operandTypeForUsage.find(m_usage);
if (i == MediumLevelILInstructionBase::operandTypeForUsage.end())
@@ -749,8 +733,8 @@ size_t MediumLevelILOperand::GetIndex() const
{
if (m_type != IndexMediumLevelOperand)
throw MediumLevelILInstructionAccessException();
- if ((m_usage == OutputSSAMemoryVersionMediumLevelOperandUsage) ||
- (m_usage == ParameterSSAMemoryVersionMediumLevelOperandUsage))
+ if ((m_usage == OutputSSAMemoryVersionMediumLevelOperandUsage)
+ || (m_usage == ParameterSSAMemoryVersionMediumLevelOperandUsage))
return m_instr.GetRawOperandAsExpr(m_operandIndex).GetRawOperandAsIndex(0);
return m_instr.GetRawOperandAsIndex(m_operandIndex);
}
@@ -810,8 +794,8 @@ MediumLevelILVariableList MediumLevelILOperand::GetVariableList() const
{
if (m_type != VariableListMediumLevelOperand)
throw MediumLevelILInstructionAccessException();
- if ((m_usage == OutputVariablesSubExprMediumLevelOperandUsage) ||
- (m_usage == ParameterVariablesMediumLevelOperandUsage))
+ if ((m_usage == OutputVariablesSubExprMediumLevelOperandUsage)
+ || (m_usage == ParameterVariablesMediumLevelOperandUsage))
return m_instr.GetRawOperandAsExpr(m_operandIndex).GetRawOperandAsVariableList(0);
return m_instr.GetRawOperandAsVariableList(m_operandIndex);
}
@@ -821,8 +805,8 @@ MediumLevelILSSAVariableList MediumLevelILOperand::GetSSAVariableList() const
{
if (m_type != SSAVariableListMediumLevelOperand)
throw MediumLevelILInstructionAccessException();
- if ((m_usage == OutputSSAVariablesSubExprMediumLevelOperandUsage) ||
- (m_usage == ParameterSSAVariablesMediumLevelOperandUsage))
+ if ((m_usage == OutputSSAVariablesSubExprMediumLevelOperandUsage)
+ || (m_usage == ParameterSSAVariablesMediumLevelOperandUsage))
return m_instr.GetRawOperandAsExpr(m_operandIndex).GetRawOperandAsSSAVariableList(1);
return m_instr.GetRawOperandAsSSAVariableList(m_operandIndex);
}
@@ -847,11 +831,11 @@ const MediumLevelILOperand MediumLevelILOperandList::ListIterator::operator*()
MediumLevelILOperandList::MediumLevelILOperandList(const MediumLevelILInstruction& instr,
- const vector<MediumLevelILOperandUsage>& usageList,
- const unordered_map<MediumLevelILOperandUsage, size_t>& operandIndexMap):
- m_instr(instr), m_usageList(usageList), m_operandIndexMap(operandIndexMap)
-{
-}
+ const vector<MediumLevelILOperandUsage>& usageList,
+ const unordered_map<MediumLevelILOperandUsage, size_t>& operandIndexMap) :
+ m_instr(instr),
+ m_usageList(usageList), m_operandIndexMap(operandIndexMap)
+{}
MediumLevelILOperandList::const_iterator MediumLevelILOperandList::begin() const
@@ -909,8 +893,8 @@ MediumLevelILInstruction::MediumLevelILInstruction()
}
-MediumLevelILInstruction::MediumLevelILInstruction(MediumLevelILFunction* func,
- const BNMediumLevelILInstruction& instr, size_t expr, size_t instrIdx)
+MediumLevelILInstruction::MediumLevelILInstruction(
+ MediumLevelILFunction* func, const BNMediumLevelILInstruction& instr, size_t expr, size_t instrIdx)
{
operation = instr.operation;
sourceOperand = instr.sourceOperand;
@@ -970,7 +954,8 @@ size_t MediumLevelILInstructionBase::GetRawOperandAsIndex(size_t operand) const
MediumLevelILInstruction MediumLevelILInstructionBase::GetRawOperandAsExpr(size_t operand) const
{
- return MediumLevelILInstruction(function, function->GetRawExpr(operands[operand]), operands[operand], instructionIndex);
+ return MediumLevelILInstruction(
+ function, function->GetRawExpr(operands[operand]), operands[operand], instructionIndex);
}
@@ -1018,8 +1003,8 @@ MediumLevelILSSAVariableList MediumLevelILInstructionBase::GetRawOperandAsSSAVar
MediumLevelILInstructionList MediumLevelILInstructionBase::GetRawOperandAsExprList(size_t operand) const
{
- return MediumLevelILInstructionList(function, function->GetRawExpr(operands[operand + 1]), operands[operand],
- instructionIndex);
+ return MediumLevelILInstructionList(
+ function, function->GetRawExpr(operands[operand + 1]), operands[operand], instructionIndex);
}
@@ -1030,14 +1015,16 @@ void MediumLevelILInstructionBase::UpdateRawOperand(size_t operandIndex, ExprId
}
-void MediumLevelILInstructionBase::UpdateRawOperandAsSSAVariableList(size_t operandIndex, const vector<SSAVariable>& vars)
+void MediumLevelILInstructionBase::UpdateRawOperandAsSSAVariableList(
+ size_t operandIndex, const vector<SSAVariable>& vars)
{
UpdateRawOperand(operandIndex, vars.size() * 2);
UpdateRawOperand(operandIndex + 1, function->AddSSAVariableList(vars));
}
-void MediumLevelILInstructionBase::UpdateRawOperandAsExprList(size_t operandIndex, const vector<MediumLevelILInstruction>& exprs)
+void MediumLevelILInstructionBase::UpdateRawOperandAsExprList(
+ size_t operandIndex, const vector<MediumLevelILInstruction>& exprs)
{
vector<ExprId> exprIndexList;
for (auto& i : exprs)
@@ -1490,14 +1477,12 @@ void MediumLevelILInstruction::VisitExprs(const std::function<bool(const MediumL
ExprId MediumLevelILInstruction::CopyTo(MediumLevelILFunction* dest) const
{
- return CopyTo(dest, [&](const MediumLevelILInstruction& subExpr) {
- return subExpr.CopyTo(dest);
- });
+ return CopyTo(dest, [&](const MediumLevelILInstruction& subExpr) { return subExpr.CopyTo(dest); });
}
ExprId MediumLevelILInstruction::CopyTo(MediumLevelILFunction* dest,
- const std::function<ExprId(const MediumLevelILInstruction& subExpr)>& subExprHandler) const
+ const std::function<ExprId(const MediumLevelILInstruction& subExpr)>& subExprHandler) const
{
vector<ExprId> params;
BNMediumLevelILLabel* labelA;
@@ -1507,128 +1492,116 @@ ExprId MediumLevelILInstruction::CopyTo(MediumLevelILFunction* dest,
case MLIL_NOP:
return dest->Nop(*this);
case MLIL_SET_VAR:
- return dest->SetVar(size, GetDestVariable<MLIL_SET_VAR>(),
- subExprHandler(GetSourceExpr<MLIL_SET_VAR>()), *this);
+ return dest->SetVar(
+ size, GetDestVariable<MLIL_SET_VAR>(), subExprHandler(GetSourceExpr<MLIL_SET_VAR>()), *this);
case MLIL_SET_VAR_SSA:
- return dest->SetVarSSA(size, GetDestSSAVariable<MLIL_SET_VAR_SSA>(),
- subExprHandler(GetSourceExpr<MLIL_SET_VAR_SSA>()), *this);
+ return dest->SetVarSSA(
+ size, GetDestSSAVariable<MLIL_SET_VAR_SSA>(), subExprHandler(GetSourceExpr<MLIL_SET_VAR_SSA>()), *this);
case MLIL_SET_VAR_ALIASED:
return dest->SetVarAliased(size, GetDestSSAVariable<MLIL_SET_VAR_ALIASED>().var,
- GetDestSSAVariable<MLIL_SET_VAR_ALIASED>().version,
- GetSourceSSAVariable<MLIL_SET_VAR_ALIASED>().version,
- subExprHandler(GetSourceExpr<MLIL_SET_VAR_ALIASED>()), *this);
+ GetDestSSAVariable<MLIL_SET_VAR_ALIASED>().version, GetSourceSSAVariable<MLIL_SET_VAR_ALIASED>().version,
+ subExprHandler(GetSourceExpr<MLIL_SET_VAR_ALIASED>()), *this);
case MLIL_SET_VAR_SPLIT:
- return dest->SetVarSplit(size, GetHighVariable<MLIL_SET_VAR_SPLIT>(),
- GetLowVariable<MLIL_SET_VAR_SPLIT>(),
- subExprHandler(GetSourceExpr<MLIL_SET_VAR_SPLIT>()), *this);
+ return dest->SetVarSplit(size, GetHighVariable<MLIL_SET_VAR_SPLIT>(), GetLowVariable<MLIL_SET_VAR_SPLIT>(),
+ subExprHandler(GetSourceExpr<MLIL_SET_VAR_SPLIT>()), *this);
case MLIL_SET_VAR_SPLIT_SSA:
return dest->SetVarSSASplit(size, GetHighSSAVariable<MLIL_SET_VAR_SPLIT_SSA>(),
- GetLowSSAVariable<MLIL_SET_VAR_SPLIT_SSA>(),
- subExprHandler(GetSourceExpr<MLIL_SET_VAR_SPLIT_SSA>()), *this);
+ GetLowSSAVariable<MLIL_SET_VAR_SPLIT_SSA>(), subExprHandler(GetSourceExpr<MLIL_SET_VAR_SPLIT_SSA>()),
+ *this);
case MLIL_SET_VAR_FIELD:
- return dest->SetVarField(size, GetDestVariable<MLIL_SET_VAR_FIELD>(),
- GetOffset<MLIL_SET_VAR_FIELD>(), subExprHandler(GetSourceExpr<MLIL_SET_VAR_FIELD>()), *this);
+ return dest->SetVarField(size, GetDestVariable<MLIL_SET_VAR_FIELD>(), GetOffset<MLIL_SET_VAR_FIELD>(),
+ subExprHandler(GetSourceExpr<MLIL_SET_VAR_FIELD>()), *this);
case MLIL_SET_VAR_SSA_FIELD:
return dest->SetVarSSAField(size, GetDestSSAVariable<MLIL_SET_VAR_SSA_FIELD>().var,
- GetDestSSAVariable<MLIL_SET_VAR_SSA_FIELD>().version,
- GetSourceSSAVariable<MLIL_SET_VAR_SSA_FIELD>().version,
- GetOffset<MLIL_SET_VAR_SSA_FIELD>(),
- subExprHandler(GetSourceExpr<MLIL_SET_VAR_SSA_FIELD>()), *this);
+ GetDestSSAVariable<MLIL_SET_VAR_SSA_FIELD>().version,
+ GetSourceSSAVariable<MLIL_SET_VAR_SSA_FIELD>().version, GetOffset<MLIL_SET_VAR_SSA_FIELD>(),
+ subExprHandler(GetSourceExpr<MLIL_SET_VAR_SSA_FIELD>()), *this);
case MLIL_SET_VAR_ALIASED_FIELD:
return dest->SetVarAliasedField(size, GetDestSSAVariable<MLIL_SET_VAR_ALIASED_FIELD>().var,
- GetDestSSAVariable<MLIL_SET_VAR_ALIASED_FIELD>().version,
- GetSourceSSAVariable<MLIL_SET_VAR_ALIASED_FIELD>().version,
- GetOffset<MLIL_SET_VAR_ALIASED_FIELD>(),
- subExprHandler(GetSourceExpr<MLIL_SET_VAR_ALIASED_FIELD>()), *this);
+ GetDestSSAVariable<MLIL_SET_VAR_ALIASED_FIELD>().version,
+ GetSourceSSAVariable<MLIL_SET_VAR_ALIASED_FIELD>().version, GetOffset<MLIL_SET_VAR_ALIASED_FIELD>(),
+ subExprHandler(GetSourceExpr<MLIL_SET_VAR_ALIASED_FIELD>()), *this);
case MLIL_VAR:
return dest->Var(size, GetSourceVariable<MLIL_VAR>(), *this);
case MLIL_VAR_FIELD:
- return dest->VarField(size, GetSourceVariable<MLIL_VAR_FIELD>(),
- GetOffset<MLIL_VAR_FIELD>(), *this);
+ return dest->VarField(size, GetSourceVariable<MLIL_VAR_FIELD>(), GetOffset<MLIL_VAR_FIELD>(), *this);
case MLIL_VAR_SPLIT:
- return dest->VarSplit(size, GetHighVariable<MLIL_VAR_SPLIT>(),
- GetLowVariable<MLIL_VAR_SPLIT>(), *this);
+ return dest->VarSplit(size, GetHighVariable<MLIL_VAR_SPLIT>(), GetLowVariable<MLIL_VAR_SPLIT>(), *this);
case MLIL_VAR_SSA:
return dest->VarSSA(size, GetSourceSSAVariable<MLIL_VAR_SSA>(), *this);
case MLIL_VAR_SSA_FIELD:
- return dest->VarSSAField(size, GetSourceSSAVariable<MLIL_VAR_SSA_FIELD>(),
- GetOffset<MLIL_VAR_SSA_FIELD>(), *this);
+ return dest->VarSSAField(
+ size, GetSourceSSAVariable<MLIL_VAR_SSA_FIELD>(), GetOffset<MLIL_VAR_SSA_FIELD>(), *this);
case MLIL_VAR_ALIASED:
return dest->VarAliased(size, GetSourceSSAVariable<MLIL_VAR_ALIASED>().var,
- GetSourceSSAVariable<MLIL_VAR_ALIASED>().version, *this);
+ GetSourceSSAVariable<MLIL_VAR_ALIASED>().version, *this);
case MLIL_VAR_ALIASED_FIELD:
return dest->VarAliasedField(size, GetSourceSSAVariable<MLIL_VAR_ALIASED_FIELD>().var,
- GetSourceSSAVariable<MLIL_VAR_ALIASED_FIELD>().version,
- GetOffset<MLIL_VAR_ALIASED_FIELD>(), *this);
+ GetSourceSSAVariable<MLIL_VAR_ALIASED_FIELD>().version, GetOffset<MLIL_VAR_ALIASED_FIELD>(), *this);
case MLIL_VAR_SPLIT_SSA:
- return dest->VarSplitSSA(size, GetHighSSAVariable<MLIL_VAR_SPLIT_SSA>(),
- GetLowSSAVariable<MLIL_VAR_SPLIT_SSA>(), *this);
+ return dest->VarSplitSSA(
+ size, GetHighSSAVariable<MLIL_VAR_SPLIT_SSA>(), GetLowSSAVariable<MLIL_VAR_SPLIT_SSA>(), *this);
case MLIL_ADDRESS_OF:
return dest->AddressOf(GetSourceVariable<MLIL_ADDRESS_OF>(), *this);
case MLIL_ADDRESS_OF_FIELD:
- return dest->AddressOfField(GetSourceVariable<MLIL_ADDRESS_OF_FIELD>(),
- GetOffset<MLIL_ADDRESS_OF_FIELD>(), *this);
+ return dest->AddressOfField(
+ GetSourceVariable<MLIL_ADDRESS_OF_FIELD>(), GetOffset<MLIL_ADDRESS_OF_FIELD>(), *this);
case MLIL_CALL:
for (auto i : GetParameterExprs<MLIL_CALL>())
params.push_back(subExprHandler(i));
- return dest->Call(GetOutputVariables<MLIL_CALL>(), subExprHandler(GetDestExpr<MLIL_CALL>()),
- params, *this);
+ return dest->Call(GetOutputVariables<MLIL_CALL>(), subExprHandler(GetDestExpr<MLIL_CALL>()), params, *this);
case MLIL_CALL_UNTYPED:
return dest->CallUntyped(GetOutputVariables<MLIL_CALL_UNTYPED>(),
- subExprHandler(GetDestExpr<MLIL_CALL_UNTYPED>()), GetParameterVariables<MLIL_CALL_UNTYPED>(),
- subExprHandler(GetStackExpr<MLIL_CALL_UNTYPED>()), *this);
+ subExprHandler(GetDestExpr<MLIL_CALL_UNTYPED>()), GetParameterVariables<MLIL_CALL_UNTYPED>(),
+ subExprHandler(GetStackExpr<MLIL_CALL_UNTYPED>()), *this);
case MLIL_CALL_SSA:
for (auto i : GetParameterExprs<MLIL_CALL_SSA>())
params.push_back(subExprHandler(i));
return dest->CallSSA(GetOutputSSAVariables<MLIL_CALL_SSA>(), subExprHandler(GetDestExpr<MLIL_CALL_SSA>()),
- params, GetDestMemoryVersion<MLIL_CALL_SSA>(), GetSourceMemoryVersion<MLIL_CALL_SSA>(), *this);
+ params, GetDestMemoryVersion<MLIL_CALL_SSA>(), GetSourceMemoryVersion<MLIL_CALL_SSA>(), *this);
case MLIL_CALL_UNTYPED_SSA:
return dest->CallUntypedSSA(GetOutputSSAVariables<MLIL_CALL_UNTYPED_SSA>(),
- subExprHandler(GetDestExpr<MLIL_CALL_UNTYPED_SSA>()),
- GetParameterSSAVariables<MLIL_CALL_UNTYPED_SSA>(),
- GetDestMemoryVersion<MLIL_CALL_UNTYPED_SSA>(),
- GetSourceMemoryVersion<MLIL_CALL_UNTYPED_SSA>(),
- subExprHandler(GetStackExpr<MLIL_CALL_UNTYPED_SSA>()), *this);
+ subExprHandler(GetDestExpr<MLIL_CALL_UNTYPED_SSA>()), GetParameterSSAVariables<MLIL_CALL_UNTYPED_SSA>(),
+ GetDestMemoryVersion<MLIL_CALL_UNTYPED_SSA>(), GetSourceMemoryVersion<MLIL_CALL_UNTYPED_SSA>(),
+ subExprHandler(GetStackExpr<MLIL_CALL_UNTYPED_SSA>()), *this);
case MLIL_SYSCALL:
for (auto i : GetParameterExprs<MLIL_SYSCALL>())
params.push_back(subExprHandler(i));
return dest->Syscall(GetOutputVariables<MLIL_SYSCALL>(), params, *this);
case MLIL_SYSCALL_UNTYPED:
return dest->SyscallUntyped(GetOutputVariables<MLIL_SYSCALL_UNTYPED>(),
- GetParameterVariables<MLIL_SYSCALL_UNTYPED>(),
- subExprHandler(GetStackExpr<MLIL_SYSCALL_UNTYPED>()), *this);
+ GetParameterVariables<MLIL_SYSCALL_UNTYPED>(), subExprHandler(GetStackExpr<MLIL_SYSCALL_UNTYPED>()), *this);
case MLIL_SYSCALL_SSA:
for (auto i : GetParameterExprs<MLIL_SYSCALL_SSA>())
params.push_back(subExprHandler(i));
return dest->SyscallSSA(GetOutputSSAVariables<MLIL_SYSCALL_SSA>(), params,
- GetDestMemoryVersion<MLIL_SYSCALL_SSA>(), GetSourceMemoryVersion<MLIL_SYSCALL_SSA>(), *this);
+ GetDestMemoryVersion<MLIL_SYSCALL_SSA>(), GetSourceMemoryVersion<MLIL_SYSCALL_SSA>(), *this);
case MLIL_SYSCALL_UNTYPED_SSA:
return dest->SyscallUntypedSSA(GetOutputSSAVariables<MLIL_SYSCALL_UNTYPED_SSA>(),
- GetParameterSSAVariables<MLIL_SYSCALL_UNTYPED_SSA>(),
- GetDestMemoryVersion<MLIL_SYSCALL_UNTYPED_SSA>(),
- GetSourceMemoryVersion<MLIL_SYSCALL_UNTYPED_SSA>(),
- subExprHandler(GetStackExpr<MLIL_SYSCALL_UNTYPED_SSA>()), *this);
+ GetParameterSSAVariables<MLIL_SYSCALL_UNTYPED_SSA>(), GetDestMemoryVersion<MLIL_SYSCALL_UNTYPED_SSA>(),
+ GetSourceMemoryVersion<MLIL_SYSCALL_UNTYPED_SSA>(),
+ subExprHandler(GetStackExpr<MLIL_SYSCALL_UNTYPED_SSA>()), *this);
case MLIL_TAILCALL:
for (auto i : GetParameterExprs<MLIL_TAILCALL>())
params.push_back(subExprHandler(i));
- return dest->TailCall(GetOutputVariables<MLIL_TAILCALL>(), subExprHandler(GetDestExpr<MLIL_TAILCALL>()),
- params, *this);
+ return dest->TailCall(
+ GetOutputVariables<MLIL_TAILCALL>(), subExprHandler(GetDestExpr<MLIL_TAILCALL>()), params, *this);
case MLIL_TAILCALL_UNTYPED:
return dest->TailCallUntyped(GetOutputVariables<MLIL_TAILCALL_UNTYPED>(),
- subExprHandler(GetDestExpr<MLIL_TAILCALL_UNTYPED>()), GetParameterVariables<MLIL_TAILCALL_UNTYPED>(),
- subExprHandler(GetStackExpr<MLIL_TAILCALL_UNTYPED>()), *this);
+ subExprHandler(GetDestExpr<MLIL_TAILCALL_UNTYPED>()), GetParameterVariables<MLIL_TAILCALL_UNTYPED>(),
+ subExprHandler(GetStackExpr<MLIL_TAILCALL_UNTYPED>()), *this);
case MLIL_TAILCALL_SSA:
for (auto i : GetParameterExprs<MLIL_TAILCALL_SSA>())
params.push_back(subExprHandler(i));
- return dest->TailCallSSA(GetOutputSSAVariables<MLIL_TAILCALL_SSA>(), subExprHandler(GetDestExpr<MLIL_TAILCALL_SSA>()),
- params, GetDestMemoryVersion<MLIL_TAILCALL_SSA>(), GetSourceMemoryVersion<MLIL_TAILCALL_SSA>(), *this);
+ return dest->TailCallSSA(GetOutputSSAVariables<MLIL_TAILCALL_SSA>(),
+ subExprHandler(GetDestExpr<MLIL_TAILCALL_SSA>()), params, GetDestMemoryVersion<MLIL_TAILCALL_SSA>(),
+ GetSourceMemoryVersion<MLIL_TAILCALL_SSA>(), *this);
case MLIL_TAILCALL_UNTYPED_SSA:
return dest->TailCallUntypedSSA(GetOutputSSAVariables<MLIL_TAILCALL_UNTYPED_SSA>(),
- subExprHandler(GetDestExpr<MLIL_TAILCALL_UNTYPED_SSA>()),
- GetParameterSSAVariables<MLIL_TAILCALL_UNTYPED_SSA>(),
- GetDestMemoryVersion<MLIL_TAILCALL_UNTYPED_SSA>(),
- GetSourceMemoryVersion<MLIL_TAILCALL_UNTYPED_SSA>(),
- subExprHandler(GetStackExpr<MLIL_TAILCALL_UNTYPED_SSA>()), *this);
+ subExprHandler(GetDestExpr<MLIL_TAILCALL_UNTYPED_SSA>()),
+ GetParameterSSAVariables<MLIL_TAILCALL_UNTYPED_SSA>(), GetDestMemoryVersion<MLIL_TAILCALL_UNTYPED_SSA>(),
+ GetSourceMemoryVersion<MLIL_TAILCALL_UNTYPED_SSA>(),
+ subExprHandler(GetStackExpr<MLIL_TAILCALL_UNTYPED_SSA>()), *this);
case MLIL_RET:
for (auto i : GetSourceExprs<MLIL_RET>())
params.push_back(subExprHandler(i));
@@ -1636,31 +1609,31 @@ ExprId MediumLevelILInstruction::CopyTo(MediumLevelILFunction* dest,
case MLIL_NORET:
return dest->NoReturn(*this);
case MLIL_STORE:
- return dest->Store(size, subExprHandler(GetDestExpr<MLIL_STORE>()),
- subExprHandler(GetSourceExpr<MLIL_STORE>()), *this);
+ return dest->Store(
+ size, subExprHandler(GetDestExpr<MLIL_STORE>()), subExprHandler(GetSourceExpr<MLIL_STORE>()), *this);
case MLIL_STORE_STRUCT:
- return dest->StoreStruct(size, subExprHandler(GetDestExpr<MLIL_STORE_STRUCT>()),
- GetOffset<MLIL_STORE_STRUCT>(), subExprHandler(GetSourceExpr<MLIL_STORE_STRUCT>()), *this);
+ return dest->StoreStruct(size, subExprHandler(GetDestExpr<MLIL_STORE_STRUCT>()), GetOffset<MLIL_STORE_STRUCT>(),
+ subExprHandler(GetSourceExpr<MLIL_STORE_STRUCT>()), *this);
case MLIL_STORE_SSA:
return dest->StoreSSA(size, subExprHandler(GetDestExpr<MLIL_STORE_SSA>()),
- GetDestMemoryVersion<MLIL_STORE_SSA>(), GetSourceMemoryVersion<MLIL_STORE_SSA>(),
- subExprHandler(GetSourceExpr<MLIL_STORE_SSA>()), *this);
+ GetDestMemoryVersion<MLIL_STORE_SSA>(), GetSourceMemoryVersion<MLIL_STORE_SSA>(),
+ subExprHandler(GetSourceExpr<MLIL_STORE_SSA>()), *this);
case MLIL_STORE_STRUCT_SSA:
return dest->StoreStructSSA(size, subExprHandler(GetDestExpr<MLIL_STORE_STRUCT_SSA>()),
- GetOffset<MLIL_STORE_STRUCT_SSA>(),
- GetDestMemoryVersion<MLIL_STORE_STRUCT_SSA>(), GetSourceMemoryVersion<MLIL_STORE_STRUCT_SSA>(),
- subExprHandler(GetSourceExpr<MLIL_STORE_STRUCT_SSA>()), *this);
+ GetOffset<MLIL_STORE_STRUCT_SSA>(), GetDestMemoryVersion<MLIL_STORE_STRUCT_SSA>(),
+ GetSourceMemoryVersion<MLIL_STORE_STRUCT_SSA>(), subExprHandler(GetSourceExpr<MLIL_STORE_STRUCT_SSA>()),
+ *this);
case MLIL_LOAD:
return dest->Load(size, subExprHandler(GetSourceExpr<MLIL_LOAD>()), *this);
case MLIL_LOAD_STRUCT:
- return dest->LoadStruct(size, subExprHandler(GetSourceExpr<MLIL_LOAD_STRUCT>()),
- GetOffset<MLIL_LOAD_STRUCT>(), *this);
+ return dest->LoadStruct(
+ size, subExprHandler(GetSourceExpr<MLIL_LOAD_STRUCT>()), GetOffset<MLIL_LOAD_STRUCT>(), *this);
case MLIL_LOAD_SSA:
- return dest->LoadSSA(size, subExprHandler(GetSourceExpr<MLIL_LOAD_SSA>()),
- GetSourceMemoryVersion<MLIL_LOAD_SSA>(), *this);
+ return dest->LoadSSA(
+ size, subExprHandler(GetSourceExpr<MLIL_LOAD_SSA>()), GetSourceMemoryVersion<MLIL_LOAD_SSA>(), *this);
case MLIL_LOAD_STRUCT_SSA:
return dest->LoadStructSSA(size, subExprHandler(GetSourceExpr<MLIL_LOAD_STRUCT_SSA>()),
- GetOffset<MLIL_LOAD_STRUCT_SSA>(), GetSourceMemoryVersion<MLIL_LOAD_STRUCT_SSA>(), *this);
+ GetOffset<MLIL_LOAD_STRUCT_SSA>(), GetSourceMemoryVersion<MLIL_LOAD_STRUCT_SSA>(), *this);
case MLIL_NEG:
case MLIL_NOT:
case MLIL_SX:
@@ -1680,8 +1653,7 @@ ExprId MediumLevelILInstruction::CopyTo(MediumLevelILFunction* dest,
case MLIL_FLOOR:
case MLIL_CEIL:
case MLIL_FTRUNC:
- return dest->AddExprWithLocation(operation, *this, size,
- subExprHandler(AsOneOperand().GetSourceExpr()));
+ return dest->AddExprWithLocation(operation, *this, size, subExprHandler(AsOneOperand().GetSourceExpr()));
case MLIL_ADD:
case MLIL_SUB:
case MLIL_AND:
@@ -1727,34 +1699,34 @@ ExprId MediumLevelILInstruction::CopyTo(MediumLevelILFunction* dest,
case MLIL_FCMP_GT:
case MLIL_FCMP_O:
case MLIL_FCMP_UO:
- return dest->AddExprWithLocation(operation, *this, size,
- subExprHandler(AsTwoOperand().GetLeftExpr()), subExprHandler(AsTwoOperand().GetRightExpr()));
+ return dest->AddExprWithLocation(operation, *this, size, subExprHandler(AsTwoOperand().GetLeftExpr()),
+ subExprHandler(AsTwoOperand().GetRightExpr()));
case MLIL_ADC:
case MLIL_SBB:
case MLIL_RLC:
case MLIL_RRC:
- return dest->AddExprWithLocation(operation, *this, size,
- subExprHandler(AsTwoOperandWithCarry().GetLeftExpr()),
- subExprHandler(AsTwoOperandWithCarry().GetRightExpr()),
- subExprHandler(AsTwoOperandWithCarry().GetCarryExpr()));
+ return dest->AddExprWithLocation(operation, *this, size, subExprHandler(AsTwoOperandWithCarry().GetLeftExpr()),
+ subExprHandler(AsTwoOperandWithCarry().GetRightExpr()),
+ subExprHandler(AsTwoOperandWithCarry().GetCarryExpr()));
case MLIL_JUMP_TO:
+ {
+ map<uint64_t, BNMediumLevelILLabel*> labelList;
+ for (auto target : GetTargets<MLIL_JUMP_TO>())
{
- map<uint64_t, BNMediumLevelILLabel*> labelList;
- for (auto target : GetTargets<MLIL_JUMP_TO>())
- {
- labelA = dest->GetLabelForSourceInstruction(target.second);
- if (!labelA)
- return dest->Jump(subExprHandler(GetDestExpr<MLIL_JUMP_TO>()), *this);
- labelList[target.first] = labelA;
- }
- return dest->JumpTo(subExprHandler(GetDestExpr<MLIL_JUMP_TO>()), labelList, *this);
+ labelA = dest->GetLabelForSourceInstruction(target.second);
+ if (!labelA)
+ return dest->Jump(subExprHandler(GetDestExpr<MLIL_JUMP_TO>()), *this);
+ labelList[target.first] = labelA;
}
+ return dest->JumpTo(subExprHandler(GetDestExpr<MLIL_JUMP_TO>()), labelList, *this);
+ }
case MLIL_GOTO:
labelA = dest->GetLabelForSourceInstruction(GetTarget<MLIL_GOTO>());
if (!labelA)
{
return dest->Jump(dest->ConstPointer(function->GetArchitecture()->GetAddressSize(),
- function->GetInstruction(GetTarget<MLIL_GOTO>()).address), *this);
+ function->GetInstruction(GetTarget<MLIL_GOTO>()).address),
+ *this);
}
return dest->Goto(*labelA, *this);
case MLIL_IF:
@@ -1780,19 +1752,18 @@ ExprId MediumLevelILInstruction::CopyTo(MediumLevelILFunction* dest,
case MLIL_INTRINSIC:
for (auto i : GetParameterExprs<MLIL_INTRINSIC>())
params.push_back(subExprHandler(i));
- return dest->Intrinsic(GetOutputVariables<MLIL_INTRINSIC>(),
- GetIntrinsic<MLIL_INTRINSIC>(), params, *this);
+ return dest->Intrinsic(GetOutputVariables<MLIL_INTRINSIC>(), GetIntrinsic<MLIL_INTRINSIC>(), params, *this);
case MLIL_INTRINSIC_SSA:
for (auto i : GetParameterExprs<MLIL_INTRINSIC_SSA>())
params.push_back(subExprHandler(i));
- return dest->IntrinsicSSA(GetOutputSSAVariables<MLIL_INTRINSIC_SSA>(),
- GetIntrinsic<MLIL_INTRINSIC_SSA>(), params, *this);
+ return dest->IntrinsicSSA(
+ GetOutputSSAVariables<MLIL_INTRINSIC_SSA>(), GetIntrinsic<MLIL_INTRINSIC_SSA>(), params, *this);
case MLIL_FREE_VAR_SLOT:
return dest->FreeVarSlot(GetDestVariable<MLIL_FREE_VAR_SLOT>(), *this);
case MLIL_FREE_VAR_SLOT_SSA:
return dest->FreeVarSlotSSA(GetDestSSAVariable<MLIL_FREE_VAR_SLOT_SSA>().var,
- GetDestSSAVariable<MLIL_FREE_VAR_SLOT_SSA>().version,
- GetSourceSSAVariable<MLIL_FREE_VAR_SLOT_SSA>().version, *this);
+ GetDestSSAVariable<MLIL_FREE_VAR_SLOT_SSA>().version,
+ GetSourceSSAVariable<MLIL_FREE_VAR_SLOT_SSA>().version, *this);
case MLIL_UNDEF:
return dest->Undefined(*this);
case MLIL_UNIMPL:
@@ -2129,66 +2100,61 @@ ExprId MediumLevelILFunction::Nop(const ILSourceLocation& loc)
}
-ExprId MediumLevelILFunction::SetVar(size_t size, const Variable& dest, ExprId src,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::SetVar(size_t size, const Variable& dest, ExprId src, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_SET_VAR, loc, size, dest.ToIdentifier(), src);
}
-ExprId MediumLevelILFunction::SetVarField(size_t size, const Variable& dest, uint64_t offset, ExprId src,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::SetVarField(
+ size_t size, const Variable& dest, uint64_t offset, ExprId src, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_SET_VAR_FIELD, loc, size, dest.ToIdentifier(), offset, src);
}
-ExprId MediumLevelILFunction::SetVarSplit(size_t size, const Variable& high, const Variable& low, ExprId src,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::SetVarSplit(
+ size_t size, const Variable& high, const Variable& low, ExprId src, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_SET_VAR_SPLIT, loc, size, high.ToIdentifier(), low.ToIdentifier(), src);
}
-ExprId MediumLevelILFunction::SetVarSSA(size_t size, const SSAVariable& dest, ExprId src,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::SetVarSSA(size_t size, const SSAVariable& dest, ExprId src, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_SET_VAR_SSA, loc, size, dest.var.ToIdentifier(), dest.version, src);
}
-ExprId MediumLevelILFunction::SetVarSSAField(size_t size, const Variable& dest,
- size_t newVersion, size_t prevVersion, uint64_t offset, ExprId src,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::SetVarSSAField(size_t size, const Variable& dest, size_t newVersion, size_t prevVersion,
+ uint64_t offset, ExprId src, const ILSourceLocation& loc)
{
- return AddExprWithLocation(MLIL_SET_VAR_SSA_FIELD, loc, size, dest.ToIdentifier(), newVersion, prevVersion,
- offset, src);
+ return AddExprWithLocation(
+ MLIL_SET_VAR_SSA_FIELD, loc, size, dest.ToIdentifier(), newVersion, prevVersion, offset, src);
}
-ExprId MediumLevelILFunction::SetVarSSASplit(size_t size, const SSAVariable& high, const SSAVariable& low,
- ExprId src, const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::SetVarSSASplit(
+ size_t size, const SSAVariable& high, const SSAVariable& low, ExprId src, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_SET_VAR_SPLIT_SSA, loc, size, high.var.ToIdentifier(), high.version,
- low.var.ToIdentifier(), low.version, src);
+ low.var.ToIdentifier(), low.version, src);
}
-ExprId MediumLevelILFunction::SetVarAliased(size_t size, const Variable& dest,
- size_t newMemVersion, size_t prevMemVersion,
- ExprId src, const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::SetVarAliased(size_t size, const Variable& dest, size_t newMemVersion,
+ size_t prevMemVersion, ExprId src, const ILSourceLocation& loc)
{
- return AddExprWithLocation(MLIL_SET_VAR_ALIASED, loc, size, dest.ToIdentifier(),
- newMemVersion, prevMemVersion, src);
+ return AddExprWithLocation(
+ MLIL_SET_VAR_ALIASED, loc, size, dest.ToIdentifier(), newMemVersion, prevMemVersion, src);
}
-ExprId MediumLevelILFunction::SetVarAliasedField(size_t size, const Variable& dest,
- size_t newMemVersion, size_t prevMemVersion,
- uint64_t offset, ExprId src, const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::SetVarAliasedField(size_t size, const Variable& dest, size_t newMemVersion,
+ size_t prevMemVersion, uint64_t offset, ExprId src, const ILSourceLocation& loc)
{
- return AddExprWithLocation(MLIL_SET_VAR_ALIASED_FIELD, loc, size, dest.ToIdentifier(),
- newMemVersion, prevMemVersion, offset, src);
+ return AddExprWithLocation(
+ MLIL_SET_VAR_ALIASED_FIELD, loc, size, dest.ToIdentifier(), newMemVersion, prevMemVersion, offset, src);
}
@@ -2198,111 +2164,103 @@ ExprId MediumLevelILFunction::Load(size_t size, ExprId src, const ILSourceLocati
}
-ExprId MediumLevelILFunction::LoadStruct(size_t size, ExprId src, uint64_t offset,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::LoadStruct(size_t size, ExprId src, uint64_t offset, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_LOAD_STRUCT, loc, size, src, offset);
}
-ExprId MediumLevelILFunction::LoadSSA(size_t size, ExprId src, size_t memVersion,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::LoadSSA(size_t size, ExprId src, size_t memVersion, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_LOAD_SSA, loc, size, src, memVersion);
}
-ExprId MediumLevelILFunction::LoadStructSSA(size_t size, ExprId src, uint64_t offset, size_t memVersion,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::LoadStructSSA(
+ size_t size, ExprId src, uint64_t offset, size_t memVersion, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_LOAD_STRUCT_SSA, loc, size, src, offset, memVersion);
}
-ExprId MediumLevelILFunction::Store(size_t size, ExprId dest, ExprId src,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::Store(size_t size, ExprId dest, ExprId src, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_STORE, loc, size, dest, src);
}
-ExprId MediumLevelILFunction::StoreStruct(size_t size, ExprId dest, uint64_t offset, ExprId src,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::StoreStruct(
+ size_t size, ExprId dest, uint64_t offset, ExprId src, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_STORE_STRUCT, loc, size, dest, offset, src);
}
-ExprId MediumLevelILFunction::StoreSSA(size_t size, ExprId dest,
- size_t newMemVersion, size_t prevMemVersion, ExprId src,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::StoreSSA(
+ size_t size, ExprId dest, size_t newMemVersion, size_t prevMemVersion, ExprId src, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_STORE_SSA, loc, size, dest, newMemVersion, prevMemVersion, src);
}
-ExprId MediumLevelILFunction::StoreStructSSA(size_t size, ExprId dest, uint64_t offset,
- size_t newMemVersion, size_t prevMemVersion, ExprId src,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::StoreStructSSA(size_t size, ExprId dest, uint64_t offset, size_t newMemVersion,
+ size_t prevMemVersion, ExprId src, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_STORE_STRUCT_SSA, loc, size, dest, offset, newMemVersion, prevMemVersion, src);
}
-ExprId MediumLevelILFunction::Var(size_t size, const Variable& src,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::Var(size_t size, const Variable& src, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_VAR, loc, size, src.ToIdentifier());
}
-ExprId MediumLevelILFunction::VarField(size_t size, const Variable& src, uint64_t offset,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::VarField(size_t size, const Variable& src, uint64_t offset, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_VAR_FIELD, loc, size, src.ToIdentifier(), offset);
}
-ExprId MediumLevelILFunction::VarSplit(size_t size, const Variable& high, const Variable& low,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::VarSplit(
+ size_t size, const Variable& high, const Variable& low, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_VAR_SPLIT, loc, size, high.ToIdentifier(), low.ToIdentifier());
}
-ExprId MediumLevelILFunction::VarSSA(size_t size, const SSAVariable& src,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::VarSSA(size_t size, const SSAVariable& src, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_VAR_SSA, loc, size, src.var.ToIdentifier(), src.version);
}
-ExprId MediumLevelILFunction::VarSSAField(size_t size, const SSAVariable& src, uint64_t offset,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::VarSSAField(
+ size_t size, const SSAVariable& src, uint64_t offset, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_VAR_SSA_FIELD, loc, size, src.var.ToIdentifier(), src.version, offset);
}
-ExprId MediumLevelILFunction::VarAliased(size_t size, const Variable& src, size_t memVersion,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::VarAliased(
+ size_t size, const Variable& src, size_t memVersion, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_VAR_ALIASED, loc, size, src.ToIdentifier(), memVersion);
}
-ExprId MediumLevelILFunction::VarAliasedField(size_t size, const Variable& src,
- size_t memVersion, uint64_t offset, const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::VarAliasedField(
+ size_t size, const Variable& src, size_t memVersion, uint64_t offset, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_VAR_ALIASED_FIELD, loc, size, src.ToIdentifier(), memVersion, offset);
}
-ExprId MediumLevelILFunction::VarSplitSSA(size_t size, const SSAVariable& high, const SSAVariable& low,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::VarSplitSSA(
+ size_t size, const SSAVariable& high, const SSAVariable& low, const ILSourceLocation& loc)
{
- return AddExprWithLocation(MLIL_VAR_SPLIT_SSA, loc, size, high.var.ToIdentifier(), high.version,
- low.var.ToIdentifier(), low.version);
+ return AddExprWithLocation(
+ MLIL_VAR_SPLIT_SSA, loc, size, high.var.ToIdentifier(), high.version, low.var.ToIdentifier(), low.version);
}
@@ -2312,8 +2270,7 @@ ExprId MediumLevelILFunction::AddressOf(const Variable& var, const ILSourceLocat
}
-ExprId MediumLevelILFunction::AddressOfField(const Variable& var, uint64_t offset,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::AddressOfField(const Variable& var, uint64_t offset, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_ADDRESS_OF_FIELD, loc, 0, var.ToIdentifier(), offset);
}
@@ -2379,8 +2336,8 @@ ExprId MediumLevelILFunction::Add(size_t size, ExprId left, ExprId right, const
}
-ExprId MediumLevelILFunction::AddWithCarry(size_t size, ExprId left, ExprId right, ExprId carry,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::AddWithCarry(
+ size_t size, ExprId left, ExprId right, ExprId carry, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_ADC, loc, size, left, right, carry);
}
@@ -2392,8 +2349,8 @@ ExprId MediumLevelILFunction::Sub(size_t size, ExprId left, ExprId right, const
}
-ExprId MediumLevelILFunction::SubWithBorrow(size_t size, ExprId left, ExprId right, ExprId carry,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::SubWithBorrow(
+ size_t size, ExprId left, ExprId right, ExprId carry, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_SBB, loc, size, left, right, carry);
}
@@ -2417,127 +2374,112 @@ ExprId MediumLevelILFunction::Xor(size_t size, ExprId left, ExprId right, const
}
-ExprId MediumLevelILFunction::ShiftLeft(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::ShiftLeft(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_LSL, loc, size, left, right);
}
-ExprId MediumLevelILFunction::LogicalShiftRight(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::LogicalShiftRight(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_LSR, loc, size, left, right);
}
-ExprId MediumLevelILFunction::ArithShiftRight(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::ArithShiftRight(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_ASR, loc, size, left, right);
}
-ExprId MediumLevelILFunction::RotateLeft(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::RotateLeft(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_ROL, loc, size, left, right);
}
-ExprId MediumLevelILFunction::RotateLeftCarry(size_t size, ExprId left, ExprId right, ExprId carry,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::RotateLeftCarry(
+ size_t size, ExprId left, ExprId right, ExprId carry, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_RLC, loc, size, left, right, carry);
}
-ExprId MediumLevelILFunction::RotateRight(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::RotateRight(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_ROR, loc, size, left, right);
}
-ExprId MediumLevelILFunction::RotateRightCarry(size_t size, ExprId left, ExprId right, ExprId carry,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::RotateRightCarry(
+ size_t size, ExprId left, ExprId right, ExprId carry, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_RRC, loc, size, left, right, carry);
}
-ExprId MediumLevelILFunction::Mult(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::Mult(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_MUL, loc, size, left, right);
}
-ExprId MediumLevelILFunction::MultDoublePrecSigned(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::MultDoublePrecSigned(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_MULS_DP, loc, size, left, right);
}
-ExprId MediumLevelILFunction::MultDoublePrecUnsigned(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::MultDoublePrecUnsigned(
+ size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_MULU_DP, loc, size, left, right);
}
-ExprId MediumLevelILFunction::DivSigned(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::DivSigned(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_DIVS, loc, size, left, right);
}
-ExprId MediumLevelILFunction::DivUnsigned(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::DivUnsigned(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_DIVU, loc, size, left, right);
}
-ExprId MediumLevelILFunction::DivDoublePrecSigned(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::DivDoublePrecSigned(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_DIVS_DP, loc, size, left, right);
}
-ExprId MediumLevelILFunction::DivDoublePrecUnsigned(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::DivDoublePrecUnsigned(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_DIVU_DP, loc, size, left, right);
}
-ExprId MediumLevelILFunction::ModSigned(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::ModSigned(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_MODS, loc, size, left, right);
}
-ExprId MediumLevelILFunction::ModUnsigned(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::ModUnsigned(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_MODU, loc, size, left, right);
}
-ExprId MediumLevelILFunction::ModDoublePrecSigned(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::ModDoublePrecSigned(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_MODS_DP, loc, size, left, right);
}
-ExprId MediumLevelILFunction::ModDoublePrecUnsigned(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::ModDoublePrecUnsigned(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_MODU_DP, loc, size, left, right);
}
@@ -2579,8 +2521,8 @@ ExprId MediumLevelILFunction::Jump(ExprId dest, const ILSourceLocation& loc)
}
-ExprId MediumLevelILFunction::JumpTo(ExprId dest, const map<uint64_t, BNMediumLevelILLabel*>& targets,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::JumpTo(
+ ExprId dest, const map<uint64_t, BNMediumLevelILLabel*>& targets, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_JUMP_TO, loc, 0, dest, targets.size() * 2, AddLabelMap(targets));
}
@@ -2592,120 +2534,115 @@ ExprId MediumLevelILFunction::ReturnHint(ExprId dest, const ILSourceLocation& lo
}
-ExprId MediumLevelILFunction::Call(const vector<Variable>& output, ExprId dest,
- const vector<ExprId>& params, const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::Call(
+ const vector<Variable>& output, ExprId dest, const vector<ExprId>& params, const ILSourceLocation& loc)
{
- return AddExprWithLocation(MLIL_CALL, loc, 0, output.size(), AddVariableList(output), dest,
- params.size(), AddOperandList(params));
+ return AddExprWithLocation(
+ MLIL_CALL, loc, 0, output.size(), AddVariableList(output), dest, params.size(), AddOperandList(params));
}
-ExprId MediumLevelILFunction::CallUntyped(const vector<Variable>& output, ExprId dest,
- const vector<Variable>& params, ExprId stack, const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::CallUntyped(const vector<Variable>& output, ExprId dest, const vector<Variable>& params,
+ ExprId stack, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_CALL_UNTYPED, loc, 0,
- AddExprWithLocation(MLIL_CALL_OUTPUT, loc, 0, output.size(), AddVariableList(output)), dest,
- AddExprWithLocation(MLIL_CALL_PARAM, loc, 0, params.size(), AddVariableList(params)), stack);
+ AddExprWithLocation(MLIL_CALL_OUTPUT, loc, 0, output.size(), AddVariableList(output)), dest,
+ AddExprWithLocation(MLIL_CALL_PARAM, loc, 0, params.size(), AddVariableList(params)), stack);
}
-ExprId MediumLevelILFunction::Syscall(const vector<Variable>& output, const vector<ExprId>& params,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::Syscall(
+ const vector<Variable>& output, const vector<ExprId>& params, const ILSourceLocation& loc)
{
- return AddExprWithLocation(MLIL_SYSCALL, loc, 0, output.size(), AddVariableList(output),
- params.size(), AddOperandList(params));
+ return AddExprWithLocation(
+ MLIL_SYSCALL, loc, 0, output.size(), AddVariableList(output), params.size(), AddOperandList(params));
}
-ExprId MediumLevelILFunction::SyscallUntyped(const vector<Variable>& output, const vector<Variable>& params,
- ExprId stack, const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::SyscallUntyped(
+ const vector<Variable>& output, const vector<Variable>& params, ExprId stack, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_SYSCALL_UNTYPED, loc, 0,
- AddExprWithLocation(MLIL_CALL_OUTPUT, loc, 0, output.size(), AddVariableList(output)),
- AddExprWithLocation(MLIL_CALL_PARAM, loc, 0, params.size(), AddVariableList(params)), stack);
+ AddExprWithLocation(MLIL_CALL_OUTPUT, loc, 0, output.size(), AddVariableList(output)),
+ AddExprWithLocation(MLIL_CALL_PARAM, loc, 0, params.size(), AddVariableList(params)), stack);
}
-ExprId MediumLevelILFunction::TailCall(const vector<Variable>& output, ExprId dest,
- const vector<ExprId>& params, const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::TailCall(
+ const vector<Variable>& output, ExprId dest, const vector<ExprId>& params, const ILSourceLocation& loc)
{
- return AddExprWithLocation(MLIL_TAILCALL, loc, 0, output.size(), AddVariableList(output), dest,
- params.size(), AddOperandList(params));
+ return AddExprWithLocation(
+ MLIL_TAILCALL, loc, 0, output.size(), AddVariableList(output), dest, params.size(), AddOperandList(params));
}
ExprId MediumLevelILFunction::TailCallUntyped(const vector<Variable>& output, ExprId dest,
- const vector<Variable>& params, ExprId stack, const ILSourceLocation& loc)
+ const vector<Variable>& params, ExprId stack, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_TAILCALL_UNTYPED, loc, 0,
- AddExprWithLocation(MLIL_CALL_OUTPUT, loc, 0, output.size(), AddVariableList(output)), dest,
- AddExprWithLocation(MLIL_CALL_PARAM, loc, 0, params.size(), AddVariableList(params)), stack);
+ AddExprWithLocation(MLIL_CALL_OUTPUT, loc, 0, output.size(), AddVariableList(output)), dest,
+ AddExprWithLocation(MLIL_CALL_PARAM, loc, 0, params.size(), AddVariableList(params)), stack);
}
ExprId MediumLevelILFunction::CallSSA(const vector<SSAVariable>& output, ExprId dest, const vector<ExprId>& params,
- size_t newMemVersion, size_t prevMemVersion, const ILSourceLocation& loc)
+ size_t newMemVersion, size_t prevMemVersion, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_CALL_SSA, loc, 0,
- AddExprWithLocation(MLIL_CALL_OUTPUT_SSA, loc, 0, newMemVersion,
- output.size() * 2, AddSSAVariableList(output)), dest,
- params.size(), AddOperandList(params), prevMemVersion);
+ AddExprWithLocation(MLIL_CALL_OUTPUT_SSA, loc, 0, newMemVersion, output.size() * 2, AddSSAVariableList(output)),
+ dest, params.size(), AddOperandList(params), prevMemVersion);
}
ExprId MediumLevelILFunction::CallUntypedSSA(const vector<SSAVariable>& output, ExprId dest,
- const vector<SSAVariable>& params, size_t newMemVersion, size_t prevMemVersion,
- ExprId stack, const ILSourceLocation& loc)
+ const vector<SSAVariable>& params, size_t newMemVersion, size_t prevMemVersion, ExprId stack,
+ const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_CALL_UNTYPED_SSA, loc, 0,
- AddExprWithLocation(MLIL_CALL_OUTPUT_SSA, loc, 0, newMemVersion,
- output.size() * 2, AddSSAVariableList(output)), dest,
- AddExprWithLocation(MLIL_CALL_PARAM_SSA, loc, 0, prevMemVersion,
- params.size() * 2, AddSSAVariableList(params)), stack);
+ AddExprWithLocation(MLIL_CALL_OUTPUT_SSA, loc, 0, newMemVersion, output.size() * 2, AddSSAVariableList(output)),
+ dest,
+ AddExprWithLocation(MLIL_CALL_PARAM_SSA, loc, 0, prevMemVersion, params.size() * 2, AddSSAVariableList(params)),
+ stack);
}
ExprId MediumLevelILFunction::SyscallSSA(const vector<SSAVariable>& output, const vector<ExprId>& params,
- size_t newMemVersion, size_t prevMemVersion, const ILSourceLocation& loc)
+ size_t newMemVersion, size_t prevMemVersion, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_SYSCALL_SSA, loc, 0,
- AddExprWithLocation(MLIL_CALL_OUTPUT_SSA, loc, 0, newMemVersion,
- output.size() * 2, AddSSAVariableList(output)),
- params.size(), AddOperandList(params), prevMemVersion);
+ AddExprWithLocation(MLIL_CALL_OUTPUT_SSA, loc, 0, newMemVersion, output.size() * 2, AddSSAVariableList(output)),
+ params.size(), AddOperandList(params), prevMemVersion);
}
-ExprId MediumLevelILFunction::SyscallUntypedSSA(const vector<SSAVariable>& output,
- const vector<SSAVariable>& params, size_t newMemVersion, size_t prevMemVersion,
- ExprId stack, const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::SyscallUntypedSSA(const vector<SSAVariable>& output, const vector<SSAVariable>& params,
+ size_t newMemVersion, size_t prevMemVersion, ExprId stack, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_SYSCALL_UNTYPED_SSA, loc, 0,
- AddExprWithLocation(MLIL_CALL_OUTPUT_SSA, loc, 0, newMemVersion,
- output.size() * 2, AddSSAVariableList(output)),
- AddExprWithLocation(MLIL_CALL_PARAM_SSA, loc, 0, prevMemVersion,
- params.size() * 2, AddSSAVariableList(params)), stack);
+ AddExprWithLocation(MLIL_CALL_OUTPUT_SSA, loc, 0, newMemVersion, output.size() * 2, AddSSAVariableList(output)),
+ AddExprWithLocation(MLIL_CALL_PARAM_SSA, loc, 0, prevMemVersion, params.size() * 2, AddSSAVariableList(params)),
+ stack);
}
ExprId MediumLevelILFunction::TailCallSSA(const vector<SSAVariable>& output, ExprId dest, const vector<ExprId>& params,
- size_t newMemVersion, size_t prevMemVersion, const ILSourceLocation& loc)
+ size_t newMemVersion, size_t prevMemVersion, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_TAILCALL_SSA, loc, 0,
- AddExprWithLocation(MLIL_CALL_OUTPUT_SSA, loc, 0, newMemVersion,
- output.size() * 2, AddSSAVariableList(output)), dest,
- params.size(), AddOperandList(params), prevMemVersion);
+ AddExprWithLocation(MLIL_CALL_OUTPUT_SSA, loc, 0, newMemVersion, output.size() * 2, AddSSAVariableList(output)),
+ dest, params.size(), AddOperandList(params), prevMemVersion);
}
ExprId MediumLevelILFunction::TailCallUntypedSSA(const vector<SSAVariable>& output, ExprId dest,
- const vector<SSAVariable>& params, size_t newMemVersion, size_t prevMemVersion,
- ExprId stack, const ILSourceLocation& loc)
+ const vector<SSAVariable>& params, size_t newMemVersion, size_t prevMemVersion, ExprId stack,
+ const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_TAILCALL_UNTYPED_SSA, loc, 0,
- AddExprWithLocation(MLIL_CALL_OUTPUT_SSA, loc, 0, newMemVersion,
- output.size() * 2, AddSSAVariableList(output)), dest,
- AddExprWithLocation(MLIL_CALL_PARAM_SSA, loc, 0, prevMemVersion,
- params.size() * 2, AddSSAVariableList(params)), stack);
+ AddExprWithLocation(MLIL_CALL_OUTPUT_SSA, loc, 0, newMemVersion, output.size() * 2, AddSSAVariableList(output)),
+ dest,
+ AddExprWithLocation(MLIL_CALL_PARAM_SSA, loc, 0, prevMemVersion, params.size() * 2, AddSSAVariableList(params)),
+ stack);
}
@@ -2721,78 +2658,74 @@ ExprId MediumLevelILFunction::NoReturn(const ILSourceLocation& loc)
}
-ExprId MediumLevelILFunction::CompareEqual(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::CompareEqual(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_CMP_E, loc, size, left, right);
}
-ExprId MediumLevelILFunction::CompareNotEqual(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::CompareNotEqual(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_CMP_NE, loc, size, left, right);
}
-ExprId MediumLevelILFunction::CompareSignedLessThan(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::CompareSignedLessThan(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_CMP_SLT, loc, size, left, right);
}
-ExprId MediumLevelILFunction::CompareUnsignedLessThan(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::CompareUnsignedLessThan(
+ size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_CMP_ULT, loc, size, left, right);
}
-ExprId MediumLevelILFunction::CompareSignedLessEqual(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::CompareSignedLessEqual(
+ size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_CMP_SLE, loc, size, left, right);
}
-ExprId MediumLevelILFunction::CompareUnsignedLessEqual(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::CompareUnsignedLessEqual(
+ size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_CMP_ULE, loc, size, left, right);
}
-ExprId MediumLevelILFunction::CompareSignedGreaterEqual(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::CompareSignedGreaterEqual(
+ size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_CMP_SGE, loc, size, left, right);
}
-ExprId MediumLevelILFunction::CompareUnsignedGreaterEqual(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::CompareUnsignedGreaterEqual(
+ size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_CMP_UGE, loc, size, left, right);
}
-ExprId MediumLevelILFunction::CompareSignedGreaterThan(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::CompareSignedGreaterThan(
+ size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_CMP_SGT, loc, size, left, right);
}
-ExprId MediumLevelILFunction::CompareUnsignedGreaterThan(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::CompareUnsignedGreaterThan(
+ size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_CMP_UGT, loc, size, left, right);
}
-ExprId MediumLevelILFunction::TestBit(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::TestBit(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_TEST_BIT, loc, size, left, right);
}
@@ -2804,8 +2737,7 @@ ExprId MediumLevelILFunction::BoolToInt(size_t size, ExprId src, const ILSourceL
}
-ExprId MediumLevelILFunction::AddOverflow(size_t size, ExprId left, ExprId right,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::AddOverflow(size_t size, ExprId left, ExprId right, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_ADD_OVERFLOW, loc, size, left, right);
}
@@ -2823,19 +2755,19 @@ ExprId MediumLevelILFunction::Trap(int64_t vector, const ILSourceLocation& loc)
}
-ExprId MediumLevelILFunction::Intrinsic(const vector<Variable>& outputs, uint32_t intrinsic,
- const vector<ExprId>& params, const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::Intrinsic(
+ const vector<Variable>& outputs, uint32_t intrinsic, const vector<ExprId>& params, const ILSourceLocation& loc)
{
- return AddExprWithLocation(MLIL_INTRINSIC, loc, 0, outputs.size(), AddVariableList(outputs),
- intrinsic, params.size(), AddOperandList(params));
+ return AddExprWithLocation(MLIL_INTRINSIC, loc, 0, outputs.size(), AddVariableList(outputs), intrinsic,
+ params.size(), AddOperandList(params));
}
-ExprId MediumLevelILFunction::IntrinsicSSA(const vector<SSAVariable>& outputs, uint32_t intrinsic,
- const vector<ExprId>& params, const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::IntrinsicSSA(
+ const vector<SSAVariable>& outputs, uint32_t intrinsic, const vector<ExprId>& params, const ILSourceLocation& loc)
{
- return AddExprWithLocation(MLIL_INTRINSIC_SSA, loc, 0, outputs.size() * 2, AddSSAVariableList(outputs),
- intrinsic, params.size(), AddOperandList(params));
+ return AddExprWithLocation(MLIL_INTRINSIC_SSA, loc, 0, outputs.size() * 2, AddSSAVariableList(outputs), intrinsic,
+ params.size(), AddOperandList(params));
}
@@ -2845,8 +2777,8 @@ ExprId MediumLevelILFunction::FreeVarSlot(const Variable& var, const ILSourceLoc
}
-ExprId MediumLevelILFunction::FreeVarSlotSSA(const Variable& var, size_t newVersion, size_t prevVersion,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::FreeVarSlotSSA(
+ const Variable& var, size_t newVersion, size_t prevVersion, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_FREE_VAR_SLOT_SSA, loc, 0, var.ToIdentifier(), newVersion, prevVersion);
}
@@ -2864,26 +2796,25 @@ ExprId MediumLevelILFunction::Unimplemented(const ILSourceLocation& loc)
}
-ExprId MediumLevelILFunction::UnimplementedMemoryRef(size_t size, ExprId target,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::UnimplementedMemoryRef(size_t size, ExprId target, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_UNIMPL_MEM, loc, size, target);
}
-ExprId MediumLevelILFunction::VarPhi(const SSAVariable& dest, const vector<SSAVariable>& sources,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::VarPhi(
+ const SSAVariable& dest, const vector<SSAVariable>& sources, const ILSourceLocation& loc)
{
- return AddExprWithLocation(MLIL_VAR_PHI, loc, 0, dest.var.ToIdentifier(), dest.version,
- sources.size() * 2, AddSSAVariableList(sources));
+ return AddExprWithLocation(
+ MLIL_VAR_PHI, loc, 0, dest.var.ToIdentifier(), dest.version, sources.size() * 2, AddSSAVariableList(sources));
}
-ExprId MediumLevelILFunction::MemoryPhi(size_t destMemVersion, const vector<size_t>& sourceMemVersions,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::MemoryPhi(
+ size_t destMemVersion, const vector<size_t>& sourceMemVersions, const ILSourceLocation& loc)
{
- return AddExprWithLocation(MLIL_MEM_PHI, loc, 0, destMemVersion,
- sourceMemVersions.size(), AddIndexList(sourceMemVersions));
+ return AddExprWithLocation(
+ MLIL_MEM_PHI, loc, 0, destMemVersion, sourceMemVersions.size(), AddIndexList(sourceMemVersions));
}
diff --git a/mediumlevelilinstruction.h b/mediumlevelilinstruction.h
index 1d3d2689..7e6194a7 100644
--- a/mediumlevelilinstruction.h
+++ b/mediumlevelilinstruction.h
@@ -24,9 +24,9 @@
#include <unordered_map>
#include <vector>
#ifdef BINARYNINJACORE_LIBRARY
-#include "variable.h"
+ #include "variable.h"
#else
-#include "binaryninjaapi.h"
+ #include "binaryninjaapi.h"
#endif
#ifdef BINARYNINJACORE_LIBRARY
@@ -38,7 +38,8 @@ namespace BinaryNinja
class MediumLevelILFunction;
template <BNMediumLevelILOperation N>
- struct MediumLevelILInstructionAccessor {};
+ struct MediumLevelILInstructionAccessor
+ {};
struct MediumLevelILInstruction;
struct MediumLevelILConstantInstruction;
@@ -122,14 +123,15 @@ namespace BinaryNinja
ParameterSSAMemoryVersionMediumLevelOperandUsage,
SourceSSAVariablesMediumLevelOperandUsages
};
-}
+} // namespace BinaryNinjaCore
-namespace std
-{
+namespace std {
#ifdef BINARYNINJACORE_LIBRARY
- template<> struct hash<BinaryNinjaCore::SSAVariable>
+ template <>
+ struct hash<BinaryNinjaCore::SSAVariable>
#else
- template<> struct hash<BinaryNinja::SSAVariable>
+ template <>
+ struct hash<BinaryNinja::SSAVariable>
#endif
{
#ifdef BINARYNINJACORE_LIBRARY
@@ -143,20 +145,20 @@ namespace std
}
};
- template<> struct hash<BNMediumLevelILOperation>
+ template <>
+ struct hash<BNMediumLevelILOperation>
{
typedef BNMediumLevelILOperation argument_type;
typedef int result_type;
- result_type operator()(argument_type const& value) const
- {
- return (result_type)value;
- }
+ result_type operator()(argument_type const& value) const { return (result_type)value; }
};
#ifdef BINARYNINJACORE_LIBRARY
- template<> struct hash<BinaryNinjaCore::MediumLevelILOperandUsage>
+ template <>
+ struct hash<BinaryNinjaCore::MediumLevelILOperandUsage>
#else
- template<> struct hash<BinaryNinja::MediumLevelILOperandUsage>
+ template <>
+ struct hash<BinaryNinja::MediumLevelILOperandUsage>
#endif
{
#ifdef BINARYNINJACORE_LIBRARY
@@ -165,12 +167,9 @@ namespace std
typedef BinaryNinja::MediumLevelILOperandUsage argument_type;
#endif
typedef int result_type;
- result_type operator()(argument_type const& value) const
- {
- return (result_type)value;
- }
+ result_type operator()(argument_type const& value) const { return (result_type)value; }
};
-}
+} // namespace std
#ifdef BINARYNINJACORE_LIBRARY
namespace BinaryNinjaCore
@@ -179,21 +178,21 @@ namespace BinaryNinja
#endif
{
#ifdef BINARYNINJACORE_LIBRARY
-#define _STD_VECTOR vector
-#define _STD_SET set
-#define _STD_UNORDERED_MAP unordered_map
-#define _STD_MAP map
+ #define _STD_VECTOR vector
+ #define _STD_SET set
+ #define _STD_UNORDERED_MAP unordered_map
+ #define _STD_MAP map
#else
-#define _STD_VECTOR std::vector
-#define _STD_SET std::set
-#define _STD_UNORDERED_MAP std::unordered_map
-#define _STD_MAP std::map
+ #define _STD_VECTOR std::vector
+ #define _STD_SET std::set
+ #define _STD_UNORDERED_MAP std::unordered_map
+ #define _STD_MAP std::map
#endif
- class MediumLevelILInstructionAccessException: public std::exception
+ class MediumLevelILInstructionAccessException : public std::exception
{
- public:
- MediumLevelILInstructionAccessException(): std::exception() {}
+ public:
+ MediumLevelILInstructionAccessException() : std::exception() {}
virtual const char* what() const NOEXCEPT { return "invalid access to MLIL instruction"; }
};
@@ -219,7 +218,7 @@ namespace BinaryNinja
ListIterator m_start;
- public:
+ public:
typedef ListIterator const_iterator;
MediumLevelILIntegerList(MediumLevelILFunction* func, const BNMediumLevelILInstruction& instr, size_t count);
@@ -240,13 +239,17 @@ namespace BinaryNinja
bool operator==(const ListIterator& a) const { return pos == a.pos; }
bool operator!=(const ListIterator& a) const { return pos != a.pos; }
bool operator<(const ListIterator& a) const { return pos < a.pos; }
- ListIterator& operator++() { ++pos; return *this; }
+ ListIterator& operator++()
+ {
+ ++pos;
+ return *this;
+ }
size_t operator*();
};
MediumLevelILIntegerList m_list;
- public:
+ public:
typedef ListIterator const_iterator;
MediumLevelILIndexList(MediumLevelILFunction* func, const BNMediumLevelILInstruction& instr, size_t count);
@@ -267,13 +270,18 @@ namespace BinaryNinja
bool operator==(const ListIterator& a) const { return pos == a.pos; }
bool operator!=(const ListIterator& a) const { return pos != a.pos; }
bool operator<(const ListIterator& a) const { return pos < a.pos; }
- ListIterator& operator++() { ++pos; ++pos; return *this; }
+ ListIterator& operator++()
+ {
+ ++pos;
+ ++pos;
+ return *this;
+ }
const std::pair<uint64_t, size_t> operator*();
};
MediumLevelILIntegerList m_list;
- public:
+ public:
typedef ListIterator const_iterator;
MediumLevelILIndexMap(MediumLevelILFunction* func, const BNMediumLevelILInstruction& instr, size_t count);
@@ -294,13 +302,17 @@ namespace BinaryNinja
bool operator==(const ListIterator& a) const { return pos == a.pos; }
bool operator!=(const ListIterator& a) const { return pos != a.pos; }
bool operator<(const ListIterator& a) const { return pos < a.pos; }
- ListIterator& operator++() { ++pos; return *this; }
+ ListIterator& operator++()
+ {
+ ++pos;
+ return *this;
+ }
const Variable operator*();
};
MediumLevelILIntegerList m_list;
- public:
+ public:
typedef ListIterator const_iterator;
MediumLevelILVariableList(MediumLevelILFunction* func, const BNMediumLevelILInstruction& instr, size_t count);
@@ -321,16 +333,22 @@ namespace BinaryNinja
bool operator==(const ListIterator& a) const { return pos == a.pos; }
bool operator!=(const ListIterator& a) const { return pos != a.pos; }
bool operator<(const ListIterator& a) const { return pos < a.pos; }
- ListIterator& operator++() { ++pos; ++pos; return *this; }
+ ListIterator& operator++()
+ {
+ ++pos;
+ ++pos;
+ return *this;
+ }
const SSAVariable operator*();
};
MediumLevelILIntegerList m_list;
- public:
+ public:
typedef ListIterator const_iterator;
- MediumLevelILSSAVariableList(MediumLevelILFunction* func, const BNMediumLevelILInstruction& instr, size_t count);
+ MediumLevelILSSAVariableList(
+ MediumLevelILFunction* func, const BNMediumLevelILInstruction& instr, size_t count);
const_iterator begin() const;
const_iterator end() const;
@@ -349,18 +367,22 @@ namespace BinaryNinja
bool operator==(const ListIterator& a) const { return pos == a.pos; }
bool operator!=(const ListIterator& a) const { return pos != a.pos; }
bool operator<(const ListIterator& a) const { return pos < a.pos; }
- ListIterator& operator++() { ++pos; return *this; }
+ ListIterator& operator++()
+ {
+ ++pos;
+ return *this;
+ }
const MediumLevelILInstruction operator*();
};
MediumLevelILIntegerList m_list;
size_t m_instructionIndex;
- public:
+ public:
typedef ListIterator const_iterator;
MediumLevelILInstructionList(MediumLevelILFunction* func, const BNMediumLevelILInstruction& instr, size_t count,
- size_t instructionIndex);
+ size_t instructionIndex);
const_iterator begin() const;
const_iterator end() const;
@@ -370,7 +392,7 @@ namespace BinaryNinja
operator _STD_VECTOR<MediumLevelILInstruction>() const;
};
- struct MediumLevelILInstructionBase: public BNMediumLevelILInstruction
+ struct MediumLevelILInstructionBase : public BNMediumLevelILInstruction
{
#ifdef BINARYNINJACORE_LIBRARY
MediumLevelILFunction* function;
@@ -380,10 +402,10 @@ namespace BinaryNinja
size_t exprIndex, instructionIndex;
static _STD_UNORDERED_MAP<MediumLevelILOperandUsage, MediumLevelILOperandType> operandTypeForUsage;
- static _STD_UNORDERED_MAP<BNMediumLevelILOperation,
- _STD_VECTOR<MediumLevelILOperandUsage>> operationOperandUsage;
- static _STD_UNORDERED_MAP<BNMediumLevelILOperation,
- _STD_UNORDERED_MAP<MediumLevelILOperandUsage, size_t>> operationOperandIndex;
+ static _STD_UNORDERED_MAP<BNMediumLevelILOperation, _STD_VECTOR<MediumLevelILOperandUsage>>
+ operationOperandUsage;
+ static _STD_UNORDERED_MAP<BNMediumLevelILOperation, _STD_UNORDERED_MAP<MediumLevelILOperandUsage, size_t>>
+ operationOperandIndex;
MediumLevelILOperandList GetOperands() const;
@@ -405,8 +427,8 @@ namespace BinaryNinja
void UpdateRawOperandAsExprList(size_t operandIndex, const _STD_VECTOR<size_t>& exprs);
RegisterValue GetValue() const;
- PossibleValueSet GetPossibleValues(const _STD_SET<BNDataFlowQueryOption>& options =
- _STD_SET<BNDataFlowQueryOption>()) const;
+ PossibleValueSet GetPossibleValues(
+ const _STD_SET<BNDataFlowQueryOption>& options = _STD_SET<BNDataFlowQueryOption>()) const;
Confidence<Ref<Type>> GetType() const;
size_t GetSSAVarVersion(const Variable& var);
@@ -459,14 +481,8 @@ namespace BinaryNinja
throw MediumLevelILInstructionAccessException();
return *(MediumLevelILInstructionAccessor<N>*)this;
}
- MediumLevelILOneOperandInstruction& AsOneOperand()
- {
- return *(MediumLevelILOneOperandInstruction*)this;
- }
- MediumLevelILTwoOperandInstruction& AsTwoOperand()
- {
- return *(MediumLevelILTwoOperandInstruction*)this;
- }
+ MediumLevelILOneOperandInstruction& AsOneOperand() { return *(MediumLevelILOneOperandInstruction*)this; }
+ MediumLevelILTwoOperandInstruction& AsTwoOperand() { return *(MediumLevelILTwoOperandInstruction*)this; }
MediumLevelILTwoOperandWithCarryInstruction& AsTwoOperandWithCarry()
{
return *(MediumLevelILTwoOperandWithCarryInstruction*)this;
@@ -497,66 +513,246 @@ namespace BinaryNinja
}
};
- struct MediumLevelILInstruction: public MediumLevelILInstructionBase
+ struct MediumLevelILInstruction : public MediumLevelILInstructionBase
{
MediumLevelILInstruction();
- MediumLevelILInstruction(MediumLevelILFunction* func, const BNMediumLevelILInstruction& instr,
- size_t expr, size_t instrIdx);
+ MediumLevelILInstruction(
+ MediumLevelILFunction* func, const BNMediumLevelILInstruction& instr, size_t expr, size_t instrIdx);
MediumLevelILInstruction(const MediumLevelILInstructionBase& instr);
void VisitExprs(const std::function<bool(const MediumLevelILInstruction& expr)>& func) const;
ExprId CopyTo(MediumLevelILFunction* dest) const;
ExprId CopyTo(MediumLevelILFunction* dest,
- const std::function<ExprId(const MediumLevelILInstruction& subExpr)>& subExprHandler) const;
+ const std::function<ExprId(const MediumLevelILInstruction& subExpr)>& subExprHandler) const;
// Templated accessors for instruction operands, use these for efficient access to a known instruction
- template <BNMediumLevelILOperation N> MediumLevelILInstruction GetSourceExpr() const { return As<N>().GetSourceExpr(); }
- template <BNMediumLevelILOperation N> Variable GetSourceVariable() const { return As<N>().GetSourceVariable(); }
- template <BNMediumLevelILOperation N> SSAVariable GetSourceSSAVariable() const { return As<N>().GetSourceSSAVariable(); }
- template <BNMediumLevelILOperation N> MediumLevelILInstruction GetDestExpr() const { return As<N>().GetDestExpr(); }
- template <BNMediumLevelILOperation N> Variable GetDestVariable() const { return As<N>().GetDestVariable(); }
- template <BNMediumLevelILOperation N> SSAVariable GetDestSSAVariable() const { return As<N>().GetDestSSAVariable(); }
- template <BNMediumLevelILOperation N> MediumLevelILInstruction GetLeftExpr() const { return As<N>().GetLeftExpr(); }
- template <BNMediumLevelILOperation N> MediumLevelILInstruction GetRightExpr() const { return As<N>().GetRightExpr(); }
- template <BNMediumLevelILOperation N> MediumLevelILInstruction GetCarryExpr() const { return As<N>().GetCarryExpr(); }
- template <BNMediumLevelILOperation N> MediumLevelILInstruction GetStackExpr() const { return As<N>().GetStackExpr(); }
- template <BNMediumLevelILOperation N> MediumLevelILInstruction GetConditionExpr() const { return As<N>().GetConditionExpr(); }
- template <BNMediumLevelILOperation N> Variable GetHighVariable() const { return As<N>().GetHighVariable(); }
- template <BNMediumLevelILOperation N> Variable GetLowVariable() const { return As<N>().GetLowVariable(); }
- template <BNMediumLevelILOperation N> SSAVariable GetHighSSAVariable() const { return As<N>().GetHighSSAVariable(); }
- template <BNMediumLevelILOperation N> SSAVariable GetLowSSAVariable() const { return As<N>().GetLowSSAVariable(); }
- template <BNMediumLevelILOperation N> uint64_t GetOffset() const { return As<N>().GetOffset(); }
- template <BNMediumLevelILOperation N> int64_t GetConstant() const { return As<N>().GetConstant(); }
- template <BNMediumLevelILOperation N> int64_t GetVector() const { return As<N>().GetVector(); }
- template <BNMediumLevelILOperation N> uint32_t GetIntrinsic() const { return As<N>().GetIntrinsic(); }
- template <BNMediumLevelILOperation N> size_t GetTarget() const { return As<N>().GetTarget(); }
- template <BNMediumLevelILOperation N> size_t GetTrueTarget() const { return As<N>().GetTrueTarget(); }
- template <BNMediumLevelILOperation N> size_t GetFalseTarget() const { return As<N>().GetFalseTarget(); }
- template <BNMediumLevelILOperation N> size_t GetDestMemoryVersion() const { return As<N>().GetDestMemoryVersion(); }
- template <BNMediumLevelILOperation N> size_t GetSourceMemoryVersion() const { return As<N>().GetSourceMemoryVersion(); }
- template <BNMediumLevelILOperation N> MediumLevelILIndexMap GetTargets() const { return As<N>().GetTargets(); }
- template <BNMediumLevelILOperation N> MediumLevelILIndexList GetSourceMemoryVersions() const { return As<N>().GetSourceMemoryVersions(); }
- template <BNMediumLevelILOperation N> MediumLevelILVariableList GetOutputVariables() const { return As<N>().GetOutputVariables(); }
- template <BNMediumLevelILOperation N> MediumLevelILSSAVariableList GetOutputSSAVariables() const { return As<N>().GetOutputSSAVariables(); }
- template <BNMediumLevelILOperation N> MediumLevelILInstructionList GetParameterExprs() const { return As<N>().GetParameterExprs(); }
- template <BNMediumLevelILOperation N> MediumLevelILInstructionList GetSourceExprs() const { return As<N>().GetSourceExprs(); }
- template <BNMediumLevelILOperation N> MediumLevelILVariableList GetParameterVariables() const { return As<N>().GetParameterVariables(); }
- template <BNMediumLevelILOperation N> MediumLevelILSSAVariableList GetParameterSSAVariables() const { return As<N>().GetParameterSSAVariables(); }
- template <BNMediumLevelILOperation N> MediumLevelILSSAVariableList GetSourceSSAVariables() const { return As<N>().GetSourceSSAVariables(); }
+ template <BNMediumLevelILOperation N>
+ MediumLevelILInstruction GetSourceExpr() const
+ {
+ return As<N>().GetSourceExpr();
+ }
+ template <BNMediumLevelILOperation N>
+ Variable GetSourceVariable() const
+ {
+ return As<N>().GetSourceVariable();
+ }
+ template <BNMediumLevelILOperation N>
+ SSAVariable GetSourceSSAVariable() const
+ {
+ return As<N>().GetSourceSSAVariable();
+ }
+ template <BNMediumLevelILOperation N>
+ MediumLevelILInstruction GetDestExpr() const
+ {
+ return As<N>().GetDestExpr();
+ }
+ template <BNMediumLevelILOperation N>
+ Variable GetDestVariable() const
+ {
+ return As<N>().GetDestVariable();
+ }
+ template <BNMediumLevelILOperation N>
+ SSAVariable GetDestSSAVariable() const
+ {
+ return As<N>().GetDestSSAVariable();
+ }
+ template <BNMediumLevelILOperation N>
+ MediumLevelILInstruction GetLeftExpr() const
+ {
+ return As<N>().GetLeftExpr();
+ }
+ template <BNMediumLevelILOperation N>
+ MediumLevelILInstruction GetRightExpr() const
+ {
+ return As<N>().GetRightExpr();
+ }
+ template <BNMediumLevelILOperation N>
+ MediumLevelILInstruction GetCarryExpr() const
+ {
+ return As<N>().GetCarryExpr();
+ }
+ template <BNMediumLevelILOperation N>
+ MediumLevelILInstruction GetStackExpr() const
+ {
+ return As<N>().GetStackExpr();
+ }
+ template <BNMediumLevelILOperation N>
+ MediumLevelILInstruction GetConditionExpr() const
+ {
+ return As<N>().GetConditionExpr();
+ }
+ template <BNMediumLevelILOperation N>
+ Variable GetHighVariable() const
+ {
+ return As<N>().GetHighVariable();
+ }
+ template <BNMediumLevelILOperation N>
+ Variable GetLowVariable() const
+ {
+ return As<N>().GetLowVariable();
+ }
+ template <BNMediumLevelILOperation N>
+ SSAVariable GetHighSSAVariable() const
+ {
+ return As<N>().GetHighSSAVariable();
+ }
+ template <BNMediumLevelILOperation N>
+ SSAVariable GetLowSSAVariable() const
+ {
+ return As<N>().GetLowSSAVariable();
+ }
+ template <BNMediumLevelILOperation N>
+ uint64_t GetOffset() const
+ {
+ return As<N>().GetOffset();
+ }
+ template <BNMediumLevelILOperation N>
+ int64_t GetConstant() const
+ {
+ return As<N>().GetConstant();
+ }
+ template <BNMediumLevelILOperation N>
+ int64_t GetVector() const
+ {
+ return As<N>().GetVector();
+ }
+ template <BNMediumLevelILOperation N>
+ uint32_t GetIntrinsic() const
+ {
+ return As<N>().GetIntrinsic();
+ }
+ template <BNMediumLevelILOperation N>
+ size_t GetTarget() const
+ {
+ return As<N>().GetTarget();
+ }
+ template <BNMediumLevelILOperation N>
+ size_t GetTrueTarget() const
+ {
+ return As<N>().GetTrueTarget();
+ }
+ template <BNMediumLevelILOperation N>
+ size_t GetFalseTarget() const
+ {
+ return As<N>().GetFalseTarget();
+ }
+ template <BNMediumLevelILOperation N>
+ size_t GetDestMemoryVersion() const
+ {
+ return As<N>().GetDestMemoryVersion();
+ }
+ template <BNMediumLevelILOperation N>
+ size_t GetSourceMemoryVersion() const
+ {
+ return As<N>().GetSourceMemoryVersion();
+ }
+ template <BNMediumLevelILOperation N>
+ MediumLevelILIndexMap GetTargets() const
+ {
+ return As<N>().GetTargets();
+ }
+ template <BNMediumLevelILOperation N>
+ MediumLevelILIndexList GetSourceMemoryVersions() const
+ {
+ return As<N>().GetSourceMemoryVersions();
+ }
+ template <BNMediumLevelILOperation N>
+ MediumLevelILVariableList GetOutputVariables() const
+ {
+ return As<N>().GetOutputVariables();
+ }
+ template <BNMediumLevelILOperation N>
+ MediumLevelILSSAVariableList GetOutputSSAVariables() const
+ {
+ return As<N>().GetOutputSSAVariables();
+ }
+ template <BNMediumLevelILOperation N>
+ MediumLevelILInstructionList GetParameterExprs() const
+ {
+ return As<N>().GetParameterExprs();
+ }
+ template <BNMediumLevelILOperation N>
+ MediumLevelILInstructionList GetSourceExprs() const
+ {
+ return As<N>().GetSourceExprs();
+ }
+ template <BNMediumLevelILOperation N>
+ MediumLevelILVariableList GetParameterVariables() const
+ {
+ return As<N>().GetParameterVariables();
+ }
+ template <BNMediumLevelILOperation N>
+ MediumLevelILSSAVariableList GetParameterSSAVariables() const
+ {
+ return As<N>().GetParameterSSAVariables();
+ }
+ template <BNMediumLevelILOperation N>
+ MediumLevelILSSAVariableList GetSourceSSAVariables() const
+ {
+ return As<N>().GetSourceSSAVariables();
+ }
- template <BNMediumLevelILOperation N> void SetDestSSAVersion(size_t version) { As<N>().SetDestSSAVersion(version); }
- template <BNMediumLevelILOperation N> void SetSourceSSAVersion(size_t version) { As<N>().SetSourceSSAVersion(version); }
- template <BNMediumLevelILOperation N> void SetHighSSAVersion(size_t version) { As<N>().SetHighSSAVersion(version); }
- template <BNMediumLevelILOperation N> void SetLowSSAVersion(size_t version) { As<N>().SetLowSSAVersion(version); }
- template <BNMediumLevelILOperation N> void SetDestMemoryVersion(size_t version) { As<N>().SetDestMemoryVersion(version); }
- template <BNMediumLevelILOperation N> void SetSourceMemoryVersion(size_t version) { As<N>().SetSourceMemoryVersion(version); }
- template <BNMediumLevelILOperation N> void SetOutputSSAVariables(const _STD_VECTOR<SSAVariable>& vars) { As<N>().SetOutputSSAVariables(vars); }
- template <BNMediumLevelILOperation N> void SetParameterSSAVariables(const _STD_VECTOR<SSAVariable>& vars) { As<N>().SetParameterSSAVariables(vars); }
- template <BNMediumLevelILOperation N> void SetParameterExprs(const _STD_VECTOR<MediumLevelILInstruction>& params) { As<N>().SetParameterExprs(params); }
- template <BNMediumLevelILOperation N> void SetParameterExprs(const _STD_VECTOR<ExprId>& params) { As<N>().SetParameterExprs(params); }
- template <BNMediumLevelILOperation N> void SetSourceExprs(const _STD_VECTOR<MediumLevelILInstruction>& params) { As<N>().SetSourceExprs(params); }
- template <BNMediumLevelILOperation N> void SetSourceExprs(const _STD_VECTOR<ExprId>& params) { As<N>().SetSourceExprs(params); }
+ template <BNMediumLevelILOperation N>
+ void SetDestSSAVersion(size_t version)
+ {
+ As<N>().SetDestSSAVersion(version);
+ }
+ template <BNMediumLevelILOperation N>
+ void SetSourceSSAVersion(size_t version)
+ {
+ As<N>().SetSourceSSAVersion(version);
+ }
+ template <BNMediumLevelILOperation N>
+ void SetHighSSAVersion(size_t version)
+ {
+ As<N>().SetHighSSAVersion(version);
+ }
+ template <BNMediumLevelILOperation N>
+ void SetLowSSAVersion(size_t version)
+ {
+ As<N>().SetLowSSAVersion(version);
+ }
+ template <BNMediumLevelILOperation N>
+ void SetDestMemoryVersion(size_t version)
+ {
+ As<N>().SetDestMemoryVersion(version);
+ }
+ template <BNMediumLevelILOperation N>
+ void SetSourceMemoryVersion(size_t version)
+ {
+ As<N>().SetSourceMemoryVersion(version);
+ }
+ template <BNMediumLevelILOperation N>
+ void SetOutputSSAVariables(const _STD_VECTOR<SSAVariable>& vars)
+ {
+ As<N>().SetOutputSSAVariables(vars);
+ }
+ template <BNMediumLevelILOperation N>
+ void SetParameterSSAVariables(const _STD_VECTOR<SSAVariable>& vars)
+ {
+ As<N>().SetParameterSSAVariables(vars);
+ }
+ template <BNMediumLevelILOperation N>
+ void SetParameterExprs(const _STD_VECTOR<MediumLevelILInstruction>& params)
+ {
+ As<N>().SetParameterExprs(params);
+ }
+ template <BNMediumLevelILOperation N>
+ void SetParameterExprs(const _STD_VECTOR<ExprId>& params)
+ {
+ As<N>().SetParameterExprs(params);
+ }
+ template <BNMediumLevelILOperation N>
+ void SetSourceExprs(const _STD_VECTOR<MediumLevelILInstruction>& params)
+ {
+ As<N>().SetSourceExprs(params);
+ }
+ template <BNMediumLevelILOperation N>
+ void SetSourceExprs(const _STD_VECTOR<ExprId>& params)
+ {
+ As<N>().SetSourceExprs(params);
+ }
bool GetOperandIndexForUsage(MediumLevelILOperandUsage usage, size_t& operandIndex) const;
@@ -604,9 +800,9 @@ namespace BinaryNinja
MediumLevelILOperandType m_type;
size_t m_operandIndex;
- public:
- MediumLevelILOperand(const MediumLevelILInstruction& instr, MediumLevelILOperandUsage usage,
- size_t operandIndex);
+ public:
+ MediumLevelILOperand(
+ const MediumLevelILInstruction& instr, MediumLevelILOperandUsage usage, size_t operandIndex);
MediumLevelILOperandType GetType() const { return m_type; }
MediumLevelILOperandUsage GetUsage() const { return m_usage; }
@@ -633,7 +829,11 @@ namespace BinaryNinja
bool operator==(const ListIterator& a) const { return pos == a.pos; }
bool operator!=(const ListIterator& a) const { return pos != a.pos; }
bool operator<(const ListIterator& a) const { return pos < a.pos; }
- ListIterator& operator++() { ++pos; return *this; }
+ ListIterator& operator++()
+ {
+ ++pos;
+ return *this;
+ }
const MediumLevelILOperand operator*();
};
@@ -641,12 +841,12 @@ namespace BinaryNinja
const _STD_VECTOR<MediumLevelILOperandUsage>& m_usageList;
const _STD_UNORDERED_MAP<MediumLevelILOperandUsage, size_t>& m_operandIndexMap;
- public:
+ public:
typedef ListIterator const_iterator;
MediumLevelILOperandList(const MediumLevelILInstruction& instr,
- const _STD_VECTOR<MediumLevelILOperandUsage>& usageList,
- const _STD_UNORDERED_MAP<MediumLevelILOperandUsage, size_t>& operandIndexMap);
+ const _STD_VECTOR<MediumLevelILOperandUsage>& usageList,
+ const _STD_UNORDERED_MAP<MediumLevelILOperandUsage, size_t>& operandIndexMap);
const_iterator begin() const;
const_iterator end() const;
@@ -656,23 +856,23 @@ namespace BinaryNinja
operator _STD_VECTOR<MediumLevelILOperand>() const;
};
- struct MediumLevelILConstantInstruction: public MediumLevelILInstructionBase
+ struct MediumLevelILConstantInstruction : public MediumLevelILInstructionBase
{
int64_t GetConstant() const { return GetRawOperandAsInteger(0); }
};
- struct MediumLevelILOneOperandInstruction: public MediumLevelILInstructionBase
+ struct MediumLevelILOneOperandInstruction : public MediumLevelILInstructionBase
{
MediumLevelILInstruction GetSourceExpr() const { return GetRawOperandAsExpr(0); }
};
- struct MediumLevelILTwoOperandInstruction: public MediumLevelILInstructionBase
+ struct MediumLevelILTwoOperandInstruction : public MediumLevelILInstructionBase
{
MediumLevelILInstruction GetLeftExpr() const { return GetRawOperandAsExpr(0); }
MediumLevelILInstruction GetRightExpr() const { return GetRawOperandAsExpr(1); }
};
- struct MediumLevelILTwoOperandWithCarryInstruction: public MediumLevelILInstructionBase
+ struct MediumLevelILTwoOperandWithCarryInstruction : public MediumLevelILInstructionBase
{
MediumLevelILInstruction GetLeftExpr() const { return GetRawOperandAsExpr(0); }
MediumLevelILInstruction GetRightExpr() const { return GetRawOperandAsExpr(1); }
@@ -682,31 +882,36 @@ namespace BinaryNinja
// Implementations of each instruction to fetch the correct operand value for the valid operands, these
// are derived from MediumLevelILInstructionBase so that invalid operand accessor functions will generate
// a compiler error.
- template <> struct MediumLevelILInstructionAccessor<MLIL_SET_VAR>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_SET_VAR> : public MediumLevelILInstructionBase
{
Variable GetDestVariable() const { return GetRawOperandAsVariable(0); }
MediumLevelILInstruction GetSourceExpr() const { return GetRawOperandAsExpr(1); }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_SET_VAR_FIELD>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_SET_VAR_FIELD> : public MediumLevelILInstructionBase
{
Variable GetDestVariable() const { return GetRawOperandAsVariable(0); }
uint64_t GetOffset() const { return GetRawOperandAsInteger(1); }
MediumLevelILInstruction GetSourceExpr() const { return GetRawOperandAsExpr(2); }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_SET_VAR_SPLIT>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_SET_VAR_SPLIT> : public MediumLevelILInstructionBase
{
Variable GetHighVariable() const { return GetRawOperandAsVariable(0); }
Variable GetLowVariable() const { return GetRawOperandAsVariable(1); }
MediumLevelILInstruction GetSourceExpr() const { return GetRawOperandAsExpr(2); }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_SET_VAR_SSA>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_SET_VAR_SSA> : public MediumLevelILInstructionBase
{
SSAVariable GetDestSSAVariable() const { return GetRawOperandAsSSAVariable(0); }
MediumLevelILInstruction GetSourceExpr() const { return GetRawOperandAsExpr(2); }
void SetDestSSAVersion(size_t version) { UpdateRawOperand(1, version); }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_SET_VAR_SSA_FIELD>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_SET_VAR_SSA_FIELD> : public MediumLevelILInstructionBase
{
SSAVariable GetDestSSAVariable() const { return GetRawOperandAsSSAVariable(0); }
SSAVariable GetSourceSSAVariable() const { return GetRawOperandAsPartialSSAVariableSource(0); }
@@ -715,7 +920,8 @@ namespace BinaryNinja
void SetDestSSAVersion(size_t version) { UpdateRawOperand(1, version); }
void SetSourceSSAVersion(size_t version) { UpdateRawOperand(2, version); }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_SET_VAR_SPLIT_SSA>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_SET_VAR_SPLIT_SSA> : public MediumLevelILInstructionBase
{
SSAVariable GetHighSSAVariable() const { return GetRawOperandAsSSAVariable(0); }
SSAVariable GetLowSSAVariable() const { return GetRawOperandAsSSAVariable(2); }
@@ -723,7 +929,8 @@ namespace BinaryNinja
void SetHighSSAVersion(size_t version) { UpdateRawOperand(1, version); }
void SetLowSSAVersion(size_t version) { UpdateRawOperand(3, version); }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_SET_VAR_ALIASED>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_SET_VAR_ALIASED> : public MediumLevelILInstructionBase
{
SSAVariable GetDestSSAVariable() const { return GetRawOperandAsSSAVariable(0); }
SSAVariable GetSourceSSAVariable() const { return GetRawOperandAsPartialSSAVariableSource(0); }
@@ -731,7 +938,8 @@ namespace BinaryNinja
void SetDestMemoryVersion(size_t version) { UpdateRawOperand(1, version); }
void SetSourceMemoryVersion(size_t version) { UpdateRawOperand(2, version); }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_SET_VAR_ALIASED_FIELD>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_SET_VAR_ALIASED_FIELD> : public MediumLevelILInstructionBase
{
SSAVariable GetDestSSAVariable() const { return GetRawOperandAsSSAVariable(0); }
SSAVariable GetSourceSSAVariable() const { return GetRawOperandAsPartialSSAVariableSource(0); }
@@ -741,19 +949,24 @@ namespace BinaryNinja
void SetSourceMemoryVersion(size_t version) { UpdateRawOperand(2, version); }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_LOAD>: public MediumLevelILOneOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_LOAD_STRUCT>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_LOAD> : public MediumLevelILOneOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_LOAD_STRUCT> : public MediumLevelILInstructionBase
{
MediumLevelILInstruction GetSourceExpr() const { return GetRawOperandAsExpr(0); }
uint64_t GetOffset() const { return GetRawOperandAsInteger(1); }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_LOAD_SSA>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_LOAD_SSA> : public MediumLevelILInstructionBase
{
MediumLevelILInstruction GetSourceExpr() const { return GetRawOperandAsExpr(0); }
size_t GetSourceMemoryVersion() const { return GetRawOperandAsIndex(1); }
void SetSourceMemoryVersion(size_t version) { UpdateRawOperand(1, version); }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_LOAD_STRUCT_SSA>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_LOAD_STRUCT_SSA> : public MediumLevelILInstructionBase
{
MediumLevelILInstruction GetSourceExpr() const { return GetRawOperandAsExpr(0); }
uint64_t GetOffset() const { return GetRawOperandAsInteger(1); }
@@ -761,18 +974,21 @@ namespace BinaryNinja
void SetSourceMemoryVersion(size_t version) { UpdateRawOperand(2, version); }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_STORE>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_STORE> : public MediumLevelILInstructionBase
{
MediumLevelILInstruction GetDestExpr() const { return GetRawOperandAsExpr(0); }
MediumLevelILInstruction GetSourceExpr() const { return GetRawOperandAsExpr(1); }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_STORE_STRUCT>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_STORE_STRUCT> : public MediumLevelILInstructionBase
{
MediumLevelILInstruction GetDestExpr() const { return GetRawOperandAsExpr(0); }
uint64_t GetOffset() const { return GetRawOperandAsInteger(1); }
MediumLevelILInstruction GetSourceExpr() const { return GetRawOperandAsExpr(2); }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_STORE_SSA>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_STORE_SSA> : public MediumLevelILInstructionBase
{
MediumLevelILInstruction GetDestExpr() const { return GetRawOperandAsExpr(0); }
size_t GetDestMemoryVersion() const { return GetRawOperandAsIndex(1); }
@@ -781,7 +997,8 @@ namespace BinaryNinja
void SetDestMemoryVersion(size_t version) { UpdateRawOperand(1, version); }
void SetSourceMemoryVersion(size_t version) { UpdateRawOperand(2, version); }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_STORE_STRUCT_SSA>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_STORE_STRUCT_SSA> : public MediumLevelILInstructionBase
{
MediumLevelILInstruction GetDestExpr() const { return GetRawOperandAsExpr(0); }
uint64_t GetOffset() const { return GetRawOperandAsInteger(1); }
@@ -792,44 +1009,52 @@ namespace BinaryNinja
void SetSourceMemoryVersion(size_t version) { UpdateRawOperand(3, version); }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_VAR>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_VAR> : public MediumLevelILInstructionBase
{
Variable GetSourceVariable() const { return GetRawOperandAsVariable(0); }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_VAR_FIELD>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_VAR_FIELD> : public MediumLevelILInstructionBase
{
Variable GetSourceVariable() const { return GetRawOperandAsVariable(0); }
uint64_t GetOffset() const { return GetRawOperandAsInteger(1); }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_VAR_SPLIT>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_VAR_SPLIT> : public MediumLevelILInstructionBase
{
Variable GetHighVariable() const { return GetRawOperandAsVariable(0); }
Variable GetLowVariable() const { return GetRawOperandAsVariable(1); }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_VAR_SSA>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_VAR_SSA> : public MediumLevelILInstructionBase
{
SSAVariable GetSourceSSAVariable() const { return GetRawOperandAsSSAVariable(0); }
void SetSourceSSAVersion(size_t version) { UpdateRawOperand(1, version); }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_VAR_SSA_FIELD>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_VAR_SSA_FIELD> : public MediumLevelILInstructionBase
{
SSAVariable GetSourceSSAVariable() const { return GetRawOperandAsSSAVariable(0); }
uint64_t GetOffset() const { return GetRawOperandAsInteger(2); }
void SetSourceSSAVersion(size_t version) { UpdateRawOperand(1, version); }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_VAR_ALIASED>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_VAR_ALIASED> : public MediumLevelILInstructionBase
{
SSAVariable GetSourceSSAVariable() const { return GetRawOperandAsSSAVariable(0); }
void SetSourceMemoryVersion(size_t version) { UpdateRawOperand(1, version); }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_VAR_ALIASED_FIELD>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_VAR_ALIASED_FIELD> : public MediumLevelILInstructionBase
{
SSAVariable GetSourceSSAVariable() const { return GetRawOperandAsSSAVariable(0); }
uint64_t GetOffset() const { return GetRawOperandAsInteger(2); }
void SetSourceMemoryVersion(size_t version) { UpdateRawOperand(1, version); }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_VAR_SPLIT_SSA>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_VAR_SPLIT_SSA> : public MediumLevelILInstructionBase
{
SSAVariable GetHighSSAVariable() const { return GetRawOperandAsSSAVariable(0); }
SSAVariable GetLowSSAVariable() const { return GetRawOperandAsSSAVariable(2); }
@@ -837,169 +1062,272 @@ namespace BinaryNinja
void SetLowSSAVersion(size_t version) { UpdateRawOperand(3, version); }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_ADDRESS_OF>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_ADDRESS_OF> : public MediumLevelILInstructionBase
{
Variable GetSourceVariable() const { return GetRawOperandAsVariable(0); }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_ADDRESS_OF_FIELD>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_ADDRESS_OF_FIELD> : public MediumLevelILInstructionBase
{
Variable GetSourceVariable() const { return GetRawOperandAsVariable(0); }
uint64_t GetOffset() const { return GetRawOperandAsInteger(1); }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_JUMP>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_JUMP> : public MediumLevelILInstructionBase
{
MediumLevelILInstruction GetDestExpr() const { return GetRawOperandAsExpr(0); }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_JUMP_TO>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_JUMP_TO> : public MediumLevelILInstructionBase
{
MediumLevelILInstruction GetDestExpr() const { return GetRawOperandAsExpr(0); }
MediumLevelILIndexMap GetTargets() const { return GetRawOperandAsIndexMap(1); }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_RET_HINT>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_RET_HINT> : public MediumLevelILInstructionBase
{
MediumLevelILInstruction GetDestExpr() const { return GetRawOperandAsExpr(0); }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_CALL>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_CALL> : public MediumLevelILInstructionBase
{
MediumLevelILVariableList GetOutputVariables() const { return GetRawOperandAsVariableList(0); }
MediumLevelILInstruction GetDestExpr() const { return GetRawOperandAsExpr(2); }
MediumLevelILInstructionList GetParameterExprs() const { return GetRawOperandAsExprList(3); }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_CALL_UNTYPED>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_CALL_UNTYPED> : public MediumLevelILInstructionBase
{
- MediumLevelILVariableList GetOutputVariables() const { return GetRawOperandAsExpr(0).GetRawOperandAsVariableList(0); }
+ MediumLevelILVariableList GetOutputVariables() const
+ {
+ return GetRawOperandAsExpr(0).GetRawOperandAsVariableList(0);
+ }
MediumLevelILInstruction GetDestExpr() const { return GetRawOperandAsExpr(1); }
- MediumLevelILVariableList GetParameterVariables() const { return GetRawOperandAsExpr(2).GetRawOperandAsVariableList(0); }
+ MediumLevelILVariableList GetParameterVariables() const
+ {
+ return GetRawOperandAsExpr(2).GetRawOperandAsVariableList(0);
+ }
MediumLevelILInstruction GetStackExpr() const { return GetRawOperandAsExpr(3); }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_SYSCALL>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_SYSCALL> : public MediumLevelILInstructionBase
{
MediumLevelILVariableList GetOutputVariables() const { return GetRawOperandAsVariableList(0); }
MediumLevelILInstructionList GetParameterExprs() const { return GetRawOperandAsExprList(2); }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_SYSCALL_UNTYPED>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_SYSCALL_UNTYPED> : public MediumLevelILInstructionBase
{
- MediumLevelILVariableList GetOutputVariables() const { return GetRawOperandAsExpr(0).GetRawOperandAsVariableList(0); }
- MediumLevelILVariableList GetParameterVariables() const { return GetRawOperandAsExpr(1).GetRawOperandAsVariableList(0); }
+ MediumLevelILVariableList GetOutputVariables() const
+ {
+ return GetRawOperandAsExpr(0).GetRawOperandAsVariableList(0);
+ }
+ MediumLevelILVariableList GetParameterVariables() const
+ {
+ return GetRawOperandAsExpr(1).GetRawOperandAsVariableList(0);
+ }
MediumLevelILInstruction GetStackExpr() const { return GetRawOperandAsExpr(2); }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_TAILCALL>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_TAILCALL> : public MediumLevelILInstructionBase
{
MediumLevelILVariableList GetOutputVariables() const { return GetRawOperandAsVariableList(0); }
MediumLevelILInstruction GetDestExpr() const { return GetRawOperandAsExpr(2); }
MediumLevelILInstructionList GetParameterExprs() const { return GetRawOperandAsExprList(3); }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_TAILCALL_UNTYPED>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_TAILCALL_UNTYPED> : public MediumLevelILInstructionBase
{
- MediumLevelILVariableList GetOutputVariables() const { return GetRawOperandAsExpr(0).GetRawOperandAsVariableList(0); }
+ MediumLevelILVariableList GetOutputVariables() const
+ {
+ return GetRawOperandAsExpr(0).GetRawOperandAsVariableList(0);
+ }
MediumLevelILInstruction GetDestExpr() const { return GetRawOperandAsExpr(1); }
- MediumLevelILVariableList GetParameterVariables() const { return GetRawOperandAsExpr(2).GetRawOperandAsVariableList(0); }
+ MediumLevelILVariableList GetParameterVariables() const
+ {
+ return GetRawOperandAsExpr(2).GetRawOperandAsVariableList(0);
+ }
MediumLevelILInstruction GetStackExpr() const { return GetRawOperandAsExpr(3); }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_CALL_SSA>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_CALL_SSA> : public MediumLevelILInstructionBase
{
size_t GetDestMemoryVersion() const { return GetRawOperandAsExpr(0).GetRawOperandAsIndex(0); }
- MediumLevelILSSAVariableList GetOutputSSAVariables() const { return GetRawOperandAsExpr(0).GetRawOperandAsSSAVariableList(1); }
+ MediumLevelILSSAVariableList GetOutputSSAVariables() const
+ {
+ return GetRawOperandAsExpr(0).GetRawOperandAsSSAVariableList(1);
+ }
MediumLevelILInstruction GetDestExpr() const { return GetRawOperandAsExpr(1); }
MediumLevelILInstructionList GetParameterExprs() const { return GetRawOperandAsExprList(2); }
size_t GetSourceMemoryVersion() const { return GetRawOperandAsIndex(4); }
void SetDestMemoryVersion(size_t version) { GetRawOperandAsExpr(0).UpdateRawOperand(0, version); }
void SetSourceMemoryVersion(size_t version) { UpdateRawOperand(4, version); }
- void SetOutputSSAVariables(const _STD_VECTOR<SSAVariable>& vars) { GetRawOperandAsExpr(0).UpdateRawOperandAsSSAVariableList(1, vars); }
- void SetParameterExprs(const _STD_VECTOR<MediumLevelILInstruction>& params) { UpdateRawOperandAsExprList(2, params); }
+ void SetOutputSSAVariables(const _STD_VECTOR<SSAVariable>& vars)
+ {
+ GetRawOperandAsExpr(0).UpdateRawOperandAsSSAVariableList(1, vars);
+ }
+ void SetParameterExprs(const _STD_VECTOR<MediumLevelILInstruction>& params)
+ {
+ UpdateRawOperandAsExprList(2, params);
+ }
void SetParameterExprs(const _STD_VECTOR<ExprId>& params) { UpdateRawOperandAsExprList(2, params); }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_CALL_UNTYPED_SSA>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_CALL_UNTYPED_SSA> : public MediumLevelILInstructionBase
{
size_t GetDestMemoryVersion() const { return GetRawOperandAsExpr(0).GetRawOperandAsIndex(0); }
- MediumLevelILSSAVariableList GetOutputSSAVariables() const { return GetRawOperandAsExpr(0).GetRawOperandAsSSAVariableList(1); }
+ MediumLevelILSSAVariableList GetOutputSSAVariables() const
+ {
+ return GetRawOperandAsExpr(0).GetRawOperandAsSSAVariableList(1);
+ }
MediumLevelILInstruction GetDestExpr() const { return GetRawOperandAsExpr(1); }
- MediumLevelILSSAVariableList GetParameterSSAVariables() const { return GetRawOperandAsExpr(2).GetRawOperandAsSSAVariableList(1); }
+ MediumLevelILSSAVariableList GetParameterSSAVariables() const
+ {
+ return GetRawOperandAsExpr(2).GetRawOperandAsSSAVariableList(1);
+ }
size_t GetSourceMemoryVersion() const { return GetRawOperandAsExpr(2).GetRawOperandAsIndex(0); }
MediumLevelILInstruction GetStackExpr() const { return GetRawOperandAsExpr(3); }
void SetDestMemoryVersion(size_t version) { GetRawOperandAsExpr(0).UpdateRawOperand(0, version); }
void SetSourceMemoryVersion(size_t version) { GetRawOperandAsExpr(2).UpdateRawOperand(0, version); }
- void SetOutputSSAVariables(const _STD_VECTOR<SSAVariable>& vars) { GetRawOperandAsExpr(0).UpdateRawOperandAsSSAVariableList(1, vars); }
- void SetParameterSSAVariables(const _STD_VECTOR<SSAVariable>& vars) { GetRawOperandAsExpr(2).UpdateRawOperandAsSSAVariableList(1, vars); }
+ void SetOutputSSAVariables(const _STD_VECTOR<SSAVariable>& vars)
+ {
+ GetRawOperandAsExpr(0).UpdateRawOperandAsSSAVariableList(1, vars);
+ }
+ void SetParameterSSAVariables(const _STD_VECTOR<SSAVariable>& vars)
+ {
+ GetRawOperandAsExpr(2).UpdateRawOperandAsSSAVariableList(1, vars);
+ }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_SYSCALL_SSA>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_SYSCALL_SSA> : public MediumLevelILInstructionBase
{
size_t GetDestMemoryVersion() const { return GetRawOperandAsExpr(0).GetRawOperandAsIndex(0); }
- MediumLevelILSSAVariableList GetOutputSSAVariables() const { return GetRawOperandAsExpr(0).GetRawOperandAsSSAVariableList(1); }
+ MediumLevelILSSAVariableList GetOutputSSAVariables() const
+ {
+ return GetRawOperandAsExpr(0).GetRawOperandAsSSAVariableList(1);
+ }
MediumLevelILInstructionList GetParameterExprs() const { return GetRawOperandAsExprList(1); }
size_t GetSourceMemoryVersion() const { return GetRawOperandAsIndex(3); }
void SetDestMemoryVersion(size_t version) { GetRawOperandAsExpr(0).UpdateRawOperand(0, version); }
void SetSourceMemoryVersion(size_t version) { UpdateRawOperand(3, version); }
- void SetOutputSSAVariables(const _STD_VECTOR<SSAVariable>& vars) { GetRawOperandAsExpr(0).UpdateRawOperandAsSSAVariableList(1, vars); }
- void SetParameterExprs(const _STD_VECTOR<MediumLevelILInstruction>& params) { UpdateRawOperandAsExprList(1, params); }
+ void SetOutputSSAVariables(const _STD_VECTOR<SSAVariable>& vars)
+ {
+ GetRawOperandAsExpr(0).UpdateRawOperandAsSSAVariableList(1, vars);
+ }
+ void SetParameterExprs(const _STD_VECTOR<MediumLevelILInstruction>& params)
+ {
+ UpdateRawOperandAsExprList(1, params);
+ }
void SetParameterExprs(const _STD_VECTOR<ExprId>& params) { UpdateRawOperandAsExprList(1, params); }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_SYSCALL_UNTYPED_SSA>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_SYSCALL_UNTYPED_SSA> : public MediumLevelILInstructionBase
{
size_t GetDestMemoryVersion() const { return GetRawOperandAsExpr(0).GetRawOperandAsIndex(0); }
- MediumLevelILSSAVariableList GetOutputSSAVariables() const { return GetRawOperandAsExpr(0).GetRawOperandAsSSAVariableList(1); }
- MediumLevelILSSAVariableList GetParameterSSAVariables() const { return GetRawOperandAsExpr(1).GetRawOperandAsSSAVariableList(1); }
+ MediumLevelILSSAVariableList GetOutputSSAVariables() const
+ {
+ return GetRawOperandAsExpr(0).GetRawOperandAsSSAVariableList(1);
+ }
+ MediumLevelILSSAVariableList GetParameterSSAVariables() const
+ {
+ return GetRawOperandAsExpr(1).GetRawOperandAsSSAVariableList(1);
+ }
size_t GetSourceMemoryVersion() const { return GetRawOperandAsExpr(1).GetRawOperandAsIndex(0); }
MediumLevelILInstruction GetStackExpr() const { return GetRawOperandAsExpr(2); }
void SetDestMemoryVersion(size_t version) { GetRawOperandAsExpr(0).UpdateRawOperand(0, version); }
void SetSourceMemoryVersion(size_t version) { GetRawOperandAsExpr(1).UpdateRawOperand(0, version); }
- void SetOutputSSAVariables(const _STD_VECTOR<SSAVariable>& vars) { GetRawOperandAsExpr(0).UpdateRawOperandAsSSAVariableList(1, vars); }
- void SetParameterSSAVariables(const _STD_VECTOR<SSAVariable>& vars) { GetRawOperandAsExpr(1).UpdateRawOperandAsSSAVariableList(1, vars); }
+ void SetOutputSSAVariables(const _STD_VECTOR<SSAVariable>& vars)
+ {
+ GetRawOperandAsExpr(0).UpdateRawOperandAsSSAVariableList(1, vars);
+ }
+ void SetParameterSSAVariables(const _STD_VECTOR<SSAVariable>& vars)
+ {
+ GetRawOperandAsExpr(1).UpdateRawOperandAsSSAVariableList(1, vars);
+ }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_TAILCALL_SSA>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_TAILCALL_SSA> : public MediumLevelILInstructionBase
{
size_t GetDestMemoryVersion() const { return GetRawOperandAsExpr(0).GetRawOperandAsIndex(0); }
- MediumLevelILSSAVariableList GetOutputSSAVariables() const { return GetRawOperandAsExpr(0).GetRawOperandAsSSAVariableList(1); }
+ MediumLevelILSSAVariableList GetOutputSSAVariables() const
+ {
+ return GetRawOperandAsExpr(0).GetRawOperandAsSSAVariableList(1);
+ }
MediumLevelILInstruction GetDestExpr() const { return GetRawOperandAsExpr(1); }
MediumLevelILInstructionList GetParameterExprs() const { return GetRawOperandAsExprList(2); }
size_t GetSourceMemoryVersion() const { return GetRawOperandAsIndex(4); }
void SetDestMemoryVersion(size_t version) { GetRawOperandAsExpr(0).UpdateRawOperand(0, version); }
void SetSourceMemoryVersion(size_t version) { UpdateRawOperand(4, version); }
- void SetOutputSSAVariables(const _STD_VECTOR<SSAVariable>& vars) { GetRawOperandAsExpr(0).UpdateRawOperandAsSSAVariableList(1, vars); }
- void SetParameterExprs(const _STD_VECTOR<MediumLevelILInstruction>& params) { UpdateRawOperandAsExprList(2, params); }
+ void SetOutputSSAVariables(const _STD_VECTOR<SSAVariable>& vars)
+ {
+ GetRawOperandAsExpr(0).UpdateRawOperandAsSSAVariableList(1, vars);
+ }
+ void SetParameterExprs(const _STD_VECTOR<MediumLevelILInstruction>& params)
+ {
+ UpdateRawOperandAsExprList(2, params);
+ }
void SetParameterExprs(const _STD_VECTOR<ExprId>& params) { UpdateRawOperandAsExprList(2, params); }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_TAILCALL_UNTYPED_SSA>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_TAILCALL_UNTYPED_SSA> : public MediumLevelILInstructionBase
{
size_t GetDestMemoryVersion() const { return GetRawOperandAsExpr(0).GetRawOperandAsIndex(0); }
- MediumLevelILSSAVariableList GetOutputSSAVariables() const { return GetRawOperandAsExpr(0).GetRawOperandAsSSAVariableList(1); }
+ MediumLevelILSSAVariableList GetOutputSSAVariables() const
+ {
+ return GetRawOperandAsExpr(0).GetRawOperandAsSSAVariableList(1);
+ }
MediumLevelILInstruction GetDestExpr() const { return GetRawOperandAsExpr(1); }
- MediumLevelILSSAVariableList GetParameterSSAVariables() const { return GetRawOperandAsExpr(2).GetRawOperandAsSSAVariableList(1); }
+ MediumLevelILSSAVariableList GetParameterSSAVariables() const
+ {
+ return GetRawOperandAsExpr(2).GetRawOperandAsSSAVariableList(1);
+ }
size_t GetSourceMemoryVersion() const { return GetRawOperandAsExpr(2).GetRawOperandAsIndex(0); }
MediumLevelILInstruction GetStackExpr() const { return GetRawOperandAsExpr(3); }
void SetDestMemoryVersion(size_t version) { GetRawOperandAsExpr(0).UpdateRawOperand(0, version); }
void SetSourceMemoryVersion(size_t version) { GetRawOperandAsExpr(2).UpdateRawOperand(0, version); }
- void SetOutputSSAVariables(const _STD_VECTOR<SSAVariable>& vars) { GetRawOperandAsExpr(0).UpdateRawOperandAsSSAVariableList(1, vars); }
- void SetParameterSSAVariables(const _STD_VECTOR<SSAVariable>& vars) { GetRawOperandAsExpr(2).UpdateRawOperandAsSSAVariableList(1, vars); }
+ void SetOutputSSAVariables(const _STD_VECTOR<SSAVariable>& vars)
+ {
+ GetRawOperandAsExpr(0).UpdateRawOperandAsSSAVariableList(1, vars);
+ }
+ void SetParameterSSAVariables(const _STD_VECTOR<SSAVariable>& vars)
+ {
+ GetRawOperandAsExpr(2).UpdateRawOperandAsSSAVariableList(1, vars);
+ }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_RET>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_RET> : public MediumLevelILInstructionBase
{
MediumLevelILInstructionList GetSourceExprs() const { return GetRawOperandAsExprList(0); }
void SetSourceExprs(const _STD_VECTOR<ExprId>& exprs) { UpdateRawOperandAsExprList(0, exprs); }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_IF>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_IF> : public MediumLevelILInstructionBase
{
MediumLevelILInstruction GetConditionExpr() const { return GetRawOperandAsExpr(0); }
size_t GetTrueTarget() const { return GetRawOperandAsIndex(1); }
size_t GetFalseTarget() const { return GetRawOperandAsIndex(2); }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_GOTO>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_GOTO> : public MediumLevelILInstructionBase
{
size_t GetTarget() const { return GetRawOperandAsIndex(0); }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_INTRINSIC>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_INTRINSIC> : public MediumLevelILInstructionBase
{
MediumLevelILVariableList GetOutputVariables() const { return GetRawOperandAsVariableList(0); }
uint32_t GetIntrinsic() const { return (uint32_t)GetRawOperandAsInteger(2); }
MediumLevelILInstructionList GetParameterExprs() const { return GetRawOperandAsExprList(3); }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_INTRINSIC_SSA>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_INTRINSIC_SSA> : public MediumLevelILInstructionBase
{
MediumLevelILSSAVariableList GetOutputSSAVariables() const { return GetRawOperandAsSSAVariableList(0); }
uint32_t GetIntrinsic() const { return (uint32_t)GetRawOperandAsInteger(2); }
@@ -1007,11 +1335,13 @@ namespace BinaryNinja
void SetOutputSSAVariables(const _STD_VECTOR<SSAVariable>& vars) { UpdateRawOperandAsSSAVariableList(0, vars); }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_FREE_VAR_SLOT>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_FREE_VAR_SLOT> : public MediumLevelILInstructionBase
{
Variable GetDestVariable() const { return GetRawOperandAsVariable(0); }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_FREE_VAR_SLOT_SSA>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_FREE_VAR_SLOT_SSA> : public MediumLevelILInstructionBase
{
SSAVariable GetDestSSAVariable() const { return GetRawOperandAsSSAVariable(0); }
SSAVariable GetSourceSSAVariable() const { return GetRawOperandAsPartialSSAVariableSource(0); }
@@ -1019,110 +1349,264 @@ namespace BinaryNinja
void SetSourceSSAVersion(size_t version) { UpdateRawOperand(2, version); }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_TRAP>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_TRAP> : public MediumLevelILInstructionBase
{
int64_t GetVector() const { return GetRawOperandAsInteger(0); }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_VAR_PHI>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_VAR_PHI> : public MediumLevelILInstructionBase
{
SSAVariable GetDestSSAVariable() const { return GetRawOperandAsSSAVariable(0); }
MediumLevelILSSAVariableList GetSourceSSAVariables() const { return GetRawOperandAsSSAVariableList(2); }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_MEM_PHI>: public MediumLevelILInstructionBase
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_MEM_PHI> : public MediumLevelILInstructionBase
{
size_t GetDestMemoryVersion() const { return GetRawOperandAsIndex(0); }
MediumLevelILIndexList GetSourceMemoryVersions() const { return GetRawOperandAsIndexList(1); }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_EXTERN_PTR>: public MediumLevelILConstantInstruction
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_EXTERN_PTR> : public MediumLevelILConstantInstruction
{
int64_t GetConstant() const { return GetRawOperandAsInteger(0); }
int64_t GetOffset() const { return GetRawOperandAsInteger(1); }
};
- template <> struct MediumLevelILInstructionAccessor<MLIL_NOP>: public MediumLevelILInstructionBase {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_NORET>: public MediumLevelILInstructionBase {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_BP>: public MediumLevelILInstructionBase {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_UNDEF>: public MediumLevelILInstructionBase {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_UNIMPL>: public MediumLevelILInstructionBase {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_NOP> : public MediumLevelILInstructionBase
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_NORET> : public MediumLevelILInstructionBase
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_BP> : public MediumLevelILInstructionBase
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_UNDEF> : public MediumLevelILInstructionBase
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_UNIMPL> : public MediumLevelILInstructionBase
+ {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_CONST>: public MediumLevelILConstantInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_CONST_PTR>: public MediumLevelILConstantInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_FLOAT_CONST>: public MediumLevelILConstantInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_IMPORT>: public MediumLevelILConstantInstruction {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_CONST> : public MediumLevelILConstantInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_CONST_PTR> : public MediumLevelILConstantInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_FLOAT_CONST> : public MediumLevelILConstantInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_IMPORT> : public MediumLevelILConstantInstruction
+ {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_ADD>: public MediumLevelILTwoOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_SUB>: public MediumLevelILTwoOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_AND>: public MediumLevelILTwoOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_OR>: public MediumLevelILTwoOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_XOR>: public MediumLevelILTwoOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_LSL>: public MediumLevelILTwoOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_LSR>: public MediumLevelILTwoOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_ASR>: public MediumLevelILTwoOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_ROL>: public MediumLevelILTwoOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_ROR>: public MediumLevelILTwoOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_MUL>: public MediumLevelILTwoOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_MULU_DP>: public MediumLevelILTwoOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_MULS_DP>: public MediumLevelILTwoOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_DIVU>: public MediumLevelILTwoOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_DIVS>: public MediumLevelILTwoOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_MODU>: public MediumLevelILTwoOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_MODS>: public MediumLevelILTwoOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_DIVU_DP>: public MediumLevelILTwoOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_DIVS_DP>: public MediumLevelILTwoOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_MODU_DP>: public MediumLevelILTwoOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_MODS_DP>: public MediumLevelILTwoOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_CMP_E>: public MediumLevelILTwoOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_CMP_NE>: public MediumLevelILTwoOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_CMP_SLT>: public MediumLevelILTwoOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_CMP_ULT>: public MediumLevelILTwoOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_CMP_SLE>: public MediumLevelILTwoOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_CMP_ULE>: public MediumLevelILTwoOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_CMP_SGE>: public MediumLevelILTwoOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_CMP_UGE>: public MediumLevelILTwoOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_CMP_SGT>: public MediumLevelILTwoOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_CMP_UGT>: public MediumLevelILTwoOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_TEST_BIT>: public MediumLevelILTwoOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_ADD_OVERFLOW>: public MediumLevelILTwoOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_FADD>: public MediumLevelILTwoOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_FSUB>: public MediumLevelILTwoOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_FMUL>: public MediumLevelILTwoOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_FDIV>: public MediumLevelILTwoOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_FCMP_E>: public MediumLevelILTwoOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_FCMP_NE>: public MediumLevelILTwoOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_FCMP_LT>: public MediumLevelILTwoOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_FCMP_LE>: public MediumLevelILTwoOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_FCMP_GE>: public MediumLevelILTwoOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_FCMP_GT>: public MediumLevelILTwoOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_FCMP_O>: public MediumLevelILTwoOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_FCMP_UO>: public MediumLevelILTwoOperandInstruction {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_ADD> : public MediumLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_SUB> : public MediumLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_AND> : public MediumLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_OR> : public MediumLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_XOR> : public MediumLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_LSL> : public MediumLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_LSR> : public MediumLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_ASR> : public MediumLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_ROL> : public MediumLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_ROR> : public MediumLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_MUL> : public MediumLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_MULU_DP> : public MediumLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_MULS_DP> : public MediumLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_DIVU> : public MediumLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_DIVS> : public MediumLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_MODU> : public MediumLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_MODS> : public MediumLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_DIVU_DP> : public MediumLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_DIVS_DP> : public MediumLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_MODU_DP> : public MediumLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_MODS_DP> : public MediumLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_CMP_E> : public MediumLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_CMP_NE> : public MediumLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_CMP_SLT> : public MediumLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_CMP_ULT> : public MediumLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_CMP_SLE> : public MediumLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_CMP_ULE> : public MediumLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_CMP_SGE> : public MediumLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_CMP_UGE> : public MediumLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_CMP_SGT> : public MediumLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_CMP_UGT> : public MediumLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_TEST_BIT> : public MediumLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_ADD_OVERFLOW> : public MediumLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_FADD> : public MediumLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_FSUB> : public MediumLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_FMUL> : public MediumLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_FDIV> : public MediumLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_FCMP_E> : public MediumLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_FCMP_NE> : public MediumLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_FCMP_LT> : public MediumLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_FCMP_LE> : public MediumLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_FCMP_GE> : public MediumLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_FCMP_GT> : public MediumLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_FCMP_O> : public MediumLevelILTwoOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_FCMP_UO> : public MediumLevelILTwoOperandInstruction
+ {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_ADC>: public MediumLevelILTwoOperandWithCarryInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_SBB>: public MediumLevelILTwoOperandWithCarryInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_RLC>: public MediumLevelILTwoOperandWithCarryInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_RRC>: public MediumLevelILTwoOperandWithCarryInstruction {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_ADC> : public MediumLevelILTwoOperandWithCarryInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_SBB> : public MediumLevelILTwoOperandWithCarryInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_RLC> : public MediumLevelILTwoOperandWithCarryInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_RRC> : public MediumLevelILTwoOperandWithCarryInstruction
+ {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_NEG>: public MediumLevelILOneOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_NOT>: public MediumLevelILOneOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_SX>: public MediumLevelILOneOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_ZX>: public MediumLevelILOneOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_LOW_PART>: public MediumLevelILOneOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_BOOL_TO_INT>: public MediumLevelILOneOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_UNIMPL_MEM>: public MediumLevelILOneOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_FSQRT>: public MediumLevelILOneOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_FNEG>: public MediumLevelILOneOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_FABS>: public MediumLevelILOneOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_FLOAT_TO_INT>: public MediumLevelILOneOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_INT_TO_FLOAT>: public MediumLevelILOneOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_FLOAT_CONV>: public MediumLevelILOneOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_ROUND_TO_INT>: public MediumLevelILOneOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_FLOOR>: public MediumLevelILOneOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_CEIL>: public MediumLevelILOneOperandInstruction {};
- template <> struct MediumLevelILInstructionAccessor<MLIL_FTRUNC>: public MediumLevelILOneOperandInstruction {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_NEG> : public MediumLevelILOneOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_NOT> : public MediumLevelILOneOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_SX> : public MediumLevelILOneOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_ZX> : public MediumLevelILOneOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_LOW_PART> : public MediumLevelILOneOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_BOOL_TO_INT> : public MediumLevelILOneOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_UNIMPL_MEM> : public MediumLevelILOneOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_FSQRT> : public MediumLevelILOneOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_FNEG> : public MediumLevelILOneOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_FABS> : public MediumLevelILOneOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_FLOAT_TO_INT> : public MediumLevelILOneOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_INT_TO_FLOAT> : public MediumLevelILOneOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_FLOAT_CONV> : public MediumLevelILOneOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_ROUND_TO_INT> : public MediumLevelILOneOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_FLOOR> : public MediumLevelILOneOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_CEIL> : public MediumLevelILOneOperandInstruction
+ {};
+ template <>
+ struct MediumLevelILInstructionAccessor<MLIL_FTRUNC> : public MediumLevelILOneOperandInstruction
+ {};
#undef _STD_VECTOR
#undef _STD_SET
#undef _STD_UNORDERED_MAP
#undef _STD_MAP
-}
+} // namespace BinaryNinjaCore
diff --git a/metadata.cpp b/metadata.cpp
index a724a9e3..bd9bbdee 100644
--- a/metadata.cpp
+++ b/metadata.cpp
@@ -63,7 +63,7 @@ Metadata::Metadata(const std::map<std::string, Ref<Metadata>>& data)
BNMetadata** values = new BNMetadata*[data.size()];
size_t i = 0;
- for (auto &elm : data)
+ for (auto& elm : data)
{
keys[i] = BNAllocString(elm.first.c_str());
values[i++] = elm.second->m_object;
diff --git a/platform.cpp b/platform.cpp
index 83e937f4..68e812dc 100644
--- a/platform.cpp
+++ b/platform.cpp
@@ -41,7 +41,8 @@ Platform::Platform(Architecture* arch, const string& name, const string& typeFil
const char** includeDirList = new const char*[includeDirs.size()];
for (size_t i = 0; i < includeDirs.size(); i++)
includeDirList[i] = includeDirs[i].c_str();
- m_object = BNCreatePlatformWithTypes(arch->GetObject(), name.c_str(), typeFile.c_str(), includeDirList, includeDirs.size());
+ m_object = BNCreatePlatformWithTypes(
+ arch->GetObject(), name.c_str(), typeFile.c_str(), includeDirList, includeDirs.size());
delete[] includeDirList;
}
@@ -403,8 +404,8 @@ string Platform::GenerateAutoPlatformTypeId(const QualifiedName& name)
}
-Ref<NamedTypeReference> Platform::GenerateAutoPlatformTypeReference(BNNamedTypeReferenceClass cls,
- const QualifiedName& name)
+Ref<NamedTypeReference> Platform::GenerateAutoPlatformTypeReference(
+ BNNamedTypeReferenceClass cls, const QualifiedName& name)
{
string id = GenerateAutoPlatformTypeId(name);
return new NamedTypeReference(cls, id, name);
@@ -420,10 +421,9 @@ string Platform::GetAutoPlatformTypeIdSource()
}
-bool Platform::ParseTypesFromSource(const string& source, const string& fileName,
- map<QualifiedName, Ref<Type>>& types, map<QualifiedName, Ref<Type>>& variables,
- map<QualifiedName, Ref<Type>>& functions, string& errors, const vector<string>& includeDirs,
- const string& autoTypeSource)
+bool Platform::ParseTypesFromSource(const string& source, const string& fileName, map<QualifiedName, Ref<Type>>& types,
+ map<QualifiedName, Ref<Type>>& variables, map<QualifiedName, Ref<Type>>& functions, string& errors,
+ const vector<string>& includeDirs, const string& autoTypeSource)
{
BNTypeParserResult result;
char* errorStr;
@@ -436,8 +436,8 @@ bool Platform::ParseTypesFromSource(const string& source, const string& fileName
variables.clear();
functions.clear();
- bool ok = BNParseTypesFromSource(m_object, source.c_str(), fileName.c_str(), &result,
- &errorStr, includeDirList, includeDirs.size(), autoTypeSource.c_str());
+ bool ok = BNParseTypesFromSource(m_object, source.c_str(), fileName.c_str(), &result, &errorStr, includeDirList,
+ includeDirs.size(), autoTypeSource.c_str());
errors = errorStr;
BNFreeString(errorStr);
delete[] includeDirList;
@@ -465,8 +465,8 @@ bool Platform::ParseTypesFromSource(const string& source, const string& fileName
bool Platform::ParseTypesFromSourceFile(const string& fileName, map<QualifiedName, Ref<Type>>& types,
- map<QualifiedName, Ref<Type>>& variables, map<QualifiedName, Ref<Type>>& functions,
- string& errors, const vector<string>& includeDirs, const string& autoTypeSource)
+ map<QualifiedName, Ref<Type>>& variables, map<QualifiedName, Ref<Type>>& functions, string& errors,
+ const vector<string>& includeDirs, const string& autoTypeSource)
{
BNTypeParserResult result;
char* errorStr;
@@ -479,8 +479,8 @@ bool Platform::ParseTypesFromSourceFile(const string& fileName, map<QualifiedNam
variables.clear();
functions.clear();
- bool ok = BNParseTypesFromSourceFile(m_object, fileName.c_str(), &result, &errorStr,
- includeDirList, includeDirs.size(), autoTypeSource.c_str());
+ bool ok = BNParseTypesFromSourceFile(
+ m_object, fileName.c_str(), &result, &errorStr, includeDirList, includeDirs.size(), autoTypeSource.c_str());
errors = errorStr;
BNFreeString(errorStr);
delete[] includeDirList;
diff --git a/plugin.cpp b/plugin.cpp
index 2233200b..23b4b1ea 100644
--- a/plugin.cpp
+++ b/plugin.cpp
@@ -101,8 +101,8 @@ void PluginCommand::FunctionPluginCommandActionCallback(void* ctxt, BNBinaryView
}
-void PluginCommand::LowLevelILFunctionPluginCommandActionCallback(void* ctxt, BNBinaryView* view,
- BNLowLevelILFunction* func)
+void PluginCommand::LowLevelILFunctionPluginCommandActionCallback(
+ void* ctxt, BNBinaryView* view, BNLowLevelILFunction* func)
{
RegisteredLowLevelILFunctionCommand* cmd = (RegisteredLowLevelILFunctionCommand*)ctxt;
Ref<BinaryView> viewObject = new BinaryView(BNNewViewReference(view));
@@ -111,8 +111,8 @@ void PluginCommand::LowLevelILFunctionPluginCommandActionCallback(void* ctxt, BN
}
-void PluginCommand::LowLevelILInstructionPluginCommandActionCallback(void* ctxt, BNBinaryView* view,
- BNLowLevelILFunction* func, size_t instr)
+void PluginCommand::LowLevelILInstructionPluginCommandActionCallback(
+ void* ctxt, BNBinaryView* view, BNLowLevelILFunction* func, size_t instr)
{
RegisteredLowLevelILInstructionCommand* cmd = (RegisteredLowLevelILInstructionCommand*)ctxt;
Ref<BinaryView> viewObject = new BinaryView(BNNewViewReference(view));
@@ -122,8 +122,8 @@ void PluginCommand::LowLevelILInstructionPluginCommandActionCallback(void* ctxt,
}
-void PluginCommand::MediumLevelILFunctionPluginCommandActionCallback(void* ctxt, BNBinaryView* view,
- BNMediumLevelILFunction* func)
+void PluginCommand::MediumLevelILFunctionPluginCommandActionCallback(
+ void* ctxt, BNBinaryView* view, BNMediumLevelILFunction* func)
{
RegisteredMediumLevelILFunctionCommand* cmd = (RegisteredMediumLevelILFunctionCommand*)ctxt;
Ref<BinaryView> viewObject = new BinaryView(BNNewViewReference(view));
@@ -132,8 +132,8 @@ void PluginCommand::MediumLevelILFunctionPluginCommandActionCallback(void* ctxt,
}
-void PluginCommand::MediumLevelILInstructionPluginCommandActionCallback(void* ctxt, BNBinaryView* view,
- BNMediumLevelILFunction* func, size_t instr)
+void PluginCommand::MediumLevelILInstructionPluginCommandActionCallback(
+ void* ctxt, BNBinaryView* view, BNMediumLevelILFunction* func, size_t instr)
{
RegisteredMediumLevelILInstructionCommand* cmd = (RegisteredMediumLevelILInstructionCommand*)ctxt;
Ref<BinaryView> viewObject = new BinaryView(BNNewViewReference(view));
@@ -143,8 +143,8 @@ void PluginCommand::MediumLevelILInstructionPluginCommandActionCallback(void* ct
}
-void PluginCommand::HighLevelILFunctionPluginCommandActionCallback(void* ctxt, BNBinaryView* view,
- BNHighLevelILFunction* func)
+void PluginCommand::HighLevelILFunctionPluginCommandActionCallback(
+ void* ctxt, BNBinaryView* view, BNHighLevelILFunction* func)
{
RegisteredHighLevelILFunctionCommand* cmd = (RegisteredHighLevelILFunctionCommand*)ctxt;
Ref<BinaryView> viewObject = new BinaryView(BNNewViewReference(view));
@@ -153,8 +153,8 @@ void PluginCommand::HighLevelILFunctionPluginCommandActionCallback(void* ctxt, B
}
-void PluginCommand::HighLevelILInstructionPluginCommandActionCallback(void* ctxt, BNBinaryView* view,
- BNHighLevelILFunction* func, size_t instr)
+void PluginCommand::HighLevelILInstructionPluginCommandActionCallback(
+ void* ctxt, BNBinaryView* view, BNHighLevelILFunction* func, size_t instr)
{
RegisteredHighLevelILInstructionCommand* cmd = (RegisteredHighLevelILInstructionCommand*)ctxt;
Ref<BinaryView> viewObject = new BinaryView(BNNewViewReference(view));
@@ -197,8 +197,8 @@ bool PluginCommand::FunctionPluginCommandIsValidCallback(void* ctxt, BNBinaryVie
}
-bool PluginCommand::LowLevelILFunctionPluginCommandIsValidCallback(void* ctxt, BNBinaryView* view,
- BNLowLevelILFunction* func)
+bool PluginCommand::LowLevelILFunctionPluginCommandIsValidCallback(
+ void* ctxt, BNBinaryView* view, BNLowLevelILFunction* func)
{
RegisteredLowLevelILFunctionCommand* cmd = (RegisteredLowLevelILFunctionCommand*)ctxt;
Ref<BinaryView> viewObject = new BinaryView(BNNewViewReference(view));
@@ -207,8 +207,8 @@ bool PluginCommand::LowLevelILFunctionPluginCommandIsValidCallback(void* ctxt, B
}
-bool PluginCommand::LowLevelILInstructionPluginCommandIsValidCallback(void* ctxt, BNBinaryView* view,
- BNLowLevelILFunction* func, size_t instr)
+bool PluginCommand::LowLevelILInstructionPluginCommandIsValidCallback(
+ void* ctxt, BNBinaryView* view, BNLowLevelILFunction* func, size_t instr)
{
RegisteredLowLevelILInstructionCommand* cmd = (RegisteredLowLevelILInstructionCommand*)ctxt;
Ref<BinaryView> viewObject = new BinaryView(BNNewViewReference(view));
@@ -218,8 +218,8 @@ bool PluginCommand::LowLevelILInstructionPluginCommandIsValidCallback(void* ctxt
}
-bool PluginCommand::MediumLevelILFunctionPluginCommandIsValidCallback(void* ctxt, BNBinaryView* view,
- BNMediumLevelILFunction* func)
+bool PluginCommand::MediumLevelILFunctionPluginCommandIsValidCallback(
+ void* ctxt, BNBinaryView* view, BNMediumLevelILFunction* func)
{
RegisteredMediumLevelILFunctionCommand* cmd = (RegisteredMediumLevelILFunctionCommand*)ctxt;
Ref<BinaryView> viewObject = new BinaryView(BNNewViewReference(view));
@@ -228,8 +228,8 @@ bool PluginCommand::MediumLevelILFunctionPluginCommandIsValidCallback(void* ctxt
}
-bool PluginCommand::MediumLevelILInstructionPluginCommandIsValidCallback(void* ctxt, BNBinaryView* view,
- BNMediumLevelILFunction* func, size_t instr)
+bool PluginCommand::MediumLevelILInstructionPluginCommandIsValidCallback(
+ void* ctxt, BNBinaryView* view, BNMediumLevelILFunction* func, size_t instr)
{
RegisteredMediumLevelILInstructionCommand* cmd = (RegisteredMediumLevelILInstructionCommand*)ctxt;
Ref<BinaryView> viewObject = new BinaryView(BNNewViewReference(view));
@@ -239,8 +239,8 @@ bool PluginCommand::MediumLevelILInstructionPluginCommandIsValidCallback(void* c
}
-bool PluginCommand::HighLevelILFunctionPluginCommandIsValidCallback(void* ctxt, BNBinaryView* view,
- BNHighLevelILFunction* func)
+bool PluginCommand::HighLevelILFunctionPluginCommandIsValidCallback(
+ void* ctxt, BNBinaryView* view, BNHighLevelILFunction* func)
{
RegisteredHighLevelILFunctionCommand* cmd = (RegisteredHighLevelILFunctionCommand*)ctxt;
Ref<BinaryView> viewObject = new BinaryView(BNNewViewReference(view));
@@ -249,8 +249,8 @@ bool PluginCommand::HighLevelILFunctionPluginCommandIsValidCallback(void* ctxt,
}
-bool PluginCommand::HighLevelILInstructionPluginCommandIsValidCallback(void* ctxt, BNBinaryView* view,
- BNHighLevelILFunction* func, size_t instr)
+bool PluginCommand::HighLevelILInstructionPluginCommandIsValidCallback(
+ void* ctxt, BNBinaryView* view, BNHighLevelILFunction* func, size_t instr)
{
RegisteredHighLevelILInstructionCommand* cmd = (RegisteredHighLevelILInstructionCommand*)ctxt;
Ref<BinaryView> viewObject = new BinaryView(BNNewViewReference(view));
@@ -260,204 +260,196 @@ bool PluginCommand::HighLevelILInstructionPluginCommandIsValidCallback(void* ctx
}
-void PluginCommand::Register(const string& name, const string& description,
- const function<void(BinaryView* view)>& action)
+void PluginCommand::Register(
+ const string& name, const string& description, const function<void(BinaryView* view)>& action)
{
Register(name, description, action, [](BinaryView*) { return true; });
}
void PluginCommand::Register(const string& name, const string& description,
- const function<void(BinaryView* view)>& action,
- const function<bool(BinaryView* view)>& isValid)
+ const function<void(BinaryView* view)>& action, const function<bool(BinaryView* view)>& isValid)
{
RegisteredDefaultCommand* cmd = new RegisteredDefaultCommand;
cmd->action = action;
cmd->isValid = isValid;
BNRegisterPluginCommand(name.c_str(), description.c_str(), DefaultPluginCommandActionCallback,
- DefaultPluginCommandIsValidCallback, cmd);
+ DefaultPluginCommandIsValidCallback, cmd);
}
-void PluginCommand::RegisterForAddress(const string& name, const string& description,
- const function<void(BinaryView* view, uint64_t addr)>& action)
+void PluginCommand::RegisterForAddress(
+ const string& name, const string& description, const function<void(BinaryView* view, uint64_t addr)>& action)
{
RegisterForAddress(name, description, action, [](BinaryView*, uint64_t) { return true; });
}
void PluginCommand::RegisterForAddress(const string& name, const string& description,
- const function<void(BinaryView* view, uint64_t addr)>& action,
- const function<bool(BinaryView* view, uint64_t addr)>& isValid)
+ const function<void(BinaryView* view, uint64_t addr)>& action,
+ const function<bool(BinaryView* view, uint64_t addr)>& isValid)
{
RegisteredAddressCommand* cmd = new RegisteredAddressCommand;
cmd->action = action;
cmd->isValid = isValid;
BNRegisterPluginCommandForAddress(name.c_str(), description.c_str(), AddressPluginCommandActionCallback,
- AddressPluginCommandIsValidCallback, cmd);
+ AddressPluginCommandIsValidCallback, cmd);
}
void PluginCommand::RegisterForRange(const string& name, const string& description,
- const function<void(BinaryView* view, uint64_t addr, uint64_t len)>& action)
+ const function<void(BinaryView* view, uint64_t addr, uint64_t len)>& action)
{
RegisterForRange(name, description, action, [](BinaryView*, uint64_t, uint64_t) { return true; });
}
void PluginCommand::RegisterForRange(const string& name, const string& description,
- const function<void(BinaryView* view, uint64_t addr, uint64_t len)>& action,
- const function<bool(BinaryView* view, uint64_t addr, uint64_t len)>& isValid)
+ const function<void(BinaryView* view, uint64_t addr, uint64_t len)>& action,
+ const function<bool(BinaryView* view, uint64_t addr, uint64_t len)>& isValid)
{
RegisteredRangeCommand* cmd = new RegisteredRangeCommand;
cmd->action = action;
cmd->isValid = isValid;
- BNRegisterPluginCommandForRange(name.c_str(), description.c_str(), RangePluginCommandActionCallback,
- RangePluginCommandIsValidCallback, cmd);
+ BNRegisterPluginCommandForRange(
+ name.c_str(), description.c_str(), RangePluginCommandActionCallback, RangePluginCommandIsValidCallback, cmd);
}
-void PluginCommand::RegisterForFunction(const string& name, const string& description,
- const function<void(BinaryView* view, Function* func)>& action)
+void PluginCommand::RegisterForFunction(
+ const string& name, const string& description, const function<void(BinaryView* view, Function* func)>& action)
{
RegisterForFunction(name, description, action, [](BinaryView*, Function*) { return true; });
}
void PluginCommand::RegisterForFunction(const string& name, const string& description,
- const function<void(BinaryView* view, Function* func)>& action,
- const function<bool(BinaryView* view, Function* func)>& isValid)
+ const function<void(BinaryView* view, Function* func)>& action,
+ const function<bool(BinaryView* view, Function* func)>& isValid)
{
RegisteredFunctionCommand* cmd = new RegisteredFunctionCommand;
cmd->action = action;
cmd->isValid = isValid;
BNRegisterPluginCommandForFunction(name.c_str(), description.c_str(), FunctionPluginCommandActionCallback,
- FunctionPluginCommandIsValidCallback, cmd);
+ FunctionPluginCommandIsValidCallback, cmd);
}
void PluginCommand::RegisterForLowLevelILFunction(const string& name, const string& description,
- const function<void(BinaryView* view, LowLevelILFunction* func)>& action)
+ const function<void(BinaryView* view, LowLevelILFunction* func)>& action)
{
RegisterForLowLevelILFunction(name, description, action, [](BinaryView*, LowLevelILFunction*) { return true; });
}
void PluginCommand::RegisterForLowLevelILFunction(const string& name, const string& description,
- const function<void(BinaryView* view, LowLevelILFunction* func)>& action,
- const function<bool(BinaryView* view, LowLevelILFunction* func)>& isValid)
+ const function<void(BinaryView* view, LowLevelILFunction* func)>& action,
+ const function<bool(BinaryView* view, LowLevelILFunction* func)>& isValid)
{
RegisteredLowLevelILFunctionCommand* cmd = new RegisteredLowLevelILFunctionCommand;
cmd->action = action;
cmd->isValid = isValid;
BNRegisterPluginCommandForLowLevelILFunction(name.c_str(), description.c_str(),
- LowLevelILFunctionPluginCommandActionCallback,
- LowLevelILFunctionPluginCommandIsValidCallback, cmd);
+ LowLevelILFunctionPluginCommandActionCallback, LowLevelILFunctionPluginCommandIsValidCallback, cmd);
}
void PluginCommand::RegisterForLowLevelILInstruction(const string& name, const string& description,
- const function<void(BinaryView* view, const LowLevelILInstruction& instr)>& action)
+ const function<void(BinaryView* view, const LowLevelILInstruction& instr)>& action)
{
- RegisterForLowLevelILInstruction(name, description, action,
- [](BinaryView*, const LowLevelILInstruction&) { return true; });
+ RegisterForLowLevelILInstruction(
+ name, description, action, [](BinaryView*, const LowLevelILInstruction&) { return true; });
}
void PluginCommand::RegisterForLowLevelILInstruction(const string& name, const string& description,
- const function<void(BinaryView* view, const LowLevelILInstruction& instr)>& action,
- const function<bool(BinaryView* view, const LowLevelILInstruction& instr)>& isValid)
+ const function<void(BinaryView* view, const LowLevelILInstruction& instr)>& action,
+ const function<bool(BinaryView* view, const LowLevelILInstruction& instr)>& isValid)
{
RegisteredLowLevelILInstructionCommand* cmd = new RegisteredLowLevelILInstructionCommand;
cmd->action = action;
cmd->isValid = isValid;
BNRegisterPluginCommandForLowLevelILInstruction(name.c_str(), description.c_str(),
- LowLevelILInstructionPluginCommandActionCallback,
- LowLevelILInstructionPluginCommandIsValidCallback, cmd);
+ LowLevelILInstructionPluginCommandActionCallback, LowLevelILInstructionPluginCommandIsValidCallback, cmd);
}
void PluginCommand::RegisterForMediumLevelILFunction(const string& name, const string& description,
- const function<void(BinaryView* view, MediumLevelILFunction* func)>& action)
+ const function<void(BinaryView* view, MediumLevelILFunction* func)>& action)
{
- RegisterForMediumLevelILFunction(name, description, action,
- [](BinaryView*, MediumLevelILFunction*) { return true; });
+ RegisterForMediumLevelILFunction(
+ name, description, action, [](BinaryView*, MediumLevelILFunction*) { return true; });
}
void PluginCommand::RegisterForMediumLevelILFunction(const string& name, const string& description,
- const function<void(BinaryView* view, MediumLevelILFunction* func)>& action,
- const function<bool(BinaryView* view, MediumLevelILFunction* func)>& isValid)
+ const function<void(BinaryView* view, MediumLevelILFunction* func)>& action,
+ const function<bool(BinaryView* view, MediumLevelILFunction* func)>& isValid)
{
RegisteredMediumLevelILFunctionCommand* cmd = new RegisteredMediumLevelILFunctionCommand;
cmd->action = action;
cmd->isValid = isValid;
BNRegisterPluginCommandForMediumLevelILFunction(name.c_str(), description.c_str(),
- MediumLevelILFunctionPluginCommandActionCallback,
- MediumLevelILFunctionPluginCommandIsValidCallback, cmd);
+ MediumLevelILFunctionPluginCommandActionCallback, MediumLevelILFunctionPluginCommandIsValidCallback, cmd);
}
void PluginCommand::RegisterForMediumLevelILInstruction(const string& name, const string& description,
- const function<void(BinaryView* view, const MediumLevelILInstruction& instr)>& action)
+ const function<void(BinaryView* view, const MediumLevelILInstruction& instr)>& action)
{
- RegisterForMediumLevelILInstruction(name, description, action,
- [](BinaryView*, const MediumLevelILInstruction&) { return true; });
+ RegisterForMediumLevelILInstruction(
+ name, description, action, [](BinaryView*, const MediumLevelILInstruction&) { return true; });
}
void PluginCommand::RegisterForMediumLevelILInstruction(const string& name, const string& description,
- const function<void(BinaryView* view, const MediumLevelILInstruction& instr)>& action,
- const function<bool(BinaryView* view, const MediumLevelILInstruction& instr)>& isValid)
+ const function<void(BinaryView* view, const MediumLevelILInstruction& instr)>& action,
+ const function<bool(BinaryView* view, const MediumLevelILInstruction& instr)>& isValid)
{
RegisteredMediumLevelILInstructionCommand* cmd = new RegisteredMediumLevelILInstructionCommand;
cmd->action = action;
cmd->isValid = isValid;
BNRegisterPluginCommandForMediumLevelILInstruction(name.c_str(), description.c_str(),
- MediumLevelILInstructionPluginCommandActionCallback,
- MediumLevelILInstructionPluginCommandIsValidCallback, cmd);
+ MediumLevelILInstructionPluginCommandActionCallback, MediumLevelILInstructionPluginCommandIsValidCallback, cmd);
}
void PluginCommand::RegisterForHighLevelILFunction(const string& name, const string& description,
- const function<void(BinaryView* view, HighLevelILFunction* func)>& action)
+ const function<void(BinaryView* view, HighLevelILFunction* func)>& action)
{
- RegisterForHighLevelILFunction(name, description, action,
- [](BinaryView*, HighLevelILFunction*) { return true; });
+ RegisterForHighLevelILFunction(name, description, action, [](BinaryView*, HighLevelILFunction*) { return true; });
}
void PluginCommand::RegisterForHighLevelILFunction(const string& name, const string& description,
- const function<void(BinaryView* view, HighLevelILFunction* func)>& action,
- const function<bool(BinaryView* view, HighLevelILFunction* func)>& isValid)
+ const function<void(BinaryView* view, HighLevelILFunction* func)>& action,
+ const function<bool(BinaryView* view, HighLevelILFunction* func)>& isValid)
{
RegisteredHighLevelILFunctionCommand* cmd = new RegisteredHighLevelILFunctionCommand;
cmd->action = action;
cmd->isValid = isValid;
BNRegisterPluginCommandForHighLevelILFunction(name.c_str(), description.c_str(),
- HighLevelILFunctionPluginCommandActionCallback,
- HighLevelILFunctionPluginCommandIsValidCallback, cmd);
+ HighLevelILFunctionPluginCommandActionCallback, HighLevelILFunctionPluginCommandIsValidCallback, cmd);
}
void PluginCommand::RegisterForHighLevelILInstruction(const string& name, const string& description,
- const function<void(BinaryView* view, const HighLevelILInstruction& instr)>& action)
+ const function<void(BinaryView* view, const HighLevelILInstruction& instr)>& action)
{
- RegisterForHighLevelILInstruction(name, description, action,
- [](BinaryView*, const HighLevelILInstruction&) { return true; });
+ RegisterForHighLevelILInstruction(
+ name, description, action, [](BinaryView*, const HighLevelILInstruction&) { return true; });
}
void PluginCommand::RegisterForHighLevelILInstruction(const string& name, const string& description,
- const function<void(BinaryView* view, const HighLevelILInstruction& instr)>& action,
- const function<bool(BinaryView* view, const HighLevelILInstruction& instr)>& isValid)
+ const function<void(BinaryView* view, const HighLevelILInstruction& instr)>& action,
+ const function<bool(BinaryView* view, const HighLevelILInstruction& instr)>& isValid)
{
RegisteredHighLevelILInstructionCommand* cmd = new RegisteredHighLevelILInstructionCommand;
cmd->action = action;
cmd->isValid = isValid;
BNRegisterPluginCommandForHighLevelILInstruction(name.c_str(), description.c_str(),
- HighLevelILInstructionPluginCommandActionCallback,
- HighLevelILInstructionPluginCommandIsValidCallback, cmd);
+ HighLevelILInstructionPluginCommandActionCallback, HighLevelILInstructionPluginCommandIsValidCallback, cmd);
}
@@ -519,8 +511,8 @@ bool PluginCommand::IsValid(const PluginCommandContext& ctxt) const
return false;
if (!m_command.lowLevelILFunctionIsValid)
return true;
- return m_command.lowLevelILFunctionIsValid(m_command.context, ctxt.binaryView->GetObject(),
- ctxt.lowLevelILFunction->GetObject());
+ return m_command.lowLevelILFunctionIsValid(
+ m_command.context, ctxt.binaryView->GetObject(), ctxt.lowLevelILFunction->GetObject());
case LowLevelILInstructionPluginCommand:
if (!ctxt.lowLevelILFunction)
return false;
@@ -528,15 +520,15 @@ bool PluginCommand::IsValid(const PluginCommandContext& ctxt) const
return false;
if (!m_command.lowLevelILInstructionIsValid)
return true;
- return m_command.lowLevelILInstructionIsValid(m_command.context, ctxt.binaryView->GetObject(),
- ctxt.lowLevelILFunction->GetObject(), ctxt.instrIndex);
+ return m_command.lowLevelILInstructionIsValid(
+ m_command.context, ctxt.binaryView->GetObject(), ctxt.lowLevelILFunction->GetObject(), ctxt.instrIndex);
case MediumLevelILFunctionPluginCommand:
if (!ctxt.mediumLevelILFunction)
return false;
if (!m_command.mediumLevelILFunctionIsValid)
return true;
- return m_command.mediumLevelILFunctionIsValid(m_command.context, ctxt.binaryView->GetObject(),
- ctxt.mediumLevelILFunction->GetObject());
+ return m_command.mediumLevelILFunctionIsValid(
+ m_command.context, ctxt.binaryView->GetObject(), ctxt.mediumLevelILFunction->GetObject());
case MediumLevelILInstructionPluginCommand:
if (!ctxt.mediumLevelILFunction)
return false;
@@ -544,15 +536,15 @@ bool PluginCommand::IsValid(const PluginCommandContext& ctxt) const
return false;
if (!m_command.mediumLevelILInstructionIsValid)
return true;
- return m_command.mediumLevelILInstructionIsValid(m_command.context, ctxt.binaryView->GetObject(),
- ctxt.mediumLevelILFunction->GetObject(), ctxt.instrIndex);
+ return m_command.mediumLevelILInstructionIsValid(
+ m_command.context, ctxt.binaryView->GetObject(), ctxt.mediumLevelILFunction->GetObject(), ctxt.instrIndex);
case HighLevelILFunctionPluginCommand:
if (!ctxt.highLevelILFunction)
return false;
if (!m_command.highLevelILFunctionIsValid)
return true;
- return m_command.highLevelILFunctionIsValid(m_command.context, ctxt.binaryView->GetObject(),
- ctxt.highLevelILFunction->GetObject());
+ return m_command.highLevelILFunctionIsValid(
+ m_command.context, ctxt.binaryView->GetObject(), ctxt.highLevelILFunction->GetObject());
case HighLevelILInstructionPluginCommand:
if (!ctxt.highLevelILFunction)
return false;
@@ -560,8 +552,8 @@ bool PluginCommand::IsValid(const PluginCommandContext& ctxt) const
return false;
if (!m_command.highLevelILInstructionIsValid)
return true;
- return m_command.highLevelILInstructionIsValid(m_command.context, ctxt.binaryView->GetObject(),
- ctxt.highLevelILFunction->GetObject(), ctxt.instrIndex);
+ return m_command.highLevelILInstructionIsValid(
+ m_command.context, ctxt.binaryView->GetObject(), ctxt.highLevelILFunction->GetObject(), ctxt.instrIndex);
default:
return false;
}
@@ -588,28 +580,28 @@ void PluginCommand::Execute(const PluginCommandContext& ctxt) const
m_command.functionCommand(m_command.context, ctxt.binaryView->GetObject(), ctxt.function->GetObject());
break;
case LowLevelILFunctionPluginCommand:
- m_command.lowLevelILFunctionCommand(m_command.context, ctxt.binaryView->GetObject(),
- ctxt.lowLevelILFunction->GetObject());
+ m_command.lowLevelILFunctionCommand(
+ m_command.context, ctxt.binaryView->GetObject(), ctxt.lowLevelILFunction->GetObject());
break;
case LowLevelILInstructionPluginCommand:
- m_command.lowLevelILInstructionCommand(m_command.context, ctxt.binaryView->GetObject(),
- ctxt.lowLevelILFunction->GetObject(), ctxt.instrIndex);
+ m_command.lowLevelILInstructionCommand(
+ m_command.context, ctxt.binaryView->GetObject(), ctxt.lowLevelILFunction->GetObject(), ctxt.instrIndex);
break;
case MediumLevelILFunctionPluginCommand:
- m_command.mediumLevelILFunctionCommand(m_command.context, ctxt.binaryView->GetObject(),
- ctxt.mediumLevelILFunction->GetObject());
+ m_command.mediumLevelILFunctionCommand(
+ m_command.context, ctxt.binaryView->GetObject(), ctxt.mediumLevelILFunction->GetObject());
break;
case MediumLevelILInstructionPluginCommand:
- m_command.mediumLevelILInstructionCommand(m_command.context, ctxt.binaryView->GetObject(),
- ctxt.mediumLevelILFunction->GetObject(), ctxt.instrIndex);
+ m_command.mediumLevelILInstructionCommand(
+ m_command.context, ctxt.binaryView->GetObject(), ctxt.mediumLevelILFunction->GetObject(), ctxt.instrIndex);
break;
case HighLevelILFunctionPluginCommand:
- m_command.highLevelILFunctionCommand(m_command.context, ctxt.binaryView->GetObject(),
- ctxt.highLevelILFunction->GetObject());
+ m_command.highLevelILFunctionCommand(
+ m_command.context, ctxt.binaryView->GetObject(), ctxt.highLevelILFunction->GetObject());
break;
case HighLevelILInstructionPluginCommand:
- m_command.highLevelILInstructionCommand(m_command.context, ctxt.binaryView->GetObject(),
- ctxt.highLevelILFunction->GetObject(), ctxt.instrIndex);
+ m_command.highLevelILInstructionCommand(
+ m_command.context, ctxt.binaryView->GetObject(), ctxt.highLevelILFunction->GetObject(), ctxt.instrIndex);
break;
default:
break;
diff --git a/pluginmanager.cpp b/pluginmanager.cpp
index d3108907..6a72e69c 100644
--- a/pluginmanager.cpp
+++ b/pluginmanager.cpp
@@ -3,12 +3,14 @@
using namespace BinaryNinja;
using namespace std;
-#define RETURN_STRING(s) do { \
- char* contents = (char*)(s); \
- string result(contents); \
- BNFreeString(contents); \
- return result; \
-}while(0)
+#define RETURN_STRING(s) \
+ do \
+ { \
+ char* contents = (char*)(s); \
+ string result(contents); \
+ BNFreeString(contents); \
+ return result; \
+ } while (0)
RepoPlugin::RepoPlugin(BNRepoPlugin* plugin)
{
@@ -326,7 +328,7 @@ vector<Ref<Repository>> RepositoryManager::GetRepositories()
}
bool RepositoryManager::AddRepository(const std::string& url,
- const std::string& repoPath) // Relative path within the repositories directory
+ const std::string& repoPath) // Relative path within the repositories directory
{
return BNRepositoryManagerAddRepository(m_object, url.c_str(), repoPath.c_str());
}
diff --git a/python/__init__.py b/python/__init__.py
index 9f193bea..b973118a 100644
--- a/python/__init__.py
+++ b/python/__init__.py
@@ -18,7 +18,6 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
-
import atexit
import sys
import ctypes
@@ -26,7 +25,6 @@ from time import gmtime, struct_time
import os
from typing import Mapping, Optional
-
# Binary Ninja components
import binaryninja._binaryninjacore as core
import binaryninja
@@ -68,9 +66,10 @@ from .commonil import *
from .database import *
# We import each of these by name to prevent conflicts between
# log.py and the function 'log' which we don't import below
-from .log import (redirect_output_to_log, is_output_redirected_to_log,
- log_debug, log_info, log_warn, log_error, log_alert,
- log_to_stdout, log_to_stderr, log_to_file, close_logs)
+from .log import (
+ redirect_output_to_log, is_output_redirected_to_log, log_debug, log_info, log_warn, log_error, log_alert,
+ log_to_stdout, log_to_stderr, log_to_file, close_logs
+)
from .log import log as log_at_level
# Only load Enterprise Client support on Enterprise builds
if core.BNGetProduct() == "Binary Ninja Enterprise Client":
@@ -136,15 +135,17 @@ def _init_plugins():
pass
if not core.BNIsLicenseValidated() or not enterprise.is_license_still_activated():
raise RuntimeError(
- "To use Binary Ninja Enterprise from a headless python script, you must check out a license first.\n"
- "You can either check out a license for an extended time with the UI, or use the binaryninja.enterprise module.")
+ "To use Binary Ninja Enterprise from a headless python script, you must check out a license first.\n"
+ "You can either check out a license for an extended time with the UI, or use the binaryninja.enterprise module."
+ )
if not _plugin_init:
# The first call to BNInitCorePlugins returns True for successful initialization and True in this context indicates headless operation.
# The result is pulled from BNInitPlugins as that now wraps BNInitCorePlugins.
is_headless_init_once = core.BNInitPlugins(not os.environ.get('BN_DISABLE_USER_PLUGINS'))
min_level = Settings().get_string("python.log.minLevel")
- if _enable_default_log and is_headless_init_once and min_level in LogLevel.__members__ and not core_ui_enabled() and sys.stderr.isatty():
+ if _enable_default_log and is_headless_init_once and min_level in LogLevel.__members__ and not core_ui_enabled(
+ ) and sys.stderr.isatty():
log_to_stderr(LogLevel[min_level])
core.BNInitRepoPlugins()
if core.BNIsLicenseValidated():
@@ -162,6 +163,7 @@ def disable_default_log() -> None:
_enable_default_log = False
close_logs()
+
def bundled_plugin_path() -> Optional[str]:
"""
``bundled_plugin_path`` returns a string containing the current plugin path inside the `install path <https://docs.binary.ninja/getting-started.html#binary-path>`_
@@ -171,6 +173,7 @@ def bundled_plugin_path() -> Optional[str]:
"""
return core.BNGetBundledPluginDirectory()
+
def user_plugin_path() -> Optional[str]:
"""
``user_plugin_path`` returns a string containing the current plugin path inside the `user directory <https://docs.binary.ninja/getting-started.html#user-folder>`_
@@ -180,6 +183,7 @@ def user_plugin_path() -> Optional[str]:
"""
return core.BNGetUserPluginDirectory()
+
def user_directory() -> Optional[str]:
"""
``user_directory`` returns a string containing the path to the `user directory <https://docs.binary.ninja/getting-started.html#user-folder>`_
@@ -189,6 +193,7 @@ def user_directory() -> Optional[str]:
"""
return core.BNGetUserDirectory()
+
def core_version() -> Optional[str]:
"""
``core_version`` returns a string containing the current version
@@ -198,6 +203,7 @@ def core_version() -> Optional[str]:
"""
return core.BNGetVersionString()
+
def core_build_id() -> int:
"""
``core_build_id`` returns a integer containing the current build id
@@ -207,6 +213,7 @@ def core_build_id() -> int:
"""
return core.BNGetBuildId()
+
def core_serial() -> Optional[str]:
"""
``core_serial`` returns a string containing the current serial number
@@ -216,28 +223,33 @@ def core_serial() -> Optional[str]:
"""
return core.BNGetSerialNumber()
+
def core_expires() -> struct_time:
'''License Expiration'''
return gmtime(core.BNGetLicenseExpirationTime())
+
def core_product() -> Optional[str]:
'''Product string from the license file'''
return core.BNGetProduct()
+
def core_product_type() -> Optional[str]:
'''Product type from the license file'''
return core.BNGetProductType()
+
def core_license_count() -> int:
'''License count from the license file'''
return core.BNGetLicenseCount()
+
def core_ui_enabled() -> bool:
'''Indicates that a UI exists and the UI has invoked BNInitUI'''
return core.BNIsUIEnabled()
-def core_set_license(licenseData:str) -> None:
+def core_set_license(licenseData: str) -> None:
'''
``core_set_license`` is used to initialize the core with a license file that doesn't necessarily reside on a file system. This is especially useful for headless environments such as docker where loading the license file via an environment variable allows for greater security of the license file itself.
@@ -294,7 +306,7 @@ def connect_pycharm_debugger(port=5678):
# Get pip install string from PyCharm's Python Debug Server Configuration
# e.g. for PyCharm 2021.1.1 #PY-7142.13:
# pip install --user pydevd-pycharm~=211.7142.13
- import pydevd_pycharm # type: ignore
+ import pydevd_pycharm # type: ignore
pydevd_pycharm.settrace('localhost', port=port, stdoutToServer=True, stderrToServer=True, suspend=False)
diff --git a/python/architecture.py b/python/architecture.py
index fd9e28f1..ff598a35 100644
--- a/python/architecture.py
+++ b/python/architecture.py
@@ -26,9 +26,10 @@ from dataclasses import dataclass, field
# Binary Ninja components
import binaryninja
from . import _binaryninjacore as core
-from .enums import (Endianness, ImplicitRegisterExtend, BranchType,
- LowLevelILFlagCondition, FlagRole, LowLevelILOperation,
- InstructionTextTokenType, InstructionTextTokenContext)
+from .enums import (
+ Endianness, ImplicitRegisterExtend, BranchType, LowLevelILFlagCondition, FlagRole, LowLevelILOperation,
+ InstructionTextTokenType, InstructionTextTokenContext
+)
from .log import log_error
from . import lowlevelil
from . import types
@@ -65,11 +66,11 @@ IntrinsicType = Union[IntrinsicName, 'lowlevelil.ILIntrinsic', IntrinsicIndex]
@dataclass(frozen=True)
class RegisterInfo:
- full_width_reg:RegisterName
- size:int
- offset:int = 0
- extend:ImplicitRegisterExtend = ImplicitRegisterExtend.NoExtend
- index:Optional[RegisterIndex] = None
+ full_width_reg: RegisterName
+ size: int
+ offset: int = 0
+ extend: ImplicitRegisterExtend = ImplicitRegisterExtend.NoExtend
+ index: Optional[RegisterIndex] = None
def __repr__(self):
if self.extend == ImplicitRegisterExtend.ZeroExtendToFullWidth:
@@ -83,10 +84,10 @@ class RegisterInfo:
@dataclass(frozen=True)
class RegisterStackInfo:
- storage_regs:List[RegisterName]
- top_relative_regs:List[RegisterName]
- stack_top_reg:RegisterName
- index:Optional[RegisterStackIndex] = None
+ storage_regs: List[RegisterName]
+ top_relative_regs: List[RegisterName]
+ stack_top_reg: RegisterName
+ index: Optional[RegisterStackIndex] = None
def __repr__(self):
return f"<reg stack: {len(self.storage_regs)} regs, stack top in {self.stack_top_reg}>"
@@ -94,8 +95,8 @@ class RegisterStackInfo:
@dataclass(frozen=True)
class IntrinsicInput:
- type:'types.Type'
- name:str = ""
+ type: 'types.Type'
+ name: str = ""
def __repr__(self):
if len(self.name) == 0:
@@ -105,9 +106,9 @@ class IntrinsicInput:
@dataclass(frozen=True)
class IntrinsicInfo:
- inputs:List[IntrinsicInput]
- outputs:List['types.Type']
- index:Optional[int] = None
+ inputs: List[IntrinsicInput]
+ outputs: List['types.Type']
+ index: Optional[int] = None
def __repr__(self):
return f"<intrinsic: {repr(self.inputs)} -> {repr(self.outputs)}>"
@@ -115,9 +116,9 @@ class IntrinsicInfo:
@dataclass(frozen=True)
class InstructionBranch:
- type:BranchType
- target:int
- arch:Optional['Architecture']
+ type: BranchType
+ target: int
+ arch: Optional['Architecture']
def __repr__(self):
if self.arch is not None:
@@ -127,12 +128,12 @@ class InstructionBranch:
@dataclass(frozen=False)
class InstructionInfo:
- length:int = 0
- arch_transition_by_target_addr:bool = False
- branch_delay:bool = False
- branches:List[InstructionBranch] = field(default_factory=list)
+ length: int = 0
+ arch_transition_by_target_addr: bool = False
+ branch_delay: bool = False
+ branches: List[InstructionBranch] = field(default_factory=list)
- def add_branch(self, branch_type:BranchType, target:int = 0, arch:Optional['Architecture'] = None) -> None:
+ def add_branch(self, branch_type: BranchType, target: int = 0, arch: Optional['Architecture'] = None) -> None:
self.branches.append(InstructionBranch(branch_type, target, arch))
def __len__(self):
@@ -158,7 +159,7 @@ class _ArchitectureMetaClass(type):
finally:
core.BNFreeArchitectureList(archs)
- def __getitem__(cls:'_ArchitectureMetaClass', name:str) -> 'Architecture':
+ def __getitem__(cls: '_ArchitectureMetaClass', name: str) -> 'Architecture':
binaryninja._init_plugins()
arch = core.BNGetArchitectureByName(name)
if arch is None:
@@ -207,7 +208,7 @@ class Architecture(metaclass=_ArchitectureMetaClass):
global_regs = []
system_regs = []
flags = []
- flag_write_types:List[FlagWriteTypeName] = []
+ flag_write_types: List[FlagWriteTypeName] = []
semantic_flag_classes = []
semantic_flag_groups = []
flag_roles = {}
@@ -235,47 +236,63 @@ class Architecture(metaclass=_ArchitectureMetaClass):
self._cb.getInstructionAlignment = self._cb.getInstructionAlignment.__class__(self._get_instruction_alignment)
self._cb.getMaxInstructionLength = self._cb.getMaxInstructionLength.__class__(self._get_max_instruction_length)
self._cb.getOpcodeDisplayLength = self._cb.getOpcodeDisplayLength.__class__(self._get_opcode_display_length)
- self._cb.getAssociatedArchitectureByAddress = \
- self._cb.getAssociatedArchitectureByAddress.__class__(self._get_associated_arch_by_address)
+ self._cb.getAssociatedArchitectureByAddress = self._cb.getAssociatedArchitectureByAddress.__class__(
+ self._get_associated_arch_by_address
+ )
self._cb.getInstructionInfo = self._cb.getInstructionInfo.__class__(self._get_instruction_info)
self._cb.getInstructionText = self._cb.getInstructionText.__class__(self._get_instruction_text)
self._cb.freeInstructionText = self._cb.freeInstructionText.__class__(self._free_instruction_text)
self._cb.getInstructionLowLevelIL = self._cb.getInstructionLowLevelIL.__class__(
- self._get_instruction_low_level_il)
+ self._get_instruction_low_level_il
+ )
self._cb.getRegisterName = self._cb.getRegisterName.__class__(self._get_register_name)
self._cb.getFlagName = self._cb.getFlagName.__class__(self._get_flag_name)
self._cb.getFlagWriteTypeName = self._cb.getFlagWriteTypeName.__class__(self._get_flag_write_type_name)
- self._cb.getSemanticFlagClassName = self._cb.getSemanticFlagClassName.__class__(self._get_semantic_flag_class_name)
- self._cb.getSemanticFlagGroupName = self._cb.getSemanticFlagGroupName.__class__(self._get_semantic_flag_group_name)
+ self._cb.getSemanticFlagClassName = self._cb.getSemanticFlagClassName.__class__(
+ self._get_semantic_flag_class_name
+ )
+ self._cb.getSemanticFlagGroupName = self._cb.getSemanticFlagGroupName.__class__(
+ self._get_semantic_flag_group_name
+ )
self._cb.getFullWidthRegisters = self._cb.getFullWidthRegisters.__class__(self._get_full_width_registers)
self._cb.getAllRegisters = self._cb.getAllRegisters.__class__(self._get_all_registers)
self._cb.getAllFlags = self._cb.getAllRegisters.__class__(self._get_all_flags)
self._cb.getAllFlagWriteTypes = self._cb.getAllRegisters.__class__(self._get_all_flag_write_types)
- self._cb.getAllSemanticFlagClasses = self._cb.getAllSemanticFlagClasses.__class__(self._get_all_semantic_flag_classes)
- self._cb.getAllSemanticFlagGroups = self._cb.getAllSemanticFlagGroups.__class__(self._get_all_semantic_flag_groups)
+ self._cb.getAllSemanticFlagClasses = self._cb.getAllSemanticFlagClasses.__class__(
+ self._get_all_semantic_flag_classes
+ )
+ self._cb.getAllSemanticFlagGroups = self._cb.getAllSemanticFlagGroups.__class__(
+ self._get_all_semantic_flag_groups
+ )
self._cb.getFlagRole = self._cb.getFlagRole.__class__(self._get_flag_role)
self._cb.getFlagsRequiredForFlagCondition = self._cb.getFlagsRequiredForFlagCondition.__class__(
- self._get_flags_required_for_flag_condition)
+ self._get_flags_required_for_flag_condition
+ )
self._cb.getFlagsRequiredForSemanticFlagGroup = self._cb.getFlagsRequiredForSemanticFlagGroup.__class__(
- self._get_flags_required_for_semantic_flag_group)
+ self._get_flags_required_for_semantic_flag_group
+ )
self._cb.getFlagConditionsForSemanticFlagGroup = self._cb.getFlagConditionsForSemanticFlagGroup.__class__(
- self._get_flag_conditions_for_semantic_flag_group)
+ self._get_flag_conditions_for_semantic_flag_group
+ )
self._cb.freeFlagConditionsForSemanticFlagGroup = self._cb.freeFlagConditionsForSemanticFlagGroup.__class__(
- self._free_flag_conditions_for_semantic_flag_group)
+ self._free_flag_conditions_for_semantic_flag_group
+ )
self._cb.getFlagsWrittenByFlagWriteType = self._cb.getFlagsWrittenByFlagWriteType.__class__(
- self._get_flags_written_by_flag_write_type)
+ self._get_flags_written_by_flag_write_type
+ )
self._cb.getSemanticClassForFlagWriteType = self._cb.getSemanticClassForFlagWriteType.__class__(
- self._get_semantic_class_for_flag_write_type)
- self._cb.getFlagWriteLowLevelIL = self._cb.getFlagWriteLowLevelIL.__class__(
- self._get_flag_write_low_level_il)
+ self._get_semantic_class_for_flag_write_type
+ )
+ self._cb.getFlagWriteLowLevelIL = self._cb.getFlagWriteLowLevelIL.__class__(self._get_flag_write_low_level_il)
self._cb.getFlagConditionLowLevelIL = self._cb.getFlagConditionLowLevelIL.__class__(
- self._get_flag_condition_low_level_il)
+ self._get_flag_condition_low_level_il
+ )
self._cb.getSemanticFlagGroupLowLevelIL = self._cb.getSemanticFlagGroupLowLevelIL.__class__(
- self._get_semantic_flag_group_low_level_il)
+ self._get_semantic_flag_group_low_level_il
+ )
self._cb.freeRegisterList = self._cb.freeRegisterList.__class__(self._free_register_list)
self._cb.getRegisterInfo = self._cb.getRegisterInfo.__class__(self._get_register_info)
- self._cb.getStackPointerRegister = self._cb.getStackPointerRegister.__class__(
- self._get_stack_pointer_register)
+ self._cb.getStackPointerRegister = self._cb.getStackPointerRegister.__class__(self._get_stack_pointer_register)
self._cb.getLinkRegister = self._cb.getLinkRegister.__class__(self._get_link_register)
self._cb.getGlobalRegisters = self._cb.getGlobalRegisters.__class__(self._get_global_registers)
self._cb.getSystemRegisters = self._cb.getSystemRegisters.__class__(self._get_system_registers)
@@ -290,15 +307,20 @@ class Architecture(metaclass=_ArchitectureMetaClass):
self._cb.freeTypeList = self._cb.freeTypeList.__class__(self._free_type_list)
self._cb.assemble = self._cb.assemble.__class__(self._assemble)
self._cb.isNeverBranchPatchAvailable = self._cb.isNeverBranchPatchAvailable.__class__(
- self._is_never_branch_patch_available)
+ self._is_never_branch_patch_available
+ )
self._cb.isAlwaysBranchPatchAvailable = self._cb.isAlwaysBranchPatchAvailable.__class__(
- self._is_always_branch_patch_available)
+ self._is_always_branch_patch_available
+ )
self._cb.isInvertBranchPatchAvailable = self._cb.isInvertBranchPatchAvailable.__class__(
- self._is_invert_branch_patch_available)
+ self._is_invert_branch_patch_available
+ )
self._cb.isSkipAndReturnZeroPatchAvailable = self._cb.isSkipAndReturnZeroPatchAvailable.__class__(
- self._is_skip_and_return_zero_patch_available)
+ self._is_skip_and_return_zero_patch_available
+ )
self._cb.isSkipAndReturnValuePatchAvailable = self._cb.isSkipAndReturnValuePatchAvailable.__class__(
- self._is_skip_and_return_value_patch_available)
+ self._is_skip_and_return_value_patch_available
+ )
self._cb.convertToNop = self._cb.convertToNop.__class__(self._convert_to_nop)
self._cb.alwaysBranch = self._cb.alwaysBranch.__class__(self._always_branch)
self._cb.invertBranch = self._cb.invertBranch.__class__(self._invert_branch)
@@ -313,16 +335,16 @@ class Architecture(metaclass=_ArchitectureMetaClass):
self.__dict__['stack_pointer'] = self.__class__.stack_pointer
self.__dict__['link_reg'] = self.__class__.link_reg
- self._all_regs:Dict[RegisterName, RegisterIndex] = {}
- self._full_width_regs:Dict[RegisterName, RegisterIndex] = {}
- self._regs_by_index:Dict[RegisterIndex, RegisterName] = {}
+ self._all_regs: Dict[RegisterName, RegisterIndex] = {}
+ self._full_width_regs: Dict[RegisterName, RegisterIndex] = {}
+ self._regs_by_index: Dict[RegisterIndex, RegisterName] = {}
self.regs = self.__class__.regs
assert self.regs is not None, "Custom Architecture doesn't specify a register map"
reg_index = RegisterIndex(0)
# Registers used for storage in register stacks must be sequential, so allocate these in order first
- self._all_reg_stacks:Dict[RegisterStackName, RegisterStackIndex] = {}
- self._reg_stacks_by_index:Dict[RegisterStackIndex, RegisterStackName] = {}
+ self._all_reg_stacks: Dict[RegisterStackName, RegisterStackIndex] = {}
+ self._reg_stacks_by_index: Dict[RegisterStackIndex, RegisterStackName] = {}
self.reg_stacks = self.__class__.reg_stacks
assert self.regs is not None, "Custom Architecture doesn't specify a reg_stacks map"
reg_stack_index = RegisterStackIndex(0)
@@ -343,7 +365,9 @@ class Architecture(metaclass=_ArchitectureMetaClass):
self._all_reg_stacks[reg_stack] = reg_stack_index
self._reg_stacks_by_index[reg_stack_index] = reg_stack
rs = self.reg_stacks[reg_stack]
- self.reg_stacks[reg_stack] = RegisterStackInfo(rs.storage_regs, rs.top_relative_regs, rs.stack_top_reg, reg_stack_index)
+ self.reg_stacks[reg_stack] = RegisterStackInfo(
+ rs.storage_regs, rs.top_relative_regs, rs.stack_top_reg, reg_stack_index
+ )
reg_stack_index = RegisterStackIndex(reg_stack_index + 1)
for reg, info in self.regs.items():
@@ -362,9 +386,9 @@ class Architecture(metaclass=_ArchitectureMetaClass):
if info.full_width_reg not in self._full_width_regs:
self._full_width_regs[info.full_width_reg] = self._all_regs[info.full_width_reg]
- self._flags:Dict[FlagName, FlagIndex] = {}
- self._flags_by_index:Dict[FlagIndex, FlagName] = {}
- self.flags:List[FlagName] = self.__class__.flags
+ self._flags: Dict[FlagName, FlagIndex] = {}
+ self._flags_by_index: Dict[FlagIndex, FlagName] = {}
+ self.flags: List[FlagName] = self.__class__.flags
flag_index = FlagIndex(0)
for flag in self.__class__.flags:
if flag not in self._flags:
@@ -372,9 +396,9 @@ class Architecture(metaclass=_ArchitectureMetaClass):
self._flags_by_index[flag_index] = flag
flag_index = FlagIndex(flag_index + 1)
- self._flag_write_types:Dict[FlagWriteTypeName, FlagWriteTypeIndex] = {}
- self._flag_write_types_by_index:Dict[FlagWriteTypeIndex, FlagWriteTypeName] = {}
- self.flag_write_types:List[FlagWriteTypeName] = self.__class__.flag_write_types
+ self._flag_write_types: Dict[FlagWriteTypeName, FlagWriteTypeIndex] = {}
+ self._flag_write_types_by_index: Dict[FlagWriteTypeIndex, FlagWriteTypeName] = {}
+ self.flag_write_types: List[FlagWriteTypeName] = self.__class__.flag_write_types
write_type_index = FlagWriteTypeIndex(1)
for write_type in self.__class__.flag_write_types:
if write_type not in self._flag_write_types:
@@ -382,9 +406,9 @@ class Architecture(metaclass=_ArchitectureMetaClass):
self._flag_write_types_by_index[write_type_index] = write_type
write_type_index = FlagWriteTypeIndex(write_type_index + 1)
- self._semantic_flag_classes:Dict[SemanticClassName, SemanticClassIndex] = {}
- self._semantic_flag_classes_by_index:Dict[SemanticClassIndex, SemanticClassName] = {}
- self.semantic_flag_classes:List[SemanticClassName] = self.__class__.semantic_flag_classes
+ self._semantic_flag_classes: Dict[SemanticClassName, SemanticClassIndex] = {}
+ self._semantic_flag_classes_by_index: Dict[SemanticClassIndex, SemanticClassName] = {}
+ self.semantic_flag_classes: List[SemanticClassName] = self.__class__.semantic_flag_classes
semantic_class_index = SemanticClassIndex(1)
for sem_class in self.__class__.semantic_flag_classes:
if sem_class not in self._semantic_flag_classes:
@@ -392,9 +416,9 @@ class Architecture(metaclass=_ArchitectureMetaClass):
self._semantic_flag_classes_by_index[semantic_class_index] = sem_class
semantic_class_index = SemanticClassIndex(semantic_class_index + 1)
- self._semantic_flag_groups:Dict[SemanticGroupName, SemanticGroupIndex] = {}
- self._semantic_flag_groups_by_index:Dict[SemanticGroupIndex, SemanticGroupName] = {}
- self.semantic_flag_groups:List[SemanticGroupName] = self.__class__.semantic_flag_groups
+ self._semantic_flag_groups: Dict[SemanticGroupName, SemanticGroupIndex] = {}
+ self._semantic_flag_groups_by_index: Dict[SemanticGroupIndex, SemanticGroupName] = {}
+ self.semantic_flag_groups: List[SemanticGroupName] = self.__class__.semantic_flag_groups
semantic_group_index = SemanticGroupIndex(0)
for sem_group in self.__class__.semantic_flag_groups:
if sem_group not in self._semantic_flag_groups:
@@ -402,20 +426,22 @@ class Architecture(metaclass=_ArchitectureMetaClass):
self._semantic_flag_groups_by_index[semantic_group_index] = sem_group
semantic_group_index = SemanticGroupIndex(semantic_group_index + 1)
- self._flag_roles:Dict[FlagIndex, FlagRole] = {}
- self.flag_roles:Dict[FlagName, FlagRole] = self.__class__.flag_roles
+ self._flag_roles: Dict[FlagIndex, FlagRole] = {}
+ self.flag_roles: Dict[FlagName, FlagRole] = self.__class__.flag_roles
for flag in self.__class__.flag_roles:
role = self.__class__.flag_roles[flag]
if isinstance(role, str):
role = FlagRole[role]
self._flag_roles[self._flags[flag]] = role
- self.flags_required_for_flag_condition:Dict['lowlevelil.LowLevelILFlagCondition', List[FlagName]] = self.__class__.flags_required_for_flag_condition
+ self.flags_required_for_flag_condition: Dict['lowlevelil.LowLevelILFlagCondition',
+ List[FlagName]] = self.__class__.flags_required_for_flag_condition
- self._flags_required_by_semantic_flag_group:Dict[SemanticGroupIndex, List[FlagIndex]] = {}
- self.flags_required_for_semantic_flag_group:Dict[SemanticGroupName, List[FlagName]] = self.__class__.flags_required_for_semantic_flag_group
+ self._flags_required_by_semantic_flag_group: Dict[SemanticGroupIndex, List[FlagIndex]] = {}
+ self.flags_required_for_semantic_flag_group: Dict[
+ SemanticGroupName, List[FlagName]] = self.__class__.flags_required_for_semantic_flag_group
for group in self.__class__.flags_required_for_semantic_flag_group:
- flags:List[FlagIndex] = []
+ flags: List[FlagIndex] = []
for flag in self.__class__.flags_required_for_semantic_flag_group[group]:
flags.append(self._flags[flag])
self._flags_required_by_semantic_flag_group[self._semantic_flag_groups[group]] = flags
@@ -428,7 +454,8 @@ class Architecture(metaclass=_ArchitectureMetaClass):
if sem_class is None:
class_cond[0] = self.__class__.flag_conditions_for_semantic_flag_group[group][sem_class]
else:
- class_cond[self._semantic_flag_classes[sem_class]] = self.__class__.flag_conditions_for_semantic_flag_group[group][sem_class]
+ class_cond[self._semantic_flag_classes[sem_class]
+ ] = self.__class__.flag_conditions_for_semantic_flag_group[group][sem_class]
self._flag_conditions_for_semantic_flag_group[self._semantic_flag_groups[group]] = class_cond
self._flags_written_by_flag_write_type = {}
@@ -452,8 +479,8 @@ class Architecture(metaclass=_ArchitectureMetaClass):
self.global_regs = self.__class__.global_regs
self.system_regs = self.__class__.system_regs
- self._intrinsics:Dict[IntrinsicName, IntrinsicIndex] = {}
- self._intrinsics_by_index:Dict[IntrinsicIndex, Tuple[IntrinsicName, IntrinsicInfo]] = {}
+ self._intrinsics: Dict[IntrinsicName, IntrinsicIndex] = {}
+ self._intrinsics_by_index: Dict[IntrinsicIndex, Tuple[IntrinsicName, IntrinsicInfo]] = {}
intrinsic_index = IntrinsicIndex(0)
for intrinsic in self.__class__.intrinsics.keys():
if intrinsic not in self._intrinsics:
@@ -509,7 +536,7 @@ class Architecture(metaclass=_ArchitectureMetaClass):
count = ctypes.c_ulonglong()
regs = core.BNGetFullWidthArchitectureRegisters(self.handle, count)
assert regs is not None, "core.BNGetFullWidthArchitectureRegisters returned None"
- result:List[RegisterName] = []
+ result: List[RegisterName] = []
try:
for i in range(0, count.value):
result.append(RegisterName(core.BNGetArchitectureRegisterName(self.handle, regs[i])))
@@ -668,8 +695,9 @@ class Architecture(metaclass=_ArchitectureMetaClass):
try:
buf = ctypes.create_string_buffer(length[0])
ctypes.memmove(buf, data, length[0])
- result = self.get_instruction_low_level_il(buf.raw, addr,
- lowlevelil.LowLevelILFunction(self, core.BNNewLowLevelILFunctionReference(il)))
+ result = self.get_instruction_low_level_il(
+ buf.raw, addr, lowlevelil.LowLevelILFunction(self, core.BNNewLowLevelILFunctionReference(il))
+ )
if result is None:
return False
length[0] = result
@@ -696,7 +724,7 @@ class Architecture(metaclass=_ArchitectureMetaClass):
log_error(traceback.format_exc())
return core.BNAllocString("")
- def _get_flag_write_type_name(self, ctxt, write_type:FlagWriteTypeIndex):
+ def _get_flag_write_type_name(self, ctxt, write_type: FlagWriteTypeIndex):
try:
if write_type in self._flag_write_types_by_index:
return core.BNAllocString(self._flag_write_types_by_index[write_type])
@@ -813,7 +841,7 @@ class Architecture(metaclass=_ArchitectureMetaClass):
count[0] = 0
return None
- def _get_flag_role(self, ctxt, flag:FlagIndex, sem_class:Optional[SemanticClassName]=None):
+ def _get_flag_role(self, ctxt, flag: FlagIndex, sem_class: Optional[SemanticClassName] = None):
if sem_class in self._semantic_flag_classes:
assert sem_class is not None
_sem_class = self._semantic_flag_classes[sem_class]
@@ -933,8 +961,10 @@ class Architecture(metaclass=_ArchitectureMetaClass):
operand_list.append(lowlevelil.ILRegister(self, operands[i].reg))
else:
operand_list.append(lowlevelil.ILRegister(self, operands[i].reg))
- return self.get_flag_write_low_level_il(op, size, write_type_name, flag_name, operand_list,
- lowlevelil.LowLevelILFunction(self, core.BNNewLowLevelILFunctionReference(il)))
+ return self.get_flag_write_low_level_il(
+ op, size, write_type_name, flag_name, operand_list,
+ lowlevelil.LowLevelILFunction(self, core.BNNewLowLevelILFunctionReference(il))
+ )
except (KeyError, OSError):
log_error(traceback.format_exc())
return False
@@ -945,8 +975,9 @@ class Architecture(metaclass=_ArchitectureMetaClass):
sem_class_name = self._semantic_flag_classes_by_index[sem_class]
else:
sem_class_name = None
- return self.get_flag_condition_low_level_il(cond, sem_class_name,
- lowlevelil.LowLevelILFunction(self, core.BNNewLowLevelILFunctionReference(il)))
+ return self.get_flag_condition_low_level_il(
+ cond, sem_class_name, lowlevelil.LowLevelILFunction(self, core.BNNewLowLevelILFunctionReference(il))
+ )
except OSError:
log_error(traceback.format_exc())
return 0
@@ -957,8 +988,9 @@ class Architecture(metaclass=_ArchitectureMetaClass):
sem_group_name = self._semantic_flag_groups_by_index[sem_group]
else:
sem_group_name = None
- return self.get_semantic_flag_group_low_level_il(sem_group_name,
- lowlevelil.LowLevelILFunction(self, core.BNNewLowLevelILFunctionReference(il)))
+ return self.get_semantic_flag_group_low_level_il(
+ sem_group_name, lowlevelil.LowLevelILFunction(self, core.BNNewLowLevelILFunctionReference(il))
+ )
except OSError:
log_error(traceback.format_exc())
return 0
@@ -1309,10 +1341,10 @@ class Architecture(metaclass=_ArchitectureMetaClass):
log_error(traceback.format_exc())
return False
- def get_associated_arch_by_address(self, addr:int) -> Tuple['Architecture', int]:
+ def get_associated_arch_by_address(self, addr: int) -> Tuple['Architecture', int]:
return self, addr
- def get_instruction_info(self, data:bytes, addr:int) -> Optional[InstructionInfo]:
+ def get_instruction_info(self, data: bytes, addr: int) -> Optional[InstructionInfo]:
"""
``get_instruction_info`` returns an InstructionInfo object for the instruction at the given virtual address
``addr`` with data ``data``.
@@ -1344,7 +1376,7 @@ class Architecture(metaclass=_ArchitectureMetaClass):
"""
raise NotImplementedError
- def get_instruction_text(self, data:bytes, addr:int) -> Tuple[List['function.InstructionTextToken'], int]:
+ def get_instruction_text(self, data: bytes, addr: int) -> Tuple[List['function.InstructionTextToken'], int]:
"""
``get_instruction_text`` returns a tuple containing a list of decoded InstructionTextToken objects and the bytes used at the given virtual
address ``addr`` with data ``data``.
@@ -1358,13 +1390,15 @@ class Architecture(metaclass=_ArchitectureMetaClass):
"""
raise NotImplementedError
- def get_instruction_low_level_il_instruction(self, bv:'binaryview.BinaryView', addr:int) -> 'lowlevelil.LowLevelILInstruction':
+ def get_instruction_low_level_il_instruction(
+ self, bv: 'binaryview.BinaryView', addr: int
+ ) -> 'lowlevelil.LowLevelILInstruction':
il = lowlevelil.LowLevelILFunction(self)
data = bv.read(addr, self.max_instr_length)
self.get_instruction_low_level_il(data, addr, il)
return il[0]
- def get_instruction_low_level_il(self, data:bytes, addr:int, il:'lowlevelil.LowLevelILFunction') -> int:
+ def get_instruction_low_level_il(self, data: bytes, addr: int, il: 'lowlevelil.LowLevelILFunction') -> int:
"""
``get_instruction_low_level_il`` appends lowlevelil.ExpressionIndex objects to ``il`` for the instruction at the given
virtual address ``addr`` with data ``data``.
@@ -1382,7 +1416,7 @@ class Architecture(metaclass=_ArchitectureMetaClass):
"""
raise NotImplementedError
- def get_low_level_il_from_bytes(self, data:bytes, addr:int) -> 'lowlevelil.LowLevelILInstruction':
+ def get_low_level_il_from_bytes(self, data: bytes, addr: int) -> 'lowlevelil.LowLevelILInstruction':
"""
``get_low_level_il_from_bytes`` converts the instruction in bytes to ``il`` at the given virtual address
@@ -1400,7 +1434,7 @@ class Architecture(metaclass=_ArchitectureMetaClass):
self.get_instruction_low_level_il(data, addr, func)
return func[0]
- def get_reg_name(self, reg:RegisterIndex) -> RegisterName:
+ def get_reg_name(self, reg: RegisterIndex) -> RegisterName:
"""
``get_reg_name`` gets a register name from a register index.
@@ -1410,7 +1444,7 @@ class Architecture(metaclass=_ArchitectureMetaClass):
"""
return RegisterName(core.BNGetArchitectureRegisterName(self.handle, reg))
- def get_reg_stack_name(self, reg_stack:RegisterStackIndex) -> RegisterStackName:
+ def get_reg_stack_name(self, reg_stack: RegisterStackIndex) -> RegisterStackName:
"""
``get_reg_stack_name`` gets a register stack name from a register stack number.
@@ -1420,14 +1454,14 @@ class Architecture(metaclass=_ArchitectureMetaClass):
"""
return RegisterStackName(core.BNGetArchitectureRegisterStackName(self.handle, reg_stack))
- def get_reg_stack_for_reg(self, reg:RegisterName) -> Optional[RegisterStackName]:
+ def get_reg_stack_for_reg(self, reg: RegisterName) -> Optional[RegisterStackName]:
_reg = self.get_reg_index(reg)
result = core.BNGetArchitectureRegisterStackForRegister(self.handle, _reg)
if result == 0xffffffff:
return None
return self.get_reg_stack_name(RegisterStackIndex(result))
- def get_flag_name(self, flag:FlagIndex) -> FlagName:
+ def get_flag_name(self, flag: FlagIndex) -> FlagName:
"""
``get_flag_name`` gets a flag name from a flag index.
@@ -1437,7 +1471,7 @@ class Architecture(metaclass=_ArchitectureMetaClass):
"""
return FlagName(core.BNGetArchitectureFlagName(self.handle, flag))
- def get_reg_index(self, reg:RegisterType) -> RegisterIndex:
+ def get_reg_index(self, reg: RegisterType) -> RegisterIndex:
if isinstance(reg, str):
try:
index = self.regs[reg].index
@@ -1452,7 +1486,7 @@ class Architecture(metaclass=_ArchitectureMetaClass):
return RegisterIndex(reg)
raise Exception("Attempting to get register index of non-existant register")
- def get_reg_stack_index(self, reg_stack:RegisterStackType) -> RegisterStackIndex:
+ def get_reg_stack_index(self, reg_stack: RegisterStackType) -> RegisterStackIndex:
if isinstance(reg_stack, str):
reg_stack_info = self.reg_stacks[reg_stack]
if reg_stack_info is not None and reg_stack_info.index is not None:
@@ -1463,7 +1497,7 @@ class Architecture(metaclass=_ArchitectureMetaClass):
return RegisterStackIndex(reg_stack)
raise Exception("reg_stack is not convertable to index")
- def get_flag_index(self, flag:FlagType) -> FlagIndex:
+ def get_flag_index(self, flag: FlagType) -> FlagIndex:
if isinstance(flag, str):
return self._flags[FlagName(flag)]
elif isinstance(flag, lowlevelil.ILFlag):
@@ -1472,7 +1506,7 @@ class Architecture(metaclass=_ArchitectureMetaClass):
return FlagIndex(flag)
raise Exception("flag is not convertable to index")
- def get_semantic_flag_class_index(self, sem_class:Optional[SemanticClassType]) -> SemanticClassIndex:
+ def get_semantic_flag_class_index(self, sem_class: Optional[SemanticClassType]) -> SemanticClassIndex:
if sem_class is None:
return SemanticClassIndex(0)
if isinstance(sem_class, str):
@@ -1483,7 +1517,7 @@ class Architecture(metaclass=_ArchitectureMetaClass):
return SemanticClassIndex(sem_class)
raise Exception("sem_class is not convertable to index")
- def get_semantic_flag_class_name(self, class_index:SemanticClassIndex) -> SemanticClassName:
+ def get_semantic_flag_class_name(self, class_index: SemanticClassIndex) -> SemanticClassName:
"""
``get_semantic_flag_class_name`` gets the name of a semantic flag class from the index.
@@ -1495,14 +1529,14 @@ class Architecture(metaclass=_ArchitectureMetaClass):
raise ValueError("argument 'class_index' must be an integer")
return self._semantic_flag_classes_by_index[class_index]
- def get_semantic_flag_group_index(self, sem_group:SemanticGroupType) -> SemanticGroupIndex:
+ def get_semantic_flag_group_index(self, sem_group: SemanticGroupType) -> SemanticGroupIndex:
if isinstance(sem_group, str):
return self._semantic_flag_groups[SemanticGroupName(sem_group)]
elif isinstance(sem_group, lowlevelil.ILSemanticFlagGroup):
return sem_group.index
return sem_group
- def get_semantic_flag_group_name(self, group_index:SemanticGroupIndex) -> SemanticGroupName:
+ def get_semantic_flag_group_name(self, group_index: SemanticGroupIndex) -> SemanticGroupName:
"""
``get_semantic_flag_group_name`` gets the name of a semantic flag group from the index.
@@ -1514,7 +1548,7 @@ class Architecture(metaclass=_ArchitectureMetaClass):
raise ValueError("argument 'group_index' must be an integer")
return self._semantic_flag_groups_by_index[group_index]
- def get_intrinsic_name(self, intrinsic:IntrinsicIndex) -> IntrinsicName:
+ def get_intrinsic_name(self, intrinsic: IntrinsicIndex) -> IntrinsicName:
"""
``get_intrinsic_name`` gets an intrinsic name from an intrinsic number.
@@ -1524,7 +1558,7 @@ class Architecture(metaclass=_ArchitectureMetaClass):
"""
return IntrinsicName(core.BNGetArchitectureIntrinsicName(self.handle, intrinsic))
- def get_intrinsic_index(self, intrinsic:IntrinsicType) -> IntrinsicIndex:
+ def get_intrinsic_index(self, intrinsic: IntrinsicType) -> IntrinsicIndex:
"""
``get_intrinsic_index`` gets an intrinsic index given an IntrinsicType.
@@ -1540,7 +1574,7 @@ class Architecture(metaclass=_ArchitectureMetaClass):
return IntrinsicIndex(intrinsic)
raise Exception("intrinsic is not convertable to index")
- def get_flag_write_type_name(self, write_type:FlagWriteTypeIndex) -> FlagWriteTypeName:
+ def get_flag_write_type_name(self, write_type: FlagWriteTypeIndex) -> FlagWriteTypeName:
"""
``get_flag_write_type_name`` gets the flag write type name for the given flag.
@@ -1550,7 +1584,7 @@ class Architecture(metaclass=_ArchitectureMetaClass):
"""
return FlagWriteTypeName(core.BNGetArchitectureFlagWriteTypeName(self.handle, write_type))
- def get_flag_by_name(self, flag:FlagName) -> FlagIndex:
+ def get_flag_by_name(self, flag: FlagName) -> FlagIndex:
"""
``get_flag_by_name`` get flag name for flag index.
@@ -1560,7 +1594,7 @@ class Architecture(metaclass=_ArchitectureMetaClass):
"""
return self._flags[flag]
- def get_flag_write_type_by_name(self, write_type:FlagWriteTypeName) -> FlagWriteTypeIndex:
+ def get_flag_write_type_by_name(self, write_type: FlagWriteTypeName) -> FlagWriteTypeIndex:
"""
``get_flag_write_type_by_name`` gets the flag write type name for the flag write type.
@@ -1570,7 +1604,7 @@ class Architecture(metaclass=_ArchitectureMetaClass):
"""
return self._flag_write_types[write_type]
- def get_semantic_flag_class_by_name(self, sem_class:SemanticClassName) -> SemanticClassIndex:
+ def get_semantic_flag_class_by_name(self, sem_class: SemanticClassName) -> SemanticClassIndex:
"""
``get_semantic_flag_class_by_name`` gets the semantic flag class index by name.
@@ -1580,7 +1614,7 @@ class Architecture(metaclass=_ArchitectureMetaClass):
"""
return self._semantic_flag_classes[sem_class]
- def get_semantic_flag_group_by_name(self, sem_group:SemanticGroupName) -> SemanticGroupIndex:
+ def get_semantic_flag_group_by_name(self, sem_group: SemanticGroupName) -> SemanticGroupIndex:
"""
``get_semantic_flag_group_by_name`` gets the semantic flag group index by name.
@@ -1590,7 +1624,7 @@ class Architecture(metaclass=_ArchitectureMetaClass):
"""
return self._semantic_flag_groups[sem_group]
- def get_flag_role(self, flag:FlagIndex, sem_class:Optional[SemanticClassIndex]= None) -> FlagRole:
+ def get_flag_role(self, flag: FlagIndex, sem_class: Optional[SemanticClassIndex] = None) -> FlagRole:
"""
``get_flag_role`` gets the role of a given flag.
@@ -1603,8 +1637,10 @@ class Architecture(metaclass=_ArchitectureMetaClass):
return self._flag_roles[flag]
return FlagRole.SpecialFlagRole
- def get_flag_write_low_level_il(self, op:LowLevelILOperation, size:int, write_type:Optional[FlagWriteTypeName], flag:FlagType,
- operands:List['lowlevelil.ILRegisterType'], il:'lowlevelil.LowLevelILFunction') -> 'lowlevelil.ExpressionIndex':
+ def get_flag_write_low_level_il(
+ self, op: LowLevelILOperation, size: int, write_type: Optional[FlagWriteTypeName], flag: FlagType,
+ operands: List['lowlevelil.ILRegisterType'], il: 'lowlevelil.LowLevelILFunction'
+ ) -> 'lowlevelil.ExpressionIndex':
"""
:param LowLevelILOperation op:
:param int size:
@@ -1620,8 +1656,10 @@ class Architecture(metaclass=_ArchitectureMetaClass):
return il.unimplemented()
return self.get_default_flag_write_low_level_il(op, size, self._flag_roles[flag], operands, il)
- def get_default_flag_write_low_level_il(self, op:'lowlevelil.LowLevelILOperation', size:int, role:FlagRole,
- operands:List['lowlevelil.ILRegisterType'], il:'lowlevelil.LowLevelILFunction') -> 'lowlevelil.ExpressionIndex':
+ def get_default_flag_write_low_level_il(
+ self, op: 'lowlevelil.LowLevelILOperation', size: int, role: FlagRole,
+ operands: List['lowlevelil.ILRegisterType'], il: 'lowlevelil.LowLevelILFunction'
+ ) -> 'lowlevelil.ExpressionIndex':
"""
:param LowLevelILOperation op:
:param int size:
@@ -1643,11 +1681,16 @@ class Architecture(metaclass=_ArchitectureMetaClass):
else:
operand_list[i].constant = True
operand_list[i].value = operand
- return lowlevelil.ExpressionIndex(core.BNGetDefaultArchitectureFlagWriteLowLevelIL(self.handle, op, size,
- role, operand_list, len(operand_list), il.handle))
+ return lowlevelil.ExpressionIndex(
+ core.BNGetDefaultArchitectureFlagWriteLowLevelIL(
+ self.handle, op, size, role, operand_list, len(operand_list), il.handle
+ )
+ )
- def get_flag_condition_low_level_il(self, cond:'lowlevelil.LowLevelILFlagCondition', sem_class:Optional[SemanticClassType],
- il:'lowlevelil.LowLevelILFunction') -> 'lowlevelil.ExpressionIndex':
+ def get_flag_condition_low_level_il(
+ self, cond: 'lowlevelil.LowLevelILFlagCondition', sem_class: Optional[SemanticClassType],
+ il: 'lowlevelil.LowLevelILFunction'
+ ) -> 'lowlevelil.ExpressionIndex':
"""
:param LowLevelILFlagCondition cond: Flag condition to be computed
:param SemanticClassType sem_class: Semantic class to be used (None for default semantics)
@@ -1656,8 +1699,10 @@ class Architecture(metaclass=_ArchitectureMetaClass):
"""
return self.get_default_flag_condition_low_level_il(cond, sem_class, il)
- def get_default_flag_condition_low_level_il(self, cond:'lowlevelil.LowLevelILFlagCondition',
- sem_class:Optional[SemanticClassType], il:'lowlevelil.LowLevelILFunction') -> 'lowlevelil.ExpressionIndex':
+ def get_default_flag_condition_low_level_il(
+ self, cond: 'lowlevelil.LowLevelILFlagCondition', sem_class: Optional[SemanticClassType],
+ il: 'lowlevelil.LowLevelILFunction'
+ ) -> 'lowlevelil.ExpressionIndex':
"""
:param LowLevelILFlagCondition cond:
:param SemanticClassType sem_class:
@@ -1666,11 +1711,13 @@ class Architecture(metaclass=_ArchitectureMetaClass):
"""
_class_index = None
_class_index = self.get_semantic_flag_class_index(sem_class)
- return lowlevelil.ExpressionIndex(core.BNGetDefaultArchitectureFlagConditionLowLevelIL(self.handle, cond,
- _class_index, il.handle))
+ return lowlevelil.ExpressionIndex(
+ core.BNGetDefaultArchitectureFlagConditionLowLevelIL(self.handle, cond, _class_index, il.handle)
+ )
- def get_semantic_flag_group_low_level_il(self, sem_group:Optional[SemanticGroupType],
- il:'lowlevelil.LowLevelILFunction') -> 'lowlevelil.ExpressionIndex':
+ def get_semantic_flag_group_low_level_il(
+ self, sem_group: Optional[SemanticGroupType], il: 'lowlevelil.LowLevelILFunction'
+ ) -> 'lowlevelil.ExpressionIndex':
"""
:param Optional[SemanticGroupType] sem_group:
:param LowLevelILFunction il:
@@ -1678,13 +1725,14 @@ class Architecture(metaclass=_ArchitectureMetaClass):
"""
return il.unimplemented()
- def get_flags_required_for_flag_condition(self, cond:'lowlevelil.LowLevelILFlagCondition',
- sem_class:Optional[SemanticClassType]=None):
+ def get_flags_required_for_flag_condition(
+ self, cond: 'lowlevelil.LowLevelILFlagCondition', sem_class: Optional[SemanticClassType] = None
+ ):
if cond in self.flags_required_for_flag_condition:
return self.flags_required_for_flag_condition[cond]
return []
- def get_modified_regs_on_write(self, reg:RegisterName) -> List[RegisterName]:
+ def get_modified_regs_on_write(self, reg: RegisterName) -> List[RegisterName]:
"""
``get_modified_regs_on_write`` returns a list of register names that are modified when ``reg`` is written.
@@ -1696,13 +1744,13 @@ class Architecture(metaclass=_ArchitectureMetaClass):
count = ctypes.c_ulonglong()
regs = core.BNGetModifiedArchitectureRegistersOnWrite(self.handle, reg, count)
assert regs is not None, "core.BNGetModifiedArchitectureRegistersOnWrite is not None"
- result:List[RegisterName] = []
+ result: List[RegisterName] = []
for i in range(0, count.value):
result.append(RegisterName(core.BNGetArchitectureRegisterName(self.handle, regs[i])))
core.BNFreeRegisterList(regs)
return result
- def assemble(self, code:str, addr:int=0) -> bytes:
+ def assemble(self, code: str, addr: int = 0) -> bytes:
"""
``assemble`` converts the string of assembly instructions ``code`` loaded at virtual address ``addr`` to the
byte representation of those instructions.
@@ -1729,7 +1777,7 @@ class Architecture(metaclass=_ArchitectureMetaClass):
"""
return NotImplemented
- def is_never_branch_patch_available(self, data:bytes, addr:int=0) -> bool:
+ def is_never_branch_patch_available(self, data: bytes, addr: int = 0) -> bool:
"""
``is_never_branch_patch_available`` determines if the instruction ``data`` at ``addr`` can be made to **never branch**.
@@ -1749,7 +1797,7 @@ class Architecture(metaclass=_ArchitectureMetaClass):
"""
return NotImplemented
- def is_always_branch_patch_available(self, data:bytes, addr:int=0) -> bool:
+ def is_always_branch_patch_available(self, data: bytes, addr: int = 0) -> bool:
"""
``is_always_branch_patch_available`` determines if the instruction ``data`` at ``addr`` can be made to
**always branch**.
@@ -1770,7 +1818,7 @@ class Architecture(metaclass=_ArchitectureMetaClass):
"""
return NotImplemented
- def is_invert_branch_patch_available(self, data:bytes, addr:int=0) -> bool:
+ def is_invert_branch_patch_available(self, data: bytes, addr: int = 0) -> bool:
"""
``is_always_branch_patch_available`` determines if the instruction ``data`` at ``addr`` can be inverted.
@@ -1790,7 +1838,7 @@ class Architecture(metaclass=_ArchitectureMetaClass):
"""
return NotImplemented
- def is_skip_and_return_zero_patch_available(self, data:bytes, addr:int=0) -> bool:
+ def is_skip_and_return_zero_patch_available(self, data: bytes, addr: int = 0) -> bool:
"""
``is_skip_and_return_zero_patch_available`` determines if the instruction ``data`` at ``addr`` is a *call-like*
instruction that can be made into an instruction *returns zero*.
@@ -1813,7 +1861,7 @@ class Architecture(metaclass=_ArchitectureMetaClass):
"""
return NotImplemented
- def is_skip_and_return_value_patch_available(self, data:bytes, addr:int=0) -> bool:
+ def is_skip_and_return_value_patch_available(self, data: bytes, addr: int = 0) -> bool:
"""
``is_skip_and_return_value_patch_available`` determines if the instruction ``data`` at ``addr`` is a *call-like*
instruction that can be made into an instruction *returns a value*.
@@ -1834,7 +1882,7 @@ class Architecture(metaclass=_ArchitectureMetaClass):
"""
return NotImplemented
- def convert_to_nop(self, data:bytes, addr:int=0) -> Optional[bytes]:
+ def convert_to_nop(self, data: bytes, addr: int = 0) -> Optional[bytes]:
"""
``convert_to_nop`` reads the instruction(s) in ``data`` at virtual address ``addr`` and returns a string of nop
instructions of the same length as data.
@@ -1853,7 +1901,7 @@ class Architecture(metaclass=_ArchitectureMetaClass):
"""
return NotImplemented
- def always_branch(self, data:bytes, addr:int=0) -> Optional[bytes]:
+ def always_branch(self, data: bytes, addr: int = 0) -> Optional[bytes]:
"""
``always_branch`` reads the instruction(s) in ``data`` at virtual address ``addr`` and returns a string of bytes
of the same length which always branches.
@@ -1875,7 +1923,7 @@ class Architecture(metaclass=_ArchitectureMetaClass):
"""
return NotImplemented
- def invert_branch(self, data:bytes, addr:int=0) -> Optional[bytes]:
+ def invert_branch(self, data: bytes, addr: int = 0) -> Optional[bytes]:
"""
``invert_branch`` reads the instruction(s) in ``data`` at virtual address ``addr`` and returns a string of bytes
of the same length which inverts the branch of provided instruction.
@@ -1898,7 +1946,7 @@ class Architecture(metaclass=_ArchitectureMetaClass):
"""
return NotImplemented
- def skip_and_return_value(self, data:bytes, addr:int, value:int) -> Optional[bytes]:
+ def skip_and_return_value(self, data: bytes, addr: int, value: int) -> Optional[bytes]:
"""
``skip_and_return_value`` reads the instruction(s) in ``data`` at virtual address ``addr`` and returns a string of
bytes of the same length which doesn't call and instead *return a value*.
@@ -1917,7 +1965,7 @@ class Architecture(metaclass=_ArchitectureMetaClass):
"""
return NotImplemented
- def is_view_type_constant_defined(self, type_name:str, const_name:str) -> bool:
+ def is_view_type_constant_defined(self, type_name: str, const_name: str) -> bool:
"""
:param str type_name: the BinaryView type name of the constant to query
@@ -1935,7 +1983,7 @@ class Architecture(metaclass=_ArchitectureMetaClass):
"""
return core.BNIsBinaryViewTypeArchitectureConstantDefined(self.handle, type_name, const_name)
- def get_view_type_constant(self, type_name:str, const_name:str, default_value:int=0) -> int:
+ def get_view_type_constant(self, type_name: str, const_name: str, default_value: int = 0) -> int:
"""
``get_view_type_constant`` retrieves the view type constant for the given type_name and const_name.
@@ -1955,7 +2003,7 @@ class Architecture(metaclass=_ArchitectureMetaClass):
"""
return core.BNGetBinaryViewTypeArchitectureConstant(self.handle, type_name, const_name, default_value)
- def set_view_type_constant(self, type_name:str, const_name:str, value:int) -> None:
+ def set_view_type_constant(self, type_name: str, const_name: str, value: int) -> None:
"""
``set_view_type_constant`` creates a new binaryview type constant.
@@ -1971,7 +2019,7 @@ class Architecture(metaclass=_ArchitectureMetaClass):
"""
core.BNSetBinaryViewTypeArchitectureConstant(self.handle, type_name, const_name, value)
- def register_calling_convention(self, cc:'callingconvention.CallingConvention') -> None:
+ def register_calling_convention(self, cc: 'callingconvention.CallingConvention') -> None:
"""
``register_calling_convention`` registers a new calling convention for the Architecture.
@@ -1982,8 +2030,10 @@ class Architecture(metaclass=_ArchitectureMetaClass):
_architecture_cache = {}
+
+
class CoreArchitecture(Architecture):
- def __init__(self, handle:core.BNArchitecture):
+ def __init__(self, handle: core.BNArchitecture):
super(CoreArchitecture, self).__init__()
self.handle = core.handle_of_type(handle, core.BNArchitecture)
@@ -1994,8 +2044,9 @@ class CoreArchitecture(Architecture):
self.instr_alignment = core.BNGetArchitectureInstructionAlignment(self.handle)
self.max_instr_length = core.BNGetArchitectureMaxInstructionLength(self.handle)
self.opcode_display_length = core.BNGetArchitectureOpcodeDisplayLength(self.handle)
- self.stack_pointer:str = core.BNGetArchitectureRegisterName(self.handle,
- core.BNGetArchitectureStackPointerRegister(self.handle))
+ self.stack_pointer: str = core.BNGetArchitectureRegisterName(
+ self.handle, core.BNGetArchitectureStackPointerRegister(self.handle)
+ )
link_reg = core.BNGetArchitectureLinkRegister(self.handle)
if link_reg == 0xffffffff:
@@ -2015,8 +2066,9 @@ class CoreArchitecture(Architecture):
assert name is not None, ""
info = core.BNGetArchitectureRegisterInfo(self.handle, regs[i])
full_width_reg = RegisterName(core.BNGetArchitectureRegisterName(self.handle, info.fullWidthRegister))
- self.regs[name] = RegisterInfo(full_width_reg, info.size, info.offset,
- ImplicitRegisterExtend(info.extend), regs[i])
+ self.regs[name] = RegisterInfo(
+ full_width_reg, info.size, info.offset, ImplicitRegisterExtend(info.extend), regs[i]
+ )
self._all_regs[name] = regs[i]
self._regs_by_index[regs[i]] = name
for i in range(0, count.value):
@@ -2042,7 +2094,7 @@ class CoreArchitecture(Architecture):
count = ctypes.c_ulonglong()
write_types = core.BNGetAllArchitectureFlagWriteTypes(self.handle, count)
assert write_types is not None, "core.BNGetAllArchitectureFlagWriteTypes returned None"
- self._flag_write_types:Dict[str, FlagWriteTypeIndex] = {}
+ self._flag_write_types: Dict[str, FlagWriteTypeIndex] = {}
self._flag_write_types_by_index = {}
self.flag_write_types = []
for i in range(0, count.value):
@@ -2054,7 +2106,7 @@ class CoreArchitecture(Architecture):
count = ctypes.c_ulonglong()
sem_classes = core.BNGetAllArchitectureSemanticFlagClasses(self.handle, count)
- assert sem_classes is not None,"core.BNGetAllArchitectureSemanticFlagClasses returned None"
+ assert sem_classes is not None, "core.BNGetAllArchitectureSemanticFlagClasses returned None"
self._semantic_flag_classes = {}
self._semantic_flag_classes_by_index = {}
self.semantic_flag_classes = []
@@ -2067,7 +2119,7 @@ class CoreArchitecture(Architecture):
count = ctypes.c_ulonglong()
sem_groups = core.BNGetAllArchitectureSemanticFlagGroups(self.handle, count)
- assert sem_groups is not None,"core.BNGetAllArchitectureSemanticFlagGroups returned Non"
+ assert sem_groups is not None, "core.BNGetAllArchitectureSemanticFlagGroups returned Non"
self._semantic_flag_groups = {}
self._semantic_flag_groups_by_index = {}
self.semantic_flag_groups = []
@@ -2085,7 +2137,7 @@ class CoreArchitecture(Architecture):
self.flag_roles[flag] = role
self._flag_roles[self._flags[flag]] = role
- self.flags_required_for_flag_condition:Dict[LowLevelILFlagCondition, List[FlagName]] = {}
+ self.flags_required_for_flag_condition: Dict[LowLevelILFlagCondition, List[FlagName]] = {}
for cond in LowLevelILFlagCondition:
count = ctypes.c_ulonglong()
flags = core.BNGetArchitectureFlagsRequiredForFlagCondition(self.handle, cond, 0, count)
@@ -2100,8 +2152,9 @@ class CoreArchitecture(Architecture):
self.flags_required_for_semantic_flag_group = {}
for group in self.semantic_flag_groups:
count = ctypes.c_ulonglong()
- flags = core.BNGetArchitectureFlagsRequiredForSemanticFlagGroup(self.handle,
- self._semantic_flag_groups[group], count)
+ flags = core.BNGetArchitectureFlagsRequiredForSemanticFlagGroup(
+ self.handle, self._semantic_flag_groups[group], count
+ )
assert flags is not None, "core.BNGetArchitectureFlagsRequiredForSemanticFlagGroup returned None"
flag_indexes = []
flag_names = []
@@ -2116,8 +2169,9 @@ class CoreArchitecture(Architecture):
self.flag_conditions_for_semantic_flag_group = {}
for group in self.semantic_flag_groups:
count = ctypes.c_ulonglong()
- conditions = core.BNGetArchitectureFlagConditionsForSemanticFlagGroup(self.handle,
- self._semantic_flag_groups[group], count)
+ conditions = core.BNGetArchitectureFlagConditionsForSemanticFlagGroup(
+ self.handle, self._semantic_flag_groups[group], count
+ )
assert conditions is not None, "core.BNGetArchitectureFlagConditionsForSemanticFlagGroup returned None"
class_index_cond = {}
class_cond = {}
@@ -2126,7 +2180,8 @@ class CoreArchitecture(Architecture):
if conditions[i].semanticClass == 0:
class_cond[None] = conditions[i].condition
elif conditions[i].semanticClass in self._semantic_flag_classes_by_index:
- class_cond[self._semantic_flag_classes_by_index[conditions[i].semanticClass]] = conditions[i].condition
+ class_cond[self._semantic_flag_classes_by_index[conditions[i].semanticClass]
+ ] = conditions[i].condition
core.BNFreeFlagConditionsForSemanticFlagGroup(conditions)
self._flag_conditions_for_semantic_flag_group[self._semantic_flag_groups[group]] = class_index_cond
self.flag_conditions_for_semantic_flag_group[group] = class_cond
@@ -2135,8 +2190,9 @@ class CoreArchitecture(Architecture):
self.flags_written_by_flag_write_type = {}
for write_type in self.flag_write_types:
count = ctypes.c_ulonglong()
- flags = core.BNGetArchitectureFlagsWrittenByFlagWriteType(self.handle,
- self._flag_write_types[write_type], count)
+ flags = core.BNGetArchitectureFlagsWrittenByFlagWriteType(
+ self.handle, self._flag_write_types[write_type], count
+ )
assert flags is not None, "core.BNGetArchitectureFlagsWrittenByFlagWriteType returned None"
flag_indexes = []
flag_names = []
@@ -2150,8 +2206,9 @@ class CoreArchitecture(Architecture):
self._semantic_class_for_flag_write_type = {}
self.semantic_class_for_flag_write_type = {}
for write_type in self.flag_write_types:
- sem_class = core.BNGetArchitectureSemanticClassForFlagWriteType(self.handle,
- self._flag_write_types[write_type])
+ sem_class = core.BNGetArchitectureSemanticClassForFlagWriteType(
+ self.handle, self._flag_write_types[write_type]
+ )
if sem_class == 0:
sem_class_name = None
else:
@@ -2162,14 +2219,14 @@ class CoreArchitecture(Architecture):
count = ctypes.c_ulonglong()
regs = core.BNGetArchitectureGlobalRegisters(self.handle, count)
assert regs is not None, "core.BNGetArchitectureGlobalRegisters returned None"
- self.global_regs:List[RegisterName] = []
+ self.global_regs: List[RegisterName] = []
for i in range(0, count.value):
self.global_regs.append(RegisterName(core.BNGetArchitectureRegisterName(self.handle, regs[i])))
core.BNFreeRegisterList(regs)
count = ctypes.c_ulonglong()
regs = core.BNGetArchitectureSystemRegisters(self.handle, count)
- self.system_regs:List[RegisterName] = []
+ self.system_regs: List[RegisterName] = []
for i in range(0, count.value):
assert regs is not None, "core.BNGetArchitectureSystemRegisters returned None"
self.system_regs.append(RegisterName(core.BNGetArchitectureRegisterName(self.handle, regs[i])))
@@ -2184,10 +2241,10 @@ class CoreArchitecture(Architecture):
for i in range(0, count.value):
name = RegisterStackName(core.BNGetArchitectureRegisterStackName(self.handle, regs[i]))
info = core.BNGetArchitectureRegisterStackInfo(self.handle, regs[i])
- storage:List[RegisterName] = []
+ storage: List[RegisterName] = []
for j in range(0, info.storageCount):
storage.append(RegisterName(core.BNGetArchitectureRegisterName(self.handle, info.firstStorageReg + j)))
- top_rel:List[RegisterName] = []
+ top_rel: List[RegisterName] = []
for j in range(0, info.topRelativeCount):
reg_name = RegisterName(core.BNGetArchitectureRegisterName(self.handle, info.firstTopRelativeReg + j))
top_rel.append(reg_name)
@@ -2200,9 +2257,9 @@ class CoreArchitecture(Architecture):
count = ctypes.c_ulonglong()
intrinsics = core.BNGetAllArchitectureIntrinsics(self.handle, count)
assert intrinsics is not None, "core.BNGetAllArchitectureIntrinsics returned None"
- self._intrinsics:Dict[IntrinsicName, IntrinsicIndex] = {}
- self._intrinsics_by_index:Dict[IntrinsicIndex, Tuple[IntrinsicName, IntrinsicInfo]] = {}
- self._intrinsics_info:Dict[IntrinsicName, IntrinsicInfo] = {}
+ self._intrinsics: Dict[IntrinsicName, IntrinsicIndex] = {}
+ self._intrinsics_by_index: Dict[IntrinsicIndex, Tuple[IntrinsicName, IntrinsicInfo]] = {}
+ self._intrinsics_info: Dict[IntrinsicName, IntrinsicInfo] = {}
for i in range(count.value):
name = IntrinsicName(core.BNGetArchitectureIntrinsicName(self.handle, intrinsics[i]))
input_count = ctypes.c_ulonglong()
@@ -2211,7 +2268,9 @@ class CoreArchitecture(Architecture):
input_list = []
for j in range(0, input_count.value):
input_name = inputs[j].name
- type_obj = types.Type.create(core.BNNewTypeReference(inputs[j].type), confidence = inputs[j].typeConfidence)
+ type_obj = types.Type.create(
+ core.BNNewTypeReference(inputs[j].type), confidence=inputs[j].typeConfidence
+ )
input_list.append(IntrinsicInput(type_obj, input_name))
core.BNFreeNameAndTypeList(inputs, input_count.value)
output_count = ctypes.c_ulonglong()
@@ -2219,7 +2278,9 @@ class CoreArchitecture(Architecture):
assert outputs is not None, "core.BNGetArchitectureIntrinsicOutputs returned None"
output_list = []
for j in range(output_count.value):
- output_list.append(types.Type.create(core.BNNewTypeReference(outputs[j].type), confidence = outputs[j].confidence))
+ output_list.append(
+ types.Type.create(core.BNNewTypeReference(outputs[j].type), confidence=outputs[j].confidence)
+ )
core.BNFreeOutputTypeList(outputs, output_count.value)
self._intrinsics_info[name] = IntrinsicInfo(input_list, output_list)
self._intrinsics[name] = intrinsics[i]
@@ -2234,13 +2295,13 @@ class CoreArchitecture(Architecture):
global _architecture_cache
return _architecture_cache.get(ctypes.addressof(handle.contents)) or cls(handle)
- def get_associated_arch_by_address(self, addr:int) -> Tuple['Architecture', int]:
+ def get_associated_arch_by_address(self, addr: int) -> Tuple['Architecture', int]:
new_addr = ctypes.c_ulonglong()
new_addr.value = addr
result = core.BNGetAssociatedArchitectureByAddress(self.handle, new_addr)
- return CoreArchitecture._from_cache(handle = result), new_addr.value
+ return CoreArchitecture._from_cache(handle=result), new_addr.value
- def get_instruction_info(self, data:bytes, addr:int) -> Optional[InstructionInfo]:
+ def get_instruction_info(self, data: bytes, addr: int) -> Optional[InstructionInfo]:
"""
``get_instruction_info`` returns an InstructionInfo object for the instruction at the given virtual address
``addr`` with data ``data``.
@@ -2271,7 +2332,7 @@ class CoreArchitecture(Architecture):
result.add_branch(BranchType(info.branchType[i]), target, arch)
return result
- def get_instruction_text(self, data:bytes, addr:int) -> Tuple[List['function.InstructionTextToken'], int]:
+ def get_instruction_text(self, data: bytes, addr: int) -> Tuple[List['function.InstructionTextToken'], int]:
"""
``get_instruction_text`` returns a list of InstructionTextToken objects for the instruction at the given virtual
address ``addr`` with data ``data``.
@@ -2295,7 +2356,7 @@ class CoreArchitecture(Architecture):
core.BNFreeInstructionText(tokens, count.value)
return result, result_length
- def get_instruction_low_level_il(self, data:bytes, addr:int, il:lowlevelil.LowLevelILFunction) -> Optional[int]:
+ def get_instruction_low_level_il(self, data: bytes, addr: int, il: lowlevelil.LowLevelILFunction) -> Optional[int]:
"""
``get_instruction_low_level_il`` appends lowlevelil.ExpressionIndex objects to ``il`` for the instruction at the given
virtual address ``addr`` with data ``data``.
@@ -2317,8 +2378,10 @@ class CoreArchitecture(Architecture):
return length.value
return None
- def get_flag_write_low_level_il(self, op:LowLevelILOperation, size:int, write_type:FlagWriteTypeName,
- flag:FlagType, operands:List['lowlevelil.ILRegisterType'], il:'lowlevelil.LowLevelILFunction') -> 'lowlevelil.ExpressionIndex':
+ def get_flag_write_low_level_il(
+ self, op: LowLevelILOperation, size: int, write_type: FlagWriteTypeName, flag: FlagType,
+ operands: List['lowlevelil.ILRegisterType'], il: 'lowlevelil.LowLevelILFunction'
+ ) -> 'lowlevelil.ExpressionIndex':
"""
:param LowLevelILOperation op:
:param int size:
@@ -2341,11 +2404,16 @@ class CoreArchitecture(Architecture):
else:
operand_list[i].constant = True
operand_list[i].value = operand
- return lowlevelil.ExpressionIndex(core.BNGetArchitectureFlagWriteLowLevelIL(self.handle, op, size,
- self._flag_write_types[write_type], flag, operand_list, len(operand_list), il.handle))
+ return lowlevelil.ExpressionIndex(
+ core.BNGetArchitectureFlagWriteLowLevelIL(
+ self.handle, op, size, self._flag_write_types[write_type], flag, operand_list, len(operand_list),
+ il.handle
+ )
+ )
- def get_flag_condition_low_level_il(self, cond:LowLevelILFlagCondition, sem_class:SemanticClassType,
- il:'lowlevelil.LowLevelILFunction') -> 'lowlevelil.ExpressionIndex':
+ def get_flag_condition_low_level_il(
+ self, cond: LowLevelILFlagCondition, sem_class: SemanticClassType, il: 'lowlevelil.LowLevelILFunction'
+ ) -> 'lowlevelil.ExpressionIndex':
"""
:param LowLevelILFlagCondition cond: Flag condition to be computed
:param str sem_class: Semantic class to be used (None for default semantics)
@@ -2353,20 +2421,24 @@ class CoreArchitecture(Architecture):
:rtype: ExpressionIndex
"""
class_index = self.get_semantic_flag_class_index(sem_class)
- return lowlevelil.ExpressionIndex(core.BNGetArchitectureFlagConditionLowLevelIL(self.handle, cond,
- class_index, il.handle))
+ return lowlevelil.ExpressionIndex(
+ core.BNGetArchitectureFlagConditionLowLevelIL(self.handle, cond, class_index, il.handle)
+ )
- def get_semantic_flag_group_low_level_il(self, sem_group:SemanticGroupName,
- il:'lowlevelil.LowLevelILFunction') -> 'lowlevelil.ExpressionIndex':
+ def get_semantic_flag_group_low_level_il(
+ self, sem_group: SemanticGroupName, il: 'lowlevelil.LowLevelILFunction'
+ ) -> 'lowlevelil.ExpressionIndex':
"""
:param str sem_group:
:param LowLevelILFunction il:
:rtype: ExpressionIndex
"""
group_index = self.get_semantic_flag_group_index(sem_group)
- return lowlevelil.ExpressionIndex(core.BNGetArchitectureSemanticFlagGroupLowLevelIL(self.handle, group_index, il.handle))
+ return lowlevelil.ExpressionIndex(
+ core.BNGetArchitectureSemanticFlagGroupLowLevelIL(self.handle, group_index, il.handle)
+ )
- def assemble(self, code:str, addr:int=0) -> bytes:
+ def assemble(self, code: str, addr: int = 0) -> bytes:
"""
``assemble`` converts the string of assembly instructions ``code`` loaded at virtual address ``addr`` to the
byte representation of those instructions.
@@ -2389,7 +2461,7 @@ class CoreArchitecture(Architecture):
raise ValueError(f"Could not assemble: {error_str}")
return bytes(result)
- def is_never_branch_patch_available(self, data:bytes, addr:int=0) -> bool:
+ def is_never_branch_patch_available(self, data: bytes, addr: int = 0) -> bool:
"""
``is_never_branch_patch_available`` determines if the instruction ``data`` at ``addr`` can be made to **never branch**.
@@ -2409,7 +2481,7 @@ class CoreArchitecture(Architecture):
ctypes.memmove(buf, data, len(data))
return core.BNIsArchitectureNeverBranchPatchAvailable(self.handle, buf, addr, len(data))
- def is_always_branch_patch_available(self, data:bytes, addr:int=0) -> bool:
+ def is_always_branch_patch_available(self, data: bytes, addr: int = 0) -> bool:
"""
``is_always_branch_patch_available`` determines if the instruction ``data`` at ``addr`` can be made to
**always branch**.
@@ -2430,7 +2502,7 @@ class CoreArchitecture(Architecture):
ctypes.memmove(buf, data, len(data))
return core.BNIsArchitectureAlwaysBranchPatchAvailable(self.handle, buf, addr, len(data))
- def is_invert_branch_patch_available(self, data:bytes, addr:int=0) -> bool:
+ def is_invert_branch_patch_available(self, data: bytes, addr: int = 0) -> bool:
"""
``is_always_branch_patch_available`` determines if the instruction ``data`` at ``addr`` can be inverted.
@@ -2450,7 +2522,7 @@ class CoreArchitecture(Architecture):
ctypes.memmove(buf, data, len(data))
return core.BNIsArchitectureInvertBranchPatchAvailable(self.handle, buf, addr, len(data))
- def is_skip_and_return_zero_patch_available(self, data:bytes, addr:int=0) -> bool:
+ def is_skip_and_return_zero_patch_available(self, data: bytes, addr: int = 0) -> bool:
"""
``is_skip_and_return_zero_patch_available`` determines if the instruction ``data`` at ``addr`` is a *call-like*
instruction that can be made into an instruction *returns zero*.
@@ -2473,7 +2545,7 @@ class CoreArchitecture(Architecture):
ctypes.memmove(buf, data, len(data))
return core.BNIsArchitectureSkipAndReturnZeroPatchAvailable(self.handle, buf, addr, len(data))
- def is_skip_and_return_value_patch_available(self, data:bytes, addr:int=0) -> bool:
+ def is_skip_and_return_value_patch_available(self, data: bytes, addr: int = 0) -> bool:
"""
``is_skip_and_return_value_patch_available`` determines if the instruction ``data`` at ``addr`` is a *call-like*
instruction that can be made into an instruction *returns a value*.
@@ -2494,7 +2566,7 @@ class CoreArchitecture(Architecture):
ctypes.memmove(buf, data, len(data))
return core.BNIsArchitectureSkipAndReturnValuePatchAvailable(self.handle, buf, addr, len(data))
- def convert_to_nop(self, data:bytes, addr:int=0) -> Optional[bytes]:
+ def convert_to_nop(self, data: bytes, addr: int = 0) -> Optional[bytes]:
"""
``convert_to_nop`` reads the instruction(s) in ``data`` at virtual address ``addr`` and returns a string of nop
instructions of the same length as data.
@@ -2517,7 +2589,7 @@ class CoreArchitecture(Architecture):
ctypes.memmove(result, buf, len(data))
return result.raw
- def always_branch(self, data:bytes, addr:int=0) -> Optional[bytes]:
+ def always_branch(self, data: bytes, addr: int = 0) -> Optional[bytes]:
"""
``always_branch`` reads the instruction(s) in ``data`` at virtual address ``addr`` and returns a string of bytes
of the same length which always branches.
@@ -2543,7 +2615,7 @@ class CoreArchitecture(Architecture):
ctypes.memmove(result, buf, len(data))
return result.raw
- def invert_branch(self, data:bytes, addr:int=0) -> Optional[bytes]:
+ def invert_branch(self, data: bytes, addr: int = 0) -> Optional[bytes]:
"""
``invert_branch`` reads the instruction(s) in ``data`` at virtual address ``addr`` and returns a string of bytes
of the same length which inverts the branch of provided instruction.
@@ -2570,7 +2642,7 @@ class CoreArchitecture(Architecture):
ctypes.memmove(result, buf, len(data))
return result.raw
- def skip_and_return_value(self, data:bytes, addr:int, value:int) -> Optional[bytes]:
+ def skip_and_return_value(self, data: bytes, addr: int, value: int) -> Optional[bytes]:
"""
``skip_and_return_value`` reads the instruction(s) in ``data`` at virtual address ``addr`` and returns a string of
bytes of the same length which doesn't call and instead *return a value*.
@@ -2594,7 +2666,7 @@ class CoreArchitecture(Architecture):
ctypes.memmove(result, buf, len(data))
return result.raw
- def get_flag_role(self, flag:FlagIndex, sem_class:Optional[SemanticClassIndex]= None) -> FlagRole:
+ def get_flag_role(self, flag: FlagIndex, sem_class: Optional[SemanticClassIndex] = None) -> FlagRole:
"""
``get_flag_role`` gets the role of a given flag.
@@ -2607,8 +2679,9 @@ class CoreArchitecture(Architecture):
_sem_class = self.get_semantic_flag_class_index(sem_class)
return FlagRole(core.BNGetArchitectureFlagRole(self.handle, flag, _sem_class))
- def get_flags_required_for_flag_condition(self, cond:LowLevelILFlagCondition,
- sem_class:Optional[SemanticClassType]=None) -> List[FlagName]:
+ def get_flags_required_for_flag_condition(
+ self, cond: LowLevelILFlagCondition, sem_class: Optional[SemanticClassType] = None
+ ) -> List[FlagName]:
_sem_class = self.get_semantic_flag_class_index(sem_class)
count = ctypes.c_ulonglong()
flags = core.BNGetArchitectureFlagsRequiredForFlagCondition(self.handle, cond, _sem_class, count)
@@ -2621,7 +2694,7 @@ class CoreArchitecture(Architecture):
class ArchitectureHook(CoreArchitecture):
- def __init__(self, base_arch:'Architecture'):
+ def __init__(self, base_arch: 'Architecture'):
self._base_arch = base_arch
super(ArchitectureHook, self).__init__(base_arch.handle)
@@ -2659,9 +2732,10 @@ class ArchitectureHook(CoreArchitecture):
return self._base_arch
@base_arch.setter
- def base_arch(self, value:'Architecture') -> None:
+ def base_arch(self, value: 'Architecture') -> None:
self._base_arch = value
+
@dataclass
class InstructionTextToken:
"""
@@ -2711,24 +2785,25 @@ class InstructionTextToken:
========================== ============================================
"""
- type:Union[InstructionTextTokenType, int]
- text:str
- value:int = 0
- size:int = 0
- operand:int = 0xffffffff
- context:InstructionTextTokenContext = InstructionTextTokenContext.NoTokenContext
- address:int = 0
- confidence:int = core.max_confidence
- typeNames:List[str] = field(default_factory=list)
- width:int = 0
+ type: Union[InstructionTextTokenType, int]
+ text: str
+ value: int = 0
+ size: int = 0
+ operand: int = 0xffffffff
+ context: InstructionTextTokenContext = InstructionTextTokenContext.NoTokenContext
+ address: int = 0
+ confidence: int = core.max_confidence
+ typeNames: List[str] = field(default_factory=list)
+ width: int = 0
def __post_init__(self):
if self.width == 0:
self.width = len(self.text)
@staticmethod
- def _from_core_struct(tokens:'ctypes.pointer[core.BNInstructionTextToken]', count:int) -> List['InstructionTextToken']:
- result:List['InstructionTextToken'] = []
+ def _from_core_struct(tokens: 'ctypes.pointer[core.BNInstructionTextToken]',
+ count: int) -> List['InstructionTextToken']:
+ result: List['InstructionTextToken'] = []
for j in range(count):
token_type = InstructionTextTokenType(tokens[j].type)
text = tokens[j].text
@@ -2747,11 +2822,15 @@ class InstructionTextToken:
typeNames.append(tokens[j].typeNames[i].decode("utf-8"))
else:
typeNames.append(tokens[j].typeNames[i])
- result.append(InstructionTextToken(token_type, text, value, size, operand, context, address, confidence, typeNames, width))
+ result.append(
+ InstructionTextToken(
+ token_type, text, value, size, operand, context, address, confidence, typeNames, width
+ )
+ )
return result
@staticmethod
- def _get_core_struct(tokens:List['InstructionTextToken']) -> 'ctypes.Array[core.BNInstructionTextToken]':
+ def _get_core_struct(tokens: List['InstructionTextToken']) -> 'ctypes.Array[core.BNInstructionTextToken]':
""" Helper method for converting between core.BNInstructionTextToken and InstructionTextToken lists """
result = (core.BNInstructionTextToken * len(tokens))()
for j in range(len(tokens)):
diff --git a/python/associateddatastore.py b/python/associateddatastore.py
index 256437a0..66434d56 100644
--- a/python/associateddatastore.py
+++ b/python/associateddatastore.py
@@ -21,14 +21,15 @@
import copy
from typing import Any
+
class _AssociatedDataStore(dict):
_defaults = {}
@classmethod
- def set_default(cls, name:str, value:Any):
+ def set_default(cls, name: str, value: Any):
cls._defaults[name] = value
- def __getattr__(self, name:str) -> Any:
+ def __getattr__(self, name: str) -> Any:
if name in self.__dict__:
return self.__dict__[name]
if name not in self:
@@ -38,8 +39,8 @@ class _AssociatedDataStore(dict):
return result
return self.__getitem__(name)
- def __setattr__(self, name:str, value:Any):
+ def __setattr__(self, name: str, value: Any):
self.__setitem__(name, value)
- def __delattr__(self, name:str):
+ def __delattr__(self, name: str):
self.__delitem__(name)
diff --git a/python/basicblock.py b/python/basicblock.py
index d504933b..24f549d7 100644
--- a/python/basicblock.py
+++ b/python/basicblock.py
@@ -30,13 +30,14 @@ from . import architecture
from . import highlight as _highlight
from . import function as _function
+
@dataclass(frozen=True)
class BasicBlockEdge:
- type:BranchType
- source:'BasicBlock'
- target:'BasicBlock'
- back_edge:bool
- fall_through:bool
+ type: BranchType
+ source: 'BasicBlock'
+ target: 'BasicBlock'
+ back_edge: bool
+ fall_through: bool
def __repr__(self):
if self.type == BranchType.UnresolvedBranch:
@@ -48,14 +49,14 @@ class BasicBlockEdge:
class BasicBlock:
- def __init__(self, handle:core.BNBasicBlockHandle, view:Optional['binaryview.BinaryView']=None):
+ def __init__(self, handle: core.BNBasicBlockHandle, view: Optional['binaryview.BinaryView'] = None):
self._view = view
_handle = core.BNBasicBlockHandle
- self.handle:core.BNBasicBlockHandle = ctypes.cast(handle, _handle)
+ self.handle: core.BNBasicBlockHandle = ctypes.cast(handle, _handle)
self._arch = None
self._func = None
- self._instStarts:Optional[List[int]] = None
- self._instLengths:Optional[List[int]] = None
+ self._instStarts: Optional[List[int]] = None
+ self._instLengths: Optional[List[int]] = None
def __del__(self):
if core is not None:
@@ -129,7 +130,7 @@ class BasicBlock:
data = self.view.read(start, length)
return self.arch.get_instruction_text(data, start)
- def __contains__(self, i:int):
+ def __contains__(self, i: int):
return self.start <= i < self.end
def _buildStartCache(self) -> None:
@@ -142,13 +143,13 @@ class BasicBlock:
start = self.start
while start < self.end:
length = self.view.get_instruction_length(start, self.arch)
- if length == 0: # invalid instruction. avoid infinite loop
+ if length == 0: # invalid instruction. avoid infinite loop
break
self._instLengths.append(length)
self._instStarts.append(start)
start += length
- def _create_instance(self, handle:core.BNBasicBlockHandle, view:'binaryview.BinaryView') -> 'BasicBlock':
+ def _create_instance(self, handle: core.BNBasicBlockHandle, view: 'binaryview.BinaryView') -> 'BasicBlock':
"""Internal method used to instantiate child instances"""
return BasicBlock(handle, view)
@@ -220,12 +221,11 @@ class BasicBlock:
"""Basic block index in list of blocks for the function (read-only)"""
return core.BNGetBasicBlockIndex(self.handle)
-
- def _make_edges(self, edges, count:int, direction:bool) -> List[BasicBlockEdge]:
+ def _make_edges(self, edges, count: int, direction: bool) -> List[BasicBlockEdge]:
assert edges is not None, "Got empty edges list from core"
if self.view is None:
raise ValueError("Attempting to get BasicBlock edges when BinaryView is None")
- result:List[BasicBlockEdge] = []
+ result: List[BasicBlockEdge] = []
try:
for i in range(0, count):
branch_type = BranchType(edges[i].type)
@@ -241,7 +241,6 @@ class BasicBlock:
finally:
core.BNFreeBasicBlockEdgeList(edges, count)
-
@property
def outgoing_edges(self) -> List[BasicBlockEdge]:
"""List of basic block outgoing edges (read-only)"""
@@ -254,7 +253,6 @@ class BasicBlock:
count = ctypes.c_ulonglong(0)
return self._make_edges(core.BNGetBasicBlockIncomingEdges(self.handle, count), count.value, True)
-
@property
def has_undetermined_outgoing_edges(self) -> bool:
"""Whether basic block has undetermined outgoing edges (read-only)"""
@@ -266,7 +264,7 @@ class BasicBlock:
return core.BNBasicBlockCanExit(self.handle)
@can_exit.setter
- def can_exit(self, value:bool) -> None:
+ def can_exit(self, value: bool) -> None:
"""Sets whether basic block can return or is tagged as 'No Return'"""
core.BNBasicBlockSetCanExit(self.handle, value)
@@ -275,9 +273,9 @@ class BasicBlock:
"""Whether basic block has any invalid instructions (read-only)"""
return core.BNBasicBlockHasInvalidInstructions(self.handle)
- def _make_blocks(self, blocks, count:int) -> List['BasicBlock']:
+ def _make_blocks(self, blocks, count: int) -> List['BasicBlock']:
assert blocks is not None, "core returned empty block list"
- result:List['BasicBlock'] = []
+ result: List['BasicBlock'] = []
try:
for i in range(0, count):
handle = core.BNNewBasicBlockReference(blocks[i])
@@ -295,12 +293,11 @@ class BasicBlock:
count = ctypes.c_ulonglong()
return self._make_blocks(core.BNGetBasicBlockDominators(self.handle, count, False), count.value)
-
@property
def post_dominators(self) -> List['BasicBlock']:
"""List of dominators for this basic block (read-only)"""
if self.view is None:
- raise Exception("Attempting to call BasicBlock.post_dominators when BinaryView is None")
+ raise Exception("Attempting to call BasicBlock.post_dominators when BinaryView is None")
count = ctypes.c_ulonglong()
return self._make_blocks(core.BNGetBasicBlockDominators(self.handle, count, True), count.value)
@@ -403,7 +400,7 @@ class BasicBlock:
return _highlight.HighlightColor._from_core_struct(core.BNGetBasicBlockHighlight(self.handle))
@highlight.setter
- def highlight(self, value:'_highlight.HighlightColor') -> None:
+ def highlight(self, value: '_highlight.HighlightColor') -> None:
self.set_user_highlight(value)
@property
@@ -427,10 +424,10 @@ class BasicBlock:
return core.BNIsHighLevelILBasicBlock(self.handle)
@staticmethod
- def get_iterated_dominance_frontier(blocks:List['BasicBlock']) -> List['BasicBlock']:
+ def get_iterated_dominance_frontier(blocks: List['BasicBlock']) -> List['BasicBlock']:
if len(blocks) == 0:
return []
- block_set = (ctypes.POINTER(core.BNBasicBlock) * len(blocks))() # type: ignore
+ block_set = (ctypes.POINTER(core.BNBasicBlock) * len(blocks))() # type: ignore
for i in range(len(blocks)):
block_set[i] = blocks[i].handle
count = ctypes.c_ulonglong()
@@ -449,7 +446,8 @@ class BasicBlock:
def mark_recent_use(self) -> None:
core.BNMarkBasicBlockAsRecentlyUsed(self.handle)
- def get_disassembly_text(self, settings:'_function.DisassemblySettings'=None) -> List['_function.DisassemblyTextLine']:
+ def get_disassembly_text(self,
+ settings: '_function.DisassemblySettings' = None) -> List['_function.DisassemblyTextLine']:
"""
``get_disassembly_text`` returns a list of DisassemblyTextLine objects for the current basic block.
@@ -471,7 +469,7 @@ class BasicBlock:
for i in range(0, count.value):
addr = lines[i].addr
if (lines[i].instrIndex != 0xffffffffffffffff) and hasattr(self, 'il_function'):
- il_instr = self.il_function[lines[i].instrIndex] # type: ignore
+ il_instr = self.il_function[lines[i].instrIndex] # type: ignore
else:
il_instr = None
color = _highlight.HighlightColor._from_core_struct(lines[i].highlight)
@@ -481,7 +479,7 @@ class BasicBlock:
finally:
core.BNFreeDisassemblyTextLines(lines, count.value)
- def set_auto_highlight(self, color:'_highlight.HighlightColor') -> None:
+ def set_auto_highlight(self, color: '_highlight.HighlightColor') -> None:
"""
``set_auto_highlight`` highlights the current BasicBlock with the supplied color.
@@ -495,7 +493,7 @@ class BasicBlock:
color = _highlight.HighlightColor(color)
core.BNSetAutoBasicBlockHighlight(self.handle, color._to_core_struct())
- def set_user_highlight(self, color:'_highlight.HighlightColor') -> None:
+ def set_user_highlight(self, color: '_highlight.HighlightColor') -> None:
"""
``set_user_highlight`` highlights the current BasicBlock with the supplied color
@@ -511,7 +509,7 @@ class BasicBlock:
color = _highlight.HighlightColor(color)
core.BNSetUserBasicBlockHighlight(self.handle, color._to_core_struct())
- def get_instruction_containing_address(self, addr:int) -> Tuple[bool, int]:
+ def get_instruction_containing_address(self, addr: int) -> Tuple[bool, int]:
start = ctypes.c_uint64()
- ret:bool = core.BNGetBasicBlockInstructionContainingAddress(self.handle, addr, start)
+ ret: bool = core.BNGetBasicBlockInstructionContainingAddress(self.handle, addr, start)
return ret, start.value
diff --git a/python/binaryview.py b/python/binaryview.py
index acc437c7..ce9cca92 100644
--- a/python/binaryview.py
+++ b/python/binaryview.py
@@ -34,15 +34,14 @@ from dataclasses import dataclass
import collections
from collections import defaultdict, OrderedDict, deque
-
# Binary Ninja components
import binaryninja
from . import _binaryninjacore as core
-from .enums import (AnalysisState, SymbolType,
- Endianness, ModificationStatus, StringType, SegmentFlag, SectionSemantics, FindFlag,
- TypeClass, BinaryViewEventType, FunctionGraphType, TagReferenceType, TagTypeType,
- RegisterValueType)
-from . import associateddatastore # required for _BinaryViewAssociatedDataStore
+from .enums import (
+ AnalysisState, SymbolType, Endianness, ModificationStatus, StringType, SegmentFlag, SectionSemantics, FindFlag,
+ TypeClass, BinaryViewEventType, FunctionGraphType, TagReferenceType, TagTypeType, RegisterValueType
+)
+from . import associateddatastore # required for _BinaryViewAssociatedDataStore
from .log import log_error, log_warn
from . import typelibrary
from . import fileaccessor
@@ -67,7 +66,6 @@ from . import function as _function
from . import types as _types
from . import platform as _platform
-
PathType = Union[str, os.PathLike]
InstructionsType = Generator[Tuple[List['_function.InstructionTextToken'], int], None, None]
NotificationType = Mapping['BinaryDataNotification', 'BinaryDataNotificationCallbacks']
@@ -76,14 +74,16 @@ DataMatchCallbackType = Callable[[int, 'databuffer.DataBuffer'], bool]
LineMatchCallbackType = Callable[[int, 'lineardisassembly.LinearDisassemblyLine'], bool]
StringOrType = Union[str, '_types.Type', '_types.TypeBuilder']
+
class RelocationWriteException(Exception):
pass
+
@dataclass(frozen=True)
class ReferenceSource:
- function:Optional['_function.Function']
- arch:Optional['architecture.Architecture']
- address:int
+ function: Optional['_function.Function']
+ arch: Optional['architecture.Architecture']
+ address: int
def __repr__(self):
if self.arch:
@@ -92,7 +92,7 @@ class ReferenceSource:
return f"<ref: {self.address:#x}>"
@classmethod
- def _from_core_struct(cls, view:'BinaryView', ref:core.BNReferenceSource) -> 'ReferenceSource':
+ def _from_core_struct(cls, view: 'BinaryView', ref: core.BNReferenceSource) -> 'ReferenceSource':
if ref.func:
func = _function.Function(view, core.BNNewFunctionReference(ref.func))
else:
@@ -109,89 +109,95 @@ class BinaryDataNotification:
def __init__(self):
pass
- def data_written(self, view:'BinaryView', offset:int, length:int) -> None:
+ def data_written(self, view: 'BinaryView', offset: int, length: int) -> None:
pass
- def data_inserted(self, view:'BinaryView', offset:int, length:int) -> None:
+ def data_inserted(self, view: 'BinaryView', offset: int, length: int) -> None:
pass
- def data_removed(self, view:'BinaryView', offset:int, length:int) -> None:
+ def data_removed(self, view: 'BinaryView', offset: int, length: int) -> None:
pass
- def function_added(self, view:'BinaryView', func:'_function.Function') -> None:
+ def function_added(self, view: 'BinaryView', func: '_function.Function') -> None:
pass
- def function_removed(self, view:'BinaryView', func:'_function.Function') -> None:
+ def function_removed(self, view: 'BinaryView', func: '_function.Function') -> None:
pass
- def function_updated(self, view:'BinaryView', func:'_function.Function') -> None:
+ def function_updated(self, view: 'BinaryView', func: '_function.Function') -> None:
pass
- def function_update_requested(self, view:'BinaryView', func:'_function.Function') -> None:
+ def function_update_requested(self, view: 'BinaryView', func: '_function.Function') -> None:
pass
- def data_var_added(self, view:'BinaryView', var:'DataVariable') -> None:
+ def data_var_added(self, view: 'BinaryView', var: 'DataVariable') -> None:
pass
- def data_var_removed(self, view:'BinaryView', var:'DataVariable') -> None:
+ def data_var_removed(self, view: 'BinaryView', var: 'DataVariable') -> None:
pass
- def data_var_updated(self, view:'BinaryView', var:'DataVariable') -> None:
+ def data_var_updated(self, view: 'BinaryView', var: 'DataVariable') -> None:
pass
- def data_metadata_updated(self, view:'BinaryView', offset:int) -> None:
+ def data_metadata_updated(self, view: 'BinaryView', offset: int) -> None:
pass
- def tag_type_updated(self, view:'BinaryView', tag_type) -> None:
+ def tag_type_updated(self, view: 'BinaryView', tag_type) -> None:
pass
- def tag_added(self, view:'BinaryView', tag:'Tag', ref_type:TagReferenceType, auto_defined:bool,
- arch:Optional['architecture.Architecture'], func:Optional[_function.Function], addr:int) -> None:
+ def tag_added(
+ self, view: 'BinaryView', tag: 'Tag', ref_type: TagReferenceType, auto_defined: bool,
+ arch: Optional['architecture.Architecture'], func: Optional[_function.Function], addr: int
+ ) -> None:
pass
- def tag_updated(self, view:'BinaryView', tag:'Tag', ref_type:TagReferenceType, auto_defined:bool,
- arch:Optional['architecture.Architecture'], func:Optional[_function.Function], addr:int) -> None:
+ def tag_updated(
+ self, view: 'BinaryView', tag: 'Tag', ref_type: TagReferenceType, auto_defined: bool,
+ arch: Optional['architecture.Architecture'], func: Optional[_function.Function], addr: int
+ ) -> None:
pass
- def tag_removed(self, view:'BinaryView', tag:'Tag', ref_type:TagReferenceType, auto_defined:bool,
- arch:Optional['architecture.Architecture'], func:Optional[_function.Function], addr:int) -> None:
+ def tag_removed(
+ self, view: 'BinaryView', tag: 'Tag', ref_type: TagReferenceType, auto_defined: bool,
+ arch: Optional['architecture.Architecture'], func: Optional[_function.Function], addr: int
+ ) -> None:
pass
- def symbol_added(self, view:'BinaryView', sym:'_types.CoreSymbol') -> None:
+ def symbol_added(self, view: 'BinaryView', sym: '_types.CoreSymbol') -> None:
pass
- def symbol_updated(self, view:'BinaryView', sym:'_types.CoreSymbol') -> None:
+ def symbol_updated(self, view: 'BinaryView', sym: '_types.CoreSymbol') -> None:
pass
- def symbol_removed(self, view:'BinaryView', sym:'_types.CoreSymbol') -> None:
+ def symbol_removed(self, view: 'BinaryView', sym: '_types.CoreSymbol') -> None:
pass
- def string_found(self, view:'BinaryView', string_type:StringType, offset:int, length:int) -> None:
+ def string_found(self, view: 'BinaryView', string_type: StringType, offset: int, length: int) -> None:
pass
- def string_removed(self, view:'BinaryView', string_type:StringType, offset:int, length:int) -> None:
+ def string_removed(self, view: 'BinaryView', string_type: StringType, offset: int, length: int) -> None:
pass
- def type_defined(self, view:'BinaryView', name:'_types.QualifiedName', type:'_types.Type') -> None:
+ def type_defined(self, view: 'BinaryView', name: '_types.QualifiedName', type: '_types.Type') -> None:
pass
- def type_undefined(self, view:'BinaryView', name:'_types.QualifiedName', type:'_types.Type') -> None:
+ def type_undefined(self, view: 'BinaryView', name: '_types.QualifiedName', type: '_types.Type') -> None:
pass
- def type_ref_changed(self, view:'BinaryView', name:'_types.QualifiedName', type:'_types.Type') -> None:
+ def type_ref_changed(self, view: 'BinaryView', name: '_types.QualifiedName', type: '_types.Type') -> None:
pass
- def type_field_ref_changed(self, view:'BinaryView', name:'_types.QualifiedName', offset: int) -> None:
+ def type_field_ref_changed(self, view: 'BinaryView', name: '_types.QualifiedName', offset: int) -> None:
pass
+
class StringReference:
_decodings = {
- StringType.AsciiString: "ascii",
- StringType.Utf8String: "utf-8",
- StringType.Utf16String: "utf-16",
- StringType.Utf32String: "utf-32",
+ StringType.AsciiString: "ascii", StringType.Utf8String: "utf-8", StringType.Utf16String: "utf-16",
+ StringType.Utf32String: "utf-32",
}
- def __init__(self, bv:'BinaryView', string_type:StringType, start:int, length:int):
+
+ def __init__(self, bv: 'BinaryView', string_type: StringType, start: int, length: int):
self._type = string_type
self._start = start
self._length = length
@@ -219,7 +225,7 @@ class StringReference:
return self._type
@type.setter
- def type(self, value:StringType) -> None:
+ def type(self, value: StringType) -> None:
self._type = value
@property
@@ -227,7 +233,7 @@ class StringReference:
return self._start
@start.setter
- def start(self, value:int) -> None:
+ def start(self, value: int) -> None:
self._start = value
@property
@@ -254,7 +260,10 @@ class AnalysisCompletionEvent:
>>>
"""
_pending_analysis_completion_events = {}
- def __init__(self, view:'BinaryView', callback:Union[Callable[['AnalysisCompletionEvent'], None], Callable[[], None]]):
+
+ def __init__(
+ self, view: 'BinaryView', callback: Union[Callable[['AnalysisCompletionEvent'], None], Callable[[], None]]
+ ):
self._view = view
self.callback = callback
self._cb = ctypes.CFUNCTYPE(None, ctypes.c_void_p)(self._notify)
@@ -274,9 +283,9 @@ class AnalysisCompletionEvent:
arg_offset = inspect.ismethod(self.callback)
callback_spec = inspect.getargspec(self.callback)
if len(callback_spec.args) > arg_offset:
- self.callback(self) # type: ignore
+ self.callback(self) # type: ignore
else:
- self.callback() # type: ignore
+ self.callback() # type: ignore
except:
log_error(traceback.format_exc())
@@ -300,7 +309,7 @@ class AnalysisCompletionEvent:
return self._view
@view.setter
- def view(self, value:'BinaryView') -> None:
+ def view(self, value: 'BinaryView') -> None:
self._view = value
@@ -331,16 +340,18 @@ class BinaryViewEvent:
_binaryview_events = {}
@classmethod
- def register(cls, event_type:BinaryViewEventType, callback:BinaryViewEventCallback) -> None:
- callback_obj = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView))(lambda ctxt, view: cls._notify(view, callback))
+ def register(cls, event_type: BinaryViewEventType, callback: BinaryViewEventCallback) -> None:
+ callback_obj = ctypes.CFUNCTYPE(None, ctypes.c_void_p,
+ ctypes.POINTER(core.BNBinaryView
+ ))(lambda ctxt, view: cls._notify(view, callback))
core.BNRegisterBinaryViewEvent(event_type, callback_obj, None)
cls._binaryview_events[len(cls._binaryview_events)] = callback_obj
@staticmethod
- def _notify(view:core.BNBinaryView, callback:BinaryViewEventCallback) -> None:
+ def _notify(view: core.BNBinaryView, callback: BinaryViewEventCallback) -> None:
try:
- file_metadata = filemetadata.FileMetadata(handle = core.BNGetFileForView(view))
- view_obj = BinaryView(file_metadata = file_metadata, handle = core.BNNewViewReference(view))
+ file_metadata = filemetadata.FileMetadata(handle=core.BNGetFileForView(view))
+ view_obj = BinaryView(file_metadata=file_metadata, handle=core.BNNewViewReference(view))
callback(view_obj)
except:
log_error(traceback.format_exc())
@@ -348,10 +359,10 @@ class BinaryViewEvent:
@dataclass(frozen=True)
class ActiveAnalysisInfo:
- func:'_function.Function'
- analysis_time:int
- update_count:int
- submit_count:int
+ func: '_function.Function'
+ analysis_time: int
+ update_count: int
+ submit_count: int
def __repr__(self):
return f"<ActiveAnalysisInfo {self.func}, analysis_time {self.analysis_time}, update_count {self.update_count}, submit_count {self.submit_count}>"
@@ -359,9 +370,9 @@ class ActiveAnalysisInfo:
@dataclass(frozen=True)
class AnalysisInfo:
- state:AnalysisState
- analysis_time:int
- active_info:List[ActiveAnalysisInfo]
+ state: AnalysisState
+ analysis_time: int
+ active_info: List[ActiveAnalysisInfo]
def __repr__(self):
return f"<AnalysisInfo {self.state}, analysis_time {self.analysis_time}, active_info {len(self.active_info)}>"
@@ -369,9 +380,9 @@ class AnalysisInfo:
@dataclass(frozen=True)
class AnalysisProgress:
- state:AnalysisState
- count:int
- total:int
+ state: AnalysisState
+ count: int
+ total: int
def __str__(self):
if self.state == AnalysisState.InitialState:
@@ -391,7 +402,7 @@ class AnalysisProgress:
class BinaryDataNotificationCallbacks:
- def __init__(self, view:'BinaryView', notify:'BinaryDataNotification'):
+ def __init__(self, view: 'BinaryView', notify: 'BinaryDataNotification'):
self._view = view
self._notify = notify
self._cb = core.BNBinaryDataNotification()
@@ -427,73 +438,75 @@ class BinaryDataNotificationCallbacks:
def _unregister(self) -> None:
core.BNUnregisterDataNotification(self._view.handle, self._cb)
- def _data_written(self, ctxt, view:core.BNBinaryView, offset:int, length:int) -> None:
+ def _data_written(self, ctxt, view: core.BNBinaryView, offset: int, length: int) -> None:
try:
self._notify.data_written(self._view, offset, length)
except OSError:
log_error(traceback.format_exc())
- def _data_inserted(self, ctxt, view:core.BNBinaryView, offset:int, length:int) -> None:
+ def _data_inserted(self, ctxt, view: core.BNBinaryView, offset: int, length: int) -> None:
try:
self._notify.data_inserted(self._view, offset, length)
except:
log_error(traceback.format_exc())
- def _data_removed(self, ctxt, view:core.BNBinaryView, offset:int, length:int) -> None:
+ def _data_removed(self, ctxt, view: core.BNBinaryView, offset: int, length: int) -> None:
try:
self._notify.data_removed(self._view, offset, length)
except:
log_error(traceback.format_exc())
- def _function_added(self, ctxt, view:core.BNBinaryView, func:core.BNFunction) -> None:
+ def _function_added(self, ctxt, view: core.BNBinaryView, func: core.BNFunction) -> None:
try:
self._notify.function_added(self._view, _function.Function(self._view, core.BNNewFunctionReference(func)))
except:
log_error(traceback.format_exc())
- def _function_removed(self, ctxt, view:core.BNBinaryView, func:core.BNFunction) -> None:
+ def _function_removed(self, ctxt, view: core.BNBinaryView, func: core.BNFunction) -> None:
try:
self._notify.function_removed(self._view, _function.Function(self._view, core.BNNewFunctionReference(func)))
except:
log_error(traceback.format_exc())
- def _function_updated(self, ctxt, view:core.BNBinaryView, func:core.BNFunction) -> None:
+ def _function_updated(self, ctxt, view: core.BNBinaryView, func: core.BNFunction) -> None:
try:
self._notify.function_updated(self._view, _function.Function(self._view, core.BNNewFunctionReference(func)))
except:
log_error(traceback.format_exc())
- def _function_update_requested(self, ctxt, view:core.BNBinaryView, func:core.BNFunction) -> None:
+ def _function_update_requested(self, ctxt, view: core.BNBinaryView, func: core.BNFunction) -> None:
try:
- self._notify.function_update_requested(self._view, _function.Function(self._view, core.BNNewFunctionReference(func)))
+ self._notify.function_update_requested(
+ self._view, _function.Function(self._view, core.BNNewFunctionReference(func))
+ )
except:
log_error(traceback.format_exc())
- def _data_var_added(self, ctxt, view:core.BNBinaryView, var:core.BNDataVariable) -> None:
+ def _data_var_added(self, ctxt, view: core.BNBinaryView, var: core.BNDataVariable) -> None:
try:
self._notify.data_var_added(self._view, DataVariable.from_core_struct(var[0], self._view))
except:
log_error(traceback.format_exc())
- def _data_var_removed(self, ctxt, view:core.BNBinaryView, var:core.BNDataVariable) -> None:
+ def _data_var_removed(self, ctxt, view: core.BNBinaryView, var: core.BNDataVariable) -> None:
try:
self._notify.data_var_removed(self._view, DataVariable.from_core_struct(var[0], self._view))
except:
log_error(traceback.format_exc())
- def _data_var_updated(self, ctxt, view:core.BNBinaryView, var:core.BNDataVariable) -> None:
+ def _data_var_updated(self, ctxt, view: core.BNBinaryView, var: core.BNDataVariable) -> None:
try:
self._notify.data_var_updated(self._view, DataVariable.from_core_struct(var[0], self._view))
except:
log_error(traceback.format_exc())
- def _data_metadata_updated(self, ctxt, view:core.BNBinaryView, offset:int) -> None:
+ def _data_metadata_updated(self, ctxt, view: core.BNBinaryView, offset: int) -> None:
try:
self._notify.data_metadata_updated(self._view, offset)
except:
log_error(traceback.format_exc())
- def _tag_type_updated(self, ctxt, view:core.BNBinaryView, tag_type:core.BNTagType) -> None:
+ def _tag_type_updated(self, ctxt, view: core.BNBinaryView, tag_type: core.BNTagType) -> None:
try:
core_tag_type = core.BNNewTagTypeReference(tag_type)
assert core_tag_type is not None, "core.BNNewTagTypeReference returned None"
@@ -501,7 +514,7 @@ class BinaryDataNotificationCallbacks:
except:
log_error(traceback.format_exc())
- def _tag_added(self, ctxt, view:core.BNBinaryView, tag_ref:core.BNTagReference) -> None:
+ def _tag_added(self, ctxt, view: core.BNBinaryView, tag_ref: core.BNTagReference) -> None:
try:
ref_type = tag_ref[0].refType
auto_defined = tag_ref[0].autoDefined
@@ -512,7 +525,7 @@ class BinaryDataNotificationCallbacks:
if ctypes.cast(tag_ref[0].arch, ctypes.c_void_p).value is None:
arch = None
else:
- arch = architecture.CoreArchitecture._from_cache(tag_ref[0].arch)
+ arch = architecture.CoreArchitecture._from_cache(tag_ref[0].arch)
if ctypes.cast(tag_ref[0].func, ctypes.c_void_p).value is None:
func = None
else:
@@ -522,7 +535,7 @@ class BinaryDataNotificationCallbacks:
except:
log_error(traceback.format_exc())
- def _tag_updated(self, ctxt, view:core.BNBinaryView, tag_ref:core.BNTagReference) -> None:
+ def _tag_updated(self, ctxt, view: core.BNBinaryView, tag_ref: core.BNTagReference) -> None:
try:
ref_type = tag_ref[0].refType
auto_defined = tag_ref[0].autoDefined
@@ -543,7 +556,7 @@ class BinaryDataNotificationCallbacks:
except:
log_error(traceback.format_exc())
- def _tag_removed(self, ctxt, view:core.BNBinaryView, tag_ref:core.BNTagReference) -> None:
+ def _tag_removed(self, ctxt, view: core.BNBinaryView, tag_ref: core.BNTagReference) -> None:
try:
ref_type = tag_ref[0].refType
auto_defined = tag_ref[0].autoDefined
@@ -564,7 +577,7 @@ class BinaryDataNotificationCallbacks:
except:
log_error(traceback.format_exc())
- def _symbol_added(self, ctxt, view:core.BNBinaryView, sym:core.BNSymbol) -> None:
+ def _symbol_added(self, ctxt, view: core.BNBinaryView, sym: core.BNSymbol) -> None:
try:
_handle = core.BNNewSymbolReference(sym)
assert _handle is not None, "core.BNNewSymbolReference returned None"
@@ -572,7 +585,7 @@ class BinaryDataNotificationCallbacks:
except:
log_error(traceback.format_exc())
- def _symbol_updated(self, ctxt, view:core.BNBinaryView, sym:core.BNSymbol) -> None:
+ def _symbol_updated(self, ctxt, view: core.BNBinaryView, sym: core.BNSymbol) -> None:
try:
_handle = core.BNNewSymbolReference(sym)
assert _handle is not None, "core.BNNewSymbolReference returned None"
@@ -580,7 +593,7 @@ class BinaryDataNotificationCallbacks:
except:
log_error(traceback.format_exc())
- def _symbol_removed(self, ctxt, view:core.BNBinaryView, sym:core.BNSymbol) -> None:
+ def _symbol_removed(self, ctxt, view: core.BNBinaryView, sym: core.BNSymbol) -> None:
try:
_handle = core.BNNewSymbolReference(sym)
assert _handle is not None, "core.BNNewSymbolReference returned None"
@@ -588,40 +601,49 @@ class BinaryDataNotificationCallbacks:
except:
log_error(traceback.format_exc())
- def _string_found(self, ctxt, view:core.BNBinaryView, string_type:int, offset:int, length:int) -> None:
+ def _string_found(self, ctxt, view: core.BNBinaryView, string_type: int, offset: int, length: int) -> None:
try:
self._notify.string_found(self._view, StringType(string_type), offset, length)
except:
log_error(traceback.format_exc())
- def _string_removed(self, ctxt, view:core.BNBinaryView, string_type:int, offset:int, length:int) -> None:
+ def _string_removed(self, ctxt, view: core.BNBinaryView, string_type: int, offset: int, length: int) -> None:
try:
self._notify.string_removed(self._view, StringType(string_type), offset, length)
except:
log_error(traceback.format_exc())
- def _type_defined(self, ctxt, view:core.BNBinaryView, name:str, type_obj:'_types.Type') -> None:
+ def _type_defined(self, ctxt, view: core.BNBinaryView, name: str, type_obj: '_types.Type') -> None:
try:
qualified_name = _types.QualifiedName._from_core_struct(name[0])
- self._notify.type_defined(self._view, qualified_name, _types.Type.create(core.BNNewTypeReference(type_obj), platform = self._view.platform))
+ self._notify.type_defined(
+ self._view, qualified_name,
+ _types.Type.create(core.BNNewTypeReference(type_obj), platform=self._view.platform)
+ )
except:
log_error(traceback.format_exc())
- def _type_undefined(self, ctxt, view:core.BNBinaryView, name:str, type_obj:'_types.Type') -> None:
+ def _type_undefined(self, ctxt, view: core.BNBinaryView, name: str, type_obj: '_types.Type') -> None:
try:
qualified_name = _types.QualifiedName._from_core_struct(name[0])
- self._notify.type_undefined(self._view, qualified_name, _types.Type.create(core.BNNewTypeReference(type_obj), platform = self._view.platform))
+ self._notify.type_undefined(
+ self._view, qualified_name,
+ _types.Type.create(core.BNNewTypeReference(type_obj), platform=self._view.platform)
+ )
except:
log_error(traceback.format_exc())
- def _type_ref_changed(self, ctxt, view:core.BNBinaryView, name:str, type_obj:'_types.Type') -> None:
+ def _type_ref_changed(self, ctxt, view: core.BNBinaryView, name: str, type_obj: '_types.Type') -> None:
try:
qualified_name = _types.QualifiedName._from_core_struct(name[0])
- self._notify.type_ref_changed(self._view, qualified_name, _types.Type.create(core.BNNewTypeReference(type_obj), platform = self._view.platform))
+ self._notify.type_ref_changed(
+ self._view, qualified_name,
+ _types.Type.create(core.BNNewTypeReference(type_obj), platform=self._view.platform)
+ )
except:
log_error(traceback.format_exc())
- def _type_field_ref_changed(self, ctxt, view:core.BNBinaryView, name:str, offset:int) -> None:
+ def _type_field_ref_changed(self, ctxt, view: core.BNBinaryView, name: str, offset: int) -> None:
try:
qualified_name = _types.QualifiedName._from_core_struct(name[0])
self._notify.type_field_ref_changed(self._view, qualified_name, offset)
@@ -661,7 +683,8 @@ class _BinaryViewTypeMetaclass(type):
class BinaryViewType(metaclass=_BinaryViewTypeMetaclass):
# Used to force Python callback objects to not get garbage collected
_platform_recognizers = {}
- def __init__(self, handle:core.BNBinaryViewTypeHandle):
+
+ def __init__(self, handle: core.BNBinaryViewTypeHandle):
_handle = core.BNBinaryViewTypeHandle
self.handle = ctypes.cast(handle, _handle)
@@ -696,13 +719,13 @@ class BinaryViewType(metaclass=_BinaryViewTypeMetaclass):
"""returns if the BinaryViewType is deprecated (read-only)"""
return core.BNIsBinaryViewTypeDeprecated(self.handle)
- def create(self, data:'BinaryView') -> Optional['BinaryView']:
+ def create(self, data: 'BinaryView') -> Optional['BinaryView']:
view = core.BNCreateBinaryViewOfType(self.handle, data.handle)
if view is None:
return None
return BinaryView(file_metadata=data.file, handle=view)
- def open(self, src:PathType, file_metadata:'filemetadata.FileMetadata'=None) -> Optional['BinaryView']:
+ def open(self, src: PathType, file_metadata: 'filemetadata.FileMetadata' = None) -> Optional['BinaryView']:
"""
``open`` opens an instance of a particular BinaryViewType and returns it, or None if not possible.
@@ -717,8 +740,9 @@ class BinaryViewType(metaclass=_BinaryViewTypeMetaclass):
return self.create(data)
@classmethod
- def get_view_of_file(cls, filename:PathType, update_analysis:bool=True,
- progress_func:Optional[ProgressFuncType]=None) -> Optional['BinaryView']:
+ def get_view_of_file(
+ cls, filename: PathType, update_analysis: bool = True, progress_func: Optional[ProgressFuncType] = None
+ ) -> Optional['BinaryView']:
"""
``get_view_of_file`` opens and returns the first available :py:class:`BinaryView`, excluding a Raw :py:class:`BinaryViewType` unless no other view is available
@@ -761,15 +785,17 @@ class BinaryViewType(metaclass=_BinaryViewTypeMetaclass):
if isDatabase:
bv = view.get_view_of_type("Raw")
else:
- bv = cls["Raw"].open(filename) # type: ignore
+ bv = cls["Raw"].open(filename) # type: ignore
if bv is not None and update_analysis:
bv.update_analysis_and_wait()
return bv
@classmethod
- def get_view_of_file_with_options(cls, filename:str, update_analysis:Optional[bool]=True,
- progress_func:Optional[ProgressFuncType]=None, options:Mapping[str, Any]={}) -> Optional['BinaryView']:
+ def get_view_of_file_with_options(
+ cls, filename: str, update_analysis: Optional[bool] = True, progress_func: Optional[ProgressFuncType] = None,
+ options: Mapping[str, Any] = {}
+ ) -> Optional['BinaryView']:
"""
``get_view_of_file_with_options`` opens, generates default load options (which are overridable), and returns the first available \
:py:class:`BinaryView`. If no :py:class:`BinaryViewType` is available, then a ``Mapped`` :py:class:`BinaryViewType` is used to load \
@@ -834,7 +860,7 @@ class BinaryViewType(metaclass=_BinaryViewTypeMetaclass):
bvt = available
if bvt is None:
- bvt = cls["Mapped"] # type: ignore
+ bvt = cls["Mapped"] # type: ignore
default_settings = settings.Settings(bvt.name + "_settings")
default_settings.deserialize_schema(settings.Settings().serialize_schema())
@@ -858,7 +884,9 @@ class BinaryViewType(metaclass=_BinaryViewTypeMetaclass):
break
if not arch_entry:
arch_names = [entry['architecture'] for entry in arch_list if entry['architecture']]
- raise Exception(f"Could not load any of: {options['files.universal.architecturePreference']} from Universal image. Entry not found! Available entries: {arch_names}")
+ raise Exception(
+ f"Could not load any of: {options['files.universal.architecturePreference']} from Universal image. Entry not found! Available entries: {arch_names}"
+ )
load_settings = settings.Settings(core.BNGetUniqueIdentifierString())
load_settings.deserialize_schema(arch_entry[0]['loadSchema'])
@@ -893,22 +921,22 @@ class BinaryViewType(metaclass=_BinaryViewTypeMetaclass):
bv.update_analysis_and_wait()
return bv
- def parse(self, data:'BinaryView') -> Optional['BinaryView']:
+ def parse(self, data: 'BinaryView') -> Optional['BinaryView']:
view = core.BNParseBinaryViewOfType(self, data.handle)
if view is None:
return None
return BinaryView(file_metadata=data.file, handle=view)
- def is_valid_for_data(self, data:'BinaryView') -> bool:
+ def is_valid_for_data(self, data: 'BinaryView') -> bool:
return core.BNIsBinaryViewTypeValidForData(self.handle, data.handle)
- def get_default_load_settings_for_data(self, data:'BinaryView') -> Optional['settings.Settings']:
+ def get_default_load_settings_for_data(self, data: 'BinaryView') -> Optional['settings.Settings']:
load_settings = core.BNGetBinaryViewDefaultLoadSettingsForData(self.handle, data.handle)
if load_settings is None:
return None
return settings.Settings(handle=load_settings)
- def get_load_settings_for_data(self, data:'BinaryView') -> Optional['settings.Settings']:
+ def get_load_settings_for_data(self, data: 'BinaryView') -> Optional['settings.Settings']:
view_handle = None
if data is not None:
view_handle = data.handle
@@ -917,27 +945,27 @@ class BinaryViewType(metaclass=_BinaryViewTypeMetaclass):
return None
return settings.Settings(handle=load_settings)
- def register_arch(self, ident:int, endian:Endianness, arch:'architecture.Architecture') -> None:
+ def register_arch(self, ident: int, endian: Endianness, arch: 'architecture.Architecture') -> None:
core.BNRegisterArchitectureForViewType(self.handle, ident, endian, arch.handle)
- def get_arch(self, ident:int, endian:Endianness) -> Optional['architecture.Architecture']:
+ def get_arch(self, ident: int, endian: Endianness) -> Optional['architecture.Architecture']:
arch = core.BNGetArchitectureForViewType(self.handle, ident, endian)
if arch is None:
return None
return architecture.CoreArchitecture._from_cache(arch)
- def register_platform(self, ident:int, arch:'architecture.Architecture', plat:'_platform.Platform') -> None:
+ def register_platform(self, ident: int, arch: 'architecture.Architecture', plat: '_platform.Platform') -> None:
core.BNRegisterPlatformForViewType(self.handle, ident, arch.handle, plat.handle)
- def register_default_platform(self, arch:'architecture.Architecture', plat:'_platform.Platform') -> None:
+ def register_default_platform(self, arch: 'architecture.Architecture', plat: '_platform.Platform') -> None:
core.BNRegisterDefaultPlatformForViewType(self.handle, arch.handle, plat.handle)
def register_platform_recognizer(self, ident, endian, cb):
def callback(cb, view, meta):
try:
- file_metadata = filemetadata.FileMetadata(handle = core.BNGetFileForView(view))
- view_obj = BinaryView(file_metadata = file_metadata, handle = core.BNNewViewReference(view))
- meta_obj = metadata.Metadata(handle = core.BNNewMetadataReference(meta))
+ file_metadata = filemetadata.FileMetadata(handle=core.BNGetFileForView(view))
+ view_obj = BinaryView(file_metadata=file_metadata, handle=core.BNNewViewReference(view))
+ meta_obj = metadata.Metadata(handle=core.BNNewMetadataReference(meta))
plat = cb(view_obj, meta_obj)
if plat:
handle = core.BNNewPlatformReference(plat.handle)
@@ -947,25 +975,26 @@ class BinaryViewType(metaclass=_BinaryViewTypeMetaclass):
binaryninja.log_error(traceback.format_exc())
return None
- callback_obj = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView), ctypes.POINTER(core.BNMetadata))(lambda ctxt, view, meta: callback(cb, view, meta))
+ callback_obj = ctypes.CFUNCTYPE(
+ ctypes.c_void_p, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView), ctypes.POINTER(core.BNMetadata)
+ )(lambda ctxt, view, meta: callback(cb, view, meta))
core.BNRegisterPlatformRecognizerForViewType(self.handle, ident, endian, callback_obj, None)
self.__class__._platform_recognizers[len(self.__class__._platform_recognizers)] = callback_obj
-
- def get_platform(self, ident:int, arch:'architecture.Architecture') -> Optional['_platform.Platform']:
+ def get_platform(self, ident: int, arch: 'architecture.Architecture') -> Optional['_platform.Platform']:
plat = core.BNGetPlatformForViewType(self.handle, ident, arch.handle)
if plat is None:
return None
- return _platform.Platform(handle = plat)
+ return _platform.Platform(handle=plat)
def recognize_platform(self, ident, endian, view, metadata):
plat = core.BNRecognizePlatformForViewType(self.handle, ident, endian, view.handle, metadata.handle)
if plat is None:
return None
- return binaryninja.platform.Platform(handle = plat)
+ return binaryninja.platform.Platform(handle=plat)
@staticmethod
- def add_binaryview_finalized_event(callback:BinaryViewEvent.BinaryViewEventCallback) -> None:
+ def add_binaryview_finalized_event(callback: BinaryViewEvent.BinaryViewEventCallback) -> None:
"""
`add_binaryview_finalized_event` adds a callback that gets executed
when new binaryview is finalized.
@@ -974,7 +1003,7 @@ class BinaryViewType(metaclass=_BinaryViewTypeMetaclass):
BinaryViewEvent.register(BinaryViewEventType.BinaryViewFinalizationEvent, callback)
@staticmethod
- def add_binaryview_initial_analysis_completion_event(callback:BinaryViewEvent.BinaryViewEventCallback) -> None:
+ def add_binaryview_initial_analysis_completion_event(callback: BinaryViewEvent.BinaryViewEventCallback) -> None:
"""
`add_binaryview_initial_analysis_completion_event` adds a callback
that gets executed after the initial analysis, as well as linear
@@ -985,7 +1014,7 @@ class BinaryViewType(metaclass=_BinaryViewTypeMetaclass):
class Segment:
- def __init__(self, handle:core.BNSegmentHandle):
+ def __init__(self, handle: core.BNSegmentHandle):
self.handle = handle
def __del__(self):
@@ -993,9 +1022,9 @@ class Segment:
core.BNFreeSegment(self.handle)
def __repr__(self):
- r ="r" if self.readable else "-"
- w ="w" if self.writable else "-"
- x ="x" if self.executable else "-"
+ r = "r" if self.readable else "-"
+ w = "w" if self.writable else "-"
+ x = "x" if self.executable else "-"
return f"<segment: {self.start:#x}-{self.end:#x}, {r}{w}{x}>"
def __len__(self):
@@ -1014,7 +1043,7 @@ class Segment:
def __hash__(self):
return hash(ctypes.addressof(self.handle.contents))
- def __contains__(self, i:int):
+ def __contains__(self, i: int):
return i >= self.start and i < self.end
@property
@@ -1069,7 +1098,7 @@ class Segment:
finally:
core.BNFreeRelocationRanges(ranges)
- def relocation_ranges_at(self, addr:int) -> List[Tuple[int, int]]:
+ def relocation_ranges_at(self, addr: int) -> List[Tuple[int, int]]:
"""List of relocation range tuples (read-only)"""
count = ctypes.c_ulonglong()
@@ -1082,7 +1111,7 @@ class Segment:
class Section:
- def __init__(self, handle:core.BNSectionHandle):
+ def __init__(self, handle: core.BNSectionHandle):
self.handle = handle
def __del__(self):
@@ -1108,7 +1137,7 @@ class Section:
def __hash__(self):
return hash(ctypes.addressof(self.handle.contents))
- def __contains__(self, i:int):
+ def __contains__(self, i: int):
return i >= self.start and i < self.end
@property
@@ -1155,13 +1184,13 @@ class Section:
def end(self) -> int:
return self.start + len(self)
- def range_contains_relocation(self, addr:int, size:int) -> bool:
+ def range_contains_relocation(self, addr: int, size: int) -> bool:
"""Checks if the specified range overlaps with a relocation"""
return core.BNSegmentRangeContainsRelocation(self.handle, addr, size)
class TagType:
- def __init__(self, handle:core.BNTagTypeHandle):
+ def __init__(self, handle: core.BNTagTypeHandle):
self.handle = handle
def __del__(self):
@@ -1195,7 +1224,7 @@ class TagType:
return core.BNTagTypeGetName(self.handle)
@name.setter
- def name(self, value:str) -> None:
+ def name(self, value: str) -> None:
core.BNTagTypeSetName(self.handle, value)
@property
@@ -1204,7 +1233,7 @@ class TagType:
return core.BNTagTypeGetIcon(self.handle)
@icon.setter
- def icon(self, value:str) -> None:
+ def icon(self, value: str) -> None:
core.BNTagTypeSetIcon(self.handle, value)
@property
@@ -1213,7 +1242,7 @@ class TagType:
return core.BNTagTypeGetVisible(self.handle)
@visible.setter
- def visible(self, value:bool) -> None:
+ def visible(self, value: bool) -> None:
core.BNTagTypeSetVisible(self.handle, value)
@property
@@ -1222,12 +1251,12 @@ class TagType:
return TagTypeType(core.BNTagTypeGetType(self.handle))
@type.setter
- def type(self, value:TagTypeType) -> None:
+ def type(self, value: TagTypeType) -> None:
core.BNTagTypeSetType(self.handle, value)
class Tag:
- def __init__(self, handle:core.BNTagHandle):
+ def __init__(self, handle: core.BNTagHandle):
self.handle = handle
def __del__(self):
@@ -1265,7 +1294,7 @@ class Tag:
return core.BNTagGetData(self.handle)
@data.setter
- def data(self, value:str) -> None:
+ def data(self, value: str) -> None:
core.BNTagSetData(self.handle, value)
@@ -1284,10 +1313,10 @@ class SymbolMapping(collections.abc.Mapping): # type: ignore
>>> print("Found")
"""
- def __init__(self, view:'BinaryView'):
+ def __init__(self, view: 'BinaryView'):
self._symbol_list = None
self._count = None
- self._symbol_cache:Optional[Mapping[bytes, List[_types.CoreSymbol]]] = None
+ self._symbol_cache: Optional[Mapping[bytes, List[_types.CoreSymbol]]] = None
self._view = view
self._n = 0
@@ -1384,10 +1413,10 @@ class TypeMapping(collections.abc.Mapping): # type: ignore
>>> print("Found")
"""
- def __init__(self, view:'BinaryView'):
+ def __init__(self, view: 'BinaryView'):
self._type_list = None
self._count = None
- self._type_cache:Optional[Mapping[_types.QualifiedName, _types.Type]] = None
+ self._type_cache: Optional[Mapping[_types.QualifiedName, _types.Type]] = None
self._view = view
def __repr__(self):
@@ -1418,7 +1447,7 @@ class TypeMapping(collections.abc.Mapping): # type: ignore
self._count = count.value
for i in range(len(self)):
name = _types.QualifiedName._from_core_struct(self._type_list[i].name)
- type = _types.Type.create(core.BNNewTypeReference(self._type_list[i].type), platform = self._view.platform)
+ type = _types.Type.create(core.BNNewTypeReference(self._type_list[i].type), platform=self._view.platform)
self._type_cache[name] = type
yield name, type
@@ -1442,7 +1471,7 @@ class TypeMapping(collections.abc.Mapping): # type: ignore
return self.view == other.view
def __ne__(self, other):
- return not(self == other)
+ return not (self == other)
def keys(self):
if self._type_cache is None:
@@ -1470,7 +1499,7 @@ class TypeMapping(collections.abc.Mapping): # type: ignore
class FunctionList:
- def __init__(self, view:'BinaryView'):
+ def __init__(self, view: 'BinaryView'):
count = ctypes.c_ulonglong(0)
_funcs = core.BNGetAnalysisFunctionList(view.handle, count)
assert _funcs is not None, "core.BNGetAnalysisFunctionList returned None"
@@ -1491,7 +1520,7 @@ class FunctionList:
self._n += 1
return _function.Function(self._view, func)
- def __getitem__(self, i:Union[int, slice]) -> Union['_function.Function', List['_function.Function']]:
+ def __getitem__(self, i: Union[int, slice]) -> Union['_function.Function', List['_function.Function']]:
if isinstance(i, int):
if i < 0:
i = len(self) + i
@@ -1545,7 +1574,7 @@ class AdvancedILFunctionList:
>>> timeit.timeit(lambda:[f for f in bv.functions], number=1)
0.02230275600004461
"""
- def __init__(self, view:'BinaryView', preload_limit:int = 5, functions:Optional[Iterable]=None):
+ def __init__(self, view: 'BinaryView', preload_limit: int = 5, functions: Optional[Iterable] = None):
self._view = view
self._func_queue = deque()
self._preload_limit = preload_limit
@@ -1614,13 +1643,17 @@ class BinaryView:
to the database is desired.
"""
name: Optional[str] = None
- long_name: Optional[str] = None
+ long_name: Optional[str] = None
_registered = False
_registered_cb = None
registered_view_type = None
_associated_data = {}
_registered_instances = []
- def __init__(self, file_metadata:'filemetadata.FileMetadata'=None, parent_view:'BinaryView'=None, handle:core.BNBinaryViewHandle=None):
+
+ def __init__(
+ self, file_metadata: 'filemetadata.FileMetadata' = None, parent_view: 'BinaryView' = None,
+ handle: core.BNBinaryViewHandle = None
+ ):
if handle is not None:
_handle = handle
if file_metadata is None:
@@ -1785,7 +1818,7 @@ class BinaryView:
else:
raise IndexError("index out of range")
- def __contains__(self, i:int):
+ def __contains__(self, i: int):
for s in self.segments:
if i in s:
return True
@@ -1803,7 +1836,9 @@ class BinaryView:
cls._registered_cb.create = cls._registered_cb.create.__class__(cls._create)
cls._registered_cb.parse = cls._registered_cb.parse.__class__(cls._parse)
cls._registered_cb.isValidForData = cls._registered_cb.isValidForData.__class__(cls._is_valid_for_data)
- cls._registered_cb.getLoadSettingsForData = cls._registered_cb.getLoadSettingsForData.__class__(cls._get_load_settings_for_data)
+ cls._registered_cb.getLoadSettingsForData = cls._registered_cb.getLoadSettingsForData.__class__(
+ cls._get_load_settings_for_data
+ )
view_handle = core.BNRegisterBinaryViewType(cls.name, cls.long_name, cls._registered_cb)
assert view_handle is not None, "core.BNRegisterBinaryViewType returned None"
cls.registered_view_type = BinaryViewType(view_handle)
@@ -1814,14 +1849,14 @@ class BinaryView:
return self._parse_only
@parse_only.setter
- def parse_only(self, value:bool) -> None:
+ def parse_only(self, value: bool) -> None:
self._parse_only = value
@classmethod
- def _create(cls, ctxt, data:core.BNBinaryView):
+ def _create(cls, ctxt, data: core.BNBinaryView):
try:
file_metadata = filemetadata.FileMetadata(handle=core.BNGetFileForView(data))
- view = cls(BinaryView(file_metadata=file_metadata, handle=core.BNNewViewReference(data))) # type: ignore
+ view = cls(BinaryView(file_metadata=file_metadata, handle=core.BNNewViewReference(data))) # type: ignore
if view is None:
return None
view.parse_only = False
@@ -1833,10 +1868,10 @@ class BinaryView:
return None
@classmethod
- def _parse(cls, ctxt, data:core.BNBinaryView):
+ def _parse(cls, ctxt, data: core.BNBinaryView):
try:
file_metadata = filemetadata.FileMetadata(handle=core.BNGetFileForView(data))
- view = cls(BinaryView(file_metadata=file_metadata, handle=core.BNNewViewReference(data))) # type: ignore
+ view = cls(BinaryView(file_metadata=file_metadata, handle=core.BNNewViewReference(data))) # type: ignore
if view is None:
return None
view.parse_only = True
@@ -1851,7 +1886,7 @@ class BinaryView:
def _is_valid_for_data(cls, ctxt, data):
try:
# I'm not sure whats going on here even so I've suppressed the linter warning
- return cls.is_valid_for_data(BinaryView(handle=core.BNNewViewReference(data))) # type: ignore
+ return cls.is_valid_for_data(BinaryView(handle=core.BNNewViewReference(data))) # type: ignore
except:
log_error(traceback.format_exc())
return False
@@ -1861,7 +1896,9 @@ class BinaryView:
try:
attr = getattr(cls, "get_load_settings_for_data", None)
if callable(attr):
- result = cls.get_load_settings_for_data(BinaryView(handle=core.BNNewViewReference(data))) # type: ignore
+ result = cls.get_load_settings_for_data(
+ BinaryView(handle=core.BNNewViewReference(data))
+ ) # type: ignore
settings_handle = core.BNNewSettingsReference(result.handle)
assert settings_handle is not None, "core.BNNewSettingsReference returned None"
return ctypes.cast(settings_handle, ctypes.c_void_p).value
@@ -1887,7 +1924,7 @@ class BinaryView:
return BinaryView(file_metadata=file_metadata, handle=view)
@staticmethod
- def new(data:bytes=None, file_metadata:Optional['filemetadata.FileMetadata']=None) -> Optional['BinaryView']:
+ def new(data: bytes = None, file_metadata: Optional['filemetadata.FileMetadata'] = None) -> Optional['BinaryView']:
binaryninja._init_plugins()
if file_metadata is None:
file_metadata = filemetadata.FileMetadata()
@@ -1901,13 +1938,13 @@ class BinaryView:
return BinaryView(file_metadata=file_metadata, handle=view)
@classmethod
- def _unregister(cls, view:core.BNBinaryView) -> None:
+ def _unregister(cls, view: core.BNBinaryView) -> None:
handle = ctypes.cast(view, ctypes.c_void_p)
if handle.value in cls._associated_data:
del cls._associated_data[handle.value]
@staticmethod
- def set_default_session_data(name:str, value:str) -> None:
+ def set_default_session_data(name: str, value: str) -> None:
"""
``set_default_session_data`` saves a variable to the BinaryView.
@@ -1926,7 +1963,7 @@ class BinaryView:
return self._preload_limit
@preload_limit.setter
- def preload_limit(self, value:int) -> None:
+ def preload_limit(self, value: int) -> None:
self._preload_limit = value
@property
@@ -1948,7 +1985,7 @@ class BinaryView:
yield from func.basic_blocks
@property
- def hlil_basic_blocks(self) -> Generator['highlevelil.HighLevelILBasicBlock', None, None]:
+ def hlil_basic_blocks(self) -> Generator['highlevelil.HighLevelILBasicBlock', None, None]:
"""A generator of all HighLevelILBasicBlock objects in the BinaryView"""
for func in self.hlil_functions():
yield from func.basic_blocks
@@ -1994,7 +2031,7 @@ class BinaryView:
return self._file.modified
@modified.setter
- def modified(self, value:bool) -> None:
+ def modified(self, value: bool) -> None:
self._file.modified = value
@property
@@ -2012,7 +2049,7 @@ class BinaryView:
return self._file.view
@view.setter
- def view(self, value:str) -> None:
+ def view(self, value: str) -> None:
self._file.view = value
@property
@@ -2020,7 +2057,7 @@ class BinaryView:
return self._file.offset
@offset.setter
- def offset(self, value:int) -> None:
+ def offset(self, value: int) -> None:
self._file.offset = value
@property
@@ -2052,7 +2089,7 @@ class BinaryView:
return architecture.CoreArchitecture._from_cache(handle=arch)
@arch.setter
- def arch(self, value:'architecture.Architecture') -> None:
+ def arch(self, value: 'architecture.Architecture') -> None:
if value is None:
core.BNSetDefaultArchitecture(self.handle, None)
else:
@@ -2067,7 +2104,7 @@ class BinaryView:
return _platform.Platform(self.arch, handle=plat)
@platform.setter
- def platform(self, value:Optional['_platform.Platform']) -> None:
+ def platform(self, value: Optional['_platform.Platform']) -> None:
if value is None:
core.BNSetDefaultPlatform(self.handle, None)
else:
@@ -2098,20 +2135,30 @@ class BinaryView:
"""returns a FunctionList object (read-only)"""
return FunctionList(self)
- def mlil_functions(self, preload_limit:Optional[int] = None, function_generator:Generator['_function.Function', None, None] = None) -> Generator['mediumlevelil.MediumLevelILFunction', None, None]:
+ def mlil_functions(
+ self, preload_limit: Optional[int] = None, function_generator: Generator['_function.Function', None,
+ None] = None
+ ) -> Generator['mediumlevelil.MediumLevelILFunction', None, None]:
"""
Generates a list of il functions. This method should be used instead of 'functions' property if
MLIL is needed and performance is a concern.
"""
- for func in AdvancedILFunctionList(self, self.preload_limit if preload_limit is None else preload_limit, function_generator):
+ for func in AdvancedILFunctionList(
+ self, self.preload_limit if preload_limit is None else preload_limit, function_generator
+ ):
yield func.mlil
- def hlil_functions(self, preload_limit:Optional[int] = None, function_generator:Generator['_function.Function', None, None] = None) -> Generator['highlevelil.HighLevelILFunction', None, None]:
+ def hlil_functions(
+ self, preload_limit: Optional[int] = None, function_generator: Generator['_function.Function', None,
+ None] = None
+ ) -> Generator['highlevelil.HighLevelILFunction', None, None]:
"""
Generates a list of il functions. This method should be used instead of 'functions' property if
HLIL is needed and performance is a concern.
"""
- for func in AdvancedILFunctionList(self, self.preload_limit if preload_limit is None else preload_limit, function_generator):
+ for func in AdvancedILFunctionList(
+ self, self.preload_limit if preload_limit is None else preload_limit, function_generator
+ ):
yield func.hlil
@property
@@ -2211,7 +2258,7 @@ class BinaryView:
return self._file.saved
@saved.setter
- def saved(self, value:bool) -> None:
+ def saved(self, value: bool) -> None:
self._file.saved = value
@property
@@ -2228,11 +2275,14 @@ class BinaryView:
info_ref = core.BNGetAnalysisInfo(self.handle)
assert info_ref is not None, "core.BNGetAnalysisInfo returned None"
info = info_ref[0]
- active_info_list:List[ActiveAnalysisInfo] = []
+ active_info_list: List[ActiveAnalysisInfo] = []
try:
for i in range(0, info.count):
func = _function.Function(self, core.BNNewFunctionReference(info.activeInfo[i].func))
- active_info = ActiveAnalysisInfo(func, info.activeInfo[i].analysisTime, info.activeInfo[i].updateCount, info.activeInfo[i].submitCount)
+ active_info = ActiveAnalysisInfo(
+ func, info.activeInfo[i].analysisTime, info.activeInfo[i].updateCount,
+ info.activeInfo[i].submitCount
+ )
active_info_list.append(active_info)
return AnalysisInfo(info.state, info.analysisTime, active_info_list)
finally:
@@ -2281,7 +2331,6 @@ class BinaryView:
finally:
core.BNFreeTypeNameList(name_list, count.value)
-
@property
def type_libraries(self) -> List['typelibrary.TypeLibrary']:
"""List of imported type libraries (read-only)"""
@@ -2296,7 +2345,6 @@ class BinaryView:
finally:
core.BNFreeTypeLibraryList(libraries, count.value)
-
@property
def segments(self) -> List['Segment']:
"""List of segments (read-only)"""
@@ -2374,7 +2422,7 @@ class BinaryView:
return core.BNGetMaxFunctionSizeForAnalysis(self.handle)
@max_function_size_for_analysis.setter
- def max_function_size_for_analysis(self, size:int) -> None:
+ def max_function_size_for_analysis(self, size: int) -> None:
core.BNSetMaxFunctionSizeForAnalysis(self.handle, size)
@property
@@ -2388,7 +2436,7 @@ class BinaryView:
finally:
core.BNFreeRelocationRanges(ranges)
- def relocation_ranges_at(self, addr:int) -> List[Tuple[int, int]]:
+ def relocation_ranges_at(self, addr: int) -> List[Tuple[int, int]]:
"""List of relocation range tuples for a given address"""
count = ctypes.c_ulonglong()
@@ -2399,7 +2447,7 @@ class BinaryView:
finally:
core.BNFreeRelocationRanges(ranges)
- def range_contains_relocation(self, addr:int, size:int) -> bool:
+ def range_contains_relocation(self, addr: int, size: int) -> bool:
"""Checks if the specified range overlaps with a relocation"""
return core.BNRangeContainsRelocation(self.handle, addr, size)
@@ -2409,7 +2457,7 @@ class BinaryView:
return core.BNGetNewAutoFunctionAnalysisSuppressed(self.handle)
@new_auto_function_analysis_suppressed.setter
- def new_auto_function_analysis_suppressed(self, suppress:bool) -> None:
+ def new_auto_function_analysis_suppressed(self, suppress: bool) -> None:
core.BNSetNewAutoFunctionAnalysisSuppressed(self.handle, suppress)
def _init(self, ctxt):
@@ -2570,7 +2618,9 @@ class BinaryView:
def init(self) -> bool:
return True
- def disassembly_tokens(self, addr:int, arch:Optional['architecture.Architecture']=None) -> Generator[Tuple[List['_function.InstructionTextToken'], int], None, None]:
+ def disassembly_tokens(
+ self, addr: int, arch: Optional['architecture.Architecture'] = None
+ ) -> Generator[Tuple[List['_function.InstructionTextToken'], int], None, None]:
if arch is None:
if self.arch is None:
raise Exception("Can not call method disassembly with no Architecture specified")
@@ -2584,7 +2634,8 @@ class BinaryView:
break
yield (tokens, size)
- def disassembly_text(self, addr:int, arch:Optional['architecture.Architecture']=None) -> Generator[Tuple[str, int], None, None]:
+ def disassembly_text(self, addr: int,
+ arch: Optional['architecture.Architecture'] = None) -> Generator[Tuple[str, int], None, None]:
"""
``disassembly_text`` helper function for getting disassembly of a given address
@@ -2611,7 +2662,7 @@ class BinaryView:
break
yield (''.join(str(a) for a in tokens).strip(), size)
- def get_disassembly(self, addr:int, arch:Optional['architecture.Architecture']=None) -> Optional[str]:
+ def get_disassembly(self, addr: int, arch: Optional['architecture.Architecture'] = None) -> Optional[str]:
"""
``get_disassembly`` simple helper function for printing disassembly of a given address
:param int addr: virtual address of instruction
@@ -2659,7 +2710,7 @@ class BinaryView:
"""
return 0
- def perform_read(self, addr:int, length:int) -> bytes:
+ def perform_read(self, addr: int, length: int) -> bytes:
"""
``perform_read`` implements a mapping between a virtual address and an absolute file offset, reading
``length`` bytes from the rebased address ``addr``.
@@ -2676,7 +2727,7 @@ class BinaryView:
"""
return b""
- def perform_write(self, addr:int, data:bytes) -> int:
+ def perform_write(self, addr: int, data: bytes) -> int:
"""
``perform_write`` implements a mapping between a virtual address and an absolute file offset, writing
the bytes ``data`` to rebased address ``addr``.
@@ -2693,7 +2744,7 @@ class BinaryView:
"""
return 0
- def perform_insert(self, addr:int, data:bytes) -> int:
+ def perform_insert(self, addr: int, data: bytes) -> int:
"""
``perform_insert`` implements a mapping between a virtual address and an absolute file offset, inserting
the bytes ``data`` to rebased address ``addr``.
@@ -2709,7 +2760,7 @@ class BinaryView:
"""
return 0
- def perform_remove(self, addr:int, length:int) -> int:
+ def perform_remove(self, addr: int, length: int) -> int:
"""
``perform_remove`` implements a mapping between a virtual address and an absolute file offset, removing
``length`` bytes from the rebased address ``addr``.
@@ -2725,7 +2776,7 @@ class BinaryView:
"""
return 0
- def perform_get_modification(self, addr:int) -> ModificationStatus:
+ def perform_get_modification(self, addr: int) -> ModificationStatus:
"""
``perform_get_modification`` implements query to the whether the virtual address ``addr`` is modified.
@@ -2740,7 +2791,7 @@ class BinaryView:
"""
return ModificationStatus.Original
- def perform_is_valid_offset(self, addr:int) -> bool:
+ def perform_is_valid_offset(self, addr: int) -> bool:
"""
``perform_is_valid_offset`` implements a check if an virtual address ``addr`` is valid.
@@ -2756,7 +2807,7 @@ class BinaryView:
data = self.read(addr, 1)
return (data is not None) and (len(data) == 1)
- def perform_is_offset_readable(self, offset:int) -> bool:
+ def perform_is_offset_readable(self, offset: int) -> bool:
"""
``perform_is_offset_readable`` implements a check if an virtual address is readable.
@@ -2771,7 +2822,7 @@ class BinaryView:
"""
return self.is_valid_offset(offset)
- def perform_is_offset_writable(self, addr:int) -> bool:
+ def perform_is_offset_writable(self, addr: int) -> bool:
"""
``perform_is_offset_writable`` implements a check if a virtual address ``addr`` is writable.
@@ -2786,7 +2837,7 @@ class BinaryView:
"""
return self.is_valid_offset(addr)
- def perform_is_offset_executable(self, addr:int) -> bool:
+ def perform_is_offset_executable(self, addr: int) -> bool:
"""
``perform_is_offset_executable`` implements a check if a virtual address ``addr`` is executable.
@@ -2801,7 +2852,7 @@ class BinaryView:
"""
return self.is_valid_offset(addr)
- def perform_get_next_valid_offset(self, addr:int) -> int:
+ def perform_get_next_valid_offset(self, addr: int) -> int:
"""
``perform_get_next_valid_offset`` implements a query for the next valid readable, writable, or executable virtual
memory address.
@@ -2886,7 +2937,10 @@ class BinaryView:
"""
return False
- def create_database(self, filename:str, progress_func:Optional[ProgressFuncType]=None, settings:Optional['filemetadata.SaveSettings']=None) -> bool:
+ def create_database(
+ self, filename: str, progress_func: Optional[ProgressFuncType] = None,
+ settings: Optional['filemetadata.SaveSettings'] = None
+ ) -> bool:
"""
``create_database`` writes the current database (.bndb) out to the specified file.
@@ -2902,7 +2956,9 @@ class BinaryView:
"""
return self._file.create_database(filename, progress_func, settings)
- def save_auto_snapshot(self, progress_func:Optional[ProgressFuncType]=None, settings:Optional['filemetadata.SaveSettings']=None) -> bool:
+ def save_auto_snapshot(
+ self, progress_func: Optional[ProgressFuncType] = None, settings: Optional['filemetadata.SaveSettings'] = None
+ ) -> bool:
"""
``save_auto_snapshot`` saves the current database to the already created file.
@@ -2915,7 +2971,7 @@ class BinaryView:
"""
return self._file.save_auto_snapshot(progress_func, settings)
- def get_view_of_type(self, name:str) -> Optional['BinaryView']:
+ def get_view_of_type(self, name: str) -> Optional['BinaryView']:
"""
``get_view_of_type`` returns the BinaryView associated with the provided name if it exists.
@@ -3019,7 +3075,7 @@ class BinaryView:
"""
self._file.redo()
- def navigate(self, view_name:str, offset:int) -> bool:
+ def navigate(self, view_name: str, offset: int) -> bool:
"""
``navigate`` navigates the UI to the specified virtual address
@@ -3037,7 +3093,7 @@ class BinaryView:
"""
return self._file.navigate(view_name, offset)
- def read(self, addr:int, length:int) -> bytes:
+ def read(self, addr: int, length: int) -> bytes:
"""
``read`` returns the data reads at most ``length`` bytes from virtual address ``addr``.
@@ -3060,7 +3116,7 @@ class BinaryView:
buf = databuffer.DataBuffer(handle=core.BNReadViewBuffer(self.handle, addr, length))
return bytes(buf)
- def read_int(self, address:int, size:int, sign:bool=True, endian:Optional[Endianness]=None) -> int:
+ def read_int(self, address: int, size: int, sign: bool = True, endian: Optional[Endianness] = None) -> int:
_endian = self.endianness
if endian is not None:
_endian = endian
@@ -3069,7 +3125,7 @@ class BinaryView:
raise ValueError(f"Couldn't read {size} bytes from address: {address:#x}")
return TypedDataAccessor.int_from_bytes(data, size, sign, _endian)
- def read_pointer(self, address:int, size=None) -> int:
+ def read_pointer(self, address: int, size=None) -> int:
_size = size
if size is None:
if self.arch is None:
@@ -3077,7 +3133,7 @@ class BinaryView:
_size = self.arch.address_size
return self.read_int(address, _size, False, self.endianness)
- def write(self, addr:int, data:bytes, except_on_relocation:bool = True) -> int:
+ def write(self, addr: int, data: bytes, except_on_relocation: bool = True) -> int:
"""
``write`` writes the bytes in ``data`` to the virtual address ``addr``.
@@ -3103,7 +3159,7 @@ class BinaryView:
return core.BNWriteViewBuffer(self.handle, addr, buf.handle)
- def insert(self, addr:int, data:bytes) -> int:
+ def insert(self, addr: int, data: bytes) -> int:
"""
``insert`` inserts the bytes in ``data`` to the virtual address ``addr``.
@@ -3124,7 +3180,7 @@ class BinaryView:
buf = databuffer.DataBuffer(data)
return core.BNInsertViewBuffer(self.handle, addr, buf.handle)
- def remove(self, addr:int, length:int) -> int:
+ def remove(self, addr: int, length: int) -> int:
"""
``remove`` removes at most ``length`` bytes from virtual address ``addr``.
@@ -3143,7 +3199,7 @@ class BinaryView:
"""
return core.BNRemoveViewData(self.handle, addr, length)
- def get_entropy(self, addr:int, length:int, block_size:int=0) -> List[float]:
+ def get_entropy(self, addr: int, length: int, block_size: int = 0) -> List[float]:
"""
``get_entropy`` returns the shannon entropy given the start ``addr``, ``length`` in bytes, and optionally in
``block_size`` chunks.
@@ -3159,14 +3215,14 @@ class BinaryView:
return result
if block_size == 0:
block_size = length
- data = (ctypes.c_float * ((length // block_size) + 1))()
+ data = (ctypes.c_float * ((length//block_size) + 1))()
length = core.BNGetEntropy(self.handle, addr, length, block_size, data)
for i in range(0, length):
result.append(float(data[i]))
return result
- def get_modification(self, addr:int, length:int=None) -> List[ModificationStatus]:
+ def get_modification(self, addr: int, length: int = None) -> List[ModificationStatus]:
"""
``get_modification`` returns the modified bytes of up to ``length`` bytes from virtual address ``addr``, or if
``length`` is None returns the ModificationStatus.
@@ -3182,7 +3238,7 @@ class BinaryView:
length = core.BNGetModificationArray(self.handle, addr, data, length)
return [ModificationStatus(a) for a in data[:length]]
- def is_valid_offset(self, addr:int) -> bool:
+ def is_valid_offset(self, addr: int) -> bool:
"""
``is_valid_offset`` checks if an virtual address ``addr`` is valid .
@@ -3192,7 +3248,7 @@ class BinaryView:
"""
return core.BNIsValidOffset(self.handle, addr)
- def is_offset_readable(self, addr:int) -> bool:
+ def is_offset_readable(self, addr: int) -> bool:
"""
``is_offset_readable`` checks if an virtual address ``addr`` is valid for reading.
@@ -3202,7 +3258,7 @@ class BinaryView:
"""
return core.BNIsOffsetReadable(self.handle, addr)
- def is_offset_writable(self, addr:int) -> bool:
+ def is_offset_writable(self, addr: int) -> bool:
"""
``is_offset_writable`` checks if an virtual address ``addr`` is valid for writing.
@@ -3212,7 +3268,7 @@ class BinaryView:
"""
return core.BNIsOffsetWritable(self.handle, addr)
- def is_offset_executable(self, addr:int) -> bool:
+ def is_offset_executable(self, addr: int) -> bool:
"""
``is_offset_executable`` checks if an virtual address ``addr`` is valid for executing.
@@ -3222,7 +3278,7 @@ class BinaryView:
"""
return core.BNIsOffsetExecutable(self.handle, addr)
- def is_offset_code_semantics(self, addr:int) -> bool:
+ def is_offset_code_semantics(self, addr: int) -> bool:
"""
``is_offset_code_semantics`` checks if an virtual address ``addr`` is semantically valid for code.
@@ -3232,7 +3288,7 @@ class BinaryView:
"""
return core.BNIsOffsetCodeSemantics(self.handle, addr)
- def is_offset_extern_semantics(self, addr:int) -> bool:
+ def is_offset_extern_semantics(self, addr: int) -> bool:
"""
``is_offset_extern_semantics`` checks if an virtual address ``addr`` is semantically valid for external references.
@@ -3242,7 +3298,7 @@ class BinaryView:
"""
return core.BNIsOffsetExternSemantics(self.handle, addr)
- def is_offset_writable_semantics(self, addr:int) -> bool:
+ def is_offset_writable_semantics(self, addr: int) -> bool:
"""
``is_offset_writable_semantics`` checks if an virtual address ``addr`` is semantically writable. Some sections
may have writable permissions for linking purposes but can be treated as read-only for the purposes of
@@ -3254,7 +3310,7 @@ class BinaryView:
"""
return core.BNIsOffsetWritableSemantics(self.handle, addr)
- def save(self, dest:Union['fileaccessor.FileAccessor', str]) -> bool:
+ def save(self, dest: Union['fileaccessor.FileAccessor', str]) -> bool:
"""
``save`` saves the original binary file to the provided destination ``dest`` along with any modifications.
@@ -3266,7 +3322,7 @@ class BinaryView:
return core.BNSaveToFile(self.handle, dest._cb)
return core.BNSaveToFilename(self.handle, str(dest))
- def register_notification(self, notify:BinaryDataNotification) -> None:
+ def register_notification(self, notify: BinaryDataNotification) -> None:
"""
`register_notification` provides a mechanism for receiving callbacks for various analysis events. A full
list of callbacks can be seen in :py:Class:`BinaryDataNotification`.
@@ -3278,7 +3334,7 @@ class BinaryView:
cb._register()
self._notifications[notify] = cb
- def unregister_notification(self, notify:BinaryDataNotification) -> None:
+ def unregister_notification(self, notify: BinaryDataNotification) -> None:
"""
`unregister_notification` unregisters the :py:Class:`BinaryDataNotification` object passed to
`register_notification`
@@ -3290,7 +3346,7 @@ class BinaryView:
self._notifications[notify]._unregister()
del self._notifications[notify]
- def add_function(self, addr:int, plat:Optional['_platform.Platform']=None) -> None:
+ def add_function(self, addr: int, plat: Optional['_platform.Platform'] = None) -> None:
"""
``add_function`` add a new function of the given ``plat`` at the virtual address ``addr``
@@ -3312,7 +3368,7 @@ class BinaryView:
raise AttributeError("Provided platform is not of type `Platform`")
core.BNAddFunctionForAnalysis(self.handle, plat.handle, addr)
- def add_entry_point(self, addr:int, plat:Optional['_platform.Platform']=None) -> None:
+ def add_entry_point(self, addr: int, plat: Optional['_platform.Platform'] = None) -> None:
"""
``add_entry_point`` adds an virtual address to start analysis from for a given plat.
@@ -3331,7 +3387,7 @@ class BinaryView:
raise AttributeError("Provided platform is not of type `Platform`")
core.BNAddEntryPointForAnalysis(self.handle, plat.handle, addr)
- def remove_function(self, func:'_function.Function') -> None:
+ def remove_function(self, func: '_function.Function') -> None:
"""
``remove_function`` removes the function ``func`` from the list of functions
@@ -3349,7 +3405,7 @@ class BinaryView:
"""
core.BNRemoveAnalysisFunction(self.handle, func.handle)
- def create_user_function(self, addr:int, plat:Optional['_platform.Platform']=None) -> '_function.Function':
+ def create_user_function(self, addr: int, plat: Optional['_platform.Platform'] = None) -> '_function.Function':
"""
``create_user_function`` add a new *user* function of the given ``plat`` at the virtual address ``addr``
@@ -3369,7 +3425,7 @@ class BinaryView:
plat = self.platform
return _function.Function(self, core.BNCreateUserFunction(self.handle, plat.handle, addr))
- def remove_user_function(self, func:'_function.Function') -> None:
+ def remove_user_function(self, func: '_function.Function') -> None:
"""
``remove_user_function`` removes the function ``func`` from the list of functions as a user action.
@@ -3387,7 +3443,7 @@ class BinaryView:
"""
core.BNRemoveUserFunction(self.handle, func.handle)
- def add_analysis_option(self, name:str) -> None:
+ def add_analysis_option(self, name: str) -> None:
"""
``add_analysis_option`` adds an analysis option. Analysis options elaborate the analysis phase. The user must
start analysis by calling either :func:`update_analysis` or :func:`update_analysis_and_wait`.
@@ -3411,7 +3467,7 @@ class BinaryView:
"""
return core.BNHasInitialAnalysis(self.handle)
- def set_analysis_hold(self, enable:bool) -> None:
+ def set_analysis_hold(self, enable: bool) -> None:
"""
``set_analysis_hold`` control the analysis hold for this BinaryView. Enabling analysis hold defers all future
analysis updates, therefore causing :func:`update_analysis` or :func:`update_analysis_and_wait` to take no action.
@@ -3452,7 +3508,9 @@ class BinaryView:
"""
core.BNAbortAnalysis(self.handle)
- def define_data_var(self, addr:int, var_type:StringOrType, name:Optional[Union[str, '_types.CoreSymbol']]=None) -> None:
+ def define_data_var(
+ self, addr: int, var_type: StringOrType, name: Optional[Union[str, '_types.CoreSymbol']] = None
+ ) -> None:
"""
``define_data_var`` defines a non-user data variable ``var_type`` at the virtual address ``addr``.
@@ -3483,7 +3541,9 @@ class BinaryView:
name = _types.Symbol(SymbolType.DataSymbol, addr, name)
self.define_auto_symbol(name)
- def define_user_data_var(self, addr:int, var_type:StringOrType, name:Optional[Union[str, '_types.CoreSymbol']]=None) -> Optional['DataVariable']:
+ def define_user_data_var(
+ self, addr: int, var_type: StringOrType, name: Optional[Union[str, '_types.CoreSymbol']] = None
+ ) -> Optional['DataVariable']:
"""
``define_user_data_var`` defines a user data variable ``var_type`` at the virtual address ``addr``.
@@ -3518,7 +3578,7 @@ class BinaryView:
return self.get_data_var_at(addr)
- def undefine_data_var(self, addr:int) -> None:
+ def undefine_data_var(self, addr: int) -> None:
"""
``undefine_data_var`` removes the non-user data variable at the virtual address ``addr``.
@@ -3531,7 +3591,7 @@ class BinaryView:
"""
core.BNUndefineDataVariable(self.handle, addr)
- def undefine_user_data_var(self, addr:int) -> None:
+ def undefine_user_data_var(self, addr: int) -> None:
"""
``undefine_user_data_var`` removes the user data variable at the virtual address ``addr``.
@@ -3544,7 +3604,7 @@ class BinaryView:
"""
core.BNUndefineUserDataVariable(self.handle, addr)
- def get_data_var_at(self, addr:int) -> Optional['DataVariable']:
+ def get_data_var_at(self, addr: int) -> Optional['DataVariable']:
"""
``get_data_var_at`` returns the data type at a given virtual address.
@@ -3564,7 +3624,8 @@ class BinaryView:
return None
return DataVariable.from_core_struct(var, self)
- def get_functions_containing(self, addr:int, plat:Optional['_platform.Platform']=None) -> List['_function.Function']:
+ def get_functions_containing(self, addr: int,
+ plat: Optional['_platform.Platform'] = None) -> List['_function.Function']:
"""
``get_functions_containing`` returns a list of functions which contain the given address.
@@ -3584,7 +3645,9 @@ class BinaryView:
finally:
core.BNFreeFunctionList(funcs, count.value)
- def get_functions_by_name(self, name:str, plat:Optional['_platform.Platform']=None, ordered_filter:Optional[List[SymbolType]]=None) -> List['_function.Function']:
+ def get_functions_by_name(
+ self, name: str, plat: Optional['_platform.Platform'] = None, ordered_filter: Optional[List[SymbolType]] = None
+ ) -> List['_function.Function']:
"""``get_functions_by_name`` returns a list of Function objects
function with a Symbol of ``name``.
@@ -3600,9 +3663,9 @@ class BinaryView:
>>>
"""
if ordered_filter is None:
- ordered_filter = [SymbolType.FunctionSymbol,
- SymbolType.ImportedFunctionSymbol,
- SymbolType.LibraryFunctionSymbol]
+ ordered_filter = [
+ SymbolType.FunctionSymbol, SymbolType.ImportedFunctionSymbol, SymbolType.LibraryFunctionSymbol
+ ]
if plat == None:
plat = self.platform
@@ -3616,7 +3679,7 @@ class BinaryView:
fns.append(fn)
return fns
- def get_function_at(self, addr:int, plat:Optional['_platform.Platform']=None) -> Optional['_function.Function']:
+ def get_function_at(self, addr: int, plat: Optional['_platform.Platform'] = None) -> Optional['_function.Function']:
"""
``get_function_at`` gets a Function object for the function that starts at virtual address ``addr``:
@@ -3644,7 +3707,7 @@ class BinaryView:
return None
return _function.Function(self, func)
- def get_functions_at(self, addr:int) -> List['_function.Function']:
+ def get_functions_at(self, addr: int) -> List['_function.Function']:
"""
``get_functions_at`` get a list of binaryninja.Function objects (one for each valid platform) that start at the
@@ -3670,13 +3733,13 @@ class BinaryView:
finally:
core.BNFreeFunctionList(funcs, count.value)
- def get_recent_function_at(self, addr:int) -> Optional['_function.Function']:
+ def get_recent_function_at(self, addr: int) -> Optional['_function.Function']:
func = core.BNGetRecentAnalysisFunctionForAddress(self.handle, addr)
if func is None:
return None
return _function.Function(self, func)
- def get_basic_blocks_at(self, addr:int) -> List['basicblock.BasicBlock']:
+ def get_basic_blocks_at(self, addr: int) -> List['basicblock.BasicBlock']:
"""
``get_basic_blocks_at`` get a list of :py:Class:`BasicBlock` objects which exist at the provided virtual address.
@@ -3697,7 +3760,7 @@ class BinaryView:
finally:
core.BNFreeBasicBlockList(blocks, count.value)
- def get_basic_blocks_starting_at(self, addr:int) -> List['basicblock.BasicBlock']:
+ def get_basic_blocks_starting_at(self, addr: int) -> List['basicblock.BasicBlock']:
"""
``get_basic_blocks_starting_at`` get a list of :py:Class:`BasicBlock` objects which start at the provided virtual address.
@@ -3718,13 +3781,13 @@ class BinaryView:
finally:
core.BNFreeBasicBlockList(blocks, count.value)
- def get_recent_basic_block_at(self, addr:int) -> Optional['basicblock.BasicBlock']:
+ def get_recent_basic_block_at(self, addr: int) -> Optional['basicblock.BasicBlock']:
block = core.BNGetRecentBasicBlockForAddress(self.handle, addr)
if block is None:
return None
return basicblock.BasicBlock(block, self)
- def get_code_refs(self, addr:int, length:int=None) -> Generator['ReferenceSource', None, None]:
+ def get_code_refs(self, addr: int, length: int = None) -> Generator['ReferenceSource', None, None]:
"""
``get_code_refs`` returns a Generator[ReferenceSource] objects (xrefs or cross-references) that point to the provided virtual address.
This function returns both autoanalysis ("auto") and user-specified ("user") xrefs.
@@ -3755,7 +3818,10 @@ class BinaryView:
finally:
core.BNFreeCodeReferences(refs, count.value)
- def get_code_refs_from(self, addr:int, func:Optional['_function.Function']=None, arch:Optional['architecture.Architecture']=None, length:Optional[int]=None) -> List[int]:
+ def get_code_refs_from(
+ self, addr: int, func: Optional['_function.Function'] = None,
+ arch: Optional['architecture.Architecture'] = None, length: Optional[int] = None
+ ) -> List[int]:
"""
``get_code_refs_from`` returns a list of virtual addresses referenced by code in the function ``func``,
of the architecture ``arch``, and at the address ``addr``. If no function is specified, references from
@@ -3791,7 +3857,7 @@ class BinaryView:
core.BNFreeAddressList(refs)
return result
- def get_data_refs(self, addr:int, length:int=None) -> Generator[int, None, None]:
+ def get_data_refs(self, addr: int, length: int = None) -> Generator[int, None, None]:
"""
``get_data_refs`` returns a list of virtual addresses of data which references ``addr``. Optionally specifying
a length. When ``length`` is set ``get_data_refs`` returns the data which references in the range ``addr``-``addr``+``length``.
@@ -3822,7 +3888,7 @@ class BinaryView:
finally:
core.BNFreeDataReferences(refs)
- def get_data_refs_from(self, addr:int, length:int=None) -> Generator[int, None, None]:
+ def get_data_refs_from(self, addr: int, length: int = None) -> Generator[int, None, None]:
"""
``get_data_refs_from`` returns a list of virtual addresses referenced by the address ``addr``. Optionally specifying
a length. When ``length`` is set ``get_data_refs_from`` returns the data referenced in the range ``addr``-``addr``+``length``.
@@ -3853,7 +3919,7 @@ class BinaryView:
finally:
core.BNFreeDataReferences(refs)
- def get_code_refs_for_type(self, name:str) -> Generator[ReferenceSource, None, None]:
+ def get_code_refs_for_type(self, name: str) -> Generator[ReferenceSource, None, None]:
"""
``get_code_refs_for_type`` returns a Generator[ReferenceSource] objects (xrefs or cross-references) that reference the provided QualifiedName.
@@ -3878,8 +3944,8 @@ class BinaryView:
finally:
core.BNFreeCodeReferences(refs, count.value)
-
- def get_code_refs_for_type_field(self, name:str, offset:int) -> Generator['_types.TypeFieldReference', None, None]:
+ def get_code_refs_for_type_field(self, name: str,
+ offset: int) -> Generator['_types.TypeFieldReference', None, None]:
"""
``get_code_refs_for_type`` returns a Generator[TypeFieldReference] objects (xrefs or cross-references) that reference the provided type field.
@@ -3913,13 +3979,14 @@ class BinaryView:
size = refs[i].size
typeObj = None
if refs[i].incomingType.type:
- typeObj = _types.Type(core.BNNewTypeReference(refs[i].incomingType.type),
- confidence = refs[i].incomingType.confidence)
+ typeObj = _types.Type(
+ core.BNNewTypeReference(refs[i].incomingType.type), confidence=refs[i].incomingType.confidence
+ )
yield _types.TypeFieldReference(func, arch, addr, size, typeObj)
finally:
core.BNFreeTypeFieldReferences(refs, count.value)
- def get_data_refs_for_type(self, name:str) -> Generator[int, None, None]:
+ def get_data_refs_for_type(self, name: str) -> Generator[int, None, None]:
"""
``get_data_refs_for_type`` returns a list of virtual addresses of data which references the type ``name``.
Note, the returned addresses are the actual start of the queried type. For example, suppose there is a DataVariable
@@ -3946,8 +4013,7 @@ class BinaryView:
finally:
core.BNFreeDataReferences(refs)
-
- def get_data_refs_for_type_field(self, name:'_types.QualifiedNameType', offset:int) -> List[int]:
+ def get_data_refs_for_type_field(self, name: '_types.QualifiedNameType', offset: int) -> List[int]:
"""
``get_data_refs_for_type_field`` returns a list of virtual addresses of data which references the type ``name``.
Note, the returned addresses are the actual start of the queried type field. For example, suppose there is a
@@ -3977,8 +4043,7 @@ class BinaryView:
finally:
core.BNFreeDataReferences(refs)
-
- def get_type_refs_for_type(self, name:'_types.QualifiedNameType') -> List['_types.TypeReferenceSource']:
+ def get_type_refs_for_type(self, name: '_types.QualifiedNameType') -> List['_types.TypeReferenceSource']:
"""
``get_type_refs_for_type`` returns a list of TypeReferenceSource objects (xrefs or cross-references) that reference the provided QualifiedName.
@@ -4000,14 +4065,16 @@ class BinaryView:
result = []
try:
for i in range(0, count.value):
- type_field = _types.TypeReferenceSource(_types.QualifiedName._from_core_struct(refs[i].name), refs[i].offset, refs[i].type)
+ type_field = _types.TypeReferenceSource(
+ _types.QualifiedName._from_core_struct(refs[i].name), refs[i].offset, refs[i].type
+ )
result.append(type_field)
return result
finally:
core.BNFreeTypeReferences(refs, count.value)
-
- def get_type_refs_for_type_field(self, name:'_types.QualifiedNameType', offset:int) -> List['_types.TypeReferenceSource']:
+ def get_type_refs_for_type_field(self, name: '_types.QualifiedNameType',
+ offset: int) -> List['_types.TypeReferenceSource']:
"""
``get_type_refs_for_type`` returns a list of TypeReferenceSource objects (xrefs or cross-references) that reference the provided type field.
@@ -4030,13 +4097,18 @@ class BinaryView:
result = []
try:
for i in range(0, count.value):
- type_field = _types.TypeReferenceSource(_types.QualifiedName._from_core_struct(refs[i].name), refs[i].offset, refs[i].type)
+ type_field = _types.TypeReferenceSource(
+ _types.QualifiedName._from_core_struct(refs[i].name), refs[i].offset, refs[i].type
+ )
result.append(type_field)
return result
finally:
core.BNFreeTypeReferences(refs, count.value)
- def get_code_refs_for_type_from(self, addr:int, func:Optional['_function.Function']=None, arch:Optional['architecture.Architecture']= None, length:Optional[int] = None) -> List['_types.TypeReferenceSource']:
+ def get_code_refs_for_type_from(
+ self, addr: int, func: Optional['_function.Function'] = None,
+ arch: Optional['architecture.Architecture'] = None, length: Optional[int] = None
+ ) -> List['_types.TypeReferenceSource']:
"""
``get_code_refs_for_type_from`` returns a list of types referenced by code in the function ``func``,
of the architecture ``arch``, and at the address ``addr``. If no function is specified, references from
@@ -4065,13 +4137,18 @@ class BinaryView:
assert refs is not None, "core.BNGetCodeReferencesForTypeFromInRange returned None"
try:
for i in range(0, count.value):
- type_field = _types.TypeReferenceSource(_types.QualifiedName._from_core_struct(refs[i].name), refs[i].offset, refs[i].type)
+ type_field = _types.TypeReferenceSource(
+ _types.QualifiedName._from_core_struct(refs[i].name), refs[i].offset, refs[i].type
+ )
result.append(type_field)
finally:
core.BNFreeTypeReferences(refs, count.value)
return result
- def get_code_refs_for_type_fields_from(self, addr:int, func:Optional['_function.Function']=None, arch:Optional['architecture.Architecture']= None, length:Optional[int] = None) -> List['_types.TypeReferenceSource']:
+ def get_code_refs_for_type_fields_from(
+ self, addr: int, func: Optional['_function.Function'] = None,
+ arch: Optional['architecture.Architecture'] = None, length: Optional[int] = None
+ ) -> List['_types.TypeReferenceSource']:
"""
``get_code_refs_for_type_fields_from`` returns a list of type fields referenced by code in the function ``func``,
of the architecture ``arch``, and at the address ``addr``. If no function is specified, references from
@@ -4100,13 +4177,15 @@ class BinaryView:
assert refs is not None, "core.BNGetCodeReferencesForTypeFieldsFromInRange returned None"
try:
for i in range(0, count.value):
- type_field = _types.TypeReferenceSource(_types.QualifiedName._from_core_struct(refs[i].name), refs[i].offset, refs[i].type)
+ type_field = _types.TypeReferenceSource(
+ _types.QualifiedName._from_core_struct(refs[i].name), refs[i].offset, refs[i].type
+ )
result.append(type_field)
finally:
core.BNFreeTypeReferences(refs, count.value)
return result
- def add_user_data_ref(self, from_addr:int, to_addr:int) -> None:
+ def add_user_data_ref(self, from_addr: int, to_addr: int) -> None:
"""
``add_user_data_ref`` adds a user-specified data cross-reference (xref) from the address ``from_addr`` to the address ``to_addr``.
If the reference already exists, no action is performed. To remove the reference, use :func:`remove_user_data_ref`.
@@ -4117,8 +4196,7 @@ class BinaryView:
"""
core.BNAddUserDataReference(self.handle, from_addr, to_addr)
-
- def remove_user_data_ref(self, from_addr:int, to_addr:int) -> None:
+ def remove_user_data_ref(self, from_addr: int, to_addr: int) -> None:
"""
``remove_user_data_ref`` removes a user-specified data cross-reference (xref) from the address ``from_addr`` to the address ``to_addr``.
This function will only remove user-specified references, not ones generated during autoanalysis.
@@ -4130,8 +4208,7 @@ class BinaryView:
"""
core.BNRemoveUserDataReference(self.handle, from_addr, to_addr)
-
- def get_all_fields_referenced(self, name:'_types.QualifiedNameType') -> List[int]:
+ def get_all_fields_referenced(self, name: '_types.QualifiedNameType') -> List[int]:
"""
``get_all_fields_referenced`` returns a list of offsets in the QualifiedName
specified by name, which are referenced by code.
@@ -4159,7 +4236,7 @@ class BinaryView:
finally:
core.BNFreeDataReferences(refs)
- def get_all_sizes_referenced(self, name:'_types.QualifiedNameType') -> Mapping[int, List[int]]:
+ def get_all_sizes_referenced(self, name: '_types.QualifiedNameType') -> Mapping[int, List[int]]:
"""
``get_all_sizes_referenced`` returns a map from field offset to a list of sizes of
the accesses to it.
@@ -4178,7 +4255,7 @@ class BinaryView:
_name = _types.QualifiedName(name)._to_core_struct()
refs = core.BNGetAllSizesReferenced(self.handle, _name, count)
assert refs is not None, "core.BNGetAllSizesReferenced returned None"
- result:Mapping[int, List[int]] = {}
+ result: Mapping[int, List[int]] = {}
try:
for i in range(0, count.value):
result[refs[i].offset] = []
@@ -4188,7 +4265,7 @@ class BinaryView:
finally:
core.BNFreeTypeFieldReferenceSizeInfo(refs, count.value)
- def get_all_types_referenced(self, name:'_types.QualifiedNameType') -> Mapping[int, List['_types.Type']]:
+ def get_all_types_referenced(self, name: '_types.QualifiedNameType') -> Mapping[int, List['_types.Type']]:
"""
``get_all_types_referenced`` returns a map from field offset to a related to the
type field access.
@@ -4209,19 +4286,20 @@ class BinaryView:
refs = core.BNGetAllTypesReferenced(self.handle, _name, count)
assert refs is not None, "core.BNGetAllTypesReferenced returned None"
- result:Mapping[int, List['_types.Type']] = {}
+ result: Mapping[int, List['_types.Type']] = {}
try:
for i in range(0, count.value):
result[refs[i].offset] = []
for j in range(0, refs[i].count):
- typeObj = _types.Type.create(core.BNNewTypeReference(refs[i].types[j].type),
- self.platform, refs[i].types[j].confidence)
+ typeObj = _types.Type.create(
+ core.BNNewTypeReference(refs[i].types[j].type), self.platform, refs[i].types[j].confidence
+ )
result[refs[i].offset].append(typeObj)
return result
finally:
core.BNFreeTypeFieldReferenceTypeInfo(refs, count.value)
- def get_sizes_referenced(self, name:'_types.QualifiedNameType', offset:int) -> List[int]:
+ def get_sizes_referenced(self, name: '_types.QualifiedNameType', offset: int) -> List[int]:
"""
``get_sizes_referenced`` returns a list of sizes of the accesses to it.
@@ -4249,7 +4327,7 @@ class BinaryView:
finally:
core.BNFreeTypeFieldReferenceSizes(refs, count.value)
- def get_types_referenced(self, name:'_types.QualifiedName', offset:int) -> List['_types.Type']:
+ def get_types_referenced(self, name: '_types.QualifiedName', offset: int) -> List['_types.Type']:
"""
``get_types_referenced`` returns a list of types related to the type field access.
@@ -4270,14 +4348,13 @@ class BinaryView:
try:
result = []
for i in range(0, count.value):
- typeObj = _types.Type.create(core.BNNewTypeReference(refs[i].type),
- confidence = refs[i].confidence)
+ typeObj = _types.Type.create(core.BNNewTypeReference(refs[i].type), confidence=refs[i].confidence)
result.append(typeObj)
return result
finally:
core.BNFreeTypeFieldReferenceTypes(refs, count.value)
- def create_structure_from_offset_access(self, name:'_types.QualifiedName') -> '_types.StructureType':
+ def create_structure_from_offset_access(self, name: '_types.QualifiedName') -> '_types.StructureType':
newMemberAdded = ctypes.c_bool(False)
_name = _types.QualifiedName(name)._to_core_struct()
struct = core.BNCreateStructureFromOffsetAccess(self.handle, _name, newMemberAdded)
@@ -4285,16 +4362,15 @@ class BinaryView:
raise Exception("BNCreateStructureFromOffsetAccess failed to create struct from offsets")
return _types.StructureType.from_core_struct(struct)
- def create_structure_member_from_access(self, name:'_types.QualifiedName', offset:int) -> '_types.Type':
+ def create_structure_member_from_access(self, name: '_types.QualifiedName', offset: int) -> '_types.Type':
_name = _types.QualifiedName(name)._to_core_struct()
result = core.BNCreateStructureMemberFromAccess(self.handle, _name, offset)
if not result.type:
raise Exception("BNCreateStructureMemberFromAccess failed to create struct member offsets")
- return _types.Type.create(core.BNNewTypeReference(result.type),
- confidence = result.confidence)
+ return _types.Type.create(core.BNNewTypeReference(result.type), confidence=result.confidence)
- def get_callers(self, addr:int) -> Generator[ReferenceSource, None, None]:
+ def get_callers(self, addr: int) -> Generator[ReferenceSource, None, None]:
"""
``get_callers`` returns a list of ReferenceSource objects (xrefs or cross-references) that call the provided virtual address.
In this case, tail calls, jumps, and ordinary calls are considered.
@@ -4318,7 +4394,8 @@ class BinaryView:
finally:
core.BNFreeCodeReferences(refs, count.value)
- def get_callees(self, addr:int, func:'_function.Function'=None, arch:'architecture.Architecture'=None) -> List[int]:
+ def get_callees(self, addr: int, func: '_function.Function' = None,
+ arch: 'architecture.Architecture' = None) -> List[int]:
"""
``get_callees`` returns a list of virtual addresses called by the call site in the function ``func``,
of the architecture ``arch``, and at the address ``addr``. If no function is specified, call sites from
@@ -4350,7 +4427,7 @@ class BinaryView:
core.BNFreeAddressList(refs)
return result
- def get_symbol_at(self, addr:int, namespace:'_types.NameSpaceType'=None) -> Optional['_types.CoreSymbol']:
+ def get_symbol_at(self, addr: int, namespace: '_types.NameSpaceType' = None) -> Optional['_types.CoreSymbol']:
"""
``get_symbol_at`` returns the Symbol at the provided virtual address.
@@ -4370,7 +4447,7 @@ class BinaryView:
return None
return _types.CoreSymbol(sym)
- def get_symbols_by_raw_name(self, name:str, namespace:'_types.NameSpaceType'=None) -> List['_types.CoreSymbol']:
+ def get_symbols_by_raw_name(self, name: str, namespace: '_types.NameSpaceType' = None) -> List['_types.CoreSymbol']:
_namespace = _types.NameSpace.get_core_struct(namespace)
count = ctypes.c_ulonglong(0)
syms = core.BNGetSymbolsByRawName(self.handle, name, count, _namespace)
@@ -4385,7 +4462,8 @@ class BinaryView:
finally:
core.BNFreeSymbolList(syms, count.value)
- def get_symbol_by_raw_name(self, name:str, namespace:'_types.NameSpaceType'=None) -> Optional['_types.CoreSymbol']:
+ def get_symbol_by_raw_name(self, name: str,
+ namespace: '_types.NameSpaceType' = None) -> Optional['_types.CoreSymbol']:
"""
``get_symbol_by_raw_name`` retrieves a Symbol object for the given a raw (mangled) name.
@@ -4405,7 +4483,9 @@ class BinaryView:
return None
return _types.CoreSymbol(sym)
- def get_symbols_by_name(self, name:str, namespace:'_types.NameSpaceType'=None, ordered_filter:Optional[List[SymbolType]]=None) -> List['_types.CoreSymbol']:
+ def get_symbols_by_name(
+ self, name: str, namespace: '_types.NameSpaceType' = None, ordered_filter: Optional[List[SymbolType]] = None
+ ) -> List['_types.CoreSymbol']:
"""
``get_symbols_by_name`` retrieves a list of Symbol objects for the given symbol name and ordered filter
@@ -4422,13 +4502,11 @@ class BinaryView:
>>>
"""
if ordered_filter is None:
- ordered_filter = [SymbolType.FunctionSymbol,
- SymbolType.ImportedFunctionSymbol,
- SymbolType.LibraryFunctionSymbol,
- SymbolType.DataSymbol,
- SymbolType.ImportedDataSymbol,
- SymbolType.ImportAddressSymbol,
- SymbolType.ExternalSymbol]
+ ordered_filter = [
+ SymbolType.FunctionSymbol, SymbolType.ImportedFunctionSymbol, SymbolType.LibraryFunctionSymbol,
+ SymbolType.DataSymbol, SymbolType.ImportedDataSymbol, SymbolType.ImportAddressSymbol,
+ SymbolType.ExternalSymbol
+ ]
_namespace = _types.NameSpace.get_core_struct(namespace)
count = ctypes.c_ulonglong(0)
@@ -4440,12 +4518,16 @@ class BinaryView:
handle = core.BNNewSymbolReference(syms[i])
assert handle is not None, "core.BNNewSymbolReference returned None"
result.append(_types.CoreSymbol(handle))
- result = sorted(filter(lambda sym: sym.type in ordered_filter, result), key=lambda sym: ordered_filter.index(sym.type))
+ result = sorted(
+ filter(lambda sym: sym.type in ordered_filter, result), key=lambda sym: ordered_filter.index(sym.type)
+ )
return result
finally:
core.BNFreeSymbolList(syms, count.value)
- def get_symbols(self, start:Optional[int]=None, length:Optional[int]=None, namespace:'_types.NameSpaceType'=None) -> List['_types.CoreSymbol']:
+ def get_symbols(
+ self, start: Optional[int] = None, length: Optional[int] = None, namespace: '_types.NameSpaceType' = None
+ ) -> List['_types.CoreSymbol']:
"""
``get_symbols`` retrieves the list of all Symbol objects in the optionally provided range.
@@ -4479,8 +4561,10 @@ class BinaryView:
finally:
core.BNFreeSymbolList(syms, count.value)
- def get_symbols_of_type(self, sym_type:SymbolType, start:Optional[int]=None, length:Optional[int]=None,
- namespace:'_types.NameSpaceType'=None) -> List['_types.CoreSymbol']:
+ def get_symbols_of_type(
+ self, sym_type: SymbolType, start: Optional[int] = None, length: Optional[int] = None,
+ namespace: '_types.NameSpaceType' = None
+ ) -> List['_types.CoreSymbol']:
"""
``get_symbols_of_type`` retrieves a list of all Symbol objects of the provided symbol type in the optionally
provided range.
@@ -4517,7 +4601,7 @@ class BinaryView:
finally:
core.BNFreeSymbolList(syms, count.value)
- def define_auto_symbol(self, sym:'_types.CoreSymbol') -> None:
+ def define_auto_symbol(self, sym: '_types.CoreSymbol') -> None:
"""
``define_auto_symbol`` adds a symbol to the internal list of automatically discovered Symbol objects in a given
namespace.
@@ -4529,8 +4613,9 @@ class BinaryView:
"""
core.BNDefineAutoSymbol(self.handle, sym.handle)
- def define_auto_symbol_and_var_or_function(self, sym:'_types.CoreSymbol', sym_type:SymbolType,
- plat:Optional['_platform.Platform']=None) -> Optional['_types.CoreSymbol']:
+ def define_auto_symbol_and_var_or_function(
+ self, sym: '_types.CoreSymbol', sym_type: SymbolType, plat: Optional['_platform.Platform'] = None
+ ) -> Optional['_types.CoreSymbol']:
"""
``define_auto_symbol_and_var_or_function``
@@ -4558,7 +4643,7 @@ class BinaryView:
return None
return _types.CoreSymbol(_sym)
- def undefine_auto_symbol(self, sym:'_types.CoreSymbol') -> None:
+ def undefine_auto_symbol(self, sym: '_types.CoreSymbol') -> None:
"""
``undefine_auto_symbol`` removes a symbol from the internal list of automatically discovered Symbol objects.
@@ -4567,7 +4652,7 @@ class BinaryView:
"""
core.BNUndefineAutoSymbol(self.handle, sym.handle)
- def define_user_symbol(self, sym:'_types.CoreSymbol') -> None:
+ def define_user_symbol(self, sym: '_types.CoreSymbol') -> None:
"""
``define_user_symbol`` adds a symbol to the internal list of user added Symbol objects.
@@ -4578,7 +4663,7 @@ class BinaryView:
"""
core.BNDefineUserSymbol(self.handle, sym.handle)
- def undefine_user_symbol(self, sym:'_types.CoreSymbol') -> None:
+ def undefine_user_symbol(self, sym: '_types.CoreSymbol') -> None:
"""
``undefine_user_symbol`` removes a symbol from the internal list of user added Symbol objects.
@@ -4587,7 +4672,9 @@ class BinaryView:
"""
core.BNUndefineUserSymbol(self.handle, sym.handle)
- def define_imported_function(self, import_addr_sym:'_types.CoreSymbol', func:'_function.Function', type:Optional['_types.Type']=None) -> None:
+ def define_imported_function(
+ self, import_addr_sym: '_types.CoreSymbol', func: '_function.Function', type: Optional['_types.Type'] = None
+ ) -> None:
"""
``define_imported_function`` defines an imported Function ``func`` with a ImportedFunctionSymbol type.
@@ -4595,9 +4682,11 @@ class BinaryView:
:param Function func: A Function object to define as an imported function
:rtype: None
"""
- core.BNDefineImportedFunction(self.handle, import_addr_sym.handle, func.handle, None if type is None else type.handle)
+ core.BNDefineImportedFunction(
+ self.handle, import_addr_sym.handle, func.handle, None if type is None else type.handle
+ )
- def create_tag_type(self, name:str, icon:str) -> 'TagType':
+ def create_tag_type(self, name: str, icon: str) -> 'TagType':
"""
``create_tag_type`` creates a new Tag Type and adds it to the view
@@ -4619,7 +4708,7 @@ class BinaryView:
core.BNAddTagType(self.handle, tag_type.handle)
return tag_type
- def remove_tag_type(self, tag_type:'TagType') -> None:
+ def remove_tag_type(self, tag_type: 'TagType') -> None:
"""
``remove_tag_type`` removes a new Tag Type and all tags that use it
@@ -4642,7 +4731,7 @@ class BinaryView:
count = ctypes.c_ulonglong(0)
types = core.BNGetTagTypes(self.handle, count)
assert types is not None, "core.BNGetTagTypes returned None"
- result:Mapping[str, Union['TagType', List['TagType']]] = {}
+ result: Mapping[str, Union['TagType', List['TagType']]] = {}
try:
for i in range(0, count.value):
tag_handle = core.BNNewTagTypeReference(types[i])
@@ -4661,7 +4750,7 @@ class BinaryView:
finally:
core.BNFreeTagTypeList(types, count.value)
- def get_tag_type(self, name:str) -> Optional['TagType']:
+ def get_tag_type(self, name: str) -> Optional['TagType']:
"""
Get a tag type by its name. Shorthand for get_tag_type_by_name()
:param name: Name of the tag type
@@ -4670,7 +4759,7 @@ class BinaryView:
"""
return self.get_tag_type_by_name(name)
- def get_tag_type_by_name(self, name:str) -> Optional['TagType']:
+ def get_tag_type_by_name(self, name: str) -> Optional['TagType']:
"""
Get a tag type by its name
:param name: Name of the tag type
@@ -4682,7 +4771,7 @@ class BinaryView:
return None
return TagType(tag_type)
- def get_tag_type_by_id(self, id:str) -> Optional['TagType']:
+ def get_tag_type_by_id(self, id: str) -> Optional['TagType']:
"""
Get a tag type by its id
:param id: Id of the tag type
@@ -4694,13 +4783,13 @@ class BinaryView:
return None
return TagType(tag_type)
- def create_user_tag(self, type:'TagType', data:str) -> 'Tag':
+ def create_user_tag(self, type: 'TagType', data: str) -> 'Tag':
return self.create_tag(type, data, True)
- def create_auto_tag(self, type:'TagType', data:str) -> 'Tag':
+ def create_auto_tag(self, type: 'TagType', data: str) -> 'Tag':
return self.create_tag(type, data, False)
- def create_tag(self, tag_type:'TagType', data:str, user:bool=True) -> 'Tag':
+ def create_tag(self, tag_type: 'TagType', data: str, user: bool = True) -> 'Tag':
"""
``create_tag`` creates a new Tag object but does not add it anywhere.
Use :py:meth:`create_user_data_tag` to create and add in one step.
@@ -4725,7 +4814,7 @@ class BinaryView:
core.BNAddTag(self.handle, tag.handle, user)
return tag
- def get_tag(self, id:str) -> Optional['Tag']:
+ def get_tag(self, id: str) -> Optional['Tag']:
"""
Get a tag by its id. Note this does not tell you anything about where it is used.
:param id: Tag id
@@ -4807,7 +4896,7 @@ class BinaryView:
finally:
core.BNFreeTagReferences(refs, count.value)
- def get_data_tags_at(self, addr:int) -> List['Tag']:
+ def get_data_tags_at(self, addr: int) -> List['Tag']:
"""
``get_data_tags_at`` gets a list of all Tags for a data address.
@@ -4828,7 +4917,7 @@ class BinaryView:
finally:
core.BNFreeTagList(tags, count.value)
- def get_auto_data_tags_at(self, addr:int) -> List['Tag']:
+ def get_auto_data_tags_at(self, addr: int) -> List['Tag']:
"""
``get_auto_data_tags_at`` gets a list of all auto-defined Tags for a data address.
@@ -4849,7 +4938,7 @@ class BinaryView:
finally:
core.BNFreeTagList(tags, count.value)
- def get_user_data_tags_at(self, addr:int) -> List['Tag']:
+ def get_user_data_tags_at(self, addr: int) -> List['Tag']:
"""
``get_user_data_tags_at`` gets a list of all user Tags for a data address.
@@ -4870,7 +4959,7 @@ class BinaryView:
finally:
core.BNFreeTagList(tags, count.value)
- def get_data_tags_of_type(self, addr:int, tag_type:'TagType') -> List['Tag']:
+ def get_data_tags_of_type(self, addr: int, tag_type: 'TagType') -> List['Tag']:
"""
``get_data_tags_of_type`` gets a list of all Tags for a data address of a given type.
@@ -4892,7 +4981,7 @@ class BinaryView:
finally:
core.BNFreeTagList(tags, count.value)
- def get_auto_data_tags_of_type(self, addr:int, tag_type:'TagType') -> List['Tag']:
+ def get_auto_data_tags_of_type(self, addr: int, tag_type: 'TagType') -> List['Tag']:
"""
``get_auto_data_tags_of_type`` gets a list of all auto-defined Tags for a data address of a given type.
@@ -4914,7 +5003,7 @@ class BinaryView:
finally:
core.BNFreeTagList(tags, count.value)
- def get_user_data_tags_of_type(self, addr:int, tag_type:'TagType') -> List['Tag']:
+ def get_user_data_tags_of_type(self, addr: int, tag_type: 'TagType') -> List['Tag']:
"""
``get_user_data_tags_of_type`` gets a list of all user Tags for a data address of a given type.
@@ -4936,7 +5025,7 @@ class BinaryView:
finally:
core.BNFreeTagList(tags, count.value)
- def get_data_tags_in_range(self, address_range:'variable.AddressRange') -> List[Tuple[int, 'Tag']]:
+ def get_data_tags_in_range(self, address_range: 'variable.AddressRange') -> List[Tuple[int, 'Tag']]:
"""
``get_data_tags_in_range`` gets a list of all data Tags in a given range.
Range is inclusive at the start, exclusive at the end.
@@ -4959,7 +5048,7 @@ class BinaryView:
finally:
core.BNFreeTagReferences(refs, count.value)
- def get_auto_data_tags_in_range(self, address_range:'variable.AddressRange') -> List[Tuple[int, 'Tag']]:
+ def get_auto_data_tags_in_range(self, address_range: 'variable.AddressRange') -> List[Tuple[int, 'Tag']]:
"""
``get_auto_data_tags_in_range`` gets a list of all auto-defined data Tags in a given range.
Range is inclusive at the start, exclusive at the end.
@@ -4982,7 +5071,7 @@ class BinaryView:
finally:
core.BNFreeTagReferences(refs, count.value)
- def get_user_data_tags_in_range(self, address_range:'variable.AddressRange') -> List[Tuple[int, 'Tag']]:
+ def get_user_data_tags_in_range(self, address_range: 'variable.AddressRange') -> List[Tuple[int, 'Tag']]:
"""
``get_user_data_tags_in_range`` gets a list of all user data Tags in a given range.
Range is inclusive at the start, exclusive at the end.
@@ -5005,7 +5094,7 @@ class BinaryView:
finally:
core.BNFreeTagReferences(refs, count.value)
- def add_user_data_tag(self, addr:int, tag:'Tag') -> None:
+ def add_user_data_tag(self, addr: int, tag: 'Tag') -> None:
"""
``add_user_data_tag`` adds an already-created Tag object at a data address.
Since this adds a user tag, it will be added to the current undo buffer.
@@ -5018,7 +5107,7 @@ class BinaryView:
"""
core.BNAddUserDataTag(self.handle, addr, tag.handle)
- def create_user_data_tag(self, addr:int, type:'TagType', data:str, unique:bool=False) -> 'Tag':
+ def create_user_data_tag(self, addr: int, type: 'TagType', data: str, unique: bool = False) -> 'Tag':
"""
``create_user_data_tag`` creates and adds a Tag object at a data
address. Since this adds a user tag, it will be added to the current
@@ -5050,7 +5139,7 @@ class BinaryView:
core.BNAddUserDataTag(self.handle, addr, tag.handle)
return tag
- def remove_user_data_tag(self, addr:int, tag:Tag) -> None:
+ def remove_user_data_tag(self, addr: int, tag: Tag) -> None:
"""
``remove_user_data_tag`` removes a Tag object at a data address.
Since this removes a user tag, it will be added to the current undo buffer.
@@ -5061,7 +5150,7 @@ class BinaryView:
"""
core.BNRemoveUserDataTag(self.handle, addr, tag.handle)
- def remove_user_data_tags_of_type(self, addr:int, tag_type:'TagType') -> None:
+ def remove_user_data_tags_of_type(self, addr: int, tag_type: 'TagType') -> None:
"""
``remove_user_data_tags_of_type`` removes all data tags at the given address of the given type.
Since this removes user tags, it will be added to the current undo buffer.
@@ -5072,7 +5161,7 @@ class BinaryView:
"""
core.BNRemoveUserDataTagsOfType(self.handle, addr, tag_type.handle)
- def add_auto_data_tag(self, addr:int, tag:'Tag') -> None:
+ def add_auto_data_tag(self, addr: int, tag: 'Tag') -> None:
"""
``add_auto_data_tag`` adds an already-created Tag object at a data address.
If you want want to create the tag as well, consider using
@@ -5084,7 +5173,7 @@ class BinaryView:
"""
core.BNAddAutoDataTag(self.handle, addr, tag.handle)
- def create_auto_data_tag(self, addr:int, type:'TagType', data:str, unique:bool=False) -> 'Tag':
+ def create_auto_data_tag(self, addr: int, type: 'TagType', data: str, unique: bool = False) -> 'Tag':
"""
``create_auto_data_tag`` creates and adds a Tag object at a data address.
@@ -5105,7 +5194,7 @@ class BinaryView:
core.BNAddAutoDataTag(self.handle, addr, tag.handle)
return tag
- def remove_auto_data_tag(self, addr:int, tag:'Tag') -> None:
+ def remove_auto_data_tag(self, addr: int, tag: 'Tag') -> None:
"""
``remove_auto_data_tag`` removes a Tag object at a data address.
Since this removes a user tag, it will be added to the current undo buffer.
@@ -5116,7 +5205,7 @@ class BinaryView:
"""
core.BNRemoveAutoDataTag(self.handle, addr, tag.handle)
- def remove_auto_data_tags_of_type(self, addr:int, tag_type:'TagType') -> None:
+ def remove_auto_data_tags_of_type(self, addr: int, tag_type: 'TagType') -> None:
"""
``remove_auto_data_tags_of_type`` removes all data tags at the given address of the given type.
Since this removes user tags, it will be added to the current undo buffer.
@@ -5127,7 +5216,7 @@ class BinaryView:
"""
core.BNRemoveAutoDataTagsOfType(self.handle, addr, tag_type.handle)
- def can_assemble(self, arch:Optional['architecture.Architecture']=None) -> bool:
+ def can_assemble(self, arch: Optional['architecture.Architecture'] = None) -> bool:
"""
``can_assemble`` queries the architecture plugin to determine if the architecture can assemble instructions.
@@ -5145,7 +5234,7 @@ class BinaryView:
arch = self.arch
return core.BNCanAssemble(self.handle, arch.handle)
- def is_never_branch_patch_available(self, addr:int, arch:Optional['architecture.Architecture']=None) -> bool:
+ def is_never_branch_patch_available(self, addr: int, arch: Optional['architecture.Architecture'] = None) -> bool:
"""
``is_never_branch_patch_available`` queries the architecture plugin to determine if the instruction at the
instruction at ``addr`` can be made to **never branch**. The actual logic of which is implemented in the
@@ -5173,7 +5262,7 @@ class BinaryView:
arch = self.arch
return core.BNIsNeverBranchPatchAvailable(self.handle, arch.handle, addr)
- def is_always_branch_patch_available(self, addr:int, arch:Optional['architecture.Architecture']=None) -> bool:
+ def is_always_branch_patch_available(self, addr: int, arch: Optional['architecture.Architecture'] = None) -> bool:
"""
``is_always_branch_patch_available`` queries the architecture plugin to determine if the
instruction at ``addr`` can be made to **always branch**. The actual logic of which is implemented in the
@@ -5201,7 +5290,7 @@ class BinaryView:
arch = self.arch
return core.BNIsAlwaysBranchPatchAvailable(self.handle, arch.handle, addr)
- def is_invert_branch_patch_available(self, addr:int, arch:Optional['architecture.Architecture']=None) -> bool:
+ def is_invert_branch_patch_available(self, addr: int, arch: Optional['architecture.Architecture'] = None) -> bool:
"""
``is_invert_branch_patch_available`` queries the architecture plugin to determine if the instruction at ``addr``
is a branch that can be inverted. The actual logic of which is implemented in the
@@ -5230,7 +5319,9 @@ class BinaryView:
arch = self.arch
return core.BNIsInvertBranchPatchAvailable(self.handle, arch.handle, addr)
- def is_skip_and_return_zero_patch_available(self, addr:int, arch:Optional['architecture.Architecture']=None) -> bool:
+ def is_skip_and_return_zero_patch_available(
+ self, addr: int, arch: Optional['architecture.Architecture'] = None
+ ) -> bool:
"""
``is_skip_and_return_zero_patch_available`` queries the architecture plugin to determine if the
instruction at ``addr`` is similar to an x86 "call" instruction which can be made to return zero. The actual
@@ -5259,7 +5350,9 @@ class BinaryView:
arch = self.arch
return core.BNIsSkipAndReturnZeroPatchAvailable(self.handle, arch.handle, addr)
- def is_skip_and_return_value_patch_available(self, addr:int, arch:Optional['architecture.Architecture']=None) -> bool:
+ def is_skip_and_return_value_patch_available(
+ self, addr: int, arch: Optional['architecture.Architecture'] = None
+ ) -> bool:
"""
``is_skip_and_return_value_patch_available`` queries the architecture plugin to determine if the
instruction at ``addr`` is similar to an x86 "call" instruction which can be made to return a value. The actual
@@ -5288,7 +5381,7 @@ class BinaryView:
arch = self.arch
return core.BNIsSkipAndReturnValuePatchAvailable(self.handle, arch.handle, addr)
- def convert_to_nop(self, addr:int, arch:Optional['architecture.Architecture']=None) -> bool:
+ def convert_to_nop(self, addr: int, arch: Optional['architecture.Architecture'] = None) -> bool:
"""
``convert_to_nop`` converts the instruction at virtual address ``addr`` to a nop of the provided architecture.
@@ -5326,7 +5419,7 @@ class BinaryView:
arch = self.arch
return core.BNConvertToNop(self.handle, arch.handle, addr)
- def always_branch(self, addr:int, arch:Optional['architecture.Architecture']=None) -> bool:
+ def always_branch(self, addr: int, arch: Optional['architecture.Architecture'] = None) -> bool:
"""
``always_branch`` convert the instruction of architecture ``arch`` at the virtual address ``addr`` to an
unconditional branch.
@@ -5354,7 +5447,7 @@ class BinaryView:
arch = self.arch
return core.BNAlwaysBranch(self.handle, arch.handle, addr)
- def never_branch(self, addr:int, arch:Optional['architecture.Architecture']=None) -> bool:
+ def never_branch(self, addr: int, arch: Optional['architecture.Architecture'] = None) -> bool:
"""
``never_branch`` convert the branch instruction of architecture ``arch`` at the virtual address ``addr`` to
a fall through.
@@ -5382,7 +5475,7 @@ class BinaryView:
arch = self.arch
return core.BNConvertToNop(self.handle, arch.handle, addr)
- def invert_branch(self, addr:int, arch:Optional['architecture.Architecture']=None) -> bool:
+ def invert_branch(self, addr: int, arch: Optional['architecture.Architecture'] = None) -> bool:
"""
``invert_branch`` convert the branch instruction of architecture ``arch`` at the virtual address ``addr`` to the
inverse branch.
@@ -5411,7 +5504,7 @@ class BinaryView:
arch = self.arch
return core.BNInvertBranch(self.handle, arch.handle, addr)
- def skip_and_return_value(self, addr:int, value:int, arch:Optional['architecture.Architecture']=None) -> bool:
+ def skip_and_return_value(self, addr: int, value: int, arch: Optional['architecture.Architecture'] = None) -> bool:
"""
``skip_and_return_value`` convert the ``call`` instruction of architecture ``arch`` at the virtual address
``addr`` to the equivalent of returning a value.
@@ -5438,7 +5531,7 @@ class BinaryView:
arch = self.arch
return core.BNSkipAndReturnValue(self.handle, arch.handle, addr, value)
- def get_instruction_length(self, addr:int, arch:Optional['architecture.Architecture']=None) -> int:
+ def get_instruction_length(self, addr: int, arch: Optional['architecture.Architecture'] = None) -> int:
"""
``get_instruction_length`` returns the number of bytes in the instruction of Architecture ``arch`` at the virtual
address ``addr``
@@ -5461,16 +5554,16 @@ class BinaryView:
arch = self.arch
return core.BNGetInstructionLength(self.handle, arch.handle, addr)
- def notify_data_written(self, offset:int, length:int) -> None:
+ def notify_data_written(self, offset: int, length: int) -> None:
core.BNNotifyDataWritten(self.handle, offset, length)
- def notify_data_inserted(self, offset:int, length:int) -> None:
+ def notify_data_inserted(self, offset: int, length: int) -> None:
core.BNNotifyDataInserted(self.handle, offset, length)
- def notify_data_removed(self, offset:int, length:int) -> None:
+ def notify_data_removed(self, offset: int, length: int) -> None:
core.BNNotifyDataRemoved(self.handle, offset, length)
- def get_strings(self, start:Optional[int] = None, length:Optional[int] = None) -> List['StringReference']:
+ def get_strings(self, start: Optional[int] = None, length: Optional[int] = None) -> List['StringReference']:
"""
``get_strings`` returns a list of strings defined in the binary in the optional virtual address range:
``start-(start+length)``
@@ -5504,7 +5597,7 @@ class BinaryView:
finally:
core.BNFreeStringReferenceList(strings)
- def get_string_at(self, addr:int, partial:bool=False) -> Optional['StringReference']:
+ def get_string_at(self, addr: int, partial: bool = False) -> Optional['StringReference']:
"""
``get_string_at`` returns the string that falls on given virtual address.
@@ -5530,7 +5623,8 @@ class BinaryView:
length = str_ref.length - (addr - str_ref.start) if partial else str_ref.length
return StringReference(self, StringType(str_ref.type), start, length)
- def get_ascii_string_at(self, addr:int, min_length:int=4, max_length:int=None, require_cstring:bool=True) -> Optional['StringReference']:
+ def get_ascii_string_at(self, addr: int, min_length: int = 4, max_length: int = None,
+ require_cstring: bool = True) -> Optional['StringReference']:
"""
``get_ascii_string_at`` returns an ascii string found at ``addr``.
@@ -5575,7 +5669,7 @@ class BinaryView:
return None
return StringReference(self, StringType.AsciiString, addr, length)
- def add_analysis_completion_event(self, callback:Callable[[], None]) -> 'AnalysisCompletionEvent':
+ def add_analysis_completion_event(self, callback: Callable[[], None]) -> 'AnalysisCompletionEvent':
"""
``add_analysis_completion_event`` sets up a call back function to be called when analysis has been completed.
This is helpful when using :func:`update_analysis` which does not wait for analysis completion before returning.
@@ -5600,7 +5694,7 @@ class BinaryView:
"""
return AnalysisCompletionEvent(self, callback)
- def get_next_function_start_after(self, addr:int) -> int:
+ def get_next_function_start_after(self, addr: int) -> int:
"""
``get_next_function_start_after`` returns the virtual address of the Function that occurs after the virtual address
``addr``
@@ -5622,7 +5716,7 @@ class BinaryView:
"""
return core.BNGetNextFunctionStartAfterAddress(self.handle, addr)
- def get_next_basic_block_start_after(self, addr:int) -> int:
+ def get_next_basic_block_start_after(self, addr: int) -> int:
"""
``get_next_basic_block_start_after`` returns the virtual address of the BasicBlock that occurs after the virtual
address ``addr``
@@ -5640,7 +5734,7 @@ class BinaryView:
"""
return core.BNGetNextBasicBlockStartAfterAddress(self.handle, addr)
- def get_next_data_after(self, addr:int) -> int:
+ def get_next_data_after(self, addr: int) -> int:
"""
``get_next_data_after`` retrieves the virtual address of the next non-code byte.
@@ -5654,7 +5748,7 @@ class BinaryView:
"""
return core.BNGetNextDataAfterAddress(self.handle, addr)
- def get_next_data_var_after(self, addr:int) -> Optional['DataVariable']:
+ def get_next_data_var_after(self, addr: int) -> Optional['DataVariable']:
"""
``get_next_data_var_after`` retrieves the next :py:Class:`DataVariable`, or None.
@@ -5680,7 +5774,7 @@ class BinaryView:
break
return DataVariable.from_core_struct(var, self)
- def get_next_data_var_start_after(self, addr:int) -> int:
+ def get_next_data_var_start_after(self, addr: int) -> int:
"""
``get_next_data_var_start_after`` retrieves the next virtual address of the next :py:Class:`DataVariable`
@@ -5697,7 +5791,7 @@ class BinaryView:
"""
return core.BNGetNextDataVariableStartAfterAddress(self.handle, addr)
- def get_previous_function_start_before(self, addr:int) -> int:
+ def get_previous_function_start_before(self, addr: int) -> int:
"""
``get_previous_function_start_before`` returns the virtual address of the Function that occurs prior to the
virtual address provided
@@ -5717,7 +5811,7 @@ class BinaryView:
"""
return core.BNGetPreviousFunctionStartBeforeAddress(self.handle, addr)
- def get_previous_basic_block_start_before(self, addr:int) -> int:
+ def get_previous_basic_block_start_before(self, addr: int) -> int:
"""
``get_previous_basic_block_start_before`` returns the virtual address of the BasicBlock that occurs prior to the
provided virtual address
@@ -5737,7 +5831,7 @@ class BinaryView:
"""
return core.BNGetPreviousBasicBlockStartBeforeAddress(self.handle, addr)
- def get_previous_basic_block_end_before(self, addr:int) -> int:
+ def get_previous_basic_block_end_before(self, addr: int) -> int:
"""
``get_previous_basic_block_end_before``
@@ -5754,7 +5848,7 @@ class BinaryView:
"""
return core.BNGetPreviousBasicBlockEndBeforeAddress(self.handle, addr)
- def get_previous_data_before(self, addr:int) -> int:
+ def get_previous_data_before(self, addr: int) -> int:
"""
``get_previous_data_before``
@@ -5769,7 +5863,7 @@ class BinaryView:
"""
return core.BNGetPreviousDataBeforeAddress(self.handle, addr)
- def get_previous_data_var_before(self, addr:int) -> Optional['DataVariable']:
+ def get_previous_data_var_before(self, addr: int) -> Optional['DataVariable']:
"""
``get_previous_data_var_before`` retrieves the previous :py:Class:`DataVariable`, or None.
@@ -5790,7 +5884,7 @@ class BinaryView:
return None
return DataVariable.from_core_struct(var, self)
- def get_previous_data_var_start_before(self, addr:int) -> int:
+ def get_previous_data_var_start_before(self, addr: int) -> int:
"""
``get_previous_data_var_start_before``
@@ -5807,7 +5901,9 @@ class BinaryView:
"""
return core.BNGetPreviousDataVariableStartBeforeAddress(self.handle, addr)
- def get_linear_disassembly_position_at(self, addr:int, settings:'_function.DisassemblySettings'=None) -> 'lineardisassembly.LinearViewCursor':
+ def get_linear_disassembly_position_at(
+ self, addr: int, settings: '_function.DisassemblySettings' = None
+ ) -> 'lineardisassembly.LinearViewCursor':
"""
``get_linear_disassembly_position_at`` instantiates a :py:class:`LinearViewCursor <binaryninja.lineardisassembly.LinearViewCursor>` object for use in
:py:meth:`get_previous_linear_disassembly_lines` or :py:meth:`get_next_linear_disassembly_lines`.
@@ -5829,7 +5925,9 @@ class BinaryView:
pos.seek_to_address(addr)
return pos
- def get_previous_linear_disassembly_lines(self, pos:'lineardisassembly.LinearViewCursor') -> List['lineardisassembly.LinearDisassemblyLine']:
+ def get_previous_linear_disassembly_lines(
+ self, pos: 'lineardisassembly.LinearViewCursor'
+ ) -> List['lineardisassembly.LinearDisassemblyLine']:
"""
``get_previous_linear_disassembly_lines`` retrieves a list of :py:class:`LinearDisassemblyLine` objects for the
previous disassembly lines, and updates the LinearViewCursor passed in. This function can be called
@@ -5853,7 +5951,9 @@ class BinaryView:
result = pos.lines
return result
- def get_next_linear_disassembly_lines(self, pos:'lineardisassembly.LinearViewCursor') -> List['lineardisassembly.LinearDisassemblyLine']:
+ def get_next_linear_disassembly_lines(
+ self, pos: 'lineardisassembly.LinearViewCursor'
+ ) -> List['lineardisassembly.LinearDisassemblyLine']:
"""
``get_next_linear_disassembly_lines`` retrieves a list of :py:class:`LinearDisassemblyLine` objects for the
next disassembly lines, and updates the LinearViewCursor passed in. This function can be called
@@ -5878,8 +5978,9 @@ class BinaryView:
return result
return result
- def get_linear_disassembly(self, settings:'_function.DisassemblySettings'=None) -> \
- Iterator['lineardisassembly.LinearDisassemblyLine']:
+ def get_linear_disassembly(
+ self, settings: '_function.DisassemblySettings' = None
+ ) -> Iterator['lineardisassembly.LinearDisassemblyLine']:
"""
``get_linear_disassembly`` gets an iterator for all lines in the linear disassembly of the view for the given
disassembly settings.
@@ -5902,12 +6003,13 @@ class BinaryView:
"""
@dataclass
class LinearDisassemblyIterator:
- view:'BinaryView'
- settings:Optional['_function.DisassemblySettings'] = None
+ view: 'BinaryView'
+ settings: Optional['_function.DisassemblySettings'] = None
def __iter__(self):
- pos = lineardisassembly.LinearViewCursor(lineardisassembly.LinearViewObject.disassembly(
- self.view, self.settings))
+ pos = lineardisassembly.LinearViewCursor(
+ lineardisassembly.LinearViewObject.disassembly(self.view, self.settings)
+ )
while True:
lines = self.view.get_next_linear_disassembly_lines(pos)
if len(lines) == 0:
@@ -5917,7 +6019,7 @@ class BinaryView:
return iter(LinearDisassemblyIterator(self, settings))
- def parse_type_string(self, text:str) -> Tuple['_types.Type', '_types.QualifiedName']:
+ def parse_type_string(self, text: str) -> Tuple['_types.Type', '_types.QualifiedName']:
"""
``parse_type_string`` parses string containing C into a single type :py:Class:`Type`.
In contrast to the :py:'platform
@@ -5944,13 +6046,13 @@ class BinaryView:
error_str = errors.value.decode("utf-8")
core.free_string(errors)
raise SyntaxError(error_str)
- type_obj = _types.Type.create(core.BNNewTypeReference(result.type), platform = self.platform)
+ type_obj = _types.Type.create(core.BNNewTypeReference(result.type), platform=self.platform)
name = _types.QualifiedName._from_core_struct(result.name)
return type_obj, name
finally:
core.BNFreeQualifiedNameAndType(result)
- def parse_types_from_string(self, text:str) -> '_types.TypeParserResult':
+ def parse_types_from_string(self, text: str) -> '_types.TypeParserResult':
"""
``parse_types_from_string`` parses string containing C into a :py:Class:`TypeParserResult` objects. This API
unlike the :py:meth:`Platform.parse_types_from_source` allows the reference of types already defined
@@ -5980,23 +6082,31 @@ class BinaryView:
core.free_string(errors)
raise SyntaxError(error_str)
- type_dict:Mapping[_types.QualifiedName, _types.Type] = {}
- variables:Mapping[_types.QualifiedName, _types.Type] = {}
- functions:Mapping[_types.QualifiedName, _types.Type] = {}
+ type_dict: Mapping[_types.QualifiedName, _types.Type] = {}
+ variables: Mapping[_types.QualifiedName, _types.Type] = {}
+ functions: Mapping[_types.QualifiedName, _types.Type] = {}
for i in range(0, parse.typeCount):
name = _types.QualifiedName._from_core_struct(parse.types[i].name)
- type_dict[name] = _types.Type.create(core.BNNewTypeReference(parse.types[i].type), platform = self.platform)
+ type_dict[name] = _types.Type.create(
+ core.BNNewTypeReference(parse.types[i].type), platform=self.platform
+ )
for i in range(0, parse.variableCount):
name = _types.QualifiedName._from_core_struct(parse.variables[i].name)
- variables[name] = _types.Type.create(core.BNNewTypeReference(parse.variables[i].type), platform = self.platform)
+ variables[name] = _types.Type.create(
+ core.BNNewTypeReference(parse.variables[i].type), platform=self.platform
+ )
for i in range(0, parse.functionCount):
name = _types.QualifiedName._from_core_struct(parse.functions[i].name)
- functions[name] = _types.Type.create(core.BNNewTypeReference(parse.functions[i].type), platform = self.platform)
+ functions[name] = _types.Type.create(
+ core.BNNewTypeReference(parse.functions[i].type), platform=self.platform
+ )
return _types.TypeParserResult(type_dict, variables, functions)
finally:
core.BNFreeTypeParserResult(parse)
- def parse_possiblevalueset(self, value:str, state:RegisterValueType, here:int=0) -> 'variable.PossibleValueSet':
+ def parse_possiblevalueset(
+ self, value: str, state: RegisterValueType, here: int = 0
+ ) -> 'variable.PossibleValueSet':
"""
Evaluates a string representation of a PossibleValueSet into an instance of the ``PossibleValueSet`` value.
@@ -6043,7 +6153,7 @@ class BinaryView:
raise ValueError(error_str)
return variable.PossibleValueSet(self.arch, result)
- def get_type_by_name(self, name:'_types.QualifiedNameType') -> Optional['_types.Type']:
+ def get_type_by_name(self, name: '_types.QualifiedNameType') -> Optional['_types.Type']:
"""
``get_type_by_name`` returns the defined type whose name corresponds with the provided ``name``
@@ -6062,9 +6172,9 @@ class BinaryView:
obj = core.BNGetAnalysisTypeByName(self.handle, _name)
if not obj:
return None
- return _types.Type.create(obj, platform = self.platform)
+ return _types.Type.create(obj, platform=self.platform)
- def get_type_by_id(self, id:str) -> Optional['_types.Type']:
+ def get_type_by_id(self, id: str) -> Optional['_types.Type']:
"""
``get_type_by_id`` returns the defined type whose unique identifier corresponds with the provided ``id``
@@ -6083,9 +6193,9 @@ class BinaryView:
obj = core.BNGetAnalysisTypeById(self.handle, id)
if not obj:
return None
- return _types.Type.create(obj, platform = self.platform)
+ return _types.Type.create(obj, platform=self.platform)
- def get_type_name_by_id(self, id:str) -> Optional['_types.QualifiedName']:
+ def get_type_name_by_id(self, id: str) -> Optional['_types.QualifiedName']:
"""
``get_type_name_by_id`` returns the defined type name whose unique identifier corresponds with the provided ``id``
@@ -6109,7 +6219,7 @@ class BinaryView:
return None
return result
- def get_type_id(self, name:'_types.QualifiedNameType') -> str:
+ def get_type_id(self, name: '_types.QualifiedNameType') -> str:
"""
``get_type_id`` returns the unique identifier of the defined type whose name corresponds with the
provided ``name``
@@ -6129,7 +6239,7 @@ class BinaryView:
_name = _types.QualifiedName(name)._to_core_struct()
return core.BNGetAnalysisTypeId(self.handle, _name)
- def add_type_library(self, lib:'typelibrary.TypeLibrary') -> None:
+ def add_type_library(self, lib: 'typelibrary.TypeLibrary') -> None:
"""
``add_type_library`` make the contents of a type library available for type/import resolution
@@ -6140,7 +6250,7 @@ class BinaryView:
raise ValueError("must pass in a TypeLibrary object")
core.BNAddBinaryViewTypeLibrary(self.handle, lib.handle)
- def get_type_library(self, name:str) -> Optional['typelibrary.TypeLibrary']:
+ def get_type_library(self, name: str) -> Optional['typelibrary.TypeLibrary']:
"""
``get_type_library`` returns the TypeLibrary
@@ -6155,7 +6265,7 @@ class BinaryView:
return None
return typelibrary.TypeLibrary(handle)
- def is_type_auto_defined(self, name:'_types.QualifiedNameType') -> bool:
+ def is_type_auto_defined(self, name: '_types.QualifiedNameType') -> bool:
"""
``is_type_auto_defined`` queries the user type list of name. If name is not in the *user* type list then the name
is considered an *auto* type.
@@ -6173,7 +6283,9 @@ class BinaryView:
_name = _types.QualifiedName(name)._to_core_struct()
return core.BNIsAnalysisTypeAutoDefined(self.handle, _name)
- def define_type(self, type_id:str, default_name:Optional['_types.QualifiedNameType'], type_obj:StringOrType) -> '_types.QualifiedName':
+ def define_type(
+ self, type_id: str, default_name: Optional['_types.QualifiedNameType'], type_obj: StringOrType
+ ) -> '_types.QualifiedName':
"""
``define_type`` registers a :py:Class:`Type` ``type_obj`` of the given ``name`` in the global list of types for
the current :py:Class:`BinaryView`. This method should only be used for automatically generated types.
@@ -6205,7 +6317,7 @@ class BinaryView:
core.BNFreeQualifiedName(reg_name)
return result
- def define_user_type(self, name:Optional['_types.QualifiedNameType'], type_obj:StringOrType) -> None:
+ def define_user_type(self, name: Optional['_types.QualifiedNameType'], type_obj: StringOrType) -> None:
"""
``define_user_type`` registers a :py:Class:`Type` ``type_obj`` of the given ``name`` in the global list of user
types for the current :py:Class:`BinaryView`.
@@ -6232,7 +6344,7 @@ class BinaryView:
_name = _types.QualifiedName(name)._to_core_struct()
core.BNDefineUserAnalysisType(self.handle, _name, type_obj.handle)
- def undefine_type(self, type_id:str) -> None:
+ def undefine_type(self, type_id: str) -> None:
"""
``undefine_type`` removes a :py:Class:`Type` from the global list of types for the current :py:Class:`BinaryView`
@@ -6251,7 +6363,7 @@ class BinaryView:
"""
core.BNUndefineAnalysisType(self.handle, type_id)
- def undefine_user_type(self, name:'_types.QualifiedNameType') -> None:
+ def undefine_user_type(self, name: '_types.QualifiedNameType') -> None:
"""
``undefine_user_type`` removes a :py:Class:`Type` from the global list of user types for the current
:py:Class:`BinaryView`
@@ -6271,7 +6383,7 @@ class BinaryView:
_name = _types.QualifiedName(name)._to_core_struct()
core.BNUndefineUserAnalysisType(self.handle, _name)
- def rename_type(self, old_name:'_types.QualifiedNameType', new_name:'_types.QualifiedNameType') -> None:
+ def rename_type(self, old_name: '_types.QualifiedNameType', new_name: '_types.QualifiedNameType') -> None:
"""
``rename_type`` renames a type in the global list of types for the current :py:Class:`BinaryView`
@@ -6293,7 +6405,7 @@ class BinaryView:
_new_name = _types.QualifiedName(new_name)._to_core_struct()
core.BNRenameAnalysisType(self.handle, _old_name, _new_name)
- def import_library_type(self, name:str, lib:typelibrary.TypeLibrary = None) -> Optional['_types.Type']:
+ def import_library_type(self, name: str, lib: typelibrary.TypeLibrary = None) -> Optional['_types.Type']:
"""
``import_library_type`` recursively imports a type from the specified type library, or, if
no library was explicitly provided, the first type library associated with the current :py:Class:`BinaryView`
@@ -6312,12 +6424,14 @@ class BinaryView:
:rtype: Type
"""
_name = _types.QualifiedName(name)
- handle = core.BNBinaryViewImportTypeLibraryType(self.handle, None if lib is None else lib.handle, _name._to_core_struct())
+ handle = core.BNBinaryViewImportTypeLibraryType(
+ self.handle, None if lib is None else lib.handle, _name._to_core_struct()
+ )
if handle is None:
return None
- return _types.Type.create(handle, platform = self.platform)
+ return _types.Type.create(handle, platform=self.platform)
- def import_library_object(self, name:str, lib:typelibrary.TypeLibrary = None) -> Optional['_types.Type']:
+ def import_library_object(self, name: str, lib: typelibrary.TypeLibrary = None) -> Optional['_types.Type']:
"""
``import_library_object`` recursively imports an object from the specified type library, or, if
no library was explicitly provided, the first type library associated with the current :py:Class:`BinaryView`
@@ -6332,12 +6446,14 @@ class BinaryView:
:rtype: Type
"""
_name = _types.QualifiedName(name)
- handle = core.BNBinaryViewImportTypeLibraryObject(self.handle, None if lib is None else lib.handle, _name._to_core_struct())
+ handle = core.BNBinaryViewImportTypeLibraryObject(
+ self.handle, None if lib is None else lib.handle, _name._to_core_struct()
+ )
if handle is None:
return None
- return _types.Type.create(handle, platform = self.platform)
+ return _types.Type.create(handle, platform=self.platform)
- def export_type_to_library(self, lib:typelibrary.TypeLibrary, name:Optional[str], type_obj:StringOrType) -> None:
+ def export_type_to_library(self, lib: typelibrary.TypeLibrary, name: Optional[str], type_obj: StringOrType) -> None:
"""
``export_type_to_library`` recursively exports ``type_obj`` into ``lib`` as a type with name ``name``
@@ -6364,7 +6480,9 @@ class BinaryView:
raise ValueError("name can only be None if named type is derived from string passed to type_obj")
core.BNBinaryViewExportTypeToTypeLibrary(self.handle, lib.handle, _name._to_core_struct(), type_obj.handle)
- def export_object_to_library(self, lib:typelibrary.TypeLibrary, name:Optional[str], type_obj:StringOrType) -> None:
+ def export_object_to_library(
+ self, lib: typelibrary.TypeLibrary, name: Optional[str], type_obj: StringOrType
+ ) -> None:
"""
``export_object_to_library`` recursively exports ``type_obj`` into ``lib`` as an object with name ``name``
@@ -6392,7 +6510,7 @@ class BinaryView:
raise ValueError("name can only be None if named type is derived from string passed to type_obj")
core.BNBinaryViewExportObjectToTypeLibrary(self.handle, lib.handle, _name._to_core_struct(), type_obj.handle)
- def register_platform_types(self, platform:'_platform.Platform') -> None:
+ def register_platform_types(self, platform: '_platform.Platform') -> None:
"""
``register_platform_types`` ensures that the platform-specific types for a :py:Class:`Platform` are available
for the current :py:Class:`BinaryView`. This is automatically performed when adding a new function or setting
@@ -6408,7 +6526,7 @@ class BinaryView:
"""
core.BNRegisterPlatformTypes(self.handle, platform.handle)
- def find_next_data(self, start:int, data:bytes, flags:FindFlag=FindFlag.FindCaseSensitive) -> Optional[int]:
+ def find_next_data(self, start: int, data: bytes, flags: FindFlag = FindFlag.FindCaseSensitive) -> Optional[int]:
"""
``find_next_data`` searches for the bytes ``data`` starting at the virtual address ``start`` until the end of the BinaryView.
@@ -6432,10 +6550,11 @@ class BinaryView:
return None
return result.value
-
- def find_next_text(self, start:int, text:str, settings:_function.DisassemblySettings=None,
- flags:FindFlag=FindFlag.FindCaseSensitive,
- graph_type:FunctionGraphType = FunctionGraphType.NormalFunctionGraph) -> Optional[int]:
+ def find_next_text(
+ self, start: int, text: str, settings: _function.DisassemblySettings = None,
+ flags: FindFlag = FindFlag.FindCaseSensitive,
+ graph_type: FunctionGraphType = FunctionGraphType.NormalFunctionGraph
+ ) -> Optional[int]:
"""
``find_next_text`` searches for string ``text`` occurring in the linear view output starting at the virtual
address ``start`` until the end of the BinaryView.
@@ -6461,13 +6580,14 @@ class BinaryView:
raise TypeError("settings parameter is not DisassemblySettings type")
result = ctypes.c_ulonglong()
- if not core.BNFindNextText(self.handle, start, text, result, settings.handle, flags,
- graph_type):
+ if not core.BNFindNextText(self.handle, start, text, result, settings.handle, flags, graph_type):
return None
return result.value
- def find_next_constant(self, start:int, constant:int, settings:_function.DisassemblySettings=None,
- graph_type:FunctionGraphType = FunctionGraphType.NormalFunctionGraph) -> Optional[int]:
+ def find_next_constant(
+ self, start: int, constant: int, settings: _function.DisassemblySettings = None,
+ graph_type: FunctionGraphType = FunctionGraphType.NormalFunctionGraph
+ ) -> Optional[int]:
"""
``find_next_constant`` searches for integer constant ``constant`` occurring in the linear view output starting at the virtual
address ``start`` until the end of the BinaryView.
@@ -6485,8 +6605,7 @@ class BinaryView:
raise TypeError("settings parameter is not DisassemblySettings type")
result = ctypes.c_ulonglong()
- if not core.BNFindNextConstant(self.handle, start, constant, result, settings.handle,
- graph_type):
+ if not core.BNFindNextConstant(self.handle, start, constant, result, settings.handle, graph_type):
return None
return result.value
@@ -6507,8 +6626,10 @@ class BinaryView:
if (not self.thread.is_alive()) and self.results.empty():
raise StopIteration
- def find_all_data(self, start:int, end:int, data:bytes, flags:FindFlag = FindFlag.FindCaseSensitive,
- progress_func:ProgressFuncType = None, match_callback:DataMatchCallbackType = None) -> QueueGenerator:
+ def find_all_data(
+ self, start: int, end: int, data: bytes, flags: FindFlag = FindFlag.FindCaseSensitive,
+ progress_func: ProgressFuncType = None, match_callback: DataMatchCallbackType = None
+ ) -> QueueGenerator:
"""
``find_all_data`` searches for the bytes ``data`` starting at the virtual address ``start``
until the virtual address ``end``. Once a match is found, the ``match_callback`` is called.
@@ -6542,35 +6663,40 @@ class BinaryView:
raise TypeError('flag parameter must have type FindFlag')
if progress_func:
- progress_func_obj = ctypes.CFUNCTYPE(ctypes.c_bool, ctypes.c_void_p,
- ctypes.c_ulonglong, ctypes.c_ulonglong)\
- (lambda ctxt, cur, total: progress_func(cur, total))
+ progress_func_obj = ctypes.CFUNCTYPE(
+ ctypes.c_bool, ctypes.c_void_p, ctypes.c_ulonglong, ctypes.c_ulonglong
+ )(lambda ctxt, cur, total: progress_func(cur, total))
else:
- progress_func_obj = ctypes.CFUNCTYPE(ctypes.c_bool, ctypes.c_void_p,
- ctypes.c_ulonglong, ctypes.c_ulonglong)\
- (lambda ctxt, cur, total: True)
+ progress_func_obj = ctypes.CFUNCTYPE(
+ ctypes.c_bool, ctypes.c_void_p, ctypes.c_ulonglong, ctypes.c_ulonglong
+ )(lambda ctxt, cur, total: True)
if match_callback:
# the `not match_callback(...) is False` tolerates the users who forget to return
# `True` from inside the callback
- match_callback_obj = ctypes.CFUNCTYPE(ctypes.c_bool, ctypes.c_void_p,
- ctypes.c_ulonglong, ctypes.POINTER(core.BNDataBuffer))\
- (lambda ctxt, addr, match: not match_callback(addr, databuffer.DataBuffer(handle = match)) is False)
- return core.BNFindAllDataWithProgress(self.handle, start, end, buf.handle, flags,
- None, progress_func_obj, None, match_callback_obj)
+ match_callback_obj = ctypes.CFUNCTYPE(
+ ctypes.c_bool, ctypes.c_void_p, ctypes.c_ulonglong, ctypes.POINTER(core.BNDataBuffer)
+ )(lambda ctxt, addr, match: not match_callback(addr, databuffer.DataBuffer(handle=match)) is False)
+ return core.BNFindAllDataWithProgress(
+ self.handle, start, end, buf.handle, flags, None, progress_func_obj, None, match_callback_obj
+ )
else:
results = queue.Queue()
- match_callback_obj = ctypes.CFUNCTYPE(ctypes.c_bool, ctypes.c_void_p,
- ctypes.c_ulonglong, ctypes.POINTER(core.BNDataBuffer))\
- (lambda ctxt, addr, match:
- results.put((addr, databuffer.DataBuffer(handle = match))) or True)
+ match_callback_obj = ctypes.CFUNCTYPE(
+ ctypes.c_bool, ctypes.c_void_p, ctypes.c_ulonglong, ctypes.POINTER(core.BNDataBuffer)
+ )(lambda ctxt, addr, match: results.put((addr, databuffer.DataBuffer(handle=match))) or True)
- t = threading.Thread(target = lambda: core.BNFindAllDataWithProgress(self.handle,
- start, end, buf.handle, flags, None, progress_func_obj, None, match_callback_obj))
+ t = threading.Thread(
+ target=lambda: core.BNFindAllDataWithProgress(
+ self.handle, start, end, buf.handle, flags, None, progress_func_obj, None, match_callback_obj
+ )
+ )
return self.QueueGenerator(t, results)
- def _LinearDisassemblyLine_convertor(self, lines:core.BNLinearDisassemblyLineHandle) -> 'lineardisassembly.LinearDisassemblyLine':
+ def _LinearDisassemblyLine_convertor(
+ self, lines: core.BNLinearDisassemblyLineHandle
+ ) -> 'lineardisassembly.LinearDisassemblyLine':
func = None
block = None
line = lines[0]
@@ -6583,13 +6709,14 @@ class BinaryView:
color = highlight.HighlightColor._from_core_struct(line.contents.highlight)
addr = line.contents.addr
tokens = _function.InstructionTextToken._from_core_struct(line.contents.tokens, line.contents.count)
- contents = _function.DisassemblyTextLine(tokens, addr, color = color)
+ contents = _function.DisassemblyTextLine(tokens, addr, color=color)
return lineardisassembly.LinearDisassemblyLine(line.type, func, block, contents)
- def find_all_text(self, start:int, end:int, text:str, settings:_function.DisassemblySettings = None,
- flags = FindFlag.FindCaseSensitive,
- graph_type = FunctionGraphType.NormalFunctionGraph, progress_func = None,
- match_callback = None) -> QueueGenerator:
+ def find_all_text(
+ self, start: int, end: int, text: str, settings: _function.DisassemblySettings = None,
+ flags=FindFlag.FindCaseSensitive, graph_type=FunctionGraphType.NormalFunctionGraph, progress_func=None,
+ match_callback=None
+ ) -> QueueGenerator:
"""
``find_all_text`` searches for string ``text`` occurring in the linear view output starting
at the virtual address ``start`` until the virtual address ``end``. Once a match is found,
@@ -6631,43 +6758,54 @@ class BinaryView:
raise TypeError('flag parameter must have type FindFlag')
if progress_func:
- progress_func_obj = ctypes.CFUNCTYPE(ctypes.c_bool, ctypes.c_void_p,
- ctypes.c_ulonglong, ctypes.c_ulonglong)\
- (lambda ctxt, cur, total: progress_func(cur, total))
+ progress_func_obj = ctypes.CFUNCTYPE(
+ ctypes.c_bool, ctypes.c_void_p, ctypes.c_ulonglong, ctypes.c_ulonglong
+ )(lambda ctxt, cur, total: progress_func(cur, total))
else:
- progress_func_obj = ctypes.CFUNCTYPE(ctypes.c_bool, ctypes.c_void_p,
- ctypes.c_ulonglong, ctypes.c_ulonglong)\
- (lambda ctxt, cur, total: True)
+ progress_func_obj = ctypes.CFUNCTYPE(
+ ctypes.c_bool, ctypes.c_void_p, ctypes.c_ulonglong, ctypes.c_ulonglong
+ )(lambda ctxt, cur, total: True)
if match_callback:
# The reason we use `not match_callback(...) is False` is the user tends to happily
# deal with the returned data, but forget to return True at the end of the callback.
# Then only the first result will be returned.
- match_callback_obj = ctypes.CFUNCTYPE(ctypes.c_bool, ctypes.c_void_p,
- ctypes.c_ulonglong, ctypes.c_char_p,
- ctypes.POINTER(core.BNLinearDisassemblyLine))\
- (lambda ctxt, addr, match, line: not match_callback(addr, match,\
- self._LinearDisassemblyLine_convertor(line)) is False)
+ match_callback_obj = ctypes.CFUNCTYPE(
+ ctypes.c_bool, ctypes.c_void_p, ctypes.c_ulonglong, ctypes.c_char_p,
+ ctypes.POINTER(core.BNLinearDisassemblyLine)
+ )(
+ lambda ctxt, addr, match, line:
+ not match_callback(addr, match, self._LinearDisassemblyLine_convertor(line)) is False
+ )
- return core.BNFindAllTextWithProgress(self.handle, start, end, text,
- settings.handle, flags, graph_type, None, progress_func_obj, None, match_callback_obj)
+ return core.BNFindAllTextWithProgress(
+ self.handle, start, end, text, settings.handle, flags, graph_type, None, progress_func_obj, None,
+ match_callback_obj
+ )
else:
results = queue.Queue()
- match_callback_obj = ctypes.CFUNCTYPE(ctypes.c_bool, ctypes.c_void_p,
- ctypes.c_ulonglong, ctypes.c_char_p,
- ctypes.POINTER(core.BNLinearDisassemblyLine))\
- (lambda ctxt, addr, match, line: results.put((addr, match,\
- self._LinearDisassemblyLine_convertor(line))) or True)
+ match_callback_obj = ctypes.CFUNCTYPE(
+ ctypes.c_bool, ctypes.c_void_p, ctypes.c_ulonglong, ctypes.c_char_p,
+ ctypes.POINTER(core.BNLinearDisassemblyLine)
+ )(
+ lambda ctxt, addr, match, line: results.put((addr, match, self._LinearDisassemblyLine_convertor(line)))
+ or True
+ )
- t = threading.Thread(target = lambda: core.BNFindAllTextWithProgress(self.handle,
- start, end, text, settings.handle, flags, graph_type, None, progress_func_obj, None,
- match_callback_obj))
+ t = threading.Thread(
+ target=lambda: core.BNFindAllTextWithProgress(
+ self.handle, start, end, text, settings.handle, flags, graph_type, None, progress_func_obj, None,
+ match_callback_obj
+ )
+ )
return self.QueueGenerator(t, results)
- def find_all_constant(self, start:int, end:int, constant:int, settings:_function.DisassemblySettings = None,
- graph_type:FunctionGraphType = FunctionGraphType.NormalFunctionGraph, progress_func:ProgressFuncType = None,
- match_callback:LineMatchCallbackType = None) -> QueueGenerator:
+ def find_all_constant(
+ self, start: int, end: int, constant: int, settings: _function.DisassemblySettings = None,
+ graph_type: FunctionGraphType = FunctionGraphType.NormalFunctionGraph, progress_func: ProgressFuncType = None,
+ match_callback: LineMatchCallbackType = None
+ ) -> QueueGenerator:
"""
``find_all_constant`` searches for the integer constant ``constant`` starting at the
virtual address ``start`` until the virtual address ``end``. Once a match is found,
@@ -6698,32 +6836,35 @@ class BinaryView:
raise TypeError("settings parameter is not DisassemblySettings type")
if progress_func:
- progress_func_obj = ctypes.CFUNCTYPE(ctypes.c_bool, ctypes.c_void_p,
- ctypes.c_ulonglong, ctypes.c_ulonglong)\
- (lambda ctxt, cur, total: progress_func(cur, total))
+ progress_func_obj = ctypes.CFUNCTYPE(
+ ctypes.c_bool, ctypes.c_void_p, ctypes.c_ulonglong, ctypes.c_ulonglong
+ )(lambda ctxt, cur, total: progress_func(cur, total))
else:
- progress_func_obj = ctypes.CFUNCTYPE(ctypes.c_bool, ctypes.c_void_p,
- ctypes.c_ulonglong, ctypes.c_ulonglong)\
- (lambda ctxt, cur, total: True)
+ progress_func_obj = ctypes.CFUNCTYPE(
+ ctypes.c_bool, ctypes.c_void_p, ctypes.c_ulonglong, ctypes.c_ulonglong
+ )(lambda ctxt, cur, total: True)
if match_callback:
- match_callback_obj = ctypes.CFUNCTYPE(ctypes.c_bool, ctypes.c_void_p,\
- ctypes.c_ulonglong, ctypes.POINTER(core.BNLinearDisassemblyLine))\
- (lambda ctxt, addr, line: not match_callback(addr,\
- self._LinearDisassemblyLine_convertor(line)) is False)
+ match_callback_obj = ctypes.CFUNCTYPE(
+ ctypes.c_bool, ctypes.c_void_p, ctypes.c_ulonglong, ctypes.POINTER(core.BNLinearDisassemblyLine)
+ )(lambda ctxt, addr, line: not match_callback(addr, self._LinearDisassemblyLine_convertor(line)) is False)
- return core.BNFindAllConstantWithProgress(self.handle, start, end, constant,
- settings.handle, graph_type, None, progress_func_obj, None, match_callback_obj)
+ return core.BNFindAllConstantWithProgress(
+ self.handle, start, end, constant, settings.handle, graph_type, None, progress_func_obj, None,
+ match_callback_obj
+ )
else:
results = queue.Queue()
- match_callback_obj = ctypes.CFUNCTYPE(ctypes.c_bool, ctypes.c_void_p,\
- ctypes.c_ulonglong, ctypes.POINTER(core.BNLinearDisassemblyLine))\
- (lambda ctxt, addr, line: results.put((addr,\
- self._LinearDisassemblyLine_convertor(line))) or True)
+ match_callback_obj = ctypes.CFUNCTYPE(
+ ctypes.c_bool, ctypes.c_void_p, ctypes.c_ulonglong, ctypes.POINTER(core.BNLinearDisassemblyLine)
+ )(lambda ctxt, addr, line: results.put((addr, self._LinearDisassemblyLine_convertor(line))) or True)
- t = threading.Thread(target = lambda: core.BNFindAllConstantWithProgress(self.handle,
- start, end, constant, settings.handle, graph_type, None, progress_func_obj, None,\
- match_callback_obj))
+ t = threading.Thread(
+ target=lambda: core.BNFindAllConstantWithProgress(
+ self.handle, start, end, constant, settings.handle, graph_type, None, progress_func_obj, None,
+ match_callback_obj
+ )
+ )
return self.QueueGenerator(t, results)
@@ -6740,9 +6881,10 @@ class BinaryView:
handle = core.BNGetWorkflowForBinaryView(self.handle)
if handle is None:
return None
- return _workflow.Workflow(handle = handle)
+ return _workflow.Workflow(handle=handle)
- def rebase(self, address:int, force:bool = False, progress_func:ProgressFuncType = None) -> Optional['BinaryView']:
+ def rebase(self, address: int, force: bool = False,
+ progress_func: ProgressFuncType = None) -> Optional['BinaryView']:
"""
``rebase`` rebase the existing :py:class:`BinaryView` into a new :py:class:`BinaryView` at the specified virtual address
@@ -6757,22 +6899,27 @@ class BinaryView:
"""
result = False
if core.BNIsUIEnabled() and not force:
- log_warn("The BinaryView rebase API does not update cooresponding UI components. If the BinaryView is not associated with the UI rerun with 'force = True'.")
+ log_warn(
+ "The BinaryView rebase API does not update cooresponding UI components. If the BinaryView is not associated with the UI rerun with 'force = True'."
+ )
return None
if progress_func is None:
result = core.BNRebase(self.handle, address)
else:
- result = core.BNRebaseWithProgress(self.handle, address, None, ctypes.CFUNCTYPE(ctypes.c_bool, ctypes.c_void_p, ctypes.c_ulonglong, ctypes.c_ulonglong)(
- lambda ctxt, cur, total: progress_func(cur, total)))
+ result = core.BNRebaseWithProgress(
+ self.handle, address, None,
+ ctypes.CFUNCTYPE(ctypes.c_bool, ctypes.c_void_p, ctypes.c_ulonglong,
+ ctypes.c_ulonglong)(lambda ctxt, cur, total: progress_func(cur, total))
+ )
if result:
return self.get_view_of_type(self.view_type)
else:
return None
- def show_plain_text_report(self, title:str, contents:str) -> None:
+ def show_plain_text_report(self, title: str, contents: str) -> None:
core.BNShowPlainTextReport(self.handle, title, contents)
- def show_markdown_report(self, title:str, contents:str, plaintext:str = "") -> None:
+ def show_markdown_report(self, title: str, contents: str, plaintext: str = "") -> None:
"""
``show_markdown_report`` displays the markdown contents in UI applications and plaintext in command-line
applications. Markdown reports support hyperlinking into the BinaryView. Hyperlinks can be specified as follows:
@@ -6790,7 +6937,7 @@ class BinaryView:
"""
core.BNShowMarkdownReport(self.handle, title, contents, plaintext)
- def show_html_report(self, title:str, contents:str, plaintext:str = "") -> None:
+ def show_html_report(self, title: str, contents: str, plaintext: str = "") -> None:
"""
``show_html_report`` displays the HTML contents in UI applications and plaintext in command-line
applications. HTML reports support hyperlinking into the BinaryView. Hyperlinks can be specified as follows:
@@ -6808,7 +6955,7 @@ class BinaryView:
"""
core.BNShowHTMLReport(self.handle, title, contents, plaintext)
- def show_graph_report(self, title:str, graph:flowgraph.FlowGraph) -> None:
+ def show_graph_report(self, title: str, graph: flowgraph.FlowGraph) -> None:
"""
``show_graph_report`` displays a :py:Class:`FlowGraph` object `graph` in a new tab with ``title``.
@@ -6819,7 +6966,7 @@ class BinaryView:
"""
core.BNShowGraphReport(self.handle, title, graph.handle)
- def get_address_input(self, prompt:str, title:str, current_address:int = None) -> Optional[int]:
+ def get_address_input(self, prompt: str, title: str, current_address: int = None) -> Optional[int]:
if current_address is None:
current_address = self._file.offset
value = ctypes.c_ulonglong()
@@ -6827,10 +6974,10 @@ class BinaryView:
return None
return value.value
- def add_auto_segment(self, start:int, length:int, data_offset:int, data_length:int, flags:SegmentFlag) -> None:
+ def add_auto_segment(self, start: int, length: int, data_offset: int, data_length: int, flags: SegmentFlag) -> None:
core.BNAddAutoSegment(self.handle, start, length, data_offset, data_length, flags)
- def remove_auto_segment(self, start:int, length:int) -> None:
+ def remove_auto_segment(self, start: int, length: int) -> None:
"""
``remove_auto_segment`` removes an automatically generated segment from the current segment mapping.
@@ -6843,7 +6990,7 @@ class BinaryView:
"""
core.BNRemoveAutoSegment(self.handle, start, length)
- def add_user_segment(self, start:int, length:int, data_offset:int, data_length:int, flags:SegmentFlag) -> None:
+ def add_user_segment(self, start: int, length: int, data_offset: int, data_length: int, flags: SegmentFlag) -> None:
"""
``add_user_segment`` creates a user-defined segment that specifies how data from the raw file is mapped into a virtual address space.
@@ -6856,10 +7003,10 @@ class BinaryView:
"""
core.BNAddUserSegment(self.handle, start, length, data_offset, data_length, flags)
- def remove_user_segment(self, start:int, length:int) -> None:
+ def remove_user_segment(self, start: int, length: int) -> None:
core.BNRemoveUserSegment(self.handle, start, length)
- def get_segment_at(self, addr:int) -> Optional[Segment]:
+ def get_segment_at(self, addr: int) -> Optional[Segment]:
seg = core.BNGetSegmentAt(self.handle, addr)
if not seg:
return None
@@ -6867,7 +7014,7 @@ class BinaryView:
assert segment_handle is not None, "core.BNNewSegmentReference returned None"
return Segment(segment_handle)
- def get_address_for_data_offset(self, offset:int) -> Optional[int]:
+ def get_address_for_data_offset(self, offset: int) -> Optional[int]:
"""
``get_address_for_data_offset`` returns the virtual address that maps to the specific file offset.
@@ -6880,7 +7027,7 @@ class BinaryView:
return None
return address.value
- def get_data_offset_for_address(self, address:int) -> Optional[int]:
+ def get_data_offset_for_address(self, address: int) -> Optional[int]:
"""
``get_data_offset_for_address`` returns the file offset that maps to the given virtual address, if possible.
@@ -6897,17 +7044,24 @@ class BinaryView:
return offset + segment.data_offset
return None
- def add_auto_section(self, name:str, start:int, length:int,
- semantics:SectionSemantics = SectionSemantics.DefaultSectionSemantics, type:str = "",
- align:int = 1, entry_size:int = 1, linked_section:str = "", info_section:str = "", info_data:int = 0) -> None:
- core.BNAddAutoSection(self.handle, name, start, length, semantics, type, align, entry_size, linked_section,
- info_section, info_data)
+ def add_auto_section(
+ self, name: str, start: int, length: int,
+ semantics: SectionSemantics = SectionSemantics.DefaultSectionSemantics, type: str = "", align: int = 1,
+ entry_size: int = 1, linked_section: str = "", info_section: str = "", info_data: int = 0
+ ) -> None:
+ core.BNAddAutoSection(
+ self.handle, name, start, length, semantics, type, align, entry_size, linked_section, info_section,
+ info_data
+ )
- def remove_auto_section(self, name:str) -> None:
+ def remove_auto_section(self, name: str) -> None:
core.BNRemoveAutoSection(self.handle, name)
- def add_user_section(self, name:str, start:int, length:int, semantics:SectionSemantics = SectionSemantics.DefaultSectionSemantics,
- type:str = "", align:int = 1, entry_size:int = 1, linked_section:str = "", info_section:str = "", info_data:int = 0) -> None:
+ def add_user_section(
+ self, name: str, start: int, length: int,
+ semantics: SectionSemantics = SectionSemantics.DefaultSectionSemantics, type: str = "", align: int = 1,
+ entry_size: int = 1, linked_section: str = "", info_section: str = "", info_data: int = 0
+ ) -> None:
"""
``add_user_section`` creates a user-defined section that can help inform analysis by clarifying what types of
data exist in what ranges. Note that all data specified must already be mapped by an existing segment.
@@ -6924,13 +7078,15 @@ class BinaryView:
:param int info_data: optional info data
:rtype: None
"""
- core.BNAddUserSection(self.handle, name, start, length, semantics, type, align, entry_size, linked_section,
- info_section, info_data)
+ core.BNAddUserSection(
+ self.handle, name, start, length, semantics, type, align, entry_size, linked_section, info_section,
+ info_data
+ )
- def remove_user_section(self, name:str) -> None:
+ def remove_user_section(self, name: str) -> None:
core.BNRemoveUserSection(self.handle, name)
- def get_sections_at(self, addr:int) -> List[Section]:
+ def get_sections_at(self, addr: int) -> List[Section]:
count = ctypes.c_ulonglong(0)
section_list = core.BNGetSectionsAt(self.handle, addr, count)
assert section_list is not None, "core.BNGetSectionsAt returned None"
@@ -6944,7 +7100,7 @@ class BinaryView:
finally:
core.BNFreeSectionList(section_list, count.value)
- def get_section_by_name(self, name:str) -> Optional[Section]:
+ def get_section_by_name(self, name: str) -> Optional[Section]:
section = core.BNGetSectionByName(self.handle, name)
if section is None:
return None
@@ -6953,7 +7109,7 @@ class BinaryView:
result = Section(section_handle)
return result
- def get_unique_section_names(self, name_list:List[str]) -> List[str]:
+ def get_unique_section_names(self, name_list: List[str]) -> List[str]:
incoming_names = (ctypes.c_char_p * len(name_list))()
for i in range(0, len(name_list)):
incoming_names[i] = name_list[i].encode("utf-8")
@@ -6990,7 +7146,7 @@ class BinaryView:
finally:
core.BNFreeAddressList(addrs)
- def get_comment_at(self, addr:int) -> str:
+ def get_comment_at(self, addr: int) -> str:
"""
``get_comment_at`` returns the address-based comment attached to the given address in this BinaryView
Note that address-based comments are different from function-level comments which are specific to each _function.
@@ -7001,7 +7157,7 @@ class BinaryView:
"""
return core.BNGetGlobalCommentForAddress(self.handle, addr)
- def set_comment_at(self, addr:int, comment:str) -> None:
+ def set_comment_at(self, addr: int, comment: str) -> None:
"""
``set_comment_at`` sets a comment for the BinaryView at the address specified
@@ -7039,7 +7195,7 @@ class BinaryView:
raise ValueError("Attempting to apply_debug_info with something which isn't and instance of 'DebugInfo'")
core.BNApplyDebugInfo(self.handle, value.handle)
- def query_metadata(self, key:str) -> 'metadata.MetadataValueType':
+ def query_metadata(self, key: str) -> 'metadata.MetadataValueType':
"""
`query_metadata` retrieves a metadata associated with the given key stored in the current BinaryView.
@@ -7062,7 +7218,7 @@ class BinaryView:
raise KeyError(key)
return metadata.Metadata(handle=md_handle).value
- def store_metadata(self, key:str, md:metadata.MetadataValueType, isAuto:bool = False) -> None:
+ def store_metadata(self, key: str, md: metadata.MetadataValueType, isAuto: bool = False) -> None:
"""
`store_metadata` stores an object for the given key in the current BinaryView. Objects stored using
`store_metadata` can be retrieved when the database is reopened. Objects stored are not arbitrary python
@@ -7094,7 +7250,7 @@ class BinaryView:
_md = metadata.Metadata(_md)
core.BNBinaryViewStoreMetadata(self.handle, key, _md.handle, isAuto)
- def remove_metadata(self, key:str) -> None:
+ def remove_metadata(self, key: str) -> None:
"""
`remove_metadata` removes the metadata associated with key from the current BinaryView.
@@ -7126,7 +7282,7 @@ class BinaryView:
finally:
core.BNFreeStringList(names, count.value)
- def get_load_settings(self, type_name:str) -> Optional[settings.Settings]:
+ def get_load_settings(self, type_name: str) -> Optional[settings.Settings]:
"""
``get_load_settings`` retrieve a :py:class:`Settings` object which defines the load settings for the given :py:class:`BinaryViewType` ``type_name``
@@ -7139,7 +7295,7 @@ class BinaryView:
return None
return settings.Settings(handle=settings_handle)
- def set_load_settings(self, type_name:str, settings:settings.Settings) -> None:
+ def set_load_settings(self, type_name: str, settings: settings.Settings) -> None:
"""
``set_load_settings`` set a :py:class:`settings.Settings` object which defines the load settings for the given :py:class:`BinaryViewType` ``type_name``
@@ -7151,7 +7307,7 @@ class BinaryView:
settings = settings.handle
core.BNBinaryViewSetLoadSettings(self.handle, type_name, settings)
- def parse_expression(self, expression:str, here:int=0) -> int:
+ def parse_expression(self, expression: str, here: int = 0) -> int:
r"""
Evaluates a string expression to an integer value.
@@ -7194,22 +7350,22 @@ class BinaryView:
raise ValueError(error_str)
return offset.value
- def eval(self, expression:str, here:int=0) -> int:
+ def eval(self, expression: str, here: int = 0) -> int:
"""
Evaluates an string expression to an integer value. This is a more concise alias for the :py:meth:`parse_expression` API
"""
return self.parse_expression(expression, here)
- def reader(self, address:Optional[int]=None) -> 'BinaryReader':
+ def reader(self, address: Optional[int] = None) -> 'BinaryReader':
return BinaryReader(self, address=address)
- def writer(self, address:Optional[int]=None) -> 'BinaryWriter':
+ def writer(self, address: Optional[int] = None) -> 'BinaryWriter':
return BinaryWriter(self, address=address)
@property
def libraries(self) -> List[str]:
try:
- result:List[str] = []
+ result: List[str] = []
libs = self.query_metadata("Libraries")
assert isinstance(libs, metadata.Metadata)
for s in libs:
@@ -7219,7 +7375,7 @@ class BinaryView:
except KeyError:
return []
- def typed_data_accessor(self, address:int, type:'_types.Type') -> 'TypedDataAccessor':
+ def typed_data_accessor(self, address: int, type: '_types.Type') -> 'TypedDataAccessor':
return TypedDataAccessor(type, address, self, self.endianness)
@@ -7244,7 +7400,7 @@ class BinaryReader:
'0xcffaedfeL'
>>>
"""
- def __init__(self, view:'BinaryView', endian:Optional[Endianness]=None, address:Optional[int]=None):
+ def __init__(self, view: 'BinaryView', endian: Optional[Endianness] = None, address: Optional[int] = None):
_handle = core.BNCreateBinaryReader(view.handle)
assert _handle is not None, "core.BNCreateBinaryReader returned None"
self._handle = _handle
@@ -7285,7 +7441,7 @@ class BinaryReader:
return Endianness(core.BNGetBinaryReaderEndianness(self._handle))
@endianness.setter
- def endianness(self, value:Endianness) -> None:
+ def endianness(self, value: Endianness) -> None:
core.BNSetBinaryReaderEndianness(self._handle, value)
@property
@@ -7300,7 +7456,7 @@ class BinaryReader:
return core.BNGetReaderPosition(self._handle)
@offset.setter
- def offset(self, value:int) -> None:
+ def offset(self, value: int) -> None:
core.BNSeekBinaryReader(self._handle, value)
@property
@@ -7313,7 +7469,7 @@ class BinaryReader:
"""
return core.BNIsEndOfFile(self._handle)
- def read(self, length:int, address:Optional[int]=None) -> Optional[bytes]:
+ def read(self, length: int, address: Optional[int] = None) -> Optional[bytes]:
"""
``read`` returns ``length`` bytes read from the current offset, adding ``length`` to offset.
@@ -7335,7 +7491,7 @@ class BinaryReader:
return None
return dest.raw
- def read8(self, address:Optional[int]=None) -> Optional[int]:
+ def read8(self, address: Optional[int] = None) -> Optional[int]:
"""
``read8`` returns a one byte integer from offset incrementing the offset.
@@ -7357,7 +7513,7 @@ class BinaryReader:
return None
return result.value
- def read16(self, address:Optional[int]=None) -> Optional[int]:
+ def read16(self, address: Optional[int] = None) -> Optional[int]:
"""
``read16`` returns a two byte integer from offset incrementing the offset by two, using specified endianness.
@@ -7379,7 +7535,7 @@ class BinaryReader:
return None
return result.value
- def read32(self, address:Optional[int]=None) -> Optional[int]:
+ def read32(self, address: Optional[int] = None) -> Optional[int]:
"""
``read32`` returns a four byte integer from offset incrementing the offset by four, using specified endianness.
@@ -7401,7 +7557,7 @@ class BinaryReader:
return None
return result.value
- def read64(self, address:Optional[int]=None) -> Optional[int]:
+ def read64(self, address: Optional[int] = None) -> Optional[int]:
"""
``read64`` returns an eight byte integer from offset incrementing the offset by eight, using specified endianness.
@@ -7423,7 +7579,7 @@ class BinaryReader:
return None
return result.value
- def read16le(self, address:Optional[int]=None) -> Optional[int]:
+ def read16le(self, address: Optional[int] = None) -> Optional[int]:
"""
``read16le`` returns a two byte little endian integer from offset incrementing the offset by two.
@@ -7445,7 +7601,7 @@ class BinaryReader:
return None
return struct.unpack("<H", result)[0]
- def read32le(self, address:Optional[int]=None) -> Optional[int]:
+ def read32le(self, address: Optional[int] = None) -> Optional[int]:
"""
``read32le`` returns a four byte little endian integer from offset incrementing the offset by four.
@@ -7467,7 +7623,7 @@ class BinaryReader:
return None
return struct.unpack("<I", result)[0]
- def read64le(self, address:Optional[int]=None) -> Optional[int]:
+ def read64le(self, address: Optional[int] = None) -> Optional[int]:
"""
``read64le`` returns an eight byte little endian integer from offset incrementing the offset by eight.
@@ -7489,7 +7645,7 @@ class BinaryReader:
return None
return struct.unpack("<Q", result)[0]
- def read16be(self, address:Optional[int]=None) -> Optional[int]:
+ def read16be(self, address: Optional[int] = None) -> Optional[int]:
"""
``read16be`` returns a two byte big endian integer from offset incrementing the offset by two.
@@ -7511,7 +7667,7 @@ class BinaryReader:
return None
return struct.unpack(">H", result)[0]
- def read32be(self, address:Optional[int]=None) -> Optional[int]:
+ def read32be(self, address: Optional[int] = None) -> Optional[int]:
"""
``read32be`` returns a four byte big endian integer from offset incrementing the offset by four.
@@ -7532,7 +7688,7 @@ class BinaryReader:
return None
return struct.unpack(">I", result)[0]
- def read64be(self, address:Optional[int]=None) -> Optional[int]:
+ def read64be(self, address: Optional[int] = None) -> Optional[int]:
"""
``read64be`` returns an eight byte big endian integer from offset incrementing the offset by eight.
@@ -7553,7 +7709,7 @@ class BinaryReader:
return None
return struct.unpack(">Q", result)[0]
- def seek(self, offset:int) -> None:
+ def seek(self, offset: int) -> None:
"""
``seek`` update internal offset to ``offset``.
@@ -7570,7 +7726,7 @@ class BinaryReader:
"""
core.BNSeekBinaryReader(self._handle, offset)
- def seek_relative(self, offset:int) -> None:
+ def seek_relative(self, offset: int) -> None:
"""
``seek_relative`` updates the internal offset by ``offset``.
@@ -7610,7 +7766,7 @@ class BinaryWriter:
>>> bw = BinaryWriter(bv, Endianness.BigEndian)
>>>
"""
- def __init__(self, view:BinaryView, endian:Optional[Endianness] = None, address:Optional[int]=None):
+ def __init__(self, view: BinaryView, endian: Optional[Endianness] = None, address: Optional[int] = None):
self._handle = core.BNCreateBinaryWriter(view.handle)
assert self._handle is not None, "core.BNCreateBinaryWriter returned None"
self._view = view
@@ -7654,7 +7810,7 @@ class BinaryWriter:
return core.BNGetBinaryWriterEndianness(self._handle)
@endianness.setter
- def endianness(self, value:Endianness) -> None:
+ def endianness(self, value: Endianness) -> None:
core.BNSetBinaryWriterEndianness(self._handle, value)
@property
@@ -7669,10 +7825,10 @@ class BinaryWriter:
return core.BNGetWriterPosition(self._handle)
@offset.setter
- def offset(self, value:int) -> None:
+ def offset(self, value: int) -> None:
core.BNSeekBinaryWriter(self._handle, value)
- def write(self, value:bytes, address:Optional[int]=None, except_on_relocation=True) -> bool:
+ def write(self, value: bytes, address: Optional[int] = None, except_on_relocation=True) -> bool:
"""
``write`` writes ``len(value)`` bytes to the internal offset, without regard to endianness.
@@ -7700,7 +7856,7 @@ class BinaryWriter:
ctypes.memmove(buf, value, len(value))
return core.BNWriteData(self._handle, buf, len(value))
- def write8(self, value:int, address:Optional[int]=None, except_on_relocation=True) -> bool:
+ def write8(self, value: int, address: Optional[int] = None, except_on_relocation=True) -> bool:
"""
``write8`` lowest order byte from the integer ``value`` to the current offset.
@@ -7724,7 +7880,7 @@ class BinaryWriter:
raise RelocationWriteException("Attempting to write to a location which has a relocation")
return core.BNWrite8(self._handle, value)
- def write16(self, value:int, address:Optional[int]=None, except_on_relocation=True) -> bool:
+ def write16(self, value: int, address: Optional[int] = None, except_on_relocation=True) -> bool:
"""
``write16`` writes the lowest order two bytes from the integer ``value`` to the current offset, using internal endianness.
@@ -7741,7 +7897,7 @@ class BinaryWriter:
raise RelocationWriteException("Attempting to write to a location which has a relocation")
return core.BNWrite16(self._handle, value)
- def write32(self, value:int, address:Optional[int]=None, except_on_relocation=True) -> bool:
+ def write32(self, value: int, address: Optional[int] = None, except_on_relocation=True) -> bool:
"""
``write32`` writes the lowest order four bytes from the integer ``value`` to the current offset, using internal endianness.
@@ -7758,7 +7914,7 @@ class BinaryWriter:
raise RelocationWriteException("Attempting to write to a location which has a relocation")
return core.BNWrite32(self._handle, value)
- def write64(self, value:int, address:Optional[int]=None, except_on_relocation=True) -> bool:
+ def write64(self, value: int, address: Optional[int] = None, except_on_relocation=True) -> bool:
"""
``write64`` writes the lowest order eight bytes from the integer ``value`` to the current offset, using internal endianness.
@@ -7775,7 +7931,7 @@ class BinaryWriter:
raise RelocationWriteException("Attempting to write to a location which has a relocation")
return core.BNWrite64(self._handle, value)
- def write16le(self, value:int, address:Optional[int]=None, except_on_relocation=True) -> bool:
+ def write16le(self, value: int, address: Optional[int] = None, except_on_relocation=True) -> bool:
"""
``write16le`` writes the lowest order two bytes from the little endian integer ``value`` to the current offset.
@@ -7789,7 +7945,7 @@ class BinaryWriter:
self.seek(address)
return self.write(struct.pack("<H", value), except_on_relocation=except_on_relocation)
- def write32le(self, value:int, address:Optional[int]=None, except_on_relocation=True) -> bool:
+ def write32le(self, value: int, address: Optional[int] = None, except_on_relocation=True) -> bool:
"""
``write32le`` writes the lowest order four bytes from the little endian integer ``value`` to the current offset.
@@ -7803,7 +7959,7 @@ class BinaryWriter:
self.seek(address)
return self.write(struct.pack("<I", value), except_on_relocation=except_on_relocation)
- def write64le(self, value:int, address:Optional[int]=None, except_on_relocation=True) -> bool:
+ def write64le(self, value: int, address: Optional[int] = None, except_on_relocation=True) -> bool:
"""
``write64le`` writes the lowest order eight bytes from the little endian integer ``value`` to the current offset.
@@ -7817,7 +7973,7 @@ class BinaryWriter:
self.seek(address)
return self.write(struct.pack("<Q", value), except_on_relocation=except_on_relocation)
- def write16be(self, value:int, address:Optional[int]=None, except_on_relocation=True) -> bool:
+ def write16be(self, value: int, address: Optional[int] = None, except_on_relocation=True) -> bool:
"""
``write16be`` writes the lowest order two bytes from the big endian integer ``value`` to the current offset.
@@ -7831,7 +7987,7 @@ class BinaryWriter:
self.seek(address)
return self.write(struct.pack(">H", value), except_on_relocation=except_on_relocation)
- def write32be(self, value:int, address:Optional[int]=None, except_on_relocation=True) -> bool:
+ def write32be(self, value: int, address: Optional[int] = None, except_on_relocation=True) -> bool:
"""
``write32be`` writes the lowest order four bytes from the big endian integer ``value`` to the current offset.
@@ -7845,7 +8001,7 @@ class BinaryWriter:
self.seek(address)
return self.write(struct.pack(">I", value), except_on_relocation=except_on_relocation)
- def write64be(self, value:int, address:Optional[int]=None, except_on_relocation=True) -> bool:
+ def write64be(self, value: int, address: Optional[int] = None, except_on_relocation=True) -> bool:
"""
``write64be`` writes the lowest order eight bytes from the big endian integer ``value`` to the current offset.
@@ -7859,7 +8015,7 @@ class BinaryWriter:
self.seek(address)
return self.write(struct.pack(">Q", value), except_on_relocation=except_on_relocation)
- def seek(self, offset:int) -> None:
+ def seek(self, offset: int) -> None:
"""
``seek`` update internal offset to ``offset``.
@@ -7876,7 +8032,7 @@ class BinaryWriter:
"""
core.BNSeekBinaryWriter(self._handle, offset)
- def seek_relative(self, offset:int) -> None:
+ def seek_relative(self, offset: int) -> None:
"""
``seek_relative`` updates the internal offset by ``offset``.
@@ -7899,10 +8055,10 @@ class StructuredDataValue(object):
"""
DEPRECATED use: TypedDataAccessor instead.
"""
- type:'_types.Type'
- address:int
- value:bytes
- endian:Endianness
+ type: '_types.Type'
+ address: int
+ value: bytes
+ endian: Endianness
def __str__(self):
decode_str = "{}B".format(self.type.width)
@@ -7956,7 +8112,7 @@ class StructuredDataView(object):
003e
>>>
"""
- def __init__(self, bv:'BinaryView', structure_name:'_types.QualifiedNameType', address:int):
+ def __init__(self, bv: 'BinaryView', structure_name: '_types.QualifiedNameType', address: int):
self._bv = bv
self._structure_name = structure_name
self._address = address
@@ -7988,7 +8144,7 @@ class StructuredDataView(object):
return self[key]
- def __getitem__(self, key:str) -> Optional[StructuredDataValue]:
+ def __getitem__(self, key: str) -> Optional[StructuredDataValue]:
m = self._members.get(key, None)
if m is None:
return None
@@ -8027,10 +8183,10 @@ class StructuredDataView(object):
@dataclass
class TypedDataAccessor:
- type:'_types.Type'
- address:int
- view:'BinaryView'
- endian:Endianness
+ type: '_types.Type'
+ address: int
+ view: 'BinaryView'
+ endian: Endianness
def __post_init__(self):
if not isinstance(self.type, _types.Type):
@@ -8060,7 +8216,7 @@ class TypedDataAccessor:
return self.int_from_bytes(bytes(self), len(self), bool(_type.signed), self.endian)
raise Exception(f"Attempting to coerce non integral type: {type(_type)} to an integer")
- def __getitem__(self, key:Union[str, int]) -> 'TypedDataAccessor':
+ def __getitem__(self, key: Union[str, int]) -> 'TypedDataAccessor':
_type = self.type
if isinstance(_type, _types.NamedTypeReferenceType):
_type = _type.target(self.view)
@@ -8078,12 +8234,14 @@ class TypedDataAccessor:
return TypedDataAccessor(m.type.immutable_copy(), self.address + m.offset, self.view, self.endian)
@staticmethod
- def byte_order(endian) -> str: # as of python3.8 -> Literal["little", "big"]
+ def byte_order(endian) -> str: # as of python3.8 -> Literal["little", "big"]
return "little" if endian == Endianness.LittleEndian else "big"
@staticmethod
- def int_from_bytes(data:bytes, width:int, sign:bool, endian:Optional[Endianness]=None) -> int:
- return int.from_bytes(data[0:width], byteorder=TypedDataAccessor.byte_order(endian), signed=sign) # type: ignore
+ def int_from_bytes(data: bytes, width: int, sign: bool, endian: Optional[Endianness] = None) -> int:
+ return int.from_bytes(
+ data[0:width], byteorder=TypedDataAccessor.byte_order(endian), signed=sign
+ ) # type: ignore
def __float__(self):
if not isinstance(self.type, _types.FloatType):
@@ -8104,14 +8262,13 @@ class TypedDataAccessor:
return self._value_helper(self.type, self.view.read(self.address, len(self.type)))
@value.setter
- def value(self, data:Union[bytes, int]) -> None:
+ def value(self, data: Union[bytes, int]) -> None:
if isinstance(data, int):
- integral_types = (_types.IntegerType, _types.IntegerBuilder,
- _types.BoolType, _types.BoolBuilder,
- _types.CharType, _types.CharBuilder,
- _types.WideCharType, _types.WideCharBuilder,
- _types.PointerType, _types.PointerBuilder,
- _types.EnumerationType, _types.EnumerationBuilder)
+ integral_types = (
+ _types.IntegerType, _types.IntegerBuilder, _types.BoolType, _types.BoolBuilder, _types.CharType,
+ _types.CharBuilder, _types.WideCharType, _types.WideCharBuilder, _types.PointerType,
+ _types.PointerBuilder, _types.EnumerationType, _types.EnumerationBuilder
+ )
if not isinstance(self.type, integral_types):
raise TypeError(f"Can't set the value of type {type(self.type)} to int value")
to_write = data.to_bytes(len(self), TypedDataAccessor.byte_order(self.endian)) # type: ignore
@@ -8131,7 +8288,7 @@ class TypedDataAccessor:
count = self.view.write(self.address, to_write)
assert count == len(to_write), "Unable to write all bytes to the location, segment might not have file backing"
- def _value_helper(self, _type:'_types.Type', data:bytes) -> Any:
+ def _value_helper(self, _type: '_types.Type', data: bytes) -> Any:
if not isinstance(_type, _types.Type):
raise TypeError(f"Attempting to get value of TypeBuilder of type {type(_type)}")
if isinstance(_type, _types.NamedTypeReferenceType):
@@ -8140,7 +8297,7 @@ class TypedDataAccessor:
raise ValueError("Couldn't find target for type")
_type = target
- if isinstance(_type, (_types.VoidType, _types.FunctionType)): #, _types.VarArgsType, _types.ValueType)):
+ if isinstance(_type, (_types.VoidType, _types.FunctionType)): #, _types.VarArgsType, _types.ValueType)):
return None
elif isinstance(_type, _types.BoolType):
return bool(self)
@@ -8153,7 +8310,8 @@ class TypedDataAccessor:
elif isinstance(_type, _types.StructureType):
result = {}
for member in _type.members:
- result[member.name] = TypedDataAccessor(member.type, self.address + member.offset, self.view, self.endian).value
+ result[member.name
+ ] = TypedDataAccessor(member.type, self.address + member.offset, self.view, self.endian).value
return result
elif isinstance(_type, _types.EnumerationType):
value = int(self)
@@ -8168,7 +8326,9 @@ class TypedDataAccessor:
if _type.element_type.width == 1 and _type.element_type.type_class == TypeClass.IntegerTypeClass:
return bytes(self)
for offset in range(0, len(_type), _type.element_type.width):
- result.append(TypedDataAccessor(_type.element_type, self.address + offset, self.view, self.endian).value)
+ result.append(
+ TypedDataAccessor(_type.element_type, self.address + offset, self.view, self.endian).value
+ )
return result
else:
raise TypeError(f"Unhandled `Type` {type(_type)}")
@@ -8177,11 +8337,12 @@ class TypedDataAccessor:
# for backward compatibility
TypedDataReader = TypedDataAccessor
+
@dataclass
class CoreDataVariable:
- _address:int
- _type:'_types.Type'
- _auto_discovered:bool
+ _address: int
+ _type: '_types.Type'
+ _auto_discovered: bool
def __len__(self):
return len(self._type)
@@ -8200,15 +8361,16 @@ class CoreDataVariable:
class DataVariable(CoreDataVariable):
- def __init__(self, view:BinaryView, address:int, type:'_types.Type', auto_discovered:bool):
+ def __init__(self, view: BinaryView, address: int, type: '_types.Type', auto_discovered: bool):
super(DataVariable, self).__init__(address, type, auto_discovered)
self.view = view
self._sdv = TypedDataAccessor(self.type, self.address, self.view, self.view.endianness)
@classmethod
- def from_core_struct(cls, var:core.BNDataVariable, view:'BinaryView') -> 'DataVariable':
- var_type = _types.Type.create(core.BNNewTypeReference(var.type), platform=view.platform,
- confidence=var.typeConfidence)
+ def from_core_struct(cls, var: core.BNDataVariable, view: 'BinaryView') -> 'DataVariable':
+ var_type = _types.Type.create(
+ core.BNNewTypeReference(var.type), platform=view.platform, confidence=var.typeConfidence
+ )
return cls(view, var.address, var_type, var.autoDiscovered)
@property
@@ -8237,10 +8399,10 @@ class DataVariable(CoreDataVariable):
return self._sdv.value
@value.setter
- def value(self, data:bytes) -> None:
+ def value(self, data: bytes) -> None:
self._sdv.value = data
- def __getitem__(self, item:str):
+ def __getitem__(self, item: str):
return self._sdv[item]
@property
@@ -8248,7 +8410,7 @@ class DataVariable(CoreDataVariable):
return self._type
@type.setter
- def type(self, value:Optional['_types.Type']) -> None: # type: ignore
+ def type(self, value: Optional['_types.Type']) -> None: # type: ignore
_type = value if value is not None else _types.VoidType.create()
assert self.view.define_user_data_var(self.address, _type) is not None, "Unable to set DataVariable's type"
self._type = _type
@@ -8258,7 +8420,7 @@ class DataVariable(CoreDataVariable):
return self.view.get_symbol_at(self.address)
@symbol.setter
- def symbol(self, value:Optional[Union[str, '_types.CoreSymbol']]) -> None: # type: ignore
+ def symbol(self, value: Optional[Union[str, '_types.CoreSymbol']]) -> None: # type: ignore
if value is None or value == "":
if self.symbol is not None:
self.view.undefine_user_symbol(self.symbol)
@@ -8277,14 +8439,14 @@ class DataVariable(CoreDataVariable):
return self.symbol.name
@name.setter
- def name(self, value:str) -> None:
+ def name(self, value: str) -> None:
self.symbol = value
class DataVariableAndName(CoreDataVariable):
- def __init__(self, addr:int, var_type:'_types.Type', var_name:str, auto_discovered:bool) -> None:
+ def __init__(self, addr: int, var_type: '_types.Type', var_name: str, auto_discovered: bool) -> None:
super(DataVariableAndName, self).__init__(addr, var_type, auto_discovered)
self.name = var_name
def __repr__(self) -> str:
- return f"<var {self.address:#x}: {self.type} {self.name}>" \ No newline at end of file
+ return f"<var {self.address:#x}: {self.type} {self.name}>"
diff --git a/python/bncompleter.py b/python/bncompleter.py
index ba012a2a..ff093b9d 100644
--- a/python/bncompleter.py
+++ b/python/bncompleter.py
@@ -48,6 +48,7 @@ from typing import Optional
__all__ = ["Completer"]
+
def fnsignature(obj):
if sys.version_info[0:2] >= (3, 5):
try:
@@ -59,14 +60,14 @@ def fnsignature(obj):
try:
args = inspect.getargspec(obj).args
args.remove('self')
- sig = "(" + ','.join(args) + ")"
+ sig = "(" + ','.join(args) + ")"
except:
sig = "()"
return sig
class Completer:
- def __init__(self, namespace = None):
+ def __init__(self, namespace=None):
"""Create a new completer for the command line.
Completer([namespace]) -> completer instance.
@@ -93,7 +94,7 @@ class Completer:
self.use_main_ns = 0
self.namespace = namespace
- def complete(self, text:str, state) -> Optional[str]:
+ def complete(self, text: str, state) -> Optional[str]:
"""Return the next possible completion for 'text'.
This is called successively with state == 0, 1, 2, ... until it
@@ -140,16 +141,14 @@ class Completer:
seen.add(word)
if word in {'finally', 'try'}:
word = word + ':'
- elif word not in {'False', 'None', 'True',
- 'break', 'continue', 'pass',
- 'else'}:
+ elif word not in {'False', 'None', 'True', 'break', 'continue', 'pass', 'else'}:
word = word + ' '
matches.append(word)
#Not sure why in the console builtins becomes a dict but this works for now.
if hasattr(__builtins__, '__dict__'): # type: ignore # remove this ignore > pyright 1.1.149
- builtins = __builtins__.__dict__ # type: ignore # remove this ignore > pyright 1.1.149
+ builtins = __builtins__.__dict__ # type: ignore # remove this ignore > pyright 1.1.149
else:
- builtins = __builtins__ # type: ignore # remove this ignore > pyright 1.1.149
+ builtins = __builtins__ # type: ignore # remove this ignore > pyright 1.1.149
for nspace in [self.namespace, builtins]:
for word, val in nspace.items():
if word[:n] == text and word not in seen:
@@ -196,7 +195,7 @@ class Completer:
noprefix = None
while True:
for word in words:
- if (word[:n] == attr and not (noprefix and word[:n+1] == noprefix)):
+ if (word[:n] == attr and not (noprefix and word[:n + 1] == noprefix)):
match = f"{expr}.{word}"
try:
val = inspect.getattr_static(thisobject, word)
@@ -214,9 +213,10 @@ class Completer:
matches.sort()
return matches
+
def get_class_members(klass):
ret = dir(klass)
- if hasattr(klass,'__bases__'):
+ if hasattr(klass, '__bases__'):
for base in klass.__bases__:
ret = ret + get_class_members(base)
return ret
diff --git a/python/callingconvention.py b/python/callingconvention.py
index 89040119..44d835b7 100644
--- a/python/callingconvention.py
+++ b/python/callingconvention.py
@@ -29,8 +29,7 @@ from . import variable
from . import function
from . import architecture
-FunctionOrILFunction = Union["binaryninja.function.Function",
- "binaryninja.lowlevelil.LowLevelILFunction",
+FunctionOrILFunction = Union["binaryninja.function.Function", "binaryninja.lowlevelil.LowLevelILFunction",
"binaryninja.mediumlevelil.MediumLevelILFunction",
"binaryninja.highlevelil.HighLevelILFunction"]
@@ -54,7 +53,10 @@ class CallingConvention:
_registered_calling_conventions = []
- def __init__(self, arch:'architecture.Architecture'=None, name:str=None, handle=None, confidence:int=core.max_confidence):
+ def __init__(
+ self, arch: 'architecture.Architecture' = None, name: str = None, handle=None,
+ confidence: int = core.max_confidence
+ ):
if handle is None:
if arch is None or name is None:
raise ValueError("Must specify either handle or architecture and name")
@@ -64,23 +66,49 @@ class CallingConvention:
self._cb.context = 0
self._cb.getCallerSavedRegisters = self._cb.getCallerSavedRegisters.__class__(self._get_caller_saved_regs)
self._cb.getCalleeSavedRegisters = self._cb.getCalleeSavedRegisters.__class__(self._get_callee_saved_regs)
- self._cb.getIntegerArgumentRegisters = self._cb.getIntegerArgumentRegisters.__class__(self._get_int_arg_regs)
+ self._cb.getIntegerArgumentRegisters = self._cb.getIntegerArgumentRegisters.__class__(
+ self._get_int_arg_regs
+ )
self._cb.getFloatArgumentRegisters = self._cb.getFloatArgumentRegisters.__class__(self._get_float_arg_regs)
self._cb.freeRegisterList = self._cb.freeRegisterList.__class__(self._free_register_list)
- self._cb.areArgumentRegistersSharedIndex = self._cb.areArgumentRegistersSharedIndex.__class__(self._arg_regs_share_index)
- self._cb.areArgumentRegistersUsedForVarArgs = self._cb.areArgumentRegistersUsedForVarArgs.__class__(self._arg_regs_used_for_varargs)
- self._cb.isStackReservedForArgumentRegisters = self._cb.isStackReservedForArgumentRegisters.__class__(self._stack_reserved_for_arg_regs)
- self._cb.isStackAdjustedOnReturn = self._cb.isStackAdjustedOnReturn.__class__(self._stack_adjusted_on_return)
+ self._cb.areArgumentRegistersSharedIndex = self._cb.areArgumentRegistersSharedIndex.__class__(
+ self._arg_regs_share_index
+ )
+ self._cb.areArgumentRegistersUsedForVarArgs = self._cb.areArgumentRegistersUsedForVarArgs.__class__(
+ self._arg_regs_used_for_varargs
+ )
+ self._cb.isStackReservedForArgumentRegisters = self._cb.isStackReservedForArgumentRegisters.__class__(
+ self._stack_reserved_for_arg_regs
+ )
+ self._cb.isStackAdjustedOnReturn = self._cb.isStackAdjustedOnReturn.__class__(
+ self._stack_adjusted_on_return
+ )
self._cb.isEligibleForHeuristics = self._cb.isEligibleForHeuristics.__class__(self._eligible_for_heuristics)
- self._cb.getIntegerReturnValueRegister = self._cb.getIntegerReturnValueRegister.__class__(self._get_int_return_reg)
- self._cb.getHighIntegerReturnValueRegister = self._cb.getHighIntegerReturnValueRegister.__class__(self._get_high_int_return_reg)
- self._cb.getFloatReturnValueRegister = self._cb.getFloatReturnValueRegister.__class__(self._get_float_return_reg)
- self._cb.getGlobalPointerRegister = self._cb.getGlobalPointerRegister.__class__(self._get_global_pointer_reg)
- self._cb.getImplicitlyDefinedRegisters = self._cb.getImplicitlyDefinedRegisters.__class__(self._get_implicitly_defined_regs)
- self._cb.getIncomingRegisterValue = self._cb.getIncomingRegisterValue.__class__(self._get_incoming_reg_value)
+ self._cb.getIntegerReturnValueRegister = self._cb.getIntegerReturnValueRegister.__class__(
+ self._get_int_return_reg
+ )
+ self._cb.getHighIntegerReturnValueRegister = self._cb.getHighIntegerReturnValueRegister.__class__(
+ self._get_high_int_return_reg
+ )
+ self._cb.getFloatReturnValueRegister = self._cb.getFloatReturnValueRegister.__class__(
+ self._get_float_return_reg
+ )
+ self._cb.getGlobalPointerRegister = self._cb.getGlobalPointerRegister.__class__(
+ self._get_global_pointer_reg
+ )
+ self._cb.getImplicitlyDefinedRegisters = self._cb.getImplicitlyDefinedRegisters.__class__(
+ self._get_implicitly_defined_regs
+ )
+ self._cb.getIncomingRegisterValue = self._cb.getIncomingRegisterValue.__class__(
+ self._get_incoming_reg_value
+ )
self._cb.getIncomingFlagValue = self._cb.getIncomingFlagValue.__class__(self._get_incoming_flag_value)
- self._cb.getIncomingVariableForParameterVariable = self._cb.getIncomingVariableForParameterVariable.__class__(self._get_incoming_var_for_parameter_var)
- self._cb.getParameterVariableForIncomingVariable = self._cb.getParameterVariableForIncomingVariable.__class__(self._get_parameter_var_for_incoming_var)
+ self._cb.getIncomingVariableForParameterVariable = self._cb.getIncomingVariableForParameterVariable.__class__(
+ self._get_incoming_var_for_parameter_var
+ )
+ self._cb.getParameterVariableForIncomingVariable = self._cb.getParameterVariableForIncomingVariable.__class__(
+ self._get_parameter_var_for_incoming_var
+ )
_handle = core.BNCreateCallingConvention(arch.handle, name, self._cb)
self.__class__._registered_calling_conventions.append(self)
else:
@@ -352,7 +380,7 @@ class CallingConvention:
def _get_incoming_reg_value(self, ctxt, reg, func, result):
try:
- func_obj = function.Function(handle = core.BNNewFunctionReference(func))
+ func_obj = function.Function(handle=core.BNNewFunctionReference(func))
reg_name = self.arch.get_reg_name(reg)
api_obj = self.perform_get_incoming_reg_value(reg_name, func_obj)._to_core_struct()
except:
@@ -363,7 +391,7 @@ class CallingConvention:
def _get_incoming_flag_value(self, ctxt, reg, func, result):
try:
- func_obj = function.Function(handle = core.BNNewFunctionReference(func))
+ func_obj = function.Function(handle=core.BNNewFunctionReference(func))
reg_name = self.arch.get_reg_name(reg)
api_obj = self.perform_get_incoming_flag_value(reg_name, func_obj)._to_core_struct()
except:
@@ -377,7 +405,7 @@ class CallingConvention:
if func is None:
func_obj = None
else:
- func_obj = function.Function(handle = core.BNNewFunctionReference(func))
+ func_obj = function.Function(handle=core.BNNewFunctionReference(func))
in_var_obj = variable.CoreVariable.from_BNVariable(in_var[0])
out_var = self.perform_get_incoming_var_for_parameter_var(in_var_obj, func_obj)
result[0].type = out_var.source_type
@@ -394,7 +422,7 @@ class CallingConvention:
if func is None:
func_obj = None
else:
- func_obj = function.Function(handle = core.BNNewFunctionReference(func))
+ func_obj = function.Function(handle=core.BNNewFunctionReference(func))
in_var_obj = variable.CoreVariable.from_BNVariable(in_var[0])
out_var = self.perform_get_parameter_var_for_incoming_var(in_var_obj, func_obj)
result[0].type = out_var.source_type
@@ -406,45 +434,62 @@ class CallingConvention:
result[0].index = in_var[0].index
result[0].storage = in_var[0].storage
- def perform_get_incoming_reg_value(self, reg:'architecture.RegisterName', func:'function.Function') -> 'variable.RegisterValue':
+ def perform_get_incoming_reg_value(
+ self, reg: 'architecture.RegisterName', func: 'function.Function'
+ ) -> 'variable.RegisterValue':
reg_stack = self.arch.get_reg_stack_for_reg(reg)
if reg_stack is not None:
if reg == self.arch.reg_stacks[reg_stack].stack_top_reg:
return variable.ConstantRegisterValue(0)
return variable.Undetermined()
- def perform_get_incoming_flag_value(self, reg:'architecture.RegisterName', func:'function.Function') -> 'variable.RegisterValue':
+ def perform_get_incoming_flag_value(
+ self, reg: 'architecture.RegisterName', func: 'function.Function'
+ ) -> 'variable.RegisterValue':
return variable.Undetermined()
- def perform_get_incoming_var_for_parameter_var(self, in_var:'variable.CoreVariable',
- func:Optional['function.Function']=None) -> 'variable.CoreVariable':
+ def perform_get_incoming_var_for_parameter_var(
+ self, in_var: 'variable.CoreVariable', func: Optional['function.Function'] = None
+ ) -> 'variable.CoreVariable':
out_var = core.BNGetDefaultIncomingVariableForParameterVariable(self.handle, in_var.to_BNVariable())
return variable.CoreVariable.from_BNVariable(out_var)
- def perform_get_parameter_var_for_incoming_var(self, in_var:'variable.CoreVariable',
- func:Optional['function.Function']=None) -> 'variable.CoreVariable':
+ def perform_get_parameter_var_for_incoming_var(
+ self, in_var: 'variable.CoreVariable', func: Optional['function.Function'] = None
+ ) -> 'variable.CoreVariable':
out_var = core.BNGetDefaultParameterVariableForIncomingVariable(self.handle, in_var.to_BNVariable())
return variable.CoreVariable.from_BNVariable(out_var)
- def with_confidence(self, confidence:int) -> 'CallingConvention':
- return CallingConvention(self.arch, handle = core.BNNewCallingConventionReference(self.handle),
- confidence = confidence)
+ def with_confidence(self, confidence: int) -> 'CallingConvention':
+ return CallingConvention(
+ self.arch, handle=core.BNNewCallingConventionReference(self.handle), confidence=confidence
+ )
- def get_incoming_reg_value(self, reg:'architecture.RegisterType', func:'function.Function') -> 'variable.RegisterValue':
+ def get_incoming_reg_value(
+ self, reg: 'architecture.RegisterType', func: 'function.Function'
+ ) -> 'variable.RegisterValue':
reg_num = self.arch.get_reg_index(reg)
func_handle = None
if func is not None:
func_handle = func.handle
- return variable.RegisterValue.from_BNRegisterValue(core.BNGetIncomingRegisterValue(self.handle, reg_num, func_handle), self.arch)
+ return variable.RegisterValue.from_BNRegisterValue(
+ core.BNGetIncomingRegisterValue(self.handle, reg_num, func_handle), self.arch
+ )
- def get_incoming_flag_value(self, flag:'architecture.FlagIndex', func:'function.Function') -> 'variable.RegisterValue':
+ def get_incoming_flag_value(
+ self, flag: 'architecture.FlagIndex', func: 'function.Function'
+ ) -> 'variable.RegisterValue':
reg_num = self.arch.get_flag_index(flag)
func_handle = None
if func is not None:
func_handle = func.handle
- return variable.RegisterValue.from_BNRegisterValue(core.BNGetIncomingFlagValue(self.handle, reg_num, func_handle), self.arch)
+ return variable.RegisterValue.from_BNRegisterValue(
+ core.BNGetIncomingFlagValue(self.handle, reg_num, func_handle), self.arch
+ )
- def get_incoming_var_for_parameter_var(self, in_var:'variable.CoreVariable', func:FunctionOrILFunction) -> 'variable.Variable':
+ def get_incoming_var_for_parameter_var(
+ self, in_var: 'variable.CoreVariable', func: FunctionOrILFunction
+ ) -> 'variable.Variable':
in_buf = in_var.to_BNVariable()
if func is None:
func_obj = None
@@ -453,7 +498,9 @@ class CallingConvention:
out_var = core.BNGetIncomingVariableForParameterVariable(self.handle, in_buf, func_obj)
return variable.Variable.from_BNVariable(func, out_var)
- def get_parameter_var_for_incoming_var(self, in_var:'variable.CoreVariable', func:FunctionOrILFunction) -> 'variable.Variable':
+ def get_parameter_var_for_incoming_var(
+ self, in_var: 'variable.CoreVariable', func: FunctionOrILFunction
+ ) -> 'variable.Variable':
in_buf = in_var.to_BNVariable()
if func is None:
func_obj = None
@@ -467,5 +514,5 @@ class CallingConvention:
return self._arch
@arch.setter
- def arch(self, value:'architecture.Architecture') -> None:
+ def arch(self, value: 'architecture.Architecture') -> None:
self._arch = value
diff --git a/python/commonil.py b/python/commonil.py
index 9e9f6fea..7517574d 100644
--- a/python/commonil.py
+++ b/python/commonil.py
@@ -24,11 +24,12 @@ from .enums import BranchType
from .interaction import show_graph_report
from .log import log_warn
+
# This file contains a list of top level abstract classes for implementing BNIL instructions
@dataclass(frozen=True, repr=False, eq=False)
class BaseILInstruction:
@classmethod
- def prepend_parent(cls, graph:FlowGraph, node:FlowGraphNode, nodes={}):
+ def prepend_parent(cls, graph: FlowGraph, node: FlowGraphNode, nodes={}):
for parent in cls.__bases__:
if not issubclass(parent, BaseILInstruction):
continue
@@ -54,6 +55,7 @@ class BaseILInstruction:
def show_hierarchy_graph(cls):
show_graph_report(f"{cls.__name__}", cls.add_subgraph(FlowGraph(), {}))
+
@dataclass(frozen=True, repr=False, eq=False)
class Constant(BaseILInstruction):
pass
@@ -123,6 +125,7 @@ class Localcall(Call):
class Tailcall(Localcall):
pass
+
@dataclass(frozen=True, repr=False, eq=False)
class Return(Terminal):
pass
diff --git a/python/compatibility.py b/python/compatibility.py
index bae8a6d3..fef7e49b 100644
--- a/python/compatibility.py
+++ b/python/compatibility.py
@@ -20,6 +20,7 @@
import sys
+
def pyNativeStr(arg):
if isinstance(arg, str):
return arg
@@ -36,5 +37,3 @@ def valid_import(mod_name):
mod_loader = importlib.find_loader(mod_name)
found = mod_loader is not None
return found
-
-
diff --git a/python/database.py b/python/database.py
index a563d99c..b9b81058 100644
--- a/python/database.py
+++ b/python/database.py
@@ -28,322 +28,322 @@ from . import filemetadata
class KeyValueStore:
- """
+ """
``class KeyValueStore`` maintains access to the raw data stored in Snapshots and various
other Database-related structures.
"""
- def __init__(self, buffer: Optional[databuffer.DataBuffer] = None, handle=None):
- if handle is not None:
- self.handle = core.handle_of_type(handle, core.BNKeyValueStore)
- else:
- if buffer is None:
- _handle = core.BNCreateKeyValueStore()
- else:
- _handle = core.BNCreateKeyValueStoreFromDataBuffer(buffer.handle)
- assert _handle is not None
- self.handle = _handle
+ def __init__(self, buffer: Optional[databuffer.DataBuffer] = None, handle=None):
+ if handle is not None:
+ self.handle = core.handle_of_type(handle, core.BNKeyValueStore)
+ else:
+ if buffer is None:
+ _handle = core.BNCreateKeyValueStore()
+ else:
+ _handle = core.BNCreateKeyValueStoreFromDataBuffer(buffer.handle)
+ assert _handle is not None
+ self.handle = _handle
- def __del__(self):
- core.BNFreeKeyValueStore(self.handle)
+ def __del__(self):
+ core.BNFreeKeyValueStore(self.handle)
- def __getitem__(self, item: str) -> databuffer.DataBuffer:
- return self.get_value(item)
+ def __getitem__(self, item: str) -> databuffer.DataBuffer:
+ return self.get_value(item)
- def __setitem__(self, key: str, value: databuffer.DataBuffer):
- return self.set_value(key, value)
+ def __setitem__(self, key: str, value: databuffer.DataBuffer):
+ return self.set_value(key, value)
- @property
- def keys(self):
- """Get a list of all keys stored in the kvs (read-only)"""
- count = ctypes.c_ulonglong(0)
- value = core.BNGetKeyValueStoreKeys(self.handle, count)
- assert value is not None
+ @property
+ def keys(self):
+ """Get a list of all keys stored in the kvs (read-only)"""
+ count = ctypes.c_ulonglong(0)
+ value = core.BNGetKeyValueStoreKeys(self.handle, count)
+ assert value is not None
- result = []
- try:
- for i in range(0, count.value):
- result.append(value[i])
- return result
- finally:
- core.BNFreeStringList(value, count)
+ result = []
+ try:
+ for i in range(0, count.value):
+ result.append(value[i])
+ return result
+ finally:
+ core.BNFreeStringList(value, count)
- def get_value(self, key: str) -> databuffer.DataBuffer:
- """Get the value for a single key"""
- handle = core.BNGetKeyValueStoreBuffer(self.handle, key)
- assert handle is not None
- return databuffer.DataBuffer(handle=handle)
+ def get_value(self, key: str) -> databuffer.DataBuffer:
+ """Get the value for a single key"""
+ handle = core.BNGetKeyValueStoreBuffer(self.handle, key)
+ assert handle is not None
+ return databuffer.DataBuffer(handle=handle)
- def set_value(self, key: str, value: databuffer.DataBuffer):
- """Set the value for a single key"""
- core.BNSetKeyValueStoreBuffer(self.handle, key, value.handle)
+ def set_value(self, key: str, value: databuffer.DataBuffer):
+ """Set the value for a single key"""
+ core.BNSetKeyValueStoreBuffer(self.handle, key, value.handle)
- @property
- def serialized_data(self) -> databuffer.DataBuffer:
- """Get the stored representation of the kvs (read-only)"""
- handle = core.BNGetKeyValueStoreSerializedData(self.handle)
- assert handle is not None
- return databuffer.DataBuffer(handle=handle)
+ @property
+ def serialized_data(self) -> databuffer.DataBuffer:
+ """Get the stored representation of the kvs (read-only)"""
+ handle = core.BNGetKeyValueStoreSerializedData(self.handle)
+ assert handle is not None
+ return databuffer.DataBuffer(handle=handle)
- def begin_namespace(self, name: str):
- """Begin storing new keys into a namespace"""
- core.BNBeginKeyValueStoreNamespace(self.handle, name)
+ def begin_namespace(self, name: str):
+ """Begin storing new keys into a namespace"""
+ core.BNBeginKeyValueStoreNamespace(self.handle, name)
- def end_namespace(self):
- """End storing new keys into a namespace"""
- core.BNEndKeyValueStoreNamespace(self.handle)
+ def end_namespace(self):
+ """End storing new keys into a namespace"""
+ core.BNEndKeyValueStoreNamespace(self.handle)
- @property
- def empty(self) -> bool:
- """If the kvs is empty (read-only)"""
- return core.BNIsKeyValueStoreEmpty(self.handle)
+ @property
+ def empty(self) -> bool:
+ """If the kvs is empty (read-only)"""
+ return core.BNIsKeyValueStoreEmpty(self.handle)
- @property
- def value_size(self) -> bool:
- """Number of values in the kvs (read-only)"""
- return core.BNGetKeyValueStoreValueSize(self.handle)
+ @property
+ def value_size(self) -> bool:
+ """Number of values in the kvs (read-only)"""
+ return core.BNGetKeyValueStoreValueSize(self.handle)
- @property
- def data_size(self) -> bool:
- """Length of serialized data (read-only)"""
- return core.BNGetKeyValueStoreDataSize(self.handle)
+ @property
+ def data_size(self) -> bool:
+ """Length of serialized data (read-only)"""
+ return core.BNGetKeyValueStoreDataSize(self.handle)
- @property
- def value_storage_size(self) -> bool:
- """Size of all data in storage (read-only)"""
- return core.BNGetKeyValueStoreValueStorageSize(self.handle)
+ @property
+ def value_storage_size(self) -> bool:
+ """Size of all data in storage (read-only)"""
+ return core.BNGetKeyValueStoreValueStorageSize(self.handle)
- @property
- def namespace_size(self) -> bool:
- """Number of namespaces pushed with begin_namespace (read-only)"""
- return core.BNGetKeyValueStoreNamespaceSize(self.handle)
+ @property
+ def namespace_size(self) -> bool:
+ """Number of namespaces pushed with begin_namespace (read-only)"""
+ return core.BNGetKeyValueStoreNamespaceSize(self.handle)
class Snapshot:
- """
+ """
``class Snapshot`` is a model of an individual database snapshot, created on save.
"""
- def __init__(self, handle):
- self.handle = core.handle_of_type(handle, core.BNSnapshot)
+ def __init__(self, handle):
+ self.handle = core.handle_of_type(handle, core.BNSnapshot)
- def __del__(self):
- core.BNFreeSnapshot(self.handle)
+ def __del__(self):
+ core.BNFreeSnapshot(self.handle)
- @property
- def database(self) -> 'Database':
- """Get the owning database (read-only)"""
- return Database(handle=core.BNGetSnapshotDatabase(self.handle))
+ @property
+ def database(self) -> 'Database':
+ """Get the owning database (read-only)"""
+ return Database(handle=core.BNGetSnapshotDatabase(self.handle))
- @property
- def id(self) -> int:
- """Get the numerical id (read-only)"""
- return core.BNGetSnapshotId(self.handle)
+ @property
+ def id(self) -> int:
+ """Get the numerical id (read-only)"""
+ return core.BNGetSnapshotId(self.handle)
- @property
- def name(self) -> str:
- """Get the displayed snapshot name (read-only)"""
- return core.BNGetSnapshotName(self.handle)
+ @property
+ def name(self) -> str:
+ """Get the displayed snapshot name (read-only)"""
+ return core.BNGetSnapshotName(self.handle)
- @property
- def is_auto_save(self) -> bool:
- """If the snapshot was the result of an auto-save (read-only)"""
- return core.BNIsSnapshotAutoSave(self.handle)
+ @property
+ def is_auto_save(self) -> bool:
+ """If the snapshot was the result of an auto-save (read-only)"""
+ return core.BNIsSnapshotAutoSave(self.handle)
- @property
- def has_contents(self) -> bool:
- """If the snapshot has contents, and has not been trimmed (read-only)"""
- return core.BNSnapshotHasContents(self.handle)
+ @property
+ def has_contents(self) -> bool:
+ """If the snapshot has contents, and has not been trimmed (read-only)"""
+ return core.BNSnapshotHasContents(self.handle)
- @property
- def has_undo(self) -> bool:
- """If the snapshot has undo data (read-only)"""
- return core.BNSnapshotHasUndo(self.handle)
+ @property
+ def has_undo(self) -> bool:
+ """If the snapshot has undo data (read-only)"""
+ return core.BNSnapshotHasUndo(self.handle)
- @property
- def first_parent(self) -> Optional['Snapshot']:
- """Get the first parent of the snapshot, or None if it has no parents (read-only)"""
- handle = core.BNGetSnapshotFirstParent(self.handle)
- if handle is None:
- return None
- return Snapshot(handle=handle)
+ @property
+ def first_parent(self) -> Optional['Snapshot']:
+ """Get the first parent of the snapshot, or None if it has no parents (read-only)"""
+ handle = core.BNGetSnapshotFirstParent(self.handle)
+ if handle is None:
+ return None
+ return Snapshot(handle=handle)
- @property
- def parents(self) -> List['Snapshot']:
- """Get a list of all parent snapshots of the snapshot (read-only)"""
- count = ctypes.c_ulonglong(0)
- parents = core.BNGetSnapshotParents(self.handle, count)
+ @property
+ def parents(self) -> List['Snapshot']:
+ """Get a list of all parent snapshots of the snapshot (read-only)"""
+ count = ctypes.c_ulonglong(0)
+ parents = core.BNGetSnapshotParents(self.handle, count)
- result = []
- try:
- for i in range(0, count.value):
- handle = core.BNNewSnapshotReference(parents[i])
- result.append(Snapshot(handle=handle))
- return result
- finally:
- core.BNFreeSnapshotList(parents, count)
+ result = []
+ try:
+ for i in range(0, count.value):
+ handle = core.BNNewSnapshotReference(parents[i])
+ result.append(Snapshot(handle=handle))
+ return result
+ finally:
+ core.BNFreeSnapshotList(parents, count)
- @property
- def children(self) -> List['Snapshot']:
- """Get a list of all child snapshots of the snapshot (read-only)"""
- count = ctypes.c_ulonglong(0)
- children = core.BNGetSnapshotChildren(self.handle, count)
+ @property
+ def children(self) -> List['Snapshot']:
+ """Get a list of all child snapshots of the snapshot (read-only)"""
+ count = ctypes.c_ulonglong(0)
+ children = core.BNGetSnapshotChildren(self.handle, count)
- result = []
- try:
- for i in range(0, count.value):
- handle = core.BNNewSnapshotReference(children[i])
- result.append(Snapshot(handle=handle))
- return result
- finally:
- core.BNFreeSnapshotList(children, count)
+ result = []
+ try:
+ for i in range(0, count.value):
+ handle = core.BNNewSnapshotReference(children[i])
+ result.append(Snapshot(handle=handle))
+ return result
+ finally:
+ core.BNFreeSnapshotList(children, count)
- @property
- def file_contents(self) -> databuffer.DataBuffer:
- """Get a buffer of the raw data at the time of the snapshot (read-only)"""
- assert self.has_contents
- handle = core.BNGetSnapshotFileContents(self.handle)
- assert handle is not None
- return databuffer.DataBuffer(handle=handle)
+ @property
+ def file_contents(self) -> databuffer.DataBuffer:
+ """Get a buffer of the raw data at the time of the snapshot (read-only)"""
+ assert self.has_contents
+ handle = core.BNGetSnapshotFileContents(self.handle)
+ assert handle is not None
+ return databuffer.DataBuffer(handle=handle)
- @property
- def file_contents_hash(self) -> databuffer.DataBuffer:
- """Get a hash of the data at the time of the snapshot (read-only)"""
- assert self.has_contents
- handle = core.BNGetSnapshotFileContentsHash(self.handle)
- assert handle is not None
- return databuffer.DataBuffer(handle=handle)
+ @property
+ def file_contents_hash(self) -> databuffer.DataBuffer:
+ """Get a hash of the data at the time of the snapshot (read-only)"""
+ assert self.has_contents
+ handle = core.BNGetSnapshotFileContentsHash(self.handle)
+ assert handle is not None
+ return databuffer.DataBuffer(handle=handle)
- @property
- def undo_entries(self):
- """Get a list of undo entries at the time of the snapshot (read-only)"""
- assert self.has_undo
- raise NotImplementedError("GetUndoEntries is not implemented in python")
+ @property
+ def undo_entries(self):
+ """Get a list of undo entries at the time of the snapshot (read-only)"""
+ assert self.has_undo
+ raise NotImplementedError("GetUndoEntries is not implemented in python")
- @property
- def data(self) -> KeyValueStore:
- """Get the backing kvs data with snapshot fields (read-only)"""
- assert self.has_contents
- handle = core.BNReadSnapshotData(self.handle)
- assert handle is not None
- return KeyValueStore(handle=handle)
+ @property
+ def data(self) -> KeyValueStore:
+ """Get the backing kvs data with snapshot fields (read-only)"""
+ assert self.has_contents
+ handle = core.BNReadSnapshotData(self.handle)
+ assert handle is not None
+ return KeyValueStore(handle=handle)
- def has_ancestor(self, other: 'Snapshot') -> bool:
- """Determine if this snapshot has another as an ancestor"""
- return core.BNSnapshotHasAncestor(self.handle, other.handle)
+ def has_ancestor(self, other: 'Snapshot') -> bool:
+ """Determine if this snapshot has another as an ancestor"""
+ return core.BNSnapshotHasAncestor(self.handle, other.handle)
class Database:
- """
+ """
``class Database`` provides lower level access to raw snapshot data used to construct analysis data
"""
- def __init__(self, handle):
- self.handle = core.handle_of_type(handle, core.BNDatabase)
+ def __init__(self, handle):
+ self.handle = core.handle_of_type(handle, core.BNDatabase)
- def __del__(self):
- core.BNFreeDatabase(self.handle)
+ def __del__(self):
+ core.BNFreeDatabase(self.handle)
- def __getitem__(self, item: int) -> Optional[Snapshot]:
- return self.get_snapshot(item)
+ def __getitem__(self, item: int) -> Optional[Snapshot]:
+ return self.get_snapshot(item)
- def get_snapshot(self, id: int) -> Optional[Snapshot]:
- """Get a snapshot by its id, or None if no snapshot with that id exists"""
- snap = core.BNGetDatabaseSnapshot(self.handle, id)
- if snap is None:
- return None
- return Snapshot(handle=snap)
+ def get_snapshot(self, id: int) -> Optional[Snapshot]:
+ """Get a snapshot by its id, or None if no snapshot with that id exists"""
+ snap = core.BNGetDatabaseSnapshot(self.handle, id)
+ if snap is None:
+ return None
+ return Snapshot(handle=snap)
- @property
- def snapshots(self) -> List[Snapshot]:
- """Get a list of all snapshots in the database (read-only)"""
- count = ctypes.c_ulonglong(0)
- snapshots = core.BNGetDatabaseSnapshots(self.handle, count)
- assert snapshots is not None
+ @property
+ def snapshots(self) -> List[Snapshot]:
+ """Get a list of all snapshots in the database (read-only)"""
+ count = ctypes.c_ulonglong(0)
+ snapshots = core.BNGetDatabaseSnapshots(self.handle, count)
+ assert snapshots is not None
- result = []
- try:
- for i in range(0, count.value):
- handle = core.BNNewSnapshotReference(snapshots[i])
- result.append(Snapshot(handle=handle))
- return result
- finally:
- core.BNFreeSnapshotList(snapshots, count)
+ result = []
+ try:
+ for i in range(0, count.value):
+ handle = core.BNNewSnapshotReference(snapshots[i])
+ result.append(Snapshot(handle=handle))
+ return result
+ finally:
+ core.BNFreeSnapshotList(snapshots, count)
- @property
- def current_snapshot(self) -> Optional[Snapshot]:
- """Get the current snapshot"""
- snap = core.BNGetDatabaseCurrentSnapshot(self.handle)
- if snap is None:
- return None
- return Snapshot(handle=snap)
+ @property
+ def current_snapshot(self) -> Optional[Snapshot]:
+ """Get the current snapshot"""
+ snap = core.BNGetDatabaseCurrentSnapshot(self.handle)
+ if snap is None:
+ return None
+ return Snapshot(handle=snap)
- @current_snapshot.setter
- def current_snapshot(self, value: Snapshot):
- core.BNSetDatabaseCurrentSnapshot(self.handle, value.id)
+ @current_snapshot.setter
+ def current_snapshot(self, value: Snapshot):
+ core.BNSetDatabaseCurrentSnapshot(self.handle, value.id)
- def remove_snapsot(self, id: int):
- """Remove a snapshot in the database by id"""
- core.BNRemoveDatabaseSnapshot(self.handle, id)
+ def remove_snapsot(self, id: int):
+ """Remove a snapshot in the database by id"""
+ core.BNRemoveDatabaseSnapshot(self.handle, id)
- @property
- def global_keys(self) -> List[str]:
- """Get a list of keys for all globals in the database (read-only)"""
- count = ctypes.c_ulonglong(0)
- value = core.BNGetDatabaseGlobalKeys(self.handle, count)
- assert value is not None
+ @property
+ def global_keys(self) -> List[str]:
+ """Get a list of keys for all globals in the database (read-only)"""
+ count = ctypes.c_ulonglong(0)
+ value = core.BNGetDatabaseGlobalKeys(self.handle, count)
+ assert value is not None
- result = []
- try:
- for i in range(0, count.value):
- result.append(value[i])
- return result
- finally:
- core.BNFreeStringList(value, count)
+ result = []
+ try:
+ for i in range(0, count.value):
+ result.append(value[i])
+ return result
+ finally:
+ core.BNFreeStringList(value, count)
- @property
- def globals(self) -> Dict[str, str]:
- """Get a dictionary of all globals (read-only)"""
- count = ctypes.c_ulonglong(0)
- value = core.BNGetDatabaseGlobalKeys(self.handle, count)
- assert value is not None
+ @property
+ def globals(self) -> Dict[str, str]:
+ """Get a dictionary of all globals (read-only)"""
+ count = ctypes.c_ulonglong(0)
+ value = core.BNGetDatabaseGlobalKeys(self.handle, count)
+ assert value is not None
- result = {}
- try:
- for i in range(0, count.value):
- key = value[i]
- result[key] = self.read_global(key)
- return result
- finally:
- core.BNFreeStringList(value, count)
+ result = {}
+ try:
+ for i in range(0, count.value):
+ key = value[i]
+ result[key] = self.read_global(key)
+ return result
+ finally:
+ core.BNFreeStringList(value, count)
- def read_global(self, key: str) -> str:
- """Get a specific global by key"""
- value = core.BNReadDatabaseGlobal(self.handle, key)
- assert value is not None
- return value
+ def read_global(self, key: str) -> str:
+ """Get a specific global by key"""
+ value = core.BNReadDatabaseGlobal(self.handle, key)
+ assert value is not None
+ return value
- def write_global(self, key: str, value: str):
- """Write a global into the database"""
- core.BNWriteDatabaseGlobal(self.handle, key, value)
+ def write_global(self, key: str, value: str):
+ """Write a global into the database"""
+ core.BNWriteDatabaseGlobal(self.handle, key, value)
- def read_global_data(self, key: str) -> databuffer.DataBuffer:
- """Get a specific global by key, as a binary buffer"""
- handle = core.BNReadDatabaseGlobalData(self.handle, key)
- assert handle is not None
- return databuffer.DataBuffer(handle=handle)
+ def read_global_data(self, key: str) -> databuffer.DataBuffer:
+ """Get a specific global by key, as a binary buffer"""
+ handle = core.BNReadDatabaseGlobalData(self.handle, key)
+ assert handle is not None
+ return databuffer.DataBuffer(handle=handle)
- def write_global_data(self, key: str, value: databuffer.DataBuffer):
- """Write a binary buffer into a global in the database"""
- core.BNWriteDatabaseGlobalData(self.handle, key, value.handle)
+ def write_global_data(self, key: str, value: databuffer.DataBuffer):
+ """Write a binary buffer into a global in the database"""
+ core.BNWriteDatabaseGlobalData(self.handle, key, value.handle)
- @property
- def file(self) -> 'filemetadata.FileMetadata':
- """Get the owning FileMetadata (read-only)"""
- handle = core.BNGetDatabaseFile(self.handle)
- assert handle is not None
- return filemetadata.FileMetadata(handle=handle)
+ @property
+ def file(self) -> 'filemetadata.FileMetadata':
+ """Get the owning FileMetadata (read-only)"""
+ handle = core.BNGetDatabaseFile(self.handle)
+ assert handle is not None
+ return filemetadata.FileMetadata(handle=handle)
- @property
- def analysis_cache(self) -> KeyValueStore:
- """Get the backing analysis cache kvs (read-only)"""
- handle = core.BNReadDatabaseAnalysisCache(self.handle)
- assert handle is not None
- return KeyValueStore(handle=handle)
+ @property
+ def analysis_cache(self) -> KeyValueStore:
+ """Get the backing analysis cache kvs (read-only)"""
+ handle = core.BNReadDatabaseAnalysisCache(self.handle)
+ assert handle is not None
+ return KeyValueStore(handle=handle)
diff --git a/python/databuffer.py b/python/databuffer.py
index df16cc54..f4905cbd 100644
--- a/python/databuffer.py
+++ b/python/databuffer.py
@@ -25,8 +25,10 @@ from typing import Optional, Union
from . import _binaryninjacore as core
DataBufferInputType = Union[str, bytes, 'DataBuffer', int]
+
+
class DataBuffer:
- def __init__(self, contents:Union[str, bytes, 'DataBuffer', int]=b"", handle=None):
+ def __init__(self, contents: Union[str, bytes, 'DataBuffer', int] = b"", handle=None):
if handle is not None:
self.handle = core.handle_of_type(handle, core.BNDataBuffer)
elif isinstance(contents, int):
@@ -147,24 +149,24 @@ class DataBuffer:
return core.BNDataBufferToBase64(self.handle)
def base64_decode(self) -> 'DataBuffer':
- return DataBuffer(handle = core.BNDecodeBase64(str(self)))
+ return DataBuffer(handle=core.BNDecodeBase64(str(self)))
def zlib_compress(self) -> Optional['DataBuffer']:
buf = core.BNZlibCompress(self.handle)
if buf is None:
return None
- return DataBuffer(handle = buf)
+ return DataBuffer(handle=buf)
def zlib_decompress(self) -> Optional['DataBuffer']:
buf = core.BNZlibDecompress(self.handle)
if buf is None:
return None
- return DataBuffer(handle = buf)
+ return DataBuffer(handle=buf)
-def escape_string(text:bytes) -> str:
+def escape_string(text: bytes) -> str:
return DataBuffer(text).escape()
-def unescape_string(text:bytes) -> 'DataBuffer':
+def unescape_string(text: bytes) -> 'DataBuffer':
return DataBuffer(text).unescape()
diff --git a/python/dataclasses.py b/python/dataclasses.py
index ddd59c66..9bfab21c 100644
--- a/python/dataclasses.py
+++ b/python/dataclasses.py
@@ -5,21 +5,12 @@ import types
import inspect
import keyword
-__all__ = ['dataclass',
- 'field',
- 'Field',
- 'FrozenInstanceError',
- 'InitVar',
- 'MISSING',
+__all__ = [
+ 'dataclass', 'field', 'Field', 'FrozenInstanceError', 'InitVar', 'MISSING',
- # Helper functions.
- 'fields',
- 'asdict',
- 'astuple',
- 'make_dataclass',
- 'replace',
- 'is_dataclass',
- ]
+ # Helper functions.
+ 'fields', 'asdict', 'astuple', 'make_dataclass', 'replace', 'is_dataclass',
+]
# Conditions for adding methods. The boxes indicate what action the
# dataclass decorator takes. For all of these tables, when I talk
@@ -66,7 +57,6 @@ __all__ = ['dataclass',
# | True | add | | <- the default
# +=======+=======+=======+
-
# __setattr__
# __delattr__
#
@@ -148,32 +138,43 @@ __all__ = ['dataclass',
# Raised when an attempt is made to modify a frozen class.
-class FrozenInstanceError(AttributeError): pass
+class FrozenInstanceError(AttributeError):
+ pass
+
# A sentinel object for default values to signal that a default
# factory will be used. This is given a nice repr() which will appear
# in the function signature of dataclasses' constructors.
class _HAS_DEFAULT_FACTORY_CLASS:
- def __repr__(self):
- return '<factory>'
+ def __repr__(self):
+ return '<factory>'
+
+
_HAS_DEFAULT_FACTORY = _HAS_DEFAULT_FACTORY_CLASS()
+
# A sentinel object to detect if a parameter is supplied or not. Use
# a class to give it a better repr.
class _MISSING_TYPE:
- pass
+ pass
+
+
MISSING = _MISSING_TYPE()
# Since most per-field metadata will be unused, create an empty
# read-only proxy that can be shared among all fields.
_EMPTY_METADATA = types.MappingProxyType({})
+
# Markers for the various kinds of fields and pseudo-fields.
class _FIELD_BASE:
- def __init__(self, name):
- self.name = name
- def __repr__(self):
- return self.name
+ def __init__(self, name):
+ self.name = name
+
+ def __repr__(self):
+ return self.name
+
+
_FIELD = _FIELD_BASE('_FIELD')
_FIELD_CLASSVAR = _FIELD_BASE('_FIELD_CLASSVAR')
_FIELD_INITVAR = _FIELD_BASE('_FIELD_INITVAR')
@@ -195,12 +196,14 @@ _POST_INIT_NAME = '__post_init__'
# https://bugs.python.org/issue33453 for details.
_MODULE_IDENTIFIER_RE = re.compile(r'^(?:\s*(\w+)\s*\.)?\s*(\w+)')
+
class _InitVarMeta(type):
- def __getitem__(self, params):
- return self
+ def __getitem__(self, params):
+ return self
+
class InitVar(metaclass=_InitVarMeta):
- pass
+ pass
# Instances of Field are only ever created from within this module,
@@ -214,97 +217,86 @@ class InitVar(metaclass=_InitVarMeta):
# When cls._FIELDS is filled in with a list of Field objects, the name
# and type fields will have been populated.
class Field:
- __slots__ = ('name',
- 'type',
- 'default',
- 'default_factory',
- 'repr',
- 'hash',
- 'init',
- 'compare',
- 'metadata',
- '_field_type', # Private: not to be used by user code.
- )
+ __slots__ = (
+ 'name', 'type', 'default', 'default_factory', 'repr', 'hash', 'init', 'compare', 'metadata',
+ '_field_type', # Private: not to be used by user code.
+ )
- def __init__(self, default, default_factory, init, repr, hash, compare,
- metadata):
- self.name = None
- self.type = None
- self.default = default
- self.default_factory = default_factory
- self.init = init
- self.repr = repr
- self.hash = hash
- self.compare = compare
- self.metadata = (_EMPTY_METADATA
- if metadata is None or len(metadata) == 0 else
- types.MappingProxyType(metadata))
- self._field_type = None
+ def __init__(self, default, default_factory, init, repr, hash, compare, metadata):
+ self.name = None
+ self.type = None
+ self.default = default
+ self.default_factory = default_factory
+ self.init = init
+ self.repr = repr
+ self.hash = hash
+ self.compare = compare
+ self.metadata = (
+ _EMPTY_METADATA if metadata is None or len(metadata) == 0 else types.MappingProxyType(metadata)
+ )
+ self._field_type = None
- def __repr__(self):
- return ('Field('
- f'name={self.name!r},'
- f'type={self.type!r},'
- f'default={self.default!r},'
- f'default_factory={self.default_factory!r},'
- f'init={self.init!r},'
- f'repr={self.repr!r},'
- f'hash={self.hash!r},'
- f'compare={self.compare!r},'
- f'metadata={self.metadata!r},'
- f'_field_type={self._field_type}'
- ')')
+ def __repr__(self):
+ return (
+ 'Field('
+ f'name={self.name!r},'
+ f'type={self.type!r},'
+ f'default={self.default!r},'
+ f'default_factory={self.default_factory!r},'
+ f'init={self.init!r},'
+ f'repr={self.repr!r},'
+ f'hash={self.hash!r},'
+ f'compare={self.compare!r},'
+ f'metadata={self.metadata!r},'
+ f'_field_type={self._field_type}'
+ ')'
+ )
- # This is used to support the PEP 487 __set_name__ protocol in the
- # case where we're using a field that contains a descriptor as a
- # defaul value. For details on __set_name__, see
- # https://www.python.org/dev/peps/pep-0487/#implementation-details.
- #
- # Note that in _process_class, this Field object is overwritten
- # with the default value, so the end result is a descriptor that
- # had __set_name__ called on it at the right time.
- def __set_name__(self, owner, name):
- func = getattr(type(self.default), '__set_name__', None)
- if func:
- # There is a __set_name__ method on the descriptor, call
- # it.
- func(self.default, owner, name)
+ # This is used to support the PEP 487 __set_name__ protocol in the
+ # case where we're using a field that contains a descriptor as a
+ # defaul value. For details on __set_name__, see
+ # https://www.python.org/dev/peps/pep-0487/#implementation-details.
+ #
+ # Note that in _process_class, this Field object is overwritten
+ # with the default value, so the end result is a descriptor that
+ # had __set_name__ called on it at the right time.
+ def __set_name__(self, owner, name):
+ func = getattr(type(self.default), '__set_name__', None)
+ if func:
+ # There is a __set_name__ method on the descriptor, call
+ # it.
+ func(self.default, owner, name)
class _DataclassParams:
- __slots__ = ('init',
- 'repr',
- 'eq',
- 'order',
- 'unsafe_hash',
- 'frozen',
- )
+ __slots__ = ('init', 'repr', 'eq', 'order', 'unsafe_hash', 'frozen', )
- def __init__(self, init, repr, eq, order, unsafe_hash, frozen):
- self.init = init
- self.repr = repr
- self.eq = eq
- self.order = order
- self.unsafe_hash = unsafe_hash
- self.frozen = frozen
+ def __init__(self, init, repr, eq, order, unsafe_hash, frozen):
+ self.init = init
+ self.repr = repr
+ self.eq = eq
+ self.order = order
+ self.unsafe_hash = unsafe_hash
+ self.frozen = frozen
- def __repr__(self):
- return ('_DataclassParams('
- f'init={self.init!r},'
- f'repr={self.repr!r},'
- f'eq={self.eq!r},'
- f'order={self.order!r},'
- f'unsafe_hash={self.unsafe_hash!r},'
- f'frozen={self.frozen!r}'
- ')')
+ def __repr__(self):
+ return (
+ '_DataclassParams('
+ f'init={self.init!r},'
+ f'repr={self.repr!r},'
+ f'eq={self.eq!r},'
+ f'order={self.order!r},'
+ f'unsafe_hash={self.unsafe_hash!r},'
+ f'frozen={self.frozen!r}'
+ ')'
+ )
# This function is used instead of exposing Field creation directly,
# so that a type checker can be told (via overloads) that this is a
# function whose type depends on its parameters.
-def field(*, default=MISSING, default_factory=MISSING, init=True, repr=True,
- hash=None, compare=True, metadata=None):
- """Return an object to identify dataclass fields.
+def field(*, default=MISSING, default_factory=MISSING, init=True, repr=True, hash=None, compare=True, metadata=None):
+ """Return an object to identify dataclass fields.
default is the default value of the field. default_factory is a
0-argument function called to initialize a field's value. If init
@@ -318,392 +310,386 @@ def field(*, default=MISSING, default_factory=MISSING, init=True, repr=True,
It is an error to specify both default and default_factory.
"""
- if default is not MISSING and default_factory is not MISSING:
- raise ValueError('cannot specify both default and default_factory')
- return Field(default, default_factory, init, repr, hash, compare,
- metadata)
+ if default is not MISSING and default_factory is not MISSING:
+ raise ValueError('cannot specify both default and default_factory')
+ return Field(default, default_factory, init, repr, hash, compare, metadata)
def _tuple_str(obj_name, fields):
- # Return a string representing each field of obj_name as a tuple
- # member. So, if fields is ['x', 'y'] and obj_name is "self",
- # return "(self.x,self.y)".
+ # Return a string representing each field of obj_name as a tuple
+ # member. So, if fields is ['x', 'y'] and obj_name is "self",
+ # return "(self.x,self.y)".
- # Special case for the 0-tuple.
- if not fields:
- return '()'
- # Note the trailing comma, needed if this turns out to be a 1-tuple.
- return f'({",".join([f"{obj_name}.{f.name}" for f in fields])},)'
+ # Special case for the 0-tuple.
+ if not fields:
+ return '()'
+ # Note the trailing comma, needed if this turns out to be a 1-tuple.
+ return f'({",".join([f"{obj_name}.{f.name}" for f in fields])},)'
-def _create_fn(name, args, body, *, globals=None, locals=None,
- return_type=MISSING):
- # Note that we mutate locals when exec() is called. Caller
- # beware! The only callers are internal to this module, so no
- # worries about external callers.
- if locals is None:
- locals = {}
- return_annotation = ''
- if return_type is not MISSING:
- locals['_return_type'] = return_type
- return_annotation = '->_return_type'
- args = ','.join(args)
- body = '\n'.join(f' {b}' for b in body)
+def _create_fn(name, args, body, *, globals=None, locals=None, return_type=MISSING):
+ # Note that we mutate locals when exec() is called. Caller
+ # beware! The only callers are internal to this module, so no
+ # worries about external callers.
+ if locals is None:
+ locals = {}
+ return_annotation = ''
+ if return_type is not MISSING:
+ locals['_return_type'] = return_type
+ return_annotation = '->_return_type'
+ args = ','.join(args)
+ body = '\n'.join(f' {b}' for b in body)
- # Compute the text of the entire function.
- txt = f'def {name}({args}){return_annotation}:\n{body}'
+ # Compute the text of the entire function.
+ txt = f'def {name}({args}){return_annotation}:\n{body}'
- exec(txt, globals, locals)
- return locals[name]
+ exec(txt, globals, locals)
+ return locals[name]
def _field_assign(frozen, name, value, self_name):
- # If we're a frozen class, then assign to our fields in __init__
- # via object.__setattr__. Otherwise, just use a simple
- # assignment.
- #
- # self_name is what "self" is called in this function: don't
- # hard-code "self", since that might be a field name.
- if frozen:
- return f'object.__setattr__({self_name},{name!r},{value})'
- return f'{self_name}.{name}={value}'
+ # If we're a frozen class, then assign to our fields in __init__
+ # via object.__setattr__. Otherwise, just use a simple
+ # assignment.
+ #
+ # self_name is what "self" is called in this function: don't
+ # hard-code "self", since that might be a field name.
+ if frozen:
+ return f'object.__setattr__({self_name},{name!r},{value})'
+ return f'{self_name}.{name}={value}'
def _field_init(f, frozen, globals, self_name):
- # Return the text of the line in the body of __init__ that will
- # initialize this field.
+ # Return the text of the line in the body of __init__ that will
+ # initialize this field.
- default_name = f'_dflt_{f.name}'
- if f.default_factory is not MISSING:
- if f.init:
- # This field has a default factory. If a parameter is
- # given, use it. If not, call the factory.
- globals[default_name] = f.default_factory
- value = (f'{default_name}() '
- f'if {f.name} is _HAS_DEFAULT_FACTORY '
- f'else {f.name}')
- else:
- # This is a field that's not in the __init__ params, but
- # has a default factory function. It needs to be
- # initialized here by calling the factory function,
- # because there's no other way to initialize it.
+ default_name = f'_dflt_{f.name}'
+ if f.default_factory is not MISSING:
+ if f.init:
+ # This field has a default factory. If a parameter is
+ # given, use it. If not, call the factory.
+ globals[default_name] = f.default_factory
+ value = (f'{default_name}() '
+ f'if {f.name} is _HAS_DEFAULT_FACTORY '
+ f'else {f.name}')
+ else:
+ # This is a field that's not in the __init__ params, but
+ # has a default factory function. It needs to be
+ # initialized here by calling the factory function,
+ # because there's no other way to initialize it.
- # For a field initialized with a default=defaultvalue, the
- # class dict just has the default value
- # (cls.fieldname=defaultvalue). But that won't work for a
- # default factory, the factory must be called in __init__
- # and we must assign that to self.fieldname. We can't
- # fall back to the class dict's value, both because it's
- # not set, and because it might be different per-class
- # (which, after all, is why we have a factory function!).
+ # For a field initialized with a default=defaultvalue, the
+ # class dict just has the default value
+ # (cls.fieldname=defaultvalue). But that won't work for a
+ # default factory, the factory must be called in __init__
+ # and we must assign that to self.fieldname. We can't
+ # fall back to the class dict's value, both because it's
+ # not set, and because it might be different per-class
+ # (which, after all, is why we have a factory function!).
- globals[default_name] = f.default_factory
- value = f'{default_name}()'
- else:
- # No default factory.
- if f.init:
- if f.default is MISSING:
- # There's no default, just do an assignment.
- value = f.name
- elif f.default is not MISSING:
- globals[default_name] = f.default
- value = f.name
- else:
- # This field does not need initialization. Signify that
- # to the caller by returning None.
- return None
+ globals[default_name] = f.default_factory
+ value = f'{default_name}()'
+ else:
+ # No default factory.
+ if f.init:
+ if f.default is MISSING:
+ # There's no default, just do an assignment.
+ value = f.name
+ elif f.default is not MISSING:
+ globals[default_name] = f.default
+ value = f.name
+ else:
+ # This field does not need initialization. Signify that
+ # to the caller by returning None.
+ return None
- # Only test this now, so that we can create variables for the
- # default. However, return None to signify that we're not going
- # to actually do the assignment statement for InitVars.
- if f._field_type is _FIELD_INITVAR:
- return None
+ # Only test this now, so that we can create variables for the
+ # default. However, return None to signify that we're not going
+ # to actually do the assignment statement for InitVars.
+ if f._field_type is _FIELD_INITVAR:
+ return None
- # Now, actually generate the field assignment.
- return _field_assign(frozen, f.name, value, self_name)
+ # Now, actually generate the field assignment.
+ return _field_assign(frozen, f.name, value, self_name)
def _init_param(f):
- # Return the __init__ parameter string for this field. For
- # example, the equivalent of 'x:int=3' (except instead of 'int',
- # reference a variable set to int, and instead of '3', reference a
- # variable set to 3).
- if f.default is MISSING and f.default_factory is MISSING:
- # There's no default, and no default_factory, just output the
- # variable name and type.
- default = ''
- elif f.default is not MISSING:
- # There's a default, this will be the name that's used to look
- # it up.
- default = f'=_dflt_{f.name}'
- elif f.default_factory is not MISSING:
- # There's a factory function. Set a marker.
- default = '=_HAS_DEFAULT_FACTORY'
- return f'{f.name}:_type_{f.name}{default}'
+ # Return the __init__ parameter string for this field. For
+ # example, the equivalent of 'x:int=3' (except instead of 'int',
+ # reference a variable set to int, and instead of '3', reference a
+ # variable set to 3).
+ if f.default is MISSING and f.default_factory is MISSING:
+ # There's no default, and no default_factory, just output the
+ # variable name and type.
+ default = ''
+ elif f.default is not MISSING:
+ # There's a default, this will be the name that's used to look
+ # it up.
+ default = f'=_dflt_{f.name}'
+ elif f.default_factory is not MISSING:
+ # There's a factory function. Set a marker.
+ default = '=_HAS_DEFAULT_FACTORY'
+ return f'{f.name}:_type_{f.name}{default}'
def _init_fn(fields, frozen, has_post_init, self_name):
- # fields contains both real fields and InitVar pseudo-fields.
+ # fields contains both real fields and InitVar pseudo-fields.
- # Make sure we don't have fields without defaults following fields
- # with defaults. This actually would be caught when exec-ing the
- # function source code, but catching it here gives a better error
- # message, and future-proofs us in case we build up the function
- # using ast.
- seen_default = False
- for f in fields:
- # Only consider fields in the __init__ call.
- if f.init:
- if not (f.default is MISSING and f.default_factory is MISSING):
- seen_default = True
- elif seen_default:
- raise TypeError(f'non-default argument {f.name!r} '
- 'follows default argument')
+ # Make sure we don't have fields without defaults following fields
+ # with defaults. This actually would be caught when exec-ing the
+ # function source code, but catching it here gives a better error
+ # message, and future-proofs us in case we build up the function
+ # using ast.
+ seen_default = False
+ for f in fields:
+ # Only consider fields in the __init__ call.
+ if f.init:
+ if not (f.default is MISSING and f.default_factory is MISSING):
+ seen_default = True
+ elif seen_default:
+ raise TypeError(f'non-default argument {f.name!r} '
+ 'follows default argument')
- globals = {'MISSING': MISSING,
- '_HAS_DEFAULT_FACTORY': _HAS_DEFAULT_FACTORY}
+ globals = {'MISSING': MISSING, '_HAS_DEFAULT_FACTORY': _HAS_DEFAULT_FACTORY}
- body_lines = []
- for f in fields:
- line = _field_init(f, frozen, globals, self_name)
- # line is None means that this field doesn't require
- # initialization (it's a pseudo-field). Just skip it.
- if line:
- body_lines.append(line)
+ body_lines = []
+ for f in fields:
+ line = _field_init(f, frozen, globals, self_name)
+ # line is None means that this field doesn't require
+ # initialization (it's a pseudo-field). Just skip it.
+ if line:
+ body_lines.append(line)
- # Does this class have a post-init function?
- if has_post_init:
- params_str = ','.join(f.name for f in fields
- if f._field_type is _FIELD_INITVAR)
- body_lines.append(f'{self_name}.{_POST_INIT_NAME}({params_str})')
+ # Does this class have a post-init function?
+ if has_post_init:
+ params_str = ','.join(f.name for f in fields if f._field_type is _FIELD_INITVAR)
+ body_lines.append(f'{self_name}.{_POST_INIT_NAME}({params_str})')
- # If no body lines, use 'pass'.
- if not body_lines:
- body_lines = ['pass']
+ # If no body lines, use 'pass'.
+ if not body_lines:
+ body_lines = ['pass']
- locals = {f'_type_{f.name}': f.type for f in fields}
- return _create_fn('__init__',
- [self_name] + [_init_param(f) for f in fields if f.init],
- body_lines,
- locals=locals,
- globals=globals,
- return_type=None)
+ locals = {f'_type_{f.name}': f.type for f in fields}
+ return _create_fn(
+ '__init__', [self_name] + [_init_param(f) for f in fields if f.init], body_lines, locals=locals,
+ globals=globals, return_type=None
+ )
def _repr_fn(fields):
- return _create_fn('__repr__',
- ('self',),
- ['return self.__class__.__qualname__ + f"(' +
- ', '.join([f"{f.name}={{self.{f.name}!r}}"
- for f in fields]) +
- ')"'])
+ return _create_fn(
+ '__repr__', ('self', ), [
+ 'return self.__class__.__qualname__ + f"(' + ', '.join([f"{f.name}={{self.{f.name}!r}}"
+ for f in fields]) + ')"'
+ ]
+ )
def _frozen_get_del_attr(cls, fields):
- # XXX: globals is modified on the first call to _create_fn, then
- # the modified version is used in the second call. Is this okay?
- globals = {'cls': cls,
- 'FrozenInstanceError': FrozenInstanceError}
- if fields:
- fields_str = '(' + ','.join(repr(f.name) for f in fields) + ',)'
- else:
- # Special case for the zero-length tuple.
- fields_str = '()'
- return (_create_fn('__setattr__',
- ('self', 'name', 'value'),
- (f'if type(self) is cls or name in {fields_str}:',
- ' raise FrozenInstanceError(f"cannot assign to field {name!r}")',
- f'super(cls, self).__setattr__(name, value)'),
- globals=globals),
- _create_fn('__delattr__',
- ('self', 'name'),
- (f'if type(self) is cls or name in {fields_str}:',
- ' raise FrozenInstanceError(f"cannot delete field {name!r}")',
- f'super(cls, self).__delattr__(name)'),
- globals=globals),
- )
+ # XXX: globals is modified on the first call to _create_fn, then
+ # the modified version is used in the second call. Is this okay?
+ globals = {'cls': cls, 'FrozenInstanceError': FrozenInstanceError}
+ if fields:
+ fields_str = '(' + ','.join(repr(f.name) for f in fields) + ',)'
+ else:
+ # Special case for the zero-length tuple.
+ fields_str = '()'
+ return (
+ _create_fn(
+ '__setattr__', ('self', 'name', 'value'), (
+ f'if type(self) is cls or name in {fields_str}:',
+ ' raise FrozenInstanceError(f"cannot assign to field {name!r}")',
+ f'super(cls, self).__setattr__(name, value)'
+ ), globals=globals
+ ),
+ _create_fn(
+ '__delattr__', ('self', 'name'), (
+ f'if type(self) is cls or name in {fields_str}:',
+ ' raise FrozenInstanceError(f"cannot delete field {name!r}")', f'super(cls, self).__delattr__(name)'
+ ), globals=globals
+ ),
+ )
def _cmp_fn(name, op, self_tuple, other_tuple):
- # Create a comparison function. If the fields in the object are
- # named 'x' and 'y', then self_tuple is the string
- # '(self.x,self.y)' and other_tuple is the string
- # '(other.x,other.y)'.
+ # Create a comparison function. If the fields in the object are
+ # named 'x' and 'y', then self_tuple is the string
+ # '(self.x,self.y)' and other_tuple is the string
+ # '(other.x,other.y)'.
- return _create_fn(name,
- ('self', 'other'),
- [ 'if other.__class__ is self.__class__:',
- f' return {self_tuple}{op}{other_tuple}',
- 'return NotImplemented'])
+ return _create_fn(
+ name, ('self', 'other'),
+ ['if other.__class__ is self.__class__:', f' return {self_tuple}{op}{other_tuple}', 'return NotImplemented']
+ )
def _hash_fn(fields):
- self_tuple = _tuple_str('self', fields)
- return _create_fn('__hash__',
- ('self',),
- [f'return hash({self_tuple})'])
+ self_tuple = _tuple_str('self', fields)
+ return _create_fn('__hash__', ('self', ), [f'return hash({self_tuple})'])
def _is_classvar(a_type, typing):
- # This test uses a typing internal class, but it's the best way to
- # test if this is a ClassVar.
- return type(a_type) is typing._ClassVar
+ # This test uses a typing internal class, but it's the best way to
+ # test if this is a ClassVar.
+ return type(a_type) is typing._ClassVar
def _is_initvar(a_type, dataclasses):
- # The module we're checking against is the module we're
- # currently in (dataclasses.py).
- return a_type is dataclasses.InitVar
+ # The module we're checking against is the module we're
+ # currently in (dataclasses.py).
+ return a_type is dataclasses.InitVar
def _is_type(annotation, cls, a_module, a_type, is_type_predicate):
- # Given a type annotation string, does it refer to a_type in
- # a_module? For example, when checking that annotation denotes a
- # ClassVar, then a_module is typing, and a_type is
- # typing.ClassVar.
+ # Given a type annotation string, does it refer to a_type in
+ # a_module? For example, when checking that annotation denotes a
+ # ClassVar, then a_module is typing, and a_type is
+ # typing.ClassVar.
- # It's possible to look up a_module given a_type, but it involves
- # looking in sys.modules (again!), and seems like a waste since
- # the caller already knows a_module.
+ # It's possible to look up a_module given a_type, but it involves
+ # looking in sys.modules (again!), and seems like a waste since
+ # the caller already knows a_module.
- # - annotation is a string type annotation
- # - cls is the class that this annotation was found in
- # - a_module is the module we want to match
- # - a_type is the type in that module we want to match
- # - is_type_predicate is a function called with (obj, a_module)
- # that determines if obj is of the desired type.
+ # - annotation is a string type annotation
+ # - cls is the class that this annotation was found in
+ # - a_module is the module we want to match
+ # - a_type is the type in that module we want to match
+ # - is_type_predicate is a function called with (obj, a_module)
+ # that determines if obj is of the desired type.
- # Since this test does not do a local namespace lookup (and
- # instead only a module (global) lookup), there are some things it
- # gets wrong.
+ # Since this test does not do a local namespace lookup (and
+ # instead only a module (global) lookup), there are some things it
+ # gets wrong.
- # With string annotations, cv0 will be detected as a ClassVar:
- # CV = ClassVar
- # @dataclass
- # class C0:
- # cv0: CV
+ # With string annotations, cv0 will be detected as a ClassVar:
+ # CV = ClassVar
+ # @dataclass
+ # class C0:
+ # cv0: CV
- # But in this example cv1 will not be detected as a ClassVar:
- # @dataclass
- # class C1:
- # CV = ClassVar
- # cv1: CV
+ # But in this example cv1 will not be detected as a ClassVar:
+ # @dataclass
+ # class C1:
+ # CV = ClassVar
+ # cv1: CV
- # In C1, the code in this function (_is_type) will look up "CV" in
- # the module and not find it, so it will not consider cv1 as a
- # ClassVar. This is a fairly obscure corner case, and the best
- # way to fix it would be to eval() the string "CV" with the
- # correct global and local namespaces. However that would involve
- # a eval() penalty for every single field of every dataclass
- # that's defined. It was judged not worth it.
+ # In C1, the code in this function (_is_type) will look up "CV" in
+ # the module and not find it, so it will not consider cv1 as a
+ # ClassVar. This is a fairly obscure corner case, and the best
+ # way to fix it would be to eval() the string "CV" with the
+ # correct global and local namespaces. However that would involve
+ # a eval() penalty for every single field of every dataclass
+ # that's defined. It was judged not worth it.
- match = _MODULE_IDENTIFIER_RE.match(annotation)
- if match:
- ns = None
- module_name = match.group(1)
- if not module_name:
- # No module name, assume the class's module did
- # "from dataclasses import InitVar".
- ns = sys.modules.get(cls.__module__).__dict__
- else:
- # Look up module_name in the class's module.
- module = sys.modules.get(cls.__module__)
- if module and module.__dict__.get(module_name) is a_module:
- ns = sys.modules.get(a_type.__module__).__dict__
- if ns and is_type_predicate(ns.get(match.group(2)), a_module):
- return True
- return False
+ match = _MODULE_IDENTIFIER_RE.match(annotation)
+ if match:
+ ns = None
+ module_name = match.group(1)
+ if not module_name:
+ # No module name, assume the class's module did
+ # "from dataclasses import InitVar".
+ ns = sys.modules.get(cls.__module__).__dict__
+ else:
+ # Look up module_name in the class's module.
+ module = sys.modules.get(cls.__module__)
+ if module and module.__dict__.get(module_name) is a_module:
+ ns = sys.modules.get(a_type.__module__).__dict__
+ if ns and is_type_predicate(ns.get(match.group(2)), a_module):
+ return True
+ return False
def _get_field(cls, a_name, a_type):
- # Return a Field object for this field name and type. ClassVars
- # and InitVars are also returned, but marked as such (see
- # f._field_type).
+ # Return a Field object for this field name and type. ClassVars
+ # and InitVars are also returned, but marked as such (see
+ # f._field_type).
- # If the default value isn't derived from Field, then it's only a
- # normal default value. Convert it to a Field().
- default = getattr(cls, a_name, MISSING)
- if isinstance(default, Field):
- f = default
- else:
- if isinstance(default, types.MemberDescriptorType):
- # This is a field in __slots__, so it has no default value.
- default = MISSING
- f = field(default=default)
+ # If the default value isn't derived from Field, then it's only a
+ # normal default value. Convert it to a Field().
+ default = getattr(cls, a_name, MISSING)
+ if isinstance(default, Field):
+ f = default
+ else:
+ if isinstance(default, types.MemberDescriptorType):
+ # This is a field in __slots__, so it has no default value.
+ default = MISSING
+ f = field(default=default)
- # Only at this point do we know the name and the type. Set them.
- f.name = a_name
- f.type = a_type
+ # Only at this point do we know the name and the type. Set them.
+ f.name = a_name
+ f.type = a_type
- # Assume it's a normal field until proven otherwise. We're next
- # going to decide if it's a ClassVar or InitVar, everything else
- # is just a normal field.
- f._field_type = _FIELD
+ # Assume it's a normal field until proven otherwise. We're next
+ # going to decide if it's a ClassVar or InitVar, everything else
+ # is just a normal field.
+ f._field_type = _FIELD
- # In addition to checking for actual types here, also check for
- # string annotations. get_type_hints() won't always work for us
- # (see https://github.com/python/typing/issues/508 for example),
- # plus it's expensive and would require an eval for every stirng
- # annotation. So, make a best effort to see if this is a ClassVar
- # or InitVar using regex's and checking that the thing referenced
- # is actually of the correct type.
+ # In addition to checking for actual types here, also check for
+ # string annotations. get_type_hints() won't always work for us
+ # (see https://github.com/python/typing/issues/508 for example),
+ # plus it's expensive and would require an eval for every stirng
+ # annotation. So, make a best effort to see if this is a ClassVar
+ # or InitVar using regex's and checking that the thing referenced
+ # is actually of the correct type.
- # For the complete discussion, see https://bugs.python.org/issue33453
+ # For the complete discussion, see https://bugs.python.org/issue33453
- # If typing has not been imported, then it's impossible for any
- # annotation to be a ClassVar. So, only look for ClassVar if
- # typing has been imported by any module (not necessarily cls's
- # module).
- typing = sys.modules.get('typing')
- if typing:
- if (_is_classvar(a_type, typing)
- or (isinstance(f.type, str)
- and _is_type(f.type, cls, typing, typing.ClassVar,
- _is_classvar))):
- f._field_type = _FIELD_CLASSVAR
+ # If typing has not been imported, then it's impossible for any
+ # annotation to be a ClassVar. So, only look for ClassVar if
+ # typing has been imported by any module (not necessarily cls's
+ # module).
+ typing = sys.modules.get('typing')
+ if typing:
+ if (
+ _is_classvar(a_type, typing)
+ or (isinstance(f.type, str) and _is_type(f.type, cls, typing, typing.ClassVar, _is_classvar))
+ ):
+ f._field_type = _FIELD_CLASSVAR
- # If the type is InitVar, or if it's a matching string annotation,
- # then it's an InitVar.
- if f._field_type is _FIELD:
- # The module we're checking against is the module we're
- # currently in (dataclasses.py).
- dataclasses = sys.modules[__name__]
- if (_is_initvar(a_type, dataclasses)
- or (isinstance(f.type, str)
- and _is_type(f.type, cls, dataclasses, dataclasses.InitVar,
- _is_initvar))):
- f._field_type = _FIELD_INITVAR
+ # If the type is InitVar, or if it's a matching string annotation,
+ # then it's an InitVar.
+ if f._field_type is _FIELD:
+ # The module we're checking against is the module we're
+ # currently in (dataclasses.py).
+ dataclasses = sys.modules[__name__]
+ if (
+ _is_initvar(a_type, dataclasses)
+ or (isinstance(f.type, str) and _is_type(f.type, cls, dataclasses, dataclasses.InitVar, _is_initvar))
+ ):
+ f._field_type = _FIELD_INITVAR
- # Validations for individual fields. This is delayed until now,
- # instead of in the Field() constructor, since only here do we
- # know the field name, which allows for better error reporting.
+ # Validations for individual fields. This is delayed until now,
+ # instead of in the Field() constructor, since only here do we
+ # know the field name, which allows for better error reporting.
- # Special restrictions for ClassVar and InitVar.
- if f._field_type in (_FIELD_CLASSVAR, _FIELD_INITVAR):
- if f.default_factory is not MISSING:
- raise TypeError(f'field {f.name} cannot have a '
- 'default factory')
- # Should I check for other field settings? default_factory
- # seems the most serious to check for. Maybe add others. For
- # example, how about init=False (or really,
- # init=<not-the-default-init-value>)? It makes no sense for
- # ClassVar and InitVar to specify init=<anything>.
+ # Special restrictions for ClassVar and InitVar.
+ if f._field_type in (_FIELD_CLASSVAR, _FIELD_INITVAR):
+ if f.default_factory is not MISSING:
+ raise TypeError(f'field {f.name} cannot have a '
+ 'default factory')
+ # Should I check for other field settings? default_factory
+ # seems the most serious to check for. Maybe add others. For
+ # example, how about init=False (or really,
+ # init=<not-the-default-init-value>)? It makes no sense for
+ # ClassVar and InitVar to specify init=<anything>.
- # For real fields, disallow mutable defaults for known types.
- if f._field_type is _FIELD and isinstance(f.default, (list, dict, set)):
- raise ValueError(f'mutable default {type(f.default)} for field '
- f'{f.name} is not allowed: use default_factory')
+ # For real fields, disallow mutable defaults for known types.
+ if f._field_type is _FIELD and isinstance(f.default, (list, dict, set)):
+ raise ValueError(
+ f'mutable default {type(f.default)} for field '
+ f'{f.name} is not allowed: use default_factory'
+ )
- return f
+ return f
def _set_new_attribute(cls, name, value):
- # Never overwrites an existing attribute. Returns True if the
- # attribute already exists.
- if name in cls.__dict__:
- return True
- setattr(cls, name, value)
- return False
+ # Never overwrites an existing attribute. Returns True if the
+ # attribute already exists.
+ if name in cls.__dict__:
+ return True
+ setattr(cls, name, value)
+ return False
# Decide if/how we're going to create a hash function. Key is
@@ -711,17 +697,21 @@ def _set_new_attribute(cls, name, value):
# take. The common case is to do nothing, so instead of providing a
# function that is a no-op, use None to signify that.
+
def _hash_set_none(cls, fields):
- return None
+ return None
+
def _hash_add(cls, fields):
- flds = [f for f in fields if (f.compare if f.hash is None else f.hash)]
- return _hash_fn(flds)
+ flds = [f for f in fields if (f.compare if f.hash is None else f.hash)]
+ return _hash_fn(flds)
+
def _hash_exception(cls, fields):
- # Raise an exception.
- raise TypeError(f'Cannot overwrite attribute __hash__ '
- f'in class {cls.__name__}')
+ # Raise an exception.
+ raise TypeError(f'Cannot overwrite attribute __hash__ '
+ f'in class {cls.__name__}')
+
#
# +-------------------------------------- unsafe_hash?
@@ -733,208 +723,185 @@ def _hash_exception(cls, fields):
# | | | | |
# v v v v v
_hash_action = {(False, False, False, False): None,
- (False, False, False, True ): None,
- (False, False, True, False): None,
- (False, False, True, True ): None,
- (False, True, False, False): _hash_set_none,
- (False, True, False, True ): None,
- (False, True, True, False): _hash_add,
- (False, True, True, True ): None,
- (True, False, False, False): _hash_add,
- (True, False, False, True ): _hash_exception,
- (True, False, True, False): _hash_add,
- (True, False, True, True ): _hash_exception,
- (True, True, False, False): _hash_add,
- (True, True, False, True ): _hash_exception,
- (True, True, True, False): _hash_add,
- (True, True, True, True ): _hash_exception,
- }
+ (False, False, False, True): None, (False, False, True, False): None, (False, False, True, True): None,
+ (False, True, False, False): _hash_set_none, (False, True, False, True): None,
+ (False, True, True, False): _hash_add, (False, True, True, True): None,
+ (True, False, False, False): _hash_add, (True, False, False, True): _hash_exception,
+ (True, False, True, False): _hash_add, (True, False, True, True): _hash_exception,
+ (True, True, False, False): _hash_add, (True, True, False, True): _hash_exception,
+ (True, True, True, False): _hash_add, (True, True, True, True): _hash_exception, }
# See https://bugs.python.org/issue32929#msg312829 for an if-statement
# version of this table.
def _process_class(cls, init, repr, eq, order, unsafe_hash, frozen):
- # Now that dicts retain insertion order, there's no reason to use
- # an ordered dict. I am leveraging that ordering here, because
- # derived class fields overwrite base class fields, but the order
- # is defined by the base class, which is found first.
- fields = {}
+ # Now that dicts retain insertion order, there's no reason to use
+ # an ordered dict. I am leveraging that ordering here, because
+ # derived class fields overwrite base class fields, but the order
+ # is defined by the base class, which is found first.
+ fields = {}
- setattr(cls, _PARAMS, _DataclassParams(init, repr, eq, order,
- unsafe_hash, frozen))
+ setattr(cls, _PARAMS, _DataclassParams(init, repr, eq, order, unsafe_hash, frozen))
- # Find our base classes in reverse MRO order, and exclude
- # ourselves. In reversed order so that more derived classes
- # override earlier field definitions in base classes. As long as
- # we're iterating over them, see if any are frozen.
- any_frozen_base = False
- has_dataclass_bases = False
- for b in cls.__mro__[-1:0:-1]:
- # Only process classes that have been processed by our
- # decorator. That is, they have a _FIELDS attribute.
- base_fields = getattr(b, _FIELDS, None)
- if base_fields:
- has_dataclass_bases = True
- for f in base_fields.values():
- fields[f.name] = f
- if getattr(b, _PARAMS).frozen:
- any_frozen_base = True
+ # Find our base classes in reverse MRO order, and exclude
+ # ourselves. In reversed order so that more derived classes
+ # override earlier field definitions in base classes. As long as
+ # we're iterating over them, see if any are frozen.
+ any_frozen_base = False
+ has_dataclass_bases = False
+ for b in cls.__mro__[-1:0:-1]:
+ # Only process classes that have been processed by our
+ # decorator. That is, they have a _FIELDS attribute.
+ base_fields = getattr(b, _FIELDS, None)
+ if base_fields:
+ has_dataclass_bases = True
+ for f in base_fields.values():
+ fields[f.name] = f
+ if getattr(b, _PARAMS).frozen:
+ any_frozen_base = True
- # Annotations that are defined in this class (not in base
- # classes). If __annotations__ isn't present, then this class
- # adds no new annotations. We use this to compute fields that are
- # added by this class.
- #
- # Fields are found from cls_annotations, which is guaranteed to be
- # ordered. Default values are from class attributes, if a field
- # has a default. If the default value is a Field(), then it
- # contains additional info beyond (and possibly including) the
- # actual default value. Pseudo-fields ClassVars and InitVars are
- # included, despite the fact that they're not real fields. That's
- # dealt with later.
- cls_annotations = cls.__dict__.get('__annotations__', {})
+ # Annotations that are defined in this class (not in base
+ # classes). If __annotations__ isn't present, then this class
+ # adds no new annotations. We use this to compute fields that are
+ # added by this class.
+ #
+ # Fields are found from cls_annotations, which is guaranteed to be
+ # ordered. Default values are from class attributes, if a field
+ # has a default. If the default value is a Field(), then it
+ # contains additional info beyond (and possibly including) the
+ # actual default value. Pseudo-fields ClassVars and InitVars are
+ # included, despite the fact that they're not real fields. That's
+ # dealt with later.
+ cls_annotations = cls.__dict__.get('__annotations__', {})
- # Now find fields in our class. While doing so, validate some
- # things, and set the default values (as class attributes) where
- # we can.
- cls_fields = [_get_field(cls, name, type)
- for name, type in cls_annotations.items()]
- for f in cls_fields:
- fields[f.name] = f
+ # Now find fields in our class. While doing so, validate some
+ # things, and set the default values (as class attributes) where
+ # we can.
+ cls_fields = [_get_field(cls, name, type) for name, type in cls_annotations.items()]
+ for f in cls_fields:
+ fields[f.name] = f
- # If the class attribute (which is the default value for this
- # field) exists and is of type 'Field', replace it with the
- # real default. This is so that normal class introspection
- # sees a real default value, not a Field.
- if isinstance(getattr(cls, f.name, None), Field):
- if f.default is MISSING:
- # If there's no default, delete the class attribute.
- # This happens if we specify field(repr=False), for
- # example (that is, we specified a field object, but
- # no default value). Also if we're using a default
- # factory. The class attribute should not be set at
- # all in the post-processed class.
- delattr(cls, f.name)
- else:
- setattr(cls, f.name, f.default)
+ # If the class attribute (which is the default value for this
+ # field) exists and is of type 'Field', replace it with the
+ # real default. This is so that normal class introspection
+ # sees a real default value, not a Field.
+ if isinstance(getattr(cls, f.name, None), Field):
+ if f.default is MISSING:
+ # If there's no default, delete the class attribute.
+ # This happens if we specify field(repr=False), for
+ # example (that is, we specified a field object, but
+ # no default value). Also if we're using a default
+ # factory. The class attribute should not be set at
+ # all in the post-processed class.
+ delattr(cls, f.name)
+ else:
+ setattr(cls, f.name, f.default)
- # Do we have any Field members that don't also have annotations?
- for name, value in cls.__dict__.items():
- if isinstance(value, Field) and not name in cls_annotations:
- raise TypeError(f'{name!r} is a field but has no type annotation')
+ # Do we have any Field members that don't also have annotations?
+ for name, value in cls.__dict__.items():
+ if isinstance(value, Field) and not name in cls_annotations:
+ raise TypeError(f'{name!r} is a field but has no type annotation')
- # Check rules that apply if we are derived from any dataclasses.
- if has_dataclass_bases:
- # Raise an exception if any of our bases are frozen, but we're not.
- if any_frozen_base and not frozen:
- raise TypeError('cannot inherit non-frozen dataclass from a '
- 'frozen one')
+ # Check rules that apply if we are derived from any dataclasses.
+ if has_dataclass_bases:
+ # Raise an exception if any of our bases are frozen, but we're not.
+ if any_frozen_base and not frozen:
+ raise TypeError('cannot inherit non-frozen dataclass from a '
+ 'frozen one')
- # Raise an exception if we're frozen, but none of our bases are.
- if not any_frozen_base and frozen:
- raise TypeError('cannot inherit frozen dataclass from a '
- 'non-frozen one')
+ # Raise an exception if we're frozen, but none of our bases are.
+ if not any_frozen_base and frozen:
+ raise TypeError('cannot inherit frozen dataclass from a '
+ 'non-frozen one')
- # Remember all of the fields on our class (including bases). This
- # also marks this class as being a dataclass.
- setattr(cls, _FIELDS, fields)
+ # Remember all of the fields on our class (including bases). This
+ # also marks this class as being a dataclass.
+ setattr(cls, _FIELDS, fields)
- # Was this class defined with an explicit __hash__? Note that if
- # __eq__ is defined in this class, then python will automatically
- # set __hash__ to None. This is a heuristic, as it's possible
- # that such a __hash__ == None was not auto-generated, but it
- # close enough.
- class_hash = cls.__dict__.get('__hash__', MISSING)
- has_explicit_hash = not (class_hash is MISSING or
- (class_hash is None and '__eq__' in cls.__dict__))
+ # Was this class defined with an explicit __hash__? Note that if
+ # __eq__ is defined in this class, then python will automatically
+ # set __hash__ to None. This is a heuristic, as it's possible
+ # that such a __hash__ == None was not auto-generated, but it
+ # close enough.
+ class_hash = cls.__dict__.get('__hash__', MISSING)
+ has_explicit_hash = not (class_hash is MISSING or (class_hash is None and '__eq__' in cls.__dict__))
- # If we're generating ordering methods, we must be generating the
- # eq methods.
- if order and not eq:
- raise ValueError('eq must be true if order is true')
+ # If we're generating ordering methods, we must be generating the
+ # eq methods.
+ if order and not eq:
+ raise ValueError('eq must be true if order is true')
- if init:
- # Does this class have a post-init function?
- has_post_init = hasattr(cls, _POST_INIT_NAME)
+ if init:
+ # Does this class have a post-init function?
+ has_post_init = hasattr(cls, _POST_INIT_NAME)
- # Include InitVars and regular fields (so, not ClassVars).
- flds = [f for f in fields.values()
- if f._field_type in (_FIELD, _FIELD_INITVAR)]
- _set_new_attribute(cls, '__init__',
- _init_fn(flds,
- frozen,
- has_post_init,
- # The name to use for the "self"
- # param in __init__. Use "self"
- # if possible.
- '__dataclass_self__' if 'self' in fields
- else 'self',
- ))
+ # Include InitVars and regular fields (so, not ClassVars).
+ flds = [f for f in fields.values() if f._field_type in (_FIELD, _FIELD_INITVAR)]
+ _set_new_attribute(
+ cls, '__init__',
+ _init_fn(
+ flds, frozen, has_post_init,
+ # The name to use for the "self"
+ # param in __init__. Use "self"
+ # if possible.
+ '__dataclass_self__' if 'self' in fields else 'self',
+ )
+ )
- # Get the fields as a list, and include only real fields. This is
- # used in all of the following methods.
- field_list = [f for f in fields.values() if f._field_type is _FIELD]
+ # Get the fields as a list, and include only real fields. This is
+ # used in all of the following methods.
+ field_list = [f for f in fields.values() if f._field_type is _FIELD]
- if repr:
- flds = [f for f in field_list if f.repr]
- _set_new_attribute(cls, '__repr__', _repr_fn(flds))
+ if repr:
+ flds = [f for f in field_list if f.repr]
+ _set_new_attribute(cls, '__repr__', _repr_fn(flds))
- if eq:
- # Create _eq__ method. There's no need for a __ne__ method,
- # since python will call __eq__ and negate it.
- flds = [f for f in field_list if f.compare]
- self_tuple = _tuple_str('self', flds)
- other_tuple = _tuple_str('other', flds)
- _set_new_attribute(cls, '__eq__',
- _cmp_fn('__eq__', '==',
- self_tuple, other_tuple))
+ if eq:
+ # Create _eq__ method. There's no need for a __ne__ method,
+ # since python will call __eq__ and negate it.
+ flds = [f for f in field_list if f.compare]
+ self_tuple = _tuple_str('self', flds)
+ other_tuple = _tuple_str('other', flds)
+ _set_new_attribute(cls, '__eq__', _cmp_fn('__eq__', '==', self_tuple, other_tuple))
- if order:
- # Create and set the ordering methods.
- flds = [f for f in field_list if f.compare]
- self_tuple = _tuple_str('self', flds)
- other_tuple = _tuple_str('other', flds)
- for name, op in [('__lt__', '<'),
- ('__le__', '<='),
- ('__gt__', '>'),
- ('__ge__', '>='),
- ]:
- if _set_new_attribute(cls, name,
- _cmp_fn(name, op, self_tuple, other_tuple)):
- raise TypeError(f'Cannot overwrite attribute {name} '
- f'in class {cls.__name__}. Consider using '
- 'functools.total_ordering')
+ if order:
+ # Create and set the ordering methods.
+ flds = [f for f in field_list if f.compare]
+ self_tuple = _tuple_str('self', flds)
+ other_tuple = _tuple_str('other', flds)
+ for name, op in [('__lt__', '<'), ('__le__', '<='), ('__gt__', '>'), ('__ge__', '>='), ]:
+ if _set_new_attribute(cls, name, _cmp_fn(name, op, self_tuple, other_tuple)):
+ raise TypeError(
+ f'Cannot overwrite attribute {name} '
+ f'in class {cls.__name__}. Consider using '
+ 'functools.total_ordering'
+ )
- if frozen:
- for fn in _frozen_get_del_attr(cls, field_list):
- if _set_new_attribute(cls, fn.__name__, fn):
- raise TypeError(f'Cannot overwrite attribute {fn.__name__} '
- f'in class {cls.__name__}')
+ if frozen:
+ for fn in _frozen_get_del_attr(cls, field_list):
+ if _set_new_attribute(cls, fn.__name__, fn):
+ raise TypeError(f'Cannot overwrite attribute {fn.__name__} '
+ f'in class {cls.__name__}')
- # Decide if/how we're going to create a hash function.
- hash_action = _hash_action[bool(unsafe_hash),
- bool(eq),
- bool(frozen),
- has_explicit_hash]
- if hash_action:
- # No need to call _set_new_attribute here, since by the time
- # we're here the overwriting is unconditional.
- cls.__hash__ = hash_action(cls, field_list)
+ # Decide if/how we're going to create a hash function.
+ hash_action = _hash_action[bool(unsafe_hash), bool(eq), bool(frozen), has_explicit_hash]
+ if hash_action:
+ # No need to call _set_new_attribute here, since by the time
+ # we're here the overwriting is unconditional.
+ cls.__hash__ = hash_action(cls, field_list)
- if not getattr(cls, '__doc__'):
- # Create a class doc-string.
- cls.__doc__ = (cls.__name__ +
- str(inspect.signature(cls)).replace(' -> None', ''))
+ if not getattr(cls, '__doc__'):
+ # Create a class doc-string.
+ cls.__doc__ = (cls.__name__ + str(inspect.signature(cls)).replace(' -> None', ''))
- return cls
+ return cls
# _cls should never be specified by keyword, so start it with an
# underscore. The presence of _cls is used to detect if this
# decorator is being called with parameters or not.
-def dataclass(_cls=None, *, init=True, repr=True, eq=True, order=False,
- unsafe_hash=False, frozen=False):
- """Returns the same class as was passed in, with dunder methods
+def dataclass(_cls=None, *, init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False):
+ """Returns the same class as was passed in, with dunder methods
added based on the fields defined in the class.
Examines PEP 526 __annotations__ to determine fields.
@@ -945,50 +912,49 @@ def dataclass(_cls=None, *, init=True, repr=True, eq=True, order=False,
__hash__() method function is added. If frozen is true, fields may
not be assigned to after instance creation.
"""
+ def wrap(cls):
+ return _process_class(cls, init, repr, eq, order, unsafe_hash, frozen)
- def wrap(cls):
- return _process_class(cls, init, repr, eq, order, unsafe_hash, frozen)
-
- # See if we're being called as @dataclass or @dataclass().
- if _cls is None:
- # We're called with parens.
- return wrap
+ # See if we're being called as @dataclass or @dataclass().
+ if _cls is None:
+ # We're called with parens.
+ return wrap
- # We're called as @dataclass without parens.
- return wrap(_cls)
+ # We're called as @dataclass without parens.
+ return wrap(_cls)
def fields(class_or_instance):
- """Return a tuple describing the fields of this dataclass.
+ """Return a tuple describing the fields of this dataclass.
Accepts a dataclass or an instance of one. Tuple elements are of
type Field.
"""
- # Might it be worth caching this, per class?
- try:
- fields = getattr(class_or_instance, _FIELDS)
- except AttributeError:
- raise TypeError('must be called with a dataclass type or instance')
+ # Might it be worth caching this, per class?
+ try:
+ fields = getattr(class_or_instance, _FIELDS)
+ except AttributeError:
+ raise TypeError('must be called with a dataclass type or instance')
- # Exclude pseudo-fields. Note that fields is sorted by insertion
- # order, so the order of the tuple is as the fields were defined.
- return tuple(f for f in fields.values() if f._field_type is _FIELD)
+ # Exclude pseudo-fields. Note that fields is sorted by insertion
+ # order, so the order of the tuple is as the fields were defined.
+ return tuple(f for f in fields.values() if f._field_type is _FIELD)
def _is_dataclass_instance(obj):
- """Returns True if obj is an instance of a dataclass."""
- return not isinstance(obj, type) and hasattr(obj, _FIELDS)
+ """Returns True if obj is an instance of a dataclass."""
+ return not isinstance(obj, type) and hasattr(obj, _FIELDS)
def is_dataclass(obj):
- """Returns True if obj is a dataclass or an instance of a
+ """Returns True if obj is a dataclass or an instance of a
dataclass."""
- return hasattr(obj, _FIELDS)
+ return hasattr(obj, _FIELDS)
def asdict(obj, *, dict_factory=dict):
- """Return the fields of a dataclass instance as a new dictionary mapping
+ """Return the fields of a dataclass instance as a new dictionary mapping
field names to field values.
Example usage:
@@ -1006,29 +972,28 @@ def asdict(obj, *, dict_factory=dict):
dataclass instances. This will also look into built-in containers:
tuples, lists, and dicts.
"""
- if not _is_dataclass_instance(obj):
- raise TypeError("asdict() should be called on dataclass instances")
- return _asdict_inner(obj, dict_factory)
+ if not _is_dataclass_instance(obj):
+ raise TypeError("asdict() should be called on dataclass instances")
+ return _asdict_inner(obj, dict_factory)
def _asdict_inner(obj, dict_factory):
- if _is_dataclass_instance(obj):
- result = []
- for f in fields(obj):
- value = _asdict_inner(getattr(obj, f.name), dict_factory)
- result.append((f.name, value))
- return dict_factory(result)
- elif isinstance(obj, (list, tuple)):
- return type(obj)(_asdict_inner(v, dict_factory) for v in obj)
- elif isinstance(obj, dict):
- return type(obj)((_asdict_inner(k, dict_factory), _asdict_inner(v, dict_factory))
- for k, v in obj.items())
- else:
- return copy.deepcopy(obj)
+ if _is_dataclass_instance(obj):
+ result = []
+ for f in fields(obj):
+ value = _asdict_inner(getattr(obj, f.name), dict_factory)
+ result.append((f.name, value))
+ return dict_factory(result)
+ elif isinstance(obj, (list, tuple)):
+ return type(obj)(_asdict_inner(v, dict_factory) for v in obj)
+ elif isinstance(obj, dict):
+ return type(obj)((_asdict_inner(k, dict_factory), _asdict_inner(v, dict_factory)) for k, v in obj.items())
+ else:
+ return copy.deepcopy(obj)
def astuple(obj, *, tuple_factory=tuple):
- """Return the fields of a dataclass instance as a new tuple of field values.
+ """Return the fields of a dataclass instance as a new tuple of field values.
Example usage::
@@ -1046,31 +1011,31 @@ def astuple(obj, *, tuple_factory=tuple):
tuples, lists, and dicts.
"""
- if not _is_dataclass_instance(obj):
- raise TypeError("astuple() should be called on dataclass instances")
- return _astuple_inner(obj, tuple_factory)
+ if not _is_dataclass_instance(obj):
+ raise TypeError("astuple() should be called on dataclass instances")
+ return _astuple_inner(obj, tuple_factory)
def _astuple_inner(obj, tuple_factory):
- if _is_dataclass_instance(obj):
- result = []
- for f in fields(obj):
- value = _astuple_inner(getattr(obj, f.name), tuple_factory)
- result.append(value)
- return tuple_factory(result)
- elif isinstance(obj, (list, tuple)):
- return type(obj)(_astuple_inner(v, tuple_factory) for v in obj)
- elif isinstance(obj, dict):
- return type(obj)((_astuple_inner(k, tuple_factory), _astuple_inner(v, tuple_factory))
- for k, v in obj.items())
- else:
- return copy.deepcopy(obj)
+ if _is_dataclass_instance(obj):
+ result = []
+ for f in fields(obj):
+ value = _astuple_inner(getattr(obj, f.name), tuple_factory)
+ result.append(value)
+ return tuple_factory(result)
+ elif isinstance(obj, (list, tuple)):
+ return type(obj)(_astuple_inner(v, tuple_factory) for v in obj)
+ elif isinstance(obj, dict):
+ return type(obj)((_astuple_inner(k, tuple_factory), _astuple_inner(v, tuple_factory)) for k, v in obj.items())
+ else:
+ return copy.deepcopy(obj)
-def make_dataclass(cls_name, fields, *, bases=(), namespace=None, init=True,
- repr=True, eq=True, order=False, unsafe_hash=False,
- frozen=False):
- """Return a new dynamically created dataclass.
+def make_dataclass(
+ cls_name, fields, *, bases=(), namespace=None, init=True, repr=True, eq=True, order=False, unsafe_hash=False,
+ frozen=False
+):
+ """Return a new dynamically created dataclass.
The dataclass name will be 'cls_name'. 'fields' is an iterable
of either (name), (name, type) or (name, type, Field) objects. If type is
@@ -1093,48 +1058,47 @@ def make_dataclass(cls_name, fields, *, bases=(), namespace=None, init=True,
dataclass().
"""
- if namespace is None:
- namespace = {}
- else:
- # Copy namespace since we're going to mutate it.
- namespace = namespace.copy()
+ if namespace is None:
+ namespace = {}
+ else:
+ # Copy namespace since we're going to mutate it.
+ namespace = namespace.copy()
- # While we're looking through the field names, validate that they
- # are identifiers, are not keywords, and not duplicates.
- seen = set()
- anns = {}
- for item in fields:
- if isinstance(item, str):
- name = item
- tp = 'typing.Any'
- elif len(item) == 2:
- name, tp, = item
- elif len(item) == 3:
- name, tp, spec = item
- namespace[name] = spec
- else:
- raise TypeError(f'Invalid field: {item!r}')
+ # While we're looking through the field names, validate that they
+ # are identifiers, are not keywords, and not duplicates.
+ seen = set()
+ anns = {}
+ for item in fields:
+ if isinstance(item, str):
+ name = item
+ tp = 'typing.Any'
+ elif len(item) == 2:
+ name, tp, = item
+ elif len(item) == 3:
+ name, tp, spec = item
+ namespace[name] = spec
+ else:
+ raise TypeError(f'Invalid field: {item!r}')
- if not isinstance(name, str) or not name.isidentifier():
- raise TypeError(f'Field names must be valid identifers: {name!r}')
- if keyword.iskeyword(name):
- raise TypeError(f'Field names must not be keywords: {name!r}')
- if name in seen:
- raise TypeError(f'Field name duplicated: {name!r}')
+ if not isinstance(name, str) or not name.isidentifier():
+ raise TypeError(f'Field names must be valid identifers: {name!r}')
+ if keyword.iskeyword(name):
+ raise TypeError(f'Field names must not be keywords: {name!r}')
+ if name in seen:
+ raise TypeError(f'Field name duplicated: {name!r}')
- seen.add(name)
- anns[name] = tp
+ seen.add(name)
+ anns[name] = tp
- namespace['__annotations__'] = anns
- # We use `types.new_class()` instead of simply `type()` to allow dynamic creation
- # of generic dataclassses.
- cls = types.new_class(cls_name, bases, {}, lambda ns: ns.update(namespace))
- return dataclass(cls, init=init, repr=repr, eq=eq, order=order,
- unsafe_hash=unsafe_hash, frozen=frozen)
+ namespace['__annotations__'] = anns
+ # We use `types.new_class()` instead of simply `type()` to allow dynamic creation
+ # of generic dataclassses.
+ cls = types.new_class(cls_name, bases, {}, lambda ns: ns.update(namespace))
+ return dataclass(cls, init=init, repr=repr, eq=eq, order=order, unsafe_hash=unsafe_hash, frozen=frozen)
def replace(obj, **changes):
- """Return a new object replacing specified fields with new values.
+ """Return a new object replacing specified fields with new values.
This is especially useful for frozen classes. Example usage:
@@ -1148,37 +1112,39 @@ def replace(obj, **changes):
assert c1.x == 3 and c1.y == 2
"""
- # We're going to mutate 'changes', but that's okay because it's a
- # new dict, even if called with 'replace(obj, **my_changes)'.
+ # We're going to mutate 'changes', but that's okay because it's a
+ # new dict, even if called with 'replace(obj, **my_changes)'.
- if not _is_dataclass_instance(obj):
- raise TypeError("replace() should be called on dataclass instances")
+ if not _is_dataclass_instance(obj):
+ raise TypeError("replace() should be called on dataclass instances")
- # It's an error to have init=False fields in 'changes'.
- # If a field is not in 'changes', read its value from the provided obj.
+ # It's an error to have init=False fields in 'changes'.
+ # If a field is not in 'changes', read its value from the provided obj.
- for f in getattr(obj, _FIELDS).values():
- # Only consider normal fields or InitVars.
- if f._field_type is _FIELD_CLASSVAR:
- continue
+ for f in getattr(obj, _FIELDS).values():
+ # Only consider normal fields or InitVars.
+ if f._field_type is _FIELD_CLASSVAR:
+ continue
- if not f.init:
- # Error if this field is specified in changes.
- if f.name in changes:
- raise ValueError(f'field {f.name} is declared with '
- 'init=False, it cannot be specified with '
- 'replace()')
- continue
+ if not f.init:
+ # Error if this field is specified in changes.
+ if f.name in changes:
+ raise ValueError(
+ f'field {f.name} is declared with '
+ 'init=False, it cannot be specified with '
+ 'replace()'
+ )
+ continue
- if f.name not in changes:
- if f._field_type is _FIELD_INITVAR:
- raise ValueError(f"InitVar {f.name!r} "
- 'must be specified with replace()')
- changes[f.name] = getattr(obj, f.name)
+ if f.name not in changes:
+ if f._field_type is _FIELD_INITVAR:
+ raise ValueError(f"InitVar {f.name!r} "
+ 'must be specified with replace()')
+ changes[f.name] = getattr(obj, f.name)
- # Create the new object, which calls __init__() and
- # __post_init__() (if defined), using all of the init fields we've
- # added and/or left in 'changes'. If there are values supplied in
- # changes that aren't fields, this will correctly raise a
- # TypeError.
- return obj.__class__(**changes)
+ # Create the new object, which calls __init__() and
+ # __post_init__() (if defined), using all of the init fields we've
+ # added and/or left in 'changes'. If there are values supplied in
+ # changes that aren't fields, this will correctly raise a
+ # TypeError.
+ return obj.__class__(**changes)
diff --git a/python/datarender.py b/python/datarender.py
index b5b21073..88f9d6d1 100644
--- a/python/datarender.py
+++ b/python/datarender.py
@@ -18,7 +18,6 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
-
import traceback
import ctypes
@@ -49,6 +48,7 @@ class TypeContext:
"""The offset into the given type object"""
return self._offset
+
class DataRenderer:
"""
DataRenderer objects tell the Linear View how to render specific types.
@@ -95,8 +95,10 @@ class DataRenderer:
@staticmethod
def is_type_of_struct_name(t, name, context):
- return (t.type_class == enums.TypeClass.StructureTypeClass and len(context) > 0
- and isinstance(context[-1].type, types.NamedTypeReferenceType) and context[-1].type.name == name)
+ return (
+ t.type_class == enums.TypeClass.StructureTypeClass and len(context) > 0
+ and isinstance(context[-1].type, types.NamedTypeReferenceType) and context[-1].type.name == name
+ )
def register_type_specific(self):
core.BNRegisterTypeSpecificDataRenderer(core.BNGetDataRendererContainer(), self.handle)
@@ -119,7 +121,9 @@ class DataRenderer:
type = types.Type.create(handle=core.BNNewTypeReference(type))
pycontext = []
for i in range(0, ctxCount):
- pycontext.append(TypeContext(types.Type.create(core.BNNewTypeReference(context[i].type)), context[i].offset))
+ pycontext.append(
+ TypeContext(types.Type.create(core.BNNewTypeReference(context[i].type)), context[i].offset)
+ )
return self.perform_is_valid_for_data(ctxt, view, addr, type, pycontext)
except:
log_error(traceback.format_exc())
@@ -134,7 +138,9 @@ class DataRenderer:
prefixTokens = function.InstructionTextToken._from_core_struct(prefix, prefixCount)
pycontext = []
for i in range(ctxCount):
- pycontext.append(TypeContext(types.Type.create(core.BNNewTypeReference(typeCtx[i].type)), typeCtx[i].offset))
+ pycontext.append(
+ TypeContext(types.Type.create(core.BNNewTypeReference(typeCtx[i].type)), typeCtx[i].offset)
+ )
result = self.perform_get_lines_for_data(ctxt, view, addr, type, prefixTokens, width, pycontext)
@@ -143,7 +149,8 @@ class DataRenderer:
for i in range(len(result)):
line = result[i]
color = line.highlight
- if not isinstance(color, enums.HighlightStandardColor) and not isinstance(color, highlight.HighlightColor):
+ if not isinstance(color,
+ enums.HighlightStandardColor) and not isinstance(color, highlight.HighlightColor):
raise ValueError("Specified color is not one of HighlightStandardColor, highlight.HighlightColor")
if isinstance(color, enums.HighlightStandardColor):
color = highlight.HighlightColor(color)
diff --git a/python/debuginfo.py b/python/debuginfo.py
index ba96c27f..a48182e6 100644
--- a/python/debuginfo.py
+++ b/python/debuginfo.py
@@ -33,7 +33,6 @@ from .log import log_error
from . import binaryview
from . import filemetadata
-
_debug_info_parsers = {}
@@ -98,18 +97,21 @@ class _DebugInfoParserMetaClass(type):
@staticmethod
def _is_valid(view: core.BNBinaryView, callback: Callable[['binaryview.BinaryView'], bool]) -> bool:
try:
- file_metadata = filemetadata.FileMetadata(handle = core.BNGetFileForView(view))
- view_obj = binaryview.BinaryView(file_metadata = file_metadata, handle = core.BNNewViewReference(view))
+ file_metadata = filemetadata.FileMetadata(handle=core.BNGetFileForView(view))
+ view_obj = binaryview.BinaryView(file_metadata=file_metadata, handle=core.BNNewViewReference(view))
return callback(view_obj)
except:
log_error(traceback.format_exc())
return False
@staticmethod
- def _parse_info(debug_info: core.BNDebugInfo, view: core.BNBinaryView, callback: Callable[["DebugInfo", 'binaryview.BinaryView'], None]) -> None:
+ def _parse_info(
+ debug_info: core.BNDebugInfo, view: core.BNBinaryView,
+ callback: Callable[["DebugInfo", 'binaryview.BinaryView'], None]
+ ) -> None:
try:
- file_metadata = filemetadata.FileMetadata(handle = core.BNGetFileForView(view))
- view_obj = binaryview.BinaryView(file_metadata = file_metadata, handle = core.BNNewViewReference(view))
+ file_metadata = filemetadata.FileMetadata(handle=core.BNGetFileForView(view))
+ view_obj = binaryview.BinaryView(file_metadata=file_metadata, handle=core.BNNewViewReference(view))
parser_ref = core.BNNewDebugInfoReference(debug_info)
assert parser_ref is not None, "core.BNNewDebugInfoReference returned None"
callback(DebugInfo(parser_ref), view_obj)
@@ -117,12 +119,19 @@ class _DebugInfoParserMetaClass(type):
log_error(traceback.format_exc())
@classmethod
- def register(cls, name: str, is_valid: Callable[['binaryview.BinaryView'], bool], parse_info: Callable[["DebugInfo", 'binaryview.BinaryView'], None]) -> "DebugInfoParser":
+ def register(
+ cls, name: str, is_valid: Callable[['binaryview.BinaryView'], bool],
+ parse_info: Callable[["DebugInfo", 'binaryview.BinaryView'], None]
+ ) -> "DebugInfoParser":
"""Registers a DebugInfoParser. See ``debuginfo.DebugInfoParser`` for more details."""
binaryninja._init_plugins()
- is_valid_cb = ctypes.CFUNCTYPE(ctypes.c_bool, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView))(lambda ctxt, view: cls._is_valid(view, is_valid))
- parse_info_cb = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.POINTER(core.BNDebugInfo), ctypes.POINTER(core.BNBinaryView))(lambda ctxt, debug_info, view: cls._parse_info(debug_info, view, parse_info))
+ is_valid_cb = ctypes.CFUNCTYPE(ctypes.c_bool, ctypes.c_void_p,
+ ctypes.POINTER(core.BNBinaryView
+ ))(lambda ctxt, view: cls._is_valid(view, is_valid))
+ parse_info_cb = ctypes.CFUNCTYPE(
+ None, ctypes.c_void_p, ctypes.POINTER(core.BNDebugInfo), ctypes.POINTER(core.BNBinaryView)
+ )(lambda ctxt, debug_info, view: cls._parse_info(debug_info, view, parse_info))
# Don't let our callbacks get garbage collected
global _debug_info_parsers
@@ -231,15 +240,15 @@ class DebugFunctionInfo(object):
Functions will not be created if an address is not provided, but will be able to be queried from debug info for later user analysis.
"""
- short_name:Optional[str] = None
- full_name:Optional[str] = None
- raw_name:Optional[str] = None
- address:Optional[int] = None
- return_type:Optional[_types.Type] = None
- parameters:Optional[List[Tuple[str, _types.Type]]] = None
- variable_parameters:Optional[bool] = None
- calling_convention:Optional[callingconvention.CallingConvention] = None
- platform:Optional['_platform.Platform'] = None
+ short_name: Optional[str] = None
+ full_name: Optional[str] = None
+ raw_name: Optional[str] = None
+ address: Optional[int] = None
+ return_type: Optional[_types.Type] = None
+ parameters: Optional[List[Tuple[str, _types.Type]]] = None
+ variable_parameters: Optional[bool] = None
+ calling_convention: Optional[callingconvention.CallingConvention] = None
+ platform: Optional['_platform.Platform'] = None
def __repr__(self) -> str:
suffix = f"@{self.address:#x}>" if self.address != 0 else ">"
@@ -301,7 +310,10 @@ class DebugInfo(object):
parameters: List[Tuple[str, _types.Type]] = []
for j in range(functions[i].parameterCount):
- parameters.append((functions[i].parameterNames[j], _types.Type(core.BNNewTypeReference(functions[i].parameterTypes[j]))))
+ parameters.append((
+ functions[i].parameterNames[j],
+ _types.Type(core.BNNewTypeReference(functions[i].parameterTypes[j]))
+ ))
if functions[i].returnType:
return_type = _types.Type(core.BNNewTypeReference(functions[i].returnType))
@@ -309,7 +321,9 @@ class DebugInfo(object):
return_type = None
if functions[i].callingConvention:
- calling_convention = callingconvention.CallingConvention(handle=core.BNNewCallingConventionReference(functions[i].callingConvention))
+ calling_convention = callingconvention.CallingConvention(
+ handle=core.BNNewCallingConventionReference(functions[i].callingConvention)
+ )
else:
calling_convention = None
@@ -319,15 +333,8 @@ class DebugInfo(object):
func_platform = None
yield DebugFunctionInfo(
- functions[i].address,
- functions[i].shortName,
- functions[i].fullName,
- functions[i].rawName,
- return_type,
- parameters,
- functions[i].variableParameters,
- calling_convention,
- func_platform
+ functions[i].address, functions[i].shortName, functions[i].fullName, functions[i].rawName,
+ return_type, parameters, functions[i].variableParameters, calling_convention, func_platform
)
finally:
core.BNFreeDebugFunctions(functions, count.value)
@@ -345,10 +352,11 @@ class DebugInfo(object):
try:
for i in range(0, count.value):
yield binaryview.DataVariableAndName(
- data_variables[i].address,
- _types.Type(core.BNNewTypeReference(data_variables[i].type), confidence=data_variables[i].typeConfidence),
- data_variables[i].name,
- data_variables[i].autoDiscovered)
+ data_variables[i].address,
+ _types.Type(
+ core.BNNewTypeReference(data_variables[i].type), confidence=data_variables[i].typeConfidence
+ ), data_variables[i].name, data_variables[i].autoDiscovered
+ )
finally:
core.BNFreeDataVariablesAndName(data_variables, count.value)
@@ -357,7 +365,7 @@ class DebugInfo(object):
"""A generator of all data variables provided by DebugInfoParsers"""
return self.data_variables_from_parser()
- def add_type(self, name: str, new_type:'_types.Type') -> bool:
+ def add_type(self, name: str, new_type: '_types.Type') -> bool:
"""Adds a type scoped under the current parser's name to the debug info"""
if isinstance(new_type, _types.Type):
return core.BNAddDebugType(self.handle, name, new_type.handle)
@@ -406,8 +414,12 @@ class DebugInfo(object):
func_info.parameterTypes = None
func_info.parameterCount = parameter_count
else:
- func_info.parameterNames = (ctypes.c_char_p * parameter_count)(*map(lambda pair: binaryninja.cstr(pair[0]), new_func.parameters)) # type: ignore
- func_info.parameterTypes = (ctypes.POINTER(core.BNType) * parameter_count)(*map(lambda pair: pair[1].handle, new_func.parameters)) # type: ignore
+ func_info.parameterNames = (ctypes.c_char_p * parameter_count)(
+ *map(lambda pair: binaryninja.cstr(pair[0]), new_func.parameters)
+ ) # type: ignore
+ func_info.parameterTypes = (ctypes.POINTER(core.BNType) * parameter_count)(
+ *map(lambda pair: pair[1].handle, new_func.parameters)
+ ) # type: ignore
func_info.parameterCount = parameter_count
return core.BNAddDebugFunction(self.handle, func_info)
diff --git a/python/decorators.py b/python/decorators.py
index fcd3a8be..e02829f8 100644
--- a/python/decorators.py
+++ b/python/decorators.py
@@ -10,4 +10,3 @@ def passive(cls):
cls.__doc__ = passive_note
return cls
-
diff --git a/python/demangle.py b/python/demangle.py
index 3f22d294..6e9185ec 100644
--- a/python/demangle.py
+++ b/python/demangle.py
@@ -44,7 +44,7 @@ def get_qualified_name(names):
return "::".join(names)
-def demangle_ms(arch, mangled_name, options = False):
+def demangle_ms(arch, mangled_name, options=False):
"""
``demangle_ms`` demangles a mangled Microsoft Visual Studio C++ name to a Type object.
@@ -64,9 +64,19 @@ def demangle_ms(arch, mangled_name, options = False):
outName = ctypes.POINTER(ctypes.c_char_p)()
outSize = ctypes.c_ulonglong()
names = []
- if (isinstance(options, binaryview.BinaryView) and core.BNDemangleMSWithOptions(arch.handle, mangled_name, ctypes.byref(handle), ctypes.byref(outName), ctypes.byref(outSize), options)) or \
- (isinstance(options, bool) and core.BNDemangleMS(arch.handle, mangled_name, ctypes.byref(handle), ctypes.byref(outName), ctypes.byref(outSize), options)) or \
- (options is None and core.BNDemangleMSWithOptions(arch.handle, mangled_name, ctypes.byref(handle), ctypes.byref(outName), ctypes.byref(outSize), None)):
+ if (
+ isinstance(options, binaryview.BinaryView) and core.BNDemangleMSWithOptions(
+ arch.handle, mangled_name, ctypes.byref(handle), ctypes.byref(outName), ctypes.byref(outSize), options
+ )
+ ) or (
+ isinstance(options, bool) and core.BNDemangleMS(
+ arch.handle, mangled_name, ctypes.byref(handle), ctypes.byref(outName), ctypes.byref(outSize), options
+ )
+ ) or (
+ options is None and core.BNDemangleMSWithOptions(
+ arch.handle, mangled_name, ctypes.byref(handle), ctypes.byref(outName), ctypes.byref(outSize), None
+ )
+ ):
for i in range(outSize.value):
names.append(outName[i].decode('utf8')) # type: ignore
core.BNFreeDemangledName(ctypes.byref(outName), outSize.value)
@@ -74,7 +84,7 @@ def demangle_ms(arch, mangled_name, options = False):
return (None, mangled_name)
-def demangle_gnu3(arch, mangled_name, options = None):
+def demangle_gnu3(arch, mangled_name, options=None):
"""
``demangle_gnu3`` demangles a mangled name to a Type object.
@@ -89,9 +99,19 @@ def demangle_gnu3(arch, mangled_name, options = None):
outName = ctypes.POINTER(ctypes.c_char_p)()
outSize = ctypes.c_ulonglong()
names = []
- if (isinstance(options, binaryview.BinaryView) and core.BNDemangleGNU3WithOptions(arch.handle, mangled_name, ctypes.byref(handle), ctypes.byref(outName), ctypes.byref(outSize), options)) or \
- (isinstance(options, bool) and core.BNDemangleGNU3(arch.handle, mangled_name, ctypes.byref(handle), ctypes.byref(outName), ctypes.byref(outSize), options)) or \
- (options is None and core.BNDemangleGNU3WithOptions(arch.handle, mangled_name, ctypes.byref(handle), ctypes.byref(outName), ctypes.byref(outSize), None)):
+ if (
+ isinstance(options, binaryview.BinaryView) and core.BNDemangleGNU3WithOptions(
+ arch.handle, mangled_name, ctypes.byref(handle), ctypes.byref(outName), ctypes.byref(outSize), options
+ )
+ ) or (
+ isinstance(options, bool) and core.BNDemangleGNU3(
+ arch.handle, mangled_name, ctypes.byref(handle), ctypes.byref(outName), ctypes.byref(outSize), options
+ )
+ ) or (
+ options is None and core.BNDemangleGNU3WithOptions(
+ arch.handle, mangled_name, ctypes.byref(handle), ctypes.byref(outName), ctypes.byref(outSize), None
+ )
+ ):
for i in range(outSize.value):
names.append(outName[i].decode('utf8')) # type: ignore
core.BNFreeDemangledName(ctypes.byref(outName), outSize.value)
@@ -125,7 +145,7 @@ def simplify_name_to_string(input_name):
return result
-def simplify_name_to_qualified_name(input_name, simplify = True):
+def simplify_name_to_qualified_name(input_name, simplify=True):
"""
``simplify_name_to_qualified_name`` simplifies a templated C++ name with default arguments and returns a qualified name. This can also tokenize a string to a qualified name with/without simplifying it
@@ -158,5 +178,5 @@ def simplify_name_to_qualified_name(input_name, simplify = True):
name_count = len(native_result)
native_result = types.QualifiedName(native_result)
- core.BNRustFreeStringArray(result, name_count+1)
+ core.BNRustFreeStringArray(result, name_count + 1)
return native_result
diff --git a/python/downloadprovider.py b/python/downloadprovider.py
index 793dc298..ed61136c 100644
--- a/python/downloadprovider.py
+++ b/python/downloadprovider.py
@@ -18,7 +18,6 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
-
import abc
import ctypes
from json import dumps
@@ -52,7 +51,7 @@ class DownloadInstance(object):
self.headers = headers
self.content = content
- def __init__(self, provider, handle = None):
+ def __init__(self, provider, handle=None):
if handle is None:
self._cb = core.BNDownloadInstanceCallbacks()
self._cb.context = 0
@@ -88,7 +87,8 @@ class DownloadInstance(object):
def _perform_custom_request(self, ctxt, method, url, header_count, header_keys, header_values, response):
# Cast response to an array of length 1 so ctypes can write to the pointer
# out_response = ((BNDownloadInstanceResponse*)[1])response
- out_response = (ctypes.POINTER(core.BNDownloadInstanceResponse) * 1).from_address(ctypes.addressof(response.contents)) # type: ignore
+ out_response = (ctypes.POINTER(core.BNDownloadInstanceResponse)
+ * 1).from_address(ctypes.addressof(response.contents)) # type: ignore
try:
# Extract headers
keys_ptr = ctypes.cast(header_keys, ctypes.POINTER(ctypes.c_char_p))
@@ -103,7 +103,9 @@ class DownloadInstance(object):
def data_generator():
while True:
read_buffer = ctypes.create_string_buffer(0x1000)
- read_len = core.BNReadDataForDownloadInstance(self.handle, ctypes.cast(read_buffer, ctypes.POINTER(ctypes.c_uint8)), 0x1000)
+ read_len = core.BNReadDataForDownloadInstance(
+ self.handle, ctypes.cast(read_buffer, ctypes.POINTER(ctypes.c_uint8)), 0x1000
+ )
if read_len == 0:
break
if read_len < 0:
@@ -203,7 +205,7 @@ class DownloadInstance(object):
if "Content-Type" not in headers:
headers["Content-Type"] = "application/x-www-form-urlencoded"
else:
- assert(type(data) == bytes)
+ assert (type(data) == bytes)
self._data = data
if len(data) > 0 and "Content-Length" not in headers:
@@ -226,7 +228,9 @@ class DownloadInstance(object):
header_values[i] = to_bytes(value)
response = ctypes.POINTER(core.BNDownloadInstanceResponse)()
- result = core.BNPerformCustomRequest(self.handle, method, url, len(headers), header_keys, header_values, response, callbacks)
+ result = core.BNPerformCustomRequest(
+ self.handle, method, url, len(headers), header_keys, header_values, response, callbacks
+ )
if result != 0:
return None
@@ -246,6 +250,7 @@ class DownloadInstance(object):
def put(self, url, headers=None, data=None, json=None):
return self.request("POST", url, headers, data, json)
+
class _DownloadProviderMetaclass(type):
def __iter__(self):
binaryninja._init_plugins()
@@ -270,7 +275,7 @@ class DownloadProvider(metaclass=_DownloadProviderMetaclass):
instance_class = None
_registered_providers = []
- def __init__(self, handle = None):
+ def __init__(self, handle=None):
if handle is not None:
self.handle = core.handle_of_type(handle, core.BNDownloadProvider)
self.__dict__["name"] = core.BNGetDownloadProviderName(handle)
@@ -299,7 +304,7 @@ class DownloadProvider(metaclass=_DownloadProviderMetaclass):
result = core.BNCreateDownloadProviderInstance(self.handle)
if result is None:
return None
- return DownloadInstance(self, handle = result)
+ return DownloadInstance(self, handle=result)
_loaded = False
@@ -398,7 +403,10 @@ try:
if b"Content-Length" in headers:
del headers[b"Content-Length"]
- r = requests.request(method.decode('utf8'), url.decode('utf8'), headers=headers, data=data_generator, proxies=proxies, stream=True)
+ r = requests.request(
+ method.decode('utf8'), url.decode('utf8'), headers=headers, data=data_generator, proxies=proxies,
+ stream=True
+ )
total_size = 0
for (key, value) in r.headers.items():
@@ -465,7 +473,9 @@ if not _loaded and (sys.platform != "win32") and (sys.version_info >= (2, 7, 9))
core.BNSetErrorForDownloadInstance(self.handle, "Bytes written mismatch!")
return -1
bytes_sent = bytes_sent + bytes_wrote
- continue_download = core.BNNotifyProgressForDownloadInstance(self.handle, bytes_sent, total_size)
+ continue_download = core.BNNotifyProgressForDownloadInstance(
+ self.handle, bytes_sent, total_size
+ )
if continue_download is False:
core.BNSetErrorForDownloadInstance(self.handle, "Download aborted!")
return -1
@@ -490,7 +500,6 @@ if not _loaded and (sys.platform != "win32") and (sys.version_info >= (2, 7, 9))
urllib2 (python2) does not have a parameter for custom request methods
So this is a shim class to deal with that
"""
-
def __init__(self, *args, **kwargs):
if "method" in kwargs:
self._method = kwargs["method"]
@@ -518,7 +527,9 @@ if not _loaded and (sys.platform != "win32") and (sys.version_info >= (2, 7, 9))
if b"Content-Length" in headers:
del headers[b"Content-Length"]
- req = PythonDownloadInstance.CustomRequest(url.decode('utf8'), data=data_generator, headers=headers, method=method.decode('utf8'))
+ req = PythonDownloadInstance.CustomRequest(
+ url.decode('utf8'), data=data_generator, headers=headers, method=method.decode('utf8')
+ )
result = urlopen(req)
except HTTPError as he:
result = he
@@ -562,8 +573,12 @@ if not _loaded:
log_error("Please install the requests package into the selected Python environment:")
log_error(" python -m pip install requests")
else:
- log_error("On Python versions below 2.7.9, the pip requests[security] package is required for network connectivity!")
- log_error("On an Ubuntu 14.04 install, the following three commands are sufficient to enable networking for the current user:")
+ log_error(
+ "On Python versions below 2.7.9, the pip requests[security] package is required for network connectivity!"
+ )
+ log_error(
+ "On an Ubuntu 14.04 install, the following three commands are sufficient to enable networking for the current user:"
+ )
log_error(" sudo apt install python-pip")
log_error(" python -m pip install pip --upgrade --user")
log_error(" python -m pip install requests[security] --upgrade --user")
diff --git a/python/enterprise.py b/python/enterprise.py
index 18062153..e3c0e26c 100644
--- a/python/enterprise.py
+++ b/python/enterprise.py
@@ -271,7 +271,6 @@ class LicenseCheckout:
# License is released at end of scope
"""
-
def __init__(self, duration=900, cache=False):
self.desired_duration = duration
self.desired_cache = cache
@@ -284,8 +283,9 @@ class LicenseCheckout:
connect()
if not is_authenticated():
raise RuntimeError(
- "Could not checkout a license: Not authenticated. "
- "Please use binaryninja.enterprise.authenticate_with_credentials or authenticate_with_method first!")
+ "Could not checkout a license: Not authenticated. "
+ "Please use binaryninja.enterprise.authenticate_with_credentials or authenticate_with_method first!"
+ )
acquire_license(self.desired_duration, self.desired_cache)
def __exit__(self, exc_type, exc_val, exc_tb):
diff --git a/python/examples/angr_plugin.py b/python/examples/angr_plugin.py
index 940aff8b..5f2eeba0 100644
--- a/python/examples/angr_plugin.py
+++ b/python/examples/angr_plugin.py
@@ -18,7 +18,6 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
-
# This plugin assumes angr is already installed and available on the system. See the angr documentation
# for information about installing angr. It should be installed using the virtualenv method.
#
@@ -72,7 +71,7 @@ class Solver(BackgroundTaskThread):
def run(self):
# Create an angr project and an explorer with the user's settings
p = angr.Project(self.binary.name)
- e = p.surveyors.Explorer(find = self.find, avoid = self.avoid)
+ e = p.surveyors.Explorer(find=self.find, avoid=self.avoid)
# Solve loop
while not e.done:
@@ -98,7 +97,7 @@ class Solver(BackgroundTaskThread):
text_report = "Found %d path%s.\n\n" % (len(e.found), "s" if len(e.found) != 1 else "")
i = 1
for f in e.found:
- text_report += "Path %d\n" % i + "=" * 10 + "\n"
+ text_report += "Path %d\n"%i + "="*10 + "\n"
text_report += "stdin:\n" + escaped_output(f.state.posix.dumps(0)) + "\n\n"
text_report += "stdout:\n" + escaped_output(f.state.posix.dumps(1)) + "\n\n"
text_report += "stderr:\n" + escaped_output(f.state.posix.dumps(2)) + "\n\n"
@@ -115,7 +114,7 @@ def find_instr(bv, addr):
# Highlight the instruction in green
blocks = bv.get_basic_blocks_at(addr)
for block in blocks:
- block.set_auto_highlight(HighlightColor(HighlightStandardColor.GreenHighlightColor, alpha = 128))
+ block.set_auto_highlight(HighlightColor(HighlightStandardColor.GreenHighlightColor, alpha=128))
block.function.set_auto_instr_highlight(addr, HighlightStandardColor.GreenHighlightColor)
# Add the instruction to the list associated with the current view
@@ -126,7 +125,7 @@ def avoid_instr(bv, addr):
# Highlight the instruction in red
blocks = bv.get_basic_blocks_at(addr)
for block in blocks:
- block.set_auto_highlight(HighlightColor(HighlightStandardColor.RedHighlightColor, alpha = 128))
+ block.set_auto_highlight(HighlightColor(HighlightStandardColor.RedHighlightColor, alpha=128))
block.function.set_auto_instr_highlight(addr, HighlightStandardColor.RedHighlightColor)
# Add the instruction to the list associated with the current view
@@ -135,9 +134,11 @@ def avoid_instr(bv, addr):
def solve(bv):
if len(bv.session_data.angr_find) == 0:
- show_message_box("Angr Solve", "You have not specified a goal instruction.\n\n" +
- "Please right click on the goal instruction and select \"Find Path to This Instruction\" to " +
- "continue.", MessageBoxButtonSet.OKButtonSet, MessageBoxIcon.ErrorIcon)
+ show_message_box(
+ "Angr Solve", "You have not specified a goal instruction.\n\n"
+ + "Please right click on the goal instruction and select \"Find Path to This Instruction\" to " + "continue.",
+ MessageBoxButtonSet.OKButtonSet, MessageBoxIcon.ErrorIcon
+ )
return
# Start a solver thread for the path associated with the view
@@ -146,8 +147,10 @@ def solve(bv):
# Register commands for the user to interact with the plugin
-PluginCommand.register_for_address("Find Path to This Instruction",
- "When solving, find a path that gets to this instruction", find_instr)
-PluginCommand.register_for_address("Avoid This Instruction",
- "When solving, avoid paths that reach this instruction", avoid_instr)
+PluginCommand.register_for_address(
+ "Find Path to This Instruction", "When solving, find a path that gets to this instruction", find_instr
+)
+PluginCommand.register_for_address(
+ "Avoid This Instruction", "When solving, avoid paths that reach this instruction", avoid_instr
+)
PluginCommand.register("Solve With Angr", "Attempt to solve for a path that satisfies the constraints given", solve)
diff --git a/python/examples/arch_hook.py b/python/examples/arch_hook.py
index 452bd2b6..a6e280cc 100644
--- a/python/examples/arch_hook.py
+++ b/python/examples/arch_hook.py
@@ -1,16 +1,17 @@
from binaryninja.architecture import Architecture, ArchitectureHook
+
class X86ReturnHook(ArchitectureHook):
- def get_instruction_text(self, data, addr):
- # Call the original implementation's method by calling the superclass
- result, length = super(X86ReturnHook, self).get_instruction_text(data, addr)
+ def get_instruction_text(self, data, addr):
+ # Call the original implementation's method by calling the superclass
+ result, length = super(X86ReturnHook, self).get_instruction_text(data, addr)
+
+ # Patch the name of the 'retn' instruction to 'ret'
+ if len(result) > 0 and result[0].text == 'retn':
+ result[0].text = 'ret'
- # Patch the name of the 'retn' instruction to 'ret'
- if len(result) > 0 and result[0].text == 'retn':
- result[0].text = 'ret'
+ return result, length
- return result, length
# Install the hook by constructing it with the desired architecture to hook, then registering it
X86ReturnHook(Architecture['x86']).register()
-
diff --git a/python/examples/asm_to_llil_view.py b/python/examples/asm_to_llil_view.py
index 18c77547..3b7fb374 100644
--- a/python/examples/asm_to_llil_view.py
+++ b/python/examples/asm_to_llil_view.py
@@ -1,5 +1,5 @@
# Copyright (c) 2019-2022 Vector 35 Inc
-#
+#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
@@ -103,13 +103,18 @@ class DisassemblyAndLowLevelILGraph(FlowGraph):
for line in lines:
if line.il_instruction is None:
# For assembly lines, show address
- line.tokens.insert(0, InstructionTextToken(InstructionTextTokenType.AddressDisplayToken,
- "%.8x" % line.address, line.address))
+ line.tokens.insert(
+ 0, InstructionTextToken(InstructionTextTokenType.AddressDisplayToken, "%.8x" % line.address, line.address)
+ )
line.tokens.insert(1, InstructionTextToken(InstructionTextTokenType.TextToken, " "))
else:
# For IL lines, show IL instruction index
- line.tokens.insert(0, InstructionTextToken(InstructionTextTokenType.AnnotationToken,
- "%8s" % ("[%d]" % line.il_instruction.instr_index)))
+ line.tokens.insert(
+ 0,
+ InstructionTextToken(
+ InstructionTextTokenType.AnnotationToken, "%8s" % ("[%d]" % line.il_instruction.instr_index)
+ )
+ )
line.tokens.insert(1, InstructionTextToken(InstructionTextTokenType.AnnotationToken, " => "))
nodes[block.start].lines = lines
diff --git a/python/examples/breakpoint.py b/python/examples/breakpoint.py
index ab2ccfa5..20ff2b6b 100644
--- a/python/examples/breakpoint.py
+++ b/python/examples/breakpoint.py
@@ -18,7 +18,6 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
-
from binaryninja.plugin import PluginCommand
from binaryninja.log import log_error
@@ -29,12 +28,7 @@ def write_breakpoint(view, start, length):
register_for_address
register_for_function
"""
- bkpt_str = {
- "x86": "int3",
- "x86_64": "int3",
- "armv7": "bkpt",
- "aarch64": "brk #0",
- "mips32": "break"}
+ bkpt_str = {"x86": "int3", "x86_64": "int3", "armv7": "bkpt", "aarch64": "brk #0", "mips32": "break"}
if view.arch.name not in bkpt_str:
log_error("Architecture %s not supported" % view.arch.name)
diff --git a/python/examples/cli_dis.py b/python/examples/cli_dis.py
index 8f863db3..cbd4b8f1 100755
--- a/python/examples/cli_dis.py
+++ b/python/examples/cli_dis.py
@@ -55,12 +55,12 @@ archName = sys.argv[1]
bytesList = sys.argv[2:]
# parse byte arguments
-data = b''.join(list(map(lambda x: int(x,16).to_bytes(1,'big'), bytesList)))
+data = b''.join(list(map(lambda x: int(x, 16).to_bytes(1, 'big'), bytesList)))
# disassemble
arch = binaryninja.Architecture[archName]
toksAndLen = arch.get_instruction_text(data, 0)
-if not toksAndLen or toksAndLen[1]==0:
+if not toksAndLen or toksAndLen[1] == 0:
print('disassembly failed')
sys.exit(-1)
@@ -68,4 +68,3 @@ if not toksAndLen or toksAndLen[1]==0:
toks = toksAndLen[0]
strs = map(lambda x: x.text, toks)
print(GREEN, ''.join(strs), NORMAL)
-
diff --git a/python/examples/cli_lift.py b/python/examples/cli_lift.py
index b335a5e4..946f8c3a 100755
--- a/python/examples/cli_lift.py
+++ b/python/examples/cli_lift.py
@@ -34,16 +34,18 @@ from binaryninja import lowlevelil
RED = '\x1B[31m'
NORMAL = '\x1B[0m'
+
def traverse_IL(il, indent):
if isinstance(il, lowlevelil.LowLevelILInstruction):
print('\t'*indent + il.operation.name)
for o in il.operands:
- traverse_IL(o, indent+1)
+ traverse_IL(o, indent + 1)
else:
print('\t'*indent + str(il))
+
if __name__ == '__main__':
if not sys.argv[2:]:
@@ -63,7 +65,7 @@ if __name__ == '__main__':
bytesList = sys.argv[2:]
# parse byte arguments
- data = b''.join(list(map(lambda x: int(x,16).to_bytes(1,'big'), bytesList)))
+ data = b''.join(list(map(lambda x: int(x, 16).to_bytes(1, 'big'), bytesList)))
plat = binaryninja.Platform[platName]
bv = binaryview.BinaryView.new(data)
@@ -71,13 +73,13 @@ if __name__ == '__main__':
bv.add_function(0, plat=plat)
-# print('print all the functions, their basic blocks, and their mc instructions')
-# for func in bv.functions:
-# print(repr(func))
-# for block in func:
-# print("\t{0}".format(block))
-# for insn in block:
-# print("\t\t{0}".format(insn))
+ # print('print all the functions, their basic blocks, and their mc instructions')
+ # for func in bv.functions:
+ # print(repr(func))
+ # for block in func:
+ # print("\t{0}".format(block))
+ # for insn in block:
+ # print("\t\t{0}".format(insn))
print(RED)
for func in bv.functions:
@@ -87,4 +89,3 @@ if __name__ == '__main__':
for insn in block:
traverse_IL(insn, 0)
print(NORMAL)
-
diff --git a/python/examples/debug_info.py b/python/examples/debug_info.py
index 8f379544..28175ba1 100755
--- a/python/examples/debug_info.py
+++ b/python/examples/debug_info.py
@@ -29,7 +29,6 @@
# bv.apply_debug_info(debug_info)
# ```
-
# The rest of this file serves as a test and example of implementing debug info parsers, and the resultant debug info.
#
# All that is required is to provide functions similar to "is_valid" and "parse_info" below, and call
@@ -98,50 +97,56 @@
# }
# ```
-
import binaryninja as bn
import os
-
filename = os.path.join(os.path.dirname(os.path.abspath(__file__)), "test_debug_info")
-
# Some setup code not just for informative printing
-
print = print
if __name__ != "__main__":
- print = bn.log_error
+ print = bn.log_error
-def pretty_print_add_data_variable(debug_info: bn.debuginfo.DebugInfo, address: int, t: bn.types.Type, name: str = None) -> None:
- print(f" Adding data variable of type `{t}` at {hex(address)} : {debug_info.add_data_variable(address, t, name)}")
+def pretty_print_add_data_variable(
+ debug_info: bn.debuginfo.DebugInfo, address: int, t: bn.types.Type, name: str = None
+) -> None:
+ print(f" Adding data variable of type `{t}` at {hex(address)} : {debug_info.add_data_variable(address, t, name)}")
-def pretty_print_add_function(debug_info: bn.debuginfo.DebugInfo, address: int, short_name: str = None, full_name: str = None, raw_name: str = None, return_type = None, parameters = None) -> None:
- function_info = bn.debuginfo.DebugFunctionInfo(address, short_name, full_name, raw_name, return_type, parameters)
- if parameters is not None:
- print(f" Adding function `{return_type} {short_name}({', '.join(f'{t} {name}' for name, t in parameters)})` at {hex(address)} : {debug_info.add_function(function_info)}")
- else:
- print(f" Adding function `{return_type} {short_name}()` at {hex(address)} : {debug_info.add_function(function_info)}")
+def pretty_print_add_function(
+ debug_info: bn.debuginfo.DebugInfo, address: int, short_name: str = None, full_name: str = None, raw_name: str = None,
+ return_type=None, parameters=None
+) -> None:
+ function_info = bn.debuginfo.DebugFunctionInfo(address, short_name, full_name, raw_name, return_type, parameters)
+ if parameters is not None:
+ print(
+ f" Adding function `{return_type} {short_name}({', '.join(f'{t} {name}' for name, t in parameters)})` at {hex(address)} : {debug_info.add_function(function_info)}"
+ )
+ else:
+ print(
+ f" Adding function `{return_type} {short_name}()` at {hex(address)} : {debug_info.add_function(function_info)}"
+ )
# The beginning of the actual debug info plugin
def is_valid(bv: bn.binaryview.BinaryView):
- sym = bv.get_symbol_by_raw_name("__elf_interp")
- if sym is None:
- return False
- else:
- var = bv.get_data_var_at(sym.address)
- return b"test_debug_info_parsing" == bv.read(sym.address, var.type.width-1)
+ sym = bv.get_symbol_by_raw_name("__elf_interp")
+ if sym is None:
+ return False
+ else:
+ var = bv.get_data_var_at(sym.address)
+ return b"test_debug_info_parsing" == bv.read(sym.address, var.type.width - 1)
def parse_info(debug_info: bn.debuginfo.DebugInfo, bv: bn.binaryview.BinaryView):
- print("Adding types")
- types = []
- for name, t in bv.parse_types_from_string("""
+ print("Adding types")
+ types = []
+ for name, t in bv.parse_types_from_string(
+ """
struct test_type_1 {
int a;
char b[4];
@@ -153,62 +158,81 @@ def parse_info(debug_info: bn.debuginfo.DebugInfo, bv: bn.binaryview.BinaryView)
struct test_type_1 a;
struct test_type_1* b;
struct test_type_2* c;
- };""").types.items():
- print(f" Adding type \"{name}\" `{t}` : {debug_info.add_type(str(name), t)}")
- types.append(t)
+ };"""
+ ).types.items():
+ print(f" Adding type \"{name}\" `{t}` : {debug_info.add_type(str(name), t)}")
+ types.append(t)
- print("Adding data variables")
- pretty_print_add_data_variable(debug_info, 0x4030, types[0], "test_var_1")
- pretty_print_add_data_variable(debug_info, 0x4010, bn.types.Type.int(4, True), "test_var_2")
- # Names are optional
- pretty_print_add_data_variable(debug_info, 0x4014, bn.types.Type.int(4, True))
+ print("Adding data variables")
+ pretty_print_add_data_variable(debug_info, 0x4030, types[0], "test_var_1")
+ pretty_print_add_data_variable(debug_info, 0x4010, bn.types.Type.int(4, True), "test_var_2")
+ # Names are optional
+ pretty_print_add_data_variable(debug_info, 0x4014, bn.types.Type.int(4, True))
- t = bn.types.Type.int(4, True)
- t.const = True
- pretty_print_add_data_variable(debug_info, 0x2004, t, "test_var_3")
+ t = bn.types.Type.int(4, True)
+ t.const = True
+ pretty_print_add_data_variable(debug_info, 0x2004, t, "test_var_3")
- print("Adding functions")
- char_star = bv.parse_type_string("char*")[0]
- pretty_print_add_function(debug_info, 0x1129, "no_return_type_no_parameters", None, None, bn.types.Type.void(), None)
- pretty_print_add_function(debug_info, 0x1134, "used_parameter", None, None, bn.types.Type.bool(), [("value", bn.types.Type.bool())])
- pretty_print_add_function(debug_info, 0x1155, "unused_parameters", None, None, bn.types.Type.int(4, True), [("value_1", bn.types.Type.bool()), ("value_2", bn.types.Type.int(4, True)), ("value_3", char_star)])
- pretty_print_add_function(debug_info, 0x1170, "used_and_unused_parameters_1", None, None, bn.types.Type.int(4, True), [("value_1", bn.types.Type.int(4, True)), ("value_2", bn.types.Type.int(4, True)), ("value_3", char_star), ("value_4", bn.types.Type.bool())])
- pretty_print_add_function(debug_info, 0x1191, "used_and_unused_parameters_2", None, None, bn.types.Type.int(1, False), [("value_1", bn.types.Type.bool()), ("value_2", bn.types.Type.int(1, False)), ("value_3", char_star), ("value_4", bn.types.Type.int(1, False)), ("value_5", bn.types.Type.char())])
- pretty_print_add_function(debug_info, 0x11c0, "local_parameters", None, None, bn.types.Type.void(), [("value_1", bn.types.Type.bool()), ("value_2", bn.types.Type.int(1, False)), ("value_3", char_star), ("value_4", bn.types.Type.int(1, False)), ("value_5", bn.types.Type.char())])
+ print("Adding functions")
+ char_star = bv.parse_type_string("char*")[0]
+ pretty_print_add_function(debug_info, 0x1129, "no_return_type_no_parameters", None, None, bn.types.Type.void(), None)
+ pretty_print_add_function(
+ debug_info, 0x1134, "used_parameter", None, None, bn.types.Type.bool(), [("value", bn.types.Type.bool())]
+ )
+ pretty_print_add_function(
+ debug_info, 0x1155, "unused_parameters", None, None, bn.types.Type.int(4, True),
+ [("value_1", bn.types.Type.bool()), ("value_2", bn.types.Type.int(4, True)), ("value_3", char_star)]
+ )
+ pretty_print_add_function(
+ debug_info, 0x1170, "used_and_unused_parameters_1", None, None, bn.types.Type.int(4, True),
+ [("value_1", bn.types.Type.int(4, True)), ("value_2", bn.types.Type.int(4, True)), ("value_3", char_star),
+ ("value_4", bn.types.Type.bool())]
+ )
+ pretty_print_add_function(
+ debug_info, 0x1191, "used_and_unused_parameters_2", None, None, bn.types.Type.int(1, False),
+ [("value_1", bn.types.Type.bool()), ("value_2", bn.types.Type.int(1, False)), ("value_3", char_star),
+ ("value_4", bn.types.Type.int(1, False)), ("value_5", bn.types.Type.char())]
+ )
+ pretty_print_add_function(
+ debug_info, 0x11c0, "local_parameters", None, None, bn.types.Type.void(), [("value_1", bn.types.Type.bool()),
+ ("value_2", bn.types.Type.int(1, False)),
+ ("value_3", char_star),
+ ("value_4", bn.types.Type.int(1, False)),
+ ("value_5", bn.types.Type.char())]
+ )
parser = bn.debuginfo.DebugInfoParser.register("test debug info parser", is_valid, parse_info)
print(f"Registered parser: {parser.name}")
-
# The above is all that is needed for a DebugInfo plugin
# The below serves to test the correctness of (the Python bindings' implementation of) debug info parsers' functionality.
-
bn.debuginfo.DebugInfoParser.register("dummy extra debug parser 1", lambda bv: False, lambda di, bv: None)
-bn.debuginfo.DebugInfoParser.register("dummy extra debug parser 2", lambda bv: bv.view_type != "Raw", lambda di, bv: None)
+bn.debuginfo.DebugInfoParser.register(
+ "dummy extra debug parser 2", lambda bv: bv.view_type != "Raw", lambda di, bv: None
+)
# Test fetching parser list and fetching by name
print(f"Availible parsers: {len(list(bn.debuginfo.DebugInfoParser))}")
for p in bn.debuginfo.DebugInfoParser:
- if p == parser:
- print(f" {bn.debuginfo.DebugInfoParser[p.name].name} (the one we just registered)")
- else:
- print(f" {bn.debuginfo.DebugInfoParser[p.name].name}")
+ if p == parser:
+ print(f" {bn.debuginfo.DebugInfoParser[p.name].name} (the one we just registered)")
+ else:
+ print(f" {bn.debuginfo.DebugInfoParser[p.name].name}")
# Test calling our `is_valid` callback
bv = bn.open_view(filename, options={"analysis.experimental.parseDebugInfo": False})
if parser.is_valid_for_view(bv):
- print("Parser is valid")
+ print("Parser is valid")
else:
- print("Parser is NOT valid!")
- quit()
-
+ print("Parser is NOT valid!")
+ quit()
# Test getting list of valid parsers, and DebugInfoParser's repr
print("")
for p in bn.debuginfo.DebugInfoParser.get_parsers_for_view(bv):
- print(f"`{p.name}` is valid for `{bv}`")
+ print(f"`{p.name}` is valid for `{bv}`")
print("")
# Test calling our `parse_info` callback
@@ -219,32 +243,31 @@ print("\nEach of the following pairs of prints should be the same\n")
print("All types:")
for name, t in debug_info.types:
- print(f" \"{name}\": `{t}`")
+ print(f" \"{name}\": `{t}`")
print("Types from parser:")
for name, t in debug_info.types_from_parser(parser.name):
- print(f" \"{name}\": `{t}`")
+ print(f" \"{name}\": `{t}`")
print("")
print("All functions:")
for func in debug_info.functions:
- print(f" {func}")
+ print(f" {func}")
print("Functions from parser:")
for func in debug_info.functions_from_parser(parser.name):
- print(f" {func}")
+ print(f" {func}")
print("")
print("All data variables:")
for data_var in debug_info.data_variables:
- print(f" {data_var}")
+ print(f" {data_var}")
print("Data variables from parser:")
for data_var in debug_info.data_variables_from_parser(parser.name):
- print(f" {data_var}")
-
+ print(f" {data_var}")
print("Appling debug info!")
bv.apply_debug_info(debug_info)
@@ -254,16 +277,16 @@ bv.update_analysis_and_wait()
print("")
print("Types:")
for name, t in debug_info.types:
- print(f" {bv.get_type_by_name(name)}")
+ print(f" {bv.get_type_by_name(name)}")
print("")
print("Functions:")
for func in debug_info.functions:
- print(f" {bv.get_function_at(func.address)}")
+ print(f" {bv.get_function_at(func.address)}")
print("")
print("Data variables:")
for data_var in debug_info.data_variables:
- print(f" {bv.get_data_var_at(data_var.address)}")
+ print(f" {bv.get_data_var_at(data_var.address)}")
diff --git a/python/examples/export_svg.py b/python/examples/export_svg.py
index c96873e1..8166b27a 100755
--- a/python/examples/export_svg.py
+++ b/python/examples/export_svg.py
@@ -12,119 +12,126 @@ from binaryninja.enums import MessageBoxButtonSet, MessageBoxIcon, MessageBoxBut
from binaryninja.function import DisassemblySettings
from binaryninja.plugin import PluginCommand
-colors = {'green': [162, 217, 175], 'red': [222, 143, 151], 'blue': [128, 198, 233], 'cyan': [142, 230, 237], 'lightCyan': [
- 176, 221, 228], 'orange': [237, 189, 129], 'yellow': [237, 223, 179], 'magenta': [218, 196, 209], 'none': [74, 74, 74],
- 'disabled': [144, 144, 144]}
-
-escape_table = {
- "'": "&#39;",
- ">": "&#62;",
- "<": "&#60;",
- '"': "&#34;",
- ' ': "&#160;"
+colors = {
+ 'green': [162, 217, 175], 'red': [222, 143, 151], 'blue': [128, 198, 233], 'cyan': [142, 230, 237],
+ 'lightCyan': [176, 221, 228], 'orange': [237, 189, 129], 'yellow': [237, 223, 179], 'magenta': [218, 196, 209],
+ 'none': [74, 74, 74], 'disabled': [144, 144, 144]
}
+escape_table = {"'": "&#39;", ">": "&#62;", "<": "&#60;", '"': "&#34;", ' ': "&#160;"}
+
def escape(toescape):
- # handle extended unicode
- toescape = toescape.encode('ascii', 'xmlcharrefreplace')
- # still escape the basics
- if sys.version_info[0] == 3:
- return ''.join(escape_table.get(chr(i), chr(i)) for i in toescape)
- else:
- return ''.join(escape_table.get(i, i) for i in toescape)
+ # handle extended unicode
+ toescape = toescape.encode('ascii', 'xmlcharrefreplace')
+ # still escape the basics
+ if sys.version_info[0] == 3:
+ return ''.join(escape_table.get(chr(i), chr(i)) for i in toescape)
+ else:
+ return ''.join(escape_table.get(i, i) for i in toescape)
def save_svg(bv, function):
- sym = bv.get_symbol_at(function.start)
- if sym:
- offset = sym.name
- else:
- offset = "%x" % function.start
- path = Path(os.path.dirname(bv.file.filename))
- origname = os.path.basename(bv.file.filename)
- filename = path / f'binaryninja-{origname}-{offset}.html'
+ sym = bv.get_symbol_at(function.start)
+ if sym:
+ offset = sym.name
+ else:
+ offset = "%x" % function.start
+ path = Path(os.path.dirname(bv.file.filename))
+ origname = os.path.basename(bv.file.filename)
+ filename = path / f'binaryninja-{origname}-{offset}.html'
- functionChoice = TextLineField("Blank to accept default")
- # TODO: implement linear disassembly settings and output
- modeChoices = ["Graph"]
- modeChoiceField = ChoiceField("Mode", modeChoices)
- if Settings().get_bool('ui.debugMode'):
- formChoices = ["Assembly", "Lifted IL", "LLIL", "LLIL SSA", "Mapped Medium", "Mapped Medium SSA", "MLIL", "MLIL SSA", "HLIL", "HLIL SSA"]
- formChoiceField = ChoiceField("Form", formChoices)
- else:
- formChoices = ["Assembly", "LLIL", "MLIL", "HLIL"]
- formChoiceField = ChoiceField("Form", formChoices)
+ functionChoice = TextLineField("Blank to accept default")
+ # TODO: implement linear disassembly settings and output
+ modeChoices = ["Graph"]
+ modeChoiceField = ChoiceField("Mode", modeChoices)
+ if Settings().get_bool('ui.debugMode'):
+ formChoices = [
+ "Assembly", "Lifted IL", "LLIL", "LLIL SSA", "Mapped Medium", "Mapped Medium SSA", "MLIL", "MLIL SSA", "HLIL",
+ "HLIL SSA"
+ ]
+ formChoiceField = ChoiceField("Form", formChoices)
+ else:
+ formChoices = ["Assembly", "LLIL", "MLIL", "HLIL"]
+ formChoiceField = ChoiceField("Form", formChoices)
- showOpcodes = ChoiceField("Show Opcodes", ["Yes", "No"])
- showAddresses = ChoiceField("Show Addresses", ["Yes", "No"])
+ showOpcodes = ChoiceField("Show Opcodes", ["Yes", "No"])
+ showAddresses = ChoiceField("Show Addresses", ["Yes", "No"])
- saveFileChoices = SaveFileNameField("Output file", 'HTML files (*.html)', str(filename))
- if not get_form_input([f'Current Function: {offset}', functionChoice, formChoiceField, modeChoiceField, showOpcodes, showAddresses, saveFileChoices], "SVG Export") or saveFileChoices.result is None:
- return
- if saveFileChoices.result == '':
- outputfile = filename
- else:
- outputfile = saveFileChoices.result
- content = render_svg(function, offset, modeChoices[modeChoiceField.result], formChoices[formChoiceField.result], showOpcodes.result == 0, showAddresses.result == 0, origname)
- output = open(outputfile, 'w')
- output.write(content)
- output.close()
- result = show_message_box("Open SVG", "Would you like to view the exported SVG?",
- buttons=MessageBoxButtonSet.YesNoButtonSet, icon=MessageBoxIcon.QuestionIcon)
- if result == MessageBoxButtonResult.YesButton:
- # might need more testing, latest py3 on windows seems.... broken with these APIs relative to other platforms
- if sys.platform == 'win32':
- webbrowser.open(outputfile)
- else:
- webbrowser.open('file://' + str(outputfile))
+ saveFileChoices = SaveFileNameField("Output file", 'HTML files (*.html)', str(filename))
+ if not get_form_input([
+ f'Current Function: {offset}', functionChoice, formChoiceField, modeChoiceField, showOpcodes, showAddresses,
+ saveFileChoices
+ ], "SVG Export") or saveFileChoices.result is None:
+ return
+ if saveFileChoices.result == '':
+ outputfile = filename
+ else:
+ outputfile = saveFileChoices.result
+ content = render_svg(
+ function, offset, modeChoices[modeChoiceField.result], formChoices[formChoiceField.result], showOpcodes.result == 0,
+ showAddresses.result == 0, origname
+ )
+ output = open(outputfile, 'w')
+ output.write(content)
+ output.close()
+ result = show_message_box(
+ "Open SVG", "Would you like to view the exported SVG?", buttons=MessageBoxButtonSet.YesNoButtonSet,
+ icon=MessageBoxIcon.QuestionIcon
+ )
+ if result == MessageBoxButtonResult.YesButton:
+ # might need more testing, latest py3 on windows seems.... broken with these APIs relative to other platforms
+ if sys.platform == 'win32':
+ webbrowser.open(outputfile)
+ else:
+ webbrowser.open('file://' + str(outputfile))
def instruction_data_flow(function, address):
- # TODO: Extract data flow information
- length = function.view.get_instruction_length(address)
- func_bytes = function.view.read(address, length)
- if sys.version_info[0] == 3:
- hex = func_bytes.hex()
- else:
- hex = func_bytes.encode('hex')
- padded = ' '.join([hex[i:i + 2] for i in range(0, len(hex), 2)])
- return 'Opcode: {bytes}'.format(bytes=padded)
+ # TODO: Extract data flow information
+ length = function.view.get_instruction_length(address)
+ func_bytes = function.view.read(address, length)
+ if sys.version_info[0] == 3:
+ hex = func_bytes.hex()
+ else:
+ hex = func_bytes.encode('hex')
+ padded = ' '.join([hex[i:i + 2] for i in range(0, len(hex), 2)])
+ return 'Opcode: {bytes}'.format(bytes=padded)
def render_svg(function, offset, mode, form, showOpcodes, showAddresses, origname):
- settings = DisassemblySettings()
- if showOpcodes:
- settings.set_option(DisassemblyOption.ShowOpcode, True)
- if showAddresses:
- settings.set_option(DisassemblyOption.ShowAddress, True)
- if form == "LLIL":
- graph_type = FunctionGraphType.LowLevelILFunctionGraph
- elif form == "LLIL SSA":
- graph_type = FunctionGraphType.LowLevelILSSAFormFunctionGraph
- elif form == "Lifted IL":
- graph_type = FunctionGraphType.LiftedILFunctionGraph
- elif form == "Mapped Medium":
- graph_type = FunctionGraphType.MappedMediumLevelILFunctionGraph
- elif form == "Mapped Medium SSA":
- graph_type = FunctionGraphType.MappedMediumLevelILSSAFormFunctionGraph
- elif form == "MLIL":
- graph_type = FunctionGraphType.MediumLevelILFunctionGraph
- elif form == "MLIL SSA":
- graph_type = FunctionGraphType.MediumLevelILSSAFormFunctionGraph
- elif form == "HLIL":
- graph_type = FunctionGraphType.HighLevelILFunctionGraph
- elif form == "HLIL SSA":
- graph_type = FunctionGraphType.HighLevelILSSAFormFunctionGraph
- else:
- graph_type = FunctionGraphType.NormalFunctionGraph
- graph = function.create_graph(graph_type=graph_type, settings=settings)
- graph.layout_and_wait()
- heightconst = 15
- ratio = 0.48
- widthconst = heightconst * ratio
+ settings = DisassemblySettings()
+ if showOpcodes:
+ settings.set_option(DisassemblyOption.ShowOpcode, True)
+ if showAddresses:
+ settings.set_option(DisassemblyOption.ShowAddress, True)
+ if form == "LLIL":
+ graph_type = FunctionGraphType.LowLevelILFunctionGraph
+ elif form == "LLIL SSA":
+ graph_type = FunctionGraphType.LowLevelILSSAFormFunctionGraph
+ elif form == "Lifted IL":
+ graph_type = FunctionGraphType.LiftedILFunctionGraph
+ elif form == "Mapped Medium":
+ graph_type = FunctionGraphType.MappedMediumLevelILFunctionGraph
+ elif form == "Mapped Medium SSA":
+ graph_type = FunctionGraphType.MappedMediumLevelILSSAFormFunctionGraph
+ elif form == "MLIL":
+ graph_type = FunctionGraphType.MediumLevelILFunctionGraph
+ elif form == "MLIL SSA":
+ graph_type = FunctionGraphType.MediumLevelILSSAFormFunctionGraph
+ elif form == "HLIL":
+ graph_type = FunctionGraphType.HighLevelILFunctionGraph
+ elif form == "HLIL SSA":
+ graph_type = FunctionGraphType.HighLevelILSSAFormFunctionGraph
+ else:
+ graph_type = FunctionGraphType.NormalFunctionGraph
+ graph = function.create_graph(graph_type=graph_type, settings=settings)
+ graph.layout_and_wait()
+ heightconst = 15
+ ratio = 0.48
+ widthconst = heightconst * ratio
- output = '''<html>
+ output = '''<html>
<head>
<style type="text/css">
@import url(https://fonts.googleapis.com/css?family=Source+Code+Pro);
@@ -205,7 +212,7 @@ def render_svg(function, offset, mode, form, showOpcodes, showAddresses, orignam
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
</head>
'''
- output += '''<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="{width}" height="{height}">
+ output += '''<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="{width}" height="{height}">
<defs>
<marker id="arrow-TrueBranch" class="arrow TrueBranch" viewBox="0 0 10 10" refX="10" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto">
<path d="M 0 0 L 10 5 L 0 10 z" />
@@ -221,83 +228,87 @@ def render_svg(function, offset, mode, form, showOpcodes, showAddresses, orignam
</marker>
</defs>
'''.format(width=graph.width * widthconst + 20, height=graph.height * heightconst + 20)
- output += ''' <g id="functiongraph0" class="functiongraph">
+ output += ''' <g id="functiongraph0" class="functiongraph">
<title>Function Graph 0</title>
'''
- edges = ''
- for i, block in enumerate(graph):
+ edges = ''
+ for i, block in enumerate(graph):
- # Calculate basic block location and coordinates
- x = ((block.x) * widthconst)
- y = ((block.y) * heightconst)
- width = ((block.width) * widthconst)
- height = ((block.height) * heightconst)
+ # Calculate basic block location and coordinates
+ x = ((block.x) * widthconst)
+ y = ((block.y) * heightconst)
+ width = ((block.width) * widthconst)
+ height = ((block.height) * heightconst)
- # Render block
- output += ' <g id="basicblock{i}">\n'.format(i=i)
- output += ' <title>Basic Block {i}</title>\n'.format(i=i)
- rgb = colors['none']
- try:
- bb = block.basic_block
- if hasattr(bb.highlight, 'color'):
- color_code = bb.highlight.color
- color_str = bb.highlight._standard_color_to_str(color_code)
- if color_str in colors:
- rgb = colors[color_str]
- else:
- rgb = [bb.highlight.red, bb.highlight.green, bb.highlight.blue]
- except:
- pass
- output += ' <rect class="basicblock" x="{x}" y="{y}" fill-opacity="0.4" height="{height}" width="{width}" fill="rgb({r},{g},{b})"/>\n'.format(
- x=x, y=y, width=width + 16, height=height + 12, r=rgb[0], g=rgb[1], b=rgb[2])
+ # Render block
+ output += ' <g id="basicblock{i}">\n'.format(i=i)
+ output += ' <title>Basic Block {i}</title>\n'.format(i=i)
+ rgb = colors['none']
+ try:
+ bb = block.basic_block
+ if hasattr(bb.highlight, 'color'):
+ color_code = bb.highlight.color
+ color_str = bb.highlight._standard_color_to_str(color_code)
+ if color_str in colors:
+ rgb = colors[color_str]
+ else:
+ rgb = [bb.highlight.red, bb.highlight.green, bb.highlight.blue]
+ except:
+ pass
+ output += ' <rect class="basicblock" x="{x}" y="{y}" fill-opacity="0.4" height="{height}" width="{width}" fill="rgb({r},{g},{b})"/>\n'.format(
+ x=x, y=y, width=width + 16, height=height + 12, r=rgb[0], g=rgb[1], b=rgb[2]
+ )
- # Render instructions, unfortunately tspans don't allow copying/pasting more
- # than one line at a time, need SVG 1.2 textarea tags for that it looks like
+ # Render instructions, unfortunately tspans don't allow copying/pasting more
+ # than one line at a time, need SVG 1.2 textarea tags for that it looks like
- output += ' <text x="{x}" y="{y}">\n'.format(
- x=x, y=y + (i + 1) * heightconst)
- for i, line in enumerate(block.lines):
- output += ' <tspan id="instr-{address}" x="{x}" y="{y}">'.format(
- x=x + 6, y=y + 6 + (i + 0.7) * heightconst, address=hex(line.address)[:-1])
- hover = instruction_data_flow(function, line.address)
- output += '<title>{hover}</title>'.format(hover=hover)
- for token in line.tokens:
- # TODO: add hover for hex, function, and reg tokens
- output += '<tspan class="{tokentype}">{text}</tspan>'.format(
- text=escape(token.text), tokentype=InstructionTextTokenType(token.type).name)
- output += '</tspan>\n'
- output += ' </text>\n'
- output += ' </g>\n'
+ output += ' <text x="{x}" y="{y}">\n'.format(x=x, y=y + (i+1) * heightconst)
+ for i, line in enumerate(block.lines):
+ output += ' <tspan id="instr-{address}" x="{x}" y="{y}">'.format(
+ x=x + 6, y=y + 6 + (i+0.7) * heightconst, address=hex(line.address)[:-1]
+ )
+ hover = instruction_data_flow(function, line.address)
+ output += '<title>{hover}</title>'.format(hover=hover)
+ for token in line.tokens:
+ # TODO: add hover for hex, function, and reg tokens
+ output += '<tspan class="{tokentype}">{text}</tspan>'.format(
+ text=escape(token.text), tokentype=InstructionTextTokenType(token.type).name
+ )
+ output += '</tspan>\n'
+ output += ' </text>\n'
+ output += ' </g>\n'
- # Edges are rendered in a seperate chunk so they have priority over the
- # basic blocks or else they'd render below them
+ # Edges are rendered in a seperate chunk so they have priority over the
+ # basic blocks or else they'd render below them
- for edge in block.outgoing_edges:
- points = ""
- x, y = edge.points[0]
- points += str(x * widthconst) + "," + \
- str(y * heightconst + 12) + " "
- for x, y in edge.points[1:-1]:
- points += str(x * widthconst) + "," + \
- str(y * heightconst) + " "
- x, y = edge.points[-1]
- points += str(x * widthconst) + "," + \
- str(y * heightconst + 0) + " "
- if edge.back_edge:
- edges += ' <polyline class="back_edge {type}" points="{points}" marker-end="url(#arrow-{type})"/>\n'.format(
- type=BranchType(edge.type).name, points=points)
- else:
- edges += ' <polyline class="edge {type}" points="{points}" marker-end="url(#arrow-{type})"/>\n'.format(
- type=BranchType(edge.type).name, points=points)
- output += ' ' + edges + '\n'
- output += ' </g>\n'
- output += '</svg>'
+ for edge in block.outgoing_edges:
+ points = ""
+ x, y = edge.points[0]
+ points += str(x * widthconst) + "," + \
+ str(y * heightconst + 12) + " "
+ for x, y in edge.points[1:-1]:
+ points += str(x * widthconst) + "," + \
+ str(y * heightconst) + " "
+ x, y = edge.points[-1]
+ points += str(x * widthconst) + "," + \
+ str(y * heightconst + 0) + " "
+ if edge.back_edge:
+ edges += ' <polyline class="back_edge {type}" points="{points}" marker-end="url(#arrow-{type})"/>\n'.format(
+ type=BranchType(edge.type).name, points=points
+ )
+ else:
+ edges += ' <polyline class="edge {type}" points="{points}" marker-end="url(#arrow-{type})"/>\n'.format(
+ type=BranchType(edge.type).name, points=points
+ )
+ output += ' ' + edges + '\n'
+ output += ' </g>\n'
+ output += '</svg>'
- output += '<p>This CFG generated by <a href="https://binary.ninja/">Binary Ninja</a> from {filename} on {timestring} showing {function} as {form}.</p>'.format(
- filename=origname, timestring=time.strftime("%c"), function=offset, form=form)
- output += '</html>'
- return output
+ output += '<p>This CFG generated by <a href="https://binary.ninja/">Binary Ninja</a> from {filename} on {timestring} showing {function} as {form}.</p>'.format(
+ filename=origname, timestring=time.strftime("%c"), function=offset, form=form
+ )
+ output += '</html>'
+ return output
-PluginCommand.register_for_function(
- "Export to SVG", "Exports an SVG of the current function", save_svg)
+PluginCommand.register_for_function("Export to SVG", "Exports an SVG of the current function", save_svg)
diff --git a/python/examples/helloglobalarea.py b/python/examples/helloglobalarea.py
index d4b1b5ed..b0ac8ede 100644
--- a/python/examples/helloglobalarea.py
+++ b/python/examples/helloglobalarea.py
@@ -29,6 +29,7 @@ from PySide6.QtGui import QImage, QPixmap, QPainter, QFont, QColor
instance_id = 0
+
# Global area widgets must derive from GlobalAreaWidget, not QWidget. GlobalAreaWidget is a QWidget but
# provides callbacks for global area events, and must be created with a title.
class HelloGlobalAreaWidget(GlobalAreaWidget):
@@ -77,6 +78,7 @@ class HelloGlobalAreaWidget(GlobalAreaWidget):
def contextMenuEvent(self, event):
self.m_contextMenuManager.show(self.m_menu, self.actionHandler)
+
# Register the global area widget constructor with Binary Ninja. This will create a new
# global area widget for each window. The callback function receives a `UIContext` object
# for identifying the window.
diff --git a/python/examples/hellopane.py b/python/examples/hellopane.py
index 2b9fbe29..06651a6f 100644
--- a/python/examples/hellopane.py
+++ b/python/examples/hellopane.py
@@ -29,6 +29,7 @@ from PySide6.QtGui import QImage, QPixmap, QPainter, QFont, QColor
instance_id = 0
+
# Class to handle UI context notifications. This will be used to listen for view and address
# changes and update the pane accordingly.
class HelloNotifications(UIContextNotification):
@@ -51,6 +52,7 @@ class HelloNotifications(UIContextNotification):
def OnAddressChange(self, context, frame, view, location):
self.widget.updateState()
+
# Pane widget itself. This can be any QWidget.
class HelloPaneWidget(QWidget, UIContextNotification):
def __init__(self, data):
@@ -120,6 +122,9 @@ class HelloPaneWidget(QWidget, UIContextNotification):
def canCreatePane(context):
return context.context and context.binaryView
+
UIAction.registerAction("Hello Pane")
-UIActionHandler.globalActions().bindAction("Hello Pane", UIAction(HelloPaneWidget.createPane, HelloPaneWidget.canCreatePane))
+UIActionHandler.globalActions().bindAction(
+ "Hello Pane", UIAction(HelloPaneWidget.createPane, HelloPaneWidget.canCreatePane)
+)
Menu.mainMenu("Tools").addAction("Hello Pane", "Hello")
diff --git a/python/examples/hellosidebar.py b/python/examples/hellosidebar.py
index fe7cbae2..69721d4c 100644
--- a/python/examples/hellosidebar.py
+++ b/python/examples/hellosidebar.py
@@ -29,6 +29,7 @@ from PySide6.QtGui import QImage, QPixmap, QPainter, QFont, QColor
instance_id = 0
+
# Sidebar widgets must derive from SidebarWidget, not QWidget. SidebarWidget is a QWidget but
# provides callbacks for sidebar events, and must be created with a title.
class HelloSidebarWidget(SidebarWidget):
@@ -77,6 +78,7 @@ class HelloSidebarWidget(SidebarWidget):
def contextMenuEvent(self, event):
self.m_contextMenuManager.show(self.m_menu, self.actionHandler)
+
class HelloSidebarWidgetType(SidebarWidgetType):
def __init__(self):
# Sidebar icons are 28x28 points. Should be at least 56x56 pixels for
@@ -102,6 +104,7 @@ class HelloSidebarWidgetType(SidebarWidgetType):
# widget is visible and the BinaryView becomes active.
return HelloSidebarWidget("Hello", frame, data)
+
# Register the sidebar widget type with Binary Ninja. This will make it appear as an icon in the
# sidebar and the `createWidget` method will be called when a widget is required.
Sidebar.addSidebarWidgetType(HelloSidebarWidgetType())
diff --git a/python/examples/instruction_iterator.py b/python/examples/instruction_iterator.py
index 9a5d864a..b5cf426f 100644
--- a/python/examples/instruction_iterator.py
+++ b/python/examples/instruction_iterator.py
@@ -32,7 +32,6 @@ binja.log_info("START: 0x%x" % bv.start)
binja.log_info("ENTRY: 0x%x" % bv.entry_point)
binja.log_info("ARCH: %s" % bv.arch.name)
binja.log_info("\n-------- Function List --------")
-
""" print all the functions, their basic blocks, and their il instructions """
for func in bv.functions:
binja.log_info(repr(func))
@@ -41,8 +40,6 @@ for func in bv.functions:
for insn in block:
binja.log_info("\t\t{0}".format(insn))
-
-
""" print all the functions, their basic blocks, and their mc instructions """
for func in bv.functions:
binja.log_info(repr(func))
diff --git a/python/examples/jump_table.py b/python/examples/jump_table.py
index 6ee60ce5..2132c950 100644
--- a/python/examples/jump_table.py
+++ b/python/examples/jump_table.py
@@ -50,13 +50,15 @@ def find_jump_table(bv, addr):
# Collect the branch targets for any tables referenced by the clicked instruction
branches = []
for token in tokens:
- if InstructionTextTokenType(token.type) == InstructionTextTokenType.PossibleAddressToken: # Table addresses will be a "possible address" token
+ if InstructionTextTokenType(
+ token.type
+ ) == InstructionTextTokenType.PossibleAddressToken: # Table addresses will be a "possible address" token
tbl = token.value
print("Found possible table at 0x%x" % tbl)
i = 0
while True:
# Read the next pointer from the table
- data = bv.read(tbl + (i * addrsize), addrsize)
+ data = bv.read(tbl + (i*addrsize), addrsize)
if len(data) == addrsize:
if addrsize == 4:
ptr = struct.unpack("<I", data)[0]
diff --git a/python/examples/linear_mlil.py b/python/examples/linear_mlil.py
index 9be79ad1..e4df1765 100644
--- a/python/examples/linear_mlil.py
+++ b/python/examples/linear_mlil.py
@@ -1,5 +1,5 @@
# Copyright (c) 2019-2022 Vector 35 Inc
-#
+#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
@@ -46,16 +46,28 @@ class LinearMLILView(TokenizedTextView):
# Sort basic blocks by IL instruction index
blocks = il.basic_blocks
- blocks.sort(key = lambda block: block.start)
+ blocks.sort(key=lambda block: block.start)
# Function header
result = []
- result.append(LinearDisassemblyLine(LinearDisassemblyLineType.FunctionHeaderStartLineType,
- self.function, None, DisassemblyTextLine([], self.function.start)))
- result.append(LinearDisassemblyLine(LinearDisassemblyLineType.FunctionHeaderLineType,
- self.function, None, DisassemblyTextLine(self.function.type_tokens, self.function.start)))
- result.append(LinearDisassemblyLine(LinearDisassemblyLineType.FunctionHeaderEndLineType,
- self.function, None, DisassemblyTextLine([], self.function.start)))
+ result.append(
+ LinearDisassemblyLine(
+ LinearDisassemblyLineType.FunctionHeaderStartLineType, self.function, None,
+ DisassemblyTextLine([], self.function.start)
+ )
+ )
+ result.append(
+ LinearDisassemblyLine(
+ LinearDisassemblyLineType.FunctionHeaderLineType, self.function, None,
+ DisassemblyTextLine(self.function.type_tokens, self.function.start)
+ )
+ )
+ result.append(
+ LinearDisassemblyLine(
+ LinearDisassemblyLineType.FunctionHeaderEndLineType, self.function, None,
+ DisassemblyTextLine([], self.function.start)
+ )
+ )
# Display IL instructions in order
lastAddr = self.function.start
@@ -64,20 +76,27 @@ class LinearMLILView(TokenizedTextView):
for block in il:
if lastBlock is not None:
# Blank line between basic blocks
- result.append(LinearDisassemblyLine(LinearDisassemblyLineType.CodeDisassemblyLineType,
- self.function, block, DisassemblyTextLine([], lastAddr)))
+ result.append(
+ LinearDisassemblyLine(
+ LinearDisassemblyLineType.CodeDisassemblyLineType, self.function, block, DisassemblyTextLine([], lastAddr)
+ )
+ )
for i in block:
lines, length = renderer.get_disassembly_text(i.instr_index)
lastAddr = i.address
lineIndex = 0
for line in lines:
- result.append(LinearDisassemblyLine(LinearDisassemblyLineType.CodeDisassemblyLineType,
- self.function, block, line))
+ result.append(
+ LinearDisassemblyLine(LinearDisassemblyLineType.CodeDisassemblyLineType, self.function, block, line)
+ )
lineIndex += 1
lastBlock = block
- result.append(LinearDisassemblyLine(LinearDisassemblyLineType.FunctionEndLineType,
- self.function, lastBlock, DisassemblyTextLine([], lastAddr)))
+ result.append(
+ LinearDisassemblyLine(
+ LinearDisassemblyLineType.FunctionEndLineType, self.function, lastBlock, DisassemblyTextLine([], lastAddr)
+ )
+ )
return result
diff --git a/python/examples/mappedview.py b/python/examples/mappedview.py
index 18bef17f..645096f5 100644
--- a/python/examples/mappedview.py
+++ b/python/examples/mappedview.py
@@ -35,13 +35,14 @@ import traceback
use_default_loader_settings = True
+
class MappedView(BinaryView):
name = "Mapped (Python)"
long_name = "Mapped (Python)"
load_address = 0x100000
def __init__(self, data):
- BinaryView.__init__(self, parent_view = data, file_metadata = data.file)
+ BinaryView.__init__(self, parent_view=data, file_metadata=data.file)
@staticmethod
def is_valid_for_data(data):
@@ -74,7 +75,10 @@ class MappedView(BinaryView):
load_settings = registered_view.get_default_load_settings_for_data(view)
# Specify default load settings that can be overridden (from the UI).
- overrides = ["loader.architecture", "loader.platform", "loader.entryPointOffset", "loader.imageBase", "loader.segments", "loader.sections"]
+ overrides = [
+ "loader.architecture", "loader.platform", "loader.entryPointOffset", "loader.imageBase", "loader.segments",
+ "loader.sections"
+ ]
for override in overrides:
if load_settings.contains(override):
load_settings.update_property(override, json.dumps({'readOnly': False}))
@@ -84,11 +88,12 @@ class MappedView(BinaryView):
load_settings.update_property("loader.entryPointOffset", json.dumps({'default': 0}))
# Specify additional custom settings.
- load_settings.register_setting("loader.my_custom_arch.customLoadSetting",
- '{"title" : "My Custom Load Setting",\
+ load_settings.register_setting(
+ "loader.my_custom_arch.customLoadSetting", '{"title" : "My Custom Load Setting",\
"type" : "boolean",\
"default" : false,\
- "description" : "My custom load setting description."}')
+ "description" : "My custom load setting description."}'
+ )
return load_settings
@@ -116,7 +121,7 @@ class MappedView(BinaryView):
if load_settings is None:
if self.parse_only is True:
self.arch = Architecture['x86'] # type: ignore
- self.platform = Architecture['x86'].standalone_platform # type: ignore
+ self.platform = Architecture['x86'].standalone_platform # type: ignore
assert self.parent_view is not None
self.add_auto_segment(0, len(self.parent_view), 0, len(self.parent_view), SegmentFlag.SegmentReadable)
return True
@@ -126,10 +131,13 @@ class MappedView(BinaryView):
load_settings = self.__class__.get_load_settings_for_data(self.parent_view)
arch = load_settings.get_string("loader.architecture", self)
- self.arch = Architecture[arch] # type: ignore
- self.platform = Architecture[arch].standalone_platform # type: ignore
+ self.arch = Architecture[arch] # type: ignore
+ self.platform = Architecture[arch].standalone_platform # type: ignore
self.load_address = load_settings.get_integer("loader.imageBase", self)
- self.add_auto_segment(self.load_address, len(self.parent_view), 0, len(self.parent_view), SegmentFlag.SegmentReadable | SegmentFlag.SegmentExecutable)
+ self.add_auto_segment(
+ self.load_address, len(self.parent_view), 0, len(self.parent_view),
+ SegmentFlag.SegmentReadable | SegmentFlag.SegmentExecutable
+ )
if load_settings.contains("loader.entryPointOffset"):
self.entry_point_offset = load_settings.get_integer("loader.entryPointOffset", self)
self.add_entry_point(self.load_address + self.entry_point_offset)
@@ -156,4 +164,5 @@ class MappedView(BinaryView):
def perform_get_address_size(self):
return self.arch.address_size
+
MappedView.register()
diff --git a/python/examples/nds.py b/python/examples/nds.py
index e7192abf..7b53c31f 100644
--- a/python/examples/nds.py
+++ b/python/examples/nds.py
@@ -29,88 +29,92 @@ import traceback
def crc16(data):
- crc = 0xffff
- for ch in data:
- crc ^= ord(ch)
- for bit in range(0, 8):
- if (crc & 1) == 1:
- crc = (crc >> 1) ^ 0xa001
- else:
- crc >>= 1
- return crc
+ crc = 0xffff
+ for ch in data:
+ crc ^= ord(ch)
+ for bit in range(0, 8):
+ if (crc & 1) == 1:
+ crc = (crc >> 1) ^ 0xa001
+ else:
+ crc >>= 1
+ return crc
class DSView(BinaryView):
- def __init__(self, data):
- BinaryView.__init__(self, file_metadata = data.file, parent_view = data)
- self.raw = data
+ def __init__(self, data):
+ BinaryView.__init__(self, file_metadata=data.file, parent_view=data)
+ self.raw = data
- @staticmethod
- def is_valid_for_data(data):
- hdr = data.read(0, 0x160)
- if len(hdr) < 0x160:
- return False
- if struct.unpack("<H", hdr[0x15e:0x160])[0] != crc16(hdr[0:0x15e]):
- return False
- if struct.unpack("<H", hdr[0x15c:0x15e])[0] != crc16(hdr[0xc0:0x15c]):
- return False
- return True
+ @staticmethod
+ def is_valid_for_data(data):
+ hdr = data.read(0, 0x160)
+ if len(hdr) < 0x160:
+ return False
+ if struct.unpack("<H", hdr[0x15e:0x160])[0] != crc16(hdr[0:0x15e]):
+ return False
+ if struct.unpack("<H", hdr[0x15c:0x15e])[0] != crc16(hdr[0xc0:0x15c]):
+ return False
+ return True
- def init_common(self):
- self.platform = Architecture["armv7"].standalone_platform # type: ignore
- self.hdr = self.raw.read(0, 0x160)
+ def init_common(self):
+ self.platform = Architecture["armv7"].standalone_platform # type: ignore
+ self.hdr = self.raw.read(0, 0x160)
- def init_arm9(self):
- try:
- self.init_common()
- self.arm9_offset = struct.unpack("<L", self.hdr[0x20:0x24])[0]
- self.arm_entry_addr = struct.unpack("<L", self.hdr[0x24:0x28])[0]
- self.arm9_load_addr = struct.unpack("<L", self.hdr[0x28:0x2C])[0]
- self.arm9_size = struct.unpack("<L", self.hdr[0x2C:0x30])[0]
- self.add_auto_segment(self.arm9_load_addr, self.arm9_size, self.arm9_offset, self.arm9_size,
- SegmentFlag.SegmentReadable | SegmentFlag.SegmentExecutable)
- self.add_entry_point(Architecture['armv7'].standalone_platform, self.arm_entry_addr) # type: ignore
- return True
- except:
- log_error(traceback.format_exc())
- return False
+ def init_arm9(self):
+ try:
+ self.init_common()
+ self.arm9_offset = struct.unpack("<L", self.hdr[0x20:0x24])[0]
+ self.arm_entry_addr = struct.unpack("<L", self.hdr[0x24:0x28])[0]
+ self.arm9_load_addr = struct.unpack("<L", self.hdr[0x28:0x2C])[0]
+ self.arm9_size = struct.unpack("<L", self.hdr[0x2C:0x30])[0]
+ self.add_auto_segment(
+ self.arm9_load_addr, self.arm9_size, self.arm9_offset, self.arm9_size,
+ SegmentFlag.SegmentReadable | SegmentFlag.SegmentExecutable
+ )
+ self.add_entry_point(Architecture['armv7'].standalone_platform, self.arm_entry_addr) # type: ignore
+ return True
+ except:
+ log_error(traceback.format_exc())
+ return False
- def init_arm7(self):
- try:
- self.init_common()
- self.arm7_offset = struct.unpack("<L", self.hdr[0x30:0x34])[0]
- self.arm_entry_addr = struct.unpack("<L", self.hdr[0x34:0x38])[0]
- self.arm7_load_addr = struct.unpack("<L", self.hdr[0x38:0x3C])[0]
- self.arm7_size = struct.unpack("<L", self.hdr[0x3C:0x40])[0]
- self.add_auto_segment(self.arm7_load_addr, self.arm7_size, self.arm7_offset, self.arm7_size,
- SegmentFlag.SegmentReadable | SegmentFlag.SegmentExecutable)
- self.add_entry_point(Architecture['armv7'].standalone_platform, self.arm_entry_addr) # type: ignore
- return True
- except:
- log_error(traceback.format_exc())
- return False
+ def init_arm7(self):
+ try:
+ self.init_common()
+ self.arm7_offset = struct.unpack("<L", self.hdr[0x30:0x34])[0]
+ self.arm_entry_addr = struct.unpack("<L", self.hdr[0x34:0x38])[0]
+ self.arm7_load_addr = struct.unpack("<L", self.hdr[0x38:0x3C])[0]
+ self.arm7_size = struct.unpack("<L", self.hdr[0x3C:0x40])[0]
+ self.add_auto_segment(
+ self.arm7_load_addr, self.arm7_size, self.arm7_offset, self.arm7_size,
+ SegmentFlag.SegmentReadable | SegmentFlag.SegmentExecutable
+ )
+ self.add_entry_point(Architecture['armv7'].standalone_platform, self.arm_entry_addr) # type: ignore
+ return True
+ except:
+ log_error(traceback.format_exc())
+ return False
- def perform_is_executable(self):
- return True
+ def perform_is_executable(self):
+ return True
- def perform_get_entry_point(self):
- return self.arm_entry_addr
+ def perform_get_entry_point(self):
+ return self.arm_entry_addr
class DSARM9View(DSView):
- name = "DSARM9"
- long_name = "DS ARM9 ROM"
+ name = "DSARM9"
+ long_name = "DS ARM9 ROM"
- def init(self):
- return self.init_arm9()
+ def init(self):
+ return self.init_arm9()
class DSARM7View(DSView):
- name = "DSARM7"
- long_name = "DS ARM7 ROM"
+ name = "DSARM7"
+ long_name = "DS ARM7 ROM"
- def init(self):
- return self.init_arm7()
+ def init(self):
+ return self.init_arm7()
DSARM9View.register()
diff --git a/python/examples/nes.py b/python/examples/nes.py
index 7e24d16b..7c7857a4 100644
--- a/python/examples/nes.py
+++ b/python/examples/nes.py
@@ -29,43 +29,43 @@ from binaryninja.function import InstructionTextToken
from binaryninja.binaryview import BinaryView
from binaryninja.types import Symbol
from binaryninja.log import log_error
-from binaryninja.enums import (BranchType, InstructionTextTokenType,
- LowLevelILOperation, LowLevelILFlagCondition, FlagRole, SegmentFlag, SymbolType)
-
+from binaryninja.enums import (
+ BranchType, InstructionTextTokenType, LowLevelILOperation, LowLevelILFlagCondition, FlagRole, SegmentFlag, SymbolType
+)
InstructionNames = [
- "brk", "ora", None, None, None, "ora", "asl", None, # 0x00
- "php", "ora", "asl@", None, None, "ora", "asl", None, # 0x08
- "bpl", "ora", None, None, None, "ora", "asl", None, # 0x10
- "clc", "ora", None, None, None, "ora", "asl", None, # 0x18
- "jsr", "and", None, None, "bit", "and", "rol", None, # 0x20
- "plp", "and", "rol@", None, "bit", "and", "rol", None, # 0x28
- "bmi", "and", None, None, None, "and", "rol", None, # 0x30
- "sec", "and", None, None, None, "and", "rol", None, # 0x38
- "rti", "eor", None, None, None, "eor", "lsr", None, # 0x40
- "pha", "eor", "lsr@", None, "jmp", "eor", "lsr", None, # 0x48
- "bvc", "eor", None, None, None, "eor", "lsr", None, # 0x50
- "cli", "eor", None, None, None, "eor", "lsr", None, # 0x58
- "rts", "adc", None, None, None, "adc", "ror", None, # 0x60
- "pla", "adc", "ror@", None, "jmp", "adc", "ror", None, # 0x68
- "bvs", "adc", None, None, None, "adc", "ror", None, # 0x70
- "sei", "adc", None, None, None, "adc", "ror", None, # 0x78
- None, "sta", None, None, "sty", "sta", "stx", None, # 0x80
- "dey", None, "txa", None, "sty", "sta", "stx", None, # 0x88
- "bcc", "sta", None, None, "sty", "sta", "stx", None, # 0x90
- "tya", "sta", "txs", None, None, "sta", None, None, # 0x98
- "ldy", "lda", "ldx", None, "ldy", "lda", "ldx", None, # 0xa0
- "tay", "lda", "tax", None, "ldy", "lda", "ldx", None, # 0xa8
- "bcs", "lda", None, None, "ldy", "lda", "ldx", None, # 0xb0
- "clv", "lda", "tsx", None, "ldy", "lda", "ldx", None, # 0xb8
- "cpy", "cmp", None, None, "cpy", "cmp", "dec", None, # 0xc0
- "iny", "cmp", "dex", None, "cpy", "cmp", "dec", None, # 0xc8
- "bne", "cmp", None, None, None, "cmp", "dec", None, # 0xd0
- "cld", "cmp", None, None, None, "cmp", "dec", None, # 0xd8
- "cpx", "sbc", None, None, "cpx", "sbc", "inc", None, # 0xe0
- "inx", "sbc", "nop", None, "cpx", "sbc", "inc", None, # 0xe8
- "beq", "sbc", None, None, None, "sbc", "inc", None, # 0xf0
- "sed", "sbc", None, None, None, "sbc", "inc", None # 0xf8
+ "brk", "ora", None, None, None, "ora", "asl", None, # 0x00
+ "php", "ora", "asl@", None, None, "ora", "asl", None, # 0x08
+ "bpl", "ora", None, None, None, "ora", "asl", None, # 0x10
+ "clc", "ora", None, None, None, "ora", "asl", None, # 0x18
+ "jsr", "and", None, None, "bit", "and", "rol", None, # 0x20
+ "plp", "and", "rol@", None, "bit", "and", "rol", None, # 0x28
+ "bmi", "and", None, None, None, "and", "rol", None, # 0x30
+ "sec", "and", None, None, None, "and", "rol", None, # 0x38
+ "rti", "eor", None, None, None, "eor", "lsr", None, # 0x40
+ "pha", "eor", "lsr@", None, "jmp", "eor", "lsr", None, # 0x48
+ "bvc", "eor", None, None, None, "eor", "lsr", None, # 0x50
+ "cli", "eor", None, None, None, "eor", "lsr", None, # 0x58
+ "rts", "adc", None, None, None, "adc", "ror", None, # 0x60
+ "pla", "adc", "ror@", None, "jmp", "adc", "ror", None, # 0x68
+ "bvs", "adc", None, None, None, "adc", "ror", None, # 0x70
+ "sei", "adc", None, None, None, "adc", "ror", None, # 0x78
+ None, "sta", None, None, "sty", "sta", "stx", None, # 0x80
+ "dey", None, "txa", None, "sty", "sta", "stx", None, # 0x88
+ "bcc", "sta", None, None, "sty", "sta", "stx", None, # 0x90
+ "tya", "sta", "txs", None, None, "sta", None, None, # 0x98
+ "ldy", "lda", "ldx", None, "ldy", "lda", "ldx", None, # 0xa0
+ "tay", "lda", "tax", None, "ldy", "lda", "ldx", None, # 0xa8
+ "bcs", "lda", None, None, "ldy", "lda", "ldx", None, # 0xb0
+ "clv", "lda", "tsx", None, "ldy", "lda", "ldx", None, # 0xb8
+ "cpy", "cmp", None, None, "cpy", "cmp", "dec", None, # 0xc0
+ "iny", "cmp", "dex", None, "cpy", "cmp", "dec", None, # 0xc8
+ "bne", "cmp", None, None, None, "cmp", "dec", None, # 0xd0
+ "cld", "cmp", None, None, None, "cmp", "dec", None, # 0xd8
+ "cpx", "sbc", None, None, "cpx", "sbc", "inc", None, # 0xe0
+ "inx", "sbc", "nop", None, "cpx", "sbc", "inc", None, # 0xe8
+ "beq", "sbc", None, None, None, "sbc", "inc", None, # 0xf0
+ "sed", "sbc", None, None, None, "sbc", "inc", None # 0xf8
]
NONE = 0
@@ -91,103 +91,151 @@ ZERO_X_DEST = 19
ZERO_Y = 20
ZERO_Y_DEST = 21
InstructionOperandTypes = [
- NONE, IND_X, NONE, NONE, NONE, ZERO, ZERO_DEST, NONE, # 0x00
- NONE, IMMED, ACCUM, NONE, NONE, ABS, ABS_DEST, NONE, # 0x08
- REL, IND_Y, NONE, NONE, NONE, ZERO_X, ZERO_X_DEST, NONE, # 0x10
- NONE, ABS_Y, NONE, NONE, NONE, ABS_X, ABS_X_DEST, NONE, # 0x18
- ADDR, IND_X, NONE, NONE, ZERO, ZERO, ZERO_DEST, NONE, # 0x20
- NONE, IMMED, ACCUM, NONE, ABS, ABS, ABS_DEST, NONE, # 0x28
- REL, IND_Y, NONE, NONE, NONE, ZERO_X, ZERO_X_DEST, NONE, # 0x30
- NONE, ABS_Y, NONE, NONE, NONE, ABS_X, ABS_X_DEST, NONE, # 0x38
- NONE, IND_X, NONE, NONE, NONE, ZERO, ZERO_DEST, NONE, # 0x40
- NONE, IMMED, ACCUM, NONE, ADDR, ABS, ABS_DEST, NONE, # 0x48
- REL, IND_Y, NONE, NONE, NONE, ZERO_X, ZERO_X_DEST, NONE, # 0x50
- NONE, ABS_Y, NONE, NONE, NONE, ABS_X, ABS_X_DEST, NONE, # 0x58
- NONE, IND_X, NONE, NONE, NONE, ZERO, ZERO_DEST, NONE, # 0x60
- NONE, IMMED, ACCUM, NONE, IND, ABS, ABS_DEST, NONE, # 0x68
- REL, IND_Y, NONE, NONE, NONE, ZERO_X, ZERO_X_DEST, NONE, # 0x70
- NONE, ABS_Y, NONE, NONE, NONE, ABS_X, ABS_X_DEST, NONE, # 0x78
- NONE, IND_X_DEST, NONE, NONE, ZERO_DEST, ZERO_DEST, ZERO_DEST, NONE, # 0x80
- NONE, NONE, NONE, NONE, ABS_DEST, ABS_DEST, ABS_DEST, NONE, # 0x88
- REL, IND_Y_DEST, NONE, NONE, ZERO_X_DEST, ZERO_X_DEST, ZERO_Y_DEST, NONE, # 0x90
- NONE, ABS_Y_DEST, NONE, NONE, NONE, ABS_X_DEST, NONE, NONE, # 0x98
- IMMED, IND_X, IMMED, NONE, ZERO, ZERO, ZERO, NONE, # 0xa0
- NONE, IMMED, NONE, NONE, ABS, ABS, ABS, NONE, # 0xa8
- REL, IND_Y, NONE, NONE, ZERO_X, ZERO_X, ZERO_Y, NONE, # 0xb0
- NONE, ABS_Y, NONE, NONE, ABS_X, ABS_X, ABS_Y, NONE, # 0xb8
- IMMED, IND_X, NONE, NONE, ZERO, ZERO, ZERO_DEST, NONE, # 0xc0
- NONE, IMMED, NONE, NONE, ABS, ABS, ABS_DEST, NONE, # 0xc8
- REL, IND_Y, NONE, NONE, NONE, ZERO_X, ZERO_X_DEST, NONE, # 0xd0
- NONE, ABS_Y, NONE, NONE, NONE, ABS_X, ABS_X_DEST, NONE, # 0xd8
- IMMED, IND_X, NONE, NONE, ZERO, ZERO, ZERO_DEST, NONE, # 0xe0
- NONE, IMMED, NONE, NONE, ABS, ABS, ABS_DEST, NONE, # 0xe8
- REL, IND_Y, NONE, NONE, NONE, ZERO_X, ZERO_X_DEST, NONE, # 0xf0
- NONE, ABS_Y, NONE, NONE, NONE, ABS_X, ABS_X_DEST, NONE # 0xf8
+ NONE, IND_X, NONE, NONE, NONE, ZERO, ZERO_DEST, NONE, # 0x00
+ NONE, IMMED, ACCUM, NONE, NONE, ABS, ABS_DEST, NONE, # 0x08
+ REL, IND_Y, NONE, NONE, NONE, ZERO_X, ZERO_X_DEST, NONE, # 0x10
+ NONE, ABS_Y, NONE, NONE, NONE, ABS_X, ABS_X_DEST, NONE, # 0x18
+ ADDR, IND_X, NONE, NONE, ZERO, ZERO, ZERO_DEST, NONE, # 0x20
+ NONE, IMMED, ACCUM, NONE, ABS, ABS, ABS_DEST, NONE, # 0x28
+ REL, IND_Y, NONE, NONE, NONE, ZERO_X, ZERO_X_DEST, NONE, # 0x30
+ NONE, ABS_Y, NONE, NONE, NONE, ABS_X, ABS_X_DEST, NONE, # 0x38
+ NONE, IND_X, NONE, NONE, NONE, ZERO, ZERO_DEST, NONE, # 0x40
+ NONE, IMMED, ACCUM, NONE, ADDR, ABS, ABS_DEST, NONE, # 0x48
+ REL, IND_Y, NONE, NONE, NONE, ZERO_X, ZERO_X_DEST, NONE, # 0x50
+ NONE, ABS_Y, NONE, NONE, NONE, ABS_X, ABS_X_DEST, NONE, # 0x58
+ NONE, IND_X, NONE, NONE, NONE, ZERO, ZERO_DEST, NONE, # 0x60
+ NONE, IMMED, ACCUM, NONE, IND, ABS, ABS_DEST, NONE, # 0x68
+ REL, IND_Y, NONE, NONE, NONE, ZERO_X, ZERO_X_DEST, NONE, # 0x70
+ NONE, ABS_Y, NONE, NONE, NONE, ABS_X, ABS_X_DEST, NONE, # 0x78
+ NONE, IND_X_DEST, NONE, NONE, ZERO_DEST, ZERO_DEST, ZERO_DEST, NONE, # 0x80
+ NONE, NONE, NONE, NONE, ABS_DEST, ABS_DEST, ABS_DEST, NONE, # 0x88
+ REL, IND_Y_DEST, NONE, NONE, ZERO_X_DEST, ZERO_X_DEST, ZERO_Y_DEST, NONE, # 0x90
+ NONE, ABS_Y_DEST, NONE, NONE, NONE, ABS_X_DEST, NONE, NONE, # 0x98
+ IMMED, IND_X, IMMED, NONE, ZERO, ZERO, ZERO, NONE, # 0xa0
+ NONE, IMMED, NONE, NONE, ABS, ABS, ABS, NONE, # 0xa8
+ REL, IND_Y, NONE, NONE, ZERO_X, ZERO_X, ZERO_Y, NONE, # 0xb0
+ NONE, ABS_Y, NONE, NONE, ABS_X, ABS_X, ABS_Y, NONE, # 0xb8
+ IMMED, IND_X, NONE, NONE, ZERO, ZERO, ZERO_DEST, NONE, # 0xc0
+ NONE, IMMED, NONE, NONE, ABS, ABS, ABS_DEST, NONE, # 0xc8
+ REL, IND_Y, NONE, NONE, NONE, ZERO_X, ZERO_X_DEST, NONE, # 0xd0
+ NONE, ABS_Y, NONE, NONE, NONE, ABS_X, ABS_X_DEST, NONE, # 0xd8
+ IMMED, IND_X, NONE, NONE, ZERO, ZERO, ZERO_DEST, NONE, # 0xe0
+ NONE, IMMED, NONE, NONE, ABS, ABS, ABS_DEST, NONE, # 0xe8
+ REL, IND_Y, NONE, NONE, NONE, ZERO_X, ZERO_X_DEST, NONE, # 0xf0
+ NONE, ABS_Y, NONE, NONE, NONE, ABS_X, ABS_X_DEST, NONE # 0xf8
]
OperandLengths = [
- 0, # NONE
- 2, # ABS
- 2, # ABS_DEST
- 2, # ABS_X
- 2, # ABS_X_DEST
- 2, # ABS_Y
- 2, # ABS_Y_DEST
- 0, # ACCUM
- 2, # ADDR
- 1, # IMMED
- 2, # IND
- 1, # IND_X
- 1, # IND_X_DEST
- 1, # IND_Y
- 1, # IND_Y_DEST
- 1, # REL
- 1, # ZERO
- 1, # ZERO_DEST
- 1, # ZERO_X
- 1, # ZERO_X_DEST
- 1, # ZERO_Y
- 1 # ZERO_Y_DEST
+ 0, # NONE
+ 2, # ABS
+ 2, # ABS_DEST
+ 2, # ABS_X
+ 2, # ABS_X_DEST
+ 2, # ABS_Y
+ 2, # ABS_Y_DEST
+ 0, # ACCUM
+ 2, # ADDR
+ 1, # IMMED
+ 2, # IND
+ 1, # IND_X
+ 1, # IND_X_DEST
+ 1, # IND_Y
+ 1, # IND_Y_DEST
+ 1, # REL
+ 1, # ZERO
+ 1, # ZERO_DEST
+ 1, # ZERO_X
+ 1, # ZERO_X_DEST
+ 1, # ZERO_Y
+ 1 # ZERO_Y_DEST
]
-OperandTokens:List[Callable[[int], List[InstructionTextToken]]] = [
- lambda value: [], # NONE
- lambda value: [InstructionTextToken(InstructionTextTokenType.PossibleAddressToken, "$%.4x" % value, value)], # ABS
- lambda value: [InstructionTextToken(InstructionTextTokenType.PossibleAddressToken, "$%.4x" % value, value)], # ABS_DEST
- lambda value: [InstructionTextToken(InstructionTextTokenType.PossibleAddressToken, "$%.4x" % value, value),
- InstructionTextToken(InstructionTextTokenType.TextToken, ", "), InstructionTextToken(InstructionTextTokenType.RegisterToken, "x")], # ABS_X
- lambda value: [InstructionTextToken(InstructionTextTokenType.PossibleAddressToken, "$%.4x" % value, value),
- InstructionTextToken(InstructionTextTokenType.TextToken, ", "), InstructionTextToken(InstructionTextTokenType.RegisterToken, "x")], # ABS_X_DEST
- lambda value: [InstructionTextToken(InstructionTextTokenType.PossibleAddressToken, "$%.4x" % value, value),
- InstructionTextToken(InstructionTextTokenType.TextToken, ", "), InstructionTextToken(InstructionTextTokenType.RegisterToken, "y")], # ABS_Y
- lambda value: [InstructionTextToken(InstructionTextTokenType.PossibleAddressToken, "$%.4x" % value, value),
- InstructionTextToken(InstructionTextTokenType.TextToken, ", "), InstructionTextToken(InstructionTextTokenType.RegisterToken, "y")], # ABS_Y_DEST
- lambda value: [InstructionTextToken(InstructionTextTokenType.RegisterToken, "a")], # ACCUM
- lambda value: [InstructionTextToken(InstructionTextTokenType.PossibleAddressToken, "$%.4x" % value, value)], # ADDR
- lambda value: [InstructionTextToken(InstructionTextTokenType.TextToken, "#"), InstructionTextToken(InstructionTextTokenType.IntegerToken, "$%.2x" % value, value)], # IMMED
- lambda value: [InstructionTextToken(InstructionTextTokenType.TextToken, "["), InstructionTextToken(InstructionTextTokenType.PossibleAddressToken, "$%.4x" % value, value),
- InstructionTextToken(InstructionTextTokenType.TextToken, "]")], # IND
- lambda value: [InstructionTextToken(InstructionTextTokenType.TextToken, "["), InstructionTextToken(InstructionTextTokenType.PossibleAddressToken, "$%.2x" % value, value),
- InstructionTextToken(InstructionTextTokenType.TextToken, ", "), InstructionTextToken(InstructionTextTokenType.RegisterToken, "x"),
- InstructionTextToken(InstructionTextTokenType.TextToken, "]")], # IND_X
- lambda value: [InstructionTextToken(InstructionTextTokenType.TextToken, "["), InstructionTextToken(InstructionTextTokenType.PossibleAddressToken, "$%.2x" % value, value),
- InstructionTextToken(InstructionTextTokenType.TextToken, ", "), InstructionTextToken(InstructionTextTokenType.RegisterToken, "x"),
- InstructionTextToken(InstructionTextTokenType.TextToken, "]")], # IND_X_DEST
- lambda value: [InstructionTextToken(InstructionTextTokenType.TextToken, "["), InstructionTextToken(InstructionTextTokenType.PossibleAddressToken, "$%.2x" % value, value),
- InstructionTextToken(InstructionTextTokenType.TextToken, "], "), InstructionTextToken(InstructionTextTokenType.RegisterToken, "y")], # IND_Y
- lambda value: [InstructionTextToken(InstructionTextTokenType.TextToken, "["), InstructionTextToken(InstructionTextTokenType.PossibleAddressToken, "$%.2x" % value, value),
- InstructionTextToken(InstructionTextTokenType.TextToken, "], "), InstructionTextToken(InstructionTextTokenType.RegisterToken, "y")], # IND_Y_DEST
- lambda value: [InstructionTextToken(InstructionTextTokenType.PossibleAddressToken, "$%.4x" % value, value)], # REL
- lambda value: [InstructionTextToken(InstructionTextTokenType.PossibleAddressToken, "$%.2x" % value, value)], # ZERO
- lambda value: [InstructionTextToken(InstructionTextTokenType.PossibleAddressToken, "$%.2x" % value, value)], # ZERO_DEST
- lambda value: [InstructionTextToken(InstructionTextTokenType.PossibleAddressToken, "$%.2x" % value, value),
- InstructionTextToken(InstructionTextTokenType.TextToken, ", "), InstructionTextToken(InstructionTextTokenType.RegisterToken, "x")], # ZERO_X
- lambda value: [InstructionTextToken(InstructionTextTokenType.PossibleAddressToken, "$%.2x" % value, value),
- InstructionTextToken(InstructionTextTokenType.TextToken, ", "), InstructionTextToken(InstructionTextTokenType.RegisterToken, "x")], # ZERO_X_DEST
- lambda value: [InstructionTextToken(InstructionTextTokenType.PossibleAddressToken, "$%.2x" % value, value),
- InstructionTextToken(InstructionTextTokenType.TextToken, ", "), InstructionTextToken(InstructionTextTokenType.RegisterToken, "y")], # ZERO_Y
- lambda value: [InstructionTextToken(InstructionTextTokenType.PossibleAddressToken, "$%.2x" % value, value),
- InstructionTextToken(InstructionTextTokenType.TextToken, ", "), InstructionTextToken(InstructionTextTokenType.RegisterToken, "y")] # ZERO_Y_DEST
+OperandTokens: List[Callable[[int], List[InstructionTextToken]]] = [
+ lambda value: [], # NONE
+ lambda value: [InstructionTextToken(InstructionTextTokenType.PossibleAddressToken, "$%.4x" % value, value)], # ABS
+ lambda value: [InstructionTextToken(InstructionTextTokenType.PossibleAddressToken, "$%.4x" % value, value)
+ ], # ABS_DEST
+ lambda value: [
+ InstructionTextToken(InstructionTextTokenType.PossibleAddressToken, "$%.4x" % value, value),
+ InstructionTextToken(InstructionTextTokenType.TextToken, ", "),
+ InstructionTextToken(InstructionTextTokenType.RegisterToken, "x")
+ ], # ABS_X
+ lambda value: [
+ InstructionTextToken(InstructionTextTokenType.PossibleAddressToken, "$%.4x" % value, value),
+ InstructionTextToken(InstructionTextTokenType.TextToken, ", "),
+ InstructionTextToken(InstructionTextTokenType.RegisterToken, "x")
+ ], # ABS_X_DEST
+ lambda value: [
+ InstructionTextToken(InstructionTextTokenType.PossibleAddressToken, "$%.4x" % value, value),
+ InstructionTextToken(InstructionTextTokenType.TextToken, ", "),
+ InstructionTextToken(InstructionTextTokenType.RegisterToken, "y")
+ ], # ABS_Y
+ lambda value: [
+ InstructionTextToken(InstructionTextTokenType.PossibleAddressToken, "$%.4x" % value, value),
+ InstructionTextToken(InstructionTextTokenType.TextToken, ", "),
+ InstructionTextToken(InstructionTextTokenType.RegisterToken, "y")
+ ], # ABS_Y_DEST
+ lambda value: [InstructionTextToken(InstructionTextTokenType.RegisterToken, "a")], # ACCUM
+ lambda value: [InstructionTextToken(InstructionTextTokenType.PossibleAddressToken, "$%.4x" % value, value)], # ADDR
+ lambda value: [
+ InstructionTextToken(InstructionTextTokenType.TextToken, "#"),
+ InstructionTextToken(InstructionTextTokenType.IntegerToken, "$%.2x" % value, value)
+ ], # IMMED
+ lambda value: [
+ InstructionTextToken(InstructionTextTokenType.TextToken, "["),
+ InstructionTextToken(InstructionTextTokenType.PossibleAddressToken, "$%.4x" % value, value),
+ InstructionTextToken(InstructionTextTokenType.TextToken, "]")
+ ], # IND
+ lambda value: [
+ InstructionTextToken(InstructionTextTokenType.TextToken, "["),
+ InstructionTextToken(InstructionTextTokenType.PossibleAddressToken, "$%.2x" % value, value),
+ InstructionTextToken(InstructionTextTokenType.TextToken, ", "),
+ InstructionTextToken(InstructionTextTokenType.RegisterToken, "x"),
+ InstructionTextToken(InstructionTextTokenType.TextToken, "]")
+ ], # IND_X
+ lambda value: [
+ InstructionTextToken(InstructionTextTokenType.TextToken, "["),
+ InstructionTextToken(InstructionTextTokenType.PossibleAddressToken, "$%.2x" % value, value),
+ InstructionTextToken(InstructionTextTokenType.TextToken, ", "),
+ InstructionTextToken(InstructionTextTokenType.RegisterToken, "x"),
+ InstructionTextToken(InstructionTextTokenType.TextToken, "]")
+ ], # IND_X_DEST
+ lambda value: [
+ InstructionTextToken(InstructionTextTokenType.TextToken, "["),
+ InstructionTextToken(InstructionTextTokenType.PossibleAddressToken, "$%.2x" % value, value),
+ InstructionTextToken(InstructionTextTokenType.TextToken, "], "),
+ InstructionTextToken(InstructionTextTokenType.RegisterToken, "y")
+ ], # IND_Y
+ lambda value: [
+ InstructionTextToken(InstructionTextTokenType.TextToken, "["),
+ InstructionTextToken(InstructionTextTokenType.PossibleAddressToken, "$%.2x" % value, value),
+ InstructionTextToken(InstructionTextTokenType.TextToken, "], "),
+ InstructionTextToken(InstructionTextTokenType.RegisterToken, "y")
+ ], # IND_Y_DEST
+ lambda value: [InstructionTextToken(InstructionTextTokenType.PossibleAddressToken, "$%.4x" % value, value)], # REL
+ lambda value: [InstructionTextToken(InstructionTextTokenType.PossibleAddressToken, "$%.2x" % value, value)], # ZERO
+ lambda value: [InstructionTextToken(InstructionTextTokenType.PossibleAddressToken, "$%.2x" % value, value)
+ ], # ZERO_DEST
+ lambda value: [
+ InstructionTextToken(InstructionTextTokenType.PossibleAddressToken, "$%.2x" % value, value),
+ InstructionTextToken(InstructionTextTokenType.TextToken, ", "),
+ InstructionTextToken(InstructionTextTokenType.RegisterToken, "x")
+ ], # ZERO_X
+ lambda value: [
+ InstructionTextToken(InstructionTextTokenType.PossibleAddressToken, "$%.2x" % value, value),
+ InstructionTextToken(InstructionTextTokenType.TextToken, ", "),
+ InstructionTextToken(InstructionTextTokenType.RegisterToken, "x")
+ ], # ZERO_X_DEST
+ lambda value: [
+ InstructionTextToken(InstructionTextTokenType.PossibleAddressToken, "$%.2x" % value, value),
+ InstructionTextToken(InstructionTextTokenType.TextToken, ", "),
+ InstructionTextToken(InstructionTextTokenType.RegisterToken, "y")
+ ], # ZERO_Y
+ lambda value: [
+ InstructionTextToken(InstructionTextTokenType.PossibleAddressToken, "$%.2x" % value, value),
+ InstructionTextToken(InstructionTextTokenType.TextToken, ", "),
+ InstructionTextToken(InstructionTextTokenType.RegisterToken, "y")
+ ] # ZERO_Y_DEST
]
@@ -218,28 +266,28 @@ def load_zero_page_16(il, value):
OperandIL = [
- lambda il, value: None, # NONE
- lambda il, value: il.load(1, il.const_pointer(2, value)), # ABS
- lambda il, value: il.const(2, value), # ABS_DEST
- lambda il, value: il.load(1, il.add(2, il.const(2, value), il.zero_extend(2, il.reg(1, "x")))), # ABS_X
- lambda il, value: il.add(2, il.const(2, value), il.zero_extend(2, il.reg(1, "x"))), # ABS_X_DEST
- lambda il, value: il.load(1, il.add(2, il.const(2, value), il.zero_extend(2, il.reg(1, "y")))), # ABS_Y
- lambda il, value: il.add(2, il.const(2, value), il.zero_extend(2, il.reg(1, "y"))), # ABS_Y_DEST
- lambda il, value: il.reg(1, "a"), # ACCUM
- lambda il, value: il.const_pointer(2, value), # ADDR
- lambda il, value: il.const(1, value), # IMMED
- lambda il, value: indirect_load(il, value), # IND
- lambda il, value: il.load(1, load_zero_page_16(il, il.add(1, il.const(1, value), il.reg(1, "x")))), # IND_X
- lambda il, value: load_zero_page_16(il, il.add(1, il.const(1, value), il.reg(1, "x"))), # IND_X_DEST
- lambda il, value: il.load(1, il.add(2, load_zero_page_16(il, il.const(1, value)), il.reg(1, "y"))), # IND_Y
- lambda il, value: il.add(2, load_zero_page_16(il, il.const(1, value)), il.reg(1, "y")), # IND_Y_DEST
- lambda il, value: il.const_pointer(2, value), # REL
- lambda il, value: il.load(1, il.const_pointer(2, value)), # ZERO
- lambda il, value: il.const_pointer(2, value), # ZERO_DEST
- lambda il, value: il.load(1, il.zero_extend(2, il.add(1, il.const(1, value), il.reg(1, "x")))), # ZERO_X
- lambda il, value: il.zero_extend(2, il.add(1, il.const(1, value), il.reg(1, "x"))), # ZERO_X_DEST
- lambda il, value: il.load(1, il.zero_extend(2, il.add(1, il.const(1, value), il.reg(1, "y")))), # ZERO_Y
- lambda il, value: il.zero_extend(2, il.add(1, il.const(1, value), il.reg(1, "y"))) # ZERO_Y_DEST
+ lambda il, value: None, # NONE
+ lambda il, value: il.load(1, il.const_pointer(2, value)), # ABS
+ lambda il, value: il.const(2, value), # ABS_DEST
+ lambda il, value: il.load(1, il.add(2, il.const(2, value), il.zero_extend(2, il.reg(1, "x")))), # ABS_X
+ lambda il, value: il.add(2, il.const(2, value), il.zero_extend(2, il.reg(1, "x"))), # ABS_X_DEST
+ lambda il, value: il.load(1, il.add(2, il.const(2, value), il.zero_extend(2, il.reg(1, "y")))), # ABS_Y
+ lambda il, value: il.add(2, il.const(2, value), il.zero_extend(2, il.reg(1, "y"))), # ABS_Y_DEST
+ lambda il, value: il.reg(1, "a"), # ACCUM
+ lambda il, value: il.const_pointer(2, value), # ADDR
+ lambda il, value: il.const(1, value), # IMMED
+ lambda il, value: indirect_load(il, value), # IND
+ lambda il, value: il.load(1, load_zero_page_16(il, il.add(1, il.const(1, value), il.reg(1, "x")))), # IND_X
+ lambda il, value: load_zero_page_16(il, il.add(1, il.const(1, value), il.reg(1, "x"))), # IND_X_DEST
+ lambda il, value: il.load(1, il.add(2, load_zero_page_16(il, il.const(1, value)), il.reg(1, "y"))), # IND_Y
+ lambda il, value: il.add(2, load_zero_page_16(il, il.const(1, value)), il.reg(1, "y")), # IND_Y_DEST
+ lambda il, value: il.const_pointer(2, value), # REL
+ lambda il, value: il.load(1, il.const_pointer(2, value)), # ZERO
+ lambda il, value: il.const_pointer(2, value), # ZERO_DEST
+ lambda il, value: il.load(1, il.zero_extend(2, il.add(1, il.const(1, value), il.reg(1, "x")))), # ZERO_X
+ lambda il, value: il.zero_extend(2, il.add(1, il.const(1, value), il.reg(1, "x"))), # ZERO_X_DEST
+ lambda il, value: il.load(1, il.zero_extend(2, il.add(1, il.const(1, value), il.reg(1, "y")))), # ZERO_Y
+ lambda il, value: il.zero_extend(2, il.add(1, il.const(1, value), il.reg(1, "y"))) # ZERO_Y_DEST
]
@@ -280,8 +328,7 @@ def get_p_value(il):
b = il.flag_bit(1, "b", 4)
v = il.flag_bit(1, "v", 6)
s = il.flag_bit(1, "s", 7)
- return il.or_expr(1, il.or_expr(1, il.or_expr(1, il.or_expr(1, il.or_expr(1,
- il.or_expr(1, c, z), i), d), b), v), s)
+ return il.or_expr(1, il.or_expr(1, il.or_expr(1, il.or_expr(1, il.or_expr(1, il.or_expr(1, c, z), i), d), b), v), s)
def set_p_value(il, value):
@@ -302,66 +349,80 @@ def rti(il):
InstructionIL = {
- "adc": lambda il, operand: il.set_reg(1, "a", il.add_carry(1, il.reg(1, "a"), operand, il.flag("c"), flags = "*")),
- "asl": lambda il, operand: il.store(1, operand, il.shift_left(1, il.load(1, operand), il.const(1, 1), flags = "czs")),
- "asl@": lambda il, operand: il.set_reg(1, "a", il.shift_left(1, operand, il.const(1, 1), flags = "czs")),
- "and": lambda il, operand: il.set_reg(1, "a", il.and_expr(1, il.reg(1, "a"), operand, flags = "zs")),
- "bcc": lambda il, operand: cond_branch(il, il.flag_condition(LowLevelILFlagCondition.LLFC_UGE), operand),
- "bcs": lambda il, operand: cond_branch(il, il.flag_condition(LowLevelILFlagCondition.LLFC_ULT), operand),
- "beq": lambda il, operand: cond_branch(il, il.flag_condition(LowLevelILFlagCondition.LLFC_E), operand),
- "bit": lambda il, operand: il.and_expr(1, il.reg(1, "a"), operand, flags = "czs"),
- "bmi": lambda il, operand: cond_branch(il, il.flag_condition(LowLevelILFlagCondition.LLFC_NEG), operand),
- "bne": lambda il, operand: cond_branch(il, il.flag_condition(LowLevelILFlagCondition.LLFC_NE), operand),
- "bpl": lambda il, operand: cond_branch(il, il.flag_condition(LowLevelILFlagCondition.LLFC_POS), operand),
- "brk": lambda il, operand: il.system_call(),
- "bvc": lambda il, operand: cond_branch(il, il.not_expr(0, il.flag("v")), operand),
- "bvs": lambda il, operand: cond_branch(il, il.flag("v"), operand),
- "clc": lambda il, operand: il.set_flag("c", il.const(0, 0)),
- "cld": lambda il, operand: il.set_flag("d", il.const(0, 0)),
- "cli": lambda il, operand: il.set_flag("i", il.const(0, 0)),
- "clv": lambda il, operand: il.set_flag("v", il.const(0, 0)),
- "cmp": lambda il, operand: il.sub(1, il.reg(1, "a"), operand, flags = "czs"),
- "cpx": lambda il, operand: il.sub(1, il.reg(1, "x"), operand, flags = "czs"),
- "cpy": lambda il, operand: il.sub(1, il.reg(1, "y"), operand, flags = "czs"),
- "dec": lambda il, operand: il.store(1, operand, il.sub(1, il.load(1, operand), il.const(1, 1), flags = "zs")),
- "dex": lambda il, operand: il.set_reg(1, "x", il.sub(1, il.reg(1, "x"), il.const(1, 1), flags = "zs")),
- "dey": lambda il, operand: il.set_reg(1, "y", il.sub(1, il.reg(1, "y"), il.const(1, 1), flags = "zs")),
- "eor": lambda il, operand: il.set_reg(1, "a", il.xor_expr(1, il.reg(1, "a"), operand, flags = "zs")),
- "inc": lambda il, operand: il.store(1, operand, il.add(1, il.load(1, operand), il.const(1, 1), flags = "zs")),
- "inx": lambda il, operand: il.set_reg(1, "x", il.add(1, il.reg(1, "x"), il.const(1, 1), flags = "zs")),
- "iny": lambda il, operand: il.set_reg(1, "y", il.add(1, il.reg(1, "y"), il.const(1, 1), flags = "zs")),
- "jmp": lambda il, operand: jump(il, operand),
- "jsr": lambda il, operand: il.call(operand),
- "lda": lambda il, operand: il.set_reg(1, "a", operand, flags = "zs"),
- "ldx": lambda il, operand: il.set_reg(1, "x", operand, flags = "zs"),
- "ldy": lambda il, operand: il.set_reg(1, "y", operand, flags = "zs"),
- "lsr": lambda il, operand: il.store(1, operand, il.logical_shift_right(1, il.load(1, operand), il.const(1, 1), flags = "czs")),
- "lsr@": lambda il, operand: il.set_reg(1, "a", il.logical_shift_right(1, il.reg(1, "a"), il.const(1, 1), flags = "czs")),
- "nop": lambda il, operand: il.nop(),
- "ora": lambda il, operand: il.set_reg(1, "a", il.or_expr(1, il.reg(1, "a"), operand, flags = "zs")),
- "pha": lambda il, operand: il.push(1, il.reg(1, "a")),
- "php": lambda il, operand: il.push(1, get_p_value(il)),
- "pla": lambda il, operand: il.set_reg(1, "a", il.pop(1), flags = "zs"),
- "plp": lambda il, operand: set_p_value(il, il.pop(1)),
- "rol": lambda il, operand: il.store(1, operand, il.rotate_left_carry(1, il.load(1, operand), il.const(1, 1), il.flag("c"), flags = "czs")),
- "rol@": lambda il, operand: il.set_reg(1, "a", il.rotate_left_carry(1, il.reg(1, "a"), il.const(1, 1), il.flag("c"), flags = "czs")),
- "ror": lambda il, operand: il.store(1, operand, il.rotate_right_carry(1, il.load(1, operand), il.const(1, 1), il.flag("c"), flags = "czs")),
- "ror@": lambda il, operand: il.set_reg(1, "a", il.rotate_right_carry(1, il.reg(1, "a"), il.const(1, 1), il.flag("c"), flags = "czs")),
- "rti": lambda il, operand: rti(il),
- "rts": lambda il, operand: il.ret(il.add(2, il.pop(2), il.const(2, 1))),
- "sbc": lambda il, operand: il.set_reg(1, "a", il.sub_borrow(1, il.reg(1, "a"), operand, il.flag("c"), flags = "*")),
- "sec": lambda il, operand: il.set_flag("c", il.const(0, 1)),
- "sed": lambda il, operand: il.set_flag("d", il.const(0, 1)),
- "sei": lambda il, operand: il.set_flag("i", il.const(0, 1)),
- "sta": lambda il, operand: il.store(1, operand, il.reg(1, "a")),
- "stx": lambda il, operand: il.store(1, operand, il.reg(1, "x")),
- "sty": lambda il, operand: il.store(1, operand, il.reg(1, "y")),
- "tax": lambda il, operand: il.set_reg(1, "x", il.reg(1, "a"), flags = "zs"),
- "tay": lambda il, operand: il.set_reg(1, "y", il.reg(1, "a"), flags = "zs"),
- "tsx": lambda il, operand: il.set_reg(1, "x", il.reg(1, "s"), flags = "zs"),
- "txa": lambda il, operand: il.set_reg(1, "a", il.reg(1, "x"), flags = "zs"),
- "txs": lambda il, operand: il.set_reg(1, "s", il.reg(1, "x")),
- "tya": lambda il, operand: il.set_reg(1, "a", il.reg(1, "y"), flags = "zs")
+ "adc":
+ lambda il, operand: il.set_reg(1, "a", il.add_carry(1, il.reg(1, "a"), operand, il.flag("c"), flags="*")), "asl":
+ lambda il, operand: il.store(1, operand, il.shift_left(1, il.load(1, operand), il.const(1, 1), flags="czs")),
+ "asl@":
+ lambda il, operand: il.set_reg(1, "a", il.shift_left(1, operand, il.const(1, 1), flags="czs")), "and":
+ lambda il, operand: il.set_reg(1, "a", il.and_expr(1, il.reg(1, "a"), operand, flags="zs")), "bcc":
+ lambda il, operand: cond_branch(il, il.flag_condition(LowLevelILFlagCondition.LLFC_UGE), operand), "bcs":
+ lambda il, operand: cond_branch(il, il.flag_condition(LowLevelILFlagCondition.LLFC_ULT), operand), "beq":
+ lambda il, operand: cond_branch(il, il.flag_condition(LowLevelILFlagCondition.LLFC_E), operand), "bit":
+ lambda il, operand: il.and_expr(1, il.reg(1, "a"), operand, flags="czs"), "bmi":
+ lambda il, operand: cond_branch(il, il.flag_condition(LowLevelILFlagCondition.LLFC_NEG), operand),
+ "bne":
+ lambda il, operand: cond_branch(il, il.flag_condition(LowLevelILFlagCondition.LLFC_NE), operand), "bpl":
+ lambda il, operand: cond_branch(il, il.flag_condition(LowLevelILFlagCondition.LLFC_POS), operand), "brk":
+ lambda il, operand: il.system_call(), "bvc":
+ lambda il, operand: cond_branch(il, il.not_expr(0, il.flag("v")), operand), "bvs":
+ lambda il, operand: cond_branch(il, il.flag("v"), operand), "clc":
+ lambda il, operand: il.set_flag("c", il.const(0, 0)), "cld":
+ lambda il, operand: il.set_flag("d", il.const(0, 0)), "cli":
+ lambda il, operand: il.set_flag("i", il.const(0, 0)), "clv":
+ lambda il, operand: il.set_flag("v", il.const(0, 0)), "cmp":
+ lambda il, operand: il.sub(1, il.reg(1, "a"), operand, flags="czs"), "cpx":
+ lambda il, operand: il.sub(1, il.reg(1, "x"), operand, flags="czs"), "cpy":
+ lambda il, operand: il.sub(1, il.reg(1, "y"), operand, flags="czs"),
+ "dec":
+ lambda il, operand: il.store(1, operand, il.sub(1, il.load(1, operand), il.const(1, 1), flags="zs")), "dex":
+ lambda il, operand: il.set_reg(1, "x", il.sub(1, il.reg(1, "x"), il.const(1, 1), flags="zs")), "dey":
+ lambda il, operand: il.set_reg(1, "y", il.sub(1, il.reg(1, "y"), il.const(1, 1), flags="zs")), "eor":
+ lambda il, operand: il.set_reg(1, "a", il.xor_expr(1, il.reg(1, "a"), operand, flags="zs")), "inc":
+ lambda il, operand: il.store(1, operand, il.add(1, il.load(1, operand), il.const(1, 1), flags="zs")), "inx":
+ lambda il, operand: il.set_reg(1, "x", il.add(1, il.reg(1, "x"), il.const(1, 1), flags="zs")), "iny":
+ lambda il, operand: il.set_reg(1, "y", il.add(1, il.reg(1, "y"), il.const(1, 1), flags="zs")), "jmp":
+ lambda il, operand: jump(il, operand), "jsr":
+ lambda il, operand: il.call(operand), "lda":
+ lambda il, operand: il.set_reg(1, "a", operand, flags="zs"), "ldx":
+ lambda il, operand: il.set_reg(1, "x", operand, flags="zs"), "ldy":
+ lambda il, operand: il.set_reg(1, "y", operand, flags="zs"),
+ "lsr":
+ lambda il, operand: il.
+ store(1, operand, il.logical_shift_right(1, il.load(1, operand), il.const(1, 1), flags="czs")), "lsr@":
+ lambda il, operand: il.set_reg(1, "a", il.logical_shift_right(1, il.reg(1, "a"), il.const(1, 1), flags="czs")),
+ "nop":
+ lambda il, operand: il.nop(), "ora":
+ lambda il, operand: il.set_reg(1, "a", il.or_expr(1, il.reg(1, "a"), operand, flags="zs")), "pha":
+ lambda il, operand: il.push(1, il.reg(1, "a")), "php":
+ lambda il, operand: il.push(1, get_p_value(il)), "pla":
+ lambda il, operand: il.set_reg(1, "a", il.pop(1), flags="zs"), "plp":
+ lambda il, operand: set_p_value(il, il.pop(1)),
+ "rol":
+ lambda il, operand: il.
+ store(1, operand, il.rotate_left_carry(1, il.load(1, operand), il.const(1, 1), il.flag("c"), flags="czs")), "rol@":
+ lambda il, operand: il.
+ set_reg(1, "a", il.rotate_left_carry(1, il.reg(1, "a"), il.const(1, 1), il.flag("c"), flags="czs")), "ror":
+ lambda il, operand: il.
+ store(1, operand, il.rotate_right_carry(1, il.load(1, operand), il.const(1, 1), il.flag("c"), flags="czs")),
+ "ror@":
+ lambda il, operand: il.
+ set_reg(1, "a", il.rotate_right_carry(1, il.reg(1, "a"), il.const(1, 1), il.flag("c"), flags="czs")), "rti":
+ lambda il, operand: rti(il), "rts":
+ lambda il, operand: il.ret(il.add(2, il.pop(2), il.const(2, 1))), "sbc":
+ lambda il, operand: il.set_reg(1, "a", il.sub_borrow(1, il.reg(1, "a"), operand, il.flag("c"), flags="*")),
+ "sec":
+ lambda il, operand: il.set_flag("c", il.const(0, 1)), "sed":
+ lambda il, operand: il.set_flag("d", il.const(0, 1)), "sei":
+ lambda il, operand: il.set_flag("i", il.const(0, 1)), "sta":
+ lambda il, operand: il.store(1, operand, il.reg(1, "a")), "stx":
+ lambda il, operand: il.store(1, operand, il.reg(1, "x")), "sty":
+ lambda il, operand: il.store(1, operand, il.reg(1, "y")), "tax":
+ lambda il, operand: il.set_reg(1, "x", il.reg(1, "a"), flags="zs"), "tay":
+ lambda il, operand: il.set_reg(1, "y", il.reg(1, "a"), flags="zs"), "tsx":
+ lambda il, operand: il.set_reg(1, "x", il.reg(1, "s"), flags="zs"), "txa":
+ lambda il, operand: il.set_reg(1, "a", il.reg(1, "x"), flags="zs"), "txs":
+ lambda il, operand: il.set_reg(1, "s", il.reg(1, "x")), "tya":
+ lambda il, operand: il.set_reg(1, "a", il.reg(1, "y"), flags="zs")
}
@@ -372,33 +433,23 @@ class M6502(Architecture):
instr_alignment = 1
max_instr_length = 3
regs = {
- "a": RegisterInfo(RegisterName("a"), 1),
- "x": RegisterInfo(RegisterName("x"), 1),
- "y": RegisterInfo(RegisterName("y"), 1),
- "s": RegisterInfo(RegisterName("s"), 1)
+ "a": RegisterInfo(RegisterName("a"), 1), "x": RegisterInfo(RegisterName("x"), 1),
+ "y": RegisterInfo(RegisterName("y"), 1), "s": RegisterInfo(RegisterName("s"), 1)
}
stack_pointer = "s"
flags = ["c", "z", "i", "d", "b", "v", "s"]
flag_write_types = ["*", "czs", "zvs", "zs"]
flag_roles = {
- "c": FlagRole.SpecialFlagRole, # Not a normal carry flag, subtract result is inverted
- "z": FlagRole.ZeroFlagRole,
- "v": FlagRole.OverflowFlagRole,
- "s": FlagRole.NegativeSignFlagRole
+ "c": FlagRole.SpecialFlagRole, # Not a normal carry flag, subtract result is inverted
+ "z": FlagRole.ZeroFlagRole, "v": FlagRole.OverflowFlagRole, "s": FlagRole.NegativeSignFlagRole
}
flags_required_for_flag_condition = {
- LowLevelILFlagCondition.LLFC_UGE: ["c"],
- LowLevelILFlagCondition.LLFC_ULT: ["c"],
- LowLevelILFlagCondition.LLFC_E: ["z"],
- LowLevelILFlagCondition.LLFC_NE: ["z"],
- LowLevelILFlagCondition.LLFC_NEG: ["s"],
- LowLevelILFlagCondition.LLFC_POS: ["s"]
+ LowLevelILFlagCondition.LLFC_UGE: ["c"], LowLevelILFlagCondition.LLFC_ULT: ["c"],
+ LowLevelILFlagCondition.LLFC_E: ["z"], LowLevelILFlagCondition.LLFC_NE: ["z"],
+ LowLevelILFlagCondition.LLFC_NEG: ["s"], LowLevelILFlagCondition.LLFC_POS: ["s"]
}
flags_written_by_flag_write_type = {
- "*": ["c", "z", "v", "s"],
- "czs": ["c", "z", "s"],
- "zvs": ["z", "v", "s"],
- "zs": ["z", "s"]
+ "*": ["c", "z", "v", "s"], "czs": ["c", "z", "s"], "zvs": ["z", "v", "s"], "zs": ["z", "s"]
}
def decode_instruction(self, data, addr):
@@ -482,12 +533,16 @@ class M6502(Architecture):
return Architecture.get_flag_write_low_level_il(self, op, size, write_type, flag, operands, il)
def is_never_branch_patch_available(self, data, addr):
- if (data[0:1] == b"\x10") or (data[0:1] == b"\x30") or (data[0:1] == b"\x50") or (data[0:1] == b"\x70") or (data[0:1] == b"\x90") or (data[0:1] == b"\xb0") or (data[0:1] == b"\xd0") or (data[0:1] == b"\xf0"):
+ if (data[0:1] == b"\x10") or (data[0:1] == b"\x30") or (data[0:1] == b"\x50") or (data[0:1] == b"\x70") or (
+ data[0:1] == b"\x90"
+ ) or (data[0:1] == b"\xb0") or (data[0:1] == b"\xd0") or (data[0:1] == b"\xf0"):
return True
return False
def is_invert_branch_patch_available(self, data, addr):
- if (data[0:1] == b"\x10") or (data[0:1] == b"\x30") or (data[0:1] == b"\x50") or (data[0:1] == b"\x70") or (data[0:1] == b"\x90") or (data[0:1] == b"\xb0") or (data[0:1] == b"\xd0") or (data[0:1] == b"\xf0"):
+ if (data[0:1] == b"\x10") or (data[0:1] == b"\x30") or (data[0:1] == b"\x50") or (data[0:1] == b"\x70") or (
+ data[0:1] == b"\x90"
+ ) or (data[0:1] == b"\xb0") or (data[0:1] == b"\xd0") or (data[0:1] == b"\xf0"):
return True
return False
@@ -504,12 +559,16 @@ class M6502(Architecture):
return b"\xea" * len(data)
def never_branch(self, data, addr):
- if (data[0:1] == b"\x10") or (data[0:1] == b"\x30") or (data[0:1] == b"\x50") or (data[0:1] == b"\x70") or (data[0:1] == b"\x90") or (data[0:1] == b"\xb0") or (data[0:1] == b"\xd0") or (data[0:1] == b"\xf0"):
+ if (data[0:1] == b"\x10") or (data[0:1] == b"\x30") or (data[0:1] == b"\x50") or (data[0:1] == b"\x70") or (
+ data[0:1] == b"\x90"
+ ) or (data[0:1] == b"\xb0") or (data[0:1] == b"\xd0") or (data[0:1] == b"\xf0"):
return b"\xea" * len(data)
return None
def invert_branch(self, data, addr):
- if (data[0:1] == b"\x10") or (data[0:1] == b"\x30") or (data[0:1] == b"\x50") or (data[0:1] == b"\x70") or (data[0:1] == b"\x90") or (data[0:1] == b"\xb0") or (data[0:1] == b"\xd0") or (data[0:1] == b"\xf0"):
+ if (data[0:1] == b"\x10") or (data[0:1] == b"\x30") or (data[0:1] == b"\x50") or (data[0:1] == b"\x70") or (
+ data[0:1] == b"\x90"
+ ) or (data[0:1] == b"\xb0") or (data[0:1] == b"\xd0") or (data[0:1] == b"\xf0"):
return chr(ord(data[0:1]) ^ 0x20) + data[1:]
return None
@@ -523,8 +582,9 @@ class NESView(BinaryView):
name = "NES"
long_name = "NES ROM"
bank = None
+
def __init__(self, data):
- BinaryView.__init__(self, parent_view = data, file_metadata = data.file)
+ BinaryView.__init__(self, parent_view=data, file_metadata=data.file)
self.platform = Architecture['6502'].standalone_platform # type: ignore
@classmethod
@@ -554,14 +614,20 @@ class NESView(BinaryView):
self.rom_length = self.rom_banks * 0x4000
# Add mapping for RAM and hardware registers, not backed by file contents
- self.add_auto_segment(0, 0x8000, 0, 0, SegmentFlag.SegmentReadable | SegmentFlag.SegmentWritable | SegmentFlag.SegmentExecutable)
+ self.add_auto_segment(
+ 0, 0x8000, 0, 0, SegmentFlag.SegmentReadable | SegmentFlag.SegmentWritable | SegmentFlag.SegmentExecutable
+ )
# Add ROM mappings
assert self.__class__.bank is not None
- self.add_auto_segment(0x8000, 0x4000, self.rom_offset + (self.__class__.bank * 0x4000), 0x4000,
- SegmentFlag.SegmentReadable | SegmentFlag.SegmentExecutable)
- self.add_auto_segment(0xc000, 0x4000, self.rom_offset + self.rom_length - 0x4000, 0x4000,
- SegmentFlag.SegmentReadable | SegmentFlag.SegmentExecutable)
+ self.add_auto_segment(
+ 0x8000, 0x4000, self.rom_offset + (self.__class__.bank * 0x4000), 0x4000,
+ SegmentFlag.SegmentReadable | SegmentFlag.SegmentExecutable
+ )
+ self.add_auto_segment(
+ 0xc000, 0x4000, self.rom_offset + self.rom_length - 0x4000, 0x4000,
+ SegmentFlag.SegmentReadable | SegmentFlag.SegmentExecutable
+ )
nmi = struct.unpack("<H", self.read(0xfffa, 2))[0]
start = struct.unpack("<H", self.read(0xfffc, 2))[0]
@@ -605,9 +671,10 @@ class NESView(BinaryView):
self.define_auto_symbol(Symbol(SymbolType.DataSymbol, 0x4016, "JOY1"))
self.define_auto_symbol(Symbol(SymbolType.DataSymbol, 0x4017, "JOY2"))
- sym_files = [self.file.filename + ".%x.nl" % self.__class__.bank,
- self.file.filename + ".ram.nl",
- self.file.filename + ".%x.nl" % (self.rom_banks - 1)]
+ sym_files = [
+ self.file.filename + ".%x.nl" % self.__class__.bank, self.file.filename + ".ram.nl",
+ self.file.filename + ".%x.nl" % (self.rom_banks - 1)
+ ]
for f in sym_files:
if os.path.exists(f):
with open(f, "r") as f:
@@ -637,6 +704,7 @@ class NESView(BinaryView):
banks = []
for i in range(0, 32):
+
class NESViewBank(NESView):
bank = i
name = "NES Bank %X" % i
diff --git a/python/examples/notification_callbacks.py b/python/examples/notification_callbacks.py
index 015cd458..d3cbf26b 100644
--- a/python/examples/notification_callbacks.py
+++ b/python/examples/notification_callbacks.py
@@ -27,6 +27,7 @@ def reg_notif(view):
demo_notification = DemoNotification(view)
view.register_notification(demo_notification)
+
class DemoNotification(BinaryDataNotification):
def __init__(self, view):
self.view = view
@@ -100,4 +101,5 @@ class DemoNotification(BinaryDataNotification):
def type_field_ref_changed(self, *args):
log.log_info(inspect.stack()[0][3] + str(args))
+
PluginCommand.register("Register Notification", "", reg_notif)
diff --git a/python/examples/nsf.py b/python/examples/nsf.py
index 76a78f1c..5121d888 100644
--- a/python/examples/nsf.py
+++ b/python/examples/nsf.py
@@ -87,11 +87,14 @@ class NSFView(BinaryView):
log_info("Bank switching not implemented in this loader.")
# Add mapping for RAM and hardware registers, not backed by file contents
- self.add_auto_segment(0, 0x8000, 0, 0, SegmentFlag.SegmentReadable | SegmentFlag.SegmentWritable | SegmentFlag.SegmentExecutable)
+ self.add_auto_segment(
+ 0, 0x8000, 0, 0, SegmentFlag.SegmentReadable | SegmentFlag.SegmentWritable | SegmentFlag.SegmentExecutable
+ )
# Add ROM mappings
- self.add_auto_segment(0x8000, 0x4000, self.rom_offset, 0x4000,
- SegmentFlag.SegmentReadable | SegmentFlag.SegmentExecutable)
+ self.add_auto_segment(
+ 0x8000, 0x4000, self.rom_offset, 0x4000, SegmentFlag.SegmentReadable | SegmentFlag.SegmentExecutable
+ )
self.define_auto_symbol(Symbol(SymbolType.FunctionSymbol, self.play_address, "_play"))
self.define_auto_symbol(Symbol(SymbolType.FunctionSymbol, self.init_address, "_init"))
diff --git a/python/examples/pe_stat.py b/python/examples/pe_stat.py
index f5a6d89f..2e3f7755 100755
--- a/python/examples/pe_stat.py
+++ b/python/examples/pe_stat.py
@@ -27,7 +27,7 @@ import sys
import binaryninja
from collections import defaultdict
-opc2count = defaultdict(lambda:0)
+opc2count = defaultdict(lambda: 0)
target = sys.argv[1]
print('opening %s' % target)
@@ -48,6 +48,5 @@ total = sum([x[1] for x in opc2count.items()])
print('op frequency %')
print('-- --------- -')
-for opc in sorted(opc2count.keys(), key=lambda x:opc2count[x], reverse=True):
- print(opc.ljust(8), str(opc2count[opc]).ljust(16), '%.1f%%'%(100.0*opc2count[opc]/total))
-
+for opc in sorted(opc2count.keys(), key=lambda x: opc2count[x], reverse=True):
+ print(opc.ljust(8), str(opc2count[opc]).ljust(16), '%.1f%%' % (100.0 * opc2count[opc] / total))
diff --git a/python/examples/print_syscalls.py b/python/examples/print_syscalls.py
index 0ed40fb9..9956636f 100644
--- a/python/examples/print_syscalls.py
+++ b/python/examples/print_syscalls.py
@@ -19,7 +19,6 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
-
# Thanks to @theqlabs from arm.ninja for the nice writeup and idea for this plugin:
# http://arm.ninja/2016/03/08/intro-to-binary-ninja-api/
@@ -41,8 +40,7 @@ def print_syscalls(fileName):
register = calling_convention.int_arg_regs[0]
for func in bv.functions:
- syscalls = (il for il in chain.from_iterable(func.low_level_il)
- if il.operation == LowLevelILOperation.LLIL_SYSCALL)
+ syscalls = (il for il in chain.from_iterable(func.low_level_il) if il.operation == LowLevelILOperation.LLIL_SYSCALL)
for il in syscalls:
value = func.get_reg_value_at(il.address, register).value
print("System call address: {:#x} - {:d}".format(il.address, value))
diff --git a/python/examples/typelib_create.py b/python/examples/typelib_create.py
index 303fa350..2ac3855d 100755
--- a/python/examples/typelib_create.py
+++ b/python/examples/typelib_create.py
@@ -36,13 +36,16 @@ typelib.add_named_type('MyPointerType', Type.pointer(arch, Type.char()))
# typedef int MyTypedefType;
typelib.add_named_type('MyTypedefType', Type.int(4))
+
# example of typedef to typedef
# typedef MyTypedefType MySuperSpecialType;
-def create_named_type_reference(type_name:str, to_what:NamedTypeReferenceClass):
- return NamedTypeReferenceType.create(named_type_class=to_what, guid=None, name=type_name)
+def create_named_type_reference(type_name: str, to_what: NamedTypeReferenceClass):
+ return NamedTypeReferenceType.create(named_type_class=to_what, guid=None, name=type_name)
+
-typelib.add_named_type('MySuperSpecialType',
- create_named_type_reference('MySpecialType', NamedTypeReferenceClass.TypedefNamedTypeClass))
+typelib.add_named_type(
+ 'MySuperSpecialType', create_named_type_reference('MySpecialType', NamedTypeReferenceClass.TypedefNamedTypeClass)
+)
# We can demonstrate three type classes in the following example:
# StructureTypeClass, PointerTypeClass, NamedTypeReferenceClass
@@ -57,11 +60,11 @@ typelib.add_named_type('MySuperSpecialType',
# }
with StructureBuilder.builder(typelib, 'Rectangle') as struct_type:
- struct_type.append(Type.int(4), 'width')
- struct_type.append(Type.int(4), 'height')
- struct_type.append(Type.pointer(arch,
- create_named_type_reference('Point', NamedTypeReferenceClass.StructNamedTypeClass)),
- 'center')
+ struct_type.append(Type.int(4), 'width')
+ struct_type.append(Type.int(4), 'height')
+ struct_type.append(
+ Type.pointer(arch, create_named_type_reference('Point', NamedTypeReferenceClass.StructNamedTypeClass)), 'center'
+ )
# add a named type "Rectangle2":
# this type cannot be applied to variables until struct Point is declared
@@ -74,10 +77,9 @@ with StructureBuilder.builder(typelib, 'Rectangle') as struct_type:
# }
with StructureBuilder.builder(typelib, 'Rectangle2') as struct_type:
- struct_type.append(Type.int(4), 'width')
- struct_type.append(Type.int(4), 'height')
- struct_type.append(create_named_type_reference('Point', NamedTypeReferenceClass.StructNamedTypeClass),
- 'center')
+ struct_type.append(Type.int(4), 'width')
+ struct_type.append(Type.int(4), 'height')
+ struct_type.append(create_named_type_reference('Point', NamedTypeReferenceClass.StructNamedTypeClass), 'center')
# example: EnumerationTypeClass
enum_type = EnumerationBuilder.create([], None, arch=arch)
@@ -119,4 +121,3 @@ typelib.add_named_object('_MySuperComputation', ftype)
typelib.finalize()
print('writing test.bntl')
typelib.write_to_file('test.bntl')
-
diff --git a/python/examples/typelib_dump.py b/python/examples/typelib_dump.py
index 4beff0db..750ac78c 100755
--- a/python/examples/typelib_dump.py
+++ b/python/examples/typelib_dump.py
@@ -18,103 +18,106 @@ from binaryninja import typelibrary
#
# etc...
+
def obj2str(t, depth=0):
- indent = ' '*depth
- result = ''
+ indent = ' ' * depth
+ result = ''
+
+ if type(t) == binaryninja.types.StructureType:
+ result = '%sStructure\n' % (indent)
+ for m in t.members:
+ result += obj2str(m, depth + 1)
+ elif type(t) == binaryninja.types.StructureMember:
+ result = '%sStructureMember "%s"\n' % (indent, t._name)
+ result += type2str(t.type, depth + 1)
+ elif type(t) == binaryninja.types.FunctionParameter:
+ result = '%sFunctionParameter "%s"\n' % (indent, t.name)
+ result += type2str(t.type, depth + 1)
+ elif type(t) == binaryninja.types.NamedTypeReferenceType:
+ result = '%sNamedTypeReference %s\n' % (indent, repr(t))
+ elif type(t) == binaryninja.types.EnumerationType:
+ result = '%sEnumeration\n' % indent
+ for m in t.members:
+ result += obj2str(m, depth + 1)
+ elif type(t) == binaryninja.types.EnumerationMember:
+ result = '%sEnumerationMember %s==%d\n' % (indent, t.name, t.value)
+ elif t == None:
+ result = 'unimplemented'
+
+ return result
- if type(t) == binaryninja.types.StructureType:
- result = '%sStructure\n' % (indent)
- for m in t.members:
- result += obj2str(m, depth+1)
- elif type(t) == binaryninja.types.StructureMember:
- result = '%sStructureMember "%s"\n' % (indent, t._name)
- result += type2str(t.type, depth+1)
- elif type(t) == binaryninja.types.FunctionParameter:
- result = '%sFunctionParameter "%s"\n' % (indent, t.name)
- result += type2str(t.type, depth+1)
- elif type(t) == binaryninja.types.NamedTypeReferenceType:
- result = '%sNamedTypeReference %s\n' % (indent, repr(t))
- elif type(t) == binaryninja.types.EnumerationType:
- result = '%sEnumeration\n' % indent
- for m in t.members:
- result += obj2str(m, depth+1)
- elif type(t) == binaryninja.types.EnumerationMember:
- result = '%sEnumerationMember %s==%d\n' % (indent, t.name, t.value)
- elif t == None:
- result = 'unimplemented'
- return result
+def type2str(t: binaryninja.types.Type, depth=0):
+ indent = ' ' * depth
+ result = 'unimplemented'
-def type2str(t:binaryninja.types.Type, depth=0):
- indent = ' '*depth
- result = 'unimplemented'
+ assert isinstance(t, binaryninja.types.Type)
+ tc = t.type_class
- assert isinstance(t, binaryninja.types.Type)
- tc = t.type_class
+ if tc == TypeClass.VoidTypeClass:
+ result = '%sType class=Void\n' % indent
+ elif tc == TypeClass.BoolTypeClass:
+ result = '%sType class=Bool\n' % indent
+ elif tc == TypeClass.IntegerTypeClass:
+ result = '%sType class=Integer width=%d\n' % (indent, t.width)
+ elif tc == TypeClass.FloatTypeClass:
+ result = '%sType class=Float\n' % indent
+ elif tc == TypeClass.StructureTypeClass:
+ result = '%sType class=Structure\n' % indent
+ result += obj2str(t.structure, depth + 1)
+ elif tc == TypeClass.EnumerationTypeClass:
+ result = '%sType class=Enumeration\n' % indent
+ result += obj2str(t.enumeration, depth + 1)
+ elif tc == TypeClass.PointerTypeClass:
+ result = '%sType class=Pointer\n' % indent
+ result += type2str(t.target, depth + 1)
+ elif tc == TypeClass.ArrayTypeClass:
+ result = '%sType class=Array\n' % indent
+ elif tc == TypeClass.FunctionTypeClass:
+ result = '%sType class=Function\n' % indent
+ result += type2str(t.return_value, depth + 1)
+ for param in t.parameters:
+ result += obj2str(param, depth + 1)
+ elif tc == TypeClass.VarArgsTypeClass:
+ result = '%sType class=VarArgs\n' % indent
+ elif tc == TypeClass.ValueTypeClass:
+ result = '%sType class=Value\n' % indent
+ elif tc == TypeClass.NamedTypeReferenceClass:
+ result = '%sType class=NamedTypeReference\n' % indent
+ result += obj2str(t.named_type_reference, depth + 1)
+ elif tc == TypeClass.WideCharTypeClass:
+ result = '%sType class=WideChar\n' % indent
- if tc == TypeClass.VoidTypeClass:
- result = '%sType class=Void\n' % indent
- elif tc == TypeClass.BoolTypeClass:
- result = '%sType class=Bool\n' % indent
- elif tc == TypeClass.IntegerTypeClass:
- result = '%sType class=Integer width=%d\n' % (indent, t.width)
- elif tc == TypeClass.FloatTypeClass:
- result = '%sType class=Float\n' % indent
- elif tc == TypeClass.StructureTypeClass:
- result = '%sType class=Structure\n' % indent
- result += obj2str(t.structure, depth+1)
- elif tc == TypeClass.EnumerationTypeClass:
- result = '%sType class=Enumeration\n' % indent
- result += obj2str(t.enumeration, depth+1)
- elif tc == TypeClass.PointerTypeClass:
- result = '%sType class=Pointer\n' % indent
- result += type2str(t.target, depth+1)
- elif tc == TypeClass.ArrayTypeClass:
- result = '%sType class=Array\n' % indent
- elif tc == TypeClass.FunctionTypeClass:
- result = '%sType class=Function\n' % indent
- result += type2str(t.return_value, depth+1)
- for param in t.parameters:
- result += obj2str(param, depth+1)
- elif tc == TypeClass.VarArgsTypeClass:
- result = '%sType class=VarArgs\n' % indent
- elif tc == TypeClass.ValueTypeClass:
- result = '%sType class=Value\n' % indent
- elif tc == TypeClass.NamedTypeReferenceClass:
- result = '%sType class=NamedTypeReference\n' % indent
- result += obj2str(t.named_type_reference, depth+1)
- elif tc == TypeClass.WideCharTypeClass:
- result = '%sType class=WideChar\n' % indent
+ return result
- return result
if __name__ == '__main__':
- binaryninja._init_plugins()
+ binaryninja._init_plugins()
- if len(sys.argv) <= 1:
- raise Exception('supply typelib file')
+ if len(sys.argv) <= 1:
+ raise Exception('supply typelib file')
- fpath = sys.argv[-1]
- print(' reading: %s' % fpath)
+ fpath = sys.argv[-1]
+ print(' reading: %s' % fpath)
- tl = typelibrary.TypeLibrary.load_from_file(fpath)
- print(' name: %s' % tl.name)
- print(' arch: %s' % tl.arch)
- print(' guid: %s' % tl.guid)
- print('dependency_name: %s' % tl.dependency_name)
- print('alternate_names: %s' % tl.alternate_names)
- print(' platform_names: %s' % tl.platform_names)
- print('')
+ tl = typelibrary.TypeLibrary.load_from_file(fpath)
+ print(' name: %s' % tl.name)
+ print(' arch: %s' % tl.arch)
+ print(' guid: %s' % tl.guid)
+ print('dependency_name: %s' % tl.dependency_name)
+ print('alternate_names: %s' % tl.alternate_names)
+ print(' platform_names: %s' % tl.platform_names)
+ print('')
- print(' named_objects: %d' % len(tl.named_objects))
- for (key, val) in tl.named_objects.items():
- print('\t"%s" %s' % (str(key), str(val)))
+ print(' named_objects: %d' % len(tl.named_objects))
+ for (key, val) in tl.named_objects.items():
+ print('\t"%s" %s' % (str(key), str(val)))
- print('')
+ print('')
- print(' named_types: %d' % len(tl.named_types))
- for (key,val) in tl.named_types.items():
- line = 'typelib.named_types["%s"] =' % (str(key))
- print(line)
- print('-'*len(line))
- print(type2str(val))
+ print(' named_types: %d' % len(tl.named_types))
+ for (key, val) in tl.named_types.items():
+ line = 'typelib.named_types["%s"] =' % (str(key))
+ print(line)
+ print('-' * len(line))
+ print(type2str(val))
diff --git a/python/examples/ui_notifications.py b/python/examples/ui_notifications.py
index 9d423f77..4a708061 100644
--- a/python/examples/ui_notifications.py
+++ b/python/examples/ui_notifications.py
@@ -20,74 +20,74 @@
from binaryninjaui import *
+
class UINotification(UIContextNotification):
- def __init__(self):
- UIContextNotification.__init__(self)
- UIContext.registerNotification(self)
- print("py UIContext.registerNotification")
+ def __init__(self):
+ UIContextNotification.__init__(self)
+ UIContext.registerNotification(self)
+ print("py UIContext.registerNotification")
- def __del__(self):
- UIContext.unregisterNotification(self)
- print("py UIContext.unregisterNotification")
+ def __del__(self):
+ UIContext.unregisterNotification(self)
+ print("py UIContext.unregisterNotification")
- def OnContextOpen(self, context):
- print("py OnContextOpen")
+ def OnContextOpen(self, context):
+ print("py OnContextOpen")
- def OnContextClose(self, context):
- print("py OnContextClose")
+ def OnContextClose(self, context):
+ print("py OnContextClose")
- def OnBeforeOpenDatabase(self, context, metadata):
- print(f"py OnBeforeOpenDatabase {metadata.filename}")
- return True
+ def OnBeforeOpenDatabase(self, context, metadata):
+ print(f"py OnBeforeOpenDatabase {metadata.filename}")
+ return True
- def OnAfterOpenDatabase(self, context, metadata, data):
- print(f"py OnAfterOpenDatabase {metadata.filename} {data.name}")
- return True
+ def OnAfterOpenDatabase(self, context, metadata, data):
+ print(f"py OnAfterOpenDatabase {metadata.filename} {data.name}")
+ return True
- def OnBeforeOpenFile(self, context, file):
- print(f"py OnBeforeOpenFile {file.getFilename()}")
- return True
+ def OnBeforeOpenFile(self, context, file):
+ print(f"py OnBeforeOpenFile {file.getFilename()}")
+ return True
- def OnAfterOpenFile(self, context, file, frame):
- print(f"py OnAfterOpenFile {file.getFilename()} {frame.getShortFileName()}")
+ def OnAfterOpenFile(self, context, file, frame):
+ print(f"py OnAfterOpenFile {file.getFilename()} {frame.getShortFileName()}")
- def OnBeforeSaveFile(self, context, file, frame):
- print(f"py OnBeforeSaveFile {file.getFilename()} {frame.getShortFileName()}")
- return True
+ def OnBeforeSaveFile(self, context, file, frame):
+ print(f"py OnBeforeSaveFile {file.getFilename()} {frame.getShortFileName()}")
+ return True
- def OnAfterSaveFile(self, context, file, frame):
- print(f"py OnAfterSaveFile {file.getFilename()} {frame.getShortFileName()}")
+ def OnAfterSaveFile(self, context, file, frame):
+ print(f"py OnAfterSaveFile {file.getFilename()} {frame.getShortFileName()}")
- def OnBeforeCloseFile(self, context, file, frame):
- print(f"py OnBeforeCloseFile {file.getFilename()} {frame.getShortFileName()}")
- return True
+ def OnBeforeCloseFile(self, context, file, frame):
+ print(f"py OnBeforeCloseFile {file.getFilename()} {frame.getShortFileName()}")
+ return True
- def OnAfterCloseFile(self, context, file, frame):
- print(f"py OnAfterCloseFile {file.getFilename()} {frame.getShortFileName()}")
+ def OnAfterCloseFile(self, context, file, frame):
+ print(f"py OnAfterCloseFile {file.getFilename()} {frame.getShortFileName()}")
- def OnViewChange(self, context, frame, type):
- if frame:
- print(f"py OnViewChange {frame.getShortFileName()} / {type}")
- else:
- print("py OnViewChange")
+ def OnViewChange(self, context, frame, type):
+ if frame:
+ print(f"py OnViewChange {frame.getShortFileName()} / {type}")
+ else:
+ print("py OnViewChange")
- def OnAddressChange(self, context, frame, view, location):
- if frame:
- print(f"py OnAddressChange {frame.getShortFileName()} {location.getOffset()}")
- else:
- print(f"py OnAddressChange {location.getOffset()}")
+ def OnAddressChange(self, context, frame, view, location):
+ if frame:
+ print(f"py OnAddressChange {frame.getShortFileName()} {location.getOffset()}")
+ else:
+ print(f"py OnAddressChange {location.getOffset()}")
- def GetNameForFile(self, context, file, name):
- # This function only works in C++: Name is an out param (cpp: &name), and not modifiable by python.
- print(f"py GetNameForFile {file.getFilename()} {name}")
- return False
+ def GetNameForFile(self, context, file, name):
+ # This function only works in C++: Name is an out param (cpp: &name), and not modifiable by python.
+ print(f"py GetNameForFile {file.getFilename()} {name}")
+ return False
- def GetNameForPath(self, context, path, name):
- # This function only works in C++: Name is an out param (cpp: &name), and not modifiable by python.
- print(f"py GetNameForPath {path} {name}")
- return False
+ def GetNameForPath(self, context, path, name):
+ # This function only works in C++: Name is an out param (cpp: &name), and not modifiable by python.
+ print(f"py GetNameForPath {path} {name}")
+ return False
# Register as a global so it doesn't get destructed
notif = UINotification()
-
diff --git a/python/fileaccessor.py b/python/fileaccessor.py
index 85642bff..451b2d20 100644
--- a/python/fileaccessor.py
+++ b/python/fileaccessor.py
@@ -25,6 +25,7 @@ import ctypes
from . import _binaryninjacore as core
from .log import log_error
+
class FileAccessor:
def __init__(self):
self._cb = core.BNFileAccessor()
@@ -39,7 +40,7 @@ class FileAccessor:
def read(self, offset, length):
return NotImplemented
- def write(self, offset:int, data:bytes):
+ def write(self, offset: int, data: bytes):
return NotImplemented
def __len__(self):
diff --git a/python/filemetadata.py b/python/filemetadata.py
index c9f9a050..5fde78d9 100644
--- a/python/filemetadata.py
+++ b/python/filemetadata.py
@@ -26,7 +26,7 @@ from typing import Any, Callable, Optional, List
import binaryninja
from . import _binaryninjacore as core
from .enums import SaveOption
-from . import associateddatastore #required for _FileMetadataAssociatedDataStore
+from . import associateddatastore #required for _FileMetadataAssociatedDataStore
from .log import log_error
from . import binaryview
from . import database
@@ -34,6 +34,7 @@ from . import database
ProgressFuncType = Callable[[int, int], bool]
ViewName = str
+
class NavigationHandler:
def _register(self, handle) -> None:
self._cb = core.BNNavigationHandler()
@@ -43,7 +44,7 @@ class NavigationHandler:
self._cb.navigate = self._cb.navigate.__class__(self._navigate)
core.BNSetFileMetadataNavigationHandler(handle, self._cb)
- def _get_current_view(self, ctxt:Any):
+ def _get_current_view(self, ctxt: Any):
try:
view = self.get_current_view()
except:
@@ -51,14 +52,14 @@ class NavigationHandler:
view = ""
return core.BNAllocString(view)
- def _get_current_offset(self, ctxt:Any) -> int:
+ def _get_current_offset(self, ctxt: Any) -> int:
try:
return self.get_current_offset()
except:
log_error(traceback.format_exc())
return 0
- def _navigate(self, ctxt:Any, view:ViewName, offset:int) -> bool:
+ def _navigate(self, ctxt: Any, view: ViewName, offset: int) -> bool:
try:
return self.navigate(view, offset)
except:
@@ -71,7 +72,7 @@ class NavigationHandler:
def get_current_offset(self) -> int:
return NotImplemented
- def navigate(self, view:ViewName, offset:int) -> bool:
+ def navigate(self, view: ViewName, offset: int) -> bool:
return NotImplemented
@@ -79,7 +80,6 @@ class SaveSettings:
"""
``class SaveSettings`` is used to specify actions and options that apply to saving a database (.bndb).
"""
-
def __init__(self, handle=None):
if handle is None:
self.handle = core.BNCreateSaveSettings()
@@ -90,12 +90,12 @@ class SaveSettings:
if core is not None:
core.BNFreeSaveSettings(self.handle)
- def is_option_set(self, option:SaveOption) -> bool:
+ def is_option_set(self, option: SaveOption) -> bool:
if isinstance(option, str):
option = SaveOption[option]
return core.BNIsSaveSettingsOptionSet(self.handle, option)
- def set_option(self, option:SaveOption, state:bool=True):
+ def set_option(self, option: SaveOption, state: bool = True):
"""
Set a SaveOption in this instance.
@@ -122,7 +122,7 @@ class FileMetadata:
_associated_data = {}
- def __init__(self, filename:Optional[str]=None, handle:Optional[core.BNFileMetadataHandle]=None):
+ def __init__(self, filename: Optional[str] = None, handle: Optional[core.BNFileMetadataHandle] = None):
"""
Instantiates a new FileMetadata class.
@@ -137,7 +137,7 @@ class FileMetadata:
_handle = core.BNCreateFileMetadata()
if filename is not None:
core.BNSetFilename(_handle, str(filename))
- self._nav:Optional[NavigationHandler] = None
+ self._nav: Optional[NavigationHandler] = None
assert _handle is not None
self.handle = _handle
@@ -168,7 +168,7 @@ class FileMetadata:
return self._nav
@nav.setter
- def nav(self, value:NavigationHandler) -> None:
+ def nav(self, value: NavigationHandler) -> None:
self._nav = value
@classmethod
@@ -178,7 +178,7 @@ class FileMetadata:
del cls._associated_data[handle.value]
@staticmethod
- def set_default_session_data(name:str, value:Any) -> None:
+ def set_default_session_data(name: str, value: Any) -> None:
_FileMetadataAssociatedDataStore.set_default(name, value)
@property
@@ -187,7 +187,7 @@ class FileMetadata:
return core.BNGetOriginalFilename(self.handle)
@original_filename.setter
- def original_filename(self, value:str) -> None:
+ def original_filename(self, value: str) -> None:
core.BNSetOriginalFilename(self.handle, str(value))
@property
@@ -196,7 +196,7 @@ class FileMetadata:
return core.BNGetFilename(self.handle)
@filename.setter
- def filename(self, value:str) -> None:
+ def filename(self, value: str) -> None:
core.BNSetFilename(self.handle, str(value))
@property
@@ -205,7 +205,7 @@ class FileMetadata:
return core.BNIsFileModified(self.handle)
@modified.setter
- def modified(self, value:bool) -> None:
+ def modified(self, value: bool) -> None:
if value:
core.BNMarkFileModified(self.handle)
else:
@@ -217,7 +217,7 @@ class FileMetadata:
return core.BNIsAnalysisChanged(self.handle)
@property
- def has_database(self, binary_view_type:ViewName="") -> bool:
+ def has_database(self, binary_view_type: ViewName = "") -> bool:
"""Whether the FileMetadata is backed by a database, or if specified, a specific BinaryViewType (read-only)"""
return core.BNIsBackedByDatabase(self.handle, binary_view_type)
@@ -226,7 +226,7 @@ class FileMetadata:
return core.BNGetCurrentView(self.handle)
@view.setter
- def view(self, value:ViewName) -> None:
+ def view(self, value: ViewName) -> None:
core.BNNavigate(self.handle, str(value), core.BNGetCurrentOffset(self.handle))
@property
@@ -235,7 +235,7 @@ class FileMetadata:
return core.BNGetCurrentOffset(self.handle)
@offset.setter
- def offset(self, value:int) -> None:
+ def offset(self, value: int) -> None:
core.BNNavigate(self.handle, core.BNGetCurrentView(self.handle), value)
@property
@@ -244,7 +244,7 @@ class FileMetadata:
view = core.BNGetFileViewOfType(self.handle, "Raw")
if view is None:
return None
- return binaryview.BinaryView(file_metadata = self, handle = view)
+ return binaryview.BinaryView(file_metadata=self, handle=view)
@property
def database(self) -> Optional['database.Database']:
@@ -260,7 +260,7 @@ class FileMetadata:
return not core.BNIsFileModified(self.handle)
@saved.setter
- def saved(self, value:bool) -> None:
+ def saved(self, value: bool) -> None:
if value:
core.BNMarkFileSaved(self.handle)
else:
@@ -272,7 +272,7 @@ class FileMetadata:
return self._nav
@navigation.setter
- def navigation(self, value:NavigationHandler) -> None:
+ def navigation(self, value: NavigationHandler) -> None:
value._register(self.handle)
self._nav = value
@@ -392,7 +392,7 @@ class FileMetadata:
"""
core.BNRedo(self.handle)
- def navigate(self, view:ViewName, offset:int) -> bool:
+ def navigate(self, view: ViewName, offset: int) -> bool:
"""
``navigate`` navigates the UI to the specified virtual address
@@ -410,7 +410,9 @@ class FileMetadata:
"""
return core.BNNavigate(self.handle, str(view), offset)
- def create_database(self, filename:str, progress_func:Optional[ProgressFuncType]= None, settings:SaveSettings=None):
+ def create_database(
+ self, filename: str, progress_func: Optional[ProgressFuncType] = None, settings: SaveSettings = None
+ ):
"""
``create_database`` writes the current database (.bndb) out to the specified file.
@@ -433,28 +435,32 @@ class FileMetadata:
return core.BNCreateDatabase(self.raw.handle, str(filename), _settings)
else:
_progress_func = progress_func
- return core.BNCreateDatabaseWithProgress(self.raw.handle, str(filename), None,
- ctypes.CFUNCTYPE(ctypes.c_bool, ctypes.c_void_p, ctypes.c_ulonglong, ctypes.c_ulonglong)(
- lambda ctxt, cur, total: _progress_func(cur, total)), settings)
+ return core.BNCreateDatabaseWithProgress(
+ self.raw.handle, str(filename), None,
+ ctypes.CFUNCTYPE(ctypes.c_bool, ctypes.c_void_p, ctypes.c_ulonglong,
+ ctypes.c_ulonglong)(lambda ctxt, cur, total: _progress_func(cur, total)), settings
+ )
- def open_existing_database(self, filename:str, progress_func:Callable[[int, int], bool]=None):
+ def open_existing_database(self, filename: str, progress_func: Callable[[int, int], bool] = None):
if progress_func is None:
view = core.BNOpenExistingDatabase(self.handle, str(filename))
else:
- view = core.BNOpenExistingDatabaseWithProgress(self.handle, str(filename), None,
- ctypes.CFUNCTYPE(ctypes.c_bool, ctypes.c_void_p, ctypes.c_ulonglong, ctypes.c_ulonglong)(
- lambda ctxt, cur, total: progress_func(cur, total)))
+ view = core.BNOpenExistingDatabaseWithProgress(
+ self.handle, str(filename), None,
+ ctypes.CFUNCTYPE(ctypes.c_bool, ctypes.c_void_p, ctypes.c_ulonglong,
+ ctypes.c_ulonglong)(lambda ctxt, cur, total: progress_func(cur, total))
+ )
if view is None:
return None
- return binaryview.BinaryView(file_metadata = self, handle = view)
+ return binaryview.BinaryView(file_metadata=self, handle=view)
- def open_database_for_configuration(self, filename:str) -> Optional['binaryview.BinaryView']:
+ def open_database_for_configuration(self, filename: str) -> Optional['binaryview.BinaryView']:
view = core.BNOpenDatabaseForConfiguration(self.handle, str(filename))
if view is None:
return None
- return binaryview.BinaryView(file_metadata = self, handle = view)
+ return binaryview.BinaryView(file_metadata=self, handle=view)
- def save_auto_snapshot(self, progress_func:Optional[ProgressFuncType]=None, settings:SaveSettings=None):
+ def save_auto_snapshot(self, progress_func: Optional[ProgressFuncType] = None, settings: SaveSettings = None):
_settings = None
if settings is not None:
_settings = settings.handle
@@ -464,21 +470,28 @@ class FileMetadata:
return core.BNSaveAutoSnapshot(self.raw.handle, _settings)
else:
_progress_func = progress_func
- return core.BNSaveAutoSnapshotWithProgress(self.raw.handle, None,
- ctypes.CFUNCTYPE(ctypes.c_bool, ctypes.c_void_p, ctypes.c_ulonglong, ctypes.c_ulonglong)(
- lambda ctxt, cur, total: _progress_func(cur, total)), _settings)
+ return core.BNSaveAutoSnapshotWithProgress(
+ self.raw.handle, None,
+ ctypes.CFUNCTYPE(ctypes.c_bool, ctypes.c_void_p, ctypes.c_ulonglong,
+ ctypes.c_ulonglong)(lambda ctxt, cur, total: _progress_func(cur, total)), _settings
+ )
- def merge_user_analysis(self, path:str, progress_func:ProgressFuncType, excluded_hashes:Optional[List[str]]=None):
+ def merge_user_analysis(
+ self, path: str, progress_func: ProgressFuncType, excluded_hashes: Optional[List[str]] = None
+ ):
if excluded_hashes is None:
excluded_hashes = []
excluded = (ctypes.c_char_p * len(excluded_hashes))()
for i in range(len(excluded_hashes)):
excluded[i] = core.cstr(excluded_hashes[i])
- return core.BNMergeUserAnalysis(self.handle, str(path), None,
- ctypes.CFUNCTYPE(None, ctypes.c_bool, ctypes.c_ulonglong, ctypes.c_ulonglong)(
- lambda ctxt, cur, total: progress_func(cur, total)), excluded, len(excluded_hashes))
+ return core.BNMergeUserAnalysis(
+ self.handle, str(path), None,
+ ctypes.CFUNCTYPE(None, ctypes.c_bool, ctypes.c_ulonglong,
+ ctypes.c_ulonglong)(lambda ctxt, cur, total: progress_func(cur, total)), excluded,
+ len(excluded_hashes)
+ )
- def get_view_of_type(self, name:str) -> Optional['binaryview.BinaryView']:
+ def get_view_of_type(self, name: str) -> Optional['binaryview.BinaryView']:
view = core.BNGetFileViewOfType(self.handle, str(name))
if view is None:
view_type = core.BNGetBinaryViewTypeByName(str(name))
@@ -489,7 +502,7 @@ class FileMetadata:
view = core.BNCreateBinaryViewOfType(view_type, self.raw.handle)
if view is None:
return None
- return binaryview.BinaryView(file_metadata = self, handle = view)
+ return binaryview.BinaryView(file_metadata=self, handle=view)
def open_project(self) -> bool:
return core.BNOpenProject(self.handle)
diff --git a/python/flowgraph.py b/python/flowgraph.py
index 7f4be6e2..165dd2b7 100644
--- a/python/flowgraph.py
+++ b/python/flowgraph.py
@@ -26,8 +26,9 @@ from typing import Optional
# Binary Ninja components
import binaryninja
from . import _binaryninjacore as core
-from .enums import (BranchType, InstructionTextTokenType, HighlightStandardColor, FlowGraphOption,
- EdgePenStyle, ThemeColor)
+from .enums import (
+ BranchType, InstructionTextTokenType, HighlightStandardColor, FlowGraphOption, EdgePenStyle, ThemeColor
+)
from . import function
from . import binaryview
from . import lowlevelil
@@ -52,8 +53,8 @@ class FlowGraphEdge:
return "<%s: %s>" % (self.type.name, repr(self.target))
def __eq__(self, other):
- return (self.type, self.source, self.target, self.points, self.back_edge, self.style) == \
- (other.type, other.source, other.target, other.points, other.back_edge, other.style)
+ return (self.type, self.source, self.target, self.points, self.back_edge,
+ self.style) == (other.type, other.source, other.target, other.points, other.back_edge, other.style)
def __hash__(self):
return hash((self.type, self.source, self.target, self.points, self.back_edge, self.style))
@@ -77,14 +78,14 @@ class EdgeStyle:
return EdgeStyle(edge_style.style, edge_style.width, edge_style.color)
def __eq__(self, other):
- return (self.style, self.width, self.color) == \
- (other.style, other.width, other.color)
+ return (self.style, self.width, self.color) == (other.style, other.width, other.color)
def __hash__(self):
return hash((self.style, self.width, self.color))
+
class FlowGraphNode:
- def __init__(self, graph = None, handle = None):
+ def __init__(self, graph=None, handle=None):
_handle = handle
if _handle is None:
if graph is None:
@@ -94,7 +95,7 @@ class FlowGraphNode:
self.handle = _handle
self._graph = graph
if self._graph is None:
- self._graph = FlowGraph(handle = core.BNGetFlowGraphNodeOwner(self.handle))
+ self._graph = FlowGraph(handle=core.BNGetFlowGraphNodeOwner(self.handle))
def __del__(self):
if core is not None:
@@ -131,7 +132,8 @@ class FlowGraphNode:
try:
for i in range(0, count.value):
addr = lines[i].addr
- if (lines[i].instrIndex != 0xffffffffffffffff) and (block is not None) and hasattr(block, 'il_function'):
+ if (lines[i].instrIndex != 0xffffffffffffffff) and (block
+ is not None) and hasattr(block, 'il_function'):
il_instr = block.__dict__['il_function'][lines[i].instrIndex]
else:
il_instr = None
@@ -142,7 +144,7 @@ class FlowGraphNode:
@property
def graph(self):
- return self._graph
+ return self._graph
@graph.setter
def graph(self, value):
@@ -159,14 +161,18 @@ class FlowGraphNode:
core.BNFreeBasicBlock(block)
return None
- view = binaryview.BinaryView(handle = core.BNGetFunctionData(func_handle))
+ view = binaryview.BinaryView(handle=core.BNGetFunctionData(func_handle))
func = function.Function(view, func_handle)
if core.BNIsLowLevelILBasicBlock(block):
- block = lowlevelil.LowLevelILBasicBlock(block,
- lowlevelil.LowLevelILFunction(func.arch, core.BNGetBasicBlockLowLevelILFunction(block), func), view)
+ block = lowlevelil.LowLevelILBasicBlock(
+ block, lowlevelil.LowLevelILFunction(func.arch, core.BNGetBasicBlockLowLevelILFunction(block), func),
+ view
+ )
elif core.BNIsMediumLevelILBasicBlock(block):
- mlil_func = mediumlevelil.MediumLevelILFunction(func.arch, core.BNGetBasicBlockMediumLevelILFunction(block), func)
+ mlil_func = mediumlevelil.MediumLevelILFunction(
+ func.arch, core.BNGetBasicBlockMediumLevelILFunction(block), func
+ )
block = mediumlevelil.MediumLevelILBasicBlock(block, mlil_func, view)
elif core.BNIsHighLevelILBasicBlock(block):
hlil_func = highlevelil.HighLevelILFunction(func.arch, core.BNGetBasicBlockHighLevelILFunction(block), func)
@@ -230,7 +236,9 @@ class FlowGraphNode:
for i in range(0, len(lines)):
line = lines[i]
if isinstance(line, str):
- line = function.DisassemblyTextLine([function.InstructionTextToken(InstructionTextTokenType.TextToken, line)])
+ line = function.DisassemblyTextLine([
+ function.InstructionTextToken(InstructionTextTokenType.TextToken, line)
+ ])
if not isinstance(line, function.DisassemblyTextLine):
line = function.DisassemblyTextLine(line)
if line.address is None:
@@ -269,7 +277,9 @@ class FlowGraphNode:
points = []
for j in range(0, edges[i].pointCount):
points.append((edges[i].points[j].x, edges[i].points[j].y))
- result.append(FlowGraphEdge(branch_type, self, target, points, edges[i].backEdge, EdgeStyle(edges[i].style)))
+ result.append(
+ FlowGraphEdge(branch_type, self, target, points, edges[i].backEdge, EdgeStyle(edges[i].style))
+ )
core.BNFreeFlowGraphNodeEdgeList(edges, count.value)
return result
@@ -288,7 +298,9 @@ class FlowGraphNode:
points = []
for j in range(0, edges[i].pointCount):
points.append((edges[i].points[j].x, edges[i].points[j].y))
- result.append(FlowGraphEdge(branch_type, self, target, points, edges[i].backEdge, EdgeStyle(edges[i].style)))
+ result.append(
+ FlowGraphEdge(branch_type, self, target, points, edges[i].backEdge, EdgeStyle(edges[i].style))
+ )
core.BNFreeFlowGraphNodeEdgeList(edges, count.value)
return result
@@ -336,7 +348,7 @@ class FlowGraphNode:
class FlowGraphLayoutRequest:
- def __init__(self, graph, callback = None):
+ def __init__(self, graph, callback=None):
self.on_complete = callback
self._cb = ctypes.CFUNCTYPE(None, ctypes.c_void_p)(self._complete)
self.handle = core.BNStartFlowGraphLayout(graph.handle, None, self._cb)
@@ -402,7 +414,7 @@ class FlowGraph:
"""
_registered_instances = []
- def __init__(self, handle:Optional[core.BNCustomFlowGraphHandle] = None):
+ def __init__(self, handle: Optional[core.BNCustomFlowGraphHandle] = None):
_handle = handle
if _handle is None:
self._ext_cb = core.BNCustomFlowGraph()
@@ -541,7 +553,7 @@ class FlowGraph:
func = core.BNGetFunctionForFlowGraph(self.handle)
if func is None:
return None
- return function.Function(handle = func)
+ return function.Function(handle=func)
@function.setter
def function(self, func):
@@ -555,7 +567,7 @@ class FlowGraph:
view = core.BNGetViewForFlowGraph(self.handle)
if view is None:
return None
- return binaryview.BinaryView(handle = view)
+ return binaryview.BinaryView(handle=view)
@view.setter
def view(self, view):
@@ -732,7 +744,7 @@ class FlowGraph:
def shows_secondary_reg_highlighting(self, value):
self.set_option(FlowGraphOption.FlowGraphShowsSecondaryRegisterHighlighting, value)
- def layout(self, callback = None):
+ def layout(self, callback=None):
"""
``layout`` starts rendering a graph for display. Once a layout is complete, each node will contain
coordinates and extents that can be used to render a graph with minimum additional computation.
@@ -807,7 +819,7 @@ class FlowGraph:
"""
return NotImplemented
- def set_option(self, option, value = True):
+ def set_option(self, option, value=True):
core.BNSetFlowGraphOption(self.handle, option, value)
def is_option_set(self, option):
diff --git a/python/function.py b/python/function.py
index 61cc11a8..2e93ac2e 100644
--- a/python/function.py
+++ b/python/function.py
@@ -26,9 +26,10 @@ from dataclasses import dataclass
# Binary Ninja components
from . import _binaryninjacore as core
-from .enums import (AnalysisSkipReason, FunctionGraphType, SymbolType, InstructionTextTokenType,
- HighlightStandardColor, HighlightColorStyle, DisassemblyOption,
- IntegerDisplayType, FunctionAnalysisSkipOverride)
+from .enums import (
+ AnalysisSkipReason, FunctionGraphType, SymbolType, InstructionTextTokenType, HighlightStandardColor,
+ HighlightColorStyle, DisassemblyOption, IntegerDisplayType, FunctionAnalysisSkipOverride
+)
from . import associateddatastore # Required in the main scope due to being an argument for _FunctionAssociatedDataStore
from . import types
@@ -50,30 +51,35 @@ from . import platform as _platform
# The following imports are for backward compatibility with API version < 3.0
# so old plugins which do 'from binaryninja.function import RegisterInfo' will still work
-from .architecture import (RegisterInfo, RegisterStackInfo, IntrinsicInput,
- IntrinsicInfo, InstructionBranch, InstructionInfo, InstructionTextToken)
-from .variable import (Variable, LookupTableEntry, RegisterValue, ValueRange,
- PossibleValueSet, StackVariableReference, ConstantReference, IndirectBranchInfo,
- ParameterVariables, AddressRange)
+from .architecture import (
+ RegisterInfo, RegisterStackInfo, IntrinsicInput, IntrinsicInfo, InstructionBranch, InstructionInfo,
+ InstructionTextToken
+)
+from .variable import (
+ Variable, LookupTableEntry, RegisterValue, ValueRange, PossibleValueSet, StackVariableReference, ConstantReference,
+ IndirectBranchInfo, ParameterVariables, AddressRange
+)
from .enums import RegisterValueType
ExpressionIndex = int
InstructionIndex = int
AnyFunctionType = Union['Function', 'lowlevelil.LowLevelILFunction', 'mediumlevelil.MediumLevelILFunction',
- 'highlevelil.HighLevelILFunction']
+ 'highlevelil.HighLevelILFunction']
ILFunctionType = Union['lowlevelil.LowLevelILFunction', 'mediumlevelil.MediumLevelILFunction',
- 'highlevelil.HighLevelILFunction']
+ 'highlevelil.HighLevelILFunction']
ILInstructionType = Union['lowlevelil.LowLevelILInstruction', 'mediumlevelil.MediumLevelILInstruction',
- 'highlevelil.HighLevelILInstruction']
+ 'highlevelil.HighLevelILInstruction']
StringOrType = Union[str, 'types.Type', 'types.TypeBuilder']
+
def _function_name_():
return inspect.stack()[1][0].f_code.co_name
+
@dataclass(frozen=True)
class ArchAndAddr:
- arch:'architecture.Architecture'
- addr:int
+ arch: 'architecture.Architecture'
+ addr: int
def __repr__(self):
return f"<archandaddr {self.arch} @ {self.addr:#x}>"
@@ -84,7 +90,7 @@ class _FunctionAssociatedDataStore(associateddatastore._AssociatedDataStore):
class DisassemblySettings:
- def __init__(self, handle:core.BNDisassemblySettingsHandle=None):
+ def __init__(self, handle: core.BNDisassemblySettingsHandle = None):
if handle is None:
self.handle = core.BNCreateDisassemblySettings()
else:
@@ -99,7 +105,7 @@ class DisassemblySettings:
return core.BNGetDisassemblyWidth(self.handle)
@width.setter
- def width(self, value:int) -> None:
+ def width(self, value: int) -> None:
core.BNSetDisassemblyWidth(self.handle, value)
@property
@@ -107,15 +113,15 @@ class DisassemblySettings:
return core.BNGetDisassemblyMaximumSymbolWidth(self.handle)
@max_symbol_width.setter
- def max_symbol_width(self, value:int) -> None:
+ def max_symbol_width(self, value: int) -> None:
core.BNSetDisassemblyMaximumSymbolWidth(self.handle, value)
- def is_option_set(self, option:DisassemblyOption) -> bool:
+ def is_option_set(self, option: DisassemblyOption) -> bool:
if isinstance(option, str):
option = DisassemblyOption[option]
return core.BNIsDisassemblySettingsOptionSet(self.handle, option)
- def set_option(self, option:DisassemblyOption, state:bool=True) -> None:
+ def set_option(self, option: DisassemblyOption, state: bool = True) -> None:
if isinstance(option, str):
option = DisassemblyOption[option]
core.BNSetDisassemblySettingsOption(self.handle, option, state)
@@ -123,14 +129,14 @@ class DisassemblySettings:
@dataclass
class ILReferenceSource:
- func:Optional['Function']
- arch:Optional['architecture.Architecture']
- address:int
- il_type:FunctionGraphType
- expr_id:ExpressionIndex
+ func: Optional['Function']
+ arch: Optional['architecture.Architecture']
+ address: int
+ il_type: FunctionGraphType
+ expr_id: ExpressionIndex
@staticmethod
- def get_il_name(il_type:FunctionGraphType) -> str:
+ def get_il_name(il_type: FunctionGraphType) -> str:
if il_type == FunctionGraphType.NormalFunctionGraph:
return 'disassembly'
if il_type == FunctionGraphType.LowLevelILFunctionGraph:
@@ -162,15 +168,18 @@ class ILReferenceSource:
@dataclass
class VariableReferenceSource:
- var:'variable.Variable'
- src:ILReferenceSource
+ var: 'variable.Variable'
+ src: ILReferenceSource
def __repr__(self):
return f"<var: {repr(self.var)}, src: {repr(self.src)}>"
class BasicBlockList:
- def __init__(self, function:Union['Function', 'lowlevelil.LowLevelILFunction', 'mediumlevelil.MediumLevelILFunction', 'highlevelil.HighLevelILFunction']):
+ def __init__(
+ self, function: Union['Function', 'lowlevelil.LowLevelILFunction', 'mediumlevelil.MediumLevelILFunction',
+ 'highlevelil.HighLevelILFunction']
+ ):
self._count, self._blocks = function._basic_block_list()
self._function = function
self._n = 0
@@ -196,7 +205,7 @@ class BasicBlockList:
self._n += 1
return self._function._instantiate_block(block)
- def __getitem__(self, i:Union[int, slice]) -> Union['basicblock.BasicBlock', List['basicblock.BasicBlock']]:
+ def __getitem__(self, i: Union[int, slice]) -> Union['basicblock.BasicBlock', List['basicblock.BasicBlock']]:
if isinstance(i, int):
if i < 0:
i = len(self) + i
@@ -218,45 +227,47 @@ class BasicBlockList:
raise ValueError("BasicBlockList.__getitem__ supports argument of type integer or slice only")
-
class LowLevelILBasicBlockList(BasicBlockList):
-
def __repr__(self):
return f"<LowLevelILBasicBlockList {len(self)} BasicBlocks: {list(self)}>"
- def __getitem__(self, i:Union[int, slice]) -> Union['lowlevelil.LowLevelILBasicBlock', List['lowlevelil.LowLevelILBasicBlock']]:
- return BasicBlockList.__getitem__(self, i) # type: ignore
+ def __getitem__(
+ self, i: Union[int, slice]
+ ) -> Union['lowlevelil.LowLevelILBasicBlock', List['lowlevelil.LowLevelILBasicBlock']]:
+ return BasicBlockList.__getitem__(self, i) # type: ignore
def __next__(self) -> 'lowlevelil.LowLevelILBasicBlock':
- return BasicBlockList.__next__(self) # type: ignore
+ return BasicBlockList.__next__(self) # type: ignore
class MediumLevelILBasicBlockList(BasicBlockList):
-
def __repr__(self):
return f"<MediumLevelILBasicBlockList {len(self)} BasicBlocks: {list(self)}>"
- def __getitem__(self, i:Union[int, slice]) -> Union['mediumlevelil.MediumLevelILBasicBlock', List['mediumlevelil.MediumLevelILBasicBlock']]:
- return BasicBlockList.__getitem__(self, i) # type: ignore
+ def __getitem__(
+ self, i: Union[int, slice]
+ ) -> Union['mediumlevelil.MediumLevelILBasicBlock', List['mediumlevelil.MediumLevelILBasicBlock']]:
+ return BasicBlockList.__getitem__(self, i) # type: ignore
def __next__(self) -> 'mediumlevelil.MediumLevelILBasicBlock':
- return BasicBlockList.__next__(self) # type: ignore
+ return BasicBlockList.__next__(self) # type: ignore
class HighLevelILBasicBlockList(BasicBlockList):
-
def __repr__(self):
return f"<HighLevelILBasicBlockList {len(self)} BasicBlocks: {list(self)}>"
- def __getitem__(self, i:Union[int, slice]) -> Union['highlevelil.HighLevelILBasicBlock', List['highlevelil.HighLevelILBasicBlock']]:
- return BasicBlockList.__getitem__(self, i) # type: ignore
+ def __getitem__(
+ self, i: Union[int, slice]
+ ) -> Union['highlevelil.HighLevelILBasicBlock', List['highlevelil.HighLevelILBasicBlock']]:
+ return BasicBlockList.__getitem__(self, i) # type: ignore
def __next__(self) -> 'highlevelil.HighLevelILBasicBlock':
- return BasicBlockList.__next__(self) # type: ignore
+ return BasicBlockList.__next__(self) # type: ignore
class TagList:
- def __init__(self, function:'Function'):
+ def __init__(self, function: 'Function'):
self._count = ctypes.c_ulonglong()
tags = core.BNGetAddressTagReferences(function.handle, self._count)
assert tags is not None, "core.BNGetAddressTagReferences returned None"
@@ -287,7 +298,10 @@ class TagList:
self._n += 1
return arch, address, binaryview.Tag(core_tag)
- def __getitem__(self, i:Union[int, slice]) -> Union[Tuple['architecture.Architecture', int, 'binaryview.Tag'], List[Tuple['architecture.Architecture', int, 'binaryview.Tag']]]:
+ def __getitem__(
+ self, i: Union[int, slice]
+ ) -> Union[Tuple['architecture.Architecture', int, 'binaryview.Tag'], List[Tuple['architecture.Architecture', int,
+ 'binaryview.Tag']]]:
if isinstance(i, int):
if i < 0:
i = len(self) + i
@@ -322,15 +336,13 @@ class Function:
>>> current_function = bv.functions[0]
>>> here = current_function.start
"""
-
-
- def __init__(self, view:Optional['binaryview.BinaryView']=None, handle:Optional[core.BNFunctionHandle]=None):
+ def __init__(self, view: Optional['binaryview.BinaryView'] = None, handle: Optional[core.BNFunctionHandle] = None):
self._advanced_analysis_requests = 0
assert handle is not None, "creation of standalone 'Function' objects is not implemented"
FunctionHandle = ctypes.POINTER(core.BNFunction)
self.handle = ctypes.cast(handle, FunctionHandle)
if view is None:
- self._view = binaryview.BinaryView(handle = core.BNGetFunctionData(self.handle))
+ self._view = binaryview.BinaryView(handle=core.BNGetFunctionData(self.handle))
else:
self._view = view
self._arch = None
@@ -349,32 +361,32 @@ class Function:
else:
return f"<func: {self.start:#x}>"
- def __eq__(self, other:'Function') -> bool:
+ def __eq__(self, other: 'Function') -> bool:
if not isinstance(other, self.__class__):
return NotImplemented
return ctypes.addressof(self.handle.contents) == ctypes.addressof(other.handle.contents)
- def __ne__(self, other:'Function') -> bool:
+ def __ne__(self, other: 'Function') -> bool:
if not isinstance(other, self.__class__):
return NotImplemented
return not (self == other)
- def __lt__(self, other:'Function') -> bool:
+ def __lt__(self, other: 'Function') -> bool:
if not isinstance(other, self.__class__):
return NotImplemented
return self.start < other.start
- def __gt__(self, other:'Function') -> bool:
+ def __gt__(self, other: 'Function') -> bool:
if not isinstance(other, self.__class__):
return NotImplemented
return self.start > other.start
- def __le__(self, other:'Function') -> bool:
+ def __le__(self, other: 'Function') -> bool:
if not isinstance(other, self.__class__):
return NotImplemented
return self.start <= other.start
- def __ge__(self, other:'Function') -> bool:
+ def __ge__(self, other: 'Function') -> bool:
if not isinstance(other, self.__class__):
return NotImplemented
return self.start >= other.start
@@ -394,19 +406,19 @@ class Function:
result += token.text
return result
- def __contains__(self, value:Union[basicblock.BasicBlock, int]):
+ def __contains__(self, value: Union[basicblock.BasicBlock, int]):
if isinstance(value, basicblock.BasicBlock):
return value.function == self
return self in [block.function for block in self.view.get_basic_blocks_at(int(value))]
@classmethod
- def _unregister(cls, func:'core.BNFunction') -> None:
+ def _unregister(cls, func: 'core.BNFunction') -> None:
handle = ctypes.cast(func, ctypes.c_void_p)
if handle.value in cls._associated_data:
del cls._associated_data[handle.value]
@staticmethod
- def set_default_session_data(name:str, value) -> None:
+ def set_default_session_data(name: str, value) -> None:
_FunctionAssociatedDataStore.set_default(name, value)
@property
@@ -415,7 +427,7 @@ class Function:
return self.symbol.name
@name.setter
- def name(self, value:Union[str, 'types.CoreSymbol']) -> None: # type: ignore
+ def name(self, value: Union[str, 'types.CoreSymbol']) -> None: # type: ignore
if value is None:
if self.symbol is not None:
self.view.undefine_user_symbol(self.symbol)
@@ -450,7 +462,7 @@ class Function:
plat = core.BNGetFunctionPlatform(self.handle)
if plat is None:
return None
- self._platform = _platform.Platform(handle = plat)
+ self._platform = _platform.Platform(handle=plat)
return self._platform
@property
@@ -516,10 +528,10 @@ class Function:
def can_return(self) -> 'types.BoolWithConfidence':
"""Whether function can return"""
result = core.BNCanFunctionReturn(self.handle)
- return types.BoolWithConfidence(result.value, confidence = result.confidence)
+ return types.BoolWithConfidence(result.value, confidence=result.confidence)
@can_return.setter
- def can_return(self, value:'types.BoolWithConfidence') -> None:
+ def can_return(self, value: 'types.BoolWithConfidence') -> None:
bc = core.BNBoolWithConfidence()
bc.value = bool(value)
if hasattr(value, 'confidence'):
@@ -564,15 +576,15 @@ class Function:
core.BNFreeAddressList(addrs)
return result
- def create_user_tag(self, type:'binaryview.TagType', data:str="") -> 'binaryview.Tag':
+ def create_user_tag(self, type: 'binaryview.TagType', data: str = "") -> 'binaryview.Tag':
"""Create a _user_ Tag object"""
return self.create_tag(type, data, True)
- def create_auto_tag(self, type:'binaryview.TagType', data:str="") -> 'binaryview.Tag':
+ def create_auto_tag(self, type: 'binaryview.TagType', data: str = "") -> 'binaryview.Tag':
"""Create an _auto_ Tag object"""
return self.create_tag(type, data, False)
- def create_tag(self, type:'binaryview.TagType', data:str="", user:bool=True) -> 'binaryview.Tag':
+ def create_tag(self, type: 'binaryview.TagType', data: str = "", user: bool = True) -> 'binaryview.Tag':
"""
``create_tag`` creates a new Tag object but does not add it anywhere.
Use :py:meth:`create_user_address_tag` or
@@ -602,7 +614,8 @@ class Function:
"""
return TagList(self)
- def get_address_tags_at(self, addr:int, arch:Optional['architecture.Architecture']=None) -> List['binaryview.Tag']:
+ def get_address_tags_at(self, addr: int,
+ arch: Optional['architecture.Architecture'] = None) -> List['binaryview.Tag']:
"""
``get_address_tags_at`` gets a generator of all Tags in the function at a given address.
@@ -627,8 +640,9 @@ class Function:
finally:
core.BNFreeTagList(tags, count.value)
-
- def add_user_address_tag(self, addr:int, tag:'binaryview.Tag', arch:Optional['architecture.Architecture']=None) -> None:
+ def add_user_address_tag(
+ self, addr: int, tag: 'binaryview.Tag', arch: Optional['architecture.Architecture'] = None
+ ) -> None:
"""
``add_user_address_tag`` adds an already-created Tag object at a given address.
Since this adds a user tag, it will be added to the current undo buffer.
@@ -646,8 +660,10 @@ class Function:
arch = self.arch
core.BNAddUserAddressTag(self.handle, arch.handle, addr, tag.handle)
- def create_user_address_tag(self, addr:int, tag_type:'binaryview.TagType', data:str, unique:bool=False,
- arch:Optional['architecture.Architecture']=None) -> 'binaryview.Tag':
+ def create_user_address_tag(
+ self, addr: int, tag_type: 'binaryview.TagType', data: str, unique: bool = False,
+ arch: Optional['architecture.Architecture'] = None
+ ) -> 'binaryview.Tag':
"""
``create_user_address_tag`` creates and adds a Tag object at a given
address. Since this adds a user tag, it will be added to the current
@@ -678,7 +694,9 @@ class Function:
core.BNAddUserAddressTag(self.handle, arch.handle, addr, tag.handle)
return tag
- def remove_user_address_tag(self, addr:int, tag:'binaryview.TagType', arch:Optional['architecture.Architecture']=None) -> None:
+ def remove_user_address_tag(
+ self, addr: int, tag: 'binaryview.TagType', arch: Optional['architecture.Architecture'] = None
+ ) -> None:
"""
``remove_user_address_tag`` removes a Tag object at a given address.
Since this removes a user tag, it will be added to the current undo buffer.
@@ -694,7 +712,9 @@ class Function:
arch = self.arch
core.BNRemoveUserAddressTag(self.handle, arch.handle, addr, tag.handle)
- def add_auto_address_tag(self, addr:int, tag:'binaryview.TagType', arch:Optional['architecture.Architecture']=None) -> None:
+ def add_auto_address_tag(
+ self, addr: int, tag: 'binaryview.TagType', arch: Optional['architecture.Architecture'] = None
+ ) -> None:
"""
``add_auto_address_tag`` adds an already-created Tag object at a given address.
If you want want to create the tag as well, consider using
@@ -711,7 +731,10 @@ class Function:
arch = self.arch
core.BNAddAutoAddressTag(self.handle, arch.handle, addr, tag.handle)
- def create_auto_address_tag(self, addr:int, type:'binaryview.TagType', data:str, unique:bool=False, arch:Optional['architecture.Architecture']=None) -> 'binaryview.Tag':
+ def create_auto_address_tag(
+ self, addr: int, type: 'binaryview.TagType', data: str, unique: bool = False,
+ arch: Optional['architecture.Architecture'] = None
+ ) -> 'binaryview.Tag':
"""
``create_auto_address_tag`` creates and adds a Tag object at a given address.
@@ -757,7 +780,7 @@ class Function:
finally:
core.BNFreeTagList(tags, count.value)
- def add_user_function_tag(self, tag:'binaryview.Tag') -> None:
+ def add_user_function_tag(self, tag: 'binaryview.Tag') -> None:
"""
``add_user_function_tag`` adds an already-created Tag object as a function tag.
Since this adds a user tag, it will be added to the current undo buffer.
@@ -769,7 +792,7 @@ class Function:
"""
core.BNAddUserFunctionTag(self.handle, tag.handle)
- def create_user_function_tag(self, type:'binaryview.TagType', data:str, unique:bool=False) -> 'binaryview.Tag':
+ def create_user_function_tag(self, type: 'binaryview.TagType', data: str, unique: bool = False) -> 'binaryview.Tag':
"""
``add_user_function_tag`` creates and adds a Tag object as a function tag.
Since this adds a user tag, it will be added to the current undo buffer.
@@ -789,7 +812,7 @@ class Function:
core.BNAddUserFunctionTag(self.handle, tag.handle)
return tag
- def remove_user_function_tag(self, tag:'binaryview.Tag') -> None:
+ def remove_user_function_tag(self, tag: 'binaryview.Tag') -> None:
"""
``remove_user_function_tag`` removes a Tag object as a function tag.
Since this removes a user tag, it will be added to the current undo buffer.
@@ -799,7 +822,7 @@ class Function:
"""
core.BNRemoveUserFunctionTag(self.handle, tag.handle)
- def add_auto_function_tag(self, tag:'binaryview.Tag') -> None:
+ def add_auto_function_tag(self, tag: 'binaryview.Tag') -> None:
"""
``add_auto_function_tag`` adds an already-created Tag object as a function tag.
If you want want to create the tag as well, consider using
@@ -809,7 +832,7 @@ class Function:
"""
core.BNAddAutoFunctionTag(self.handle, tag.handle)
- def create_auto_function_tag(self, type:'binaryview.TagType', data:str, unique:bool=False) -> 'binaryview.Tag':
+ def create_auto_function_tag(self, type: 'binaryview.TagType', data: str, unique: bool = False) -> 'binaryview.Tag':
"""
``create_auto_function_tag`` creates and adds a Tag object as a function tag.
@@ -914,10 +937,10 @@ class Function:
Function type object, can be set with either a string representing the function prototype
(`str(function)` shows examples) or a :py:class:`Type` object
"""
- return types.FunctionType(core.BNGetFunctionType(self.handle), platform = self.platform)
+ return types.FunctionType(core.BNGetFunctionType(self.handle), platform=self.platform)
@function_type.setter
- def function_type(self, value:Union['types.FunctionType', str]) -> None: # type: ignore
+ def function_type(self, value: Union['types.FunctionType', str]) -> None: # type: ignore
if isinstance(value, str):
(parsed_value, new_name) = self.view.parse_type_string(value)
self.name = str(new_name)
@@ -977,7 +1000,13 @@ class Function:
assert branches is not None, "core.BNGetIndirectBranches returned None"
result = []
for i in range(0, count.value):
- result.append(variable.IndirectBranchInfo(architecture.CoreArchitecture._from_cache(branches[i].sourceArch), branches[i].sourceAddr, architecture.CoreArchitecture._from_cache(branches[i].destArch), branches[i].destAddr, branches[i].autoDefined))
+ result.append(
+ variable.IndirectBranchInfo(
+ architecture.CoreArchitecture._from_cache(branches[i].sourceArch), branches[i].sourceAddr,
+ architecture.CoreArchitecture._from_cache(branches[i].destArch), branches[i].destAddr,
+ branches[i].autoDefined
+ )
+ )
core.BNFreeIndirectBranchList(branches)
return result
@@ -1031,10 +1060,12 @@ class Function:
result = core.BNGetFunctionReturnType(self.handle)
if not result.type:
return None
- return types.Type.create(core.BNNewTypeReference(result.type), platform = self.platform, confidence = result.confidence)
+ return types.Type.create(
+ core.BNNewTypeReference(result.type), platform=self.platform, confidence=result.confidence
+ )
@return_type.setter
- def return_type(self, value:StringOrType) -> None: # type: ignore
+ def return_type(self, value: StringOrType) -> None: # type: ignore
type_conf = core.BNTypeWithConfidence()
if value is None:
type_conf.type = None
@@ -1058,12 +1089,12 @@ class Function:
reg_set = []
for i in range(0, result.count):
reg_set.append(self.arch.get_reg_name(result.regs[i]))
- regs = types.RegisterSet(reg_set, confidence = result.confidence)
+ regs = types.RegisterSet(reg_set, confidence=result.confidence)
core.BNFreeRegisterSet(result)
return regs
@return_regs.setter
- def return_regs(self, value:Union['types.RegisterSet', List['architecture.RegisterType']]) -> None: # type: ignore
+ def return_regs(self, value: Union['types.RegisterSet', List['architecture.RegisterType']]) -> None: # type: ignore
regs = core.BNRegisterSetWithConfidence()
regs.regs = (ctypes.c_uint * len(value))()
regs.count = len(value)
@@ -1083,10 +1114,10 @@ class Function:
result = core.BNGetFunctionCallingConvention(self.handle)
if not result.convention:
return None
- return callingconvention.CallingConvention(None, handle = result.convention, confidence = result.confidence)
+ return callingconvention.CallingConvention(None, handle=result.convention, confidence=result.confidence)
@calling_convention.setter
- def calling_convention(self, value:'callingconvention.CallingConvention') -> None:
+ def calling_convention(self, value: 'callingconvention.CallingConvention') -> None:
conv_conf = core.BNCallingConventionWithConfidence()
if value is None:
conv_conf.convention = None
@@ -1108,7 +1139,9 @@ class Function:
return variable.ParameterVariables(var_list, confidence, self)
@parameter_vars.setter
- def parameter_vars(self, value:Optional[Union['variable.ParameterVariables', List['variable.Variable']]]) -> None: # type: ignore
+ def parameter_vars(
+ self, value: Optional[Union['variable.ParameterVariables', List['variable.Variable']]]
+ ) -> None: # type: ignore
if value is None:
var_list = []
else:
@@ -1132,10 +1165,10 @@ class Function:
def has_variable_arguments(self) -> 'types.BoolWithConfidence':
"""Whether the function takes a variable number of arguments"""
result = core.BNFunctionHasVariableArguments(self.handle)
- return types.BoolWithConfidence(result.value, confidence = result.confidence)
+ return types.BoolWithConfidence(result.value, confidence=result.confidence)
@has_variable_arguments.setter
- def has_variable_arguments(self, value:Union[bool, 'types.BoolWithConfidence']) -> None: # type: ignore
+ def has_variable_arguments(self, value: Union[bool, 'types.BoolWithConfidence']) -> None: # type: ignore
bc = core.BNBoolWithConfidence()
bc.value = bool(value)
if isinstance(value, types.BoolWithConfidence):
@@ -1148,10 +1181,10 @@ class Function:
def stack_adjustment(self) -> 'types.OffsetWithConfidence':
"""Number of bytes removed from the stack after return"""
result = core.BNGetFunctionStackAdjustment(self.handle)
- return types.OffsetWithConfidence(result.value, confidence = result.confidence)
+ return types.OffsetWithConfidence(result.value, confidence=result.confidence)
@stack_adjustment.setter
- def stack_adjustment(self, value:'types.OffsetWithConfidence') -> None:
+ def stack_adjustment(self, value: 'types.OffsetWithConfidence') -> None:
oc = core.BNOffsetWithConfidence()
oc.value = int(value)
if hasattr(value, 'confidence'):
@@ -1161,7 +1194,9 @@ class Function:
core.BNSetUserFunctionStackAdjustment(self.handle, oc)
@property
- def reg_stack_adjustments(self) -> Mapping['architecture.RegisterStackName', 'types.RegisterStackAdjustmentWithConfidence']:
+ def reg_stack_adjustments(
+ self
+ ) -> Mapping['architecture.RegisterStackName', 'types.RegisterStackAdjustmentWithConfidence']:
"""Number of entries removed from each register stack after return"""
count = ctypes.c_ulonglong()
adjust = core.BNGetFunctionRegisterStackAdjustments(self.handle, count)
@@ -1171,15 +1206,16 @@ class Function:
result = {}
for i in range(0, count.value):
name = self.arch.get_reg_stack_name(adjust[i].regStack)
- value = types.RegisterStackAdjustmentWithConfidence(adjust[i].adjustment,
- confidence = adjust[i].confidence)
+ value = types.RegisterStackAdjustmentWithConfidence(adjust[i].adjustment, confidence=adjust[i].confidence)
result[name] = value
core.BNFreeRegisterStackAdjustments(adjust)
return result
@reg_stack_adjustments.setter
- def reg_stack_adjustments(self,
- value:Mapping['architecture.RegisterStackName', Union[int, 'types.RegisterStackAdjustmentWithConfidence']]) -> None: # type: ignore
+ def reg_stack_adjustments(
+ self, value: Mapping['architecture.RegisterStackName', Union[int,
+ 'types.RegisterStackAdjustmentWithConfidence']]
+ ) -> None: # type: ignore
adjust = (core.BNRegisterStackAdjustment * len(value))()
if self.arch is None:
raise Exception("Can not get property return_regs with unspecified Architecture")
@@ -1206,12 +1242,14 @@ class Function:
reg_set = []
for i in range(0, result.count):
reg_set.append(self.arch.get_reg_name(result.regs[i]))
- regs = types.RegisterSet(reg_set, confidence = result.confidence)
+ regs = types.RegisterSet(reg_set, confidence=result.confidence)
core.BNFreeRegisterSet(result)
return regs
@clobbered_regs.setter
- def clobbered_regs(self, value:Union['types.RegisterSet', List['architecture.RegisterType']]) -> None: # type: ignore
+ def clobbered_regs(
+ self, value: Union['types.RegisterSet', List['architecture.RegisterType']]
+ ) -> None: # type: ignore
regs = core.BNRegisterSetWithConfidence()
if self.arch is None:
@@ -1238,7 +1276,7 @@ class Function:
return core.BNGetFunctionComment(self.handle)
@comment.setter
- def comment(self, comment:str) -> None:
+ def comment(self, comment: str) -> None:
"""Sets a comment for the current function"""
core.BNSetFunctionComment(self.handle, comment)
@@ -1284,7 +1322,7 @@ class Function:
return core.BNIsFunctionAnalysisSkipped(self.handle)
@analysis_skipped.setter
- def analysis_skipped(self, skip:bool) -> None:
+ def analysis_skipped(self, skip: bool) -> None:
if skip:
core.BNSetFunctionAnalysisSkipOverride(self.handle, FunctionAnalysisSkipOverride.AlwaysSkipFunctionAnalysis)
else:
@@ -1301,7 +1339,7 @@ class Function:
return FunctionAnalysisSkipOverride(core.BNGetFunctionAnalysisSkipOverride(self.handle))
@analysis_skip_override.setter
- def analysis_skip_override(self, override:FunctionAnalysisSkipOverride) -> None:
+ def analysis_skip_override(self, override: FunctionAnalysisSkipOverride) -> None:
core.BNSetFunctionAnalysisSkipOverride(self.handle, override)
@property
@@ -1315,14 +1353,14 @@ class Function:
def mark_recent_use(self) -> None:
core.BNMarkFunctionAsRecentlyUsed(self.handle)
- def get_comment_at(self, addr:int) -> str:
+ def get_comment_at(self, addr: int) -> str:
return core.BNGetCommentForAddress(self.handle, addr)
- def set_comment(self, addr:int, comment:str) -> None:
+ def set_comment(self, addr: int, comment: str) -> None:
"""Deprecated method provided for compatibility. Use set_comment_at instead."""
core.BNSetCommentForAddress(self.handle, addr, comment)
- def set_comment_at(self, addr:int, comment:str) -> None:
+ def set_comment_at(self, addr: int, comment: str) -> None:
"""
``set_comment_at`` sets a comment for the current function at the address specified
@@ -1336,7 +1374,9 @@ class Function:
"""
core.BNSetCommentForAddress(self.handle, addr, comment)
- def add_user_code_ref(self, from_addr:int, to_addr:int, arch:Optional['architecture.Architecture']=None) -> None:
+ def add_user_code_ref(
+ self, from_addr: int, to_addr: int, arch: Optional['architecture.Architecture'] = None
+ ) -> None:
"""
``add_user_code_ref`` places a user-defined cross-reference from the instruction at
the given address and architecture to the specified target address. If the specified
@@ -1360,7 +1400,9 @@ class Function:
core.BNAddUserCodeReference(self.handle, arch.handle, from_addr, to_addr)
- def remove_user_code_ref(self, from_addr:int, to_addr:int, from_arch:Optional['architecture.Architecture']=None) -> None:
+ def remove_user_code_ref(
+ self, from_addr: int, to_addr: int, from_arch: Optional['architecture.Architecture'] = None
+ ) -> None:
"""
``remove_user_code_ref`` removes a user-defined cross-reference.
If the given address is not contained within this function, or if there is no
@@ -1383,8 +1425,9 @@ class Function:
core.BNRemoveUserCodeReference(self.handle, from_arch.handle, from_addr, to_addr)
- def add_user_type_ref(self, from_addr:int, name:'types.QualifiedNameType',
- from_arch:Optional['architecture.Architecture']=None) -> None:
+ def add_user_type_ref(
+ self, from_addr: int, name: 'types.QualifiedNameType', from_arch: Optional['architecture.Architecture'] = None
+ ) -> None:
"""
``add_user_type_ref`` places a user-defined type cross-reference from the instruction at
the given address and architecture to the specified type. If the specified
@@ -1409,7 +1452,9 @@ class Function:
_name = types.QualifiedName(name)._to_core_struct()
core.BNAddUserTypeReference(self.handle, from_arch.handle, from_addr, _name)
- def remove_user_type_ref(self, from_addr:int, name:'types.QualifiedNameType', from_arch:Optional['architecture.Architecture']=None) -> None:
+ def remove_user_type_ref(
+ self, from_addr: int, name: 'types.QualifiedNameType', from_arch: Optional['architecture.Architecture'] = None
+ ) -> None:
"""
``remove_user_type_ref`` removes a user-defined type cross-reference.
If the given address is not contained within this function, or if there is no
@@ -1433,8 +1478,10 @@ class Function:
_name = types.QualifiedName(name)._to_core_struct()
core.BNRemoveUserTypeReference(self.handle, from_arch.handle, from_addr, _name)
- def add_user_type_field_ref(self, from_addr:int, name:'types.QualifiedNameType', offset:int,
- from_arch:Optional['architecture.Architecture']=None, size:int=0) -> None:
+ def add_user_type_field_ref(
+ self, from_addr: int, name: 'types.QualifiedNameType', offset: int,
+ from_arch: Optional['architecture.Architecture'] = None, size: int = 0
+ ) -> None:
"""
``add_user_type_field_ref`` places a user-defined type field cross-reference from the
instruction at the given address and architecture to the specified type. If the specified
@@ -1459,11 +1506,12 @@ class Function:
from_arch = self.arch
_name = types.QualifiedName(name)._to_core_struct()
- core.BNAddUserTypeFieldReference(self.handle, from_arch.handle, from_addr, _name,
- offset, size)
+ core.BNAddUserTypeFieldReference(self.handle, from_arch.handle, from_addr, _name, offset, size)
- def remove_user_type_field_ref(self, from_addr:int, name:'types.QualifiedNameType', offset:int,
- from_arch:Optional['architecture.Architecture']=None, size:int=0) -> None:
+ def remove_user_type_field_ref(
+ self, from_addr: int, name: 'types.QualifiedNameType', offset: int,
+ from_arch: Optional['architecture.Architecture'] = None, size: int = 0
+ ) -> None:
"""
``remove_user_type_field_ref`` removes a user-defined type field cross-reference.
If the given address is not contained within this function, or if there is no
@@ -1487,10 +1535,11 @@ class Function:
from_arch = self.arch
_name = types.QualifiedName(name)._to_core_struct()
- core.BNRemoveUserTypeFieldReference(self.handle, from_arch.handle, from_addr, _name,
- offset, size)
+ core.BNRemoveUserTypeFieldReference(self.handle, from_arch.handle, from_addr, _name, offset, size)
- def get_low_level_il_at(self, addr:int, arch:Optional['architecture.Architecture']=None) -> Optional['lowlevelil.LowLevelILInstruction']:
+ def get_low_level_il_at(
+ self, addr: int, arch: Optional['architecture.Architecture'] = None
+ ) -> Optional['lowlevelil.LowLevelILInstruction']:
"""
``get_low_level_il_at`` gets the LowLevelILInstruction corresponding to the given virtual address
@@ -1515,7 +1564,8 @@ class Function:
return self.llil[idx]
- def get_llil_at(self, addr:int, arch:Optional['architecture.Architecture']=None) -> Optional['lowlevelil.LowLevelILInstruction']:
+ def get_llil_at(self, addr: int,
+ arch: Optional['architecture.Architecture'] = None) -> Optional['lowlevelil.LowLevelILInstruction']:
"""
``get_llil_at`` gets the LowLevelILInstruction corresponding to the given virtual address
@@ -1540,7 +1590,8 @@ class Function:
return self.llil[idx]
- def get_llils_at(self, addr:int, arch:Optional['architecture.Architecture']=None) -> List['lowlevelil.LowLevelILInstruction']:
+ def get_llils_at(self, addr: int,
+ arch: Optional['architecture.Architecture'] = None) -> List['lowlevelil.LowLevelILInstruction']:
"""
``get_llils_at`` gets the LowLevelILInstruction(s) corresponding to the given virtual address
@@ -1566,7 +1617,7 @@ class Function:
core.BNFreeILInstructionList(instrs)
return result
- def get_low_level_il_exits_at(self, addr:int, arch:Optional['architecture.Architecture']=None) -> List[int]:
+ def get_low_level_il_exits_at(self, addr: int, arch: Optional['architecture.Architecture'] = None) -> List[int]:
if arch is None:
if self.arch is None:
raise Exception(f"Can't call {_function_name_()} for function with no architecture specified")
@@ -1580,8 +1631,9 @@ class Function:
core.BNFreeILInstructionList(exits)
return result
- def get_reg_value_at(self, addr:int, reg:'architecture.RegisterType',
- arch:Optional['architecture.Architecture']=None) -> 'variable.RegisterValue':
+ def get_reg_value_at(
+ self, addr: int, reg: 'architecture.RegisterType', arch: Optional['architecture.Architecture'] = None
+ ) -> 'variable.RegisterValue':
"""
``get_reg_value_at`` gets the value the provided string register address corresponding to the given virtual address
@@ -1645,8 +1697,9 @@ class Function:
core.BNFreeTagReferences(tags, count.value)
return result
- def get_reg_value_after(self, addr:int, reg:'architecture.RegisterType',
- arch:Optional['architecture.Architecture']=None) -> 'variable.RegisterValue':
+ def get_reg_value_after(
+ self, addr: int, reg: 'architecture.RegisterType', arch: Optional['architecture.Architecture'] = None
+ ) -> 'variable.RegisterValue':
"""
``get_reg_value_after`` gets the value instruction address corresponding to the given virtual address
@@ -1861,8 +1914,9 @@ class Function:
core.BNFreeTagReferences(refs, count.value)
return result
- def get_stack_contents_at(self, addr:int, offset:int, size:int,
- arch:Optional['architecture.Architecture']=None) -> 'variable.RegisterValue':
+ def get_stack_contents_at(
+ self, addr: int, offset: int, size: int, arch: Optional['architecture.Architecture'] = None
+ ) -> 'variable.RegisterValue':
"""
``get_stack_contents_at`` returns the RegisterValue for the item on the stack in the current function at the
given virtual address ``addr``, stack offset ``offset`` and size of ``size``. Optionally specifying the architecture.
@@ -1883,27 +1937,29 @@ class Function:
"""
if arch is None:
if self.arch is None:
- raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
+ raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
arch = self.arch
value = core.BNGetStackContentsAtInstruction(self.handle, arch.handle, addr, offset, size)
result = variable.RegisterValue.from_BNRegisterValue(value, arch)
return result
- def get_stack_contents_after(self, addr:int, offset:int, size:int,
- arch:Optional['architecture.Architecture']=None) -> 'variable.RegisterValue':
+ def get_stack_contents_after(
+ self, addr: int, offset: int, size: int, arch: Optional['architecture.Architecture'] = None
+ ) -> 'variable.RegisterValue':
if arch is None:
if self.arch is None:
- raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
+ raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
arch = self.arch
value = core.BNGetStackContentsAfterInstruction(self.handle, arch.handle, addr, offset, size)
result = variable.RegisterValue.from_BNRegisterValue(value, arch)
return result
- def get_parameter_at(self, addr:int, func_type:Optional['types.Type'], i:int,
- arch:Optional['architecture.Architecture']=None) -> 'variable.RegisterValue':
+ def get_parameter_at(
+ self, addr: int, func_type: Optional['types.Type'], i: int, arch: Optional['architecture.Architecture'] = None
+ ) -> 'variable.RegisterValue':
if arch is None:
if self.arch is None:
- raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
+ raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
arch = self.arch
_func_type = None
@@ -1925,12 +1981,13 @@ class Function:
"""
if arch is None:
if self.arch is None:
- raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
+ raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
arch = self.arch
core.BNRemoveUserAddressTagsOfType(self.handle, arch.handle, addr, tag_type.handle)
- def get_parameter_at_low_level_il_instruction(self, instr:'lowlevelil.InstructionIndex',
- func_type:'types.Type', i:int) -> 'variable.RegisterValue':
+ def get_parameter_at_low_level_il_instruction(
+ self, instr: 'lowlevelil.InstructionIndex', func_type: 'types.Type', i: int
+ ) -> 'variable.RegisterValue':
_func_type = None
if func_type is not None:
_func_type = func_type.handle
@@ -1938,10 +1995,11 @@ class Function:
result = variable.RegisterValue.from_BNRegisterValue(value, self.arch)
return result
- def get_regs_read_by(self, addr:int, arch:Optional['architecture.Architecture']=None) -> List['architecture.RegisterName']:
+ def get_regs_read_by(self, addr: int,
+ arch: Optional['architecture.Architecture'] = None) -> List['architecture.RegisterName']:
if arch is None:
if self.arch is None:
- raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
+ raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
arch = self.arch
count = ctypes.c_ulonglong()
regs = core.BNGetRegistersReadByInstruction(self.handle, arch.handle, addr, count)
@@ -1952,10 +2010,11 @@ class Function:
core.BNFreeRegisterList(regs)
return result
- def get_regs_written_by(self, addr:int, arch:Optional['architecture.Architecture']=None) -> List['architecture.RegisterName']:
+ def get_regs_written_by(self, addr: int,
+ arch: Optional['architecture.Architecture'] = None) -> List['architecture.RegisterName']:
if arch is None:
if self.arch is None:
- raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
+ raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
arch = self.arch
count = ctypes.c_ulonglong()
regs = core.BNGetRegistersWrittenByInstruction(self.handle, arch.handle, addr, count)
@@ -1966,7 +2025,9 @@ class Function:
core.BNFreeRegisterList(regs)
return result
- def remove_auto_address_tag(self, addr:int, tag:'binaryview.TagType', arch:Optional['architecture.Architecture']=None) -> None:
+ def remove_auto_address_tag(
+ self, addr: int, tag: 'binaryview.TagType', arch: Optional['architecture.Architecture'] = None
+ ) -> None:
"""
``remove_auto_address_tag`` removes a Tag object at a given address.
@@ -1977,7 +2038,7 @@ class Function:
"""
if arch is None:
if self.arch is None:
- raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
+ raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
arch = self.arch
core.BNRemoveAutoAddressTag(self.handle, arch.handle, addr, tag.handle)
@@ -1992,25 +2053,31 @@ class Function:
"""
if arch is None:
if self.arch is None:
- raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
+ raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
arch = self.arch
core.BNRemoveAutoAddressTagsOfType(self.handle, arch.handle, addr, tag_type.handle)
- def get_stack_vars_referenced_by(self, addr:int,
- arch:Optional['architecture.Architecture']=None) -> List['variable.StackVariableReference']:
+ def get_stack_vars_referenced_by(
+ self, addr: int, arch: Optional['architecture.Architecture'] = None
+ ) -> List['variable.StackVariableReference']:
if arch is None:
if self.arch is None:
- raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
+ raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
arch = self.arch
count = ctypes.c_ulonglong()
refs = core.BNGetStackVariablesReferencedByInstruction(self.handle, arch.handle, addr, count)
assert refs is not None, "core.BNGetStackVariablesReferencedByInstruction returned None"
result = []
for i in range(0, count.value):
- var_type = types.Type.create(core.BNNewTypeReference(refs[i].type), platform = self.platform, confidence = refs[i].typeConfidence)
+ var_type = types.Type.create(
+ core.BNNewTypeReference(refs[i].type), platform=self.platform, confidence=refs[i].typeConfidence
+ )
var = variable.Variable.from_identifier(self, refs[i].varIdentifier)
- result.append(variable.StackVariableReference(refs[i].sourceOperand, var_type, refs[i].name, var,
- refs[i].referencedOffset, refs[i].size))
+ result.append(
+ variable.StackVariableReference(
+ refs[i].sourceOperand, var_type, refs[i].name, var, refs[i].referencedOffset, refs[i].size
+ )
+ )
core.BNFreeStackVariableReferenceList(refs, count.value)
return result
@@ -2050,11 +2117,12 @@ class Function:
core.BNFreeTagList(tags, count.value)
return result
- def get_lifted_il_at(self, addr:int,
- arch:Optional['architecture.Architecture']=None) -> Optional['lowlevelil.LowLevelILInstruction']:
+ def get_lifted_il_at(
+ self, addr: int, arch: Optional['architecture.Architecture'] = None
+ ) -> Optional['lowlevelil.LowLevelILInstruction']:
if arch is None:
if self.arch is None:
- raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
+ raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
arch = self.arch
idx = core.BNGetLiftedILForInstruction(self.handle, arch.handle, addr)
@@ -2064,8 +2132,9 @@ class Function:
return self.lifted_il[idx]
- def get_lifted_ils_at(self, addr:int,
- arch:Optional['architecture.Architecture']=None) -> List['lowlevelil.LowLevelILInstruction']:
+ def get_lifted_ils_at(
+ self, addr: int, arch: Optional['architecture.Architecture'] = None
+ ) -> List['lowlevelil.LowLevelILInstruction']:
"""
``get_lifted_ils_at`` gets the Lifted IL Instruction(s) corresponding to the given virtual address
@@ -2079,7 +2148,7 @@ class Function:
"""
if arch is None:
if self.arch is None:
- raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
+ raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
arch = self.arch
count = ctypes.c_ulonglong()
instrs = core.BNGetLiftedILInstructionsForAddress(self.handle, arch.handle, addr, count)
@@ -2157,22 +2226,24 @@ class Function:
"""
core.BNRemoveUserFunctionTagsOfType(self.handle, tag_type.handle)
- def get_constants_referenced_by(self, addr:int,
- arch:'architecture.Architecture'=None) -> List[variable.ConstantReference]:
+ def get_constants_referenced_by(self, addr: int,
+ arch: 'architecture.Architecture' = None) -> List[variable.ConstantReference]:
if arch is None:
if self.arch is None:
- raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
+ raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
arch = self.arch
count = ctypes.c_ulonglong()
refs = core.BNGetConstantsReferencedByInstruction(self.handle, arch.handle, addr, count)
assert refs is not None, "core.BNGetConstantsReferencedByInstruction returned None"
result = []
for i in range(0, count.value):
- result.append(variable.ConstantReference(refs[i].value, refs[i].size, refs[i].pointer, refs[i].intermediate))
+ result.append(
+ variable.ConstantReference(refs[i].value, refs[i].size, refs[i].pointer, refs[i].intermediate)
+ )
core.BNFreeConstantReferenceList(refs)
return result
- def remove_auto_function_tag(self, tag:'binaryview.Tag') -> None:
+ def remove_auto_function_tag(self, tag: 'binaryview.Tag') -> None:
"""
``remove_user_function_tag`` removes a Tag object as a function tag.
@@ -2190,10 +2261,11 @@ class Function:
"""
core.BNRemoveAutoFunctionTagsOfType(self.handle, tag_type.handle)
- def get_lifted_il_flag_uses_for_definition(self, i:'lowlevelil.InstructionIndex',
- flag:'architecture.FlagType') -> List['lowlevelil.LowLevelILInstruction']:
+ def get_lifted_il_flag_uses_for_definition(
+ self, i: 'lowlevelil.InstructionIndex', flag: 'architecture.FlagType'
+ ) -> List['lowlevelil.LowLevelILInstruction']:
if self.arch is None:
- raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
+ raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
flag = self.arch.get_flag_index(flag)
count = ctypes.c_ulonglong()
instrs = core.BNGetLiftedILFlagUsesForDefinition(self.handle, i, flag, count)
@@ -2204,10 +2276,10 @@ class Function:
core.BNFreeILInstructionList(instrs)
return result
- def get_lifted_il_flag_definitions_for_use(self, i:'lowlevelil.InstructionIndex',
- flag:'architecture.FlagType') -> List['lowlevelil.InstructionIndex']:
+ def get_lifted_il_flag_definitions_for_use(self, i: 'lowlevelil.InstructionIndex',
+ flag: 'architecture.FlagType') -> List['lowlevelil.InstructionIndex']:
if self.arch is None:
- raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
+ raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
flag = self.arch.get_flag_index(flag)
count = ctypes.c_ulonglong()
@@ -2219,10 +2291,10 @@ class Function:
core.BNFreeILInstructionList(instrs)
return result
- def get_flags_read_by_lifted_il_instruction(self, i:'lowlevelil.InstructionIndex') -> \
- List['architecture.FlagName']:
+ def get_flags_read_by_lifted_il_instruction(self,
+ i: 'lowlevelil.InstructionIndex') -> List['architecture.FlagName']:
if self.arch is None:
- raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
+ raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
count = ctypes.c_ulonglong()
flags = core.BNGetFlagsReadByLiftedILInstruction(self.handle, i, count)
@@ -2233,11 +2305,11 @@ class Function:
core.BNFreeRegisterList(flags)
return result
- def get_flags_written_by_lifted_il_instruction(self, i:'lowlevelil.InstructionIndex') -> \
- List['architecture.FlagName']:
+ def get_flags_written_by_lifted_il_instruction(self,
+ i: 'lowlevelil.InstructionIndex') -> List['architecture.FlagName']:
count = ctypes.c_ulonglong()
if self.arch is None:
- raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
+ raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
flags = core.BNGetFlagsWrittenByLiftedILInstruction(self.handle, i, count)
assert flags is not None, "core.BNGetFlagsWrittenByLiftedILInstruction returned None"
@@ -2247,29 +2319,33 @@ class Function:
core.BNFreeRegisterList(flags)
return result
- def create_graph(self, graph_type:FunctionGraphType=FunctionGraphType.NormalFunctionGraph,
- settings:'DisassemblySettings'=None) -> flowgraph.CoreFlowGraph:
+ def create_graph(
+ self, graph_type: FunctionGraphType = FunctionGraphType.NormalFunctionGraph,
+ settings: 'DisassemblySettings' = None
+ ) -> flowgraph.CoreFlowGraph:
if settings is not None:
settings_obj = settings.handle
else:
settings_obj = None
return flowgraph.CoreFlowGraph(core.BNCreateFunctionGraph(self.handle, graph_type, settings_obj))
- def apply_imported_types(self, sym:'types.CoreSymbol', type:Optional[StringOrType]=None) -> None:
+ def apply_imported_types(self, sym: 'types.CoreSymbol', type: Optional[StringOrType] = None) -> None:
if isinstance(type, str):
(type, _) = self.view.parse_type_string(type)
core.BNApplyImportedTypes(self.handle, sym.handle, None if type is None else type.handle)
- def apply_auto_discovered_type(self, func_type:StringOrType) -> None:
+ def apply_auto_discovered_type(self, func_type: StringOrType) -> None:
if isinstance(func_type, str):
(func_type, _) = self.view.parse_type_string(func_type)
core.BNApplyAutoDiscoveredFunctionType(self.handle, func_type.handle)
- def set_auto_indirect_branches(self, source:int, branches:List[Tuple['architecture.Architecture', int]],
- source_arch:Optional['architecture.Architecture']=None) -> None:
+ def set_auto_indirect_branches(
+ self, source: int, branches: List[Tuple['architecture.Architecture', int]],
+ source_arch: Optional['architecture.Architecture'] = None
+ ) -> None:
if source_arch is None:
if self.arch is None:
- raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
+ raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
source_arch = self.arch
branch_list = (core.BNArchitectureAndAddress * len(branches))()
for i in range(len(branches)):
@@ -2277,11 +2353,13 @@ class Function:
branch_list[i].address = branches[i][1]
core.BNSetAutoIndirectBranches(self.handle, source_arch.handle, source, branch_list, len(branches))
- def set_user_indirect_branches(self, source:int, branches:List[Tuple['architecture.Architecture', int]],
- source_arch:Optional['architecture.Architecture']=None) -> None:
+ def set_user_indirect_branches(
+ self, source: int, branches: List[Tuple['architecture.Architecture', int]],
+ source_arch: Optional['architecture.Architecture'] = None
+ ) -> None:
if source_arch is None:
if self.arch is None:
- raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
+ raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
source_arch = self.arch
branch_list = (core.BNArchitectureAndAddress * len(branches))()
for i in range(len(branches)):
@@ -2289,10 +2367,12 @@ class Function:
branch_list[i].address = branches[i][1]
core.BNSetUserIndirectBranches(self.handle, source_arch.handle, source, branch_list, len(branches))
- def get_indirect_branches_at(self, addr:int, arch:Optional['architecture.Architecture']=None) -> List['variable.IndirectBranchInfo']:
+ def get_indirect_branches_at(
+ self, addr: int, arch: Optional['architecture.Architecture'] = None
+ ) -> List['variable.IndirectBranchInfo']:
if arch is None:
if self.arch is None:
- raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
+ raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
arch = self.arch
count = ctypes.c_ulonglong()
branches = core.BNGetIndirectBranchesAt(self.handle, arch.handle, addr, count)
@@ -2300,13 +2380,19 @@ class Function:
assert branches is not None, "core.BNGetIndirectBranchesAt returned None"
result = []
for i in range(count.value):
- result.append(variable.IndirectBranchInfo(architecture.CoreArchitecture._from_cache(branches[i].sourceArch), branches[i].sourceAddr, architecture.CoreArchitecture._from_cache(branches[i].destArch), branches[i].destAddr, branches[i].autoDefined))
+ result.append(
+ variable.IndirectBranchInfo(
+ architecture.CoreArchitecture._from_cache(branches[i].sourceArch), branches[i].sourceAddr,
+ architecture.CoreArchitecture._from_cache(branches[i].destArch), branches[i].destAddr,
+ branches[i].autoDefined
+ )
+ )
return result
finally:
core.BNFreeIndirectBranchList(branches)
- def get_block_annotations(self, addr:int, arch:Optional['architecture.Architecture']=None) -> \
- List[List['InstructionTextToken']]:
+ def get_block_annotations(self, addr: int,
+ arch: Optional['architecture.Architecture'] = None) -> List[List['InstructionTextToken']]:
if arch is None:
if self.arch is None:
raise Exception("can not get_block_annotations if Function.arch is None")
@@ -2322,17 +2408,17 @@ class Function:
finally:
core.BNFreeInstructionTextLines(lines, count.value)
- def set_auto_type(self, value:StringOrType) -> None:
+ def set_auto_type(self, value: StringOrType) -> None:
if isinstance(value, str):
(value, _) = self.view.parse_type_string(value)
core.BNSetFunctionAutoType(self.handle, value.handle)
- def set_user_type(self, value:StringOrType) -> None:
+ def set_user_type(self, value: StringOrType) -> None:
if isinstance(value, str):
(value, _) = self.view.parse_type_string(value)
core.BNSetFunctionUserType(self.handle, value.handle)
- def set_auto_return_type(self, value:StringOrType) -> None:
+ def set_auto_return_type(self, value: StringOrType) -> None:
type_conf = core.BNTypeWithConfidence()
if value is None:
type_conf.type = None
@@ -2346,7 +2432,7 @@ class Function:
type_conf.confidence = value.confidence
core.BNSetAutoFunctionReturnType(self.handle, type_conf)
- def set_auto_return_regs(self, value:Union['types.RegisterSet', List['architecture.RegisterType']]) -> None:
+ def set_auto_return_regs(self, value: Union['types.RegisterSet', List['architecture.RegisterType']]) -> None:
regs = core.BNRegisterSetWithConfidence()
regs.regs = (ctypes.c_uint * len(value))()
regs.count = len(value)
@@ -2361,7 +2447,7 @@ class Function:
regs.confidence = core.max_confidence
core.BNSetAutoFunctionReturnRegisters(self.handle, regs)
- def set_auto_calling_convention(self, value:'callingconvention.CallingConvention') -> None:
+ def set_auto_calling_convention(self, value: 'callingconvention.CallingConvention') -> None:
conv_conf = core.BNCallingConventionWithConfidence()
if value is None:
conv_conf.convention = None
@@ -2371,8 +2457,9 @@ class Function:
conv_conf.confidence = value.confidence
core.BNSetAutoFunctionCallingConvention(self.handle, conv_conf)
- def set_auto_parameter_vars(self, value:Optional[Union[List['variable.Variable'], 'variable.Variable', \
- 'variable.ParameterVariables']]) -> None:
+ def set_auto_parameter_vars(
+ self, value: Optional[Union[List['variable.Variable'], 'variable.Variable', 'variable.ParameterVariables']]
+ ) -> None:
if value is None:
var_list = []
elif isinstance(value, variable.Variable):
@@ -2396,7 +2483,7 @@ class Function:
var_conf.confidence = core.max_confidence
core.BNSetAutoFunctionParameterVariables(self.handle, var_conf)
- def set_auto_has_variable_arguments(self, value:Union[bool, 'types.BoolWithConfidence']) -> None:
+ def set_auto_has_variable_arguments(self, value: Union[bool, 'types.BoolWithConfidence']) -> None:
bc = core.BNBoolWithConfidence()
bc.value = bool(value)
if isinstance(value, types.BoolWithConfidence):
@@ -2405,7 +2492,7 @@ class Function:
bc.confidence = core.max_confidence
core.BNSetAutoFunctionHasVariableArguments(self.handle, bc)
- def set_auto_can_return(self, value:Union[bool, 'types.BoolWithConfidence']) -> None:
+ def set_auto_can_return(self, value: Union[bool, 'types.BoolWithConfidence']) -> None:
bc = core.BNBoolWithConfidence()
bc.value = bool(value)
if isinstance(value, types.BoolWithConfidence):
@@ -2414,7 +2501,7 @@ class Function:
bc.confidence = core.max_confidence
core.BNSetAutoFunctionCanReturn(self.handle, bc)
- def set_auto_stack_adjustment(self, value:Union[int, 'types.OffsetWithConfidence']) -> None:
+ def set_auto_stack_adjustment(self, value: Union[int, 'types.OffsetWithConfidence']) -> None:
oc = core.BNOffsetWithConfidence()
oc.value = int(value)
if isinstance(value, types.OffsetWithConfidence):
@@ -2423,7 +2510,9 @@ class Function:
oc.confidence = core.max_confidence
core.BNSetAutoFunctionStackAdjustment(self.handle, oc)
- def set_auto_reg_stack_adjustments(self, value:Mapping['architecture.RegisterStackName', 'types.RegisterStackAdjustmentWithConfidence']):
+ def set_auto_reg_stack_adjustments(
+ self, value: Mapping['architecture.RegisterStackName', 'types.RegisterStackAdjustmentWithConfidence']
+ ):
adjust = (core.BNRegisterStackAdjustment * len(value))()
i = 0
if self.arch is None:
@@ -2440,7 +2529,7 @@ class Function:
i += 1
core.BNSetAutoFunctionRegisterStackAdjustments(self.handle, adjust, len(value))
- def set_auto_clobbered_regs(self, value:List['architecture.RegisterType']) -> None:
+ def set_auto_clobbered_regs(self, value: List['architecture.RegisterType']) -> None:
regs = core.BNRegisterSetWithConfidence()
regs.regs = (ctypes.c_uint * len(value))()
regs.count = len(value)
@@ -2455,7 +2544,9 @@ class Function:
regs.confidence = core.max_confidence
core.BNSetAutoFunctionClobberedRegisters(self.handle, regs)
- def get_int_display_type(self, instr_addr:int, value:int, operand:int, arch:Optional['architecture.Architecture']=None) -> IntegerDisplayType:
+ def get_int_display_type(
+ self, instr_addr: int, value: int, operand: int, arch: Optional['architecture.Architecture'] = None
+ ) -> IntegerDisplayType:
"""
Get the current text display type for an integer token in the disassembly or IL views
:param int instr_addr: Address of the instruction or IL line containing the token
@@ -2465,11 +2556,16 @@ class Function:
"""
if arch is None:
if self.arch is None:
- raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
+ raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
arch = self.arch
- return IntegerDisplayType(core.BNGetIntegerConstantDisplayType(self.handle, arch.handle, instr_addr, value, operand))
+ return IntegerDisplayType(
+ core.BNGetIntegerConstantDisplayType(self.handle, arch.handle, instr_addr, value, operand)
+ )
- def set_int_display_type(self, instr_addr:int, value:int, operand:int, display_type:IntegerDisplayType, arch:Optional['architecture.Architecture']=None) -> None:
+ def set_int_display_type(
+ self, instr_addr: int, value: int, operand: int, display_type: IntegerDisplayType,
+ arch: Optional['architecture.Architecture'] = None
+ ) -> None:
"""
Change the text display type for an integer token in the disassembly or IL views
:param int instr_addr: Address of the instruction or IL line containing the token
@@ -2480,7 +2576,7 @@ class Function:
"""
if arch is None:
if self.arch is None:
- raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
+ raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
arch = self.arch
if isinstance(display_type, str):
display_type = IntegerDisplayType[display_type]
@@ -2502,7 +2598,8 @@ class Function:
core.BNReleaseAdvancedFunctionAnalysisData(self.handle)
self._advanced_analysis_requests -= 1
- def get_basic_block_at(self, addr:int, arch:Optional['architecture.Architecture']=None) -> Optional['basicblock.BasicBlock']:
+ def get_basic_block_at(self, addr: int,
+ arch: Optional['architecture.Architecture'] = None) -> Optional['basicblock.BasicBlock']:
"""
``get_basic_block_at`` returns the BasicBlock of the optionally specified Architecture ``arch`` at the given
address ``addr``.
@@ -2515,14 +2612,16 @@ class Function:
"""
if arch is None:
if self.arch is None:
- raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
+ raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
arch = self.arch
block = core.BNGetFunctionBasicBlockAtAddress(self.handle, arch.handle, addr)
if not block:
return None
return basicblock.BasicBlock(block, self._view)
- def get_instr_highlight(self, addr:int, arch:Optional['architecture.Architecture']=None) -> '_highlight.HighlightColor':
+ def get_instr_highlight(
+ self, addr: int, arch: Optional['architecture.Architecture'] = None
+ ) -> '_highlight.HighlightColor':
"""
:Example:
>>> current_function.set_user_instr_highlight(here, highlight.HighlightColor(red=0xff, blue=0xff, green=0))
@@ -2531,19 +2630,23 @@ class Function:
"""
if arch is None:
if self.arch is None:
- raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
+ raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
arch = self.arch
color = core.BNGetInstructionHighlight(self.handle, arch.handle, addr)
if color.style == HighlightColorStyle.StandardHighlightColor:
- return _highlight.HighlightColor(color = color.color, alpha = color.alpha)
+ return _highlight.HighlightColor(color=color.color, alpha=color.alpha)
elif color.style == HighlightColorStyle.MixedHighlightColor:
- return _highlight.HighlightColor(color = color.color, mix_color = color.mixColor, mix = color.mix, alpha = color.alpha)
+ return _highlight.HighlightColor(
+ color=color.color, mix_color=color.mixColor, mix=color.mix, alpha=color.alpha
+ )
elif color.style == HighlightColorStyle.CustomHighlightColor:
- return _highlight.HighlightColor(red = color.r, green = color.g, blue = color.b, alpha = color.alpha)
- return _highlight.HighlightColor(color = HighlightStandardColor.NoHighlightColor)
+ return _highlight.HighlightColor(red=color.r, green=color.g, blue=color.b, alpha=color.alpha)
+ return _highlight.HighlightColor(color=HighlightStandardColor.NoHighlightColor)
- def set_auto_instr_highlight(self, addr:int, color:Union['_highlight.HighlightColor', HighlightStandardColor],
- arch:Optional['architecture.Architecture']=None):
+ def set_auto_instr_highlight(
+ self, addr: int, color: Union['_highlight.HighlightColor', HighlightStandardColor],
+ arch: Optional['architecture.Architecture'] = None
+ ):
"""
``set_auto_instr_highlight`` highlights the instruction at the specified address with the supplied color
@@ -2555,17 +2658,18 @@ class Function:
"""
if arch is None:
if self.arch is None:
- raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
+ raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
arch = self.arch
if not isinstance(color, HighlightStandardColor) and not isinstance(color, _highlight.HighlightColor):
raise ValueError("Specified color is not one of HighlightStandardColor, _highlight.HighlightColor")
if isinstance(color, HighlightStandardColor):
- color = _highlight.HighlightColor(color = color)
+ color = _highlight.HighlightColor(color=color)
core.BNSetAutoInstructionHighlight(self.handle, arch.handle, addr, color._to_core_struct())
-
- def set_user_instr_highlight(self, addr:int, color:Union['_highlight.HighlightColor', HighlightStandardColor],
- arch:Optional['architecture.Architecture']=None):
+ def set_user_instr_highlight(
+ self, addr: int, color: Union['_highlight.HighlightColor', HighlightStandardColor],
+ arch: Optional['architecture.Architecture'] = None
+ ):
"""
``set_user_instr_highlight`` highlights the instruction at the specified address with the supplied color
@@ -2579,7 +2683,7 @@ class Function:
"""
if arch is None:
if self.arch is None:
- raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
+ raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
arch = self.arch
if not isinstance(color, HighlightStandardColor) and not isinstance(color, _highlight.HighlightColor):
raise ValueError("Specified color is not one of HighlightStandardColor, highlight.HighlightColor")
@@ -2587,49 +2691,52 @@ class Function:
color = _highlight.HighlightColor(color)
core.BNSetUserInstructionHighlight(self.handle, arch.handle, addr, color._to_core_struct())
- def create_auto_stack_var(self, offset:int, var_type:StringOrType, name:str) -> None:
+ def create_auto_stack_var(self, offset: int, var_type: StringOrType, name: str) -> None:
if isinstance(var_type, str):
(var_type, _) = self.view.parse_type_string(var_type)
tc = var_type._to_core_struct()
core.BNCreateAutoStackVariable(self.handle, offset, tc, name)
- def create_user_stack_var(self, offset:int, var_type:StringOrType, name:str) -> None:
+ def create_user_stack_var(self, offset: int, var_type: StringOrType, name: str) -> None:
if isinstance(var_type, str):
(var_type, _) = self.view.parse_type_string(var_type)
tc = var_type._to_core_struct()
core.BNCreateUserStackVariable(self.handle, offset, tc, name)
- def delete_auto_stack_var(self, offset:int) -> None:
+ def delete_auto_stack_var(self, offset: int) -> None:
core.BNDeleteAutoStackVariable(self.handle, offset)
- def delete_user_stack_var(self, offset:int) -> None:
+ def delete_user_stack_var(self, offset: int) -> None:
core.BNDeleteUserStackVariable(self.handle, offset)
- def create_auto_var(self, var:'variable.Variable', var_type:StringOrType, name:str,
- ignore_disjoint_uses:bool=False) -> None:
+ def create_auto_var(
+ self, var: 'variable.Variable', var_type: StringOrType, name: str, ignore_disjoint_uses: bool = False
+ ) -> None:
if isinstance(var_type, str):
(var_type, _) = self.view.parse_type_string(var_type)
tc = var_type._to_core_struct()
core.BNCreateAutoVariable(self.handle, var.to_BNVariable(), tc, name, ignore_disjoint_uses)
- def create_user_var(self, var:'variable.Variable', var_type:StringOrType, name:str,
- ignore_disjoint_uses:bool=False) -> None:
+ def create_user_var(
+ self, var: 'variable.Variable', var_type: StringOrType, name: str, ignore_disjoint_uses: bool = False
+ ) -> None:
if isinstance(var_type, str):
(var_type, _) = self.view.parse_type_string(var_type)
tc = var_type._to_core_struct()
core.BNCreateUserVariable(self.handle, var.to_BNVariable(), tc, name, ignore_disjoint_uses)
- def delete_user_var(self, var:'variable.Variable') -> None:
+ def delete_user_var(self, var: 'variable.Variable') -> None:
core.BNDeleteUserVariable(self.handle, var.to_BNVariable())
- def is_var_user_defined(self, var:'variable.Variable') -> bool:
+ def is_var_user_defined(self, var: 'variable.Variable') -> bool:
return core.BNIsVariableUserDefined(self.handle, var.to_BNVariable())
- def get_stack_var_at_frame_offset(self, offset:int, addr:int, arch:Optional['architecture.Architecture']=None) -> \
- Optional['variable.Variable']:
+ def get_stack_var_at_frame_offset(
+ self, offset: int, addr: int, arch: Optional['architecture.Architecture'] = None
+ ) -> Optional['variable.Variable']:
if arch is None:
if self.arch is None:
- raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
+ raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
arch = self.arch
found_var = core.BNVariableNameAndType()
if not core.BNGetStackVariableAtFrameOffset(self.handle, arch.handle, addr, offset, found_var):
@@ -2638,7 +2745,7 @@ class Function:
core.BNFreeVariableNameAndType(found_var)
return result
- def get_type_tokens(self, settings:'DisassemblySettings'=None) -> List['DisassemblyTextLine']:
+ def get_type_tokens(self, settings: 'DisassemblySettings' = None) -> List['DisassemblyTextLine']:
_settings = None
if settings is not None:
_settings = settings.handle
@@ -2650,32 +2757,36 @@ class Function:
addr = lines[i].addr
color = _highlight.HighlightColor._from_core_struct(lines[i].highlight)
tokens = InstructionTextToken._from_core_struct(lines[i].tokens, lines[i].count)
- result.append(DisassemblyTextLine(tokens, addr, color = color))
+ result.append(DisassemblyTextLine(tokens, addr, color=color))
core.BNFreeDisassemblyTextLines(lines, count.value)
return result
- def get_reg_value_at_exit(self, reg:'architecture.RegisterType') -> 'variable.RegisterValue':
+ def get_reg_value_at_exit(self, reg: 'architecture.RegisterType') -> 'variable.RegisterValue':
if self.arch is None:
raise Exception("can not get_reg_value_at_exit if Function.arch is")
result = core.BNGetFunctionRegisterValueAtExit(self.handle, self.arch.get_reg_index(reg))
return variable.RegisterValue.from_BNRegisterValue(result, self.arch)
- def set_auto_call_stack_adjustment(self, addr:int, adjust:Union[int, 'types.OffsetWithConfidence'],
- arch:Optional['architecture.Architecture']=None) -> None:
+ def set_auto_call_stack_adjustment(
+ self, addr: int, adjust: Union[int, 'types.OffsetWithConfidence'],
+ arch: Optional['architecture.Architecture'] = None
+ ) -> None:
if arch is None:
if self.arch is None:
- raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
+ raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
arch = self.arch
if not isinstance(adjust, types.OffsetWithConfidence):
adjust = types.OffsetWithConfidence(adjust)
core.BNSetAutoCallStackAdjustment(self.handle, arch.handle, addr, adjust.value, adjust.confidence)
- def set_auto_call_reg_stack_adjustment(self, addr:int, adjust:Mapping['architecture.RegisterStackName', int],
- arch:Optional['architecture.Architecture']=None) -> None:
+ def set_auto_call_reg_stack_adjustment(
+ self, addr: int, adjust: Mapping['architecture.RegisterStackName', int],
+ arch: Optional['architecture.Architecture'] = None
+ ) -> None:
if arch is None:
if self.arch is None:
- raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
+ raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
arch = self.arch
adjust_buf = (core.BNRegisterStackAdjustment * len(adjust))()
i = 0
@@ -2689,25 +2800,29 @@ class Function:
i += 1
core.BNSetAutoCallRegisterStackAdjustment(self.handle, arch.handle, addr, adjust_buf, len(adjust))
- def set_auto_call_reg_stack_adjustment_for_reg_stack(self, addr:int, reg_stack:'architecture.RegisterStackType',
- adjust, arch:Optional['architecture.Architecture']=None) -> None:
+ def set_auto_call_reg_stack_adjustment_for_reg_stack(
+ self, addr: int, reg_stack: 'architecture.RegisterStackType', adjust,
+ arch: Optional['architecture.Architecture'] = None
+ ) -> None:
if arch is None:
if self.arch is None:
- raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
+ raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
arch = self.arch
reg_stack = arch.get_reg_stack_index(reg_stack)
if not isinstance(adjust, types.RegisterStackAdjustmentWithConfidence):
adjust = types.RegisterStackAdjustmentWithConfidence(adjust)
- core.BNSetAutoCallRegisterStackAdjustmentForRegisterStack(self.handle, arch.handle, addr, reg_stack,
- adjust.value, adjust.confidence)
+ core.BNSetAutoCallRegisterStackAdjustmentForRegisterStack(
+ self.handle, arch.handle, addr, reg_stack, adjust.value, adjust.confidence
+ )
- def set_call_type_adjustment(self, addr:int, adjust_type:StringOrType, arch:Optional['architecture.Architecture']=None) -> \
- None:
+ def set_call_type_adjustment(
+ self, addr: int, adjust_type: StringOrType, arch: Optional['architecture.Architecture'] = None
+ ) -> None:
if isinstance(adjust_type, str):
(adjust_type, _) = self.view.parse_type_string(adjust_type)
if arch is None:
if self.arch is None:
- raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
+ raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
arch = self.arch
if adjust_type is None:
tc = None
@@ -2715,22 +2830,26 @@ class Function:
tc = adjust_type._to_core_struct()
core.BNSetUserCallTypeAdjustment(self.handle, arch.handle, addr, tc)
- def set_call_stack_adjustment(self, addr:int, adjust:Union[int, 'types.OffsetWithConfidence'],
- arch:Optional['architecture.Architecture']=None):
+ def set_call_stack_adjustment(
+ self, addr: int, adjust: Union[int, 'types.OffsetWithConfidence'],
+ arch: Optional['architecture.Architecture'] = None
+ ):
if arch is None:
if self.arch is None:
- raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
+ raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
arch = self.arch
if not isinstance(adjust, types.OffsetWithConfidence):
adjust = types.OffsetWithConfidence(adjust)
core.BNSetUserCallStackAdjustment(self.handle, arch.handle, addr, adjust.value, adjust.confidence)
- def set_call_reg_stack_adjustment(self, addr:int,
- adjust:Mapping['architecture.RegisterStackName', 'types.RegisterStackAdjustmentWithConfidence'],
- arch:Optional['architecture.Architecture']=None) -> None:
+ def set_call_reg_stack_adjustment(
+ self, addr: int, adjust: Mapping['architecture.RegisterStackName',
+ 'types.RegisterStackAdjustmentWithConfidence'],
+ arch: Optional['architecture.Architecture'] = None
+ ) -> None:
if arch is None:
if self.arch is None:
- raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
+ raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
arch = self.arch
adjust_buf = (core.BNRegisterStackAdjustment * len(adjust))()
i = 0
@@ -2744,72 +2863,82 @@ class Function:
i += 1
core.BNSetUserCallRegisterStackAdjustment(self.handle, arch.handle, addr, adjust_buf, len(adjust))
- def set_call_reg_stack_adjustment_for_reg_stack(self, addr:int, reg_stack:'architecture.RegisterStackType',
- adjust:Union[int, 'types.RegisterStackAdjustmentWithConfidence'], arch:Optional['architecture.Architecture']=None) -> None:
+ def set_call_reg_stack_adjustment_for_reg_stack(
+ self, addr: int, reg_stack: 'architecture.RegisterStackType',
+ adjust: Union[int,
+ 'types.RegisterStackAdjustmentWithConfidence'], arch: Optional['architecture.Architecture'] = None
+ ) -> None:
if arch is None:
if self.arch is None:
- raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
+ raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
arch = self.arch
reg_stack = arch.get_reg_stack_index(reg_stack)
if not isinstance(adjust, types.RegisterStackAdjustmentWithConfidence):
adjust = types.RegisterStackAdjustmentWithConfidence(adjust)
- core.BNSetUserCallRegisterStackAdjustmentForRegisterStack(self.handle, arch.handle, addr, reg_stack,
- adjust.value, adjust.confidence)
+ core.BNSetUserCallRegisterStackAdjustmentForRegisterStack(
+ self.handle, arch.handle, addr, reg_stack, adjust.value, adjust.confidence
+ )
- def get_call_type_adjustment(self, addr:int, arch:Optional['architecture.Architecture']=None) -> Optional['types.Type']:
+ def get_call_type_adjustment(self, addr: int,
+ arch: Optional['architecture.Architecture'] = None) -> Optional['types.Type']:
if arch is None:
if self.arch is None:
- raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
+ raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
arch = self.arch
result = core.BNGetCallTypeAdjustment(self.handle, arch.handle, addr)
if not result.type:
return None
platform = self.platform
- return types.Type.create(core.BNNewTypeReference(result.type), platform = platform, confidence = result.confidence)
+ return types.Type.create(core.BNNewTypeReference(result.type), platform=platform, confidence=result.confidence)
- def get_call_stack_adjustment(self, addr:int, arch:Optional['architecture.Architecture']=None) -> 'types.OffsetWithConfidence':
+ def get_call_stack_adjustment(
+ self, addr: int, arch: Optional['architecture.Architecture'] = None
+ ) -> 'types.OffsetWithConfidence':
if arch is None:
if self.arch is None:
- raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
+ raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
arch = self.arch
result = core.BNGetCallStackAdjustment(self.handle, arch.handle, addr)
- return types.OffsetWithConfidence(result.value, confidence = result.confidence)
+ return types.OffsetWithConfidence(result.value, confidence=result.confidence)
- def get_call_reg_stack_adjustment(self, addr:int, arch:Optional['architecture.Architecture']=None) -> \
- Dict['architecture.RegisterStackName', 'types.RegisterStackAdjustmentWithConfidence']:
+ def get_call_reg_stack_adjustment(
+ self, addr: int, arch: Optional['architecture.Architecture'] = None
+ ) -> Dict['architecture.RegisterStackName', 'types.RegisterStackAdjustmentWithConfidence']:
if arch is None:
if self.arch is None:
- raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
+ raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
arch = self.arch
count = ctypes.c_ulonglong()
adjust = core.BNGetCallRegisterStackAdjustment(self.handle, arch.handle, addr, count)
assert adjust is not None, "core.BNGetCallRegisterStackAdjustment returned None"
result = {}
for i in range(0, count.value):
- result[arch.get_reg_stack_name(adjust[i].regStack)] = types.RegisterStackAdjustmentWithConfidence(
- adjust[i].adjustment, confidence = adjust[i].confidence)
+ result[arch.get_reg_stack_name(
+ adjust[i].regStack
+ )] = types.RegisterStackAdjustmentWithConfidence(adjust[i].adjustment, confidence=adjust[i].confidence)
core.BNFreeRegisterStackAdjustments(adjust)
return result
- def get_call_reg_stack_adjustment_for_reg_stack(self, addr:int, reg_stack:'architecture.RegisterStackType',
- arch:Optional['architecture.Architecture']=None) -> 'types.RegisterStackAdjustmentWithConfidence':
+ def get_call_reg_stack_adjustment_for_reg_stack(
+ self, addr: int, reg_stack: 'architecture.RegisterStackType', arch: Optional['architecture.Architecture'] = None
+ ) -> 'types.RegisterStackAdjustmentWithConfidence':
if arch is None:
if self.arch is None:
- raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
+ raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
arch = self.arch
reg_stack = arch.get_reg_stack_index(reg_stack)
adjust = core.BNGetCallRegisterStackAdjustmentForRegisterStack(self.handle, arch.handle, addr, reg_stack)
- result = types.RegisterStackAdjustmentWithConfidence(adjust.adjustment, confidence = adjust.confidence)
+ result = types.RegisterStackAdjustmentWithConfidence(adjust.adjustment, confidence=adjust.confidence)
return result
- def is_call_instruction(self, addr:int, arch:Optional['architecture.Architecture']=None) -> bool:
+ def is_call_instruction(self, addr: int, arch: Optional['architecture.Architecture'] = None) -> bool:
if arch is None:
if self.arch is None:
- raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
+ raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
arch = self.arch
return core.BNIsCallInstruction(self.handle, arch.handle, addr)
- def set_user_var_value(self, var:'variable.Variable', def_addr:int, value:'variable.PossibleValueSet') -> None:
+ def set_user_var_value(self, var: 'variable.Variable', def_addr: int, value: 'variable.PossibleValueSet') -> None:
"""
`set_user_var_value` allows the user to specify a PossibleValueSet value for an MLIL variable at its \
definition site.
@@ -2849,7 +2978,7 @@ class Function:
core.BNSetUserVariableValue(self.handle, var.to_BNVariable(), def_site, value._to_core_struct())
- def clear_user_var_value(self, var:'variable.Variable', def_addr:int) -> None:
+ def clear_user_var_value(self, var: 'variable.Variable', def_addr: int) -> None:
"""
Clears a previously defined user variable value.
@@ -2876,8 +3005,9 @@ class Function:
core.BNClearUserVariableValue(self.handle, var.to_BNVariable(), def_site)
- def get_all_user_var_values(self) -> \
- Mapping['variable.Variable', Mapping['ArchAndAddr', 'variable.PossibleValueSet']]:
+ def get_all_user_var_values(
+ self
+ ) -> Mapping['variable.Variable', Mapping['ArchAndAddr', 'variable.PossibleValueSet']]:
"""
Returns a map of current defined user variable values.
@@ -2909,7 +3039,7 @@ class Function:
for def_site in all_values[var]:
self.clear_user_var_value(var, def_site.addr)
- def request_debug_report(self, name:str) -> None:
+ def request_debug_report(self, name: str) -> None:
"""
``request_debug_report`` can generate internal debug reports for a variety of analysis.
Current list of possible values include:
@@ -3002,9 +3132,9 @@ class Function:
handle = core.BNGetWorkflowForFunction(self.handle)
if handle is None:
return None
- return workflow.Workflow(handle = handle)
+ return workflow.Workflow(handle=handle)
- def get_mlil_var_refs(self, var:'variable.Variable') -> List[ILReferenceSource]:
+ def get_mlil_var_refs(self, var: 'variable.Variable') -> List[ILReferenceSource]:
"""
``get_mlil_var_refs`` returns a list of ILReferenceSource objects (IL xrefs or cross-references)
that reference the given variable. The variable is a local variable that can be either on the stack,
@@ -3035,13 +3165,12 @@ class Function:
else:
arch = None
- result.append(ILReferenceSource(
- func, arch, refs[i].addr, refs[i].type, refs[i].exprId))
+ result.append(ILReferenceSource(func, arch, refs[i].addr, refs[i].type, refs[i].exprId))
core.BNFreeILReferences(refs, count.value)
return result
- def get_mlil_var_refs_from(self, addr:int, length:int=None, arch:Optional['architecture.Architecture']=None) -> \
- List[VariableReferenceSource]:
+ def get_mlil_var_refs_from(self, addr: int, length: int = None,
+ arch: Optional['architecture.Architecture'] = None) -> List[VariableReferenceSource]:
"""
``get_mlil_var_refs_from`` returns a list of variables referenced by code in the function ``func``,
of the architecture ``arch``, and at the address ``addr``. If no function is specified, references from
@@ -3062,7 +3191,7 @@ class Function:
if arch is None:
if self.arch is None:
- raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
+ raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
arch = self.arch
if length is None:
@@ -3087,7 +3216,7 @@ class Function:
core.BNFreeVariableReferenceSourceList(refs, count.value)
return result
- def get_hlil_var_refs(self, var:'variable.Variable') -> List[ILReferenceSource]:
+ def get_hlil_var_refs(self, var: 'variable.Variable') -> List[ILReferenceSource]:
"""
``get_hlil_var_refs`` returns a list of ILReferenceSource objects (IL xrefs or cross-references)
that reference the given variable. The variable is a local variable that can be either on the stack,
@@ -3114,13 +3243,12 @@ class Function:
arch = architecture.CoreArchitecture._from_cache(refs[i].arch)
else:
arch = None
- result.append(ILReferenceSource(
- func, arch, refs[i].addr, refs[i].type, refs[i].exprId))
+ result.append(ILReferenceSource(func, arch, refs[i].addr, refs[i].type, refs[i].exprId))
core.BNFreeILReferences(refs, count.value)
return result
- def get_hlil_var_refs_from(self, addr:int, length:int=None, arch:Optional['architecture.Architecture']=None) -> \
- List[VariableReferenceSource]:
+ def get_hlil_var_refs_from(self, addr: int, length: int = None,
+ arch: Optional['architecture.Architecture'] = None) -> List[VariableReferenceSource]:
"""
``get_hlil_var_refs_from`` returns a list of variables referenced by code in the function ``func``,
of the architecture ``arch``, and at the address ``addr``. If no function is specified, references from
@@ -3161,11 +3289,11 @@ class Function:
core.BNFreeVariableReferenceSourceList(refs, count.value)
return result
- def get_instruction_containing_address(self, addr:int, arch:Optional['architecture.Architecture']=None) -> \
- Optional[int]:
+ def get_instruction_containing_address(self, addr: int,
+ arch: Optional['architecture.Architecture'] = None) -> Optional[int]:
if arch is None:
if self.arch is None:
- raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
+ raise ValueError(f"Can't call {_function_name_()} for function with no architecture specified")
arch = self.arch
start = ctypes.c_ulonglong()
@@ -3175,7 +3303,7 @@ class Function:
class AdvancedFunctionAnalysisDataRequestor:
- def __init__(self, func:'Function'=None):
+ def __init__(self, func: 'Function' = None):
self._function = func
if self._function is not None:
self._function.request_advanced_analysis_data()
@@ -3189,7 +3317,7 @@ class AdvancedFunctionAnalysisDataRequestor:
return self._function
@function.setter
- def function(self, func:'Function') -> None:
+ def function(self, func: 'Function') -> None:
if self._function is not None:
self._function.release_advanced_analysis_data()
self._function = func
@@ -3204,13 +3332,15 @@ class AdvancedFunctionAnalysisDataRequestor:
@dataclass
class DisassemblyTextLine:
- tokens:List['InstructionTextToken']
- highlight:'_highlight.HighlightColor'
- address:Optional[int]
- il_instruction:Optional[ILInstructionType]
+ tokens: List['InstructionTextToken']
+ highlight: '_highlight.HighlightColor'
+ address: Optional[int]
+ il_instruction: Optional[ILInstructionType]
- def __init__(self, tokens:List['InstructionTextToken'], address:int=None, il_instr:ILInstructionType=None,
- color:Union['_highlight.HighlightColor', HighlightStandardColor]=None):
+ def __init__(
+ self, tokens: List['InstructionTextToken'], address: int = None, il_instr: ILInstructionType = None,
+ color: Union['_highlight.HighlightColor', HighlightStandardColor] = None
+ ):
self.address = address
self.tokens = tokens
self.il_instruction = il_instr
@@ -3235,8 +3365,10 @@ class DisassemblyTextLine:
class DisassemblyTextRenderer:
- def __init__(self, func:AnyFunctionType=None, settings:'DisassemblySettings'=None,
- handle:core.BNDisassemblySettings=None):
+ def __init__(
+ self, func: AnyFunctionType = None, settings: 'DisassemblySettings' = None,
+ handle: core.BNDisassemblySettings = None
+ ):
if handle is None:
if func is None:
raise ValueError("function required for disassembly")
@@ -3262,30 +3394,30 @@ class DisassemblyTextRenderer:
@property
def function(self) -> 'Function':
- return Function(handle = core.BNGetDisassemblyTextRendererFunction(self.handle))
+ return Function(handle=core.BNGetDisassemblyTextRendererFunction(self.handle))
@property
def il_function(self) -> Optional[ILFunctionType]:
llil = core.BNGetDisassemblyTextRendererLowLevelILFunction(self.handle)
if llil:
- return lowlevelil.LowLevelILFunction(handle = llil)
+ return lowlevelil.LowLevelILFunction(handle=llil)
mlil = core.BNGetDisassemblyTextRendererMediumLevelILFunction(self.handle)
if mlil:
- return mediumlevelil.MediumLevelILFunction(handle = mlil)
+ return mediumlevelil.MediumLevelILFunction(handle=mlil)
hlil = core.BNGetDisassemblyTextRendererHighLevelILFunction(self.handle)
if hlil:
- return highlevelil.HighLevelILFunction(handle = hlil)
+ return highlevelil.HighLevelILFunction(handle=hlil)
return None
@property
def basic_block(self) -> Optional['basicblock.BasicBlock']:
result = core.BNGetDisassemblyTextRendererBasicBlock(self.handle)
if result:
- return basicblock.BasicBlock(handle = result)
+ return basicblock.BasicBlock(handle=result)
return None
@basic_block.setter
- def basic_block(self, block:'basicblock.BasicBlock') -> None:
+ def basic_block(self, block: 'basicblock.BasicBlock') -> None:
if block is not None:
core.BNSetDisassemblyTextRendererBasicBlock(self.handle, block.handle)
else:
@@ -3293,18 +3425,20 @@ class DisassemblyTextRenderer:
@property
def arch(self) -> 'architecture.Architecture':
- return architecture.CoreArchitecture._from_cache(handle = core.BNGetDisassemblyTextRendererArchitecture(self.handle))
+ return architecture.CoreArchitecture._from_cache(
+ handle=core.BNGetDisassemblyTextRendererArchitecture(self.handle)
+ )
@arch.setter
- def arch(self, arch:'architecture.Architecture') -> None:
+ def arch(self, arch: 'architecture.Architecture') -> None:
core.BNSetDisassemblyTextRendererArchitecture(self.handle, arch.handle)
@property
def settings(self) -> 'DisassemblySettings':
- return DisassemblySettings(handle = core.BNGetDisassemblyTextRendererSettings(self.handle))
+ return DisassemblySettings(handle=core.BNGetDisassemblyTextRendererSettings(self.handle))
@settings.setter
- def settings(self, settings:'DisassemblySettings') -> None:
+ def settings(self, settings: 'DisassemblySettings') -> None:
if settings is not None:
core.BNSetDisassemblyTextRendererSettings(self.handle, settings.handle)
core.BNSetDisassemblyTextRendererSettings(self.handle, None)
@@ -3317,7 +3451,7 @@ class DisassemblyTextRenderer:
def has_data_flow(self) -> bool:
return core.BNDisassemblyTextRendererHasDataFlow(self.handle)
- def get_instruction_annotations(self, addr:int) -> List['InstructionTextToken']:
+ def get_instruction_annotations(self, addr: int) -> List['InstructionTextToken']:
count = ctypes.c_ulonglong()
tokens = core.BNGetDisassemblyTextRendererInstructionAnnotations(self.handle, addr, count)
assert tokens is not None, "core.BNGetDisassemblyTextRendererInstructionAnnotations returned None"
@@ -3325,7 +3459,7 @@ class DisassemblyTextRenderer:
core.BNFreeInstructionText(tokens, count.value)
return result
- def get_instruction_text(self, addr:int) -> Generator[Tuple[Optional['DisassemblyTextLine'], int], None, None]:
+ def get_instruction_text(self, addr: int) -> Generator[Tuple[Optional['DisassemblyTextLine'], int], None, None]:
count = ctypes.c_ulonglong()
length = ctypes.c_ulonglong()
lines = ctypes.POINTER(core.BNDisassemblyTextLine)()
@@ -3346,7 +3480,7 @@ class DisassemblyTextRenderer:
finally:
core.BNFreeDisassemblyTextLines(lines, count.value)
- def get_disassembly_text(self, addr:int) -> Generator[Tuple[Optional['DisassemblyTextLine'], int], None, None]:
+ def get_disassembly_text(self, addr: int) -> Generator[Tuple[Optional['DisassemblyTextLine'], int], None, None]:
count = ctypes.c_ulonglong()
length = ctypes.c_ulonglong()
length.value = 0
@@ -3369,8 +3503,10 @@ class DisassemblyTextRenderer:
finally:
core.BNFreeDisassemblyTextLines(lines, count.value)
- def post_process_lines(self, addr:int, length:int, in_lines:Union[str, List[str], List['DisassemblyTextLine']],
- indent_spaces:str=''):
+ def post_process_lines(
+ self, addr: int, length: int, in_lines: Union[str, List[str], List['DisassemblyTextLine']],
+ indent_spaces: str = ''
+ ):
if isinstance(in_lines, str):
in_lines = in_lines.split('\n')
line_buf = (core.BNDisassemblyTextLine * len(in_lines))()
@@ -3399,7 +3535,9 @@ class DisassemblyTextRenderer:
line_buf[i].count = len(line.tokens)
line_buf[i].tokens = InstructionTextToken._get_core_struct(line.tokens)
count = ctypes.c_ulonglong()
- lines = core.BNPostProcessDisassemblyTextRendererLines(self.handle, addr, length, line_buf, len(in_lines), count, indent_spaces)
+ lines = core.BNPostProcessDisassemblyTextRendererLines(
+ self.handle, addr, length, line_buf, len(in_lines), count, indent_spaces
+ )
assert lines is not None, "core.BNPostProcessDisassemblyTextRendererLines returned None"
il_function = self.il_function
try:
@@ -3418,7 +3556,7 @@ class DisassemblyTextRenderer:
def reset_deduplicated_comments(self) -> None:
core.BNResetDisassemblyTextRendererDeduplicatedComments(self.handle)
- def add_symbol_token(self, tokens:List['InstructionTextToken'], addr:int, size:int, operand:int=None) -> bool:
+ def add_symbol_token(self, tokens: List['InstructionTextToken'], addr: int, size: int, operand: int = None) -> bool:
if operand is None:
operand = 0xffffffff
count = ctypes.c_ulonglong()
@@ -3431,8 +3569,9 @@ class DisassemblyTextRenderer:
core.BNFreeInstructionText(new_tokens, count.value)
return True
- def add_stack_var_reference_tokens(self, tokens:List['InstructionTextToken'],
- ref:'variable.StackVariableReference') -> None:
+ def add_stack_var_reference_tokens(
+ self, tokens: List['InstructionTextToken'], ref: 'variable.StackVariableReference'
+ ) -> None:
stack_ref = core.BNStackVariableReference()
if ref.source_operand is None:
stack_ref.sourceOperand = 0xffffffff
@@ -3456,11 +3595,13 @@ class DisassemblyTextRenderer:
core.BNFreeInstructionText(new_tokens, count.value)
@staticmethod
- def is_integer_token(token:'InstructionTextToken') -> bool:
+ def is_integer_token(token: 'InstructionTextToken') -> bool:
return core.BNIsIntegerToken(token.type)
- def add_integer_token(self, tokens:List['InstructionTextToken'], int_token:'InstructionTextToken', addr:int,
- arch:Optional['architecture.Architecture']=None) -> None:
+ def add_integer_token(
+ self, tokens: List['InstructionTextToken'], int_token: 'InstructionTextToken', addr: int,
+ arch: Optional['architecture.Architecture'] = None
+ ) -> None:
if arch is not None:
arch = arch.handle
in_token_obj = InstructionTextToken._get_core_struct([int_token])
@@ -3471,8 +3612,10 @@ class DisassemblyTextRenderer:
tokens += result
core.BNFreeInstructionText(new_tokens, count.value)
- def wrap_comment(self, lines:List['DisassemblyTextLine'], cur_line:'DisassemblyTextLine', comment:str,
- has_auto_annotations:bool, leading_spaces:str=" ", indent_spaces:str= "") -> None:
+ def wrap_comment(
+ self, lines: List['DisassemblyTextLine'], cur_line: 'DisassemblyTextLine', comment: str,
+ has_auto_annotations: bool, leading_spaces: str = " ", indent_spaces: str = ""
+ ) -> None:
cur_line_obj = core.BNDisassemblyTextLine()
cur_line_obj.addr = cur_line.address
if cur_line.il_instruction is None:
@@ -3483,8 +3626,9 @@ class DisassemblyTextRenderer:
cur_line_obj.tokens = InstructionTextToken._get_core_struct(cur_line.tokens)
cur_line_obj.count = len(cur_line.tokens)
count = ctypes.c_ulonglong()
- new_lines = core.BNDisassemblyTextRendererWrapComment(self.handle, cur_line_obj, count, comment,
- has_auto_annotations, leading_spaces, indent_spaces)
+ new_lines = core.BNDisassemblyTextRendererWrapComment(
+ self.handle, cur_line_obj, count, comment, has_auto_annotations, leading_spaces, indent_spaces
+ )
assert new_lines is not None, "core.BNDisassemblyTextRendererWrapComment returned None"
il_function = self.il_function
for i in range(0, count.value):
diff --git a/python/functionrecognizer.py b/python/functionrecognizer.py
index 1b3f13b8..1d84eadc 100644
--- a/python/functionrecognizer.py
+++ b/python/functionrecognizer.py
@@ -54,10 +54,10 @@ class FunctionRecognizer:
def _recognize_low_level_il(self, ctxt, data, func, il):
try:
- file_metadata = filemetadata.FileMetadata(handle = core.BNGetFileForView(data))
- view = binaryview.BinaryView(file_metadata = file_metadata, handle = core.BNNewViewReference(data))
- func = function.Function(view, handle = core.BNNewFunctionReference(func))
- il = lowlevelil.LowLevelILFunction(func.arch, handle = core.BNNewLowLevelILFunctionReference(il))
+ file_metadata = filemetadata.FileMetadata(handle=core.BNGetFileForView(data))
+ view = binaryview.BinaryView(file_metadata=file_metadata, handle=core.BNNewViewReference(data))
+ func = function.Function(view, handle=core.BNNewFunctionReference(func))
+ il = lowlevelil.LowLevelILFunction(func.arch, handle=core.BNNewLowLevelILFunctionReference(il))
return self.recognize_low_level_il(view, func, il)
except:
log_error(traceback.format_exc())
@@ -68,10 +68,10 @@ class FunctionRecognizer:
def _recognize_medium_level_il(self, ctxt, data, func, il):
try:
- file_metadata = filemetadata.FileMetadata(handle = core.BNGetFileForView(data))
- view = binaryview.BinaryView(file_metadata = file_metadata, handle = core.BNNewViewReference(data))
- func = function.Function(view, handle = core.BNNewFunctionReference(func))
- il = mediumlevelil.MediumLevelILFunction(func.arch, handle = core.BNNewMediumLevelILFunctionReference(il))
+ file_metadata = filemetadata.FileMetadata(handle=core.BNGetFileForView(data))
+ view = binaryview.BinaryView(file_metadata=file_metadata, handle=core.BNNewViewReference(data))
+ func = function.Function(view, handle=core.BNNewFunctionReference(func))
+ il = mediumlevelil.MediumLevelILFunction(func.arch, handle=core.BNNewMediumLevelILFunctionReference(il))
return self.recognize_medium_level_il(view, func, il)
except:
log_error(traceback.format_exc())
diff --git a/python/generator.cpp b/python/generator.cpp
index 135bc958..99d2d455 100644
--- a/python/generator.cpp
+++ b/python/generator.cpp
@@ -27,41 +27,41 @@ using namespace std;
map<string, string> g_pythonKeywordReplacements = {
- {"False", "False_"},
- {"True", "True_"},
- {"None", "None_"},
- {"and", "and_"},
- {"as", "as_"},
- {"assert", "assert_"},
- {"async", "async_"},
- {"await", "await_"},
- {"break", "break_"},
- {"class", "class_"},
- {"continue", "continue_"},
- {"def", "def_"},
- {"del", "del_"},
- {"elif", "elif_"},
- {"else", "else_"},
- {"except", "except_"},
- {"finally", "finally_"},
- {"for", "for_"},
- {"from", "from_"},
- {"global", "global_"},
- {"if", "if_"},
- {"import", "import_"},
- {"in", "in_"},
- {"is", "is_"},
- {"lambda", "lambda_"},
- {"nonlocal", "nonlocal_"},
- {"not", "not_"},
- {"or", "or_"},
- {"pass", "pass_"},
- {"raise", "raise_"},
- {"return", "return_"},
- {"try", "try_"},
- {"while", "while_"},
- {"with", "with_"},
- {"yield", "yield_"},
+ {"False", "False_"},
+ {"True", "True_"},
+ {"None", "None_"},
+ {"and", "and_"},
+ {"as", "as_"},
+ {"assert", "assert_"},
+ {"async", "async_"},
+ {"await", "await_"},
+ {"break", "break_"},
+ {"class", "class_"},
+ {"continue", "continue_"},
+ {"def", "def_"},
+ {"del", "del_"},
+ {"elif", "elif_"},
+ {"else", "else_"},
+ {"except", "except_"},
+ {"finally", "finally_"},
+ {"for", "for_"},
+ {"from", "from_"},
+ {"global", "global_"},
+ {"if", "if_"},
+ {"import", "import_"},
+ {"in", "in_"},
+ {"is", "is_"},
+ {"lambda", "lambda_"},
+ {"nonlocal", "nonlocal_"},
+ {"not", "not_"},
+ {"or", "or_"},
+ {"pass", "pass_"},
+ {"raise", "raise_"},
+ {"return", "return_"},
+ {"try", "try_"},
+ {"while", "while_"},
+ {"with", "with_"},
+ {"yield", "yield_"},
};
@@ -126,8 +126,8 @@ void OutputType(FILE* out, Type* type, bool isReturnType = false, bool isCallbac
fprintf(out, "ctypes.c_void_p");
break;
}
- else if ((type->GetChildType()->GetClass() == IntegerTypeClass) &&
- (type->GetChildType()->GetWidth() == 1) && (type->GetChildType()->IsSigned()))
+ else if ((type->GetChildType()->GetClass() == IntegerTypeClass) && (type->GetChildType()->GetWidth() == 1)
+ && (type->GetChildType()->IsSigned()))
{
if (isReturnType)
fprintf(out, "ctypes.POINTER(ctypes.c_byte)");
@@ -194,8 +194,8 @@ void OutputSwizzledType(FILE* out, Type* type)
fprintf(out, "Optional[ctypes.c_void_p]");
break;
}
- else if ((type->GetChildType()->GetClass() == IntegerTypeClass) &&
- (type->GetChildType()->GetWidth() == 1) && (type->GetChildType()->IsSigned()))
+ else if ((type->GetChildType()->GetClass() == IntegerTypeClass) && (type->GetChildType()->GetWidth() == 1)
+ && (type->GetChildType()->IsSigned()))
{
fprintf(out, "Optional[str]");
break;
@@ -300,12 +300,13 @@ int main(int argc, char* argv[])
bool stringField = false;
for (auto& arg : i.second->GetStructure()->GetMembers())
{
- if ((arg.type->GetClass() == PointerTypeClass) &&
- (arg.type->GetChildType()->GetWidth() == 1) &&
- (arg.type->GetChildType()->IsSigned()))
+ if ((arg.type->GetClass() == PointerTypeClass) && (arg.type->GetChildType()->GetWidth() == 1)
+ && (arg.type->GetChildType()->IsSigned()))
{
- fprintf(out, "\t@property\n\tdef %s(self):\n\t\treturn pyNativeStr(self._%s)\n", arg.name.c_str(), arg.name.c_str());
- fprintf(out, "\t@%s.setter\n\tdef %s(self, value):\n\t\tself._%s = cstr(value)\n", arg.name.c_str(), arg.name.c_str(), arg.name.c_str());
+ fprintf(out, "\t@property\n\tdef %s(self):\n\t\treturn pyNativeStr(self._%s)\n", arg.name.c_str(),
+ arg.name.c_str());
+ fprintf(out, "\t@%s.setter\n\tdef %s(self, value):\n\t\tself._%s = cstr(value)\n", arg.name.c_str(),
+ arg.name.c_str(), arg.name.c_str());
stringField = true;
}
}
@@ -328,8 +329,8 @@ int main(int argc, char* argv[])
fprintf(enums, "\t%s = %" PRId64 "\n", j.name.c_str(), j.value);
}
}
- else if ((i.second->GetClass() == BoolTypeClass) || (i.second->GetClass() == IntegerTypeClass) ||
- (i.second->GetClass() == FloatTypeClass) || (i.second->GetClass() == ArrayTypeClass))
+ else if ((i.second->GetClass() == BoolTypeClass) || (i.second->GetClass() == IntegerTypeClass)
+ || (i.second->GetClass() == FloatTypeClass) || (i.second->GetClass() == ArrayTypeClass))
{
fprintf(out, "%s = ", name.c_str());
OutputType(out, i.second);
@@ -359,9 +360,9 @@ int main(int argc, char* argv[])
bool requiresDependency = false;
for (auto& j : type->GetStructure()->GetMembers())
{
- if ((j.type->GetClass() == NamedTypeReferenceClass) &&
- (types[j.type->GetNamedTypeReference()->GetName()]->GetClass() == StructureTypeClass) &&
- (finishedStructs.count(j.type->GetNamedTypeReference()->GetName()) == 0))
+ if ((j.type->GetClass() == NamedTypeReferenceClass)
+ && (types[j.type->GetNamedTypeReference()->GetName()]->GetClass() == StructureTypeClass)
+ && (finishedStructs.count(j.type->GetNamedTypeReference()->GetName()) == 0))
{
// This structure needs another structure that isn't fully defined yet, need to wait
// for the dependencies to be defined
@@ -377,9 +378,8 @@ int main(int argc, char* argv[])
for (auto& j : type->GetStructure()->GetMembers())
{
// To help the python->C wrappers
- if ((j.type->GetClass() == PointerTypeClass) &&
- (j.type->GetChildType()->GetWidth() == 1) &&
- (j.type->GetChildType()->IsSigned()))
+ if ((j.type->GetClass() == PointerTypeClass) && (j.type->GetChildType()->GetWidth() == 1)
+ && (j.type->GetChildType()->IsSigned()))
{
fprintf(out, "\t\t(\"_%s\", ", j.name.c_str());
}
@@ -395,7 +395,8 @@ int main(int argc, char* argv[])
else if (type->GetClass() == NamedTypeReferenceClass)
{
fprintf(out, "%s = %s\n", name.c_str(), type->GetNamedTypeReference()->GetName().GetString().c_str());
- fprintf(out, "%sHandle = %sHandle\n", name.c_str(), type->GetNamedTypeReference()->GetName().GetString().c_str());
+ fprintf(out, "%sHandle = %sHandle\n", name.c_str(),
+ type->GetNamedTypeReference()->GetName().GetString().c_str());
finishedStructs.insert(i);
processedSome = true;
}
@@ -420,9 +421,9 @@ int main(int argc, char* argv[])
// Check for a string result, these will be automatically wrapped to free the string
// memory and return a Python string
- bool stringResult = (i.second->GetChildType()->GetClass() == PointerTypeClass) &&
- (i.second->GetChildType()->GetChildType()->GetWidth() == 1) &&
- (i.second->GetChildType()->GetChildType()->IsSigned());
+ bool stringResult = (i.second->GetChildType()->GetClass() == PointerTypeClass)
+ && (i.second->GetChildType()->GetChildType()->GetWidth() == 1)
+ && (i.second->GetChildType()->GetChildType()->IsSigned());
// Pointer returns will be automatically wrapped to return None on null pointer
bool pointerResult = (i.second->GetChildType()->GetClass() == PointerTypeClass);
@@ -475,7 +476,8 @@ int main(int argc, char* argv[])
}
else
{
- // As of writing this, only BNLog's have variable instruction lengths, but in an attempt not to break in the future:
+ // As of writing this, only BNLog's have variable instruction lengths, but in an attempt not to break in the
+ // future:
if (funcName.compare(0, 6, "_BNLog") == 0)
{
if (funcName != "_BNLog")
@@ -497,7 +499,7 @@ int main(int argc, char* argv[])
if (!i.second->HasVariableArguments())
{
size_t argN = 0;
- for (auto& arg: i.second->GetParameters())
+ for (auto& arg : i.second->GetParameters())
{
string argName = arg.name;
if (g_pythonKeywordReplacements.find(argName) != g_pythonKeywordReplacements.end())
@@ -514,7 +516,7 @@ int main(int argc, char* argv[])
OutputSwizzledType(out, arg.type);
else
OutputType(out, arg.type);
- argN ++;
+ argN++;
}
}
fprintf(out, "\n\t\t) -> ");
@@ -536,10 +538,9 @@ int main(int argc, char* argv[])
if (argName.empty())
argName = "arg" + to_string(argN);
- if (swizzleArgs && (arg.type->GetClass() == PointerTypeClass) &&
- (arg.type->GetChildType()->GetClass() == IntegerTypeClass) &&
- (arg.type->GetChildType()->GetWidth() == 1) &&
- (arg.type->GetChildType()->IsSigned()))
+ if (swizzleArgs && (arg.type->GetClass() == PointerTypeClass)
+ && (arg.type->GetChildType()->GetClass() == IntegerTypeClass)
+ && (arg.type->GetChildType()->GetWidth() == 1) && (arg.type->GetChildType()->IsSigned()))
{
stringArgFuncCall += string("cstr(") + argName + "), ";
}
@@ -550,7 +551,7 @@ int main(int argc, char* argv[])
argN++;
}
if (argN > 0)
- stringArgFuncCall = stringArgFuncCall.substr(0, stringArgFuncCall.size()-2);
+ stringArgFuncCall = stringArgFuncCall.substr(0, stringArgFuncCall.size() - 2);
stringArgFuncCall += ")";
if (stringResult)
diff --git a/python/highlevelil.py b/python/highlevelil.py
index b813c2ec..1aafd316 100644
--- a/python/highlevelil.py
+++ b/python/highlevelil.py
@@ -38,9 +38,10 @@ from . import highlight
from . import flowgraph
from . import variable
from .interaction import show_graph_report
-from .commonil import (BaseILInstruction, Tailcall, Syscall, Localcall, Comparison, Signed, UnaryOperation, BinaryOperation,
- SSA, Phi, Loop, ControlFlow, Memory, Constant, Arithmetic, DoublePrecision, Terminal,
- FloatingPoint)
+from .commonil import (
+ BaseILInstruction, Tailcall, Syscall, Localcall, Comparison, Signed, UnaryOperation, BinaryOperation, SSA, Phi,
+ Loop, ControlFlow, Memory, Constant, Arithmetic, DoublePrecision, Terminal, FloatingPoint
+)
LinesType = Generator['function.DisassemblyTextLine', None, None]
ExpressionIndex = NewType('ExpressionIndex', int)
@@ -48,30 +49,23 @@ InstructionIndex = NewType('InstructionIndex', int)
HLILInstructionsType = Generator['HighLevelILInstruction', None, None]
HLILBasicBlocksType = Generator['HighLevelILBasicBlock', None, None]
OperandsType = Tuple[ExpressionIndex, ExpressionIndex, ExpressionIndex, ExpressionIndex, ExpressionIndex]
-HighLevelILOperandType = Union[
- 'HighLevelILInstruction',
- 'lowlevelil.ILIntrinsic',
- 'variable.Variable',
- 'mediumlevelil.SSAVariable',
- List[int],
- List['variable.Variable'],
- List['mediumlevelil.SSAVariable'],
- List['HighLevelILInstruction'],
- Optional[int],
- float,
- 'GotoLabel'
-]
+HighLevelILOperandType = Union['HighLevelILInstruction', 'lowlevelil.ILIntrinsic', 'variable.Variable',
+ 'mediumlevelil.SSAVariable', List[int], List['variable.Variable'],
+ List['mediumlevelil.SSAVariable'], List['HighLevelILInstruction'], Optional[int], float,
+ 'GotoLabel']
VariablesList = List[Union['mediumlevelil.SSAVariable', 'variable.Variable']]
+
class VariableReferenceType(Enum):
Read = 0
Written = 1
AddressTaken = 2
+
@dataclass(frozen=True)
class HighLevelILOperationAndSize:
- operation:HighLevelILOperation
- size:int
+ operation: HighLevelILOperation
+ size: int
def __repr__(self):
if self.size == 0:
@@ -81,8 +75,8 @@ class HighLevelILOperationAndSize:
@dataclass(frozen=True)
class GotoLabel:
- function:'HighLevelILFunction'
- id:int
+ function: 'HighLevelILFunction'
+ id: int
def __repr__(self):
return f"<label: {self.name}>"
@@ -100,7 +94,7 @@ class GotoLabel:
return core.BNGetGotoLabelName(self.function.source_function.handle, self.id)
@name.setter
- def name(self, value:str) -> None:
+ def name(self, value: str) -> None:
assert self.function.source_function is not None, "Cant set name of function without source_function"
core.BNSetUserGotoLabelName(self.function.source_function.handle, self.id, value)
@@ -115,17 +109,20 @@ class GotoLabel:
@dataclass(frozen=True, order=True)
class CoreHighLevelILInstruction:
- operation:HighLevelILOperation
- source_operand:int
- size:int
- operands:OperandsType
- address:int
- parent:ExpressionIndex
+ operation: HighLevelILOperation
+ source_operand: int
+ size: int
+ operands: OperandsType
+ address: int
+ parent: ExpressionIndex
@classmethod
- def from_BNHighLevelILInstruction(cls, instr:core.BNHighLevelILInstruction) -> 'CoreHighLevelILInstruction':
- operands:OperandsType = tuple([ExpressionIndex(instr.operands[i]) for i in range(5)]) # type: ignore
- return cls(HighLevelILOperation(instr.operation), instr.sourceOperand, instr.size, operands, instr.address, instr.parent)
+ def from_BNHighLevelILInstruction(cls, instr: core.BNHighLevelILInstruction) -> 'CoreHighLevelILInstruction':
+ operands: OperandsType = tuple([ExpressionIndex(instr.operands[i]) for i in range(5)]) # type: ignore
+ return cls(
+ HighLevelILOperation(instr.operation), instr.sourceOperand, instr.size, operands, instr.address,
+ instr.parent
+ )
@dataclass(frozen=True)
@@ -134,132 +131,162 @@ class HighLevelILInstruction(BaseILInstruction):
``class HighLevelILInstruction`` High Level Intermediate Language Instructions form an abstract syntax tree of
the code. Control flow structures are present as high level constructs in the HLIL tree.
"""
- function:'HighLevelILFunction'
- expr_index:ExpressionIndex
- core_instr:CoreHighLevelILInstruction
- as_ast:bool
- instr_index:InstructionIndex
- ILOperations:ClassVar[Mapping[HighLevelILOperation, List[Tuple[str,str]]]] = {
- HighLevelILOperation.HLIL_NOP: [],
- HighLevelILOperation.HLIL_BLOCK: [("body", "expr_list")],
- HighLevelILOperation.HLIL_IF: [("condition", "expr"), ("true", "expr"), ("false", "expr")],
- HighLevelILOperation.HLIL_WHILE: [("condition", "expr"), ("body", "expr")],
- HighLevelILOperation.HLIL_WHILE_SSA: [("condition_phi", "expr"), ("condition", "expr"), ("body", "expr")],
- HighLevelILOperation.HLIL_DO_WHILE: [("body", "expr"), ("condition", "expr")],
- HighLevelILOperation.HLIL_DO_WHILE_SSA: [("body", "expr"), ("condition_phi", "expr"), ("condition", "expr")],
- HighLevelILOperation.HLIL_FOR: [("init", "expr"), ("condition", "expr"), ("update", "expr"), ("body", "expr")],
- HighLevelILOperation.HLIL_FOR_SSA: [("init", "expr"), ("condition_phi", "expr"), ("condition", "expr"), ("update", "expr"), ("body", "expr")],
- HighLevelILOperation.HLIL_SWITCH: [("condition", "expr"), ("default", "expr"), ("cases", "expr_list")],
- HighLevelILOperation.HLIL_CASE: [("values", "expr_list"), ("body", "expr")],
- HighLevelILOperation.HLIL_BREAK: [],
- HighLevelILOperation.HLIL_CONTINUE: [],
- HighLevelILOperation.HLIL_JUMP: [("dest", "expr")],
- HighLevelILOperation.HLIL_RET: [("src", "expr_list")],
- HighLevelILOperation.HLIL_NORET: [],
- HighLevelILOperation.HLIL_GOTO: [("target", "label")],
- HighLevelILOperation.HLIL_LABEL: [("target", "label")],
- HighLevelILOperation.HLIL_VAR_DECLARE: [("var", "var")],
- HighLevelILOperation.HLIL_VAR_INIT: [("dest", "var"), ("src", "expr")],
- HighLevelILOperation.HLIL_VAR_INIT_SSA: [("dest", "var_ssa"), ("src", "expr")],
- HighLevelILOperation.HLIL_ASSIGN: [("dest", "expr"), ("src", "expr")],
- HighLevelILOperation.HLIL_ASSIGN_UNPACK: [("dest", "expr_list"), ("src", "expr")],
- HighLevelILOperation.HLIL_ASSIGN_MEM_SSA: [("dest", "expr"), ("dest_memory", "int"), ("src", "expr"), ("src_memory", "int")],
- HighLevelILOperation.HLIL_ASSIGN_UNPACK_MEM_SSA: [("dest", "expr_list"), ("dest_memory", "int"), ("src", "expr"), ("src_memory", "int")],
- HighLevelILOperation.HLIL_VAR: [("var", "var")],
- HighLevelILOperation.HLIL_VAR_SSA: [("var", "var_ssa")],
- HighLevelILOperation.HLIL_VAR_PHI: [("dest", "var_ssa"), ("src", "var_ssa_list")],
- HighLevelILOperation.HLIL_MEM_PHI: [("dest", "int"), ("src", "int_list")],
- HighLevelILOperation.HLIL_STRUCT_FIELD: [("src", "expr"), ("offset", "int"), ("member_index", "member_index")],
- HighLevelILOperation.HLIL_ARRAY_INDEX: [("src", "expr"), ("index", "expr")],
- HighLevelILOperation.HLIL_ARRAY_INDEX_SSA: [("src", "expr"), ("src_memory", "int"), ("index", "expr")],
- HighLevelILOperation.HLIL_SPLIT: [("high", "expr"), ("low", "expr")],
- HighLevelILOperation.HLIL_DEREF: [("src", "expr")],
- HighLevelILOperation.HLIL_DEREF_FIELD: [("src", "expr"), ("offset", "int"), ("member_index", "member_index")],
- HighLevelILOperation.HLIL_DEREF_SSA: [("src", "expr"), ("src_memory", "int")],
- HighLevelILOperation.HLIL_DEREF_FIELD_SSA: [("src", "expr"), ("src_memory", "int"), ("offset", "int"), ("member_index", "member_index")],
- HighLevelILOperation.HLIL_ADDRESS_OF: [("src", "expr")],
- HighLevelILOperation.HLIL_CONST: [("constant", "int")],
- HighLevelILOperation.HLIL_CONST_PTR: [("constant", "int")],
- HighLevelILOperation.HLIL_EXTERN_PTR: [("constant", "int"), ("offset", "int")],
- HighLevelILOperation.HLIL_FLOAT_CONST: [("constant", "float")],
- HighLevelILOperation.HLIL_IMPORT: [("constant", "int")],
- HighLevelILOperation.HLIL_ADD: [("left", "expr"), ("right", "expr")],
- HighLevelILOperation.HLIL_ADC: [("left", "expr"), ("right", "expr"), ("carry", "expr")],
- HighLevelILOperation.HLIL_SUB: [("left", "expr"), ("right", "expr")],
- HighLevelILOperation.HLIL_SBB: [("left", "expr"), ("right", "expr"), ("carry", "expr")],
- HighLevelILOperation.HLIL_AND: [("left", "expr"), ("right", "expr")],
- HighLevelILOperation.HLIL_OR: [("left", "expr"), ("right", "expr")],
- HighLevelILOperation.HLIL_XOR: [("left", "expr"), ("right", "expr")],
- HighLevelILOperation.HLIL_LSL: [("left", "expr"), ("right", "expr")],
- HighLevelILOperation.HLIL_LSR: [("left", "expr"), ("right", "expr")],
- HighLevelILOperation.HLIL_ASR: [("left", "expr"), ("right", "expr")],
- HighLevelILOperation.HLIL_ROL: [("left", "expr"), ("right", "expr")],
- HighLevelILOperation.HLIL_RLC: [("left", "expr"), ("right", "expr"), ("carry", "expr")],
- HighLevelILOperation.HLIL_ROR: [("left", "expr"), ("right", "expr")],
- HighLevelILOperation.HLIL_RRC: [("left", "expr"), ("right", "expr"), ("carry", "expr")],
- HighLevelILOperation.HLIL_MUL: [("left", "expr"), ("right", "expr")],
- HighLevelILOperation.HLIL_MULU_DP: [("left", "expr"), ("right", "expr")],
- HighLevelILOperation.HLIL_MULS_DP: [("left", "expr"), ("right", "expr")],
- HighLevelILOperation.HLIL_DIVU: [("left", "expr"), ("right", "expr")],
- HighLevelILOperation.HLIL_DIVU_DP: [("left", "expr"), ("right", "expr")],
- HighLevelILOperation.HLIL_DIVS: [("left", "expr"), ("right", "expr")],
- HighLevelILOperation.HLIL_DIVS_DP: [("left", "expr"), ("right", "expr")],
- HighLevelILOperation.HLIL_MODU: [("left", "expr"), ("right", "expr")],
- HighLevelILOperation.HLIL_MODU_DP: [("left", "expr"), ("right", "expr")],
- HighLevelILOperation.HLIL_MODS: [("left", "expr"), ("right", "expr")],
- HighLevelILOperation.HLIL_MODS_DP: [("left", "expr"), ("right", "expr")],
- HighLevelILOperation.HLIL_NEG: [("src", "expr")],
- HighLevelILOperation.HLIL_NOT: [("src", "expr")],
- HighLevelILOperation.HLIL_SX: [("src", "expr")],
- HighLevelILOperation.HLIL_ZX: [("src", "expr")],
- HighLevelILOperation.HLIL_LOW_PART: [("src", "expr")],
- HighLevelILOperation.HLIL_CALL: [("dest", "expr"), ("params", "expr_list")],
- HighLevelILOperation.HLIL_CALL_SSA: [("dest", "expr"), ("params", "expr_list"), ("dest_memory", "int"), ("src_memory", "int")],
- HighLevelILOperation.HLIL_CMP_E: [("left", "expr"), ("right", "expr")],
- HighLevelILOperation.HLIL_CMP_NE: [("left", "expr"), ("right", "expr")],
- HighLevelILOperation.HLIL_CMP_SLT: [("left", "expr"), ("right", "expr")],
- HighLevelILOperation.HLIL_CMP_ULT: [("left", "expr"), ("right", "expr")],
- HighLevelILOperation.HLIL_CMP_SLE: [("left", "expr"), ("right", "expr")],
- HighLevelILOperation.HLIL_CMP_ULE: [("left", "expr"), ("right", "expr")],
- HighLevelILOperation.HLIL_CMP_SGE: [("left", "expr"), ("right", "expr")],
- HighLevelILOperation.HLIL_CMP_UGE: [("left", "expr"), ("right", "expr")],
- HighLevelILOperation.HLIL_CMP_SGT: [("left", "expr"), ("right", "expr")],
- HighLevelILOperation.HLIL_CMP_UGT: [("left", "expr"), ("right", "expr")],
- HighLevelILOperation.HLIL_TEST_BIT: [("left", "expr"), ("right", "expr")],
- HighLevelILOperation.HLIL_BOOL_TO_INT: [("src", "expr")],
- HighLevelILOperation.HLIL_ADD_OVERFLOW: [("left", "expr"), ("right", "expr")],
- HighLevelILOperation.HLIL_SYSCALL: [("params", "expr_list")],
- HighLevelILOperation.HLIL_SYSCALL_SSA: [("params", "expr_list"), ("dest_memory", "int"), ("src_memory", "int")],
- HighLevelILOperation.HLIL_TAILCALL: [("dest", "expr"), ("params", "expr_list")],
- HighLevelILOperation.HLIL_BP: [],
- HighLevelILOperation.HLIL_TRAP: [("vector", "int")],
- HighLevelILOperation.HLIL_INTRINSIC: [("intrinsic", "intrinsic"), ("params", "expr_list")],
- HighLevelILOperation.HLIL_INTRINSIC_SSA: [("intrinsic", "intrinsic"), ("params", "expr_list"), ("dest_memory", "int"), ("src_memory", "int")],
- HighLevelILOperation.HLIL_UNDEF: [],
- HighLevelILOperation.HLIL_UNIMPL: [],
- HighLevelILOperation.HLIL_UNIMPL_MEM: [("src", "expr")],
- HighLevelILOperation.HLIL_FADD: [("left", "expr"), ("right", "expr")],
- HighLevelILOperation.HLIL_FSUB: [("left", "expr"), ("right", "expr")],
- HighLevelILOperation.HLIL_FMUL: [("left", "expr"), ("right", "expr")],
- HighLevelILOperation.HLIL_FDIV: [("left", "expr"), ("right", "expr")],
- HighLevelILOperation.HLIL_FSQRT: [("src", "expr")],
- HighLevelILOperation.HLIL_FNEG: [("src", "expr")],
- HighLevelILOperation.HLIL_FABS: [("src", "expr")],
- HighLevelILOperation.HLIL_FLOAT_TO_INT: [("src", "expr")],
- HighLevelILOperation.HLIL_INT_TO_FLOAT: [("src", "expr")],
- HighLevelILOperation.HLIL_FLOAT_CONV: [("src", "expr")],
- HighLevelILOperation.HLIL_ROUND_TO_INT: [("src", "expr")],
- HighLevelILOperation.HLIL_FLOOR: [("src", "expr")],
- HighLevelILOperation.HLIL_CEIL: [("src", "expr")],
- HighLevelILOperation.HLIL_FTRUNC: [("src", "expr")],
- HighLevelILOperation.HLIL_FCMP_E: [("left", "expr"), ("right", "expr")],
- HighLevelILOperation.HLIL_FCMP_NE: [("left", "expr"), ("right", "expr")],
- HighLevelILOperation.HLIL_FCMP_LT: [("left", "expr"), ("right", "expr")],
- HighLevelILOperation.HLIL_FCMP_LE: [("left", "expr"), ("right", "expr")],
- HighLevelILOperation.HLIL_FCMP_GE: [("left", "expr"), ("right", "expr")],
- HighLevelILOperation.HLIL_FCMP_GT: [("left", "expr"), ("right", "expr")],
- HighLevelILOperation.HLIL_FCMP_O: [("left", "expr"), ("right", "expr")],
- HighLevelILOperation.HLIL_FCMP_UO: [("left", "expr"), ("right", "expr")]
+ function: 'HighLevelILFunction'
+ expr_index: ExpressionIndex
+ core_instr: CoreHighLevelILInstruction
+ as_ast: bool
+ instr_index: InstructionIndex
+ ILOperations: ClassVar[Mapping[HighLevelILOperation, List[Tuple[str, str]]]] = {
+ HighLevelILOperation.HLIL_NOP: [], HighLevelILOperation.HLIL_BLOCK: [("body", "expr_list")],
+ HighLevelILOperation.HLIL_IF: [("condition", "expr"), ("true", "expr"),
+ ("false", "expr")], HighLevelILOperation.HLIL_WHILE: [("condition", "expr"),
+ ("body", "expr")],
+ HighLevelILOperation.HLIL_WHILE_SSA: [("condition_phi", "expr"), ("condition", "expr"),
+ ("body", "expr")], HighLevelILOperation.HLIL_DO_WHILE: [
+ ("body", "expr"), ("condition", "expr")
+ ], HighLevelILOperation.HLIL_DO_WHILE_SSA: [("body", "expr"),
+ ("condition_phi", "expr"),
+ ("condition", "expr")],
+ HighLevelILOperation.HLIL_FOR: [("init", "expr"), ("condition", "expr"), ("update", "expr"),
+ ("body", "expr")], HighLevelILOperation.HLIL_FOR_SSA: [
+ ("init", "expr"), ("condition_phi", "expr"), ("condition", "expr"),
+ ("update", "expr"), ("body", "expr")
+ ], HighLevelILOperation.HLIL_SWITCH: [
+ ("condition", "expr"), ("default", "expr"), ("cases", "expr_list")
+ ], HighLevelILOperation.HLIL_CASE: [("values", "expr_list"), ("body", "expr")],
+ HighLevelILOperation.HLIL_BREAK: [], HighLevelILOperation.HLIL_CONTINUE: [], HighLevelILOperation.HLIL_JUMP: [
+ ("dest", "expr")
+ ], HighLevelILOperation.HLIL_RET: [("src", "expr_list")], HighLevelILOperation.HLIL_NORET: [],
+ HighLevelILOperation.HLIL_GOTO: [("target", "label")], HighLevelILOperation.HLIL_LABEL: [
+ ("target", "label")
+ ], HighLevelILOperation.HLIL_VAR_DECLARE: [("var", "var")], HighLevelILOperation.HLIL_VAR_INIT: [
+ ("dest", "var"), ("src", "expr")
+ ], HighLevelILOperation.HLIL_VAR_INIT_SSA: [
+ ("dest", "var_ssa"), ("src", "expr")
+ ], HighLevelILOperation.HLIL_ASSIGN: [("dest", "expr"),
+ ("src", "expr")], HighLevelILOperation.HLIL_ASSIGN_UNPACK: [
+ ("dest", "expr_list"), ("src", "expr")
+ ], HighLevelILOperation.HLIL_ASSIGN_MEM_SSA: [("dest", "expr"),
+ ("dest_memory", "int"),
+ ("src", "expr"),
+ ("src_memory", "int")],
+ HighLevelILOperation.HLIL_ASSIGN_UNPACK_MEM_SSA: [
+ ("dest", "expr_list"), ("dest_memory", "int"), ("src", "expr"), ("src_memory", "int")
+ ], HighLevelILOperation.HLIL_VAR: [("var", "var")], HighLevelILOperation.HLIL_VAR_SSA: [
+ ("var", "var_ssa")
+ ], HighLevelILOperation.HLIL_VAR_PHI: [("dest", "var_ssa"),
+ ("src", "var_ssa_list")], HighLevelILOperation.HLIL_MEM_PHI: [
+ ("dest", "int"), ("src", "int_list")
+ ], HighLevelILOperation.HLIL_STRUCT_FIELD: [
+ ("src", "expr"), ("offset", "int"), ("member_index", "member_index")
+ ], HighLevelILOperation.HLIL_ARRAY_INDEX: [
+ ("src", "expr"), ("index", "expr")
+ ], HighLevelILOperation.HLIL_ARRAY_INDEX_SSA: [("src", "expr"),
+ ("src_memory", "int"),
+ ("index", "expr")],
+ HighLevelILOperation.HLIL_SPLIT: [("high", "expr"), ("low", "expr")], HighLevelILOperation.HLIL_DEREF: [
+ ("src", "expr")
+ ], HighLevelILOperation.HLIL_DEREF_FIELD: [
+ ("src", "expr"), ("offset", "int"), ("member_index", "member_index")
+ ], HighLevelILOperation.HLIL_DEREF_SSA: [
+ ("src", "expr"), ("src_memory", "int")
+ ], HighLevelILOperation.HLIL_DEREF_FIELD_SSA: [
+ ("src", "expr"), ("src_memory", "int"), ("offset", "int"),
+ ("member_index", "member_index")
+ ], HighLevelILOperation.HLIL_ADDRESS_OF: [("src", "expr")], HighLevelILOperation.HLIL_CONST: [
+ ("constant", "int")
+ ], HighLevelILOperation.HLIL_CONST_PTR: [("constant", "int")], HighLevelILOperation.HLIL_EXTERN_PTR: [
+ ("constant", "int"), ("offset", "int")
+ ], HighLevelILOperation.HLIL_FLOAT_CONST: [("constant", "float")], HighLevelILOperation.HLIL_IMPORT: [
+ ("constant", "int")
+ ], HighLevelILOperation.HLIL_ADD: [("left", "expr"), ("right", "expr")], HighLevelILOperation.HLIL_ADC: [
+ ("left", "expr"), ("right", "expr"), ("carry", "expr")
+ ], HighLevelILOperation.HLIL_SUB: [("left", "expr"), ("right", "expr")], HighLevelILOperation.HLIL_SBB: [
+ ("left", "expr"), ("right", "expr"), ("carry", "expr")
+ ], HighLevelILOperation.HLIL_AND: [("left", "expr"), ("right", "expr")], HighLevelILOperation.HLIL_OR: [
+ ("left", "expr"), ("right", "expr")
+ ], HighLevelILOperation.HLIL_XOR: [("left", "expr"), ("right", "expr")], HighLevelILOperation.HLIL_LSL: [
+ ("left", "expr"), ("right", "expr")
+ ], HighLevelILOperation.HLIL_LSR: [("left", "expr"), ("right", "expr")], HighLevelILOperation.HLIL_ASR: [
+ ("left", "expr"), ("right", "expr")
+ ], HighLevelILOperation.HLIL_ROL: [("left", "expr"), ("right", "expr")], HighLevelILOperation.HLIL_RLC: [
+ ("left", "expr"), ("right", "expr"), ("carry", "expr")
+ ], HighLevelILOperation.HLIL_ROR: [("left", "expr"), ("right", "expr")], HighLevelILOperation.HLIL_RRC: [
+ ("left", "expr"), ("right", "expr"), ("carry", "expr")
+ ], HighLevelILOperation.HLIL_MUL: [("left", "expr"), ("right", "expr")], HighLevelILOperation.HLIL_MULU_DP: [
+ ("left", "expr"), ("right", "expr")
+ ], HighLevelILOperation.HLIL_MULS_DP: [("left", "expr"), ("right", "expr")], HighLevelILOperation.HLIL_DIVU: [
+ ("left", "expr"), ("right", "expr")
+ ], HighLevelILOperation.HLIL_DIVU_DP: [("left", "expr"), ("right", "expr")], HighLevelILOperation.HLIL_DIVS: [
+ ("left", "expr"), ("right", "expr")
+ ], HighLevelILOperation.HLIL_DIVS_DP: [("left", "expr"), ("right", "expr")], HighLevelILOperation.HLIL_MODU: [
+ ("left", "expr"), ("right", "expr")
+ ], HighLevelILOperation.HLIL_MODU_DP: [("left", "expr"), ("right", "expr")], HighLevelILOperation.HLIL_MODS: [
+ ("left", "expr"), ("right", "expr")
+ ], HighLevelILOperation.HLIL_MODS_DP: [("left", "expr"), ("right", "expr")], HighLevelILOperation.HLIL_NEG: [
+ ("src", "expr")
+ ], HighLevelILOperation.HLIL_NOT: [("src", "expr")], HighLevelILOperation.HLIL_SX: [
+ ("src", "expr")
+ ], HighLevelILOperation.HLIL_ZX: [("src", "expr")], HighLevelILOperation.HLIL_LOW_PART: [
+ ("src", "expr")
+ ], HighLevelILOperation.HLIL_CALL: [
+ ("dest", "expr"), ("params", "expr_list")
+ ], HighLevelILOperation.HLIL_CALL_SSA: [
+ ("dest", "expr"), ("params", "expr_list"), ("dest_memory", "int"), ("src_memory", "int")
+ ], HighLevelILOperation.HLIL_CMP_E: [("left", "expr"), ("right", "expr")], HighLevelILOperation.HLIL_CMP_NE: [
+ ("left", "expr"), ("right", "expr")
+ ], HighLevelILOperation.HLIL_CMP_SLT: [("left", "expr"), ("right", "expr")],
+ HighLevelILOperation.HLIL_CMP_ULT: [("left", "expr"), ("right", "expr")], HighLevelILOperation.HLIL_CMP_SLE: [
+ ("left", "expr"), ("right", "expr")
+ ], HighLevelILOperation.HLIL_CMP_ULE: [("left", "expr"),
+ ("right", "expr")], HighLevelILOperation.HLIL_CMP_SGE: [
+ ("left", "expr"), ("right", "expr")
+ ], HighLevelILOperation.HLIL_CMP_UGE: [("left", "expr"),
+ ("right", "expr")],
+ HighLevelILOperation.HLIL_CMP_SGT: [("left", "expr"), ("right", "expr")], HighLevelILOperation.HLIL_CMP_UGT: [
+ ("left", "expr"), ("right", "expr")
+ ], HighLevelILOperation.HLIL_TEST_BIT: [
+ ("left", "expr"), ("right", "expr")
+ ], HighLevelILOperation.HLIL_BOOL_TO_INT: [("src", "expr")], HighLevelILOperation.HLIL_ADD_OVERFLOW: [
+ ("left", "expr"), ("right", "expr")
+ ], HighLevelILOperation.HLIL_SYSCALL: [("params", "expr_list")], HighLevelILOperation.HLIL_SYSCALL_SSA: [
+ ("params", "expr_list"), ("dest_memory", "int"), ("src_memory", "int")
+ ], HighLevelILOperation.HLIL_TAILCALL: [
+ ("dest", "expr"), ("params", "expr_list")
+ ], HighLevelILOperation.HLIL_BP: [], HighLevelILOperation.HLIL_TRAP: [
+ ("vector", "int")
+ ], HighLevelILOperation.HLIL_INTRINSIC: [("intrinsic", "intrinsic"),
+ ("params", "expr_list")], HighLevelILOperation.HLIL_INTRINSIC_SSA: [
+ ("intrinsic", "intrinsic"), ("params", "expr_list"),
+ ("dest_memory", "int"), ("src_memory", "int")
+ ], HighLevelILOperation.HLIL_UNDEF: [],
+ HighLevelILOperation.HLIL_UNIMPL: [], HighLevelILOperation.HLIL_UNIMPL_MEM: [
+ ("src", "expr")
+ ], HighLevelILOperation.HLIL_FADD: [("left", "expr"), ("right", "expr")], HighLevelILOperation.HLIL_FSUB: [
+ ("left", "expr"), ("right", "expr")
+ ], HighLevelILOperation.HLIL_FMUL: [("left", "expr"), ("right", "expr")], HighLevelILOperation.HLIL_FDIV: [
+ ("left", "expr"), ("right", "expr")
+ ], HighLevelILOperation.HLIL_FSQRT: [("src", "expr")], HighLevelILOperation.HLIL_FNEG: [
+ ("src", "expr")
+ ], HighLevelILOperation.HLIL_FABS: [("src", "expr")], HighLevelILOperation.HLIL_FLOAT_TO_INT: [
+ ("src", "expr")
+ ], HighLevelILOperation.HLIL_INT_TO_FLOAT: [("src", "expr")], HighLevelILOperation.HLIL_FLOAT_CONV: [
+ ("src", "expr")
+ ], HighLevelILOperation.HLIL_ROUND_TO_INT: [("src", "expr")], HighLevelILOperation.HLIL_FLOOR: [
+ ("src", "expr")
+ ], HighLevelILOperation.HLIL_CEIL: [("src", "expr")], HighLevelILOperation.HLIL_FTRUNC: [
+ ("src", "expr")
+ ], HighLevelILOperation.HLIL_FCMP_E: [("left", "expr"), ("right", "expr")], HighLevelILOperation.HLIL_FCMP_NE: [
+ ("left", "expr"), ("right", "expr")
+ ], HighLevelILOperation.HLIL_FCMP_LT: [
+ ("left", "expr"), ("right", "expr")
+ ], HighLevelILOperation.HLIL_FCMP_LE: [
+ ("left", "expr"), ("right", "expr")
+ ], HighLevelILOperation.HLIL_FCMP_GE: [
+ ("left", "expr"), ("right", "expr")
+ ], HighLevelILOperation.HLIL_FCMP_GT: [("left", "expr"), ("right", "expr")], HighLevelILOperation.HLIL_FCMP_O: [
+ ("left", "expr"), ("right", "expr")
+ ], HighLevelILOperation.HLIL_FCMP_UO: [("left", "expr"), ("right", "expr")]
}
@staticmethod
@@ -271,7 +298,10 @@ class HighLevelILInstruction(BaseILInstruction):
show_graph_report("HLIL Class Hierarchy Graph", graph)
@classmethod
- def create(cls, func:'HighLevelILFunction', expr_index:ExpressionIndex, as_ast:bool=True, instr_index:Optional[InstructionIndex]=None) -> 'HighLevelILInstruction':
+ def create(
+ cls, func: 'HighLevelILFunction', expr_index: ExpressionIndex, as_ast: bool = True,
+ instr_index: Optional[InstructionIndex] = None
+ ) -> 'HighLevelILInstruction':
assert func.arch is not None, "Attempted to create IL instruction with function missing an Architecture"
instr = core.BNGetHighLevelILByIndex(func.handle, expr_index, as_ast)
assert instr is not None, "core.BNGetHighLevelILByIndex returned None"
@@ -306,27 +336,27 @@ class HighLevelILInstruction(BaseILInstruction):
continuation = "..."
return f"<{self.operation.name}: {first_line}{continuation}>"
- def __eq__(self, other:'HighLevelILInstruction'):
+ def __eq__(self, other: 'HighLevelILInstruction'):
if not isinstance(other, HighLevelILInstruction):
return NotImplemented
return self.function == other.function and self.expr_index == other.expr_index
- def __lt__(self, other:'HighLevelILInstruction'):
+ def __lt__(self, other: 'HighLevelILInstruction'):
if not isinstance(other, HighLevelILInstruction):
return NotImplemented
return self.function == other.function and self.expr_index < other.expr_index
- def __le__(self, other:'HighLevelILInstruction'):
+ def __le__(self, other: 'HighLevelILInstruction'):
if not isinstance(other, HighLevelILInstruction):
return NotImplemented
return self.function == other.function and self.expr_index <= other.expr_index
- def __gt__(self, other:'HighLevelILInstruction'):
+ def __gt__(self, other: 'HighLevelILInstruction'):
if not isinstance(other, HighLevelILInstruction):
return NotImplemented
return self.function == other.function and self.expr_index > other.expr_index
- def __ge__(self, other:'HighLevelILInstruction'):
+ def __ge__(self, other: 'HighLevelILInstruction'):
if not isinstance(other, HighLevelILInstruction):
return NotImplemented
return self.function == other.function and self.expr_index >= other.expr_index
@@ -356,8 +386,8 @@ class HighLevelILInstruction(BaseILInstruction):
@property
def prefix_operands(self) -> List[Union[HighLevelILOperandType, HighLevelILOperationAndSize]]:
"""All operands in the expression tree in prefix order"""
- result:List[Union[HighLevelILOperandType, HighLevelILOperationAndSize]] = [
- HighLevelILOperationAndSize(self.operation, self.size)]
+ result: List[Union[HighLevelILOperandType,
+ HighLevelILOperationAndSize]] = [HighLevelILOperationAndSize(self.operation, self.size)]
for operand in self.operands:
if isinstance(operand, HighLevelILInstruction):
result.extend(operand.prefix_operands)
@@ -368,7 +398,7 @@ class HighLevelILInstruction(BaseILInstruction):
@property
def postfix_operands(self) -> List[Union[HighLevelILOperandType, HighLevelILOperationAndSize]]:
"""All operands in the expression tree in postfix order"""
- result:List[Union[HighLevelILOperandType, HighLevelILOperationAndSize]] = []
+ result: List[Union[HighLevelILOperandType, HighLevelILOperationAndSize]] = []
for operand in self.operands:
if isinstance(operand, HighLevelILInstruction):
result.extend(operand.postfix_operands)
@@ -488,16 +518,20 @@ class HighLevelILInstruction(BaseILInstruction):
def ssa_form(self) -> 'HighLevelILInstruction':
"""SSA form of expression (read-only)"""
assert self.function.ssa_form is not None
- return HighLevelILInstruction.create(self.function.ssa_form,
- ExpressionIndex(core.BNGetHighLevelILSSAExprIndex(self.function.handle, self.expr_index)), self.as_ast)
+ return HighLevelILInstruction.create(
+ self.function.ssa_form,
+ ExpressionIndex(core.BNGetHighLevelILSSAExprIndex(self.function.handle, self.expr_index)), self.as_ast
+ )
@property
def non_ssa_form(self) -> Optional['HighLevelILInstruction']:
"""Non-SSA form of expression (read-only)"""
if self.function.non_ssa_form is None:
return None
- return HighLevelILInstruction.create(self.function.non_ssa_form,
- ExpressionIndex(core.BNGetHighLevelILNonSSAExprIndex(self.function.handle, self.expr_index)), self.as_ast)
+ return HighLevelILInstruction.create(
+ self.function.non_ssa_form,
+ ExpressionIndex(core.BNGetHighLevelILNonSSAExprIndex(self.function.handle, self.expr_index)), self.as_ast
+ )
@property
def medium_level_il(self) -> Optional['mediumlevelil.MediumLevelILInstruction']:
@@ -588,10 +622,12 @@ class HighLevelILInstruction(BaseILInstruction):
platform = None
if self.function.source_function:
platform = self.function.source_function.platform
- return types.Type.create(core.BNNewTypeReference(result.type), platform = platform, confidence = result.confidence)
+ return types.Type.create(
+ core.BNNewTypeReference(result.type), platform=platform, confidence=result.confidence
+ )
return None
- def get_possible_values(self, options:Optional[List[DataFlowQueryOption]]=None) -> 'variable.PossibleValueSet':
+ def get_possible_values(self, options: Optional[List[DataFlowQueryOption]] = None) -> 'variable.PossibleValueSet':
mlil = self.mlil
if mlil is None:
return variable.PossibleValueSet()
@@ -604,15 +640,15 @@ class HighLevelILInstruction(BaseILInstruction):
"""Version of active memory contents in SSA form for this instruction"""
return core.BNGetHighLevelILSSAMemoryVersionAtILInstruction(self.function.handle, self.instr_index)
- def get_ssa_var_version(self, var:'variable.Variable') -> int:
+ def get_ssa_var_version(self, var: 'variable.Variable') -> int:
var_data = var.to_BNVariable()
return core.BNGetHighLevelILSSAVarVersionAtILInstruction(self.function.handle, var_data, self.instr_index)
- def get_int(self, operand_index:int) -> int:
+ def get_int(self, operand_index: int) -> int:
value = self.core_instr.operands[operand_index]
return (value & ((1 << 63) - 1)) - (value & (1 << 63))
- def get_float(self, operand_index:int) -> float:
+ def get_float(self, operand_index: int) -> float:
value = self.core_instr.operands[operand_index]
if self.core_instr.size == 4:
return struct.unpack("f", struct.pack("I", value & 0xffffffff))[0]
@@ -621,35 +657,35 @@ class HighLevelILInstruction(BaseILInstruction):
else:
return float(value)
- def get_expr(self, operand_index:int) -> 'HighLevelILInstruction':
- return HighLevelILInstruction.create(self.function,
- ExpressionIndex(self.core_instr.operands[operand_index]))
+ def get_expr(self, operand_index: int) -> 'HighLevelILInstruction':
+ return HighLevelILInstruction.create(self.function, ExpressionIndex(self.core_instr.operands[operand_index]))
- def get_intrinsic(self, operand_index:int) -> 'lowlevelil.ILIntrinsic':
+ def get_intrinsic(self, operand_index: int) -> 'lowlevelil.ILIntrinsic':
if self.function.arch is None:
raise ValueError("Attempting to create ILIntrinsic from function with no Architecture")
- return lowlevelil.ILIntrinsic(self.function.arch,
- architecture.IntrinsicIndex(self.core_instr.operands[operand_index]))
+ return lowlevelil.ILIntrinsic(
+ self.function.arch, architecture.IntrinsicIndex(self.core_instr.operands[operand_index])
+ )
- def get_var(self, operand_index:int) -> 'variable.Variable':
+ def get_var(self, operand_index: int) -> 'variable.Variable':
value = self.core_instr.operands[operand_index]
return variable.Variable.from_identifier(self.function, value)
- def get_var_ssa(self, operand_index1:int, operand_index2:int) -> 'mediumlevelil.SSAVariable':
+ def get_var_ssa(self, operand_index1: int, operand_index2: int) -> 'mediumlevelil.SSAVariable':
var = variable.Variable.from_identifier(self.function, self.core_instr.operands[operand_index1])
version = self.core_instr.operands[operand_index2]
return mediumlevelil.SSAVariable(var, version)
- def get_var_ssa_dest_and_src(self, operand_index1:int, operand_index2:int) -> 'mediumlevelil.SSAVariable':
+ def get_var_ssa_dest_and_src(self, operand_index1: int, operand_index2: int) -> 'mediumlevelil.SSAVariable':
var = variable.Variable.from_identifier(self.function, self.core_instr.operands[operand_index1])
dest_version = self.core_instr.operands[operand_index2]
return mediumlevelil.SSAVariable(var, dest_version)
- def get_int_list(self, operand_index:int) -> List[int]:
+ def get_int_list(self, operand_index: int) -> List[int]:
count = ctypes.c_ulonglong()
operand_list = core.BNHighLevelILGetOperandList(self.function.handle, self.expr_index, operand_index, count)
assert operand_list is not None, "core.BNHighLevelILGetOperandList returned None"
- value:List[int] = []
+ value: List[int] = []
try:
for j in range(count.value):
value.append(operand_list[j])
@@ -657,11 +693,11 @@ class HighLevelILInstruction(BaseILInstruction):
finally:
core.BNHighLevelILFreeOperandList(operand_list)
- def get_expr_list(self, operand_index1:int, operand_index2:int) -> List['HighLevelILInstruction']:
+ def get_expr_list(self, operand_index1: int, operand_index2: int) -> List['HighLevelILInstruction']:
count = ctypes.c_ulonglong()
operand_list = core.BNHighLevelILGetOperandList(self.function.handle, self.expr_index, operand_index1, count)
assert operand_list is not None, "core.BNHighLevelILGetOperandList returned None"
- value:List[HighLevelILInstruction] = []
+ value: List[HighLevelILInstruction] = []
try:
for j in range(count.value):
value.append(HighLevelILInstruction.create(self.function, operand_list[j], self.as_ast))
@@ -669,8 +705,7 @@ class HighLevelILInstruction(BaseILInstruction):
finally:
core.BNHighLevelILFreeOperandList(operand_list)
-
- def get_var_ssa_list(self, operand_index1:int, _:int) -> List['mediumlevelil.SSAVariable']:
+ def get_var_ssa_list(self, operand_index1: int, _: int) -> List['mediumlevelil.SSAVariable']:
count = ctypes.c_ulonglong()
operand_list = core.BNHighLevelILGetOperandList(self.function.handle, self.expr_index, operand_index1, count)
assert operand_list is not None, "core.BNHighLevelILGetOperandList returned None"
@@ -678,20 +713,21 @@ class HighLevelILInstruction(BaseILInstruction):
try:
for j in range(count.value // 2):
var_id = operand_list[j * 2]
- var_version = operand_list[(j * 2) + 1]
- value.append(mediumlevelil.SSAVariable(variable.Variable.from_identifier(self.function,
- var_id), var_version))
+ var_version = operand_list[(j*2) + 1]
+ value.append(
+ mediumlevelil.SSAVariable(variable.Variable.from_identifier(self.function, var_id), var_version)
+ )
return value
finally:
core.BNMediumLevelILFreeOperandList(operand_list)
- def get_member_index(self, operand_index:int) -> Optional[int]:
+ def get_member_index(self, operand_index: int) -> Optional[int]:
value = self.core_instr.operands[operand_index]
if (value & (1 << 63)) != 0:
value = None
return value
- def get_label(self, operand_index:int) -> GotoLabel:
+ def get_label(self, operand_index: int) -> GotoLabel:
return GotoLabel(self.function, self.core_instr.operands[operand_index])
@property
@@ -701,7 +737,6 @@ class HighLevelILInstruction(BaseILInstruction):
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILUnaryBase(HighLevelILInstruction, UnaryOperation):
-
@property
def src(self) -> HighLevelILInstruction:
return self.get_expr(0)
@@ -713,7 +748,6 @@ class HighLevelILUnaryBase(HighLevelILInstruction, UnaryOperation):
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILBinaryBase(HighLevelILInstruction, BinaryOperation):
-
@property
def left(self) -> HighLevelILInstruction:
return self.get_expr(0)
@@ -734,7 +768,6 @@ class HighLevelILComparisonBase(HighLevelILBinaryBase, Comparison):
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILCarryBase(HighLevelILInstruction, Arithmetic):
-
@property
def left(self) -> HighLevelILInstruction:
return self.get_expr(0)
@@ -759,7 +792,6 @@ class HighLevelILNop(HighLevelILInstruction):
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILBlock(HighLevelILInstruction):
-
@property
def body(self) -> List[HighLevelILInstruction]:
return self.get_expr_list(0, 1)
@@ -771,7 +803,6 @@ class HighLevelILBlock(HighLevelILInstruction):
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILIf(HighLevelILInstruction, ControlFlow):
-
@property
def condition(self) -> HighLevelILInstruction:
return self.get_expr(0)
@@ -791,7 +822,6 @@ class HighLevelILIf(HighLevelILInstruction, ControlFlow):
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILWhile(HighLevelILInstruction, Loop):
-
@property
def condition(self) -> HighLevelILInstruction:
return self.get_expr(0)
@@ -807,7 +837,6 @@ class HighLevelILWhile(HighLevelILInstruction, Loop):
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILWhileSsa(HighLevelILInstruction, Loop, SSA):
-
@property
def condition_phi(self) -> HighLevelILInstruction:
return self.get_expr(0)
@@ -827,7 +856,6 @@ class HighLevelILWhileSsa(HighLevelILInstruction, Loop, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILDoWhile(HighLevelILInstruction, Loop):
-
@property
def body(self) -> HighLevelILInstruction:
return self.get_expr(0)
@@ -843,7 +871,6 @@ class HighLevelILDoWhile(HighLevelILInstruction, Loop):
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILDoWhileSsa(HighLevelILInstruction, Loop, SSA):
-
@property
def body(self) -> HighLevelILInstruction:
return self.get_expr(0)
@@ -863,7 +890,6 @@ class HighLevelILDoWhileSsa(HighLevelILInstruction, Loop, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILFor(HighLevelILInstruction, Loop):
-
@property
def init(self) -> HighLevelILInstruction:
return self.get_expr(0)
@@ -887,7 +913,6 @@ class HighLevelILFor(HighLevelILInstruction, Loop):
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILForSsa(HighLevelILInstruction, Loop, SSA):
-
@property
def init(self) -> HighLevelILInstruction:
return self.get_expr(0)
@@ -915,7 +940,6 @@ class HighLevelILForSsa(HighLevelILInstruction, Loop, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILSwitch(HighLevelILInstruction, ControlFlow):
-
@property
def condition(self) -> HighLevelILInstruction:
return self.get_expr(0)
@@ -935,7 +959,6 @@ class HighLevelILSwitch(HighLevelILInstruction, ControlFlow):
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILCase(HighLevelILInstruction):
-
@property
def values(self) -> List[HighLevelILInstruction]:
return self.get_expr_list(0, 1)
@@ -953,6 +976,7 @@ class HighLevelILCase(HighLevelILInstruction):
class HighLevelILBreak(HighLevelILInstruction, Terminal):
pass
+
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILContinue(HighLevelILInstruction, ControlFlow):
pass
@@ -960,7 +984,6 @@ class HighLevelILContinue(HighLevelILInstruction, ControlFlow):
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILJump(HighLevelILInstruction, Terminal):
-
@property
def dest(self) -> HighLevelILInstruction:
return self.get_expr(0)
@@ -972,7 +995,6 @@ class HighLevelILJump(HighLevelILInstruction, Terminal):
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILRet(HighLevelILInstruction, ControlFlow):
-
@property
def src(self) -> List[HighLevelILInstruction]:
return self.get_expr_list(0, 1)
@@ -989,7 +1011,6 @@ class HighLevelILNoret(HighLevelILInstruction, Terminal):
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILGoto(HighLevelILInstruction, Terminal):
-
@property
def target(self) -> GotoLabel:
return self.get_label(0)
@@ -1001,7 +1022,6 @@ class HighLevelILGoto(HighLevelILInstruction, Terminal):
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILLabel(HighLevelILInstruction):
-
@property
def target(self) -> GotoLabel:
return self.get_label(0)
@@ -1013,7 +1033,6 @@ class HighLevelILLabel(HighLevelILInstruction):
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILVarDeclare(HighLevelILInstruction):
-
@property
def var(self) -> 'variable.Variable':
return self.get_var(0)
@@ -1025,7 +1044,6 @@ class HighLevelILVarDeclare(HighLevelILInstruction):
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILVarInit(HighLevelILInstruction):
-
@property
def dest(self) -> 'variable.Variable':
return self.get_var(0)
@@ -1045,7 +1063,6 @@ class HighLevelILVarInit(HighLevelILInstruction):
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILVarInitSsa(HighLevelILInstruction, SSA):
-
@property
def dest(self) -> 'mediumlevelil.SSAVariable':
return self.get_var_ssa(0, 1)
@@ -1065,7 +1082,6 @@ class HighLevelILVarInitSsa(HighLevelILInstruction, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILAssign(HighLevelILInstruction):
-
@property
def dest(self) -> HighLevelILInstruction:
return self.get_expr(0)
@@ -1090,7 +1106,6 @@ class HighLevelILAssign(HighLevelILInstruction):
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILAssignUnpack(HighLevelILInstruction):
-
@property
def dest(self) -> List[HighLevelILInstruction]:
return self.get_expr_list(0, 1)
@@ -1116,7 +1131,6 @@ class HighLevelILAssignUnpack(HighLevelILInstruction):
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILAssignMemSsa(HighLevelILInstruction, SSA):
-
@property
def dest(self) -> HighLevelILInstruction:
return self.get_expr(0)
@@ -1140,7 +1154,6 @@ class HighLevelILAssignMemSsa(HighLevelILInstruction, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILAssignUnpackMemSsa(HighLevelILInstruction, SSA, Memory):
-
@property
def dest(self) -> List[HighLevelILInstruction]:
return self.get_expr_list(0, 1)
@@ -1164,7 +1177,6 @@ class HighLevelILAssignUnpackMemSsa(HighLevelILInstruction, SSA, Memory):
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILVar(HighLevelILInstruction):
-
@property
def var(self) -> 'variable.Variable':
return self.get_var(0)
@@ -1176,7 +1188,6 @@ class HighLevelILVar(HighLevelILInstruction):
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILVarSsa(HighLevelILInstruction, SSA):
-
@property
def var(self) -> 'mediumlevelil.SSAVariable':
return self.get_var_ssa(0, 1)
@@ -1188,7 +1199,6 @@ class HighLevelILVarSsa(HighLevelILInstruction, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILVarPhi(HighLevelILInstruction, Phi):
-
@property
def dest(self) -> 'mediumlevelil.SSAVariable':
return self.get_var_ssa(0, 1)
@@ -1208,7 +1218,6 @@ class HighLevelILVarPhi(HighLevelILInstruction, Phi):
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILMemPhi(HighLevelILInstruction, Memory, Phi):
-
@property
def dest(self) -> int:
return self.get_int(0)
@@ -1224,7 +1233,6 @@ class HighLevelILMemPhi(HighLevelILInstruction, Memory, Phi):
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILStructField(HighLevelILInstruction):
-
@property
def src(self) -> HighLevelILInstruction:
return self.get_expr(0)
@@ -1241,9 +1249,9 @@ class HighLevelILStructField(HighLevelILInstruction):
def operands(self) -> List[HighLevelILOperandType]:
return [self.src, self.offset, self.member_index]
+
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILArrayIndex(HighLevelILInstruction):
-
@property
def src(self) -> HighLevelILInstruction:
return self.get_expr(0)
@@ -1259,7 +1267,6 @@ class HighLevelILArrayIndex(HighLevelILInstruction):
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILArrayIndexSsa(HighLevelILInstruction, SSA):
-
@property
def src(self) -> HighLevelILInstruction:
return self.get_expr(0)
@@ -1279,7 +1286,6 @@ class HighLevelILArrayIndexSsa(HighLevelILInstruction, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILSplit(HighLevelILInstruction):
-
@property
def high(self) -> HighLevelILInstruction:
return self.get_expr(0)
@@ -1300,7 +1306,6 @@ class HighLevelILDeref(HighLevelILUnaryBase):
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILDerefField(HighLevelILInstruction):
-
@property
def src(self) -> HighLevelILInstruction:
return self.get_expr(0)
@@ -1320,7 +1325,6 @@ class HighLevelILDerefField(HighLevelILInstruction):
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILDerefSsa(HighLevelILInstruction, SSA):
-
@property
def src(self) -> HighLevelILInstruction:
return self.get_expr(0)
@@ -1336,7 +1340,6 @@ class HighLevelILDerefSsa(HighLevelILInstruction, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILDerefFieldSsa(HighLevelILInstruction, SSA):
-
@property
def src(self) -> HighLevelILInstruction:
return self.get_expr(0)
@@ -1360,7 +1363,6 @@ class HighLevelILDerefFieldSsa(HighLevelILInstruction, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILAddressOf(HighLevelILUnaryBase):
-
@property
def vars_address_taken(self) -> VariablesList:
if isinstance(self.src, HighLevelILVar):
@@ -1372,7 +1374,6 @@ class HighLevelILAddressOf(HighLevelILUnaryBase):
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILConst(HighLevelILInstruction, Constant):
-
@property
def constant(self) -> int:
return self.get_int(0)
@@ -1384,7 +1385,6 @@ class HighLevelILConst(HighLevelILInstruction, Constant):
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILConstPtr(HighLevelILInstruction, Constant):
-
@property
def constant(self) -> int:
return self.get_int(0)
@@ -1396,7 +1396,6 @@ class HighLevelILConstPtr(HighLevelILInstruction, Constant):
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILExternPtr(HighLevelILInstruction, Constant):
-
@property
def constant(self) -> int:
return self.get_int(0)
@@ -1412,7 +1411,6 @@ class HighLevelILExternPtr(HighLevelILInstruction, Constant):
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILFloatConst(HighLevelILInstruction, Constant):
-
@property
def constant(self) -> float:
return self.get_float(0)
@@ -1424,7 +1422,6 @@ class HighLevelILFloatConst(HighLevelILInstruction, Constant):
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILImport(HighLevelILInstruction, Constant):
-
@property
def constant(self) -> int:
return self.get_int(0)
@@ -1586,7 +1583,6 @@ class HighLevelILLowPart(HighLevelILUnaryBase, Arithmetic):
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILCall(HighLevelILInstruction, Localcall):
-
@property
def dest(self) -> HighLevelILInstruction:
return self.get_expr(0)
@@ -1602,7 +1598,6 @@ class HighLevelILCall(HighLevelILInstruction, Localcall):
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILCallSsa(HighLevelILInstruction, Localcall, SSA):
-
@property
def dest(self) -> HighLevelILInstruction:
return self.get_expr(0)
@@ -1691,7 +1686,6 @@ class HighLevelILAddOverflow(HighLevelILBinaryBase, Arithmetic):
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILSyscall(HighLevelILInstruction, Syscall):
-
@property
def params(self) -> List[HighLevelILInstruction]:
return self.get_expr_list(0, 1)
@@ -1703,7 +1697,6 @@ class HighLevelILSyscall(HighLevelILInstruction, Syscall):
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILSyscallSsa(HighLevelILInstruction, Syscall, SSA):
-
@property
def params(self) -> List[HighLevelILInstruction]:
return self.get_expr_list(0, 1)
@@ -1723,7 +1716,6 @@ class HighLevelILSyscallSsa(HighLevelILInstruction, Syscall, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILTailcall(HighLevelILInstruction, Tailcall):
-
@property
def dest(self) -> HighLevelILInstruction:
return self.get_expr(0)
@@ -1744,7 +1736,6 @@ class HighLevelILBp(HighLevelILInstruction, Terminal):
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILTrap(HighLevelILInstruction, Terminal):
-
@property
def vector(self) -> int:
return self.get_int(0)
@@ -1756,7 +1747,6 @@ class HighLevelILTrap(HighLevelILInstruction, Terminal):
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILIntrinsic(HighLevelILInstruction):
-
@property
def intrinsic(self) -> 'lowlevelil.ILIntrinsic':
return self.get_intrinsic(0)
@@ -1772,7 +1762,6 @@ class HighLevelILIntrinsic(HighLevelILInstruction):
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILIntrinsicSsa(HighLevelILInstruction, SSA):
-
@property
def intrinsic(self) -> 'lowlevelil.ILIntrinsic':
return self.get_intrinsic(0)
@@ -1920,135 +1909,150 @@ class HighLevelILFcmpUo(HighLevelILComparisonBase, FloatingPoint):
ILInstruction = {
- HighLevelILOperation.HLIL_NOP:HighLevelILNop, # ,
- HighLevelILOperation.HLIL_BLOCK:HighLevelILBlock, # ("body", "expr_list"),
- HighLevelILOperation.HLIL_IF:HighLevelILIf, # ("condition", "expr"), ("true", "expr"), ("false", "expr"),
- HighLevelILOperation.HLIL_WHILE:HighLevelILWhile, # ("condition", "expr"), ("body", "expr"),
- HighLevelILOperation.HLIL_WHILE_SSA:HighLevelILWhileSsa, # ("condition_phi", "expr"), ("condition", "expr"), ("body", "expr"),
- HighLevelILOperation.HLIL_DO_WHILE:HighLevelILDoWhile, # ("body", "expr"), ("condition", "expr"),
- HighLevelILOperation.HLIL_DO_WHILE_SSA:HighLevelILDoWhileSsa, # ("body", "expr"), ("condition_phi", "expr"), ("condition", "expr"),
- HighLevelILOperation.HLIL_FOR:HighLevelILFor, # ("init", "expr"), ("condition", "expr"), ("update", "expr"), ("body", "expr"),
- HighLevelILOperation.HLIL_FOR_SSA:HighLevelILForSsa, # ("init", "expr"), ("condition_phi", "expr"), ("condition", "expr"), ("update", "expr"), ("body", "expr"),
- HighLevelILOperation.HLIL_SWITCH:HighLevelILSwitch, # ("condition", "expr"), ("default", "expr"), ("cases", "expr_list"),
- HighLevelILOperation.HLIL_CASE:HighLevelILCase, # ("values", "expr_list"), ("body", "expr"),
- HighLevelILOperation.HLIL_BREAK:HighLevelILBreak, # ,
- HighLevelILOperation.HLIL_CONTINUE:HighLevelILContinue, # ,
- HighLevelILOperation.HLIL_JUMP:HighLevelILJump, # ("dest", "expr"),
- HighLevelILOperation.HLIL_RET:HighLevelILRet, # ("src", "expr_list"),
- HighLevelILOperation.HLIL_NORET:HighLevelILNoret, # ,
- HighLevelILOperation.HLIL_GOTO:HighLevelILGoto, # ("target", "label"),
- HighLevelILOperation.HLIL_LABEL:HighLevelILLabel, # ("target", "label"),
- HighLevelILOperation.HLIL_VAR_DECLARE:HighLevelILVarDeclare, # ("var", "var"),
- HighLevelILOperation.HLIL_VAR_INIT:HighLevelILVarInit, # ("dest", "var"), ("src", "expr"),
- HighLevelILOperation.HLIL_VAR_INIT_SSA:HighLevelILVarInitSsa, # ("dest", "var_ssa"), ("src", "expr"),
- HighLevelILOperation.HLIL_ASSIGN:HighLevelILAssign, # ("dest", "expr"), ("src", "expr"),
- HighLevelILOperation.HLIL_ASSIGN_UNPACK:HighLevelILAssignUnpack, # ("dest", "expr_list"), ("src", "expr"),
- HighLevelILOperation.HLIL_ASSIGN_MEM_SSA:HighLevelILAssignMemSsa, # ("dest", "expr"), ("dest_memory", "int"), ("src", "expr"), ("src_memory", "int"),
- HighLevelILOperation.HLIL_ASSIGN_UNPACK_MEM_SSA:HighLevelILAssignUnpackMemSsa, # ("dest", "expr_list"), ("dest_memory", "int"), ("src", "expr"), ("src_memory", "int"),
- HighLevelILOperation.HLIL_VAR:HighLevelILVar, # ("var", "var"),
- HighLevelILOperation.HLIL_VAR_SSA:HighLevelILVarSsa, # ("var", "var_ssa"),
- HighLevelILOperation.HLIL_VAR_PHI:HighLevelILVarPhi, # ("dest", "var_ssa"), ("src", "var_ssa_list"),
- HighLevelILOperation.HLIL_MEM_PHI:HighLevelILMemPhi, # ("dest", "int"), ("src", "int_list"),
- HighLevelILOperation.HLIL_ARRAY_INDEX:HighLevelILArrayIndex, # ("src", "expr"), ("index", "expr"),
- HighLevelILOperation.HLIL_ARRAY_INDEX_SSA:HighLevelILArrayIndexSsa, # ("src", "expr"), ("src_memory", "int"), ("index", "expr"),
- HighLevelILOperation.HLIL_SPLIT:HighLevelILSplit, # ("high", "expr"), ("low", "expr"),
- HighLevelILOperation.HLIL_DEREF:HighLevelILDeref, # ("src", "expr"),
- HighLevelILOperation.HLIL_STRUCT_FIELD:HighLevelILStructField, # ("src", "expr"), ("offset", "int"), ("member_index", "member_index"),
- HighLevelILOperation.HLIL_DEREF_FIELD:HighLevelILDerefField, # ("src", "expr"), ("offset", "int"), ("member_index", "member_index"),
- HighLevelILOperation.HLIL_DEREF_SSA:HighLevelILDerefSsa, # ("src", "expr"), ("src_memory", "int"),
- HighLevelILOperation.HLIL_DEREF_FIELD_SSA:HighLevelILDerefFieldSsa, # ("src", "expr"), ("src_memory", "int"), ("offset", "int"), ("member_index", "member_index"),
- HighLevelILOperation.HLIL_ADDRESS_OF:HighLevelILAddressOf, # ("src", "expr"),
- HighLevelILOperation.HLIL_CONST:HighLevelILConst, # ("constant", "int"),
- HighLevelILOperation.HLIL_CONST_PTR:HighLevelILConstPtr, # ("constant", "int"),
- HighLevelILOperation.HLIL_EXTERN_PTR:HighLevelILExternPtr, # ("constant", "int"), ("offset", "int"),
- HighLevelILOperation.HLIL_FLOAT_CONST:HighLevelILFloatConst, # ("constant", "float"),
- HighLevelILOperation.HLIL_IMPORT:HighLevelILImport, # ("constant", "int"),
- HighLevelILOperation.HLIL_ADD:HighLevelILAdd, # ("left", "expr"), ("right", "expr"),
- HighLevelILOperation.HLIL_ADC:HighLevelILAdc, # ("left", "expr"), ("right", "expr"), ("carry", "expr"),
- HighLevelILOperation.HLIL_SUB:HighLevelILSub, # ("left", "expr"), ("right", "expr"),
- HighLevelILOperation.HLIL_SBB:HighLevelILSbb, # ("left", "expr"), ("right", "expr"), ("carry", "expr"),
- HighLevelILOperation.HLIL_AND:HighLevelILAnd, # ("left", "expr"), ("right", "expr"),
- HighLevelILOperation.HLIL_OR:HighLevelILOr, # ("left", "expr"), ("right", "expr"),
- HighLevelILOperation.HLIL_XOR:HighLevelILXor, # ("left", "expr"), ("right", "expr"),
- HighLevelILOperation.HLIL_LSL:HighLevelILLsl, # ("left", "expr"), ("right", "expr"),
- HighLevelILOperation.HLIL_LSR:HighLevelILLsr, # ("left", "expr"), ("right", "expr"),
- HighLevelILOperation.HLIL_ASR:HighLevelILAsr, # ("left", "expr"), ("right", "expr"),
- HighLevelILOperation.HLIL_ROL:HighLevelILRol, # ("left", "expr"), ("right", "expr"),
- HighLevelILOperation.HLIL_RLC:HighLevelILRlc, # ("left", "expr"), ("right", "expr"), ("carry", "expr"),
- HighLevelILOperation.HLIL_ROR:HighLevelILRor, # ("left", "expr"), ("right", "expr"),
- HighLevelILOperation.HLIL_RRC:HighLevelILRrc, # ("left", "expr"), ("right", "expr"), ("carry", "expr"),
- HighLevelILOperation.HLIL_MUL:HighLevelILMul, # ("left", "expr"), ("right", "expr"),
- HighLevelILOperation.HLIL_MULU_DP:HighLevelILMuluDp, # ("left", "expr"), ("right", "expr"),
- HighLevelILOperation.HLIL_MULS_DP:HighLevelILMulsDp, # ("left", "expr"), ("right", "expr"),
- HighLevelILOperation.HLIL_DIVU:HighLevelILDivu, # ("left", "expr"), ("right", "expr"),
- HighLevelILOperation.HLIL_DIVU_DP:HighLevelILDivuDp, # ("left", "expr"), ("right", "expr"),
- HighLevelILOperation.HLIL_DIVS:HighLevelILDivs, # ("left", "expr"), ("right", "expr"),
- HighLevelILOperation.HLIL_DIVS_DP:HighLevelILDivsDp, # ("left", "expr"), ("right", "expr"),
- HighLevelILOperation.HLIL_MODU:HighLevelILModu, # ("left", "expr"), ("right", "expr"),
- HighLevelILOperation.HLIL_MODU_DP:HighLevelILModuDp, # ("left", "expr"), ("right", "expr"),
- HighLevelILOperation.HLIL_MODS:HighLevelILMods, # ("left", "expr"), ("right", "expr"),
- HighLevelILOperation.HLIL_MODS_DP:HighLevelILModsDp, # ("left", "expr"), ("right", "expr"),
- HighLevelILOperation.HLIL_NEG:HighLevelILNeg, # ("src", "expr"),
- HighLevelILOperation.HLIL_NOT:HighLevelILNot, # ("src", "expr"),
- HighLevelILOperation.HLIL_SX:HighLevelILSx, # ("src", "expr"),
- HighLevelILOperation.HLIL_ZX:HighLevelILZx, # ("src", "expr"),
- HighLevelILOperation.HLIL_LOW_PART:HighLevelILLowPart, # ("src", "expr"),
- HighLevelILOperation.HLIL_CALL:HighLevelILCall, # ("dest", "expr"), ("params", "expr_list"),
- HighLevelILOperation.HLIL_CALL_SSA:HighLevelILCallSsa, # ("dest", "expr"), ("params", "expr_list"), ("dest_memory", "int"), ("src_memory", "int"),
- HighLevelILOperation.HLIL_CMP_E:HighLevelILCmpE, # ("left", "expr"), ("right", "expr"),
- HighLevelILOperation.HLIL_CMP_NE:HighLevelILCmpNe, # ("left", "expr"), ("right", "expr"),
- HighLevelILOperation.HLIL_CMP_SLT:HighLevelILCmpSlt, # ("left", "expr"), ("right", "expr"),
- HighLevelILOperation.HLIL_CMP_ULT:HighLevelILCmpUlt, # ("left", "expr"), ("right", "expr"),
- HighLevelILOperation.HLIL_CMP_SLE:HighLevelILCmpSle, # ("left", "expr"), ("right", "expr"),
- HighLevelILOperation.HLIL_CMP_ULE:HighLevelILCmpUle, # ("left", "expr"), ("right", "expr"),
- HighLevelILOperation.HLIL_CMP_SGE:HighLevelILCmpSge, # ("left", "expr"), ("right", "expr"),
- HighLevelILOperation.HLIL_CMP_UGE:HighLevelILCmpUge, # ("left", "expr"), ("right", "expr"),
- HighLevelILOperation.HLIL_CMP_SGT:HighLevelILCmpSgt, # ("left", "expr"), ("right", "expr"),
- HighLevelILOperation.HLIL_CMP_UGT:HighLevelILCmpUgt, # ("left", "expr"), ("right", "expr"),
- HighLevelILOperation.HLIL_TEST_BIT:HighLevelILTestBit, # ("left", "expr"), ("right", "expr"),
- HighLevelILOperation.HLIL_BOOL_TO_INT:HighLevelILBoolToInt, # ("src", "expr"),
- HighLevelILOperation.HLIL_ADD_OVERFLOW:HighLevelILAddOverflow, # ("left", "expr"), ("right", "expr"),
- HighLevelILOperation.HLIL_SYSCALL:HighLevelILSyscall, # ("params", "expr_list"),
- HighLevelILOperation.HLIL_SYSCALL_SSA:HighLevelILSyscallSsa, # ("params", "expr_list"), ("dest_memory", "int"), ("src_memory", "int"),
- HighLevelILOperation.HLIL_TAILCALL:HighLevelILTailcall, # ("dest", "expr"), ("params", "expr_list"),
- HighLevelILOperation.HLIL_BP:HighLevelILBp, # ,
- HighLevelILOperation.HLIL_TRAP:HighLevelILTrap, # ("vector", "int"),
- HighLevelILOperation.HLIL_INTRINSIC:HighLevelILIntrinsic, # ("intrinsic", "intrinsic"), ("params", "expr_list"),
- HighLevelILOperation.HLIL_INTRINSIC_SSA:HighLevelILIntrinsicSsa, # ("intrinsic", "intrinsic"), ("params", "expr_list"), ("dest_memory", "int"), ("src_memory", "int"),
- HighLevelILOperation.HLIL_UNDEF:HighLevelILUndef, # ,
- HighLevelILOperation.HLIL_UNIMPL:HighLevelILUnimpl, # ,
- HighLevelILOperation.HLIL_UNIMPL_MEM:HighLevelILUnimplMem, # ("src", "expr"),
- HighLevelILOperation.HLIL_FADD:HighLevelILFadd, # ("left", "expr"), ("right", "expr"),
- HighLevelILOperation.HLIL_FSUB:HighLevelILFsub, # ("left", "expr"), ("right", "expr"),
- HighLevelILOperation.HLIL_FMUL:HighLevelILFmul, # ("left", "expr"), ("right", "expr"),
- HighLevelILOperation.HLIL_FDIV:HighLevelILFdiv, # ("left", "expr"), ("right", "expr"),
- HighLevelILOperation.HLIL_FSQRT:HighLevelILFsqrt, # ("src", "expr"),
- HighLevelILOperation.HLIL_FNEG:HighLevelILFneg, # ("src", "expr"),
- HighLevelILOperation.HLIL_FABS:HighLevelILFabs, # ("src", "expr"),
- HighLevelILOperation.HLIL_FLOAT_TO_INT:HighLevelILFloatToInt, # ("src", "expr"),
- HighLevelILOperation.HLIL_INT_TO_FLOAT:HighLevelILIntToFloat, # ("src", "expr"),
- HighLevelILOperation.HLIL_FLOAT_CONV:HighLevelILFloatConv, # ("src", "expr"),
- HighLevelILOperation.HLIL_ROUND_TO_INT:HighLevelILRoundToInt, # ("src", "expr"),
- HighLevelILOperation.HLIL_FLOOR:HighLevelILFloor, # ("src", "expr"),
- HighLevelILOperation.HLIL_CEIL:HighLevelILCeil, # ("src", "expr"),
- HighLevelILOperation.HLIL_FTRUNC:HighLevelILFtrunc, # ("src", "expr"),
- HighLevelILOperation.HLIL_FCMP_E:HighLevelILFcmpE, # ("left", "expr"), ("right", "expr"),
- HighLevelILOperation.HLIL_FCMP_NE:HighLevelILFcmpNe, # ("left", "expr"), ("right", "expr"),
- HighLevelILOperation.HLIL_FCMP_LT:HighLevelILFcmpLt, # ("left", "expr"), ("right", "expr"),
- HighLevelILOperation.HLIL_FCMP_LE:HighLevelILFcmpLe, # ("left", "expr"), ("right", "expr"),
- HighLevelILOperation.HLIL_FCMP_GE:HighLevelILFcmpGe, # ("left", "expr"), ("right", "expr"),
- HighLevelILOperation.HLIL_FCMP_GT:HighLevelILFcmpGt, # ("left", "expr"), ("right", "expr"),
- HighLevelILOperation.HLIL_FCMP_O:HighLevelILFcmpO, # ("left", "expr"), ("right", "expr"),
- HighLevelILOperation.HLIL_FCMP_UO:HighLevelILFcmpUo, # ("left", "expr"), ("right", "expr"),
+ HighLevelILOperation.HLIL_NOP: HighLevelILNop, # ,
+ HighLevelILOperation.HLIL_BLOCK: HighLevelILBlock, # ("body", "expr_list"),
+ HighLevelILOperation.HLIL_IF: HighLevelILIf, # ("condition", "expr"), ("true", "expr"), ("false", "expr"),
+ HighLevelILOperation.HLIL_WHILE: HighLevelILWhile, # ("condition", "expr"), ("body", "expr"),
+ HighLevelILOperation.HLIL_WHILE_SSA:
+ HighLevelILWhileSsa, # ("condition_phi", "expr"), ("condition", "expr"), ("body", "expr"),
+ HighLevelILOperation.HLIL_DO_WHILE: HighLevelILDoWhile, # ("body", "expr"), ("condition", "expr"),
+ HighLevelILOperation.HLIL_DO_WHILE_SSA:
+ HighLevelILDoWhileSsa, # ("body", "expr"), ("condition_phi", "expr"), ("condition", "expr"),
+ HighLevelILOperation.HLIL_FOR:
+ HighLevelILFor, # ("init", "expr"), ("condition", "expr"), ("update", "expr"), ("body", "expr"),
+ HighLevelILOperation.HLIL_FOR_SSA:
+ HighLevelILForSsa, # ("init", "expr"), ("condition_phi", "expr"), ("condition", "expr"), ("update", "expr"), ("body", "expr"),
+ HighLevelILOperation.HLIL_SWITCH:
+ HighLevelILSwitch, # ("condition", "expr"), ("default", "expr"), ("cases", "expr_list"),
+ HighLevelILOperation.HLIL_CASE: HighLevelILCase, # ("values", "expr_list"), ("body", "expr"),
+ HighLevelILOperation.HLIL_BREAK: HighLevelILBreak, # ,
+ HighLevelILOperation.HLIL_CONTINUE: HighLevelILContinue, # ,
+ HighLevelILOperation.HLIL_JUMP: HighLevelILJump, # ("dest", "expr"),
+ HighLevelILOperation.HLIL_RET: HighLevelILRet, # ("src", "expr_list"),
+ HighLevelILOperation.HLIL_NORET: HighLevelILNoret, # ,
+ HighLevelILOperation.HLIL_GOTO: HighLevelILGoto, # ("target", "label"),
+ HighLevelILOperation.HLIL_LABEL: HighLevelILLabel, # ("target", "label"),
+ HighLevelILOperation.HLIL_VAR_DECLARE: HighLevelILVarDeclare, # ("var", "var"),
+ HighLevelILOperation.HLIL_VAR_INIT: HighLevelILVarInit, # ("dest", "var"), ("src", "expr"),
+ HighLevelILOperation.HLIL_VAR_INIT_SSA: HighLevelILVarInitSsa, # ("dest", "var_ssa"), ("src", "expr"),
+ HighLevelILOperation.HLIL_ASSIGN: HighLevelILAssign, # ("dest", "expr"), ("src", "expr"),
+ HighLevelILOperation.HLIL_ASSIGN_UNPACK: HighLevelILAssignUnpack, # ("dest", "expr_list"), ("src", "expr"),
+ HighLevelILOperation.HLIL_ASSIGN_MEM_SSA:
+ HighLevelILAssignMemSsa, # ("dest", "expr"), ("dest_memory", "int"), ("src", "expr"), ("src_memory", "int"),
+ HighLevelILOperation.HLIL_ASSIGN_UNPACK_MEM_SSA:
+ HighLevelILAssignUnpackMemSsa, # ("dest", "expr_list"), ("dest_memory", "int"), ("src", "expr"), ("src_memory", "int"),
+ HighLevelILOperation.HLIL_VAR: HighLevelILVar, # ("var", "var"),
+ HighLevelILOperation.HLIL_VAR_SSA: HighLevelILVarSsa, # ("var", "var_ssa"),
+ HighLevelILOperation.HLIL_VAR_PHI: HighLevelILVarPhi, # ("dest", "var_ssa"), ("src", "var_ssa_list"),
+ HighLevelILOperation.HLIL_MEM_PHI: HighLevelILMemPhi, # ("dest", "int"), ("src", "int_list"),
+ HighLevelILOperation.HLIL_ARRAY_INDEX: HighLevelILArrayIndex, # ("src", "expr"), ("index", "expr"),
+ HighLevelILOperation.HLIL_ARRAY_INDEX_SSA:
+ HighLevelILArrayIndexSsa, # ("src", "expr"), ("src_memory", "int"), ("index", "expr"),
+ HighLevelILOperation.HLIL_SPLIT: HighLevelILSplit, # ("high", "expr"), ("low", "expr"),
+ HighLevelILOperation.HLIL_DEREF: HighLevelILDeref, # ("src", "expr"),
+ HighLevelILOperation.HLIL_STRUCT_FIELD:
+ HighLevelILStructField, # ("src", "expr"), ("offset", "int"), ("member_index", "member_index"),
+ HighLevelILOperation.HLIL_DEREF_FIELD:
+ HighLevelILDerefField, # ("src", "expr"), ("offset", "int"), ("member_index", "member_index"),
+ HighLevelILOperation.HLIL_DEREF_SSA: HighLevelILDerefSsa, # ("src", "expr"), ("src_memory", "int"),
+ HighLevelILOperation.HLIL_DEREF_FIELD_SSA:
+ HighLevelILDerefFieldSsa, # ("src", "expr"), ("src_memory", "int"), ("offset", "int"), ("member_index", "member_index"),
+ HighLevelILOperation.HLIL_ADDRESS_OF: HighLevelILAddressOf, # ("src", "expr"),
+ HighLevelILOperation.HLIL_CONST: HighLevelILConst, # ("constant", "int"),
+ HighLevelILOperation.HLIL_CONST_PTR: HighLevelILConstPtr, # ("constant", "int"),
+ HighLevelILOperation.HLIL_EXTERN_PTR: HighLevelILExternPtr, # ("constant", "int"), ("offset", "int"),
+ HighLevelILOperation.HLIL_FLOAT_CONST: HighLevelILFloatConst, # ("constant", "float"),
+ HighLevelILOperation.HLIL_IMPORT: HighLevelILImport, # ("constant", "int"),
+ HighLevelILOperation.HLIL_ADD: HighLevelILAdd, # ("left", "expr"), ("right", "expr"),
+ HighLevelILOperation.HLIL_ADC: HighLevelILAdc, # ("left", "expr"), ("right", "expr"), ("carry", "expr"),
+ HighLevelILOperation.HLIL_SUB: HighLevelILSub, # ("left", "expr"), ("right", "expr"),
+ HighLevelILOperation.HLIL_SBB: HighLevelILSbb, # ("left", "expr"), ("right", "expr"), ("carry", "expr"),
+ HighLevelILOperation.HLIL_AND: HighLevelILAnd, # ("left", "expr"), ("right", "expr"),
+ HighLevelILOperation.HLIL_OR: HighLevelILOr, # ("left", "expr"), ("right", "expr"),
+ HighLevelILOperation.HLIL_XOR: HighLevelILXor, # ("left", "expr"), ("right", "expr"),
+ HighLevelILOperation.HLIL_LSL: HighLevelILLsl, # ("left", "expr"), ("right", "expr"),
+ HighLevelILOperation.HLIL_LSR: HighLevelILLsr, # ("left", "expr"), ("right", "expr"),
+ HighLevelILOperation.HLIL_ASR: HighLevelILAsr, # ("left", "expr"), ("right", "expr"),
+ HighLevelILOperation.HLIL_ROL: HighLevelILRol, # ("left", "expr"), ("right", "expr"),
+ HighLevelILOperation.HLIL_RLC: HighLevelILRlc, # ("left", "expr"), ("right", "expr"), ("carry", "expr"),
+ HighLevelILOperation.HLIL_ROR: HighLevelILRor, # ("left", "expr"), ("right", "expr"),
+ HighLevelILOperation.HLIL_RRC: HighLevelILRrc, # ("left", "expr"), ("right", "expr"), ("carry", "expr"),
+ HighLevelILOperation.HLIL_MUL: HighLevelILMul, # ("left", "expr"), ("right", "expr"),
+ HighLevelILOperation.HLIL_MULU_DP: HighLevelILMuluDp, # ("left", "expr"), ("right", "expr"),
+ HighLevelILOperation.HLIL_MULS_DP: HighLevelILMulsDp, # ("left", "expr"), ("right", "expr"),
+ HighLevelILOperation.HLIL_DIVU: HighLevelILDivu, # ("left", "expr"), ("right", "expr"),
+ HighLevelILOperation.HLIL_DIVU_DP: HighLevelILDivuDp, # ("left", "expr"), ("right", "expr"),
+ HighLevelILOperation.HLIL_DIVS: HighLevelILDivs, # ("left", "expr"), ("right", "expr"),
+ HighLevelILOperation.HLIL_DIVS_DP: HighLevelILDivsDp, # ("left", "expr"), ("right", "expr"),
+ HighLevelILOperation.HLIL_MODU: HighLevelILModu, # ("left", "expr"), ("right", "expr"),
+ HighLevelILOperation.HLIL_MODU_DP: HighLevelILModuDp, # ("left", "expr"), ("right", "expr"),
+ HighLevelILOperation.HLIL_MODS: HighLevelILMods, # ("left", "expr"), ("right", "expr"),
+ HighLevelILOperation.HLIL_MODS_DP: HighLevelILModsDp, # ("left", "expr"), ("right", "expr"),
+ HighLevelILOperation.HLIL_NEG: HighLevelILNeg, # ("src", "expr"),
+ HighLevelILOperation.HLIL_NOT: HighLevelILNot, # ("src", "expr"),
+ HighLevelILOperation.HLIL_SX: HighLevelILSx, # ("src", "expr"),
+ HighLevelILOperation.HLIL_ZX: HighLevelILZx, # ("src", "expr"),
+ HighLevelILOperation.HLIL_LOW_PART: HighLevelILLowPart, # ("src", "expr"),
+ HighLevelILOperation.HLIL_CALL: HighLevelILCall, # ("dest", "expr"), ("params", "expr_list"),
+ HighLevelILOperation.HLIL_CALL_SSA:
+ HighLevelILCallSsa, # ("dest", "expr"), ("params", "expr_list"), ("dest_memory", "int"), ("src_memory", "int"),
+ HighLevelILOperation.HLIL_CMP_E: HighLevelILCmpE, # ("left", "expr"), ("right", "expr"),
+ HighLevelILOperation.HLIL_CMP_NE: HighLevelILCmpNe, # ("left", "expr"), ("right", "expr"),
+ HighLevelILOperation.HLIL_CMP_SLT: HighLevelILCmpSlt, # ("left", "expr"), ("right", "expr"),
+ HighLevelILOperation.HLIL_CMP_ULT: HighLevelILCmpUlt, # ("left", "expr"), ("right", "expr"),
+ HighLevelILOperation.HLIL_CMP_SLE: HighLevelILCmpSle, # ("left", "expr"), ("right", "expr"),
+ HighLevelILOperation.HLIL_CMP_ULE: HighLevelILCmpUle, # ("left", "expr"), ("right", "expr"),
+ HighLevelILOperation.HLIL_CMP_SGE: HighLevelILCmpSge, # ("left", "expr"), ("right", "expr"),
+ HighLevelILOperation.HLIL_CMP_UGE: HighLevelILCmpUge, # ("left", "expr"), ("right", "expr"),
+ HighLevelILOperation.HLIL_CMP_SGT: HighLevelILCmpSgt, # ("left", "expr"), ("right", "expr"),
+ HighLevelILOperation.HLIL_CMP_UGT: HighLevelILCmpUgt, # ("left", "expr"), ("right", "expr"),
+ HighLevelILOperation.HLIL_TEST_BIT: HighLevelILTestBit, # ("left", "expr"), ("right", "expr"),
+ HighLevelILOperation.HLIL_BOOL_TO_INT: HighLevelILBoolToInt, # ("src", "expr"),
+ HighLevelILOperation.HLIL_ADD_OVERFLOW: HighLevelILAddOverflow, # ("left", "expr"), ("right", "expr"),
+ HighLevelILOperation.HLIL_SYSCALL: HighLevelILSyscall, # ("params", "expr_list"),
+ HighLevelILOperation.HLIL_SYSCALL_SSA:
+ HighLevelILSyscallSsa, # ("params", "expr_list"), ("dest_memory", "int"), ("src_memory", "int"),
+ HighLevelILOperation.HLIL_TAILCALL: HighLevelILTailcall, # ("dest", "expr"), ("params", "expr_list"),
+ HighLevelILOperation.HLIL_BP: HighLevelILBp, # ,
+ HighLevelILOperation.HLIL_TRAP: HighLevelILTrap, # ("vector", "int"),
+ HighLevelILOperation.HLIL_INTRINSIC: HighLevelILIntrinsic, # ("intrinsic", "intrinsic"), ("params", "expr_list"),
+ HighLevelILOperation.HLIL_INTRINSIC_SSA:
+ HighLevelILIntrinsicSsa, # ("intrinsic", "intrinsic"), ("params", "expr_list"), ("dest_memory", "int"), ("src_memory", "int"),
+ HighLevelILOperation.HLIL_UNDEF: HighLevelILUndef, # ,
+ HighLevelILOperation.HLIL_UNIMPL: HighLevelILUnimpl, # ,
+ HighLevelILOperation.HLIL_UNIMPL_MEM: HighLevelILUnimplMem, # ("src", "expr"),
+ HighLevelILOperation.HLIL_FADD: HighLevelILFadd, # ("left", "expr"), ("right", "expr"),
+ HighLevelILOperation.HLIL_FSUB: HighLevelILFsub, # ("left", "expr"), ("right", "expr"),
+ HighLevelILOperation.HLIL_FMUL: HighLevelILFmul, # ("left", "expr"), ("right", "expr"),
+ HighLevelILOperation.HLIL_FDIV: HighLevelILFdiv, # ("left", "expr"), ("right", "expr"),
+ HighLevelILOperation.HLIL_FSQRT: HighLevelILFsqrt, # ("src", "expr"),
+ HighLevelILOperation.HLIL_FNEG: HighLevelILFneg, # ("src", "expr"),
+ HighLevelILOperation.HLIL_FABS: HighLevelILFabs, # ("src", "expr"),
+ HighLevelILOperation.HLIL_FLOAT_TO_INT: HighLevelILFloatToInt, # ("src", "expr"),
+ HighLevelILOperation.HLIL_INT_TO_FLOAT: HighLevelILIntToFloat, # ("src", "expr"),
+ HighLevelILOperation.HLIL_FLOAT_CONV: HighLevelILFloatConv, # ("src", "expr"),
+ HighLevelILOperation.HLIL_ROUND_TO_INT: HighLevelILRoundToInt, # ("src", "expr"),
+ HighLevelILOperation.HLIL_FLOOR: HighLevelILFloor, # ("src", "expr"),
+ HighLevelILOperation.HLIL_CEIL: HighLevelILCeil, # ("src", "expr"),
+ HighLevelILOperation.HLIL_FTRUNC: HighLevelILFtrunc, # ("src", "expr"),
+ HighLevelILOperation.HLIL_FCMP_E: HighLevelILFcmpE, # ("left", "expr"), ("right", "expr"),
+ HighLevelILOperation.HLIL_FCMP_NE: HighLevelILFcmpNe, # ("left", "expr"), ("right", "expr"),
+ HighLevelILOperation.HLIL_FCMP_LT: HighLevelILFcmpLt, # ("left", "expr"), ("right", "expr"),
+ HighLevelILOperation.HLIL_FCMP_LE: HighLevelILFcmpLe, # ("left", "expr"), ("right", "expr"),
+ HighLevelILOperation.HLIL_FCMP_GE: HighLevelILFcmpGe, # ("left", "expr"), ("right", "expr"),
+ HighLevelILOperation.HLIL_FCMP_GT: HighLevelILFcmpGt, # ("left", "expr"), ("right", "expr"),
+ HighLevelILOperation.HLIL_FCMP_O: HighLevelILFcmpO, # ("left", "expr"), ("right", "expr"),
+ HighLevelILOperation.HLIL_FCMP_UO: HighLevelILFcmpUo, # ("left", "expr"), ("right", "expr"),
}
+
class HighLevelILExpr:
"""
``class HighLevelILExpr`` hold the index of IL Expressions.
.. note:: Deprecated. Use ExpressionIndex instead
"""
- def __init__(self, index:ExpressionIndex):
+ def __init__(self, index: ExpressionIndex):
self._index = index
def __int__(self):
@@ -2064,15 +2068,17 @@ class HighLevelILFunction:
``class HighLevelILFunction`` contains the a HighLevelILInstruction object that makes up the abstract syntax tree of
a function.
"""
- def __init__(self, arch:Optional['architecture.Architecture']=None, handle:core.BNHighLevelILFunction=None,
- source_func:'function.Function'=None):
+ def __init__(
+ self, arch: Optional['architecture.Architecture'] = None, handle: core.BNHighLevelILFunction = None,
+ source_func: 'function.Function' = None
+ ):
self._arch = arch
self._source_function = source_func
if handle is not None:
HLILHandle = ctypes.POINTER(core.BNHighLevelILFunction)
_handle = ctypes.cast(handle, HLILHandle)
if self._source_function is None:
- self._source_function = function.Function(handle = core.BNGetHighLevelILOwnerFunction(_handle))
+ self._source_function = function.Function(handle=core.BNGetHighLevelILOwnerFunction(_handle))
if self._arch is None:
self._arch = self._source_function.arch
else:
@@ -2116,7 +2122,7 @@ class HighLevelILFunction:
def __len__(self):
return int(core.BNGetHighLevelILInstructionCount(self.handle))
- def __getitem__(self, i:Union[HighLevelILExpr, int]) -> HighLevelILInstruction:
+ def __getitem__(self, i: Union[HighLevelILExpr, int]) -> HighLevelILInstruction:
if isinstance(i, slice) or isinstance(i, tuple):
raise IndexError("expected integer instruction index")
if isinstance(i, HighLevelILExpr):
@@ -2125,8 +2131,9 @@ class HighLevelILFunction:
raise IndexError("index out of range")
if i < 0:
i = len(self) + i
- return HighLevelILInstruction.create(self, ExpressionIndex(core.BNGetHighLevelILIndexForInstruction(self.handle, i)), False,
- InstructionIndex(i))
+ return HighLevelILInstruction.create(
+ self, ExpressionIndex(core.BNGetHighLevelILIndexForInstruction(self.handle, i)), False, InstructionIndex(i)
+ )
def __setitem__(self, i, j):
raise IndexError("instruction modification not implemented")
@@ -2155,10 +2162,10 @@ class HighLevelILFunction:
return core.BNHighLevelILGetCurrentAddress(self.handle)
@current_address.setter
- def current_address(self, value:int) -> None:
+ def current_address(self, value: int) -> None:
core.BNHighLevelILSetCurrentAddress(self.handle, self.arch.handle, value)
- def set_current_address(self, value:int, arch:Optional['architecture.Architecture'] = None) -> None:
+ def set_current_address(self, value: int, arch: Optional['architecture.Architecture'] = None) -> None:
if arch is None:
arch = self.arch
core.BNHighLevelILSetCurrentAddress(self.handle, arch.handle, value)
@@ -2172,7 +2179,7 @@ class HighLevelILFunction:
return HighLevelILInstruction.create(self, ExpressionIndex(expr_index))
@root.setter
- def root(self, value:HighLevelILInstruction) -> None:
+ def root(self, value: HighLevelILInstruction) -> None:
core.BNSetHighLevelILRootExpr(self.handle, value.expr_index)
def _basic_block_list(self):
@@ -2224,7 +2231,7 @@ class HighLevelILFunction:
return self._source_function
@source_function.setter
- def source_function(self, value:'function.Function') -> None:
+ def source_function(self, value: 'function.Function') -> None:
self._source_function = value
@property
@@ -2240,26 +2247,26 @@ class HighLevelILFunction:
"""Alias for medium_level_il"""
return self.medium_level_il
- def get_ssa_instruction_index(self, instr:int) -> int:
+ def get_ssa_instruction_index(self, instr: int) -> int:
return core.BNGetHighLevelILSSAInstructionIndex(self.handle, instr)
- def get_non_ssa_instruction_index(self, instr:int) -> int:
+ def get_non_ssa_instruction_index(self, instr: int) -> int:
return core.BNGetHighLevelILNonSSAInstructionIndex(self.handle, instr)
- def get_ssa_var_definition(self, ssa_var:'mediumlevelil.SSAVariable') -> Optional[HighLevelILInstruction]:
+ def get_ssa_var_definition(self, ssa_var: 'mediumlevelil.SSAVariable') -> Optional[HighLevelILInstruction]:
var_data = ssa_var.var.to_BNVariable()
result = core.BNGetHighLevelILSSAVarDefinition(self.handle, var_data, ssa_var.version)
if result >= core.BNGetHighLevelILExprCount(self.handle):
return None
return HighLevelILInstruction.create(self, ExpressionIndex(result))
- def get_ssa_memory_definition(self, version:int) -> Optional[HighLevelILInstruction]:
+ def get_ssa_memory_definition(self, version: int) -> Optional[HighLevelILInstruction]:
result = core.BNGetHighLevelILSSAMemoryDefinition(self.handle, version)
if result >= core.BNGetHighLevelILExprCount(self.handle):
return None
return HighLevelILInstruction.create(self, ExpressionIndex(result))
- def get_ssa_var_uses(self, ssa_var:'mediumlevelil.SSAVariable') -> List[HighLevelILInstruction]:
+ def get_ssa_var_uses(self, ssa_var: 'mediumlevelil.SSAVariable') -> List[HighLevelILInstruction]:
count = ctypes.c_ulonglong()
var_data = ssa_var.var.to_BNVariable()
instrs = core.BNGetHighLevelILSSAVarUses(self.handle, var_data, ssa_var.version, count)
@@ -2270,7 +2277,7 @@ class HighLevelILFunction:
core.BNFreeILInstructionList(instrs)
return result
- def get_ssa_memory_uses(self, version:int) -> List[HighLevelILInstruction]:
+ def get_ssa_memory_uses(self, version: int) -> List[HighLevelILInstruction]:
count = ctypes.c_ulonglong()
instrs = core.BNGetHighLevelILSSAMemoryUses(self.handle, version, count)
assert instrs is not None, "core.BNGetHighLevelILSSAMemoryUses returned None"
@@ -2280,7 +2287,7 @@ class HighLevelILFunction:
core.BNFreeILInstructionList(instrs)
return result
- def is_ssa_var_live(self, ssa_var:'mediumlevelil.SSAVariable') -> bool:
+ def is_ssa_var_live(self, ssa_var: 'mediumlevelil.SSAVariable') -> bool:
"""
``is_ssa_var_live`` determines if ``ssa_var`` is live at any point in the function
@@ -2311,7 +2318,7 @@ class HighLevelILFunction:
var_data.storage = ssa_var.var.storage
return core.BNIsHighLevelILSSAVarLiveAt(self.handle, var_data, ssa_var.version, instr)
- def get_var_definitions(self, var:'variable.Variable') -> List[HighLevelILInstruction]:
+ def get_var_definitions(self, var: 'variable.Variable') -> List[HighLevelILInstruction]:
count = ctypes.c_ulonglong()
var_data = var.to_BNVariable()
instrs = core.BNGetHighLevelILVariableDefinitions(self.handle, var_data, count)
@@ -2322,7 +2329,7 @@ class HighLevelILFunction:
core.BNFreeILInstructionList(instrs)
return result
- def get_var_uses(self, var:'variable.Variable') -> List[HighLevelILInstruction]:
+ def get_var_uses(self, var: 'variable.Variable') -> List[HighLevelILInstruction]:
count = ctypes.c_ulonglong()
var_data = var.to_BNVariable()
instrs = core.BNGetHighLevelILVariableUses(self.handle, var_data, count)
@@ -2333,8 +2340,10 @@ class HighLevelILFunction:
core.BNFreeILInstructionList(instrs)
return result
- def expr(self, operation:Union[str, HighLevelILOperation], a:int = 0, b:int = 0, c:int = 0,
- d:int = 0, e:int = 0, size:int = 0) -> ExpressionIndex:
+ def expr(
+ self, operation: Union[str, HighLevelILOperation], a: int = 0, b: int = 0, c: int = 0, d: int = 0, e: int = 0,
+ size: int = 0
+ ) -> ExpressionIndex:
if isinstance(operation, str):
operation_value = HighLevelILOperation[operation]
else:
@@ -2342,7 +2351,7 @@ class HighLevelILFunction:
operation_value = operation.value
return ExpressionIndex(core.BNHighLevelILAddExpr(self.handle, operation_value, size, a, b, c, d, e))
- def add_operand_list(self, operands:List[int]) -> ExpressionIndex:
+ def add_operand_list(self, operands: List[int]) -> ExpressionIndex:
"""
``add_operand_list`` returns an operand list expression for the given list of integer operands.
@@ -2363,7 +2372,7 @@ class HighLevelILFunction:
"""
core.BNFinalizeHighLevelILFunction(self.handle)
- def create_graph(self, settings:'function.DisassemblySettings'=None) -> 'flowgraph.CoreFlowGraph':
+ def create_graph(self, settings: 'function.DisassemblySettings' = None) -> 'flowgraph.CoreFlowGraph':
if settings is not None:
settings_obj = settings.handle
else:
@@ -2382,14 +2391,20 @@ class HighLevelILFunction:
if self.source_function is None:
return []
- if self.il_form in [FunctionGraphType.HighLevelILFunctionGraph, FunctionGraphType.HighLevelILSSAFormFunctionGraph]:
+ if self.il_form in [
+ FunctionGraphType.HighLevelILFunctionGraph, FunctionGraphType.HighLevelILSSAFormFunctionGraph
+ ]:
count = ctypes.c_ulonglong()
core_variables = core.BNGetHighLevelILVariables(self.handle, count)
assert core_variables is not None, "core.BNGetHighLevelILVariables returned None"
try:
result = []
for var_i in range(count.value):
- result.append(variable.Variable(self, core_variables[var_i].type, core_variables[var_i].index, core_variables[var_i].storage))
+ result.append(
+ variable.Variable(
+ self, core_variables[var_i].type, core_variables[var_i].index, core_variables[var_i].storage
+ )
+ )
return result
finally:
core.BNFreeVariableList(core_variables)
@@ -2401,14 +2416,20 @@ class HighLevelILFunction:
if self.source_function is None:
return []
- if self.il_form in [FunctionGraphType.HighLevelILFunctionGraph, FunctionGraphType.HighLevelILSSAFormFunctionGraph]:
+ if self.il_form in [
+ FunctionGraphType.HighLevelILFunctionGraph, FunctionGraphType.HighLevelILSSAFormFunctionGraph
+ ]:
count = ctypes.c_ulonglong()
core_variables = core.BNGetHighLevelILAliasedVariables(self.handle, count)
assert core_variables is not None, "core.BNGetHighLevelILAliasedVariables returned None"
try:
result = []
for var_i in range(count.value):
- result.append(variable.Variable(self, core_variables[var_i].type, core_variables[var_i].index, core_variables[var_i].storage))
+ result.append(
+ variable.Variable(
+ self, core_variables[var_i].type, core_variables[var_i].index, core_variables[var_i].storage
+ )
+ )
return result
finally:
core.BNFreeVariableList(core_variables)
@@ -2428,11 +2449,20 @@ class HighLevelILFunction:
result = []
for var_i in range(variable_count.value):
version_count = ctypes.c_ulonglong()
- versions = core.BNGetHighLevelILVariableSSAVersions(self.handle, core_variables[var_i], version_count)
+ versions = core.BNGetHighLevelILVariableSSAVersions(
+ self.handle, core_variables[var_i], version_count
+ )
assert versions is not None, "core.BNGetHighLevelILVariableSSAVersions returned None"
try:
for version_i in range(version_count.value):
- result.append(mediumlevelil.SSAVariable(variable.Variable(self, core_variables[var_i].type, core_variables[var_i].index, core_variables[var_i].storage), versions[version_i]))
+ result.append(
+ mediumlevelil.SSAVariable(
+ variable.Variable(
+ self, core_variables[var_i].type, core_variables[var_i].index,
+ core_variables[var_i].storage
+ ), versions[version_i]
+ )
+ )
finally:
core.BNFreeILInstructionList(versions)
return result
@@ -2443,7 +2473,7 @@ class HighLevelILFunction:
return []
- def get_medium_level_il_expr_index(self, expr:ExpressionIndex) -> Optional['mediumlevelil.ExpressionIndex']:
+ def get_medium_level_il_expr_index(self, expr: ExpressionIndex) -> Optional['mediumlevelil.ExpressionIndex']:
medium_il = self.medium_level_il
if medium_il is None:
return None
@@ -2455,7 +2485,7 @@ class HighLevelILFunction:
return None
return mediumlevelil.ExpressionIndex(result)
- def get_medium_level_il_expr_indexes(self, expr:ExpressionIndex) -> List['mediumlevelil.ExpressionIndex']:
+ def get_medium_level_il_expr_indexes(self, expr: ExpressionIndex) -> List['mediumlevelil.ExpressionIndex']:
count = ctypes.c_ulonglong()
exprs = core.BNGetMediumLevelILExprIndexesFromHighLevelIL(self.handle, expr, count)
assert exprs is not None, "core.BNGetMediumLevelILExprIndexesFromHighLevelIL returned None"
@@ -2465,13 +2495,13 @@ class HighLevelILFunction:
core.BNFreeILInstructionList(exprs)
return result
- def get_label(self, label_idx:int) -> Optional[HighLevelILInstruction]:
+ def get_label(self, label_idx: int) -> Optional[HighLevelILInstruction]:
result = core.BNGetHighLevelILExprIndexForLabel(self.handle, label_idx)
if result >= core.BNGetHighLevelILExprCount(self.handle):
return None
return HighLevelILInstruction.create(self, ExpressionIndex(result))
- def get_label_uses(self, label_idx:int) -> List[HighLevelILInstruction]:
+ def get_label_uses(self, label_idx: int) -> List[HighLevelILInstruction]:
count = ctypes.c_ulonglong()
uses = core.BNGetHighLevelILUsesForLabel(self.handle, label_idx, count)
assert uses is not None, "core.BNGetHighLevelILUsesForLabel returned None"
@@ -2483,7 +2513,9 @@ class HighLevelILFunction:
class HighLevelILBasicBlock(basicblock.BasicBlock):
- def __init__(self, handle:core.BNBasicBlockHandle, owner:HighLevelILFunction, view:Optional['binaryview.BinaryView']):
+ def __init__(
+ self, handle: core.BNBasicBlockHandle, owner: HighLevelILFunction, view: Optional['binaryview.BinaryView']
+ ):
super(HighLevelILBasicBlock, self).__init__(handle, view)
self._il_function = owner
@@ -2502,7 +2534,7 @@ class HighLevelILBasicBlock(basicblock.BasicBlock):
else:
return self.il_function[self.end + idx]
- def _create_instance(self, handle:core.BNBasicBlockHandle, view:'binaryview.BinaryView'):
+ def _create_instance(self, handle: core.BNBasicBlockHandle, view: 'binaryview.BinaryView'):
"""Internal method by super to instantiate child instances"""
return HighLevelILBasicBlock(handle, self.il_function, view)
diff --git a/python/highlight.py b/python/highlight.py
index b1666f54..a224ef30 100644
--- a/python/highlight.py
+++ b/python/highlight.py
@@ -18,14 +18,13 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
-
# Binary Ninja components
from . import _binaryninjacore as core
from .enums import HighlightColorStyle, HighlightStandardColor
class HighlightColor:
- def __init__(self, color = None, mix_color = None, mix = None, red = None, green = None, blue = None, alpha = 255):
+ def __init__(self, color=None, mix_color=None, mix=None, red=None, green=None, blue=None, alpha=255):
if (red is not None) and (green is not None) and (blue is not None):
self._style = HighlightColorStyle.CustomHighlightColor
self._red = red
@@ -141,10 +140,13 @@ class HighlightColor:
return "<color: %s, alpha %d>" % (self._standard_color_to_str(self.color), self.alpha)
if self.style == HighlightColorStyle.MixedHighlightColor:
if self.alpha == 255:
- return "<color: mix %s to %s factor %d>" % (self._standard_color_to_str(self.color),
- self._standard_color_to_str(self.mix_color), self.mix)
- return "<color: mix %s to %s factor %d, alpha %d>" % (self._standard_color_to_str(self.color),
- self._standard_color_to_str(self.mix_color), self.mix, self.alpha)
+ return "<color: mix %s to %s factor %d>" % (
+ self._standard_color_to_str(self.color), self._standard_color_to_str(self.mix_color), self.mix
+ )
+ return "<color: mix %s to %s factor %d, alpha %d>" % (
+ self._standard_color_to_str(self.color), self._standard_color_to_str(self.mix_color
+ ), self.mix, self.alpha
+ )
if self.style == HighlightColorStyle.CustomHighlightColor:
if self.alpha == 255:
return "<color: #%.2x%.2x%.2x>" % (self.red, self.green, self.blue)
@@ -184,4 +186,3 @@ class HighlightColor:
elif color.style == HighlightColorStyle.CustomHighlightColor:
return HighlightColor(red=color.r, green=color.g, blue=color.b, alpha=color.alpha)
return HighlightColor(color=HighlightStandardColor.NoHighlightColor)
-
diff --git a/python/interaction.py b/python/interaction.py
index 7389f023..978de6b2 100644
--- a/python/interaction.py
+++ b/python/interaction.py
@@ -35,7 +35,7 @@ class LabelField:
"""
``LabelField`` adds a text label to the display.
"""
- def __init__(self, text:str):
+ def __init__(self, text: str):
self._text = text
def _fill_core_struct(self, value):
@@ -54,7 +54,7 @@ class LabelField:
return self._text
@text.setter
- def text(self, value:str) -> None:
+ def text(self, value: str) -> None:
self._text = value
@@ -501,7 +501,7 @@ class InteractionHandler:
def _show_plain_text_report(self, ctxt, view, title, contents):
try:
if view:
- view = binaryview.BinaryView(handle = core.BNNewViewReference(view))
+ view = binaryview.BinaryView(handle=core.BNNewViewReference(view))
else:
view = None
self.show_plain_text_report(view, title, contents)
@@ -511,7 +511,7 @@ class InteractionHandler:
def _show_markdown_report(self, ctxt, view, title, contents, plaintext):
try:
if view:
- view = binaryview.BinaryView(handle = core.BNNewViewReference(view))
+ view = binaryview.BinaryView(handle=core.BNNewViewReference(view))
else:
view = None
self.show_markdown_report(view, title, contents, plaintext)
@@ -521,7 +521,7 @@ class InteractionHandler:
def _show_html_report(self, ctxt, view, title, contents, plaintext):
try:
if view:
- view = binaryview.BinaryView(handle = core.BNNewViewReference(view))
+ view = binaryview.BinaryView(handle=core.BNNewViewReference(view))
else:
view = None
self.show_html_report(view, title, contents, plaintext)
@@ -531,7 +531,7 @@ class InteractionHandler:
def _show_graph_report(self, ctxt, view, title, graph):
try:
if view:
- view = binaryview.BinaryView(handle = core.BNNewViewReference(view))
+ view = binaryview.BinaryView(handle=core.BNNewViewReference(view))
else:
view = None
self.show_graph_report(view, title, flowgraph.CoreFlowGraph(core.BNNewFlowGraphReference(graph)))
@@ -567,7 +567,7 @@ class InteractionHandler:
def _get_address_input(self, ctxt, result, prompt, title, view, current_address):
try:
if view:
- view = binaryview.BinaryView(handle = core.BNNewViewReference(view))
+ view = binaryview.BinaryView(handle=core.BNNewViewReference(view))
else:
view = None
value = self.get_address_input(prompt, title, view, current_address)
@@ -630,27 +630,61 @@ class InteractionHandler:
elif fields[i].type == FormInputFieldType.SeparatorFormField:
field_objs.append(SeparatorField())
elif fields[i].type == FormInputFieldType.TextLineFormField:
- field_objs.append(TextLineField(fields[i].prompt, default=fields[i].stringDefault if fields[i].hasDefault else None))
+ field_objs.append(
+ TextLineField(
+ fields[i].prompt, default=fields[i].stringDefault if fields[i].hasDefault else None
+ )
+ )
elif fields[i].type == FormInputFieldType.MultilineTextFormField:
- field_objs.append(MultilineTextField(fields[i].prompt, default=fields[i].stringDefault if fields[i].hasDefault else None))
+ field_objs.append(
+ MultilineTextField(
+ fields[i].prompt, default=fields[i].stringDefault if fields[i].hasDefault else None
+ )
+ )
elif fields[i].type == FormInputFieldType.IntegerFormField:
- field_objs.append(IntegerField(fields[i].prompt, default=fields[i].intDefault if fields[i].hasDefault else None))
+ field_objs.append(
+ IntegerField(fields[i].prompt, default=fields[i].intDefault if fields[i].hasDefault else None)
+ )
elif fields[i].type == FormInputFieldType.AddressFormField:
view = None
if fields[i].view:
- view = binaryview.BinaryView(handle = core.BNNewViewReference(fields[i].view))
- field_objs.append(AddressField(fields[i].prompt, view, fields[i].currentAddress, default=fields[i].addressDefault if fields[i].hasDefault else None))
+ view = binaryview.BinaryView(handle=core.BNNewViewReference(fields[i].view))
+ field_objs.append(
+ AddressField(
+ fields[i].prompt, view, fields[i].currentAddress,
+ default=fields[i].addressDefault if fields[i].hasDefault else None
+ )
+ )
elif fields[i].type == FormInputFieldType.ChoiceFormField:
choices = []
for j in range(0, fields[i].count):
choices.append(fields[i].choices[j])
- field_objs.append(ChoiceField(fields[i].prompt, choices, default=fields[i].choiceDefault if fields[i].hasDefault else None))
+ field_objs.append(
+ ChoiceField(
+ fields[i].prompt, choices, default=fields[i].choiceDefault if fields[i].hasDefault else None
+ )
+ )
elif fields[i].type == FormInputFieldType.OpenFileNameFormField:
- field_objs.append(OpenFileNameField(fields[i].prompt, fields[i].ext, default=fields[i].stringDefault if fields[i].hasDefault else None))
+ field_objs.append(
+ OpenFileNameField(
+ fields[i].prompt, fields[i].ext,
+ default=fields[i].stringDefault if fields[i].hasDefault else None
+ )
+ )
elif fields[i].type == FormInputFieldType.SaveFileNameFormField:
- field_objs.append(SaveFileNameField(fields[i].prompt, fields[i].ext, fields[i].defaultName, default=fields[i].stringDefault if fields[i].hasDefault else None))
+ field_objs.append(
+ SaveFileNameField(
+ fields[i].prompt, fields[i].ext, fields[i].defaultName,
+ default=fields[i].stringDefault if fields[i].hasDefault else None
+ )
+ )
elif fields[i].type == FormInputFieldType.DirectoryNameFormField:
- field_objs.append(DirectoryNameField(fields[i].prompt, fields[i].defaultName, default=fields[i].stringDefault if fields[i].hasDefault else None))
+ field_objs.append(
+ DirectoryNameField(
+ fields[i].prompt, fields[i].defaultName,
+ default=fields[i].stringDefault if fields[i].hasDefault else None
+ )
+ )
else:
field_objs.append(LabelField(fields[i].prompt))
if not self.get_form_input(field_objs, title):
@@ -730,7 +764,7 @@ class InteractionHandler:
class PlainTextReport:
- def __init__(self, title, contents, view = None):
+ def __init__(self, title, contents, view=None):
self._view = view
self._title = title
self._contents = contents
@@ -767,7 +801,7 @@ class PlainTextReport:
class MarkdownReport:
- def __init__(self, title, contents, plaintext = "", view = None):
+ def __init__(self, title, contents, plaintext="", view=None):
self._view = view
self._title = title
self._contents = contents
@@ -813,7 +847,7 @@ class MarkdownReport:
class HTMLReport:
- def __init__(self, title, contents, plaintext = "", view = None):
+ def __init__(self, title, contents, plaintext="", view=None):
self._view = view
self._title = title
self._contents = contents
@@ -859,7 +893,7 @@ class HTMLReport:
class FlowGraphReport:
- def __init__(self, title, graph, view = None):
+ def __init__(self, title, graph, view=None):
self._view = view
self._title = title
self._graph = graph
@@ -893,7 +927,7 @@ class FlowGraphReport:
class ReportCollection:
- def __init__(self, handle = None):
+ def __init__(self, handle=None):
if handle is None:
self.handle = core.BNCreateReportCollection()
else:
@@ -907,7 +941,7 @@ class ReportCollection:
title = core.BNGetReportTitle(self.handle, i)
view = core.BNGetReportView(self.handle, i)
if view:
- view = binaryview.BinaryView(handle = view)
+ view = binaryview.BinaryView(handle=view)
else:
view = None
if report_type == ReportType.PlainTextReportType:
@@ -1163,7 +1197,7 @@ def get_choice_input(prompt, title, choices):
return value.value
-def get_open_filename_input(prompt:str, ext:str="") -> Optional[str]:
+def get_open_filename_input(prompt: str, ext: str = "") -> Optional[str]:
"""
``get_open_filename_input`` prompts the user for a file name to open
@@ -1191,7 +1225,7 @@ def get_open_filename_input(prompt:str, ext:str="") -> Optional[str]:
return result.decode("utf-8")
-def get_save_filename_input(prompt:str, ext:str="", default_name:str="") -> Optional[str]:
+def get_save_filename_input(prompt: str, ext: str = "", default_name: str = "") -> Optional[str]:
"""
``get_save_filename_input`` prompts the user for a file name to save as, optionally providing a file extension and \
default_name
@@ -1216,7 +1250,7 @@ def get_save_filename_input(prompt:str, ext:str="", default_name:str="") -> Opti
return result.decode("utf-8")
-def get_directory_name_input(prompt:str, default_name:str=""):
+def get_directory_name_input(prompt: str, default_name: str = ""):
"""
``get_directory_name_input`` prompts the user for a directory name to save as, optionally providing a default_name
diff --git a/python/lineardisassembly.py b/python/lineardisassembly.py
index f87e8b33..ddc8fd5d 100644
--- a/python/lineardisassembly.py
+++ b/python/lineardisassembly.py
@@ -45,7 +45,7 @@ class LinearDisassemblyLine:
class LinearViewObjectIdentifier:
- def __init__(self, name, start = None, end = None):
+ def __init__(self, name, start=None, end=None):
self._name = name
self._start = start
self._end = end
@@ -73,7 +73,7 @@ class LinearViewObjectIdentifier:
def __hash__(self):
return hash((self._name, self._start, self._end))
- def _to_core_struct(self, obj = None):
+ def _to_core_struct(self, obj=None):
if obj is None:
result = core.BNLinearViewObjectIdentifier()
else:
@@ -129,7 +129,7 @@ class LinearViewObjectIdentifier:
class LinearViewObject:
- def __init__(self, handle, parent = None):
+ def __init__(self, handle, parent=None):
self.handle = handle
self._parent = parent
@@ -246,174 +246,223 @@ class LinearViewObject:
next_obj = next_obj.handle
count = ctypes.c_ulonglong(0)
- return LinearViewCursor._make_lines(core.BNGetLinearViewObjectLines(self.handle, prev_obj, next_obj, count), count.value)
+ return LinearViewCursor._make_lines(
+ core.BNGetLinearViewObjectLines(self.handle, prev_obj, next_obj, count), count.value
+ )
def ordering_index_for_child(self, child):
return core.BNGetLinearViewObjectOrderingIndexForChild(self.handle, child.handle)
@staticmethod
- def disassembly(view:'binaryview.BinaryView', settings:Optional['_function.DisassemblySettings'] = None) -> 'LinearViewObject':
+ def disassembly(
+ view: 'binaryview.BinaryView', settings: Optional['_function.DisassemblySettings'] = None
+ ) -> 'LinearViewObject':
_settings = settings
if _settings is not None:
_settings = _settings.handle
return LinearViewObject(core.BNCreateLinearViewDisassembly(view.handle, _settings))
@staticmethod
- def lifted_il(view:'binaryview.BinaryView', settings:Optional['_function.DisassemblySettings'] = None) -> 'LinearViewObject':
+ def lifted_il(
+ view: 'binaryview.BinaryView', settings: Optional['_function.DisassemblySettings'] = None
+ ) -> 'LinearViewObject':
_settings = settings
if _settings is not None:
_settings = _settings.handle
return LinearViewObject(core.BNCreateLinearViewLiftedIL(view.handle, _settings))
@staticmethod
- def llil(view:'binaryview.BinaryView', settings:Optional['_function.DisassemblySettings'] = None) -> 'LinearViewObject':
+ def llil(
+ view: 'binaryview.BinaryView', settings: Optional['_function.DisassemblySettings'] = None
+ ) -> 'LinearViewObject':
_settings = settings
if _settings is not None:
_settings = _settings.handle
return LinearViewObject(core.BNCreateLinearViewLowLevelIL(view.handle, _settings))
@staticmethod
- def llil_ssa_form(view:'binaryview.BinaryView', settings:Optional['_function.DisassemblySettings'] = None) -> 'LinearViewObject':
+ def llil_ssa_form(
+ view: 'binaryview.BinaryView', settings: Optional['_function.DisassemblySettings'] = None
+ ) -> 'LinearViewObject':
_settings = settings
if _settings is not None:
_settings = _settings.handle
return LinearViewObject(core.BNCreateLinearViewLowLevelILSSAForm(view.handle, _settings))
@staticmethod
- def mlil(view:'binaryview.BinaryView', settings:Optional['_function.DisassemblySettings'] = None) -> 'LinearViewObject':
+ def mlil(
+ view: 'binaryview.BinaryView', settings: Optional['_function.DisassemblySettings'] = None
+ ) -> 'LinearViewObject':
_settings = settings
if _settings is not None:
_settings = _settings.handle
return LinearViewObject(core.BNCreateLinearViewMediumLevelIL(view.handle, _settings))
@staticmethod
- def mlil_ssa_form(view:'binaryview.BinaryView', settings:Optional['_function.DisassemblySettings'] = None) -> 'LinearViewObject':
+ def mlil_ssa_form(
+ view: 'binaryview.BinaryView', settings: Optional['_function.DisassemblySettings'] = None
+ ) -> 'LinearViewObject':
_settings = settings
if _settings is not None:
_settings = _settings.handle
return LinearViewObject(core.BNCreateLinearViewMediumLevelILSSAForm(view.handle, _settings))
@staticmethod
- def mmlil(view:'binaryview.BinaryView', settings:Optional['_function.DisassemblySettings'] = None) -> 'LinearViewObject':
+ def mmlil(
+ view: 'binaryview.BinaryView', settings: Optional['_function.DisassemblySettings'] = None
+ ) -> 'LinearViewObject':
_settings = settings
if _settings is not None:
_settings = _settings.handle
return LinearViewObject(core.BNCreateLinearViewMappedMediumLevelIL(view.handle, _settings))
@staticmethod
- def mmlil_ssa_form(view:'binaryview.BinaryView', settings:Optional['_function.DisassemblySettings'] = None) -> 'LinearViewObject':
+ def mmlil_ssa_form(
+ view: 'binaryview.BinaryView', settings: Optional['_function.DisassemblySettings'] = None
+ ) -> 'LinearViewObject':
_settings = settings
if _settings is not None:
_settings = _settings.handle
return LinearViewObject(core.BNCreateLinearViewMappedMediumLevelILSSAForm(view.handle, _settings))
@staticmethod
- def hlil(view:'binaryview.BinaryView', settings:Optional['_function.DisassemblySettings'] = None) -> 'LinearViewObject':
+ def hlil(
+ view: 'binaryview.BinaryView', settings: Optional['_function.DisassemblySettings'] = None
+ ) -> 'LinearViewObject':
_settings = settings
if _settings is not None:
_settings = _settings.handle
return LinearViewObject(core.BNCreateLinearViewHighLevelIL(view.handle, _settings))
@staticmethod
- def hlil_ssa_form(view:'binaryview.BinaryView', settings:Optional['_function.DisassemblySettings'] = None) -> 'LinearViewObject':
+ def hlil_ssa_form(
+ view: 'binaryview.BinaryView', settings: Optional['_function.DisassemblySettings'] = None
+ ) -> 'LinearViewObject':
_settings = settings
if _settings is not None:
_settings = _settings.handle
return LinearViewObject(core.BNCreateLinearViewHighLevelILSSAForm(view.handle, _settings))
@staticmethod
- def language_representation(view:'binaryview.BinaryView', settings:Optional['_function.DisassemblySettings'] = None) -> 'LinearViewObject':
+ def language_representation(
+ view: 'binaryview.BinaryView', settings: Optional['_function.DisassemblySettings'] = None
+ ) -> 'LinearViewObject':
_settings = settings
if _settings is not None:
_settings = _settings.handle
return LinearViewObject(core.BNCreateLinearViewLanguageRepresentation(view.handle, _settings))
@staticmethod
- def data_only(view:'binaryview.BinaryView', settings:Optional['_function.DisassemblySettings'] = None) -> 'LinearViewObject':
+ def data_only(
+ view: 'binaryview.BinaryView', settings: Optional['_function.DisassemblySettings'] = None
+ ) -> 'LinearViewObject':
_settings = settings
if _settings is not None:
_settings = _settings.handle
return LinearViewObject(core.BNCreateLinearViewDataOnly(view.handle, _settings))
@staticmethod
- def single_function_disassembly(func:'_function.Function', settings:Optional['_function.DisassemblySettings'] = None) -> 'LinearViewObject':
+ def single_function_disassembly(
+ func: '_function.Function', settings: Optional['_function.DisassemblySettings'] = None
+ ) -> 'LinearViewObject':
_settings = settings
if _settings is not None:
_settings = _settings.handle
return LinearViewObject(core.BNCreateLinearViewSingleFunctionDisassembly(func.handle, _settings))
@staticmethod
- def single_function_lifted_il(func:'_function.Function', settings:Optional['_function.DisassemblySettings'] = None) -> 'LinearViewObject':
+ def single_function_lifted_il(
+ func: '_function.Function', settings: Optional['_function.DisassemblySettings'] = None
+ ) -> 'LinearViewObject':
_settings = settings
if _settings is not None:
_settings = _settings.handle
return LinearViewObject(core.BNCreateLinearViewSingleFunctionLiftedIL(func.handle, _settings))
@staticmethod
- def single_function_llil(func:'_function.Function', settings:Optional['_function.DisassemblySettings'] = None) -> 'LinearViewObject':
+ def single_function_llil(
+ func: '_function.Function', settings: Optional['_function.DisassemblySettings'] = None
+ ) -> 'LinearViewObject':
_settings = settings
if _settings is not None:
_settings = _settings.handle
return LinearViewObject(core.BNCreateLinearViewSingleFunctionLowLevelIL(func.handle, _settings))
@staticmethod
- def single_function_llil_ssa_form(func:'_function.Function', settings:Optional['_function.DisassemblySettings'] = None) -> 'LinearViewObject':
+ def single_function_llil_ssa_form(
+ func: '_function.Function', settings: Optional['_function.DisassemblySettings'] = None
+ ) -> 'LinearViewObject':
_settings = settings
if _settings is not None:
_settings = _settings.handle
return LinearViewObject(core.BNCreateLinearViewSingleFunctionLowLevelILSSAForm(func.handle, _settings))
@staticmethod
- def single_function_mlil(func:'_function.Function', settings:Optional['_function.DisassemblySettings'] = None) -> 'LinearViewObject':
+ def single_function_mlil(
+ func: '_function.Function', settings: Optional['_function.DisassemblySettings'] = None
+ ) -> 'LinearViewObject':
_settings = settings
if _settings is not None:
_settings = _settings.handle
return LinearViewObject(core.BNCreateLinearViewSingleFunctionMediumLevelIL(func.handle, _settings))
@staticmethod
- def single_function_mlil_ssa_form(func:'_function.Function', settings:Optional['_function.DisassemblySettings'] = None) -> 'LinearViewObject':
+ def single_function_mlil_ssa_form(
+ func: '_function.Function', settings: Optional['_function.DisassemblySettings'] = None
+ ) -> 'LinearViewObject':
_settings = settings
if _settings is not None:
_settings = _settings.handle
return LinearViewObject(core.BNCreateLinearViewSingleFunctionMediumLevelILSSAForm(func.handle, _settings))
@staticmethod
- def single_function_mmlil(func:'_function.Function', settings:Optional['_function.DisassemblySettings'] = None) -> 'LinearViewObject':
+ def single_function_mmlil(
+ func: '_function.Function', settings: Optional['_function.DisassemblySettings'] = None
+ ) -> 'LinearViewObject':
_settings = settings
if _settings is not None:
_settings = _settings.handle
return LinearViewObject(core.BNCreateLinearViewSingleFunctionMappedMediumLevelIL(func.handle, _settings))
@staticmethod
- def single_function_mmlil_ssa_form(func:'_function.Function', settings:Optional['_function.DisassemblySettings'] = None) -> 'LinearViewObject':
+ def single_function_mmlil_ssa_form(
+ func: '_function.Function', settings: Optional['_function.DisassemblySettings'] = None
+ ) -> 'LinearViewObject':
_settings = settings
if _settings is not None:
_settings = _settings.handle
return LinearViewObject(core.BNCreateLinearViewSingleFunctionMappedMediumLevelILSSAForm(func.handle, _settings))
@staticmethod
- def single_function_hlil(func:'_function.Function', settings:Optional['_function.DisassemblySettings'] = None) -> 'LinearViewObject':
+ def single_function_hlil(
+ func: '_function.Function', settings: Optional['_function.DisassemblySettings'] = None
+ ) -> 'LinearViewObject':
_settings = settings
if _settings is not None:
_settings = _settings.handle
return LinearViewObject(core.BNCreateLinearViewSingleFunctionHighLevelIL(func.handle, _settings))
@staticmethod
- def single_function_hlil_ssa_form(func:'_function.Function', settings:Optional['_function.DisassemblySettings'] = None) -> 'LinearViewObject':
+ def single_function_hlil_ssa_form(
+ func: '_function.Function', settings: Optional['_function.DisassemblySettings'] = None
+ ) -> 'LinearViewObject':
_settings = settings
if _settings is not None:
_settings = _settings.handle
return LinearViewObject(core.BNCreateLinearViewSingleFunctionHighLevelILSSAForm(func.handle, _settings))
@staticmethod
- def single_function_language_representation(view:'binaryview.BinaryView', settings:Optional['_function.DisassemblySettings'] = None) -> 'LinearViewObject':
+ def single_function_language_representation(
+ view: 'binaryview.BinaryView', settings: Optional['_function.DisassemblySettings'] = None
+ ) -> 'LinearViewObject':
_settings = settings
if _settings is not None:
_settings = _settings.handle
return LinearViewObject(core.BNCreateLinearViewSingleFunctionLanguageRepresentation(view.handle, _settings))
+
class LinearViewCursor:
- def __init__(self, root_object, handle = None):
+ def __init__(self, root_object, handle=None):
if handle is not None:
self.handle = handle
else:
@@ -529,7 +578,7 @@ class LinearViewCursor:
def seek_to_address(self, addr):
core.BNSeekLinearViewCursorToAddress(self.handle, addr)
- def seek_to_path(self, path, addr = None):
+ def seek_to_path(self, path, addr=None):
if isinstance(path, LinearViewCursor):
if addr is None:
return core.BNSeekLinearViewCursorToCursorPath(self.handle, path.handle)
@@ -551,7 +600,7 @@ class LinearViewCursor:
return core.BNLinearViewCursorNext(self.handle)
@staticmethod
- def _make_lines(lines, count:int) -> List['LinearDisassemblyLine']:
+ def _make_lines(lines, count: int) -> List['LinearDisassemblyLine']:
assert lines is not None, "core returned None for LinearDisassembly lines"
try:
result = []
@@ -566,8 +615,10 @@ class LinearViewCursor:
block = basicblock.BasicBlock(core_block, None)
color = highlight.HighlightColor._from_core_struct(lines[i].contents.highlight)
addr = lines[i].contents.addr
- tokens = _function.InstructionTextToken._from_core_struct(lines[i].contents.tokens, lines[i].contents.count)
- contents = _function.DisassemblyTextLine(tokens, addr, color = color)
+ tokens = _function.InstructionTextToken._from_core_struct(
+ lines[i].contents.tokens, lines[i].contents.count
+ )
+ contents = _function.DisassemblyTextLine(tokens, addr, color=color)
result.append(LinearDisassemblyLine(lines[i].type, func, block, contents))
return result
finally:
@@ -579,7 +630,7 @@ class LinearViewCursor:
return LinearViewCursor._make_lines(core.BNGetLinearViewCursorLines(self.handle, count), count.value)
def duplicate(self):
- return LinearViewCursor(None, handle = core.BNDuplicateLinearViewCursor(self.handle))
+ return LinearViewCursor(None, handle=core.BNDuplicateLinearViewCursor(self.handle))
@staticmethod
def compare(a, b):
diff --git a/python/log.py b/python/log.py
index 21e3bae2..04d8693a 100644
--- a/python/log.py
+++ b/python/log.py
@@ -18,12 +18,10 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
-
# Binary Ninja components
from . import _binaryninjacore as core
from .enums import LogLevel
-
_output_to_log = False
@@ -163,7 +161,7 @@ def log_to_stderr(min_level):
core.BNLogToStderr(min_level)
-def log_to_file(min_level, path, append = False):
+def log_to_file(min_level, path, append=False):
"""
``log_to_file`` redirects minimum log level to a file named ``path``, optionally appending rather than overwriting.
diff --git a/python/lowlevelil.py b/python/lowlevelil.py
index 87eb5a34..2849c2bf 100644
--- a/python/lowlevelil.py
+++ b/python/lowlevelil.py
@@ -26,7 +26,7 @@ from dataclasses import dataclass
# Binary Ninja components
from .enums import LowLevelILOperation, LowLevelILFlagCondition, DataFlowQueryOption, FunctionGraphType
from . import _binaryninjacore as core
-from . import basicblock #required for LowLevelILBasicBlock
+from . import basicblock #required for LowLevelILBasicBlock
from . import function
from . import mediumlevelil
from . import highlevelil
@@ -36,9 +36,11 @@ from . import binaryview
from . import architecture
from . import types
from .interaction import show_graph_report
-from .commonil import (BaseILInstruction, Constant, BinaryOperation, Tailcall, UnaryOperation, Comparison, SSA,
- Phi, FloatingPoint, ControlFlow, Terminal, Syscall, Localcall, StackOperation, Return,
- Signed, Arithmetic, Carry, DoublePrecision, Memory, Load, Store, RegisterStack, SetReg)
+from .commonil import (
+ BaseILInstruction, Constant, BinaryOperation, Tailcall, UnaryOperation, Comparison, SSA, Phi, FloatingPoint,
+ ControlFlow, Terminal, Syscall, Localcall, StackOperation, Return, Signed, Arithmetic, Carry, DoublePrecision,
+ Memory, Load, Store, RegisterStack, SetReg
+)
ExpressionIndex = NewType('ExpressionIndex', int)
InstructionIndex = NewType('InstructionIndex', int)
@@ -48,45 +50,27 @@ InstructionOrExpression = Union['LowLevelILInstruction', Index]
ILRegisterType = Union[str, 'ILRegister', int]
LLILInstructionsType = Generator['LowLevelILInstruction', None, None]
OperandsType = Tuple[ExpressionIndex, ExpressionIndex, ExpressionIndex, ExpressionIndex]
-LowLevelILOperandType = Union[
- 'LowLevelILOperationAndSize',
- 'ILRegister',
- 'ILFlag',
- 'ILIntrinsic',
- 'ILRegisterStack',
- int,
- Dict[int, int],
- float,
- 'LowLevelILInstruction',
- Dict['architecture.RegisterStackName', int],
- 'SSAFlag',
- 'SSARegister',
- 'SSARegisterStack',
- 'ILSemanticFlagClass',
- 'ILSemanticFlagGroup',
- 'LowLevelILFlagCondition',
- List[int],
- List['LowLevelILInstruction'],
- List[Union['ILFlag', 'ILRegister']],
- List['SSARegister'],
- List['SSARegisterStack'],
- List['SSAFlag'],
- List['SSARegisterOrFlag'],
- None
-]
+LowLevelILOperandType = Union['LowLevelILOperationAndSize', 'ILRegister', 'ILFlag', 'ILIntrinsic', 'ILRegisterStack',
+ int, Dict[int, int], float, 'LowLevelILInstruction',
+ Dict['architecture.RegisterStackName', int], 'SSAFlag', 'SSARegister', 'SSARegisterStack',
+ 'ILSemanticFlagClass', 'ILSemanticFlagGroup', 'LowLevelILFlagCondition', List[int],
+ List['LowLevelILInstruction'], List[Union['ILFlag', 'ILRegister']], List['SSARegister'],
+ List['SSARegisterStack'], List['SSAFlag'], List['SSARegisterOrFlag'], None]
+
class LowLevelILLabel:
- def __init__(self, handle:core.BNLowLevelILLabel=None):
+ def __init__(self, handle: core.BNLowLevelILLabel = None):
if handle is None:
self.handle = (core.BNLowLevelILLabel * 1)()
core.BNLowLevelILInitLabel(self.handle)
else:
self.handle = handle
+
@dataclass(frozen=True)
class ILRegister:
- arch:'architecture.Architecture'
- index:'architecture.RegisterIndex'
+ arch: 'architecture.Architecture'
+ index: 'architecture.RegisterIndex'
def __repr__(self):
return f"<reg {self.name}>"
@@ -124,8 +108,8 @@ class ILRegister:
@dataclass(frozen=True)
class ILRegisterStack:
- arch:'architecture.Architecture'
- index:'architecture.RegisterStackIndex'
+ arch: 'architecture.Architecture'
+ index: 'architecture.RegisterStackIndex'
def __repr__(self):
return f"<reg-stack {self.name}>"
@@ -147,8 +131,8 @@ class ILRegisterStack:
@dataclass(frozen=True)
class ILFlag:
- arch:'architecture.Architecture'
- index:'architecture.FlagIndex'
+ arch: 'architecture.Architecture'
+ index: 'architecture.FlagIndex'
def __repr__(self):
return f"<flag {self.name}>"
@@ -173,8 +157,8 @@ class ILFlag:
@dataclass(frozen=True)
class ILSemanticFlagClass:
- arch:'architecture.Architecture'
- index:'architecture.SemanticClassIndex'
+ arch: 'architecture.Architecture'
+ index: 'architecture.SemanticClassIndex'
def __repr__(self):
return self.name
@@ -192,8 +176,8 @@ class ILSemanticFlagClass:
@dataclass(frozen=True)
class ILSemanticFlagGroup:
- arch:'architecture.Architecture'
- index:'architecture.SemanticGroupIndex'
+ arch: 'architecture.Architecture'
+ index: 'architecture.SemanticGroupIndex'
def __repr__(self):
return self.name
@@ -211,8 +195,8 @@ class ILSemanticFlagGroup:
@dataclass(frozen=True)
class ILIntrinsic:
- arch:'architecture.Architecture'
- index:'architecture.IntrinsicIndex'
+ arch: 'architecture.Architecture'
+ index: 'architecture.IntrinsicIndex'
def __repr__(self):
return self.name
@@ -237,8 +221,8 @@ class ILIntrinsic:
@dataclass(frozen=True)
class SSARegister:
- reg:ILRegister
- version:int
+ reg: ILRegister
+ version: int
def __repr__(self):
return f"<ssa {self.reg} version {self.version}>"
@@ -246,8 +230,8 @@ class SSARegister:
@dataclass(frozen=True)
class SSARegisterStack:
- reg_stack:ILRegisterStack
- version:int
+ reg_stack: ILRegisterStack
+ version: int
def __repr__(self):
return f"<ssa {self.reg_stack} version {self.version}>"
@@ -255,8 +239,8 @@ class SSARegisterStack:
@dataclass(frozen=True)
class SSAFlag:
- flag:ILFlag
- version:int
+ flag: ILFlag
+ version: int
def __repr__(self):
return f"<ssa {self.flag} version {self.version}>"
@@ -264,8 +248,8 @@ class SSAFlag:
@dataclass(frozen=True)
class SSARegisterOrFlag:
- reg_or_flag:Union[ILRegister, ILFlag]
- version:int
+ reg_or_flag: Union[ILRegister, ILFlag]
+ version: int
def __repr__(self):
return f"<ssa {self.reg_or_flag} version {self.version}>"
@@ -273,8 +257,8 @@ class SSARegisterOrFlag:
@dataclass(frozen=True)
class LowLevelILOperationAndSize:
- operation:'LowLevelILOperation'
- size:int
+ operation: 'LowLevelILOperation'
+ size: int
def __repr__(self):
if self.size == 0:
@@ -284,20 +268,22 @@ class LowLevelILOperationAndSize:
@dataclass(frozen=True)
class CoreLowLevelILInstruction:
- operation:LowLevelILOperation
- size:int
- flags:int
- source_operand:ExpressionIndex
- operands:OperandsType
- address:int
+ operation: LowLevelILOperation
+ size: int
+ flags: int
+ source_operand: ExpressionIndex
+ operands: OperandsType
+ address: int
@classmethod
- def from_BNLowLevelILInstruction(cls, instr:core.BNLowLevelILInstruction) -> 'CoreLowLevelILInstruction':
- operands:OperandsType = (ExpressionIndex(instr.operands[0]),
- ExpressionIndex(instr.operands[1]),
- ExpressionIndex(instr.operands[2]),
- ExpressionIndex(instr.operands[3]))
- return cls(LowLevelILOperation(instr.operation), instr.size, instr.flags, instr.sourceOperand, operands, instr.address)
+ def from_BNLowLevelILInstruction(cls, instr: core.BNLowLevelILInstruction) -> 'CoreLowLevelILInstruction':
+ operands: OperandsType = (
+ ExpressionIndex(instr.operands[0]), ExpressionIndex(instr.operands[1]), ExpressionIndex(instr.operands[2]),
+ ExpressionIndex(instr.operands[3])
+ )
+ return cls(
+ LowLevelILOperation(instr.operation), instr.size, instr.flags, instr.sourceOperand, operands, instr.address
+ )
@dataclass(frozen=True)
@@ -308,146 +294,167 @@ class LowLevelILInstruction(BaseILInstruction):
Infix notation is thus more natural to read than other notations (e.g. x86 ``mov eax, 0`` vs. LLIL ``eax = 0``).
"""
- function:'LowLevelILFunction'
- expr_index:ExpressionIndex
- instr:CoreLowLevelILInstruction
- instr_index:Optional[InstructionIndex]
- ILOperations:ClassVar[Dict[LowLevelILOperation, List[Tuple[str,str]]]] = {
- LowLevelILOperation.LLIL_NOP: [],
- LowLevelILOperation.LLIL_SET_REG: [("dest", "reg"), ("src", "expr")],
- LowLevelILOperation.LLIL_SET_REG_SPLIT: [("hi", "reg"), ("lo", "reg"), ("src", "expr")],
- LowLevelILOperation.LLIL_SET_REG_STACK_REL: [("stack", "reg_stack"), ("dest", "expr"), ("src", "expr")],
- LowLevelILOperation.LLIL_REG_STACK_PUSH: [("stack", "reg_stack"), ("src", "expr")],
- LowLevelILOperation.LLIL_SET_FLAG: [("dest", "flag"), ("src", "expr")],
- LowLevelILOperation.LLIL_LOAD: [("src", "expr")],
- LowLevelILOperation.LLIL_STORE: [("dest", "expr"), ("src", "expr")],
- LowLevelILOperation.LLIL_PUSH: [("src", "expr")],
- LowLevelILOperation.LLIL_POP: [],
- LowLevelILOperation.LLIL_REG: [("src", "reg")],
- LowLevelILOperation.LLIL_REG_SPLIT: [("hi", "reg"), ("lo", "reg")],
- LowLevelILOperation.LLIL_REG_STACK_REL: [("stack", "reg_stack"), ("src", "expr")],
- LowLevelILOperation.LLIL_REG_STACK_POP: [("stack", "reg_stack")],
- LowLevelILOperation.LLIL_REG_STACK_FREE_REG: [("dest", "reg")],
- LowLevelILOperation.LLIL_REG_STACK_FREE_REL: [("stack", "reg_stack"), ("dest", "expr")],
- LowLevelILOperation.LLIL_CONST: [("constant", "int")],
- LowLevelILOperation.LLIL_CONST_PTR: [("constant", "int")],
- LowLevelILOperation.LLIL_EXTERN_PTR: [("constant", "int"), ("offset", "int")],
- LowLevelILOperation.LLIL_FLOAT_CONST: [("constant", "float")],
- LowLevelILOperation.LLIL_FLAG: [("src", "flag")],
- LowLevelILOperation.LLIL_FLAG_BIT: [("src", "flag"), ("bit", "int")],
- LowLevelILOperation.LLIL_ADD: [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_ADC: [("left", "expr"), ("right", "expr"), ("carry", "expr")],
- LowLevelILOperation.LLIL_SUB: [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_SBB: [("left", "expr"), ("right", "expr"), ("carry", "expr")],
- LowLevelILOperation.LLIL_AND: [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_OR: [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_XOR: [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_LSL: [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_LSR: [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_ASR: [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_ROL: [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_RLC: [("left", "expr"), ("right", "expr"), ("carry", "expr")],
- LowLevelILOperation.LLIL_ROR: [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_RRC: [("left", "expr"), ("right", "expr"), ("carry", "expr")],
- LowLevelILOperation.LLIL_MUL: [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_MULU_DP: [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_MULS_DP: [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_DIVU: [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_DIVU_DP: [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_DIVS: [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_DIVS_DP: [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_MODU: [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_MODU_DP: [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_MODS: [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_MODS_DP: [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_NEG: [("src", "expr")],
- LowLevelILOperation.LLIL_NOT: [("src", "expr")],
- LowLevelILOperation.LLIL_SX: [("src", "expr")],
- LowLevelILOperation.LLIL_ZX: [("src", "expr")],
- LowLevelILOperation.LLIL_LOW_PART: [("src", "expr")],
- LowLevelILOperation.LLIL_JUMP: [("dest", "expr")],
- LowLevelILOperation.LLIL_JUMP_TO: [("dest", "expr"), ("targets", "target_map")],
- LowLevelILOperation.LLIL_CALL: [("dest", "expr")],
- LowLevelILOperation.LLIL_CALL_STACK_ADJUST: [("dest", "expr"), ("stack_adjustment", "int"), ("reg_stack_adjustments", "reg_stack_adjust")],
- LowLevelILOperation.LLIL_TAILCALL: [("dest", "expr")],
- LowLevelILOperation.LLIL_RET: [("dest", "expr")],
- LowLevelILOperation.LLIL_NORET: [],
- LowLevelILOperation.LLIL_IF: [("condition", "expr"), ("true", "int"), ("false", "int")],
- LowLevelILOperation.LLIL_GOTO: [("dest", "int")],
- LowLevelILOperation.LLIL_FLAG_COND: [("condition", "cond"), ("semantic_class", "sem_class")],
- LowLevelILOperation.LLIL_FLAG_GROUP: [("semantic_group", "sem_group")],
- LowLevelILOperation.LLIL_CMP_E: [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_CMP_NE: [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_CMP_SLT: [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_CMP_ULT: [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_CMP_SLE: [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_CMP_ULE: [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_CMP_SGE: [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_CMP_UGE: [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_CMP_SGT: [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_CMP_UGT: [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_TEST_BIT: [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_BOOL_TO_INT: [("src", "expr")],
- LowLevelILOperation.LLIL_ADD_OVERFLOW: [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_SYSCALL: [],
- LowLevelILOperation.LLIL_INTRINSIC: [("output", "reg_or_flag_list"), ("intrinsic", "intrinsic"), ("param", "expr")],
- LowLevelILOperation.LLIL_INTRINSIC_SSA: [("output", "reg_or_flag_ssa_list"), ("intrinsic", "intrinsic"), ("param", "expr")],
- LowLevelILOperation.LLIL_BP: [],
- LowLevelILOperation.LLIL_TRAP: [("vector", "int")],
- LowLevelILOperation.LLIL_UNDEF: [],
- LowLevelILOperation.LLIL_UNIMPL: [],
- LowLevelILOperation.LLIL_UNIMPL_MEM: [("src", "expr")],
- LowLevelILOperation.LLIL_FADD: [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_FSUB: [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_FMUL: [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_FDIV: [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_FSQRT: [("src", "expr")],
- LowLevelILOperation.LLIL_FNEG: [("src", "expr")],
- LowLevelILOperation.LLIL_FABS: [("src", "expr")],
- LowLevelILOperation.LLIL_FLOAT_TO_INT: [("src", "expr")],
- LowLevelILOperation.LLIL_INT_TO_FLOAT: [("src", "expr")],
- LowLevelILOperation.LLIL_FLOAT_CONV: [("src", "expr")],
- LowLevelILOperation.LLIL_ROUND_TO_INT: [("src", "expr")],
- LowLevelILOperation.LLIL_FLOOR: [("src", "expr")],
- LowLevelILOperation.LLIL_CEIL: [("src", "expr")],
- LowLevelILOperation.LLIL_FTRUNC: [("src", "expr")],
- LowLevelILOperation.LLIL_FCMP_E: [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_FCMP_NE: [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_FCMP_LT: [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_FCMP_LE: [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_FCMP_GE: [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_FCMP_GT: [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_FCMP_O: [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_FCMP_UO: [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_SET_REG_SSA: [("dest", "reg_ssa"), ("src", "expr")],
- LowLevelILOperation.LLIL_SET_REG_SSA_PARTIAL: [("full_reg", "reg_ssa"), ("dest", "reg"), ("src", "expr")],
- LowLevelILOperation.LLIL_SET_REG_SPLIT_SSA: [("hi", "expr"), ("lo", "expr"), ("src", "expr")],
- LowLevelILOperation.LLIL_SET_REG_STACK_REL_SSA: [("stack", "expr"), ("dest", "expr"), ("top", "expr"), ("src", "expr")],
- LowLevelILOperation.LLIL_SET_REG_STACK_ABS_SSA: [("stack", "expr"), ("dest", "reg"), ("src", "expr")],
- LowLevelILOperation.LLIL_REG_SPLIT_DEST_SSA: [("dest", "reg_ssa")],
- LowLevelILOperation.LLIL_REG_STACK_DEST_SSA: [("src", "reg_stack_ssa_dest_and_src")],
- LowLevelILOperation.LLIL_REG_SSA: [("src", "reg_ssa")],
- LowLevelILOperation.LLIL_REG_SSA_PARTIAL: [("full_reg", "reg_ssa"), ("src", "reg")],
- LowLevelILOperation.LLIL_REG_SPLIT_SSA: [("hi", "reg_ssa"), ("lo", "reg_ssa")],
- LowLevelILOperation.LLIL_REG_STACK_REL_SSA: [("stack", "reg_stack_ssa"), ("src", "expr"), ("top", "expr")],
- LowLevelILOperation.LLIL_REG_STACK_ABS_SSA: [("stack", "reg_stack_ssa"), ("src", "reg")],
- LowLevelILOperation.LLIL_REG_STACK_FREE_REL_SSA: [("stack", "expr"), ("dest", "expr"), ("top", "expr")],
- LowLevelILOperation.LLIL_REG_STACK_FREE_ABS_SSA: [("stack", "expr"), ("dest", "reg")],
- LowLevelILOperation.LLIL_SET_FLAG_SSA: [("dest", "flag_ssa"), ("src", "expr")],
- LowLevelILOperation.LLIL_FLAG_SSA: [("src", "flag_ssa")],
- LowLevelILOperation.LLIL_FLAG_BIT_SSA: [("src", "flag_ssa"), ("bit", "int")],
- LowLevelILOperation.LLIL_CALL_SSA: [("output", "expr"), ("dest", "expr"), ("stack", "expr"), ("param", "expr")],
- LowLevelILOperation.LLIL_SYSCALL_SSA: [("output", "expr"), ("stack", "expr"), ("param", "expr")],
- LowLevelILOperation.LLIL_TAILCALL_SSA: [("output", "expr"), ("dest", "expr"), ("stack", "expr"), ("param", "expr")],
- LowLevelILOperation.LLIL_CALL_OUTPUT_SSA: [("dest_memory", "int"), ("dest", "reg_ssa_list")],
- LowLevelILOperation.LLIL_CALL_STACK_SSA: [("src", "reg_ssa"), ("src_memory", "int")],
- LowLevelILOperation.LLIL_CALL_PARAM: [("src", "expr_list")],
- LowLevelILOperation.LLIL_LOAD_SSA: [("src", "expr"), ("src_memory", "int")],
- LowLevelILOperation.LLIL_STORE_SSA: [("dest", "expr"), ("dest_memory", "int"), ("src_memory", "int"), ("src", "expr")],
- LowLevelILOperation.LLIL_REG_PHI: [("dest", "reg_ssa"), ("src", "reg_ssa_list")],
- LowLevelILOperation.LLIL_REG_STACK_PHI: [("dest", "reg_stack_ssa"), ("src", "reg_stack_ssa_list")],
- LowLevelILOperation.LLIL_FLAG_PHI: [("dest", "flag_ssa"), ("src", "flag_ssa_list")],
- LowLevelILOperation.LLIL_MEM_PHI: [("dest_memory", "int"), ("src_memory", "int_list")]
+ function: 'LowLevelILFunction'
+ expr_index: ExpressionIndex
+ instr: CoreLowLevelILInstruction
+ instr_index: Optional[InstructionIndex]
+ ILOperations: ClassVar[Dict[LowLevelILOperation, List[Tuple[str, str]]]] = {
+ LowLevelILOperation.LLIL_NOP: [], LowLevelILOperation.LLIL_SET_REG: [("dest", "reg"), ("src", "expr")],
+ LowLevelILOperation.LLIL_SET_REG_SPLIT: [("hi", "reg"), ("lo", "reg"),
+ ("src", "expr")], LowLevelILOperation.LLIL_SET_REG_STACK_REL: [
+ ("stack", "reg_stack"), ("dest", "expr"), ("src", "expr")
+ ], LowLevelILOperation.LLIL_REG_STACK_PUSH: [("stack", "reg_stack"),
+ ("src", "expr")],
+ LowLevelILOperation.LLIL_SET_FLAG: [("dest", "flag"), ("src", "expr")], LowLevelILOperation.LLIL_LOAD: [
+ ("src", "expr")
+ ], LowLevelILOperation.LLIL_STORE: [("dest", "expr"),
+ ("src", "expr")], LowLevelILOperation.LLIL_PUSH: [("src", "expr")],
+ LowLevelILOperation.LLIL_POP: [], LowLevelILOperation.LLIL_REG: [("src", "reg")],
+ LowLevelILOperation.LLIL_REG_SPLIT: [("hi", "reg"), ("lo", "reg")], LowLevelILOperation.LLIL_REG_STACK_REL: [
+ ("stack", "reg_stack"), ("src", "expr")
+ ], LowLevelILOperation.LLIL_REG_STACK_POP: [("stack", "reg_stack")],
+ LowLevelILOperation.LLIL_REG_STACK_FREE_REG: [("dest", "reg")], LowLevelILOperation.LLIL_REG_STACK_FREE_REL: [
+ ("stack", "reg_stack"), ("dest", "expr")
+ ], LowLevelILOperation.LLIL_CONST: [("constant", "int")], LowLevelILOperation.LLIL_CONST_PTR: [
+ ("constant", "int")
+ ], LowLevelILOperation.LLIL_EXTERN_PTR: [
+ ("constant", "int"), ("offset", "int")
+ ], LowLevelILOperation.LLIL_FLOAT_CONST: [("constant", "float")], LowLevelILOperation.LLIL_FLAG: [
+ ("src", "flag")
+ ], LowLevelILOperation.LLIL_FLAG_BIT: [("src", "flag"), ("bit", "int")], LowLevelILOperation.LLIL_ADD: [
+ ("left", "expr"), ("right", "expr")
+ ], LowLevelILOperation.LLIL_ADC: [
+ ("left", "expr"), ("right", "expr"), ("carry", "expr")
+ ], LowLevelILOperation.LLIL_SUB: [("left", "expr"), ("right", "expr")], LowLevelILOperation.LLIL_SBB: [
+ ("left", "expr"), ("right", "expr"), ("carry", "expr")
+ ], LowLevelILOperation.LLIL_AND: [("left", "expr"), ("right", "expr")], LowLevelILOperation.LLIL_OR: [
+ ("left", "expr"), ("right", "expr")
+ ], LowLevelILOperation.LLIL_XOR: [("left", "expr"), ("right", "expr")], LowLevelILOperation.LLIL_LSL: [
+ ("left", "expr"), ("right", "expr")
+ ], LowLevelILOperation.LLIL_LSR: [("left", "expr"), ("right", "expr")], LowLevelILOperation.LLIL_ASR: [
+ ("left", "expr"), ("right", "expr")
+ ], LowLevelILOperation.LLIL_ROL: [("left", "expr"), ("right", "expr")], LowLevelILOperation.LLIL_RLC: [
+ ("left", "expr"), ("right", "expr"), ("carry", "expr")
+ ], LowLevelILOperation.LLIL_ROR: [("left", "expr"), ("right", "expr")], LowLevelILOperation.LLIL_RRC: [
+ ("left", "expr"), ("right", "expr"), ("carry", "expr")
+ ], LowLevelILOperation.LLIL_MUL: [("left", "expr"), ("right", "expr")], LowLevelILOperation.LLIL_MULU_DP: [
+ ("left", "expr"), ("right", "expr")
+ ], LowLevelILOperation.LLIL_MULS_DP: [("left", "expr"), ("right", "expr")], LowLevelILOperation.LLIL_DIVU: [
+ ("left", "expr"), ("right", "expr")
+ ], LowLevelILOperation.LLIL_DIVU_DP: [("left", "expr"), ("right", "expr")], LowLevelILOperation.LLIL_DIVS: [
+ ("left", "expr"), ("right", "expr")
+ ], LowLevelILOperation.LLIL_DIVS_DP: [("left", "expr"), ("right", "expr")], LowLevelILOperation.LLIL_MODU: [
+ ("left", "expr"), ("right", "expr")
+ ], LowLevelILOperation.LLIL_MODU_DP: [("left", "expr"), ("right", "expr")], LowLevelILOperation.LLIL_MODS: [
+ ("left", "expr"), ("right", "expr")
+ ], LowLevelILOperation.LLIL_MODS_DP: [("left", "expr"), ("right", "expr")], LowLevelILOperation.LLIL_NEG: [
+ ("src", "expr")
+ ], LowLevelILOperation.LLIL_NOT: [("src", "expr")], LowLevelILOperation.LLIL_SX: [
+ ("src", "expr")
+ ], LowLevelILOperation.LLIL_ZX: [("src", "expr")], LowLevelILOperation.LLIL_LOW_PART: [
+ ("src", "expr")
+ ], LowLevelILOperation.LLIL_JUMP: [("dest", "expr")], LowLevelILOperation.LLIL_JUMP_TO: [
+ ("dest", "expr"), ("targets", "target_map")
+ ], LowLevelILOperation.LLIL_CALL: [("dest", "expr")], LowLevelILOperation.LLIL_CALL_STACK_ADJUST: [
+ ("dest", "expr"), ("stack_adjustment", "int"), ("reg_stack_adjustments", "reg_stack_adjust")
+ ], LowLevelILOperation.LLIL_TAILCALL: [("dest", "expr")], LowLevelILOperation.LLIL_RET: [
+ ("dest", "expr")
+ ], LowLevelILOperation.LLIL_NORET: [], LowLevelILOperation.LLIL_IF: [
+ ("condition", "expr"), ("true", "int"), ("false", "int")
+ ], LowLevelILOperation.LLIL_GOTO: [("dest", "int")], LowLevelILOperation.LLIL_FLAG_COND: [
+ ("condition", "cond"), ("semantic_class", "sem_class")
+ ], LowLevelILOperation.LLIL_FLAG_GROUP: [("semantic_group", "sem_group")], LowLevelILOperation.LLIL_CMP_E: [
+ ("left", "expr"), ("right", "expr")
+ ], LowLevelILOperation.LLIL_CMP_NE: [("left", "expr"), ("right", "expr")], LowLevelILOperation.LLIL_CMP_SLT: [
+ ("left", "expr"), ("right", "expr")
+ ], LowLevelILOperation.LLIL_CMP_ULT: [("left", "expr"), ("right", "expr")], LowLevelILOperation.LLIL_CMP_SLE: [
+ ("left", "expr"), ("right", "expr")
+ ], LowLevelILOperation.LLIL_CMP_ULE: [("left", "expr"), ("right", "expr")], LowLevelILOperation.LLIL_CMP_SGE: [
+ ("left", "expr"), ("right", "expr")
+ ], LowLevelILOperation.LLIL_CMP_UGE: [("left", "expr"), ("right", "expr")], LowLevelILOperation.LLIL_CMP_SGT: [
+ ("left", "expr"), ("right", "expr")
+ ], LowLevelILOperation.LLIL_CMP_UGT: [("left", "expr"), ("right", "expr")], LowLevelILOperation.LLIL_TEST_BIT: [
+ ("left", "expr"), ("right", "expr")
+ ], LowLevelILOperation.LLIL_BOOL_TO_INT: [("src", "expr")], LowLevelILOperation.LLIL_ADD_OVERFLOW: [
+ ("left", "expr"), ("right", "expr")
+ ], LowLevelILOperation.LLIL_SYSCALL: [], LowLevelILOperation.LLIL_INTRINSIC: [
+ ("output", "reg_or_flag_list"), ("intrinsic", "intrinsic"), ("param", "expr")
+ ], LowLevelILOperation.LLIL_INTRINSIC_SSA: [
+ ("output", "reg_or_flag_ssa_list"), ("intrinsic", "intrinsic"), ("param", "expr")
+ ], LowLevelILOperation.LLIL_BP: [], LowLevelILOperation.LLIL_TRAP: [("vector", "int")],
+ LowLevelILOperation.LLIL_UNDEF: [], LowLevelILOperation.LLIL_UNIMPL: [], LowLevelILOperation.LLIL_UNIMPL_MEM: [
+ ("src", "expr")
+ ], LowLevelILOperation.LLIL_FADD: [("left", "expr"), ("right", "expr")], LowLevelILOperation.LLIL_FSUB: [
+ ("left", "expr"), ("right", "expr")
+ ], LowLevelILOperation.LLIL_FMUL: [("left", "expr"), ("right", "expr")], LowLevelILOperation.LLIL_FDIV: [
+ ("left", "expr"), ("right", "expr")
+ ], LowLevelILOperation.LLIL_FSQRT: [("src", "expr")], LowLevelILOperation.LLIL_FNEG: [
+ ("src", "expr")
+ ], LowLevelILOperation.LLIL_FABS: [("src", "expr")], LowLevelILOperation.LLIL_FLOAT_TO_INT: [
+ ("src", "expr")
+ ], LowLevelILOperation.LLIL_INT_TO_FLOAT: [("src", "expr")], LowLevelILOperation.LLIL_FLOAT_CONV: [
+ ("src", "expr")
+ ], LowLevelILOperation.LLIL_ROUND_TO_INT: [("src", "expr")], LowLevelILOperation.LLIL_FLOOR: [
+ ("src", "expr")
+ ], LowLevelILOperation.LLIL_CEIL: [("src", "expr")], LowLevelILOperation.LLIL_FTRUNC: [
+ ("src", "expr")
+ ], LowLevelILOperation.LLIL_FCMP_E: [("left", "expr"), ("right", "expr")], LowLevelILOperation.LLIL_FCMP_NE: [
+ ("left", "expr"), ("right", "expr")
+ ], LowLevelILOperation.LLIL_FCMP_LT: [("left", "expr"), ("right", "expr")], LowLevelILOperation.LLIL_FCMP_LE: [
+ ("left", "expr"), ("right", "expr")
+ ], LowLevelILOperation.LLIL_FCMP_GE: [("left", "expr"), ("right", "expr")], LowLevelILOperation.LLIL_FCMP_GT: [
+ ("left", "expr"), ("right", "expr")
+ ], LowLevelILOperation.LLIL_FCMP_O: [("left", "expr"), ("right", "expr")], LowLevelILOperation.LLIL_FCMP_UO: [
+ ("left", "expr"), ("right", "expr")
+ ], LowLevelILOperation.LLIL_SET_REG_SSA: [("dest", "reg_ssa"),
+ ("src", "expr")], LowLevelILOperation.LLIL_SET_REG_SSA_PARTIAL: [
+ ("full_reg", "reg_ssa"), ("dest", "reg"), ("src", "expr")
+ ], LowLevelILOperation.LLIL_SET_REG_SPLIT_SSA: [
+ ("hi", "expr"), ("lo", "expr"), ("src", "expr")
+ ], LowLevelILOperation.LLIL_SET_REG_STACK_REL_SSA: [
+ ("stack", "expr"), ("dest", "expr"), ("top", "expr"),
+ ("src", "expr")
+ ], LowLevelILOperation.LLIL_SET_REG_STACK_ABS_SSA: [
+ ("stack", "expr"), ("dest", "reg"), ("src", "expr")
+ ], LowLevelILOperation.LLIL_REG_SPLIT_DEST_SSA: [("dest", "reg_ssa")],
+ LowLevelILOperation.LLIL_REG_STACK_DEST_SSA: [
+ ("src", "reg_stack_ssa_dest_and_src")
+ ], LowLevelILOperation.LLIL_REG_SSA: [("src", "reg_ssa")], LowLevelILOperation.LLIL_REG_SSA_PARTIAL: [
+ ("full_reg", "reg_ssa"), ("src", "reg")
+ ], LowLevelILOperation.LLIL_REG_SPLIT_SSA: [("hi", "reg_ssa"),
+ ("lo", "reg_ssa")], LowLevelILOperation.LLIL_REG_STACK_REL_SSA: [
+ ("stack", "reg_stack_ssa"), ("src", "expr"), ("top", "expr")
+ ], LowLevelILOperation.LLIL_REG_STACK_ABS_SSA: [
+ ("stack", "reg_stack_ssa"), ("src", "reg")
+ ], LowLevelILOperation.LLIL_REG_STACK_FREE_REL_SSA: [
+ ("stack", "expr"), ("dest", "expr"), ("top", "expr")
+ ], LowLevelILOperation.LLIL_REG_STACK_FREE_ABS_SSA: [
+ ("stack", "expr"), ("dest", "reg")
+ ], LowLevelILOperation.LLIL_SET_FLAG_SSA: [("dest", "flag_ssa"),
+ ("src", "expr")],
+ LowLevelILOperation.LLIL_FLAG_SSA: [("src", "flag_ssa")], LowLevelILOperation.LLIL_FLAG_BIT_SSA: [
+ ("src", "flag_ssa"), ("bit", "int")
+ ], LowLevelILOperation.LLIL_CALL_SSA: [("output", "expr"), ("dest", "expr"), ("stack", "expr"),
+ ("param", "expr")], LowLevelILOperation.LLIL_SYSCALL_SSA: [
+ ("output", "expr"), ("stack", "expr"), ("param", "expr")
+ ], LowLevelILOperation.LLIL_TAILCALL_SSA: [
+ ("output", "expr"), ("dest", "expr"), ("stack", "expr"),
+ ("param", "expr")
+ ], LowLevelILOperation.LLIL_CALL_OUTPUT_SSA: [
+ ("dest_memory", "int"), ("dest", "reg_ssa_list")
+ ], LowLevelILOperation.LLIL_CALL_STACK_SSA: [("src", "reg_ssa"),
+ ("src_memory", "int")],
+ LowLevelILOperation.LLIL_CALL_PARAM: [("src", "expr_list")], LowLevelILOperation.LLIL_LOAD_SSA: [
+ ("src", "expr"), ("src_memory", "int")
+ ], LowLevelILOperation.LLIL_STORE_SSA: [("dest", "expr"), ("dest_memory", "int"), ("src_memory", "int"),
+ ("src", "expr")], LowLevelILOperation.LLIL_REG_PHI: [
+ ("dest", "reg_ssa"), ("src", "reg_ssa_list")
+ ], LowLevelILOperation.LLIL_REG_STACK_PHI: [
+ ("dest", "reg_stack_ssa"), ("src", "reg_stack_ssa_list")
+ ], LowLevelILOperation.LLIL_FLAG_PHI: [
+ ("dest", "flag_ssa"), ("src", "flag_ssa_list")
+ ], LowLevelILOperation.LLIL_MEM_PHI: [("dest_memory", "int"),
+ ("src_memory", "int_list")]
}
@staticmethod
@@ -459,7 +466,9 @@ class LowLevelILInstruction(BaseILInstruction):
show_graph_report("LLIL Class Hierarchy Graph", graph)
@classmethod
- def create(cls, func:'LowLevelILFunction', expr_index:ExpressionIndex, instr_index:Optional[InstructionIndex]=None) -> 'LowLevelILInstruction':
+ def create(
+ cls, func: 'LowLevelILFunction', expr_index: ExpressionIndex, instr_index: Optional[InstructionIndex] = None
+ ) -> 'LowLevelILInstruction':
assert func.arch is not None, "Attempted to create IL instruction with function missing an Architecture"
inst = core.BNGetLowLevelILByIndex(func.handle, expr_index)
assert inst is not None, "core.BNGetLowLevelILByIndex returned None"
@@ -478,32 +487,32 @@ class LowLevelILInstruction(BaseILInstruction):
def __repr__(self):
return f"<llil: {self}>"
- def __eq__(self, other:'LowLevelILInstruction') -> bool:
+ def __eq__(self, other: 'LowLevelILInstruction') -> bool:
if not isinstance(other, LowLevelILInstruction):
return NotImplemented
return self.function == other.function and self.expr_index == other.expr_index
- def __ne__(self, other:'LowLevelILInstruction') -> bool:
+ def __ne__(self, other: 'LowLevelILInstruction') -> bool:
if not isinstance(other, LowLevelILInstruction):
return NotImplemented
return not (self == other)
- def __lt__(self, other:'LowLevelILInstruction') -> bool:
+ def __lt__(self, other: 'LowLevelILInstruction') -> bool:
if not isinstance(other, LowLevelILInstruction):
return NotImplemented
return self.function == other.function and self.expr_index < other.expr_index
- def __le__(self, other:'LowLevelILInstruction') -> bool:
+ def __le__(self, other: 'LowLevelILInstruction') -> bool:
if not isinstance(other, LowLevelILInstruction):
return NotImplemented
return self.function == other.function and self.expr_index <= other.expr_index
- def __gt__(self, other:'LowLevelILInstruction') -> bool:
+ def __gt__(self, other: 'LowLevelILInstruction') -> bool:
if not isinstance(other, LowLevelILInstruction):
return NotImplemented
return self.function == other.function and self.expr_index > other.expr_index
- def __ge__(self, other:'LowLevelILInstruction') -> bool:
+ def __ge__(self, other: 'LowLevelILInstruction') -> bool:
if not isinstance(other, LowLevelILInstruction):
return NotImplemented
return self.function == other.function and self.expr_index >= other.expr_index
@@ -533,8 +542,9 @@ class LowLevelILInstruction(BaseILInstruction):
count = ctypes.c_ulonglong()
assert self.function.arch is not None, f"self.function.arch is None"
tokens = ctypes.POINTER(core.BNInstructionTextToken)()
- result = core.BNGetLowLevelILExprText(self.function.handle, self.function.arch.handle,
- self.expr_index, tokens, count)
+ result = core.BNGetLowLevelILExprText(
+ self.function.handle, self.function.arch.handle, self.expr_index, tokens, count
+ )
assert result, "core.BNGetLowLevelILExprText returned False"
try:
return function.InstructionTextToken._from_core_struct(tokens, count.value)
@@ -555,18 +565,23 @@ class LowLevelILInstruction(BaseILInstruction):
"""SSA form of expression (read-only)"""
ssa_func = self.function.ssa_form
assert ssa_func is not None
- return LowLevelILInstruction.create(ssa_func,
- ExpressionIndex(core.BNGetLowLevelILSSAExprIndex(self.function.handle, self.expr_index)),
- core.BNGetLowLevelILSSAInstructionIndex(self.function.handle, self.instr_index) if self.instr_index is not None else None)
+ return LowLevelILInstruction.create(
+ ssa_func, ExpressionIndex(core.BNGetLowLevelILSSAExprIndex(self.function.handle, self.expr_index)),
+ core.BNGetLowLevelILSSAInstructionIndex(self.function.handle, self.instr_index)
+ if self.instr_index is not None else None
+ )
@property
def non_ssa_form(self) -> 'LowLevelILInstruction':
"""Non-SSA form of expression (read-only)"""
non_ssa_function = self.function.non_ssa_form
assert non_ssa_function is not None
- return LowLevelILInstruction.create(non_ssa_function,
- ExpressionIndex(core.BNGetLowLevelILNonSSAExprIndex(self.function.handle, self.expr_index)),
- core.BNGetLowLevelILNonSSAInstructionIndex(self.function.handle, self.instr_index) if self.instr_index is not None else None)
+ return LowLevelILInstruction.create(
+ non_ssa_function,
+ ExpressionIndex(core.BNGetLowLevelILNonSSAExprIndex(self.function.handle, self.expr_index)),
+ core.BNGetLowLevelILNonSSAInstructionIndex(self.function.handle, self.instr_index)
+ if self.instr_index is not None else None
+ )
@property
def medium_level_il(self) -> Optional['mediumlevelil.MediumLevelILInstruction']:
@@ -644,7 +659,7 @@ class LowLevelILInstruction(BaseILInstruction):
@property
def prefix_operands(self) -> List[LowLevelILOperandType]:
"""All operands in the expression tree in prefix order"""
- result:List[LowLevelILOperandType] = [LowLevelILOperationAndSize(self.instr.operation, self.instr.size)]
+ result: List[LowLevelILOperandType] = [LowLevelILOperationAndSize(self.instr.operation, self.instr.size)]
for operand in self.operands:
if isinstance(operand, LowLevelILInstruction):
assert id(self) != id(operand), f"circular reference {operand}({repr(operand)}) is {self}({repr(self)})"
@@ -656,7 +671,7 @@ class LowLevelILInstruction(BaseILInstruction):
@property
def postfix_operands(self) -> List[LowLevelILOperandType]:
"""All operands in the expression tree in postfix order"""
- result:List[LowLevelILOperandType] = []
+ result: List[LowLevelILOperandType] = []
for operand in self.operands:
if isinstance(operand, LowLevelILInstruction):
assert id(self) != id(operand), f"circular reference {operand}({repr(operand)}) is {self}({repr(self)})"
@@ -667,7 +682,7 @@ class LowLevelILInstruction(BaseILInstruction):
return result
@staticmethod
- def _make_options_array(options:Optional[List[DataFlowQueryOption]]):
+ def _make_options_array(options: Optional[List[DataFlowQueryOption]]):
if options is None:
options = []
idx = 0
@@ -677,50 +692,56 @@ class LowLevelILInstruction(BaseILInstruction):
idx += 1
return option_array, len(options)
- def get_possible_values(self, options:Optional[List[DataFlowQueryOption]]=None) -> variable.PossibleValueSet:
+ def get_possible_values(self, options: Optional[List[DataFlowQueryOption]] = None) -> variable.PossibleValueSet:
option_array, option_size = LowLevelILInstruction._make_options_array(options)
value = core.BNGetLowLevelILPossibleExprValues(self.function.handle, self.expr_index, option_array, option_size)
result = variable.PossibleValueSet(self.function.arch, value)
core.BNFreePossibleValueSet(value)
return result
- def get_reg_value(self, reg:'architecture.RegisterType') -> variable.RegisterValue:
+ def get_reg_value(self, reg: 'architecture.RegisterType') -> variable.RegisterValue:
if self.function.arch is None:
raise Exception("Can not call get_reg_value on function with Architecture set to None")
reg = self.function.arch.get_reg_index(reg)
value = core.BNGetLowLevelILRegisterValueAtInstruction(self.function.handle, reg, self.instr_index)
return variable.RegisterValue.from_BNRegisterValue(value, self.function.arch)
- def get_reg_value_after(self, reg:'architecture.RegisterType') -> variable.RegisterValue:
+ def get_reg_value_after(self, reg: 'architecture.RegisterType') -> variable.RegisterValue:
if self.function.arch is None:
raise Exception("Can not call get_reg_value_after on function with Architecture set to None")
reg = self.function.arch.get_reg_index(reg)
value = core.BNGetLowLevelILRegisterValueAfterInstruction(self.function.handle, reg, self.instr_index)
return variable.RegisterValue.from_BNRegisterValue(value, self.function.arch)
- def get_possible_reg_values(self, reg:'architecture.RegisterType', options:List[DataFlowQueryOption]=None) -> 'variable.PossibleValueSet':
+ def get_possible_reg_values(
+ self, reg: 'architecture.RegisterType', options: List[DataFlowQueryOption] = None
+ ) -> 'variable.PossibleValueSet':
if self.function.arch is None:
raise Exception("Can not call get_possible_reg_values on function with Architecture set to None")
reg = self.function.arch.get_reg_index(reg)
option_array, option_size = LowLevelILInstruction._make_options_array(options)
- value = core.BNGetLowLevelILPossibleRegisterValuesAtInstruction(self.function.handle, reg, self.instr_index,
- option_array, option_size)
+ value = core.BNGetLowLevelILPossibleRegisterValuesAtInstruction(
+ self.function.handle, reg, self.instr_index, option_array, option_size
+ )
result = variable.PossibleValueSet(self.function.arch, value)
core.BNFreePossibleValueSet(value)
return result
- def get_possible_reg_values_after(self, reg:'architecture.RegisterType', options:Optional[List[DataFlowQueryOption]]=None) -> 'variable.PossibleValueSet':
+ def get_possible_reg_values_after(
+ self, reg: 'architecture.RegisterType', options: Optional[List[DataFlowQueryOption]] = None
+ ) -> 'variable.PossibleValueSet':
if self.function.arch is None:
raise Exception("Can not call get_possible_reg_values_after on function with Architecture set to None")
reg = self.function.arch.get_reg_index(reg)
option_array, option_size = LowLevelILInstruction._make_options_array(options)
- value = core.BNGetLowLevelILPossibleRegisterValuesAfterInstruction(self.function.handle, reg, self.instr_index,
- option_array, option_size)
+ value = core.BNGetLowLevelILPossibleRegisterValuesAfterInstruction(
+ self.function.handle, reg, self.instr_index, option_array, option_size
+ )
result = variable.PossibleValueSet(self.function.arch, value)
core.BNFreePossibleValueSet(value)
return result
- def get_flag_value(self, flag:'architecture.FlagType') -> 'variable.RegisterValue':
+ def get_flag_value(self, flag: 'architecture.FlagType') -> 'variable.RegisterValue':
if self.function.arch is None:
raise Exception("Can not call get_flag_value on function with Architecture set to None")
flag = self.function.arch.get_flag_index(flag)
@@ -728,7 +749,7 @@ class LowLevelILInstruction(BaseILInstruction):
result = variable.RegisterValue.from_BNRegisterValue(value, self.function.arch)
return result
- def get_flag_value_after(self, flag:'architecture.FlagType') -> 'variable.RegisterValue':
+ def get_flag_value_after(self, flag: 'architecture.FlagType') -> 'variable.RegisterValue':
if self.function.arch is None:
raise Exception("Can not call get_flag_value_after on function with Architecture set to None")
flag = self.function.arch.get_flag_index(flag)
@@ -736,50 +757,62 @@ class LowLevelILInstruction(BaseILInstruction):
result = variable.RegisterValue.from_BNRegisterValue(value, self.function.arch)
return result
- def get_possible_flag_values(self, flag:'architecture.FlagType', options:Optional[List[DataFlowQueryOption]]=None) -> 'variable.PossibleValueSet':
+ def get_possible_flag_values(
+ self, flag: 'architecture.FlagType', options: Optional[List[DataFlowQueryOption]] = None
+ ) -> 'variable.PossibleValueSet':
if self.function.arch is None:
raise Exception("Can not call get_possible_flag_values on function with Architecture set to None")
flag = self.function.arch.get_flag_index(flag)
option_array, option_size = LowLevelILInstruction._make_options_array(options)
- value = core.BNGetLowLevelILPossibleFlagValuesAtInstruction(self.function.handle, flag, self.instr_index,
- option_array, option_size)
+ value = core.BNGetLowLevelILPossibleFlagValuesAtInstruction(
+ self.function.handle, flag, self.instr_index, option_array, option_size
+ )
result = variable.PossibleValueSet(self.function.arch, value)
core.BNFreePossibleValueSet(value)
return result
- def get_possible_flag_values_after(self, flag:'architecture.FlagType', options:Optional[List[DataFlowQueryOption]]=None) -> 'variable.PossibleValueSet':
+ def get_possible_flag_values_after(
+ self, flag: 'architecture.FlagType', options: Optional[List[DataFlowQueryOption]] = None
+ ) -> 'variable.PossibleValueSet':
if self.function.arch is None:
raise Exception("Can not call get_possible_flag_values_after on function with Architecture set to None")
flag = self.function.arch.get_flag_index(flag)
option_array, option_size = LowLevelILInstruction._make_options_array(options)
- value = core.BNGetLowLevelILPossibleFlagValuesAfterInstruction(self.function.handle, flag, self.instr_index,
- option_array, option_size)
+ value = core.BNGetLowLevelILPossibleFlagValuesAfterInstruction(
+ self.function.handle, flag, self.instr_index, option_array, option_size
+ )
result = variable.PossibleValueSet(self.function.arch, value)
core.BNFreePossibleValueSet(value)
return result
- def get_stack_contents(self, offset:int, size:int) -> 'variable.RegisterValue':
+ def get_stack_contents(self, offset: int, size: int) -> 'variable.RegisterValue':
value = core.BNGetLowLevelILStackContentsAtInstruction(self.function.handle, offset, size, self.instr_index)
result = variable.RegisterValue.from_BNRegisterValue(value, self.function.arch)
return result
- def get_stack_contents_after(self, offset:int, size:int) -> 'variable.RegisterValue':
+ def get_stack_contents_after(self, offset: int, size: int) -> 'variable.RegisterValue':
value = core.BNGetLowLevelILStackContentsAfterInstruction(self.function.handle, offset, size, self.instr_index)
result = variable.RegisterValue.from_BNRegisterValue(value, self.function.arch)
return result
- def get_possible_stack_contents(self, offset:int, size:int, options:Optional[List[DataFlowQueryOption]]=None) -> variable.PossibleValueSet:
+ def get_possible_stack_contents(
+ self, offset: int, size: int, options: Optional[List[DataFlowQueryOption]] = None
+ ) -> variable.PossibleValueSet:
option_array, option_size = LowLevelILInstruction._make_options_array(options)
- value = core.BNGetLowLevelILPossibleStackContentsAtInstruction(self.function.handle, offset, size, self.instr_index,
- option_array, option_size)
+ value = core.BNGetLowLevelILPossibleStackContentsAtInstruction(
+ self.function.handle, offset, size, self.instr_index, option_array, option_size
+ )
result = variable.PossibleValueSet(self.function.arch, value)
core.BNFreePossibleValueSet(value)
return result
- def get_possible_stack_contents_after(self, offset:int, size:int, options:Optional[List[DataFlowQueryOption]]=None) -> variable.PossibleValueSet:
+ def get_possible_stack_contents_after(
+ self, offset: int, size: int, options: Optional[List[DataFlowQueryOption]] = None
+ ) -> variable.PossibleValueSet:
option_array, option_size = LowLevelILInstruction._make_options_array(options)
- value = core.BNGetLowLevelILPossibleStackContentsAfterInstruction(self.function.handle, offset, size, self.instr_index,
- option_array, option_size)
+ value = core.BNGetLowLevelILPossibleStackContentsAfterInstruction(
+ self.function.handle, offset, size, self.instr_index, option_array, option_size
+ )
result = variable.PossibleValueSet(self.function.arch, value)
core.BNFreePossibleValueSet(value)
return result
@@ -788,36 +821,36 @@ class LowLevelILInstruction(BaseILInstruction):
def flags(self) -> Optional['architecture.FlagWriteTypeName']:
return self.function.arch.get_flag_write_type_name(architecture.FlagWriteTypeIndex(self.instr.flags))
- def _get_reg(self, operand_index:int) -> ILRegister:
+ def _get_reg(self, operand_index: int) -> ILRegister:
return ILRegister(self.function.arch, architecture.RegisterIndex(self.instr.operands[operand_index]))
- def _get_flag(self, operand_index:int) -> ILFlag:
+ def _get_flag(self, operand_index: int) -> ILFlag:
return ILFlag(self.function.arch, architecture.FlagIndex(self.instr.operands[operand_index]))
- def _get_intrinsic(self, operand_index:int) -> ILIntrinsic:
+ def _get_intrinsic(self, operand_index: int) -> ILIntrinsic:
return ILIntrinsic(self.function.arch, architecture.IntrinsicIndex(self.instr.operands[operand_index]))
- def _get_reg_stack(self, operand_index:int) -> ILRegisterStack:
+ def _get_reg_stack(self, operand_index: int) -> ILRegisterStack:
return ILRegisterStack(self.function.arch, architecture.RegisterStackIndex(self.instr.operands[operand_index]))
- def _get_int(self, operand_index:int) -> int:
+ def _get_int(self, operand_index: int) -> int:
return (self.instr.operands[operand_index] & ((1 << 63) - 1)) - (self.instr.operands[operand_index] & (1 << 63))
- def _get_target_map(self, operand_index:int) -> Dict[int, int]:
+ def _get_target_map(self, operand_index: int) -> Dict[int, int]:
count = ctypes.c_ulonglong()
operand_list = core.BNLowLevelILGetOperandList(self.function.handle, self.expr_index, operand_index, count)
assert operand_list is not None, "core.BNLowLevelILGetOperandList returned None"
try:
- value:Dict[int, int] = {}
+ value: Dict[int, int] = {}
for j in range(count.value // 2):
key = operand_list[j * 2]
- target = operand_list[(j * 2) + 1]
+ target = operand_list[(j*2) + 1]
value[key] = target
return value
finally:
core.BNLowLevelILFreeOperandList(operand_list)
- def _get_float(self, operand_index:int) -> Union[int, float]:
+ def _get_float(self, operand_index: int) -> Union[int, float]:
if self.instr.size == 4:
return struct.unpack("f", struct.pack("I", self.instr.operands[operand_index] & 0xffffffff))[0]
elif self.instr.size == 8:
@@ -825,18 +858,18 @@ class LowLevelILInstruction(BaseILInstruction):
else:
return self.instr.operands[operand_index]
- def _get_expr(self, operand_index:int) -> 'LowLevelILInstruction':
+ def _get_expr(self, operand_index: int) -> 'LowLevelILInstruction':
return LowLevelILInstruction.create(self.function, self.instr.operands[operand_index], self.instr_index)
- def _get_reg_stack_adjust(self, operand_index:int) -> Dict['architecture.RegisterStackName', int]:
+ def _get_reg_stack_adjust(self, operand_index: int) -> Dict['architecture.RegisterStackName', int]:
count = ctypes.c_ulonglong()
operand_list = core.BNLowLevelILGetOperandList(self.function.handle, self.expr_index, operand_index, count)
assert operand_list is not None, "core.BNLowLevelILGetOperandList returned None"
- result:Dict['architecture.RegisterStackName', int] = {}
+ result: Dict['architecture.RegisterStackName', int] = {}
try:
for j in range(count.value // 2):
reg_stack = operand_list[j * 2]
- adjust = operand_list[(j * 2) + 1]
+ adjust = operand_list[(j*2) + 1]
if adjust & 0x80000000:
adjust |= ~0x80000000
result[self.function.arch.get_reg_stack_name(reg_stack)] = adjust
@@ -844,38 +877,44 @@ class LowLevelILInstruction(BaseILInstruction):
finally:
core.BNLowLevelILFreeOperandList(operand_list)
- def _get_flag_ssa(self, operand_index1:int, operand_index2:int) -> SSAFlag:
- return SSAFlag(ILFlag(self.function.arch, architecture.FlagIndex(self.instr.operands[operand_index1])),
- self.instr.operands[operand_index2])
+ def _get_flag_ssa(self, operand_index1: int, operand_index2: int) -> SSAFlag:
+ return SSAFlag(
+ ILFlag(self.function.arch, architecture.FlagIndex(self.instr.operands[operand_index1])),
+ self.instr.operands[operand_index2]
+ )
- def _get_reg_ssa(self, operand_index1:int, operand_index2:int) -> SSARegister:
- return SSARegister(ILRegister(self.function.arch,
- architecture.RegisterIndex(self.instr.operands[operand_index1])),
- self.instr.operands[operand_index2])
+ def _get_reg_ssa(self, operand_index1: int, operand_index2: int) -> SSARegister:
+ return SSARegister(
+ ILRegister(self.function.arch, architecture.RegisterIndex(self.instr.operands[operand_index1])),
+ self.instr.operands[operand_index2]
+ )
- def _get_reg_stack_ssa(self, operand_index1:int, operand_index2:int) -> SSARegisterStack:
- reg_stack = ILRegisterStack(self.function.arch,
- architecture.RegisterStackIndex(self.instr.operands[operand_index1]))
+ def _get_reg_stack_ssa(self, operand_index1: int, operand_index2: int) -> SSARegisterStack:
+ reg_stack = ILRegisterStack(
+ self.function.arch, architecture.RegisterStackIndex(self.instr.operands[operand_index1])
+ )
return SSARegisterStack(reg_stack, self.instr.operands[operand_index2])
- def _get_sem_class(self, operand_index:int) -> Optional[ILSemanticFlagClass]:
+ def _get_sem_class(self, operand_index: int) -> Optional[ILSemanticFlagClass]:
if self.instr.operands[operand_index] == 0:
return None
- return ILSemanticFlagClass(self.function.arch,
- architecture.SemanticClassIndex(self.instr.operands[operand_index]))
+ return ILSemanticFlagClass(
+ self.function.arch, architecture.SemanticClassIndex(self.instr.operands[operand_index])
+ )
- def _get_sem_group(self, operand_index:int) -> ILSemanticFlagGroup:
- return ILSemanticFlagGroup(self.function.arch,
- architecture.SemanticGroupIndex(self.instr.operands[operand_index]))
+ def _get_sem_group(self, operand_index: int) -> ILSemanticFlagGroup:
+ return ILSemanticFlagGroup(
+ self.function.arch, architecture.SemanticGroupIndex(self.instr.operands[operand_index])
+ )
- def _get_cond(self, operand_index:int) -> LowLevelILFlagCondition:
+ def _get_cond(self, operand_index: int) -> LowLevelILFlagCondition:
return LowLevelILFlagCondition(self.instr.operands[operand_index])
- def _get_int_list(self, operand_index:int) -> List[int]:
+ def _get_int_list(self, operand_index: int) -> List[int]:
count = ctypes.c_ulonglong()
operand_list = core.BNLowLevelILGetOperandList(self.function.handle, self.expr_index, operand_index, count)
assert operand_list is not None, "core.BNLowLevelILGetOperandList returned None"
- result:List[int] = []
+ result: List[int] = []
try:
for j in range(count.value):
result.append(operand_list[j])
@@ -883,7 +922,7 @@ class LowLevelILInstruction(BaseILInstruction):
finally:
core.BNLowLevelILFreeOperandList(operand_list)
- def _get_expr_list(self, operand_index:int) -> List['LowLevelILInstruction']:
+ def _get_expr_list(self, operand_index: int) -> List['LowLevelILInstruction']:
count = ctypes.c_ulonglong()
operand_list = core.BNLowLevelILGetOperandList(self.function.handle, self.expr_index, operand_index, count)
assert operand_list is not None, "core.BNLowLevelILGetOperandList returned None"
@@ -895,12 +934,12 @@ class LowLevelILInstruction(BaseILInstruction):
finally:
core.BNLowLevelILFreeOperandList(operand_list)
- def _get_reg_or_flag_list(self, operand_index:int) -> List[Union[ILFlag, ILRegister]]:
+ def _get_reg_or_flag_list(self, operand_index: int) -> List[Union[ILFlag, ILRegister]]:
count = ctypes.c_ulonglong()
operand_list = core.BNLowLevelILGetOperandList(self.function.handle, self.expr_index, operand_index, count)
assert operand_list is not None, "core.BNLowLevelILGetOperandList returned None"
- result:List[Union[ILFlag, ILRegister]] = []
+ result: List[Union[ILFlag, ILRegister]] = []
try:
for j in range(count.value):
if (operand_list[j] & (1 << 32)) != 0:
@@ -911,7 +950,7 @@ class LowLevelILInstruction(BaseILInstruction):
finally:
core.BNLowLevelILFreeOperandList(operand_list)
- def _get_reg_ssa_list(self, operand_index:int) -> List[SSARegister]:
+ def _get_reg_ssa_list(self, operand_index: int) -> List[SSARegister]:
count = ctypes.c_ulonglong()
operand_list = core.BNLowLevelILGetOperandList(self.function.handle, self.expr_index, operand_index, count)
assert operand_list is not None, "core.BNLowLevelILGetOperandList returned None"
@@ -919,52 +958,52 @@ class LowLevelILInstruction(BaseILInstruction):
try:
for j in range(count.value // 2):
reg = operand_list[j * 2]
- reg_version = operand_list[(j * 2) + 1]
+ reg_version = operand_list[(j*2) + 1]
result.append(SSARegister(ILRegister(self.function.arch, reg), reg_version))
return result
finally:
core.BNLowLevelILFreeOperandList(operand_list)
- def _get_reg_stack_ssa_list(self, operand_index:int) -> List[SSARegisterStack]:
+ def _get_reg_stack_ssa_list(self, operand_index: int) -> List[SSARegisterStack]:
count = ctypes.c_ulonglong()
operand_list = core.BNLowLevelILGetOperandList(self.function.handle, self.expr_index, operand_index, count)
assert operand_list is not None, "core.BNLowLevelILGetOperandList returned None"
- result:List[SSARegisterStack] = []
+ result: List[SSARegisterStack] = []
try:
for j in range(count.value // 2):
reg_stack = operand_list[j * 2]
- reg_version = operand_list[(j * 2) + 1]
+ reg_version = operand_list[(j*2) + 1]
result.append(SSARegisterStack(ILRegisterStack(self.function.arch, reg_stack), reg_version))
return result
finally:
core.BNLowLevelILFreeOperandList(operand_list)
- def _get_flag_ssa_list(self, operand_index:int) -> List[SSAFlag]:
+ def _get_flag_ssa_list(self, operand_index: int) -> List[SSAFlag]:
count = ctypes.c_ulonglong()
operand_list = core.BNLowLevelILGetOperandList(self.function.handle, self.expr_index, operand_index, count)
assert operand_list is not None, "core.BNLowLevelILGetOperandList returned None"
try:
- result:List[SSAFlag] = []
+ result: List[SSAFlag] = []
for j in range(count.value // 2):
flag = operand_list[j * 2]
- flag_version = operand_list[(j * 2) + 1]
+ flag_version = operand_list[(j*2) + 1]
result.append(SSAFlag(ILFlag(self.function.arch, flag), flag_version))
return result
finally:
core.BNLowLevelILFreeOperandList(operand_list)
- def _get_reg_or_flag_ssa_list(self, operand_index:int) -> List[SSARegisterOrFlag]:
+ def _get_reg_or_flag_ssa_list(self, operand_index: int) -> List[SSARegisterOrFlag]:
count = ctypes.c_ulonglong()
operand_list = core.BNLowLevelILGetOperandList(self.function.handle, self.expr_index, operand_index, count)
assert operand_list is not None, "core.BNLowLevelILGetOperandList returned None"
- result:List[SSARegisterOrFlag] = []
+ result: List[SSARegisterOrFlag] = []
try:
for j in range(count.value // 2):
if (operand_list[j * 2] & (1 << 32)) != 0:
reg_or_flag = ILFlag(self.function.arch, operand_list[j * 2] & 0xffffffff)
else:
reg_or_flag = ILRegister(self.function.arch, operand_list[j * 2] & 0xffffffff)
- reg_version = operand_list[(j * 2) + 1]
+ reg_version = operand_list[(j*2) + 1]
result.append(SSARegisterOrFlag(reg_or_flag, reg_version))
return result
finally:
@@ -973,7 +1012,6 @@ class LowLevelILInstruction(BaseILInstruction):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILBinaryBase(LowLevelILInstruction, BinaryOperation):
-
@property
def left(self) -> LowLevelILInstruction:
return self._get_expr(0)
@@ -994,7 +1032,6 @@ class LowLevelILComparisonBase(LowLevelILBinaryBase):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILCarryBase(LowLevelILInstruction, Carry):
-
@property
def left(self) -> LowLevelILInstruction:
return self._get_expr(0)
@@ -1014,7 +1051,6 @@ class LowLevelILCarryBase(LowLevelILInstruction, Carry):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILUnaryBase(LowLevelILInstruction, UnaryOperation):
-
@property
def src(self) -> LowLevelILInstruction:
return self._get_expr(0)
@@ -1026,29 +1062,28 @@ class LowLevelILUnaryBase(LowLevelILInstruction, UnaryOperation):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILConstantBase(LowLevelILInstruction, Constant):
-
def __int__(self):
return self.constant
def __bool__(self):
return self.constant != 0
- def __eq__(self, other:'LowLevelILConstantBase'):
+ def __eq__(self, other: 'LowLevelILConstantBase'):
return self.constant == other.constant
- def __ne__(self, other:'LowLevelILConstantBase'):
+ def __ne__(self, other: 'LowLevelILConstantBase'):
return self.constant != other.constant
- def __lt__(self, other:'LowLevelILConstantBase'):
+ def __lt__(self, other: 'LowLevelILConstantBase'):
return self.constant < other.constant
- def __gt__(self, other:'LowLevelILConstantBase'):
+ def __gt__(self, other: 'LowLevelILConstantBase'):
return self.constant > other.constant
- def __le__(self, other:'LowLevelILConstantBase'):
+ def __le__(self, other: 'LowLevelILConstantBase'):
return self.constant <= other.constant
- def __ge__(self, other:'LowLevelILConstantBase'):
+ def __ge__(self, other: 'LowLevelILConstantBase'):
return self.constant >= other.constant
def __hash__(self):
@@ -1125,7 +1160,6 @@ class LowLevelILLowPart(LowLevelILUnaryBase, Arithmetic):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILJump(LowLevelILInstruction, Terminal):
-
@property
def dest(self) -> LowLevelILInstruction:
return self._get_expr(0)
@@ -1137,7 +1171,6 @@ class LowLevelILJump(LowLevelILInstruction, Terminal):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILCall(LowLevelILInstruction, Localcall):
-
@property
def dest(self) -> LowLevelILInstruction:
return self._get_expr(0)
@@ -1149,7 +1182,6 @@ class LowLevelILCall(LowLevelILInstruction, Localcall):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILTailcall(LowLevelILInstruction, Tailcall):
-
@property
def dest(self) -> LowLevelILInstruction:
return self._get_expr(0)
@@ -1161,7 +1193,6 @@ class LowLevelILTailcall(LowLevelILInstruction, Tailcall):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILRet(LowLevelILInstruction, Return):
-
@property
def dest(self) -> LowLevelILInstruction:
return self._get_expr(0)
@@ -1173,7 +1204,6 @@ class LowLevelILRet(LowLevelILInstruction, Return):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILUnimplMem(LowLevelILInstruction, Memory):
-
@property
def src(self) -> LowLevelILInstruction:
return self._get_expr(0)
@@ -1185,7 +1215,6 @@ class LowLevelILUnimplMem(LowLevelILInstruction, Memory):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILFsqrt(LowLevelILInstruction, FloatingPoint, Arithmetic):
-
@property
def src(self) -> LowLevelILInstruction:
return self._get_expr(0)
@@ -1197,7 +1226,6 @@ class LowLevelILFsqrt(LowLevelILInstruction, FloatingPoint, Arithmetic):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILFneg(LowLevelILInstruction, FloatingPoint, Arithmetic):
-
@property
def src(self) -> LowLevelILInstruction:
return self._get_expr(0)
@@ -1209,7 +1237,6 @@ class LowLevelILFneg(LowLevelILInstruction, FloatingPoint, Arithmetic):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILFabs(LowLevelILInstruction, FloatingPoint, Arithmetic):
-
@property
def src(self) -> LowLevelILInstruction:
return self._get_expr(0)
@@ -1221,7 +1248,6 @@ class LowLevelILFabs(LowLevelILInstruction, FloatingPoint, Arithmetic):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILFloatToInt(LowLevelILInstruction, FloatingPoint, Arithmetic):
-
@property
def src(self) -> LowLevelILInstruction:
return self._get_expr(0)
@@ -1233,7 +1259,6 @@ class LowLevelILFloatToInt(LowLevelILInstruction, FloatingPoint, Arithmetic):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILIntToFloat(LowLevelILInstruction, FloatingPoint, Arithmetic):
-
@property
def src(self) -> LowLevelILInstruction:
return self._get_expr(0)
@@ -1245,7 +1270,6 @@ class LowLevelILIntToFloat(LowLevelILInstruction, FloatingPoint, Arithmetic):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILFloatConv(LowLevelILInstruction, FloatingPoint, Arithmetic):
-
@property
def src(self) -> LowLevelILInstruction:
return self._get_expr(0)
@@ -1257,7 +1281,6 @@ class LowLevelILFloatConv(LowLevelILInstruction, FloatingPoint, Arithmetic):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILRoundToInt(LowLevelILInstruction, FloatingPoint, Arithmetic):
-
@property
def src(self) -> LowLevelILInstruction:
return self._get_expr(0)
@@ -1269,7 +1292,6 @@ class LowLevelILRoundToInt(LowLevelILInstruction, FloatingPoint, Arithmetic):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILFloor(LowLevelILInstruction, FloatingPoint, Arithmetic):
-
@property
def src(self) -> LowLevelILInstruction:
return self._get_expr(0)
@@ -1281,7 +1303,6 @@ class LowLevelILFloor(LowLevelILInstruction, FloatingPoint, Arithmetic):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILCeil(LowLevelILInstruction, FloatingPoint, Arithmetic):
-
@property
def src(self) -> LowLevelILInstruction:
return self._get_expr(0)
@@ -1293,7 +1314,6 @@ class LowLevelILCeil(LowLevelILInstruction, FloatingPoint, Arithmetic):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILFtrunc(LowLevelILInstruction, FloatingPoint, Arithmetic):
-
@property
def src(self) -> LowLevelILInstruction:
return self._get_expr(0)
@@ -1305,7 +1325,6 @@ class LowLevelILFtrunc(LowLevelILInstruction, FloatingPoint, Arithmetic):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILLoad(LowLevelILInstruction, Load):
-
@property
def src(self) -> LowLevelILInstruction:
return self._get_expr(0)
@@ -1317,7 +1336,6 @@ class LowLevelILLoad(LowLevelILInstruction, Load):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILPush(LowLevelILInstruction, StackOperation):
-
@property
def src(self) -> LowLevelILInstruction:
return self._get_expr(0)
@@ -1329,7 +1347,6 @@ class LowLevelILPush(LowLevelILInstruction, StackOperation):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILReg(LowLevelILInstruction):
-
@property
def src(self) -> ILRegister:
return self._get_reg(0)
@@ -1341,7 +1358,6 @@ class LowLevelILReg(LowLevelILInstruction):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILRegStackPop(LowLevelILInstruction, RegisterStack):
-
@property
def stack(self) -> ILRegisterStack:
return self._get_reg_stack(0)
@@ -1353,7 +1369,6 @@ class LowLevelILRegStackPop(LowLevelILInstruction, RegisterStack):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILRegStackFreeReg(LowLevelILInstruction, RegisterStack):
-
@property
def dest(self) -> ILRegister:
return self._get_reg(0)
@@ -1375,7 +1390,6 @@ class LowLevelILConstPtr(LowLevelILConstantBase):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILFloatConst(LowLevelILConstantBase, FloatingPoint):
-
@property
def constant(self) -> Union[int, float]:
return self._get_float(0)
@@ -1387,7 +1401,6 @@ class LowLevelILFloatConst(LowLevelILConstantBase, FloatingPoint):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILFlag(LowLevelILInstruction):
-
@property
def src(self) -> ILFlag:
return self._get_flag(0)
@@ -1399,7 +1412,6 @@ class LowLevelILFlag(LowLevelILInstruction):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILGoto(LowLevelILInstruction, Terminal):
-
@property
def dest(self) -> int:
return self._get_int(0)
@@ -1411,7 +1423,6 @@ class LowLevelILGoto(LowLevelILInstruction, Terminal):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILFlagGroup(LowLevelILInstruction):
-
@property
def semantic_group(self) -> ILSemanticFlagGroup:
return self._get_sem_group(0)
@@ -1423,7 +1434,6 @@ class LowLevelILFlagGroup(LowLevelILInstruction):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILBoolToInt(LowLevelILInstruction):
-
@property
def src(self) -> LowLevelILInstruction:
return self._get_expr(0)
@@ -1435,7 +1445,6 @@ class LowLevelILBoolToInt(LowLevelILInstruction):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILTrap(LowLevelILInstruction, Terminal):
-
@property
def vector(self) -> int:
return self._get_int(0)
@@ -1447,7 +1456,6 @@ class LowLevelILTrap(LowLevelILInstruction, Terminal):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILRegSplitDestSsa(LowLevelILInstruction, SSA):
-
@property
def dest(self) -> SSARegister:
return self._get_reg_ssa(0, 1)
@@ -1459,7 +1467,6 @@ class LowLevelILRegSplitDestSsa(LowLevelILInstruction, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILRegStackDestSsa(LowLevelILInstruction, RegisterStack, SSA):
-
@property
def dest(self) -> SSARegisterStack:
return self._get_reg_stack_ssa(0, 1)
@@ -1475,7 +1482,6 @@ class LowLevelILRegStackDestSsa(LowLevelILInstruction, RegisterStack, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILRegSsa(LowLevelILInstruction, SSA):
-
@property
def src(self) -> SSARegister:
return self._get_reg_ssa(0, 1)
@@ -1487,7 +1493,6 @@ class LowLevelILRegSsa(LowLevelILInstruction, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILFlagSsa(LowLevelILInstruction, SSA):
-
@property
def src(self) -> SSAFlag:
return self._get_flag_ssa(0, 1)
@@ -1499,7 +1504,6 @@ class LowLevelILFlagSsa(LowLevelILInstruction, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILCallParam(LowLevelILInstruction, SSA):
-
@property
def src(self) -> List['LowLevelILInstruction']:
return self._get_expr_list(0)
@@ -1511,7 +1515,6 @@ class LowLevelILCallParam(LowLevelILInstruction, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILMemPhi(LowLevelILInstruction, Memory, Phi):
-
@property
def dest_memory(self) -> int:
return self._get_int(0)
@@ -1527,7 +1530,6 @@ class LowLevelILMemPhi(LowLevelILInstruction, Memory, Phi):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILSetReg(LowLevelILInstruction, SetReg):
-
@property
def dest(self) -> ILRegister:
return self._get_reg(0)
@@ -1543,7 +1545,6 @@ class LowLevelILSetReg(LowLevelILInstruction, SetReg):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILRegStackPush(LowLevelILInstruction, RegisterStack):
-
@property
def stack(self) -> ILRegisterStack:
return self._get_reg_stack(0)
@@ -1559,7 +1560,6 @@ class LowLevelILRegStackPush(LowLevelILInstruction, RegisterStack):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILSetFlag(LowLevelILInstruction):
-
@property
def dest(self) -> ILFlag:
return self._get_flag(0)
@@ -1575,7 +1575,6 @@ class LowLevelILSetFlag(LowLevelILInstruction):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILStore(LowLevelILInstruction, Store):
-
@property
def dest(self) -> LowLevelILInstruction:
return self._get_expr(0)
@@ -1591,7 +1590,6 @@ class LowLevelILStore(LowLevelILInstruction, Store):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILRegSplit(LowLevelILInstruction):
-
@property
def hi(self) -> ILRegister:
return self._get_reg(0)
@@ -1607,7 +1605,6 @@ class LowLevelILRegSplit(LowLevelILInstruction):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILRegStackRel(LowLevelILInstruction, RegisterStack):
-
@property
def stack(self) -> ILRegisterStack:
return self._get_reg_stack(0)
@@ -1623,7 +1620,6 @@ class LowLevelILRegStackRel(LowLevelILInstruction, RegisterStack):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILRegStackFreeRel(LowLevelILInstruction, RegisterStack):
-
@property
def stack(self) -> ILRegisterStack:
return self._get_reg_stack(0)
@@ -1639,7 +1635,6 @@ class LowLevelILRegStackFreeRel(LowLevelILInstruction, RegisterStack):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILExternPtr(LowLevelILConstantBase):
-
@property
def constant(self) -> int:
return self._get_int(0)
@@ -1655,7 +1650,6 @@ class LowLevelILExternPtr(LowLevelILConstantBase):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILFlagBit(LowLevelILInstruction):
-
@property
def src(self) -> ILFlag:
return self._get_flag(0)
@@ -1795,7 +1789,7 @@ class LowLevelILCmpUlt(LowLevelILComparisonBase):
@dataclass(frozen=True, repr=False, eq=False)
-class LowLevelILCmpSle(LowLevelILComparisonBase,Signed):
+class LowLevelILCmpSle(LowLevelILComparisonBase, Signed):
pass
@@ -1891,7 +1885,6 @@ class LowLevelILFcmpUo(LowLevelILInstruction, Comparison, FloatingPoint):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILJumpTo(LowLevelILInstruction):
-
@property
def dest(self) -> LowLevelILInstruction:
return self._get_expr(0)
@@ -1907,7 +1900,6 @@ class LowLevelILJumpTo(LowLevelILInstruction):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILFlagCond(LowLevelILInstruction):
-
@property
def condition(self) -> LowLevelILFlagCondition:
return self._get_cond(0)
@@ -1928,7 +1920,6 @@ class LowLevelILAddOverflow(LowLevelILBinaryBase, Arithmetic):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILSetRegSsa(LowLevelILInstruction, SetReg, SSA):
-
@property
def dest(self) -> SSARegister:
return self._get_reg_ssa(0, 1)
@@ -1944,7 +1935,6 @@ class LowLevelILSetRegSsa(LowLevelILInstruction, SetReg, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILRegSsaPartial(LowLevelILInstruction, SetReg, SSA):
-
@property
def full_reg(self) -> SSARegister:
return self._get_reg_ssa(0, 1)
@@ -1960,7 +1950,6 @@ class LowLevelILRegSsaPartial(LowLevelILInstruction, SetReg, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILRegSplitSsa(LowLevelILInstruction, SetReg, SSA):
-
@property
def hi(self) -> SSARegister:
return self._get_reg_ssa(0, 1)
@@ -1976,7 +1965,6 @@ class LowLevelILRegSplitSsa(LowLevelILInstruction, SetReg, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILRegStackAbsSsa(LowLevelILInstruction, RegisterStack, SSA):
-
@property
def stack(self) -> SSARegisterStack:
return self._get_reg_stack_ssa(0, 1)
@@ -1992,7 +1980,6 @@ class LowLevelILRegStackAbsSsa(LowLevelILInstruction, RegisterStack, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILRegStackFreeAbsSsa(LowLevelILInstruction, RegisterStack):
-
@property
def stack(self) -> LowLevelILInstruction:
return self._get_expr(0)
@@ -2008,7 +1995,6 @@ class LowLevelILRegStackFreeAbsSsa(LowLevelILInstruction, RegisterStack):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILSetFlagSsa(LowLevelILInstruction, SSA):
-
@property
def dest(self) -> SSAFlag:
return self._get_flag_ssa(0, 1)
@@ -2024,7 +2010,6 @@ class LowLevelILSetFlagSsa(LowLevelILInstruction, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILFlagBitSsa(LowLevelILInstruction, SSA):
-
@property
def src(self) -> SSAFlag:
return self._get_flag_ssa(0, 1)
@@ -2040,7 +2025,6 @@ class LowLevelILFlagBitSsa(LowLevelILInstruction, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILCallOutputSsa(LowLevelILInstruction, SSA):
-
@property
def dest_memory(self) -> int:
return self._get_int(0)
@@ -2056,7 +2040,6 @@ class LowLevelILCallOutputSsa(LowLevelILInstruction, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILCallStackSsa(LowLevelILInstruction, SSA):
-
@property
def src(self) -> SSARegister:
return self._get_reg_ssa(0, 1)
@@ -2072,7 +2055,6 @@ class LowLevelILCallStackSsa(LowLevelILInstruction, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILLoadSsa(LowLevelILInstruction, Load, SSA):
-
@property
def src(self) -> LowLevelILInstruction:
return self._get_expr(0)
@@ -2088,7 +2070,6 @@ class LowLevelILLoadSsa(LowLevelILInstruction, Load, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILRegPhi(LowLevelILInstruction, Phi):
-
@property
def dest(self) -> SSARegister:
return self._get_reg_ssa(0, 1)
@@ -2104,7 +2085,6 @@ class LowLevelILRegPhi(LowLevelILInstruction, Phi):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILRegStackPhi(LowLevelILInstruction, RegisterStack, Phi):
-
@property
def dest(self) -> SSARegisterStack:
return self._get_reg_stack_ssa(0, 1)
@@ -2120,7 +2100,6 @@ class LowLevelILRegStackPhi(LowLevelILInstruction, RegisterStack, Phi):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILFlagPhi(LowLevelILInstruction, Phi):
-
@property
def dest(self) -> SSAFlag:
return self._get_flag_ssa(0, 1)
@@ -2136,7 +2115,6 @@ class LowLevelILFlagPhi(LowLevelILInstruction, Phi):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILSetRegSplit(LowLevelILInstruction, SetReg):
-
@property
def hi(self) -> ILRegister:
return self._get_reg(0)
@@ -2156,7 +2134,6 @@ class LowLevelILSetRegSplit(LowLevelILInstruction, SetReg):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILSetRegStackRel(LowLevelILInstruction, RegisterStack):
-
@property
def stack(self) -> ILRegisterStack:
return self._get_reg_stack(0)
@@ -2196,7 +2173,6 @@ class LowLevelILRrc(LowLevelILCarryBase):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILCallStackAdjust(LowLevelILInstruction, Localcall):
-
@property
def dest(self) -> LowLevelILInstruction:
return self._get_expr(0)
@@ -2216,7 +2192,6 @@ class LowLevelILCallStackAdjust(LowLevelILInstruction, Localcall):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILIf(LowLevelILInstruction, ControlFlow):
-
@property
def condition(self) -> LowLevelILInstruction:
return self._get_expr(0)
@@ -2236,7 +2211,6 @@ class LowLevelILIf(LowLevelILInstruction, ControlFlow):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILIntrinsic(LowLevelILInstruction):
-
@property
def output(self) -> List[Union[ILFlag, ILRegister]]:
return self._get_reg_or_flag_list(0)
@@ -2256,7 +2230,6 @@ class LowLevelILIntrinsic(LowLevelILInstruction):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILIntrinsicSsa(LowLevelILInstruction, SSA):
-
@property
def output(self) -> List[SSARegisterOrFlag]:
return self._get_reg_or_flag_ssa_list(0)
@@ -2276,7 +2249,6 @@ class LowLevelILIntrinsicSsa(LowLevelILInstruction, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILSetRegSsaPartial(LowLevelILInstruction, SetReg, SSA):
-
@property
def full_reg(self) -> SSARegister:
return self._get_reg_ssa(0, 1)
@@ -2296,7 +2268,6 @@ class LowLevelILSetRegSsaPartial(LowLevelILInstruction, SetReg, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILSetRegSplitSsa(LowLevelILInstruction, SetReg, SSA):
-
@property
def hi(self) -> LowLevelILInstruction:
return self._get_expr(0)
@@ -2335,7 +2306,6 @@ class LowLevelILSetRegStackAbsSsa(LowLevelILInstruction, RegisterStack, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILRegStackRelSsa(LowLevelILInstruction, RegisterStack, SSA):
-
@property
def stack(self) -> SSARegisterStack:
return self._get_reg_stack_ssa(0, 1)
@@ -2355,7 +2325,6 @@ class LowLevelILRegStackRelSsa(LowLevelILInstruction, RegisterStack, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILRegStackFreeRelSsa(LowLevelILInstruction, RegisterStack, SSA):
-
@property
def stack(self) -> LowLevelILInstruction:
return self._get_expr(0)
@@ -2375,7 +2344,6 @@ class LowLevelILRegStackFreeRelSsa(LowLevelILInstruction, RegisterStack, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILSyscallSsa(LowLevelILInstruction, Syscall, SSA):
-
@property
def output(self) -> LowLevelILInstruction:
return self._get_expr(0)
@@ -2395,7 +2363,6 @@ class LowLevelILSyscallSsa(LowLevelILInstruction, Syscall, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILSetRegStackRelSsa(LowLevelILInstruction, RegisterStack, SSA):
-
@property
def stack(self) -> LowLevelILInstruction:
return self._get_expr(0)
@@ -2419,7 +2386,6 @@ class LowLevelILSetRegStackRelSsa(LowLevelILInstruction, RegisterStack, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILCallSsa(LowLevelILInstruction, Localcall, SSA):
-
@property
def output(self) -> LowLevelILInstruction:
return self._get_expr(0)
@@ -2443,7 +2409,6 @@ class LowLevelILCallSsa(LowLevelILInstruction, Localcall, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILTailcallSsa(LowLevelILInstruction, Tailcall, SSA, Terminal):
-
@property
def output(self) -> LowLevelILInstruction:
return self._get_expr(0)
@@ -2467,7 +2432,6 @@ class LowLevelILTailcallSsa(LowLevelILInstruction, Tailcall, SSA, Terminal):
@dataclass(frozen=True, repr=False, eq=False)
class LowLevelILStoreSsa(LowLevelILInstruction, Store, SSA):
-
@property
def dest(self) -> LowLevelILInstruction:
return self._get_expr(0)
@@ -2490,141 +2454,141 @@ class LowLevelILStoreSsa(LowLevelILInstruction, Store, SSA):
ILInstruction:Dict[LowLevelILOperation, LowLevelILInstruction] = { # type: ignore
- LowLevelILOperation.LLIL_NOP: LowLevelILNop, # [],
- LowLevelILOperation.LLIL_SET_REG: LowLevelILSetReg, # [("dest", "reg"), ("src", "expr")],
- LowLevelILOperation.LLIL_SET_REG_SPLIT: LowLevelILSetRegSplit, # [("hi", "reg"), ("lo", "reg"), ("src", "expr")],
- LowLevelILOperation.LLIL_SET_REG_STACK_REL: LowLevelILSetRegStackRel, # [("stack", "reg_stack"), ("dest", "expr"), ("src", "expr")],
- LowLevelILOperation.LLIL_REG_STACK_PUSH: LowLevelILRegStackPush, # [("stack", "reg_stack"), ("src", "expr")],
- LowLevelILOperation.LLIL_SET_FLAG: LowLevelILSetFlag, # [("dest", "flag"), ("src", "expr")],
- LowLevelILOperation.LLIL_LOAD: LowLevelILLoad, # [("src", "expr")],
- LowLevelILOperation.LLIL_STORE: LowLevelILStore, # [("dest", "expr"), ("src", "expr")],
- LowLevelILOperation.LLIL_PUSH: LowLevelILPush, # [("src", "expr")],
- LowLevelILOperation.LLIL_POP: LowLevelILPop, # [],
- LowLevelILOperation.LLIL_REG: LowLevelILReg, # [("src", "reg")],
- LowLevelILOperation.LLIL_REG_SPLIT: LowLevelILRegSplit, # [("hi", "reg"), ("lo", "reg")],
- LowLevelILOperation.LLIL_REG_STACK_REL: LowLevelILRegStackRel, # [("stack", "reg_stack"), ("src", "expr")],
- LowLevelILOperation.LLIL_REG_STACK_POP: LowLevelILRegStackPop, # [("stack", "reg_stack")],
- LowLevelILOperation.LLIL_REG_STACK_FREE_REG: LowLevelILRegStackFreeReg, # [("dest", "reg")],
- LowLevelILOperation.LLIL_REG_STACK_FREE_REL: LowLevelILRegStackFreeRel, # [("stack", "reg_stack"), ("dest", "expr")],
- LowLevelILOperation.LLIL_CONST: LowLevelILConst, # [("constant", "int")],
- LowLevelILOperation.LLIL_CONST_PTR: LowLevelILConstPtr, # [("constant", "int")],
- LowLevelILOperation.LLIL_EXTERN_PTR: LowLevelILExternPtr, # [("constant", "int"), ("offset", "int")],
- LowLevelILOperation.LLIL_FLOAT_CONST: LowLevelILFloatConst, # [("constant", "float")],
- LowLevelILOperation.LLIL_FLAG: LowLevelILFlag, # [("src", "flag")],
- LowLevelILOperation.LLIL_FLAG_BIT: LowLevelILFlagBit, # [("src", "flag"), ("bit", "int")],
- LowLevelILOperation.LLIL_ADD: LowLevelILAdd, # [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_ADC: LowLevelILAdc, # [("left", "expr"), ("right", "expr"), ("carry", "expr")],
- LowLevelILOperation.LLIL_SUB: LowLevelILSub, # [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_SBB: LowLevelILSbb, # [("left", "expr"), ("right", "expr"), ("carry", "expr")],
- LowLevelILOperation.LLIL_AND: LowLevelILAnd, # [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_OR: LowLevelILOr, # [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_XOR: LowLevelILXor, # [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_LSL: LowLevelILLsl, # [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_LSR: LowLevelILLsr, # [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_ASR: LowLevelILAsr, # [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_ROL: LowLevelILRol, # [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_RLC: LowLevelILRlc, # [("left", "expr"), ("right", "expr"), ("carry", "expr")],
- LowLevelILOperation.LLIL_ROR: LowLevelILRor, # [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_RRC: LowLevelILRrc, # [("left", "expr"), ("right", "expr"), ("carry", "expr")],
- LowLevelILOperation.LLIL_MUL: LowLevelILMul, # [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_MULU_DP: LowLevelILMuluDp, # [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_MULS_DP: LowLevelILMulsDp, # [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_DIVU: LowLevelILDivu, # [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_DIVU_DP: LowLevelILDivuDp, # [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_DIVS: LowLevelILDivs, # [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_DIVS_DP: LowLevelILDivsDp, # [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_MODU: LowLevelILModu, # [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_MODU_DP: LowLevelILModuDp, # [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_MODS: LowLevelILMods, # [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_MODS_DP: LowLevelILModsDp, # [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_NEG: LowLevelILNeg, # [("src", "expr")],
- LowLevelILOperation.LLIL_NOT: LowLevelILNot, # [("src", "expr")],
- LowLevelILOperation.LLIL_SX: LowLevelILSx, # [("src", "expr")],
- LowLevelILOperation.LLIL_ZX: LowLevelILZx, # [("src", "expr")],
- LowLevelILOperation.LLIL_LOW_PART: LowLevelILLowPart, # [("src", "expr")],
- LowLevelILOperation.LLIL_JUMP: LowLevelILJump, # [("dest", "expr")],
- LowLevelILOperation.LLIL_JUMP_TO: LowLevelILJumpTo, # [("dest", "expr"), ("targets", "target_map")],
- LowLevelILOperation.LLIL_CALL: LowLevelILCall, # [("dest", "expr")],
- LowLevelILOperation.LLIL_CALL_STACK_ADJUST: LowLevelILCallStackAdjust, # [("dest", "expr"), ("stack_adjustment", "int"), ("reg_stack_adjustments", "reg_stack_adjust")],
- LowLevelILOperation.LLIL_TAILCALL: LowLevelILTailcall, # [("dest", "expr")],
- LowLevelILOperation.LLIL_RET: LowLevelILRet, # [("dest", "expr")],
- LowLevelILOperation.LLIL_NORET: LowLevelILNoret, # [],
- LowLevelILOperation.LLIL_IF: LowLevelILIf, # [("condition", "expr"), ("true", "int"), ("false", "int")],
- LowLevelILOperation.LLIL_GOTO: LowLevelILGoto, # [("dest", "int")],
- LowLevelILOperation.LLIL_FLAG_COND: LowLevelILFlagCond, # [("condition", "cond"), ("semantic_class", "sem_class")],
- LowLevelILOperation.LLIL_FLAG_GROUP: LowLevelILFlagGroup, # [("semantic_group", "sem_group")],
- LowLevelILOperation.LLIL_CMP_E: LowLevelILCmpE, # [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_CMP_NE: LowLevelILCmpNe, # [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_CMP_SLT: LowLevelILCmpSlt, # [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_CMP_ULT: LowLevelILCmpUlt, # [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_CMP_SLE: LowLevelILCmpSle, # [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_CMP_ULE: LowLevelILCmpUle, # [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_CMP_SGE: LowLevelILCmpSge, # [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_CMP_UGE: LowLevelILCmpUge, # [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_CMP_SGT: LowLevelILCmpSgt, # [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_CMP_UGT: LowLevelILCmpUgt, # [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_TEST_BIT: LowLevelILTestBit, # [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_BOOL_TO_INT: LowLevelILBoolToInt, # [("src", "expr")],
- LowLevelILOperation.LLIL_ADD_OVERFLOW: LowLevelILAddOverflow, # [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_SYSCALL: LowLevelILSyscall, # [],
- LowLevelILOperation.LLIL_INTRINSIC: LowLevelILIntrinsic, # [("output", "reg_or_flag_list"), ("intrinsic", "intrinsic"), ("param", "expr")],
- LowLevelILOperation.LLIL_INTRINSIC_SSA: LowLevelILIntrinsicSsa, # [("output", "reg_or_flag_ssa_list"), ("intrinsic", "intrinsic"), ("param", "expr")],
- LowLevelILOperation.LLIL_BP: LowLevelILBp, # [],
- LowLevelILOperation.LLIL_TRAP: LowLevelILTrap, # [("vector", "int")],
- LowLevelILOperation.LLIL_UNDEF: LowLevelILUndef, # [],
- LowLevelILOperation.LLIL_UNIMPL: LowLevelILUnimpl, # [],
- LowLevelILOperation.LLIL_UNIMPL_MEM: LowLevelILUnimplMem, # [("src", "expr")],
- LowLevelILOperation.LLIL_FADD: LowLevelILFadd, # [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_FSUB: LowLevelILFsub, # [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_FMUL: LowLevelILFmul, # [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_FDIV: LowLevelILFdiv, # [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_FSQRT: LowLevelILFsqrt, # [("src", "expr")],
- LowLevelILOperation.LLIL_FNEG: LowLevelILFneg, # [("src", "expr")],
- LowLevelILOperation.LLIL_FABS: LowLevelILFabs, # [("src", "expr")],
- LowLevelILOperation.LLIL_FLOAT_TO_INT: LowLevelILFloatToInt, # [("src", "expr")],
- LowLevelILOperation.LLIL_INT_TO_FLOAT: LowLevelILIntToFloat, # [("src", "expr")],
- LowLevelILOperation.LLIL_FLOAT_CONV: LowLevelILFloatConv, # [("src", "expr")],
- LowLevelILOperation.LLIL_ROUND_TO_INT: LowLevelILRoundToInt, # [("src", "expr")],
- LowLevelILOperation.LLIL_FLOOR: LowLevelILFloor, # [("src", "expr")],
- LowLevelILOperation.LLIL_CEIL: LowLevelILCeil, # [("src", "expr")],
- LowLevelILOperation.LLIL_FTRUNC: LowLevelILFtrunc, # [("src", "expr")],
- LowLevelILOperation.LLIL_FCMP_E: LowLevelILFcmpE, # [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_FCMP_NE: LowLevelILFcmpNe, # [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_FCMP_LT: LowLevelILFcmpLt, # [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_FCMP_LE: LowLevelILFcmpLe, # [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_FCMP_GE: LowLevelILFcmpGe, # [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_FCMP_GT: LowLevelILFcmpGt, # [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_FCMP_O: LowLevelILFcmpO, # [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_FCMP_UO: LowLevelILFcmpUo, # [("left", "expr"), ("right", "expr")],
- LowLevelILOperation.LLIL_SET_REG_SSA: LowLevelILSetRegSsa, # [("dest", "reg_ssa"), ("src", "expr")],
- LowLevelILOperation.LLIL_SET_REG_SSA_PARTIAL: LowLevelILSetRegSsaPartial, # [("full_reg", "reg_ssa"), ("dest", "reg"), ("src", "expr")],
- LowLevelILOperation.LLIL_SET_REG_SPLIT_SSA: LowLevelILSetRegSplitSsa, # [("hi", "expr"), ("lo", "expr"), ("src", "expr")],
- LowLevelILOperation.LLIL_SET_REG_STACK_REL_SSA: LowLevelILSetRegStackRelSsa, # [("stack", "expr"), ("dest", "expr"), ("top", "expr"), ("src", "expr")],
- LowLevelILOperation.LLIL_SET_REG_STACK_ABS_SSA: LowLevelILSetRegStackAbsSsa, # [("stack", "expr"), ("dest", "reg"), ("src", "expr")],
- LowLevelILOperation.LLIL_REG_SPLIT_DEST_SSA: LowLevelILRegSplitDestSsa, # [("dest", "reg_ssa")],
- LowLevelILOperation.LLIL_REG_STACK_DEST_SSA: LowLevelILRegStackDestSsa, # [("src", "reg_stack_ssa_dest_and_src")],
- LowLevelILOperation.LLIL_REG_SSA: LowLevelILRegSsa, # [("src", "reg_ssa")],
- LowLevelILOperation.LLIL_REG_SSA_PARTIAL: LowLevelILRegSsaPartial, # [("full_reg", "reg_ssa"), ("src", "reg")],
- LowLevelILOperation.LLIL_REG_SPLIT_SSA: LowLevelILRegSplitSsa, # [("hi", "reg_ssa"), ("lo", "reg_ssa")],
- LowLevelILOperation.LLIL_REG_STACK_REL_SSA: LowLevelILRegStackRelSsa, # [("stack", "reg_stack_ssa"), ("src", "expr"), ("top", "expr")],
- LowLevelILOperation.LLIL_REG_STACK_ABS_SSA: LowLevelILRegStackAbsSsa, # [("stack", "reg_stack_ssa"), ("src", "reg")],
- LowLevelILOperation.LLIL_REG_STACK_FREE_REL_SSA: LowLevelILRegStackFreeRelSsa, # [("stack", "expr"), ("dest", "expr"), ("top", "expr")],
- LowLevelILOperation.LLIL_REG_STACK_FREE_ABS_SSA: LowLevelILRegStackFreeAbsSsa, # [("stack", "expr"), ("dest", "reg")],
- LowLevelILOperation.LLIL_SET_FLAG_SSA: LowLevelILSetFlagSsa, # [("dest", "flag_ssa"), ("src", "expr")],
- LowLevelILOperation.LLIL_FLAG_SSA: LowLevelILFlagSsa, # [("src", "flag_ssa")],
- LowLevelILOperation.LLIL_FLAG_BIT_SSA: LowLevelILFlagBitSsa, # [("src", "flag_ssa"), ("bit", "int")],
- LowLevelILOperation.LLIL_CALL_SSA: LowLevelILCallSsa, # [("output", "expr"), ("dest", "expr"), ("stack", "expr"), ("param", "expr")],
- LowLevelILOperation.LLIL_SYSCALL_SSA: LowLevelILSyscallSsa, # [("output", "expr"), ("stack", "expr"), ("param", "expr")],
- LowLevelILOperation.LLIL_TAILCALL_SSA: LowLevelILTailcallSsa, # [("output", "expr"), ("dest", "expr"), ("stack", "expr"), ("param", "expr")],
- LowLevelILOperation.LLIL_CALL_OUTPUT_SSA: LowLevelILCallOutputSsa, # [("dest_memory", "int"), ("dest", "reg_ssa_list")],
- LowLevelILOperation.LLIL_CALL_STACK_SSA: LowLevelILCallStackSsa, # [("src", "reg_ssa"), ("src_memory", "int")],
- LowLevelILOperation.LLIL_CALL_PARAM: LowLevelILCallParam, # [("src", "expr_list")],
- LowLevelILOperation.LLIL_LOAD_SSA: LowLevelILLoadSsa, # [("src", "expr"), ("src_memory", "int")],
- LowLevelILOperation.LLIL_STORE_SSA: LowLevelILStoreSsa, # [("dest", "expr"), ("dest_memory", "int"), ("src_memory", "int"), ("src", "expr")],
- LowLevelILOperation.LLIL_REG_PHI: LowLevelILRegPhi, # [("dest", "reg_ssa"), ("src", "reg_ssa_list")],
- LowLevelILOperation.LLIL_REG_STACK_PHI: LowLevelILRegStackPhi, # [("dest", "reg_stack_ssa"), ("src", "reg_stack_ssa_list")],
- LowLevelILOperation.LLIL_FLAG_PHI: LowLevelILFlagPhi, # [("dest", "flag_ssa"), ("src", "flag_ssa_list")],
- LowLevelILOperation.LLIL_MEM_PHI: LowLevelILMemPhi, # [("dest_memory", "int"), ("src_memory", "int_list")]
+ LowLevelILOperation.LLIL_NOP: LowLevelILNop, # [],
+ LowLevelILOperation.LLIL_SET_REG: LowLevelILSetReg, # [("dest", "reg"), ("src", "expr")],
+ LowLevelILOperation.LLIL_SET_REG_SPLIT: LowLevelILSetRegSplit, # [("hi", "reg"), ("lo", "reg"), ("src", "expr")],
+ LowLevelILOperation.LLIL_SET_REG_STACK_REL: LowLevelILSetRegStackRel, # [("stack", "reg_stack"), ("dest", "expr"), ("src", "expr")],
+ LowLevelILOperation.LLIL_REG_STACK_PUSH: LowLevelILRegStackPush, # [("stack", "reg_stack"), ("src", "expr")],
+ LowLevelILOperation.LLIL_SET_FLAG: LowLevelILSetFlag, # [("dest", "flag"), ("src", "expr")],
+ LowLevelILOperation.LLIL_LOAD: LowLevelILLoad, # [("src", "expr")],
+ LowLevelILOperation.LLIL_STORE: LowLevelILStore, # [("dest", "expr"), ("src", "expr")],
+ LowLevelILOperation.LLIL_PUSH: LowLevelILPush, # [("src", "expr")],
+ LowLevelILOperation.LLIL_POP: LowLevelILPop, # [],
+ LowLevelILOperation.LLIL_REG: LowLevelILReg, # [("src", "reg")],
+ LowLevelILOperation.LLIL_REG_SPLIT: LowLevelILRegSplit, # [("hi", "reg"), ("lo", "reg")],
+ LowLevelILOperation.LLIL_REG_STACK_REL: LowLevelILRegStackRel, # [("stack", "reg_stack"), ("src", "expr")],
+ LowLevelILOperation.LLIL_REG_STACK_POP: LowLevelILRegStackPop, # [("stack", "reg_stack")],
+ LowLevelILOperation.LLIL_REG_STACK_FREE_REG: LowLevelILRegStackFreeReg, # [("dest", "reg")],
+ LowLevelILOperation.LLIL_REG_STACK_FREE_REL: LowLevelILRegStackFreeRel, # [("stack", "reg_stack"), ("dest", "expr")],
+ LowLevelILOperation.LLIL_CONST: LowLevelILConst, # [("constant", "int")],
+ LowLevelILOperation.LLIL_CONST_PTR: LowLevelILConstPtr, # [("constant", "int")],
+ LowLevelILOperation.LLIL_EXTERN_PTR: LowLevelILExternPtr, # [("constant", "int"), ("offset", "int")],
+ LowLevelILOperation.LLIL_FLOAT_CONST: LowLevelILFloatConst, # [("constant", "float")],
+ LowLevelILOperation.LLIL_FLAG: LowLevelILFlag, # [("src", "flag")],
+ LowLevelILOperation.LLIL_FLAG_BIT: LowLevelILFlagBit, # [("src", "flag"), ("bit", "int")],
+ LowLevelILOperation.LLIL_ADD: LowLevelILAdd, # [("left", "expr"), ("right", "expr")],
+ LowLevelILOperation.LLIL_ADC: LowLevelILAdc, # [("left", "expr"), ("right", "expr"), ("carry", "expr")],
+ LowLevelILOperation.LLIL_SUB: LowLevelILSub, # [("left", "expr"), ("right", "expr")],
+ LowLevelILOperation.LLIL_SBB: LowLevelILSbb, # [("left", "expr"), ("right", "expr"), ("carry", "expr")],
+ LowLevelILOperation.LLIL_AND: LowLevelILAnd, # [("left", "expr"), ("right", "expr")],
+ LowLevelILOperation.LLIL_OR: LowLevelILOr, # [("left", "expr"), ("right", "expr")],
+ LowLevelILOperation.LLIL_XOR: LowLevelILXor, # [("left", "expr"), ("right", "expr")],
+ LowLevelILOperation.LLIL_LSL: LowLevelILLsl, # [("left", "expr"), ("right", "expr")],
+ LowLevelILOperation.LLIL_LSR: LowLevelILLsr, # [("left", "expr"), ("right", "expr")],
+ LowLevelILOperation.LLIL_ASR: LowLevelILAsr, # [("left", "expr"), ("right", "expr")],
+ LowLevelILOperation.LLIL_ROL: LowLevelILRol, # [("left", "expr"), ("right", "expr")],
+ LowLevelILOperation.LLIL_RLC: LowLevelILRlc, # [("left", "expr"), ("right", "expr"), ("carry", "expr")],
+ LowLevelILOperation.LLIL_ROR: LowLevelILRor, # [("left", "expr"), ("right", "expr")],
+ LowLevelILOperation.LLIL_RRC: LowLevelILRrc, # [("left", "expr"), ("right", "expr"), ("carry", "expr")],
+ LowLevelILOperation.LLIL_MUL: LowLevelILMul, # [("left", "expr"), ("right", "expr")],
+ LowLevelILOperation.LLIL_MULU_DP: LowLevelILMuluDp, # [("left", "expr"), ("right", "expr")],
+ LowLevelILOperation.LLIL_MULS_DP: LowLevelILMulsDp, # [("left", "expr"), ("right", "expr")],
+ LowLevelILOperation.LLIL_DIVU: LowLevelILDivu, # [("left", "expr"), ("right", "expr")],
+ LowLevelILOperation.LLIL_DIVU_DP: LowLevelILDivuDp, # [("left", "expr"), ("right", "expr")],
+ LowLevelILOperation.LLIL_DIVS: LowLevelILDivs, # [("left", "expr"), ("right", "expr")],
+ LowLevelILOperation.LLIL_DIVS_DP: LowLevelILDivsDp, # [("left", "expr"), ("right", "expr")],
+ LowLevelILOperation.LLIL_MODU: LowLevelILModu, # [("left", "expr"), ("right", "expr")],
+ LowLevelILOperation.LLIL_MODU_DP: LowLevelILModuDp, # [("left", "expr"), ("right", "expr")],
+ LowLevelILOperation.LLIL_MODS: LowLevelILMods, # [("left", "expr"), ("right", "expr")],
+ LowLevelILOperation.LLIL_MODS_DP: LowLevelILModsDp, # [("left", "expr"), ("right", "expr")],
+ LowLevelILOperation.LLIL_NEG: LowLevelILNeg, # [("src", "expr")],
+ LowLevelILOperation.LLIL_NOT: LowLevelILNot, # [("src", "expr")],
+ LowLevelILOperation.LLIL_SX: LowLevelILSx, # [("src", "expr")],
+ LowLevelILOperation.LLIL_ZX: LowLevelILZx, # [("src", "expr")],
+ LowLevelILOperation.LLIL_LOW_PART: LowLevelILLowPart, # [("src", "expr")],
+ LowLevelILOperation.LLIL_JUMP: LowLevelILJump, # [("dest", "expr")],
+ LowLevelILOperation.LLIL_JUMP_TO: LowLevelILJumpTo, # [("dest", "expr"), ("targets", "target_map")],
+ LowLevelILOperation.LLIL_CALL: LowLevelILCall, # [("dest", "expr")],
+ LowLevelILOperation.LLIL_CALL_STACK_ADJUST: LowLevelILCallStackAdjust, # [("dest", "expr"), ("stack_adjustment", "int"), ("reg_stack_adjustments", "reg_stack_adjust")],
+ LowLevelILOperation.LLIL_TAILCALL: LowLevelILTailcall, # [("dest", "expr")],
+ LowLevelILOperation.LLIL_RET: LowLevelILRet, # [("dest", "expr")],
+ LowLevelILOperation.LLIL_NORET: LowLevelILNoret, # [],
+ LowLevelILOperation.LLIL_IF: LowLevelILIf, # [("condition", "expr"), ("true", "int"), ("false", "int")],
+ LowLevelILOperation.LLIL_GOTO: LowLevelILGoto, # [("dest", "int")],
+ LowLevelILOperation.LLIL_FLAG_COND: LowLevelILFlagCond, # [("condition", "cond"), ("semantic_class", "sem_class")],
+ LowLevelILOperation.LLIL_FLAG_GROUP: LowLevelILFlagGroup, # [("semantic_group", "sem_group")],
+ LowLevelILOperation.LLIL_CMP_E: LowLevelILCmpE, # [("left", "expr"), ("right", "expr")],
+ LowLevelILOperation.LLIL_CMP_NE: LowLevelILCmpNe, # [("left", "expr"), ("right", "expr")],
+ LowLevelILOperation.LLIL_CMP_SLT: LowLevelILCmpSlt, # [("left", "expr"), ("right", "expr")],
+ LowLevelILOperation.LLIL_CMP_ULT: LowLevelILCmpUlt, # [("left", "expr"), ("right", "expr")],
+ LowLevelILOperation.LLIL_CMP_SLE: LowLevelILCmpSle, # [("left", "expr"), ("right", "expr")],
+ LowLevelILOperation.LLIL_CMP_ULE: LowLevelILCmpUle, # [("left", "expr"), ("right", "expr")],
+ LowLevelILOperation.LLIL_CMP_SGE: LowLevelILCmpSge, # [("left", "expr"), ("right", "expr")],
+ LowLevelILOperation.LLIL_CMP_UGE: LowLevelILCmpUge, # [("left", "expr"), ("right", "expr")],
+ LowLevelILOperation.LLIL_CMP_SGT: LowLevelILCmpSgt, # [("left", "expr"), ("right", "expr")],
+ LowLevelILOperation.LLIL_CMP_UGT: LowLevelILCmpUgt, # [("left", "expr"), ("right", "expr")],
+ LowLevelILOperation.LLIL_TEST_BIT: LowLevelILTestBit, # [("left", "expr"), ("right", "expr")],
+ LowLevelILOperation.LLIL_BOOL_TO_INT: LowLevelILBoolToInt, # [("src", "expr")],
+ LowLevelILOperation.LLIL_ADD_OVERFLOW: LowLevelILAddOverflow, # [("left", "expr"), ("right", "expr")],
+ LowLevelILOperation.LLIL_SYSCALL: LowLevelILSyscall, # [],
+ LowLevelILOperation.LLIL_INTRINSIC: LowLevelILIntrinsic, # [("output", "reg_or_flag_list"), ("intrinsic", "intrinsic"), ("param", "expr")],
+ LowLevelILOperation.LLIL_INTRINSIC_SSA: LowLevelILIntrinsicSsa, # [("output", "reg_or_flag_ssa_list"), ("intrinsic", "intrinsic"), ("param", "expr")],
+ LowLevelILOperation.LLIL_BP: LowLevelILBp, # [],
+ LowLevelILOperation.LLIL_TRAP: LowLevelILTrap, # [("vector", "int")],
+ LowLevelILOperation.LLIL_UNDEF: LowLevelILUndef, # [],
+ LowLevelILOperation.LLIL_UNIMPL: LowLevelILUnimpl, # [],
+ LowLevelILOperation.LLIL_UNIMPL_MEM: LowLevelILUnimplMem, # [("src", "expr")],
+ LowLevelILOperation.LLIL_FADD: LowLevelILFadd, # [("left", "expr"), ("right", "expr")],
+ LowLevelILOperation.LLIL_FSUB: LowLevelILFsub, # [("left", "expr"), ("right", "expr")],
+ LowLevelILOperation.LLIL_FMUL: LowLevelILFmul, # [("left", "expr"), ("right", "expr")],
+ LowLevelILOperation.LLIL_FDIV: LowLevelILFdiv, # [("left", "expr"), ("right", "expr")],
+ LowLevelILOperation.LLIL_FSQRT: LowLevelILFsqrt, # [("src", "expr")],
+ LowLevelILOperation.LLIL_FNEG: LowLevelILFneg, # [("src", "expr")],
+ LowLevelILOperation.LLIL_FABS: LowLevelILFabs, # [("src", "expr")],
+ LowLevelILOperation.LLIL_FLOAT_TO_INT: LowLevelILFloatToInt, # [("src", "expr")],
+ LowLevelILOperation.LLIL_INT_TO_FLOAT: LowLevelILIntToFloat, # [("src", "expr")],
+ LowLevelILOperation.LLIL_FLOAT_CONV: LowLevelILFloatConv, # [("src", "expr")],
+ LowLevelILOperation.LLIL_ROUND_TO_INT: LowLevelILRoundToInt, # [("src", "expr")],
+ LowLevelILOperation.LLIL_FLOOR: LowLevelILFloor, # [("src", "expr")],
+ LowLevelILOperation.LLIL_CEIL: LowLevelILCeil, # [("src", "expr")],
+ LowLevelILOperation.LLIL_FTRUNC: LowLevelILFtrunc, # [("src", "expr")],
+ LowLevelILOperation.LLIL_FCMP_E: LowLevelILFcmpE, # [("left", "expr"), ("right", "expr")],
+ LowLevelILOperation.LLIL_FCMP_NE: LowLevelILFcmpNe, # [("left", "expr"), ("right", "expr")],
+ LowLevelILOperation.LLIL_FCMP_LT: LowLevelILFcmpLt, # [("left", "expr"), ("right", "expr")],
+ LowLevelILOperation.LLIL_FCMP_LE: LowLevelILFcmpLe, # [("left", "expr"), ("right", "expr")],
+ LowLevelILOperation.LLIL_FCMP_GE: LowLevelILFcmpGe, # [("left", "expr"), ("right", "expr")],
+ LowLevelILOperation.LLIL_FCMP_GT: LowLevelILFcmpGt, # [("left", "expr"), ("right", "expr")],
+ LowLevelILOperation.LLIL_FCMP_O: LowLevelILFcmpO, # [("left", "expr"), ("right", "expr")],
+ LowLevelILOperation.LLIL_FCMP_UO: LowLevelILFcmpUo, # [("left", "expr"), ("right", "expr")],
+ LowLevelILOperation.LLIL_SET_REG_SSA: LowLevelILSetRegSsa, # [("dest", "reg_ssa"), ("src", "expr")],
+ LowLevelILOperation.LLIL_SET_REG_SSA_PARTIAL: LowLevelILSetRegSsaPartial, # [("full_reg", "reg_ssa"), ("dest", "reg"), ("src", "expr")],
+ LowLevelILOperation.LLIL_SET_REG_SPLIT_SSA: LowLevelILSetRegSplitSsa, # [("hi", "expr"), ("lo", "expr"), ("src", "expr")],
+ LowLevelILOperation.LLIL_SET_REG_STACK_REL_SSA: LowLevelILSetRegStackRelSsa, # [("stack", "expr"), ("dest", "expr"), ("top", "expr"), ("src", "expr")],
+ LowLevelILOperation.LLIL_SET_REG_STACK_ABS_SSA: LowLevelILSetRegStackAbsSsa, # [("stack", "expr"), ("dest", "reg"), ("src", "expr")],
+ LowLevelILOperation.LLIL_REG_SPLIT_DEST_SSA: LowLevelILRegSplitDestSsa, # [("dest", "reg_ssa")],
+ LowLevelILOperation.LLIL_REG_STACK_DEST_SSA: LowLevelILRegStackDestSsa, # [("src", "reg_stack_ssa_dest_and_src")],
+ LowLevelILOperation.LLIL_REG_SSA: LowLevelILRegSsa, # [("src", "reg_ssa")],
+ LowLevelILOperation.LLIL_REG_SSA_PARTIAL: LowLevelILRegSsaPartial, # [("full_reg", "reg_ssa"), ("src", "reg")],
+ LowLevelILOperation.LLIL_REG_SPLIT_SSA: LowLevelILRegSplitSsa, # [("hi", "reg_ssa"), ("lo", "reg_ssa")],
+ LowLevelILOperation.LLIL_REG_STACK_REL_SSA: LowLevelILRegStackRelSsa, # [("stack", "reg_stack_ssa"), ("src", "expr"), ("top", "expr")],
+ LowLevelILOperation.LLIL_REG_STACK_ABS_SSA: LowLevelILRegStackAbsSsa, # [("stack", "reg_stack_ssa"), ("src", "reg")],
+ LowLevelILOperation.LLIL_REG_STACK_FREE_REL_SSA: LowLevelILRegStackFreeRelSsa, # [("stack", "expr"), ("dest", "expr"), ("top", "expr")],
+ LowLevelILOperation.LLIL_REG_STACK_FREE_ABS_SSA: LowLevelILRegStackFreeAbsSsa, # [("stack", "expr"), ("dest", "reg")],
+ LowLevelILOperation.LLIL_SET_FLAG_SSA: LowLevelILSetFlagSsa, # [("dest", "flag_ssa"), ("src", "expr")],
+ LowLevelILOperation.LLIL_FLAG_SSA: LowLevelILFlagSsa, # [("src", "flag_ssa")],
+ LowLevelILOperation.LLIL_FLAG_BIT_SSA: LowLevelILFlagBitSsa, # [("src", "flag_ssa"), ("bit", "int")],
+ LowLevelILOperation.LLIL_CALL_SSA: LowLevelILCallSsa, # [("output", "expr"), ("dest", "expr"), ("stack", "expr"), ("param", "expr")],
+ LowLevelILOperation.LLIL_SYSCALL_SSA: LowLevelILSyscallSsa, # [("output", "expr"), ("stack", "expr"), ("param", "expr")],
+ LowLevelILOperation.LLIL_TAILCALL_SSA: LowLevelILTailcallSsa, # [("output", "expr"), ("dest", "expr"), ("stack", "expr"), ("param", "expr")],
+ LowLevelILOperation.LLIL_CALL_OUTPUT_SSA: LowLevelILCallOutputSsa, # [("dest_memory", "int"), ("dest", "reg_ssa_list")],
+ LowLevelILOperation.LLIL_CALL_STACK_SSA: LowLevelILCallStackSsa, # [("src", "reg_ssa"), ("src_memory", "int")],
+ LowLevelILOperation.LLIL_CALL_PARAM: LowLevelILCallParam, # [("src", "expr_list")],
+ LowLevelILOperation.LLIL_LOAD_SSA: LowLevelILLoadSsa, # [("src", "expr"), ("src_memory", "int")],
+ LowLevelILOperation.LLIL_STORE_SSA: LowLevelILStoreSsa, # [("dest", "expr"), ("dest_memory", "int"), ("src_memory", "int"), ("src", "expr")],
+ LowLevelILOperation.LLIL_REG_PHI: LowLevelILRegPhi, # [("dest", "reg_ssa"), ("src", "reg_ssa_list")],
+ LowLevelILOperation.LLIL_REG_STACK_PHI: LowLevelILRegStackPhi, # [("dest", "reg_stack_ssa"), ("src", "reg_stack_ssa_list")],
+ LowLevelILOperation.LLIL_FLAG_PHI: LowLevelILFlagPhi, # [("dest", "flag_ssa"), ("src", "flag_ssa_list")],
+ LowLevelILOperation.LLIL_MEM_PHI: LowLevelILMemPhi, # [("dest_memory", "int"), ("src_memory", "int_list")]
}
@@ -2634,7 +2598,7 @@ class LowLevelILExpr:
.. note:: Deprecated. Use ExpressionIndex instead
"""
- def __init__(self, index:ExpressionIndex):
+ def __init__(self, index: ExpressionIndex):
self._index = index
def __int__(self):
@@ -2673,8 +2637,10 @@ class LowLevelILFunction:
LLFC_NO !overflow No overflow
======================= ========== ===============================
"""
- def __init__(self, arch:Optional['architecture.Architecture']=None, handle:Optional[core.BNLowLevelILFunction]=None,
- source_func:'function.Function'=None):
+ def __init__(
+ self, arch: Optional['architecture.Architecture'] = None, handle: Optional[core.BNLowLevelILFunction] = None,
+ source_func: 'function.Function' = None
+ ):
self._arch = arch
self._source_function = source_func
if handle is not None:
@@ -2683,7 +2649,7 @@ class LowLevelILFunction:
if self._source_function is None:
source_handle = core.BNGetLowLevelILOwnerFunction(_handle)
if source_handle:
- self._source_function = function.Function(handle = source_handle)
+ self._source_function = function.Function(handle=source_handle)
else:
self._source_function = None
if self._arch is None:
@@ -2740,7 +2706,9 @@ class LowLevelILFunction:
raise IndexError("index out of range")
if i < 0:
i = len(self) + i
- return LowLevelILInstruction.create(self, ExpressionIndex(core.BNGetLowLevelILIndexForInstruction(self.handle, i)), i)
+ return LowLevelILInstruction.create(
+ self, ExpressionIndex(core.BNGetLowLevelILIndexForInstruction(self.handle, i)), i
+ )
def __setitem__(self, i, j):
raise IndexError("instruction modification not implemented")
@@ -2766,10 +2734,10 @@ class LowLevelILFunction:
return core.BNLowLevelILGetCurrentAddress(self.handle)
@current_address.setter
- def current_address(self, value:int) -> None:
+ def current_address(self, value: int) -> None:
core.BNLowLevelILSetCurrentAddress(self.handle, self.arch.handle, value)
- def set_current_address(self, value:int, arch:Optional['architecture.Architecture']=None) -> None:
+ def set_current_address(self, value: int, arch: Optional['architecture.Architecture'] = None) -> None:
if arch is None:
arch = self.arch
core.BNLowLevelILSetCurrentAddress(self.handle, arch.handle, value)
@@ -2858,7 +2826,7 @@ class LowLevelILFunction:
return self._source_function
@source_function.setter
- def source_function(self, value:'function.Function') -> None:
+ def source_function(self, value: 'function.Function') -> None:
self._source_function = value
@property
@@ -2951,11 +2919,15 @@ class LowLevelILFunction:
try:
for var_i in range(register_stack_count.value):
version_count = ctypes.c_ulonglong()
- versions = core.BNGetLowLevelRegisterStackSSAVersions(self.handle, register_stacks[var_i], version_count)
+ versions = core.BNGetLowLevelRegisterStackSSAVersions(
+ self.handle, register_stacks[var_i], version_count
+ )
assert versions is not None, "core.BNGetLowLevelRegisterStackSSAVersions returned None"
try:
for version_i in range(version_count.value):
- result.append(SSARegisterStack(ILRegisterStack(self.arch, register_stacks[var_i]), versions[version_i]))
+ result.append(
+ SSARegisterStack(ILRegisterStack(self.arch, register_stacks[var_i]), versions[version_i])
+ )
finally:
core.BNFreeLLILVariableVersionList(versions)
finally:
@@ -3006,7 +2978,10 @@ class LowLevelILFunction:
if self._source_function is None:
return []
- if self.il_form in [FunctionGraphType.LiftedILFunctionGraph, FunctionGraphType.LowLevelILFunctionGraph, FunctionGraphType.LowLevelILSSAFormFunctionGraph]:
+ if self.il_form in [
+ FunctionGraphType.LiftedILFunctionGraph, FunctionGraphType.LowLevelILFunctionGraph,
+ FunctionGraphType.LowLevelILSSAFormFunctionGraph
+ ]:
return self.registers + self.register_stacks + self.flags # type: ignore
return []
@@ -3020,7 +2995,7 @@ class LowLevelILFunction:
return self.ssa_form.ssa_vars
return []
- def get_instruction_start(self, addr:int, arch:Optional['architecture.Architecture']=None) -> Optional[int]:
+ def get_instruction_start(self, addr: int, arch: Optional['architecture.Architecture'] = None) -> Optional[int]:
if arch is None:
arch = self.arch
result = core.BNLowLevelILGetInstructionStart(self.handle, arch.handle, addr)
@@ -3031,15 +3006,17 @@ class LowLevelILFunction:
def clear_indirect_branches(self) -> None:
core.BNLowLevelILClearIndirectBranches(self.handle)
- def set_indirect_branches(self, branches:List[Tuple['architecture.Architecture', int]]) -> None:
+ def set_indirect_branches(self, branches: List[Tuple['architecture.Architecture', int]]) -> None:
branch_list = (core.BNArchitectureAndAddress * len(branches))()
for i in range(len(branches)):
branch_list[i].arch = branches[i][0].handle
branch_list[i].address = branches[i][1]
core.BNLowLevelILSetIndirectBranches(self.handle, branch_list, len(branches))
- def expr(self, operation, a:int=0, b:int=0, c:int=0, d:int=0, size:int=0,
- flags:Union['architecture.FlagWriteTypeName', 'architecture.FlagType', 'architecture.FlagIndex']=None):
+ def expr(
+ self, operation, a: int = 0, b: int = 0, c: int = 0, d: int = 0, size: int = 0,
+ flags: Union['architecture.FlagWriteTypeName', 'architecture.FlagType', 'architecture.FlagIndex'] = None
+ ):
_flags = architecture.FlagIndex(0)
if isinstance(operation, str):
operation = LowLevelILOperation[operation]
@@ -3057,7 +3034,7 @@ class LowLevelILFunction:
assert False, "flags type unsupported"
return ExpressionIndex(core.BNLowLevelILAddExpr(self.handle, operation, size, _flags, a, b, c, d))
- def replace_expr(self, original:InstructionOrExpression, new:InstructionOrExpression) -> None:
+ def replace_expr(self, original: InstructionOrExpression, new: InstructionOrExpression) -> None:
"""
``replace_expr`` allows modification of ExpressionIndexessions but ONLY during lifting.
@@ -3079,7 +3056,7 @@ class LowLevelILFunction:
core.BNReplaceLowLevelILExpr(self.handle, original, new)
- def append(self, expr:ExpressionIndex) -> int:
+ def append(self, expr: ExpressionIndex) -> int:
"""
``append`` adds the ExpressionIndex ``expr`` to the current LowLevelILFunction.
@@ -3098,8 +3075,10 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_NOP)
- def set_reg(self, size:int, reg:'architecture.RegisterType', value:ExpressionIndex,
- flags:Optional['architecture.FlagType']=None) -> ExpressionIndex:
+ def set_reg(
+ self, size: int, reg: 'architecture.RegisterType', value: ExpressionIndex,
+ flags: Optional['architecture.FlagType'] = None
+ ) -> ExpressionIndex:
"""
``set_reg`` sets the register ``reg`` of size ``size`` to the expression ``value``
@@ -3113,10 +3092,12 @@ class LowLevelILFunction:
_reg = ExpressionIndex(self.arch.get_reg_index(reg))
if flags is None:
flags = architecture.FlagIndex(0)
- return self.expr(LowLevelILOperation.LLIL_SET_REG, _reg, value, size = size, flags = flags)
+ return self.expr(LowLevelILOperation.LLIL_SET_REG, _reg, value, size=size, flags=flags)
- def set_reg_split(self, size:int, hi:'architecture.RegisterType', lo:'architecture.RegisterType',
- value:ExpressionIndex, flags:'architecture.FlagType'=None) -> ExpressionIndex:
+ def set_reg_split(
+ self, size: int, hi: 'architecture.RegisterType', lo: 'architecture.RegisterType', value: ExpressionIndex,
+ flags: 'architecture.FlagType' = None
+ ) -> ExpressionIndex:
"""
``set_reg_split`` uses ``hi`` and ``lo`` as a single extended register setting ``hi:lo`` to the expression
``value``.
@@ -3133,10 +3114,12 @@ class LowLevelILFunction:
_lo = ExpressionIndex(self.arch.get_reg_index(lo))
if flags is None:
flags = architecture.FlagIndex(0)
- return self.expr(LowLevelILOperation.LLIL_SET_REG_SPLIT, _hi, _lo, value, size = size, flags = flags)
+ return self.expr(LowLevelILOperation.LLIL_SET_REG_SPLIT, _hi, _lo, value, size=size, flags=flags)
- def set_reg_stack_top_relative(self, size:int, reg_stack:'architecture.RegisterStackType', entry:ExpressionIndex,
- value:ExpressionIndex, flags:'architecture.FlagType'=None) -> ExpressionIndex:
+ def set_reg_stack_top_relative(
+ self, size: int, reg_stack: 'architecture.RegisterStackType', entry: ExpressionIndex, value: ExpressionIndex,
+ flags: 'architecture.FlagType' = None
+ ) -> ExpressionIndex:
"""
``set_reg_stack_top_relative`` sets the top-relative entry ``entry`` of size ``size`` in register
stack ``reg_stack`` to the expression ``value``
@@ -3152,11 +3135,12 @@ class LowLevelILFunction:
_reg_stack = ExpressionIndex(self.arch.get_reg_stack_index(reg_stack))
if flags is None:
flags = architecture.FlagIndex(0)
- return self.expr(LowLevelILOperation.LLIL_SET_REG_STACK_REL, _reg_stack, entry, value,
- size = size, flags = flags)
+ return self.expr(LowLevelILOperation.LLIL_SET_REG_STACK_REL, _reg_stack, entry, value, size=size, flags=flags)
- def reg_stack_push(self, size:int, reg_stack:'architecture.RegisterStackType', value:ExpressionIndex,
- flags:'architecture.FlagType'=None) -> ExpressionIndex:
+ def reg_stack_push(
+ self, size: int, reg_stack: 'architecture.RegisterStackType', value: ExpressionIndex,
+ flags: 'architecture.FlagType' = None
+ ) -> ExpressionIndex:
"""
``reg_stack_push`` pushes the expression ``value`` of size ``size`` onto the top of the register
stack ``reg_stack``
@@ -3171,9 +3155,9 @@ class LowLevelILFunction:
_reg_stack = ExpressionIndex(self.arch.get_reg_stack_index(reg_stack))
if flags is None:
flags = architecture.FlagIndex(0)
- return self.expr(LowLevelILOperation.LLIL_REG_STACK_PUSH, _reg_stack, value, size = size, flags = flags)
+ return self.expr(LowLevelILOperation.LLIL_REG_STACK_PUSH, _reg_stack, value, size=size, flags=flags)
- def set_flag(self, flag:'architecture.FlagName', value:ExpressionIndex) -> ExpressionIndex:
+ def set_flag(self, flag: 'architecture.FlagName', value: ExpressionIndex) -> ExpressionIndex:
"""
``set_flag`` sets the flag ``flag`` to the ExpressionIndex ``value``
@@ -3182,10 +3166,9 @@ class LowLevelILFunction:
:return: The expression FLAG.flag = value
:rtype: ExpressionIndex
"""
- return self.expr(LowLevelILOperation.LLIL_SET_FLAG, ExpressionIndex(self.arch.get_flag_by_name(flag)),
- value)
+ return self.expr(LowLevelILOperation.LLIL_SET_FLAG, ExpressionIndex(self.arch.get_flag_by_name(flag)), value)
- def load(self, size:int, addr:ExpressionIndex) -> ExpressionIndex:
+ def load(self, size: int, addr: ExpressionIndex) -> ExpressionIndex:
"""
``load`` Reads ``size`` bytes from the expression ``addr``
@@ -3196,7 +3179,9 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_LOAD, addr, size=size)
- def store(self, size:int, addr:ExpressionIndex, value:ExpressionIndex, flags:Optional['architecture.FlagName']=None) -> ExpressionIndex:
+ def store(
+ self, size: int, addr: ExpressionIndex, value: ExpressionIndex, flags: Optional['architecture.FlagName'] = None
+ ) -> ExpressionIndex:
"""
``store`` Writes ``size`` bytes to expression ``addr`` read from expression ``value``
@@ -3209,7 +3194,7 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_STORE, addr, value, size=size, flags=flags)
- def push(self, size:int, value:ExpressionIndex) -> ExpressionIndex:
+ def push(self, size: int, value: ExpressionIndex) -> ExpressionIndex:
"""
``push`` writes ``size`` bytes from expression ``value`` to the stack, adjusting the stack by ``size``.
@@ -3220,7 +3205,7 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_PUSH, value, size=size)
- def pop(self, size:int) -> ExpressionIndex:
+ def pop(self, size: int) -> ExpressionIndex:
"""
``pop`` reads ``size`` bytes from the stack, adjusting the stack by ``size``.
@@ -3230,7 +3215,7 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_POP, size=size)
- def reg(self, size:int, reg:'architecture.RegisterType') -> ExpressionIndex:
+ def reg(self, size: int, reg: 'architecture.RegisterType') -> ExpressionIndex:
"""
``reg`` returns a register of size ``size`` with name ``reg``
@@ -3242,7 +3227,7 @@ class LowLevelILFunction:
_reg = ExpressionIndex(self.arch.get_reg_index(reg))
return self.expr(LowLevelILOperation.LLIL_REG, _reg, size=size)
- def reg_split(self, size:int, hi:'architecture.RegisterType', lo:'architecture.RegisterType') -> ExpressionIndex:
+ def reg_split(self, size: int, hi: 'architecture.RegisterType', lo: 'architecture.RegisterType') -> ExpressionIndex:
"""
``reg_split`` combines registers of size ``size`` with names ``hi`` and ``lo``
@@ -3256,7 +3241,9 @@ class LowLevelILFunction:
_lo = ExpressionIndex(self.arch.get_reg_index(lo))
return self.expr(LowLevelILOperation.LLIL_REG_SPLIT, _hi, _lo, size=size)
- def reg_stack_top_relative(self, size:int, reg_stack:'architecture.RegisterStackType', entry:ExpressionIndex) -> ExpressionIndex:
+ def reg_stack_top_relative(
+ self, size: int, reg_stack: 'architecture.RegisterStackType', entry: ExpressionIndex
+ ) -> ExpressionIndex:
"""
``reg_stack_top_relative`` returns a register stack entry of size ``size`` at top-relative
location ``entry`` in register stack with name ``reg_stack``
@@ -3270,7 +3257,7 @@ class LowLevelILFunction:
_reg_stack = self.arch.get_reg_stack_index(reg_stack)
return self.expr(LowLevelILOperation.LLIL_REG_STACK_REL, _reg_stack, entry, size=size)
- def reg_stack_pop(self, size:int, reg_stack:'architecture.RegisterStackType') -> ExpressionIndex:
+ def reg_stack_pop(self, size: int, reg_stack: 'architecture.RegisterStackType') -> ExpressionIndex:
"""
``reg_stack_pop`` returns the top entry of size ``size`` in register stack with name ``reg_stack``, and
removes the entry from the stack
@@ -3283,7 +3270,7 @@ class LowLevelILFunction:
_reg_stack = ExpressionIndex(self.arch.get_reg_stack_index(reg_stack))
return self.expr(LowLevelILOperation.LLIL_REG_STACK_POP, _reg_stack, size=size)
- def const(self, size:int, value:int) -> ExpressionIndex:
+ def const(self, size: int, value: int) -> ExpressionIndex:
"""
``const`` returns an expression for the constant integer ``value`` with size ``size``
@@ -3294,7 +3281,7 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_CONST, ExpressionIndex(value), size=size)
- def const_pointer(self, size:int, value:int) -> ExpressionIndex:
+ def const_pointer(self, size: int, value: int) -> ExpressionIndex:
"""
``const_pointer`` returns an expression for the constant pointer ``value`` with size ``size``
@@ -3305,7 +3292,7 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_CONST_PTR, value, size=size)
- def reloc_pointer(self, size:int, value:int) -> ExpressionIndex:
+ def reloc_pointer(self, size: int, value: int) -> ExpressionIndex:
"""
``reloc_pointer`` returns an expression for the constant relocated pointer ``value`` with size ``size``
@@ -3316,7 +3303,7 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_EXTERN_PTR, value, size=size)
- def float_const_raw(self, size:int, value:int) -> ExpressionIndex:
+ def float_const_raw(self, size: int, value: int) -> ExpressionIndex:
"""
``float_const_raw`` returns an expression for the constant raw binary floating point
value ``value`` with size ``size``
@@ -3328,7 +3315,7 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_FLOAT_CONST, value, size=size)
- def float_const_single(self, value:float) -> ExpressionIndex:
+ def float_const_single(self, value: float) -> ExpressionIndex:
"""
``float_const_single`` returns an expression for the single precision floating point value ``value``
@@ -3338,7 +3325,7 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_FLOAT_CONST, struct.unpack("I", struct.pack("f", value))[0], size=4)
- def float_const_double(self, value:float) -> ExpressionIndex:
+ def float_const_double(self, value: float) -> ExpressionIndex:
"""
``float_const_double`` returns an expression for the double precision floating point value ``value``
@@ -3348,7 +3335,7 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_FLOAT_CONST, struct.unpack("Q", struct.pack("d", value))[0], size=8)
- def flag(self, reg:'architecture.FlagName') -> ExpressionIndex:
+ def flag(self, reg: 'architecture.FlagName') -> ExpressionIndex:
"""
``flag`` returns a flag expression for the given flag name.
@@ -3358,7 +3345,7 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_FLAG, self.arch.get_flag_by_name(reg))
- def flag_bit(self, size:int, reg:'architecture.FlagName', bit:int) -> ExpressionIndex:
+ def flag_bit(self, size: int, reg: 'architecture.FlagName', bit: int) -> ExpressionIndex:
"""
``flag_bit`` sets the flag named ``reg`` and size ``size`` to the constant integer value ``bit``
@@ -3370,7 +3357,9 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_FLAG_BIT, self.arch.get_flag_by_name(reg), bit, size=size)
- def add(self, size:int, a:ExpressionIndex, b:ExpressionIndex, flags:'architecture.FlagType'=None) -> ExpressionIndex:
+ def add(
+ self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: 'architecture.FlagType' = None
+ ) -> ExpressionIndex:
"""
``add`` adds expression ``a`` to expression ``b`` potentially setting flags ``flags`` and returning
an expression of ``size`` bytes.
@@ -3384,8 +3373,10 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_ADD, a, b, size=size, flags=flags)
- def add_carry(self, size:int, a:ExpressionIndex, b:ExpressionIndex, carry:ExpressionIndex,
- flags:'architecture.FlagType'=None) -> ExpressionIndex:
+ def add_carry(
+ self, size: int, a: ExpressionIndex, b: ExpressionIndex, carry: ExpressionIndex,
+ flags: 'architecture.FlagType' = None
+ ) -> ExpressionIndex:
"""
``add_carry`` adds with carry expression ``a`` to expression ``b`` potentially setting flags ``flags`` and
returning an expression of ``size`` bytes.
@@ -3400,7 +3391,9 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_ADC, a, b, carry, size=size, flags=flags)
- def sub(self, size:int, a:ExpressionIndex, b:ExpressionIndex, flags:'architecture.FlagType'=None) -> ExpressionIndex:
+ def sub(
+ self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: 'architecture.FlagType' = None
+ ) -> ExpressionIndex:
"""
``sub`` subtracts expression ``b`` from expression ``a`` potentially setting flags ``flags`` and returning
an expression of ``size`` bytes.
@@ -3414,8 +3407,10 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_SUB, a, b, size=size, flags=flags)
- def sub_borrow(self, size:int, a:ExpressionIndex, b:ExpressionIndex, carry:ExpressionIndex,
- flags:'architecture.FlagType'=None) -> ExpressionIndex:
+ def sub_borrow(
+ self, size: int, a: ExpressionIndex, b: ExpressionIndex, carry: ExpressionIndex,
+ flags: 'architecture.FlagType' = None
+ ) -> ExpressionIndex:
"""
``sub_borrow`` subtracts with borrow expression ``b`` from expression ``a`` potentially setting flags ``flags``
and returning an expression of ``size`` bytes.
@@ -3430,7 +3425,9 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_SBB, a, b, carry, size=size, flags=flags)
- def and_expr(self, size:int, a:ExpressionIndex, b:ExpressionIndex, flags:'architecture.FlagType'=None) -> ExpressionIndex:
+ def and_expr(
+ self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: 'architecture.FlagType' = None
+ ) -> ExpressionIndex:
"""
``and_expr`` bitwise and's expression ``a`` and expression ``b`` potentially setting flags ``flags``
and returning an expression of ``size`` bytes.
@@ -3444,7 +3441,9 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_AND, a, b, size=size, flags=flags)
- def or_expr(self, size:int, a:ExpressionIndex, b:ExpressionIndex, flags:'architecture.FlagType'=None) -> ExpressionIndex:
+ def or_expr(
+ self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: 'architecture.FlagType' = None
+ ) -> ExpressionIndex:
"""
``or_expr`` bitwise or's expression ``a`` and expression ``b`` potentially setting flags ``flags``
and returning an expression of ``size`` bytes.
@@ -3458,7 +3457,9 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_OR, a, b, size=size, flags=flags)
- def xor_expr(self, size:int, a:ExpressionIndex, b:ExpressionIndex, flags:'architecture.FlagType'=None) -> ExpressionIndex:
+ def xor_expr(
+ self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: 'architecture.FlagType' = None
+ ) -> ExpressionIndex:
"""
``xor_expr`` xor's expression ``a`` with expression ``b`` potentially setting flags ``flags``
and returning an expression of ``size`` bytes.
@@ -3472,7 +3473,9 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_XOR, a, b, size=size, flags=flags)
- def shift_left(self, size:int, a:ExpressionIndex, b:ExpressionIndex, flags:'architecture.FlagType'=None) -> ExpressionIndex:
+ def shift_left(
+ self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: 'architecture.FlagType' = None
+ ) -> ExpressionIndex:
"""
``shift_left`` shifts left expression ``a`` by expression ``b`` from expression ``a`` potentially setting flags ``flags``
and returning an expression of ``size`` bytes.
@@ -3486,7 +3489,9 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_LSL, a, b, size=size, flags=flags)
- def logical_shift_right(self, size:int, a:ExpressionIndex, b:ExpressionIndex, flags:'architecture.FlagType'=None) -> ExpressionIndex:
+ def logical_shift_right(
+ self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: 'architecture.FlagType' = None
+ ) -> ExpressionIndex:
"""
``logical_shift_right`` shifts logically right expression ``a`` by expression ``b`` potentially setting flags
``flags`` and returning an expression of ``size`` bytes.
@@ -3500,7 +3505,9 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_LSR, a, b, size=size, flags=flags)
- def arith_shift_right(self, size:int, a:ExpressionIndex, b:ExpressionIndex, flags:'architecture.FlagType'=None) -> ExpressionIndex:
+ def arith_shift_right(
+ self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: 'architecture.FlagType' = None
+ ) -> ExpressionIndex:
"""
``arith_shift_right`` shifts arithmetic right expression ``a`` by expression ``b`` potentially setting flags
``flags`` and returning an expression of ``size`` bytes.
@@ -3514,7 +3521,9 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_ASR, a, b, size=size, flags=flags)
- def rotate_left(self, size:int, a:ExpressionIndex, b:ExpressionIndex, flags:'architecture.FlagType'=None) -> ExpressionIndex:
+ def rotate_left(
+ self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: 'architecture.FlagType' = None
+ ) -> ExpressionIndex:
"""
``rotate_left`` bitwise rotates left expression ``a`` by expression ``b`` potentially setting flags ``flags``
and returning an expression of ``size`` bytes.
@@ -3528,8 +3537,10 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_ROL, a, b, size=size, flags=flags)
- def rotate_left_carry(self, size:int, a:ExpressionIndex, b:ExpressionIndex, carry:ExpressionIndex,
- flags:'architecture.FlagType'=None) -> ExpressionIndex:
+ def rotate_left_carry(
+ self, size: int, a: ExpressionIndex, b: ExpressionIndex, carry: ExpressionIndex,
+ flags: 'architecture.FlagType' = None
+ ) -> ExpressionIndex:
"""
``rotate_left_carry`` bitwise rotates left with carry expression ``a`` by expression ``b`` potentially setting
flags ``flags`` and returning an expression of ``size`` bytes.
@@ -3544,7 +3555,9 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_RLC, a, b, carry, size=size, flags=flags)
- def rotate_right(self, size:int, a:ExpressionIndex, b:ExpressionIndex, flags:'architecture.FlagType'=None) -> ExpressionIndex:
+ def rotate_right(
+ self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: 'architecture.FlagType' = None
+ ) -> ExpressionIndex:
"""
``rotate_right`` bitwise rotates right expression ``a`` by expression ``b`` potentially setting flags ``flags``
and returning an expression of ``size`` bytes.
@@ -3558,8 +3571,10 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_ROR, a, b, size=size, flags=flags)
- def rotate_right_carry(self, size:int, a:ExpressionIndex, b:ExpressionIndex, carry:ExpressionIndex,
- flags:'architecture.FlagType'=None) -> ExpressionIndex:
+ def rotate_right_carry(
+ self, size: int, a: ExpressionIndex, b: ExpressionIndex, carry: ExpressionIndex,
+ flags: 'architecture.FlagType' = None
+ ) -> ExpressionIndex:
"""
``rotate_right_carry`` bitwise rotates right with carry expression ``a`` by expression ``b`` potentially setting
flags ``flags`` and returning an expression of ``size`` bytes.
@@ -3574,7 +3589,9 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_RRC, a, b, carry, size=size, flags=flags)
- def mult(self, size:int, a:ExpressionIndex, b:ExpressionIndex, flags:'architecture.FlagType'=None) -> ExpressionIndex:
+ def mult(
+ self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: 'architecture.FlagType' = None
+ ) -> ExpressionIndex:
"""
``mult`` multiplies expression ``a`` by expression ``b`` potentially setting flags ``flags`` and returning an
expression of ``size`` bytes.
@@ -3588,7 +3605,9 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_MUL, a, b, size=size, flags=flags)
- def mult_double_prec_signed(self, size:int, a:ExpressionIndex, b:ExpressionIndex, flags:'architecture.FlagType'=None) -> ExpressionIndex:
+ def mult_double_prec_signed(
+ self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: 'architecture.FlagType' = None
+ ) -> ExpressionIndex:
"""
``mult_double_prec_signed`` multiplies signed with double precision expression ``a`` by expression ``b``
potentially setting flags ``flags`` and returning an expression of ``size`` bytes.
@@ -3602,7 +3621,9 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_MULS_DP, a, b, size=size, flags=flags)
- def mult_double_prec_unsigned(self, size:int, a:ExpressionIndex, b:ExpressionIndex, flags:'architecture.FlagType'=None) -> ExpressionIndex:
+ def mult_double_prec_unsigned(
+ self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: 'architecture.FlagType' = None
+ ) -> ExpressionIndex:
"""
``mult_double_prec_unsigned`` multiplies unsigned with double precision expression ``a`` by expression ``b``
potentially setting flags ``flags`` and returning an expression of ``size`` bytes.
@@ -3616,7 +3637,9 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_MULU_DP, a, b, size=size, flags=flags)
- def div_signed(self, size:int, a:ExpressionIndex, b:ExpressionIndex, flags:'architecture.FlagType'=None) -> ExpressionIndex:
+ def div_signed(
+ self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: 'architecture.FlagType' = None
+ ) -> ExpressionIndex:
"""
``div_signed`` signed divide expression ``a`` by expression ``b`` potentially setting flags ``flags``
and returning an expression of ``size`` bytes.
@@ -3630,7 +3653,9 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_DIVS, a, b, size=size, flags=flags)
- def div_double_prec_signed(self, size:int, a:ExpressionIndex, b:ExpressionIndex, flags:'architecture.FlagType'=None) -> ExpressionIndex:
+ def div_double_prec_signed(
+ self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: 'architecture.FlagType' = None
+ ) -> ExpressionIndex:
"""
``div_double_prec_signed`` signed double precision divide using expression ``a`` as a
single double precision register by expression ``b`` potentially setting flags ``flags`` and returning an
@@ -3645,7 +3670,9 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_DIVS_DP, a, b, size=size, flags=flags)
- def div_unsigned(self, size:int, a:ExpressionIndex, b:ExpressionIndex, flags:'architecture.FlagType'=None) -> ExpressionIndex:
+ def div_unsigned(
+ self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: 'architecture.FlagType' = None
+ ) -> ExpressionIndex:
"""
``div_unsigned`` unsigned divide expression ``a`` by expression ``b`` potentially setting flags ``flags``
and returning an expression of ``size`` bytes.
@@ -3659,7 +3686,9 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_DIVU, a, b, size=size, flags=flags)
- def div_double_prec_unsigned(self, size:int, a:ExpressionIndex, b:ExpressionIndex, flags:'architecture.FlagType'=None) -> ExpressionIndex:
+ def div_double_prec_unsigned(
+ self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: 'architecture.FlagType' = None
+ ) -> ExpressionIndex:
"""
``div_double_prec_unsigned`` unsigned double precision divide using expression ``a`` as
a single double precision register by expression ``b`` potentially setting flags ``flags`` and returning an
@@ -3674,7 +3703,9 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_DIVU_DP, a, b, size=size, flags=flags)
- def mod_signed(self, size:int, a:ExpressionIndex, b:ExpressionIndex, flags:'architecture.FlagType'=None) -> ExpressionIndex:
+ def mod_signed(
+ self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: 'architecture.FlagType' = None
+ ) -> ExpressionIndex:
"""
``mod_signed`` signed modulus expression ``a`` by expression ``b`` potentially setting flags ``flags``
and returning an expression of ``size`` bytes.
@@ -3688,7 +3719,9 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_MODS, a, b, size=size, flags=flags)
- def mod_double_prec_signed(self, size:int, a:ExpressionIndex, b:ExpressionIndex, flags:'architecture.FlagType'=None) -> ExpressionIndex:
+ def mod_double_prec_signed(
+ self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: 'architecture.FlagType' = None
+ ) -> ExpressionIndex:
"""
``mod_double_prec_signed`` signed double precision modulus using expression ``a`` as a single
double precision register by expression ``b`` potentially setting flags ``flags`` and returning an expression
@@ -3703,7 +3736,9 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_MODS_DP, a, b, size=size, flags=flags)
- def mod_unsigned(self, size:int, a:ExpressionIndex, b:ExpressionIndex, flags:'architecture.FlagType'=None) -> ExpressionIndex:
+ def mod_unsigned(
+ self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: 'architecture.FlagType' = None
+ ) -> ExpressionIndex:
"""
``mod_unsigned`` unsigned modulus expression ``a`` by expression ``b`` potentially setting flags ``flags``
and returning an expression of ``size`` bytes.
@@ -3717,7 +3752,9 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_MODU, a, b, size=size, flags=flags)
- def mod_double_prec_unsigned(self, size:int, a:ExpressionIndex, b:ExpressionIndex, flags:'architecture.FlagType'=None) -> ExpressionIndex:
+ def mod_double_prec_unsigned(
+ self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: 'architecture.FlagType' = None
+ ) -> ExpressionIndex:
"""
``mod_double_prec_unsigned`` unsigned double precision modulus using expression ``a`` as
a single double precision register by expression ``b`` potentially setting flags ``flags`` and returning an
@@ -3732,7 +3769,7 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_MODU_DP, a, b, size=size, flags=flags)
- def neg_expr(self, size:int, value:ExpressionIndex, flags:'architecture.FlagType'=None) -> ExpressionIndex:
+ def neg_expr(self, size: int, value: ExpressionIndex, flags: 'architecture.FlagType' = None) -> ExpressionIndex:
"""
``neg_expr`` two's complement sign negation of expression ``value`` of size ``size`` potentially setting flags
@@ -3744,7 +3781,7 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_NEG, value, size=size, flags=flags)
- def not_expr(self, size:int, value:ExpressionIndex, flags:'architecture.FlagType'=None) -> ExpressionIndex:
+ def not_expr(self, size: int, value: ExpressionIndex, flags: 'architecture.FlagType' = None) -> ExpressionIndex:
"""
``not_expr`` bitwise inverse of expression ``value`` of size ``size`` potentially setting flags
@@ -3756,7 +3793,7 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_NOT, value, size=size, flags=flags)
- def sign_extend(self, size:int, value:ExpressionIndex, flags:'architecture.FlagType'=None) -> ExpressionIndex:
+ def sign_extend(self, size: int, value: ExpressionIndex, flags: 'architecture.FlagType' = None) -> ExpressionIndex:
"""
``sign_extend`` two's complement sign-extends the expression in ``value`` to ``size`` bytes
@@ -3768,7 +3805,7 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_SX, value, size=size, flags=flags)
- def zero_extend(self, size:int, value:ExpressionIndex, flags:'architecture.FlagType'=None) -> ExpressionIndex:
+ def zero_extend(self, size: int, value: ExpressionIndex, flags: 'architecture.FlagType' = None) -> ExpressionIndex:
"""
``zero_extend`` zero-extends the expression in ``value`` to ``size`` bytes
@@ -3779,7 +3816,7 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_ZX, value, size=size, flags=flags)
- def low_part(self, size:int, value:ExpressionIndex, flags:'architecture.FlagType'=None) -> ExpressionIndex:
+ def low_part(self, size: int, value: ExpressionIndex, flags: 'architecture.FlagType' = None) -> ExpressionIndex:
"""
``low_part`` truncates ``value`` to ``size`` bytes
@@ -3790,7 +3827,7 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_LOW_PART, value, size=size, flags=flags)
- def jump(self, dest:ExpressionIndex) -> ExpressionIndex:
+ def jump(self, dest: ExpressionIndex) -> ExpressionIndex:
"""
``jump`` returns an expression which jumps (branches) to the expression ``dest``
@@ -3800,7 +3837,7 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_JUMP, dest)
- def call(self, dest:ExpressionIndex) -> ExpressionIndex:
+ def call(self, dest: ExpressionIndex) -> ExpressionIndex:
"""
``call`` returns an expression which first pushes the address of the next instruction onto the stack then jumps
(branches) to the expression ``dest``
@@ -3811,7 +3848,7 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_CALL, dest)
- def call_stack_adjust(self, dest:ExpressionIndex, stack_adjust:int) -> ExpressionIndex:
+ def call_stack_adjust(self, dest: ExpressionIndex, stack_adjust: int) -> ExpressionIndex:
"""
``call_stack_adjust`` returns an expression which first pushes the address of the next instruction onto the stack
then jumps (branches) to the expression ``dest``. After the function exits, ``stack_adjust`` is added to the
@@ -3823,7 +3860,7 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_CALL_STACK_ADJUST, dest, stack_adjust)
- def tailcall(self, dest:ExpressionIndex) -> ExpressionIndex:
+ def tailcall(self, dest: ExpressionIndex) -> ExpressionIndex:
"""
``tailcall`` returns an expression which jumps (branches) to the expression ``dest``
@@ -3833,7 +3870,7 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_TAILCALL, dest)
- def ret(self, dest:ExpressionIndex) -> ExpressionIndex:
+ def ret(self, dest: ExpressionIndex) -> ExpressionIndex:
"""
``ret`` returns an expression which jumps (branches) to the expression ``dest``. ``ret`` is a special alias for
jump that makes the disassembler stop disassembling.
@@ -3853,8 +3890,10 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_NORET)
- def flag_condition(self, cond:Union[str, LowLevelILFlagCondition, int],
- sem_class:Optional['architecture.SemanticClassType']=None) -> ExpressionIndex:
+ def flag_condition(
+ self, cond: Union[str, LowLevelILFlagCondition, int],
+ sem_class: Optional['architecture.SemanticClassType'] = None
+ ) -> ExpressionIndex:
"""
``flag_condition`` returns a flag_condition expression for the given LowLevelILFlagCondition
@@ -3870,7 +3909,7 @@ class LowLevelILFunction:
class_index = self.arch.get_semantic_flag_class_index(sem_class)
return self.expr(LowLevelILOperation.LLIL_FLAG_COND, cond, architecture.SemanticClassIndex(class_index))
- def flag_group(self, sem_group:'architecture.SemanticGroupName') -> ExpressionIndex:
+ def flag_group(self, sem_group: 'architecture.SemanticGroupName') -> ExpressionIndex:
"""
``flag_group`` returns a flag_group expression for the given semantic flag group
@@ -3881,7 +3920,7 @@ class LowLevelILFunction:
group = self.arch.get_semantic_flag_group_index(sem_group)
return self.expr(LowLevelILOperation.LLIL_FLAG_GROUP, group)
- def compare_equal(self, size:int, a:ExpressionIndex, b:ExpressionIndex) -> ExpressionIndex:
+ def compare_equal(self, size: int, a: ExpressionIndex, b: ExpressionIndex) -> ExpressionIndex:
"""
``compare_equal`` returns comparison expression of size ``size`` checking if expression ``a`` is equal to
expression ``b``
@@ -3892,9 +3931,9 @@ class LowLevelILFunction:
:return: a comparison expression.
:rtype: ExpressionIndex
"""
- return self.expr(LowLevelILOperation.LLIL_CMP_E, a, b, size = size)
+ return self.expr(LowLevelILOperation.LLIL_CMP_E, a, b, size=size)
- def compare_not_equal(self, size:int, a:ExpressionIndex, b:ExpressionIndex) -> ExpressionIndex:
+ def compare_not_equal(self, size: int, a: ExpressionIndex, b: ExpressionIndex) -> ExpressionIndex:
"""
``compare_not_equal`` returns comparison expression of size ``size`` checking if expression ``a`` is not equal to
expression ``b``
@@ -3905,9 +3944,9 @@ class LowLevelILFunction:
:return: a comparison expression.
:rtype: ExpressionIndex
"""
- return self.expr(LowLevelILOperation.LLIL_CMP_NE, a, b, size = size)
+ return self.expr(LowLevelILOperation.LLIL_CMP_NE, a, b, size=size)
- def compare_signed_less_than(self, size:int, a:ExpressionIndex, b:ExpressionIndex) -> ExpressionIndex:
+ def compare_signed_less_than(self, size: int, a: ExpressionIndex, b: ExpressionIndex) -> ExpressionIndex:
"""
``compare_signed_less_than`` returns comparison expression of size ``size`` checking if expression ``a`` is
signed less than expression ``b``
@@ -3918,9 +3957,9 @@ class LowLevelILFunction:
:return: a comparison expression.
:rtype: ExpressionIndex
"""
- return self.expr(LowLevelILOperation.LLIL_CMP_SLT, a, b, size = size)
+ return self.expr(LowLevelILOperation.LLIL_CMP_SLT, a, b, size=size)
- def compare_unsigned_less_than(self, size:int, a:ExpressionIndex, b:ExpressionIndex) -> ExpressionIndex:
+ def compare_unsigned_less_than(self, size: int, a: ExpressionIndex, b: ExpressionIndex) -> ExpressionIndex:
"""
``compare_unsigned_less_than`` returns comparison expression of size ``size`` checking if expression ``a`` is
unsigned less than expression ``b``
@@ -3931,9 +3970,9 @@ class LowLevelILFunction:
:return: a comparison expression.
:rtype: ExpressionIndex
"""
- return self.expr(LowLevelILOperation.LLIL_CMP_ULT, a, b, size = size)
+ return self.expr(LowLevelILOperation.LLIL_CMP_ULT, a, b, size=size)
- def compare_signed_less_equal(self, size:int, a:ExpressionIndex, b:ExpressionIndex) -> ExpressionIndex:
+ def compare_signed_less_equal(self, size: int, a: ExpressionIndex, b: ExpressionIndex) -> ExpressionIndex:
"""
``compare_signed_less_equal`` returns comparison expression of size ``size`` checking if expression ``a`` is
signed less than or equal to expression ``b``
@@ -3944,9 +3983,9 @@ class LowLevelILFunction:
:return: a comparison expression.
:rtype: ExpressionIndex
"""
- return self.expr(LowLevelILOperation.LLIL_CMP_SLE, a, b, size = size)
+ return self.expr(LowLevelILOperation.LLIL_CMP_SLE, a, b, size=size)
- def compare_unsigned_less_equal(self, size:int, a:ExpressionIndex, b:ExpressionIndex) -> ExpressionIndex:
+ def compare_unsigned_less_equal(self, size: int, a: ExpressionIndex, b: ExpressionIndex) -> ExpressionIndex:
"""
``compare_unsigned_less_equal`` returns comparison expression of size ``size`` checking if expression ``a`` is
unsigned less than or equal to expression ``b``
@@ -3957,9 +3996,9 @@ class LowLevelILFunction:
:return: a comparison expression.
:rtype: ExpressionIndex
"""
- return self.expr(LowLevelILOperation.LLIL_CMP_ULE, a, b, size = size)
+ return self.expr(LowLevelILOperation.LLIL_CMP_ULE, a, b, size=size)
- def compare_signed_greater_equal(self, size:int, a:ExpressionIndex, b:ExpressionIndex) -> ExpressionIndex:
+ def compare_signed_greater_equal(self, size: int, a: ExpressionIndex, b: ExpressionIndex) -> ExpressionIndex:
"""
``compare_signed_greater_equal`` returns comparison expression of size ``size`` checking if expression ``a`` is
signed greater than or equal to expression ``b``
@@ -3970,9 +4009,9 @@ class LowLevelILFunction:
:return: a comparison expression.
:rtype: ExpressionIndex
"""
- return self.expr(LowLevelILOperation.LLIL_CMP_SGE, a, b, size = size)
+ return self.expr(LowLevelILOperation.LLIL_CMP_SGE, a, b, size=size)
- def compare_unsigned_greater_equal(self, size:int, a:ExpressionIndex, b:ExpressionIndex) -> ExpressionIndex:
+ def compare_unsigned_greater_equal(self, size: int, a: ExpressionIndex, b: ExpressionIndex) -> ExpressionIndex:
"""
``compare_unsigned_greater_equal`` returns comparison expression of size ``size`` checking if expression ``a``
is unsigned greater than or equal to expression ``b``
@@ -3983,9 +4022,9 @@ class LowLevelILFunction:
:return: a comparison expression.
:rtype: ExpressionIndex
"""
- return self.expr(LowLevelILOperation.LLIL_CMP_UGE, a, b, size = size)
+ return self.expr(LowLevelILOperation.LLIL_CMP_UGE, a, b, size=size)
- def compare_signed_greater_than(self, size:int, a:ExpressionIndex, b:ExpressionIndex) -> ExpressionIndex:
+ def compare_signed_greater_than(self, size: int, a: ExpressionIndex, b: ExpressionIndex) -> ExpressionIndex:
"""
``compare_signed_greater_than`` returns comparison expression of size ``size`` checking if expression ``a`` is
signed greater than or equal to expression ``b``
@@ -3996,9 +4035,9 @@ class LowLevelILFunction:
:return: a comparison expression.
:rtype: ExpressionIndex
"""
- return self.expr(LowLevelILOperation.LLIL_CMP_SGT, a, b, size = size)
+ return self.expr(LowLevelILOperation.LLIL_CMP_SGT, a, b, size=size)
- def compare_unsigned_greater_than(self, size:int, a:ExpressionIndex, b:ExpressionIndex) -> ExpressionIndex:
+ def compare_unsigned_greater_than(self, size: int, a: ExpressionIndex, b: ExpressionIndex) -> ExpressionIndex:
"""
``compare_unsigned_greater_than`` returns comparison expression of size ``size`` checking if expression ``a`` is
unsigned greater than or equal to expression ``b``
@@ -4009,10 +4048,10 @@ class LowLevelILFunction:
:return: a comparison expression.
:rtype: ExpressionIndex
"""
- return self.expr(LowLevelILOperation.LLIL_CMP_UGT, a, b, size = size)
+ return self.expr(LowLevelILOperation.LLIL_CMP_UGT, a, b, size=size)
- def test_bit(self, size:int, a:ExpressionIndex, b:ExpressionIndex) -> ExpressionIndex:
- return self.expr(LowLevelILOperation.LLIL_TEST_BIT, a, b, size = size)
+ def test_bit(self, size: int, a: ExpressionIndex, b: ExpressionIndex) -> ExpressionIndex:
+ return self.expr(LowLevelILOperation.LLIL_TEST_BIT, a, b, size=size)
def system_call(self) -> ExpressionIndex:
"""
@@ -4023,8 +4062,10 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_SYSCALL)
- def intrinsic(self, outputs:List[Union[ILFlag, ExpressionIndex]], intrinsic:'architecture.IntrinsicType',
- params:List[ExpressionIndex], flags:'architecture.FlagType'=None):
+ def intrinsic(
+ self, outputs: List[Union[ILFlag, ExpressionIndex]], intrinsic: 'architecture.IntrinsicType',
+ params: List[ExpressionIndex], flags: 'architecture.FlagType' = None
+ ):
"""
``intrinsic`` return an intrinsic expression.
@@ -4041,8 +4082,10 @@ class LowLevelILFunction:
for param in params:
param_list.append(param)
call_param = self.expr(LowLevelILOperation.LLIL_CALL_PARAM, len(params), self.add_operand_list(param_list))
- return self.expr(LowLevelILOperation.LLIL_INTRINSIC, len(outputs), self.add_operand_list(output_list),
- self.arch.get_intrinsic_index(intrinsic), call_param, flags = flags)
+ return self.expr(
+ LowLevelILOperation.LLIL_INTRINSIC, len(outputs), self.add_operand_list(output_list),
+ self.arch.get_intrinsic_index(intrinsic), call_param, flags=flags
+ )
def breakpoint(self) -> ExpressionIndex:
"""
@@ -4053,7 +4096,7 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_BP)
- def trap(self, value:int) -> ExpressionIndex:
+ def trap(self, value: int) -> ExpressionIndex:
"""
``trap`` returns a processor trap (interrupt) expression of the given integer ``value``.
@@ -4083,7 +4126,7 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_UNIMPL)
- def unimplemented_memory_ref(self, size:int, addr:ExpressionIndex) -> ExpressionIndex:
+ def unimplemented_memory_ref(self, size: int, addr: ExpressionIndex) -> ExpressionIndex:
"""
``unimplemented_memory_ref`` a memory reference to expression ``addr`` of size ``size`` with unimplemented operation.
@@ -4092,9 +4135,11 @@ class LowLevelILFunction:
:return: the unimplemented memory reference expression.
:rtype: ExpressionIndex
"""
- return self.expr(LowLevelILOperation.LLIL_UNIMPL_MEM, addr, size = size)
+ return self.expr(LowLevelILOperation.LLIL_UNIMPL_MEM, addr, size=size)
- def float_add(self, size:int, a:ExpressionIndex, b:ExpressionIndex, flags:'architecture.FlagType'=None) -> ExpressionIndex:
+ def float_add(
+ self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: 'architecture.FlagType' = None
+ ) -> ExpressionIndex:
"""
``float_add`` adds floating point expression ``a`` to expression ``b`` potentially setting flags ``flags``
and returning an expression of ``size`` bytes.
@@ -4108,7 +4153,9 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_FADD, a, b, size=size, flags=flags)
- def float_sub(self, size:int, a:ExpressionIndex, b:ExpressionIndex, flags:'architecture.FlagType'=None) -> ExpressionIndex:
+ def float_sub(
+ self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: 'architecture.FlagType' = None
+ ) -> ExpressionIndex:
"""
``float_sub`` subtracts floating point expression ``b`` from expression ``a`` potentially setting flags ``flags``
and returning an expression of ``size`` bytes.
@@ -4122,7 +4169,9 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_FSUB, a, b, size=size, flags=flags)
- def float_mult(self, size:int, a:ExpressionIndex, b:ExpressionIndex, flags:'architecture.FlagType'=None) -> ExpressionIndex:
+ def float_mult(
+ self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: 'architecture.FlagType' = None
+ ) -> ExpressionIndex:
"""
``float_mult`` multiplies floating point expression ``a`` by expression ``b`` potentially setting flags ``flags``
and returning an expression of ``size`` bytes.
@@ -4136,7 +4185,9 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_FMUL, a, b, size=size, flags=flags)
- def float_div(self, size:int, a:ExpressionIndex, b:ExpressionIndex, flags:'architecture.FlagType'=None) -> ExpressionIndex:
+ def float_div(
+ self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: 'architecture.FlagType' = None
+ ) -> ExpressionIndex:
"""
``float_div`` divides floating point expression ``a`` by expression ``b`` potentially setting flags ``flags``
and returning an expression of ``size`` bytes.
@@ -4150,7 +4201,7 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_FDIV, a, b, size=size, flags=flags)
- def float_sqrt(self, size:int, value:ExpressionIndex, flags:'architecture.FlagType'=None) -> ExpressionIndex:
+ def float_sqrt(self, size: int, value: ExpressionIndex, flags: 'architecture.FlagType' = None) -> ExpressionIndex:
"""
``float_sqrt`` returns square root of floating point expression ``value`` of size ``size`` potentially setting flags
@@ -4162,7 +4213,7 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_FSQRT, value, size=size, flags=flags)
- def float_neg(self, size:int, value:ExpressionIndex, flags:'architecture.FlagType'=None) -> ExpressionIndex:
+ def float_neg(self, size: int, value: ExpressionIndex, flags: 'architecture.FlagType' = None) -> ExpressionIndex:
"""
``float_neg`` returns sign negation of floating point expression ``value`` of size ``size`` potentially setting flags
@@ -4174,7 +4225,7 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_FNEG, value, size=size, flags=flags)
- def float_abs(self, size:int, value:ExpressionIndex, flags:'architecture.FlagType'=None) -> ExpressionIndex:
+ def float_abs(self, size: int, value: ExpressionIndex, flags: 'architecture.FlagType' = None) -> ExpressionIndex:
"""
``float_abs`` returns absolute value of floating point expression ``value`` of size ``size`` potentially setting flags
@@ -4186,7 +4237,7 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_FABS, value, size=size, flags=flags)
- def float_to_int(self, size:int, value:ExpressionIndex, flags:'architecture.FlagType'=None) -> ExpressionIndex:
+ def float_to_int(self, size: int, value: ExpressionIndex, flags: 'architecture.FlagType' = None) -> ExpressionIndex:
"""
``float_to_int`` returns integer value of floating point expression ``value`` of size ``size`` potentially setting flags
@@ -4198,7 +4249,7 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_FLOAT_TO_INT, value, size=size, flags=flags)
- def int_to_float(self, size:int, value:ExpressionIndex, flags:'architecture.FlagType'=None) -> ExpressionIndex:
+ def int_to_float(self, size: int, value: ExpressionIndex, flags: 'architecture.FlagType' = None) -> ExpressionIndex:
"""
``int_to_float`` returns floating point value of integer expression ``value`` of size ``size`` potentially setting flags
@@ -4210,7 +4261,9 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_INT_TO_FLOAT, value, size=size, flags=flags)
- def float_convert(self, size:int, value:ExpressionIndex, flags:'architecture.FlagType'=None) -> ExpressionIndex:
+ def float_convert(
+ self, size: int, value: ExpressionIndex, flags: 'architecture.FlagType' = None
+ ) -> ExpressionIndex:
"""
``int_to_float`` converts floating point value of expression ``value`` to size ``size`` potentially setting flags
@@ -4222,7 +4275,7 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_FLOAT_CONV, value, size=size, flags=flags)
- def round_to_int(self, size:int, value:ExpressionIndex, flags:'architecture.FlagType'=None) -> ExpressionIndex:
+ def round_to_int(self, size: int, value: ExpressionIndex, flags: 'architecture.FlagType' = None) -> ExpressionIndex:
"""
``round_to_int`` rounds a floating point value to the nearest integer
@@ -4234,7 +4287,7 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_ROUND_TO_INT, value, size=size, flags=flags)
- def floor(self, size:int, value:ExpressionIndex, flags:'architecture.FlagType'=None) -> ExpressionIndex:
+ def floor(self, size: int, value: ExpressionIndex, flags: 'architecture.FlagType' = None) -> ExpressionIndex:
"""
``floor`` rounds a floating point value to an integer towards negative infinity
@@ -4246,7 +4299,7 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_FLOOR, value, size=size, flags=flags)
- def ceil(self, size:int, value:ExpressionIndex, flags:'architecture.FlagType'=None) -> ExpressionIndex:
+ def ceil(self, size: int, value: ExpressionIndex, flags: 'architecture.FlagType' = None) -> ExpressionIndex:
"""
``ceil`` rounds a floating point value to an integer towards positive infinity
@@ -4258,7 +4311,7 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_CEIL, value, size=size, flags=flags)
- def float_trunc(self, size:int, value:ExpressionIndex, flags:'architecture.FlagType'=None) -> ExpressionIndex:
+ def float_trunc(self, size: int, value: ExpressionIndex, flags: 'architecture.FlagType' = None) -> ExpressionIndex:
"""
``float_trunc`` rounds a floating point value to an integer towards zero
@@ -4270,7 +4323,7 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_FTRUNC, value, size=size, flags=flags)
- def float_compare_equal(self, size:int, a:ExpressionIndex, b:ExpressionIndex) -> ExpressionIndex:
+ def float_compare_equal(self, size: int, a: ExpressionIndex, b: ExpressionIndex) -> ExpressionIndex:
"""
``float_compare_equal`` returns floating point comparison expression of size ``size`` checking if
expression ``a`` is equal to expression ``b``
@@ -4284,7 +4337,7 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_FCMP_E, a, b)
- def float_compare_not_equal(self, size:int, a:ExpressionIndex, b:ExpressionIndex) -> ExpressionIndex:
+ def float_compare_not_equal(self, size: int, a: ExpressionIndex, b: ExpressionIndex) -> ExpressionIndex:
"""
``float_compare_not_equal`` returns floating point comparison expression of size ``size`` checking if
expression ``a`` is not equal to expression ``b``
@@ -4298,7 +4351,7 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_FCMP_NE, a, b)
- def float_compare_less_than(self, size:int, a:ExpressionIndex, b:ExpressionIndex) -> ExpressionIndex:
+ def float_compare_less_than(self, size: int, a: ExpressionIndex, b: ExpressionIndex) -> ExpressionIndex:
"""
``float_compare_less_than`` returns floating point comparison expression of size ``size`` checking if
expression ``a`` is less than to expression ``b``
@@ -4312,7 +4365,7 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_FCMP_LT, a, b)
- def float_compare_less_equal(self, size:int, a:ExpressionIndex, b:ExpressionIndex) -> ExpressionIndex:
+ def float_compare_less_equal(self, size: int, a: ExpressionIndex, b: ExpressionIndex) -> ExpressionIndex:
"""
``float_compare_less_equal`` returns floating point comparison expression of size ``size`` checking if
expression ``a`` is less than or equal to expression ``b``
@@ -4326,7 +4379,7 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_FCMP_LE, a, b)
- def float_compare_greater_equal(self, size:int, a:ExpressionIndex, b:ExpressionIndex) -> ExpressionIndex:
+ def float_compare_greater_equal(self, size: int, a: ExpressionIndex, b: ExpressionIndex) -> ExpressionIndex:
"""
``float_compare_greater_equal`` returns floating point comparison expression of size ``size`` checking if
expression ``a`` is greater than or equal to expression ``b``
@@ -4340,7 +4393,7 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_FCMP_GE, a, b)
- def float_compare_greater_than(self, size:int, a:ExpressionIndex, b:ExpressionIndex) -> ExpressionIndex:
+ def float_compare_greater_than(self, size: int, a: ExpressionIndex, b: ExpressionIndex) -> ExpressionIndex:
"""
``float_compare_greater_than`` returns floating point comparison expression of size ``size`` checking if
expression ``a`` is greater than or equal to expression ``b``
@@ -4354,7 +4407,7 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_FCMP_GT, a, b)
- def float_compare_unordered(self, size:int, a:ExpressionIndex, b:ExpressionIndex) -> ExpressionIndex:
+ def float_compare_unordered(self, size: int, a: ExpressionIndex, b: ExpressionIndex) -> ExpressionIndex:
"""
``float_compare_unordered`` returns floating point comparison expression of size ``size`` checking if
expression ``a`` is unordered relative to expression ``b``
@@ -4368,7 +4421,7 @@ class LowLevelILFunction:
"""
return self.expr(LowLevelILOperation.LLIL_FCMP_UO, a, b)
- def goto(self, label:LowLevelILLabel) -> ExpressionIndex:
+ def goto(self, label: LowLevelILLabel) -> ExpressionIndex:
"""
``goto`` returns a goto expression which jumps to the provided LowLevelILLabel.
@@ -4378,7 +4431,7 @@ class LowLevelILFunction:
"""
return ExpressionIndex(core.BNLowLevelILGoto(self.handle, label.handle))
- def if_expr(self, operand:ExpressionIndex, t:LowLevelILLabel, f:LowLevelILLabel) -> ExpressionIndex:
+ def if_expr(self, operand: ExpressionIndex, t: LowLevelILLabel, f: LowLevelILLabel) -> ExpressionIndex:
"""
``if_expr`` returns the ``if`` expression which depending on condition ``operand`` jumps to the LowLevelILLabel
``t`` when the condition expression ``operand`` is non-zero and ``f`` when it's zero.
@@ -4391,7 +4444,7 @@ class LowLevelILFunction:
"""
return ExpressionIndex(core.BNLowLevelILIf(self.handle, operand, t.handle, f.handle))
- def mark_label(self, label:LowLevelILLabel) -> None:
+ def mark_label(self, label: LowLevelILLabel) -> None:
"""
``mark_label`` assigns a LowLevelILLabel to the current IL address.
@@ -4400,7 +4453,7 @@ class LowLevelILFunction:
"""
core.BNLowLevelILMarkLabel(self.handle, label.handle)
- def add_label_map(self, labels:Dict[int, LowLevelILLabel]) -> ExpressionIndex:
+ def add_label_map(self, labels: Dict[int, LowLevelILLabel]) -> ExpressionIndex:
"""
``add_label_map`` returns a label list expression for the given list of LowLevelILLabel objects.
@@ -4417,7 +4470,7 @@ class LowLevelILFunction:
return ExpressionIndex(core.BNLowLevelILAddLabelMap(self.handle, value_list, label_list, len(labels)))
- def add_operand_list(self, operands:List[Union[ExpressionIndex, ExpressionIndex]]) -> ExpressionIndex:
+ def add_operand_list(self, operands: List[Union[ExpressionIndex, ExpressionIndex]]) -> ExpressionIndex:
"""
``add_operand_list`` returns an operand list expression for the given list of integer operands.
@@ -4435,7 +4488,7 @@ class LowLevelILFunction:
raise Exception("Invalid operand type")
return ExpressionIndex(core.BNLowLevelILAddOperandList(self.handle, operand_list, len(operands)))
- def operand(self, n:int, expr:ExpressionIndex) -> ExpressionIndex:
+ def operand(self, n: int, expr: ExpressionIndex) -> ExpressionIndex:
"""
``operand`` sets the operand number of the expression ``expr`` and passes back ``expr`` without modification.
@@ -4463,7 +4516,7 @@ class LowLevelILFunction:
"""
core.BNGenerateLowLevelILSSAForm(self.handle)
- def add_label_for_address(self, arch:'architecture.Architecture', addr:int) -> None:
+ def add_label_for_address(self, arch: 'architecture.Architecture', addr: int) -> None:
"""
``add_label_for_address`` adds a low-level IL label for the given architecture ``arch`` at the given virtual
address ``addr``
@@ -4475,7 +4528,7 @@ class LowLevelILFunction:
arch = arch.handle
core.BNAddLowLevelILLabelForAddress(self.handle, arch, addr)
- def get_label_for_address(self, arch:'architecture.Architecture', addr:int) -> Optional[LowLevelILLabel]:
+ def get_label_for_address(self, arch: 'architecture.Architecture', addr: int) -> Optional[LowLevelILLabel]:
"""
``get_label_for_address`` returns the LowLevelILLabel for the given Architecture ``arch`` and IL address ``addr``.
@@ -4491,33 +4544,33 @@ class LowLevelILFunction:
return None
return LowLevelILLabel(label)
- def get_ssa_instruction_index(self, instr:InstructionIndex) -> InstructionIndex:
+ def get_ssa_instruction_index(self, instr: InstructionIndex) -> InstructionIndex:
return core.BNGetLowLevelILSSAInstructionIndex(self.handle, instr)
- def get_non_ssa_instruction_index(self, instr:InstructionIndex) -> InstructionIndex:
+ def get_non_ssa_instruction_index(self, instr: InstructionIndex) -> InstructionIndex:
return core.BNGetLowLevelILNonSSAInstructionIndex(self.handle, instr)
- def get_ssa_reg_definition(self, reg_ssa:SSARegister) -> Optional[LowLevelILInstruction]:
+ def get_ssa_reg_definition(self, reg_ssa: SSARegister) -> Optional[LowLevelILInstruction]:
reg = self.arch.get_reg_index(reg_ssa.reg)
result = core.BNGetLowLevelILSSARegisterDefinition(self.handle, reg, reg_ssa.version)
if result >= core.BNGetLowLevelILInstructionCount(self.handle):
return None
return self[result]
- def get_ssa_flag_definition(self, flag_ssa:SSAFlag) -> Optional[LowLevelILInstruction]:
+ def get_ssa_flag_definition(self, flag_ssa: SSAFlag) -> Optional[LowLevelILInstruction]:
flag = self.arch.get_flag_index(flag_ssa.flag)
result = core.BNGetLowLevelILSSAFlagDefinition(self.handle, flag, flag_ssa.version)
if result >= core.BNGetLowLevelILInstructionCount(self.handle):
return None
return self[result]
- def get_ssa_memory_definition(self, index:int) -> Optional[LowLevelILInstruction]:
+ def get_ssa_memory_definition(self, index: int) -> Optional[LowLevelILInstruction]:
result = core.BNGetLowLevelILSSAMemoryDefinition(self.handle, index)
if result >= core.BNGetLowLevelILInstructionCount(self.handle):
return None
return self[result]
- def get_ssa_reg_uses(self, reg_ssa:SSARegister) -> List[LowLevelILInstruction]:
+ def get_ssa_reg_uses(self, reg_ssa: SSARegister) -> List[LowLevelILInstruction]:
reg = self.arch.get_reg_index(reg_ssa.reg)
count = ctypes.c_ulonglong()
instrs = core.BNGetLowLevelILSSARegisterUses(self.handle, reg, reg_ssa.version, count)
@@ -4528,7 +4581,7 @@ class LowLevelILFunction:
core.BNFreeILInstructionList(instrs)
return result
- def get_ssa_flag_uses(self, flag_ssa:SSAFlag) -> List[LowLevelILInstruction]:
+ def get_ssa_flag_uses(self, flag_ssa: SSAFlag) -> List[LowLevelILInstruction]:
flag = self.arch.get_flag_index(flag_ssa.flag)
count = ctypes.c_ulonglong()
instrs = core.BNGetLowLevelILSSAFlagUses(self.handle, flag, flag_ssa.version, count)
@@ -4539,7 +4592,7 @@ class LowLevelILFunction:
core.BNFreeILInstructionList(instrs)
return result
- def get_ssa_memory_uses(self, index:int) -> List[LowLevelILInstruction]:
+ def get_ssa_memory_uses(self, index: int) -> List[LowLevelILInstruction]:
count = ctypes.c_ulonglong()
instrs = core.BNGetLowLevelILSSAMemoryUses(self.handle, index, count)
assert instrs is not None, "core.BNGetLowLevelILSSAMemoryUses returned None"
@@ -4549,19 +4602,20 @@ class LowLevelILFunction:
core.BNFreeILInstructionList(instrs)
return result
- def get_ssa_reg_value(self, reg_ssa:SSARegister) -> 'variable.RegisterValue':
+ def get_ssa_reg_value(self, reg_ssa: SSARegister) -> 'variable.RegisterValue':
reg = self.arch.get_reg_index(reg_ssa.reg)
value = core.BNGetLowLevelILSSARegisterValue(self.handle, reg, reg_ssa.version)
result = variable.RegisterValue.from_BNRegisterValue(value, self._arch)
return result
- def get_ssa_flag_value(self, flag_ssa:SSAFlag) -> 'variable.RegisterValue':
+ def get_ssa_flag_value(self, flag_ssa: SSAFlag) -> 'variable.RegisterValue':
flag = self.arch.get_flag_index(flag_ssa.flag)
value = core.BNGetLowLevelILSSAFlagValue(self.handle, flag, flag_ssa.version)
result = variable.RegisterValue.from_BNRegisterValue(value, self._arch)
return result
- def get_medium_level_il_instruction_index(self, instr:InstructionIndex) -> Optional['mediumlevelil.InstructionIndex']:
+ def get_medium_level_il_instruction_index(self,
+ instr: InstructionIndex) -> Optional['mediumlevelil.InstructionIndex']:
med_il = self.medium_level_il
if med_il is None:
return None
@@ -4570,7 +4624,7 @@ class LowLevelILFunction:
return None
return result
- def get_medium_level_il_expr_index(self, expr:ExpressionIndex) -> Optional['mediumlevelil.ExpressionIndex']:
+ def get_medium_level_il_expr_index(self, expr: ExpressionIndex) -> Optional['mediumlevelil.ExpressionIndex']:
med_il = self.medium_level_il
if med_il is None:
return None
@@ -4579,7 +4633,7 @@ class LowLevelILFunction:
return None
return result
- def get_medium_level_il_expr_indexes(self, expr:ExpressionIndex) -> List['mediumlevelil.ExpressionIndex']:
+ def get_medium_level_il_expr_indexes(self, expr: ExpressionIndex) -> List['mediumlevelil.ExpressionIndex']:
count = ctypes.c_ulonglong()
exprs = core.BNGetMediumLevelILExprIndexes(self.handle, expr, count)
assert exprs is not None, "core.BNGetMediumLevelILExprIndexes returned None"
@@ -4589,7 +4643,7 @@ class LowLevelILFunction:
core.BNFreeILInstructionList(exprs)
return result
- def get_mapped_medium_level_il_instruction_index(self, instr:InstructionIndex) -> Optional[InstructionIndex]:
+ def get_mapped_medium_level_il_instruction_index(self, instr: InstructionIndex) -> Optional[InstructionIndex]:
med_il = self.mapped_medium_level_il
if med_il is None:
return None
@@ -4598,7 +4652,7 @@ class LowLevelILFunction:
return None
return result
- def get_mapped_medium_level_il_expr_index(self, expr:ExpressionIndex) -> Optional['mediumlevelil.ExpressionIndex']:
+ def get_mapped_medium_level_il_expr_index(self, expr: ExpressionIndex) -> Optional['mediumlevelil.ExpressionIndex']:
med_il = self.mapped_medium_level_il
if med_il is None:
return None
@@ -4607,7 +4661,7 @@ class LowLevelILFunction:
return None
return result
- def get_high_level_il_instruction_index(self, instr:InstructionIndex) -> Optional['highlevelil.InstructionIndex']:
+ def get_high_level_il_instruction_index(self, instr: InstructionIndex) -> Optional['highlevelil.InstructionIndex']:
med_il = self.medium_level_il
if med_il is None:
return None
@@ -4616,7 +4670,7 @@ class LowLevelILFunction:
return None
return med_il.get_high_level_il_instruction_index(mlil_instr)
- def get_high_level_il_expr_index(self, expr:ExpressionIndex) -> Optional['highlevelil.ExpressionIndex']:
+ def get_high_level_il_expr_index(self, expr: ExpressionIndex) -> Optional['highlevelil.ExpressionIndex']:
med_il = self.medium_level_il
if med_il is None:
return None
@@ -4625,7 +4679,7 @@ class LowLevelILFunction:
return None
return med_il.get_high_level_il_expr_index(mlil_expr)
- def create_graph(self, settings:Optional['function.DisassemblySettings']=None) -> flowgraph.CoreFlowGraph:
+ def create_graph(self, settings: Optional['function.DisassemblySettings'] = None) -> flowgraph.CoreFlowGraph:
if settings is not None:
settings_obj = settings.handle
else:
@@ -4634,7 +4688,9 @@ class LowLevelILFunction:
class LowLevelILBasicBlock(basicblock.BasicBlock):
- def __init__(self, handle:core.BNBasicBlockHandle, owner:LowLevelILFunction, view:Optional['binaryview.BinaryView']):
+ def __init__(
+ self, handle: core.BNBasicBlockHandle, owner: LowLevelILFunction, view: Optional['binaryview.BinaryView']
+ ):
super(LowLevelILBasicBlock, self).__init__(handle, view)
self._il_function = owner
@@ -4681,13 +4737,13 @@ class LowLevelILBasicBlock(basicblock.BasicBlock):
return self._il_function
-def LLIL_TEMP(n:Union[ILRegister, int]) -> int:
+def LLIL_TEMP(n: Union[ILRegister, int]) -> int:
return int(n) | 0x80000000
-def LLIL_REG_IS_TEMP(n:Union[ILRegister, int]) -> bool:
+def LLIL_REG_IS_TEMP(n: Union[ILRegister, int]) -> bool:
return (int(n) & 0x80000000) != 0
-def LLIL_GET_TEMP_REG_INDEX(n:Union[ILRegister, int]) -> int:
+def LLIL_GET_TEMP_REG_INDEX(n: Union[ILRegister, int]) -> int:
return int(n) & 0x7fffffff
diff --git a/python/mediumlevelil.py b/python/mediumlevelil.py
index 51413c79..e0bc60d1 100644
--- a/python/mediumlevelil.py
+++ b/python/mediumlevelil.py
@@ -37,9 +37,11 @@ from . import variable
from . import architecture
from . import binaryview
from .interaction import show_graph_report
-from .commonil import (BaseILInstruction, Constant, BinaryOperation, UnaryOperation, Comparison, SSA,
- Phi, FloatingPoint, ControlFlow, Terminal, Call, Localcall, Syscall, Tailcall, Return,
- Signed, Arithmetic, Carry, DoublePrecision, Memory, Load, Store, RegisterStack, SetVar)
+from .commonil import (
+ BaseILInstruction, Constant, BinaryOperation, UnaryOperation, Comparison, SSA, Phi, FloatingPoint, ControlFlow,
+ Terminal, Call, Localcall, Syscall, Tailcall, Return, Signed, Arithmetic, Carry, DoublePrecision, Memory, Load,
+ Store, RegisterStack, SetVar
+)
TokenList = List['function.InstructionTextToken']
ExpressionIndex = NewType('ExpressionIndex', int)
@@ -47,25 +49,16 @@ InstructionIndex = NewType('InstructionIndex', int)
MLILInstructionsType = Generator['MediumLevelILInstruction', None, None]
MLILBasicBlocksType = Generator['MediumLevelILBasicBlock', None, None]
OperandsType = Tuple[ExpressionIndex, ExpressionIndex, ExpressionIndex, ExpressionIndex, ExpressionIndex]
-MediumLevelILOperandType = Union[
- int,
- float,
- 'MediumLevelILOperationAndSize',
- 'MediumLevelILInstruction',
- 'lowlevelil.ILIntrinsic',
- 'variable.Variable',
- 'SSAVariable',
- List[int],
- List['variable.Variable'],
- List['SSAVariable'],
- List['MediumLevelILInstruction'],
- Mapping[int, int]
- ]
+MediumLevelILOperandType = Union[int, float, 'MediumLevelILOperationAndSize', 'MediumLevelILInstruction',
+ 'lowlevelil.ILIntrinsic', 'variable.Variable', 'SSAVariable', List[int],
+ List['variable.Variable'], List['SSAVariable'], List['MediumLevelILInstruction'],
+ Mapping[int, int]]
+
@dataclass(frozen=True, repr=False, order=True)
class SSAVariable:
- var:'variable.Variable'
- version:int
+ var: 'variable.Variable'
+ version: int
def __repr__(self):
return f"<ssa {self.var} version {self.version}>"
@@ -88,7 +81,7 @@ class SSAVariable:
class MediumLevelILLabel:
- def __init__(self, handle:Optional[core.BNMediumLevelILLabel]=None):
+ def __init__(self, handle: Optional[core.BNMediumLevelILLabel] = None):
if handle is None:
self.handle = (core.BNMediumLevelILLabel * 1)()
core.BNMediumLevelILInitLabel(self.handle)
@@ -98,8 +91,8 @@ class MediumLevelILLabel:
@dataclass(frozen=True, repr=False)
class MediumLevelILOperationAndSize:
- operation:MediumLevelILOperation
- size:int
+ operation: MediumLevelILOperation
+ size: int
def __repr__(self):
if self.size == 0:
@@ -109,16 +102,15 @@ class MediumLevelILOperationAndSize:
@dataclass(frozen=True)
class CoreMediumLevelILInstruction:
- operation:MediumLevelILOperation
- source_operand:int
- size:int
- operands:OperandsType
- address:int
-
+ operation: MediumLevelILOperation
+ source_operand: int
+ size: int
+ operands: OperandsType
+ address: int
@classmethod
- def from_BNMediumLevelILInstruction(cls, instr:core.BNMediumLevelILInstruction) -> 'CoreMediumLevelILInstruction':
- operands:OperandsType = tuple([ExpressionIndex(instr.operands[i]) for i in range(5)]) # type: ignore
+ def from_BNMediumLevelILInstruction(cls, instr: core.BNMediumLevelILInstruction) -> 'CoreMediumLevelILInstruction':
+ operands: OperandsType = tuple([ExpressionIndex(instr.operands[i]) for i in range(5)]) # type: ignore
return cls(MediumLevelILOperation(instr.operation), instr.sourceOperand, instr.size, operands, instr.address)
@@ -130,142 +122,199 @@ class MediumLevelILInstruction(BaseILInstruction):
Infix notation is thus more natural to read than other notations (e.g. x86 ``mov eax, 0`` vs. MLIL ``eax = 0``).
"""
- function:'MediumLevelILFunction'
- expr_index:ExpressionIndex
- instr:CoreMediumLevelILInstruction
- instr_index:InstructionIndex
- ILOperations:ClassVar[Mapping[MediumLevelILOperation, List[Tuple[str,str]]]] = {
- MediumLevelILOperation.MLIL_NOP: [],
- MediumLevelILOperation.MLIL_SET_VAR: [("dest", "var"), ("src", "expr")],
- MediumLevelILOperation.MLIL_SET_VAR_FIELD: [("dest", "var"), ("offset", "int"), ("src", "expr")],
- MediumLevelILOperation.MLIL_SET_VAR_SPLIT: [("high", "var"), ("low", "var"), ("src", "expr")],
- MediumLevelILOperation.MLIL_LOAD: [("src", "expr")],
- MediumLevelILOperation.MLIL_LOAD_STRUCT: [("src", "expr"), ("offset", "int")],
- MediumLevelILOperation.MLIL_STORE: [("dest", "expr"), ("src", "expr")],
- MediumLevelILOperation.MLIL_STORE_STRUCT: [("dest", "expr"), ("offset", "int"), ("src", "expr")],
- MediumLevelILOperation.MLIL_VAR: [("src", "var")],
- MediumLevelILOperation.MLIL_VAR_FIELD: [("src", "var"), ("offset", "int")],
- MediumLevelILOperation.MLIL_VAR_SPLIT: [("high", "var"), ("low", "var")],
- MediumLevelILOperation.MLIL_ADDRESS_OF: [("src", "var")],
- MediumLevelILOperation.MLIL_ADDRESS_OF_FIELD: [("src", "var"), ("offset", "int")],
- MediumLevelILOperation.MLIL_CONST: [("constant", "int")],
- MediumLevelILOperation.MLIL_CONST_PTR: [("constant", "int")],
- MediumLevelILOperation.MLIL_EXTERN_PTR: [("constant", "int"), ("offset", "int")],
- MediumLevelILOperation.MLIL_FLOAT_CONST: [("constant", "float")],
- MediumLevelILOperation.MLIL_IMPORT: [("constant", "int")],
- MediumLevelILOperation.MLIL_ADD: [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_ADC: [("left", "expr"), ("right", "expr"), ("carry", "expr")],
- MediumLevelILOperation.MLIL_SUB: [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_SBB: [("left", "expr"), ("right", "expr"), ("carry", "expr")],
- MediumLevelILOperation.MLIL_AND: [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_OR: [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_XOR: [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_LSL: [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_LSR: [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_ASR: [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_ROL: [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_RLC: [("left", "expr"), ("right", "expr"), ("carry", "expr")],
- MediumLevelILOperation.MLIL_ROR: [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_RRC: [("left", "expr"), ("right", "expr"), ("carry", "expr")],
- MediumLevelILOperation.MLIL_MUL: [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_MULU_DP: [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_MULS_DP: [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_DIVU: [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_DIVU_DP: [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_DIVS: [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_DIVS_DP: [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_MODU: [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_MODU_DP: [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_MODS: [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_MODS_DP: [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_NEG: [("src", "expr")],
- MediumLevelILOperation.MLIL_NOT: [("src", "expr")],
- MediumLevelILOperation.MLIL_SX: [("src", "expr")],
- MediumLevelILOperation.MLIL_ZX: [("src", "expr")],
- MediumLevelILOperation.MLIL_LOW_PART: [("src", "expr")],
- MediumLevelILOperation.MLIL_JUMP: [("dest", "expr")],
- MediumLevelILOperation.MLIL_JUMP_TO: [("dest", "expr"), ("targets", "target_map")],
- MediumLevelILOperation.MLIL_RET_HINT: [("dest", "expr")],
- MediumLevelILOperation.MLIL_CALL: [("output", "var_list"), ("dest", "expr"), ("params", "expr_list")],
- MediumLevelILOperation.MLIL_CALL_UNTYPED: [("output", "expr"), ("dest", "expr"), ("params", "expr"), ("stack", "expr")],
- MediumLevelILOperation.MLIL_CALL_OUTPUT: [("dest", "var_list")],
- MediumLevelILOperation.MLIL_CALL_PARAM: [("src", "var_list")],
- MediumLevelILOperation.MLIL_RET: [("src", "expr_list")],
- MediumLevelILOperation.MLIL_NORET: [],
- MediumLevelILOperation.MLIL_IF: [("condition", "expr"), ("true", "int"), ("false", "int")],
- MediumLevelILOperation.MLIL_GOTO: [("dest", "int")],
- MediumLevelILOperation.MLIL_CMP_E: [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_CMP_NE: [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_CMP_SLT: [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_CMP_ULT: [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_CMP_SLE: [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_CMP_ULE: [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_CMP_SGE: [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_CMP_UGE: [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_CMP_SGT: [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_CMP_UGT: [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_TEST_BIT: [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_BOOL_TO_INT: [("src", "expr")],
- MediumLevelILOperation.MLIL_ADD_OVERFLOW: [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_SYSCALL: [("output", "var_list"), ("params", "expr_list")],
- MediumLevelILOperation.MLIL_SYSCALL_UNTYPED: [("output", "expr"), ("params", "expr"), ("stack", "expr")],
- MediumLevelILOperation.MLIL_TAILCALL: [("output", "var_list"), ("dest", "expr"), ("params", "expr_list")],
- MediumLevelILOperation.MLIL_TAILCALL_UNTYPED: [("output", "expr"), ("dest", "expr"), ("params", "expr"), ("stack", "expr")],
- MediumLevelILOperation.MLIL_BP: [],
- MediumLevelILOperation.MLIL_TRAP: [("vector", "int")],
- MediumLevelILOperation.MLIL_INTRINSIC: [("output", "var_list"), ("intrinsic", "intrinsic"), ("params", "expr_list")],
- MediumLevelILOperation.MLIL_INTRINSIC_SSA: [("output", "var_ssa_list"), ("intrinsic", "intrinsic"), ("params", "expr_list")],
- MediumLevelILOperation.MLIL_FREE_VAR_SLOT: [("dest", "var")],
- MediumLevelILOperation.MLIL_FREE_VAR_SLOT_SSA: [("prev", "var_ssa_dest_and_src")],
- MediumLevelILOperation.MLIL_UNDEF: [],
- MediumLevelILOperation.MLIL_UNIMPL: [],
- MediumLevelILOperation.MLIL_UNIMPL_MEM: [("src", "expr")],
- MediumLevelILOperation.MLIL_FADD: [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_FSUB: [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_FMUL: [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_FDIV: [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_FSQRT: [("src", "expr")],
- MediumLevelILOperation.MLIL_FNEG: [("src", "expr")],
- MediumLevelILOperation.MLIL_FABS: [("src", "expr")],
- MediumLevelILOperation.MLIL_FLOAT_TO_INT: [("src", "expr")],
- MediumLevelILOperation.MLIL_INT_TO_FLOAT: [("src", "expr")],
- MediumLevelILOperation.MLIL_FLOAT_CONV: [("src", "expr")],
- MediumLevelILOperation.MLIL_ROUND_TO_INT: [("src", "expr")],
- MediumLevelILOperation.MLIL_FLOOR: [("src", "expr")],
- MediumLevelILOperation.MLIL_CEIL: [("src", "expr")],
- MediumLevelILOperation.MLIL_FTRUNC: [("src", "expr")],
- MediumLevelILOperation.MLIL_FCMP_E: [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_FCMP_NE: [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_FCMP_LT: [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_FCMP_LE: [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_FCMP_GE: [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_FCMP_GT: [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_FCMP_O: [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_FCMP_UO: [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_SET_VAR_SSA: [("dest", "var_ssa"), ("src", "expr")],
- MediumLevelILOperation.MLIL_SET_VAR_SSA_FIELD: [("prev", "var_ssa_dest_and_src"), ("offset", "int"), ("src", "expr")],
- MediumLevelILOperation.MLIL_SET_VAR_SPLIT_SSA: [("high", "var_ssa"), ("low", "var_ssa"), ("src", "expr")],
- MediumLevelILOperation.MLIL_SET_VAR_ALIASED: [("prev", "var_ssa_dest_and_src"), ("src", "expr")],
- MediumLevelILOperation.MLIL_SET_VAR_ALIASED_FIELD: [("prev", "var_ssa_dest_and_src"), ("offset", "int"), ("src", "expr")],
- MediumLevelILOperation.MLIL_VAR_SSA: [("src", "var_ssa")],
- MediumLevelILOperation.MLIL_VAR_SSA_FIELD: [("src", "var_ssa"), ("offset", "int")],
- MediumLevelILOperation.MLIL_VAR_ALIASED: [("src", "var_ssa")],
- MediumLevelILOperation.MLIL_VAR_ALIASED_FIELD: [("src", "var_ssa"), ("offset", "int")],
- MediumLevelILOperation.MLIL_VAR_SPLIT_SSA: [("high", "var_ssa"), ("low", "var_ssa")],
- MediumLevelILOperation.MLIL_CALL_SSA: [("output", "expr"), ("dest", "expr"), ("params", "expr_list"), ("src_memory", "int")],
- MediumLevelILOperation.MLIL_CALL_UNTYPED_SSA: [("output", "expr"), ("dest", "expr"), ("params", "expr"), ("stack", "expr")],
- MediumLevelILOperation.MLIL_SYSCALL_SSA: [("output", "expr"), ("params", "expr_list"), ("src_memory", "int")],
- MediumLevelILOperation.MLIL_SYSCALL_UNTYPED_SSA: [("output", "expr"), ("params", "expr"), ("stack", "expr")],
- MediumLevelILOperation.MLIL_TAILCALL_SSA: [("output", "expr"), ("dest", "expr"), ("params", "expr_list"), ("src_memory", "int")],
- MediumLevelILOperation.MLIL_TAILCALL_UNTYPED_SSA: [("output", "expr"), ("dest", "expr"), ("params", "expr"), ("stack", "expr")],
- MediumLevelILOperation.MLIL_CALL_OUTPUT_SSA: [("dest_memory", "int"), ("dest", "var_ssa_list")],
- MediumLevelILOperation.MLIL_CALL_PARAM_SSA: [("src_memory", "int"), ("src", "var_ssa_list")],
- MediumLevelILOperation.MLIL_LOAD_SSA: [("src", "expr"), ("src_memory", "int")],
- MediumLevelILOperation.MLIL_LOAD_STRUCT_SSA: [("src", "expr"), ("offset", "int"), ("src_memory", "int")],
- MediumLevelILOperation.MLIL_STORE_SSA: [("dest", "expr"), ("dest_memory", "int"), ("src_memory", "int"), ("src", "expr")],
- MediumLevelILOperation.MLIL_STORE_STRUCT_SSA: [("dest", "expr"), ("offset", "int"), ("dest_memory", "int"), ("src_memory", "int"), ("src", "expr")],
- MediumLevelILOperation.MLIL_VAR_PHI: [("dest", "var_ssa"), ("src", "var_ssa_list")],
- MediumLevelILOperation.MLIL_MEM_PHI: [("dest_memory", "int"), ("src_memory", "int_list")]
+ function: 'MediumLevelILFunction'
+ expr_index: ExpressionIndex
+ instr: CoreMediumLevelILInstruction
+ instr_index: InstructionIndex
+ ILOperations: ClassVar[Mapping[MediumLevelILOperation, List[Tuple[str, str]]]] = {
+ MediumLevelILOperation.MLIL_NOP: [], MediumLevelILOperation.MLIL_SET_VAR: [("dest", "var"), ("src", "expr")],
+ MediumLevelILOperation.MLIL_SET_VAR_FIELD: [("dest", "var"), ("offset", "int"),
+ ("src", "expr")], MediumLevelILOperation.MLIL_SET_VAR_SPLIT: [
+ ("high", "var"), ("low", "var"), ("src", "expr")
+ ], MediumLevelILOperation.MLIL_LOAD: [("src", "expr")],
+ MediumLevelILOperation.MLIL_LOAD_STRUCT: [("src", "expr"),
+ ("offset", "int")], MediumLevelILOperation.MLIL_STORE: [
+ ("dest", "expr"), ("src", "expr")
+ ], MediumLevelILOperation.MLIL_STORE_STRUCT: [("dest", "expr"),
+ ("offset", "int"),
+ ("src", "expr")],
+ MediumLevelILOperation.MLIL_VAR: [("src", "var")], MediumLevelILOperation.MLIL_VAR_FIELD: [
+ ("src", "var"), ("offset", "int")
+ ], MediumLevelILOperation.MLIL_VAR_SPLIT: [("high", "var"), ("low", "var")],
+ MediumLevelILOperation.MLIL_ADDRESS_OF: [("src", "var")], MediumLevelILOperation.MLIL_ADDRESS_OF_FIELD: [
+ ("src", "var"), ("offset", "int")
+ ], MediumLevelILOperation.MLIL_CONST: [("constant", "int")], MediumLevelILOperation.MLIL_CONST_PTR: [
+ ("constant", "int")
+ ], MediumLevelILOperation.MLIL_EXTERN_PTR: [
+ ("constant", "int"), ("offset", "int")
+ ], MediumLevelILOperation.MLIL_FLOAT_CONST: [("constant", "float")], MediumLevelILOperation.MLIL_IMPORT: [
+ ("constant", "int")
+ ], MediumLevelILOperation.MLIL_ADD: [("left", "expr"), ("right", "expr")], MediumLevelILOperation.MLIL_ADC: [
+ ("left", "expr"), ("right", "expr"), ("carry", "expr")
+ ], MediumLevelILOperation.MLIL_SUB: [("left", "expr"), ("right", "expr")], MediumLevelILOperation.MLIL_SBB: [
+ ("left", "expr"), ("right", "expr"), ("carry", "expr")
+ ], MediumLevelILOperation.MLIL_AND: [("left", "expr"), ("right", "expr")], MediumLevelILOperation.MLIL_OR: [
+ ("left", "expr"), ("right", "expr")
+ ], MediumLevelILOperation.MLIL_XOR: [("left", "expr"), ("right", "expr")], MediumLevelILOperation.MLIL_LSL: [
+ ("left", "expr"), ("right", "expr")
+ ], MediumLevelILOperation.MLIL_LSR: [("left", "expr"), ("right", "expr")], MediumLevelILOperation.MLIL_ASR: [
+ ("left", "expr"), ("right", "expr")
+ ], MediumLevelILOperation.MLIL_ROL: [("left", "expr"), ("right", "expr")], MediumLevelILOperation.MLIL_RLC: [
+ ("left", "expr"), ("right", "expr"), ("carry", "expr")
+ ], MediumLevelILOperation.MLIL_ROR: [("left", "expr"),
+ ("right", "expr")], MediumLevelILOperation.MLIL_RRC: [("left", "expr"),
+ ("right", "expr"),
+ ("carry", "expr")],
+ MediumLevelILOperation.MLIL_MUL: [("left", "expr"), ("right", "expr")], MediumLevelILOperation.MLIL_MULU_DP: [
+ ("left", "expr"), ("right", "expr")
+ ], MediumLevelILOperation.MLIL_MULS_DP: [("left", "expr"),
+ ("right", "expr")], MediumLevelILOperation.MLIL_DIVU: [
+ ("left", "expr"), ("right", "expr")
+ ], MediumLevelILOperation.MLIL_DIVU_DP: [("left", "expr"),
+ ("right", "expr")],
+ MediumLevelILOperation.MLIL_DIVS: [("left", "expr"), ("right", "expr")], MediumLevelILOperation.MLIL_DIVS_DP: [
+ ("left", "expr"), ("right", "expr")
+ ], MediumLevelILOperation.MLIL_MODU: [("left", "expr"),
+ ("right", "expr")], MediumLevelILOperation.MLIL_MODU_DP: [
+ ("left", "expr"), ("right", "expr")
+ ], MediumLevelILOperation.MLIL_MODS: [("left", "expr"),
+ ("right", "expr")],
+ MediumLevelILOperation.MLIL_MODS_DP: [("left", "expr"), ("right", "expr")], MediumLevelILOperation.MLIL_NEG: [
+ ("src", "expr")
+ ], MediumLevelILOperation.MLIL_NOT: [("src", "expr")], MediumLevelILOperation.MLIL_SX: [
+ ("src", "expr")
+ ], MediumLevelILOperation.MLIL_ZX: [("src", "expr")], MediumLevelILOperation.MLIL_LOW_PART: [
+ ("src", "expr")
+ ], MediumLevelILOperation.MLIL_JUMP: [("dest", "expr")], MediumLevelILOperation.MLIL_JUMP_TO: [
+ ("dest", "expr"), ("targets", "target_map")
+ ], MediumLevelILOperation.MLIL_RET_HINT: [("dest", "expr")], MediumLevelILOperation.MLIL_CALL: [
+ ("output", "var_list"), ("dest", "expr"), ("params", "expr_list")
+ ], MediumLevelILOperation.MLIL_CALL_UNTYPED: [
+ ("output", "expr"), ("dest", "expr"), ("params", "expr"), ("stack", "expr")
+ ], MediumLevelILOperation.MLIL_CALL_OUTPUT: [("dest", "var_list")], MediumLevelILOperation.MLIL_CALL_PARAM: [
+ ("src", "var_list")
+ ], MediumLevelILOperation.MLIL_RET: [
+ ("src", "expr_list")
+ ], MediumLevelILOperation.MLIL_NORET: [], MediumLevelILOperation.MLIL_IF: [
+ ("condition", "expr"), ("true", "int"), ("false", "int")
+ ], MediumLevelILOperation.MLIL_GOTO: [("dest", "int")], MediumLevelILOperation.MLIL_CMP_E: [
+ ("left", "expr"), ("right", "expr")
+ ], MediumLevelILOperation.MLIL_CMP_NE: [("left", "expr"),
+ ("right", "expr")], MediumLevelILOperation.MLIL_CMP_SLT: [
+ ("left", "expr"), ("right", "expr")
+ ], MediumLevelILOperation.MLIL_CMP_ULT: [
+ ("left", "expr"), ("right", "expr")
+ ], MediumLevelILOperation.MLIL_CMP_SLE: [
+ ("left", "expr"), ("right", "expr")
+ ], MediumLevelILOperation.MLIL_CMP_ULE: [
+ ("left", "expr"), ("right", "expr")
+ ], MediumLevelILOperation.MLIL_CMP_SGE: [
+ ("left", "expr"), ("right", "expr")
+ ], MediumLevelILOperation.MLIL_CMP_UGE: [
+ ("left", "expr"), ("right", "expr")
+ ], MediumLevelILOperation.MLIL_CMP_SGT: [
+ ("left", "expr"), ("right", "expr")
+ ], MediumLevelILOperation.MLIL_CMP_UGT: [
+ ("left", "expr"), ("right", "expr")
+ ], MediumLevelILOperation.MLIL_TEST_BIT: [("left", "expr"),
+ ("right", "expr")],
+ MediumLevelILOperation.MLIL_BOOL_TO_INT: [("src", "expr")], MediumLevelILOperation.MLIL_ADD_OVERFLOW: [
+ ("left", "expr"), ("right", "expr")
+ ], MediumLevelILOperation.MLIL_SYSCALL: [
+ ("output", "var_list"), ("params", "expr_list")
+ ], MediumLevelILOperation.MLIL_SYSCALL_UNTYPED: [
+ ("output", "expr"), ("params", "expr"), ("stack", "expr")
+ ], MediumLevelILOperation.MLIL_TAILCALL: [
+ ("output", "var_list"), ("dest", "expr"), ("params", "expr_list")
+ ], MediumLevelILOperation.MLIL_TAILCALL_UNTYPED: [("output", "expr"), ("dest", "expr"), ("params", "expr"),
+ ("stack", "expr")], MediumLevelILOperation.MLIL_BP: [],
+ MediumLevelILOperation.MLIL_TRAP: [("vector", "int")], MediumLevelILOperation.MLIL_INTRINSIC: [
+ ("output", "var_list"), ("intrinsic", "intrinsic"), ("params", "expr_list")
+ ], MediumLevelILOperation.MLIL_INTRINSIC_SSA: [
+ ("output", "var_ssa_list"), ("intrinsic", "intrinsic"), ("params", "expr_list")
+ ], MediumLevelILOperation.MLIL_FREE_VAR_SLOT: [
+ ("dest", "var")
+ ], MediumLevelILOperation.MLIL_FREE_VAR_SLOT_SSA: [
+ ("prev", "var_ssa_dest_and_src")
+ ], MediumLevelILOperation.MLIL_UNDEF: [], MediumLevelILOperation.MLIL_UNIMPL: [],
+ MediumLevelILOperation.MLIL_UNIMPL_MEM: [("src", "expr")], MediumLevelILOperation.MLIL_FADD: [
+ ("left", "expr"), ("right", "expr")
+ ], MediumLevelILOperation.MLIL_FSUB: [("left", "expr"), ("right", "expr")], MediumLevelILOperation.MLIL_FMUL: [
+ ("left", "expr"), ("right", "expr")
+ ], MediumLevelILOperation.MLIL_FDIV: [("left", "expr"), ("right", "expr")], MediumLevelILOperation.MLIL_FSQRT: [
+ ("src", "expr")
+ ], MediumLevelILOperation.MLIL_FNEG: [("src", "expr")], MediumLevelILOperation.MLIL_FABS: [
+ ("src", "expr")
+ ], MediumLevelILOperation.MLIL_FLOAT_TO_INT: [("src", "expr")], MediumLevelILOperation.MLIL_INT_TO_FLOAT: [
+ ("src", "expr")
+ ], MediumLevelILOperation.MLIL_FLOAT_CONV: [("src", "expr")], MediumLevelILOperation.MLIL_ROUND_TO_INT: [
+ ("src", "expr")
+ ], MediumLevelILOperation.MLIL_FLOOR: [("src", "expr")], MediumLevelILOperation.MLIL_CEIL: [
+ ("src", "expr")
+ ], MediumLevelILOperation.MLIL_FTRUNC: [("src", "expr")], MediumLevelILOperation.MLIL_FCMP_E: [
+ ("left", "expr"), ("right", "expr")
+ ], MediumLevelILOperation.MLIL_FCMP_NE: [
+ ("left", "expr"), ("right", "expr")
+ ], MediumLevelILOperation.MLIL_FCMP_LT: [
+ ("left", "expr"), ("right", "expr")
+ ], MediumLevelILOperation.MLIL_FCMP_LE: [
+ ("left", "expr"), ("right", "expr")
+ ], MediumLevelILOperation.MLIL_FCMP_GE: [
+ ("left", "expr"), ("right", "expr")
+ ], MediumLevelILOperation.MLIL_FCMP_GT: [
+ ("left", "expr"), ("right", "expr")
+ ], MediumLevelILOperation.MLIL_FCMP_O: [
+ ("left", "expr"), ("right", "expr")
+ ], MediumLevelILOperation.MLIL_FCMP_UO: [
+ ("left", "expr"), ("right", "expr")
+ ], MediumLevelILOperation.MLIL_SET_VAR_SSA: [
+ ("dest", "var_ssa"), ("src", "expr")
+ ], MediumLevelILOperation.MLIL_SET_VAR_SSA_FIELD: [
+ ("prev", "var_ssa_dest_and_src"), ("offset", "int"), ("src", "expr")
+ ], MediumLevelILOperation.MLIL_SET_VAR_SPLIT_SSA: [
+ ("high", "var_ssa"), ("low", "var_ssa"), ("src", "expr")
+ ], MediumLevelILOperation.MLIL_SET_VAR_ALIASED: [
+ ("prev", "var_ssa_dest_and_src"), ("src", "expr")
+ ], MediumLevelILOperation.MLIL_SET_VAR_ALIASED_FIELD: [
+ ("prev", "var_ssa_dest_and_src"), ("offset", "int"), ("src", "expr")
+ ], MediumLevelILOperation.MLIL_VAR_SSA: [("src", "var_ssa")], MediumLevelILOperation.MLIL_VAR_SSA_FIELD: [
+ ("src", "var_ssa"), ("offset", "int")
+ ], MediumLevelILOperation.MLIL_VAR_ALIASED: [
+ ("src", "var_ssa")
+ ], MediumLevelILOperation.MLIL_VAR_ALIASED_FIELD: [
+ ("src", "var_ssa"), ("offset", "int")
+ ], MediumLevelILOperation.MLIL_VAR_SPLIT_SSA: [
+ ("high", "var_ssa"), ("low", "var_ssa")
+ ], MediumLevelILOperation.MLIL_CALL_SSA: [
+ ("output", "expr"), ("dest", "expr"),
+ ("params", "expr_list"), ("src_memory", "int")
+ ], MediumLevelILOperation.MLIL_CALL_UNTYPED_SSA: [
+ ("output", "expr"), ("dest", "expr"), ("params", "expr"), ("stack", "expr")
+ ], MediumLevelILOperation.MLIL_SYSCALL_SSA: [
+ ("output", "expr"), ("params", "expr_list"),
+ ("src_memory", "int")
+ ], MediumLevelILOperation.MLIL_SYSCALL_UNTYPED_SSA: [
+ ("output", "expr"), ("params", "expr"), ("stack", "expr")
+ ], MediumLevelILOperation.MLIL_TAILCALL_SSA: [
+ ("output", "expr"), ("dest", "expr"), ("params", "expr_list"), ("src_memory", "int")
+ ], MediumLevelILOperation.MLIL_TAILCALL_UNTYPED_SSA: [
+ ("output", "expr"), ("dest", "expr"), ("params", "expr"), ("stack", "expr")
+ ], MediumLevelILOperation.MLIL_CALL_OUTPUT_SSA: [
+ ("dest_memory", "int"), ("dest", "var_ssa_list")
+ ], MediumLevelILOperation.MLIL_CALL_PARAM_SSA: [
+ ("src_memory", "int"), ("src", "var_ssa_list")
+ ], MediumLevelILOperation.MLIL_LOAD_SSA: [
+ ("src", "expr"), ("src_memory", "int")
+ ], MediumLevelILOperation.MLIL_LOAD_STRUCT_SSA: [
+ ("src", "expr"), ("offset", "int"), ("src_memory", "int")
+ ], MediumLevelILOperation.MLIL_STORE_SSA: [("dest", "expr"), ("dest_memory", "int"), ("src_memory", "int"),
+ ("src", "expr")], MediumLevelILOperation.MLIL_STORE_STRUCT_SSA: [
+ ("dest", "expr"), ("offset", "int"), ("dest_memory", "int"),
+ ("src_memory", "int"), ("src", "expr")
+ ], MediumLevelILOperation.MLIL_VAR_PHI: [
+ ("dest", "var_ssa"), ("src", "var_ssa_list")
+ ], MediumLevelILOperation.MLIL_MEM_PHI: [("dest_memory", "int"),
+ ("src_memory", "int_list")]
}
@staticmethod
@@ -277,7 +326,9 @@ class MediumLevelILInstruction(BaseILInstruction):
show_graph_report("MLIL Class Hierarchy Graph", graph)
@classmethod
- def create(cls, func:'MediumLevelILFunction', expr_index:ExpressionIndex, instr_index:Optional[InstructionIndex]=None) -> 'MediumLevelILInstruction':
+ def create(
+ cls, func: 'MediumLevelILFunction', expr_index: ExpressionIndex, instr_index: Optional[InstructionIndex] = None
+ ) -> 'MediumLevelILInstruction':
assert func.arch is not None, "Attempted to create IL instruction with function missing an Architecture"
inst = core.BNGetMediumLevelILByIndex(func.handle, expr_index)
assert inst is not None, "core.BNGetMediumLevelILByIndex returned None"
@@ -299,27 +350,27 @@ class MediumLevelILInstruction(BaseILInstruction):
def __repr__(self):
return f"<mlil: {self}>"
- def __eq__(self, other:'MediumLevelILInstruction') -> bool:
+ def __eq__(self, other: 'MediumLevelILInstruction') -> bool:
if not isinstance(other, MediumLevelILInstruction):
return NotImplemented
return self.function == other.function and self.expr_index == other.expr_index
- def __lt__(self, other:'MediumLevelILInstruction') -> bool:
+ def __lt__(self, other: 'MediumLevelILInstruction') -> bool:
if not isinstance(other, MediumLevelILInstruction):
return NotImplemented
return self.function == other.function and self.expr_index < other.expr_index
- def __le__(self, other:'MediumLevelILInstruction') -> bool:
+ def __le__(self, other: 'MediumLevelILInstruction') -> bool:
if not isinstance(other, MediumLevelILInstruction):
return NotImplemented
return self.function == other.function and self.expr_index <= other.expr_index
- def __gt__(self, other:'MediumLevelILInstruction') -> bool:
+ def __gt__(self, other: 'MediumLevelILInstruction') -> bool:
if not isinstance(other, MediumLevelILInstruction):
return NotImplemented
return self.function == other.function and self.expr_index > other.expr_index
- def __ge__(self, other:'MediumLevelILInstruction') -> bool:
+ def __ge__(self, other: 'MediumLevelILInstruction') -> bool:
if not isinstance(other, MediumLevelILInstruction):
return NotImplemented
return self.function == other.function and self.expr_index >= other.expr_index
@@ -333,8 +384,9 @@ class MediumLevelILInstruction(BaseILInstruction):
count = ctypes.c_ulonglong()
tokens = ctypes.POINTER(core.BNInstructionTextToken)()
assert self.function.arch is not None, f"type(self.function): {type(self.function)} "
- result = core.BNGetMediumLevelILExprText(self.function.handle, self.function.arch.handle,
- self.expr_index, tokens, count, None)
+ result = core.BNGetMediumLevelILExprText(
+ self.function.handle, self.function.arch.handle, self.expr_index, tokens, count, None
+ )
assert result, "core.BNGetMediumLevelILExprText returned False"
try:
return function.InstructionTextToken._from_core_struct(tokens, count.value)
@@ -354,16 +406,19 @@ class MediumLevelILInstruction(BaseILInstruction):
"""SSA form of expression (read-only)"""
ssa_func = self.function.ssa_form
assert ssa_func is not None
- return MediumLevelILInstruction.create(ssa_func,
- ExpressionIndex(core.BNGetMediumLevelILSSAExprIndex(self.function.handle, self.expr_index)))
+ return MediumLevelILInstruction.create(
+ ssa_func, ExpressionIndex(core.BNGetMediumLevelILSSAExprIndex(self.function.handle, self.expr_index))
+ )
@property
def non_ssa_form(self) -> 'MediumLevelILInstruction':
"""Non-SSA form of expression (read-only)"""
non_ssa_func = self.function.non_ssa_form
assert non_ssa_func is not None
- return MediumLevelILInstruction.create(non_ssa_func,
- ExpressionIndex(core.BNGetMediumLevelILNonSSAExprIndex(self.function.handle, self.expr_index)))
+ return MediumLevelILInstruction.create(
+ non_ssa_func,
+ ExpressionIndex(core.BNGetMediumLevelILNonSSAExprIndex(self.function.handle, self.expr_index))
+ )
@property
def value(self) -> variable.RegisterValue:
@@ -446,7 +501,7 @@ class MediumLevelILInstruction(BaseILInstruction):
@property
def prefix_operands(self) -> List[MediumLevelILOperandType]:
"""All operands in the expression tree in prefix order"""
- result:List[MediumLevelILOperandType] = [MediumLevelILOperationAndSize(self.operation, self.size)]
+ result: List[MediumLevelILOperandType] = [MediumLevelILOperationAndSize(self.operation, self.size)]
for operand in self.operands:
if isinstance(operand, MediumLevelILInstruction):
result.extend(operand.prefix_operands)
@@ -457,7 +512,7 @@ class MediumLevelILInstruction(BaseILInstruction):
@property
def postfix_operands(self) -> List[MediumLevelILOperandType]:
"""All operands in the expression tree in postfix order"""
- result:List[MediumLevelILOperandType] = []
+ result: List[MediumLevelILOperandType] = []
for operand in self.operands:
if isinstance(operand, MediumLevelILInstruction):
result.extend(operand.postfix_operands)
@@ -507,11 +562,13 @@ class MediumLevelILInstruction(BaseILInstruction):
platform = None
if self.function.source_function:
platform = self.function.source_function.platform
- return types.Type.create(core.BNNewTypeReference(result.type), platform = platform, confidence = result.confidence)
+ return types.Type.create(
+ core.BNNewTypeReference(result.type), platform=platform, confidence=result.confidence
+ )
return None
@staticmethod
- def _make_options_array(options:Optional[List[DataFlowQueryOption]]):
+ def _make_options_array(options: Optional[List[DataFlowQueryOption]]):
if options is None:
options = []
idx = 0
@@ -521,134 +578,153 @@ class MediumLevelILInstruction(BaseILInstruction):
idx += 1
return option_array, len(options)
- def get_possible_values(self, options:Optional[List[DataFlowQueryOption]]=None) -> variable.PossibleValueSet:
+ def get_possible_values(self, options: Optional[List[DataFlowQueryOption]] = None) -> variable.PossibleValueSet:
option_array, size = MediumLevelILInstruction._make_options_array(options)
value = core.BNGetMediumLevelILPossibleExprValues(self.function.handle, self.expr_index, option_array, size)
result = variable.PossibleValueSet(self.function.arch, value)
core.BNFreePossibleValueSet(value)
return result
- def get_ssa_var_possible_values(self, ssa_var:SSAVariable, options:List[DataFlowQueryOption]=[]):
+ def get_ssa_var_possible_values(self, ssa_var: SSAVariable, options: List[DataFlowQueryOption] = []):
var_data = ssa_var.var.to_BNVariable()
option_array, size = MediumLevelILInstruction._make_options_array(options)
- value = core.BNGetMediumLevelILPossibleSSAVarValues(self.function.handle, var_data, ssa_var.version,
- self.instr_index, option_array, size)
+ value = core.BNGetMediumLevelILPossibleSSAVarValues(
+ self.function.handle, var_data, ssa_var.version, self.instr_index, option_array, size
+ )
result = variable.PossibleValueSet(self.function.arch, value)
core.BNFreePossibleValueSet(value)
return result
- def get_ssa_var_version(self, var:variable.Variable) -> int:
+ def get_ssa_var_version(self, var: variable.Variable) -> int:
var_data = var.to_BNVariable()
return core.BNGetMediumLevelILSSAVarVersionAtILInstruction(self.function.handle, var_data, self.instr_index)
- def get_var_for_reg(self, reg:'architecture.RegisterType') -> variable.Variable:
+ def get_var_for_reg(self, reg: 'architecture.RegisterType') -> variable.Variable:
reg = self.function.arch.get_reg_index(reg)
result = core.BNGetMediumLevelILVariableForRegisterAtInstruction(self.function.handle, reg, self.instr_index)
return variable.Variable.from_BNVariable(self.function, result)
- def get_var_for_flag(self, flag:'architecture.FlagType') -> variable.Variable:
+ def get_var_for_flag(self, flag: 'architecture.FlagType') -> variable.Variable:
flag = self.function.arch.get_flag_index(flag)
result = core.BNGetMediumLevelILVariableForFlagAtInstruction(self.function.handle, flag, self.instr_index)
return variable.Variable.from_BNVariable(self.function, result)
- def get_var_for_stack_location(self, offset:int) -> variable.Variable:
- result = core.BNGetMediumLevelILVariableForStackLocationAtInstruction(self.function.handle, offset, self.instr_index)
+ def get_var_for_stack_location(self, offset: int) -> variable.Variable:
+ result = core.BNGetMediumLevelILVariableForStackLocationAtInstruction(
+ self.function.handle, offset, self.instr_index
+ )
return variable.Variable.from_BNVariable(self.function, result)
- def get_reg_value(self, reg:'architecture.RegisterType') -> 'variable.RegisterValue':
+ def get_reg_value(self, reg: 'architecture.RegisterType') -> 'variable.RegisterValue':
reg = self.function.arch.get_reg_index(reg)
value = core.BNGetMediumLevelILRegisterValueAtInstruction(self.function.handle, reg, self.instr_index)
result = variable.RegisterValue.from_BNRegisterValue(value, self.function.arch)
return result
- def get_reg_value_after(self, reg:'architecture.RegisterType') -> 'variable.RegisterValue':
+ def get_reg_value_after(self, reg: 'architecture.RegisterType') -> 'variable.RegisterValue':
reg = self.function.arch.get_reg_index(reg)
value = core.BNGetMediumLevelILRegisterValueAfterInstruction(self.function.handle, reg, self.instr_index)
result = variable.RegisterValue.from_BNRegisterValue(value, self.function.arch)
return result
- def get_possible_reg_values(self, reg:'architecture.RegisterType',
- options:Optional[List[DataFlowQueryOption]]=None) -> 'variable.PossibleValueSet':
+ def get_possible_reg_values(
+ self, reg: 'architecture.RegisterType', options: Optional[List[DataFlowQueryOption]] = None
+ ) -> 'variable.PossibleValueSet':
option_array, size = MediumLevelILInstruction._make_options_array(options)
reg = self.function.arch.get_reg_index(reg)
- value = core.BNGetMediumLevelILPossibleRegisterValuesAtInstruction(self.function.handle, reg, self.instr_index,
- option_array, size)
+ value = core.BNGetMediumLevelILPossibleRegisterValuesAtInstruction(
+ self.function.handle, reg, self.instr_index, option_array, size
+ )
result = variable.PossibleValueSet(self.function.arch, value)
core.BNFreePossibleValueSet(value)
return result
- def get_possible_reg_values_after(self, reg:'architecture.RegisterType',
- options:Optional[List[DataFlowQueryOption]]=None) -> 'variable.PossibleValueSet':
+ def get_possible_reg_values_after(
+ self, reg: 'architecture.RegisterType', options: Optional[List[DataFlowQueryOption]] = None
+ ) -> 'variable.PossibleValueSet':
reg = self.function.arch.get_reg_index(reg)
option_array, size = MediumLevelILInstruction._make_options_array(options)
- value = core.BNGetMediumLevelILPossibleRegisterValuesAfterInstruction(self.function.handle, reg, self.instr_index,
- option_array, size)
+ value = core.BNGetMediumLevelILPossibleRegisterValuesAfterInstruction(
+ self.function.handle, reg, self.instr_index, option_array, size
+ )
result = variable.PossibleValueSet(self.function.arch, value)
core.BNFreePossibleValueSet(value)
return result
- def get_flag_value(self, flag:'architecture.FlagType') -> 'variable.RegisterValue':
+ def get_flag_value(self, flag: 'architecture.FlagType') -> 'variable.RegisterValue':
flag = self.function.arch.get_flag_index(flag)
value = core.BNGetMediumLevelILFlagValueAtInstruction(self.function.handle, flag, self.instr_index)
result = variable.RegisterValue.from_BNRegisterValue(value, self.function.arch)
return result
- def get_flag_value_after(self, flag:'architecture.FlagType') -> 'variable.RegisterValue':
+ def get_flag_value_after(self, flag: 'architecture.FlagType') -> 'variable.RegisterValue':
flag = self.function.arch.get_flag_index(flag)
value = core.BNGetMediumLevelILFlagValueAfterInstruction(self.function.handle, flag, self.instr_index)
result = variable.RegisterValue.from_BNRegisterValue(value, self.function.arch)
return result
- def get_possible_flag_values(self, flag:'architecture.FlagType',
- options:Optional[List[DataFlowQueryOption]]=None) -> 'variable.PossibleValueSet':
+ def get_possible_flag_values(
+ self, flag: 'architecture.FlagType', options: Optional[List[DataFlowQueryOption]] = None
+ ) -> 'variable.PossibleValueSet':
flag = self.function.arch.get_flag_index(flag)
option_array, size = MediumLevelILInstruction._make_options_array(options)
- value = core.BNGetMediumLevelILPossibleFlagValuesAtInstruction(self.function.handle, flag, self.instr_index,
- option_array, size)
+ value = core.BNGetMediumLevelILPossibleFlagValuesAtInstruction(
+ self.function.handle, flag, self.instr_index, option_array, size
+ )
result = variable.PossibleValueSet(self.function.arch, value)
core.BNFreePossibleValueSet(value)
return result
- def get_possible_flag_values_after(self, flag:'architecture.FlagType',
- options:Optional[List[DataFlowQueryOption]]=None) -> 'variable.PossibleValueSet':
+ def get_possible_flag_values_after(
+ self, flag: 'architecture.FlagType', options: Optional[List[DataFlowQueryOption]] = None
+ ) -> 'variable.PossibleValueSet':
flag = self.function.arch.get_flag_index(flag)
option_array, size = MediumLevelILInstruction._make_options_array(options)
- value = core.BNGetMediumLevelILPossibleFlagValuesAfterInstruction(self.function.handle, flag, self.instr_index,
- option_array, size)
+ value = core.BNGetMediumLevelILPossibleFlagValuesAfterInstruction(
+ self.function.handle, flag, self.instr_index, option_array, size
+ )
result = variable.PossibleValueSet(self.function.arch, value)
core.BNFreePossibleValueSet(value)
return result
- def get_stack_contents(self, offset:int, size:int) -> 'variable.RegisterValue':
+ def get_stack_contents(self, offset: int, size: int) -> 'variable.RegisterValue':
value = core.BNGetMediumLevelILStackContentsAtInstruction(self.function.handle, offset, size, self.instr_index)
result = variable.RegisterValue.from_BNRegisterValue(value, self.function.arch)
return result
- def get_stack_contents_after(self, offset:int, size:int) -> 'variable.RegisterValue':
- value = core.BNGetMediumLevelILStackContentsAfterInstruction(self.function.handle, offset, size, self.instr_index)
+ def get_stack_contents_after(self, offset: int, size: int) -> 'variable.RegisterValue':
+ value = core.BNGetMediumLevelILStackContentsAfterInstruction(
+ self.function.handle, offset, size, self.instr_index
+ )
result = variable.RegisterValue.from_BNRegisterValue(value, self.function.arch)
return result
- def get_possible_stack_contents(self, offset:int, size:int,
- options:Optional[List[DataFlowQueryOption]]=None) -> 'variable.PossibleValueSet':
+ def get_possible_stack_contents(
+ self, offset: int, size: int, options: Optional[List[DataFlowQueryOption]] = None
+ ) -> 'variable.PossibleValueSet':
option_array, option_size = MediumLevelILInstruction._make_options_array(options)
- value = core.BNGetMediumLevelILPossibleStackContentsAtInstruction(self.function.handle, offset, size, self.instr_index,
- option_array, option_size)
+ value = core.BNGetMediumLevelILPossibleStackContentsAtInstruction(
+ self.function.handle, offset, size, self.instr_index, option_array, option_size
+ )
result = variable.PossibleValueSet(self.function.arch, value)
core.BNFreePossibleValueSet(value)
return result
- def get_possible_stack_contents_after(self, offset:int, size:int,
- options:List[DataFlowQueryOption]=None) -> 'variable.PossibleValueSet':
+ def get_possible_stack_contents_after(
+ self, offset: int, size: int, options: List[DataFlowQueryOption] = None
+ ) -> 'variable.PossibleValueSet':
option_array, option_size = MediumLevelILInstruction._make_options_array(options)
- value = core.BNGetMediumLevelILPossibleStackContentsAfterInstruction(self.function.handle, offset, size, self.instr_index,
- option_array, option_size)
+ value = core.BNGetMediumLevelILPossibleStackContentsAfterInstruction(
+ self.function.handle, offset, size, self.instr_index, option_array, option_size
+ )
result = variable.PossibleValueSet(self.function.arch, value)
core.BNFreePossibleValueSet(value)
return result
- def get_branch_dependence(self, branch_instr:int) -> ILBranchDependence:
- return ILBranchDependence(core.BNGetMediumLevelILBranchDependence(self.function.handle, self.instr_index, branch_instr))
+ def get_branch_dependence(self, branch_instr: int) -> ILBranchDependence:
+ return ILBranchDependence(
+ core.BNGetMediumLevelILBranchDependence(self.function.handle, self.instr_index, branch_instr)
+ )
@property
def operation(self) -> MediumLevelILOperation:
@@ -670,11 +746,11 @@ class MediumLevelILInstruction(BaseILInstruction):
def core_operands(self) -> OperandsType:
return self.instr.operands
- def _get_int(self, operand_index:int) -> int:
+ def _get_int(self, operand_index: int) -> int:
value = self.instr.operands[operand_index]
return (value & ((1 << 63) - 1)) - (value & (1 << 63))
- def _get_float(self, operand_index:int) -> float:
+ def _get_float(self, operand_index: int) -> float:
value = self.instr.operands[operand_index]
if self.instr.size == 4:
return struct.unpack("f", struct.pack("I", value & 0xffffffff))[0]
@@ -683,34 +759,34 @@ class MediumLevelILInstruction(BaseILInstruction):
else:
return float(value)
- def _get_expr(self, operand_index:int) -> 'MediumLevelILInstruction':
- return MediumLevelILInstruction.create(self.function,
- ExpressionIndex(self.instr.operands[operand_index]))
+ def _get_expr(self, operand_index: int) -> 'MediumLevelILInstruction':
+ return MediumLevelILInstruction.create(self.function, ExpressionIndex(self.instr.operands[operand_index]))
- def _get_intrinsic(self, operand_index:int) -> 'lowlevelil.ILIntrinsic':
+ def _get_intrinsic(self, operand_index: int) -> 'lowlevelil.ILIntrinsic':
assert self.function.arch is not None, "Attempting to create ILIntrinsic from function with no Architecture"
- return lowlevelil.ILIntrinsic(self.function.arch,
- architecture.IntrinsicIndex(self.instr.operands[operand_index]))
+ return lowlevelil.ILIntrinsic(
+ self.function.arch, architecture.IntrinsicIndex(self.instr.operands[operand_index])
+ )
- def _get_var(self, operand_index:int) -> variable.Variable:
+ def _get_var(self, operand_index: int) -> variable.Variable:
value = self.instr.operands[operand_index]
return variable.Variable.from_identifier(self.function, value)
- def _get_var_ssa(self, operand_index1:int, operand_index2:int) -> SSAVariable:
+ def _get_var_ssa(self, operand_index1: int, operand_index2: int) -> SSAVariable:
var = variable.Variable.from_identifier(self.function, self.instr.operands[operand_index1])
version = self.instr.operands[operand_index2]
return SSAVariable(var, version)
- def _get_var_ssa_dest_and_src(self, operand_index1:int, operand_index2:int) -> SSAVariable:
+ def _get_var_ssa_dest_and_src(self, operand_index1: int, operand_index2: int) -> SSAVariable:
var = variable.Variable.from_identifier(self.function, self.instr.operands[operand_index1])
dest_version = self.instr.operands[operand_index2]
return SSAVariable(var, dest_version)
- def _get_int_list(self, operand_index:int) -> List[int]:
+ def _get_int_list(self, operand_index: int) -> List[int]:
count = ctypes.c_ulonglong()
operand_list = core.BNMediumLevelILGetOperandList(self.function.handle, self.expr_index, operand_index, count)
assert operand_list is not None, "core.BNMediumLevelILGetOperandList returned None"
- value:List[int] = []
+ value: List[int] = []
try:
for j in range(count.value):
value.append(operand_list[j])
@@ -718,7 +794,7 @@ class MediumLevelILInstruction(BaseILInstruction):
finally:
core.BNMediumLevelILFreeOperandList(operand_list)
- def _get_var_list(self, operand_index1:int, operand_index2:int) -> List[variable.Variable]:
+ def _get_var_list(self, operand_index1: int, operand_index2: int) -> List[variable.Variable]:
# We keep this extra parameter around because when this function is called
# the subclasses that call this don't use the next operand
# without this parameter it looks like this operand is being skipped unintentionally
@@ -727,7 +803,7 @@ class MediumLevelILInstruction(BaseILInstruction):
count = ctypes.c_ulonglong()
operand_list = core.BNMediumLevelILGetOperandList(self.function.handle, self.expr_index, operand_index1, count)
assert operand_list is not None, "core.BNMediumLevelILGetOperandList returned None"
- value:List[variable.Variable] = []
+ value: List[variable.Variable] = []
try:
for j in range(count.value):
value.append(variable.Variable.from_identifier(self.function, operand_list[j]))
@@ -735,7 +811,7 @@ class MediumLevelILInstruction(BaseILInstruction):
finally:
core.BNMediumLevelILFreeOperandList(operand_list)
- def _get_var_ssa_list(self, operand_index1:int, _:int) -> List[SSAVariable]:
+ def _get_var_ssa_list(self, operand_index1: int, _: int) -> List[SSAVariable]:
count = ctypes.c_ulonglong()
operand_list = core.BNMediumLevelILGetOperandList(self.function.handle, self.expr_index, operand_index1, count)
assert operand_list is not None, "core.BNMediumLevelILGetOperandList returned None"
@@ -743,18 +819,17 @@ class MediumLevelILInstruction(BaseILInstruction):
try:
for j in range(count.value // 2):
var_id = operand_list[j * 2]
- var_version = operand_list[(j * 2) + 1]
- value.append(SSAVariable(variable.Variable.from_identifier(self.function,
- var_id), var_version))
+ var_version = operand_list[(j*2) + 1]
+ value.append(SSAVariable(variable.Variable.from_identifier(self.function, var_id), var_version))
return value
finally:
core.BNMediumLevelILFreeOperandList(operand_list)
- def _get_expr_list(self, operand_index1:int, _:int) -> List['MediumLevelILInstruction']:
+ def _get_expr_list(self, operand_index1: int, _: int) -> List['MediumLevelILInstruction']:
count = ctypes.c_ulonglong()
operand_list = core.BNMediumLevelILGetOperandList(self.function.handle, self.expr_index, operand_index1, count)
assert operand_list is not None, "core.BNMediumLevelILGetOperandList returned None"
- value:List['MediumLevelILInstruction'] = []
+ value: List['MediumLevelILInstruction'] = []
try:
for j in range(count.value):
value.append(MediumLevelILInstruction.create(self.function, operand_list[j], None))
@@ -762,15 +837,15 @@ class MediumLevelILInstruction(BaseILInstruction):
finally:
core.BNMediumLevelILFreeOperandList(operand_list)
- def _get_target_map(self, operand_index1:int, _:int) -> Mapping[int, int]:
+ def _get_target_map(self, operand_index1: int, _: int) -> Mapping[int, int]:
count = ctypes.c_ulonglong()
operand_list = core.BNMediumLevelILGetOperandList(self.function.handle, self.expr_index, operand_index1, count)
assert operand_list is not None, "core.BNMediumLevelILGetOperandList returned None"
- value:Dict[int, int] = {}
+ value: Dict[int, int] = {}
try:
for j in range(count.value // 2):
key = operand_list[j * 2]
- target = operand_list[(j * 2) + 1]
+ target = operand_list[(j*2) + 1]
value[key] = target
return value
finally:
@@ -811,7 +886,6 @@ class MediumLevelILCallBase(MediumLevelILInstruction, Call):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILUnaryBase(MediumLevelILInstruction, UnaryOperation):
-
@property
def src(self) -> MediumLevelILInstruction:
return self._get_expr(0)
@@ -823,7 +897,6 @@ class MediumLevelILUnaryBase(MediumLevelILInstruction, UnaryOperation):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILBinaryBase(MediumLevelILInstruction, BinaryOperation):
-
@property
def left(self) -> MediumLevelILInstruction:
return self._get_expr(0)
@@ -844,7 +917,6 @@ class MediumLevelILComparisonBase(MediumLevelILBinaryBase, Comparison):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILCarryBase(MediumLevelILInstruction, Carry):
-
@property
def left(self) -> MediumLevelILInstruction:
return self._get_expr(0)
@@ -889,7 +961,6 @@ class MediumLevelILUnimpl(MediumLevelILInstruction):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILLoad(MediumLevelILInstruction, Load):
-
@property
def src(self) -> MediumLevelILInstruction:
return self._get_expr(0)
@@ -901,7 +972,6 @@ class MediumLevelILLoad(MediumLevelILInstruction, Load):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILVar(MediumLevelILInstruction):
-
@property
def src(self) -> variable.Variable:
return self._get_var(0)
@@ -913,7 +983,6 @@ class MediumLevelILVar(MediumLevelILInstruction):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILAddressOf(MediumLevelILInstruction):
-
@property
def src(self) -> variable.Variable:
return self._get_var(0)
@@ -929,7 +998,6 @@ class MediumLevelILAddressOf(MediumLevelILInstruction):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILConst(MediumLevelILConstBase):
-
@property
def constant(self) -> int:
return self._get_int(0)
@@ -941,7 +1009,6 @@ class MediumLevelILConst(MediumLevelILConstBase):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILConstPtr(MediumLevelILConstBase):
-
@property
def constant(self) -> int:
return self._get_int(0)
@@ -953,7 +1020,6 @@ class MediumLevelILConstPtr(MediumLevelILConstBase):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILFloatConst(MediumLevelILConstBase, FloatingPoint):
-
@property
def constant(self) -> float:
return self._get_float(0)
@@ -965,7 +1031,6 @@ class MediumLevelILFloatConst(MediumLevelILConstBase, FloatingPoint):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILImport(MediumLevelILConstBase):
-
@property
def constant(self) -> int:
return self._get_int(0)
@@ -1002,7 +1067,6 @@ class MediumLevelILLowPart(MediumLevelILUnaryBase, Arithmetic):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILJump(MediumLevelILInstruction, Terminal):
-
@property
def dest(self) -> MediumLevelILInstruction:
return self._get_expr(0)
@@ -1014,7 +1078,6 @@ class MediumLevelILJump(MediumLevelILInstruction, Terminal):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILRetHint(MediumLevelILInstruction, ControlFlow):
-
@property
def dest(self) -> MediumLevelILInstruction:
return self._get_expr(0)
@@ -1026,7 +1089,6 @@ class MediumLevelILRetHint(MediumLevelILInstruction, ControlFlow):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILCallOutput(MediumLevelILInstruction):
-
@property
def dest(self) -> List[variable.Variable]:
return self._get_var_list(0, 1)
@@ -1042,7 +1104,6 @@ class MediumLevelILCallOutput(MediumLevelILInstruction):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILCallParam(MediumLevelILInstruction):
-
@property
def src(self) -> List[variable.Variable]:
return self._get_var_list(0, 1)
@@ -1054,7 +1115,6 @@ class MediumLevelILCallParam(MediumLevelILInstruction):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILRet(MediumLevelILInstruction, Return):
-
@property
def src(self) -> List[MediumLevelILInstruction]:
return self._get_expr_list(0, 1)
@@ -1066,7 +1126,6 @@ class MediumLevelILRet(MediumLevelILInstruction, Return):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILGoto(MediumLevelILInstruction, Terminal):
-
@property
def dest(self) -> int:
return self._get_int(0)
@@ -1078,7 +1137,6 @@ class MediumLevelILGoto(MediumLevelILInstruction, Terminal):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILBoolToInt(MediumLevelILInstruction):
-
@property
def src(self) -> MediumLevelILInstruction:
return self._get_expr(0)
@@ -1090,7 +1148,6 @@ class MediumLevelILBoolToInt(MediumLevelILInstruction):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILFreeVarSlot(MediumLevelILInstruction, RegisterStack):
-
@property
def dest(self) -> variable.Variable:
return self._get_var(0)
@@ -1102,7 +1159,6 @@ class MediumLevelILFreeVarSlot(MediumLevelILInstruction, RegisterStack):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILTrap(MediumLevelILInstruction, Terminal):
-
@property
def vector(self) -> int:
return self._get_int(0)
@@ -1114,7 +1170,6 @@ class MediumLevelILTrap(MediumLevelILInstruction, Terminal):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILFreeVarSlotSsa(MediumLevelILInstruction, SSA, RegisterStack):
-
@property
def dest(self) -> SSAVariable:
return self._get_var_ssa_dest_and_src(0, 1)
@@ -1130,7 +1185,6 @@ class MediumLevelILFreeVarSlotSsa(MediumLevelILInstruction, SSA, RegisterStack):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILUnimplMem(MediumLevelILInstruction, Memory):
-
@property
def src(self) -> MediumLevelILInstruction:
return self._get_expr(0)
@@ -1192,7 +1246,6 @@ class MediumLevelILFtrunc(MediumLevelILUnaryBase, Arithmetic, FloatingPoint):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILVarSsa(MediumLevelILInstruction, SSA):
-
@property
def src(self) -> SSAVariable:
return self._get_var_ssa(0, 1)
@@ -1204,7 +1257,6 @@ class MediumLevelILVarSsa(MediumLevelILInstruction, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILVarAliased(MediumLevelILInstruction, SSA):
-
@property
def src(self) -> SSAVariable:
return self._get_var_ssa(0, 1)
@@ -1216,7 +1268,6 @@ class MediumLevelILVarAliased(MediumLevelILInstruction, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILSetVar(MediumLevelILInstruction, SetVar):
-
@property
def dest(self) -> variable.Variable:
return self._get_var(0)
@@ -1240,7 +1291,6 @@ class MediumLevelILSetVar(MediumLevelILInstruction, SetVar):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILLoadStruct(MediumLevelILInstruction, Load):
-
@property
def src(self) -> MediumLevelILInstruction:
return self._get_expr(0)
@@ -1256,7 +1306,6 @@ class MediumLevelILLoadStruct(MediumLevelILInstruction, Load):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILStore(MediumLevelILInstruction, Store):
-
@property
def dest(self) -> MediumLevelILInstruction:
return self._get_expr(0)
@@ -1272,7 +1321,6 @@ class MediumLevelILStore(MediumLevelILInstruction, Store):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILVarField(MediumLevelILInstruction):
-
@property
def src(self) -> variable.Variable:
return self._get_var(0)
@@ -1288,7 +1336,6 @@ class MediumLevelILVarField(MediumLevelILInstruction):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILVarSplit(MediumLevelILInstruction):
-
@property
def high(self) -> variable.Variable:
return self._get_var(0)
@@ -1304,7 +1351,6 @@ class MediumLevelILVarSplit(MediumLevelILInstruction):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILAddressOfField(MediumLevelILInstruction):
-
@property
def src(self) -> variable.Variable:
return self._get_var(0)
@@ -1320,7 +1366,6 @@ class MediumLevelILAddressOfField(MediumLevelILInstruction):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILExternPtr(MediumLevelILConstBase):
-
@property
def constant(self) -> int:
return self._get_int(0)
@@ -1501,7 +1546,6 @@ class MediumLevelILAddOverflow(MediumLevelILBinaryBase, Arithmetic):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILSyscall(MediumLevelILInstruction, Syscall):
-
@property
def output(self) -> List[variable.Variable]:
return self._get_var_list(0, 1)
@@ -1517,7 +1561,6 @@ class MediumLevelILSyscall(MediumLevelILInstruction, Syscall):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILVarSsaField(MediumLevelILInstruction, SSA):
-
@property
def src(self) -> SSAVariable:
return self._get_var_ssa(0, 1)
@@ -1533,7 +1576,6 @@ class MediumLevelILVarSsaField(MediumLevelILInstruction, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILVarAliasedField(MediumLevelILInstruction, SSA):
-
@property
def src(self) -> SSAVariable:
return self._get_var_ssa(0, 1)
@@ -1549,7 +1591,6 @@ class MediumLevelILVarAliasedField(MediumLevelILInstruction, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILVarSplitSsa(MediumLevelILInstruction, SSA):
-
@property
def high(self) -> SSAVariable:
return self._get_var_ssa(0, 1)
@@ -1565,7 +1606,6 @@ class MediumLevelILVarSplitSsa(MediumLevelILInstruction, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILCallOutputSsa(MediumLevelILInstruction, SSA):
-
@property
def dest_memory(self) -> int:
return self._get_int(0)
@@ -1585,7 +1625,6 @@ class MediumLevelILCallOutputSsa(MediumLevelILInstruction, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILCallParamSsa(MediumLevelILInstruction, SSA):
-
@property
def src_memory(self) -> int:
return self._get_int(0)
@@ -1601,7 +1640,6 @@ class MediumLevelILCallParamSsa(MediumLevelILInstruction, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILLoadSsa(MediumLevelILInstruction, Load, SSA):
-
@property
def src(self) -> MediumLevelILInstruction:
return self._get_expr(0)
@@ -1617,7 +1655,6 @@ class MediumLevelILLoadSsa(MediumLevelILInstruction, Load, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILVarPhi(MediumLevelILInstruction, SetVar, Phi, SSA):
-
@property
def dest(self) -> SSAVariable:
return self._get_var_ssa(0, 1)
@@ -1637,7 +1674,6 @@ class MediumLevelILVarPhi(MediumLevelILInstruction, SetVar, Phi, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILMemPhi(MediumLevelILInstruction, Memory, Phi):
-
@property
def dest_memory(self) -> int:
return self._get_int(0)
@@ -1653,7 +1689,6 @@ class MediumLevelILMemPhi(MediumLevelILInstruction, Memory, Phi):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILSetVarSsa(MediumLevelILInstruction, SetVar, SSA):
-
@property
def dest(self) -> SSAVariable:
return self._get_var_ssa(0, 1)
@@ -1737,7 +1772,6 @@ class MediumLevelILFdiv(MediumLevelILBinaryBase, Arithmetic, FloatingPoint):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILJumpTo(MediumLevelILInstruction, Terminal):
-
@property
def dest(self) -> MediumLevelILInstruction:
return self._get_expr(0)
@@ -1753,7 +1787,6 @@ class MediumLevelILJumpTo(MediumLevelILInstruction, Terminal):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILSetVarAliased(MediumLevelILInstruction, SetVar, SSA):
-
@property
def dest(self) -> SSAVariable:
return self._get_var_ssa_dest_and_src(0, 1)
@@ -1779,10 +1812,8 @@ class MediumLevelILSetVarAliased(MediumLevelILInstruction, SetVar, SSA):
return [self.dest]
-
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILSyscallUntyped(MediumLevelILCallBase, Syscall):
-
@property
def output(self) -> List[variable.Variable]:
inst = self._get_expr(0)
@@ -1806,7 +1837,6 @@ class MediumLevelILSyscallUntyped(MediumLevelILCallBase, Syscall):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILIntrinsic(MediumLevelILInstruction):
-
@property
def output(self) -> List[variable.Variable]:
return self._get_var_list(0, 1)
@@ -1821,7 +1851,7 @@ class MediumLevelILIntrinsic(MediumLevelILInstruction):
@property
def vars_read(self) -> List[variable.Variable]:
- result:List[variable.Variable] = []
+ result: List[variable.Variable] = []
for i in self.params:
result.extend(i.vars_read) # type: ignore
return result
@@ -1837,7 +1867,6 @@ class MediumLevelILIntrinsic(MediumLevelILInstruction):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILIntrinsicSsa(MediumLevelILInstruction, SSA):
-
@property
def output(self) -> List[SSAVariable]:
return self._get_var_ssa_list(0, 1)
@@ -1852,7 +1881,7 @@ class MediumLevelILIntrinsicSsa(MediumLevelILInstruction, SSA):
@property
def vars_read(self) -> List[SSAVariable]:
- result:List[SSAVariable] = []
+ result: List[SSAVariable] = []
for i in self.params:
result.extend(i.vars_read) # type: ignore
return result
@@ -1868,7 +1897,6 @@ class MediumLevelILIntrinsicSsa(MediumLevelILInstruction, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILSetVarSsaField(MediumLevelILInstruction, SetVar, SSA):
-
@property
def dest(self) -> SSAVariable:
return self._get_var_ssa_dest_and_src(0, 1)
@@ -1900,7 +1928,6 @@ class MediumLevelILSetVarSsaField(MediumLevelILInstruction, SetVar, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILSetVarSplitSsa(MediumLevelILInstruction, SetVar, SSA):
-
@property
def high(self) -> SSAVariable:
return self._get_var_ssa(0, 1)
@@ -1928,7 +1955,6 @@ class MediumLevelILSetVarSplitSsa(MediumLevelILInstruction, SetVar, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILSetVarAliasedField(MediumLevelILInstruction, SetVar, SSA):
-
@property
def dest(self) -> SSAVariable:
return self._get_var_ssa_dest_and_src(0, 1)
@@ -1956,7 +1982,6 @@ class MediumLevelILSetVarAliasedField(MediumLevelILInstruction, SetVar, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILSyscallSsa(MediumLevelILCallBase, Syscall, SSA):
-
@property
def output(self) -> List[SSAVariable]:
inst = self._get_expr(0)
@@ -1984,29 +2009,36 @@ class MediumLevelILSyscallSsa(MediumLevelILCallBase, Syscall, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILSyscallUntypedSsa(MediumLevelILCallBase, Syscall, SSA):
-
@property
def output(self) -> List[SSAVariable]:
inst = self._get_expr(0)
- assert isinstance(inst, MediumLevelILCallOutputSsa), "MediumLevelILSyscallUntypedSsa return bad type for 'output'"
+ assert isinstance(
+ inst, MediumLevelILCallOutputSsa
+ ), "MediumLevelILSyscallUntypedSsa return bad type for 'output'"
return inst.dest
@property
def output_dest_memory(self) -> int:
inst = self._get_expr(0)
- assert isinstance(inst, MediumLevelILCallOutputSsa), "MediumLevelILSyscallUntypedSsa return bad type for 'output_dest_memory'"
+ assert isinstance(
+ inst, MediumLevelILCallOutputSsa
+ ), "MediumLevelILSyscallUntypedSsa return bad type for 'output_dest_memory'"
return inst.dest_memory
@property
def params(self) -> List[SSAVariable]:
inst = self._get_expr(1)
- assert isinstance(inst, MediumLevelILCallParamSsa), "MediumLevelILSyscallUntypedSsa return bad type for 'params'"
+ assert isinstance(
+ inst, MediumLevelILCallParamSsa
+ ), "MediumLevelILSyscallUntypedSsa return bad type for 'params'"
return inst.src
@property
def params_src_memory(self) -> int:
inst = self._get_expr(1)
- assert isinstance(inst, MediumLevelILCallParamSsa), "MediumLevelILSyscallUntypedSsa return bad type for 'params_src_memory'"
+ assert isinstance(
+ inst, MediumLevelILCallParamSsa
+ ), "MediumLevelILSyscallUntypedSsa return bad type for 'params_src_memory'"
return inst.src_memory
@property
@@ -2020,7 +2052,6 @@ class MediumLevelILSyscallUntypedSsa(MediumLevelILCallBase, Syscall, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILLoadStructSsa(MediumLevelILInstruction, Load, SSA):
-
@property
def src(self) -> MediumLevelILInstruction:
return self._get_expr(0)
@@ -2040,7 +2071,6 @@ class MediumLevelILLoadStructSsa(MediumLevelILInstruction, Load, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILSetVarField(MediumLevelILInstruction, SetVar):
-
@property
def dest(self) -> variable.Variable:
return self._get_var(0)
@@ -2060,7 +2090,6 @@ class MediumLevelILSetVarField(MediumLevelILInstruction, SetVar):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILSetVarSplit(MediumLevelILInstruction, SetVar):
-
@property
def high(self) -> variable.Variable:
return self._get_var(0)
@@ -2084,7 +2113,6 @@ class MediumLevelILSetVarSplit(MediumLevelILInstruction, SetVar):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILStoreStruct(MediumLevelILInstruction, Store):
-
@property
def dest(self) -> MediumLevelILInstruction:
return self._get_expr(0)
@@ -2124,7 +2152,6 @@ class MediumLevelILRrc(MediumLevelILCarryBase):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILCall(MediumLevelILCallBase, Localcall):
-
@property
def output(self) -> List[variable.Variable]:
return self._get_var_list(0, 1)
@@ -2144,7 +2171,6 @@ class MediumLevelILCall(MediumLevelILCallBase, Localcall):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILIf(MediumLevelILInstruction, Terminal):
-
@property
def condition(self) -> MediumLevelILInstruction:
return self._get_expr(0)
@@ -2164,7 +2190,6 @@ class MediumLevelILIf(MediumLevelILInstruction, Terminal):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILTailcallUntyped(MediumLevelILCallBase, Tailcall):
-
@property
def output(self) -> List[variable.Variable]:
inst = self._get_expr(0)
@@ -2192,7 +2217,6 @@ class MediumLevelILTailcallUntyped(MediumLevelILCallBase, Tailcall):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILCallSsa(MediumLevelILCallBase, Localcall, SSA):
-
@property
def output(self) -> List[SSAVariable]:
inst = self._get_expr(0)
@@ -2224,7 +2248,6 @@ class MediumLevelILCallSsa(MediumLevelILCallBase, Localcall, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILCallUntypedSsa(MediumLevelILCallBase, Localcall, SSA):
-
@property
def output(self) -> List[SSAVariable]:
inst = self._get_expr(0)
@@ -2250,7 +2273,9 @@ class MediumLevelILCallUntypedSsa(MediumLevelILCallBase, Localcall, SSA):
@property
def params_src_memory(self):
inst = self._get_expr(2)
- assert isinstance(inst, MediumLevelILCallParamSsa), "MediumLevelILCallUntypedSsa return bad type for 'params_src_memory'"
+ assert isinstance(
+ inst, MediumLevelILCallParamSsa
+ ), "MediumLevelILCallUntypedSsa return bad type for 'params_src_memory'"
return inst.src_memory
@property
@@ -2264,7 +2289,6 @@ class MediumLevelILCallUntypedSsa(MediumLevelILCallBase, Localcall, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILTailcall(MediumLevelILCallBase, Tailcall):
-
@property
def output(self) -> List[variable.Variable]:
return self._get_var_list(0, 1)
@@ -2284,7 +2308,6 @@ class MediumLevelILTailcall(MediumLevelILCallBase, Tailcall):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILTailcallSsa(MediumLevelILCallBase, Tailcall, SSA):
-
@property
def output(self) -> List[SSAVariable]:
inst = self._get_expr(0)
@@ -2316,17 +2339,20 @@ class MediumLevelILTailcallSsa(MediumLevelILCallBase, Tailcall, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILTailcallUntypedSsa(MediumLevelILCallBase, Tailcall, SSA):
-
@property
def output(self) -> List[SSAVariable]:
inst = self._get_expr(0)
- assert isinstance(inst, MediumLevelILCallOutputSsa), "MediumLevelILTailcallUntypedSsa return bad type for 'output'"
+ assert isinstance(
+ inst, MediumLevelILCallOutputSsa
+ ), "MediumLevelILTailcallUntypedSsa return bad type for 'output'"
return inst.dest
@property
def output_dest_memory(self) -> int:
inst = self._get_expr(0)
- assert isinstance(inst, MediumLevelILCallOutputSsa), "MediumLevelILTailcallUntypedSsa return bad type for 'output'"
+ assert isinstance(
+ inst, MediumLevelILCallOutputSsa
+ ), "MediumLevelILTailcallUntypedSsa return bad type for 'output'"
return inst.dest_memory
@property
@@ -2336,7 +2362,9 @@ class MediumLevelILTailcallUntypedSsa(MediumLevelILCallBase, Tailcall, SSA):
@property
def params(self) -> List[SSAVariable]:
inst = self._get_expr(2)
- assert isinstance(inst, MediumLevelILCallParamSsa), "MediumLevelILTailcallUntypedSsa return bad type for 'params'"
+ assert isinstance(
+ inst, MediumLevelILCallParamSsa
+ ), "MediumLevelILTailcallUntypedSsa return bad type for 'params'"
return inst.src
@property
@@ -2350,7 +2378,6 @@ class MediumLevelILTailcallUntypedSsa(MediumLevelILCallBase, Tailcall, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILStoreSsa(MediumLevelILInstruction, Store, SSA):
-
@property
def dest(self) -> MediumLevelILInstruction:
return self._get_expr(0)
@@ -2374,7 +2401,6 @@ class MediumLevelILStoreSsa(MediumLevelILInstruction, Store, SSA):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILCallUntyped(MediumLevelILCallBase, Localcall):
-
@property
def output(self) -> List[variable.Variable]:
inst = self._get_expr(0)
@@ -2402,7 +2428,6 @@ class MediumLevelILCallUntyped(MediumLevelILCallBase, Localcall):
@dataclass(frozen=True, repr=False, eq=False)
class MediumLevelILStoreStructSsa(MediumLevelILInstruction, Store, SSA):
-
@property
def dest(self) -> MediumLevelILInstruction:
return self._get_expr(0)
@@ -2429,139 +2454,166 @@ class MediumLevelILStoreStructSsa(MediumLevelILInstruction, Store, SSA):
ILInstruction = {
- MediumLevelILOperation.MLIL_NOP:MediumLevelILNop, # [],
- MediumLevelILOperation.MLIL_NORET:MediumLevelILNoret, # [],
- MediumLevelILOperation.MLIL_BP:MediumLevelILBp, # [],
- MediumLevelILOperation.MLIL_UNDEF:MediumLevelILUndef, # [],
- MediumLevelILOperation.MLIL_UNIMPL:MediumLevelILUnimpl, # [],
- MediumLevelILOperation.MLIL_LOAD:MediumLevelILLoad, # [("src", "expr")],
- MediumLevelILOperation.MLIL_VAR:MediumLevelILVar, # [("src", "var")],
- MediumLevelILOperation.MLIL_ADDRESS_OF:MediumLevelILAddressOf, # [("src", "var")],
- MediumLevelILOperation.MLIL_CONST:MediumLevelILConst, # [("constant", "int")],
- MediumLevelILOperation.MLIL_CONST_PTR:MediumLevelILConstPtr, # [("constant", "int")],
- MediumLevelILOperation.MLIL_FLOAT_CONST:MediumLevelILFloatConst, # [("constant", "float")],
- MediumLevelILOperation.MLIL_IMPORT:MediumLevelILImport, # [("constant", "int")],
- MediumLevelILOperation.MLIL_SET_VAR:MediumLevelILSetVar, # [("dest", "var"), ("src", "expr")],
- MediumLevelILOperation.MLIL_LOAD_STRUCT:MediumLevelILLoadStruct, # [("src", "expr"), ("offset", "int")],
- MediumLevelILOperation.MLIL_STORE:MediumLevelILStore, # [("dest", "expr"), ("src", "expr")],
- MediumLevelILOperation.MLIL_VAR_FIELD:MediumLevelILVarField, # [("src", "var"), ("offset", "int")],
- MediumLevelILOperation.MLIL_VAR_SPLIT:MediumLevelILVarSplit, # [("high", "var"), ("low", "var")],
- MediumLevelILOperation.MLIL_ADDRESS_OF_FIELD:MediumLevelILAddressOfField, # [("src", "var"), ("offset", "int")],
- MediumLevelILOperation.MLIL_EXTERN_PTR:MediumLevelILExternPtr, # [("constant", "int"), ("offset", "int")],
- MediumLevelILOperation.MLIL_ADD:MediumLevelILAdd, # [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_SUB:MediumLevelILSub, # [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_AND:MediumLevelILAnd, # [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_OR:MediumLevelILOr, # [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_XOR:MediumLevelILXor, # [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_LSL:MediumLevelILLsl, # [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_LSR:MediumLevelILLsr, # [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_ASR:MediumLevelILAsr, # [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_ROL:MediumLevelILRol, # [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_ROR:MediumLevelILRor, # [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_MUL:MediumLevelILMul, # [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_MULU_DP:MediumLevelILMuluDp, # [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_MULS_DP:MediumLevelILMulsDp, # [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_DIVU:MediumLevelILDivu, # [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_DIVU_DP:MediumLevelILDivuDp, # [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_DIVS:MediumLevelILDivs, # [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_DIVS_DP:MediumLevelILDivsDp, # [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_MODU:MediumLevelILModu, # [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_MODU_DP:MediumLevelILModuDp, # [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_MODS:MediumLevelILMods, # [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_MODS_DP:MediumLevelILModsDp, # [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_NEG:MediumLevelILNeg, # [("src", "expr")],
- MediumLevelILOperation.MLIL_NOT:MediumLevelILNot, # [("src", "expr")],
- MediumLevelILOperation.MLIL_SX:MediumLevelILSx, # [("src", "expr")],
- MediumLevelILOperation.MLIL_ZX:MediumLevelILZx, # [("src", "expr")],
- MediumLevelILOperation.MLIL_LOW_PART:MediumLevelILLowPart, # [("src", "expr")],
- MediumLevelILOperation.MLIL_JUMP:MediumLevelILJump, # [("dest", "expr")],
- MediumLevelILOperation.MLIL_RET_HINT:MediumLevelILRetHint, # [("dest", "expr")],
- MediumLevelILOperation.MLIL_CALL_OUTPUT:MediumLevelILCallOutput, # [("dest", "var_list")],
- MediumLevelILOperation.MLIL_CALL_PARAM:MediumLevelILCallParam, # [("src", "var_list")],
- MediumLevelILOperation.MLIL_RET:MediumLevelILRet, # [("src", "expr_list")],
- MediumLevelILOperation.MLIL_GOTO:MediumLevelILGoto, # [("dest", "int")],
- MediumLevelILOperation.MLIL_BOOL_TO_INT:MediumLevelILBoolToInt, # [("src", "expr")],
- MediumLevelILOperation.MLIL_FREE_VAR_SLOT:MediumLevelILFreeVarSlot, # [("dest", "var")],
- MediumLevelILOperation.MLIL_TRAP:MediumLevelILTrap, # [("vector", "int")],
- MediumLevelILOperation.MLIL_FREE_VAR_SLOT_SSA:MediumLevelILFreeVarSlotSsa, # [("prev", "var_ssa_dest_and_src")],
- MediumLevelILOperation.MLIL_UNIMPL_MEM:MediumLevelILUnimplMem, # [("src", "expr")],
- MediumLevelILOperation.MLIL_FSQRT:MediumLevelILFsqrt, # [("src", "expr")],
- MediumLevelILOperation.MLIL_FNEG:MediumLevelILFneg, # [("src", "expr")],
- MediumLevelILOperation.MLIL_FABS:MediumLevelILFabs, # [("src", "expr")],
- MediumLevelILOperation.MLIL_FLOAT_TO_INT:MediumLevelILFloatToInt, # [("src", "expr")],
- MediumLevelILOperation.MLIL_INT_TO_FLOAT:MediumLevelILIntToFloat, # [("src", "expr")],
- MediumLevelILOperation.MLIL_FLOAT_CONV:MediumLevelILFloatConv, # [("src", "expr")],
- MediumLevelILOperation.MLIL_ROUND_TO_INT:MediumLevelILRoundToInt, # [("src", "expr")],
- MediumLevelILOperation.MLIL_FLOOR:MediumLevelILFloor, # [("src", "expr")],
- MediumLevelILOperation.MLIL_CEIL:MediumLevelILCeil, # [("src", "expr")],
- MediumLevelILOperation.MLIL_FTRUNC:MediumLevelILFtrunc, # [("src", "expr")],
- MediumLevelILOperation.MLIL_VAR_SSA:MediumLevelILVarSsa, # [("src", "var_ssa")],
- MediumLevelILOperation.MLIL_VAR_ALIASED:MediumLevelILVarAliased, # [("src", "var_ssa")],
- MediumLevelILOperation.MLIL_CMP_E:MediumLevelILCmpE, # [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_CMP_NE:MediumLevelILCmpNe, # [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_CMP_SLT:MediumLevelILCmpSlt, # [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_CMP_ULT:MediumLevelILCmpUlt, # [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_CMP_SLE:MediumLevelILCmpSle, # [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_CMP_ULE:MediumLevelILCmpUle, # [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_CMP_SGE:MediumLevelILCmpSge, # [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_CMP_UGE:MediumLevelILCmpUge, # [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_CMP_SGT:MediumLevelILCmpSgt, # [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_CMP_UGT:MediumLevelILCmpUgt, # [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_TEST_BIT:MediumLevelILTestBit, # [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_ADD_OVERFLOW:MediumLevelILAddOverflow, # [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_SYSCALL:MediumLevelILSyscall, # [("output", "var_list"), ("params", "expr_list")],
- MediumLevelILOperation.MLIL_VAR_SSA_FIELD:MediumLevelILVarSsaField, # [("src", "var_ssa"), ("offset", "int")],
- MediumLevelILOperation.MLIL_VAR_ALIASED_FIELD:MediumLevelILVarAliasedField, # [("src", "var_ssa"), ("offset", "int")],
- MediumLevelILOperation.MLIL_VAR_SPLIT_SSA:MediumLevelILVarSplitSsa, # [("high", "var_ssa"), ("low", "var_ssa")],
- MediumLevelILOperation.MLIL_CALL_OUTPUT_SSA:MediumLevelILCallOutputSsa, # [("dest_memory", "int"), ("dest", "var_ssa_list")],
- MediumLevelILOperation.MLIL_CALL_PARAM_SSA:MediumLevelILCallParamSsa, # [("src_memory", "int"), ("src", "var_ssa_list")],
- MediumLevelILOperation.MLIL_LOAD_SSA:MediumLevelILLoadSsa, # [("src", "expr"), ("src_memory", "int")],
- MediumLevelILOperation.MLIL_VAR_PHI:MediumLevelILVarPhi, # [("dest", "var_ssa"), ("src", "var_ssa_list")],
- MediumLevelILOperation.MLIL_MEM_PHI:MediumLevelILMemPhi, # [("dest_memory", "int"), ("src_memory", "int_list")],
- MediumLevelILOperation.MLIL_SET_VAR_SSA:MediumLevelILSetVarSsa, # [("dest", "var_ssa"), ("src", "expr")],
- MediumLevelILOperation.MLIL_FCMP_E:MediumLevelILFcmpE, # [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_FCMP_NE:MediumLevelILFcmpNe, # [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_FCMP_LT:MediumLevelILFcmpLt, # [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_FCMP_LE:MediumLevelILFcmpLe, # [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_FCMP_GE:MediumLevelILFcmpGe, # [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_FCMP_GT:MediumLevelILFcmpGt, # [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_FCMP_O:MediumLevelILFcmpO, # [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_FCMP_UO:MediumLevelILFcmpUo, # [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_FADD:MediumLevelILFadd, # [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_FSUB:MediumLevelILFsub, # [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_FMUL:MediumLevelILFmul, # [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_FDIV:MediumLevelILFdiv, # [("left", "expr"), ("right", "expr")],
- MediumLevelILOperation.MLIL_JUMP_TO:MediumLevelILJumpTo, # [("dest", "expr"), ("targets", "target_map")],
- MediumLevelILOperation.MLIL_SET_VAR_ALIASED:MediumLevelILSetVarAliased, # [("prev", "var_ssa_dest_and_src"), ("src", "expr")],
- MediumLevelILOperation.MLIL_SYSCALL_UNTYPED:MediumLevelILSyscallUntyped, # [("output", "expr"), ("params", "expr"), ("stack", "expr")],
- MediumLevelILOperation.MLIL_TAILCALL:MediumLevelILTailcall, # [("output", "var_list"), ("dest", "expr"), ("params", "expr_list")],
- MediumLevelILOperation.MLIL_INTRINSIC:MediumLevelILIntrinsic, # [("output", "var_list"), ("intrinsic", "intrinsic"), ("params", "expr_list")],
- MediumLevelILOperation.MLIL_INTRINSIC_SSA:MediumLevelILIntrinsicSsa, # [("output", "var_ssa_list"), ("intrinsic", "intrinsic"), ("params", "expr_list")],
- MediumLevelILOperation.MLIL_SET_VAR_SSA_FIELD:MediumLevelILSetVarSsaField, # [("prev", "var_ssa_dest_and_src"), ("offset", "int"), ("src", "expr")],
- MediumLevelILOperation.MLIL_SET_VAR_SPLIT_SSA:MediumLevelILSetVarSplitSsa, # [("high", "var_ssa"), ("low", "var_ssa"), ("src", "expr")],
- MediumLevelILOperation.MLIL_SET_VAR_ALIASED_FIELD:MediumLevelILSetVarAliasedField, # [("prev", "var_ssa_dest_and_src"), ("offset", "int"), ("src", "expr")],
- MediumLevelILOperation.MLIL_SYSCALL_SSA:MediumLevelILSyscallSsa, # [("output", "expr"), ("params", "expr_list"), ("src_memory", "int")],
- MediumLevelILOperation.MLIL_SYSCALL_UNTYPED_SSA:MediumLevelILSyscallUntypedSsa, # [("output", "expr"), ("params", "expr"), ("stack", "expr")],
- MediumLevelILOperation.MLIL_LOAD_STRUCT_SSA:MediumLevelILLoadStructSsa, # [("src", "expr"), ("offset", "int"), ("src_memory", "int")],
- MediumLevelILOperation.MLIL_SET_VAR_FIELD:MediumLevelILSetVarField, # [("dest", "var"), ("offset", "int"), ("src", "expr")],
- MediumLevelILOperation.MLIL_SET_VAR_SPLIT:MediumLevelILSetVarSplit, # [("high", "var"), ("low", "var"), ("src", "expr")],
- MediumLevelILOperation.MLIL_STORE_STRUCT:MediumLevelILStoreStruct, # [("dest", "expr"), ("offset", "int"), ("src", "expr")],
- MediumLevelILOperation.MLIL_ADC:MediumLevelILAdc, # [("left", "expr"), ("right", "expr"), ("carry", "expr")],
- MediumLevelILOperation.MLIL_SBB:MediumLevelILSbb, # [("left", "expr"), ("right", "expr"), ("carry", "expr")],
- MediumLevelILOperation.MLIL_RLC:MediumLevelILRlc, # [("left", "expr"), ("right", "expr"), ("carry", "expr")],
- MediumLevelILOperation.MLIL_RRC:MediumLevelILRrc, # [("left", "expr"), ("right", "expr"), ("carry", "expr")],
- MediumLevelILOperation.MLIL_TAILCALL_UNTYPED:MediumLevelILTailcallUntyped, # [("output", "expr"), ("dest", "expr"), ("params", "expr"), ("stack", "expr")],
- MediumLevelILOperation.MLIL_CALL_SSA:MediumLevelILCallSsa, # [("output", "expr"), ("dest", "expr"), ("params", "expr_list"), ("src_memory", "int")],
- MediumLevelILOperation.MLIL_CALL_UNTYPED_SSA:MediumLevelILCallUntypedSsa, # [("output", "expr"), ("dest", "expr"), ("params", "expr"), ("stack", "expr")],
- MediumLevelILOperation.MLIL_TAILCALL_SSA:MediumLevelILTailcallSsa, # [("output", "expr"), ("dest", "expr"), ("params", "expr_list"), ("src_memory", "int")],
- MediumLevelILOperation.MLIL_TAILCALL_UNTYPED_SSA:MediumLevelILTailcallUntypedSsa, # [("output", "expr"), ("dest", "expr"), ("params", "expr"), ("stack", "expr")],
- MediumLevelILOperation.MLIL_CALL:MediumLevelILCall, # [("output", "var_list"), ("dest", "expr"), ("params", "expr_list")],
- MediumLevelILOperation.MLIL_IF:MediumLevelILIf, # [("condition", "expr"), ("true", "int"), ("false", "int")],
- MediumLevelILOperation.MLIL_STORE_SSA:MediumLevelILStoreSsa, # [("dest", "expr"), ("dest_memory", "int"), ("src_memory", "int"), ("src", "expr")],
- MediumLevelILOperation.MLIL_CALL_UNTYPED:MediumLevelILCallUntyped, # [("output", "expr"), ("dest", "expr"), ("params", "expr"), ("stack", "expr")],
- MediumLevelILOperation.MLIL_STORE_STRUCT_SSA:MediumLevelILStoreStructSsa, # [("dest", "expr"), ("offset", "int"), ("dest_memory", "int"), ("src_memory", "int"), ("src", "expr")],
+ MediumLevelILOperation.MLIL_NOP: MediumLevelILNop, # [],
+ MediumLevelILOperation.MLIL_NORET: MediumLevelILNoret, # [],
+ MediumLevelILOperation.MLIL_BP: MediumLevelILBp, # [],
+ MediumLevelILOperation.MLIL_UNDEF: MediumLevelILUndef, # [],
+ MediumLevelILOperation.MLIL_UNIMPL: MediumLevelILUnimpl, # [],
+ MediumLevelILOperation.MLIL_LOAD: MediumLevelILLoad, # [("src", "expr")],
+ MediumLevelILOperation.MLIL_VAR: MediumLevelILVar, # [("src", "var")],
+ MediumLevelILOperation.MLIL_ADDRESS_OF: MediumLevelILAddressOf, # [("src", "var")],
+ MediumLevelILOperation.MLIL_CONST: MediumLevelILConst, # [("constant", "int")],
+ MediumLevelILOperation.MLIL_CONST_PTR: MediumLevelILConstPtr, # [("constant", "int")],
+ MediumLevelILOperation.MLIL_FLOAT_CONST: MediumLevelILFloatConst, # [("constant", "float")],
+ MediumLevelILOperation.MLIL_IMPORT: MediumLevelILImport, # [("constant", "int")],
+ MediumLevelILOperation.MLIL_SET_VAR: MediumLevelILSetVar, # [("dest", "var"), ("src", "expr")],
+ MediumLevelILOperation.MLIL_LOAD_STRUCT: MediumLevelILLoadStruct, # [("src", "expr"), ("offset", "int")],
+ MediumLevelILOperation.MLIL_STORE: MediumLevelILStore, # [("dest", "expr"), ("src", "expr")],
+ MediumLevelILOperation.MLIL_VAR_FIELD: MediumLevelILVarField, # [("src", "var"), ("offset", "int")],
+ MediumLevelILOperation.MLIL_VAR_SPLIT: MediumLevelILVarSplit, # [("high", "var"), ("low", "var")],
+ MediumLevelILOperation.MLIL_ADDRESS_OF_FIELD: MediumLevelILAddressOfField, # [("src", "var"), ("offset", "int")],
+ MediumLevelILOperation.MLIL_EXTERN_PTR: MediumLevelILExternPtr, # [("constant", "int"), ("offset", "int")],
+ MediumLevelILOperation.MLIL_ADD: MediumLevelILAdd, # [("left", "expr"), ("right", "expr")],
+ MediumLevelILOperation.MLIL_SUB: MediumLevelILSub, # [("left", "expr"), ("right", "expr")],
+ MediumLevelILOperation.MLIL_AND: MediumLevelILAnd, # [("left", "expr"), ("right", "expr")],
+ MediumLevelILOperation.MLIL_OR: MediumLevelILOr, # [("left", "expr"), ("right", "expr")],
+ MediumLevelILOperation.MLIL_XOR: MediumLevelILXor, # [("left", "expr"), ("right", "expr")],
+ MediumLevelILOperation.MLIL_LSL: MediumLevelILLsl, # [("left", "expr"), ("right", "expr")],
+ MediumLevelILOperation.MLIL_LSR: MediumLevelILLsr, # [("left", "expr"), ("right", "expr")],
+ MediumLevelILOperation.MLIL_ASR: MediumLevelILAsr, # [("left", "expr"), ("right", "expr")],
+ MediumLevelILOperation.MLIL_ROL: MediumLevelILRol, # [("left", "expr"), ("right", "expr")],
+ MediumLevelILOperation.MLIL_ROR: MediumLevelILRor, # [("left", "expr"), ("right", "expr")],
+ MediumLevelILOperation.MLIL_MUL: MediumLevelILMul, # [("left", "expr"), ("right", "expr")],
+ MediumLevelILOperation.MLIL_MULU_DP: MediumLevelILMuluDp, # [("left", "expr"), ("right", "expr")],
+ MediumLevelILOperation.MLIL_MULS_DP: MediumLevelILMulsDp, # [("left", "expr"), ("right", "expr")],
+ MediumLevelILOperation.MLIL_DIVU: MediumLevelILDivu, # [("left", "expr"), ("right", "expr")],
+ MediumLevelILOperation.MLIL_DIVU_DP: MediumLevelILDivuDp, # [("left", "expr"), ("right", "expr")],
+ MediumLevelILOperation.MLIL_DIVS: MediumLevelILDivs, # [("left", "expr"), ("right", "expr")],
+ MediumLevelILOperation.MLIL_DIVS_DP: MediumLevelILDivsDp, # [("left", "expr"), ("right", "expr")],
+ MediumLevelILOperation.MLIL_MODU: MediumLevelILModu, # [("left", "expr"), ("right", "expr")],
+ MediumLevelILOperation.MLIL_MODU_DP: MediumLevelILModuDp, # [("left", "expr"), ("right", "expr")],
+ MediumLevelILOperation.MLIL_MODS: MediumLevelILMods, # [("left", "expr"), ("right", "expr")],
+ MediumLevelILOperation.MLIL_MODS_DP: MediumLevelILModsDp, # [("left", "expr"), ("right", "expr")],
+ MediumLevelILOperation.MLIL_NEG: MediumLevelILNeg, # [("src", "expr")],
+ MediumLevelILOperation.MLIL_NOT: MediumLevelILNot, # [("src", "expr")],
+ MediumLevelILOperation.MLIL_SX: MediumLevelILSx, # [("src", "expr")],
+ MediumLevelILOperation.MLIL_ZX: MediumLevelILZx, # [("src", "expr")],
+ MediumLevelILOperation.MLIL_LOW_PART: MediumLevelILLowPart, # [("src", "expr")],
+ MediumLevelILOperation.MLIL_JUMP: MediumLevelILJump, # [("dest", "expr")],
+ MediumLevelILOperation.MLIL_RET_HINT: MediumLevelILRetHint, # [("dest", "expr")],
+ MediumLevelILOperation.MLIL_CALL_OUTPUT: MediumLevelILCallOutput, # [("dest", "var_list")],
+ MediumLevelILOperation.MLIL_CALL_PARAM: MediumLevelILCallParam, # [("src", "var_list")],
+ MediumLevelILOperation.MLIL_RET: MediumLevelILRet, # [("src", "expr_list")],
+ MediumLevelILOperation.MLIL_GOTO: MediumLevelILGoto, # [("dest", "int")],
+ MediumLevelILOperation.MLIL_BOOL_TO_INT: MediumLevelILBoolToInt, # [("src", "expr")],
+ MediumLevelILOperation.MLIL_FREE_VAR_SLOT: MediumLevelILFreeVarSlot, # [("dest", "var")],
+ MediumLevelILOperation.MLIL_TRAP: MediumLevelILTrap, # [("vector", "int")],
+ MediumLevelILOperation.MLIL_FREE_VAR_SLOT_SSA: MediumLevelILFreeVarSlotSsa, # [("prev", "var_ssa_dest_and_src")],
+ MediumLevelILOperation.MLIL_UNIMPL_MEM: MediumLevelILUnimplMem, # [("src", "expr")],
+ MediumLevelILOperation.MLIL_FSQRT: MediumLevelILFsqrt, # [("src", "expr")],
+ MediumLevelILOperation.MLIL_FNEG: MediumLevelILFneg, # [("src", "expr")],
+ MediumLevelILOperation.MLIL_FABS: MediumLevelILFabs, # [("src", "expr")],
+ MediumLevelILOperation.MLIL_FLOAT_TO_INT: MediumLevelILFloatToInt, # [("src", "expr")],
+ MediumLevelILOperation.MLIL_INT_TO_FLOAT: MediumLevelILIntToFloat, # [("src", "expr")],
+ MediumLevelILOperation.MLIL_FLOAT_CONV: MediumLevelILFloatConv, # [("src", "expr")],
+ MediumLevelILOperation.MLIL_ROUND_TO_INT: MediumLevelILRoundToInt, # [("src", "expr")],
+ MediumLevelILOperation.MLIL_FLOOR: MediumLevelILFloor, # [("src", "expr")],
+ MediumLevelILOperation.MLIL_CEIL: MediumLevelILCeil, # [("src", "expr")],
+ MediumLevelILOperation.MLIL_FTRUNC: MediumLevelILFtrunc, # [("src", "expr")],
+ MediumLevelILOperation.MLIL_VAR_SSA: MediumLevelILVarSsa, # [("src", "var_ssa")],
+ MediumLevelILOperation.MLIL_VAR_ALIASED: MediumLevelILVarAliased, # [("src", "var_ssa")],
+ MediumLevelILOperation.MLIL_CMP_E: MediumLevelILCmpE, # [("left", "expr"), ("right", "expr")],
+ MediumLevelILOperation.MLIL_CMP_NE: MediumLevelILCmpNe, # [("left", "expr"), ("right", "expr")],
+ MediumLevelILOperation.MLIL_CMP_SLT: MediumLevelILCmpSlt, # [("left", "expr"), ("right", "expr")],
+ MediumLevelILOperation.MLIL_CMP_ULT: MediumLevelILCmpUlt, # [("left", "expr"), ("right", "expr")],
+ MediumLevelILOperation.MLIL_CMP_SLE: MediumLevelILCmpSle, # [("left", "expr"), ("right", "expr")],
+ MediumLevelILOperation.MLIL_CMP_ULE: MediumLevelILCmpUle, # [("left", "expr"), ("right", "expr")],
+ MediumLevelILOperation.MLIL_CMP_SGE: MediumLevelILCmpSge, # [("left", "expr"), ("right", "expr")],
+ MediumLevelILOperation.MLIL_CMP_UGE: MediumLevelILCmpUge, # [("left", "expr"), ("right", "expr")],
+ MediumLevelILOperation.MLIL_CMP_SGT: MediumLevelILCmpSgt, # [("left", "expr"), ("right", "expr")],
+ MediumLevelILOperation.MLIL_CMP_UGT: MediumLevelILCmpUgt, # [("left", "expr"), ("right", "expr")],
+ MediumLevelILOperation.MLIL_TEST_BIT: MediumLevelILTestBit, # [("left", "expr"), ("right", "expr")],
+ MediumLevelILOperation.MLIL_ADD_OVERFLOW: MediumLevelILAddOverflow, # [("left", "expr"), ("right", "expr")],
+ MediumLevelILOperation.MLIL_SYSCALL: MediumLevelILSyscall, # [("output", "var_list"), ("params", "expr_list")],
+ MediumLevelILOperation.MLIL_VAR_SSA_FIELD: MediumLevelILVarSsaField, # [("src", "var_ssa"), ("offset", "int")],
+ MediumLevelILOperation.MLIL_VAR_ALIASED_FIELD:
+ MediumLevelILVarAliasedField, # [("src", "var_ssa"), ("offset", "int")],
+ MediumLevelILOperation.MLIL_VAR_SPLIT_SSA: MediumLevelILVarSplitSsa, # [("high", "var_ssa"), ("low", "var_ssa")],
+ MediumLevelILOperation.MLIL_CALL_OUTPUT_SSA:
+ MediumLevelILCallOutputSsa, # [("dest_memory", "int"), ("dest", "var_ssa_list")],
+ MediumLevelILOperation.MLIL_CALL_PARAM_SSA:
+ MediumLevelILCallParamSsa, # [("src_memory", "int"), ("src", "var_ssa_list")],
+ MediumLevelILOperation.MLIL_LOAD_SSA: MediumLevelILLoadSsa, # [("src", "expr"), ("src_memory", "int")],
+ MediumLevelILOperation.MLIL_VAR_PHI: MediumLevelILVarPhi, # [("dest", "var_ssa"), ("src", "var_ssa_list")],
+ MediumLevelILOperation.MLIL_MEM_PHI: MediumLevelILMemPhi, # [("dest_memory", "int"), ("src_memory", "int_list")],
+ MediumLevelILOperation.MLIL_SET_VAR_SSA: MediumLevelILSetVarSsa, # [("dest", "var_ssa"), ("src", "expr")],
+ MediumLevelILOperation.MLIL_FCMP_E: MediumLevelILFcmpE, # [("left", "expr"), ("right", "expr")],
+ MediumLevelILOperation.MLIL_FCMP_NE: MediumLevelILFcmpNe, # [("left", "expr"), ("right", "expr")],
+ MediumLevelILOperation.MLIL_FCMP_LT: MediumLevelILFcmpLt, # [("left", "expr"), ("right", "expr")],
+ MediumLevelILOperation.MLIL_FCMP_LE: MediumLevelILFcmpLe, # [("left", "expr"), ("right", "expr")],
+ MediumLevelILOperation.MLIL_FCMP_GE: MediumLevelILFcmpGe, # [("left", "expr"), ("right", "expr")],
+ MediumLevelILOperation.MLIL_FCMP_GT: MediumLevelILFcmpGt, # [("left", "expr"), ("right", "expr")],
+ MediumLevelILOperation.MLIL_FCMP_O: MediumLevelILFcmpO, # [("left", "expr"), ("right", "expr")],
+ MediumLevelILOperation.MLIL_FCMP_UO: MediumLevelILFcmpUo, # [("left", "expr"), ("right", "expr")],
+ MediumLevelILOperation.MLIL_FADD: MediumLevelILFadd, # [("left", "expr"), ("right", "expr")],
+ MediumLevelILOperation.MLIL_FSUB: MediumLevelILFsub, # [("left", "expr"), ("right", "expr")],
+ MediumLevelILOperation.MLIL_FMUL: MediumLevelILFmul, # [("left", "expr"), ("right", "expr")],
+ MediumLevelILOperation.MLIL_FDIV: MediumLevelILFdiv, # [("left", "expr"), ("right", "expr")],
+ MediumLevelILOperation.MLIL_JUMP_TO: MediumLevelILJumpTo, # [("dest", "expr"), ("targets", "target_map")],
+ MediumLevelILOperation.MLIL_SET_VAR_ALIASED:
+ MediumLevelILSetVarAliased, # [("prev", "var_ssa_dest_and_src"), ("src", "expr")],
+ MediumLevelILOperation.MLIL_SYSCALL_UNTYPED:
+ MediumLevelILSyscallUntyped, # [("output", "expr"), ("params", "expr"), ("stack", "expr")],
+ MediumLevelILOperation.MLIL_TAILCALL:
+ MediumLevelILTailcall, # [("output", "var_list"), ("dest", "expr"), ("params", "expr_list")],
+ MediumLevelILOperation.MLIL_INTRINSIC:
+ MediumLevelILIntrinsic, # [("output", "var_list"), ("intrinsic", "intrinsic"), ("params", "expr_list")],
+ MediumLevelILOperation.MLIL_INTRINSIC_SSA:
+ MediumLevelILIntrinsicSsa, # [("output", "var_ssa_list"), ("intrinsic", "intrinsic"), ("params", "expr_list")],
+ MediumLevelILOperation.MLIL_SET_VAR_SSA_FIELD:
+ MediumLevelILSetVarSsaField, # [("prev", "var_ssa_dest_and_src"), ("offset", "int"), ("src", "expr")],
+ MediumLevelILOperation.MLIL_SET_VAR_SPLIT_SSA:
+ MediumLevelILSetVarSplitSsa, # [("high", "var_ssa"), ("low", "var_ssa"), ("src", "expr")],
+ MediumLevelILOperation.MLIL_SET_VAR_ALIASED_FIELD:
+ MediumLevelILSetVarAliasedField, # [("prev", "var_ssa_dest_and_src"), ("offset", "int"), ("src", "expr")],
+ MediumLevelILOperation.MLIL_SYSCALL_SSA:
+ MediumLevelILSyscallSsa, # [("output", "expr"), ("params", "expr_list"), ("src_memory", "int")],
+ MediumLevelILOperation.MLIL_SYSCALL_UNTYPED_SSA:
+ MediumLevelILSyscallUntypedSsa, # [("output", "expr"), ("params", "expr"), ("stack", "expr")],
+ MediumLevelILOperation.MLIL_LOAD_STRUCT_SSA:
+ MediumLevelILLoadStructSsa, # [("src", "expr"), ("offset", "int"), ("src_memory", "int")],
+ MediumLevelILOperation.MLIL_SET_VAR_FIELD:
+ MediumLevelILSetVarField, # [("dest", "var"), ("offset", "int"), ("src", "expr")],
+ MediumLevelILOperation.MLIL_SET_VAR_SPLIT:
+ MediumLevelILSetVarSplit, # [("high", "var"), ("low", "var"), ("src", "expr")],
+ MediumLevelILOperation.MLIL_STORE_STRUCT:
+ MediumLevelILStoreStruct, # [("dest", "expr"), ("offset", "int"), ("src", "expr")],
+ MediumLevelILOperation.MLIL_ADC: MediumLevelILAdc, # [("left", "expr"), ("right", "expr"), ("carry", "expr")],
+ MediumLevelILOperation.MLIL_SBB: MediumLevelILSbb, # [("left", "expr"), ("right", "expr"), ("carry", "expr")],
+ MediumLevelILOperation.MLIL_RLC: MediumLevelILRlc, # [("left", "expr"), ("right", "expr"), ("carry", "expr")],
+ MediumLevelILOperation.MLIL_RRC: MediumLevelILRrc, # [("left", "expr"), ("right", "expr"), ("carry", "expr")],
+ MediumLevelILOperation.MLIL_TAILCALL_UNTYPED:
+ MediumLevelILTailcallUntyped, # [("output", "expr"), ("dest", "expr"), ("params", "expr"), ("stack", "expr")],
+ MediumLevelILOperation.MLIL_CALL_SSA:
+ MediumLevelILCallSsa, # [("output", "expr"), ("dest", "expr"), ("params", "expr_list"), ("src_memory", "int")],
+ MediumLevelILOperation.MLIL_CALL_UNTYPED_SSA:
+ MediumLevelILCallUntypedSsa, # [("output", "expr"), ("dest", "expr"), ("params", "expr"), ("stack", "expr")],
+ MediumLevelILOperation.MLIL_TAILCALL_SSA:
+ MediumLevelILTailcallSsa, # [("output", "expr"), ("dest", "expr"), ("params", "expr_list"), ("src_memory", "int")],
+ MediumLevelILOperation.MLIL_TAILCALL_UNTYPED_SSA:
+ MediumLevelILTailcallUntypedSsa, # [("output", "expr"), ("dest", "expr"), ("params", "expr"), ("stack", "expr")],
+ MediumLevelILOperation.MLIL_CALL:
+ MediumLevelILCall, # [("output", "var_list"), ("dest", "expr"), ("params", "expr_list")],
+ MediumLevelILOperation.MLIL_IF: MediumLevelILIf, # [("condition", "expr"), ("true", "int"), ("false", "int")],
+ MediumLevelILOperation.MLIL_STORE_SSA:
+ MediumLevelILStoreSsa, # [("dest", "expr"), ("dest_memory", "int"), ("src_memory", "int"), ("src", "expr")],
+ MediumLevelILOperation.MLIL_CALL_UNTYPED:
+ MediumLevelILCallUntyped, # [("output", "expr"), ("dest", "expr"), ("params", "expr"), ("stack", "expr")],
+ MediumLevelILOperation.MLIL_STORE_STRUCT_SSA:
+ MediumLevelILStoreStructSsa, # [("dest", "expr"), ("offset", "int"), ("dest_memory", "int"), ("src_memory", "int"), ("src", "expr")],
}
+
class MediumLevelILExpr:
"""
``class MediumLevelILExpr`` hold the index of IL Expressions.
@@ -2585,15 +2637,17 @@ class MediumLevelILFunction:
objects can be added to the MediumLevelILFunction by calling :func:`append` and passing the result of the various class
methods which return ExpressionIndex objects.
"""
- def __init__(self, arch:Optional['architecture.Architecture']=None,
- handle:Optional[core.BNMediumLevelILFunction]=None, source_func:Optional['function.Function']=None):
+ def __init__(
+ self, arch: Optional['architecture.Architecture'] = None, handle: Optional[core.BNMediumLevelILFunction] = None,
+ source_func: Optional['function.Function'] = None
+ ):
_arch = arch
_source_function = source_func
if handle is not None:
MLILHandle = ctypes.POINTER(core.BNMediumLevelILFunction)
_handle = ctypes.cast(handle, MLILHandle)
if _source_function is None:
- _source_function = function.Function(handle = core.BNGetMediumLevelILOwnerFunction(_handle))
+ _source_function = function.Function(handle=core.BNGetMediumLevelILOwnerFunction(_handle))
if _arch is None:
_arch = _source_function.arch
else:
@@ -2640,13 +2694,15 @@ class MediumLevelILFunction:
def __getitem__(self, i) -> 'MediumLevelILInstruction':
if isinstance(i, slice) or isinstance(i, tuple):
raise IndexError("expected integer instruction index")
- elif isinstance(i, MediumLevelILInstruction): # for backwards compatibility
+ elif isinstance(i, MediumLevelILInstruction): # for backwards compatibility
return i
if i < -len(self) or i >= len(self):
raise IndexError("index out of range")
if i < 0:
i = len(self) + i
- return MediumLevelILInstruction.create(self, ExpressionIndex(core.BNGetMediumLevelILIndexForInstruction(self.handle, i)), i)
+ return MediumLevelILInstruction.create(
+ self, ExpressionIndex(core.BNGetMediumLevelILIndexForInstruction(self.handle, i)), i
+ )
def __setitem__(self, i, j):
raise IndexError("instruction modification not implemented")
@@ -2672,10 +2728,10 @@ class MediumLevelILFunction:
return core.BNMediumLevelILGetCurrentAddress(self.handle)
@current_address.setter
- def current_address(self, value:int) -> None:
+ def current_address(self, value: int) -> None:
core.BNMediumLevelILSetCurrentAddress(self.handle, self._arch.handle, value)
- def set_current_address(self, value:int, arch:Optional['architecture.Architecture']=None) -> None:
+ def set_current_address(self, value: int, arch: Optional['architecture.Architecture'] = None) -> None:
_arch = arch
if _arch is None:
_arch = self._arch
@@ -2741,7 +2797,7 @@ class MediumLevelILFunction:
def hlil(self) -> Optional[highlevelil.HighLevelILFunction]:
return self.high_level_il
- def get_instruction_start(self, addr:int, arch:Optional['architecture.Architecture']=None) -> Optional[int]:
+ def get_instruction_start(self, addr: int, arch: Optional['architecture.Architecture'] = None) -> Optional[int]:
_arch = arch
if _arch is None:
if self._arch is None:
@@ -2752,8 +2808,10 @@ class MediumLevelILFunction:
return None
return result
- def expr(self, operation:MediumLevelILOperation, a:int=0, b:int=0, c:int=0, d:int=0, e:int=0,
- size:int=0) -> ExpressionIndex:
+ def expr(
+ self, operation: MediumLevelILOperation, a: int = 0, b: int = 0, c: int = 0, d: int = 0, e: int = 0,
+ size: int = 0
+ ) -> ExpressionIndex:
_operation = operation
if isinstance(operation, str):
_operation = MediumLevelILOperation[operation]
@@ -2761,7 +2819,7 @@ class MediumLevelILFunction:
_operation = operation.value
return ExpressionIndex(core.BNMediumLevelILAddExpr(self.handle, _operation, size, a, b, c, d, e))
- def append(self, expr:ExpressionIndex) -> int:
+ def append(self, expr: ExpressionIndex) -> int:
"""
``append`` adds the ExpressionIndex ``expr`` to the current MediumLevelILFunction.
@@ -2771,7 +2829,7 @@ class MediumLevelILFunction:
"""
return core.BNMediumLevelILAddInstruction(self.handle, expr)
- def goto(self, label:MediumLevelILLabel) -> ExpressionIndex:
+ def goto(self, label: MediumLevelILLabel) -> ExpressionIndex:
"""
``goto`` returns a goto expression which jumps to the provided MediumLevelILLabel.
@@ -2781,7 +2839,7 @@ class MediumLevelILFunction:
"""
return ExpressionIndex(core.BNMediumLevelILGoto(self.handle, label.handle))
- def if_expr(self, operand:ExpressionIndex, t:MediumLevelILLabel, f:MediumLevelILLabel) -> ExpressionIndex:
+ def if_expr(self, operand: ExpressionIndex, t: MediumLevelILLabel, f: MediumLevelILLabel) -> ExpressionIndex:
"""
``if_expr`` returns the ``if`` expression which depending on condition ``operand`` jumps to the MediumLevelILLabel
``t`` when the condition expression ``operand`` is non-zero and ``f`` when it's zero.
@@ -2794,7 +2852,7 @@ class MediumLevelILFunction:
"""
return ExpressionIndex(core.BNMediumLevelILIf(self.handle, operand, t.handle, f.handle))
- def mark_label(self, label:MediumLevelILLabel) -> None:
+ def mark_label(self, label: MediumLevelILLabel) -> None:
"""
``mark_label`` assigns a MediumLevelILLabel to the current IL address.
@@ -2803,7 +2861,7 @@ class MediumLevelILFunction:
"""
core.BNMediumLevelILMarkLabel(self.handle, label.handle)
- def add_label_map(self, labels:Mapping[int, MediumLevelILLabel]) -> ExpressionIndex:
+ def add_label_map(self, labels: Mapping[int, MediumLevelILLabel]) -> ExpressionIndex:
"""
``add_label_map`` returns a label list expression for the given list of MediumLevelILLabel objects.
@@ -2820,7 +2878,7 @@ class MediumLevelILFunction:
return ExpressionIndex(core.BNMediumLevelILAddLabelMap(self.handle, value_list, label_list, len(labels)))
- def add_operand_list(self, operands:List[ExpressionIndex]) -> ExpressionIndex:
+ def add_operand_list(self, operands: List[ExpressionIndex]) -> ExpressionIndex:
"""
``add_operand_list`` returns an operand list expression for the given list of integer operands.
@@ -2842,26 +2900,26 @@ class MediumLevelILFunction:
"""
core.BNFinalizeMediumLevelILFunction(self.handle)
- def get_ssa_instruction_index(self, instr:InstructionIndex) -> InstructionIndex:
+ def get_ssa_instruction_index(self, instr: InstructionIndex) -> InstructionIndex:
return InstructionIndex(core.BNGetMediumLevelILSSAInstructionIndex(self.handle, instr))
- def get_non_ssa_instruction_index(self, instr:InstructionIndex) -> InstructionIndex:
+ def get_non_ssa_instruction_index(self, instr: InstructionIndex) -> InstructionIndex:
return InstructionIndex(core.BNGetMediumLevelILNonSSAInstructionIndex(self.handle, instr))
- def get_ssa_var_definition(self, ssa_var:SSAVariable) -> Optional[MediumLevelILInstruction]:
+ def get_ssa_var_definition(self, ssa_var: SSAVariable) -> Optional[MediumLevelILInstruction]:
var_data = ssa_var.var.to_BNVariable()
result = core.BNGetMediumLevelILSSAVarDefinition(self.handle, var_data, ssa_var.version)
if result >= core.BNGetMediumLevelILInstructionCount(self.handle):
return None
return self[result]
- def get_ssa_memory_definition(self, version:int) -> Optional[MediumLevelILInstruction]:
+ def get_ssa_memory_definition(self, version: int) -> Optional[MediumLevelILInstruction]:
result = core.BNGetMediumLevelILSSAMemoryDefinition(self.handle, version)
if result >= core.BNGetMediumLevelILInstructionCount(self.handle):
return None
return self[result]
- def get_ssa_var_uses(self, ssa_var:SSAVariable) -> List[MediumLevelILInstruction]:
+ def get_ssa_var_uses(self, ssa_var: SSAVariable) -> List[MediumLevelILInstruction]:
count = ctypes.c_ulonglong()
var_data = ssa_var.var.to_BNVariable()
instrs = core.BNGetMediumLevelILSSAVarUses(self.handle, var_data, ssa_var.version, count)
@@ -2872,7 +2930,7 @@ class MediumLevelILFunction:
core.BNFreeILInstructionList(instrs)
return result
- def get_ssa_memory_uses(self, version:int) -> List[MediumLevelILInstruction]:
+ def get_ssa_memory_uses(self, version: int) -> List[MediumLevelILInstruction]:
count = ctypes.c_ulonglong()
instrs = core.BNGetMediumLevelILSSAMemoryUses(self.handle, version, count)
assert instrs is not None, "core.BNGetMediumLevelILSSAMemoryUses returned None"
@@ -2882,7 +2940,7 @@ class MediumLevelILFunction:
core.BNFreeILInstructionList(instrs)
return result
- def is_ssa_var_live(self, ssa_var:SSAVariable) -> bool:
+ def is_ssa_var_live(self, ssa_var: SSAVariable) -> bool:
"""
``is_ssa_var_live`` determines if ``ssa_var`` is live at any point in the function
@@ -2893,7 +2951,7 @@ class MediumLevelILFunction:
var_data = ssa_var.var.to_BNVariable()
return core.BNIsMediumLevelILSSAVarLive(self.handle, var_data, ssa_var.version)
- def get_var_definitions(self, var:'variable.Variable') -> List[MediumLevelILInstruction]:
+ def get_var_definitions(self, var: 'variable.Variable') -> List[MediumLevelILInstruction]:
count = ctypes.c_ulonglong()
var_data = var.to_BNVariable()
instrs = core.BNGetMediumLevelILVariableDefinitions(self.handle, var_data, count)
@@ -2904,7 +2962,7 @@ class MediumLevelILFunction:
core.BNFreeILInstructionList(instrs)
return result
- def get_var_uses(self, var:'variable.Variable') -> List[MediumLevelILInstruction]:
+ def get_var_uses(self, var: 'variable.Variable') -> List[MediumLevelILInstruction]:
count = ctypes.c_ulonglong()
var_data = var.to_BNVariable()
instrs = core.BNGetMediumLevelILVariableUses(self.handle, var_data, count)
@@ -2917,13 +2975,13 @@ class MediumLevelILFunction:
finally:
core.BNFreeILInstructionList(instrs)
- def get_ssa_var_value(self, ssa_var:SSAVariable) -> 'variable.RegisterValue':
+ def get_ssa_var_value(self, ssa_var: SSAVariable) -> 'variable.RegisterValue':
var_data = ssa_var.var.to_BNVariable()
value = core.BNGetMediumLevelILSSAVarValue(self.handle, var_data, ssa_var.version)
result = variable.RegisterValue.from_BNRegisterValue(value, self._arch)
return result
- def get_low_level_il_instruction_index(self, instr:InstructionIndex) -> Optional['lowlevelil.InstructionIndex']:
+ def get_low_level_il_instruction_index(self, instr: InstructionIndex) -> Optional['lowlevelil.InstructionIndex']:
low_il = self.low_level_il
if low_il is None:
return None
@@ -2935,7 +2993,7 @@ class MediumLevelILFunction:
return None
return lowlevelil.InstructionIndex(result)
- def get_low_level_il_expr_index(self, expr:ExpressionIndex) -> Optional['lowlevelil.ExpressionIndex']:
+ def get_low_level_il_expr_index(self, expr: ExpressionIndex) -> Optional['lowlevelil.ExpressionIndex']:
low_il = self.low_level_il
if low_il is None:
return None
@@ -2947,17 +3005,17 @@ class MediumLevelILFunction:
return None
return lowlevelil.ExpressionIndex(result)
- def get_low_level_il_expr_indexes(self, expr:ExpressionIndex) -> List['lowlevelil.ExpressionIndex']:
+ def get_low_level_il_expr_indexes(self, expr: ExpressionIndex) -> List['lowlevelil.ExpressionIndex']:
count = ctypes.c_ulonglong()
exprs = core.BNGetLowLevelILExprIndexes(self.handle, expr, count)
assert exprs is not None, "core.BNGetLowLevelILExprIndexes returned None"
- result:List['lowlevelil.ExpressionIndex'] = []
+ result: List['lowlevelil.ExpressionIndex'] = []
for i in range(0, count.value):
result.append(lowlevelil.ExpressionIndex(exprs[i]))
core.BNFreeILInstructionList(exprs)
return result
- def get_high_level_il_instruction_index(self, instr:InstructionIndex) -> Optional['highlevelil.InstructionIndex']:
+ def get_high_level_il_instruction_index(self, instr: InstructionIndex) -> Optional['highlevelil.InstructionIndex']:
high_il = self.high_level_il
if high_il is None:
return None
@@ -2966,7 +3024,7 @@ class MediumLevelILFunction:
return None
return highlevelil.InstructionIndex(result)
- def get_high_level_il_expr_index(self, expr:ExpressionIndex) -> Optional['highlevelil.ExpressionIndex']:
+ def get_high_level_il_expr_index(self, expr: ExpressionIndex) -> Optional['highlevelil.ExpressionIndex']:
high_il = self.high_level_il
if high_il is None:
return None
@@ -2975,17 +3033,17 @@ class MediumLevelILFunction:
return None
return highlevelil.ExpressionIndex(result)
- def get_high_level_il_expr_indexes(self, expr:ExpressionIndex) -> List['highlevelil.ExpressionIndex']:
+ def get_high_level_il_expr_indexes(self, expr: ExpressionIndex) -> List['highlevelil.ExpressionIndex']:
count = ctypes.c_ulonglong()
exprs = core.BNGetHighLevelILExprIndexes(self.handle, expr, count)
assert exprs is not None, "core.BNGetHighLevelILExprIndexes returned None"
- result:List['highlevelil.ExpressionIndex'] = []
+ result: List['highlevelil.ExpressionIndex'] = []
for i in range(0, count.value):
result.append(highlevelil.ExpressionIndex(exprs[i]))
core.BNFreeILInstructionList(exprs)
return result
- def create_graph(self, settings:'function.DisassemblySettings'=None) -> flowgraph.CoreFlowGraph:
+ def create_graph(self, settings: 'function.DisassemblySettings' = None) -> flowgraph.CoreFlowGraph:
if settings is not None:
settings_obj = settings.handle
else:
@@ -3020,14 +3078,22 @@ class MediumLevelILFunction:
if self.source_function is None:
return []
- if self.il_form in [FunctionGraphType.MediumLevelILFunctionGraph, FunctionGraphType.MediumLevelILSSAFormFunctionGraph, FunctionGraphType.MappedMediumLevelILFunctionGraph, FunctionGraphType.MappedMediumLevelILSSAFormFunctionGraph]:
+ if self.il_form in [
+ FunctionGraphType.MediumLevelILFunctionGraph, FunctionGraphType.MediumLevelILSSAFormFunctionGraph,
+ FunctionGraphType.MappedMediumLevelILFunctionGraph,
+ FunctionGraphType.MappedMediumLevelILSSAFormFunctionGraph
+ ]:
count = ctypes.c_ulonglong()
core_variables = core.BNGetMediumLevelILVariables(self.handle, count)
assert core_variables is not None, "core.BNGetMediumLevelILVariables returned None"
result = []
try:
for var_i in range(count.value):
- result.append(variable.Variable(self, core_variables[var_i].type, core_variables[var_i].index, core_variables[var_i].storage))
+ result.append(
+ variable.Variable(
+ self, core_variables[var_i].type, core_variables[var_i].index, core_variables[var_i].storage
+ )
+ )
return result
finally:
core.BNFreeVariableList(core_variables)
@@ -3039,14 +3105,20 @@ class MediumLevelILFunction:
if self.source_function is None:
return []
- if self.il_form in [FunctionGraphType.MediumLevelILFunctionGraph, FunctionGraphType.MediumLevelILSSAFormFunctionGraph]:
+ if self.il_form in [
+ FunctionGraphType.MediumLevelILFunctionGraph, FunctionGraphType.MediumLevelILSSAFormFunctionGraph
+ ]:
count = ctypes.c_ulonglong()
core_variables = core.BNGetMediumLevelILAliasedVariables(self.handle, count)
assert core_variables is not None, "core.BNGetMediumLevelILAliasedVariables returned None"
try:
result = []
for var_i in range(count.value):
- result.append(variable.Variable(self, core_variables[var_i].type, core_variables[var_i].index, core_variables[var_i].storage))
+ result.append(
+ variable.Variable(
+ self, core_variables[var_i].type, core_variables[var_i].index, core_variables[var_i].storage
+ )
+ )
return result
finally:
core.BNFreeVariableList(core_variables)
@@ -3058,7 +3130,10 @@ class MediumLevelILFunction:
if self.source_function is None:
return []
- if self.il_form in [FunctionGraphType.MediumLevelILSSAFormFunctionGraph, FunctionGraphType.MappedMediumLevelILSSAFormFunctionGraph]:
+ if self.il_form in [
+ FunctionGraphType.MediumLevelILSSAFormFunctionGraph,
+ FunctionGraphType.MappedMediumLevelILSSAFormFunctionGraph
+ ]:
variable_count = ctypes.c_ulonglong()
core_variables = core.BNGetMediumLevelILVariables(self.handle, variable_count)
assert core_variables is not None, "core.BNGetMediumLevelILVariables returned None"
@@ -3066,27 +3141,39 @@ class MediumLevelILFunction:
result = []
for var_i in range(variable_count.value):
version_count = ctypes.c_ulonglong()
- versions = core.BNGetMediumLevelILVariableSSAVersions(self.handle, core_variables[var_i], version_count)
+ versions = core.BNGetMediumLevelILVariableSSAVersions(
+ self.handle, core_variables[var_i], version_count
+ )
assert versions is not None, "core.BNGetMediumLevelILVariableSSAVersions returned None"
try:
for version_i in range(version_count.value):
- result.append(SSAVariable(variable.Variable(self,
- core_variables[var_i].type, core_variables[var_i].index,
- core_variables[var_i].storage), versions[version_i]))
+ result.append(
+ SSAVariable(
+ variable.Variable(
+ self, core_variables[var_i].type, core_variables[var_i].index,
+ core_variables[var_i].storage
+ ), versions[version_i]
+ )
+ )
finally:
core.BNFreeILInstructionList(versions)
return result
finally:
core.BNFreeVariableList(core_variables)
- elif self.il_form in [FunctionGraphType.MediumLevelILFunctionGraph, FunctionGraphType.MappedMediumLevelILFunctionGraph]:
+ elif self.il_form in [
+ FunctionGraphType.MediumLevelILFunctionGraph, FunctionGraphType.MappedMediumLevelILFunctionGraph
+ ]:
return self.ssa_form.ssa_vars
return []
class MediumLevelILBasicBlock(basicblock.BasicBlock):
- def __init__(self, handle:core.BNBasicBlockHandle, owner:MediumLevelILFunction, view:Optional['binaryview.BinaryView']=None):
+ def __init__(
+ self, handle: core.BNBasicBlockHandle, owner: MediumLevelILFunction,
+ view: Optional['binaryview.BinaryView'] = None
+ ):
super(MediumLevelILBasicBlock, self).__init__(handle, view)
self._il_function = owner
@@ -3123,7 +3210,9 @@ class MediumLevelILBasicBlock(basicblock.BasicBlock):
else:
return False
- def _create_instance(self, handle:core.BNBasicBlockHandle, view:'binaryview.BinaryView') -> 'MediumLevelILBasicBlock':
+ def _create_instance(
+ self, handle: core.BNBasicBlockHandle, view: 'binaryview.BinaryView'
+ ) -> 'MediumLevelILBasicBlock':
"""Internal method by super to instantiate child instances"""
return MediumLevelILBasicBlock(handle, self.il_function, view)
diff --git a/python/metadata.py b/python/metadata.py
index c7820ee9..4c643112 100644
--- a/python/metadata.py
+++ b/python/metadata.py
@@ -27,9 +27,12 @@ from .enums import MetadataType
MetadataValueType = Union[int, bool, str, bytes, float, List['MetadataValueType'], Tuple['MetadataValueType'], dict]
+
class Metadata:
- def __init__(self, value:MetadataValueType=None, signed:Optional[bool]=None,
- raw:Optional[bool]=None, handle:Optional[core.BNMetadata]=None):
+ def __init__(
+ self, value: MetadataValueType = None, signed: Optional[bool] = None, raw: Optional[bool] = None,
+ handle: Optional[core.BNMetadata] = None
+ ):
if handle is not None:
self.handle = handle
elif isinstance(value, int):
@@ -278,4 +281,4 @@ class Metadata:
elif isinstance(key_or_index, int) and self.is_array:
core.BNMetadataRemoveIndex(self.handle, key_or_index)
else:
- raise TypeError("remove only valid for dict and array objects") \ No newline at end of file
+ raise TypeError("remove only valid for dict and array objects")
diff --git a/python/platform.py b/python/platform.py
index 050aa21e..28a2a5f2 100644
--- a/python/platform.py
+++ b/python/platform.py
@@ -39,7 +39,7 @@ class _PlatformMetaClass(type):
assert platforms is not None, "core.BNGetPlatformList returned None"
try:
for i in range(0, count.value):
- yield Platform(handle = core.BNNewPlatformReference(platforms[i]))
+ yield Platform(handle=core.BNNewPlatformReference(platforms[i]))
finally:
core.BNFreePlatformList(platforms, count.value)
@@ -48,7 +48,7 @@ class _PlatformMetaClass(type):
platform = core.BNGetPlatformByName(str(value))
if platform is None:
raise KeyError("'%s' is not a valid platform" % str(value))
- return Platform(handle = platform)
+ return Platform(handle=platform)
class Platform(metaclass=_PlatformMetaClass):
@@ -57,10 +57,10 @@ class Platform(metaclass=_PlatformMetaClass):
calling conventions used.
"""
name = None
- type_file_path = None # path to platform types file
- type_include_dirs = [] # list of directories available to #include from type_file_path
+ type_file_path = None # path to platform types file
+ type_include_dirs = [] # list of directories available to #include from type_file_path
- def __init__(self, arch:'architecture.Architecture'=None, handle=None):
+ def __init__(self, arch: 'architecture.Architecture' = None, handle=None):
if handle is None:
if arch is None:
raise ValueError("platform must have an associated architecture")
@@ -73,7 +73,10 @@ class Platform(metaclass=_PlatformMetaClass):
dir_buf = (ctypes.c_char_p * len(self.__class__.type_include_dirs))()
for (i, dir) in enumerate(self.__class__.type_include_dirs):
dir_buf[i] = dir.encode('charmap')
- _handle = core.BNCreatePlatformWithTypes(arch.handle, self.__class__.name, self.__class__.type_file_path, dir_buf, len(self.__class__.type_include_dirs))
+ _handle = core.BNCreatePlatformWithTypes(
+ arch.handle, self.__class__.name, self.__class__.type_file_path, dir_buf,
+ len(self.__class__.type_include_dirs)
+ )
assert _handle is not None
else:
_handle = handle
@@ -121,7 +124,7 @@ class Platform(metaclass=_PlatformMetaClass):
return result
@classmethod
- def get_list(cls, os = None, arch = None):
+ def get_list(cls, os=None, arch=None):
binaryninja._init_plugins()
count = ctypes.c_ulonglong()
if os is None:
@@ -135,7 +138,7 @@ class Platform(metaclass=_PlatformMetaClass):
assert platforms is not None, "core.BNGetPlatformListByArchitecture returned None"
result = []
for i in range(0, count.value):
- result.append(Platform(handle = core.BNNewPlatformReference(platforms[i])))
+ result.append(Platform(handle=core.BNNewPlatformReference(platforms[i])))
core.BNFreePlatformList(platforms, count.value)
return result
@@ -251,7 +254,7 @@ class Platform(metaclass=_PlatformMetaClass):
result = {}
for i in range(0, count.value):
name = types.QualifiedName._from_core_struct(type_list[i].name)
- result[name] = types.Type.create(core.BNNewTypeReference(type_list[i].type), platform = self)
+ result[name] = types.Type.create(core.BNNewTypeReference(type_list[i].type), platform=self)
core.BNFreeTypeList(type_list, count.value)
return result
@@ -264,7 +267,7 @@ class Platform(metaclass=_PlatformMetaClass):
result = {}
for i in range(0, count.value):
name = types.QualifiedName._from_core_struct(type_list[i].name)
- result[name] = types.Type.create(core.BNNewTypeReference(type_list[i].type), platform = self)
+ result[name] = types.Type.create(core.BNNewTypeReference(type_list[i].type), platform=self)
core.BNFreeTypeList(type_list, count.value)
return result
@@ -277,7 +280,7 @@ class Platform(metaclass=_PlatformMetaClass):
result = {}
for i in range(0, count.value):
name = types.QualifiedName._from_core_struct(type_list[i].name)
- result[name] = types.Type.create(core.BNNewTypeReference(type_list[i].type), platform = self)
+ result[name] = types.Type.create(core.BNNewTypeReference(type_list[i].type), platform=self)
core.BNFreeTypeList(type_list, count.value)
return result
@@ -290,7 +293,7 @@ class Platform(metaclass=_PlatformMetaClass):
result = {}
for i in range(0, count.value):
name = types.QualifiedName._from_core_struct(call_list[i].name)
- t = types.Type.create(core.BNNewTypeReference(call_list[i].type), platform = self)
+ t = types.Type.create(core.BNNewTypeReference(call_list[i].type), platform=self)
result[call_list[i].number] = (name, t)
core.BNFreeSystemCallList(call_list, count.value)
return result
@@ -338,7 +341,7 @@ class Platform(metaclass=_PlatformMetaClass):
result = core.BNGetRelatedPlatform(self.handle, arch.handle)
if not result:
return None
- return Platform(handle = result)
+ return Platform(handle=result)
def add_related_platform(self, arch, platform):
core.BNAddRelatedPlatform(self.handle, arch.handle, platform.handle)
@@ -347,28 +350,28 @@ class Platform(metaclass=_PlatformMetaClass):
new_addr = ctypes.c_ulonglong()
new_addr.value = addr
result = core.BNGetAssociatedPlatformByAddress(self.handle, new_addr)
- return Platform(handle = result), new_addr.value
+ return Platform(handle=result), new_addr.value
def get_type_by_name(self, name):
name = types.QualifiedName(name)._to_core_struct()
obj = core.BNGetPlatformTypeByName(self.handle, name)
if not obj:
return None
- return types.Type.create(core.BNNewTypeReference(obj), platform = self)
+ return types.Type.create(core.BNNewTypeReference(obj), platform=self)
def get_variable_by_name(self, name):
name = types.QualifiedName(name)._to_core_struct()
obj = core.BNGetPlatformVariableByName(self.handle, name)
if not obj:
return None
- return types.Type.create(core.BNNewTypeReference(obj), platform = self)
+ return types.Type.create(core.BNNewTypeReference(obj), platform=self)
def get_function_by_name(self, name, exactMatch=False):
name = types.QualifiedName(name)._to_core_struct()
obj = core.BNGetPlatformFunctionByName(self.handle, name, exactMatch)
if not obj:
return None
- return types.Type.create(core.BNNewTypeReference(obj), platform = self)
+ return types.Type.create(core.BNNewTypeReference(obj), platform=self)
def get_system_call_name(self, number):
return core.BNGetPlatformSystemCallName(self.handle, number)
@@ -377,7 +380,7 @@ class Platform(metaclass=_PlatformMetaClass):
obj = core.BNGetPlatformSystemCallType(self.handle, number)
if not obj:
return None
- return types.Type.create(core.BNNewTypeReference(obj), platform = self)
+ return types.Type.create(core.BNNewTypeReference(obj), platform=self)
def generate_auto_platform_type_id(self, name):
name = types.QualifiedName(name)._to_core_struct()
@@ -390,7 +393,9 @@ class Platform(metaclass=_PlatformMetaClass):
def get_auto_platform_type_id_source(self):
return core.BNGetAutoPlatformTypeIdSource(self.handle)
- def parse_types_from_source(self, source, filename=None, include_dirs:Optional[List[str]]=None, auto_type_source=None):
+ def parse_types_from_source(
+ self, source, filename=None, include_dirs: Optional[List[str]] = None, auto_type_source=None
+ ):
"""
``parse_types_from_source`` parses the source string and any needed headers searching for them in
the optional list of directories provided in ``include_dirs``.
@@ -421,29 +426,30 @@ class Platform(metaclass=_PlatformMetaClass):
dir_buf[i] = include_dirs[i].encode('charmap')
parse = core.BNTypeParserResult()
errors = ctypes.c_char_p()
- result = core.BNParseTypesFromSource(self.handle, source, filename, parse, errors, dir_buf,
- len(include_dirs), auto_type_source)
+ result = core.BNParseTypesFromSource(
+ self.handle, source, filename, parse, errors, dir_buf, len(include_dirs), auto_type_source
+ )
assert errors.value is not None, "core.BNParseTypesFromSource returned errors set to None"
error_str = errors.value.decode("utf-8")
core.free_string(errors)
if not result:
raise SyntaxError(error_str)
- type_dict:Dict[types.QualifiedName, types.Type] = {}
- variables:Dict[types.QualifiedName, types.Type] = {}
- functions:Dict[types.QualifiedName, types.Type] = {}
+ type_dict: Dict[types.QualifiedName, types.Type] = {}
+ variables: Dict[types.QualifiedName, types.Type] = {}
+ functions: Dict[types.QualifiedName, types.Type] = {}
for i in range(0, parse.typeCount):
name = types.QualifiedName._from_core_struct(parse.types[i].name)
- type_dict[name] = types.Type.create(core.BNNewTypeReference(parse.types[i].type), platform = self)
+ type_dict[name] = types.Type.create(core.BNNewTypeReference(parse.types[i].type), platform=self)
for i in range(0, parse.variableCount):
name = types.QualifiedName._from_core_struct(parse.variables[i].name)
- variables[name] = types.Type.create(core.BNNewTypeReference(parse.variables[i].type), platform = self)
+ variables[name] = types.Type.create(core.BNNewTypeReference(parse.variables[i].type), platform=self)
for i in range(0, parse.functionCount):
name = types.QualifiedName._from_core_struct(parse.functions[i].name)
- functions[name] = types.Type.create(core.BNNewTypeReference(parse.functions[i].type), platform = self)
+ functions[name] = types.Type.create(core.BNNewTypeReference(parse.functions[i].type), platform=self)
core.BNFreeTypeParserResult(parse)
return types.TypeParserResult(type_dict, variables, functions)
- def parse_types_from_source_file(self, filename, include_dirs:Optional[List[str]]=None, auto_type_source=None):
+ def parse_types_from_source_file(self, filename, include_dirs: Optional[List[str]] = None, auto_type_source=None):
"""
``parse_types_from_source_file`` parses the source file ``filename`` and any needed headers searching for them in
the optional list of directories provided in ``include_dirs``.
@@ -473,8 +479,9 @@ class Platform(metaclass=_PlatformMetaClass):
dir_buf[i] = include_dirs[i].encode('charmap')
parse = core.BNTypeParserResult()
errors = ctypes.c_char_p()
- result = core.BNParseTypesFromSourceFile(self.handle, filename, parse, errors, dir_buf,
- len(include_dirs), auto_type_source)
+ result = core.BNParseTypesFromSourceFile(
+ self.handle, filename, parse, errors, dir_buf, len(include_dirs), auto_type_source
+ )
assert errors.value is not None, "core.BNParseTypesFromSourceFile returned errors set to None"
error_str = errors.value.decode("utf-8")
core.free_string(errors)
@@ -485,13 +492,13 @@ class Platform(metaclass=_PlatformMetaClass):
functions = {}
for i in range(0, parse.typeCount):
name = types.QualifiedName._from_core_struct(parse.types[i].name)
- type_dict[name] = types.Type.create(core.BNNewTypeReference(parse.types[i].type), platform = self)
+ type_dict[name] = types.Type.create(core.BNNewTypeReference(parse.types[i].type), platform=self)
for i in range(0, parse.variableCount):
name = types.QualifiedName._from_core_struct(parse.variables[i].name)
- variables[name] = types.Type.create(core.BNNewTypeReference(parse.variables[i].type), platform = self)
+ variables[name] = types.Type.create(core.BNNewTypeReference(parse.variables[i].type), platform=self)
for i in range(0, parse.functionCount):
name = types.QualifiedName._from_core_struct(parse.functions[i].name)
- functions[name] = types.Type.create(core.BNNewTypeReference(parse.functions[i].type), platform = self)
+ functions[name] = types.Type.create(core.BNNewTypeReference(parse.functions[i].type), platform=self)
core.BNFreeTypeParserResult(parse)
return types.TypeParserResult(type_dict, variables, functions)
diff --git a/python/plugin.py b/python/plugin.py
index 5dbc4fa7..741fe4a1 100644
--- a/python/plugin.py
+++ b/python/plugin.py
@@ -115,8 +115,8 @@ class PluginCommand(metaclass=_PluginCommandMetaClass):
@staticmethod
def _default_action(view, action):
try:
- file_metadata = filemetadata.FileMetadata(handle = core.BNGetFileForView(view))
- view_obj = binaryview.BinaryView(file_metadata = file_metadata, handle = core.BNNewViewReference(view))
+ file_metadata = filemetadata.FileMetadata(handle=core.BNGetFileForView(view))
+ view_obj = binaryview.BinaryView(file_metadata=file_metadata, handle=core.BNNewViewReference(view))
action(view_obj)
except:
log_error(traceback.format_exc())
@@ -124,8 +124,8 @@ class PluginCommand(metaclass=_PluginCommandMetaClass):
@staticmethod
def _address_action(view, addr, action):
try:
- file_metadata = filemetadata.FileMetadata(handle = core.BNGetFileForView(view))
- view_obj = binaryview.BinaryView(file_metadata = file_metadata, handle = core.BNNewViewReference(view))
+ file_metadata = filemetadata.FileMetadata(handle=core.BNGetFileForView(view))
+ view_obj = binaryview.BinaryView(file_metadata=file_metadata, handle=core.BNNewViewReference(view))
action(view_obj, addr)
except:
log_error(traceback.format_exc())
@@ -133,8 +133,8 @@ class PluginCommand(metaclass=_PluginCommandMetaClass):
@staticmethod
def _range_action(view, addr, length, action):
try:
- file_metadata = filemetadata.FileMetadata(handle = core.BNGetFileForView(view))
- view_obj = binaryview.BinaryView(file_metadata = file_metadata, handle = core.BNNewViewReference(view))
+ file_metadata = filemetadata.FileMetadata(handle=core.BNGetFileForView(view))
+ view_obj = binaryview.BinaryView(file_metadata=file_metadata, handle=core.BNNewViewReference(view))
action(view_obj, addr, length)
except:
log_error(traceback.format_exc())
@@ -142,8 +142,8 @@ class PluginCommand(metaclass=_PluginCommandMetaClass):
@staticmethod
def _function_action(view, func, action):
try:
- file_metadata = filemetadata.FileMetadata(handle = core.BNGetFileForView(view))
- view_obj = binaryview.BinaryView(file_metadata = file_metadata, handle = core.BNNewViewReference(view))
+ file_metadata = filemetadata.FileMetadata(handle=core.BNGetFileForView(view))
+ view_obj = binaryview.BinaryView(file_metadata=file_metadata, handle=core.BNNewViewReference(view))
func_obj = function.Function(view_obj, core.BNNewFunctionReference(func))
action(view_obj, func_obj)
except:
@@ -152,8 +152,8 @@ class PluginCommand(metaclass=_PluginCommandMetaClass):
@staticmethod
def _low_level_il_function_action(view, func, action):
try:
- file_metadata = filemetadata.FileMetadata(handle = core.BNGetFileForView(view))
- view_obj = binaryview.BinaryView(file_metadata = file_metadata, handle = core.BNNewViewReference(view))
+ file_metadata = filemetadata.FileMetadata(handle=core.BNGetFileForView(view))
+ view_obj = binaryview.BinaryView(file_metadata=file_metadata, handle=core.BNNewViewReference(view))
owner = function.Function(view_obj, core.BNGetLowLevelILOwnerFunction(func))
func_obj = lowlevelil.LowLevelILFunction(owner.arch, core.BNNewLowLevelILFunctionReference(func), owner)
action(view_obj, func_obj)
@@ -163,8 +163,8 @@ class PluginCommand(metaclass=_PluginCommandMetaClass):
@staticmethod
def _low_level_il_instruction_action(view, func, instr, action):
try:
- file_metadata = filemetadata.FileMetadata(handle = core.BNGetFileForView(view))
- view_obj = binaryview.BinaryView(file_metadata = file_metadata, handle = core.BNNewViewReference(view))
+ file_metadata = filemetadata.FileMetadata(handle=core.BNGetFileForView(view))
+ view_obj = binaryview.BinaryView(file_metadata=file_metadata, handle=core.BNNewViewReference(view))
owner = function.Function(view_obj, core.BNGetLowLevelILOwnerFunction(func))
func_obj = lowlevelil.LowLevelILFunction(owner.arch, core.BNNewLowLevelILFunctionReference(func), owner)
action(view_obj, func_obj[instr])
@@ -174,10 +174,12 @@ class PluginCommand(metaclass=_PluginCommandMetaClass):
@staticmethod
def _medium_level_il_function_action(view, func, action):
try:
- file_metadata = filemetadata.FileMetadata(handle = core.BNGetFileForView(view))
- view_obj = binaryview.BinaryView(file_metadata = file_metadata, handle = core.BNNewViewReference(view))
+ file_metadata = filemetadata.FileMetadata(handle=core.BNGetFileForView(view))
+ view_obj = binaryview.BinaryView(file_metadata=file_metadata, handle=core.BNNewViewReference(view))
owner = function.Function(view_obj, core.BNGetMediumLevelILOwnerFunction(func))
- func_obj = mediumlevelil.MediumLevelILFunction(owner.arch, core.BNNewMediumLevelILFunctionReference(func), owner)
+ func_obj = mediumlevelil.MediumLevelILFunction(
+ owner.arch, core.BNNewMediumLevelILFunctionReference(func), owner
+ )
action(view_obj, func_obj)
except:
log_error(traceback.format_exc())
@@ -185,10 +187,12 @@ class PluginCommand(metaclass=_PluginCommandMetaClass):
@staticmethod
def _medium_level_il_instruction_action(view, func, instr, action):
try:
- file_metadata = filemetadata.FileMetadata(handle = core.BNGetFileForView(view))
- view_obj = binaryview.BinaryView(file_metadata = file_metadata, handle = core.BNNewViewReference(view))
+ file_metadata = filemetadata.FileMetadata(handle=core.BNGetFileForView(view))
+ view_obj = binaryview.BinaryView(file_metadata=file_metadata, handle=core.BNNewViewReference(view))
owner = function.Function(view_obj, core.BNGetMediumLevelILOwnerFunction(func))
- func_obj = mediumlevelil.MediumLevelILFunction(owner.arch, core.BNNewMediumLevelILFunctionReference(func), owner)
+ func_obj = mediumlevelil.MediumLevelILFunction(
+ owner.arch, core.BNNewMediumLevelILFunctionReference(func), owner
+ )
action(view_obj, func_obj[instr])
except:
log_error(traceback.format_exc())
@@ -196,8 +200,8 @@ class PluginCommand(metaclass=_PluginCommandMetaClass):
@staticmethod
def _high_level_il_function_action(view, func, action):
try:
- file_metadata = filemetadata.FileMetadata(handle = core.BNGetFileForView(view))
- view_obj = binaryview.BinaryView(file_metadata = file_metadata, handle = core.BNNewViewReference(view))
+ file_metadata = filemetadata.FileMetadata(handle=core.BNGetFileForView(view))
+ view_obj = binaryview.BinaryView(file_metadata=file_metadata, handle=core.BNNewViewReference(view))
owner = function.Function(view_obj, core.BNGetHighLevelILOwnerFunction(func))
func_obj = highlevelil.HighLevelILFunction(owner.arch, core.BNNewHighLevelILFunctionReference(func), owner)
action(view_obj, func_obj)
@@ -207,8 +211,8 @@ class PluginCommand(metaclass=_PluginCommandMetaClass):
@staticmethod
def _high_level_il_instruction_action(view, func, instr, action):
try:
- file_metadata = filemetadata.FileMetadata(handle = core.BNGetFileForView(view))
- view_obj = binaryview.BinaryView(file_metadata = file_metadata, handle = core.BNNewViewReference(view))
+ file_metadata = filemetadata.FileMetadata(handle=core.BNGetFileForView(view))
+ view_obj = binaryview.BinaryView(file_metadata=file_metadata, handle=core.BNNewViewReference(view))
owner = function.Function(view_obj, core.BNGetHighLevelILOwnerFunction(func))
func_obj = highlevelil.HighLevelILFunction(owner.arch, core.BNNewHighLevelILFunctionReference(func), owner)
action(view_obj, func_obj[instr])
@@ -220,8 +224,8 @@ class PluginCommand(metaclass=_PluginCommandMetaClass):
try:
if is_valid is None:
return True
- file_metadata = filemetadata.FileMetadata(handle = core.BNGetFileForView(view))
- view_obj = binaryview.BinaryView(file_metadata = file_metadata, handle = core.BNNewViewReference(view))
+ file_metadata = filemetadata.FileMetadata(handle=core.BNGetFileForView(view))
+ view_obj = binaryview.BinaryView(file_metadata=file_metadata, handle=core.BNNewViewReference(view))
return is_valid(view_obj)
except:
log_error(traceback.format_exc())
@@ -232,8 +236,8 @@ class PluginCommand(metaclass=_PluginCommandMetaClass):
try:
if is_valid is None:
return True
- file_metadata = filemetadata.FileMetadata(handle = core.BNGetFileForView(view))
- view_obj = binaryview.BinaryView(file_metadata = file_metadata, handle = core.BNNewViewReference(view))
+ file_metadata = filemetadata.FileMetadata(handle=core.BNGetFileForView(view))
+ view_obj = binaryview.BinaryView(file_metadata=file_metadata, handle=core.BNNewViewReference(view))
return is_valid(view_obj, addr)
except:
log_error(traceback.format_exc())
@@ -244,8 +248,8 @@ class PluginCommand(metaclass=_PluginCommandMetaClass):
try:
if is_valid is None:
return True
- file_metadata = filemetadata.FileMetadata(handle = core.BNGetFileForView(view))
- view_obj = binaryview.BinaryView(file_metadata = file_metadata, handle = core.BNNewViewReference(view))
+ file_metadata = filemetadata.FileMetadata(handle=core.BNGetFileForView(view))
+ view_obj = binaryview.BinaryView(file_metadata=file_metadata, handle=core.BNNewViewReference(view))
return is_valid(view_obj, addr, length)
except:
log_error(traceback.format_exc())
@@ -256,8 +260,8 @@ class PluginCommand(metaclass=_PluginCommandMetaClass):
try:
if is_valid is None:
return True
- file_metadata = filemetadata.FileMetadata(handle = core.BNGetFileForView(view))
- view_obj = binaryview.BinaryView(file_metadata = file_metadata, handle = core.BNNewViewReference(view))
+ file_metadata = filemetadata.FileMetadata(handle=core.BNGetFileForView(view))
+ view_obj = binaryview.BinaryView(file_metadata=file_metadata, handle=core.BNNewViewReference(view))
func_obj = function.Function(view_obj, core.BNNewFunctionReference(func))
return is_valid(view_obj, func_obj)
except:
@@ -269,8 +273,8 @@ class PluginCommand(metaclass=_PluginCommandMetaClass):
try:
if is_valid is None:
return True
- file_metadata = filemetadata.FileMetadata(handle = core.BNGetFileForView(view))
- view_obj = binaryview.BinaryView(file_metadata = file_metadata, handle = core.BNNewViewReference(view))
+ file_metadata = filemetadata.FileMetadata(handle=core.BNGetFileForView(view))
+ view_obj = binaryview.BinaryView(file_metadata=file_metadata, handle=core.BNNewViewReference(view))
owner = function.Function(view_obj, core.BNGetLowLevelILOwnerFunction(func))
func_obj = lowlevelil.LowLevelILFunction(owner.arch, core.BNNewLowLevelILFunctionReference(func), owner)
return is_valid(view_obj, func_obj)
@@ -283,8 +287,8 @@ class PluginCommand(metaclass=_PluginCommandMetaClass):
try:
if is_valid is None:
return True
- file_metadata = filemetadata.FileMetadata(handle = core.BNGetFileForView(view))
- view_obj = binaryview.BinaryView(file_metadata = file_metadata, handle = core.BNNewViewReference(view))
+ file_metadata = filemetadata.FileMetadata(handle=core.BNGetFileForView(view))
+ view_obj = binaryview.BinaryView(file_metadata=file_metadata, handle=core.BNNewViewReference(view))
owner = function.Function(view_obj, core.BNGetLowLevelILOwnerFunction(func))
func_obj = lowlevelil.LowLevelILFunction(owner.arch, core.BNNewLowLevelILFunctionReference(func), owner)
return is_valid(view_obj, func_obj[instr])
@@ -297,10 +301,12 @@ class PluginCommand(metaclass=_PluginCommandMetaClass):
try:
if is_valid is None:
return True
- file_metadata = filemetadata.FileMetadata(handle = core.BNGetFileForView(view))
- view_obj = binaryview.BinaryView(file_metadata = file_metadata, handle = core.BNNewViewReference(view))
+ file_metadata = filemetadata.FileMetadata(handle=core.BNGetFileForView(view))
+ view_obj = binaryview.BinaryView(file_metadata=file_metadata, handle=core.BNNewViewReference(view))
owner = function.Function(view_obj, core.BNGetMediumLevelILOwnerFunction(func))
- func_obj = mediumlevelil.MediumLevelILFunction(owner.arch, core.BNNewMediumLevelILFunctionReference(func), owner)
+ func_obj = mediumlevelil.MediumLevelILFunction(
+ owner.arch, core.BNNewMediumLevelILFunctionReference(func), owner
+ )
return is_valid(view_obj, func_obj)
except:
log_error(traceback.format_exc())
@@ -311,10 +317,12 @@ class PluginCommand(metaclass=_PluginCommandMetaClass):
try:
if is_valid is None:
return True
- file_metadata = filemetadata.FileMetadata(handle = core.BNGetFileForView(view))
- view_obj = binaryview.BinaryView(file_metadata = file_metadata, handle = core.BNNewViewReference(view))
+ file_metadata = filemetadata.FileMetadata(handle=core.BNGetFileForView(view))
+ view_obj = binaryview.BinaryView(file_metadata=file_metadata, handle=core.BNNewViewReference(view))
owner = function.Function(view_obj, core.BNGetMediumLevelILOwnerFunction(func))
- func_obj = mediumlevelil.MediumLevelILFunction(owner.arch, core.BNNewMediumLevelILFunctionReference(func), owner)
+ func_obj = mediumlevelil.MediumLevelILFunction(
+ owner.arch, core.BNNewMediumLevelILFunctionReference(func), owner
+ )
return is_valid(view_obj, func_obj[instr])
except:
log_error(traceback.format_exc())
@@ -325,8 +333,8 @@ class PluginCommand(metaclass=_PluginCommandMetaClass):
try:
if is_valid is None:
return True
- file_metadata = filemetadata.FileMetadata(handle = core.BNGetFileForView(view))
- view_obj = binaryview.BinaryView(file_metadata = file_metadata, handle = core.BNNewViewReference(view))
+ file_metadata = filemetadata.FileMetadata(handle=core.BNGetFileForView(view))
+ view_obj = binaryview.BinaryView(file_metadata=file_metadata, handle=core.BNNewViewReference(view))
owner = function.Function(view_obj, core.BNGetHighLevelILOwnerFunction(func))
func_obj = highlevelil.HighLevelILFunction(owner.arch, core.BNNewHighLevelILFunctionReference(func), owner)
return is_valid(view_obj, func_obj)
@@ -339,8 +347,8 @@ class PluginCommand(metaclass=_PluginCommandMetaClass):
try:
if is_valid is None:
return True
- file_metadata = filemetadata.FileMetadata(handle = core.BNGetFileForView(view))
- view_obj = binaryview.BinaryView(file_metadata = file_metadata, handle = core.BNNewViewReference(view))
+ file_metadata = filemetadata.FileMetadata(handle=core.BNGetFileForView(view))
+ view_obj = binaryview.BinaryView(file_metadata=file_metadata, handle=core.BNNewViewReference(view))
owner = function.Function(view_obj, core.BNGetHighLevelILOwnerFunction(func))
func_obj = highlevelil.HighLevelILFunction(owner.arch, core.BNNewHighLevelILFunctionReference(func), owner)
return is_valid(view_obj, func_obj[instr])
@@ -349,11 +357,9 @@ class PluginCommand(metaclass=_PluginCommandMetaClass):
return False
@classmethod
- def register(cls,
- name: str,
- description: str,
- action: Callable[[binaryview.BinaryView], None],
- is_valid: Optional[Callable[[binaryview.BinaryView], bool]] = None
+ def register(
+ cls, name: str, description: str, action: Callable[[binaryview.BinaryView], None],
+ is_valid: Optional[Callable[[binaryview.BinaryView], bool]] = None
):
r"""
``register`` Register a plugin
@@ -367,17 +373,19 @@ class PluginCommand(metaclass=_PluginCommandMetaClass):
.. warning:: Calling ``register`` with the same function name will replace the existing function but will leak the memory of the original plugin.
"""
binaryninja._init_plugins()
- action_obj = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView))(lambda ctxt, view: cls._default_action(view, action))
- is_valid_obj = ctypes.CFUNCTYPE(ctypes.c_bool, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView))(lambda ctxt, view: cls._default_is_valid(view, is_valid))
+ action_obj = ctypes.CFUNCTYPE(None, ctypes.c_void_p,
+ ctypes.POINTER(core.BNBinaryView
+ ))(lambda ctxt, view: cls._default_action(view, action))
+ is_valid_obj = ctypes.CFUNCTYPE(ctypes.c_bool, ctypes.c_void_p,
+ ctypes.POINTER(core.BNBinaryView
+ ))(lambda ctxt, view: cls._default_is_valid(view, is_valid))
cls._registered_commands.append((action_obj, is_valid_obj))
core.BNRegisterPluginCommand(name, description, action_obj, is_valid_obj, None)
@classmethod
- def register_for_address(cls,
- name: str,
- description: str,
- action: Callable[[binaryview.BinaryView, int], None],
- is_valid: Optional[Callable[[binaryview.BinaryView, int], bool]] = None
+ def register_for_address(
+ cls, name: str, description: str, action: Callable[[binaryview.BinaryView, int], None],
+ is_valid: Optional[Callable[[binaryview.BinaryView, int], bool]] = None
):
r"""
``register_for_address`` Register a plugin to be called with an address argument
@@ -391,17 +399,19 @@ class PluginCommand(metaclass=_PluginCommandMetaClass):
.. warning:: Calling ``register_for_address`` with the same function name will replace the existing function but will leak the memory of the original plugin.
"""
binaryninja._init_plugins()
- action_obj = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView), ctypes.c_ulonglong)(lambda ctxt, view, addr: cls._address_action(view, addr, action))
- is_valid_obj = ctypes.CFUNCTYPE(ctypes.c_bool, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView), ctypes.c_ulonglong)(lambda ctxt, view, addr: cls._address_is_valid(view, addr, is_valid))
+ action_obj = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.POINTER(
+ core.BNBinaryView
+ ), ctypes.c_ulonglong)(lambda ctxt, view, addr: cls._address_action(view, addr, action))
+ is_valid_obj = ctypes.CFUNCTYPE(
+ ctypes.c_bool, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView), ctypes.c_ulonglong
+ )(lambda ctxt, view, addr: cls._address_is_valid(view, addr, is_valid))
cls._registered_commands.append((action_obj, is_valid_obj))
core.BNRegisterPluginCommandForAddress(name, description, action_obj, is_valid_obj, None)
@classmethod
- def register_for_range(cls,
- name: str,
- description: str,
- action: Callable[[binaryview.BinaryView, int, int], None],
- is_valid: Optional[Callable[[binaryview.BinaryView, int, int], bool]] = None
+ def register_for_range(
+ cls, name: str, description: str, action: Callable[[binaryview.BinaryView, int, int], None],
+ is_valid: Optional[Callable[[binaryview.BinaryView, int, int], bool]] = None
):
r"""
``register_for_range`` Register a plugin to be called with a range argument
@@ -415,17 +425,19 @@ class PluginCommand(metaclass=_PluginCommandMetaClass):
.. warning:: Calling ``register_for_range`` with the same function name will replace the existing function but will leak the memory of the original plugin.
"""
binaryninja._init_plugins()
- action_obj = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView), ctypes.c_ulonglong, ctypes.c_ulonglong)(lambda ctxt, view, addr, length: cls._range_action(view, addr, length, action))
- is_valid_obj = ctypes.CFUNCTYPE(ctypes.c_bool, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView), ctypes.c_ulonglong, ctypes.c_ulonglong)(lambda ctxt, view, addr, length: cls._range_is_valid(view, addr, length, is_valid))
+ action_obj = ctypes.CFUNCTYPE(
+ None, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView), ctypes.c_ulonglong, ctypes.c_ulonglong
+ )(lambda ctxt, view, addr, length: cls._range_action(view, addr, length, action))
+ is_valid_obj = ctypes.CFUNCTYPE(
+ ctypes.c_bool, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView), ctypes.c_ulonglong, ctypes.c_ulonglong
+ )(lambda ctxt, view, addr, length: cls._range_is_valid(view, addr, length, is_valid))
cls._registered_commands.append((action_obj, is_valid_obj))
core.BNRegisterPluginCommandForRange(name, description, action_obj, is_valid_obj, None)
@classmethod
- def register_for_function(cls,
- name: str,
- description: str,
- action: Callable[[binaryview.BinaryView, function.Function], None],
- is_valid: Optional[Callable[[binaryview.BinaryView, function.Function], bool]] = None
+ def register_for_function(
+ cls, name: str, description: str, action: Callable[[binaryview.BinaryView, function.Function], None],
+ is_valid: Optional[Callable[[binaryview.BinaryView, function.Function], bool]] = None
):
r"""
``register_for_function`` Register a plugin to be called with a function argument
@@ -439,17 +451,20 @@ class PluginCommand(metaclass=_PluginCommandMetaClass):
.. warning:: Calling ``register_for_function`` with the same function name will replace the existing function but will leak the memory of the original plugin.
"""
binaryninja._init_plugins()
- action_obj = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView), ctypes.POINTER(core.BNFunction))(lambda ctxt, view, func: cls._function_action(view, func, action))
- is_valid_obj = ctypes.CFUNCTYPE(ctypes.c_bool, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView), ctypes.POINTER(core.BNFunction))(lambda ctxt, view, func: cls._function_is_valid(view, func, is_valid))
+ action_obj = ctypes.CFUNCTYPE(
+ None, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView), ctypes.POINTER(core.BNFunction)
+ )(lambda ctxt, view, func: cls._function_action(view, func, action))
+ is_valid_obj = ctypes.CFUNCTYPE(
+ ctypes.c_bool, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView), ctypes.POINTER(core.BNFunction)
+ )(lambda ctxt, view, func: cls._function_is_valid(view, func, is_valid))
cls._registered_commands.append((action_obj, is_valid_obj))
core.BNRegisterPluginCommandForFunction(name, description, action_obj, is_valid_obj, None)
@classmethod
- def register_for_low_level_il_function(cls,
- name: str,
- description: str,
- action: Callable[[binaryview.BinaryView, lowlevelil.LowLevelILFunction], None],
- is_valid: Optional[Callable[[binaryview.BinaryView, lowlevelil.LowLevelILFunction], bool]] = None
+ def register_for_low_level_il_function(
+ cls, name: str, description: str, action: Callable[[binaryview.BinaryView, lowlevelil.LowLevelILFunction],
+ None],
+ is_valid: Optional[Callable[[binaryview.BinaryView, lowlevelil.LowLevelILFunction], bool]] = None
):
r"""
``register_for_low_level_il_function`` Register a plugin to be called with a low level IL function argument
@@ -463,17 +478,21 @@ class PluginCommand(metaclass=_PluginCommandMetaClass):
.. warning:: Calling ``register_for_low_level_il_function`` with the same function name will replace the existing function but will leak the memory of the original plugin.
"""
binaryninja._init_plugins()
- action_obj = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView), ctypes.POINTER(core.BNLowLevelILFunction))(lambda ctxt, view, func: cls._low_level_il_function_action(view, func, action))
- is_valid_obj = ctypes.CFUNCTYPE(ctypes.c_bool, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView), ctypes.POINTER(core.BNLowLevelILFunction))(lambda ctxt, view, func: cls._low_level_il_function_is_valid(view, func, is_valid))
+ action_obj = ctypes.CFUNCTYPE(
+ None, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView), ctypes.POINTER(core.BNLowLevelILFunction)
+ )(lambda ctxt, view, func: cls._low_level_il_function_action(view, func, action))
+ is_valid_obj = ctypes.CFUNCTYPE(
+ ctypes.c_bool, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView),
+ ctypes.POINTER(core.BNLowLevelILFunction)
+ )(lambda ctxt, view, func: cls._low_level_il_function_is_valid(view, func, is_valid))
cls._registered_commands.append((action_obj, is_valid_obj))
core.BNRegisterPluginCommandForLowLevelILFunction(name, description, action_obj, is_valid_obj, None)
@classmethod
- def register_for_low_level_il_instruction(cls,
- name: str,
- description: str,
- action: Callable[[binaryview.BinaryView, lowlevelil.LowLevelILInstruction], None],
- is_valid: Optional[Callable[[binaryview.BinaryView, lowlevelil.LowLevelILInstruction], bool]] = None
+ def register_for_low_level_il_instruction(
+ cls, name: str, description: str, action: Callable[[binaryview.BinaryView, lowlevelil.LowLevelILInstruction],
+ None],
+ is_valid: Optional[Callable[[binaryview.BinaryView, lowlevelil.LowLevelILInstruction], bool]] = None
):
r"""
``register_for_low_level_il_instruction`` Register a plugin to be called with a low level IL instruction argument
@@ -487,17 +506,22 @@ class PluginCommand(metaclass=_PluginCommandMetaClass):
.. warning:: Calling ``register_for_low_level_il_instruction`` with the same function name will replace the existing function but will leak the memory of the original plugin.
"""
binaryninja._init_plugins()
- action_obj = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView), ctypes.POINTER(core.BNLowLevelILFunction), ctypes.c_ulonglong)(lambda ctxt, view, func, instr: cls._low_level_il_instruction_action(view, func, instr, action))
- is_valid_obj = ctypes.CFUNCTYPE(ctypes.c_bool, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView), ctypes.POINTER(core.BNLowLevelILFunction), ctypes.c_ulonglong)(lambda ctxt, view, func, instr: cls._low_level_il_instruction_is_valid(view, func, instr, is_valid))
+ action_obj = ctypes.CFUNCTYPE(
+ None, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView), ctypes.POINTER(core.BNLowLevelILFunction),
+ ctypes.c_ulonglong
+ )(lambda ctxt, view, func, instr: cls._low_level_il_instruction_action(view, func, instr, action))
+ is_valid_obj = ctypes.CFUNCTYPE(
+ ctypes.c_bool, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView),
+ ctypes.POINTER(core.BNLowLevelILFunction), ctypes.c_ulonglong
+ )(lambda ctxt, view, func, instr: cls._low_level_il_instruction_is_valid(view, func, instr, is_valid))
cls._registered_commands.append((action_obj, is_valid_obj))
core.BNRegisterPluginCommandForLowLevelILInstruction(name, description, action_obj, is_valid_obj, None)
@classmethod
- def register_for_medium_level_il_function(cls,
- name: str,
- description: str,
- action: Callable[[binaryview.BinaryView, mediumlevelil.MediumLevelILFunction], None],
- is_valid: Optional[Callable[[binaryview.BinaryView, mediumlevelil.MediumLevelILFunction], bool]] = None
+ def register_for_medium_level_il_function(
+ cls, name: str, description: str, action: Callable[[binaryview.BinaryView, mediumlevelil.MediumLevelILFunction],
+ None],
+ is_valid: Optional[Callable[[binaryview.BinaryView, mediumlevelil.MediumLevelILFunction], bool]] = None
):
r"""
``register_for_medium_level_il_function`` Register a plugin to be called with a medium level IL function argument
@@ -511,17 +535,21 @@ class PluginCommand(metaclass=_PluginCommandMetaClass):
.. warning:: Calling ``register_for_medium_level_il_function`` with the same function name will replace the existing function but will leak the memory of the original plugin.
"""
binaryninja._init_plugins()
- action_obj = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView), ctypes.POINTER(core.BNMediumLevelILFunction))(lambda ctxt, view, func: cls._medium_level_il_function_action(view, func, action))
- is_valid_obj = ctypes.CFUNCTYPE(ctypes.c_bool, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView), ctypes.POINTER(core.BNMediumLevelILFunction))(lambda ctxt, view, func: cls._medium_level_il_function_is_valid(view, func, is_valid))
+ action_obj = ctypes.CFUNCTYPE(
+ None, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView), ctypes.POINTER(core.BNMediumLevelILFunction)
+ )(lambda ctxt, view, func: cls._medium_level_il_function_action(view, func, action))
+ is_valid_obj = ctypes.CFUNCTYPE(
+ ctypes.c_bool, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView),
+ ctypes.POINTER(core.BNMediumLevelILFunction)
+ )(lambda ctxt, view, func: cls._medium_level_il_function_is_valid(view, func, is_valid))
cls._registered_commands.append((action_obj, is_valid_obj))
core.BNRegisterPluginCommandForMediumLevelILFunction(name, description, action_obj, is_valid_obj, None)
@classmethod
- def register_for_medium_level_il_instruction(cls,
- name: str,
- description: str,
- action: Callable[[binaryview.BinaryView, mediumlevelil.MediumLevelILInstruction], None],
- is_valid: Optional[Callable[[binaryview.BinaryView, mediumlevelil.MediumLevelILInstruction], bool]] = None
+ def register_for_medium_level_il_instruction(
+ cls, name: str, description: str,
+ action: Callable[[binaryview.BinaryView, mediumlevelil.MediumLevelILInstruction], None],
+ is_valid: Optional[Callable[[binaryview.BinaryView, mediumlevelil.MediumLevelILInstruction], bool]] = None
):
r"""
``register_for_medium_level_il_instruction`` Register a plugin to be called with a medium level IL instruction argument
@@ -535,17 +563,22 @@ class PluginCommand(metaclass=_PluginCommandMetaClass):
.. warning:: Calling ``register_for_medium_level_il_instruction`` with the same function name will replace the existing function but will leak the memory of the original plugin.
"""
binaryninja._init_plugins()
- action_obj = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView), ctypes.POINTER(core.BNMediumLevelILFunction), ctypes.c_ulonglong)(lambda ctxt, view, func, instr: cls._medium_level_il_instruction_action(view, func, instr, action))
- is_valid_obj = ctypes.CFUNCTYPE(ctypes.c_bool, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView), ctypes.POINTER(core.BNMediumLevelILFunction), ctypes.c_ulonglong)(lambda ctxt, view, func, instr: cls._medium_level_il_instruction_is_valid(view, func, instr, is_valid))
+ action_obj = ctypes.CFUNCTYPE(
+ None, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView), ctypes.POINTER(core.BNMediumLevelILFunction),
+ ctypes.c_ulonglong
+ )(lambda ctxt, view, func, instr: cls._medium_level_il_instruction_action(view, func, instr, action))
+ is_valid_obj = ctypes.CFUNCTYPE(
+ ctypes.c_bool, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView),
+ ctypes.POINTER(core.BNMediumLevelILFunction), ctypes.c_ulonglong
+ )(lambda ctxt, view, func, instr: cls._medium_level_il_instruction_is_valid(view, func, instr, is_valid))
cls._registered_commands.append((action_obj, is_valid_obj))
core.BNRegisterPluginCommandForMediumLevelILInstruction(name, description, action_obj, is_valid_obj, None)
@classmethod
- def register_for_high_level_il_function(cls,
- name: str,
- description: str,
- action: Callable[[binaryview.BinaryView, highlevelil.HighLevelILFunction], None],
- is_valid: Optional[Callable[[binaryview.BinaryView, highlevelil.HighLevelILFunction], bool]] = None
+ def register_for_high_level_il_function(
+ cls, name: str, description: str, action: Callable[[binaryview.BinaryView, highlevelil.HighLevelILFunction],
+ None],
+ is_valid: Optional[Callable[[binaryview.BinaryView, highlevelil.HighLevelILFunction], bool]] = None
):
r"""
``register_for_high_level_il_function`` Register a plugin to be called with a high level IL function argument
@@ -559,17 +592,21 @@ class PluginCommand(metaclass=_PluginCommandMetaClass):
.. warning:: Calling ``register_for_high_level_il_function`` with the same function name will replace the existing function but will leak the memory of the original plugin.
"""
binaryninja._init_plugins()
- action_obj = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView), ctypes.POINTER(core.BNHighLevelILFunction))(lambda ctxt, view, func: cls._high_level_il_function_action(view, func, action))
- is_valid_obj = ctypes.CFUNCTYPE(ctypes.c_bool, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView), ctypes.POINTER(core.BNHighLevelILFunction))(lambda ctxt, view, func: cls._high_level_il_function_is_valid(view, func, is_valid))
+ action_obj = ctypes.CFUNCTYPE(
+ None, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView), ctypes.POINTER(core.BNHighLevelILFunction)
+ )(lambda ctxt, view, func: cls._high_level_il_function_action(view, func, action))
+ is_valid_obj = ctypes.CFUNCTYPE(
+ ctypes.c_bool, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView),
+ ctypes.POINTER(core.BNHighLevelILFunction)
+ )(lambda ctxt, view, func: cls._high_level_il_function_is_valid(view, func, is_valid))
cls._registered_commands.append((action_obj, is_valid_obj))
core.BNRegisterPluginCommandForHighLevelILFunction(name, description, action_obj, is_valid_obj, None)
@classmethod
- def register_for_high_level_il_instruction(cls,
- name: str,
- description: str,
- action: Callable[[binaryview.BinaryView, highlevelil.HighLevelILInstruction], None],
- is_valid: Optional[Callable[[binaryview.BinaryView, highlevelil.HighLevelILInstruction], bool]] = None
+ def register_for_high_level_il_instruction(
+ cls, name: str, description: str, action: Callable[[binaryview.BinaryView, highlevelil.HighLevelILInstruction],
+ None],
+ is_valid: Optional[Callable[[binaryview.BinaryView, highlevelil.HighLevelILInstruction], bool]] = None
):
r"""
``register_for_high_level_il_instruction`` Register a plugin to be called with a high level IL instruction argument
@@ -583,8 +620,14 @@ class PluginCommand(metaclass=_PluginCommandMetaClass):
.. warning:: Calling ``register_for_high_level_il_instruction`` with the same function name will replace the existing function but will leak the memory of the original plugin.
"""
binaryninja._init_plugins()
- action_obj = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView), ctypes.POINTER(core.BNHighLevelILFunction), ctypes.c_ulonglong)(lambda ctxt, view, func, instr: cls._high_level_il_instruction_action(view, func, instr, action))
- is_valid_obj = ctypes.CFUNCTYPE(ctypes.c_bool, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView), ctypes.POINTER(core.BNHighLevelILFunction), ctypes.c_ulonglong)(lambda ctxt, view, func, instr: cls._high_level_il_instruction_is_valid(view, func, instr, is_valid))
+ action_obj = ctypes.CFUNCTYPE(
+ None, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView), ctypes.POINTER(core.BNHighLevelILFunction),
+ ctypes.c_ulonglong
+ )(lambda ctxt, view, func, instr: cls._high_level_il_instruction_action(view, func, instr, action))
+ is_valid_obj = ctypes.CFUNCTYPE(
+ ctypes.c_bool, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView),
+ ctypes.POINTER(core.BNHighLevelILFunction), ctypes.c_ulonglong
+ )(lambda ctxt, view, func, instr: cls._high_level_il_instruction_is_valid(view, func, instr, is_valid))
cls._registered_commands.append((action_obj, is_valid_obj))
core.BNRegisterPluginCommandForHighLevelILInstruction(name, description, action_obj, is_valid_obj, None)
@@ -614,7 +657,9 @@ class PluginCommand(metaclass=_PluginCommandMetaClass):
return False
if not self._command.rangeIsValid:
return True
- return self._command.rangeIsValid(self._command.context, context.view.handle, context.address, context.length)
+ return self._command.rangeIsValid(
+ self._command.context, context.view.handle, context.address, context.length
+ )
elif self._command.type == PluginCommandType.FunctionPluginCommand:
if context.function is None:
return False
@@ -626,7 +671,9 @@ class PluginCommand(metaclass=_PluginCommandMetaClass):
return False
if not self._command.lowLevelILFunctionIsValid:
return True
- return self._command.lowLevelILFunctionIsValid(self._command.context, context.view.handle, context.function.handle)
+ return self._command.lowLevelILFunctionIsValid(
+ self._command.context, context.view.handle, context.function.handle
+ )
elif self._command.type == PluginCommandType.LowLevelILInstructionPluginCommand:
if context.instruction is None:
return False
@@ -634,14 +681,18 @@ class PluginCommand(metaclass=_PluginCommandMetaClass):
return False
if not self._command.lowLevelILInstructionIsValid:
return True
- return self._command.lowLevelILInstructionIsValid(self._command.context, context.view.handle,
- context.instruction.function.handle, context.instruction.instr_index)
+ return self._command.lowLevelILInstructionIsValid(
+ self._command.context, context.view.handle, context.instruction.function.handle,
+ context.instruction.instr_index
+ )
elif self._command.type == PluginCommandType.MediumLevelILFunctionPluginCommand:
if context.function is None:
return False
if not self._command.mediumLevelILFunctionIsValid:
return True
- return self._command.mediumLevelILFunctionIsValid(self._command.context, context.view.handle, context.function.handle)
+ return self._command.mediumLevelILFunctionIsValid(
+ self._command.context, context.view.handle, context.function.handle
+ )
elif self._command.type == PluginCommandType.MediumLevelILInstructionPluginCommand:
if context.instruction is None:
return False
@@ -649,14 +700,18 @@ class PluginCommand(metaclass=_PluginCommandMetaClass):
return False
if not self._command.mediumLevelILInstructionIsValid:
return True
- return self._command.mediumLevelILInstructionIsValid(self._command.context, context.view.handle,
- context.instruction.function.handle, context.instruction.instr_index)
+ return self._command.mediumLevelILInstructionIsValid(
+ self._command.context, context.view.handle, context.instruction.function.handle,
+ context.instruction.instr_index
+ )
elif self._command.type == PluginCommandType.HighLevelILFunctionPluginCommand:
if context.function is None:
return False
if not self._command.highLevelILFunctionIsValid:
return True
- return self._command.highLevelILFunctionIsValid(self._command.context, context.view.handle, context.function.handle)
+ return self._command.highLevelILFunctionIsValid(
+ self._command.context, context.view.handle, context.function.handle
+ )
elif self._command.type == PluginCommandType.HighLevelILInstructionPluginCommand:
if context.instruction is None:
return False
@@ -664,8 +719,10 @@ class PluginCommand(metaclass=_PluginCommandMetaClass):
return False
if not self._command.highLevelILInstructionIsValid:
return True
- return self._command.highLevelILInstructionIsValid(self._command.context, context.view.handle,
- context.instruction.function.handle, context.instruction.instr_index)
+ return self._command.highLevelILInstructionIsValid(
+ self._command.context, context.view.handle, context.instruction.function.handle,
+ context.instruction.instr_index
+ )
return False
def execute(self, context):
@@ -692,18 +749,28 @@ class PluginCommand(metaclass=_PluginCommandMetaClass):
elif self._command.type == PluginCommandType.LowLevelILFunctionPluginCommand:
self._command.lowLevelILFunctionCommand(self._command.context, context.view.handle, context.function.handle)
elif self._command.type == PluginCommandType.LowLevelILInstructionPluginCommand:
- self._command.lowLevelILInstructionCommand(self._command.context, context.view.handle,
- context.instruction.function.handle, context.instruction.instr_index)
+ self._command.lowLevelILInstructionCommand(
+ self._command.context, context.view.handle, context.instruction.function.handle,
+ context.instruction.instr_index
+ )
elif self._command.type == PluginCommandType.MediumLevelILFunctionPluginCommand:
- self._command.mediumLevelILFunctionCommand(self._command.context, context.view.handle, context.function.handle)
+ self._command.mediumLevelILFunctionCommand(
+ self._command.context, context.view.handle, context.function.handle
+ )
elif self._command.type == PluginCommandType.MediumLevelILInstructionPluginCommand:
- self._command.mediumLevelILInstructionCommand(self._command.context, context.view.handle,
- context.instruction.function.handle, context.instruction.instr_index)
+ self._command.mediumLevelILInstructionCommand(
+ self._command.context, context.view.handle, context.instruction.function.handle,
+ context.instruction.instr_index
+ )
elif self._command.type == PluginCommandType.HighLevelILFunctionPluginCommand:
- self._command.highLevelILFunctionCommand(self._command.context, context.view.handle, context.function.handle)
+ self._command.highLevelILFunctionCommand(
+ self._command.context, context.view.handle, context.function.handle
+ )
elif self._command.type == PluginCommandType.HighLevelILInstructionPluginCommand:
- self._command.highLevelILInstructionCommand(self._command.context, context.view.handle,
- context.instruction.function.handle, context.instruction.instr_index)
+ self._command.highLevelILInstructionCommand(
+ self._command.context, context.view.handle, context.instruction.function.handle,
+ context.instruction.instr_index
+ )
def __repr__(self):
return "<PluginCommand: %s>" % self._name
@@ -796,7 +863,7 @@ class _BackgroundTaskMetaclass(type):
class BackgroundTask(metaclass=_BackgroundTaskMetaclass):
- def __init__(self, initial_progress_text = "", can_cancel = False, handle = None):
+ def __init__(self, initial_progress_text="", can_cancel=False, handle=None):
if handle is None:
self.handle = core.BNBeginBackgroundTask(initial_progress_text, can_cancel)
else:
@@ -848,9 +915,9 @@ class BackgroundTask(metaclass=_BackgroundTaskMetaclass):
class BackgroundTaskThread(BackgroundTask):
- def __init__(self, initial_progress_text:str="", can_cancel:bool=False):
+ def __init__(self, initial_progress_text: str = "", can_cancel: bool = False):
class _Thread(threading.Thread):
- def __init__(self, task:'BackgroundTaskThread'):
+ def __init__(self, task: 'BackgroundTaskThread'):
threading.Thread.__init__(self)
self.task = task
diff --git a/python/pluginmanager.py b/python/pluginmanager.py
index 1b5e1b72..dfa64222 100644
--- a/python/pluginmanager.py
+++ b/python/pluginmanager.py
@@ -41,7 +41,9 @@ class RepoPlugin:
core.BNFreePlugin(self.handle)
def __repr__(self):
- return "<{} {}/{}>".format(self.path, "installed" if self.installed else "not-installed", "enabled" if self.enabled else "disabled")
+ return "<{} {}/{}>".format(
+ self.path, "installed" if self.installed else "not-installed", "enabled" if self.enabled else "disabled"
+ )
@property
def path(self):
@@ -183,7 +185,6 @@ class RepoPlugin:
"""String version of the plugin"""
return core.BNPluginGetVersion(self.handle)
-
def install_instructions(self, platform):
"""
Installation instructions for the given platform
@@ -256,6 +257,7 @@ class RepoPlugin:
"""Returns a datetime object representing the plugins last update"""
return datetime.fromtimestamp(core.BNPluginGetLastUpdate(self.handle))
+
class Repository:
"""
``Repository`` is a read-only class. Use RepositoryManager to Enable/Disable/Install/Uninstall plugins.
@@ -349,7 +351,6 @@ class RepositoryManager:
binaryninja._init_plugins()
return Repository(core.BNNewRepositoryReference(core.BNRepositoryManagerGetDefaultRepository(self.handle)))
-
def add_repository(self, url=None, repopath=None):
"""
``add_repository`` adds a new plugin repository for the manager to track.
diff --git a/python/scriptingprovider.py b/python/scriptingprovider.py
index 092afdb0..67781451 100644
--- a/python/scriptingprovider.py
+++ b/python/scriptingprovider.py
@@ -18,7 +18,6 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
-
import code
import traceback
import ctypes
@@ -112,7 +111,7 @@ class ScriptingOutputListener:
class ScriptingInstance:
_registered_instances = []
- def __init__(self, provider, handle = None):
+ def __init__(self, provider, handle=None):
if handle is None:
self._cb = core.BNScriptingInstanceCallbacks()
self._cb.context = 0
@@ -167,7 +166,7 @@ class ScriptingInstance:
def _set_current_binary_view(self, ctxt, view):
try:
if view:
- view = binaryview.BinaryView(handle = core.BNNewViewReference(view))
+ view = binaryview.BinaryView(handle=core.BNNewViewReference(view))
else:
view = None
self.perform_set_current_binary_view(view)
@@ -177,7 +176,7 @@ class ScriptingInstance:
def _set_current_function(self, ctxt, func):
try:
if func:
- func = function.Function(handle = core.BNNewFunctionReference(func))
+ func = function.Function(handle=core.BNNewFunctionReference(func))
else:
func = None
self.perform_set_current_function(func)
@@ -193,8 +192,9 @@ class ScriptingInstance:
else:
core_block = core.BNNewBasicBlockReference(block)
assert core_block is not None, "core.BNNewBasicBlockReference returned None"
- block = basicblock.BasicBlock(core_block,
- binaryview.BinaryView(handle = core.BNGetFunctionData(func)))
+ block = basicblock.BasicBlock(
+ core_block, binaryview.BinaryView(handle=core.BNGetFunctionData(func))
+ )
core.BNFreeFunction(func)
else:
block = None
@@ -218,7 +218,9 @@ class ScriptingInstance:
try:
if not isinstance(text, str):
text = text.decode("charmap")
- return ctypes.cast(self.perform_complete_input(text, state).encode("utf-8"), ctypes.c_void_p).value # type: ignore
+ return ctypes.cast(
+ self.perform_complete_input(text, state).encode("utf-8"), ctypes.c_void_p
+ ).value # type: ignore
except:
log_error(traceback.format_exc())
return "".encode("utf-8")
@@ -258,7 +260,7 @@ class ScriptingInstance:
return NotImplemented
@abc.abstractmethod
- def perform_complete_input(self, text:str, state) -> str:
+ def perform_complete_input(self, text: str, state) -> str:
return NotImplemented
@abc.abstractmethod
@@ -356,7 +358,7 @@ class ScriptingProvider(metaclass=_ScriptingProviderMetaclass):
apiName = ''
instance_class: Optional['ScriptingInstance'] = None
- def __init__(self, handle = None):
+ def __init__(self, handle=None):
if handle is not None:
self.handle = core.handle_of_type(handle, core.BNScriptingProvider)
self.__dict__["name"] = core.BNGetScriptingProviderName(handle)
@@ -388,15 +390,15 @@ class ScriptingProvider(metaclass=_ScriptingProviderMetaclass):
result = core.BNCreateScriptingProviderInstance(self.handle)
if result is None:
return None
- return ScriptingInstance(self, handle = result)
+ return ScriptingInstance(self, handle=result)
- def _load_module(self, ctx, repo_path:bytes, plugin_path:bytes, force:bool) -> bool:
+ def _load_module(self, ctx, repo_path: bytes, plugin_path: bytes, force: bool) -> bool:
return False
- def _install_modules(self, ctx, modules:bytes) -> bool:
+ def _install_modules(self, ctx, modules: bytes) -> bool:
return False
- def _module_installed(self, ctx, module:str) -> bool:
+ def _module_installed(self, ctx, module: str) -> bool:
return False
@@ -522,7 +524,6 @@ class _PythonScriptingInstanceInput:
class BlacklistedDict(dict):
-
def __init__(self, blacklist, *args):
super(BlacklistedDict, self).__init__(*args)
self.__blacklist = set(blacklist)
@@ -530,7 +531,10 @@ class BlacklistedDict(dict):
def __setitem__(self, k, v):
if self.blacklist_enabled and k in self.__blacklist:
- log_error('Setting variable "{}" will have no affect as it is automatically controlled by the ScriptingProvider.'.format(k))
+ log_error(
+ 'Setting variable "{}" will have no affect as it is automatically controlled by the ScriptingProvider.'.
+ format(k)
+ )
super(BlacklistedDict, self).__setitem__(k, v)
def enable_blacklist(self, enabled):
@@ -579,8 +583,13 @@ class PythonScriptingInstance(ScriptingInstance):
super(PythonScriptingInstance.InterpreterThread, self).__init__()
self.instance = instance
# Note: "current_address" and "here" are interactive auto-variables (i.e. can be set by user and programmatically)
- blacklisted_vars = {"current_view", "bv", "current_function", "current_basic_block", "current_selection", "current_llil", "current_mlil", "current_hlil"}
- self.locals = BlacklistedDict(blacklisted_vars, {"__name__": "__console__", "__doc__": None, "binaryninja": sys.modules[__name__]})
+ blacklisted_vars = {
+ "current_view", "bv", "current_function", "current_basic_block", "current_selection", "current_llil",
+ "current_mlil", "current_hlil"
+ }
+ self.locals = BlacklistedDict(
+ blacklisted_vars, {"__name__": "__console__", "__doc__": None, "binaryninja": sys.modules[__name__]}
+ )
self.interpreter = code.InteractiveConsole(self.locals)
self.event = threading.Event()
self.daemon = True
@@ -608,14 +617,16 @@ class PythonScriptingInstance(ScriptingInstance):
self.code = None
self.input = ""
- self.completer = bncompleter.Completer(namespace = self.locals)
+ self.completer = bncompleter.Completer(namespace=self.locals)
startup_file = os.path.join(binaryninja.user_directory(), "startup.py")
if not os.path.isfile(startup_file):
with open(startup_file, 'w') as f:
- f.write("""# Commands in this file will be run in the interactive python console on startup
+ f.write(
+ """# Commands in this file will be run in the interactive python console on startup
from binaryninja import *
-""")
+"""
+ )
with open(startup_file, 'r') as f:
self.interpreter.runsource(f.read(), filename="startup.py", symbol="exec")
@@ -676,17 +687,28 @@ from binaryninja import *
tryNavigate = True
if isinstance(self.locals["here"], str) or isinstance(self.locals["current_address"], str):
try:
- self.locals["here"] = self.active_view.parse_expression(self.locals["here"], self.active_addr)
+ self.locals["here"] = self.active_view.parse_expression(
+ self.locals["here"], self.active_addr
+ )
except ValueError as e:
sys.stderr.write(str(e))
tryNavigate = False
if tryNavigate:
if self.locals["here"] != self.active_addr:
- if not self.active_view.file.navigate(self.active_view.file.view, self.locals["here"]):
- sys.stderr.write("Address 0x%x is not valid for the current view\n" % self.locals["here"])
+ if not self.active_view.file.navigate(
+ self.active_view.file.view, self.locals["here"]
+ ):
+ sys.stderr.write(
+ "Address 0x%x is not valid for the current view\n" % self.locals["here"]
+ )
elif self.locals["current_address"] != self.active_addr:
- if not self.active_view.file.navigate(self.active_view.file.view, self.locals["current_address"]):
- sys.stderr.write("Address 0x%x is not valid for the current view\n" % self.locals["current_address"])
+ if not self.active_view.file.navigate(
+ self.active_view.file.view, self.locals["current_address"]
+ ):
+ sys.stderr.write(
+ "Address 0x%x is not valid for the current view\n"
+ % self.locals["current_address"]
+ )
if self.active_view is not None:
self.active_view.update_analysis()
except:
@@ -722,7 +744,6 @@ from binaryninja import *
self.locals["current_hlil"] = self.active_func.hlil
self.locals.blacklist_enabled = True
-
def get_selected_data(self):
if self.active_view is None:
return None
@@ -782,7 +803,9 @@ from binaryninja import *
def perform_cancel_script_input(self):
for tid, tobj in threading._active.items(): # type: ignore
if tobj is self.interpreter:
- if ctypes.pythonapi.PyThreadState_SetAsyncExc(ctypes.c_long(tid), ctypes.py_object(KeyboardInterrupt)) != 1:
+ if ctypes.pythonapi.PyThreadState_SetAsyncExc(
+ ctypes.c_long(tid), ctypes.py_object(KeyboardInterrupt)
+ ) != 1:
ctypes.pythonapi.PyThreadState_SetAsyncExc(ctypes.c_long(tid), None)
break
@@ -818,8 +841,8 @@ from binaryninja import *
class PythonScriptingProvider(ScriptingProvider):
name = "Python"
- apiName = f"python{sys.version_info.major}" # Used for plugin compatibility testing
- instance_class:TypeHintType[PythonScriptingInstance] = PythonScriptingInstance
+ apiName = f"python{sys.version_info.major}" # Used for plugin compatibility testing
+ instance_class: TypeHintType[PythonScriptingInstance] = PythonScriptingInstance
@property
def _python_bin(self) -> Optional[str]:
@@ -828,7 +851,7 @@ class PythonScriptingProvider(ScriptingProvider):
python_bin, status = self._get_executable_for_libpython(python_lib, python_bin_override)
return python_bin
- def _load_module(self, ctx, _repo_path:bytes, _module:bytes, force:bool):
+ def _load_module(self, ctx, _repo_path: bytes, _module: bytes, force: bool):
repo_path = _repo_path.decode("utf-8")
module = _module.decode("utf-8")
try:
@@ -839,8 +862,9 @@ class PythonScriptingProvider(ScriptingProvider):
raise ValueError(f"Plugin API name is not {self.name}")
if not force and core.core_platform not in plugin.install_platforms:
- raise ValueError(f"Current platform {core.core_platform} isn't in list of "\
- f"valid platforms for this plugin {plugin.install_platforms}")
+ raise ValueError(
+ f"Current platform {core.core_platform} isn't in list of valid platforms for this plugin {plugin.install_platforms}"
+ )
if not plugin.installed:
plugin.installed = True
@@ -872,10 +896,10 @@ class PythonScriptingProvider(ScriptingProvider):
except subprocess.SubprocessError as se:
return (False, str(se))
- def _pip_exists(self, python_bin:str) -> bool:
+ def _pip_exists(self, python_bin: str) -> bool:
return self._run_args([python_bin, "-m", "pip", "--version"])[0]
- def _satisfied_dependencies(self, python_bin:str) -> Generator[str, None, None]:
+ def _satisfied_dependencies(self, python_bin: str) -> Generator[str, None, None]:
if python_bin is None:
return None
success, result = self._run_args([python_bin, "-m", "pip", "freeze"])
@@ -885,44 +909,56 @@ class PythonScriptingProvider(ScriptingProvider):
yield line.split("==", 2)[0]
def _bin_version(self, python_bin: str):
- return self._run_args([str(python_bin), "-c", "import sys; sys.stdout.write(f'{sys.version_info.major}.{sys.version_info.minor}')"])[1]
+ return self._run_args([
+ str(python_bin), "-c", "import sys; sys.stdout.write(f'{sys.version_info.major}.{sys.version_info.minor}')"
+ ])[1]
def _get_executable_for_libpython(self, python_lib: str, python_bin: str) -> Tuple[Optional[str], str]:
python_lib_version = f"{sys.version_info.major}.{sys.version_info.minor}"
if python_bin is not None and python_bin != "":
python_bin_version = self._bin_version(python_bin)
if python_lib_version != python_bin_version:
- return (None, f"Specified Python Binary Override is the wrong version. Expected: {python_lib_version} got: {python_bin_version}")
+ return (
+ None,
+ f"Specified Python Binary Override is the wrong version. Expected: {python_lib_version} got: {python_bin_version}"
+ )
return (python_bin, "Success")
using_bundled_python = not python_lib
if sys.platform == "darwin":
if using_bundled_python:
- return (None, "Failed: Bundled python doesn't support dependency installation. Specify a full python installation in your 'Python Interpreter' and try again")
+ return (
+ None,
+ "Failed: Bundled python doesn't support dependency installation. Specify a full python installation in your 'Python Interpreter' and try again"
+ )
python_bin = str(Path(python_lib).parent / f"bin/python{python_lib_version}")
elif sys.platform == "linux":
+
class Dl_info(ctypes.Structure):
- _fields_ = [
- ("dli_fname", ctypes.c_char_p),
- ("dli_fbase", ctypes.c_void_p),
- ("dli_sname", ctypes.c_char_p),
- ("dli_saddr", ctypes.c_void_p),
- ]
+ _fields_ = [("dli_fname", ctypes.c_char_p), ("dli_fbase", ctypes.c_void_p),
+ ("dli_sname", ctypes.c_char_p), ("dli_saddr", ctypes.c_void_p), ]
+
def _linked_libpython():
libdl = ctypes.CDLL(find_library("dl"))
libdl.dladdr.argtypes = [ctypes.c_void_p, ctypes.POINTER(Dl_info)]
libdl.dladdr.restype = ctypes.c_int
dlinfo = Dl_info()
- retcode = libdl.dladdr(ctypes.cast(ctypes.pythonapi.Py_GetVersion, ctypes.c_void_p), ctypes.pointer(dlinfo))
+ retcode = libdl.dladdr(
+ ctypes.cast(ctypes.pythonapi.Py_GetVersion, ctypes.c_void_p), ctypes.pointer(dlinfo)
+ )
if retcode == 0: # means error
return None
return os.path.realpath(dlinfo.dli_fname.decode())
+
if using_bundled_python:
python_lib = _linked_libpython()
if python_lib is None:
- return (None, "Failed: No python specified. Specify a full python installation in your 'Python Interpreter' and try again")
+ return (
+ None,
+ "Failed: No python specified. Specify a full python installation in your 'Python Interpreter' and try again"
+ )
if python_lib == os.path.realpath(sys.executable):
python_bin = python_lib
@@ -939,7 +975,7 @@ class PythonScriptingProvider(ScriptingProvider):
if using_bundled_python:
python_bin = Path(binaryninja.get_install_directory()) / "plugins\\python\\python.exe"
else:
- python_bin = Path(python_lib).parent / "python.exe"
+ python_bin = Path(python_lib).parent / "python.exe"
python_bin_version = self._bin_version(python_bin)
if python_bin_version != python_lib_version:
return (None, f"Failed: Python version not equal {python_bin_version} and {python_lib_version}")
@@ -956,26 +992,35 @@ class PythonScriptingProvider(ScriptingProvider):
python_bin_override = settings.Settings().get_string("python.binaryOverride")
python_bin, status = self._get_executable_for_libpython(python_lib, python_bin_override)
if python_bin is not None and not self._pip_exists(str(python_bin)):
- log_error(f"Pip not installed for configured python: {python_bin}.\n"
- "Please install pip or switch python versions.")
+ log_error(
+ f"Pip not installed for configured python: {python_bin}.\n"
+ "Please install pip or switch python versions."
+ )
return False
if sys.platform == "darwin" and not any([python_bin, python_lib, python_bin_override]):
- log_error(f"Plugin requirement installation unsupported on MacOS with bundled Python: {status}\n"
- "Please specify a path to a python library in the 'Python Interpreter' setting")
+ log_error(
+ f"Plugin requirement installation unsupported on MacOS with bundled Python: {status}\n"
+ "Please specify a path to a python library in the 'Python Interpreter' setting"
+ )
return False
elif python_bin is None:
- log_error(f"Unable to discover python executable required for installing python modules: {status}\n"
- "Please specify a path to a python binary in the 'Python Path Override'")
+ log_error(
+ f"Unable to discover python executable required for installing python modules: {status}\n"
+ "Please specify a path to a python binary in the 'Python Path Override'"
+ )
return False
- python_bin_version = subprocess.check_output([python_bin, "-c",
- "import sys; sys.stdout.write(f'{sys.version_info.major}.{sys.version_info.minor}')"]).decode("utf-8")
+ python_bin_version = subprocess.check_output([
+ python_bin, "-c", "import sys; sys.stdout.write(f'{sys.version_info.major}.{sys.version_info.minor}')"
+ ]).decode("utf-8")
python_lib_version = f"{sys.version_info.major}.{sys.version_info.minor}"
if (python_bin_version != python_lib_version):
- log_error(f"Python Binary Setting {python_bin_version} incompatible with python library {python_lib_version}")
+ log_error(
+ f"Python Binary Setting {python_bin_version} incompatible with python library {python_lib_version}"
+ )
return False
- args:List[str] = [str(python_bin), "-m", "pip", "--isolated", "--disable-pip-version-check"]
+ args: List[str] = [str(python_bin), "-m", "pip", "--isolated", "--disable-pip-version-check"]
proxy_settings = settings.Settings().get_string("network.httpsProxy")
if proxy_settings:
args.extend(["--proxy", proxy_settings])
@@ -989,7 +1034,9 @@ class PythonScriptingProvider(ScriptingProvider):
user_dir = binaryninja.user_directory()
if user_dir is None:
raise Exception("Unable to find user directory.")
- site_package_dir = Path(user_dir) / f"python{sys.version_info.major}{sys.version_info.minor}" / "site-packages"
+ site_package_dir = Path(
+ user_dir
+ ) / f"python{sys.version_info.major}{sys.version_info.minor}" / "site-packages"
site_package_dir.mkdir(parents=True, exist_ok=True)
args.extend(["--target", str(site_package_dir)])
args.extend(list(filter(len, modules.split("\n"))))
@@ -999,7 +1046,7 @@ class PythonScriptingProvider(ScriptingProvider):
log_error(f"Error while attempting to install requirements {result}")
return status
- def _module_installed(self, ctx, module:str) -> bool:
+ def _module_installed(self, ctx, module: str) -> bool:
if self._python_bin is None:
return False
return re.split('>|=|,', module.strip(), 1)[0] in self._satisfied_dependencies(self._python_bin)
@@ -1011,6 +1058,7 @@ original_stdin = sys.stdin
original_stdout = sys.stdout
original_stderr = sys.stderr
+
def redirect_stdio():
sys.stdin = _PythonScriptingInstanceInput(sys.stdin)
sys.stdout = _PythonScriptingInstanceOutput(sys.stdout, False)
diff --git a/python/settings.py b/python/settings.py
index 7e057780..172c7392 100644
--- a/python/settings.py
+++ b/python/settings.py
@@ -120,7 +120,7 @@ class Settings:
"""
default_handle = core.BNCreateSettings("default")
- def __init__(self, instance_id:str="default", handle=None):
+ def __init__(self, instance_id: str = "default", handle=None):
if handle is None:
if instance_id is None or instance_id == "":
instance_id = "default"
@@ -158,7 +158,7 @@ class Settings:
"""Returns the ``instance_id`` for this :class:`Settings` repository (read-only)"""
return self._instance_id
- def set_resource_id(self, resource_id = None):
+ def set_resource_id(self, resource_id=None):
"""
``set_resource_id`` Sets the resource identifier for this class:`Settings` instance. When accessing setting values at the \
``SettingsResourceScope`` level, the resource identifier is passed along through the backing store interface.
@@ -256,53 +256,53 @@ class Settings:
def update_property(self, key, setting_property):
return core.BNSettingsUpdateProperty(self.handle, key, setting_property)
- def deserialize_schema(self, schema, scope = SettingsScope.SettingsAutoScope, merge = True):
+ def deserialize_schema(self, schema, scope=SettingsScope.SettingsAutoScope, merge=True):
return core.BNSettingsDeserializeSchema(self.handle, schema, scope, merge)
def serialize_schema(self):
return core.BNSettingsSerializeSchema(self.handle)
- def deserialize_settings(self, contents, view = None, scope = SettingsScope.SettingsAutoScope):
+ def deserialize_settings(self, contents, view=None, scope=SettingsScope.SettingsAutoScope):
if view is not None:
view = view.handle
return core.BNDeserializeSettings(self.handle, contents, view, scope)
- def serialize_settings(self, view = None, scope = SettingsScope.SettingsAutoScope):
+ def serialize_settings(self, view=None, scope=SettingsScope.SettingsAutoScope):
if view is not None:
view = view.handle
return core.BNSerializeSettings(self.handle, view, scope)
- def reset(self, key, view = None, scope = SettingsScope.SettingsAutoScope):
+ def reset(self, key, view=None, scope=SettingsScope.SettingsAutoScope):
if view is not None:
view = view.handle
return core.BNSettingsReset(self.handle, key, view, scope)
- def reset_all(self, view = None, scope = SettingsScope.SettingsAutoScope, schema_only = True):
+ def reset_all(self, view=None, scope=SettingsScope.SettingsAutoScope, schema_only=True):
if view is not None:
view = view.handle
return core.BNSettingsResetAll(self.handle, view, scope, schema_only)
- def get_bool(self, key, view = None):
+ def get_bool(self, key, view=None):
if view is not None:
view = view.handle
return core.BNSettingsGetBool(self.handle, key, view, None)
- def get_double(self, key, view = None):
+ def get_double(self, key, view=None):
if view is not None:
view = view.handle
return core.BNSettingsGetDouble(self.handle, key, view, None)
- def get_integer(self, key, view = None):
+ def get_integer(self, key, view=None):
if view is not None:
view = view.handle
return core.BNSettingsGetUInt64(self.handle, key, view, None)
- def get_string(self, key, view = None):
+ def get_string(self, key, view=None):
if view is not None:
view = view.handle
return core.BNSettingsGetString(self.handle, key, view, None)
- def get_string_list(self, key, view = None):
+ def get_string_list(self, key, view=None):
if view is not None:
view = view.handle
length = ctypes.c_ulonglong()
@@ -314,40 +314,40 @@ class Settings:
core.BNFreeStringList(result, length)
return out_list
- def get_json(self, key, view = None):
+ def get_json(self, key, view=None):
if view is not None:
view = view.handle
return core.BNSettingsGetJson(self.handle, key, view, None)
- def get_bool_with_scope(self, key, view = None, scope = SettingsScope.SettingsAutoScope):
+ def get_bool_with_scope(self, key, view=None, scope=SettingsScope.SettingsAutoScope):
if view is not None:
view = view.handle
c_scope = core.SettingsScopeEnum(scope)
result = core.BNSettingsGetBool(self.handle, key, view, ctypes.byref(c_scope))
return (result, SettingsScope(c_scope.value))
- def get_double_with_scope(self, key, view = None, scope = SettingsScope.SettingsAutoScope):
+ def get_double_with_scope(self, key, view=None, scope=SettingsScope.SettingsAutoScope):
if view is not None:
view = view.handle
c_scope = core.SettingsScopeEnum(scope)
result = core.BNSettingsGetDouble(self.handle, key, view, ctypes.byref(c_scope))
return (result, SettingsScope(c_scope.value))
- def get_integer_with_scope(self, key, view = None, scope = SettingsScope.SettingsAutoScope):
+ def get_integer_with_scope(self, key, view=None, scope=SettingsScope.SettingsAutoScope):
if view is not None:
view = view.handle
c_scope = core.SettingsScopeEnum(scope)
result = core.BNSettingsGetUInt64(self.handle, key, view, ctypes.byref(c_scope))
return (result, SettingsScope(c_scope.value))
- def get_string_with_scope(self, key, view = None, scope = SettingsScope.SettingsAutoScope):
+ def get_string_with_scope(self, key, view=None, scope=SettingsScope.SettingsAutoScope):
if view is not None:
view = view.handle
c_scope = core.SettingsScopeEnum(scope)
result = core.BNSettingsGetString(self.handle, key, view, ctypes.byref(c_scope))
return (result, SettingsScope(c_scope.value))
- def get_string_list_with_scope(self, key, view = None, scope = SettingsScope.SettingsAutoScope):
+ def get_string_list_with_scope(self, key, view=None, scope=SettingsScope.SettingsAutoScope):
if view is not None:
view = view.handle
c_scope = core.SettingsScopeEnum(scope)
@@ -360,34 +360,34 @@ class Settings:
core.BNFreeStringList(result, length)
return (out_list, SettingsScope(c_scope.value))
- def get_json_with_scope(self, key, view = None, scope = SettingsScope.SettingsAutoScope):
+ def get_json_with_scope(self, key, view=None, scope=SettingsScope.SettingsAutoScope):
if view is not None:
view = view.handle
c_scope = core.SettingsScopeEnum(scope)
result = core.BNSettingsGetJson(self.handle, key, view, ctypes.byref(c_scope))
return (result, SettingsScope(c_scope.value))
- def set_bool(self, key, value, view = None, scope = SettingsScope.SettingsAutoScope):
+ def set_bool(self, key, value, view=None, scope=SettingsScope.SettingsAutoScope):
if view is not None:
view = view.handle
return core.BNSettingsSetBool(self.handle, view, scope, key, value)
- def set_double(self, key, value, view = None, scope = SettingsScope.SettingsAutoScope):
+ def set_double(self, key, value, view=None, scope=SettingsScope.SettingsAutoScope):
if view is not None:
view = view.handle
return core.BNSettingsSetDouble(self.handle, view, scope, key, value)
- def set_integer(self, key, value, view = None, scope = SettingsScope.SettingsAutoScope):
+ def set_integer(self, key, value, view=None, scope=SettingsScope.SettingsAutoScope):
if view is not None:
view = view.handle
return core.BNSettingsSetUInt64(self.handle, view, scope, key, value)
- def set_string(self, key, value, view = None, scope = SettingsScope.SettingsAutoScope):
+ def set_string(self, key, value, view=None, scope=SettingsScope.SettingsAutoScope):
if view is not None:
view = view.handle
return core.BNSettingsSetString(self.handle, view, scope, key, value)
- def set_string_list(self, key, value, view = None, scope = SettingsScope.SettingsAutoScope):
+ def set_string_list(self, key, value, view=None, scope=SettingsScope.SettingsAutoScope):
if view is not None:
view = view.handle
length = ctypes.c_ulonglong()
@@ -397,7 +397,7 @@ class Settings:
string_list[i] = value[i].encode('charmap')
return core.BNSettingsSetStringList(self.handle, view, scope, key, string_list, length)
- def set_json(self, key, value, view = None, scope = SettingsScope.SettingsAutoScope):
+ def set_json(self, key, value, view=None, scope=SettingsScope.SettingsAutoScope):
if view is not None:
view = view.handle
return core.BNSettingsSetJson(self.handle, view, scope, key, value)
diff --git a/python/transform.py b/python/transform.py
index 03f9c93e..7b75099a 100644
--- a/python/transform.py
+++ b/python/transform.py
@@ -51,7 +51,7 @@ class _TransformMetaClass(type):
class TransformParameter:
- def __init__(self, name, long_name = None, fixed_length = 0):
+ def __init__(self, name, long_name=None, fixed_length=0):
self._name = name
if long_name is None:
self._long_name = name
@@ -60,9 +60,7 @@ class TransformParameter:
self._fixed_length = fixed_length
def __repr__(self):
- return "<TransformParameter: {} fixed length: {}>".format(
- self._long_name, self._fixed_length
- )
+ return "<TransformParameter: {} fixed length: {}>".format(self._long_name, self._fixed_length)
@property
def name(self):
@@ -196,10 +194,10 @@ class Transform(metaclass=_TransformMetaClass):
def _decode(self, ctxt, input_buf, output_buf, params, count):
try:
- input_obj = databuffer.DataBuffer(handle = core.BNDuplicateDataBuffer(input_buf))
+ input_obj = databuffer.DataBuffer(handle=core.BNDuplicateDataBuffer(input_buf))
param_map = {}
for i in range(0, count):
- data = databuffer.DataBuffer(handle = core.BNDuplicateDataBuffer(params[i].value))
+ data = databuffer.DataBuffer(handle=core.BNDuplicateDataBuffer(params[i].value))
param_map[params[i].name] = bytes(data)
result = self.perform_decode(bytes(input_obj), param_map)
if result is None:
@@ -213,10 +211,10 @@ class Transform(metaclass=_TransformMetaClass):
def _encode(self, ctxt, input_buf, output_buf, params, count):
try:
- input_obj = databuffer.DataBuffer(handle = core.BNDuplicateDataBuffer(input_buf))
+ input_obj = databuffer.DataBuffer(handle=core.BNDuplicateDataBuffer(input_buf))
param_map = {}
for i in range(0, count):
- data = databuffer.DataBuffer(handle = core.BNDuplicateDataBuffer(params[i].value))
+ data = databuffer.DataBuffer(handle=core.BNDuplicateDataBuffer(params[i].value))
param_map[params[i].name] = bytes(data)
result = self.perform_encode(bytes(input_obj), param_map)
if result is None:
@@ -238,7 +236,7 @@ class Transform(metaclass=_TransformMetaClass):
def perform_encode(self, data, params):
return None
- def decode(self, input_buf, params = {}):
+ def decode(self, input_buf, params={}):
if isinstance(input_buf, int) or isinstance(input_buf, int):
return None
input_buf = databuffer.DataBuffer(input_buf)
@@ -254,7 +252,7 @@ class Transform(metaclass=_TransformMetaClass):
return None
return bytes(output_buf)
- def encode(self, input_buf, params = {}):
+ def encode(self, input_buf, params={}):
if isinstance(input_buf, int) or isinstance(input_buf, int):
return None
input_buf = databuffer.DataBuffer(input_buf)
diff --git a/python/typelibrary.py b/python/typelibrary.py
index 2fa68452..84ce3a8d 100644
--- a/python/typelibrary.py
+++ b/python/typelibrary.py
@@ -264,7 +264,7 @@ class TypeLibrary:
"""
core.BNTypeLibraryRemoveMetadata(self.handle, key)
- def add_named_object(self, name:'types.QualifiedName', type:'types.Type') -> None:
+ def add_named_object(self, name: 'types.QualifiedName', type: 'types.Type') -> None:
"""
`add_named_object` directly inserts a named object into the type library's object store.
This is not done recursively, so care should be taken that types referring to other types
@@ -285,7 +285,7 @@ class TypeLibrary:
raise ValueError("type must be a Type")
core.BNAddTypeLibraryNamedObject(self.handle, name._to_core_struct(), type.handle)
- def add_named_type(self, name:'types.QualifiedName', type:'types.Type') -> None:
+ def add_named_type(self, name: 'types.QualifiedName', type: 'types.Type') -> None:
"""
`add_named_type` directly inserts a named object into the type library's object store.
This is not done recursively, so care should be taken that types referring to other types
@@ -367,4 +367,3 @@ class TypeLibrary:
result[name] = types.Type.create(core.BNNewTypeReference(named_types[i].type))
core.BNFreeQualifiedNameAndTypeArray(named_types, count.value)
return result
-
diff --git a/python/types.py b/python/types.py
index 944f03d0..e4392434 100644
--- a/python/types.py
+++ b/python/types.py
@@ -26,8 +26,10 @@ from abc import abstractmethod
# Binary Ninja components
from . import _binaryninjacore as core
-from .enums import (StructureVariant, SymbolType, SymbolBinding, TypeClass,
- NamedTypeReferenceClass, ReferenceType, VariableSourceType, TypeReferenceType, MemberAccess, MemberScope)
+from .enums import (
+ StructureVariant, SymbolType, SymbolBinding, TypeClass, NamedTypeReferenceClass, ReferenceType, VariableSourceType,
+ TypeReferenceType, MemberAccess, MemberScope
+)
from . import callingconvention
from . import function as _function
from . import variable
@@ -41,7 +43,7 @@ BoolWithConfidenceType = Union[bool, 'BoolWithConfidence']
OffsetWithConfidenceType = Union[int, 'OffsetWithConfidence']
ParamsType = Union[List['Type'], List['FunctionParameter'], List[Tuple['Type', str]]]
MembersType = Union[List['StructureMember'], List['Type'], List[Tuple['Type', str]]]
-EnumMembersType = Union[List[Tuple[str,int]], List[str], List['EnumerationMember']]
+EnumMembersType = Union[List[Tuple[str, int]], List[str], List['EnumerationMember']]
SomeType = Union['TypeBuilder', 'Type']
TypeContainer = Union['binaryview.BinaryView', 'typelibrary.TypeLibrary']
NameSpaceType = Optional[Union[str, List[str], 'NameSpace']]
@@ -53,9 +55,10 @@ MemberName = str
MemberIndex = int
MemberOffset = int
+
class QualifiedName:
- def __init__(self, name:Optional[QualifiedNameType]=None):
- self._name:List[str] = []
+ def __init__(self, name: Optional[QualifiedNameType] = None):
+ self._name: List[str] = []
if isinstance(name, str):
self._name = [name]
elif isinstance(name, bytes):
@@ -146,15 +149,15 @@ class QualifiedName:
return self._name
@name.setter
- def name(self, value:List[str]) -> None:
+ def name(self, value: List[str]) -> None:
self._name = value
@dataclass(frozen=True)
class TypeReferenceSource:
- name:QualifiedName
- offset:int
- ref_type:TypeReferenceType
+ name: QualifiedName
+ offset: int
+ ref_type: TypeReferenceType
def __repr__(self):
if self.ref_type == TypeReferenceType.DirectTypeReferenceType:
@@ -180,14 +183,14 @@ class NameSpace(QualifiedName):
return result
@staticmethod
- def _from_core_struct(name:core.BNNameSpace) -> 'NameSpace':
+ def _from_core_struct(name: core.BNNameSpace) -> 'NameSpace':
result = []
for i in range(0, name.nameCount):
result.append(name.name[i].decode("utf-8"))
return NameSpace(result)
@staticmethod
- def get_core_struct(name:Optional[Union[str, List[str], 'NameSpace']]) -> Optional[core.BNNameSpace]:
+ def get_core_struct(name: Optional[Union[str, List[str], 'NameSpace']]) -> Optional[core.BNNameSpace]:
if name is None:
return None
if isinstance(name, NameSpace):
@@ -197,7 +200,7 @@ class NameSpace(QualifiedName):
class CoreSymbol:
- def __init__(self, handle:core.BNSymbolHandle):
+ def __init__(self, handle: core.BNSymbolHandle):
self._handle = handle
def __del__(self):
@@ -307,7 +310,9 @@ class Symbol(CoreSymbol):
LibraryFunctionSymbol Symbols for external functions outside the library
=========================== ==============================================================
"""
- def __init__(self, sym_type, addr, short_name, full_name=None, raw_name=None, binding=None, namespace=None, ordinal=0):
+ def __init__(
+ self, sym_type, addr, short_name, full_name=None, raw_name=None, binding=None, namespace=None, ordinal=0
+ ):
if isinstance(sym_type, str):
sym_type = SymbolType[sym_type]
if full_name is None:
@@ -324,9 +329,9 @@ class Symbol(CoreSymbol):
@dataclass
class FunctionParameter:
- type:SomeType
- name:str = ""
- location:Optional['variable.VariableNameAndType'] = None
+ type: SomeType
+ name: str = ""
+ location: Optional['variable.VariableNameAndType'] = None
def __repr__(self):
if (self.location is not None) and (self.location.name != self.name):
@@ -342,8 +347,8 @@ class FunctionParameter:
@dataclass(frozen=True)
class OffsetWithConfidence:
- value:int
- confidence:int=core.max_confidence
+ value: int
+ confidence: int = core.max_confidence
def __int__(self):
return self.value
@@ -376,11 +381,11 @@ class OffsetWithConfidence:
return result
@classmethod
- def from_core_struct(cls, core_struct:core.BNOffsetWithConfidence) -> 'OffsetWithConfidence':
+ def from_core_struct(cls, core_struct: core.BNOffsetWithConfidence) -> 'OffsetWithConfidence':
return cls(core_struct.value, core_struct.confidence)
@staticmethod
- def get_core_struct(value:OffsetWithConfidenceType) -> core.BNOffsetWithConfidence:
+ def get_core_struct(value: OffsetWithConfidenceType) -> core.BNOffsetWithConfidence:
if isinstance(value, OffsetWithConfidence):
return value._to_core_struct()
else:
@@ -389,8 +394,8 @@ class OffsetWithConfidence:
@dataclass(frozen=True)
class BoolWithConfidence:
- value:bool
- confidence:int=core.max_confidence
+ value: bool
+ confidence: int = core.max_confidence
def __eq__(self, other):
if not isinstance(other, self.__class__):
@@ -411,11 +416,11 @@ class BoolWithConfidence:
return result
@classmethod
- def from_core_struct(cls, core_struct:core.BNBoolWithConfidence) -> 'BoolWithConfidence':
+ def from_core_struct(cls, core_struct: core.BNBoolWithConfidence) -> 'BoolWithConfidence':
return cls(core_struct.value, core_struct.confidence)
@staticmethod
- def get_core_struct(value:BoolWithConfidenceType) -> core.BNBoolWithConfidence:
+ def get_core_struct(value: BoolWithConfidenceType) -> core.BNBoolWithConfidence:
if isinstance(value, BoolWithConfidence):
return value._to_core_struct()
else:
@@ -424,12 +429,12 @@ class BoolWithConfidence:
@dataclass
class MutableTypeBuilder:
- type:'TypeBuilder'
- container:TypeContainer
- name:QualifiedName
- platform:Optional['_platform.Platform']
- confidence:int
- user:bool = True
+ type: 'TypeBuilder'
+ container: TypeContainer
+ name: QualifiedName
+ platform: Optional['_platform.Platform']
+ confidence: int
+ user: bool = True
def __enter__(self):
return self.type
@@ -446,7 +451,10 @@ class MutableTypeBuilder:
class TypeBuilder:
- def __init__(self, handle:core.BNTypeBuilderHandle, platform:'_platform.Platform'=None, confidence:int=core.max_confidence):
+ def __init__(
+ self, handle: core.BNTypeBuilderHandle, platform: '_platform.Platform' = None,
+ confidence: int = core.max_confidence
+ ):
assert isinstance(handle, core.BNTypeBuilderHandle), "handle isn't an instance of BNTypeBuilderHandle"
self._handle = handle
self.platform = platform
@@ -456,12 +464,12 @@ class TypeBuilder:
if core is not None:
core.BNFreeTypeBuilder(self._handle)
- def __eq__(self, other:'TypeBuilder') -> bool:
+ def __eq__(self, other: 'TypeBuilder') -> bool:
if not isinstance(other, TypeBuilder):
raise ValueError(f"Unable compare equality of TypeBuilder and {type(other)}")
return self.immutable_copy() == other.immutable_copy()
- def __ne__(self, other:'TypeBuilder') -> bool:
+ def __ne__(self, other: 'TypeBuilder') -> bool:
return not self.__eq__(other)
def __repr__(self):
@@ -482,17 +490,13 @@ class TypeBuilder:
def immutable_copy(self):
Types = {
- TypeClass.VoidTypeClass:VoidType,
- TypeClass.BoolTypeClass:BoolType,
- TypeClass.IntegerTypeClass:IntegerType,
- TypeClass.FloatTypeClass:FloatType,
- TypeClass.PointerTypeClass:PointerType,
- TypeClass.ArrayTypeClass:ArrayType,
- TypeClass.FunctionTypeClass:FunctionType,
- TypeClass.WideCharTypeClass:WideCharType,
- # TypeClass.StructureTypeClass:StructureType,
- # TypeClass.EnumerationTypeClass:EnumerationType,
- # TypeClass.NamedTypeReferenceClass:NamedTypeReferenceType,
+ TypeClass.VoidTypeClass: VoidType, TypeClass.BoolTypeClass: BoolType,
+ TypeClass.IntegerTypeClass: IntegerType, TypeClass.FloatTypeClass: FloatType,
+ TypeClass.PointerTypeClass: PointerType, TypeClass.ArrayTypeClass: ArrayType,
+ TypeClass.FunctionTypeClass: FunctionType, TypeClass.WideCharTypeClass: WideCharType,
+ # TypeClass.StructureTypeClass:StructureType,
+ # TypeClass.EnumerationTypeClass:EnumerationType,
+ # TypeClass.NamedTypeReferenceClass:NamedTypeReferenceType,
}
return Types[self.type_class](self.finalized, self.platform, self.confidence)
@@ -505,8 +509,10 @@ class TypeBuilder:
return NotImplemented
@classmethod
- def builder(cls, container:TypeContainer, name:'QualifiedName', user:bool=True,
- platform:'_platform.Platform'=None, confidence:int=core.max_confidence) -> 'MutableTypeBuilder':
+ def builder(
+ cls, container: TypeContainer, name: 'QualifiedName', user: bool = True, platform: '_platform.Platform' = None,
+ confidence: int = core.max_confidence
+ ) -> 'MutableTypeBuilder':
return MutableTypeBuilder(cls.create(), container, name, platform, confidence, user)
@staticmethod
@@ -518,11 +524,13 @@ class TypeBuilder:
return BoolBuilder.create()
@staticmethod
- def char(alternate_name:str="") -> 'CharBuilder':
+ def char(alternate_name: str = "") -> 'CharBuilder':
return CharBuilder.create(alternate_name)
@staticmethod
- def int(width:_int, sign:BoolWithConfidenceType=BoolWithConfidence(True), altname:str="") -> 'IntegerBuilder':
+ def int(
+ width: _int, sign: BoolWithConfidenceType = BoolWithConfidence(True), altname: str = ""
+ ) -> 'IntegerBuilder':
"""
``int`` class method for creating an int Type.
:param int width: width of the integer in bytes
@@ -532,7 +540,7 @@ class TypeBuilder:
return IntegerBuilder.create(width, sign, altname)
@staticmethod
- def float(width:_int, altname:str="") -> 'FloatBuilder':
+ def float(width: _int, altname: str = "") -> 'FloatBuilder':
"""
``float`` class method for creating floating point Types.
:param int width: width of the floating point number in bytes
@@ -541,7 +549,7 @@ class TypeBuilder:
return FloatBuilder.create(width, altname)
@staticmethod
- def wide_char(width:_int, altname:str="") -> 'WideCharBuilder':
+ def wide_char(width: _int, altname: str = "") -> 'WideCharBuilder':
"""
``wide_char`` class method for creating wide char Types.
:param int width: width of the wide character in bytes
@@ -550,39 +558,50 @@ class TypeBuilder:
return WideCharBuilder.create(width, altname)
@staticmethod
- def named_type_from_type(name:QualifiedName, type_class:Optional[NamedTypeReferenceClass]=None) -> 'NamedTypeReferenceBuilder':
+ def named_type_from_type(
+ name: QualifiedName, type_class: Optional[NamedTypeReferenceClass] = None
+ ) -> 'NamedTypeReferenceBuilder':
return NamedTypeReferenceBuilder.named_type_from_type(name, type_class)
@staticmethod
- def named_type_from_type_and_id(type_id:str, name:QualifiedName, type:Optional['Type']=None) -> 'NamedTypeReferenceBuilder':
+ def named_type_from_type_and_id(
+ type_id: str, name: QualifiedName, type: Optional['Type'] = None
+ ) -> 'NamedTypeReferenceBuilder':
return NamedTypeReferenceBuilder.named_type_from_type_and_id(type_id, name, type)
@staticmethod
- def named_type_from_registered_type(view:'binaryview.BinaryView', name:QualifiedName) -> 'NamedTypeReferenceBuilder':
+ def named_type_from_registered_type(
+ view: 'binaryview.BinaryView', name: QualifiedName
+ ) -> 'NamedTypeReferenceBuilder':
return NamedTypeReferenceBuilder.named_type_from_registered_type(view, name)
@staticmethod
- def pointer(arch:'architecture.Architecture', type:'Type',
- const:BoolWithConfidenceType=BoolWithConfidence(False),
- volatile:BoolWithConfidenceType=BoolWithConfidence(False),
- ref_type:ReferenceType=ReferenceType.PointerReferenceType) -> 'PointerBuilder':
+ def pointer(
+ arch: 'architecture.Architecture', type: 'Type', const: BoolWithConfidenceType = BoolWithConfidence(False),
+ volatile: BoolWithConfidenceType = BoolWithConfidence(False),
+ ref_type: ReferenceType = ReferenceType.PointerReferenceType
+ ) -> 'PointerBuilder':
return PointerBuilder.create(type, arch.address_size, arch, const, volatile, ref_type)
@staticmethod
- def pointer_of_width(width:_int, type:'Type',
- const:BoolWithConfidenceType=BoolWithConfidence(False),
- volatile:BoolWithConfidenceType=BoolWithConfidence(False),
- ref_type:ReferenceType=ReferenceType.PointerReferenceType) -> 'PointerBuilder':
+ def pointer_of_width(
+ width: _int, type: 'Type', const: BoolWithConfidenceType = BoolWithConfidence(False),
+ volatile: BoolWithConfidenceType = BoolWithConfidence(False),
+ ref_type: ReferenceType = ReferenceType.PointerReferenceType
+ ) -> 'PointerBuilder':
return PointerBuilder.create(type, width, None, const, volatile, ref_type)
@staticmethod
- def array(type:'Type', count:_int) -> 'ArrayBuilder':
+ def array(type: 'Type', count: _int) -> 'ArrayBuilder':
return ArrayBuilder.create(type, count)
@staticmethod
- def function(ret:Optional['Type']=None, params:Optional[ParamsType]=None, calling_convention:'callingconvention.CallingConvention'=None,
- variable_arguments:BoolWithConfidenceType=BoolWithConfidence(False),
- stack_adjust:OffsetWithConfidenceType=0) -> 'FunctionBuilder':
+ def function(
+ ret: Optional['Type'] = None, params: Optional[ParamsType] = None,
+ calling_convention: 'callingconvention.CallingConvention' = None,
+ variable_arguments: BoolWithConfidenceType = BoolWithConfidence(False),
+ stack_adjust: OffsetWithConfidenceType = 0
+ ) -> 'FunctionBuilder':
"""
``function`` class method for creating an function Type.
:param Type ret: return Type of the function
@@ -594,29 +613,36 @@ class TypeBuilder:
return FunctionBuilder.create(ret, calling_convention, params, variable_arguments, stack_adjust)
@staticmethod
- def structure(members:Optional[MembersType]=None, packed:_bool=False, type:StructureVariant=StructureVariant.StructStructureType) -> 'StructureBuilder':
+ def structure(
+ members: Optional[MembersType] = None, packed: _bool = False,
+ type: StructureVariant = StructureVariant.StructStructureType
+ ) -> 'StructureBuilder':
return StructureBuilder.create(members, type=type, packed=packed)
-
+
@staticmethod
- def union(members:Optional[MembersType]=None, packed:_bool=False) -> 'StructureBuilder':
+ def union(members: Optional[MembersType] = None, packed: _bool = False) -> 'StructureBuilder':
return StructureBuilder.create(members, type=StructureVariant.UnionStructureType, packed=packed)
-
+
@staticmethod
- def class_type(members:Optional[MembersType]=None, packed:_bool=False) -> 'StructureBuilder':
+ def class_type(members: Optional[MembersType] = None, packed: _bool = False) -> 'StructureBuilder':
return StructureBuilder.create(members, type=StructureVariant.ClassStructureType, packed=packed)
@staticmethod
- def enumeration(arch:Optional['architecture.Architecture']=None, members:Optional[List[EnumMembersType]]=None,
- width:Optional[_int]=None, sign:BoolWithConfidenceType=BoolWithConfidence(False)) -> 'EnumerationBuilder':
+ def enumeration(
+ arch: Optional['architecture.Architecture'] = None, members: Optional[List[EnumMembersType]] = None,
+ width: Optional[_int] = None, sign: BoolWithConfidenceType = BoolWithConfidence(False)
+ ) -> 'EnumerationBuilder':
return EnumerationBuilder.create(members, width, arch, sign)
@staticmethod
- def named_type_reference(type_class:NamedTypeReferenceClass, name:QualifiedName,
- type_id:Optional[str]=None, alignment:_int=1, width:_int=0,
- const:BoolWithConfidenceType=BoolWithConfidence(False),
- volatile:BoolWithConfidenceType=BoolWithConfidence(False)) -> 'NamedTypeReferenceBuilder':
- return NamedTypeReferenceBuilder.create(type_class, type_id, name, width, alignment,
- None, core.max_confidence, const, volatile)
+ def named_type_reference(
+ type_class: NamedTypeReferenceClass, name: QualifiedName, type_id: Optional[str] = None, alignment: _int = 1,
+ width: _int = 0, const: BoolWithConfidenceType = BoolWithConfidence(False),
+ volatile: BoolWithConfidenceType = BoolWithConfidence(False)
+ ) -> 'NamedTypeReferenceBuilder':
+ return NamedTypeReferenceBuilder.create(
+ type_class, type_id, name, width, alignment, None, core.max_confidence, const, volatile
+ )
@property
def width(self) -> _int:
@@ -637,20 +663,24 @@ class TypeBuilder:
def const(self) -> BoolWithConfidence:
"""Whether type is const (read/write)"""
result = core.BNIsTypeBuilderConst(self._handle)
- return BoolWithConfidence(result.value, confidence = result.confidence)
+ return BoolWithConfidence(result.value, confidence=result.confidence)
@const.setter
- def const(self, value:BoolWithConfidenceType) -> None: # type: ignore # We explicitly allow 'set' type to be different than 'get' type
+ def const(
+ self, value: BoolWithConfidenceType
+ ) -> None: # type: ignore # We explicitly allow 'set' type to be different than 'get' type
core.BNTypeBuilderSetConst(self._handle, BoolWithConfidence.get_core_struct(value))
@property
def volatile(self) -> BoolWithConfidence:
"""Whether type is volatile (read/write)"""
result = core.BNIsTypeBuilderVolatile(self._handle)
- return BoolWithConfidence(result.value, confidence = result.confidence)
+ return BoolWithConfidence(result.value, confidence=result.confidence)
@volatile.setter
- def volatile(self, value:BoolWithConfidenceType) -> None: # type: ignore # We explicitly allow 'set' type to be different than 'get' type
+ def volatile(
+ self, value: BoolWithConfidenceType
+ ) -> None: # type: ignore # We explicitly allow 'set' type to be different than 'get' type
core.BNTypeBuilderSetVolatile(self._handle, BoolWithConfidence.get_core_struct(value))
@property
@@ -666,7 +696,7 @@ class TypeBuilder:
return Type.create(handle, self.platform, type_conf.confidence)
@child.setter
- def child(self, value:SomeType) -> None: # type: ignore
+ def child(self, value: SomeType) -> None: # type: ignore
core.BNTypeBuilderSetChildType(self._handle, value.immutable_copy()._to_core_struct())
@property
@@ -674,7 +704,7 @@ class TypeBuilder:
return core.BNGetTypeBuilderAlternateName(self._handle)
@alternate_name.setter
- def alternate_name(self, name:str) -> None:
+ def alternate_name(self, name: str) -> None:
core.BNTypeBuilderSetAlternateName(self._handle, name)
@property
@@ -685,7 +715,7 @@ class TypeBuilder:
return core.BNTypeBuilderGetSystemCallNumber(self._handle)
@system_call_number.setter
- def system_call_number(self, value:int) -> None:
+ def system_call_number(self, value: int) -> None:
core.BNTypeBuilderSetSystemCallNumber(self._handle, True, value)
def clear_system_call(self) -> None:
@@ -700,13 +730,14 @@ class TypeBuilder:
return BoolWithConfidence.from_core_struct(core.BNIsTypeBuilderSigned(self._handle))
@signed.setter
- def signed(self, value:BoolWithConfidenceType) -> None: # type: ignore
+ def signed(self, value: BoolWithConfidenceType) -> None: # type: ignore
_value = BoolWithConfidence.get_core_struct(value)
core.BNTypeBuilderSetSigned(self._handle, _value)
+
class VoidBuilder(TypeBuilder):
@classmethod
- def create(cls, platform:'_platform.Platform'=None, confidence:int=core.max_confidence) -> 'VoidBuilder':
+ def create(cls, platform: '_platform.Platform' = None, confidence: int = core.max_confidence) -> 'VoidBuilder':
handle = core.BNCreateVoidTypeBuilder()
assert handle is not None, "core.BNCreateVoidTypeBuilder returned None"
return cls(handle, platform, confidence)
@@ -714,7 +745,7 @@ class VoidBuilder(TypeBuilder):
class BoolBuilder(TypeBuilder):
@classmethod
- def create(cls, platform:'_platform.Platform'=None, confidence:int=core.max_confidence) -> 'BoolBuilder':
+ def create(cls, platform: '_platform.Platform' = None, confidence: int = core.max_confidence) -> 'BoolBuilder':
handle = core.BNCreateBoolTypeBuilder()
assert handle is not None, "core.BNCreateBoolTypeBuilder returned None"
return cls(handle, platform, confidence)
@@ -722,8 +753,10 @@ class BoolBuilder(TypeBuilder):
class IntegerBuilder(TypeBuilder):
@classmethod
- def create(cls, width:int, sign:BoolWithConfidenceType=True, alternate_name:str="",
- platform:'_platform.Platform'=None, confidence:int=core.max_confidence) -> 'IntegerBuilder':
+ def create(
+ cls, width: int, sign: BoolWithConfidenceType = True, alternate_name: str = "",
+ platform: '_platform.Platform' = None, confidence: int = core.max_confidence
+ ) -> 'IntegerBuilder':
_sign = BoolWithConfidence.get_core_struct(sign)
handle = core.BNCreateIntegerTypeBuilder(width, _sign, alternate_name)
assert handle is not None, "core.BNCreateIntegerTypeBuilder returned None"
@@ -732,8 +765,9 @@ class IntegerBuilder(TypeBuilder):
class CharBuilder(IntegerBuilder):
@classmethod
- def create(cls, alternate_name:str="",
- platform:'_platform.Platform'=None, confidence:int=core.max_confidence) -> 'CharBuilder':
+ def create(
+ cls, alternate_name: str = "", platform: '_platform.Platform' = None, confidence: int = core.max_confidence
+ ) -> 'CharBuilder':
handle = core.BNCreateIntegerTypeBuilder(1, BoolWithConfidence.get_core_struct(False), alternate_name)
assert handle is not None, "BNCreateIntegerTypeBuilder returned None"
return cls(handle, platform, confidence)
@@ -741,8 +775,10 @@ class CharBuilder(IntegerBuilder):
class FloatBuilder(TypeBuilder):
@classmethod
- def create(cls, width:int, alternate_name:str="",
- platform:'_platform.Platform'=None, confidence:int=core.max_confidence) -> 'FloatBuilder':
+ def create(
+ cls, width: int, alternate_name: str = "", platform: '_platform.Platform' = None,
+ confidence: int = core.max_confidence
+ ) -> 'FloatBuilder':
handle = core.BNCreateFloatTypeBuilder(width, alternate_name)
assert handle is not None, "core.BNCreateFloatTypeBuilder returned None"
return cls(handle, platform, confidence)
@@ -750,8 +786,10 @@ class FloatBuilder(TypeBuilder):
class WideCharBuilder(TypeBuilder):
@classmethod
- def create(cls, width:int, alternate_name:str="",
- platform:'_platform.Platform'=None, confidence:int=core.max_confidence) -> 'WideCharBuilder':
+ def create(
+ cls, width: int, alternate_name: str = "", platform: '_platform.Platform' = None,
+ confidence: int = core.max_confidence
+ ) -> 'WideCharBuilder':
handle = core.BNCreateWideCharTypeBuilder(width, alternate_name)
assert handle is not None, "core.BNCreateWideCharTypeBuilder returned None"
return cls(handle, platform, confidence)
@@ -759,10 +797,12 @@ class WideCharBuilder(TypeBuilder):
class PointerBuilder(TypeBuilder):
@classmethod
- def create(cls, type:'Type', width:int=4, arch:Optional['architecture.Architecture']=None,
- const:BoolWithConfidenceType=False, volatile:BoolWithConfidenceType=False,
- ref_type:ReferenceType=ReferenceType.PointerReferenceType,
- platform:'_platform.Platform'=None, confidence:int=core.max_confidence) -> 'PointerBuilder':
+ def create(
+ cls, type: 'Type', width: int = 4, arch: Optional['architecture.Architecture'] = None,
+ const: BoolWithConfidenceType = False, volatile: BoolWithConfidenceType = False,
+ ref_type: ReferenceType = ReferenceType.PointerReferenceType, platform: '_platform.Platform' = None,
+ confidence: int = core.max_confidence
+ ) -> 'PointerBuilder':
assert width is not None or arch is not None, "Must specify either a width or architecture when creating a pointer"
_width = width
if arch is not None:
@@ -770,8 +810,7 @@ class PointerBuilder(TypeBuilder):
_const = BoolWithConfidence.get_core_struct(const)
_volatile = BoolWithConfidence.get_core_struct(volatile)
- handle = core.BNCreatePointerTypeBuilderOfWidth(_width, type._to_core_struct(), _const,
- _volatile, ref_type)
+ handle = core.BNCreatePointerTypeBuilderOfWidth(_width, type._to_core_struct(), _const, _volatile, ref_type)
assert handle is not None, "BNCreatePointerTypeBuilderOfWidth returned None"
return cls(handle, platform, confidence)
@@ -786,8 +825,10 @@ class PointerBuilder(TypeBuilder):
class ArrayBuilder(TypeBuilder):
@classmethod
- def create(cls, type:SomeType, element_count:int,
- platform:'_platform.Platform'=None, confidence:int=core.max_confidence) -> 'ArrayBuilder':
+ def create(
+ cls, type: SomeType, element_count: int, platform: '_platform.Platform' = None,
+ confidence: int = core.max_confidence
+ ) -> 'ArrayBuilder':
handle = core.BNCreateArrayTypeBuilder(type._to_core_struct(), element_count)
assert handle is not None, "BNCreateArrayTypeBuilder returned None"
return cls(handle, platform, confidence)
@@ -803,10 +844,12 @@ class ArrayBuilder(TypeBuilder):
class FunctionBuilder(TypeBuilder):
@classmethod
- def create(cls, return_type:Optional[SomeType]=None, calling_convention:Optional['callingconvention.CallingConvention']=None,
- params:Optional[ParamsType]=None, var_args:BoolWithConfidenceType=False,
- stack_adjust:OffsetWithConfidenceType=0, platform:'_platform.Platform'=None,
- confidence:int=core.max_confidence) -> 'FunctionBuilder':
+ def create(
+ cls, return_type: Optional[SomeType] = None,
+ calling_convention: Optional['callingconvention.CallingConvention'] = None, params: Optional[ParamsType] = None,
+ var_args: BoolWithConfidenceType = False, stack_adjust: OffsetWithConfidenceType = 0,
+ platform: '_platform.Platform' = None, confidence: int = core.max_confidence
+ ) -> 'FunctionBuilder':
param_buf = FunctionBuilder._to_core_struct(params)
if return_type is None:
ret_conf = Type.void()._to_core_struct()
@@ -825,8 +868,9 @@ class FunctionBuilder(TypeBuilder):
stack_adjust_conf = OffsetWithConfidence.get_core_struct(stack_adjust)
if params is None:
params = []
- handle = core.BNCreateFunctionTypeBuilder(ret_conf, conv_conf, param_buf, len(params),
- vararg_conf, stack_adjust_conf)
+ handle = core.BNCreateFunctionTypeBuilder(
+ ret_conf, conv_conf, param_buf, len(params), vararg_conf, stack_adjust_conf
+ )
assert handle is not None, "BNCreateFunctionTypeBuilder returned None"
return cls(handle, platform, confidence)
@@ -839,10 +883,10 @@ class FunctionBuilder(TypeBuilder):
return self.child.mutable_copy()
@return_value.setter
- def return_value(self, value:SomeType) -> None: # type: ignore
+ def return_value(self, value: SomeType) -> None: # type: ignore
self.child = value
- def append(self, type:Union[SomeType, FunctionParameter], name:str=""):
+ def append(self, type: Union[SomeType, FunctionParameter], name: str = ""):
if isinstance(type, FunctionParameter):
self.parameters = [*self.parameters, type]
else:
@@ -858,7 +902,7 @@ class FunctionBuilder(TypeBuilder):
return BoolWithConfidence.from_core_struct(core.BNFunctionTypeBuilderCanReturn(self._handle))
@can_return.setter
- def can_return(self, value:BoolWithConfidenceType) -> None: # type: ignore
+ def can_return(self, value: BoolWithConfidenceType) -> None: # type: ignore
core.BNSetFunctionTypeBuilderCanReturn(self._handle, BoolWithConfidence.get_core_struct(value))
@property
@@ -873,17 +917,21 @@ class FunctionBuilder(TypeBuilder):
assert params is not None, "core.BNGetTypeBuilderParameters returned None"
result = []
for i in range(0, count.value):
- param_type = Type.create(core.BNNewTypeReference(params[i].type), platform = self.platform, confidence = params[i].typeConfidence)
+ param_type = Type.create(
+ core.BNNewTypeReference(params[i].type), platform=self.platform, confidence=params[i].typeConfidence
+ )
if params[i].defaultLocation:
param_location = None
else:
name = params[i].name
- if (params[i].location.type == VariableSourceType.RegisterVariableSourceType) and (self.platform is not None):
+ if (params[i].location.type
+ == VariableSourceType.RegisterVariableSourceType) and (self.platform is not None):
name = self.platform.arch.get_reg_name(params[i].location.storage)
elif params[i].location.type == VariableSourceType.StackVariableSourceType:
name = "arg_%x" % params[i].location.storage
- param_location = variable.VariableNameAndType(params[i].location.type, params[i].location.index,
- params[i].location.storage, name, param_type)
+ param_location = variable.VariableNameAndType(
+ params[i].location.type, params[i].location.index, params[i].location.storage, name, param_type
+ )
result.append(FunctionParameter(param_type, params[i].name, param_location))
core.BNFreeTypeParameterList(params, count.value)
return result
@@ -893,7 +941,7 @@ class FunctionBuilder(TypeBuilder):
return BoolWithConfidence.from_core_struct(core.BNTypeBuilderHasVariableArguments(self._handle))
@staticmethod
- def _to_core_struct(params:Optional[ParamsType]=None):
+ def _to_core_struct(params: Optional[ParamsType] = None):
if params is None:
params = []
param_buf = (core.BNFunctionParameter * len(params))()
@@ -920,7 +968,9 @@ class FunctionBuilder(TypeBuilder):
elif isinstance(param, tuple):
name, _type = param
assert isinstance(name, str), f"Conversion from unsupported function parameter type {type(param)}"
- assert isinstance(_type, (Type, TypeBuilder)), f"Conversion from unsupported function parameter type {type(param)}"
+ assert isinstance(
+ _type, (Type, TypeBuilder)
+ ), f"Conversion from unsupported function parameter type {type(param)}"
core_param.name = name
core_param.type = _type.handle
core_param.typeConfidence = _type.confidence
@@ -930,31 +980,32 @@ class FunctionBuilder(TypeBuilder):
return param_buf
@parameters.setter
- def parameters(self, params:List[FunctionParameter]) -> None:
+ def parameters(self, params: List[FunctionParameter]) -> None:
core.BNSetFunctionTypeBuilderParameters(self._handle, FunctionBuilder._to_core_struct(params), len(params))
@dataclass
class StructureMember:
- type:'Type'
- name:str
- offset:int
- access:MemberAccess = MemberAccess.NoAccess
- scope:MemberScope = MemberScope.NoScope
+ type: 'Type'
+ name: str
+ offset: int
+ access: MemberAccess = MemberAccess.NoAccess
+ scope: MemberScope = MemberScope.NoScope
def __repr__(self):
if len(self.name) == 0:
return f"<member: {self.type}, offset {self.offset:#x}>"
- return f"<{self.type.get_string_before_name()} {self.name}{self.type.get_string_after_name()}" + \
- f", offset {self.offset:#x}>"
+ return f"<{self.type.get_string_before_name()} {self.name}{self.type.get_string_after_name()}, offset {self.offset:#x}>"
def __len__(self):
return len(self.type)
class StructureBuilder(TypeBuilder):
- def __init__(self, handle:core.BNTypeBuilderHandle, builder_handle:core.BNStructureBuilderHandle,
- platform:'_platform.Platform'=None, confidence:int=core.max_confidence):
+ def __init__(
+ self, handle: core.BNTypeBuilderHandle, builder_handle: core.BNStructureBuilderHandle,
+ platform: '_platform.Platform' = None, confidence: int = core.max_confidence
+ ):
super(StructureBuilder, self).__init__(handle, platform, confidence)
assert builder_handle is not None, "Can't instantiate Structure with builder_handle set to None"
self.builder_handle = builder_handle
@@ -966,12 +1017,18 @@ class StructureBuilder(TypeBuilder):
for member in members:
if isinstance(member, Tuple):
_type, _name = member
- core.BNAddStructureBuilderMember(structure_builder_handle, _type._to_core_struct(), _name, MemberAccess.NoAccess, MemberScope.NoScope)
+ core.BNAddStructureBuilderMember(
+ structure_builder_handle, _type._to_core_struct(), _name, MemberAccess.NoAccess, MemberScope.NoScope
+ )
elif isinstance(member, StructureMember):
- core.BNAddStructureBuilderMemberAtOffset(structure_builder_handle, member.type._to_core_struct(),
- member.name, member.offset, False, member.access, member.scope)
+ core.BNAddStructureBuilderMemberAtOffset(
+ structure_builder_handle, member.type._to_core_struct(), member.name, member.offset, False,
+ member.access, member.scope
+ )
elif isinstance(member, (TypeBuilder, Type)):
- core.BNAddStructureBuilderMember(structure_builder_handle, member._to_core_struct(), "", MemberAccess.NoAccess, MemberScope.NoScope)
+ core.BNAddStructureBuilderMember(
+ structure_builder_handle, member._to_core_struct(), "", MemberAccess.NoAccess, MemberScope.NoScope
+ )
else:
raise ValueError(f"Structure member type {member} not supported")
@@ -979,11 +1036,11 @@ class StructureBuilder(TypeBuilder):
StructureBuilder._add_members_to_builder(self.builder_handle, members)
@classmethod
- def create(cls, members:MembersType=None,
- type:StructureVariant=StructureVariant.StructStructureType,
- packed:bool=False,
- width:Optional[int]=None, platform:'_platform.Platform'=None,
- confidence:int=core.max_confidence) -> 'StructureBuilder':
+ def create(
+ cls, members: MembersType = None, type: StructureVariant = StructureVariant.StructStructureType,
+ packed: bool = False, width: Optional[int] = None, platform: '_platform.Platform' = None,
+ confidence: int = core.max_confidence
+ ) -> 'StructureBuilder':
structure_builder_handle = core.BNCreateStructureBuilderWithOptions(type, packed)
assert structure_builder_handle is not None, "core.BNCreateStructureBuilderWithOptions returned None"
if width is not None:
@@ -1011,14 +1068,18 @@ class StructureBuilder(TypeBuilder):
result = []
for i in range(0, count.value):
t = Type.create(core.BNNewTypeReference(members[i].type), confidence=members[i].typeConfidence)
- result.append(StructureMember(t, members[i].name, members[i].offset,
- MemberAccess(members[i].access), MemberScope(members[i].scope)))
+ result.append(
+ StructureMember(
+ t, members[i].name, members[i].offset, MemberAccess(members[i].access),
+ MemberScope(members[i].scope)
+ )
+ )
return result
finally:
core.BNFreeStructureMemberList(members, count.value)
@members.setter
- def members(self, members:MembersType=None) -> None:
+ def members(self, members: MembersType = None) -> None:
count = len(self.members)
# remove members in reverse order
for i in reversed(range(count)):
@@ -1030,7 +1091,7 @@ class StructureBuilder(TypeBuilder):
return core.BNIsStructureBuilderPacked(self.builder_handle)
@packed.setter
- def packed(self, value:bool) -> None:
+ def packed(self, value: bool) -> None:
core.BNSetStructureBuilderPacked(self.builder_handle, value)
@property
@@ -1038,7 +1099,7 @@ class StructureBuilder(TypeBuilder):
return core.BNGetStructureBuilderAlignment(self.builder_handle)
@alignment.setter
- def alignment(self, value:int) -> None:
+ def alignment(self, value: int) -> None:
core.BNSetStructureBuilderAlignment(self.builder_handle, value)
@property
@@ -1046,7 +1107,7 @@ class StructureBuilder(TypeBuilder):
return core.BNGetStructureBuilderWidth(self.builder_handle)
@width.setter
- def width(self, value:int) -> None:
+ def width(self, value: int) -> None:
core.BNSetStructureBuilderWidth(self.builder_handle, value)
@property
@@ -1058,17 +1119,19 @@ class StructureBuilder(TypeBuilder):
return StructureVariant(core.BNGetStructureBuilderType(self.builder_handle))
@type.setter
- def type(self, value:StructureVariant) -> None:
+ def type(self, value: StructureVariant) -> None:
core.BNSetStructureBuilderType(self.builder_handle, value)
- def __getitem__(self, name:str) -> Optional[StructureMember]:
+ def __getitem__(self, name: str) -> Optional[StructureMember]:
member = core.BNGetStructureBuilderMemberByName(self.builder_handle, name)
if member is None:
return None
try:
- return StructureMember(Type(core.BNNewTypeReference(member.contents.type),
- confidence=member.contents.typeConfidence), member.contents.name, member.contents.offset,
- MemberAccess(member.contents.access), MemberScope(member.contents.scope))
+ return StructureMember(
+ Type(core.BNNewTypeReference(member.contents.type), confidence=member.contents.typeConfidence),
+ member.contents.name, member.contents.offset, MemberAccess(member.contents.access),
+ MemberScope(member.contents.scope)
+ )
finally:
core.BNFreeStructureMember(member)
@@ -1079,55 +1142,63 @@ class StructureBuilder(TypeBuilder):
def __len__(self) -> int:
return self.width
- def member_at_offset(self, offset:int) -> Optional[StructureMember]:
+ def member_at_offset(self, offset: int) -> Optional[StructureMember]:
for member in self.members:
if member.offset == offset:
return member
return None
- def index_by_name(self, name:MemberName) -> Optional[MemberIndex]:
+ def index_by_name(self, name: MemberName) -> Optional[MemberIndex]:
for i, member in enumerate(self.members):
if member.name == name:
return i
return None
- def index_by_offset(self, offset:MemberOffset) -> Optional[MemberIndex]:
+ def index_by_offset(self, offset: MemberOffset) -> Optional[MemberIndex]:
for i, member in enumerate(self.members):
if member.offset == offset:
return i
return None
- def replace(self, index:int, type:SomeType, name:str="", overwrite_existing:bool=True):
- core.BNReplaceStructureBuilderMember(self.builder_handle, index,
- type._to_core_struct(), name, overwrite_existing)
+ def replace(self, index: int, type: SomeType, name: str = "", overwrite_existing: bool = True):
+ core.BNReplaceStructureBuilderMember(
+ self.builder_handle, index, type._to_core_struct(), name, overwrite_existing
+ )
- def remove(self, index:int):
+ def remove(self, index: int):
core.BNRemoveStructureBuilderMember(self.builder_handle, index)
- def insert(self, offset:int, type:SomeType, name:str="", overwrite_existing:bool=True,
- access:MemberAccess=MemberAccess.NoAccess, scope:MemberScope=MemberScope.NoScope):
- core.BNAddStructureBuilderMemberAtOffset(self.builder_handle,
- type._to_core_struct(), name, offset, overwrite_existing, access, scope)
+ def insert(
+ self, offset: int, type: SomeType, name: str = "", overwrite_existing: bool = True,
+ access: MemberAccess = MemberAccess.NoAccess, scope: MemberScope = MemberScope.NoScope
+ ):
+ core.BNAddStructureBuilderMemberAtOffset(
+ self.builder_handle, type._to_core_struct(), name, offset, overwrite_existing, access, scope
+ )
- def append(self, type:SomeType, name:MemberName="", access:MemberAccess=MemberAccess.NoAccess,
- scope:MemberScope=MemberScope.NoScope) -> 'StructureBuilder':
+ def append(
+ self, type: SomeType, name: MemberName = "", access: MemberAccess = MemberAccess.NoAccess,
+ scope: MemberScope = MemberScope.NoScope
+ ) -> 'StructureBuilder':
# appends a member at the end of the structure growing the structure
- core.BNAddStructureBuilderMember(self.builder_handle,
- type._to_core_struct(), name, access, scope)
+ core.BNAddStructureBuilderMember(self.builder_handle, type._to_core_struct(), name, access, scope)
return self
- def add_member_at_offset(self, name:MemberName, type:SomeType, offset:MemberOffset, overwrite_existing:bool=True,
- access:MemberAccess=MemberAccess.NoAccess, scope:MemberScope=MemberScope.NoScope) -> 'StructureBuilder':
+ def add_member_at_offset(
+ self, name: MemberName, type: SomeType, offset: MemberOffset, overwrite_existing: bool = True,
+ access: MemberAccess = MemberAccess.NoAccess, scope: MemberScope = MemberScope.NoScope
+ ) -> 'StructureBuilder':
# Adds structure member to the given offset optionally clearing any members within the range offset-offset+len(type)
- core.BNAddStructureBuilderMemberAtOffset(self.builder_handle, type._to_core_struct(), name,
- offset, overwrite_existing, access, scope)
+ core.BNAddStructureBuilderMemberAtOffset(
+ self.builder_handle, type._to_core_struct(), name, offset, overwrite_existing, access, scope
+ )
return self
@dataclass(frozen=True)
class EnumerationMember:
- name:str
- value:Optional[int] = None
+ name: str
+ value: Optional[int] = None
def __repr__(self):
value = f"{self.value:#x}" if self.value is not None else "auto()"
@@ -1138,16 +1209,20 @@ class EnumerationMember:
class EnumerationBuilder(TypeBuilder):
- def __init__(self, handle:core.BNTypeBuilderHandle, enum_builder_handle:core.BNEnumerationBuilderHandle,
- platform:'_platform.Platform'=None, confidence:int=core.max_confidence):
+ def __init__(
+ self, handle: core.BNTypeBuilderHandle, enum_builder_handle: core.BNEnumerationBuilderHandle,
+ platform: '_platform.Platform' = None, confidence: int = core.max_confidence
+ ):
super(EnumerationBuilder, self).__init__(handle, platform, confidence)
assert isinstance(enum_builder_handle, core.BNEnumerationBuilderHandle)
self.enum_builder_handle = enum_builder_handle
@classmethod
- def create(cls, members:Optional[List[EnumMembersType]]=None, width:Optional[int]=None,
- arch:Optional['architecture.Architecture']=None, sign:BoolWithConfidenceType=False,
- platform:'_platform.Platform'=None, confidence:int=core.max_confidence) -> 'EnumerationBuilder':
+ def create(
+ cls, members: Optional[List[EnumMembersType]] = None, width: Optional[int] = None,
+ arch: Optional['architecture.Architecture'] = None, sign: BoolWithConfidenceType = False,
+ platform: '_platform.Platform' = None, confidence: int = core.max_confidence
+ ) -> 'EnumerationBuilder':
if members is None:
members = []
@@ -1182,19 +1257,21 @@ class EnumerationBuilder(TypeBuilder):
result = []
try:
for i in range(count.value):
- result.append(EnumerationMember(members[i].name, members[i].value if not members[i].isDefault else None))
+ result.append(
+ EnumerationMember(members[i].name, members[i].value if not members[i].isDefault else None)
+ )
return result
finally:
core.BNFreeEnumerationMemberList(members, count.value)
@members.setter
- def members(self, members:List[EnumMembersType]) -> None: # type: ignore
+ def members(self, members: List[EnumMembersType]) -> None: # type: ignore
for i in reversed(range(len(self.members))):
self.remove(i)
EnumerationBuilder._add_members(self.enum_builder_handle, members)
@staticmethod
- def _add_members(enum_builder_handle, members:List[EnumMembersType]):
+ def _add_members(enum_builder_handle, members: List[EnumMembersType]):
for i, member in enumerate(members):
value = None
if isinstance(member, Tuple):
@@ -1210,16 +1287,15 @@ class EnumerationBuilder(TypeBuilder):
else:
core.BNAddEnumerationBuilderMemberWithValue(enum_builder_handle, name, value)
-
- def append(self, name:str, value:Optional[int]=None) -> 'EnumerationBuilder':
+ def append(self, name: str, value: Optional[int] = None) -> 'EnumerationBuilder':
EnumerationBuilder._add_members(self.enum_builder_handle, [EnumerationMember(name, value)])
return self
- def remove(self, i:int) -> 'EnumerationBuilder':
+ def remove(self, i: int) -> 'EnumerationBuilder':
core.BNRemoveEnumerationBuilderMember(self.enum_builder_handle, i)
return self
- def replace(self, i:int, name:str, value:Optional[int]=None) -> 'EnumerationBuilder':
+ def replace(self, i: int, name: str, value: Optional[int] = None) -> 'EnumerationBuilder':
core.BNReplaceEnumerationBuilderMember(self.enum_builder_handle, i, name, value)
return self
@@ -1227,7 +1303,7 @@ class EnumerationBuilder(TypeBuilder):
for member in self.members:
yield member
- def __getitem__(self, value:Union[str, int, slice]):
+ def __getitem__(self, value: Union[str, int, slice]):
if isinstance(value, str):
for member in self.members:
if member.name == value:
@@ -1240,7 +1316,7 @@ class EnumerationBuilder(TypeBuilder):
else:
raise ValueError(f"Incompatible type {type(value)} for __getitem__")
- def __setitem__(self, item:Union[str, int], value:Union[Optional[int], EnumerationMember]):
+ def __setitem__(self, item: Union[str, int], value: Union[Optional[int], EnumerationMember]):
if isinstance(item, str):
for i, member in enumerate(self.members):
if member.name == item:
@@ -1252,25 +1328,33 @@ class EnumerationBuilder(TypeBuilder):
class NamedTypeReferenceBuilder(TypeBuilder):
- def __init__(self, handle:core.BNTypeBuilderHandle, ntr_builder_handle:core.BNNamedTypeReferenceBuilderHandle,
- platform:'_platform.Platform'=None, confidence:int=core.max_confidence):
+ def __init__(
+ self, handle: core.BNTypeBuilderHandle, ntr_builder_handle: core.BNNamedTypeReferenceBuilderHandle,
+ platform: '_platform.Platform' = None, confidence: int = core.max_confidence
+ ):
assert ntr_builder_handle is not None, "Failed to construct NameTypeReference"
assert handle is not None, "Failed to construct NameTypeReference"
- assert isinstance(ntr_builder_handle, core.BNNamedTypeReferenceBuilderHandle), "Failed to construct NameTypeReference"
+ assert isinstance(
+ ntr_builder_handle, core.BNNamedTypeReferenceBuilderHandle
+ ), "Failed to construct NameTypeReference"
super(NamedTypeReferenceBuilder, self).__init__(handle, platform, confidence)
self.ntr_builder_handle = ntr_builder_handle
@classmethod
- def create(cls, type_class:NamedTypeReferenceClass=NamedTypeReferenceClass.UnknownNamedTypeClass,
- type_id:Optional[str]=None, name:QualifiedName=QualifiedName(""), width:int=0, align:int=1,
- platform:'_platform.Platform'=None, confidence:int=core.max_confidence,
- const:BoolWithConfidenceType=False, volatile:BoolWithConfidenceType=False) -> 'NamedTypeReferenceBuilder':
+ def create(
+ cls, type_class: NamedTypeReferenceClass = NamedTypeReferenceClass.UnknownNamedTypeClass,
+ type_id: Optional[str] = None, name: QualifiedName = QualifiedName(""), width: int = 0, align: int = 1,
+ platform: '_platform.Platform' = None, confidence: int = core.max_confidence,
+ const: BoolWithConfidenceType = False, volatile: BoolWithConfidenceType = False
+ ) -> 'NamedTypeReferenceBuilder':
ntr_builder_handle = core.BNCreateNamedTypeBuilder(type_class, type_id, QualifiedName(name)._to_core_struct())
assert ntr_builder_handle is not None, "core.BNCreateNamedTypeBuilder returned None"
_const = BoolWithConfidence.get_core_struct(const)
_volatile = BoolWithConfidence.get_core_struct(volatile)
- type_builder_handle = core.BNCreateNamedTypeReferenceBuilderWithBuilder(ntr_builder_handle, width, align, _const, _volatile)
+ type_builder_handle = core.BNCreateNamedTypeReferenceBuilderWithBuilder(
+ ntr_builder_handle, width, align, _const, _volatile
+ )
assert type_builder_handle is not None, "core.BNCreateNamedTypeReferenceBuilderWithBuilder returned None"
return cls(type_builder_handle, ntr_builder_handle, platform, confidence)
@@ -1302,14 +1386,20 @@ class NamedTypeReferenceBuilder(TypeBuilder):
return NamedTypeReferenceClass(core.BNGetTypeReferenceBuilderClass(self.ntr_builder_handle))
@staticmethod
- def named_type(named_type:'NamedTypeReferenceBuilder', width:int=0, align:int=1,
- const:BoolWithConfidenceType=BoolWithConfidence(False),
- volatile:BoolWithConfidenceType=BoolWithConfidence(False)) -> 'NamedTypeReferenceBuilder':
- return NamedTypeReferenceBuilder.create(named_type.named_type_class, named_type.id,
- named_type.name, width, align, None, core.max_confidence, const, volatile)
+ def named_type(
+ named_type: 'NamedTypeReferenceBuilder', width: int = 0, align: int = 1,
+ const: BoolWithConfidenceType = BoolWithConfidence(False),
+ volatile: BoolWithConfidenceType = BoolWithConfidence(False)
+ ) -> 'NamedTypeReferenceBuilder':
+ return NamedTypeReferenceBuilder.create(
+ named_type.named_type_class, named_type.id, named_type.name, width, align, None, core.max_confidence, const,
+ volatile
+ )
@staticmethod
- def named_type_from_type_and_id(type_id:str, name:QualifiedName, type:Optional['Type']=None) -> 'NamedTypeReferenceBuilder':
+ def named_type_from_type_and_id(
+ type_id: str, name: QualifiedName, type: Optional['Type'] = None
+ ) -> 'NamedTypeReferenceBuilder':
if type is None:
return NamedTypeReferenceBuilder.create(NamedTypeReferenceClass.UnknownNamedTypeClass, type_id, name)
elif type.type_class == TypeClass.StructureTypeClass:
@@ -1325,14 +1415,20 @@ class NamedTypeReferenceBuilder(TypeBuilder):
return NamedTypeReferenceBuilder.create(NamedTypeReferenceClass.TypedefNamedTypeClass, type_id, name)
@staticmethod
- def named_type_from_type(name:QualifiedName, type_class:Optional[NamedTypeReferenceClass]=None) -> 'NamedTypeReferenceBuilder':
+ def named_type_from_type(
+ name: QualifiedName, type_class: Optional[NamedTypeReferenceClass] = None
+ ) -> 'NamedTypeReferenceBuilder':
if type_class is None:
- return NamedTypeReferenceBuilder.create(NamedTypeReferenceClass.UnknownNamedTypeClass, str(uuid.uuid4()), name)
+ return NamedTypeReferenceBuilder.create(
+ NamedTypeReferenceClass.UnknownNamedTypeClass, str(uuid.uuid4()), name
+ )
else:
return NamedTypeReferenceBuilder.create(type_class, str(uuid.uuid4()), name)
@staticmethod
- def named_type_from_registered_type(view:'binaryview.BinaryView', name:QualifiedName) -> 'NamedTypeReferenceBuilder':
+ def named_type_from_registered_type(
+ view: 'binaryview.BinaryView', name: QualifiedName
+ ) -> 'NamedTypeReferenceBuilder':
type = view.get_type_by_name(name)
if type is None:
raise ValueError(f"Unable to find type named {name}")
@@ -1365,14 +1461,16 @@ class Type:
:py:meth:`parse_types_from_source_file <platform.Platform.parse_types_from_source_file>`
"""
- def __init__(self, handle, platform:'_platform.Platform'=None, confidence:int=core.max_confidence):
+ def __init__(self, handle, platform: '_platform.Platform' = None, confidence: int = core.max_confidence):
assert isinstance(handle.contents, core.BNType), "Attempting to create mutable Type"
self._handle = handle
self._confidence = confidence
self._platform = platform
@classmethod
- def create(cls, handle=core.BNTypeHandle, platform:'_platform.Platform'=None, confidence:int=core.max_confidence) -> 'Type':
+ def create(
+ cls, handle=core.BNTypeHandle, platform: '_platform.Platform' = None, confidence: int = core.max_confidence
+ ) -> 'Type':
assert handle is not None, "Passed a handle which is None"
assert isinstance(handle, core.BNTypeHandle)
type_class = TypeClass(core.BNGetTypeClass(handle))
@@ -1458,7 +1556,7 @@ class Type:
"""Type string as a list of tokens (read-only)"""
return self.get_tokens()
- def get_tokens(self, base_confidence = core.max_confidence) -> List['_function.InstructionTextToken']:
+ def get_tokens(self, base_confidence=core.max_confidence) -> List['_function.InstructionTextToken']:
count = ctypes.c_ulonglong()
platform = None
if self._platform is not None:
@@ -1470,7 +1568,7 @@ class Type:
core.BNFreeInstructionText(tokens, count.value)
return result
- def get_tokens_before_name(self, base_confidence = core.max_confidence) -> List['_function.InstructionTextToken']:
+ def get_tokens_before_name(self, base_confidence=core.max_confidence) -> List['_function.InstructionTextToken']:
count = ctypes.c_ulonglong()
platform = None
if self._platform is not None:
@@ -1481,7 +1579,7 @@ class Type:
core.BNFreeInstructionText(tokens, count.value)
return result
- def get_tokens_after_name(self, base_confidence = core.max_confidence) -> List['_function.InstructionTextToken']:
+ def get_tokens_after_name(self, base_confidence=core.max_confidence) -> List['_function.InstructionTextToken']:
count = ctypes.c_ulonglong()
platform = None
if self._platform is not None:
@@ -1493,14 +1591,14 @@ class Type:
return result
def with_confidence(self, confidence) -> 'Type':
- return Type.create(handle = core.BNNewTypeReference(self._handle), platform = self._platform, confidence = confidence)
+ return Type.create(handle=core.BNNewTypeReference(self._handle), platform=self._platform, confidence=confidence)
@property
def confidence(self) -> _int:
return self._confidence
@confidence.setter
- def confidence(self, value:_int) -> None:
+ def confidence(self, value: _int) -> None:
self._confidence = value
@property
@@ -1508,22 +1606,18 @@ class Type:
return self._platform
@platform.setter
- def platform(self, value:'_platform.Platform') -> None:
+ def platform(self, value: '_platform.Platform') -> None:
self._platform = value
def mutable_copy(self) -> 'TypeBuilder':
TypeBuilders = {
- TypeClass.VoidTypeClass:VoidBuilder,
- TypeClass.BoolTypeClass:BoolBuilder,
- TypeClass.IntegerTypeClass:IntegerBuilder,
- TypeClass.FloatTypeClass:FloatBuilder,
- TypeClass.PointerTypeClass:PointerBuilder,
- TypeClass.ArrayTypeClass:ArrayBuilder,
- TypeClass.FunctionTypeClass:FunctionBuilder,
- TypeClass.WideCharTypeClass:WideCharBuilder,
- # TypeClass.StructureTypeClass:Structure,
- # TypeClass.EnumerationTypeClass:Enumeration,
- # TypeClass.NamedTypeReferenceClass:NamedTypeReference,
+ TypeClass.VoidTypeClass: VoidBuilder, TypeClass.BoolTypeClass: BoolBuilder,
+ TypeClass.IntegerTypeClass: IntegerBuilder, TypeClass.FloatTypeClass: FloatBuilder,
+ TypeClass.PointerTypeClass: PointerBuilder, TypeClass.ArrayTypeClass: ArrayBuilder,
+ TypeClass.FunctionTypeClass: FunctionBuilder, TypeClass.WideCharTypeClass: WideCharBuilder,
+ # TypeClass.StructureTypeClass:Structure,
+ # TypeClass.EnumerationTypeClass:Enumeration,
+ # TypeClass.NamedTypeReferenceClass:NamedTypeReference,
}
builder_handle = core.BNCreateTypeBuilderFromType(self._handle)
assert builder_handle is not None, "core.BNCreateTypeBuilderFromType returned None"
@@ -1532,12 +1626,14 @@ class Type:
def immutable_copy(self) -> 'Type':
return self
- def get_builder(self, bv:'binaryview.BinaryView') -> 'MutableTypeBuilder':
+ def get_builder(self, bv: 'binaryview.BinaryView') -> 'MutableTypeBuilder':
return MutableTypeBuilder(self.mutable_copy(), bv, self.registered_name, self.platform, self._confidence)
@staticmethod
- def builder(bv:'binaryview.BinaryView', name:Optional[QualifiedName]=None, id:Optional[str]=None,
- platform:'_platform.Platform'=None, confidence:int=core.max_confidence) -> 'MutableTypeBuilder':
+ def builder(
+ bv: 'binaryview.BinaryView', name: Optional[QualifiedName] = None, id: Optional[str] = None,
+ platform: '_platform.Platform' = None, confidence: int = core.max_confidence
+ ) -> 'MutableTypeBuilder':
type = None
if name is None and id is None:
raise ValueError("Must specify either a name or id to create a builder object")
@@ -1560,13 +1656,15 @@ class Type:
return MutableTypeBuilder(type.mutable_copy(), bv, name, platform, confidence)
def with_replaced_structure(self, from_struct, to_struct):
- return Type.create(handle = core.BNTypeWithReplacedStructure(self._handle, from_struct.handle, to_struct.handle))
+ return Type.create(handle=core.BNTypeWithReplacedStructure(self._handle, from_struct.handle, to_struct.handle))
def with_replaced_enumeration(self, from_enum, to_enum):
- return Type.create(handle = core.BNTypeWithReplacedEnumeration(self._handle, from_enum.handle, to_enum.handle))
+ return Type.create(handle=core.BNTypeWithReplacedEnumeration(self._handle, from_enum.handle, to_enum.handle))
def with_replaced_named_type_reference(self, from_ref, to_ref):
- return Type.create(handle = core.BNTypeWithReplacedNamedTypeReference(self._handle, from_ref.handle, to_ref.handle))
+ return Type.create(
+ handle=core.BNTypeWithReplacedNamedTypeReference(self._handle, from_ref.handle, to_ref.handle)
+ )
@staticmethod
def void() -> 'VoidType':
@@ -1577,11 +1675,11 @@ class Type:
return BoolType.create()
@staticmethod
- def char(alternate_name:str="") -> 'CharType':
+ def char(alternate_name: str = "") -> 'CharType':
return CharType.create(alternate_name)
@staticmethod
- def int(width:_int, sign:BoolWithConfidenceType=True, alternate_name:str="") -> 'IntegerType':
+ def int(width: _int, sign: BoolWithConfidenceType = True, alternate_name: str = "") -> 'IntegerType':
"""
``int`` class method for creating an int Type.
:param int width: width of the integer in bytes
@@ -1591,7 +1689,7 @@ class Type:
return IntegerType.create(width, sign, alternate_name)
@staticmethod
- def float(width:_int, alternate_name:str="") -> 'FloatType':
+ def float(width: _int, alternate_name: str = "") -> 'FloatType':
"""
``float`` class method for creating floating point Types.
:param int width: width of the floating point number in bytes
@@ -1600,7 +1698,7 @@ class Type:
return FloatType.create(width, alternate_name)
@staticmethod
- def wide_char(width:_int, alternate_name:str="") -> 'WideCharType':
+ def wide_char(width: _int, alternate_name: str = "") -> 'WideCharType':
"""
``wide_char`` class method for creating wide char Types.
:param int width: width of the wide character in bytes
@@ -1609,42 +1707,47 @@ class Type:
return WideCharType.create(width=width, alternate_name=alternate_name)
@staticmethod
- def structure_type(structure:'StructureBuilder') -> 'StructureType':
+ def structure_type(structure: 'StructureBuilder') -> 'StructureType':
result = structure.immutable_copy()
assert isinstance(result, StructureType)
return result
@staticmethod
- def named_type(named_type:'NamedTypeReferenceBuilder') -> 'NamedTypeReferenceType':
+ def named_type(named_type: 'NamedTypeReferenceBuilder') -> 'NamedTypeReferenceType':
result = named_type.immutable_copy()
assert isinstance(result, NamedTypeReferenceType)
return result
@staticmethod
- def named_type_from_type(name:QualifiedName, type:'Type') -> 'NamedTypeReferenceType':
+ def named_type_from_type(name: QualifiedName, type: 'Type') -> 'NamedTypeReferenceType':
return NamedTypeReferenceType.create_from_type(name, type)
@staticmethod
- def named_type_from_type_and_id(type_id:str, name:QualifiedName, type:Optional['Type']=None) -> 'NamedTypeReferenceType':
+ def named_type_from_type_and_id(
+ type_id: str, name: QualifiedName, type: Optional['Type'] = None
+ ) -> 'NamedTypeReferenceType':
return NamedTypeReferenceType.create_from_type(name, type, type_id)
@staticmethod
- def generate_named_type_reference(guid:str, name:QualifiedName) -> 'NamedTypeReferenceType':
+ def generate_named_type_reference(guid: str, name: QualifiedName) -> 'NamedTypeReferenceType':
return NamedTypeReferenceType.create(NamedTypeReferenceClass.TypedefNamedTypeClass, guid, name)
@staticmethod
- def named_type_from_registered_type(view:'binaryview.BinaryView', name:QualifiedName) -> 'NamedTypeReferenceType':
+ def named_type_from_registered_type(view: 'binaryview.BinaryView', name: QualifiedName) -> 'NamedTypeReferenceType':
return NamedTypeReferenceType.create_from_registered_type(view, name)
@staticmethod
- def enumeration_type(arch, enum:'EnumerationBuilder', width:_int=None, sign:_bool=False) -> 'EnumerationType':
+ def enumeration_type(
+ arch, enum: 'EnumerationBuilder', width: _int = None, sign: _bool = False
+ ) -> 'EnumerationType':
return EnumerationType.create(enum.members, enum.width, arch, enum.signed)
@staticmethod
- def pointer(arch:'architecture.Architecture', type:'Type',
- const:BoolWithConfidenceType=BoolWithConfidence(False),
- volatile:BoolWithConfidenceType=BoolWithConfidence(False),
- ref_type:ReferenceType=ReferenceType.PointerReferenceType, width:_int=None) -> 'PointerType':
+ def pointer(
+ arch: 'architecture.Architecture', type: 'Type', const: BoolWithConfidenceType = BoolWithConfidence(False),
+ volatile: BoolWithConfidenceType = BoolWithConfidence(False),
+ ref_type: ReferenceType = ReferenceType.PointerReferenceType, width: _int = None
+ ) -> 'PointerType':
if arch is not None:
width = arch.address_size
@@ -1654,20 +1757,23 @@ class Type:
return PointerType.create_with_width(width, type, const, volatile, ref_type)
@staticmethod
- def pointer_of_width(width:_int, type:'Type',
- const:BoolWithConfidenceType=False,
- volatile:BoolWithConfidenceType=False,
- ref_type:ReferenceType=ReferenceType.PointerReferenceType) -> 'PointerType':
+ def pointer_of_width(
+ width: _int, type: 'Type', const: BoolWithConfidenceType = False, volatile: BoolWithConfidenceType = False,
+ ref_type: ReferenceType = ReferenceType.PointerReferenceType
+ ) -> 'PointerType':
return PointerType.create_with_width(width, type, const, volatile, ref_type)
@staticmethod
- def array(type:'Type', count:_int) -> 'ArrayType':
+ def array(type: 'Type', count: _int) -> 'ArrayType':
return ArrayType.create(type, count)
@staticmethod
- def function(ret:Optional['Type']=None, params:Optional[ParamsType]=None, calling_convention:'callingconvention.CallingConvention'=None,
- variable_arguments:BoolWithConfidenceType=False,
- stack_adjust:OffsetWithConfidence=OffsetWithConfidence(0)) -> 'FunctionType':
+ def function(
+ ret: Optional['Type'] = None, params: Optional[ParamsType] = None,
+ calling_convention: 'callingconvention.CallingConvention' = None,
+ variable_arguments: BoolWithConfidenceType = False,
+ stack_adjust: OffsetWithConfidence = OffsetWithConfidence(0)
+ ) -> 'FunctionType':
"""
``function`` class method for creating an function Type.
:param Type ret: return Type of the function
@@ -1679,35 +1785,42 @@ class Type:
return FunctionType.create(ret, params, calling_convention, variable_arguments, stack_adjust)
@staticmethod
- def from_core_struct(core_type:core.BNType):
+ def from_core_struct(core_type: core.BNType):
return Type.create(core.BNNewTypeReference(core_type))
@staticmethod
- def structure(members:MembersType=None, packed:_bool=False, type:StructureVariant=StructureVariant.StructStructureType) -> 'StructureType':
+ def structure(
+ members: MembersType = None, packed: _bool = False,
+ type: StructureVariant = StructureVariant.StructStructureType
+ ) -> 'StructureType':
return StructureType.create(members, packed, type)
-
+
@staticmethod
- def union(members:Optional[MembersType]=None, packed:_bool=False) -> 'StructureType':
+ def union(members: Optional[MembersType] = None, packed: _bool = False) -> 'StructureType':
return StructureType.create(members, type=StructureVariant.UnionStructureType, packed=packed)
-
+
@staticmethod
- def class_type(members:Optional[MembersType]=None, packed:_bool=False) -> 'StructureType':
+ def class_type(members: Optional[MembersType] = None, packed: _bool = False) -> 'StructureType':
return StructureType.create(members, type=StructureVariant.ClassStructureType, packed=packed)
@staticmethod
- def enumeration(arch:Optional['architecture.Architecture']=None, members:Optional[List[EnumMembersType]]=None,
- width:Optional[_int]=None, sign:BoolWithConfidenceType=False) -> 'EnumerationType':
+ def enumeration(
+ arch: Optional['architecture.Architecture'] = None, members: Optional[List[EnumMembersType]] = None,
+ width: Optional[_int] = None, sign: BoolWithConfidenceType = False
+ ) -> 'EnumerationType':
if members is None:
members = []
return EnumerationType.create(members, width, arch, sign)
@staticmethod
- def named_type_reference(type_class:NamedTypeReferenceClass, name:QualifiedName,
- type_id:Optional[str]=None, alignment:_int=1, width:_int=0,
- const:BoolWithConfidenceType=BoolWithConfidence(False),
- volatile:BoolWithConfidenceType=BoolWithConfidence(False)):
- return NamedTypeReferenceType.create(type_class, type_id, name, alignment, width,
- None, core.max_confidence, const, volatile)
+ def named_type_reference(
+ type_class: NamedTypeReferenceClass, name: QualifiedName, type_id: Optional[str] = None, alignment: _int = 1,
+ width: _int = 0, const: BoolWithConfidenceType = BoolWithConfidence(False),
+ volatile: BoolWithConfidenceType = BoolWithConfidence(False)
+ ):
+ return NamedTypeReferenceType.create(
+ type_class, type_id, name, alignment, width, None, core.max_confidence, const, volatile
+ )
@property
@abstractmethod
@@ -1715,12 +1828,12 @@ class Type:
raise NotImplementedError("Name not implemented for this type")
@staticmethod
- def generate_auto_type_id(source:str, name:str) -> str:
+ def generate_auto_type_id(source: str, name: str) -> str:
_name = QualifiedName(name)._to_core_struct()
return core.BNGenerateAutoTypeId(source, _name)
@staticmethod
- def generate_auto_demangled_type_id(name:str) -> str:
+ def generate_auto_demangled_type_id(name: str) -> str:
_name = QualifiedName(name)._to_core_struct()
return core.BNGenerateAutoDemangledTypeId(_name)
@@ -1740,13 +1853,13 @@ class Type:
def const(self):
"""Whether type is const (read/write)"""
result = core.BNIsTypeConst(self._handle)
- return BoolWithConfidence(result.value, confidence = result.confidence)
+ return BoolWithConfidence(result.value, confidence=result.confidence)
@property
def volatile(self):
"""Whether type is volatile (read/write)"""
result = core.BNIsTypeVolatile(self._handle)
- return BoolWithConfidence(result.value, confidence = result.confidence)
+ return BoolWithConfidence(result.value, confidence=result.confidence)
@property
def system_call_number(self) -> Optional[_int]:
@@ -1758,8 +1871,8 @@ class Type:
@dataclass(frozen=True)
class RegisterStackAdjustmentWithConfidence:
- value:int
- confidence:int=core.max_confidence
+ value: int
+ confidence: int = core.max_confidence
def __int__(self):
return self.value
@@ -1767,7 +1880,7 @@ class RegisterStackAdjustmentWithConfidence:
class VoidType(Type):
@classmethod
- def create(cls, platform:'_platform.Platform'=None, confidence:int=core.max_confidence) -> 'VoidType':
+ def create(cls, platform: '_platform.Platform' = None, confidence: int = core.max_confidence) -> 'VoidType':
core_void = core.BNCreateVoidType()
assert core_void is not None, "core.BNCreateVoidType returned None"
return cls(core.BNNewTypeReference(core_void), platform, confidence)
@@ -1775,19 +1888,21 @@ class VoidType(Type):
class BoolType(Type):
@classmethod
- def create(cls, platform:'_platform.Platform'=None, confidence:int=core.max_confidence) -> 'BoolType':
+ def create(cls, platform: '_platform.Platform' = None, confidence: int = core.max_confidence) -> 'BoolType':
handle = core.BNCreateBoolType()
assert handle is not None, "core.BNCreateBoolType returned None"
return cls(core.BNNewTypeReference(handle), platform, confidence)
class IntegerType(Type):
- def __init__(self, handle, platform:'_platform.Platform'=None, confidence:int=core.max_confidence):
+ def __init__(self, handle, platform: '_platform.Platform' = None, confidence: int = core.max_confidence):
super(IntegerType, self).__init__(handle, platform, confidence)
@classmethod
- def create(cls, width:int, sign:BoolWithConfidenceType=True, alternate_name:str="",
- platform:'_platform.Platform'=None, confidence:int=core.max_confidence) -> 'IntegerType':
+ def create(
+ cls, width: int, sign: BoolWithConfidenceType = True, alternate_name: str = "",
+ platform: '_platform.Platform' = None, confidence: int = core.max_confidence
+ ) -> 'IntegerType':
_sign = BoolWithConfidence.get_core_struct(sign)
handle = core.BNCreateIntegerType(width, _sign, alternate_name)
assert handle is not None, "core.BNCreateIntegerType returned None"
@@ -1801,14 +1916,17 @@ class IntegerType(Type):
class CharType(IntegerType):
@classmethod
- def create(cls, altname:str="char", platform:'_platform.Platform'=None,
- confidence:int=core.max_confidence) -> 'CharType':
+ def create(
+ cls, altname: str = "char", platform: '_platform.Platform' = None, confidence: int = core.max_confidence
+ ) -> 'CharType':
return cls(IntegerType.create(1, True, altname).handle, platform, confidence)
class FloatType(Type):
@classmethod
- def create(cls, width:int, altname:str="", platform:'_platform.Platform'=None, confidence:int=core.max_confidence) -> 'FloatType':
+ def create(
+ cls, width: int, altname: str = "", platform: '_platform.Platform' = None, confidence: int = core.max_confidence
+ ) -> 'FloatType':
"""
``float`` class method for creating floating point Types.
@@ -1821,7 +1939,7 @@ class FloatType(Type):
class StructureType(Type):
- def __init__(self, handle, platform:'_platform.Platform'=None, confidence:int=core.max_confidence):
+ def __init__(self, handle, platform: '_platform.Platform' = None, confidence: int = core.max_confidence):
assert handle is not None, "Attempted to create EnumerationType with handle which is None"
super(StructureType, self).__init__(handle, platform, confidence)
struct_handle = core.BNGetTypeStructure(handle)
@@ -1829,8 +1947,11 @@ class StructureType(Type):
self.struct_handle = struct_handle
@classmethod
- def create(cls, members:MembersType=None, packed:bool=False, type:StructureVariant=StructureVariant.StructStructureType,
- platform:'_platform.Platform'=None, confidence:int=core.max_confidence) -> 'StructureType':
+ def create(
+ cls, members: MembersType = None, packed: bool = False,
+ type: StructureVariant = StructureVariant.StructStructureType, platform: '_platform.Platform' = None,
+ confidence: int = core.max_confidence
+ ) -> 'StructureType':
builder = core.BNCreateStructureBuilderWithOptions(type, packed)
assert builder is not None, "core.BNCreateStructureBuilder returned None"
StructureBuilder._add_members_to_builder(builder, members)
@@ -1850,7 +1971,7 @@ class StructureType(Type):
return StructureBuilder(type_builder_handle, structure_builder_handle, self.platform, self.confidence)
@classmethod
- def from_core_struct(cls, structure:core.BNStructure) -> 'StructureType':
+ def from_core_struct(cls, structure: core.BNStructure) -> 'StructureType':
return cls(core.BNNewTypeReference(core.BNCreateStructureType(structure)))
def __del__(self):
@@ -1860,28 +1981,32 @@ class StructureType(Type):
def __hash__(self):
return hash(ctypes.addressof(self.struct_handle.contents))
- def __getitem__(self, name:str) -> StructureMember:
+ def __getitem__(self, name: str) -> StructureMember:
member = None
try:
member = core.BNGetStructureMemberByName(self.struct_handle, name)
if member is None:
raise ValueError(f"Member {name} is not part of structure")
- return StructureMember(Type.create(core.BNNewTypeReference(member.contents.type), confidence=member.contents.typeConfidence),
- member.contents.name, member.contents.offset, MemberAccess(member.contents.access),
- MemberScope(member.contents.scope))
+ return StructureMember(
+ Type.create(core.BNNewTypeReference(member.contents.type), confidence=member.contents.typeConfidence),
+ member.contents.name, member.contents.offset, MemberAccess(member.contents.access),
+ MemberScope(member.contents.scope)
+ )
finally:
if member is not None:
core.BNFreeStructureMember(member)
- def member_at_offset(self, offset:int) -> StructureMember:
+ def member_at_offset(self, offset: int) -> StructureMember:
member = None
try:
member = core.BNGetStructureMemberAtOffset(self.struct_handle, offset, None)
if member is None:
raise ValueError(f"No member exists a offset {offset}")
- return StructureMember(Type.create(core.BNNewTypeReference(member.contents.type), confidence=member.contents.typeConfidence),
- member.contents.name, member.contents.offset, MemberAccess(member.contents.access),
- MemberScope(member.contents.scope))
+ return StructureMember(
+ Type.create(core.BNNewTypeReference(member.contents.type), confidence=member.contents.typeConfidence),
+ member.contents.name, member.contents.offset, MemberAccess(member.contents.access),
+ MemberScope(member.contents.scope)
+ )
finally:
core.BNFreeStructureMember(member)
@@ -1894,9 +2019,13 @@ class StructureType(Type):
try:
result = []
for i in range(0, count.value):
- result.append(StructureMember(Type.create(core.BNNewTypeReference(members[i].type), confidence=members[i].typeConfidence),
- members[i].name, members[i].offset, MemberAccess(members[i].access),
- MemberScope(members[i].scope)))
+ result.append(
+ StructureMember(
+ Type.create(core.BNNewTypeReference(members[i].type), confidence=members[i].typeConfidence),
+ members[i].name, members[i].offset, MemberAccess(members[i].access),
+ MemberScope(members[i].scope)
+ )
+ )
finally:
core.BNFreeStructureMemberList(members, count.value)
return result
@@ -1920,27 +2049,34 @@ class StructureType(Type):
return StructureVariant(core.BNGetStructureType(self.struct_handle))
def with_replaced_structure(self, from_struct, to_struct) -> 'StructureType':
- return StructureType(core.BNStructureWithReplacedStructure(self.struct_handle, from_struct.handle, to_struct.handle))
+ return StructureType(
+ core.BNStructureWithReplacedStructure(self.struct_handle, from_struct.handle, to_struct.handle)
+ )
def with_replaced_enumeration(self, from_enum, to_enum) -> 'StructureType':
- return StructureType(core.BNStructureWithReplacedEnumeration(self.struct_handle, from_enum.handle, to_enum.handle))
+ return StructureType(
+ core.BNStructureWithReplacedEnumeration(self.struct_handle, from_enum.handle, to_enum.handle)
+ )
def with_replaced_named_type_reference(self, from_ref, to_ref) -> 'StructureType':
- return StructureType(core.BNStructureWithReplacedNamedTypeReference(self.struct_handle, from_ref.handle, to_ref.handle))
+ return StructureType(
+ core.BNStructureWithReplacedNamedTypeReference(self.struct_handle, from_ref.handle, to_ref.handle)
+ )
- def generate_named_type_reference(self, guid:str, name:QualifiedName):
+ def generate_named_type_reference(self, guid: str, name: QualifiedName):
if self.type == StructureVariant.StructStructureType:
ntr_type = NamedTypeReferenceClass.StructNamedTypeClass
elif self.type == StructureVariant.UnionStructureType:
ntr_type = NamedTypeReferenceClass.UnionNamedTypeClass
else:
ntr_type = NamedTypeReferenceClass.ClassNamedTypeClass
- return NamedTypeReferenceType.create(ntr_type, guid, name, self.alignment,
- self.width, self.platform, self.confidence)
+ return NamedTypeReferenceType.create(
+ ntr_type, guid, name, self.alignment, self.width, self.platform, self.confidence
+ )
class EnumerationType(IntegerType):
- def __init__(self, handle, platform:'_platform.Platform'=None, confidence:int=core.max_confidence):
+ def __init__(self, handle, platform: '_platform.Platform' = None, confidence: int = core.max_confidence):
assert handle is not None, "Attempted to create EnumerationType without handle"
super(EnumerationType, self).__init__(handle, platform, confidence)
enum_handle = core.BNGetTypeEnumeration(handle)
@@ -1968,9 +2104,11 @@ class EnumerationType(IntegerType):
return result
@classmethod
- def create(cls, members=List[EnumMembersType], width:Optional[int]=None,
- arch:Optional['architecture.Architecture']=None, sign:BoolWithConfidenceType=False,
- platform:'_platform.Platform'=None, confidence:int=core.max_confidence) -> 'EnumerationType':
+ def create(
+ cls, members=List[EnumMembersType], width: Optional[int] = None,
+ arch: Optional['architecture.Architecture'] = None, sign: BoolWithConfidenceType = False,
+ platform: '_platform.Platform' = None, confidence: int = core.max_confidence
+ ) -> 'EnumerationType':
if width is None:
if arch is None:
raise ValueError("One of the following parameters must not be None: (arch, width)")
@@ -1998,10 +2136,9 @@ class EnumerationType(IntegerType):
assert enumeration_builder_handle is not None, "core.BNCreateEnumerationBuilderFromEnumeration returned None"
return EnumerationBuilder(type_builder_handle, enumeration_builder_handle, self.platform, self.confidence)
- def generate_named_type_reference(self, guid:str, name:QualifiedName):
+ def generate_named_type_reference(self, guid: str, name: QualifiedName):
ntr_type = NamedTypeReferenceClass.EnumNamedTypeClass
- return NamedTypeReferenceType.create(ntr_type, guid, name,
- platform=self.platform, confidence=self.confidence)
+ return NamedTypeReferenceType.create(ntr_type, guid, name, platform=self.platform, confidence=self.confidence)
class PointerType(Type):
@@ -2010,16 +2147,19 @@ class PointerType(Type):
return ReferenceType(core.BNTypeGetReferenceType(self._handle))
@classmethod
- def create(cls, arch:'architecture.Architecture', type:SomeType, const:BoolWithConfidenceType=False,
- volatile:BoolWithConfidenceType=False, ref_type:ReferenceType=ReferenceType.PointerReferenceType,
- platform:'_platform.Platform'=None, confidence:int=core.max_confidence) -> 'PointerType':
+ def create(
+ cls, arch: 'architecture.Architecture', type: SomeType, const: BoolWithConfidenceType = False,
+ volatile: BoolWithConfidenceType = False, ref_type: ReferenceType = ReferenceType.PointerReferenceType,
+ platform: '_platform.Platform' = None, confidence: int = core.max_confidence
+ ) -> 'PointerType':
return cls.create_with_width(arch.address_size, type, const, volatile, ref_type, platform, confidence)
@staticmethod
- def from_bools(const:BoolWithConfidenceType, volatile:BoolWithConfidenceType) -> Tuple[BoolWithConfidence, BoolWithConfidence]:
+ def from_bools(const: BoolWithConfidenceType,
+ volatile: BoolWithConfidenceType) -> Tuple[BoolWithConfidence, BoolWithConfidence]:
_const = const
if const is None:
- _const = BoolWithConfidence(False, confidence = 0)
+ _const = BoolWithConfidence(False, confidence=0)
elif isinstance(const, bool):
_const = BoolWithConfidence(const)
if not isinstance(_const, BoolWithConfidence):
@@ -2027,7 +2167,7 @@ class PointerType(Type):
_volatile = volatile
if volatile is None:
- _volatile = BoolWithConfidence(False, confidence = 0)
+ _volatile = BoolWithConfidence(False, confidence=0)
elif isinstance(volatile, bool):
_volatile = BoolWithConfidence(volatile)
if not isinstance(_volatile, BoolWithConfidence):
@@ -2036,17 +2176,20 @@ class PointerType(Type):
return (_const, _volatile)
@classmethod
- def create_with_width(cls, width:int, type:SomeType, const:BoolWithConfidenceType=False,
- volatile:BoolWithConfidenceType=False, ref_type:ReferenceType=None, platform:'_platform.Platform'=None,
- confidence:int=core.max_confidence) -> 'PointerType':
+ def create_with_width(
+ cls, width: int, type: SomeType, const: BoolWithConfidenceType = False,
+ volatile: BoolWithConfidenceType = False, ref_type: ReferenceType = None, platform: '_platform.Platform' = None,
+ confidence: int = core.max_confidence
+ ) -> 'PointerType':
_const, _volatile = PointerType.from_bools(const, volatile)
type = type.immutable_copy()
if ref_type is None:
ref_type = ReferenceType.PointerReferenceType
type_conf = type._to_core_struct()
- core_type = core.BNCreatePointerTypeOfWidth(width, type_conf, _const._to_core_struct(),
- _volatile._to_core_struct(), ref_type)
+ core_type = core.BNCreatePointerTypeOfWidth(
+ width, type_conf, _const._to_core_struct(), _volatile._to_core_struct(), ref_type
+ )
assert core_type is not None, "core.BNCreatePointerTypeOfWidth returned None"
return cls(core.BNNewTypeReference(core_type), platform, confidence)
@@ -2060,7 +2203,10 @@ class PointerType(Type):
class ArrayType(Type):
@classmethod
- def create(cls, element_type:Type, count:int, platform:'_platform.Platform'=None, confidence:int=core.max_confidence) -> 'ArrayType':
+ def create(
+ cls, element_type: Type, count: int, platform: '_platform.Platform' = None,
+ confidence: int = core.max_confidence
+ ) -> 'ArrayType':
type_conf = element_type._to_core_struct()
core_array = core.BNCreateArrayType(type_conf, count)
assert core_array is not None, "core.BNCreateArrayType returned None"
@@ -2080,9 +2226,13 @@ class ArrayType(Type):
class FunctionType(Type):
@classmethod
- def create(cls, ret:Optional[Type]=None, params:ParamsType=None,
- calling_convention:'callingconvention.CallingConvention'=None, variable_arguments:BoolWithConfidenceType=BoolWithConfidence(False),
- stack_adjust:OffsetWithConfidence=OffsetWithConfidence(0), platform:'_platform.Platform'=None, confidence:int=core.max_confidence) -> 'FunctionType':
+ def create(
+ cls, ret: Optional[Type] = None, params: ParamsType = None,
+ calling_convention: 'callingconvention.CallingConvention' = None,
+ variable_arguments: BoolWithConfidenceType = BoolWithConfidence(False),
+ stack_adjust: OffsetWithConfidence = OffsetWithConfidence(0), platform: '_platform.Platform' = None,
+ confidence: int = core.max_confidence
+ ) -> 'FunctionType':
if ret is None:
ret = VoidType.create()
if params is None:
@@ -2100,8 +2250,9 @@ class FunctionType(Type):
_variable_arguments = BoolWithConfidence.get_core_struct(variable_arguments)
_stack_adjust = OffsetWithConfidence.get_core_struct(stack_adjust)
- func_type = core.BNCreateFunctionType(ret_conf, conv_conf, param_buf, len(params),
- _variable_arguments, _stack_adjust)
+ func_type = core.BNCreateFunctionType(
+ ret_conf, conv_conf, param_buf, len(params), _variable_arguments, _stack_adjust
+ )
assert func_type is not None, f"core.BNCreateFunctionType returned None {ret_conf} {conv_conf} {param_buf} {_variable_arguments} {_stack_adjust}"
return cls(core.BNNewTypeReference(func_type), platform, confidence)
@@ -2109,7 +2260,7 @@ class FunctionType(Type):
def stack_adjustment(self) -> OffsetWithConfidence:
"""Stack adjustment for function (read-only)"""
result = core.BNGetTypeStackAdjustment(self._handle)
- return OffsetWithConfidence(result.value, confidence = result.confidence)
+ return OffsetWithConfidence(result.value, confidence=result.confidence)
@property
def return_value(self) -> Type:
@@ -2117,7 +2268,7 @@ class FunctionType(Type):
result = core.BNGetChildType(self._handle)
if result is None:
return Type.void()
- return Type.create(core.BNNewTypeReference(result.type), platform = self._platform, confidence = result.confidence)
+ return Type.create(core.BNNewTypeReference(result.type), platform=self._platform, confidence=result.confidence)
@property
def calling_convention(self) -> Optional[callingconvention.CallingConvention]:
@@ -2125,7 +2276,7 @@ class FunctionType(Type):
result = core.BNGetTypeCallingConvention(self._handle)
if not result.convention:
return None
- return callingconvention.CallingConvention(None, handle = result.convention, confidence = result.confidence)
+ return callingconvention.CallingConvention(None, handle=result.convention, confidence=result.confidence)
@property
def parameters(self) -> List[FunctionParameter]:
@@ -2135,17 +2286,21 @@ class FunctionType(Type):
assert params is not None, "core.BNGetTypeParameters returned None"
result = []
for i in range(0, count.value):
- param_type = Type.create(core.BNNewTypeReference(params[i].type), platform = self._platform, confidence = params[i].typeConfidence)
+ param_type = Type.create(
+ core.BNNewTypeReference(params[i].type), platform=self._platform, confidence=params[i].typeConfidence
+ )
if params[i].defaultLocation:
param_location = None
else:
name = params[i].name
- if (params[i].location.type == VariableSourceType.RegisterVariableSourceType) and (self._platform is not None):
+ if (params[i].location.type
+ == VariableSourceType.RegisterVariableSourceType) and (self._platform is not None):
name = self._platform.arch.get_reg_name(params[i].location.storage)
elif params[i].location.type == VariableSourceType.StackVariableSourceType:
name = "arg_%x" % params[i].location.storage
- param_location = variable.VariableNameAndType(params[i].location.type, params[i].location.index,
- params[i].location.storage, name, param_type)
+ param_location = variable.VariableNameAndType(
+ params[i].location.type, params[i].location.index, params[i].location.storage, name, param_type
+ )
result.append(FunctionParameter(param_type, params[i].name, param_location))
core.BNFreeTypeParameterList(params, count.value)
return result
@@ -2154,17 +2309,19 @@ class FunctionType(Type):
def has_variable_arguments(self) -> BoolWithConfidence:
"""Whether type has variable arguments (read-only)"""
result = core.BNTypeHasVariableArguments(self._handle)
- return BoolWithConfidence(result.value, confidence = result.confidence)
+ return BoolWithConfidence(result.value, confidence=result.confidence)
@property
def can_return(self) -> BoolWithConfidence:
"""Whether type can return"""
result = core.BNFunctionTypeCanReturn(self._handle)
- return BoolWithConfidence(result.value, confidence = result.confidence)
+ return BoolWithConfidence(result.value, confidence=result.confidence)
class NamedTypeReferenceType(Type):
- def __init__(self, handle, platform:'_platform.Platform'=None, confidence:int=core.max_confidence, ntr_handle=None):
+ def __init__(
+ self, handle, platform: '_platform.Platform' = None, confidence: int = core.max_confidence, ntr_handle=None
+ ):
assert handle is not None, "Attempting to create NamedTypeReferenceType handle which is None"
super(NamedTypeReferenceType, self).__init__(handle, platform, confidence)
if ntr_handle is None:
@@ -2175,14 +2332,18 @@ class NamedTypeReferenceType(Type):
def mutable_copy(self):
type_builder_handle = core.BNCreateTypeBuilderFromType(self._handle)
assert type_builder_handle is not None, "core.BNCreateTypeBuilderFromType returned None"
- ntr_builder_handle = core.BNCreateNamedTypeBuilder(self.named_type_class, self.type_id, self.name._to_core_struct())
+ ntr_builder_handle = core.BNCreateNamedTypeBuilder(
+ self.named_type_class, self.type_id, self.name._to_core_struct()
+ )
assert ntr_builder_handle is not None, "core.BNCreateNamedTypeBuilder returned None"
return NamedTypeReferenceBuilder(type_builder_handle, ntr_builder_handle, self.platform, self.confidence)
@classmethod
- def create(cls, named_type_class:NamedTypeReferenceClass, guid:Optional[str],
- name:QualifiedName, alignment:int=0, width:int=0, platform:'_platform.Platform'=None,
- confidence:int=core.max_confidence, const:BoolWithConfidenceType=False, volatile:BoolWithConfidenceType=False) -> 'NamedTypeReferenceType':
+ def create(
+ cls, named_type_class: NamedTypeReferenceClass, guid: Optional[str], name: QualifiedName, alignment: int = 0,
+ width: int = 0, platform: '_platform.Platform' = None, confidence: int = core.max_confidence,
+ const: BoolWithConfidenceType = False, volatile: BoolWithConfidenceType = False
+ ) -> 'NamedTypeReferenceType':
_guid = guid
if guid is None:
_guid = str(uuid.uuid4())
@@ -2198,8 +2359,10 @@ class NamedTypeReferenceType(Type):
return cls(core.BNNewTypeReference(core_type), platform, confidence)
@classmethod
- def create_from_type(cls, name:QualifiedName, type:Optional[Type], guid:Optional[str]=None,
- platform:'_platform.Platform'=None, confidence:int=core.max_confidence) -> 'NamedTypeReferenceType':
+ def create_from_type(
+ cls, name: QualifiedName, type: Optional[Type], guid: Optional[str] = None,
+ platform: '_platform.Platform' = None, confidence: int = core.max_confidence
+ ) -> 'NamedTypeReferenceType':
_guid = guid
if _guid is None:
_guid = str(uuid.uuid4())
@@ -2210,8 +2373,10 @@ class NamedTypeReferenceType(Type):
return type.generate_named_type_reference(_guid, name)
@classmethod
- def create_from_registered_type(cls, view:'binaryview.BinaryView', name:QualifiedName,
- platform:'_platform.Platform'=None, confidence:int=core.max_confidence) -> 'NamedTypeReferenceType':
+ def create_from_registered_type(
+ cls, view: 'binaryview.BinaryView', name: QualifiedName, platform: '_platform.Platform' = None,
+ confidence: int = core.max_confidence
+ ) -> 'NamedTypeReferenceType':
_name = QualifiedName(name)._to_core_struct()
core_type = core.BNCreateNamedTypeReferenceFromType(view.handle, _name)
assert core_type is not None, "core.BNCreateNamedTypeReferenceFromType returned None"
@@ -2262,16 +2427,16 @@ class NamedTypeReferenceType(Type):
return result
@staticmethod
- def generate_auto_type_ref(type_class:NamedTypeReferenceClass, source:str, name:QualifiedNameType):
+ def generate_auto_type_ref(type_class: NamedTypeReferenceClass, source: str, name: QualifiedNameType):
type_id = Type.generate_auto_type_id(source, name)
return NamedTypeReferenceType.create(type_class, type_id, name)
@staticmethod
- def generate_auto_demangled_type_ref(type_class:NamedTypeReferenceClass, name:QualifiedNameType):
+ def generate_auto_demangled_type_ref(type_class: NamedTypeReferenceClass, name: QualifiedNameType):
type_id = Type.generate_auto_demangled_type_id(name)
return NamedTypeReferenceType.create(type_class, type_id, name)
- def _target_helper(self, bv:'binaryview.BinaryView', type_ids=None) -> Optional[Type]:
+ def _target_helper(self, bv: 'binaryview.BinaryView', type_ids=None) -> Optional[Type]:
t = bv.get_type_by_id(self.type_id)
if t is None:
return None
@@ -2285,7 +2450,7 @@ class NamedTypeReferenceType(Type):
else:
return t
- def target(self, bv:'binaryview.BinaryView') -> Optional[Type]:
+ def target(self, bv: 'binaryview.BinaryView') -> Optional[Type]:
"""Returns the type pointed to by the current type
:param bv: The BinaryView in which this type is defined.
@@ -2298,8 +2463,10 @@ class NamedTypeReferenceType(Type):
class WideCharType(Type):
@classmethod
- def create(cls, width:int, alternate_name:str="", platform:'_platform.Platform'=None,
- confidence:int=core.max_confidence) -> 'WideCharType':
+ def create(
+ cls, width: int, alternate_name: str = "", platform: '_platform.Platform' = None,
+ confidence: int = core.max_confidence
+ ) -> 'WideCharType':
"""
``wide_char`` class method for creating wide char Types.
@@ -2310,24 +2477,20 @@ class WideCharType(Type):
assert core_type is not None, "core.BNCreateWideCharType returned None"
return cls(core.BNNewTypeReference(core_type), platform, confidence)
+
Types = {
- TypeClass.VoidTypeClass:VoidType,
- TypeClass.BoolTypeClass:BoolType,
- TypeClass.IntegerTypeClass:IntegerType,
- TypeClass.FloatTypeClass:FloatType,
- TypeClass.StructureTypeClass:StructureType,
- TypeClass.EnumerationTypeClass:EnumerationType,
- TypeClass.PointerTypeClass:PointerType,
- TypeClass.ArrayTypeClass:ArrayType,
- TypeClass.FunctionTypeClass:FunctionType,
- TypeClass.NamedTypeReferenceClass:NamedTypeReferenceType,
- TypeClass.WideCharTypeClass:WideCharType,
+ TypeClass.VoidTypeClass: VoidType, TypeClass.BoolTypeClass: BoolType, TypeClass.IntegerTypeClass: IntegerType,
+ TypeClass.FloatTypeClass: FloatType, TypeClass.StructureTypeClass: StructureType,
+ TypeClass.EnumerationTypeClass: EnumerationType, TypeClass.PointerTypeClass: PointerType,
+ TypeClass.ArrayTypeClass: ArrayType, TypeClass.FunctionTypeClass: FunctionType,
+ TypeClass.NamedTypeReferenceClass: NamedTypeReferenceType, TypeClass.WideCharTypeClass: WideCharType,
}
+
@dataclass(frozen=True)
class RegisterSet:
- regs:List['architecture.RegisterName']
- confidence:int=core.max_confidence
+ regs: List['architecture.RegisterName']
+ confidence: int = core.max_confidence
def __iter__(self) -> Generator['architecture.RegisterName', None, None]:
for reg in self.regs:
@@ -2345,15 +2508,16 @@ class RegisterSet:
@dataclass(frozen=True)
class TypeParserResult:
- types:Mapping[QualifiedName, Type]
- variables:Mapping[QualifiedName, Type]
- functions:Mapping[QualifiedName, Type]
+ types: Mapping[QualifiedName, Type]
+ variables: Mapping[QualifiedName, Type]
+ functions: Mapping[QualifiedName, Type]
def __repr__(self):
return f"<types: {self.types}, variables: {self.variables}, functions: {self.functions}>"
-def preprocess_source(source:str, filename:str=None, include_dirs:Optional[List[str]]=None) -> Tuple[Optional[str], str]:
+def preprocess_source(source: str, filename: str = None,
+ include_dirs: Optional[List[str]] = None) -> Tuple[Optional[str], str]:
"""
``preprocess_source`` run the C preprocessor on the given source or source filename.
@@ -2393,11 +2557,11 @@ def preprocess_source(source:str, filename:str=None, include_dirs:Optional[List[
@dataclass(frozen=True)
class TypeFieldReference:
- func:Optional['_function.Function']
- arch:Optional['architecture.Architecture']
- address:int
- size:int
- incomingType:Optional[Type]
+ func: Optional['_function.Function']
+ arch: Optional['architecture.Architecture']
+ address: int
+ size: int
+ incomingType: Optional[Type]
def __repr__(self):
if self.arch:
diff --git a/python/update.py b/python/update.py
index 1c91e700..db4d66ee 100644
--- a/python/update.py
+++ b/python/update.py
@@ -28,7 +28,6 @@ from .enums import UpdateResult
from .log import log_error
-
class _UpdateChannelMetaClass(type):
def __iter__(self):
binaryninja._init_plugins()
@@ -69,7 +68,8 @@ class _UpdateChannelMetaClass(type):
class UpdateProgressCallback:
def __init__(self, func):
- self.cb = ctypes.CFUNCTYPE(ctypes.c_bool, ctypes.c_void_p, ctypes.c_ulonglong, ctypes.c_ulonglong)(self.callback)
+ self.cb = ctypes.CFUNCTYPE(ctypes.c_bool, ctypes.c_void_p, ctypes.c_ulonglong,
+ ctypes.c_ulonglong)(self.callback)
self.func = func
def callback(self, ctxt, progress, total):
@@ -85,9 +85,10 @@ class UpdateProgressCallback:
return core.BNGetActiveUpdateChannel()
@active.setter
- def active(cls, value:str) -> None:
+ def active(cls, value: str) -> None:
return core.BNSetActiveUpdateChannel(value)
+
class UpdateChannel(metaclass=_UpdateChannelMetaClass):
def __init__(self, name, desc, ver):
self._name = name
@@ -153,7 +154,7 @@ class UpdateChannel(metaclass=_UpdateChannelMetaClass):
def __str__(self):
return self._name
- def update_to_latest(self, progress = None):
+ def update_to_latest(self, progress=None):
cb = UpdateProgressCallback(progress)
errors = ctypes.c_char_p()
result = core.BNUpdateToLatestVersion(self._name, errors, cb.cb, None)
@@ -201,7 +202,7 @@ class UpdateVersion:
def __str__(self):
return self._version
- def update(self, progress = None):
+ def update(self, progress=None):
cb = UpdateProgressCallback(progress)
errors = ctypes.c_char_p()
result = core.BNUpdateToVersion(self._channel.name, self._version, errors, cb.cb, None)
diff --git a/python/variable.py b/python/variable.py
index 67dc2cac..564281c6 100644
--- a/python/variable.py
+++ b/python/variable.py
@@ -28,17 +28,16 @@ from . import _binaryninjacore as core
from . import decorators
from .enums import RegisterValueType, VariableSourceType, DeadStoreElimination, FunctionGraphType
-FunctionOrILFunction = Union["binaryninja.function.Function",
- "binaryninja.lowlevelil.LowLevelILFunction",
+FunctionOrILFunction = Union["binaryninja.function.Function", "binaryninja.lowlevelil.LowLevelILFunction",
"binaryninja.mediumlevelil.MediumLevelILFunction",
"binaryninja.highlevelil.HighLevelILFunction"]
@dataclass(frozen=True)
class LookupTableEntry:
- from_values:List[int]
- to_value:int
- type:RegisterValueType = RegisterValueType.LookupTableValue
+ from_values: List[int]
+ to_value: int
+ type: RegisterValueType = RegisterValueType.LookupTableValue
def __repr__(self):
return f"[{', '.join([f'{i:#x}' for i in self.from_values])}] -> {self.to_value:#x}"
@@ -46,10 +45,10 @@ class LookupTableEntry:
@dataclass(frozen=True)
class RegisterValue:
- value:int
- offset:int
- type:RegisterValueType = RegisterValueType.UndeterminedValue
- confidence:int=core.max_confidence
+ value: int
+ offset: int
+ type: RegisterValueType = RegisterValueType.UndeterminedValue
+ confidence: int = core.max_confidence
def _to_core_struct(self) -> core.BNRegisterValue:
result = core.BNRegisterValue()
@@ -76,13 +75,15 @@ class RegisterValue:
elif isinstance(other, bool):
return bool(self) == other
elif isinstance(other, self.__class__):
- return (self.type, self.offset, self.type, self.confidence) == \
- (other.type, other.offset, other.type, other.confidence)
+ return (self.type, self.offset, self.type,
+ self.confidence) == (other.type, other.offset, other.type, other.confidence)
assert False, f"no comparison for types {repr(self)} and {repr(other)}"
@classmethod
- def from_BNRegisterValue(cls, reg_value:Union[core.BNRegisterValue, core.BNRegisterValueWithConfidence],
- arch:Optional['binaryninja.architecture.Architecture']=None) -> 'RegisterValue':
+ def from_BNRegisterValue(
+ cls, reg_value: Union[core.BNRegisterValue, core.BNRegisterValueWithConfidence],
+ arch: Optional['binaryninja.architecture.Architecture'] = None
+ ) -> 'RegisterValue':
confidence = core.max_confidence
if isinstance(reg_value, core.BNRegisterValueWithConfidence):
confidence = reg_value.confidence
@@ -111,9 +112,9 @@ class RegisterValue:
@dataclass(frozen=True, eq=False)
class Undetermined(RegisterValue):
- value:int = 0
- offset:int = 0
- type:RegisterValueType = RegisterValueType.UndeterminedValue
+ value: int = 0
+ offset: int = 0
+ type: RegisterValueType = RegisterValueType.UndeterminedValue
def __repr__(self):
return "<undetermined>"
@@ -121,8 +122,8 @@ class Undetermined(RegisterValue):
@dataclass(frozen=True, eq=False)
class ConstantRegisterValue(RegisterValue):
- offset:int = 0
- type:RegisterValueType = RegisterValueType.ConstantValue
+ offset: int = 0
+ type: RegisterValueType = RegisterValueType.ConstantValue
def __repr__(self):
return f"<const {self.value:#x}>"
@@ -130,8 +131,8 @@ class ConstantRegisterValue(RegisterValue):
@dataclass(frozen=True, eq=False)
class ConstantPointerRegisterValue(RegisterValue):
- offset:int = 0
- type:RegisterValueType = RegisterValueType.ConstantPointerValue
+ offset: int = 0
+ type: RegisterValueType = RegisterValueType.ConstantPointerValue
def __repr__(self):
return f"<const ptr {self.value:#x}>"
@@ -139,8 +140,8 @@ class ConstantPointerRegisterValue(RegisterValue):
@dataclass(frozen=True, eq=False)
class ImportedAddressRegisterValue(RegisterValue):
- offset:int = 0
- type:RegisterValueType = RegisterValueType.ImportedAddressValue
+ offset: int = 0
+ type: RegisterValueType = RegisterValueType.ImportedAddressValue
def __repr__(self):
return f"<imported address from entry {self.value:#x}>"
@@ -148,8 +149,8 @@ class ImportedAddressRegisterValue(RegisterValue):
@dataclass(frozen=True, eq=False)
class ReturnAddressRegisterValue(RegisterValue):
- offset:int = 0
- type:RegisterValueType = RegisterValueType.ReturnAddressValue
+ offset: int = 0
+ type: RegisterValueType = RegisterValueType.ReturnAddressValue
def __repr__(self):
return "<return address>"
@@ -157,10 +158,10 @@ class ReturnAddressRegisterValue(RegisterValue):
@dataclass(frozen=True, eq=False)
class EntryRegisterValue(RegisterValue):
- value:int = 0
- offset:int = 0
- type:RegisterValueType = RegisterValueType.EntryValue
- reg:Optional['binaryninja.architecture.RegisterName'] = None
+ value: int = 0
+ offset: int = 0
+ type: RegisterValueType = RegisterValueType.EntryValue
+ reg: Optional['binaryninja.architecture.RegisterName'] = None
def __repr__(self):
if self.reg is not None:
@@ -170,15 +171,16 @@ class EntryRegisterValue(RegisterValue):
@dataclass(frozen=True, eq=False)
class StackFrameOffsetRegisterValue(RegisterValue):
- offset:int = 0
- type:RegisterValueType = RegisterValueType.StackFrameOffset
+ offset: int = 0
+ type: RegisterValueType = RegisterValueType.StackFrameOffset
def __repr__(self):
return f"<stack frame offset {self.value:#x}>"
+
@dataclass(frozen=True, eq=False)
class ExternalPointerRegisterValue(RegisterValue):
- type:RegisterValueType = RegisterValueType.ExternalPointerValue
+ type: RegisterValueType = RegisterValueType.ExternalPointerValue
def __repr__(self):
return f"<external {self.value:#x} + offset {self.offset:#x}>"
@@ -186,9 +188,9 @@ class ExternalPointerRegisterValue(RegisterValue):
@dataclass(frozen=True)
class ValueRange:
- start:int
- end:int
- step:int
+ start: int
+ end: int
+ step: int
def __repr__(self):
if self.step == 1:
@@ -208,7 +210,7 @@ class PossibleValueSet:
that a variable can take. It contains methods to instantiate different
value sets such as Constant, Signed/Unsigned Ranges, etc.
"""
- def __init__(self, arch = None, value = None):
+ def __init__(self, arch=None, value=None):
if value is None:
self._type = RegisterValueType.UndeterminedValue
return
@@ -283,9 +285,11 @@ class PossibleValueSet:
return "<undetermined>"
def __contains__(self, other):
- if self.type in [RegisterValueType.ConstantValue, RegisterValueType.ConstantPointerValue] and isinstance(other, int):
+ if self.type in [RegisterValueType.ConstantValue, RegisterValueType.ConstantPointerValue
+ ] and isinstance(other, int):
return self.value == other
- if self.type in [RegisterValueType.ConstantValue, RegisterValueType.ConstantPointerValue] and hasattr(other, "value"):
+ if self.type in [RegisterValueType.ConstantValue, RegisterValueType.ConstantPointerValue
+ ] and hasattr(other, "value"):
return self.value == other.value
if not isinstance(other, int):
return NotImplemented
@@ -304,7 +308,8 @@ class PossibleValueSet:
return NotImplemented
def __eq__(self, other):
- if self.type in [RegisterValueType.ConstantValue, RegisterValueType.ConstantPointerValue] and isinstance(other, int):
+ if self.type in [RegisterValueType.ConstantValue, RegisterValueType.ConstantPointerValue
+ ] and isinstance(other, int):
return self.value == other
if not isinstance(other, self.__class__):
return NotImplemented
@@ -431,7 +436,7 @@ class PossibleValueSet:
return PossibleValueSet()
@staticmethod
- def constant(value:int) -> 'PossibleValueSet':
+ def constant(value: int) -> 'PossibleValueSet':
"""
Create a constant valued PossibleValueSet object.
@@ -444,7 +449,7 @@ class PossibleValueSet:
return result
@staticmethod
- def constant_ptr(value:int) -> 'PossibleValueSet':
+ def constant_ptr(value: int) -> 'PossibleValueSet':
"""
Create constant pointer valued PossibleValueSet object.
@@ -457,7 +462,7 @@ class PossibleValueSet:
return result
@staticmethod
- def stack_frame_offset(offset:int) -> 'PossibleValueSet':
+ def stack_frame_offset(offset: int) -> 'PossibleValueSet':
"""
Create a PossibleValueSet object for a stack frame offset.
@@ -470,7 +475,7 @@ class PossibleValueSet:
return result
@staticmethod
- def signed_range_value(ranges:List[ValueRange]) -> 'PossibleValueSet':
+ def signed_range_value(ranges: List[ValueRange]) -> 'PossibleValueSet':
"""
Create a PossibleValueSet object for a signed range of values.
@@ -491,7 +496,7 @@ class PossibleValueSet:
return result
@staticmethod
- def unsigned_range_value(ranges:List[ValueRange]) -> 'PossibleValueSet':
+ def unsigned_range_value(ranges: List[ValueRange]) -> 'PossibleValueSet':
"""
Create a PossibleValueSet object for a unsigned signed range of values.
@@ -512,7 +517,7 @@ class PossibleValueSet:
return result
@staticmethod
- def in_set_of_values(values:Union[List[int], Set[int]]) -> 'PossibleValueSet':
+ def in_set_of_values(values: Union[List[int], Set[int]]) -> 'PossibleValueSet':
"""
Create a PossibleValueSet object for a value in a set of values.
@@ -558,12 +563,12 @@ class PossibleValueSet:
@dataclass(frozen=True)
class StackVariableReference:
- _source_operand:Optional[int]
- type:'binaryninja.types.Type'
- name:str
- var:'Variable'
- referenced_offset:int
- size:int
+ _source_operand: Optional[int]
+ type: 'binaryninja.types.Type'
+ name: str
+ var: 'Variable'
+ referenced_offset: int
+ size: int
def __repr__(self):
if self.source_operand is None:
@@ -583,9 +588,9 @@ class StackVariableReference:
@dataclass(frozen=True, order=True)
class CoreVariable:
- _source_type:int
- index:int
- storage:int
+ _source_type: int
+ index: int
+ storage: int
@property
def identifier(self) -> int:
@@ -603,7 +608,7 @@ class CoreVariable:
return v
@classmethod
- def from_BNVariable(cls, var:core.BNVariable):
+ def from_BNVariable(cls, var: core.BNVariable):
return cls(var.type, var.index, var.storage)
@classmethod
@@ -614,8 +619,8 @@ class CoreVariable:
@dataclass(frozen=True, order=True)
class VariableNameAndType(CoreVariable):
- name:str
- type:'binaryninja.types.Type'
+ name: str
+ type: 'binaryninja.types.Type'
@classmethod
def from_identifier(cls, identifier, name, type):
@@ -628,7 +633,7 @@ class VariableNameAndType(CoreVariable):
class Variable(CoreVariable):
- def __init__(self, func:FunctionOrILFunction, source_type:VariableSourceType, index:int, storage:int):
+ def __init__(self, func: FunctionOrILFunction, source_type: VariableSourceType, index: int, storage: int):
super(Variable, self).__init__(int(source_type), index, storage)
if isinstance(func, binaryninja.function.Function):
self._function = func
@@ -638,19 +643,19 @@ class Variable(CoreVariable):
self._il_function = func
@classmethod
- def from_variable_name_and_type(cls, func:FunctionOrILFunction, var:VariableNameAndType):
+ def from_variable_name_and_type(cls, func: FunctionOrILFunction, var: VariableNameAndType):
return cls(func, VariableSourceType(var.type), var.index, var.storage)
@classmethod
- def from_core_variable(cls, func:FunctionOrILFunction, var:CoreVariable):
+ def from_core_variable(cls, func: FunctionOrILFunction, var: CoreVariable):
return cls(func, var.source_type, var.index, var.storage)
@classmethod
- def from_BNVariable(cls, func:FunctionOrILFunction, var:core.BNVariable):
+ def from_BNVariable(cls, func: FunctionOrILFunction, var: core.BNVariable):
return cls(func, var.type, var.index, var.storage)
@classmethod
- def from_identifier(cls, func:FunctionOrILFunction, identifier:int):
+ def from_identifier(cls, func: FunctionOrILFunction, identifier: int):
var = core.BNFromVariableIdentifier(identifier)
return cls(func, VariableSourceType(var.type), var.index, var.storage)
@@ -710,7 +715,7 @@ class Variable(CoreVariable):
return core.BNGetRealVariableName(self._function.handle, self._function.arch.handle, self.to_BNVariable())
@name.setter
- def name(self, name:Optional[str]) -> None:
+ def name(self, name: Optional[str]) -> None:
self.set_name_async(name)
self._function.view.update_analysis_and_wait()
@@ -724,7 +729,7 @@ class Variable(CoreVariable):
return None
@type.setter
- def type(self, new_type:'binaryninja.types.Type') -> None:
+ def type(self, new_type: 'binaryninja.types.Type') -> None:
self.set_type_async(new_type)
self._function.view.update_analysis_and_wait()
@@ -735,10 +740,18 @@ class Variable(CoreVariable):
raise NotImplementedError("No IL function associated with variable")
version_count = ctypes.c_ulonglong()
- if self._il_function.il_form in [FunctionGraphType.MediumLevelILFunctionGraph, FunctionGraphType.MediumLevelILSSAFormFunctionGraph]:
- versions = core.BNGetMediumLevelILVariableSSAVersions(self._il_function.handle, self.to_BNVariable(), version_count)
- elif self._il_function.il_form in [FunctionGraphType.HighLevelILFunctionGraph, FunctionGraphType.HighLevelILSSAFormFunctionGraph]:
- versions = core.BNGetHighLevelILVariableSSAVersions(self._il_function.handle, self.to_BNVariable(), version_count)
+ if self._il_function.il_form in [
+ FunctionGraphType.MediumLevelILFunctionGraph, FunctionGraphType.MediumLevelILSSAFormFunctionGraph
+ ]:
+ versions = core.BNGetMediumLevelILVariableSSAVersions(
+ self._il_function.handle, self.to_BNVariable(), version_count
+ )
+ elif self._il_function.il_form in [
+ FunctionGraphType.HighLevelILFunctionGraph, FunctionGraphType.HighLevelILSSAFormFunctionGraph
+ ]:
+ versions = core.BNGetHighLevelILVariableSSAVersions(
+ self._il_function.handle, self.to_BNVariable(), version_count
+ )
else:
raise NotImplementedError("Unsupported IL form")
@@ -753,7 +766,9 @@ class Variable(CoreVariable):
@property
def dead_store_elimination(self) -> DeadStoreElimination:
- return DeadStoreElimination(core.BNGetFunctionVariableDeadStoreElimination(self._function.handle, self.to_BNVariable()))
+ return DeadStoreElimination(
+ core.BNGetFunctionVariableDeadStoreElimination(self._function.handle, self.to_BNVariable())
+ )
@dead_store_elimination.setter
def dead_store_elimination(self, value):
@@ -764,7 +779,7 @@ class Variable(CoreVariable):
"""returns the source Function object which this variable belongs to"""
return self._function
- def set_name_async(self, name:Optional[str]) -> None:
+ def set_name_async(self, name: Optional[str]) -> None:
"""
``set_name_async`` provides a way to asynchronously set the name of a variable. This method should be used
when speed is of concern.
@@ -773,14 +788,14 @@ class Variable(CoreVariable):
name = ""
self._function.create_user_var(self, self.type, name)
- def set_type_async(self, new_type:'binaryninja.types.Type') -> None:
+ def set_type_async(self, new_type: 'binaryninja.types.Type') -> None:
"""
``set_type_async`` provides a way to asynchronously set the type of a variable. This method should be used
when speed is of concern.
"""
self._function.create_user_var(self, new_type, self.name)
- def set_name_and_type_async(self, name:Optional[str], new_type:'binaryninja.types.Type') -> None:
+ def set_name_and_type_async(self, name: Optional[str], new_type: 'binaryninja.types.Type') -> None:
"""
``set_name_and_type_async`` provides a way to asynchronously set both the name and type of a variable. This method should be used
when speed is of concern.
@@ -790,10 +805,10 @@ class Variable(CoreVariable):
@dataclass(frozen=True)
class ConstantReference:
- value:int
- size:int
- pointer:bool
- intermediate:bool
+ value: int
+ size: int
+ pointer: bool
+ intermediate: bool
def __repr__(self):
if self.pointer:
@@ -805,11 +820,11 @@ class ConstantReference:
@dataclass(frozen=True)
class IndirectBranchInfo:
- source_arch:'binaryninja.architecture.Architecture'
- source_addr:int
- dest_arch:'binaryninja.architecture.Architecture'
- dest_addr:int
- auto_defined:bool
+ source_arch: 'binaryninja.architecture.Architecture'
+ source_addr: int
+ dest_arch: 'binaryninja.architecture.Architecture'
+ dest_addr: int
+ auto_defined: bool
def __repr__(self):
return f"<branch {self.source_arch.name}:{self.source_addr:#x} -> {self.dest_arch.name}:{self.dest_addr:#x}>"
@@ -817,7 +832,10 @@ class IndirectBranchInfo:
@decorators.passive
class ParameterVariables:
- def __init__(self, var_list:List[Variable], confidence:int=core.max_confidence, func:Optional['binaryninja.function.Function']=None):
+ def __init__(
+ self, var_list: List[Variable], confidence: int = core.max_confidence,
+ func: Optional['binaryninja.function.Function'] = None
+ ):
self._vars = var_list
self._confidence = confidence
self._func = func
@@ -835,12 +853,12 @@ class ParameterVariables:
def __getitem__(self, idx) -> 'Variable':
return self._vars[idx]
- def __setitem__(self, idx:int, value:'Variable'):
+ def __setitem__(self, idx: int, value: 'Variable'):
self._vars[idx] = value
if self._func is not None:
self._func.parameter_vars = self
- def with_confidence(self, confidence:int) -> 'ParameterVariables':
+ def with_confidence(self, confidence: int) -> 'ParameterVariables':
return ParameterVariables(list(self._vars), confidence, self._func)
@property
@@ -858,11 +876,11 @@ class ParameterVariables:
@dataclass(frozen=True, order=True)
class AddressRange:
- start:int # Inclusive starting address
- end:int # Exclusive ending address
+ start: int # Inclusive starting address
+ end: int # Exclusive ending address
def __repr__(self):
return f"<{self.start:#x}-{self.end:#x}>"
- def __contains__(self, i:int):
- return self.start <= i < self.end \ No newline at end of file
+ def __contains__(self, i: int):
+ return self.start <= i < self.end
diff --git a/python/websocketprovider.py b/python/websocketprovider.py
index 3d5d194e..0a143562 100644
--- a/python/websocketprovider.py
+++ b/python/websocketprovider.py
@@ -18,7 +18,6 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
-
import abc
import ctypes
from json import loads, dumps
@@ -37,7 +36,6 @@ import binaryninja
from .log import log_error
-
def nop(*args, **kwargs):
pass
@@ -53,7 +51,7 @@ def to_bytes(field):
class WebsocketClient(object):
_registered_clients = []
- def __init__(self, provider, handle = None):
+ def __init__(self, provider, handle=None):
if handle is None:
self._cb = core.BNWebsocketClientCallbacks()
self._cb.context = 0
@@ -179,7 +177,9 @@ class WebsocketClient(object):
self.io_callbacks = core.BNWebsocketClientOutputCallbacks()
self.io_callbacks.context = 0
self.io_callbacks.connectedCallback = self.io_callbacks.connectedCallback.__class__(self._connected_callback)
- self.io_callbacks.disconnectedCallback = self.io_callbacks.disconnectedCallback.__class__(self._disconnected_callback)
+ self.io_callbacks.disconnectedCallback = self.io_callbacks.disconnectedCallback.__class__(
+ self._disconnected_callback
+ )
self.io_callbacks.errorCallback = self.io_callbacks.errorCallback.__class__(self._error_callback)
self.io_callbacks.readCallback = self.io_callbacks.readCallback.__class__(self._read_callback)
@@ -188,7 +188,9 @@ class WebsocketClient(object):
self.on_error = on_error
self.on_data = on_data
- return core.BNConnectWebsocketClient(self.handle, url, len(headers), header_keys, header_values, self.io_callbacks)
+ return core.BNConnectWebsocketClient(
+ self.handle, url, len(headers), header_keys, header_values, self.io_callbacks
+ )
def write(self, data):
"""
@@ -198,7 +200,9 @@ class WebsocketClient(object):
:return: true if successful
:rtype: bool
"""
- return core.BNWriteWebsocketClientData(self.handle, (ctypes.c_ubyte * len(data)).from_buffer_copy(data), len(data))
+ return core.BNWriteWebsocketClientData(
+ self.handle, (ctypes.c_ubyte * len(data)).from_buffer_copy(data), len(data)
+ )
def disconnect(self):
"""
@@ -209,6 +213,7 @@ class WebsocketClient(object):
"""
return core.BNDisconnectWebsocketClient(self.handle)
+
class _WebsocketProviderMetaclass(type):
@property
def list(self):
@@ -251,7 +256,7 @@ class WebsocketProvider(metaclass=_WebsocketProviderMetaclass):
instance_class = None
_registered_providers = []
- def __init__(self, handle = None):
+ def __init__(self, handle=None):
if handle is not None:
self.handle = core.handle_of_type(handle, core.BNWebsocketProvider)
self.__dict__["name"] = core.BNGetWebsocketProviderName(handle)
diff --git a/python/workflow.py b/python/workflow.py
index b9c38e35..89e0f186 100644
--- a/python/workflow.py
+++ b/python/workflow.py
@@ -30,16 +30,23 @@ from .flowgraph import FlowGraph, CoreFlowGraph
ActivityType = Union['Activity', str]
+
class Activity(object):
"""
:class:`Activity`
"""
_action_callbacks = {}
- def __init__(self, name:str = "", handle:Optional[core.BNActivityHandle] = None, action:Optional[Callable[[Any], None]] = None):
+
+ def __init__(
+ self, name: str = "", handle: Optional[core.BNActivityHandle] = None, action: Optional[Callable[[Any],
+ None]] = None
+ ):
if handle is None:
#cls._notify(ac, callback)
- action_callback = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.POINTER(core.BNAnalysisContext))(lambda ctxt, ac: self._action(ac))
+ action_callback = ctypes.CFUNCTYPE(None, ctypes.c_void_p,
+ ctypes.POINTER(core.BNAnalysisContext
+ ))(lambda ctxt, ac: self._action(ac))
_handle = core.BNCreateActivity(name, None, action_callback)
self.action = action
self.__class__._action_callbacks[len(self.__class__._action_callbacks)] = action_callback
@@ -49,7 +56,7 @@ class Activity(object):
self.handle = _handle
self._name = name
- def _action(self, ac:Any):
+ def _action(self, ac: Any):
try:
if self.action is not None:
self.action(ac)
@@ -100,7 +107,7 @@ class _WorkflowMetaclass(type):
for i in range(0, count.value):
handle = core.BNNewWorkflowReference(workflows[i])
assert handle is not None, "core.BNNewWorkflowReference returned None"
- result.append(Workflow(handle = handle))
+ result.append(Workflow(handle=handle))
return result
finally:
core.BNFreeWorkflowList(workflows, count.value)
@@ -114,14 +121,14 @@ class _WorkflowMetaclass(type):
for i in range(0, count.value):
handle = core.BNNewWorkflowReference(workflows[i])
assert handle is not None, "core.BNNewWorkflowReference returned None"
- yield Workflow(handle = handle)
+ yield Workflow(handle=handle)
finally:
core.BNFreeWorkflowList(workflows, count.value)
def __getitem__(self, value):
binaryninja._init_plugins()
workflow = core.BNWorkflowInstance(str(value))
- return Workflow(handle = workflow)
+ return Workflow(handle=workflow)
class Workflow(metaclass=_WorkflowMetaclass):
@@ -165,8 +172,7 @@ class Workflow(metaclass=_WorkflowMetaclass):
>>> Workflow().show_documentation()
"""
-
- def __init__(self, name:str = "", handle:core.BNWorkflowHandle = None, query_registry:bool = True):
+ def __init__(self, name: str = "", handle: core.BNWorkflowHandle = None, query_registry: bool = True):
if handle is None:
if query_registry:
_handle = core.BNWorkflowInstance(str(name))
@@ -211,7 +217,7 @@ class Workflow(metaclass=_WorkflowMetaclass):
def __hash__(self):
return hash(ctypes.addressof(self.handle.contents))
- def register(self, description:str = "") -> bool:
+ def register(self, description: str = "") -> bool:
"""
``register`` Register this Workflow, making it immutable and available for use.
@@ -221,7 +227,7 @@ class Workflow(metaclass=_WorkflowMetaclass):
"""
return core.BNRegisterWorkflow(self.handle, str(description))
- def clone(self, name:str, activity:ActivityType = "") -> "Workflow":
+ def clone(self, name: str, activity: ActivityType = "") -> "Workflow":
"""
``clone`` Clone a new Workflow, copying all Activities and the execution strategy.
@@ -231,9 +237,10 @@ class Workflow(metaclass=_WorkflowMetaclass):
:rtype: Workflow
"""
workflow = core.BNWorkflowClone(self.handle, str(name), str(activity))
- return Workflow(handle = workflow)
+ return Workflow(handle=workflow)
- def register_activity(self, activity:Activity, subactivities:List[ActivityType] = [], description:str = "") -> Optional[bool]:
+ def register_activity(self, activity: Activity, subactivities: List[ActivityType] = [],
+ description: str = "") -> Optional[bool]:
"""
``register_activity`` Register an Activity with this Workflow.
@@ -248,9 +255,11 @@ class Workflow(metaclass=_WorkflowMetaclass):
input_list = (ctypes.c_char_p * len(subactivities))()
for i in range(0, len(subactivities)):
input_list[i] = str(subactivities[i]).encode('charmap')
- return core.BNWorkflowRegisterActivity(self.handle, activity.handle, input_list, len(subactivities), str(description))
+ return core.BNWorkflowRegisterActivity(
+ self.handle, activity.handle, input_list, len(subactivities), str(description)
+ )
- def contains(self, activity:ActivityType) -> bool:
+ def contains(self, activity: ActivityType) -> bool:
"""
``contains`` Determine if an Activity exists in this Workflow.
@@ -260,7 +269,7 @@ class Workflow(metaclass=_WorkflowMetaclass):
"""
return core.BNWorkflowContains(self.handle, str(activity))
- def configuration(self, activity:ActivityType = "") -> str:
+ def configuration(self, activity: ActivityType = "") -> str:
"""
``configuration`` Retrieve the configuration as an adjacency list in JSON for the Workflow, or if specified just for the given ``activity``.
@@ -279,7 +288,7 @@ class Workflow(metaclass=_WorkflowMetaclass):
"""
return core.BNWorkflowIsRegistered(self.handle)
- def get_activity(self, activity:ActivityType) -> Optional[Activity]:
+ def get_activity(self, activity: ActivityType) -> Optional[Activity]:
"""
``get_activity`` Retrieve the Activity object for the specified ``activity``.
@@ -292,7 +301,7 @@ class Workflow(metaclass=_WorkflowMetaclass):
return None
return Activity(str(activity), handle)
- def activity_roots(self, activity:ActivityType = "") -> List[str]:
+ def activity_roots(self, activity: ActivityType = "") -> List[str]:
"""
``activity_roots`` Retrieve the list of activity roots for the Workflow, or if specified just for the given ``activity``.
@@ -311,7 +320,7 @@ class Workflow(metaclass=_WorkflowMetaclass):
finally:
core.BNFreeStringList(result, length.value)
- def subactivities(self, activity:ActivityType = "", immediate:bool = True) -> List[str]:
+ def subactivities(self, activity: ActivityType = "", immediate: bool = True) -> List[str]:
"""
``subactivities`` Retrieve the list of all activities, or optionally a filtered list.
@@ -331,7 +340,7 @@ class Workflow(metaclass=_WorkflowMetaclass):
finally:
core.BNFreeStringList(result, length.value)
- def assign_subactivities(self, activity:Activity, activities:List[str]) -> bool:
+ def assign_subactivities(self, activity: Activity, activities: List[str]) -> bool:
"""
``assign_subactivities`` Assign the list of ``activities`` as the new set of children for the specified ``activity``.
@@ -354,7 +363,7 @@ class Workflow(metaclass=_WorkflowMetaclass):
"""
return core.BNWorkflowClear(self.handle)
- def insert(self, activity:ActivityType, activities:List[str]) -> bool:
+ def insert(self, activity: ActivityType, activities: List[str]) -> bool:
"""
``insert`` Insert the list of ``activities`` before the specified ``activity`` and at the same level.
@@ -368,7 +377,7 @@ class Workflow(metaclass=_WorkflowMetaclass):
input_list[i] = str(activities[i]).encode('charmap')
return core.BNWorkflowInsert(self.handle, str(activity), input_list, len(activities))
- def remove(self, activity:ActivityType) -> bool:
+ def remove(self, activity: ActivityType) -> bool:
"""
``remove`` Remove the specified ``activity``.
@@ -378,7 +387,7 @@ class Workflow(metaclass=_WorkflowMetaclass):
"""
return core.BNWorkflowRemove(self.handle, str(activity))
- def replace(self, activity:ActivityType, new_activity:List[str]) -> bool:
+ def replace(self, activity: ActivityType, new_activity: List[str]) -> bool:
"""
``replace`` Replace the specified ``activity``.
@@ -389,7 +398,7 @@ class Workflow(metaclass=_WorkflowMetaclass):
"""
return core.BNWorkflowReplace(self.handle, str(activity), str(new_activity))
- def graph(self, activity:ActivityType = "", sequential:bool = False, show:bool = True) -> Optional[FlowGraph]:
+ def graph(self, activity: ActivityType = "", sequential: bool = False, show: bool = True) -> Optional[FlowGraph]:
"""
``graph`` Generate a FlowGraph object for the current Workflow and optionally show it in the UI.
diff --git a/rapidjsonwrapper.h b/rapidjsonwrapper.h
index d1988b42..5b117413 100644
--- a/rapidjsonwrapper.h
+++ b/rapidjsonwrapper.h
@@ -4,33 +4,36 @@
#if defined(__GNUC__) && __GNUC__ >= 8
// Disable warnings from rapidjson performance optimizations
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wclass-memaccess"
+ #pragma GCC diagnostic push
+ #pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
struct GenericException;
struct ParseException;
-struct GenericException: public std::exception
+struct GenericException : public std::exception
{
GenericException() : std::exception() {}
- virtual const char* what() const throw()
- {
- return "Exception while parsing json.";
- }
+ virtual const char* what() const throw() { return "Exception while parsing json."; }
};
-#define RAPIDJSON_HAS_STDSTRING 0
+#define RAPIDJSON_HAS_STDSTRING 0
#define RAPIDJSON_HAS_CXX11_NOEXCEPT 0
-#define RAPIDJSON_ASSERT(x) do {if (!(x)) throw GenericException(); } while(0);
-#define RAPIDJSON_PARSE_ERROR_NORETURN(parseErrorCode,offset) \
+#define RAPIDJSON_ASSERT(x) \
+ do \
+ { \
+ if (!(x)) \
+ throw GenericException(); \
+ } while (0);
+#define RAPIDJSON_PARSE_ERROR_NORETURN(parseErrorCode, offset) \
throw ParseException(parseErrorCode, #parseErrorCode, offset)
#include "rapidjson/error/error.h"
-struct ParseException: public std::runtime_error, public rapidjson::ParseResult
+struct ParseException : public std::runtime_error, public rapidjson::ParseResult
{
- ParseException(rapidjson::ParseErrorCode code, const char* msg, size_t offset) : std::runtime_error(msg),
- ParseResult(code, offset) {}
+ ParseException(rapidjson::ParseErrorCode code, const char* msg, size_t offset) :
+ std::runtime_error(msg), ParseResult(code, offset)
+ {}
};
#include "rapidjson/error/en.h"
@@ -41,5 +44,5 @@ struct ParseException: public std::runtime_error, public rapidjson::ParseResult
#include "rapidjson/prettywriter.h"
#if defined(__GNUC__) && __GNUC__ >= 8
-#pragma GCC diagnostic pop
+ #pragma GCC diagnostic pop
#endif
diff --git a/relocationhandler.cpp b/relocationhandler.cpp
index e2746168..04af3afe 100644
--- a/relocationhandler.cpp
+++ b/relocationhandler.cpp
@@ -51,8 +51,8 @@ void RelocationHandler::FreeCallback(void* ctxt)
}
-bool RelocationHandler::GetRelocationInfoCallback(void* ctxt, BNBinaryView* view, BNArchitecture* arch,
- BNRelocationInfo* result, size_t resultCount)
+bool RelocationHandler::GetRelocationInfoCallback(
+ void* ctxt, BNBinaryView* view, BNArchitecture* arch, BNRelocationInfo* result, size_t resultCount)
{
RelocationHandler* handler = (RelocationHandler*)ctxt;
Ref<BinaryView> viewObj = new BinaryView(BNNewViewReference(view));
@@ -67,8 +67,8 @@ bool RelocationHandler::GetRelocationInfoCallback(void* ctxt, BNBinaryView* view
}
-bool RelocationHandler::ApplyRelocationCallback(void* ctxt, BNBinaryView* view, BNArchitecture* arch, BNRelocation* reloc,
- uint8_t* dest, size_t len)
+bool RelocationHandler::ApplyRelocationCallback(
+ void* ctxt, BNBinaryView* view, BNArchitecture* arch, BNRelocation* reloc, uint8_t* dest, size_t len)
{
RelocationHandler* handler = (RelocationHandler*)ctxt;
Ref<Architecture> archObj = new CoreArchitecture(arch);
@@ -78,8 +78,8 @@ bool RelocationHandler::ApplyRelocationCallback(void* ctxt, BNBinaryView* view,
}
-size_t RelocationHandler::GetOperandForExternalRelocationCallback(void* ctxt, const uint8_t* data, uint64_t addr,
- size_t length, BNLowLevelILFunction* il, BNRelocation* reloc)
+size_t RelocationHandler::GetOperandForExternalRelocationCallback(
+ void* ctxt, const uint8_t* data, uint64_t addr, size_t length, BNLowLevelILFunction* il, BNRelocation* reloc)
{
RelocationHandler* handler = (RelocationHandler*)ctxt;
Ref<LowLevelILFunction> func(new LowLevelILFunction(BNNewLowLevelILFunctionReference(il)));
@@ -88,7 +88,8 @@ size_t RelocationHandler::GetOperandForExternalRelocationCallback(void* ctxt, co
}
-bool RelocationHandler::GetRelocationInfo(Ref<BinaryView> view, Ref<Architecture> arch, std::vector<BNRelocationInfo>& result)
+bool RelocationHandler::GetRelocationInfo(
+ Ref<BinaryView> view, Ref<Architecture> arch, std::vector<BNRelocationInfo>& result)
{
(void)view;
(void)arch;
@@ -97,16 +98,16 @@ bool RelocationHandler::GetRelocationInfo(Ref<BinaryView> view, Ref<Architecture
}
-bool RelocationHandler::ApplyRelocation(Ref<BinaryView> view, Ref<Architecture> arch, Ref<Relocation> reloc, uint8_t* dest,
- size_t len)
+bool RelocationHandler::ApplyRelocation(
+ Ref<BinaryView> view, Ref<Architecture> arch, Ref<Relocation> reloc, uint8_t* dest, size_t len)
{
- return BNRelocationHandlerDefaultApplyRelocation(m_object, view->GetObject(), arch->GetObject(),
- BNNewRelocationReference(reloc->GetObject()), dest, len);
+ return BNRelocationHandlerDefaultApplyRelocation(
+ m_object, view->GetObject(), arch->GetObject(), BNNewRelocationReference(reloc->GetObject()), dest, len);
}
-size_t RelocationHandler::GetOperandForExternalRelocation(const uint8_t* data, uint64_t addr, size_t length,
- Ref<LowLevelILFunction> il, Ref<Relocation> relocation)
+size_t RelocationHandler::GetOperandForExternalRelocation(
+ const uint8_t* data, uint64_t addr, size_t length, Ref<LowLevelILFunction> il, Ref<Relocation> relocation)
{
(void)data;
(void)addr;
@@ -117,34 +118,34 @@ size_t RelocationHandler::GetOperandForExternalRelocation(const uint8_t* data, u
}
-CoreRelocationHandler::CoreRelocationHandler(BNRelocationHandler* handler) : RelocationHandler(handler)
-{
-}
+CoreRelocationHandler::CoreRelocationHandler(BNRelocationHandler* handler) : RelocationHandler(handler) {}
-bool CoreRelocationHandler::ApplyRelocation(Ref<BinaryView> view, Ref<Architecture> arch, Ref<Relocation> reloc, uint8_t* dest,
- size_t len)
+bool CoreRelocationHandler::ApplyRelocation(
+ Ref<BinaryView> view, Ref<Architecture> arch, Ref<Relocation> reloc, uint8_t* dest, size_t len)
{
- return BNRelocationHandlerApplyRelocation(m_object, view->GetObject(), arch->GetObject(), BNNewRelocationReference(reloc->GetObject()), dest, len);
+ return BNRelocationHandlerApplyRelocation(
+ m_object, view->GetObject(), arch->GetObject(), BNNewRelocationReference(reloc->GetObject()), dest, len);
}
-bool CoreRelocationHandler::GetRelocationInfo(Ref<BinaryView> view, Ref<Architecture> arch, std::vector<BNRelocationInfo>& result)
+bool CoreRelocationHandler::GetRelocationInfo(
+ Ref<BinaryView> view, Ref<Architecture> arch, std::vector<BNRelocationInfo>& result)
{
BNRelocationInfo* results = new BNRelocationInfo[result.size()];
for (size_t i = 0; i < result.size(); i++)
results[i] = result[i];
- bool status = BNRelocationHandlerGetRelocationInfo(m_object, view->GetObject(), arch->GetObject(), results,
- result.size());
+ bool status =
+ BNRelocationHandlerGetRelocationInfo(m_object, view->GetObject(), arch->GetObject(), results, result.size());
for (size_t i = 0; i < result.size(); i++)
result[i] = results[i];
return status;
}
-size_t CoreRelocationHandler::GetOperandForExternalRelocation(const uint8_t* data, uint64_t addr, size_t length,
- Ref<LowLevelILFunction> il, Ref<Relocation> relocation)
+size_t CoreRelocationHandler::GetOperandForExternalRelocation(
+ const uint8_t* data, uint64_t addr, size_t length, Ref<LowLevelILFunction> il, Ref<Relocation> relocation)
{
- return BNRelocationHandlerGetOperandForExternalRelocation(m_object, data, addr, length, il->GetObject(),
- BNNewRelocationReference(relocation->GetObject()));
+ return BNRelocationHandlerGetOperandForExternalRelocation(
+ m_object, data, addr, length, il->GetObject(), BNNewRelocationReference(relocation->GetObject()));
}
diff --git a/rust/examples/basic_script/build.rs b/rust/examples/basic_script/build.rs
index 7ad93884..5ba9bcde 100644
--- a/rust/examples/basic_script/build.rs
+++ b/rust/examples/basic_script/build.rs
@@ -14,54 +14,55 @@ static LASTRUN_PATH: (&str, &str) = ("APPDATA", "Binary Ninja\\lastrun");
// Check last run location for path to BinaryNinja; Otherwise check the default install locations
fn link_path() -> PathBuf {
- use std::io::prelude::*;
+ use std::io::prelude::*;
- let home = PathBuf::from(env::var(LASTRUN_PATH.0).unwrap());
- let lastrun = PathBuf::from(&home).join(LASTRUN_PATH.1);
+ let home = PathBuf::from(env::var(LASTRUN_PATH.0).unwrap());
+ let lastrun = PathBuf::from(&home).join(LASTRUN_PATH.1);
- File::open(lastrun)
- .and_then(|f| {
- let mut binja_path = String::new();
- let mut reader = BufReader::new(f);
+ File::open(lastrun)
+ .and_then(|f| {
+ let mut binja_path = String::new();
+ let mut reader = BufReader::new(f);
- reader.read_line(&mut binja_path)?;
- Ok(PathBuf::from(binja_path.trim()))
- })
- .unwrap_or_else(|_| {
- #[cfg(target_os = "macos")]
- return PathBuf::from("/Applications/Binary Ninja.app/Contents/MacOS");
+ reader.read_line(&mut binja_path)?;
+ Ok(PathBuf::from(binja_path.trim()))
+ })
+ .unwrap_or_else(|_| {
+ #[cfg(target_os = "macos")]
+ return PathBuf::from("/Applications/Binary Ninja.app/Contents/MacOS");
- #[cfg(target_os = "linux")]
- return home.join("binaryninja");
+ #[cfg(target_os = "linux")]
+ return home.join("binaryninja");
- #[cfg(windows)]
- return PathBuf::from(env::var("PROGRAMFILES").unwrap()).join("Vector35\\BinaryNinja\\");
- })
+ #[cfg(windows)]
+ return PathBuf::from(env::var("PROGRAMFILES").unwrap())
+ .join("Vector35\\BinaryNinja\\");
+ })
}
fn main() {
- // Use BINARYNINJADIR first for custom BN builds/configurations (BN devs/build server), fallback on defaults
- let install_path = env::var("BINARYNINJADIR")
- .map(PathBuf::from)
- .unwrap_or_else(|_| link_path());
+ // Use BINARYNINJADIR first for custom BN builds/configurations (BN devs/build server), fallback on defaults
+ let install_path = env::var("BINARYNINJADIR")
+ .map(PathBuf::from)
+ .unwrap_or_else(|_| link_path());
- #[cfg(target_os = "linux")]
- println!(
- "cargo:rustc-link-arg=-Wl,-rpath,{},-L{},-l:libbinaryninjacore.so.1",
- install_path.to_str().unwrap(),
- install_path.to_str().unwrap(),
- );
+ #[cfg(target_os = "linux")]
+ println!(
+ "cargo:rustc-link-arg=-Wl,-rpath,{},-L{},-l:libbinaryninjacore.so.1",
+ install_path.to_str().unwrap(),
+ install_path.to_str().unwrap(),
+ );
- #[cfg(target_os = "macos")]
- println!(
- "cargo:rustc-link-arg=-Wl,-rpath,{},-L{},-lbinaryninjacore",
- install_path.to_str().unwrap(),
- install_path.to_str().unwrap(),
- );
+ #[cfg(target_os = "macos")]
+ println!(
+ "cargo:rustc-link-arg=-Wl,-rpath,{},-L{},-lbinaryninjacore",
+ install_path.to_str().unwrap(),
+ install_path.to_str().unwrap(),
+ );
- #[cfg(target_os = "windows")]
- {
- println!("cargo:rustc-link-lib=binaryninjacore");
- println!("cargo:rustc-link-search={}", install_path.to_str().unwrap());
- }
+ #[cfg(target_os = "windows")]
+ {
+ println!("cargo:rustc-link-lib=binaryninjacore");
+ println!("cargo:rustc-link-search={}", install_path.to_str().unwrap());
+ }
}
diff --git a/rust/examples/template/build.rs b/rust/examples/template/build.rs
index 7ad93884..5ba9bcde 100644
--- a/rust/examples/template/build.rs
+++ b/rust/examples/template/build.rs
@@ -14,54 +14,55 @@ static LASTRUN_PATH: (&str, &str) = ("APPDATA", "Binary Ninja\\lastrun");
// Check last run location for path to BinaryNinja; Otherwise check the default install locations
fn link_path() -> PathBuf {
- use std::io::prelude::*;
+ use std::io::prelude::*;
- let home = PathBuf::from(env::var(LASTRUN_PATH.0).unwrap());
- let lastrun = PathBuf::from(&home).join(LASTRUN_PATH.1);
+ let home = PathBuf::from(env::var(LASTRUN_PATH.0).unwrap());
+ let lastrun = PathBuf::from(&home).join(LASTRUN_PATH.1);
- File::open(lastrun)
- .and_then(|f| {
- let mut binja_path = String::new();
- let mut reader = BufReader::new(f);
+ File::open(lastrun)
+ .and_then(|f| {
+ let mut binja_path = String::new();
+ let mut reader = BufReader::new(f);
- reader.read_line(&mut binja_path)?;
- Ok(PathBuf::from(binja_path.trim()))
- })
- .unwrap_or_else(|_| {
- #[cfg(target_os = "macos")]
- return PathBuf::from("/Applications/Binary Ninja.app/Contents/MacOS");
+ reader.read_line(&mut binja_path)?;
+ Ok(PathBuf::from(binja_path.trim()))
+ })
+ .unwrap_or_else(|_| {
+ #[cfg(target_os = "macos")]
+ return PathBuf::from("/Applications/Binary Ninja.app/Contents/MacOS");
- #[cfg(target_os = "linux")]
- return home.join("binaryninja");
+ #[cfg(target_os = "linux")]
+ return home.join("binaryninja");
- #[cfg(windows)]
- return PathBuf::from(env::var("PROGRAMFILES").unwrap()).join("Vector35\\BinaryNinja\\");
- })
+ #[cfg(windows)]
+ return PathBuf::from(env::var("PROGRAMFILES").unwrap())
+ .join("Vector35\\BinaryNinja\\");
+ })
}
fn main() {
- // Use BINARYNINJADIR first for custom BN builds/configurations (BN devs/build server), fallback on defaults
- let install_path = env::var("BINARYNINJADIR")
- .map(PathBuf::from)
- .unwrap_or_else(|_| link_path());
+ // Use BINARYNINJADIR first for custom BN builds/configurations (BN devs/build server), fallback on defaults
+ let install_path = env::var("BINARYNINJADIR")
+ .map(PathBuf::from)
+ .unwrap_or_else(|_| link_path());
- #[cfg(target_os = "linux")]
- println!(
- "cargo:rustc-link-arg=-Wl,-rpath,{},-L{},-l:libbinaryninjacore.so.1",
- install_path.to_str().unwrap(),
- install_path.to_str().unwrap(),
- );
+ #[cfg(target_os = "linux")]
+ println!(
+ "cargo:rustc-link-arg=-Wl,-rpath,{},-L{},-l:libbinaryninjacore.so.1",
+ install_path.to_str().unwrap(),
+ install_path.to_str().unwrap(),
+ );
- #[cfg(target_os = "macos")]
- println!(
- "cargo:rustc-link-arg=-Wl,-rpath,{},-L{},-lbinaryninjacore",
- install_path.to_str().unwrap(),
- install_path.to_str().unwrap(),
- );
+ #[cfg(target_os = "macos")]
+ println!(
+ "cargo:rustc-link-arg=-Wl,-rpath,{},-L{},-lbinaryninjacore",
+ install_path.to_str().unwrap(),
+ install_path.to_str().unwrap(),
+ );
- #[cfg(target_os = "windows")]
- {
- println!("cargo:rustc-link-lib=binaryninjacore");
- println!("cargo:rustc-link-search={}", install_path.to_str().unwrap());
- }
+ #[cfg(target_os = "windows")]
+ {
+ println!("cargo:rustc-link-lib=binaryninjacore");
+ println!("cargo:rustc-link-search={}", install_path.to_str().unwrap());
+ }
}
diff --git a/rust/src/disassembly.rs b/rust/src/disassembly.rs
index c4ca2b33..8edf3c4f 100644
--- a/rust/src/disassembly.rs
+++ b/rust/src/disassembly.rs
@@ -128,7 +128,7 @@ impl From<Vec<InstructionTextToken>> for DisassemblyTextLine {
hasTypeInfo: false,
parentType: ptr::null_mut(),
fieldIndex: usize::MAX,
- offset: 0
+ offset: 0,
},
})
}
@@ -168,7 +168,7 @@ impl From<&Vec<&str>> for DisassemblyTextLine {
hasTypeInfo: false,
parentType: ptr::null_mut(),
fieldIndex: usize::MAX,
- offset: 0
+ offset: 0,
},
})
}
@@ -197,7 +197,7 @@ impl Default for DisassemblyTextLine {
hasTypeInfo: false,
parentType: ptr::null_mut(),
fieldIndex: usize::MAX,
- offset: 0
+ offset: 0,
},
})
}
diff --git a/rust/src/types.rs b/rust/src/types.rs
index 17721361..221fcb17 100644
--- a/rust/src/types.rs
+++ b/rust/src/types.rs
@@ -405,7 +405,7 @@ impl TypeBuilder {
0,
1,
&mut is_const,
- &mut is_volatile
+ &mut is_volatile,
))
}
}
@@ -727,7 +727,11 @@ impl Type {
unsafe { Self::ref_from_raw(BNCreateArrayType(&t.into().into(), count)) }
}
- pub fn enumeration(enumeration: &Enumeration, width: usize, is_signed: Conf<bool>) -> Ref<Self> {
+ pub fn enumeration(
+ enumeration: &Enumeration,
+ width: usize,
+ is_signed: Conf<bool>,
+ ) -> Ref<Self> {
//! The C/C++ APIs require an associated architecture, but in the core we only query the default_int_size if the given width is 0
//! For simplicity's sake, that convention isn't followed and you can query the default_int_size from an arch, if you have it, if you need to
unsafe {
@@ -749,11 +753,15 @@ impl Type {
pub fn named_type(type_reference: &NamedTypeReference) -> Ref<Self> {
let mut is_const = Conf::new(false, min_confidence()).into();
let mut is_volatile = Conf::new(false, min_confidence()).into();
- unsafe { Self::ref_from_raw(BNCreateNamedTypeReference(type_reference.handle,
+ unsafe {
+ Self::ref_from_raw(BNCreateNamedTypeReference(
+ type_reference.handle,
0,
1,
&mut is_const,
- &mut is_volatile)) }
+ &mut is_volatile,
+ ))
+ }
}
pub fn named_type_from_type<S: BnStrCompatible>(name: S, t: &Type) -> Ref<Self> {
diff --git a/scriptingprovider.cpp b/scriptingprovider.cpp
index 76cb67c2..9e85e91d 100644
--- a/scriptingprovider.cpp
+++ b/scriptingprovider.cpp
@@ -34,19 +34,13 @@ void ScriptingOutputListener::InputReadyStateChangedCallback(void* ctxt, BNScrip
}
-void ScriptingOutputListener::NotifyOutput(const string&)
-{
-}
+void ScriptingOutputListener::NotifyOutput(const string&) {}
-void ScriptingOutputListener::NotifyError(const string&)
-{
-}
+void ScriptingOutputListener::NotifyError(const string&) {}
-void ScriptingOutputListener::NotifyInputReadyStateChanged(BNScriptingProviderInputReadyState)
-{
-}
+void ScriptingOutputListener::NotifyInputReadyStateChanged(BNScriptingProviderInputReadyState) {}
ScriptingInstance::ScriptingInstance(ScriptingProvider* provider)
@@ -152,33 +146,21 @@ void ScriptingInstance::DestroyInstance()
}
-void ScriptingInstance::CancelScriptInput()
-{
-}
+void ScriptingInstance::CancelScriptInput() {}
-void ScriptingInstance::SetCurrentBinaryView(BinaryView*)
-{
-}
+void ScriptingInstance::SetCurrentBinaryView(BinaryView*) {}
-void ScriptingInstance::SetCurrentFunction(Function*)
-{
-}
+void ScriptingInstance::SetCurrentFunction(Function*) {}
-void ScriptingInstance::SetCurrentBasicBlock(BasicBlock*)
-{
-}
+void ScriptingInstance::SetCurrentBasicBlock(BasicBlock*) {}
-void ScriptingInstance::SetCurrentAddress(uint64_t)
-{
-}
+void ScriptingInstance::SetCurrentAddress(uint64_t) {}
-void ScriptingInstance::SetCurrentSelection(uint64_t, uint64_t)
-{
-}
+void ScriptingInstance::SetCurrentSelection(uint64_t, uint64_t) {}
std::string ScriptingInstance::CompleteInput(const std::string&, uint64_t)
@@ -235,14 +217,10 @@ void ScriptingInstance::SetDelimiters(const std::string& delimiters)
}
-void ScriptingInstance::Stop()
-{
-}
+void ScriptingInstance::Stop() {}
-CoreScriptingInstance::CoreScriptingInstance(BNScriptingInstance* instance): ScriptingInstance(instance)
-{
-}
+CoreScriptingInstance::CoreScriptingInstance(BNScriptingInstance* instance) : ScriptingInstance(instance) {}
BNScriptingProviderExecuteResult CoreScriptingInstance::ExecuteScriptInput(const string& input)
@@ -302,9 +280,9 @@ void CoreScriptingInstance::Stop()
}
-ScriptingProvider::ScriptingProvider(const string& name, const string& apiName): m_nameForRegister(name), m_apiNameForRegister(apiName)
-{
-}
+ScriptingProvider::ScriptingProvider(const string& name, const string& apiName) :
+ m_nameForRegister(name), m_apiNameForRegister(apiName)
+{}
ScriptingProvider::ScriptingProvider(BNScriptingProvider* provider)
@@ -390,13 +368,12 @@ void ScriptingProvider::Register(ScriptingProvider* provider)
cb.createInstance = CreateInstanceCallback;
cb.loadModule = LoadModuleCallback;
cb.installModules = InstallModulesCallback;
- provider->m_object = BNRegisterScriptingProvider(provider->m_nameForRegister.c_str(), provider->m_apiNameForRegister.c_str(), &cb);
+ provider->m_object =
+ BNRegisterScriptingProvider(provider->m_nameForRegister.c_str(), provider->m_apiNameForRegister.c_str(), &cb);
}
-CoreScriptingProvider::CoreScriptingProvider(BNScriptingProvider* provider): ScriptingProvider(provider)
-{
-}
+CoreScriptingProvider::CoreScriptingProvider(BNScriptingProvider* provider) : ScriptingProvider(provider) {}
Ref<ScriptingInstance> CoreScriptingProvider::CreateNewInstance()
diff --git a/scripts/download_headless.py b/scripts/download_headless.py
index fbd1a2a3..116fe87c 100755
--- a/scripts/download_headless.py
+++ b/scripts/download_headless.py
@@ -9,12 +9,15 @@ import zipfile
import logging
from pathlib import Path
+
class DownloadException(Exception):
- pass
+ pass
+
-url='https://master.binary.ninja/headless-download'
+url = 'https://master.binary.ninja/headless-download'
min_download = 8192
+
def get_system_license_path() -> Path:
"""Returns the default path to the Binary Ninja license.dat on the current platform
@@ -44,7 +47,7 @@ def get_serial_from_license(path: str) -> str:
raise ValueError(f'No "Headless" license in {path}')
-def download_headless(serial: str, output_path: str=None, dev: bool=False) -> str:
+def download_headless(serial: str, output_path: str = None, dev: bool = False) -> str:
"""Downloads the headless Binary Ninja installation binaries.
:param serial: Serial number for verification
@@ -71,13 +74,18 @@ def download_headless(serial: str, output_path: str=None, dev: bool=False) -> st
f.write(content.content)
return output_path
+
def install_zip(zippath: str, installpath: str, clean: bool):
with zipfile.ZipFile(zippath, 'r') as zip_ref:
zip_ref.extractall(installpath)
if clean:
os.unlink(zippath)
-def download_and_install(serial: str=None, downloaddir: str=None, dev: bool=False, clean: bool=False, install: bool=False, installdir: str='/usr/local/bin'):
+
+def download_and_install(
+ serial: str = None, downloaddir: str = None, dev: bool = False, clean: bool = False, install: bool = False,
+ installdir: str = '/usr/local/bin'
+):
env_lic = 'BN_HEADLESS_LICENSE'
if serial is None:
if env_lic in os.environ:
@@ -101,7 +109,9 @@ if __name__ == '__main__':
parser.add_argument('--output', default=None, help='path to write the file to (defaults to current directory)')
parser.add_argument('-q', '--quiet', default=False, action='store_true', help='Don\'t show any output')
parser.add_argument('-i', '--install', default=False, action='store_true', help='Install after downloading')
- parser.add_argument('-d', '--dir', default='/usr/local/bin', help='Install into provided directory used only when \'-i\' is specified')
+ parser.add_argument(
+ '-d', '--dir', default='/usr/local/bin', help='Install into provided directory used only when \'-i\' is specified'
+ )
parser.add_argument('-c', '--clean', default=False, action='store_true', help='Delete zip file after installation.')
args = parser.parse_args()
@@ -112,4 +122,4 @@ if __name__ == '__main__':
download_and_install(args.serial, args.output, args.dev, args.clean, args.install, args.dir)
except Exception as e:
logging.critical(e)
- sys.exit(1) \ No newline at end of file
+ sys.exit(1)
diff --git a/scripts/install_api.py b/scripts/install_api.py
index 9532f02b..fddf0478 100755
--- a/scripts/install_api.py
+++ b/scripts/install_api.py
@@ -8,119 +8,119 @@ import os
from site import check_enableusersite
# Handle both normal environments and virtualenvs
-try:
- from site import getusersitepackages, getsitepackages
+try:
+ from site import getusersitepackages, getsitepackages
except ImportError:
- from sysconfig import get_path
- getsitepackages = lambda: get_path('purelib')
- getusersitepackages = getsitepackages
+ from sysconfig import get_path
+ getsitepackages = lambda: get_path('purelib')
+ getusersitepackages = getsitepackages
# Hacky command line parsing to accept a silent-install -s flag like linux-setup.sh:
INTERACTIVE = True
if '-s' in sys.argv[1:]:
- INTERACTIVE = False
+ INTERACTIVE = False
INSTALL_VENV = False
if '-v' in sys.argv[1:]:
- if os.environ.get('VIRTUAL_ENV'):
- INSTALL_VENV = True
- else:
- print("Error: venv installation requested without an active python3 venv.")
- sys.exit(1)
-
+ if os.environ.get('VIRTUAL_ENV'):
+ INSTALL_VENV = True
+ else:
+ print("Error: venv installation requested without an active python3 venv.")
+ sys.exit(1)
+
try:
- import binaryninja
- import binaryninjaui #To better detect if migrating from a version without UI plugin support
- if '-u' in sys.argv[1:]:
- #Uninstall mode
- userpth = os.path.join(getusersitepackages(), 'binaryninja.pth')
- if os.path.exists(userpth):
- print(f"Removing {userpth}")
- os.unlink(userpth)
- sitepth = os.path.join(getsitepackages()[0], 'binaryninja.pth')
- if os.path.exists(sitepth):
- print(f"Removing {sitepth}")
- try:
- os.unlink(sitepth)
- except:
- print("Unable to unlink, please re-run with appropriate permissions.")
- sys.exit(0)
- print("Binary Ninja API already in the path")
- sys.exit(1)
+ import binaryninja
+ import binaryninjaui #To better detect if migrating from a version without UI plugin support
+ if '-u' in sys.argv[1:]:
+ #Uninstall mode
+ userpth = os.path.join(getusersitepackages(), 'binaryninja.pth')
+ if os.path.exists(userpth):
+ print(f"Removing {userpth}")
+ os.unlink(userpth)
+ sitepth = os.path.join(getsitepackages()[0], 'binaryninja.pth')
+ if os.path.exists(sitepth):
+ print(f"Removing {sitepth}")
+ try:
+ os.unlink(sitepth)
+ except:
+ print("Unable to unlink, please re-run with appropriate permissions.")
+ sys.exit(0)
+ print("Binary Ninja API already in the path")
+ sys.exit(1)
except ImportError:
- pass
+ pass
if '-u' in sys.argv[1:]:
- print("Uninstall specified, but binaryninja not in the current path")
- sys.exit(1)
+ print("Uninstall specified, but binaryninja not in the current path")
+ sys.exit(1)
dir_name = os.path.dirname(os.path.abspath(__file__))
api_path = os.path.abspath(os.path.join(dir_name, "..", "python"))
if (os.path.isdir(api_path)):
- print(f"Found install folder of {api_path}")
+ print(f"Found install folder of {api_path}")
else:
- print("Failed to find installed python expected at {}".format(api_path))
- sys.exit(1)
+ print("Failed to find installed python expected at {}".format(api_path))
+ sys.exit(1)
def validate_path(path):
- try:
- os.stat(path)
- except OSError:
- return False
+ try:
+ os.stat(path)
+ except OSError:
+ return False
- old_path = sys.path
- sys.path.append(path)
+ old_path = sys.path
+ sys.path.append(path)
- try:
- from binaryninja import core_version
- print("Found Binary Ninja core version: {}".format(core_version()))
- except ImportError:
- sys.path = old_path
- return False
+ try:
+ from binaryninja import core_version
+ print("Found Binary Ninja core version: {}".format(core_version()))
+ except ImportError:
+ sys.path = old_path
+ return False
- return True
+ return True
while not validate_path(api_path):
- print("\nBinary Ninja not found.")
- if not INTERACTIVE:
- print("Non-interactive mode selected, failing.")
- sys.exit(-1)
+ print("\nBinary Ninja not found.")
+ if not INTERACTIVE:
+ print("Non-interactive mode selected, failing.")
+ sys.exit(-1)
- print("Please provide the path to Binary Ninja's install directory: \n [{}] : ".format(api_path))
- new_path = sys.stdin.readline().strip()
- if len(new_path) == 0:
- print("\nInvalid path")
- continue
+ print("Please provide the path to Binary Ninja's install directory: \n [{}] : ".format(api_path))
+ new_path = sys.stdin.readline().strip()
+ if len(new_path) == 0:
+ print("\nInvalid path")
+ continue
- if not new_path.endswith('python'):
- new_path = os.path.join(new_path, 'python')
+ if not new_path.endswith('python'):
+ new_path = os.path.join(new_path, 'python')
- api_path = new_path
+ api_path = new_path
-if ( len(sys.argv) > 1 and sys.argv[1].lower() == "root" ):
- #write to root site
- install_path = getsitepackages()[0]
- if not os.access(install_path, os.W_OK):
- print("Root install specified but cannot write to {}".format(install_path))
- sys.exit(1)
+if (len(sys.argv) > 1 and sys.argv[1].lower() == "root"):
+ #write to root site
+ install_path = getsitepackages()[0]
+ if not os.access(install_path, os.W_OK):
+ print("Root install specified but cannot write to {}".format(install_path))
+ sys.exit(1)
elif INSTALL_VENV:
- install_path = getsitepackages()[0]
+ install_path = getsitepackages()[0]
else:
- if check_enableusersite():
- install_path = getusersitepackages()
- if not os.path.exists(install_path):
- os.makedirs(install_path)
- else:
- print("Warning, trying to write to user site packages, but check_enableusersite fails.")
- sys.exit(1)
+ if check_enableusersite():
+ install_path = getusersitepackages()
+ if not os.path.exists(install_path):
+ os.makedirs(install_path)
+ else:
+ print("Warning, trying to write to user site packages, but check_enableusersite fails.")
+ sys.exit(1)
binaryninja_pth_path = os.path.join(install_path, 'binaryninja.pth')
with open(binaryninja_pth_path, 'wb') as pth_file:
- pth_file.write((api_path+"\n").encode('charmap'))
- if sys.version_info.major < 3 or (sys.version_info.major == 3 and sys.version_info.minor < 10):
- pth_file.write((api_path+sys.version[0]+"\n").encode('charmap')) #support for python2/3 QT bindings
+ pth_file.write((api_path + "\n").encode('charmap'))
+ if sys.version_info.major < 3 or (sys.version_info.major == 3 and sys.version_info.minor < 10):
+ pth_file.write((api_path + sys.version[0] + "\n").encode('charmap')) #support for python2/3 QT bindings
print("Binary Ninja API installed using {}".format(binaryninja_pth_path))
diff --git a/secretsprovider.cpp b/secretsprovider.cpp
index 783e1e9c..b84113ff 100644
--- a/secretsprovider.cpp
+++ b/secretsprovider.cpp
@@ -23,10 +23,7 @@
using namespace BinaryNinja;
-SecretsProvider::SecretsProvider(const std::string& name): m_nameForRegister(name)
-{
-
-}
+SecretsProvider::SecretsProvider(const std::string& name) : m_nameForRegister(name) {}
SecretsProvider::SecretsProvider(BNSecretsProvider* provider)
@@ -104,10 +101,7 @@ void SecretsProvider::Register(SecretsProvider* provider)
}
-CoreSecretsProvider::CoreSecretsProvider(BNSecretsProvider* provider): SecretsProvider(provider)
-{
-
-}
+CoreSecretsProvider::CoreSecretsProvider(BNSecretsProvider* provider) : SecretsProvider(provider) {}
bool CoreSecretsProvider::HasData(const std::string& key)
diff --git a/settings.cpp b/settings.cpp
index e963a6d1..5c244435 100644
--- a/settings.cpp
+++ b/settings.cpp
@@ -73,7 +73,8 @@ vector<string> Settings::Keys()
}
-template<> vector<string> Settings::QueryProperty<vector<string>>(const string& key, const string& property)
+template <>
+vector<string> Settings::QueryProperty<vector<string>>(const string& key, const string& property)
{
size_t size = 0;
char** outBuffer = (char**)BNSettingsQueryPropertyStringList(m_object, key.c_str(), property.c_str(), &size);
@@ -136,7 +137,8 @@ bool Settings::UpdateProperty(const std::string& key, const std::string& propert
}
-bool Settings::UpdateProperty(const std::string& key, const std::string& property, const std::vector<std::string>& value)
+bool Settings::UpdateProperty(
+ const std::string& key, const std::string& property, const std::vector<std::string>& value)
{
char** buffer = new char*[value.size()];
if (!buffer)
@@ -145,7 +147,8 @@ bool Settings::UpdateProperty(const std::string& key, const std::string& propert
for (size_t i = 0; i < value.size(); i++)
buffer[i] = BNAllocString(value[i].c_str());
- bool result = BNSettingsUpdateStringListProperty(m_object, key.c_str(), property.c_str(), (const char**)buffer, value.size());
+ bool result =
+ BNSettingsUpdateStringListProperty(m_object, key.c_str(), property.c_str(), (const char**)buffer, value.size());
BNFreeStringList(buffer, value.size());
return result;
}
@@ -193,31 +196,36 @@ bool Settings::ResetAll(Ref<BinaryView> view, BNSettingsScope scope, bool schema
}
-template<> bool Settings::Get<bool>(const string& key, Ref<BinaryView> view, BNSettingsScope* scope)
+template <>
+bool Settings::Get<bool>(const string& key, Ref<BinaryView> view, BNSettingsScope* scope)
{
return BNSettingsGetBool(m_object, key.c_str(), view ? view->GetObject() : nullptr, scope);
}
-template<> double Settings::Get<double>(const string& key, Ref<BinaryView> view, BNSettingsScope* scope)
+template <>
+double Settings::Get<double>(const string& key, Ref<BinaryView> view, BNSettingsScope* scope)
{
return BNSettingsGetDouble(m_object, key.c_str(), view ? view->GetObject() : nullptr, scope);
}
-template<> int64_t Settings::Get<int64_t>(const string& key, Ref<BinaryView> view, BNSettingsScope* scope)
+template <>
+int64_t Settings::Get<int64_t>(const string& key, Ref<BinaryView> view, BNSettingsScope* scope)
{
return BNSettingsGetInt64(m_object, key.c_str(), view ? view->GetObject() : nullptr, scope);
}
-template<> uint64_t Settings::Get<uint64_t>(const string& key, Ref<BinaryView> view, BNSettingsScope* scope)
+template <>
+uint64_t Settings::Get<uint64_t>(const string& key, Ref<BinaryView> view, BNSettingsScope* scope)
{
return BNSettingsGetUInt64(m_object, key.c_str(), view ? view->GetObject() : nullptr, scope);
}
-template<> string Settings::Get<string>(const string& key, Ref<BinaryView> view, BNSettingsScope* scope)
+template <>
+string Settings::Get<string>(const string& key, Ref<BinaryView> view, BNSettingsScope* scope)
{
char* tmpStr = BNSettingsGetString(m_object, key.c_str(), view ? view->GetObject() : nullptr, scope);
string result(tmpStr);
@@ -226,10 +234,12 @@ template<> string Settings::Get<string>(const string& key, Ref<BinaryView> view,
}
-template<> vector<string> Settings::Get<vector<string>>(const string& key, Ref<BinaryView> view, BNSettingsScope* scope)
+template <>
+vector<string> Settings::Get<vector<string>>(const string& key, Ref<BinaryView> view, BNSettingsScope* scope)
{
size_t size = 0;
- char** outBuffer = (char**)BNSettingsGetStringList(m_object, key.c_str(), view ? view->GetObject() : nullptr, scope, &size);
+ char** outBuffer =
+ (char**)BNSettingsGetStringList(m_object, key.c_str(), view ? view->GetObject() : nullptr, scope, &size);
vector<string> result;
result.reserve(size);
@@ -301,7 +311,8 @@ bool Settings::Set(const string& key, const vector<string>& value, Ref<BinaryVie
for (size_t i = 0; i < value.size(); i++)
buffer[i] = BNAllocString(value[i].c_str());
- bool result = BNSettingsSetStringList(m_object, view ? view->GetObject() : nullptr, scope, key.c_str(), (const char**)buffer, value.size());
+ bool result = BNSettingsSetStringList(
+ m_object, view ? view->GetObject() : nullptr, scope, key.c_str(), (const char**)buffer, value.size());
BNFreeStringList(buffer, value.size());
return result;
}
diff --git a/transform.cpp b/transform.cpp
index 0f35dd07..942857d1 100644
--- a/transform.cpp
+++ b/transform.cpp
@@ -30,9 +30,8 @@ Transform::Transform(BNTransform* xform)
}
-Transform::Transform(BNTransformType type, const string& name, const string& longName, const string& group):
- m_typeForRegister(type), m_nameForRegister(name), m_longNameForRegister(longName),
- m_groupForRegister(group)
+Transform::Transform(BNTransformType type, const string& name, const string& longName, const string& group) :
+ m_typeForRegister(type), m_nameForRegister(name), m_longNameForRegister(longName), m_groupForRegister(group)
{
m_object = nullptr;
}
@@ -67,7 +66,8 @@ void Transform::FreeParametersCallback(BNTransformParameterInfo* params, size_t
}
-bool Transform::DecodeCallback(void* ctxt, BNDataBuffer* input, BNDataBuffer* output, BNTransformParameter* params, size_t paramCount)
+bool Transform::DecodeCallback(
+ void* ctxt, BNDataBuffer* input, BNDataBuffer* output, BNTransformParameter* params, size_t paramCount)
{
map<string, DataBuffer> paramMap;
for (size_t i = 0; i < paramCount; i++)
@@ -83,7 +83,8 @@ bool Transform::DecodeCallback(void* ctxt, BNDataBuffer* input, BNDataBuffer* ou
}
-bool Transform::EncodeCallback(void* ctxt, BNDataBuffer* input, BNDataBuffer* output, BNTransformParameter* params, size_t paramCount)
+bool Transform::EncodeCallback(
+ void* ctxt, BNDataBuffer* input, BNDataBuffer* output, BNTransformParameter* params, size_t paramCount)
{
map<string, DataBuffer> paramMap;
for (size_t i = 0; i < paramCount; i++)
@@ -137,8 +138,7 @@ void Transform::Register(Transform* xform)
callbacks.encode = EncodeCallback;
xform->AddRefForRegistration();
xform->m_object = BNRegisterTransformType(xform->m_typeForRegister, xform->m_nameForRegister.c_str(),
- xform->m_longNameForRegister.c_str(), xform->m_groupForRegister.c_str(),
- &callbacks);
+ xform->m_longNameForRegister.c_str(), xform->m_groupForRegister.c_str(), &callbacks);
}
@@ -219,9 +219,7 @@ bool Transform::Encode(const DataBuffer&, DataBuffer&, const map<string, DataBuf
}
-CoreTransform::CoreTransform(BNTransform* xform): Transform(xform)
-{
-}
+CoreTransform::CoreTransform(BNTransform* xform) : Transform(xform) {}
vector<TransformParameter> CoreTransform::GetParameters() const
diff --git a/type.cpp b/type.cpp
index bb07910d..ff0f3ff9 100644
--- a/type.cpp
+++ b/type.cpp
@@ -25,37 +25,28 @@ using namespace BinaryNinja;
using namespace std;
-NameList::NameList(const string& join): m_join(join)
-{
-}
+NameList::NameList(const string& join) : m_join(join) {}
-NameList::NameList(const string& name, const string& join): m_join(join)
+NameList::NameList(const string& name, const string& join) : m_join(join)
{
if (!name.empty())
m_name.push_back(name);
}
-NameList::NameList(const vector<string>& name, const string& join): m_join(join), m_name(name)
-{
-}
+NameList::NameList(const vector<string>& name, const string& join) : m_join(join), m_name(name) {}
-NameList::NameList(const NameList& name, const string& join): m_join(join), m_name(name.m_name)
-{
-}
+NameList::NameList(const NameList& name, const string& join) : m_join(join), m_name(name.m_name) {}
-NameList::NameList(const NameList& name): m_join(name.m_join), m_name(name.m_name)
-{
-}
+NameList::NameList(const NameList& name) : m_join(name.m_join), m_name(name.m_name) {}
-NameList::~NameList()
-{}
+NameList::~NameList() {}
NameList& NameList::operator=(const string& name)
{
- m_name = vector<string>{name};
+ m_name = vector<string> {name};
return *this;
}
@@ -215,7 +206,7 @@ string NameList::GetString() const
{
bool first = true;
string out;
- for (auto &name : m_name)
+ for (auto& name : m_name)
{
if (!first)
{
@@ -262,34 +253,24 @@ NameList NameList::FromAPIObject(BNNameList* name)
}
+QualifiedName::QualifiedName() : NameList("::") {}
-QualifiedName::QualifiedName(): NameList("::")
-{
-}
+QualifiedName::QualifiedName(const string& name) : NameList(name, "::") {}
-QualifiedName::QualifiedName(const string& name): NameList(name, "::")
-{
-}
-
-QualifiedName::QualifiedName(const vector<string>& name): NameList(name, "::")
-{
-}
+QualifiedName::QualifiedName(const vector<string>& name) : NameList(name, "::") {}
-QualifiedName::QualifiedName(const QualifiedName& name): NameList(name.m_name, "::")
-{
-}
+QualifiedName::QualifiedName(const QualifiedName& name) : NameList(name.m_name, "::") {}
-QualifiedName::~QualifiedName()
-{}
+QualifiedName::~QualifiedName() {}
QualifiedName& QualifiedName::operator=(const string& name)
{
- m_name = vector<string>{name};
+ m_name = vector<string> {name};
m_join = "::";
return *this;
}
@@ -350,33 +331,24 @@ QualifiedName QualifiedName::FromAPIObject(BNQualifiedName* name)
}
-NameSpace::NameSpace(): NameList("::")
-{
-}
+NameSpace::NameSpace() : NameList("::") {}
-NameSpace::NameSpace(const string& name): NameList(name, "::")
-{
-}
+NameSpace::NameSpace(const string& name) : NameList(name, "::") {}
-NameSpace::NameSpace(const vector<string>& name): NameList(name, "::")
-{
-}
+NameSpace::NameSpace(const vector<string>& name) : NameList(name, "::") {}
-NameSpace::NameSpace(const NameSpace& name): NameList(name.m_name, "::")
-{
-}
+NameSpace::NameSpace(const NameSpace& name) : NameList(name.m_name, "::") {}
-NameSpace::~NameSpace()
-{}
+NameSpace::~NameSpace() {}
NameSpace& NameSpace::operator=(const string& name)
{
- m_name = vector<string>{name};
+ m_name = vector<string> {name};
m_join = "::";
return *this;
}
@@ -636,8 +608,8 @@ string Type::GetStringAfterName(Platform* platform) const
vector<InstructionTextToken> Type::GetTokens(Platform* platform, uint8_t baseConfidence) const
{
size_t count;
- BNInstructionTextToken* tokens = BNGetTypeTokens(m_object,
- platform ? platform->GetObject() : nullptr, baseConfidence, &count);
+ BNInstructionTextToken* tokens =
+ BNGetTypeTokens(m_object, platform ? platform->GetObject() : nullptr, baseConfidence, &count);
return InstructionTextToken::ConvertAndFreeInstructionTextTokenList(tokens, count);
}
@@ -646,8 +618,8 @@ vector<InstructionTextToken> Type::GetTokens(Platform* platform, uint8_t baseCon
vector<InstructionTextToken> Type::GetTokensBeforeName(Platform* platform, uint8_t baseConfidence) const
{
size_t count;
- BNInstructionTextToken* tokens = BNGetTypeTokensBeforeName(m_object,
- platform ? platform->GetObject() : nullptr, baseConfidence, &count);
+ BNInstructionTextToken* tokens =
+ BNGetTypeTokensBeforeName(m_object, platform ? platform->GetObject() : nullptr, baseConfidence, &count);
return InstructionTextToken::ConvertAndFreeInstructionTextTokenList(tokens, count);
}
@@ -655,8 +627,8 @@ vector<InstructionTextToken> Type::GetTokensBeforeName(Platform* platform, uint8
vector<InstructionTextToken> Type::GetTokensAfterName(Platform* platform, uint8_t baseConfidence) const
{
size_t count;
- BNInstructionTextToken* tokens = BNGetTypeTokensAfterName(m_object,
- platform ? platform->GetObject() : nullptr, baseConfidence, &count);
+ BNInstructionTextToken* tokens =
+ BNGetTypeTokensAfterName(m_object, platform ? platform->GetObject() : nullptr, baseConfidence, &count);
return InstructionTextToken::ConvertAndFreeInstructionTextTokenList(tokens, count);
}
@@ -707,7 +679,8 @@ Ref<Type> Type::StructureType(Structure* strct)
}
-Ref<Type> Type::NamedType(NamedTypeReference* ref, size_t width, size_t align, const Confidence<bool>& cnst, const Confidence<bool>& vltl)
+Ref<Type> Type::NamedType(
+ NamedTypeReference* ref, size_t width, size_t align, const Confidence<bool>& cnst, const Confidence<bool>& vltl)
{
BNBoolWithConfidence cnstConf;
cnstConf.value = cnst.GetValue();
@@ -730,8 +703,7 @@ Ref<Type> Type::NamedType(const QualifiedName& name, Type* type)
Ref<Type> Type::NamedType(const string& id, const QualifiedName& name, Type* type)
{
BNQualifiedName nameObj = name.GetAPIObject();
- BNType* coreObj = BNCreateNamedTypeReferenceFromTypeAndId(id.c_str(), &nameObj,
- type ? type->GetObject() : nullptr);
+ BNType* coreObj = BNCreateNamedTypeReferenceFromTypeAndId(id.c_str(), &nameObj, type ? type->GetObject() : nullptr);
QualifiedName::FreeAPIObject(&nameObj);
return coreObj ? new Type(coreObj) : nullptr;
}
@@ -764,8 +736,8 @@ Ref<Type> Type::EnumerationType(Enumeration* enm, size_t width, const Confidence
}
-Ref<Type> Type::PointerType(Architecture* arch, const Confidence<Ref<Type>>& type,
- const Confidence<bool>& cnst, const Confidence<bool>& vltl, BNReferenceType refType)
+Ref<Type> Type::PointerType(Architecture* arch, const Confidence<Ref<Type>>& type, const Confidence<bool>& cnst,
+ const Confidence<bool>& vltl, BNReferenceType refType)
{
BNTypeWithConfidence typeConf;
typeConf.type = type->GetObject();
@@ -783,8 +755,8 @@ Ref<Type> Type::PointerType(Architecture* arch, const Confidence<Ref<Type>>& typ
}
-Ref<Type> Type::PointerType(size_t width, const Confidence<Ref<Type>>& type,
- const Confidence<bool>& cnst, const Confidence<bool>& vltl, BNReferenceType refType)
+Ref<Type> Type::PointerType(size_t width, const Confidence<Ref<Type>>& type, const Confidence<bool>& cnst,
+ const Confidence<bool>& vltl, BNReferenceType refType)
{
BNTypeWithConfidence typeConf;
typeConf.type = type->GetObject();
@@ -812,9 +784,8 @@ Ref<Type> Type::ArrayType(const Confidence<Ref<Type>>& type, uint64_t elem)
Ref<Type> Type::FunctionType(const Confidence<Ref<Type>>& returnValue,
- const Confidence<Ref<CallingConvention>>& callingConvention,
- const std::vector<FunctionParameter>& params, const Confidence<bool>& varArg,
- const Confidence<int64_t>& stackAdjust)
+ const Confidence<Ref<CallingConvention>>& callingConvention, const std::vector<FunctionParameter>& params,
+ const Confidence<bool>& varArg, const Confidence<int64_t>& stackAdjust)
{
BNTypeWithConfidence returnValueConf;
returnValueConf.type = returnValue->GetObject();
@@ -844,8 +815,8 @@ Ref<Type> Type::FunctionType(const Confidence<Ref<Type>>& returnValue,
stackAdjustConf.value = stackAdjust.GetValue();
stackAdjustConf.confidence = stackAdjust.GetConfidence();
- Type* type = new Type(BNCreateFunctionType(&returnValueConf, &callingConventionConf,
- paramArray, params.size(), &varArgConf, &stackAdjustConf));
+ Type* type = new Type(BNCreateFunctionType(
+ &returnValueConf, &callingConventionConf, paramArray, params.size(), &varArgConf, &stackAdjustConf));
delete[] paramArray;
return type;
}
@@ -991,7 +962,7 @@ Ref<Type> Type::WithReplacedNamedTypeReference(NamedTypeReference* from, NamedTy
bool Type::AddTypeMemberTokens(BinaryView* data, vector<InstructionTextToken>& tokens, int64_t offset,
- vector<string>& nameList, size_t size, bool indirect)
+ vector<string>& nameList, size_t size, bool indirect)
{
size_t tokenCount;
BNInstructionTextToken* list;
@@ -999,10 +970,12 @@ bool Type::AddTypeMemberTokens(BinaryView* data, vector<InstructionTextToken>& t
size_t nameCount;
char** names = nullptr;
- if (!BNAddTypeMemberTokens(m_object, data->GetObject(), &list, &tokenCount, offset, &names, &nameCount, size, indirect))
+ if (!BNAddTypeMemberTokens(
+ m_object, data->GetObject(), &list, &tokenCount, offset, &names, &nameCount, size, indirect))
return false;
- vector<InstructionTextToken> newTokens = InstructionTextToken::ConvertAndFreeInstructionTextTokenList(list, tokenCount);
+ vector<InstructionTextToken> newTokens =
+ InstructionTextToken::ConvertAndFreeInstructionTextTokenList(list, tokenCount);
tokens.insert(tokens.end(), newTokens.begin(), newTokens.end());
nameList.clear();
@@ -1323,8 +1296,8 @@ string TypeBuilder::GetStringAfterName(Platform* platform) const
vector<InstructionTextToken> TypeBuilder::GetTokens(Platform* platform, uint8_t baseConfidence) const
{
size_t count;
- BNInstructionTextToken* tokens = BNGetTypeBuilderTokens(m_object,
- platform ? platform->GetObject() : nullptr, baseConfidence, &count);
+ BNInstructionTextToken* tokens =
+ BNGetTypeBuilderTokens(m_object, platform ? platform->GetObject() : nullptr, baseConfidence, &count);
return InstructionTextToken::ConvertAndFreeInstructionTextTokenList(tokens, count);
}
@@ -1333,8 +1306,8 @@ vector<InstructionTextToken> TypeBuilder::GetTokens(Platform* platform, uint8_t
vector<InstructionTextToken> TypeBuilder::GetTokensBeforeName(Platform* platform, uint8_t baseConfidence) const
{
size_t count;
- BNInstructionTextToken* tokens = BNGetTypeBuilderTokensBeforeName(m_object,
- platform ? platform->GetObject() : nullptr, baseConfidence, &count);
+ BNInstructionTextToken* tokens =
+ BNGetTypeBuilderTokensBeforeName(m_object, platform ? platform->GetObject() : nullptr, baseConfidence, &count);
return InstructionTextToken::ConvertAndFreeInstructionTextTokenList(tokens, count);
}
@@ -1342,8 +1315,8 @@ vector<InstructionTextToken> TypeBuilder::GetTokensBeforeName(Platform* platform
vector<InstructionTextToken> TypeBuilder::GetTokensAfterName(Platform* platform, uint8_t baseConfidence) const
{
size_t count;
- BNInstructionTextToken* tokens = BNGetTypeBuilderTokensAfterName(m_object,
- platform ? platform->GetObject() : nullptr, baseConfidence, &count);
+ BNInstructionTextToken* tokens =
+ BNGetTypeBuilderTokensAfterName(m_object, platform ? platform->GetObject() : nullptr, baseConfidence, &count);
return InstructionTextToken::ConvertAndFreeInstructionTextTokenList(tokens, count);
}
@@ -1394,7 +1367,8 @@ TypeBuilder TypeBuilder::StructureType(StructureBuilder* strct)
}
-TypeBuilder TypeBuilder::NamedType(NamedTypeReference* ref, size_t width, size_t align, const Confidence<bool>& cnst, const Confidence<bool>& vltl)
+TypeBuilder TypeBuilder::NamedType(
+ NamedTypeReference* ref, size_t width, size_t align, const Confidence<bool>& cnst, const Confidence<bool>& vltl)
{
BNBoolWithConfidence cnstConf;
cnstConf.value = cnst.GetValue();
@@ -1407,7 +1381,8 @@ TypeBuilder TypeBuilder::NamedType(NamedTypeReference* ref, size_t width, size_t
}
-TypeBuilder TypeBuilder::NamedType(NamedTypeReferenceBuilder* ref, size_t width, size_t align, const Confidence<bool>& cnst, const Confidence<bool>& vltl)
+TypeBuilder TypeBuilder::NamedType(NamedTypeReferenceBuilder* ref, size_t width, size_t align,
+ const Confidence<bool>& cnst, const Confidence<bool>& vltl)
{
BNBoolWithConfidence cnstConf;
cnstConf.value = cnst.GetValue();
@@ -1416,7 +1391,8 @@ TypeBuilder TypeBuilder::NamedType(NamedTypeReferenceBuilder* ref, size_t width,
BNBoolWithConfidence vltlConf;
vltlConf.value = vltl.GetValue();
vltlConf.confidence = vltl.GetConfidence();
- return TypeBuilder(BNCreateNamedTypeReferenceBuilderWithBuilder(ref->GetObject(), width, align, &cnstConf, &vltlConf));
+ return TypeBuilder(
+ BNCreateNamedTypeReferenceBuilderWithBuilder(ref->GetObject(), width, align, &cnstConf, &vltlConf));
}
@@ -1429,8 +1405,8 @@ TypeBuilder TypeBuilder::NamedType(const QualifiedName& name, Type* type)
TypeBuilder TypeBuilder::NamedType(const string& id, const QualifiedName& name, Type* type)
{
BNQualifiedName nameObj = name.GetAPIObject();
- BNTypeBuilder* coreObj = BNCreateNamedTypeReferenceBuilderFromTypeAndId(id.c_str(), &nameObj,
- type ? type->GetObject() : nullptr);
+ BNTypeBuilder* coreObj =
+ BNCreateNamedTypeReferenceBuilderFromTypeAndId(id.c_str(), &nameObj, type ? type->GetObject() : nullptr);
QualifiedName::FreeAPIObject(&nameObj);
return coreObj ? TypeBuilder(coreObj) : VoidType();
}
@@ -1445,25 +1421,29 @@ TypeBuilder TypeBuilder::NamedType(BinaryView* view, const QualifiedName& name)
}
-TypeBuilder TypeBuilder::EnumerationType(Architecture* arch, Enumeration* enm, size_t width, const Confidence<bool>& isSigned)
+TypeBuilder TypeBuilder::EnumerationType(
+ Architecture* arch, Enumeration* enm, size_t width, const Confidence<bool>& isSigned)
{
BNBoolWithConfidence isSignedConf;
isSignedConf.value = isSigned.GetValue();
isSignedConf.confidence = isSigned.GetConfidence();
- return TypeBuilder(BNCreateEnumerationTypeBuilder(arch ? arch->GetObject() : nullptr, enm->GetObject(), width, &isSignedConf));
+ return TypeBuilder(
+ BNCreateEnumerationTypeBuilder(arch ? arch->GetObject() : nullptr, enm->GetObject(), width, &isSignedConf));
}
-TypeBuilder TypeBuilder::EnumerationType(Architecture* arch, EnumerationBuilder* enm, size_t width, const Confidence<bool>& isSigned)
+TypeBuilder TypeBuilder::EnumerationType(
+ Architecture* arch, EnumerationBuilder* enm, size_t width, const Confidence<bool>& isSigned)
{
BNBoolWithConfidence isSignedConf;
isSignedConf.value = isSigned.GetValue();
isSignedConf.confidence = isSigned.GetConfidence();
- return TypeBuilder(BNCreateEnumerationTypeBuilderWithBuilder(arch->GetObject(), enm->GetObject(), width, &isSignedConf));
+ return TypeBuilder(
+ BNCreateEnumerationTypeBuilderWithBuilder(arch->GetObject(), enm->GetObject(), width, &isSignedConf));
}
TypeBuilder TypeBuilder::PointerType(Architecture* arch, const Confidence<Ref<Type>>& type,
- const Confidence<bool>& cnst, const Confidence<bool>& vltl, BNReferenceType refType)
+ const Confidence<bool>& cnst, const Confidence<bool>& vltl, BNReferenceType refType)
{
BNTypeWithConfidence typeConf;
typeConf.type = type->GetObject();
@@ -1481,8 +1461,8 @@ TypeBuilder TypeBuilder::PointerType(Architecture* arch, const Confidence<Ref<Ty
}
-TypeBuilder TypeBuilder::PointerType(size_t width, const Confidence<Ref<Type>>& type,
- const Confidence<bool>& cnst, const Confidence<bool>& vltl, BNReferenceType refType)
+TypeBuilder TypeBuilder::PointerType(size_t width, const Confidence<Ref<Type>>& type, const Confidence<bool>& cnst,
+ const Confidence<bool>& vltl, BNReferenceType refType)
{
BNTypeWithConfidence typeConf;
typeConf.type = type->GetObject();
@@ -1527,9 +1507,8 @@ static BNFunctionParameter* GetParamArray(const std::vector<FunctionParameter>&
}
TypeBuilder TypeBuilder::FunctionType(const Confidence<Ref<Type>>& returnValue,
- const Confidence<Ref<CallingConvention>>& callingConvention,
- const std::vector<FunctionParameter>& params, const Confidence<bool>& varArg,
- const Confidence<int64_t>& stackAdjust)
+ const Confidence<Ref<CallingConvention>>& callingConvention, const std::vector<FunctionParameter>& params,
+ const Confidence<bool>& varArg, const Confidence<int64_t>& stackAdjust)
{
BNTypeWithConfidence returnValueConf;
returnValueConf.type = returnValue->GetObject();
@@ -1550,8 +1529,8 @@ TypeBuilder TypeBuilder::FunctionType(const Confidence<Ref<Type>>& returnValue,
stackAdjustConf.value = stackAdjust.GetValue();
stackAdjustConf.confidence = stackAdjust.GetConfidence();
- TypeBuilder type(BNCreateFunctionTypeBuilder(&returnValueConf, &callingConventionConf,
- paramArray, paramCount, &varArgConf, &stackAdjustConf));
+ TypeBuilder type(BNCreateFunctionTypeBuilder(
+ &returnValueConf, &callingConventionConf, paramArray, paramCount, &varArgConf, &stackAdjustConf));
delete[] paramArray;
return type;
}
@@ -1667,24 +1646,24 @@ QualifiedName NamedTypeReference::GetName() const
}
-Ref<NamedTypeReference> NamedTypeReference::GenerateAutoTypeReference(BNNamedTypeReferenceClass cls,
- const string& source, const QualifiedName& name)
+Ref<NamedTypeReference> NamedTypeReference::GenerateAutoTypeReference(
+ BNNamedTypeReferenceClass cls, const string& source, const QualifiedName& name)
{
string id = Type::GenerateAutoTypeId(source, name);
return new NamedTypeReference(cls, id, name);
}
-Ref<NamedTypeReference> NamedTypeReference::GenerateAutoDemangledTypeReference(BNNamedTypeReferenceClass cls,
- const QualifiedName& name)
+Ref<NamedTypeReference> NamedTypeReference::GenerateAutoDemangledTypeReference(
+ BNNamedTypeReferenceClass cls, const QualifiedName& name)
{
string id = Type::GenerateAutoDemangledTypeId(name);
return new NamedTypeReference(cls, id, name);
}
-Ref<NamedTypeReference> NamedTypeReference::GenerateAutoDebugTypeReference(BNNamedTypeReferenceClass cls,
- const QualifiedName& name)
+Ref<NamedTypeReference> NamedTypeReference::GenerateAutoDebugTypeReference(
+ BNNamedTypeReferenceClass cls, const QualifiedName& name)
{
string id = Type::GenerateAutoDebugTypeId(name);
return new NamedTypeReference(cls, id, name);
@@ -1697,10 +1676,9 @@ NamedTypeReferenceBuilder::NamedTypeReferenceBuilder(BNNamedTypeReferenceBuilder
}
-NamedTypeReferenceBuilder::NamedTypeReferenceBuilder(BNNamedTypeReferenceClass cls, const std::string& id,
- const QualifiedName& name)
+NamedTypeReferenceBuilder::NamedTypeReferenceBuilder(
+ BNNamedTypeReferenceClass cls, const std::string& id, const QualifiedName& name)
{
-
BNQualifiedName n = name.GetAPIObject();
m_object = BNCreateNamedTypeBuilder(cls, id.c_str(), &n);
QualifiedName::FreeAPIObject(&n);
@@ -2087,8 +2065,8 @@ BNStructureVariant StructureBuilder::GetStructureType() const
}
-StructureBuilder& StructureBuilder::AddMember(const Confidence<Ref<Type>>& type, const string& name,
- BNMemberAccess access, BNMemberScope scope)
+StructureBuilder& StructureBuilder::AddMember(
+ const Confidence<Ref<Type>>& type, const string& name, BNMemberAccess access, BNMemberScope scope)
{
BNTypeWithConfidence tc;
tc.type = type->GetObject();
@@ -2098,8 +2076,8 @@ StructureBuilder& StructureBuilder::AddMember(const Confidence<Ref<Type>>& type,
}
-StructureBuilder& StructureBuilder::AddMemberAtOffset(const Confidence<Ref<Type>>& type,
- const string& name, uint64_t offset, bool overwriteExisting, BNMemberAccess access, BNMemberScope scope)
+StructureBuilder& StructureBuilder::AddMemberAtOffset(const Confidence<Ref<Type>>& type, const string& name,
+ uint64_t offset, bool overwriteExisting, BNMemberAccess access, BNMemberScope scope)
{
BNTypeWithConfidence tc;
tc.type = type->GetObject();
@@ -2116,7 +2094,8 @@ StructureBuilder& StructureBuilder::RemoveMember(size_t idx)
}
-StructureBuilder& StructureBuilder::ReplaceMember(size_t idx, const Confidence<Ref<Type>>& type, const std::string& name, bool overwriteExisting)
+StructureBuilder& StructureBuilder::ReplaceMember(
+ size_t idx, const Confidence<Ref<Type>>& type, const std::string& name, bool overwriteExisting)
{
BNTypeWithConfidence tc;
tc.type = type->GetObject();
@@ -2272,8 +2251,8 @@ EnumerationBuilder& EnumerationBuilder::ReplaceMember(size_t idx, const string&
}
-bool BinaryNinja::PreprocessSource(const string& source, const string& fileName, string& output, string& errors,
- const vector<string>& includeDirs)
+bool BinaryNinja::PreprocessSource(
+ const string& source, const string& fileName, string& output, string& errors, const vector<string>& includeDirs)
{
char* outStr;
char* errorStr;
@@ -2282,8 +2261,8 @@ bool BinaryNinja::PreprocessSource(const string& source, const string& fileName,
for (size_t i = 0; i < includeDirs.size(); i++)
includeDirList[i] = includeDirs[i].c_str();
- bool result = BNPreprocessSource(source.c_str(), fileName.c_str(), &outStr, &errorStr,
- includeDirList, includeDirs.size());
+ bool result =
+ BNPreprocessSource(source.c_str(), fileName.c_str(), &outStr, &errorStr, includeDirList, includeDirs.size());
output = outStr;
errors = errorStr;
diff --git a/ui/action.h b/ui/action.h
index 19f3d317..ef43c779 100644
--- a/ui/action.h
+++ b/ui/action.h
@@ -4,9 +4,9 @@
#include <QtWidgets/QMenuBar>
#include <QtGui/QIcon>
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
-#include <QtWidgets/QShortcut>
+ #include <QtWidgets/QShortcut>
#else
-#include <QtGui/QShortcut>
+ #include <QtGui/QShortcut>
#endif
#include <QtCore/QPointer>
#include <functional>
@@ -15,11 +15,11 @@
#include <vector>
#include "uitypes.h"
-#define MENU_ORDER_FIRST 0
-#define MENU_ORDER_EARLY 64
+#define MENU_ORDER_FIRST 0
+#define MENU_ORDER_EARLY 64
#define MENU_ORDER_NORMAL 128
-#define MENU_ORDER_LATE 192
-#define MENU_ORDER_LAST 255
+#define MENU_ORDER_LATE 192
+#define MENU_ORDER_LAST 255
class View;
class UIContext;
@@ -68,20 +68,17 @@ struct BINARYNINJAUIAPI UIActionContext
struct BINARYNINJAUIAPI UIAction
{
- std::function<void (const UIActionContext& context)> activate;
- std::function<bool (const UIActionContext& context)> isValid;
+ std::function<void(const UIActionContext& context)> activate;
+ std::function<bool(const UIActionContext& context)> isValid;
UIAction();
- UIAction(const std::function<void (const UIActionContext& context)>& activate);
+ UIAction(const std::function<void(const UIActionContext& context)>& activate);
UIAction(const std::function<void()>& activate);
- UIAction(const std::function<void (const UIActionContext& context)>& activate,
- const std::function<bool (const UIActionContext& context)>& isValid);
- UIAction(const std::function<void()>& activate,
- const std::function<bool (const UIActionContext& context)>& isValid);
- UIAction(const std::function<void (const UIActionContext& context)>& activate,
- const std::function<bool()>& isValid);
- UIAction(const std::function<void()>& activate,
- const std::function<bool()>& isValid);
+ UIAction(const std::function<void(const UIActionContext& context)>& activate,
+ const std::function<bool(const UIActionContext& context)>& isValid);
+ UIAction(const std::function<void()>& activate, const std::function<bool(const UIActionContext& context)>& isValid);
+ UIAction(const std::function<void(const UIActionContext& context)>& activate, const std::function<bool()>& isValid);
+ UIAction(const std::function<void()>& activate, const std::function<bool()>& isValid);
UIAction(const UIAction& other);
UIAction& operator=(const UIAction& other);
@@ -97,7 +94,8 @@ struct BINARYNINJAUIAPI UIAction
static void setActionDisplayName(const QString& registeredName, const QString& displayName);
static void setActionDisplayName(const QString& registeredName, const std::function<QString()>& displayNameFunc);
- static void setActionDisplayName(const QString& registeredName, const std::function<QString(const UIActionContext&)>& displayNameFunc);
+ static void setActionDisplayName(
+ const QString& registeredName, const std::function<QString(const UIActionContext&)>& displayNameFunc);
static bool isActionRegistered(const QString& name);
static std::set<QString> getAllRegisteredActions();
@@ -116,48 +114,49 @@ struct BINARYNINJAUIAPI UIAction
struct BINARYNINJAUIAPI UITransformAction
{
- std::function<void (const UIActionContext& context, TransformRef xform)> activate;
- std::function<bool (const UIActionContext& context, TransformRef xform)> isValid;
+ std::function<void(const UIActionContext& context, TransformRef xform)> activate;
+ std::function<bool(const UIActionContext& context, TransformRef xform)> isValid;
UITransformAction();
- UITransformAction(const std::function<void (const UIActionContext& context, TransformRef xform)>& activate);
+ UITransformAction(const std::function<void(const UIActionContext& context, TransformRef xform)>& activate);
UITransformAction(const std::function<void(TransformRef xform)>& activate);
- UITransformAction(const std::function<void (const UIActionContext& context, TransformRef xform)>& activate,
- const std::function<bool (const UIActionContext& context, TransformRef xform)>& isValid);
+ UITransformAction(const std::function<void(const UIActionContext& context, TransformRef xform)>& activate,
+ const std::function<bool(const UIActionContext& context, TransformRef xform)>& isValid);
UITransformAction(const std::function<void(TransformRef xform)>& activate,
- const std::function<bool (const UIActionContext& context, TransformRef xform)>& isValid);
- UITransformAction(const std::function<void (const UIActionContext& context, TransformRef xform)>& activate,
- const std::function<bool(TransformRef xform)>& isValid);
+ const std::function<bool(const UIActionContext& context, TransformRef xform)>& isValid);
+ UITransformAction(const std::function<void(const UIActionContext& context, TransformRef xform)>& activate,
+ const std::function<bool(TransformRef xform)>& isValid);
UITransformAction(const std::function<void(TransformRef xform)>& activate,
- const std::function<bool(TransformRef xform)>& isValid);
+ const std::function<bool(TransformRef xform)>& isValid);
UITransformAction(const UITransformAction& other);
};
struct BINARYNINJAUIAPI UIHighlightColorAction
{
- std::function<void (const UIActionContext& context, BNHighlightColor color)> activate;
- std::function<bool (const UIActionContext& context)> isValid;
+ std::function<void(const UIActionContext& context, BNHighlightColor color)> activate;
+ std::function<bool(const UIActionContext& context)> isValid;
UIHighlightColorAction();
- UIHighlightColorAction(const std::function<void (const UIActionContext& context, BNHighlightColor color)>& activate);
+ UIHighlightColorAction(const std::function<void(const UIActionContext& context, BNHighlightColor color)>& activate);
UIHighlightColorAction(const std::function<void(BNHighlightColor color)>& activate);
- UIHighlightColorAction(const std::function<void (const UIActionContext& context, BNHighlightColor color)>& activate,
- const std::function<bool (const UIActionContext& context)>& isValid);
+ UIHighlightColorAction(const std::function<void(const UIActionContext& context, BNHighlightColor color)>& activate,
+ const std::function<bool(const UIActionContext& context)>& isValid);
UIHighlightColorAction(const std::function<void(BNHighlightColor color)>& activate,
- const std::function<bool (const UIActionContext& context)>& isValid);
- UIHighlightColorAction(const std::function<void (const UIActionContext& context, BNHighlightColor color)>& activate,
- const std::function<bool()>& isValid);
- UIHighlightColorAction(const std::function<void(BNHighlightColor color)>& activate,
- const std::function<bool()>& isValid);
+ const std::function<bool(const UIActionContext& context)>& isValid);
+ UIHighlightColorAction(const std::function<void(const UIActionContext& context, BNHighlightColor color)>& activate,
+ const std::function<bool()>& isValid);
+ UIHighlightColorAction(
+ const std::function<void(BNHighlightColor color)>& activate, const std::function<bool()>& isValid);
UIHighlightColorAction(const UIHighlightColorAction& other);
};
struct BINARYNINJAUIAPI UIBookmarkAction
{
- std::function<void (const UIActionContext& context, int index)> activate;
- std::function<bool (const UIActionContext& context, int index)> isValid;
+ std::function<void(const UIActionContext& context, int index)> activate;
+ std::function<bool(const UIActionContext& context, int index)> isValid;
- UIBookmarkAction(const std::function<void (const UIActionContext& context, int index)>& activate, const std::function<bool (const UIActionContext& context, int index)>& isValid);
+ UIBookmarkAction(const std::function<void(const UIActionContext& context, int index)>& activate,
+ const std::function<bool(const UIActionContext& context, int index)>& isValid);
};
enum ActionPriority
@@ -188,7 +187,7 @@ class BINARYNINJAUIAPI UIActionHandler
void addActionToChildren(const QString& name);
void removeActionFromChildren(const QString& name);
-public:
+ public:
UIActionHandler(bool isGlobal = false);
virtual ~UIActionHandler();
void setupActionHandler(QWidget* obj, bool inheritParentBindings = true);
@@ -216,8 +215,8 @@ public:
void bindPluginCommandActions();
void bindPluginCommandActions(const QString& prefix,
- const std::function<UIActionContext(const UIActionContext&, const BinaryNinja::PluginCommand&)>& context,
- const std::function<bool(const UIActionContext&, const BinaryNinja::PluginCommand&)>& isValid);
+ const std::function<UIActionContext(const UIActionContext&, const BinaryNinja::PluginCommand&)>& context,
+ const std::function<bool(const UIActionContext&, const BinaryNinja::PluginCommand&)>& isValid);
void unbindPluginCommandActions();
void unbindPluginCommandActions(const QString& prefix);
@@ -229,7 +228,8 @@ public:
void setActionDisplayName(const QString& registeredName, const QString& displayName);
void setActionDisplayName(const QString& registeredName, const std::function<QString()>& displayNameFunc);
- void setActionDisplayName(const QString& registeredName, const std::function<QString(const UIActionContext&)>& displayNameFunc);
+ void setActionDisplayName(
+ const QString& registeredName, const std::function<QString(const UIActionContext&)>& displayNameFunc);
QString getActionDisplayName(const QString& name);
QString getActionDisplayName(const QString& name, const UIActionContext& context);
@@ -281,12 +281,13 @@ class BINARYNINJAUIAPI Menu
Menu(bool global);
void setParentOrdering(const QString& path, const QString& group, uint8_t order);
-public:
+ public:
Menu();
Menu(const Menu& menu);
void addAction(const QString& action, const QString& group, uint8_t order = MENU_ORDER_NORMAL);
- void addAction(const QString& submenu, const QString& action, const QString& group, uint8_t order = MENU_ORDER_NORMAL);
+ void addAction(
+ const QString& submenu, const QString& action, const QString& group, uint8_t order = MENU_ORDER_NORMAL);
void removeAction(const QString& action);
void removeAction(const QString& submenu, const QString& action);
@@ -300,8 +301,8 @@ public:
void addPluginCommandActions(const QString& group);
void addPluginCommandActions(const QString& prefix, const QString& group, uint8_t order = MENU_ORDER_NORMAL);
void addPluginCommandSubmenuActions(const QString& submenu, const QString& group);
- void addPluginCommandSubmenuActions(const QString& submenu, const QString& prefix, const QString& group,
- uint8_t order = MENU_ORDER_NORMAL);
+ void addPluginCommandSubmenuActions(
+ const QString& submenu, const QString& prefix, const QString& group, uint8_t order = MENU_ORDER_NORMAL);
void removePluginCommandActions();
void removePluginCommandSubmenuActions(const QString& submenu);
@@ -317,8 +318,8 @@ public:
void setIcon(const QString& path, const QIcon& icon);
MenuInstance* create(QWidget* owner, UIActionHandler* handler, bool showInactiveActions = false);
- MenuInstance* create(QWidget* owner, UIActionHandler* handler, const UIActionContext& context,
- bool showInactiveActions = false);
+ MenuInstance* create(
+ QWidget* owner, UIActionHandler* handler, const UIActionContext& context, bool showInactiveActions = false);
uint64_t getVersion();
const std::map<QString, QString>& getActions();
@@ -364,11 +365,11 @@ class BINARYNINJAUIAPI MenuInstance
static std::map<QString, std::set<MenuInstance*>> m_actionBindings;
- std::vector<Group> layoutMenu(const std::map<QString, QString>& actions, const QString& prefix,
- bool showInactiveActions);
+ std::vector<Group> layoutMenu(
+ const std::map<QString, QString>& actions, const QString& prefix, bool showInactiveActions);
void addGroupsToMenu(QMenu* menu, const std::vector<Group>& groups);
-public:
+ public:
MenuInstance(Menu* menu, QMenu* instance);
virtual ~MenuInstance();
void update(UIActionHandler* handler, bool showInactiveActions = false);
@@ -385,7 +386,7 @@ class BINARYNINJAUIAPI MainMenuInstance
QMenuBar* m_instance;
std::map<QString, MenuInstance*> m_menus;
-public:
+ public:
MainMenuInstance(QMenuBar* instance);
~MainMenuInstance();
void update(UIActionHandler* handler);
diff --git a/ui/addressdialog.h b/ui/addressdialog.h
index 261f0732..f1dfec84 100644
--- a/ui/addressdialog.h
+++ b/ui/addressdialog.h
@@ -7,14 +7,14 @@
#include <QtWidgets/QComboBox>
#include <QtCore/QTimer>
#ifndef BINARYNINJAUI_BINDINGS
-#include <QtCore/QThread>
+ #include <QtCore/QThread>
#endif
#include "binaryninjaapi.h"
#include "uitypes.h"
#include "getsymbolslistthread.h"
-class BINARYNINJAUIAPI AddressDialogWithPreview: public QDialog
+class BINARYNINJAUIAPI AddressDialogWithPreview : public QDialog
{
Q_OBJECT
@@ -40,7 +40,7 @@ class BINARYNINJAUIAPI AddressDialogWithPreview: public QDialog
void commitHistory();
void customEvent(QEvent* event);
-private Q_SLOTS:
+ private Q_SLOTS:
void updateTimerEvent();
void accepted();
void updateRelativeState(int state);
@@ -48,14 +48,14 @@ private Q_SLOTS:
void updatePreviewText();
void updatePreviewWithText(QString data);
-public:
- AddressDialogWithPreview(QWidget* parent, BinaryViewRef view, uint64_t here,
- const QString& title = "Go to Address", const QString& prompt = "Enter Expression", bool defaultToCurrent = false);
+ public:
+ AddressDialogWithPreview(QWidget* parent, BinaryViewRef view, uint64_t here, const QString& title = "Go to Address",
+ const QString& prompt = "Enter Expression", bool defaultToCurrent = false);
~AddressDialogWithPreview() { delete m_updateThread; }
uint64_t getOffset() const { return m_addr; }
};
-class BINARYNINJAUIAPI FileOffsetDialogWithPreview: public QDialog
+class BINARYNINJAUIAPI FileOffsetDialogWithPreview : public QDialog
{
Q_OBJECT
@@ -77,27 +77,28 @@ class BINARYNINJAUIAPI FileOffsetDialogWithPreview: public QDialog
void commitHistory();
-private Q_SLOTS:
+ private Q_SLOTS:
void updateTimerEvent();
void accepted();
void updatePreview();
void updatePreviewText();
void updatePreview(QString data);
-public:
+ public:
FileOffsetDialogWithPreview(QWidget* parent, BinaryViewRef view, uint64_t here,
- const QString& title = "Go to File Offset", const QString& prompt = "Enter Expression", bool defaultToCurrent = false);
+ const QString& title = "Go to File Offset", const QString& prompt = "Enter Expression",
+ bool defaultToCurrent = false);
~FileOffsetDialogWithPreview() {}
uint64_t getOffset() const { return m_fileOffset; }
};
-class BINARYNINJAUIAPI AddUserXrefDialog: public QDialog
+class BINARYNINJAUIAPI AddUserXrefDialog : public QDialog
{
Q_OBJECT
QComboBox* m_combo;
QStringListModel* m_model;
- QLabel* m_previewText, m_sizePrompt;
+ QLabel *m_previewText, m_sizePrompt;
QLineEdit* m_sizeInput;
BinaryViewRef m_view;
uint64_t m_addr;
@@ -118,18 +119,18 @@ class BINARYNINJAUIAPI AddUserXrefDialog: public QDialog
void commitHistory();
void customEvent(QEvent* event);
-private Q_SLOTS:
+ private Q_SLOTS:
void updateTimerEvent();
void accepted();
void updatePreview();
void updatePreviewText();
void updatePreviewWithText(QString data);
-public:
- AddUserXrefDialog(QWidget* parent, BinaryViewRef view, uint64_t here = 0,
- size_t size = 0, const QString& title = "Add User Type Field Cross Reference",
- const QString& sizeTitle = "Size of Reference (optional)",
- const QString& prompt = "Enter Expression", bool defaultToCurrent = false);
+ public:
+ AddUserXrefDialog(QWidget* parent, BinaryViewRef view, uint64_t here = 0, size_t size = 0,
+ const QString& title = "Add User Type Field Cross Reference",
+ const QString& sizeTitle = "Size of Reference (optional)", const QString& prompt = "Enter Expression",
+ bool defaultToCurrent = false);
~AddUserXrefDialog() { delete m_updateThread; }
uint64_t getOffset() const { return m_addr; }
size_t getSize() const { return m_size; }
diff --git a/ui/addressindicator.h b/ui/addressindicator.h
index d67e7d79..3288de35 100644
--- a/ui/addressindicator.h
+++ b/ui/addressindicator.h
@@ -6,19 +6,19 @@
#include "uicontext.h"
-class BINARYNINJAUIAPI AddressIndicator: public MenuHelper
+class BINARYNINJAUIAPI AddressIndicator : public MenuHelper
{
Q_OBJECT
uint64_t m_begin, m_end;
BinaryViewRef m_view;
-public:
+ public:
AddressIndicator(QWidget* parent);
void clear();
void setOffsets(uint64_t begin, uint64_t end, BinaryViewRef view);
-protected:
+ protected:
virtual void showMenu();
};
diff --git a/ui/assembledialog.h b/ui/assembledialog.h
index 7db619a2..62be31ef 100644
--- a/ui/assembledialog.h
+++ b/ui/assembledialog.h
@@ -6,7 +6,7 @@
#include "dialogtextedit.h"
#include "uicontext.h"
-class BINARYNINJAUIAPI AssembleDialog: public QDialog
+class BINARYNINJAUIAPI AssembleDialog : public QDialog
{
Q_OBJECT
@@ -19,19 +19,18 @@ class BINARYNINJAUIAPI AssembleDialog: public QDialog
BinaryNinja::DataBuffer m_bytes;
bool m_setDefault;
-public:
+ public:
AssembleDialog(QWidget* parent, BinaryViewRef data, uint64_t addr, ArchitectureRef prefArch = NULL,
- const QString& code = "", bool fixedArch = false);
+ const QString& code = "", bool fixedArch = false);
ArchitectureRef getArchitecture();
const BinaryNinja::DataBuffer& getBytes() const { return m_bytes; }
void setLength(size_t len) { m_length = len; }
-private Q_SLOTS:
+ private Q_SLOTS:
void saveOnFinish(int result);
void assemble();
-protected:
+ protected:
virtual void accept() override;
-
};
diff --git a/ui/clickablelabel.h b/ui/clickablelabel.h
index 0b373d6b..a1116f0b 100644
--- a/ui/clickablelabel.h
+++ b/ui/clickablelabel.h
@@ -18,23 +18,27 @@ struct BINARYNINJAUIAPI IconImage
};
-class BINARYNINJAUIAPI ClickableLabel: public QLabel
+class BINARYNINJAUIAPI ClickableLabel : public QLabel
{
Q_OBJECT
-public:
- ClickableLabel(QWidget* parent = nullptr, const QString& name = ""): QLabel(parent) { setText(name); }
+ public:
+ ClickableLabel(QWidget* parent = nullptr, const QString& name = "") : QLabel(parent) { setText(name); }
-Q_SIGNALS:
+ Q_SIGNALS:
void clicked();
-protected:
+ protected:
void mousePressEvent(QMouseEvent*) override {}
- void mouseReleaseEvent(QMouseEvent* event) override { if (event->button() == Qt::LeftButton) Q_EMIT clicked(); }
+ void mouseReleaseEvent(QMouseEvent* event) override
+ {
+ if (event->button() == Qt::LeftButton)
+ Q_EMIT clicked();
+ }
};
-class BINARYNINJAUIAPI ClickableIcon: public QWidget
+class BINARYNINJAUIAPI ClickableIcon : public QWidget
{
Q_OBJECT
@@ -44,7 +48,7 @@ class BINARYNINJAUIAPI ClickableIcon: public QWidget
bool m_hover = false;
QTimer* m_timer;
-public:
+ public:
ClickableIcon(const QImage& icon, const QSize& desiredPointSize);
void setAllowToggle(bool canToggle);
@@ -53,15 +57,15 @@ public:
void setImage(const QImage& icon);
-Q_SIGNALS:
+ Q_SIGNALS:
void clicked();
void toggle(bool newState);
-private Q_SLOTS:
+ private Q_SLOTS:
void underMouseTimerEvent();
void handleToggle();
-protected:
+ protected:
void enterEvent(QEnterEvent* event) override;
void leaveEvent(QEvent* event) override;
void paintEvent(QPaintEvent* event) override;
@@ -70,7 +74,7 @@ protected:
};
-class BINARYNINJAUIAPI ClickableStateLabel: public ClickableLabel
+class BINARYNINJAUIAPI ClickableStateLabel : public ClickableLabel
{
Q_OBJECT
@@ -82,25 +86,30 @@ class BINARYNINJAUIAPI ClickableStateLabel: public ClickableLabel
QPalette::ColorRole m_altOverlayColorRole;
int m_alpha;
-public:
- ClickableStateLabel(QWidget* parent, const QString& name, const QString& altName): ClickableLabel(parent, name), m_name(name), m_altName(altName) { }
+ public:
+ ClickableStateLabel(QWidget* parent, const QString& name, const QString& altName) :
+ ClickableLabel(parent, name), m_name(name), m_altName(altName)
+ {}
bool getState() { return m_state; }
- void setDisplayState(bool state) {
+ void setDisplayState(bool state)
+ {
m_state = state;
setText(m_state ? m_name : m_altName);
}
- void setAlternateTransparency(QPalette::ColorRole colorRole, int alpha, bool state) {
+ void setAlternateTransparency(QPalette::ColorRole colorRole, int alpha, bool state)
+ {
m_altOverlayColorRole = colorRole;
m_alpha = alpha;
m_altStateEffect = state;
m_stateEffectEnabled = true;
}
-protected:
- void paintEvent(QPaintEvent* event) override {
+ protected:
+ void paintEvent(QPaintEvent* event) override
+ {
ClickableLabel::paintEvent(event);
if (m_stateEffectEnabled && (m_state == m_altStateEffect))
{
diff --git a/ui/commandpalette.h b/ui/commandpalette.h
index eab17f39..af773ba9 100644
--- a/ui/commandpalette.h
+++ b/ui/commandpalette.h
@@ -20,19 +20,19 @@ class CommandPalette;
class CommandListFilter;
-class BINARYNINJAUIAPI CommandListDelegate: public QStyledItemDelegate
+class BINARYNINJAUIAPI CommandListDelegate : public QStyledItemDelegate
{
Q_OBJECT
QFont m_font;
int m_height;
-public:
+ public:
CommandListDelegate(QWidget* parent);
virtual void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& idx) const override;
- virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
+ virtual QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override;
};
-class BINARYNINJAUIAPI CommandListModel: public QAbstractItemModel
+class BINARYNINJAUIAPI CommandListModel : public QAbstractItemModel
{
Q_OBJECT
@@ -45,7 +45,7 @@ class BINARYNINJAUIAPI CommandListModel: public QAbstractItemModel
bool isFilterMatch(const QString& name, const QString& filter);
int getFilterMatchScore(const QString& name, const QString& filter);
-public:
+ public:
CommandListModel(QWidget* parent, const std::vector<CommandListItem>& items);
virtual QModelIndex index(int row, int col, const QModelIndex& parent) const override;
@@ -61,7 +61,7 @@ public:
void addRecentItem(const QString& name);
};
-class BINARYNINJAUIAPI CommandList: public QListView
+class BINARYNINJAUIAPI CommandList : public QListView
{
Q_OBJECT
@@ -69,7 +69,7 @@ class BINARYNINJAUIAPI CommandList: public QListView
CommandListModel* m_model;
CommandListFilter* m_filter;
-public:
+ public:
CommandList(CommandPalette* parent, const std::vector<CommandListItem>& items);
void setFilter(CommandListFilter* filter) { m_filter = filter; }
void setFilterText(const QString& text);
@@ -79,12 +79,12 @@ public:
QModelIndex index(int row, int col, const QModelIndex& parent = QModelIndex()) const;
void addRecentItem(const QString& name);
-protected:
+ protected:
virtual void keyPressEvent(QKeyEvent* event) override;
virtual void focusOutEvent(QFocusEvent* event) override;
};
-class BINARYNINJAUIAPI CommandListFilter: public QLineEdit
+class BINARYNINJAUIAPI CommandListFilter : public QLineEdit
{
Q_OBJECT
@@ -94,16 +94,16 @@ class BINARYNINJAUIAPI CommandListFilter: public QLineEdit
//! Focus the next or previous results list item.
bool cycleSelection(bool forward = true);
-public:
+ public:
CommandListFilter(CommandPalette* parent, CommandList* list);
-protected:
+ protected:
bool event(QEvent* event) override;
virtual void keyPressEvent(QKeyEvent* event) override;
virtual void focusOutEvent(QFocusEvent* event) override;
};
-class BINARYNINJAUIAPI CommandPalette: public QFrame
+class BINARYNINJAUIAPI CommandPalette : public QFrame
{
Q_OBJECT
@@ -119,7 +119,7 @@ class BINARYNINJAUIAPI CommandPalette: public QFrame
std::vector<CommandListItem> getCommandList();
void init();
-public:
+ public:
CommandPalette(QWidget* parent, UIActionHandler* handler);
CommandPalette(QWidget* parent, UIActionHandler* handler, const UIActionContext& context);
@@ -130,7 +130,7 @@ public:
void selectFirstItem();
void close();
-private Q_SLOTS:
+ private Q_SLOTS:
void itemClicked(const QModelIndex& idx);
void filterChanged(const QString& text);
};
diff --git a/ui/commands.h b/ui/commands.h
index 05da1ba5..9eee935e 100644
--- a/ui/commands.h
+++ b/ui/commands.h
@@ -6,39 +6,40 @@
#include "uicontext.h"
bool BINARYNINJAUIAPI undefineNameForAddress(BinaryViewRef data, uint64_t addr);
-bool BINARYNINJAUIAPI undefineNameForLocalVariable(BinaryViewRef data,
- FunctionRef func, const BinaryNinja::Variable& var);
+bool BINARYNINJAUIAPI undefineNameForLocalVariable(
+ BinaryViewRef data, FunctionRef func, const BinaryNinja::Variable& var);
bool BINARYNINJAUIAPI inputNameForAddress(QWidget* parent, BinaryViewRef data, uint64_t addr);
-bool BINARYNINJAUIAPI inputNameForLocalVariable(QWidget* parent, BinaryViewRef data,
- FunctionRef function, const BinaryNinja::Variable& var);
-bool BINARYNINJAUIAPI inputNameForType(QWidget* parent, std::string& name, const QString& title = "Set Name",
- const QString& msg = "Enter name:");
+bool BINARYNINJAUIAPI inputNameForLocalVariable(
+ QWidget* parent, BinaryViewRef data, FunctionRef function, const BinaryNinja::Variable& var);
+bool BINARYNINJAUIAPI inputNameForType(
+ QWidget* parent, std::string& name, const QString& title = "Set Name", const QString& msg = "Enter name:");
bool BINARYNINJAUIAPI InferArraySize(TypeRef& type, size_t selectionSize);
bool BINARYNINJAUIAPI askForNewType(QWidget* parent, BinaryViewRef data, FunctionRef func, const std::string& title,
- TypeRef& type, BinaryNinja::QualifiedName& name);
+ TypeRef& type, BinaryNinja::QualifiedName& name);
bool BINARYNINJAUIAPI inputNewType(QWidget* parent, BinaryViewRef data, FunctionRef currentFunction,
- uint64_t currentAddr, size_t selectionSize, HighlightTokenState& highlight);
+ uint64_t currentAddr, size_t selectionSize, HighlightTokenState& highlight);
bool BINARYNINJAUIAPI createInferredMember(QWidget* parent, BinaryViewRef data, HighlightTokenState& highlight,
- FunctionRef func, BNFunctionGraphType ilType, size_t instrIndex);
-bool BINARYNINJAUIAPI createStructMembers(QWidget* parent, BinaryViewRef data,
- HighlightTokenState& highlight, FunctionRef func);
+ FunctionRef func, BNFunctionGraphType ilType, size_t instrIndex);
+bool BINARYNINJAUIAPI createStructMembers(
+ QWidget* parent, BinaryViewRef data, HighlightTokenState& highlight, FunctionRef func);
bool BINARYNINJAUIAPI inputPossibleValueSet(QWidget* parent, BinaryViewRef data, FunctionRef currentFunction,
- HighlightTokenState& highlight, uint64_t defSiteAddress, size_t ilInstructionIndex = BN_INVALID_EXPR);
+ HighlightTokenState& highlight, uint64_t defSiteAddress, size_t ilInstructionIndex = BN_INVALID_EXPR);
-bool BINARYNINJAUIAPI overwriteCode(BinaryViewRef data, ArchitectureRef arch,
- uint64_t addr, size_t len, const BinaryNinja::DataBuffer& buffer);
-bool BINARYNINJAUIAPI overwriteCode(BinaryViewRef data, ArchitectureRef arch,
- uint64_t addr, const BinaryNinja::DataBuffer& buffer);
+bool BINARYNINJAUIAPI overwriteCode(
+ BinaryViewRef data, ArchitectureRef arch, uint64_t addr, size_t len, const BinaryNinja::DataBuffer& buffer);
+bool BINARYNINJAUIAPI overwriteCode(
+ BinaryViewRef data, ArchitectureRef arch, uint64_t addr, const BinaryNinja::DataBuffer& buffer);
StructureRef BINARYNINJAUIAPI getInnerMostStructureContaining(BinaryViewRef data, StructureRef structure,
- size_t& memberIndex, const std::vector<std::string>& nameList, size_t nameIndex, TypeRef& type, std::string& typeName);
+ size_t& memberIndex, const std::vector<std::string>& nameList, size_t nameIndex, TypeRef& type,
+ std::string& typeName);
StructureRef BINARYNINJAUIAPI getInnerMostStructureContainingOffset(BinaryViewRef data, StructureRef structure,
- const std::vector<std::string>& nameList, size_t nameIndex, size_t offset, TypeRef& type, std::string& typeName);
+ const std::vector<std::string>& nameList, size_t nameIndex, size_t offset, TypeRef& type, std::string& typeName);
// Get the offset of the inner most structure, ralative to the supplied outer most structure
-uint64_t BINARYNINJAUIAPI getInnerMostStructureOffset(BinaryViewRef data, StructureRef structure,
- const std::vector<std::string>& nameList, size_t nameIndex);
+uint64_t BINARYNINJAUIAPI getInnerMostStructureOffset(
+ BinaryViewRef data, StructureRef structure, const std::vector<std::string>& nameList, size_t nameIndex);
// Auto generate a structure name
std::string BINARYNINJAUIAPI createStructureName(BinaryViewRef data);
diff --git a/ui/commentdialog.h b/ui/commentdialog.h
index ddff7f06..2a70c3eb 100644
--- a/ui/commentdialog.h
+++ b/ui/commentdialog.h
@@ -7,14 +7,14 @@
#include "uicontext.h"
#include "uicomment.h"
-class BINARYNINJAUIAPI CommentDialog: public QDialog
+class BINARYNINJAUIAPI CommentDialog : public QDialog
{
Q_OBJECT
DialogTextEdit* m_comment;
UIComment m_uicomment;
-public:
+ public:
CommentDialog(QWidget* parent, const UIComment& comment);
QString getNewComment();
QString getCurrentComment();
diff --git a/ui/compiledialog.h b/ui/compiledialog.h
index c5d2123a..b40bc68d 100644
--- a/ui/compiledialog.h
+++ b/ui/compiledialog.h
@@ -14,7 +14,7 @@ enum CompileMode
CompilePatch
};
-class BINARYNINJAUIAPI CompileDialog: public QDialog
+class BINARYNINJAUIAPI CompileDialog : public QDialog
{
Q_OBJECT
@@ -33,17 +33,17 @@ class BINARYNINJAUIAPI CompileDialog: public QDialog
void appendOptionString(std::string& out, const std::string& text);
void updateOptionsText();
-public:
+ public:
CompileDialog(QWidget* parent, BinaryViewRef data, uint64_t addr, CompileMode mode, const QString& code = "");
ArchitectureRef getArchitecture();
const BinaryNinja::DataBuffer& getBytes() const { return m_bytes; }
-private Q_SLOTS:
+ private Q_SLOTS:
void saveOnFinish(int result);
void compile();
void options();
-protected:
+ protected:
virtual void accept() override;
};
diff --git a/ui/compileoptions.h b/ui/compileoptions.h
index 53a7e687..58521bd1 100644
--- a/ui/compileoptions.h
+++ b/ui/compileoptions.h
@@ -7,7 +7,7 @@
#include "binaryninjaapi.h"
#include "uicontext.h"
-class BINARYNINJAUIAPI CompileOptions: public QDialog
+class BINARYNINJAUIAPI CompileOptions : public QDialog
{
Q_OBJECT
@@ -36,11 +36,11 @@ class BINARYNINJAUIAPI CompileOptions: public QDialog
QString optionValue(const std::map<std::string, std::string>& options, const std::string& name);
void updateOptions(const std::map<std::string, std::string>& options);
-public:
+ public:
CompileOptions(QWidget* parent, const std::map<std::string, std::string>& initialOptions);
std::map<std::string, std::string> getSettings();
-private Q_SLOTS:
+ private Q_SLOTS:
void reset();
};
diff --git a/ui/createstructdialog.h b/ui/createstructdialog.h
index ae044bdf..f273399f 100644
--- a/ui/createstructdialog.h
+++ b/ui/createstructdialog.h
@@ -5,7 +5,7 @@
#include "binaryninjaapi.h"
#include "uicontext.h"
-class BINARYNINJAUIAPI CreateStructDialog: public QDialog
+class BINARYNINJAUIAPI CreateStructDialog : public QDialog
{
Q_OBJECT
@@ -16,16 +16,15 @@ class BINARYNINJAUIAPI CreateStructDialog: public QDialog
BinaryNinja::QualifiedName m_resultName;
uint64_t m_resultSize;
-public:
+ public:
CreateStructDialog(QWidget* parent, BinaryViewRef view, const std::string& name);
BinaryNinja::QualifiedName getName() { return m_resultName; }
uint64_t getSize() { return m_resultSize; }
-private Q_SLOTS:
+ private Q_SLOTS:
void createStruct();
-protected:
+ protected:
virtual void showEvent(QShowEvent* e) override;
-
};
diff --git a/ui/createtypedialog.h b/ui/createtypedialog.h
index 19880bc8..0df1c613 100644
--- a/ui/createtypedialog.h
+++ b/ui/createtypedialog.h
@@ -6,7 +6,7 @@
#include "dialogtextedit.h"
#include "uicontext.h"
-class BINARYNINJAUIAPI CreateTypeDialog: public QDialog
+class BINARYNINJAUIAPI CreateTypeDialog : public QDialog
{
Q_OBJECT
@@ -16,15 +16,14 @@ class BINARYNINJAUIAPI CreateTypeDialog: public QDialog
std::map<BinaryNinja::QualifiedName, TypeRef> m_results;
std::set<BinaryNinja::QualifiedName> m_typesAllowRedefinition;
-public:
- CreateTypeDialog(QWidget* parent, BinaryViewRef data, const QString& title,
- const QString& definition, const std::set<BinaryNinja::QualifiedName>& typesAllowRedefinition = {});
- std::map<BinaryNinja::QualifiedName, TypeRef> getResults() { return m_results; }
+ public:
+ CreateTypeDialog(QWidget* parent, BinaryViewRef data, const QString& title, const QString& definition,
+ const std::set<BinaryNinja::QualifiedName>& typesAllowRedefinition = {});
+ std::map<BinaryNinja::QualifiedName, TypeRef> getResults() { return m_results; }
-private Q_SLOTS:
+ private Q_SLOTS:
void createType();
-protected:
+ protected:
virtual void showEvent(QShowEvent* e) override;
-
};
diff --git a/ui/datatypelist.h b/ui/datatypelist.h
index be0fc5e9..c2a96489 100644
--- a/ui/datatypelist.h
+++ b/ui/datatypelist.h
@@ -5,7 +5,7 @@
#include "viewframe.h"
#include "menus.h"
-class BINARYNINJAUIAPI DataTypeList: public MenuHelper
+class BINARYNINJAUIAPI DataTypeList : public MenuHelper
{
Q_OBJECT
@@ -13,14 +13,14 @@ class BINARYNINJAUIAPI DataTypeList: public MenuHelper
QString m_currentType;
std::string m_currentDataType;
-public:
+ public:
DataTypeList(QWidget* parent);
void setCurrentViewType(ViewFrame* view, const QString& type);
-protected:
+ protected:
virtual void showMenu();
-Q_SIGNALS:
+ Q_SIGNALS:
void viewChanged(QString type);
};
diff --git a/ui/dialogtextedit.h b/ui/dialogtextedit.h
index cc719aae..28f025c7 100644
--- a/ui/dialogtextedit.h
+++ b/ui/dialogtextedit.h
@@ -3,16 +3,16 @@
#include <QtWidgets/QTextEdit>
#include "uicontext.h"
-class BINARYNINJAUIAPI DialogTextEdit: public QTextEdit
+class BINARYNINJAUIAPI DialogTextEdit : public QTextEdit
{
Q_OBJECT
-public:
+ public:
DialogTextEdit(QWidget* parent);
-protected:
+ protected:
virtual void keyPressEvent(QKeyEvent* event) override;
-Q_SIGNALS:
+ Q_SIGNALS:
void contentAccepted();
};
diff --git a/ui/disassemblyview.h b/ui/disassemblyview.h
index 144101fe..ffd963e5 100644
--- a/ui/disassemblyview.h
+++ b/ui/disassemblyview.h
@@ -18,11 +18,11 @@
#define FUNCTION_UPDATE_CHECK_INTERVAL 100
-class BINARYNINJAUIAPI DisassemblyHistoryEntry: public FlowGraphHistoryEntry
+class BINARYNINJAUIAPI DisassemblyHistoryEntry : public FlowGraphHistoryEntry
{
BNFunctionGraphType m_graphType;
-public:
+ public:
BNFunctionGraphType getGraphType() const { return m_graphType; }
void setGraphType(BNFunctionGraphType type) { m_graphType = type; }
@@ -32,15 +32,15 @@ public:
class DisassemblyContainer;
-class BINARYNINJAUIAPI DisassemblyView: public FlowGraphWidget
+class BINARYNINJAUIAPI DisassemblyView : public FlowGraphWidget
{
Q_OBJECT
-friend class DisassemblyFunctionHeader;
+ friend class DisassemblyFunctionHeader;
-public:
+ public:
explicit DisassemblyView(DisassemblyContainer* parent, BinaryViewRef data, FunctionRef func = nullptr,
- bool navToAddr = false, uint64_t addr = 0);
+ bool navToAddr = false, uint64_t addr = 0);
virtual void updateFonts() override;
@@ -70,26 +70,26 @@ public:
static void registerActions();
-private:
- class DisassemblyViewOptionsWidget: public MenuHelper
+ private:
+ class DisassemblyViewOptionsWidget : public MenuHelper
{
- public:
+ public:
DisassemblyViewOptionsWidget(DisassemblyView* parent);
- protected:
+ protected:
virtual void mousePressEvent(QMouseEvent* event);
virtual void showMenu();
- private:
+ private:
DisassemblyView* m_view;
};
- class DisassemblyViewOptionsIconWidget: public QWidget
+ class DisassemblyViewOptionsIconWidget : public QWidget
{
- public:
+ public:
DisassemblyViewOptionsIconWidget(DisassemblyView* parent);
- private:
+ private:
DisassemblyView* m_view;
ContextMenuManager* m_contextMenuManager;
Menu m_menu;
@@ -97,13 +97,13 @@ private:
void showMenu();
};
- class DisassemblyViewStatusBarWidget: public StatusBarWidget
+ class DisassemblyViewStatusBarWidget : public StatusBarWidget
{
- public:
+ public:
DisassemblyViewStatusBarWidget(DisassemblyView* parent);
virtual void updateStatus() override;
- private:
+ private:
DisassemblyView* m_view;
ILChooserWidget* m_chooser;
DisassemblyViewOptionsWidget* m_options;
@@ -117,7 +117,7 @@ private:
DisassemblyContainer* m_container;
SettingsRef m_settings;
-private Q_SLOTS:
+ private Q_SLOTS:
void viewInHexEditor();
void viewInLinearDisassembly();
void viewInDecompiler();
@@ -125,7 +125,7 @@ private Q_SLOTS:
};
-class GraphTypeLabel: public MenuHelper
+class GraphTypeLabel : public MenuHelper
{
Q_OBJECT
@@ -134,16 +134,16 @@ class GraphTypeLabel: public MenuHelper
void updateCustomPalette();
-public:
+ public:
GraphTypeLabel(QWidget* parent, DisassemblyContainer* container);
-protected:
- void paintEvent(QPaintEvent* event) override;
+ protected:
+ void paintEvent(QPaintEvent* event) override;
void showMenu() override;
};
-class BINARYNINJAUIAPI DisassemblyFunctionHeader: public QWidget
+class BINARYNINJAUIAPI DisassemblyFunctionHeader : public QWidget
{
Q_OBJECT
@@ -163,17 +163,17 @@ class BINARYNINJAUIAPI DisassemblyFunctionHeader: public QWidget
void adjustSize(int width, int height);
-private Q_SLOTS:
+ private Q_SLOTS:
void updateTimerEvent();
-protected:
+ protected:
virtual void paintEvent(QPaintEvent* event) override;
virtual void resizeEvent(QResizeEvent* event) override;
virtual void mousePressEvent(QMouseEvent* event) override;
virtual void mouseDoubleClickEvent(QMouseEvent* event) override;
-public:
+ public:
DisassemblyFunctionHeader(DisassemblyContainer* parent, BinaryViewRef data);
void updateFonts();
@@ -184,7 +184,7 @@ public:
virtual QSize sizeHint() const override;
};
-class BINARYNINJAUIAPI DisassemblyContainer: public QWidget, public ViewContainer
+class BINARYNINJAUIAPI DisassemblyContainer : public QWidget, public ViewContainer
{
Q_OBJECT
@@ -194,9 +194,9 @@ class BINARYNINJAUIAPI DisassemblyContainer: public QWidget, public ViewContaine
QWidget* m_analysisWarning;
QLabel* m_analysisWarningText;
-public:
+ public:
explicit DisassemblyContainer(QWidget* parent, BinaryViewRef data, ViewFrame* view, FunctionRef func = nullptr,
- bool navToAddr = false, uint64_t addr = 0);
+ bool navToAddr = false, uint64_t addr = 0);
virtual View* getView() override { return m_view; }
ViewFrame* getViewFrame() { return m_viewFrame; }
@@ -209,18 +209,18 @@ public:
void setILViewType(BNFunctionGraphType ilViewType);
void setHeaderHighlightToken(const HighlightTokenState& state);
-protected:
+ protected:
virtual void focusInEvent(QFocusEvent* event) override;
-private Q_SLOTS:
+ private Q_SLOTS:
void linkActivatedEvent(const QString& link);
};
-class DisassemblyViewType: public ViewType
+class DisassemblyViewType : public ViewType
{
static DisassemblyViewType* m_instance;
-public:
+ public:
DisassemblyViewType();
virtual int getPriority(BinaryViewRef data, const QString& filename);
virtual QWidget* create(BinaryViewRef data, ViewFrame* viewFrame);
diff --git a/ui/dockhandler.h b/ui/dockhandler.h
index 9a053b46..cb150a81 100644
--- a/ui/dockhandler.h
+++ b/ui/dockhandler.h
@@ -17,14 +17,17 @@ class Menu;
struct BINARYNINJAUIAPI DockProperties
{
- DockProperties() { };
+ DockProperties() {};
DockProperties(QDockWidget* dw, bool vis, Qt::DockWidgetArea dar, Qt::Orientation dor, bool dvis, bool vs) :
- dockWidget(dw), visibleState(vis), defaultArea(dar), defaultOrientation(dor), defaultVisibility(dvis),
- viewSensitive(vs), neverBeenVisible(true), sizeStash(0, 0), actionOnShow(nullptr) { }
- DockProperties(const DockProperties &dp) :
- dockWidget(dp.dockWidget), visibleState(dp.visibleState), defaultArea(dp.defaultArea),
- defaultOrientation(dp.defaultOrientation), defaultVisibility(dp.defaultVisibility),
- viewSensitive(dp.viewSensitive), neverBeenVisible(dp.neverBeenVisible), sizeStash(dp.sizeStash), actionOnShow(dp.actionOnShow) { }
+ dockWidget(dw), visibleState(vis), defaultArea(dar), defaultOrientation(dor), defaultVisibility(dvis),
+ viewSensitive(vs), neverBeenVisible(true), sizeStash(0, 0), actionOnShow(nullptr)
+ {}
+ DockProperties(const DockProperties& dp) :
+ dockWidget(dp.dockWidget), visibleState(dp.visibleState), defaultArea(dp.defaultArea),
+ defaultOrientation(dp.defaultOrientation), defaultVisibility(dp.defaultVisibility),
+ viewSensitive(dp.viewSensitive), neverBeenVisible(dp.neverBeenVisible), sizeStash(dp.sizeStash),
+ actionOnShow(dp.actionOnShow)
+ {}
DockProperties& operator=(const DockProperties& dp)
{
dockWidget = dp.dockWidget;
@@ -53,7 +56,7 @@ struct BINARYNINJAUIAPI DockProperties
struct DockSizePrefs
{
- DockSizePrefs() { }
+ DockSizePrefs() {}
QList<QDockWidget*> docks;
QList<int> hDockSizes;
QList<int> vDockSizes;
@@ -63,32 +66,32 @@ struct DockSizePrefs
class BINARYNINJAUIAPI DockContextHandler
{
-protected:
+ protected:
QString m_name;
UIActionHandler m_actionHandler;
ContextMenuManager* m_contextMenuManager = nullptr;
Menu* m_menu = nullptr;
QWidget* m_parentWindow;
-public:
+ public:
DockContextHandler(QWidget* widget, const QString& name);
virtual ~DockContextHandler();
QString getName() const { return m_name; }
QWidget* getParentWindow() const { return m_parentWindow; }
- virtual void notifyFontChanged() { }
- virtual void notifyOffsetChanged(uint64_t /*offset*/) { }
- virtual void notifyThemeChanged() { }
- virtual void notifyViewChanged(ViewFrame* /*frame*/) { }
- virtual void notifyViewLocationChanged(View* /*view*/, const ViewLocation& /*viewLocation*/) { }
- virtual void notifyVisibilityChanged(bool /*visible*/) { }
+ virtual void notifyFontChanged() {}
+ virtual void notifyOffsetChanged(uint64_t /*offset*/) {}
+ virtual void notifyThemeChanged() {}
+ virtual void notifyViewChanged(ViewFrame* /*frame*/) {}
+ virtual void notifyViewLocationChanged(View* /*view*/, const ViewLocation& /*viewLocation*/) {}
+ virtual void notifyVisibilityChanged(bool /*visible*/) {}
virtual bool shouldBeVisible(ViewFrame* /*frame*/) { return true; }
};
Q_DECLARE_INTERFACE(DockContextHandler, "binary.ninja.dockcontexthandler/1.0");
-class BINARYNINJAUIAPI DockHandler: public QObject
+class BINARYNINJAUIAPI DockHandler : public QObject
{
Q_OBJECT
@@ -105,11 +108,13 @@ class BINARYNINJAUIAPI DockHandler: public QObject
friend class DockContextHandler;
std::map<QWidget*, DockContextHandler*> m_contexts;
- std::map<QString, std::pair<QString, std::function<QWidget*(const QString&, ViewFrame*, BinaryViewRef)>>> m_widgetFactories;
+ std::map<QString, std::pair<QString, std::function<QWidget*(const QString&, ViewFrame*, BinaryViewRef)>>>
+ m_widgetFactories;
DockContextHandler* getDockContextHandler(QWidget* widget);
- bool addDockWidget(const QString& name, QWidget* widget, Qt::DockWidgetArea area, Qt::Orientation orientation, bool defaultVisibility);
+ bool addDockWidget(const QString& name, QWidget* widget, Qt::DockWidgetArea area, Qt::Orientation orientation,
+ bool defaultVisibility);
-public:
+ public:
explicit DockHandler(QObject* parent, int windowIndex);
void close();
@@ -117,9 +122,14 @@ public:
void reset(bool initial = false);
void reset(const QString& name);
void resizeDocksOnShow(bool resizeDocks) { m_resizeDocksRequest = resizeDocks; }
- bool addDockWidget(QWidget* widget, Qt::DockWidgetArea area = Qt::BottomDockWidgetArea, Qt::Orientation orientation = Qt::Horizontal, bool defaultVisibility = false);
- bool addDockWidget(const QString& name, const std::function<QWidget*(const QString&, ViewFrame*, BinaryViewRef)>& createWidget, Qt::DockWidgetArea area = Qt::BottomDockWidgetArea, Qt::Orientation orientation = Qt::Horizontal, bool defaultVisibility = false);
- void createDynamicWidgets(ViewFrame* frame, BinaryViewRef data, std::map<QString, QPointer<QWidget>>& store, std::vector<QString> filter, bool isExcludeFilter = true);
+ bool addDockWidget(QWidget* widget, Qt::DockWidgetArea area = Qt::BottomDockWidgetArea,
+ Qt::Orientation orientation = Qt::Horizontal, bool defaultVisibility = false);
+ bool addDockWidget(const QString& name,
+ const std::function<QWidget*(const QString&, ViewFrame*, BinaryViewRef)>& createWidget,
+ Qt::DockWidgetArea area = Qt::BottomDockWidgetArea, Qt::Orientation orientation = Qt::Horizontal,
+ bool defaultVisibility = false);
+ void createDynamicWidgets(ViewFrame* frame, BinaryViewRef data, std::map<QString, QPointer<QWidget>>& store,
+ std::vector<QString> filter, bool isExcludeFilter = true);
QDockWidget* getDockWidget(const QString& name);
ViewFrame* getViewFrame() { return m_viewFrame; }
bool isVisible(const QString& name);
@@ -139,10 +149,10 @@ public:
static DockHandler* getActiveDockHandler();
-Q_SIGNALS:
+ Q_SIGNALS:
void notifyVisibilityChanged();
-public Q_SLOTS:
+ public Q_SLOTS:
void viewChanged(ViewFrame* frame);
void visibilityChanged(bool visible);
void topLevelChanged(bool topLevel);
diff --git a/ui/expandablegroup.h b/ui/expandablegroup.h
index ee952171..1b28152e 100644
--- a/ui/expandablegroup.h
+++ b/ui/expandablegroup.h
@@ -10,18 +10,18 @@ class BINARYNINJAUIAPI ExpandableGroup : public QWidget
{
Q_OBJECT
-private:
+ private:
QToolButton* m_button;
QParallelAnimationGroup* m_animation;
QScrollArea* m_content;
int m_duration = 100;
-private Q_SLOTS:
+ private Q_SLOTS:
void toggled(bool expanded);
-public:
- explicit ExpandableGroup(QLayout* contentLayout, const QString& title = "", QWidget* parent = nullptr,
- bool expanded = false);
+ public:
+ explicit ExpandableGroup(
+ QLayout* contentLayout, const QString& title = "", QWidget* parent = nullptr, bool expanded = false);
void setupAnimation(QLayout* contentLayout);
void setTitle(const QString& title) { m_button->setText(title); }
void toggle(bool expanded);
diff --git a/ui/featuremap.h b/ui/featuremap.h
index 68fcab0a..93107eff 100644
--- a/ui/featuremap.h
+++ b/ui/featuremap.h
@@ -2,9 +2,9 @@
#include <QtGui/QColor>
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
-#include <QtWidgets/QAction>
+ #include <QtWidgets/QAction>
#else
-#include <QtGui/QAction>
+ #include <QtGui/QAction>
#endif
#include <QtGui/QImage>
#include <QtWidgets/QMenu>
@@ -27,7 +27,7 @@ class Menu;
class View;
class SplitPaneWidget;
-class BINARYNINJAUIAPI FeatureMap: public QWidget, public BinaryNinja::BinaryDataNotification
+class BINARYNINJAUIAPI FeatureMap : public QWidget, public BinaryNinja::BinaryDataNotification
{
Q_OBJECT
@@ -58,13 +58,13 @@ class BINARYNINJAUIAPI FeatureMap: public QWidget, public BinaryNinja::BinaryDat
Menu m_menu;
ContextMenuManager* m_contextMenuManager;
- class BackgroundRefresh: public BinaryNinja::RefCountObject
+ class BackgroundRefresh : public BinaryNinja::RefCountObject
{
std::mutex m_mutex;
bool m_valid;
QPointer<FeatureMap> m_featureMap;
- public:
+ public:
BackgroundRefresh(FeatureMap* featureMap);
void start();
void abort();
@@ -74,7 +74,7 @@ class BINARYNINJAUIAPI FeatureMap: public QWidget, public BinaryNinja::BinaryDat
void updateCoordinates();
-public:
+ public:
FeatureMap(SplitPaneWidget* owner, BinaryViewRef data, bool vertical = true);
virtual ~FeatureMap();
@@ -94,13 +94,14 @@ public:
virtual void OnDataVariableRemoved(BinaryNinja::BinaryView* data, const BinaryNinja::DataVariable& var) override;
virtual void OnDataVariableUpdated(BinaryNinja::BinaryView* data, const BinaryNinja::DataVariable& var) override;
virtual void OnStringFound(BinaryNinja::BinaryView* data, BNStringType type, uint64_t offset, size_t len) override;
- virtual void OnStringRemoved(BinaryNinja::BinaryView* data, BNStringType type, uint64_t offset, size_t len) override;
+ virtual void OnStringRemoved(
+ BinaryNinja::BinaryView* data, BNStringType type, uint64_t offset, size_t len) override;
void drawImageRect(uint64_t addr, size_t len, uint8_t color);
virtual QSize sizeHint() const override;
-protected:
+ protected:
virtual void contextMenuEvent(QContextMenuEvent* event) override;
virtual void mouseMoveEvent(QMouseEvent* event) override;
virtual void mousePressEvent(QMouseEvent* event) override;
@@ -108,10 +109,10 @@ protected:
virtual void paintEvent(QPaintEvent* event) override;
void scrollTo(int x, int y, bool addHistoryEntry = false);
-Q_SIGNALS:
+ Q_SIGNALS:
void notifyThemeUpdated();
-private Q_SLOTS:
+ private Q_SLOTS:
void refresh();
void updateThemeInternal();
void updateTimerEvent();
diff --git a/ui/filecontext.h b/ui/filecontext.h
index e31037ed..ef98d6a9 100644
--- a/ui/filecontext.h
+++ b/ui/filecontext.h
@@ -17,11 +17,11 @@ class SyncGroup;
// generator with a derived class with no base and a compiler error.
class FileContextBase
{
-public:
+ public:
FileContextBase() {}
};
-class BINARYNINJAUIAPI FileContext: public FileContextBase, public BinaryNinja::NavigationHandler
+class BINARYNINJAUIAPI FileContext : public FileContextBase, public BinaryNinja::NavigationHandler
{
QString m_filename;
bool m_isValidSaveFilename;
@@ -41,8 +41,9 @@ class BINARYNINJAUIAPI FileContext: public FileContextBase, public BinaryNinja::
void createBinaryViews();
-public:
- FileContext(FileMetadataRef file, BinaryViewRef rawData, const QString& filename = QString(), bool isValidSaveName = false, bool createViews = true);
+ public:
+ FileContext(FileMetadataRef file, BinaryViewRef rawData, const QString& filename = QString(),
+ bool isValidSaveName = false, bool createViews = true);
virtual ~FileContext();
void registerReference(QObject* widget);
@@ -54,7 +55,7 @@ public:
BinaryViewRef getRawData() const { return m_rawData; }
FileMetadataRef getMetadata() const { return m_file; }
QString getFilename() const { return m_filename; }
- void setFilename(QString newName) {m_filename = newName;}
+ void setFilename(QString newName) { m_filename = newName; }
ViewFrame* getCurrentViewFrame() const { return m_currentViewFrame; }
QString getTabName(QWidget* widget);
QString getShortFileName(QWidget* widget);
diff --git a/ui/filter.h b/ui/filter.h
index 7ed0ee78..ba186a38 100644
--- a/ui/filter.h
+++ b/ui/filter.h
@@ -6,7 +6,7 @@
class BINARYNINJAUIAPI FilterTarget
{
-public:
+ public:
virtual ~FilterTarget() {}
virtual void setFilter(const std::string& filter) = 0;
@@ -17,20 +17,20 @@ public:
virtual void closeFilter();
};
-class BINARYNINJAUIAPI FilterEdit: public QLineEdit
+class BINARYNINJAUIAPI FilterEdit : public QLineEdit
{
Q_OBJECT
FilterTarget* m_target;
-public:
+ public:
FilterEdit(FilterTarget* target);
-protected:
+ protected:
virtual void keyPressEvent(QKeyEvent* event) override;
};
-class BINARYNINJAUIAPI FilteredView: public QWidget
+class BINARYNINJAUIAPI FilteredView : public QWidget
{
Q_OBJECT
@@ -38,9 +38,8 @@ class BINARYNINJAUIAPI FilteredView: public QWidget
QWidget* m_widget;
FilterEdit* m_filter;
-public:
- FilteredView(QWidget* parent, QWidget* filtered, FilterTarget* target,
- FilterEdit* edit = nullptr);
+ public:
+ FilteredView(QWidget* parent, QWidget* filtered, FilterTarget* target, FilterEdit* edit = nullptr);
void setFilterPlaceholderText(const QString& text);
void updateFonts();
void clearFilter();
@@ -48,9 +47,9 @@ public:
static bool match(const std::string& name, const std::string& filter);
-protected:
+ protected:
virtual void keyPressEvent(QKeyEvent* event) override;
-private Q_SLOTS:
+ private Q_SLOTS:
void filterChanged(const QString& filter);
};
diff --git a/ui/flowgraphwidget.h b/ui/flowgraphwidget.h
index 2f294320..4de062f1 100644
--- a/ui/flowgraphwidget.h
+++ b/ui/flowgraphwidget.h
@@ -10,15 +10,16 @@
#include "commentdialog.h"
#include "instructionedit.h"
-class BINARYNINJAUIAPI GraphLayoutCompleteEvent: public QEvent
+class BINARYNINJAUIAPI GraphLayoutCompleteEvent : public QEvent
{
FlowGraphRef m_graph;
-public:
+
+ public:
GraphLayoutCompleteEvent(QEvent::Type type, const FlowGraphRef& graph);
FlowGraphRef GetGraph() { return m_graph; }
};
-class BINARYNINJAUIAPI FlowGraphHistoryEntry: public HistoryEntry
+class BINARYNINJAUIAPI FlowGraphHistoryEntry : public HistoryEntry
{
PlatformRef m_platform;
ArchitectureRef m_arch;
@@ -28,7 +29,7 @@ class BINARYNINJAUIAPI FlowGraphHistoryEntry: public HistoryEntry
uint64_t m_addr;
HighlightTokenState m_highlight;
-public:
+ public:
PlatformRef getPlatform() const { return m_platform; }
ArchitectureRef getArchitecture() const { return m_arch; }
uint64_t getFunction() const { return m_func; }
@@ -51,8 +52,11 @@ public:
virtual bool deserialize(const Json::Value& value) override;
};
-class BINARYNINJAUIAPI FlowGraphWidget: public QAbstractScrollArea, public View, public PreviewScrollHandler,
- public BinaryNinja::BinaryDataNotification
+class BINARYNINJAUIAPI FlowGraphWidget :
+ public QAbstractScrollArea,
+ public View,
+ public PreviewScrollHandler,
+ public BinaryNinja::BinaryDataNotification
{
Q_OBJECT
@@ -144,7 +148,7 @@ class BINARYNINJAUIAPI FlowGraphWidget: public QAbstractScrollArea, public View,
BNDeadStoreElimination getCurrentVariableDeadStoreElimination();
-protected:
+ protected:
virtual void paintEvent(QPaintEvent* event) override;
virtual void resizeEvent(QResizeEvent* event) override;
@@ -166,8 +170,8 @@ protected:
void navigateToAddress(uint64_t addr);
void navigateToGotoLabel(uint64_t label);
- void setGraphInternal(FlowGraphRef graph, BinaryNinja::Ref<FlowGraphHistoryEntry> entry, bool useAddr, uint64_t addr,
- bool notify, bool recenterWithPreviousGraph, size_t index = BN_INVALID_EXPR);
+ void setGraphInternal(FlowGraphRef graph, BinaryNinja::Ref<FlowGraphHistoryEntry> entry, bool useAddr,
+ uint64_t addr, bool notify, bool recenterWithPreviousGraph, size_t index = BN_INVALID_EXPR);
void up(bool selecting, size_t count = 1);
void down(bool selecting, size_t count = 1);
@@ -187,7 +191,7 @@ protected:
uint64_t getTokenAddress();
-public:
+ public:
FlowGraphWidget(QWidget* parent, BinaryViewRef view, FlowGraphRef graph = FlowGraphRef());
~FlowGraphWidget();
@@ -262,8 +266,8 @@ public:
bool paintMiniGraph(QWidget* owner, QPainter& p, QRect& miniRenderRect);
void paintNode(QPainter& p, FlowGraphNodeRef& node, int minY, int maxY);
- void paintHighlight(QPainter& p, const std::vector<BinaryNinja::DisassemblyTextLine>& lines,
- int nodeX, int nodeWidth, int x, int y, size_t line, int tagIndent);
+ void paintHighlight(QPainter& p, const std::vector<BinaryNinja::DisassemblyTextLine>& lines, int nodeX,
+ int nodeWidth, int x, int y, size_t line, int tagIndent);
void paintEdge(QPainter& p, const FlowGraphNodeRef& node, const BinaryNinja::FlowGraphEdge& edge);
void showAddress(uint64_t addr, bool select = false, bool center = false);
@@ -286,21 +290,21 @@ public:
virtual void onFunctionSelected(FunctionRef func);
virtual void onHighlightChanged(const HighlightTokenState& highlight);
-// protected:
+ // protected:
// These APIs are really supposed to be protected but since the bindings need to call them
// and they have out parameters (and thus need to be re-implemented) they must be public
bool getNodeForMouseEvent(QMouseEvent* event, FlowGraphNodeRef& node);
bool getLineForMouseEvent(QMouseEvent* event, CursorPosition& pos);
- bool getEdgeForMouseEvent(QMouseEvent* event, FlowGraphNodeRef& source,
- BinaryNinja::FlowGraphEdge& edge, bool& incoming);
+ bool getEdgeForMouseEvent(
+ QMouseEvent* event, FlowGraphNodeRef& source, BinaryNinja::FlowGraphEdge& edge, bool& incoming);
FlowGraphWidget* duplicate();
-Q_SIGNALS:
+ Q_SIGNALS:
void layoutComplete();
void updateMiniGraph();
-private Q_SLOTS:
+ private Q_SLOTS:
void loadingTimerEvent();
void updateTimerEvent();
void hoverTimerEvent();
diff --git a/ui/forminputdialog.h b/ui/forminputdialog.h
index 1a46d2ea..7c797366 100644
--- a/ui/forminputdialog.h
+++ b/ui/forminputdialog.h
@@ -9,7 +9,7 @@
#include "binaryninjaapi.h"
#include "uicontext.h"
-class BINARYNINJAUIAPI FormInputDialog: public QDialog
+class BINARYNINJAUIAPI FormInputDialog : public QDialog
{
Q_OBJECT
@@ -20,9 +20,9 @@ class BINARYNINJAUIAPI FormInputDialog: public QDialog
void saveFileName(QLineEdit* edit, const std::string& ext, const std::string& defaultName);
void directoryName(QLineEdit* edit, const std::string& defaultName);
-public:
+ public:
FormInputDialog(QWidget* parent, std::vector<BinaryNinja::FormInputField>* fields, const std::string& title);
-protected Q_SLOTS:
+ protected Q_SLOTS:
void finish();
};
diff --git a/ui/getsymbolslistthread.h b/ui/getsymbolslistthread.h
index b806448a..220c8f84 100644
--- a/ui/getsymbolslistthread.h
+++ b/ui/getsymbolslistthread.h
@@ -1,8 +1,8 @@
#pragma once
#ifndef BINARYNINJAUI_BINDINGS
-#include <QtCore/QThread>
-#include <QtCore/QEvent>
+ #include <QtCore/QThread>
+ #include <QtCore/QEvent>
#endif
#include "binaryninjaapi.h"
#include "uitypes.h"
@@ -12,7 +12,7 @@
// QThread has issues working in the bindings on some platforms
class GetSymbolsListThread;
#else
-class BINARYNINJAUIAPI GetSymbolsListThread: public QThread
+class BINARYNINJAUIAPI GetSymbolsListThread : public QThread
{
Q_OBJECT
@@ -22,10 +22,10 @@ class BINARYNINJAUIAPI GetSymbolsListThread: public QThread
bool m_done;
BinaryViewRef m_view;
-protected:
+ protected:
virtual void run() override;
-public:
+ public:
GetSymbolsListThread(BinaryViewRef view, const std::function<void()>& completeFunc);
void cancel();
diff --git a/ui/globalarea.h b/ui/globalarea.h
index 2dffe3b0..1d0cd90b 100644
--- a/ui/globalarea.h
+++ b/ui/globalarea.h
@@ -5,46 +5,46 @@
#include "viewframe.h"
#include "tabwidget.h"
-class BINARYNINJAUIAPI GlobalAreaWidget: public QWidget
+class BINARYNINJAUIAPI GlobalAreaWidget : public QWidget
{
Q_OBJECT
-protected:
+ protected:
QString m_title;
UIActionHandler m_actionHandler;
ContextMenuManager* m_contextMenuManager = nullptr;
Menu* m_menu = nullptr;
-public:
+ public:
GlobalAreaWidget(const QString& title);
const QString& title() const { return m_title; }
- virtual void notifyFontChanged() { }
- virtual void notifyOffsetChanged(uint64_t /*offset*/) { }
- virtual void notifyThemeChanged() { }
- virtual void notifyViewChanged(ViewFrame* /*frame*/) { }
- virtual void notifyViewLocationChanged(View* /*view*/, const ViewLocation& /*viewLocation*/) { }
+ virtual void notifyFontChanged() {}
+ virtual void notifyOffsetChanged(uint64_t /*offset*/) {}
+ virtual void notifyThemeChanged() {}
+ virtual void notifyViewChanged(ViewFrame* /*frame*/) {}
+ virtual void notifyViewLocationChanged(View* /*view*/, const ViewLocation& /*viewLocation*/) {}
virtual void focus();
};
-class BINARYNINJAUIAPI GlobalAreaTabStyle: public DockableTabStyle
+class BINARYNINJAUIAPI GlobalAreaTabStyle : public DockableTabStyle
{
int closeButtonSize(const QWidget* widget) const;
-public:
- virtual QSize sizeForTab(const QWidget* widget, const DockableTabInfo& info, int idx,
- int count, int active) const override;
- virtual QRect closeButtonRect(const QWidget* widget, const DockableTabInfo& info, int idx,
- int count, int active) const override;
- virtual QRect closeIconRect(const QWidget* widget, const DockableTabInfo& info, int idx,
- int count, int active) const override;
- virtual void paintTab(const QWidget* widget, QStylePainter& p, const DockableTabInfo& info, int idx,
- int count, int active, DockableTabInteractionState state, const QRect& rect) const override;
+ public:
+ virtual QSize sizeForTab(
+ const QWidget* widget, const DockableTabInfo& info, int idx, int count, int active) const override;
+ virtual QRect closeButtonRect(
+ const QWidget* widget, const DockableTabInfo& info, int idx, int count, int active) const override;
+ virtual QRect closeIconRect(
+ const QWidget* widget, const DockableTabInfo& info, int idx, int count, int active) const override;
+ virtual void paintTab(const QWidget* widget, QStylePainter& p, const DockableTabInfo& info, int idx, int count,
+ int active, DockableTabInteractionState state, const QRect& rect) const override;
virtual DockableTabStyle* duplicate() override;
};
-class BINARYNINJAUIAPI CloseButton: public QWidget
+class BINARYNINJAUIAPI CloseButton : public QWidget
{
Q_OBJECT
@@ -52,11 +52,11 @@ class BINARYNINJAUIAPI CloseButton: public QWidget
bool m_buttonDown = false;
QTimer* m_timer;
-public:
+ public:
CloseButton();
virtual QSize sizeHint() const override;
-protected:
+ protected:
virtual void paintEvent(QPaintEvent* event) override;
virtual void enterEvent(QEnterEvent* event) override;
virtual void leaveEvent(QEvent* event) override;
@@ -64,14 +64,14 @@ protected:
virtual void mousePressEvent(QMouseEvent* event) override;
virtual void mouseReleaseEvent(QMouseEvent* event) override;
-private Q_SLOTS:
+ private Q_SLOTS:
void underMouseTimerEvent();
-Q_SIGNALS:
+ Q_SIGNALS:
void clicked();
};
-class BINARYNINJAUIAPI GlobalArea: public QWidget
+class BINARYNINJAUIAPI GlobalArea : public QWidget
{
Q_OBJECT
@@ -82,11 +82,11 @@ class BINARYNINJAUIAPI GlobalArea: public QWidget
static std::vector<std::function<GlobalAreaWidget*(UIContext*)>> m_widgetFactories;
- QString actionNameForWidget(const QString &title);
+ QString actionNameForWidget(const QString& title);
static QVariant sizesToVariant(const QList<int>& sizes);
static std::optional<QList<int>> variantToSizes(const QVariant& variant);
-public:
+ public:
GlobalArea();
void setSplitter(QSplitter* splitter);
@@ -120,7 +120,7 @@ public:
return context->globalArea();
}
- template<class T>
+ template <class T>
static T* widget(const QString& title)
{
GlobalArea* globalArea = current();
@@ -132,36 +132,34 @@ public:
return qobject_cast<T*>(widget);
}
- template<class T>
- static UIAction globalAreaAction(const QString& title,
- const std::function<void(T* obj)>& activate)
+ template <class T>
+ static UIAction globalAreaAction(const QString& title, const std::function<void(T* obj)>& activate)
{
- return globalAreaAction<T>(title,
- [=](T* obj, const UIActionContext&) { activate(obj); },
- [=](T*, const UIActionContext&) { return true; });
+ return globalAreaAction<T>(
+ title, [=](T* obj, const UIActionContext&) { activate(obj); },
+ [=](T*, const UIActionContext&) { return true; });
}
- template<class T>
- static UIAction globalAreaAction(const QString& title,
- const std::function<void(T* obj, const UIActionContext& ctxt)>& activate)
+ template <class T>
+ static UIAction globalAreaAction(
+ const QString& title, const std::function<void(T* obj, const UIActionContext& ctxt)>& activate)
{
- return globalAreaAction<T>(title, activate,
- [](T*, const UIActionContext&) { return true; });
+ return globalAreaAction<T>(title, activate, [](T*, const UIActionContext&) { return true; });
}
- template<class T>
- static UIAction globalAreaAction(const QString& title,
- const std::function<void(T* obj)>& activate, const std::function<bool(T* obj)>& isValid)
+ template <class T>
+ static UIAction globalAreaAction(
+ const QString& title, const std::function<void(T* obj)>& activate, const std::function<bool(T* obj)>& isValid)
{
- return globalAreaAction<T>(title,
- [=](T* obj, const UIActionContext&) { activate(obj); },
- [=](T* obj, const UIActionContext&) { return isValid(obj); });
+ return globalAreaAction<T>(
+ title, [=](T* obj, const UIActionContext&) { activate(obj); },
+ [=](T* obj, const UIActionContext&) { return isValid(obj); });
}
- template<class T>
+ template <class T>
static UIAction globalAreaAction(const QString& title,
- const std::function<void(T* obj, const UIActionContext& ctxt)>& activate,
- const std::function<bool(T* obj, const UIActionContext& ctxt)>& isValid)
+ const std::function<void(T* obj, const UIActionContext& ctxt)>& activate,
+ const std::function<bool(T* obj, const UIActionContext& ctxt)>& isValid)
{
std::function<T*(const UIActionContext& ctxt)> lookup = [=](const UIActionContext& ctxt) {
if (!ctxt.context)
@@ -175,30 +173,29 @@ public:
return qobject_cast<T*>(widget);
};
return UIAction(
- [=](const UIActionContext& ctxt) {
- T* obj = lookup(ctxt);
- if (obj)
- activate(obj, ctxt);
- },
- [=](const UIActionContext& ctxt) {
- T* obj = lookup(ctxt);
- if (obj)
- return isValid(obj, ctxt);
- return false;
- });
+ [=](const UIActionContext& ctxt) {
+ T* obj = lookup(ctxt);
+ if (obj)
+ activate(obj, ctxt);
+ },
+ [=](const UIActionContext& ctxt) {
+ T* obj = lookup(ctxt);
+ if (obj)
+ return isValid(obj, ctxt);
+ return false;
+ });
}
- template<class T>
- static std::function<bool(const UIActionContext&)> globalAreaActionChecked(const QString& title,
- const std::function<bool(T* obj)>& isChecked)
+ template <class T>
+ static std::function<bool(const UIActionContext&)> globalAreaActionChecked(
+ const QString& title, const std::function<bool(T* obj)>& isChecked)
{
- return globalAreaActionChecked<T>(title,
- [=](T* obj, const UIActionContext&) { return isChecked(obj); });
+ return globalAreaActionChecked<T>(title, [=](T* obj, const UIActionContext&) { return isChecked(obj); });
}
- template<class T>
- static std::function<bool(const UIActionContext&)> globalAreaActionChecked(const QString& title,
- const std::function<bool(T* obj, const UIActionContext& ctxt)>& isChecked)
+ template <class T>
+ static std::function<bool(const UIActionContext&)> globalAreaActionChecked(
+ const QString& title, const std::function<bool(T* obj, const UIActionContext& ctxt)>& isChecked)
{
return [=](const UIActionContext& ctxt) {
if (!ctxt.context)
@@ -216,10 +213,10 @@ public:
};
}
-Q_SIGNALS:
+ Q_SIGNALS:
void widgetClosed(GlobalAreaWidget* widget);
-private Q_SLOTS:
+ private Q_SLOTS:
void currentChanged(QWidget* widget);
void tabClosed(QWidget* widget);
void hideButtonClicked();
diff --git a/ui/hexeditor.h b/ui/hexeditor.h
index 0374f51d..5769ad47 100644
--- a/ui/hexeditor.h
+++ b/ui/hexeditor.h
@@ -11,11 +11,15 @@
#define HEX_EDITOR_UPDATE_CHECK_INTERVAL 200
-class BINARYNINJAUIAPI HexEditor : public QAbstractScrollArea, public View, public PreviewScrollHandler,
- public BinaryNinja::BinaryDataNotification
+class BINARYNINJAUIAPI HexEditor :
+ public QAbstractScrollArea,
+ public View,
+ public PreviewScrollHandler,
+ public BinaryNinja::BinaryDataNotification
{
Q_OBJECT
-public:
+
+ public:
explicit HexEditor(BinaryViewRef data, ViewFrame* view, uint64_t startAddr = 0);
virtual ~HexEditor();
@@ -55,25 +59,25 @@ public:
static void registerActions();
-private:
- class HexEditorHighlightWidget: public MenuHelper
+ private:
+ class HexEditorHighlightWidget : public MenuHelper
{
- public:
+ public:
HexEditorHighlightWidget(HexEditor* parent);
- protected:
+ protected:
virtual void showMenu();
- private:
+ private:
HexEditor* m_editor;
};
- class HexEditorOptionsIconWidget: public QWidget
+ class HexEditorOptionsIconWidget : public QWidget
{
- public:
+ public:
HexEditorOptionsIconWidget(HexEditor* parent);
- private:
+ private:
HexEditor* m_view;
ContextMenuManager* m_contextMenuManager;
Menu m_menu;
@@ -81,13 +85,13 @@ private:
void showMenu();
};
- class HexEditorStatusBarWidget: public StatusBarWidget
+ class HexEditorStatusBarWidget : public StatusBarWidget
{
- public:
+ public:
HexEditorStatusBarWidget(HexEditor* parent);
virtual void updateStatus() override;
- private:
+ private:
HexEditor* m_editor;
HexEditorHighlightWidget* m_highlight;
};
@@ -189,7 +193,7 @@ private:
ContextMenuManager* m_contextMenuManager;
-protected:
+ protected:
virtual void resizeEvent(QResizeEvent* event) override;
virtual void paintEvent(QPaintEvent* event) override;
virtual void focusInEvent(QFocusEvent* event) override;
@@ -201,25 +205,25 @@ protected:
virtual bool event(QEvent* event) override;
virtual void wheelEvent(QWheelEvent* event) override;
-Q_SIGNALS:
+ Q_SIGNALS:
-public Q_SLOTS:
+ public Q_SLOTS:
void disassembly();
void createFunc();
void createFuncWithPlatform(PlatformRef platform, bool autoSelect = false);
-private Q_SLOTS:
+ private Q_SLOTS:
void scrollBarMoved(int value);
void scrollBarAction(int action);
void cursorTimerEvent();
void updateTimerEvent();
};
-class HexEditorViewType: public ViewType
+class HexEditorViewType : public ViewType
{
static HexEditorViewType* m_instance;
-public:
+ public:
HexEditorViewType();
virtual int getPriority(BinaryViewRef data, const QString& filename) override;
virtual QWidget* create(BinaryViewRef data, ViewFrame* viewFrame) override;
diff --git a/ui/ilchooser.h b/ui/ilchooser.h
index acf1bd22..5779c7b2 100644
--- a/ui/ilchooser.h
+++ b/ui/ilchooser.h
@@ -3,32 +3,32 @@
#include "pane.h"
#include "menus.h"
-class BINARYNINJAUIAPI ILChooserWidget: public MenuHelper
+class BINARYNINJAUIAPI ILChooserWidget : public MenuHelper
{
Q_OBJECT
UIActionHandler* m_handler;
bool m_longDescription;
-public:
+ public:
ILChooserWidget(QWidget* parent, UIActionHandler* handler, bool longDescription);
void updateStatus(BNFunctionGraphType current);
static QString shortNameForILType(BNFunctionGraphType type);
static QString longNameForILType(BNFunctionGraphType type);
-protected:
+ protected:
virtual void showMenu() override;
};
-class BINARYNINJAUIAPI ViewPaneHeaderILChooserWidget: public ViewPaneHeaderSubtypeWidget
+class BINARYNINJAUIAPI ViewPaneHeaderILChooserWidget : public ViewPaneHeaderSubtypeWidget
{
Q_OBJECT
View* m_view;
ILChooserWidget* m_widget;
-public:
+ public:
ViewPaneHeaderILChooserWidget(View* view, UIActionHandler* handler);
virtual void updateStatus();
};
diff --git a/ui/instructionedit.h b/ui/instructionedit.h
index 9e388210..ea398f34 100644
--- a/ui/instructionedit.h
+++ b/ui/instructionedit.h
@@ -4,7 +4,7 @@
#include "binaryninjaapi.h"
#include "uicontext.h"
-class BINARYNINJAUIAPI InstructionEdit: public QLineEdit
+class BINARYNINJAUIAPI InstructionEdit : public QLineEdit
{
Q_OBJECT
@@ -14,16 +14,16 @@ class BINARYNINJAUIAPI InstructionEdit: public QLineEdit
uint64_t m_offset;
bool m_preventDismiss;
-public:
+ public:
InstructionEdit(QWidget* parent, BinaryViewRef data, ArchitectureRef arch, FunctionRef func, uint64_t offset);
void acceptInstruction();
void rejectInstruction();
-protected:
+ protected:
virtual void keyPressEvent(QKeyEvent* event);
virtual void focusOutEvent(QFocusEvent* event);
-Q_SIGNALS:
+ Q_SIGNALS:
void done();
};
diff --git a/ui/linearview.h b/ui/linearview.h
index f27897a1..312299e9 100644
--- a/ui/linearview.h
+++ b/ui/linearview.h
@@ -14,9 +14,9 @@
#include <assembledialog.h>
#define LINEAR_VIEW_UPDATE_CHECK_INTERVAL 200
-#define MAX_STRING_TYPE_LENGTH 1048576
+#define MAX_STRING_TYPE_LENGTH 1048576
-struct BINARYNINJAUIAPI LinearViewLine: public BinaryNinja::LinearDisassemblyLine
+struct BINARYNINJAUIAPI LinearViewLine : public BinaryNinja::LinearDisassemblyLine
{
BinaryNinja::Ref<BinaryNinja::LinearViewCursor> cursor;
size_t cursorSize;
@@ -52,7 +52,7 @@ struct BINARYNINJAUIAPI LinearViewCursorPosition
LinearViewCursorPosition AsLine() const;
};
-class BINARYNINJAUIAPI LinearViewHistoryEntry: public HistoryEntry
+class BINARYNINJAUIAPI LinearViewHistoryEntry : public HistoryEntry
{
std::vector<BinaryNinja::LinearViewObjectIdentifier> m_topPath;
size_t m_topLineIndex;
@@ -65,7 +65,7 @@ class BINARYNINJAUIAPI LinearViewHistoryEntry: public HistoryEntry
bool m_inFunc = false;
HighlightTokenState m_highlight;
-public:
+ public:
const std::vector<BinaryNinja::LinearViewObjectIdentifier>& getTopPath() const { return m_topPath; }
size_t getTopLineIndex() const { return m_topLineIndex; }
uint64_t getTopAddress() const { return m_topAddr; }
@@ -92,28 +92,28 @@ public:
virtual bool deserialize(const Json::Value& value) override;
};
-class BINARYNINJAUIAPI LinearView: public QAbstractScrollArea, public View, public BinaryNinja::BinaryDataNotification
+class BINARYNINJAUIAPI LinearView : public QAbstractScrollArea, public View, public BinaryNinja::BinaryDataNotification
{
Q_OBJECT
- class LinearViewOptionsWidget: public MenuHelper
+ class LinearViewOptionsWidget : public MenuHelper
{
- public:
+ public:
LinearViewOptionsWidget(LinearView* parent);
- protected:
+ protected:
virtual void showMenu();
- private:
+ private:
LinearView* m_view;
};
- class LinearViewOptionsIconWidget: public QWidget
+ class LinearViewOptionsIconWidget : public QWidget
{
- public:
+ public:
LinearViewOptionsIconWidget(LinearView* parent);
- private:
+ private:
LinearView* m_view;
ContextMenuManager* m_contextMenuManager;
Menu m_menu;
@@ -121,13 +121,13 @@ class BINARYNINJAUIAPI LinearView: public QAbstractScrollArea, public View, publ
void showMenu();
};
- class LinearViewStatusBarWidget: public StatusBarWidget
+ class LinearViewStatusBarWidget : public StatusBarWidget
{
- public:
+ public:
LinearViewStatusBarWidget(LinearView* parent);
virtual void updateStatus() override;
- private:
+ private:
LinearView* m_view;
LinearViewOptionsWidget* m_options;
ILChooserWidget* m_chooser;
@@ -196,8 +196,8 @@ class BINARYNINJAUIAPI LinearView: public QAbstractScrollArea, public View, publ
void updateBounds();
void refreshAtCurrentLocation(bool cursorFixup = false);
bool navigateToAddress(uint64_t addr, bool center, bool updateHighlight, bool navByRef = false);
- bool navigateToLine(FunctionRef func, uint64_t offset, size_t instrIndex, bool center,
- bool updateHighlight, bool navByRef = false);
+ bool navigateToLine(
+ FunctionRef func, uint64_t offset, size_t instrIndex, bool center, bool updateHighlight, bool navByRef = false);
bool navigateToGotoLabel(uint64_t label);
void viewData();
@@ -206,8 +206,8 @@ class BINARYNINJAUIAPI LinearView: public QAbstractScrollArea, public View, publ
void bindActions();
static void addOptionsMenuActions(Menu& menu);
- void getHexDumpLineBytes(const BinaryNinja::LinearDisassemblyLine& line, size_t& skippedBytes, size_t& totalBytes,
- size_t& totalCols);
+ void getHexDumpLineBytes(
+ const BinaryNinja::LinearDisassemblyLine& line, size_t& skippedBytes, size_t& totalBytes, size_t& totalCols);
void paintHexDumpLine(QPainter& p, const LinearViewLine& line, int xoffset, int y, uint32_t addrLen, int tagOffset);
void paintAnalysisWarningLine(QPainter& p, const LinearViewLine& line, int xoffset, int y);
@@ -220,9 +220,10 @@ class BINARYNINJAUIAPI LinearView: public QAbstractScrollArea, public View, publ
TypeRef createStructure(BinaryNinja::QualifiedName& name, uint64_t size);
TypeRef getInnerType(TypeRef type, uint64_t offset, uint64_t size, std::set<TypeRef>& seen);
- StructureRef defineInnerType(TypeRef type, TypeRef baseType, uint64_t offset, uint64_t size, std::set<TypeRef>& seen);
- StructureRef defineInnerPointer(TypeRef type, ArchitectureRef arch, uint64_t baseAddress,
- uint64_t offset, uint64_t size, std::set<TypeRef>& seen);
+ StructureRef defineInnerType(
+ TypeRef type, TypeRef baseType, uint64_t offset, uint64_t size, std::set<TypeRef>& seen);
+ StructureRef defineInnerPointer(TypeRef type, ArchitectureRef arch, uint64_t baseAddress, uint64_t offset,
+ uint64_t size, std::set<TypeRef>& seen);
StructureRef defineInnerStruct(TypeRef type, uint64_t offset, uint64_t size, std::set<TypeRef>& seen);
StructureRef defineInnerArray(TypeRef type, uint64_t offset, uint64_t size, std::set<TypeRef>& seen);
StructureRef defineInnerName(TypeRef type, uint64_t offset, uint64_t size, std::set<TypeRef>& seen);
@@ -236,8 +237,7 @@ class BINARYNINJAUIAPI LinearView: public QAbstractScrollArea, public View, publ
bool updateCursor(LinearViewCursorPosition& cursorToUpdate, BinaryNinja::LinearViewCursor* matched, bool fullMatch);
bool updateCursor(LinearViewCursorPosition& cursorToUpdate, BinaryNinja::LinearViewCursor* newCursor);
bool updateCursor(LinearViewCursorPosition& cursorToUpdate,
- const std::vector<BinaryNinja::LinearViewObjectIdentifier>& path,
- BinaryNinja::LinearViewCursor* newCursor);
+ const std::vector<BinaryNinja::LinearViewObjectIdentifier>& path, BinaryNinja::LinearViewCursor* newCursor);
uint64_t getOrderingIndexForLine(const LinearViewLine& line);
void updateAnalysisRequestorsForCache();
@@ -247,14 +247,14 @@ class BINARYNINJAUIAPI LinearView: public QAbstractScrollArea, public View, publ
BNAnalysisWarningActionType getAnalysisWarningActionAtPos(const LinearViewLine& line, int x);
- void getCurrentOffsetByTypeInternal(TypeRef resType, uint64_t baseAddr, uint64_t& begin, uint64_t& end,
- bool singleLine, std::set<TypeRef>& seen);
+ void getCurrentOffsetByTypeInternal(
+ TypeRef resType, uint64_t baseAddr, uint64_t& begin, uint64_t& end, bool singleLine, std::set<TypeRef>& seen);
BNDeadStoreElimination getCurrentVariableDeadStoreElimination();
void setDataButtonVisible(bool visible);
-private Q_SLOTS:
+ private Q_SLOTS:
void adjustSize(int width, int height);
void viewInHexEditor();
void viewInGraph();
@@ -334,10 +334,10 @@ private Q_SLOTS:
void setCurrentVariableDeadStoreElimination(BNDeadStoreElimination elimination);
-Q_SIGNALS:
+ Q_SIGNALS:
void notifyResizeEvent(int width, int height);
-public:
+ public:
explicit LinearView(BinaryViewRef data, ViewFrame* view);
virtual ~LinearView();
@@ -422,7 +422,7 @@ public:
static void registerActions();
-protected:
+ protected:
virtual void resizeEvent(QResizeEvent* event) override;
virtual void paintEvent(QPaintEvent* event) override;
virtual void wheelEvent(QWheelEvent* event) override;
@@ -444,11 +444,11 @@ protected:
void navigateToHighlightedToken();
};
-class LinearViewType: public ViewType
+class LinearViewType : public ViewType
{
static LinearViewType* m_instance;
-public:
+ public:
LinearViewType();
virtual int getPriority(BinaryViewRef data, const QString& filename) override;
virtual QWidget* create(BinaryViewRef data, ViewFrame* viewFrame) override;
diff --git a/ui/logview.h b/ui/logview.h
index bf9d4627..2a83d919 100644
--- a/ui/logview.h
+++ b/ui/logview.h
@@ -28,11 +28,12 @@ struct BINARYNINJAUIAPI LogListItem
std::string text;
bool selected;
- LogListItem(BNLogLevel level, std::string text, bool selected = false) : level(level), text(text), selected(selected) { };
+ LogListItem(BNLogLevel level, std::string text, bool selected = false) :
+ level(level), text(text), selected(selected) {};
};
-class BINARYNINJAUIAPI LogListModel: public QAbstractItemModel, public BinaryNinja::LogListener
+class BINARYNINJAUIAPI LogListModel : public QAbstractItemModel, public BinaryNinja::LogListener
{
Q_OBJECT
@@ -45,7 +46,7 @@ class BINARYNINJAUIAPI LogListModel: public QAbstractItemModel, public BinaryNin
std::mutex m_mutex;
std::mutex m_pendingMutex;
-public:
+ public:
LogListModel(QWidget* parent);
~LogListModel();
@@ -65,12 +66,12 @@ public:
virtual QVariant data(const QModelIndex& i, int role) const override;
virtual bool setData(const QModelIndex& i, const QVariant& value, int role) override;
-public Q_SLOTS:
+ public Q_SLOTS:
void notifyDataChanged();
};
-class BINARYNINJAUIAPI LogItemDelegate: public QStyledItemDelegate
+class BINARYNINJAUIAPI LogItemDelegate : public QStyledItemDelegate
{
Q_OBJECT
@@ -84,25 +85,26 @@ class BINARYNINJAUIAPI LogItemDelegate: public QStyledItemDelegate
bool IsNavigable(const QString& str, const std::pair<int, int>& offsetLen, uint64_t& value, bool highlight) const;
-public:
+ public:
LogItemDelegate(QWidget* parent);
void updateFonts();
virtual QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& idx) const override;
virtual void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& idx) const override;
-protected:
- bool editorEvent(QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index) override;
+ protected:
+ bool editorEvent(QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option,
+ const QModelIndex& index) override;
-Q_SIGNALS:
+ Q_SIGNALS:
void notifyDataChanged();
-public Q_SLOTS:
+ public Q_SLOTS:
void viewChanged(QWidget* frame);
};
-class BINARYNINJAUIAPI LogView: public GlobalAreaWidget
+class BINARYNINJAUIAPI LogView : public GlobalAreaWidget
{
Q_OBJECT
@@ -117,7 +119,7 @@ class BINARYNINJAUIAPI LogView: public GlobalAreaWidget
bool m_scrolledToEnd;
bool m_hasSelection = false;
-public:
+ public:
LogView(LogStatus* logStatus);
virtual void copy();
@@ -135,17 +137,17 @@ public:
LogListModel* model() { return m_listModel; }
-protected:
+ protected:
void contextMenuEvent(QContextMenuEvent* event) override;
-Q_SIGNALS:
+ Q_SIGNALS:
void notifyUiStatus();
void viewChanged(QWidget* frame);
-public Q_SLOTS:
+ public Q_SLOTS:
void clear();
-private Q_SLOTS:
+ private Q_SLOTS:
void scrollRangeChanged(int minimum, int maximum);
void scrollValueChanged(int value);
void updateSelection(const QItemSelection& selected, const QItemSelection& deselected);
@@ -154,7 +156,7 @@ private Q_SLOTS:
};
-class BINARYNINJAUIAPI LogStatus: public QWidget
+class BINARYNINJAUIAPI LogStatus : public QWidget
{
Q_OBJECT
@@ -164,7 +166,7 @@ class BINARYNINJAUIAPI LogStatus: public QWidget
int m_errorCount = 0;
int m_warnCount = 0;
-public:
+ public:
LogStatus(QWidget* parent);
void incrementErrorCount(int count);
@@ -173,6 +175,6 @@ public:
void updateTheme();
-private Q_SLOTS:
+ private Q_SLOTS:
void clearStatus();
};
diff --git a/ui/menus.h b/ui/menus.h
index 59791884..20464d62 100644
--- a/ui/menus.h
+++ b/ui/menus.h
@@ -12,7 +12,7 @@
#include "action.h"
#include "viewframe.h"
-class BINARYNINJAUIAPI ContextMenuManager: public QObject
+class BINARYNINJAUIAPI ContextMenuManager : public QObject
{
Q_OBJECT
@@ -20,8 +20,8 @@ class BINARYNINJAUIAPI ContextMenuManager: public QObject
QPointer<QMenu> m_menu;
MenuInstance* m_instance;
-public:
- ContextMenuManager(): m_parent(nullptr), m_menu(nullptr), m_instance(nullptr) { }
+ public:
+ ContextMenuManager() : m_parent(nullptr), m_menu(nullptr), m_instance(nullptr) {}
ContextMenuManager(QWidget* parent);
~ContextMenuManager();
QMenu* create();
@@ -31,13 +31,13 @@ public:
MenuInstance* show(QPoint pos, Menu* source, UIActionHandler* handler);
bool isActive() { return !m_menu.isNull(); }
-Q_SIGNALS:
+ Q_SIGNALS:
void onOpen();
void onClose();
};
-class BINARYNINJAUIAPI MenuHelper: public QLabel
+class BINARYNINJAUIAPI MenuHelper : public QLabel
{
Q_OBJECT
@@ -48,15 +48,15 @@ class BINARYNINJAUIAPI MenuHelper: public QLabel
QPalette::ColorRole m_activeForegroundRole;
QPalette::ColorRole m_pressedForegroundRole;
-protected:
+ protected:
Menu m_menu;
ContextMenuManager* m_contextMenuManager;
QTimer* m_timer;
bool m_active;
bool m_pressed;
-public:
- MenuHelper() { }
+ public:
+ MenuHelper() {}
explicit MenuHelper(QWidget* parent);
void setBackgroundColorRole(QPalette::ColorRole role);
@@ -66,16 +66,16 @@ public:
void setActiveForegroundColorRole(QPalette::ColorRole role);
void setPressedForegroundColorRole(QPalette::ColorRole role);
-Q_SIGNALS:
+ Q_SIGNALS:
void clicked();
-protected Q_SLOTS:
+ protected Q_SLOTS:
virtual void showMenu() = 0;
-private Q_SLOTS:
+ private Q_SLOTS:
void underMouseTimerEvent();
-protected:
+ protected:
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void enterEvent(QEvent* event) override;
#else
diff --git a/ui/minigraph.h b/ui/minigraph.h
index 69b59768..a4be4368 100644
--- a/ui/minigraph.h
+++ b/ui/minigraph.h
@@ -13,7 +13,7 @@ class FlowGraphWidget;
class Menu;
class ViewFrame;
-class BINARYNINJAUIAPI MiniGraph: public SidebarWidget, public UIContextNotification
+class BINARYNINJAUIAPI MiniGraph : public SidebarWidget, public UIContextNotification
{
Q_OBJECT
@@ -23,7 +23,7 @@ class BINARYNINJAUIAPI MiniGraph: public SidebarWidget, public UIContextNotifica
bool m_popout;
QRect m_miniRenderRect;
-public:
+ public:
MiniGraph(bool popout = false);
~MiniGraph();
@@ -38,23 +38,23 @@ public:
void setSource(ViewFrame* frame, FlowGraphWidget* graphView);
-protected:
+ protected:
virtual void contextMenuEvent(QContextMenuEvent* event) override;
virtual void mouseMoveEvent(QMouseEvent* event) override;
virtual void mousePressEvent(QMouseEvent* event) override;
virtual void paintEvent(QPaintEvent* event) override;
virtual void scrollTo(int x, int y);
-public Q_SLOTS:
+ public Q_SLOTS:
void notifyUpdate();
void graphDestroyed();
void newPane();
};
-class BINARYNINJAUIAPI MiniGraphSidebarWidgetType: public SidebarWidgetType
+class BINARYNINJAUIAPI MiniGraphSidebarWidgetType : public SidebarWidgetType
{
-public:
+ public:
MiniGraphSidebarWidgetType();
virtual SidebarWidget* createWidget(ViewFrame* frame, BinaryViewRef data) override;
virtual bool isInReferenceArea() const override { return true; }
diff --git a/ui/options.h b/ui/options.h
index e3c2eab4..c0b9d77e 100644
--- a/ui/options.h
+++ b/ui/options.h
@@ -15,7 +15,7 @@
#include <tuple>
#include <vector>
-class BINARYNINJAUIAPI OptionsDialog: public QDialog
+class BINARYNINJAUIAPI OptionsDialog : public QDialog
{
Q_OBJECT
@@ -32,15 +32,15 @@ class BINARYNINJAUIAPI OptionsDialog: public QDialog
BinaryViewRef m_rawData = nullptr;
std::vector<std::tuple<std::string, size_t, std::string, uint64_t, uint64_t, std::string>> m_objects;
-public:
+ public:
OptionsDialog(QWidget* parent, const QString& name);
virtual ~OptionsDialog();
bool loadViews();
-Q_SIGNALS:
+ Q_SIGNALS:
void openFile(FileContext* file);
-private Q_SLOTS:
+ private Q_SLOTS:
void cancel();
void open();
void addSettingsViewForType(const std::string& bvtName);
diff --git a/ui/pane.h b/ui/pane.h
index 0fe3e8ec..5b02862d 100644
--- a/ui/pane.h
+++ b/ui/pane.h
@@ -15,7 +15,7 @@ class CloseButton;
class TabDragIndicator;
class SyncGroup;
-class BINARYNINJAUIAPI Pane: public QWidget
+class BINARYNINJAUIAPI Pane : public QWidget
{
Q_OBJECT
@@ -26,7 +26,7 @@ class BINARYNINJAUIAPI Pane: public QWidget
bool m_active = false;
QVBoxLayout* m_layout = nullptr;
-public:
+ public:
Pane(QWidget* widget);
QWidget* widget() const { return m_widget; }
@@ -45,17 +45,17 @@ public:
void setWidget(QWidget* widget);
-protected:
+ protected:
void init(PaneHeader* header);
-Q_SIGNALS:
+ Q_SIGNALS:
void paneCloseRequested();
void paneSplitRequested(Pane* newPane, Qt::Edge edge);
void movePane(Pane* target, Qt::Edge edge);
void newWindowForPane(QScreen* screen, QPoint pos);
void notifyViewChanged(ViewFrame* frame);
-public Q_SLOTS:
+ public Q_SLOTS:
void splitButtonClicked(Qt::Orientation orientation);
void closeButtonClicked();
void headerClicked();
@@ -63,7 +63,7 @@ public Q_SLOTS:
void newWindowForPaneRequested(QScreen* screen, QPoint pos);
};
-class BINARYNINJAUIAPI SplitButton: public ClickableIcon
+class BINARYNINJAUIAPI SplitButton : public ClickableIcon
{
Q_OBJECT
@@ -75,24 +75,24 @@ class BINARYNINJAUIAPI SplitButton: public ClickableIcon
void splitHorizontal();
void splitVertical();
-public:
+ public:
SplitButton();
void setDefaultOrientation(Qt::Orientation orientation);
Qt::Orientation orientation() const;
Qt::Orientation defaultOrientation() const { return m_defaultOrientation; }
-protected:
+ protected:
virtual void enterEvent(QEnterEvent* event) override;
virtual void leaveEvent(QEvent* event) override;
virtual bool eventFilter(QObject* obj, QEvent* event) override;
virtual void mousePressEvent(QMouseEvent* event) override;
-Q_SIGNALS:
+ Q_SIGNALS:
void splitWithDirection(Qt::Orientation orientation);
};
-class BINARYNINJAUIAPI PaneHeader: public QWidget
+class BINARYNINJAUIAPI PaneHeader : public QWidget
{
Q_OBJECT
@@ -104,17 +104,17 @@ class BINARYNINJAUIAPI PaneHeader: public QWidget
Qt::Edge m_dropEdge = Qt::RightEdge;
QRubberBand* m_dropIndicator = nullptr;
-public:
+ public:
PaneHeader();
void setOwner(Pane* pane) { m_owner = pane; }
-protected:
+ protected:
virtual void mousePressEvent(QMouseEvent* event) override;
virtual void mouseMoveEvent(QMouseEvent* event) override;
virtual void mouseReleaseEvent(QMouseEvent* event) override;
-Q_SIGNALS:
+ Q_SIGNALS:
void paneCloseRequested();
void paneSplitRequested(Qt::Orientation orientation);
void movePane(Pane* target, Qt::Edge edge);
@@ -125,7 +125,7 @@ Q_SIGNALS:
class ViewFrame;
class ViewPaneHeader;
-class BINARYNINJAUIAPI ViewPane: public Pane
+class BINARYNINJAUIAPI ViewPane : public Pane
{
Q_OBJECT
@@ -133,7 +133,7 @@ class BINARYNINJAUIAPI ViewPane: public Pane
UIActionHandler m_actionHandler;
ViewPaneHeader* m_header;
-public:
+ public:
ViewPane(ViewFrame* frame);
ViewFrame* viewFrame() const { return m_frame; }
@@ -148,7 +148,7 @@ public:
void recreateViewFrame(std::map<SyncGroup*, ViewLocation>& locations);
void sendViewChange();
-private Q_SLOTS:
+ private Q_SLOTS:
void viewChanged(ViewFrame* frame);
void viewChangeRequested(QString type);
};
@@ -157,16 +157,16 @@ class DataTypeList;
class ViewList;
class SyncGroupWidget;
-class BINARYNINJAUIAPI ViewPaneHeaderSubtypeWidget: public QWidget
+class BINARYNINJAUIAPI ViewPaneHeaderSubtypeWidget : public QWidget
{
Q_OBJECT
-public:
+ public:
ViewPaneHeaderSubtypeWidget() {}
virtual void updateStatus() = 0;
};
-class BINARYNINJAUIAPI ViewPaneHeader: public PaneHeader
+class BINARYNINJAUIAPI ViewPaneHeader : public PaneHeader
{
Q_OBJECT
@@ -183,7 +183,7 @@ class BINARYNINJAUIAPI ViewPaneHeader: public PaneHeader
SplitButton* m_splitButton;
-public:
+ public:
ViewPaneHeader(ViewPane* owner, UIActionHandler* handler);
void updateStatus();
@@ -191,47 +191,47 @@ public:
void setDefaultSplitDirection(Qt::Orientation orientation);
void setViewFrame(ViewFrame* frame);
-Q_SIGNALS:
+ Q_SIGNALS:
void viewChanged(QString type);
-private Q_SLOTS:
+ private Q_SLOTS:
void splitButtonClicked();
void splitButtonClickedWithDirection(Qt::Orientation orientation);
void viewChangeRequested(QString type);
void updateViewType(ViewFrame* frame);
};
-class BINARYNINJAUIAPI WidgetPane: public Pane
+class BINARYNINJAUIAPI WidgetPane : public Pane
{
Q_OBJECT
QString m_title;
-public:
+ public:
WidgetPane(QWidget* widget, QString title);
virtual QString title() override { return m_title; }
virtual void updateStatus() override;
-Q_SIGNALS:
+ Q_SIGNALS:
void updateWidgetStatus();
};
-class BINARYNINJAUIAPI WidgetPaneHeader: public PaneHeader
+class BINARYNINJAUIAPI WidgetPaneHeader : public PaneHeader
{
Q_OBJECT
QString m_title;
-public:
+ public:
WidgetPaneHeader(const QString& title);
-protected:
+ protected:
virtual void paintEvent(QPaintEvent* event) override;
};
class SplitPaneWidget;
-class BINARYNINJAUIAPI SplitPaneContainer: public QWidget
+class BINARYNINJAUIAPI SplitPaneContainer : public QWidget
{
Q_OBJECT
@@ -255,7 +255,7 @@ class BINARYNINJAUIAPI SplitPaneContainer: public QWidget
void deactivateIfCurrent(Pane* pane);
void notifyCurrentChanged(Pane* pane);
-public:
+ public:
SplitPaneContainer(Pane* initial);
Pane* currentPane() const { return m_currentChild; }
ViewPane* currentViewPane() const { return m_currentViewPane; }
@@ -284,7 +284,7 @@ public:
void recreateViewFrames(std::map<SyncGroup*, ViewLocation>& locations);
-Q_SIGNALS:
+ Q_SIGNALS:
void paneClosed(Pane* pane);
void currentChanged(Pane* pane);
void layoutChanged();
@@ -292,7 +292,7 @@ Q_SIGNALS:
void lastPaneClosed();
void newWindowForPane(SplitPaneWidget* paneWidget, QRect rect);
-private Q_SLOTS:
+ private Q_SLOTS:
void paneCloseRequested();
void paneSplitRequested(Pane* newPane, Qt::Edge edge);
void movePane(Pane* target, Qt::Edge edge);
@@ -303,7 +303,7 @@ private Q_SLOTS:
void childViewChanged(ViewFrame* frame);
};
-class BINARYNINJAUIAPI SplitPaneWidget: public QWidget
+class BINARYNINJAUIAPI SplitPaneWidget : public QWidget
{
Q_OBJECT
@@ -318,7 +318,7 @@ class BINARYNINJAUIAPI SplitPaneWidget: public QWidget
void bindActions();
-public:
+ public:
SplitPaneWidget(Pane* initial, FileContext* fileContext);
Pane* currentPane() const;
ViewPane* currentViewPane() const;
@@ -357,14 +357,14 @@ public:
static void registerActions();
-Q_SIGNALS:
+ Q_SIGNALS:
void paneClosed(Pane* pane);
void currentChanged(Pane* pane);
void layoutChanged();
void notifyViewChanged(ViewFrame* frame);
void newWindowForPane(SplitPaneWidget* paneWidget, QRect rect);
-private Q_SLOTS:
+ private Q_SLOTS:
void containerPaneClosed(Pane* pane);
void containerCurrentChanged(Pane* pane);
void containerLayoutChanged();
diff --git a/ui/platformdialog.h b/ui/platformdialog.h
index 01f2c75f..071d4f8e 100644
--- a/ui/platformdialog.h
+++ b/ui/platformdialog.h
@@ -5,7 +5,7 @@
#include "binaryninjaapi.h"
#include "uicontext.h"
-class BINARYNINJAUIAPI PlatformDialog: public QDialog
+class BINARYNINJAUIAPI PlatformDialog : public QDialog
{
Q_OBJECT
@@ -16,13 +16,13 @@ class BINARYNINJAUIAPI PlatformDialog: public QDialog
std::map<QString, PlatformRef> m_platformsByName;
PlatformRef m_selectedPlatform;
-public:
+ public:
PlatformDialog(QWidget* parent, ArchitectureRef defaultArch = nullptr);
PlatformRef getPlatform();
void saveDefaults();
-private Q_SLOTS:
+ private Q_SLOTS:
void architectureChanged(const QString& name);
void osChanged(const QString& name);
diff --git a/ui/possiblevaluesetdialog.h b/ui/possiblevaluesetdialog.h
index d2229de7..8202fca0 100644
--- a/ui/possiblevaluesetdialog.h
+++ b/ui/possiblevaluesetdialog.h
@@ -7,7 +7,7 @@
#include "uitypes.h"
-class BINARYNINJAUIAPI PossibleValueSetDialog: public QDialog
+class BINARYNINJAUIAPI PossibleValueSetDialog : public QDialog
{
Q_OBJECT
@@ -26,8 +26,9 @@ class BINARYNINJAUIAPI PossibleValueSetDialog: public QDialog
BinaryNinja::PossibleValueSet m_valueSet;
-public:
- PossibleValueSetDialog(QWidget* parent, BinaryViewRef view, uint64_t addr, BinaryNinja::PossibleValueSet existingValue);
+ public:
+ PossibleValueSetDialog(
+ QWidget* parent, BinaryViewRef view, uint64_t addr, BinaryNinja::PossibleValueSet existingValue);
BinaryNinja::PossibleValueSet getPossibleValueSet() const { return m_valueSet; }
void validate(const QString& input);
diff --git a/ui/preview.h b/ui/preview.h
index 670e8fb9..4ce1e3b2 100644
--- a/ui/preview.h
+++ b/ui/preview.h
@@ -6,23 +6,23 @@
class BINARYNINJAUIAPI PreviewScrollHandler
{
-public:
+ public:
virtual ~PreviewScrollHandler() {}
virtual void sendWheelEvent(QWheelEvent* event) = 0;
};
-class BINARYNINJAUIAPI PreviewWidget: public QFrame
+class BINARYNINJAUIAPI PreviewWidget : public QFrame
{
Q_OBJECT
QWidget* m_contents;
PreviewScrollHandler* m_scrollHandler;
-protected:
+ protected:
virtual bool eventFilter(QObject* obj, QEvent* event) override;
virtual void wheelEvent(QWheelEvent* event) override;
-public:
+ public:
PreviewWidget();
virtual ~PreviewWidget();
diff --git a/ui/progressindicator.h b/ui/progressindicator.h
index 56976f31..2e2829e9 100644
--- a/ui/progressindicator.h
+++ b/ui/progressindicator.h
@@ -27,104 +27,108 @@
/*!
\class QProgressIndicator
- \brief The QProgressIndicator class lets an application display a progress indicator to show that a lengthy task is under way.
+ \brief The QProgressIndicator class lets an application display a progress indicator to show that a lengthy task is
+ under way.
Progress indicators are indeterminate and do nothing more than spin to show that the application is busy.
\sa QProgressBar
*/
class BINARYNINJAUIAPI QProgressIndicator : public QWidget
{
- Q_OBJECT
- Q_PROPERTY(int delay READ animationDelay WRITE setAnimationDelay)
- Q_PROPERTY(bool displayedWhenStopped READ isDisplayedWhenStopped WRITE setDisplayedWhenStopped)
- Q_PROPERTY(QColor color READ color WRITE setColor)
- int m_width = 18;
+ Q_OBJECT
+ Q_PROPERTY(int delay READ animationDelay WRITE setAnimationDelay)
+ Q_PROPERTY(bool displayedWhenStopped READ isDisplayedWhenStopped WRITE setDisplayedWhenStopped)
+ Q_PROPERTY(QColor color READ color WRITE setColor)
+ int m_width = 18;
-public:
- QProgressIndicator(QWidget* parent = 0);
+ public:
+ QProgressIndicator(QWidget* parent = 0);
- /*! Returns the delay between animation steps.
- \return The number of milliseconds between animation steps. By default, the animation delay is set to 40 milliseconds.
- \sa setAnimationDelay
- */
- int animationDelay() const { return m_delay; }
+ /*! Returns the delay between animation steps.
+ \return The number of milliseconds between animation steps. By default, the animation delay is set to 40
+ milliseconds. \sa setAnimationDelay
+ */
+ int animationDelay() const { return m_delay; }
- /*! Returns a Boolean value indicating whether the component is currently animated.
- \return Animation state.
- \sa startAnimation stopAnimation
- */
- bool isAnimated () const;
+ /*! Returns a Boolean value indicating whether the component is currently animated.
+ \return Animation state.
+ \sa startAnimation stopAnimation
+ */
+ bool isAnimated() const;
- /*! Returns a Boolean value indicating whether the receiver shows itself even when it is not animating.
- \return Return true if the progress indicator shows itself even when it is not animating. By default, it returns false.
- \sa setDisplayedWhenStopped
- */
- bool isDisplayedWhenStopped() const;
+ /*! Returns a Boolean value indicating whether the receiver shows itself even when it is not animating.
+ \return Return true if the progress indicator shows itself even when it is not animating. By default, it returns
+ false. \sa setDisplayedWhenStopped
+ */
+ bool isDisplayedWhenStopped() const;
- /*! Returns the color of the component.
- \sa setColor
- */
- const QColor & color() const { return m_color; }
+ /*! Returns the color of the component.
+ \sa setColor
+ */
+ const QColor& color() const { return m_color; }
- QSize sizeHint() const override { return QSize(m_width, m_width); };
- void setWidth(int width) { m_width = width; };
- int heightForWidth(int w) const override;
-public Q_SLOTS:
- /*! Starts the spin animation.
- \sa stopAnimation isAnimated
- */
- void startAnimation();
+ QSize sizeHint() const override { return QSize(m_width, m_width); };
+ void setWidth(int width) { m_width = width; };
+ int heightForWidth(int w) const override;
+ public Q_SLOTS:
+ /*! Starts the spin animation.
+ \sa stopAnimation isAnimated
+ */
+ void startAnimation();
- /*! Stops the spin animation.
- \sa startAnimation isAnimated
- */
- void stopAnimation();
+ /*! Stops the spin animation.
+ \sa startAnimation isAnimated
+ */
+ void stopAnimation();
- /*! Sets the delay between animation steps.
- Setting the \a delay to a value larger than 40 slows the animation, while setting the \a delay to a smaller value speeds it up.
- \param delay The delay, in milliseconds.
- \sa animationDelay
- */
- void setAnimationDelay(int delay);
+ /*! Sets the delay between animation steps.
+ Setting the \a delay to a value larger than 40 slows the animation, while setting the \a delay to a smaller
+ value speeds it up. \param delay The delay, in milliseconds. \sa animationDelay
+ */
+ void setAnimationDelay(int delay);
- /*! Sets whether the component hides itself when it is not animating.
- \param state The animation state. Set false to hide the progress indicator when it is not animating; otherwise true.
- \sa isDisplayedWhenStopped
- */
- void setDisplayedWhenStopped(bool state, const QString& staticDisplay = "");
+ /*! Sets whether the component hides itself when it is not animating.
+ \param state The animation state. Set false to hide the progress indicator when it is not animating; otherwise
+ true. \sa isDisplayedWhenStopped
+ */
+ void setDisplayedWhenStopped(bool state, const QString& staticDisplay = "");
- void setToolTips(const QString& staticToolTip, const QString& animatedToolTip);
+ void setToolTips(const QString& staticToolTip, const QString& animatedToolTip);
- /*! Sets the color of the components to the given color.
- \sa color
- */
- void setColor(const QColor & color);
+ /*! Sets the color of the components to the given color.
+ \sa color
+ */
+ void setColor(const QColor& color);
-Q_SIGNALS:
+ Q_SIGNALS:
void clicked();
-protected:
+ protected:
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void enterEvent(QEvent* event) override;
#else
void enterEvent(QEnterEvent* event) override;
#endif
void leaveEvent(QEvent* event) override;
- void mouseReleaseEvent(QMouseEvent* event) override { if (event->button() == Qt::LeftButton) Q_EMIT clicked(); }
- void timerEvent(QTimerEvent * event) override;
- void paintEvent(QPaintEvent * event) override;
+ void mouseReleaseEvent(QMouseEvent* event) override
+ {
+ if (event->button() == Qt::LeftButton)
+ Q_EMIT clicked();
+ }
+ void timerEvent(QTimerEvent* event) override;
+ void paintEvent(QPaintEvent* event) override;
-private:
- int m_angle;
- int m_timerId;
- int m_delay;
- bool m_displayedWhenStopped;
- QString m_staticDisplay;
- bool m_useAutoToolTips = false;
- QString m_staticToolTip;
- QString m_animatedToolTip;
- QColor m_color;
- bool m_activeHover = false;
+ private:
+ int m_angle;
+ int m_timerId;
+ int m_delay;
+ bool m_displayedWhenStopped;
+ QString m_staticDisplay;
+ bool m_useAutoToolTips = false;
+ QString m_staticToolTip;
+ QString m_animatedToolTip;
+ QColor m_color;
+ bool m_activeHover = false;
};
-#endif // QPROGRESSINDICATOR_H
+#endif // QPROGRESSINDICATOR_H
diff --git a/ui/progresstask.h b/ui/progresstask.h
index 88cb7609..3cbfdc69 100644
--- a/ui/progresstask.h
+++ b/ui/progresstask.h
@@ -19,9 +19,9 @@
/*!
- Dialog displaying a progress bar and cancel button
+ Dialog displaying a progress bar and cancel button
*/
-class BINARYNINJAUIAPI ProgressDialog: public QDialog
+class BINARYNINJAUIAPI ProgressDialog : public QDialog
{
Q_OBJECT
@@ -34,8 +34,8 @@ class BINARYNINJAUIAPI ProgressDialog: public QDialog
std::atomic<bool> m_wasCancelled;
std::chrono::steady_clock::time_point m_lastUpdate;
-public:
- ProgressDialog(QWidget* parent, const QString& title, const QString& text, const QString& cancel=QString());
+ public:
+ ProgressDialog(QWidget* parent, const QString& title, const QString& text, const QString& cancel = QString());
bool wasCancelled() const;
@@ -45,46 +45,46 @@ public:
void setText(const QString& text);
-protected:
+ protected:
virtual void keyPressEvent(QKeyEvent* event) override;
-private Q_SLOTS:
+ private Q_SLOTS:
void cancelButton();
-public Q_SLOTS:
+ public Q_SLOTS:
void update(int cur, int total);
void cancel();
-Q_SIGNALS:
+ Q_SIGNALS:
void canceled();
};
/*!
- Wrapper around QThread and ProgressDialog that runs a task in the background,
- providing updates to the progress bar on the main thread.
+ Wrapper around QThread and ProgressDialog that runs a task in the background,
+ providing updates to the progress bar on the main thread.
- Warning: You should always construct one of these with new() as it will outlive the current
- scope and delete itself automatically.
+ Warning: You should always construct one of these with new() as it will outlive the current
+ scope and delete itself automatically.
- Started automatically. Call wait() to wait for completion, or cancel() to cancel.
+ Started automatically. Call wait() to wait for completion, or cancel() to cancel.
- Example:
+ Example:
- // Starts task
- ProgressTask* task = new ProgressTask("Long Operation", "Long Operation", "Cancel",
- [](std::function<bool(size_t, size_t)> progress) {
- doLongOperationWithProgress(progress);
+ // Starts task
+ ProgressTask* task = new ProgressTask("Long Operation", "Long Operation", "Cancel",
+ [](std::function<bool(size_t, size_t)> progress) {
+ doLongOperationWithProgress(progress);
- // Report progress by calling the progress function
- if (!progress(current, maximum))
- return; // If the progress function returns false, then the user has cancelled the operation
- });
- // Throws if doLongOperationWithProgress threw
- task->wait();
- // Task deletes itself later
+ // Report progress by calling the progress function
+ if (!progress(current, maximum))
+ return; // If the progress function returns false, then the user has cancelled the operation
+ });
+ // Throws if doLongOperationWithProgress threw
+ task->wait();
+ // Task deletes itself later
*/
-class BINARYNINJAUIAPI ProgressTask: public QObject
+class BINARYNINJAUIAPI ProgressTask : public QObject
{
Q_OBJECT
@@ -103,7 +103,7 @@ class BINARYNINJAUIAPI ProgressTask: public QObject
*/
void start();
-public:
+ public:
/*!
Construct a new progress task, which automatically starts running a given function
\param parent Parent QWidget to display progress dialog on top of
@@ -111,10 +111,11 @@ public:
\param text Text for progress dialog
\param cancel Cancel button title. If empty, the cancel button will not be shown
\param func Function to run in the background, which takes a progress reporting function for its argument.
- The function should call the progress function periodically to signal updates and check for cancellation.
+ The function should call the progress function periodically to signal updates and check for
+ cancellation.
*/
ProgressTask(QWidget* parent, const QString& name, const QString& text, const QString& cancel,
- std::function<void(std::function<bool(size_t, size_t)>)> func);
+ std::function<void(std::function<bool(size_t, size_t)>)> func);
virtual ~ProgressTask();
/*!
@@ -143,13 +144,13 @@ public:
*/
void setText(const QString& text);
-public Q_SLOTS:
+ public Q_SLOTS:
/*!
Cancel the progress dialog
*/
void cancel();
-Q_SIGNALS:
+ Q_SIGNALS:
/*!
Signal reported every time there is a progress update (probably often)
\param cur Current progress value
@@ -165,94 +166,95 @@ Q_SIGNALS:
/*!
- Helper for BackgroundThread, basically lets you take functions of various types and converts them into
- std::function<QVariant(QVariant)> so it has something easy to call.
+ Helper for BackgroundThread, basically lets you take functions of various types and converts them into
+ std::function<QVariant(QVariant)> so it has something easy to call.
- \param func Original function, can have 0 arguments, or 1 argument that can be used with QVariant,
- function can either return void or some type that works with QVariant
- \return New function whose signature is QVariant(QVariant)
+ \param func Original function, can have 0 arguments, or 1 argument that can be used with QVariant,
+ function can either return void or some type that works with QVariant
+ \return New function whose signature is QVariant(QVariant)
*/
-template<typename Func>
+template <typename Func>
std::function<QVariant(QVariant)> convertToQVariantFunction(Func&& func);
/*!
- Helper class for running chains of actions on both the main thread and a background thread.
- Especially useful for doing ui that also needs networking.
- Think of it like a JS-like promise chain except with more C++.
+ Helper class for running chains of actions on both the main thread and a background thread.
+ Especially useful for doing ui that also needs networking.
+ Think of it like a JS-like promise chain except with more C++.
- Example:
+ Example:
- BackgroundThread::create()
- // Do actions serially in the background
- ->thenBackground([this](QVariant) {
- bool success = SomeLongNetworkOperation();
- // Return value will be passed to next action's QVariant parameter
- return success;
- })
- // And serially on the main thread
- ->thenMainThread([this](QVariant var) {
- // Retrieve value from last action
- bool success = var.value<bool>();
- UpdateUI(success);
- // You don't have to return anything (next QVariant param will be QVariant())
- })
- // You can also combine with a ProgressTask for showing a progress dialog
- ->thenBackgroundWithProgress(m_window, "Doing Task", "Please wait...", "Cancel", [this](QVariant var, ProgressTask* task, ProgressFunction progress) {
- progress(0, 0);
- DoTask1WithProgress(SplitProgress(progress, 0, 1));
- // You can interface with the task itself
- task->setText("Doing Part 2");
- DoTask2WithProgress(SplitProgress(progress, 1, 1));
- progress(1, 1);
- })
- // You can combine with another BackgroundThread to do its actions after all of the
- // ones you have enqueued so far
- ->then(SomeOtherFunctionThatReturnsABackgroundThread())
- // If any then-action throws, all future then-actions will be ignored and the catch-actions will be run, serially
- // NB: If a catch-action throws, the new exception will be passed to any further catch-actions
- ->catchMainThread([this](std::exception_ptr exc) {
- // So far the only way I've found to get the exception out:
- try
- {
- std::rethrow_exception(exc);
- }
- catch (std::exception e)
- {
- // Handle exception
- }
- })
- // You can also catch in the background
- ->catchBackground([this](std::exception_ptr exc) {
- ...
- })
- // Finally-actions will be run after all then-actions are finished
- // If a then-action throws, finally-actions will be run after all catch-actions are finished
- // NB: Finally-actions should not throw exceptions
- ->finallyMainThread([this](bool success) {
- if (success)
- {
- ReportSuccess();
- }
- })
- // You can also have finally-actions in the background
- ->finallyBackground([this](bool success) {
- ...
- })
- // Call start to start the thread
- ->start();
+ BackgroundThread::create()
+ // Do actions serially in the background
+ ->thenBackground([this](QVariant) {
+ bool success = SomeLongNetworkOperation();
+ // Return value will be passed to next action's QVariant parameter
+ return success;
+ })
+ // And serially on the main thread
+ ->thenMainThread([this](QVariant var) {
+ // Retrieve value from last action
+ bool success = var.value<bool>();
+ UpdateUI(success);
+ // You don't have to return anything (next QVariant param will be QVariant())
+ })
+ // You can also combine with a ProgressTask for showing a progress dialog
+ ->thenBackgroundWithProgress(m_window, "Doing Task", "Please wait...", "Cancel", [this](QVariant var,
+ ProgressTask* task, ProgressFunction progress) { progress(0, 0); DoTask1WithProgress(SplitProgress(progress, 0, 1));
+ // You can interface with the task itself
+ task->setText("Doing Part 2");
+ DoTask2WithProgress(SplitProgress(progress, 1, 1));
+ progress(1, 1);
+ })
+ // You can combine with another BackgroundThread to do its actions after all of the
+ // ones you have enqueued so far
+ ->then(SomeOtherFunctionThatReturnsABackgroundThread())
+ // If any then-action throws, all future then-actions will be ignored and the catch-actions will be run,
+ serially
+ // NB: If a catch-action throws, the new exception will be passed to any further catch-actions
+ ->catchMainThread([this](std::exception_ptr exc) {
+ // So far the only way I've found to get the exception out:
+ try
+ {
+ std::rethrow_exception(exc);
+ }
+ catch (std::exception e)
+ {
+ // Handle exception
+ }
+ })
+ // You can also catch in the background
+ ->catchBackground([this](std::exception_ptr exc) {
+ ...
+ })
+ // Finally-actions will be run after all then-actions are finished
+ // If a then-action throws, finally-actions will be run after all catch-actions are finished
+ // NB: Finally-actions should not throw exceptions
+ ->finallyMainThread([this](bool success) {
+ if (success)
+ {
+ ReportSuccess();
+ }
+ })
+ // You can also have finally-actions in the background
+ ->finallyBackground([this](bool success) {
+ ...
+ })
+ // Call start to start the thread
+ ->start();
*/
-class BINARYNINJAUIAPI BackgroundThread: public QObject
+class BINARYNINJAUIAPI BackgroundThread : public QObject
{
Q_OBJECT
-public:
+
+ public:
typedef std::function<bool(size_t, size_t)> ProgressFunction;
typedef std::function<QVariant(QVariant value)> ThenFunction;
typedef std::function<void(std::exception_ptr exc)> CatchFunction;
typedef std::function<void(bool success) /* noexcept */> FinallyFunction;
-private:
+ private:
enum FunctionType
{
MainThread,
@@ -268,41 +270,33 @@ private:
std::vector<std::pair<FunctionType, CatchFunction>> m_catch;
std::vector<std::pair<FunctionType, FinallyFunction>> m_finally;
- BackgroundThread(): QObject(), m_finished(false), m_exception()
- {
- }
+ BackgroundThread() : QObject(), m_finished(false), m_exception() {}
void runThread()
{
QVariant value = m_init;
try
{
- for (auto& func: m_then)
+ for (auto& func : m_then)
{
switch (func.first)
{
case MainThread:
- BinaryNinja::ExecuteOnMainThreadAndWait([&]()
- {
- value = func.second(value);
- });
+ BinaryNinja::ExecuteOnMainThreadAndWait([&]() { value = func.second(value); });
break;
case Background:
value = func.second(value);
break;
}
}
- for (auto& func: m_finally)
+ for (auto& func : m_finally)
{
try
{
switch (func.first)
{
case MainThread:
- BinaryNinja::ExecuteOnMainThreadAndWait([&]()
- {
- func.second(true);
- });
+ BinaryNinja::ExecuteOnMainThreadAndWait([&]() { func.second(true); });
break;
case Background:
func.second(true);
@@ -325,17 +319,14 @@ private:
catch (...)
{
std::exception_ptr exc = std::current_exception();
- for (auto& func: m_catch)
+ for (auto& func : m_catch)
{
try
{
switch (func.first)
{
case MainThread:
- BinaryNinja::ExecuteOnMainThreadAndWait([&]()
- {
- func.second(exc);
- });
+ BinaryNinja::ExecuteOnMainThreadAndWait([&]() { func.second(exc); });
break;
case Background:
func.second(exc);
@@ -347,17 +338,14 @@ private:
exc = std::current_exception();
}
}
- for (auto& func: m_finally)
+ for (auto& func : m_finally)
{
try
{
switch (func.first)
{
case MainThread:
- BinaryNinja::ExecuteOnMainThreadAndWait([&]()
- {
- func.second(false);
- });
+ BinaryNinja::ExecuteOnMainThreadAndWait([&]() { func.second(false); });
break;
case Background:
func.second(false);
@@ -379,7 +367,7 @@ private:
}
}
-public:
+ public:
/*!
Create a new background thread (but don't start it)
\return Empty thread with no functions
@@ -406,7 +394,7 @@ public:
else
{
m_init = init;
- m_future = QtConcurrent::run([&]{
+ m_future = QtConcurrent::run([&] {
runThread();
{
std::unique_lock lock(m_finishLock);
@@ -433,9 +421,7 @@ public:
// If it's not finished, wait for it to finish
watcher.setFuture(m_future);
// Make this connection before events start processing
- connect(&watcher, &QFutureWatcher<void>::finished, [&loop]() {
- loop.exit(0);
- });
+ connect(&watcher, &QFutureWatcher<void>::finished, [&loop]() { loop.exit(0); });
}
loop.exec();
}
@@ -463,7 +449,7 @@ public:
\param func Function to run on background thread
\return This BackgroundThread
*/
- template<typename Func>
+ template <typename Func>
BackgroundThread* thenBackground(Func&& func)
{
m_then.push_back({Background, convertToQVariantFunction(std::forward<Func>(func))});
@@ -475,7 +461,7 @@ public:
\param func Function to run on main thread
\return This BackgroundThread
*/
- template<typename Func>
+ template <typename Func>
BackgroundThread* thenMainThread(Func&& func)
{
m_then.push_back({MainThread, convertToQVariantFunction(std::forward<Func>(func))});
@@ -491,55 +477,59 @@ public:
\param func Function to run on background thread
\return This BackgroundThread
*/
- template<typename Func>
- BackgroundThread* thenBackgroundWithProgress(QWidget* parent, const QString& title, const QString& text, const QString& cancel, Func&& func)
+ template <typename Func>
+ BackgroundThread* thenBackgroundWithProgress(
+ QWidget* parent, const QString& title, const QString& text, const QString& cancel, Func&& func)
{
- m_then.push_back({MainThread, [=](QVariant v) {
- QVariant result;
- // Since the task starts immediately, we need to hold a lock to its value
- // Just in case it manages to get to the part of the lambda where it reads the value
- // before this thread actually assigns it.
- // This is *probably* not a race in practice due to the variable being stored on the stack before construction.
- std::mutex taskMutex;
- taskMutex.lock();
- ProgressTask* task = new ProgressTask(parent, title, text, cancel, [&](ProgressFunction progress) {
- auto innerProgress = [=](size_t cur, size_t max) {
- // Fix dialog disappearing if the backgrounded task thinks it's done
- if (cur >= max)
- {
- cur = max - 1;
- }
- return progress(cur, max);
- };
- try
- {
- // See above comment about race conditions
- taskMutex.lock();
- ProgressTask* innerTask = task;
- taskMutex.unlock();
+ m_then.push_back(
+ {MainThread, [=](QVariant v) {
+ QVariant result;
+ // Since the task starts immediately, we need to hold a lock to its value
+ // Just in case it manages to get to the part of the lambda where it reads the value
+ // before this thread actually assigns it.
+ // This is *probably* not a race in practice due to the variable being stored on the stack before
+ // construction.
+ std::mutex taskMutex;
+ taskMutex.lock();
+ ProgressTask* task = new ProgressTask(parent, title, text, cancel, [&](ProgressFunction progress) {
+ auto innerProgress = [=](size_t cur, size_t max) {
+ // Fix dialog disappearing if the backgrounded task thinks it's done
+ if (cur >= max)
+ {
+ cur = max - 1;
+ }
+ return progress(cur, max);
+ };
+ try
+ {
+ // See above comment about race conditions
+ taskMutex.lock();
+ ProgressTask* innerTask = task;
+ taskMutex.unlock();
- if constexpr (std::is_void_v<std::invoke_result_t<Func, QVariant, ProgressTask*, ProgressFunction>>)
- {
- func(v, innerTask, innerProgress);
- }
- else
- {
- result = func(v, innerTask, innerProgress);
- }
- // And actually report success
- progress(1, 1);
- }
- catch (...)
- {
- progress(1, 1);
- std::rethrow_exception(std::current_exception());
- };
- });
- taskMutex.unlock();
- task->wait();
+ if constexpr (std::is_void_v<
+ std::invoke_result_t<Func, QVariant, ProgressTask*, ProgressFunction>>)
+ {
+ func(v, innerTask, innerProgress);
+ }
+ else
+ {
+ result = func(v, innerTask, innerProgress);
+ }
+ // And actually report success
+ progress(1, 1);
+ }
+ catch (...)
+ {
+ progress(1, 1);
+ std::rethrow_exception(std::current_exception());
+ };
+ });
+ taskMutex.unlock();
+ task->wait();
- return result;
- }});
+ return result;
+ }});
return this;
}
@@ -587,7 +577,7 @@ public:
return this;
}
-Q_SIGNALS:
+ Q_SIGNALS:
/*!
Called when all functions have been run
\param result Final result
@@ -604,20 +594,21 @@ Q_SIGNALS:
// Implementation details of convertToQVariantFunction
// Inspired by boost function_traits and various other similarly named patterns
-template<typename Function>
+template <typename Function>
struct function_traits;
-template<typename Function>
-struct function_traits: public function_traits<decltype(&Function::operator())> {};
-template<typename C, typename R, typename ... Args>
-struct function_traits<R(C::*)(Args...) const>
+template <typename Function>
+struct function_traits : public function_traits<decltype(&Function::operator())>
+{};
+template <typename C, typename R, typename... Args>
+struct function_traits<R (C::*)(Args...) const>
{
using result_type = R;
- template<size_t index>
+ template <size_t index>
using arg_type = typename std::tuple_element_t<index, std::tuple<Args...>>;
static const size_t arity = sizeof...(Args);
};
-template<typename Func>
+template <typename Func>
std::function<QVariant(QVariant)> convertToQVariantFunction(Func&& func)
{
return [func](QVariant v) {
diff --git a/ui/qfileaccessor.h b/ui/qfileaccessor.h
index 728f7605..1686eccc 100644
--- a/ui/qfileaccessor.h
+++ b/ui/qfileaccessor.h
@@ -9,7 +9,7 @@ class BINARYNINJAUIAPI QFileAccessor : public BinaryNinja::FileAccessor
QFile* m_file;
QString m_error;
-public:
+ public:
QFileAccessor(const QString& name, bool write = false);
virtual ~QFileAccessor();
diff --git a/ui/render.h b/ui/render.h
index a1b55092..92dc654f 100644
--- a/ui/render.h
+++ b/ui/render.h
@@ -44,7 +44,7 @@ class BINARYNINJAUIAPI FontParameters
float m_fontScale;
bool m_customFont;
-public:
+ public:
FontParameters(QWidget* parent, float fontScale = 1.0f);
void update();
@@ -64,7 +64,7 @@ class BINARYNINJAUIAPI RenderContext
FontParameters m_fontParams;
bool m_drawIndents;
-public:
+ public:
RenderContext(QWidget* parent, float fontScale = 1.0f);
void update();
@@ -74,12 +74,14 @@ public:
void init(QPainter& p);
- QColor getColorForHexDumpByte(const HexEditorHighlightState& state, BNModificationStatus modification, uint8_t byte);
+ QColor getColorForHexDumpByte(
+ const HexEditorHighlightState& state, BNModificationStatus modification, uint8_t byte);
QColor getHighlightColor(BNHighlightColor color);
- HighlightTokenState getTokenForDisassemblyLinePosition(int64_t col, const std::vector<BinaryNinja::InstructionTextToken>& tokens);
- HighlightTokenState getTokenForDisassemblyTokenIndex(size_t tokenIndex,
- const std::vector<BinaryNinja::InstructionTextToken>& tokens);
+ HighlightTokenState getTokenForDisassemblyLinePosition(
+ int64_t col, const std::vector<BinaryNinja::InstructionTextToken>& tokens);
+ HighlightTokenState getTokenForDisassemblyTokenIndex(
+ size_t tokenIndex, const std::vector<BinaryNinja::InstructionTextToken>& tokens);
HighlightTokenState getHighlightTokenForTextToken(const BinaryNinja::InstructionTextToken& token);
void drawText(QPainter& p, int x, int y, QColor color, const QString& text);
@@ -88,14 +90,15 @@ public:
void drawSeparatorLine(QPainter& p, QColor top, QColor bottom, QColor line, const QRect& rect);
void drawInstructionHighlight(QPainter& p, const QRect& rect);
- void drawLinearDisassemblyLineBackground(QPainter& p, BNLinearDisassemblyLineType type, const QRect& rect,
- int gutterWidth);
- void drawDisassemblyLine(QPainter& p, int left, int top, const std::vector<BinaryNinja::InstructionTextToken>& tokens,
- HighlightTokenState& highlight, bool highlightOnly=false);
+ void drawLinearDisassemblyLineBackground(
+ QPainter& p, BNLinearDisassemblyLineType type, const QRect& rect, int gutterWidth);
+ void drawDisassemblyLine(QPainter& p, int left, int top,
+ const std::vector<BinaryNinja::InstructionTextToken>& tokens, HighlightTokenState& highlight,
+ bool highlightOnly = false);
- void drawHexEditorLine(QPainter& p, int left, int top, const HexEditorHighlightState& highlight,
- BinaryViewRef view, uint64_t lineStartAddr, size_t cols, size_t firstCol, size_t count,
- bool cursorVisible, bool cursorAscii, size_t cursorPos, bool byteCursor);
+ void drawHexEditorLine(QPainter& p, int left, int top, const HexEditorHighlightState& highlight, BinaryViewRef view,
+ uint64_t lineStartAddr, size_t cols, size_t firstCol, size_t count, bool cursorVisible, bool cursorAscii,
+ size_t cursorPos, bool byteCursor);
QFont getFont() { return m_fontParams.getFont(); }
QFont getEmojiFont() { return m_fontParams.getEmojiFont(); }
void setFont(const QFont& font);
diff --git a/ui/reportcollectionwidget.h b/ui/reportcollectionwidget.h
index 13c2d659..42d56421 100644
--- a/ui/reportcollectionwidget.h
+++ b/ui/reportcollectionwidget.h
@@ -8,7 +8,7 @@
#include "viewframe.h"
#include "uicontext.h"
-class BINARYNINJAUIAPI ReportCollectionWidget: public QWidget, public ViewContainer
+class BINARYNINJAUIAPI ReportCollectionWidget : public QWidget, public ViewContainer
{
Q_OBJECT
@@ -22,13 +22,13 @@ class BINARYNINJAUIAPI ReportCollectionWidget: public QWidget, public ViewContai
int m_currentReportIndex;
std::string m_title;
-public:
+ public:
ReportCollectionWidget(QWidget* parent, ReportCollectionRef reports, const std::string& title);
virtual View* getView() override;
ReportCollectionWidget* duplicate();
-private Q_SLOTS:
+ private Q_SLOTS:
void selectReport(int i);
};
diff --git a/ui/reportwidget.h b/ui/reportwidget.h
index 51dd2d59..414fb412 100644
--- a/ui/reportwidget.h
+++ b/ui/reportwidget.h
@@ -4,13 +4,13 @@
#include <QtWidgets/QTextBrowser>
#include <QtWidgets/QScrollArea>
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
-#include <QtWebEngineWidgets/QWebEngineView>
-#include <QtWebEngineWidgets/QWebEngineScript>
-#include <QtWebEngineWidgets/QWebEngineScriptCollection>
-#include <QtWebEngineWidgets/QWebEnginePage>
-#include <QtWebEngineWidgets/QWebEngineSettings>
+ #include <QtWebEngineWidgets/QWebEngineView>
+ #include <QtWebEngineWidgets/QWebEngineScript>
+ #include <QtWebEngineWidgets/QWebEngineScriptCollection>
+ #include <QtWebEngineWidgets/QWebEnginePage>
+ #include <QtWebEngineWidgets/QWebEngineSettings>
#else
-#include <QtWidgets/QTextBrowser>
+ #include <QtWidgets/QTextBrowser>
#endif
#include "binaryninjaapi.h"
#include "action.h"
@@ -21,18 +21,18 @@ class WebPage2 : public QWebEnginePage
{
Q_OBJECT
-public:
- WebPage2(QObject *parent = nullptr) : QWebEnginePage(parent) {}
+ public:
+ WebPage2(QObject* parent = nullptr) : QWebEnginePage(parent) {}
-protected:
- virtual bool acceptNavigationRequest(const QUrl &url, QWebEnginePage::NavigationType type, bool isMainFrame);
+ protected:
+ virtual bool acceptNavigationRequest(const QUrl& url, QWebEnginePage::NavigationType type, bool isMainFrame);
-Q_SIGNALS:
+ Q_SIGNALS:
void linkClicked(const QUrl&);
};
#endif
-class BINARYNINJAUIAPI ReportWidget: public QScrollArea, public UIActionHandler
+class BINARYNINJAUIAPI ReportWidget : public QScrollArea, public UIActionHandler
{
Q_OBJECT
@@ -47,12 +47,12 @@ class BINARYNINJAUIAPI ReportWidget: public QScrollArea, public UIActionHandler
BNReportType m_type;
std::string m_plaintext;
-private Q_SLOTS:
+ private Q_SLOTS:
void onLinkClicked(QUrl url);
-public:
- ReportWidget(QWidget* parent, BinaryViewRef view, const std::string& contents,
- BNReportType type, const std::string& title, const std::string& plaintext = "");
+ public:
+ ReportWidget(QWidget* parent, BinaryViewRef view, const std::string& contents, BNReportType type,
+ const std::string& title, const std::string& plaintext = "");
std::string getContents() const { return m_original; }
std::string getTitle() const { return m_title; }
BNReportType getType() const { return m_type; }
diff --git a/ui/scriptingconsole.h b/ui/scriptingconsole.h
index 3726514b..b0aa3600 100644
--- a/ui/scriptingconsole.h
+++ b/ui/scriptingconsole.h
@@ -24,13 +24,13 @@
class ScriptingConsole;
-class BINARYNINJAUIAPI ScriptingCompletionModel: public QAbstractListModel
+class BINARYNINJAUIAPI ScriptingCompletionModel : public QAbstractListModel
{
Q_OBJECT
std::vector<std::string> m_completions;
bool m_searching;
-public:
+ public:
ScriptingCompletionModel(QWidget* parent);
virtual QModelIndex index(int row, int col, const QModelIndex& parent = QModelIndex()) const override;
@@ -42,36 +42,37 @@ public:
void setModelData(const std::vector<std::string>& completions, bool searching);
};
-class BINARYNINJAUIAPI ScriptingCompletionPopup: public QDialog
+class BINARYNINJAUIAPI ScriptingCompletionPopup : public QDialog
{
Q_OBJECT
QListView* m_list;
ScriptingCompletionModel* m_model;
-protected:
+ protected:
virtual bool eventFilter(QObject* obj, QEvent* event) override;
-public:
+ public:
ScriptingCompletionPopup(QWidget* parent);
void showWithData(QPoint pt, int cursorSize, const std::vector<std::string>& completions, bool searching = false);
bool handleKeyEvent(QKeyEvent* event);
virtual ~ScriptingCompletionPopup();
-private Q_SLOTS:
+ private Q_SLOTS:
void clickRow(const QModelIndex& index);
-Q_SIGNALS:
+ Q_SIGNALS:
void complete(QString text);
};
-class BINARYNINJAUIAPI ScriptingConsoleEdit: public QTextEdit
+class BINARYNINJAUIAPI ScriptingConsoleEdit : public QTextEdit
{
Q_OBJECT
-public:
+
+ public:
typedef std::function<std::vector<std::string>(const std::string&)> CompletionCallback;
-private:
+ private:
ScriptingConsole* m_console;
int m_charHeight;
bool m_continuation;
@@ -84,22 +85,22 @@ private:
uint64_t m_completionRegionInitialStop;
uint64_t m_completionRegionStop;
-public:
+ public:
ScriptingConsoleEdit(ScriptingConsole* parent);
void setCharHeight(int height);
void setContinuation(bool cont);
void setCompletionCallback(CompletionCallback callback) { m_completionCallback = callback; }
- void insertFromMimeData(const QMimeData * source) override;
+ void insertFromMimeData(const QMimeData* source) override;
-private Q_SLOTS:
+ private Q_SLOTS:
void complete(QString text);
-protected:
+ protected:
virtual void keyPressEvent(QKeyEvent* event) override;
};
-class BINARYNINJAUIAPI ScriptingConsoleOutput: public QTextEdit
+class BINARYNINJAUIAPI ScriptingConsoleOutput : public QTextEdit
{
Q_OBJECT
@@ -110,20 +111,21 @@ class BINARYNINJAUIAPI ScriptingConsoleOutput: public QTextEdit
BinaryViewRef m_data;
Menu* m_menu;
-public:
+ public:
ScriptingConsoleOutput(ScriptingConsole* parent, Menu* menu);
bool IsNavigable(const QString& str, const std::pair<int, int>& offsetLen, uint64_t& value, bool highlight) const;
-protected:
+
+ protected:
void contextMenuEvent(QContextMenuEvent* event) override;
-public Q_SLOTS:
+ public Q_SLOTS:
virtual void mouseReleaseEvent(QMouseEvent* event) override;
void viewChanged(QWidget* frame);
};
class ScriptingConsoleWidget;
-class BINARYNINJAUIAPI ScriptingConsole: public GlobalAreaWidget, BinaryNinja::ScriptingOutputListener
+class BINARYNINJAUIAPI ScriptingConsole : public GlobalAreaWidget, BinaryNinja::ScriptingOutputListener
{
Q_OBJECT
@@ -154,20 +156,21 @@ class BINARYNINJAUIAPI ScriptingConsole: public GlobalAreaWidget, BinaryNinja::S
static int m_stateUpdatedEventType;
-private Q_SLOTS:
+ private Q_SLOTS:
void updateTimerEvent();
void consoleTextChanged();
void cancel();
void showCancelButton();
-Q_SIGNALS:
+ Q_SIGNALS:
void viewChanged(QWidget* frame);
-protected:
+ protected:
void customEvent(QEvent* event) override;
-public:
- ScriptingConsole(QWidget* parent, const QString& providerName, const QString& instanceName, ScriptingInstanceRef instance);
+ public:
+ ScriptingConsole(
+ QWidget* parent, const QString& providerName, const QString& instanceName, ScriptingInstanceRef instance);
virtual ~ScriptingConsole();
QString getProviderName() const { return m_providerName; }
diff --git a/ui/searchresult.h b/ui/searchresult.h
index fe2d075e..3b648367 100644
--- a/ui/searchresult.h
+++ b/ui/searchresult.h
@@ -9,258 +9,265 @@
#include <QtWidgets/QTabWidget>
#include <QtWidgets/QStyledItemDelegate>
#include <QtWidgets/QDialog>
-#include <QtWidgets/QProgressBar>
-#include <QtWidgets/QToolButton>
+#include <QtWidgets/QProgressBar>
+#include <QtWidgets/QToolButton>
#include "binaryninjaapi.h"
#include "dockhandler.h"
#include "filter.h"
#include "expandablegroup.h"
#define FIND_RESULT_LIST_UPDATE_INTERVAL 250
-#define COLUMN_MIN_WIDTH_IN_CHAR 10
-#define COLUMN_MAX_WIDTH_IN_CHAR 30
+#define COLUMN_MIN_WIDTH_IN_CHAR 10
+#define COLUMN_MAX_WIDTH_IN_CHAR 30
class CachedTokens
{
-public:
- QVariant tokens;
- QVariant flattenedTokens;
- bool valid;
+ public:
+ QVariant tokens;
+ QVariant flattenedTokens;
+ bool valid;
- CachedTokens(): valid(false) {}
- CachedTokens(const CachedTokens& other):
- tokens(other.tokens), flattenedTokens(other.flattenedTokens), valid(other.valid)
- {}
+ CachedTokens() : valid(false) {}
+ CachedTokens(const CachedTokens& other) :
+ tokens(other.tokens), flattenedTokens(other.flattenedTokens), valid(other.valid)
+ {}
};
class SearchResultItem
{
-private:
- uint64_t m_addr;
- BinaryNinja::DataBuffer m_buffer;
- FunctionRef m_func;
- CachedTokens m_tokensCache[4];
+ private:
+ uint64_t m_addr;
+ BinaryNinja::DataBuffer m_buffer;
+ FunctionRef m_func;
+ CachedTokens m_tokensCache[4];
-public:
- SearchResultItem();
- SearchResultItem(uint64_t addr, const BinaryNinja::DataBuffer& buffer,
- FunctionRef func);
- SearchResultItem(uint64_t addr, const BinaryNinja::DataBuffer& buffer,
- FunctionRef func, const BinaryNinja::DisassemblyTextLine& line, QWidget* owner);
- SearchResultItem(const SearchResultItem& other);
- uint64_t addr() const { return m_addr; }
- BinaryNinja::DataBuffer buffer() const { return m_buffer; }
- FunctionRef func() const { return m_func; }
- bool operator==(const SearchResultItem& other) const { return m_addr == other.addr(); }
- bool operator!=(const SearchResultItem& other) const { return m_addr != other.addr(); }
- bool operator<(const SearchResultItem& other) const { return m_addr < other.addr(); }
+ public:
+ SearchResultItem();
+ SearchResultItem(uint64_t addr, const BinaryNinja::DataBuffer& buffer, FunctionRef func);
+ SearchResultItem(uint64_t addr, const BinaryNinja::DataBuffer& buffer, FunctionRef func,
+ const BinaryNinja::DisassemblyTextLine& line, QWidget* owner);
+ SearchResultItem(const SearchResultItem& other);
+ uint64_t addr() const { return m_addr; }
+ BinaryNinja::DataBuffer buffer() const { return m_buffer; }
+ FunctionRef func() const { return m_func; }
+ bool operator==(const SearchResultItem& other) const { return m_addr == other.addr(); }
+ bool operator!=(const SearchResultItem& other) const { return m_addr != other.addr(); }
+ bool operator<(const SearchResultItem& other) const { return m_addr < other.addr(); }
- CachedTokens getCachedTokens(size_t i) const;
- CachedTokens& getCachedTokens(size_t i);
- void setCachedTokens(size_t i, QVariant tokens, QVariant flattenedTokens);
+ CachedTokens getCachedTokens(size_t i) const;
+ CachedTokens& getCachedTokens(size_t i);
+ void setCachedTokens(size_t i, QVariant tokens, QVariant flattenedTokens);
};
Q_DECLARE_METATYPE(SearchResultItem);
-class BINARYNINJAUIAPI SearchResultModel: public QAbstractTableModel
+class BINARYNINJAUIAPI SearchResultModel : public QAbstractTableModel
{
- Q_OBJECT
+ Q_OBJECT
-protected:
- QWidget* m_owner;
- BinaryViewRef m_data;
- BinaryNinja::FindParameters m_params;
- std::vector<SearchResultItem> m_refs;
- mutable size_t m_columnWidths[4];
- // if this value is true, it means the user has overriden the automatically calculated width
- // of the coumn, and we should not resize it anymore
- bool m_userColumnWidth[4];
+ protected:
+ QWidget* m_owner;
+ BinaryViewRef m_data;
+ BinaryNinja::FindParameters m_params;
+ std::vector<SearchResultItem> m_refs;
+ mutable size_t m_columnWidths[4];
+ // if this value is true, it means the user has overriden the automatically calculated width
+ // of the coumn, and we should not resize it anymore
+ bool m_userColumnWidth[4];
- std::mutex m_updateMutex;
- std::set<SearchResultItem> m_pendingSearchResults;
+ std::mutex m_updateMutex;
+ std::set<SearchResultItem> m_pendingSearchResults;
-public:
- enum ColumnHeaders
- {
- AddressColumn = 0,
- DataColumn = 1,
- FunctionColumn = 2,
- PreviewColumn = 3,
- EndOfColumn = 4
- };
+ public:
+ enum ColumnHeaders
+ {
+ AddressColumn = 0,
+ DataColumn = 1,
+ FunctionColumn = 2,
+ PreviewColumn = 3,
+ EndOfColumn = 4
+ };
- SearchResultModel(QWidget* parent, BinaryViewRef data);
- virtual ~SearchResultModel();
+ SearchResultModel(QWidget* parent, BinaryViewRef data);
+ virtual ~SearchResultModel();
- virtual QModelIndex index(int row, int col, const QModelIndex& parent = QModelIndex()) const override;
+ virtual QModelIndex index(int row, int col, const QModelIndex& parent = QModelIndex()) const override;
- void reset();
- virtual int rowCount(const QModelIndex& parent = QModelIndex()) const override { (void) parent; return (int)m_refs.size(); }
- virtual int columnCount(const QModelIndex& parent = QModelIndex()) const override { (void) parent; return 4; }
- SearchResultItem getRow(int row) const;
- virtual QVariant data(const QModelIndex& i, int role) const override;
- virtual QVariant headerData(int column, Qt::Orientation orientation, int role) const override;
- void addItem(const SearchResultItem& addr);
- void clear();
- void updateFindParameters(const BinaryNinja::FindParameters params);
- void updateSearchResults();
+ void reset();
+ virtual int rowCount(const QModelIndex& parent = QModelIndex()) const override
+ {
+ (void)parent;
+ return (int)m_refs.size();
+ }
+ virtual int columnCount(const QModelIndex& parent = QModelIndex()) const override
+ {
+ (void)parent;
+ return 4;
+ }
+ SearchResultItem getRow(int row) const;
+ virtual QVariant data(const QModelIndex& i, int role) const override;
+ virtual QVariant headerData(int column, Qt::Orientation orientation, int role) const override;
+ void addItem(const SearchResultItem& addr);
+ void clear();
+ void updateFindParameters(const BinaryNinja::FindParameters params);
+ void updateSearchResults();
- size_t getColumnWidth(size_t column) const;
- // This function is marked as const, but it actually modifies the mutable member m_columnWidths.
- // It is called in SearchResultModel::data(), which is const. So it has to be const as well.
- void updateColumnWidth(size_t column, size_t size) const;
- void resetColumnWidth();
+ size_t getColumnWidth(size_t column) const;
+ // This function is marked as const, but it actually modifies the mutable member m_columnWidths.
+ // It is called in SearchResultModel::data(), which is const. So it has to be const as well.
+ void updateColumnWidth(size_t column, size_t size) const;
+ void resetColumnWidth();
- bool isUserColumnWidth(size_t column) const;
- void setUserColumnWidth(size_t column);
+ bool isUserColumnWidth(size_t column) const;
+ void setUserColumnWidth(size_t column);
};
-class BINARYNINJAUIAPI SearchResultFilterProxyModel: public QSortFilterProxyModel
+class BINARYNINJAUIAPI SearchResultFilterProxyModel : public QSortFilterProxyModel
{
- Q_OBJECT
+ Q_OBJECT
-public:
- SearchResultFilterProxyModel(QObject* parent);
- virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
- virtual bool lessThan(const QModelIndex& left, const QModelIndex& right) const override;
- virtual QVariant data(const QModelIndex& idx, int role) const override;
+ public:
+ SearchResultFilterProxyModel(QObject* parent);
+ virtual bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override;
+ virtual bool lessThan(const QModelIndex& left, const QModelIndex& right) const override;
+ virtual QVariant data(const QModelIndex& idx, int role) const override;
};
-class BINARYNINJAUIAPI SearchResultItemDelegate: public QStyledItemDelegate
+class BINARYNINJAUIAPI SearchResultItemDelegate : public QStyledItemDelegate
{
- Q_OBJECT
+ Q_OBJECT
- QFont m_font;
- int m_baseline, m_charWidth, m_charHeight, m_charOffset;
+ QFont m_font;
+ int m_baseline, m_charWidth, m_charHeight, m_charOffset;
-public:
- SearchResultItemDelegate(QWidget* parent);
- void updateFonts();
- void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& idx) const;
+ public:
+ SearchResultItemDelegate(QWidget* parent);
+ void updateFonts();
+ void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& idx) const;
};
class SearchResultWidget;
-class BINARYNINJAUIAPI SearchResultTable: public QTableView
+class BINARYNINJAUIAPI SearchResultTable : public QTableView
{
- Q_OBJECT
+ Q_OBJECT
- SearchResultModel* m_table;
- SearchResultFilterProxyModel* m_model;
- SearchResultItemDelegate* m_itemDelegate;
- BinaryViewRef m_data;
- BinaryNinja::FindParameters m_params;
- UIActionHandler m_actionHandler;
- QTimer* m_updateTimer;
+ SearchResultModel* m_table;
+ SearchResultFilterProxyModel* m_model;
+ SearchResultItemDelegate* m_itemDelegate;
+ BinaryViewRef m_data;
+ BinaryNinja::FindParameters m_params;
+ UIActionHandler m_actionHandler;
+ QTimer* m_updateTimer;
- int m_charWidth, m_charHeight;
+ int m_charWidth, m_charHeight;
- bool m_cacheThreadShouldExit;
+ bool m_cacheThreadShouldExit;
-public:
- SearchResultTable(SearchResultWidget* parent, BinaryViewRef data);
- virtual ~SearchResultTable();
+ public:
+ SearchResultTable(SearchResultWidget* parent, BinaryViewRef data);
+ virtual ~SearchResultTable();
- void addSearchResult(const SearchResultItem& addr);
- void updateFindParameters(const BinaryNinja::FindParameters& params);
- void clearSearchResult();
+ void addSearchResult(const SearchResultItem& addr);
+ void updateFindParameters(const BinaryNinja::FindParameters& params);
+ void clearSearchResult();
- void updateFonts();
- void updateHeaderFontAndSize();
+ void updateFonts();
+ void updateHeaderFontAndSize();
- virtual void keyPressEvent(QKeyEvent* e) override;
+ virtual void keyPressEvent(QKeyEvent* e) override;
- virtual bool hasSelection() const { return selectionModel()->selectedRows().size() != 0; }
+ virtual bool hasSelection() const { return selectionModel()->selectedRows().size() != 0; }
virtual QModelIndexList selectedRows() const { return selectionModel()->selectedRows(); }
- void goToResult(const QModelIndex& idx);
+ void goToResult(const QModelIndex& idx);
- int rowCount() const;
- int filteredCount() const;
+ int rowCount() const;
+ int filteredCount() const;
- void updateColumnWidth();
- void resetColumnWidth();
+ void updateColumnWidth();
+ void resetColumnWidth();
- void cacheTokens();
- void terminateCacheThread() { m_cacheThreadShouldExit = true; }
+ void cacheTokens();
+ void terminateCacheThread() { m_cacheThreadShouldExit = true; }
- SearchResultModel* model() const { return m_table; }
+ SearchResultModel* model() const { return m_table; }
-public Q_SLOTS:
- void resultActivated(const QModelIndex& idx);
- void updateFilter(const QString& filterText);
- void updateTimerEvent();
- void columnResized(int logicalIndex, int oldSize, int newSize);
+ public Q_SLOTS:
+ void resultActivated(const QModelIndex& idx);
+ void updateFilter(const QString& filterText);
+ void updateTimerEvent();
+ void columnResized(int logicalIndex, int oldSize, int newSize);
-Q_SIGNALS:
- void newSelection();
+ Q_SIGNALS:
+ void newSelection();
};
class SearchProgressBar;
-class BINARYNINJAUIAPI SearchResultWidget: public QWidget
+class BINARYNINJAUIAPI SearchResultWidget : public QWidget
{
- Q_OBJECT
+ Q_OBJECT
UIActionHandler m_actionHandler;
ContextMenuManager* m_contextMenuManager = nullptr;
Menu* m_menu = nullptr;
- BinaryViewRef m_data;
- SearchResultTable* m_table;
- QLabel* m_label;
- QLineEdit* m_lineEdit;
- ExpandableGroup* m_group;
- SearchProgressBar* m_progress;
- BinaryNinja::FindParameters m_params;
- QThread* m_tokenCacheThread = nullptr;
+ BinaryViewRef m_data;
+ SearchResultTable* m_table;
+ QLabel* m_label;
+ QLineEdit* m_lineEdit;
+ ExpandableGroup* m_group;
+ SearchProgressBar* m_progress;
+ BinaryNinja::FindParameters m_params;
+ QThread* m_tokenCacheThread = nullptr;
- virtual void contextMenuEvent(QContextMenuEvent* event) override;
+ virtual void contextMenuEvent(QContextMenuEvent* event) override;
-public:
- SearchResultWidget(BinaryViewRef data);
- ~SearchResultWidget();
+ public:
+ SearchResultWidget(BinaryViewRef data);
+ ~SearchResultWidget();
- void notifyFontChanged();
+ void notifyFontChanged();
- void startNewFind(const BinaryNinja::FindParameters& params);
- virtual QString getHeaderText();
+ void startNewFind(const BinaryNinja::FindParameters& params);
+ virtual QString getHeaderText();
- void addSearchResult(uint64_t addr, const BinaryNinja::DataBuffer& match);
- void addSearchResult(uint64_t addr, const BinaryNinja::DataBuffer& match,
- const BinaryNinja::LinearDisassemblyLine& line);
- void clearSearchResult();
- bool updateProgress(uint64_t cur, uint64_t total);
- void notifySearchCompleted();
- void cacheTokens();
- void terminateCacheThread();
- bool isSearchActive() const;
+ void addSearchResult(uint64_t addr, const BinaryNinja::DataBuffer& match);
+ void addSearchResult(
+ uint64_t addr, const BinaryNinja::DataBuffer& match, const BinaryNinja::LinearDisassemblyLine& line);
+ void clearSearchResult();
+ bool updateProgress(uint64_t cur, uint64_t total);
+ void notifySearchCompleted();
+ void cacheTokens();
+ void terminateCacheThread();
+ bool isSearchActive() const;
-public Q_SLOTS:
- void updateTotal();
+ public Q_SLOTS:
+ void updateTotal();
};
-class BINARYNINJAUIAPI SearchProgressBar: public QWidget
+class BINARYNINJAUIAPI SearchProgressBar : public QWidget
{
- Q_OBJECT
+ Q_OBJECT
-private:
- QProgressBar* m_progress;
- QToolButton* m_cancel;
- bool m_maxSet;
- bool m_running;
- // The minimal duration (in milliseconds) the progress bar must last, before it is displayed
- int m_minimalDuration;
- std::chrono::steady_clock::time_point m_lastUpdate;
+ private:
+ QProgressBar* m_progress;
+ QToolButton* m_cancel;
+ bool m_maxSet;
+ bool m_running;
+ // The minimal duration (in milliseconds) the progress bar must last, before it is displayed
+ int m_minimalDuration;
+ std::chrono::steady_clock::time_point m_lastUpdate;
-public:
- explicit SearchProgressBar(QWidget* parent = nullptr);
- bool updateProgress(uint64_t cur, uint64_t total);
- void init();
- void reset();
- void show();
- bool isRunning() const { return m_running; }
+ public:
+ explicit SearchProgressBar(QWidget* parent = nullptr);
+ bool updateProgress(uint64_t cur, uint64_t total);
+ void init();
+ void reset();
+ void show();
+ bool isRunning() const { return m_running; }
};
diff --git a/ui/settingsview.h b/ui/settingsview.h
index 6a11ee17..b2534436 100644
--- a/ui/settingsview.h
+++ b/ui/settingsview.h
@@ -32,7 +32,9 @@
struct SettingsEntry
{
- SettingsEntry(int p, const QString& h, const QString& g, std::vector<void*>&& j) : parent(p), heading(h), group(g), jsonDefs(j) { }
+ SettingsEntry(int p, const QString& h, const QString& g, std::vector<void*>&& j) :
+ parent(p), heading(h), group(g), jsonDefs(j)
+ {}
int parent;
QString heading;
QString group;
@@ -41,16 +43,16 @@ struct SettingsEntry
};
-class BINARYNINJAUIAPI SettingsTreeModel: public QAbstractItemModel
+class BINARYNINJAUIAPI SettingsTreeModel : public QAbstractItemModel
{
Q_OBJECT
-private:
+ private:
Json::Value m_schema;
std::vector<SettingsEntry> m_store;
std::map<std::string, QString> m_filterText;
-public:
+ public:
SettingsTreeModel(std::string schema, QObject* parent = 0);
~SettingsTreeModel();
@@ -70,7 +72,7 @@ public:
};
-class BINARYNINJAUIAPI SettingsFilterProxyModel: public QSortFilterProxyModel
+class BINARYNINJAUIAPI SettingsFilterProxyModel : public QSortFilterProxyModel
{
Q_OBJECT
@@ -79,40 +81,45 @@ class BINARYNINJAUIAPI SettingsFilterProxyModel: public QSortFilterProxyModel
mutable QRegularExpression m_regExp;
mutable std::map<QString, std::set<QString>> m_subgroupFilterCache;
-public:
+ public:
SettingsFilterProxyModel(QObject* parent = 0);
int scopeFilter() { return m_scopeFilter; }
- void setScopeFilter(int scope) { m_scopeFilter = scope; invalidateFilter(); m_subgroupFilterCache.clear(); }
+ void setScopeFilter(int scope)
+ {
+ m_scopeFilter = scope;
+ invalidateFilter();
+ m_subgroupFilterCache.clear();
+ }
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
-protected:
+ protected:
bool filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const override;
bool lessThan(const QModelIndex& left, const QModelIndex& right) const override;
-public Q_SLOTS:
+ public Q_SLOTS:
void updateScope(const std::string& key, int scope) { m_itemScope[key] = scope; }
};
-class BINARYNINJAUIAPI SettingsOutlineProxyModel: public QSortFilterProxyModel
+class BINARYNINJAUIAPI SettingsOutlineProxyModel : public QSortFilterProxyModel
{
Q_OBJECT
-public:
+ public:
SettingsOutlineProxyModel(QObject* parent = 0);
-protected:
+ protected:
bool filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const override;
};
-class BINARYNINJAUIAPI SettingsEditor: public QWidget
+class BINARYNINJAUIAPI SettingsEditor : public QWidget
{
Q_OBJECT
-private:
+ private:
SettingsRef m_settings;
Json::Value m_setting;
std::string m_settingKey;
@@ -141,14 +148,15 @@ private:
bool m_requiresRestart = false;
bool m_settingModified = false;
-public:
- SettingsEditor(QWidget* parent, SettingsRef settings, BinaryViewRef view, BNSettingsScope scope, const Json::Value* setting);
+ public:
+ SettingsEditor(
+ QWidget* parent, SettingsRef settings, BinaryViewRef view, BNSettingsScope scope, const Json::Value* setting);
~SettingsEditor();
QSize sizeHint() const override;
void setSetting(const Json::Value* value, bool updateSchema = false);
-Q_SIGNALS:
+ Q_SIGNALS:
void geometryChanged();
void settingChanged();
void allSettingsChanged();
@@ -157,10 +165,10 @@ Q_SIGNALS:
void notifySettingChanged(QString);
void notifyNeedsRestart();
-private:
- void notifySettingUpdate(); // TODO core notification callbacks
+ private:
+ void notifySettingUpdate(); // TODO core notification callbacks
-private Q_SLOTS:
+ private Q_SLOTS:
void toggleBoolSetting();
void updateBoolSetting(bool enabled);
void updateEnumStringSetting(const QString& text);
@@ -179,26 +187,26 @@ private Q_SLOTS:
void selectInterpreter();
void selectVirtualEnv();
-public Q_SLOTS:
+ public Q_SLOTS:
void updateScope(BinaryViewRef, BNSettingsScope);
void updateSize();
void updateViewMode(bool enabled);
-private:
+ private:
void contextMenu();
-protected:
+ protected:
bool eventFilter(QObject* obj, QEvent* event) override;
void mousePressEvent(QMouseEvent* event) override;
- void paintEvent(QPaintEvent *event) override;
+ void paintEvent(QPaintEvent* event) override;
};
-class BINARYNINJAUIAPI SettingsDelegate: public QStyledItemDelegate
+class BINARYNINJAUIAPI SettingsDelegate : public QStyledItemDelegate
{
Q_OBJECT
-private:
+ private:
SettingsRef m_settings;
SettingsFilterProxyModel* m_filterModel;
BinaryViewRef m_view = nullptr;
@@ -213,8 +221,9 @@ private:
std::function<void(const QModelIndex& index)> m_hoverAction = nullptr;
std::function<void()> m_defaultSelectionAction = nullptr;
-public:
- SettingsDelegate(QWidget* parent, SettingsRef settings, SettingsFilterProxyModel* filterModel, const std::function<void(const QModelIndex& index)>& hoverAction = nullptr);
+ public:
+ SettingsDelegate(QWidget* parent, SettingsRef settings, SettingsFilterProxyModel* filterModel,
+ const std::function<void(const QModelIndex& index)>& hoverAction = nullptr);
~SettingsDelegate();
void setDefaultSelection(const std::function<void()>& selectionAction);
@@ -226,13 +235,14 @@ public:
QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
void setEditorData(QWidget* editor, const QModelIndex& index) const override;
void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const override;
- void updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
+ void updateEditorGeometry(
+ QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
-protected:
+ protected:
bool eventFilter(QObject* object, QEvent* event) override;
-public:
-Q_SIGNALS:
+ public:
+ Q_SIGNALS:
void refreshAllSettings() const;
void scopeChanged(BinaryViewRef, BNSettingsScope);
void sizeChanged();
@@ -240,37 +250,37 @@ Q_SIGNALS:
void notifyNeedsRestart() const;
void notifySettingChanged(QString settingId) const;
-public Q_SLOTS:
+ public Q_SLOTS:
void updateFonts();
void updateModel();
void updateScope(BinaryViewRef, BNSettingsScope);
void updateSize();
void updateViewMode(bool enabled) const;
-private Q_SLOTS:
+ private Q_SLOTS:
void commitEditorData();
void editorGeometryChanged();
};
-class BINARYNINJAUIAPI SettingsTreeView: public QTreeView
+class BINARYNINJAUIAPI SettingsTreeView : public QTreeView
{
Q_OBJECT
-public:
+ public:
explicit SettingsTreeView(QWidget* parent);
~SettingsTreeView();
-protected:
+ protected:
virtual void resizeEvent(QResizeEvent* event) override;
-public Q_SLOTS:
+ public Q_SLOTS:
void modelChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight);
};
-class BINARYNINJAUIAPI BinaryViewScopeLabel: public MenuHelper
+class BINARYNINJAUIAPI BinaryViewScopeLabel : public MenuHelper
{
Q_OBJECT
@@ -283,23 +293,23 @@ class BINARYNINJAUIAPI BinaryViewScopeLabel: public MenuHelper
UIActionHandler m_actionHandler;
-public:
+ public:
BinaryViewScopeLabel(QWidget* parent, const QString& name = "", BNSettingsScope scope = SettingsAutoScope);
void refresh();
const QString& currentSelection() { return m_curName; }
BinaryViewRef currentBinaryView() { return m_curView; }
-Q_SIGNALS:
+ Q_SIGNALS:
void itemSelected(BinaryViewRef, BNSettingsScope);
-protected:
+ protected:
virtual void showEvent(QShowEvent* event) override;
virtual void showMenu() override;
};
-class BINARYNINJAUIAPI SettingsScopeBar: public QWidget
+class BINARYNINJAUIAPI SettingsScopeBar : public QWidget
{
Q_OBJECT
@@ -311,17 +321,17 @@ class BINARYNINJAUIAPI SettingsScopeBar: public QWidget
void setScopeHighlight(unsigned long highlightIdx);
-public:
+ public:
SettingsScopeBar(QWidget* parent = nullptr);
void refresh();
-Q_SIGNALS:
+ Q_SIGNALS:
void scopeChanged(BinaryViewRef, BNSettingsScope);
};
-class BINARYNINJAUIAPI SearchFilter: public QLineEdit
+class BINARYNINJAUIAPI SearchFilter : public QLineEdit
{
Q_OBJECT
@@ -330,7 +340,7 @@ class BINARYNINJAUIAPI SearchFilter: public QLineEdit
QTimer* m_filterDelayTimer = nullptr;
int m_delay;
-public:
+ public:
SearchFilter(QWidget* parent = nullptr);
void addTag(const QString& tagName, int tag);
@@ -339,19 +349,19 @@ public:
std::pair<QString, std::vector<int>> getSearchParams();
-protected:
+ protected:
void keyPressEvent(QKeyEvent* event) override;
-Q_SIGNALS:
+ Q_SIGNALS:
void delayedTextChanged();
};
-class BINARYNINJAUIAPI SettingsView: public QWidget
+class BINARYNINJAUIAPI SettingsView : public QWidget
{
Q_OBJECT
-private:
+ private:
QWidget* m_owner = nullptr;
SettingsRef m_settings;
SettingsFilterProxyModel* m_proxyModel = nullptr;
@@ -364,7 +374,7 @@ private:
SearchFilter* m_search = nullptr;
bool m_outlineNavEnabled = true;
-public:
+ public:
SettingsView(QWidget* parent);
SettingsView(QWidget* parent, SettingsRef settings);
~SettingsView();
@@ -374,16 +384,16 @@ public:
void setData(BinaryViewRef view, const QString& name = "");
void setDefaultGroupSelection(const QString& group);
-public Q_SLOTS:
+ public Q_SLOTS:
void updateFonts();
void updateTheme();
-private Q_SLOTS:
+ private Q_SLOTS:
void outlineSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
void updateScopeFilter();
void updateTextFilter();
-Q_SIGNALS:
+ Q_SIGNALS:
void fontsChanged();
void notifyNeedsRestart();
void notifySettingChanged(QString settingId) const;
diff --git a/ui/sidebar.h b/ui/sidebar.h
index 52ea38de..ef0b0c0b 100644
--- a/ui/sidebar.h
+++ b/ui/sidebar.h
@@ -22,38 +22,39 @@ struct SidebarIcon
static SidebarIcon generate(const QImage& src);
};
-class BINARYNINJAUIAPI SidebarWidget: public QWidget
+class BINARYNINJAUIAPI SidebarWidget : public QWidget
{
Q_OBJECT
-protected:
+ protected:
QString m_title;
UIActionHandler m_actionHandler;
ContextMenuManager* m_contextMenuManager = nullptr;
Menu* m_menu = nullptr;
-public:
+ public:
SidebarWidget(const QString& title);
const QString& title() const { return m_title; }
- virtual void notifyFontChanged() { }
- virtual void notifyOffsetChanged(uint64_t /*offset*/) { }
+ virtual void notifyFontChanged() {}
+ virtual void notifyOffsetChanged(uint64_t /*offset*/) {}
virtual void notifyThemeChanged();
- virtual void notifyViewChanged(ViewFrame* /*frame*/) { }
- virtual void notifyViewLocationChanged(View* /*view*/, const ViewLocation& /*viewLocation*/) { }
+ virtual void notifyViewChanged(ViewFrame* /*frame*/) {}
+ virtual void notifyViewLocationChanged(View* /*view*/, const ViewLocation& /*viewLocation*/) {}
virtual void focus();
virtual QWidget* headerWidget() { return nullptr; }
};
-class BINARYNINJAUIAPI SidebarWidgetAndHeader: public QWidget
+class BINARYNINJAUIAPI SidebarWidgetAndHeader : public QWidget
{
Q_OBJECT
SidebarWidget* m_widget;
QWidget* m_header;
ViewFrame* m_frame;
-public:
+
+ public:
SidebarWidgetAndHeader(SidebarWidget* widget, ViewFrame* frame);
SidebarWidget* widget() const { return m_widget; }
@@ -64,27 +65,30 @@ public:
void updateFonts();
};
-class BINARYNINJAUIAPI SidebarHeaderTitle: public QLabel
+class BINARYNINJAUIAPI SidebarHeaderTitle : public QLabel
{
Q_OBJECT
-public:
+
+ public:
SidebarHeaderTitle(const QString& name);
};
-class BINARYNINJAUIAPI SidebarHeader: public QWidget
+class BINARYNINJAUIAPI SidebarHeader : public QWidget
{
Q_OBJECT
-public:
+
+ public:
SidebarHeader(const QString& name, QWidget* rightSide = nullptr);
};
-class BINARYNINJAUIAPI SidebarInvalidContextWidget: public SidebarWidget
+class BINARYNINJAUIAPI SidebarInvalidContextWidget : public SidebarWidget
{
Q_OBJECT
-public:
+
+ public:
SidebarInvalidContextWidget(const QString& title);
-private Q_SLOTS:
+ private Q_SLOTS:
void openFile();
};
@@ -93,7 +97,7 @@ class BINARYNINJAUIAPI SidebarWidgetType
SidebarIcon m_icon;
QString m_name;
-public:
+ public:
SidebarWidgetType(const QImage& icon, const QString& name);
virtual ~SidebarWidgetType() {}
@@ -118,7 +122,7 @@ struct SidebarWidgetContainerState
QList<int> parentSplitterSizes;
};
-class BINARYNINJAUIAPI SidebarWidgetContainer: public QWidget
+class BINARYNINJAUIAPI SidebarWidgetContainer : public QWidget
{
Q_OBJECT
@@ -148,7 +152,7 @@ class BINARYNINJAUIAPI SidebarWidgetContainer: public QWidget
static QVariant sizesToVariant(const QList<int>& sizes);
static std::optional<QList<int>> variantToSizes(const QVariant& variant);
-public:
+ public:
SidebarWidgetContainer();
void setSplitter(QSplitter* splitter);
@@ -181,15 +185,15 @@ public:
void toggleSidebar();
- void moveContextToContainer(SplitPaneWidget* panes, const std::vector<ViewFrame*>& frames,
- SidebarWidgetContainer* target);
+ void moveContextToContainer(
+ SplitPaneWidget* panes, const std::vector<ViewFrame*>& frames, SidebarWidgetContainer* target);
-Q_SIGNALS:
+ Q_SIGNALS:
void showContents();
void hideContents();
};
-class BINARYNINJAUIAPI Sidebar: public QWidget
+class BINARYNINJAUIAPI Sidebar : public QWidget
{
Q_OBJECT
@@ -201,13 +205,13 @@ class BINARYNINJAUIAPI Sidebar: public QWidget
static SidebarWidgetType* m_defaultContentType;
static SidebarWidgetType* m_defaultReferenceType;
-protected:
+ protected:
virtual void paintEvent(QPaintEvent* event) override;
virtual void mouseMoveEvent(QMouseEvent* event) override;
virtual void mousePressEvent(QMouseEvent* event) override;
virtual void leaveEvent(QEvent* event) override;
-public:
+ public:
Sidebar();
SidebarWidgetContainer* container() const { return m_currentContainer; }
@@ -245,7 +249,7 @@ public:
return context->sidebar();
}
- template<class T>
+ template <class T>
static T* widget(SidebarWidgetType* type)
{
Sidebar* sidebar = current();
@@ -257,13 +261,13 @@ public:
return qobject_cast<T*>(widget);
}
- template<class T>
+ template <class T>
static T* widget(const QString& name)
{
return widget<T>(Sidebar::typeFromName(name));
}
- template<class T>
+ template <class T>
static T* activateWidget(SidebarWidgetType* type)
{
Sidebar* sidebar = current();
@@ -279,76 +283,72 @@ public:
return result;
}
- template<class T>
+ template <class T>
static T* activateWidget(const QString& name)
{
return activateWidget<T>(Sidebar::typeFromName(name));
}
- template<class T>
- static UIAction globalSidebarAction(const QString& name,
- const std::function<void(T* obj)>& activate)
+ template <class T>
+ static UIAction globalSidebarAction(const QString& name, const std::function<void(T* obj)>& activate)
{
- return globalSidebarAction<T>(name,
- [=](T* obj, const UIActionContext&) { activate(obj); },
- [=](T*, const UIActionContext&) { return true; });
+ return globalSidebarAction<T>(
+ name, [=](T* obj, const UIActionContext&) { activate(obj); },
+ [=](T*, const UIActionContext&) { return true; });
}
- template<class T>
- static UIAction globalSidebarAction(const QString& name,
- const std::function<void(T* obj, const UIActionContext& ctxt)>& activate)
+ template <class T>
+ static UIAction globalSidebarAction(
+ const QString& name, const std::function<void(T* obj, const UIActionContext& ctxt)>& activate)
{
- return globalSidebarAction<T>(name, activate,
- [](T*, const UIActionContext&) { return true; });
+ return globalSidebarAction<T>(name, activate, [](T*, const UIActionContext&) { return true; });
}
- template<class T>
- static UIAction globalSidebarAction(const QString& name,
- const std::function<void(T* obj)>& activate, const std::function<bool(T* obj)>& isValid)
+ template <class T>
+ static UIAction globalSidebarAction(
+ const QString& name, const std::function<void(T* obj)>& activate, const std::function<bool(T* obj)>& isValid)
{
- return globalSidebarAction<T>(name,
- [=](T* obj, const UIActionContext&) { activate(obj); },
- [=](T* obj, const UIActionContext&) { return isValid(obj); });
+ return globalSidebarAction<T>(
+ name, [=](T* obj, const UIActionContext&) { activate(obj); },
+ [=](T* obj, const UIActionContext&) { return isValid(obj); });
}
- template<class T>
+ template <class T>
static UIAction globalSidebarAction(const QString& name,
- const std::function<void(T* obj, const UIActionContext& ctxt)>& activate,
- const std::function<bool(T* obj, const UIActionContext& ctxt)>& isValid)
+ const std::function<void(T* obj, const UIActionContext& ctxt)>& activate,
+ const std::function<bool(T* obj, const UIActionContext& ctxt)>& isValid)
{
return globalSidebarAction<T>(Sidebar::typeFromName(name), activate, isValid);
}
- template<class T>
- static UIAction globalSidebarAction(SidebarWidgetType* type,
- const std::function<void(T* obj)>& activate)
+ template <class T>
+ static UIAction globalSidebarAction(SidebarWidgetType* type, const std::function<void(T* obj)>& activate)
{
- return globalSidebarAction<T>(type,
- [=](T* obj, const UIActionContext&) { activate(obj); },
- [=](T*, const UIActionContext&) { return true; });
+ return globalSidebarAction<T>(
+ type, [=](T* obj, const UIActionContext&) { activate(obj); },
+ [=](T*, const UIActionContext&) { return true; });
}
- template<class T>
- static UIAction globalSidebarAction(SidebarWidgetType* type,
- const std::function<void(T* obj, const UIActionContext& ctxt)>& activate)
+ template <class T>
+ static UIAction globalSidebarAction(
+ SidebarWidgetType* type, const std::function<void(T* obj, const UIActionContext& ctxt)>& activate)
{
- return globalSidebarAction<T>(type, activate,
- [](T*, const UIActionContext&) { return true; });
+ return globalSidebarAction<T>(type, activate, [](T*, const UIActionContext&) { return true; });
}
- template<class T>
- static UIAction globalSidebarAction(SidebarWidgetType* type,
- const std::function<void(T* obj)>& activate, const std::function<bool(T* obj)>& isValid)
+ template <class T>
+ static UIAction globalSidebarAction(SidebarWidgetType* type, const std::function<void(T* obj)>& activate,
+ const std::function<bool(T* obj)>& isValid)
{
- return globalSidebarAction<T>(type,
- [=](T* obj, const UIActionContext&) { activate(obj); },
- [=](T* obj, const UIActionContext&) { return isValid(obj); });
+ return globalSidebarAction<T>(
+ type, [=](T* obj, const UIActionContext&) { activate(obj); },
+ [=](T* obj, const UIActionContext&) { return isValid(obj); });
}
- template<class T>
+ template <class T>
static UIAction globalSidebarAction(SidebarWidgetType* type,
- const std::function<void(T* obj, const UIActionContext& ctxt)>& activate,
- const std::function<bool(T* obj, const UIActionContext& ctxt)>& isValid)
+ const std::function<void(T* obj, const UIActionContext& ctxt)>& activate,
+ const std::function<bool(T* obj, const UIActionContext& ctxt)>& isValid)
{
std::function<T*(const UIActionContext& ctxt)> lookup = [=](const UIActionContext& ctxt) {
if (!type || !ctxt.context)
@@ -362,45 +362,43 @@ public:
return qobject_cast<T*>(widget);
};
return UIAction(
- [=](const UIActionContext& ctxt) {
- T* obj = lookup(ctxt);
- if (obj)
- activate(obj, ctxt);
- },
- [=](const UIActionContext& ctxt) {
- T* obj = lookup(ctxt);
- if (obj)
- return isValid(obj, ctxt);
- return false;
- });
+ [=](const UIActionContext& ctxt) {
+ T* obj = lookup(ctxt);
+ if (obj)
+ activate(obj, ctxt);
+ },
+ [=](const UIActionContext& ctxt) {
+ T* obj = lookup(ctxt);
+ if (obj)
+ return isValid(obj, ctxt);
+ return false;
+ });
}
- template<class T>
- static std::function<bool(const UIActionContext&)> globalSidebarActionChecked(const QString& name,
- const std::function<bool(T* obj)>& isChecked)
+ template <class T>
+ static std::function<bool(const UIActionContext&)> globalSidebarActionChecked(
+ const QString& name, const std::function<bool(T* obj)>& isChecked)
{
- return globalSidebarActionChecked<T>(name,
- [=](T* obj, const UIActionContext&) { return isChecked(obj); });
+ return globalSidebarActionChecked<T>(name, [=](T* obj, const UIActionContext&) { return isChecked(obj); });
}
- template<class T>
- static std::function<bool(const UIActionContext&)> globalSidebarActionChecked(const QString& name,
- const std::function<bool(T* obj, const UIActionContext& ctxt)>& isChecked)
+ template <class T>
+ static std::function<bool(const UIActionContext&)> globalSidebarActionChecked(
+ const QString& name, const std::function<bool(T* obj, const UIActionContext& ctxt)>& isChecked)
{
return globalSidebarActionChecked<T>(Sidebar::typeFromName(name), isChecked);
}
- template<class T>
- static std::function<bool(const UIActionContext&)> globalSidebarActionChecked(SidebarWidgetType* type,
- const std::function<bool(T* obj)>& isChecked)
+ template <class T>
+ static std::function<bool(const UIActionContext&)> globalSidebarActionChecked(
+ SidebarWidgetType* type, const std::function<bool(T* obj)>& isChecked)
{
- return globalSidebarActionChecked<T>(type,
- [=](T* obj, const UIActionContext&) { return isChecked(obj); });
+ return globalSidebarActionChecked<T>(type, [=](T* obj, const UIActionContext&) { return isChecked(obj); });
}
- template<class T>
- static std::function<bool(const UIActionContext&)> globalSidebarActionChecked(SidebarWidgetType* type,
- const std::function<bool(T* obj, const UIActionContext& ctxt)>& isChecked)
+ template <class T>
+ static std::function<bool(const UIActionContext&)> globalSidebarActionChecked(
+ SidebarWidgetType* type, const std::function<bool(T* obj, const UIActionContext& ctxt)>& isChecked)
{
return [=](const UIActionContext& ctxt) {
if (!type || !ctxt.context)
diff --git a/ui/stackview.h b/ui/stackview.h
index 34e83950..c2e31a11 100644
--- a/ui/stackview.h
+++ b/ui/stackview.h
@@ -27,18 +27,17 @@ class BINARYNINJAUIAPI CreateStackVariableDialog : public QDialog
//! Automatically update/sanitize the offset and name fields after input.
void autoFillFields();
- protected:
+ protected:
void accept() override;
- public:
- CreateStackVariableDialog(
- QWidget* parent, BinaryViewRef data, FunctionRef func, int64_t initialOffset = 0);
+ public:
+ CreateStackVariableDialog(QWidget* parent, BinaryViewRef data, FunctionRef func, int64_t initialOffset = 0);
};
//! A single line in the stack view.
class StackViewLine
{
- public:
+ public:
enum class Type
{
Variable,
@@ -49,12 +48,10 @@ class StackViewLine
};
//! Create a new line for a variable.
- static StackViewLine variable(
- int64_t offset, const BinaryNinja::VariableNameAndType& vnat, PlatformRef plat);
+ static StackViewLine variable(int64_t offset, const BinaryNinja::VariableNameAndType& vnat, PlatformRef plat);
//! Create a new line for a struct or array member.
- static StackViewLine member(
- int64_t offset, const BinaryNinja::VariableNameAndType& vnat, PlatformRef plat);
+ static StackViewLine member(int64_t offset, const BinaryNinja::VariableNameAndType& vnat, PlatformRef plat);
//! Create a new line for a struct offset reference.
static StackViewLine offsetRef(int64_t base, uint64_t offset, size_t size);
@@ -128,7 +125,7 @@ class StackViewLine
//! Indent this line's content.
void indent(size_t levels = 1);
- private:
+ private:
StackViewLine(StackViewLine::Type type, int64_t offset);
StackViewLine::Type m_type;
@@ -184,12 +181,12 @@ class BINARYNINJAUIAPI StackView : public QAbstractScrollArea, public View
//! Find the end of a stack void given a start offset.
int64_t findVoidEnd(int64_t start) const;
- protected:
+ protected:
void paintEvent(QPaintEvent* event) override;
void mousePressEvent(QMouseEvent* event) override;
void mouseDoubleClickEvent(QMouseEvent* event) override;
- public:
+ public:
StackView(ViewFrame* view, BinaryViewRef data);
//! Refresh the stack view's content.
@@ -252,7 +249,7 @@ class BINARYNINJAUIAPI StackViewSidebarWidget : public SidebarWidget
StackView* m_stackView;
QWidget* m_header;
- public:
+ public:
StackViewSidebarWidget(ViewFrame* view, BinaryViewRef data);
void refresh();
@@ -263,7 +260,7 @@ class BINARYNINJAUIAPI StackViewSidebarWidget : public SidebarWidget
class BINARYNINJAUIAPI StackViewSidebarWidgetType : public SidebarWidgetType
{
- public:
+ public:
StackViewSidebarWidgetType();
SidebarWidget* createWidget(ViewFrame* frame, BinaryViewRef data) override;
};
diff --git a/ui/statusbarwidget.h b/ui/statusbarwidget.h
index b41391a0..b7ab2537 100644
--- a/ui/statusbarwidget.h
+++ b/ui/statusbarwidget.h
@@ -4,20 +4,20 @@
#include <QtWidgets/QLabel>
#include "uicontext.h"
-class BINARYNINJAUIAPI StatusBarWidget: public QWidget
+class BINARYNINJAUIAPI StatusBarWidget : public QWidget
{
Q_OBJECT
-public:
+ public:
StatusBarWidget(QWidget* parent);
virtual void updateStatus();
};
-class BINARYNINJAUIAPI DisabledOptionsStatusBarWidget: public StatusBarWidget
+class BINARYNINJAUIAPI DisabledOptionsStatusBarWidget : public StatusBarWidget
{
-public:
+ public:
DisabledOptionsStatusBarWidget(QFrame* parent);
-private:
+ private:
QLabel* m_label;
};
diff --git a/ui/stringsview.h b/ui/stringsview.h
index b70c6d68..4a843bb1 100644
--- a/ui/stringsview.h
+++ b/ui/stringsview.h
@@ -9,7 +9,7 @@
#define STRINGS_LIST_UPDATE_INTERVAL 250
-class BINARYNINJAUIAPI StringsListModel: public QAbstractItemModel, public BinaryNinja::BinaryDataNotification
+class BINARYNINJAUIAPI StringsListModel : public QAbstractItemModel, public BinaryNinja::BinaryDataNotification
{
Q_OBJECT
@@ -33,7 +33,7 @@ class BINARYNINJAUIAPI StringsListModel: public QAbstractItemModel, public Binar
std::vector<StringUpdateEvent> getQueuedStringUpdates();
-public:
+ public:
StringsListModel(QWidget* parent, BinaryViewRef data);
virtual ~StringsListModel();
@@ -48,13 +48,14 @@ public:
QModelIndex findString(const BNStringReference& ref);
virtual void OnStringFound(BinaryNinja::BinaryView* data, BNStringType type, uint64_t offset, size_t len) override;
- virtual void OnStringRemoved(BinaryNinja::BinaryView* data, BNStringType type, uint64_t offset, size_t len) override;
+ virtual void OnStringRemoved(
+ BinaryNinja::BinaryView* data, BNStringType type, uint64_t offset, size_t len) override;
void updateStrings();
void setFilter(const std::string& filter);
};
-class BINARYNINJAUIAPI StringItemDelegate: public QStyledItemDelegate
+class BINARYNINJAUIAPI StringItemDelegate : public QStyledItemDelegate
{
Q_OBJECT
@@ -64,7 +65,7 @@ class BINARYNINJAUIAPI StringItemDelegate: public QStyledItemDelegate
void initFont();
-public:
+ public:
StringItemDelegate(QWidget* parent);
void updateFonts();
@@ -76,7 +77,7 @@ public:
class StringsContainer;
-class BINARYNINJAUIAPI StringsView: public QListView, public View, public FilterTarget
+class BINARYNINJAUIAPI StringsView : public QListView, public View, public FilterTarget
{
Q_OBJECT
@@ -90,7 +91,7 @@ class BINARYNINJAUIAPI StringsView: public QListView, public View, public Filter
uint64_t m_selectionBegin, m_selectionEnd;
-public:
+ public:
StringsView(BinaryViewRef data, ViewFrame* view, StringsContainer* container);
virtual BinaryViewRef getData() override { return m_data; }
@@ -111,16 +112,17 @@ public:
virtual void selectFirstItem() override;
virtual void activateFirstItem() override;
virtual QFont getFont() override { return m_itemDelegate->getFont(); }
-protected:
+
+ protected:
virtual void keyPressEvent(QKeyEvent* event) override;
virtual bool event(QEvent* event) override;
-private Q_SLOTS:
+ private Q_SLOTS:
void goToString(const QModelIndex& idx);
void updateTimerEvent();
};
-class BINARYNINJAUIAPI StringsContainer: public QWidget, public ViewContainer
+class BINARYNINJAUIAPI StringsContainer : public QWidget, public ViewContainer
{
Q_OBJECT
@@ -129,7 +131,7 @@ class BINARYNINJAUIAPI StringsContainer: public QWidget, public ViewContainer
FilteredView* m_filter;
FilterEdit* m_separateEdit = nullptr;
-public:
+ public:
StringsContainer(BinaryViewRef data, ViewFrame* view, bool separateEdit = false);
virtual View* getView() override { return m_strings; }
@@ -137,15 +139,15 @@ public:
FilteredView* getFilter() { return m_filter; }
FilterEdit* getSeparateFilterEdit() { return m_separateEdit; }
-protected:
+ protected:
virtual void focusInEvent(QFocusEvent* event) override;
};
-class StringsViewType: public ViewType
+class StringsViewType : public ViewType
{
static StringsViewType* m_instance;
-public:
+ public:
StringsViewType();
virtual int getPriority(BinaryViewRef data, const QString& filename);
virtual QWidget* create(BinaryViewRef data, ViewFrame* viewFrame);
@@ -153,22 +155,23 @@ public:
};
-class BINARYNINJAUIAPI StringsViewSidebarWidget: public SidebarWidget
+class BINARYNINJAUIAPI StringsViewSidebarWidget : public SidebarWidget
{
Q_OBJECT
QWidget* m_header;
StringsContainer* m_container;
-public:
+
+ public:
StringsViewSidebarWidget(BinaryViewRef data, ViewFrame* frame);
virtual QWidget* headerWidget() override { return m_header; }
virtual void focus() override;
};
-class BINARYNINJAUIAPI StringsViewSidebarWidgetType: public SidebarWidgetType
+class BINARYNINJAUIAPI StringsViewSidebarWidgetType : public SidebarWidgetType
{
-public:
+ public:
StringsViewSidebarWidgetType();
virtual SidebarWidget* createWidget(ViewFrame* frame, BinaryViewRef data) override;
};
diff --git a/ui/symbollist.h b/ui/symbollist.h
index 471a6e00..ffefa3c8 100644
--- a/ui/symbollist.h
+++ b/ui/symbollist.h
@@ -20,22 +20,23 @@
class SymbolsView;
static std::string emptyArch;
-class BINARYNINJAUIAPI SymbolListDelegate: public QStyledItemDelegate
+class BINARYNINJAUIAPI SymbolListDelegate : public QStyledItemDelegate
{
Q_OBJECT
QFont m_font;
int m_height, m_charWidth;
-public:
+ public:
SymbolListDelegate(QWidget* parent);
void updateFonts();
- virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
+ virtual QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override;
};
-class BINARYNINJAUIAPI SymbolListModel: public QAbstractItemModel, public BinaryNinja::BinaryDataNotification
+class BINARYNINJAUIAPI SymbolListModel : public QAbstractItemModel, public BinaryNinja::BinaryDataNotification
{
Q_OBJECT
-public:
+
+ public:
enum SortType
{
SortAscendingAddresses,
@@ -90,10 +91,7 @@ public:
return (getStart() == other.getStart()) && (getType() == other.getType());
}
- bool operator!=(const NamedObject& other) const
- {
- return !((*this) == other);
- }
+ bool operator!=(const NamedObject& other) const { return !((*this) == other); }
bool operator<(const NamedObject& other) const
{
@@ -113,7 +111,11 @@ public:
return false;
}
- bool isFunc() const { return (getType() == FunctionSymbol) || (getType() == ImportedFunctionSymbol) || (getType() == LibraryFunctionSymbol); }
+ bool isFunc() const
+ {
+ return (getType() == FunctionSymbol) || (getType() == ImportedFunctionSymbol)
+ || (getType() == LibraryFunctionSymbol);
+ }
uint64_t getStart() const { return sym->GetAddress(); }
std::string getName() const { return name; }
std::string getRawName() const { return rawName; }
@@ -148,7 +150,7 @@ public:
BNSymbolType getType() const { return sym->GetType(); }
};
-private:
+ private:
enum SymbolListUpdateType
{
UnnamedFunctionAddedToSymbolList,
@@ -170,13 +172,13 @@ private:
}
};
- class SymbolListUpdate: public BinaryNinja::RefCountObject
+ class SymbolListUpdate : public BinaryNinja::RefCountObject
{
std::mutex m_mutex;
bool m_valid;
SymbolListModel* m_model;
- public:
+ public:
SymbolListUpdate(SymbolListModel* model);
void start();
void abort();
@@ -213,7 +215,7 @@ private:
void getValidObject(std::deque<NamedObject>& result);
-public:
+ public:
SymbolListModel(QWidget* parent, ViewFrame* view, BinaryViewRef data);
virtual ~SymbolListModel();
@@ -259,11 +261,11 @@ public:
void toggleLocalDataVars() { m_showLocalDataVars = !m_showLocalDataVars; }
void toggleImports() { m_showImports = !m_showImports; }
- bool getShowExportedFunctions() const { return m_showExportedFunctions; }
- bool getShowExportedDataVars() const { return m_showExportedDataVars; }
- bool getShowLocalFunctions() const { return m_showLocalFunctions; }
- bool getShowLocalDataVars() const { return m_showLocalDataVars; }
- bool getShowImports() const { return m_showImports; }
+ bool getShowExportedFunctions() const { return m_showExportedFunctions; }
+ bool getShowExportedDataVars() const { return m_showExportedDataVars; }
+ bool getShowLocalFunctions() const { return m_showLocalFunctions; }
+ bool getShowLocalDataVars() const { return m_showLocalDataVars; }
+ bool getShowImports() const { return m_showImports; }
bool getShowMangled() const { return m_displayMangled; }
void setShowMangled(bool show) { m_displayMangled = show; }
@@ -275,13 +277,13 @@ public:
bool checkTriggerFullUpdate();
-Q_SIGNALS:
+ Q_SIGNALS:
void afterListReset();
void beforeListReset();
};
-class BINARYNINJAUIAPI SymbolList: public QListView, public FilterTarget
+class BINARYNINJAUIAPI SymbolList : public QListView, public FilterTarget
{
Q_OBJECT
@@ -303,7 +305,7 @@ class BINARYNINJAUIAPI SymbolList: public QListView, public FilterTarget
SymbolListModel::NamedObject m_topIndex;
bool m_doubleClick;
-public:
+ public:
SymbolList(SymbolsView* parent, ViewFrame* frame, BinaryViewRef data);
void updateFonts();
@@ -335,12 +337,12 @@ public:
void toggleLocalDataVars() { m_list->toggleLocalDataVars(); }
void toggleImports() { m_list->toggleImports(); }
-protected:
+ protected:
virtual void focusOutEvent(QFocusEvent* event) override;
virtual void keyPressEvent(QKeyEvent* event) override;
virtual bool event(QEvent* event) override;
-private Q_SLOTS:
+ private Q_SLOTS:
void goToSymbol(const QModelIndex& i);
void updateTimerEvent();
void savePosition();
diff --git a/ui/symbolsview.h b/ui/symbolsview.h
index 0a948d81..0997285b 100644
--- a/ui/symbolsview.h
+++ b/ui/symbolsview.h
@@ -9,7 +9,7 @@
class ViewFrame;
class SymbolList;
-class BINARYNINJAUIAPI SymbolsView: public SidebarWidget, public BinaryNinja::BinaryDataNotification
+class BINARYNINJAUIAPI SymbolsView : public SidebarWidget, public BinaryNinja::BinaryDataNotification
{
Q_OBJECT
@@ -24,7 +24,7 @@ class BINARYNINJAUIAPI SymbolsView: public SidebarWidget, public BinaryNinja::Bi
bool m_updatesPending;
QTimer* m_updateTimer;
-public:
+ public:
SymbolsView(ViewFrame* frame, BinaryViewRef data);
virtual ~SymbolsView();
@@ -51,18 +51,18 @@ public:
virtual QWidget* headerWidget() override { return m_header; }
virtual void focus() override;
-protected:
+ protected:
virtual void contextMenuEvent(QContextMenuEvent* event) override;
virtual void notifyFontChanged() override;
-private Q_SLOTS:
+ private Q_SLOTS:
void updateTimerEvent();
void showContextMenu();
};
-class BINARYNINJAUIAPI SymbolsViewSidebarWidgetType: public SidebarWidgetType
+class BINARYNINJAUIAPI SymbolsViewSidebarWidgetType : public SidebarWidgetType
{
-public:
+ public:
SymbolsViewSidebarWidgetType();
virtual SidebarWidget* createWidget(ViewFrame* frame, BinaryViewRef data) override;
};
diff --git a/ui/syncgroup.h b/ui/syncgroup.h
index ff4fd9d0..6600f8ce 100644
--- a/ui/syncgroup.h
+++ b/ui/syncgroup.h
@@ -9,7 +9,7 @@ class BINARYNINJAUIAPI SyncGroup
ViewFrame* m_lastSyncFrame = nullptr;
int m_id;
-public:
+ public:
SyncGroup(int id);
void addMember(ViewFrame* frame);
@@ -26,18 +26,18 @@ public:
static void syncToTarget(View* srcView, ViewFrame* targetFrame, const ViewLocation& location);
};
-class BINARYNINJAUIAPI SyncGroupWidget: public ClickableIcon
+class BINARYNINJAUIAPI SyncGroupWidget : public ClickableIcon
{
Q_OBJECT
ViewFrame* m_frame;
-public:
+ public:
SyncGroupWidget(ViewFrame* frame);
void updateStatus();
void setViewFrame(ViewFrame* frame);
-private Q_SLOTS:
+ private Q_SLOTS:
void handleClick();
};
diff --git a/ui/tabwidget.h b/ui/tabwidget.h
index 08b84182..bf0c3ca2 100644
--- a/ui/tabwidget.h
+++ b/ui/tabwidget.h
@@ -19,14 +19,14 @@ class BINARYNINJAUIAPI DockableTabCollection
{
std::set<DockableTabWidget*> m_containers;
-public:
+ public:
void registerContainer(DockableTabWidget* widget);
void unregisterContainer(DockableTabWidget* widget);
const std::set<DockableTabWidget*>& containers() const { return m_containers; }
};
-class BINARYNINJAUIAPI TabDragIndicator: public QWidget
+class BINARYNINJAUIAPI TabDragIndicator : public QWidget
{
Q_OBJECT
@@ -36,7 +36,7 @@ class BINARYNINJAUIAPI TabDragIndicator: public QWidget
QPoint m_offset;
bool m_newWindow;
-public:
+ public:
TabDragIndicator(QPixmap pixmap, QSize size, QPoint pt, QPoint offset, bool newWindow);
void moveToMouse(QPoint pt);
@@ -44,7 +44,7 @@ public:
QSize size() const { return m_size; }
QPoint offset() const { return m_offset; }
-protected:
+ protected:
virtual QSize sizeHint() const override;
virtual QSize minimumSizeHint() const override;
virtual void paintEvent(QPaintEvent* event) override;
@@ -70,42 +70,40 @@ struct BINARYNINJAUIAPI DockableTabInfo
class BINARYNINJAUIAPI DockableTabStyle
{
-public:
+ public:
virtual ~DockableTabStyle() {}
- virtual QSize sizeForTab(const QWidget* widget, const DockableTabInfo& info, int idx,
- int count, int active) const;
- virtual QRect closeButtonRect(const QWidget* widget, const DockableTabInfo& info, int idx,
- int count, int active) const;
- virtual QRect closeIconRect(const QWidget* widget, const DockableTabInfo& info, int idx,
- int count, int active) const;
- virtual void paintTab(const QWidget* widget, QStylePainter& p, const DockableTabInfo& info, int idx,
- int count, int active, DockableTabInteractionState state, const QRect& rect) const;
- virtual void paintBase(const QWidget* widget, QStylePainter& p, const QRect& rect,
- const QRect& activeRect) const;
+ virtual QSize sizeForTab(const QWidget* widget, const DockableTabInfo& info, int idx, int count, int active) const;
+ virtual QRect closeButtonRect(
+ const QWidget* widget, const DockableTabInfo& info, int idx, int count, int active) const;
+ virtual QRect closeIconRect(
+ const QWidget* widget, const DockableTabInfo& info, int idx, int count, int active) const;
+ virtual void paintTab(const QWidget* widget, QStylePainter& p, const DockableTabInfo& info, int idx, int count,
+ int active, DockableTabInteractionState state, const QRect& rect) const;
+ virtual void paintBase(const QWidget* widget, QStylePainter& p, const QRect& rect, const QRect& activeRect) const;
virtual DockableTabStyle* duplicate();
};
-class BINARYNINJAUIAPI DefaultDockableTabStyle: public DockableTabStyle
+class BINARYNINJAUIAPI DefaultDockableTabStyle : public DockableTabStyle
{
- QStyleOptionTab styleForTab(const QWidget* widget, const DockableTabInfo& info, int idx,
- int count, int active) const;
+ QStyleOptionTab styleForTab(
+ const QWidget* widget, const DockableTabInfo& info, int idx, int count, int active) const;
int closeButtonSize(const QWidget* widget) const;
-public:
- virtual QSize sizeForTab(const QWidget* widget, const DockableTabInfo& info, int idx,
- int count, int active) const override;
- virtual QRect closeButtonRect(const QWidget* widget, const DockableTabInfo& info, int idx,
- int count, int active) const override;
- virtual QRect closeIconRect(const QWidget* widget, const DockableTabInfo& info, int idx,
- int count, int active) const override;
- virtual void paintTab(const QWidget* widget, QStylePainter& p, const DockableTabInfo& info, int idx,
- int count, int active, DockableTabInteractionState state, const QRect& rect) const override;
- virtual void paintBase(const QWidget* widget, QStylePainter& p, const QRect& rect,
- const QRect& activeRect) const override;
+ public:
+ virtual QSize sizeForTab(
+ const QWidget* widget, const DockableTabInfo& info, int idx, int count, int active) const override;
+ virtual QRect closeButtonRect(
+ const QWidget* widget, const DockableTabInfo& info, int idx, int count, int active) const override;
+ virtual QRect closeIconRect(
+ const QWidget* widget, const DockableTabInfo& info, int idx, int count, int active) const override;
+ virtual void paintTab(const QWidget* widget, QStylePainter& p, const DockableTabInfo& info, int idx, int count,
+ int active, DockableTabInteractionState state, const QRect& rect) const override;
+ virtual void paintBase(
+ const QWidget* widget, QStylePainter& p, const QRect& rect, const QRect& activeRect) const override;
virtual DockableTabStyle* duplicate() override;
};
-class BINARYNINJAUIAPI DockableTabBar: public QAbstractScrollArea
+class BINARYNINJAUIAPI DockableTabBar : public QAbstractScrollArea
{
Q_OBJECT
@@ -138,7 +136,7 @@ class BINARYNINJAUIAPI DockableTabBar: public QAbstractScrollArea
void updateLayout();
-public:
+ public:
DockableTabBar(DockableTabCollection* collection);
virtual ~DockableTabBar();
@@ -169,7 +167,7 @@ public:
DockableTabStyle* tabStyle() const { return m_style; }
void setTabStyle(DockableTabStyle* style);
-Q_SIGNALS:
+ Q_SIGNALS:
void currentChanged(int idx);
void tabCloseRequested(int idx);
void tabMoved(int oldIdx, int newIdx);
@@ -177,10 +175,10 @@ Q_SIGNALS:
void reparentTab(int oldIdx, DockableTabWidget* target, int newIdx);
void splitTab(int idx, Qt::Edge edge);
-private Q_SLOTS:
+ private Q_SLOTS:
void underMouseTimerEvent();
-protected:
+ protected:
virtual QSize sizeHint() const override;
virtual QSize minimumSizeHint() const override;
virtual void paintEvent(QPaintEvent* event) override;
@@ -193,7 +191,7 @@ protected:
virtual void wheelEvent(QWheelEvent* event) override;
};
-class BINARYNINJAUIAPI DockableTabBarWithCornerWidget: public QWidget
+class BINARYNINJAUIAPI DockableTabBarWithCornerWidget : public QWidget
{
DockableTabBar* m_bar;
QHBoxLayout* m_barLayout;
@@ -201,10 +199,10 @@ class BINARYNINJAUIAPI DockableTabBarWithCornerWidget: public QWidget
QWidget* m_cornerWidget = nullptr;
QWidget* m_cornerWidgetContainer = nullptr;
-protected:
+ protected:
virtual void paintEvent(QPaintEvent* event) override;
-public:
+ public:
DockableTabBarWithCornerWidget(DockableTabBar* bar);
DockableTabBar* tabBar() const { return m_bar; }
void setCornerWidget(QWidget* widget, Qt::Corner corner = Qt::TopRightCorner);
@@ -212,7 +210,7 @@ public:
QWidget* cornerWidget() const { return m_cornerWidget; }
};
-class BINARYNINJAUIAPI DockableTabWidget: public QWidget
+class BINARYNINJAUIAPI DockableTabWidget : public QWidget
{
Q_OBJECT
@@ -221,10 +219,10 @@ class BINARYNINJAUIAPI DockableTabWidget: public QWidget
DockableTabBarWithCornerWidget* m_cornerWidget;
QStackedWidget* m_widgets;
- void addReparentedTab(DockableTabWidget* source, int idx, QWidget* widget,
- const QString& title, const QString& toolTip, bool canClose);
+ void addReparentedTab(DockableTabWidget* source, int idx, QWidget* widget, const QString& title,
+ const QString& toolTip, bool canClose);
-public:
+ public:
DockableTabWidget(DockableTabCollection* collection, DockableTabBar* bar = nullptr);
int addTab(QWidget* widget, const QString& title);
@@ -261,7 +259,7 @@ public:
virtual QSize sizeHint() const override;
-Q_SIGNALS:
+ Q_SIGNALS:
void tabCloseRequested(int idx);
void currentChanged(int idx);
void tabMoved(int oldIdx, int newIdx);
@@ -270,7 +268,7 @@ Q_SIGNALS:
void tabAddedForReparent(int idx, DockableTabWidget* source);
void splitTab(int idx, Qt::Edge edge);
-private Q_SLOTS:
+ private Q_SLOTS:
void tabBarCurrentChanged(int idx);
void tabBarCloseRequested(int idx);
void tabBarTabMoved(int oldIdx, int newIdx);
@@ -279,7 +277,7 @@ private Q_SLOTS:
void reparentTab(int oldIdx, DockableTabWidget* target, int newIdx);
};
-class BINARYNINJAUIAPI SplitTabWidget: public QWidget
+class BINARYNINJAUIAPI SplitTabWidget : public QWidget
{
Q_OBJECT
@@ -298,12 +296,12 @@ class BINARYNINJAUIAPI SplitTabWidget: public QWidget
void enumerateTabTree(const std::function<void(SplitTabWidget*, QWidget*, QString)>& func);
Json::Value savedLayoutObject() const;
void restoreLayoutObject(const Json::Value& layout);
- void restoreLayoutObjectWithTabs(const Json::Value& layout,
- std::map<QString, std::pair<DockableTabWidget*, QWidget*>>& tabWidgets);
+ void restoreLayoutObjectWithTabs(
+ const Json::Value& layout, std::map<QString, std::pair<DockableTabWidget*, QWidget*>>& tabWidgets);
DockableTabWidget* findFirstTabWidget();
void collapseEmptyTabs();
-public:
+ public:
SplitTabWidget(DockableTabCollection* collection);
void addTab(QWidget* widget, const QString& title);
@@ -319,12 +317,12 @@ public:
QString savedLayoutString() const;
void restoreLayoutString(const QString& layout);
-Q_SIGNALS:
+ Q_SIGNALS:
void tabClosed(QWidget* widget);
void currentChanged(QWidget* widget);
void layoutChanged();
-private Q_SLOTS:
+ private Q_SLOTS:
void tabCloseRequested(int idx);
void currentTabChanged(int idx);
void splitTab(int idx, Qt::Edge edge);
diff --git a/ui/taglist.h b/ui/taglist.h
index 8b28ef32..c5ef0c7d 100644
--- a/ui/taglist.h
+++ b/ui/taglist.h
@@ -13,11 +13,11 @@
#include "tagtypelist.h"
-class BINARYNINJAUIAPI TagListModel: public QAbstractItemModel
+class BINARYNINJAUIAPI TagListModel : public QAbstractItemModel
{
Q_OBJECT
-protected:
+ protected:
QWidget* m_owner;
BinaryViewRef m_data;
std::map<TagTypeRef, size_t> m_typeIndexes;
@@ -25,7 +25,7 @@ protected:
std::map<int, QSize> m_sectionSizeHints;
DisassemblySettingsRef m_settings;
-private:
+ private:
void AddDisassemblyTokens(QList<QVariant>& line, std::vector<BinaryNinja::InstructionTextToken> tokens) const;
void TrimLeadingWhitespace(QList<QVariant>& line) const;
@@ -40,7 +40,7 @@ private:
QVariant GetDataColumn(const TagTypeRef& ref) const;
QVariant GetPreviewColumn(const TagTypeRef& ref) const;
-public:
+ public:
TagListModel(QWidget* parent, BinaryViewRef data);
BinaryNinja::TagReference& GetRef(const QModelIndex& index);
@@ -62,21 +62,22 @@ public:
virtual Qt::ItemFlags flags(const QModelIndex& i) const override;
virtual void sort(int column, Qt::SortOrder order) override;
- bool setModelData(const std::vector<std::pair<TagTypeRef, std::vector<BinaryNinja::TagReference>>>& refs, QItemSelectionModel* selectionModel, int sortColumn, Qt::SortOrder sortOrder, bool& selectionUpdated);
+ bool setModelData(const std::vector<std::pair<TagTypeRef, std::vector<BinaryNinja::TagReference>>>& refs,
+ QItemSelectionModel* selectionModel, int sortColumn, Qt::SortOrder sortOrder, bool& selectionUpdated);
};
-class BINARYNINJAUIAPI TagItemDelegate: public QStyledItemDelegate
+class BINARYNINJAUIAPI TagItemDelegate : public QStyledItemDelegate
{
Q_OBJECT
-protected:
+ protected:
QFont m_font, m_monospaceFont, m_emojiFont;
int m_baseline, m_charWidth, m_charHeight, m_charOffset;
void initFont();
-public:
+ public:
TagItemDelegate(QWidget* parent);
void updateFonts();
@@ -87,8 +88,7 @@ public:
};
-class BINARYNINJAUIAPI TagList: public QTreeView,
- public BinaryNinja::BinaryDataNotification, public FilterTarget
+class BINARYNINJAUIAPI TagList : public QTreeView, public BinaryNinja::BinaryDataNotification, public FilterTarget
{
Q_OBJECT
@@ -104,10 +104,10 @@ class BINARYNINJAUIAPI TagList: public QTreeView,
Menu* m_menu;
std::unordered_map<std::string, bool> m_expandedItems;
-public:
+ public:
typedef std::function<bool(const BinaryNinja::TagReference&)> FilterFn;
-private:
+ private:
bool m_hasFilter;
FilterFn m_filter;
std::string m_searchFilter;
@@ -120,13 +120,13 @@ private:
bool m_needsUpdate;
bool m_navToNextOrPrevStarted = false;
-protected:
+ protected:
virtual void contextMenuEvent(QContextMenuEvent* event) override;
virtual void keyPressEvent(QKeyEvent* e) override;
virtual void mouseMoveEvent(QMouseEvent* e) override;
virtual void mousePressEvent(QMouseEvent* e) override;
virtual void wheelEvent(QWheelEvent* e) override;
- virtual void resizeEvent(QResizeEvent *event) override;
+ virtual void resizeEvent(QResizeEvent* event) override;
void goToReference(const QModelIndex& idx);
void setFilter(const std::string& filter) override;
@@ -137,10 +137,10 @@ protected:
virtual void OnTagRemoved(BinaryNinja::BinaryView*, const BinaryNinja::TagReference&) override;
virtual void OnTagTypeUpdated(BinaryNinja::BinaryView*, TagTypeRef) override;
- virtual void showEvent(QShowEvent *event) override;
- virtual void hideEvent(QHideEvent *event) override;
+ virtual void showEvent(QShowEvent* event) override;
+ virtual void hideEvent(QHideEvent* event) override;
-private Q_SLOTS:
+ private Q_SLOTS:
void hoverTimerEvent();
void updateTimerEvent();
void referenceActivated(const QModelIndex& idx);
@@ -148,10 +148,10 @@ private Q_SLOTS:
void saveExpanded();
void restoreExpanded();
-public Q_SLOTS:
+ public Q_SLOTS:
void showContextMenu();
-public:
+ public:
TagList(QWidget* parent, ViewFrame* view, BinaryViewRef data, TagListModel* model = nullptr, Menu* menu = nullptr);
virtual ~TagList();
@@ -178,7 +178,7 @@ public:
};
-class BINARYNINJAUIAPI TagListWidget: public SidebarWidget
+class BINARYNINJAUIAPI TagListWidget : public SidebarWidget
{
Q_OBJECT
@@ -196,14 +196,14 @@ class BINARYNINJAUIAPI TagListWidget: public SidebarWidget
BinaryViewRef m_data;
UIActionHandler* m_handler;
-protected:
+ protected:
virtual void notifyFontChanged() override;
-private Q_SLOTS:
+ private Q_SLOTS:
void showContextMenu();
void onTabChanged(int which);
-public:
+ public:
TagList* GetList();
void editTag(TagRef tag);
TagList* getNotificationList() { return m_notificationList; }
@@ -217,14 +217,14 @@ public:
};
-class BINARYNINJAUIAPI TagListDialog: public QDialog
+class BINARYNINJAUIAPI TagListDialog : public QDialog
{
Q_OBJECT
-public:
+ public:
typedef std::function<void(const TagRef&)> AddFn;
-private:
+ private:
BinaryViewRef m_data;
TagList* m_list;
FilteredView* m_filter;
@@ -233,11 +233,11 @@ private:
QPushButton* m_removeButton;
-public:
+ public:
TagListDialog(QWidget* parent, ViewFrame* frame, BinaryViewRef data, AddFn addFn);
void setFilter(TagList::FilterFn filter);
-private Q_SLOTS:
+ private Q_SLOTS:
void updateActive(const QItemSelection&, const QItemSelection&);
void createTag();
void createTagAccept(TagTypeRef tt);
@@ -245,9 +245,9 @@ private Q_SLOTS:
};
-class BINARYNINJAUIAPI TagListSidebarWidgetType: public SidebarWidgetType
+class BINARYNINJAUIAPI TagListSidebarWidgetType : public SidebarWidgetType
{
-public:
+ public:
TagListSidebarWidgetType();
virtual SidebarWidget* createWidget(ViewFrame* frame, BinaryViewRef data) override;
};
diff --git a/ui/tagtypelist.h b/ui/tagtypelist.h
index d28dd5e8..b272113f 100644
--- a/ui/tagtypelist.h
+++ b/ui/tagtypelist.h
@@ -12,7 +12,7 @@
#define TAGS_UPDATE_CHECK_INTERVAL 200
-class BINARYNINJAUIAPI TagTypeListModel: public QAbstractItemModel, public BinaryNinja::BinaryDataNotification
+class BINARYNINJAUIAPI TagTypeListModel : public QAbstractItemModel, public BinaryNinja::BinaryDataNotification
{
Q_OBJECT
@@ -21,7 +21,7 @@ class BINARYNINJAUIAPI TagTypeListModel: public QAbstractItemModel, public Binar
std::vector<TagTypeRef> m_refs;
std::map<std::string, uint64_t> m_count;
-public:
+ public:
TagTypeListModel(QWidget* parent, BinaryViewRef data);
TagTypeRef& GetRef(int index) { return m_refs[index]; }
@@ -41,14 +41,15 @@ public:
virtual void OnTagAdded(BinaryNinja::BinaryView*, const BinaryNinja::TagReference&) override;
virtual void OnTagRemoved(BinaryNinja::BinaryView*, const BinaryNinja::TagReference&) override;
- bool setModelData(const std::vector<TagTypeRef>& refs, QItemSelectionModel* selectionModel, int sortColumn, Qt::SortOrder sortOrder, bool& selectionUpdated);
+ bool setModelData(const std::vector<TagTypeRef>& refs, QItemSelectionModel* selectionModel, int sortColumn,
+ Qt::SortOrder sortOrder, bool& selectionUpdated);
-Q_SIGNALS:
+ Q_SIGNALS:
void needRepaint();
};
-class BINARYNINJAUIAPI TagTypeItemDelegate: public QItemDelegate
+class BINARYNINJAUIAPI TagTypeItemDelegate : public QItemDelegate
{
Q_OBJECT
@@ -59,7 +60,7 @@ class BINARYNINJAUIAPI TagTypeItemDelegate: public QItemDelegate
void initFont();
-public:
+ public:
TagTypeItemDelegate(QWidget* parent);
void updateFonts();
@@ -67,11 +68,12 @@ public:
virtual QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& idx) const override;
virtual void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& idx) const override;
virtual void setEditorData(QWidget* editor, const QModelIndex& index) const override;
- virtual bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) override;
+ virtual bool editorEvent(QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option,
+ const QModelIndex& index) override;
};
-class BINARYNINJAUIAPI TagTypeList: public QTableView, public BinaryNinja::BinaryDataNotification
+class BINARYNINJAUIAPI TagTypeList : public QTableView, public BinaryNinja::BinaryDataNotification
{
Q_OBJECT
@@ -88,26 +90,26 @@ class BINARYNINJAUIAPI TagTypeList: public QTableView, public BinaryNinja::Binar
bool m_needsUpdate;
bool m_needsRepaint;
-protected:
+ protected:
virtual void contextMenuEvent(QContextMenuEvent* event) override;
- virtual void showEvent(QShowEvent *event) override;
- virtual void hideEvent(QHideEvent *event) override;
+ virtual void showEvent(QShowEvent* event) override;
+ virtual void hideEvent(QHideEvent* event) override;
virtual void OnTagTypeUpdated(BinaryNinja::BinaryView*, const TagTypeRef) override;
-private:
+ private:
void createTagType();
void removeTagType();
-private Q_SLOTS:
+ private Q_SLOTS:
void updateTimerEvent();
void needRepaint();
-public Q_SLOTS:
+ public Q_SLOTS:
void showContextMenu();
-public:
+ public:
TagTypeList(QWidget* parent, ViewFrame* view, BinaryViewRef data, Menu* menu = nullptr);
virtual ~TagTypeList();
void notifyFontChanged();
@@ -118,7 +120,7 @@ public:
bool hasSelection();
};
-class BINARYNINJAUIAPI TagTypeDialogModel: public QAbstractItemModel
+class BINARYNINJAUIAPI TagTypeDialogModel : public QAbstractItemModel
{
Q_OBJECT
@@ -126,7 +128,7 @@ class BINARYNINJAUIAPI TagTypeDialogModel: public QAbstractItemModel
BinaryViewRef m_data;
std::vector<TagTypeRef> m_refs;
-public:
+ public:
TagTypeDialogModel(QWidget* parent, BinaryViewRef data);
TagTypeRef& GetRef(int index) { return m_refs[index]; }
@@ -140,7 +142,7 @@ public:
virtual QVariant data(const QModelIndex& i, int role) const override;
};
-class BINARYNINJAUIAPI TagTypeSelectDialog: public QDialog
+class BINARYNINJAUIAPI TagTypeSelectDialog : public QDialog
{
Q_OBJECT
@@ -148,12 +150,12 @@ class BINARYNINJAUIAPI TagTypeSelectDialog: public QDialog
TagTypeDialogModel* m_model;
QComboBox* m_tagTypeList;
-private Q_SLOTS:
+ private Q_SLOTS:
void select();
-public:
+ public:
TagTypeSelectDialog(QWidget* parent, BinaryViewRef data);
-Q_SIGNALS:
+ Q_SIGNALS:
void selected(TagTypeRef tagType);
};
diff --git a/ui/textbrowser.h b/ui/textbrowser.h
index 9d4d33c3..d58a0c2f 100644
--- a/ui/textbrowser.h
+++ b/ui/textbrowser.h
@@ -23,7 +23,7 @@ class BINARYNINJAUIAPI TextBrowserDownloadCache
std::map<QUrl, QByteArray> m_downloadCache;
std::set<QUrl> m_inProgress;
-public:
+ public:
TextBrowserDownloadCache();
bool lookup(const QUrl& url, QByteArray& result);
@@ -34,7 +34,7 @@ public:
bool isInProgress(const QUrl& url);
};
-class TextBrowserDownloadQueue: public QObject
+class TextBrowserDownloadQueue : public QObject
{
Q_OBJECT
@@ -48,7 +48,7 @@ class TextBrowserDownloadQueue: public QObject
static uint64_t AppendDataCallback(uint8_t* data, uint64_t len, void* ctxt);
-public:
+ public:
TextBrowserDownloadQueue(TextBrowser* owner);
void stop();
@@ -56,11 +56,11 @@ public:
bool processNextEvent(BinaryNinja::DownloadInstance* downloadInstance);
void downloadData(const QUrl& name);
-Q_SIGNALS:
+ Q_SIGNALS:
void dataDownloaded(QUrl name, QByteArray contents);
};
-class TextBrowserDownloadThread: public QThread
+class TextBrowserDownloadThread : public QThread
{
Q_OBJECT
@@ -70,14 +70,14 @@ class TextBrowserDownloadThread: public QThread
BinaryNinja::Ref<BinaryNinja::DownloadProvider> m_provider;
BinaryNinja::Ref<BinaryNinja::DownloadInstance> m_downloadInstance;
-protected:
+ protected:
virtual void run() override;
-public:
+ public:
TextBrowserDownloadThread(TextBrowserDownloadQueue* queue);
};
-class BINARYNINJAUIAPI TextBrowser: public QTextBrowser
+class BINARYNINJAUIAPI TextBrowser : public QTextBrowser
{
Q_OBJECT
@@ -91,24 +91,24 @@ class BINARYNINJAUIAPI TextBrowser: public QTextBrowser
std::optional<QUrl> m_markdownUrl;
QString m_markdownPrefix;
- void resizeImageFragment(QTextBlock& block, QTextFragment fragment,
- QTextImageFormat imgFormat, const QImage& contents);
+ void resizeImageFragment(
+ QTextBlock& block, QTextFragment fragment, QTextImageFormat imgFormat, const QImage& contents);
-protected:
+ protected:
virtual void resizeEvent(QResizeEvent* e) override;
-public:
+ public:
TextBrowser(QSharedPointer<TextBrowserDownloadCache> cache = QSharedPointer<TextBrowserDownloadCache>());
virtual ~TextBrowser();
void reset();
- virtual QVariant loadResource(int type, const QUrl &name) override;
+ virtual QVariant loadResource(int type, const QUrl& name) override;
void resizeImagesToWidth();
QSharedPointer<TextBrowserDownloadCache> cache() { return m_cache; }
void downloadMarkdown(QUrl url, QString prefix = QString());
-private Q_SLOTS:
+ private Q_SLOTS:
void dataDownloaded(QUrl name, QByteArray contents);
};
diff --git a/ui/textdialog.h b/ui/textdialog.h
index dc8ad03b..81750bf9 100644
--- a/ui/textdialog.h
+++ b/ui/textdialog.h
@@ -8,7 +8,7 @@
#include "uitypes.h"
#include "binaryninjaapi.h"
-class BINARYNINJAUIAPI TextDialog: public QDialog
+class BINARYNINJAUIAPI TextDialog : public QDialog
{
Q_OBJECT
QString m_qSettingsListName;
@@ -19,11 +19,11 @@ class BINARYNINJAUIAPI TextDialog: public QDialog
QLabel* m_messageText;
QComboBox* m_combo;
-public:
+ public:
TextDialog(QWidget* parent, const QString& title, const QString& msg, const QString& qSettingsListName,
- const std::string& initialText = "");
+ const std::string& initialText = "");
TextDialog(QWidget* parent, const QString& title, const QString& msg, const QString& qSettingsListName,
- const QString& initialText);
+ const QString& initialText);
QString getItem();
void setInitialText(const std::string& initialText) { m_initialText = QString::fromStdString(initialText); }
void commitHistory();
diff --git a/ui/theme.h b/ui/theme.h
index b4c1ead5..5b1e5253 100644
--- a/ui/theme.h
+++ b/ui/theme.h
@@ -6,15 +6,15 @@
#include "binaryninjaapi.h"
#include "uicontext.h"
-class BINARYNINJAUIAPI CustomFusionStyle: public QProxyStyle
+class BINARYNINJAUIAPI CustomFusionStyle : public QProxyStyle
{
-public:
+ public:
CustomFusionStyle(QStyle* parent);
virtual int pixelMetric(PixelMetric metric, const QStyleOption* option, const QWidget* widget) const override;
- virtual QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption* option,
- const QWidget* widget) const override;
- virtual QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption* option,
- const QWidget* widget) const override;
+ virtual QIcon standardIcon(
+ StandardPixmap standardIcon, const QStyleOption* option, const QWidget* widget) const override;
+ virtual QPixmap standardPixmap(
+ StandardPixmap standardPixmap, const QStyleOption* option, const QWidget* widget) const override;
};
diff --git a/ui/tokenizedtextview.h b/ui/tokenizedtextview.h
index 6424e6e4..5132a476 100644
--- a/ui/tokenizedtextview.h
+++ b/ui/tokenizedtextview.h
@@ -9,12 +9,12 @@
#include "menus.h"
#include "uicontext.h"
-class BINARYNINJAUIAPI TokenizedTextViewHistoryEntry: public HistoryEntry
+class BINARYNINJAUIAPI TokenizedTextViewHistoryEntry : public HistoryEntry
{
size_t m_topLine, m_cursorLine;
HighlightTokenState m_highlight;
-public:
+ public:
size_t getTopLine() const { return m_topLine; }
size_t getCursorLine() const { return m_cursorLine; }
const HighlightTokenState& getHighlightTokenState() const { return m_highlight; }
@@ -27,7 +27,10 @@ public:
virtual bool deserialize(const Json::Value& value) override;
};
-class BINARYNINJAUIAPI TokenizedTextView: public QAbstractScrollArea, public View, public BinaryNinja::BinaryDataNotification
+class BINARYNINJAUIAPI TokenizedTextView :
+ public QAbstractScrollArea,
+ public View,
+ public BinaryNinja::BinaryDataNotification
{
Q_OBJECT
@@ -59,8 +62,8 @@ class BINARYNINJAUIAPI TokenizedTextView: public QAbstractScrollArea, public Vie
void scrollLines(int count);
void bindActions();
- void getHexDumpLineBytes(const BinaryNinja::LinearDisassemblyLine& line, size_t& skippedBytes, size_t& totalBytes,
- size_t& totalCols);
+ void getHexDumpLineBytes(
+ const BinaryNinja::LinearDisassemblyLine& line, size_t& skippedBytes, size_t& totalBytes, size_t& totalCols);
void setSectionSemantics(const std::string& name, BNSectionSemantics semantics);
@@ -110,14 +113,15 @@ class BINARYNINJAUIAPI TokenizedTextView: public QAbstractScrollArea, public Vie
void setInstructionHighlight(BNHighlightColor color);
void setBlockHighlight(BNHighlightColor color);
-private Q_SLOTS:
+ private Q_SLOTS:
void scrollBarMoved(int value);
void scrollBarAction(int action);
void updateTimerEvent();
-public:
+ public:
explicit TokenizedTextView(QWidget* parent, BinaryViewRef data,
- const std::vector<BinaryNinja::LinearDisassemblyLine>& lines = std::vector<BinaryNinja::LinearDisassemblyLine>());
+ const std::vector<BinaryNinja::LinearDisassemblyLine>& lines =
+ std::vector<BinaryNinja::LinearDisassemblyLine>());
virtual ~TokenizedTextView();
virtual BinaryViewRef getData() override { return m_data; }
@@ -168,7 +172,7 @@ public:
void setFunction(FunctionRef func);
-protected:
+ protected:
virtual void resizeEvent(QResizeEvent* event) override;
virtual void paintEvent(QPaintEvent* event) override;
virtual void wheelEvent(QWheelEvent* event) override;
diff --git a/ui/transformparam.h b/ui/transformparam.h
index 042a38c3..5c67650a 100644
--- a/ui/transformparam.h
+++ b/ui/transformparam.h
@@ -4,15 +4,15 @@
#include "binaryninjaapi.h"
#include "uicontext.h"
-class BINARYNINJAUIAPI TransformParameterDialog: public QDialog
+class BINARYNINJAUIAPI TransformParameterDialog : public QDialog
{
Q_OBJECT
std::vector<BinaryNinja::TransformParameter> m_params;
std::map<std::string, BinaryDataRef> m_paramData;
-public:
- TransformParameterDialog(QWidget* parent, TransformRef xform,
- const std::vector<BinaryNinja::TransformParameter>& params);
+ public:
+ TransformParameterDialog(
+ QWidget* parent, TransformRef xform, const std::vector<BinaryNinja::TransformParameter>& params);
std::map<std::string, BinaryNinja::DataBuffer> getParameterData();
};
diff --git a/ui/typedialog.h b/ui/typedialog.h
index 76931d13..2f171b21 100644
--- a/ui/typedialog.h
+++ b/ui/typedialog.h
@@ -6,7 +6,7 @@
#include <QtWidgets/QComboBox>
#include <QtCore/QTimer>
#ifndef BINARYNINJAUI_BINDINGS
-#include <QtCore/QThread>
+ #include <QtCore/QThread>
#endif
#include "binaryninjaapi.h"
#include "uitypes.h"
@@ -17,7 +17,7 @@
class GetTypesListThread;
class ParseTypeThread;
#else
-class BINARYNINJAUIAPI GetTypesListThread: public QThread
+class BINARYNINJAUIAPI GetTypesListThread : public QThread
{
Q_OBJECT
@@ -27,10 +27,10 @@ class BINARYNINJAUIAPI GetTypesListThread: public QThread
bool m_done;
BinaryViewRef m_view;
-protected:
+ protected:
virtual void run() override;
-public:
+ public:
GetTypesListThread(BinaryViewRef view, const std::function<void()>& completeFunc);
void cancel();
@@ -40,7 +40,8 @@ public:
Q_DECLARE_METATYPE(BinaryNinja::QualifiedNameAndType);
//! QThread subclass for handling type string parsing to avoid UI interruptions.
-class ParseTypeThread: public QThread {
+class ParseTypeThread : public QThread
+{
Q_OBJECT
BinaryViewRef m_view;
@@ -48,16 +49,16 @@ class ParseTypeThread: public QThread {
void run() override;
-Q_SIGNALS:
+ Q_SIGNALS:
void parsingComplete(bool valid, BinaryNinja::QualifiedNameAndType type, QString error);
-public:
+ public:
ParseTypeThread(BinaryViewRef view, QString text);
void cancel();
};
#endif
-class BINARYNINJAUIAPI TypeDialog: public QDialog
+class BINARYNINJAUIAPI TypeDialog : public QDialog
{
Q_OBJECT
@@ -84,15 +85,15 @@ class BINARYNINJAUIAPI TypeDialog: public QDialog
void commitHistory();
void customEvent(QEvent* event);
-private Q_SLOTS:
+ private Q_SLOTS:
void accepted();
void checkParse();
void typeParsed(bool valid, BinaryNinja::QualifiedNameAndType type, QString error);
void updateTimerEvent();
-public:
+ public:
TypeDialog(QWidget* parent, BinaryViewRef view, const QString& title = "Specify Type",
- const QString& prompt = "Enter Type Name", const QString& existing="");
+ const QString& prompt = "Enter Type Name", const QString& existing = "");
~TypeDialog() { delete m_updateThread; }
BinaryNinja::QualifiedNameAndType getType() const { return m_type; }
};
diff --git a/ui/typeview.h b/ui/typeview.h
index 527e35cf..3a7e744b 100644
--- a/ui/typeview.h
+++ b/ui/typeview.h
@@ -3,9 +3,9 @@
#include <QtWidgets/QAbstractScrollArea>
#include <QtWidgets/QComboBox>
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
-#include <QtWidgets/QAction>
+ #include <QtWidgets/QAction>
#else
-#include <QtGui/QAction>
+ #include <QtGui/QAction>
#endif
#include <QtCore/QTimer>
#include <string>
@@ -63,7 +63,7 @@ struct BINARYNINJAUIAPI TypeDefinitionLinesAndFilterStatus
};
-class BINARYNINJAUIAPI TypeViewHistoryEntry: public HistoryEntry
+class BINARYNINJAUIAPI TypeViewHistoryEntry : public HistoryEntry
{
BinaryNinja::QualifiedName m_cursorType;
size_t m_cursorLine;
@@ -74,7 +74,7 @@ class BINARYNINJAUIAPI TypeViewHistoryEntry: public HistoryEntry
size_t m_selectionStartOffset;
HighlightTokenState m_highlight;
-public:
+ public:
const BinaryNinja::QualifiedName& getCursorType() const { return m_cursorType; }
size_t getCursorLine() const { return m_cursorLine; }
size_t getCursorOffset() const { return m_cursorOffset; }
@@ -103,7 +103,7 @@ public:
class TypesContainer;
-class BINARYNINJAUIAPI TypeView: public QAbstractScrollArea, public View, public BinaryNinja::BinaryDataNotification
+class BINARYNINJAUIAPI TypeView : public QAbstractScrollArea, public View, public BinaryNinja::BinaryDataNotification
{
Q_OBJECT
@@ -189,22 +189,23 @@ class BINARYNINJAUIAPI TypeView: public QAbstractScrollArea, public View, public
void goToAddress(bool selecting);
void moveCursorToMouse(QMouseEvent* event, bool selecting);
- void createNewTypes(const QString& definition = "", const std::set<BinaryNinja::QualifiedName>& typesAllowRedefinition = {});
+ void createNewTypes(
+ const QString& definition = "", const std::set<BinaryNinja::QualifiedName>& typesAllowRedefinition = {});
void bindActions();
void checkForValidSelection();
static TypeDefinitionLine getTypeDefinitionHeaderLine(PlatformRef platform, const std::string& name, TypeRef type);
-public:
+ public:
explicit TypeView(BinaryViewRef data, ViewFrame* view, TypesContainer* container, bool compact = false);
virtual ~TypeView();
- virtual bool findNextData(uint64_t start, uint64_t end, const BinaryNinja::DataBuffer& data, uint64_t& addr, BNFindFlag flags,
- const std::function<bool (size_t current, size_t total)>& cb) override;
+ virtual bool findNextData(uint64_t start, uint64_t end, const BinaryNinja::DataBuffer& data, uint64_t& addr,
+ BNFindFlag flags, const std::function<bool(size_t current, size_t total)>& cb) override;
virtual bool findNextText(uint64_t start, uint64_t end, const std::string& text, uint64_t& addr,
- DisassemblySettingsRef settings, BNFindFlag flags, BNFunctionGraphType graph,
- const std::function<bool (size_t current, size_t total)>& cb) override;
+ DisassemblySettingsRef settings, BNFindFlag flags, BNFunctionGraphType graph,
+ const std::function<bool(size_t current, size_t total)>& cb) override;
virtual BinaryViewRef getData() override { return m_data; }
virtual uint64_t getCurrentOffset() override;
virtual BNAddressRange getSelectionOffsets() override;
@@ -216,20 +217,23 @@ public:
virtual void setNavigationMode(std::string mode) override;
virtual std::vector<std::string> getNavigationModes() override;
- uint64_t findMatchingLine(const BinaryNinja::QualifiedName& name, uint64_t offset,
- size_t& cursorOffset);
+ uint64_t findMatchingLine(const BinaryNinja::QualifiedName& name, uint64_t offset, size_t& cursorOffset);
bool navigateToType(const std::string& name, uint64_t offset = 0);
- virtual void OnTypeDefined(BinaryNinja::BinaryView* view, const BinaryNinja::QualifiedName& name,
- BinaryNinja::Type* type) override;
- virtual void OnTypeUndefined(BinaryNinja::BinaryView* view, const BinaryNinja::QualifiedName& name,
- BinaryNinja::Type* type) override;
- virtual void OnTypeReferenceChanged(BinaryNinja::BinaryView* view, const BinaryNinja::QualifiedName& name,
- BinaryNinja::Type* type) override;
- virtual void OnTypeFieldReferenceChanged(BinaryNinja::BinaryView* view, const BinaryNinja::QualifiedName& name,
- uint64_t offset) override;
+ virtual void OnTypeDefined(
+ BinaryNinja::BinaryView* view, const BinaryNinja::QualifiedName& name, BinaryNinja::Type* type) override;
+ virtual void OnTypeUndefined(
+ BinaryNinja::BinaryView* view, const BinaryNinja::QualifiedName& name, BinaryNinja::Type* type) override;
+ virtual void OnTypeReferenceChanged(
+ BinaryNinja::BinaryView* view, const BinaryNinja::QualifiedName& name, BinaryNinja::Type* type) override;
+ virtual void OnTypeFieldReferenceChanged(
+ BinaryNinja::BinaryView* view, const BinaryNinja::QualifiedName& name, uint64_t offset) override;
- void MarkFilterChanged() { m_updatesRequired = true; m_filterChanged = true; }
+ void MarkFilterChanged()
+ {
+ m_updatesRequired = true;
+ m_filterChanged = true;
+ }
void MarkTypeChanged(const BinaryNinja::QualifiedName& typeName);
virtual void updateFonts() override;
@@ -238,7 +242,7 @@ public:
virtual BinaryNinja::Ref<HistoryEntry> getHistoryEntry() override;
virtual void navigateToHistoryEntry(BinaryNinja::Ref<HistoryEntry> entry) override;
- void lineNumberAreaPaintEvent(QPaintEvent *event);
+ void lineNumberAreaPaintEvent(QPaintEvent* event);
int lineNumberAreaWidth();
virtual bool canCut() override { return false; }
@@ -258,10 +262,12 @@ public:
virtual ArchitectureRef getOrAskForArchitecture();
- bool isTypeCollapsed(const std::string& name) const { return m_collapsedTypes.find(name) != m_collapsedTypes.end(); }
- static std::vector<TypeDefinitionLine> getLinesForType(const std::string& name,
- const std::string& varName, size_t index, TypeRef type, TypeRef parent, BinaryViewRef data,
- int paddingCols, bool collapsed = false);
+ bool isTypeCollapsed(const std::string& name) const
+ {
+ return m_collapsedTypes.find(name) != m_collapsedTypes.end();
+ }
+ static std::vector<TypeDefinitionLine> getLinesForType(const std::string& name, const std::string& varName,
+ size_t index, TypeRef type, TypeRef parent, BinaryViewRef data, int paddingCols, bool collapsed = false);
void showContextMenu(Menu* source = nullptr);
@@ -271,7 +277,7 @@ public:
bool isTypeTextFiltered(const std::string& name) const;
-protected:
+ protected:
virtual void resizeEvent(QResizeEvent* event) override;
virtual void paintEvent(QPaintEvent* event) override;
virtual void mousePressEvent(QMouseEvent* event) override;
@@ -279,7 +285,7 @@ protected:
virtual void mouseDoubleClickEvent(QMouseEvent* event) override;
virtual void scrollContentsBy(int dx, int dy) override;
-private Q_SLOTS:
+ private Q_SLOTS:
void copySelection();
void selectAll();
void updateTimerEvent();
@@ -309,23 +315,23 @@ private Q_SLOTS:
class BINARYNINJAUIAPI LineNumberArea : public QWidget
{
-public:
- LineNumberArea(TypeView *editor) : QWidget(editor), m_typeEditor(editor) { }
+ public:
+ LineNumberArea(TypeView* editor) : QWidget(editor), m_typeEditor(editor) {}
QSize sizeHint() const override { return QSize(m_typeEditor->lineNumberAreaWidth(), 0); }
-protected:
- void paintEvent(QPaintEvent *event) override { m_typeEditor->lineNumberAreaPaintEvent(event); }
+ protected:
+ void paintEvent(QPaintEvent* event) override { m_typeEditor->lineNumberAreaPaintEvent(event); }
-private:
+ private:
TypeView* m_typeEditor;
};
-class TypeViewType: public ViewType
+class TypeViewType : public ViewType
{
static TypeViewType* m_instance;
-public:
+ public:
TypeViewType();
virtual int getPriority(BinaryViewRef data, const QString& filename) override;
virtual QWidget* create(BinaryViewRef data, ViewFrame* viewFrame) override;
@@ -333,22 +339,22 @@ public:
};
-class BINARYNINJAUIAPI TypeFilterEdit: public QLineEdit
+class BINARYNINJAUIAPI TypeFilterEdit : public QLineEdit
{
Q_OBJECT
-public:
+ public:
TypeFilterEdit(QWidget* parent);
-protected:
+ protected:
virtual void keyPressEvent(QKeyEvent* event) override;
-Q_SIGNALS:
+ Q_SIGNALS:
void focusView();
};
-class BINARYNINJAUIAPI TypeFilter: public QWidget
+class BINARYNINJAUIAPI TypeFilter : public QWidget
{
Q_OBJECT
@@ -359,18 +365,18 @@ class BINARYNINJAUIAPI TypeFilter: public QWidget
bool MatchesAutoFilter(BinaryViewRef data, const BinaryNinja::QualifiedName& name);
bool MatchesTextFilter(const std::vector<TypeDefinitionLine>& lines);
-Q_SIGNALS:
+ Q_SIGNALS:
void filterChanged();
-private Q_SLOTS:
+ private Q_SLOTS:
void focusView();
-public:
+ public:
TypeFilter(TypesContainer* container = nullptr);
void setContainer(TypesContainer* container) { m_container = container; }
- TypeLinesFilteredReason checkTypeLinesForFilter(BinaryViewRef data, const BinaryNinja::QualifiedName& name,
- const std::vector<TypeDefinitionLine>& lines);
+ TypeLinesFilteredReason checkTypeLinesForFilter(
+ BinaryViewRef data, const BinaryNinja::QualifiedName& name, const std::vector<TypeDefinitionLine>& lines);
void showAndFocus();
bool areAutoTypesVisible();
void setShowAutoTypes(bool showAutoTypes);
@@ -378,7 +384,7 @@ public:
};
-class BINARYNINJAUIAPI TypesContainer: public QWidget, public ViewContainer
+class BINARYNINJAUIAPI TypesContainer : public QWidget, public ViewContainer
{
Q_OBJECT
@@ -386,9 +392,8 @@ class BINARYNINJAUIAPI TypesContainer: public QWidget, public ViewContainer
TypeFilter* m_typeFilter;
UIActionHandler m_actionHandler;
-public:
- TypesContainer(BinaryViewRef data, ViewFrame* view,
- TypeFilter* filter = nullptr, bool compact = false);
+ public:
+ TypesContainer(BinaryViewRef data, ViewFrame* view, TypeFilter* filter = nullptr, bool compact = false);
virtual View* getView() override { return m_typeView; }
TypeView* getTypesView() { return m_typeView; }
@@ -396,12 +401,12 @@ public:
bool navigateToType(const std::string& name, uint64_t offset = 0);
-protected:
+ protected:
virtual void focusInEvent(QFocusEvent* event) override;
};
-class BINARYNINJAUIAPI TypeViewSidebarWidget: public SidebarWidget
+class BINARYNINJAUIAPI TypeViewSidebarWidget : public SidebarWidget
{
Q_OBJECT
@@ -409,7 +414,7 @@ class BINARYNINJAUIAPI TypeViewSidebarWidget: public SidebarWidget
QWidget* m_header;
Menu m_addMenu;
-public:
+ public:
TypeViewSidebarWidget(BinaryViewRef data, ViewFrame* frame);
TypesContainer* container() const { return m_container; }
@@ -417,14 +422,14 @@ public:
virtual QWidget* headerWidget() override { return m_header; }
-private Q_SLOTS:
+ private Q_SLOTS:
void showAddMenu();
};
-class BINARYNINJAUIAPI TypeViewSidebarWidgetType: public SidebarWidgetType
+class BINARYNINJAUIAPI TypeViewSidebarWidgetType : public SidebarWidgetType
{
-public:
+ public:
TypeViewSidebarWidgetType();
virtual SidebarWidget* createWidget(ViewFrame* frame, BinaryViewRef data) override;
};
diff --git a/ui/uicomment.h b/ui/uicomment.h
index 1ed71af7..d80444ec 100644
--- a/ui/uicomment.h
+++ b/ui/uicomment.h
@@ -13,7 +13,7 @@ typedef enum
class UIComment
{
-public:
+ public:
UICommentType type;
FunctionRef func;
BinaryViewRef data;
@@ -21,21 +21,13 @@ public:
QString content;
- UIComment(UICommentType type,
- FunctionRef func,
- uint64_t address,
- QString content):
- type(type), func(func),
- address(address), content(content)
+ UIComment(UICommentType type, FunctionRef func, uint64_t address, QString content) :
+ type(type), func(func), address(address), content(content)
{}
- UIComment(UICommentType type,
- BinaryViewRef data,
- uint64_t address,
- QString content):
- type(type), data(data),
- address(address), content(content)
+ UIComment(UICommentType type, BinaryViewRef data, uint64_t address, QString content) :
+ type(type), data(data), address(address), content(content)
{}
diff --git a/ui/uicontext.h b/ui/uicontext.h
index cb9a5391..44c1e53d 100644
--- a/ui/uicontext.h
+++ b/ui/uicontext.h
@@ -30,7 +30,7 @@ struct SelectionInfoForXref;
*/
class BINARYNINJAUIAPI UIContextNotification
{
-public:
+ public:
/*!
Callback after a UIContext is opened (eg MainWindow)
\param context Opened context
@@ -48,7 +48,12 @@ public:
\param metadata Object with info about the database file
\return True if the database should be opened
*/
- virtual bool OnBeforeOpenDatabase(UIContext* context, FileMetadataRef metadata) { (void)context; (void)metadata; return true; }
+ virtual bool OnBeforeOpenDatabase(UIContext* context, FileMetadataRef metadata)
+ {
+ (void)context;
+ (void)metadata;
+ return true;
+ }
/*!
Callback after a database (specifically a database, not a raw file) is opened
\param context Context which opened the database
@@ -56,21 +61,37 @@ public:
\param data Raw data which is backed by the database
\return True if the database should be opened
*/
- virtual bool OnAfterOpenDatabase(UIContext* context, FileMetadataRef metadata, BinaryViewRef data) { (void)context; (void)metadata; (void)data; return true; }
+ virtual bool OnAfterOpenDatabase(UIContext* context, FileMetadataRef metadata, BinaryViewRef data)
+ {
+ (void)context;
+ (void)metadata;
+ (void)data;
+ return true;
+ }
/*!
Callback before a file (raw or database) is opened (after OnAfterOpenDatabase if opening a database)
\param context Context opening the file
\param file Context with the file and ui views
\return True if the file should be opened
*/
- virtual bool OnBeforeOpenFile(UIContext* context, FileContext* file) { (void)context; (void)file; return true; }
+ virtual bool OnBeforeOpenFile(UIContext* context, FileContext* file)
+ {
+ (void)context;
+ (void)file;
+ return true;
+ }
/*!
Callback after a file (raw or database) is opened
\param context Context which opened the file
\param file Context with the file and ui views
\param frame ViewFrame constructed to display the file
*/
- virtual void OnAfterOpenFile(UIContext* context, FileContext* file, ViewFrame* frame) { (void)context; (void)file; (void)frame; }
+ virtual void OnAfterOpenFile(UIContext* context, FileContext* file, ViewFrame* frame)
+ {
+ (void)context;
+ (void)file;
+ (void)frame;
+ }
/*!
Callback before a file is saved (either as a database or raw)
\param context Context which is saving the file
@@ -78,14 +99,25 @@ public:
\param frame ViewFrame for the file
\return True if the file should be saved
*/
- virtual bool OnBeforeSaveFile(UIContext* context, FileContext* file, ViewFrame* frame) { (void)context; (void)file; (void)frame; return true; }
+ virtual bool OnBeforeSaveFile(UIContext* context, FileContext* file, ViewFrame* frame)
+ {
+ (void)context;
+ (void)file;
+ (void)frame;
+ return true;
+ }
/*!
Callback after a file is saved (either as a database or raw)
\param context Context which saved the file
\param file Context with the file and ui views
\param frame ViewFrame for the file
*/
- virtual void OnAfterSaveFile(UIContext* context, FileContext* file, ViewFrame* frame) { (void)context; (void)file; (void)frame; }
+ virtual void OnAfterSaveFile(UIContext* context, FileContext* file, ViewFrame* frame)
+ {
+ (void)context;
+ (void)file;
+ (void)frame;
+ }
/*!
Callback before a file is closed
\param context Context which is closing the file
@@ -93,14 +125,25 @@ public:
\param frame ViewFrame for the file
\return True if the file should be closed
*/
- virtual bool OnBeforeCloseFile(UIContext* context, FileContext* file, ViewFrame* frame) { (void)context; (void)file; (void)frame; return true; }
+ virtual bool OnBeforeCloseFile(UIContext* context, FileContext* file, ViewFrame* frame)
+ {
+ (void)context;
+ (void)file;
+ (void)frame;
+ return true;
+ }
/*!
Callback after a file is closed
\param context Context which closed the file
\param file Context with the file and ui views
\param frame ViewFrame which former showed the file (will be deleted after this)
*/
- virtual void OnAfterCloseFile(UIContext* context, FileContext* file, ViewFrame* frame) { (void)context; (void)file; (void)frame; }
+ virtual void OnAfterCloseFile(UIContext* context, FileContext* file, ViewFrame* frame)
+ {
+ (void)context;
+ (void)file;
+ (void)frame;
+ }
/*!
Callback when the ui changes views
@@ -108,7 +151,12 @@ public:
\param frame ViewFrame which changed views
\param type New view name
*/
- virtual void OnViewChange(UIContext* context, ViewFrame* frame, const QString& type) { (void)context; (void)frame; (void)type; }
+ virtual void OnViewChange(UIContext* context, ViewFrame* frame, const QString& type)
+ {
+ (void)context;
+ (void)frame;
+ (void)type;
+ }
/*!
Callback when the ui changes address
\param context Context changing address
@@ -116,26 +164,44 @@ public:
\param view Currently open View
\param location New location
*/
- virtual void OnAddressChange(UIContext* context, ViewFrame* frame, View* view, const ViewLocation& location) { (void)context; (void)frame; (void)view; (void)location; }
+ virtual void OnAddressChange(UIContext* context, ViewFrame* frame, View* view, const ViewLocation& location)
+ {
+ (void)context;
+ (void)frame;
+ (void)view;
+ (void)location;
+ }
/*!
Callback to modify the displayed file name for a FileContext (eg in the window title or tab title)
Note: Due to the out param &name, this is not usable from Python with PySide
- \param context Context which will display this name
+ \param context Context which will display this name
\param file File whose name to get
\param name [Out] Name to be displayed
\return True if the value in name should be used
*/
- virtual bool GetNameForFile(UIContext* context, FileContext* file, QString& name) { (void)context; (void)file; (void)name; return false; }
+ virtual bool GetNameForFile(UIContext* context, FileContext* file, QString& name)
+ {
+ (void)context;
+ (void)file;
+ (void)name;
+ return false;
+ }
/*!
Callback to modify the displayed file name for a file path (eg in the new tab widget)
Note: Due to the out param &name, this is not usable from Python with PySide
- \param context Context which will display this name
+ \param context Context which will display this name
\param path Path to file whose name to get
\param name [Out] Name to be displayed
\return True if the value in name should be used
*/
- virtual bool GetNameForPath(UIContext* context, const QString& path, QString& name) { (void)context; (void)path; (void)name; return false; }
+ virtual bool GetNameForPath(UIContext* context, const QString& path, QString& name)
+ {
+ (void)context;
+ (void)path;
+ (void)name;
+ return false;
+ }
/*!
Callback when the ui changes selection and should update cross references
@@ -144,12 +210,19 @@ public:
\param view View that changed selection
\param selection New selection
*/
- virtual void OnNewSelectionForXref(UIContext* context, ViewFrame* frame, View* view, const SelectionInfoForXref& selection) { (void)context; (void)frame; (void)view; (void)selection; }
+ virtual void OnNewSelectionForXref(
+ UIContext* context, ViewFrame* frame, View* view, const SelectionInfoForXref& selection)
+ {
+ (void)context;
+ (void)frame;
+ (void)view;
+ (void)selection;
+ }
};
class BINARYNINJAUIAPI UIContextHandler
{
-public:
+ public:
virtual ~UIContextHandler();
virtual void updateStatus() = 0;
virtual void notifyThemeChanged() = 0;
@@ -165,7 +238,7 @@ class BINARYNINJAUIAPI UIContext
static QPointer<PreviewWidget> m_currentPreview;
-protected:
+ protected:
void setupUIContext(QWidget* obj);
void NotifyOnContextOpen();
@@ -184,7 +257,7 @@ protected:
void NotifyOnAddressChange(ViewFrame* frame, View* view, const ViewLocation& location);
void NotifyOnNewSelectionForXref(ViewFrame* frame, View* view, const SelectionInfoForXref& selection);
-public:
+ public:
UIContext();
virtual ~UIContext();
@@ -223,7 +296,7 @@ public:
/*!
Open a new pane in the active tab
\param pane Pane widget to open
- \param primaryDirection Primary axis for content in pane (determines default split direction)
+ \param primaryDirection Primary axis for content in pane (determines default split direction)
*/
virtual void openPane(Pane* pane, Qt::Orientation primaryDirection = Qt::Vertical) = 0;
/*!
@@ -257,7 +330,7 @@ public:
/*!
Close the tab with the given QWidget
\param tab QWidget which is in a tab
- \param closeWindowIfLast If false, displays the new tab page if the widget was the last tab
+ \param closeWindowIfLast If false, displays the new tab page if the widget was the last tab
*/
virtual void closeTab(QWidget* tab, bool closeWindowIfLast = false) = 0;
/*!
diff --git a/ui/uitypes.h b/ui/uitypes.h
index 3ed27da8..62111001 100644
--- a/ui/uitypes.h
+++ b/ui/uitypes.h
@@ -16,44 +16,41 @@
#define BN_MINIMUM_UI_ABI_VERSION 4
#ifdef __GNUC__
-# ifdef BINARYNINJAUI_LIBRARY
-# define BINARYNINJAUIAPI __attribute__((visibility("default")))
-# else
-# define BINARYNINJAUIAPI
-# endif
+ #ifdef BINARYNINJAUI_LIBRARY
+ #define BINARYNINJAUIAPI __attribute__((visibility("default")))
+ #else
+ #define BINARYNINJAUIAPI
+ #endif
#else
-#ifdef _MSC_VER
-# ifndef DEMO_VERSION
-# ifdef BINARYNINJAUI_LIBRARY
-# define BINARYNINJAUIAPI __declspec(dllexport)
-# else
-# define BINARYNINJAUIAPI __declspec(dllimport)
-# endif
-# else
-# define BINARYNINJAUIAPI
-# endif
-#else
-#define BINARYNINJAUIAPI
-#endif
+ #ifdef _MSC_VER
+ #ifndef DEMO_VERSION
+ #ifdef BINARYNINJAUI_LIBRARY
+ #define BINARYNINJAUIAPI __declspec(dllexport)
+ #else
+ #define BINARYNINJAUIAPI __declspec(dllimport)
+ #endif
+ #else
+ #define BINARYNINJAUIAPI
+ #endif
+ #else
+ #define BINARYNINJAUIAPI
+ #endif
#endif
#ifdef BINARYNINJAUI_PYTHON_BINDINGS
-#include "bindings.h"
+ #include "bindings.h"
#endif
// The BN_DECLARE_UI_ABI_VERSION must be included in native UI plugin modules. If
// the ABI version is not declared, the UI will not load the plugin.
#ifdef DEMO_VERSION
-#define BN_DECLARE_UI_ABI_VERSION
+ #define BN_DECLARE_UI_ABI_VERSION
#else
-#define BN_DECLARE_UI_ABI_VERSION \
- extern "C" \
- { \
- BINARYNINJAPLUGIN uint32_t UIPluginABIVersion() \
+ #define BN_DECLARE_UI_ABI_VERSION \
+ extern "C" \
{ \
- return BN_CURRENT_UI_ABI_VERSION; \
- } \
- }
+ BINARYNINJAPLUGIN uint32_t UIPluginABIVersion() { return BN_CURRENT_UI_ABI_VERSION; } \
+ }
#endif
// The Python bindings generator does not recognize automatic conversion of API types into their
diff --git a/ui/util.h b/ui/util.h
index 761e83c4..e434b28e 100644
--- a/ui/util.h
+++ b/ui/util.h
@@ -6,17 +6,23 @@
#include <QtWidgets/QWidget>
#include <QtCore/QFileInfo>
-std::string BINARYNINJAUIAPI getStringForLocalVariable(ArchitectureRef arch, FunctionRef func, BinaryNinja::Variable localVar);
+std::string BINARYNINJAUIAPI getStringForLocalVariable(
+ ArchitectureRef arch, FunctionRef func, BinaryNinja::Variable localVar);
std::string BINARYNINJAUIAPI getStringForRegisterValue(ArchitectureRef arch, BinaryNinja::RegisterValue value);
std::string BINARYNINJAUIAPI getPossibleValueSetStateName(BNRegisterValueType state);
std::string BINARYNINJAUIAPI getStringForIntegerValue(int64_t value);
std::string BINARYNINJAUIAPI getStringForIntegerValue(uint64_t value);
-std::string BINARYNINJAUIAPI getStringForPossibleValueSet(ArchitectureRef arch, const BinaryNinja::PossibleValueSet& values);
-std::string BINARYNINJAUIAPI getStringForInstructionDataflowDetails(BinaryViewRef data, ArchitectureRef arch, FunctionRef func, uint64_t address);
-BinaryNinja::PossibleValueSet BINARYNINJAUIAPI getPossibleValueSetForToken(View* view, BinaryViewRef data, ArchitectureRef arch, FunctionRef func, HighlightTokenState token, size_t instrIdx);
+std::string BINARYNINJAUIAPI getStringForPossibleValueSet(
+ ArchitectureRef arch, const BinaryNinja::PossibleValueSet& values);
+std::string BINARYNINJAUIAPI getStringForInstructionDataflowDetails(
+ BinaryViewRef data, ArchitectureRef arch, FunctionRef func, uint64_t address);
+BinaryNinja::PossibleValueSet BINARYNINJAUIAPI getPossibleValueSetForToken(
+ View* view, BinaryViewRef data, ArchitectureRef arch, FunctionRef func, HighlightTokenState token, size_t instrIdx);
-void BINARYNINJAUIAPI showHexPreview(QWidget* parent, ViewFrame* frame, const QPoint& previewPos, BinaryViewRef data, uint64_t address);
-bool BINARYNINJAUIAPI showDisassemblyPreview(QWidget* parent, ViewFrame* frame, const QPoint& previewPos, BinaryViewRef data, FunctionRef func, const ViewLocation& location);
+void BINARYNINJAUIAPI showHexPreview(
+ QWidget* parent, ViewFrame* frame, const QPoint& previewPos, BinaryViewRef data, uint64_t address);
+bool BINARYNINJAUIAPI showDisassemblyPreview(QWidget* parent, ViewFrame* frame, const QPoint& previewPos,
+ BinaryViewRef data, FunctionRef func, const ViewLocation& location);
void BINARYNINJAUIAPI showTextTooltip(QWidget* parent, const QPoint& previewPos, const QString& text);
bool BINARYNINJAUIAPI isBinaryNinjaDataBase(QFileInfo& info, QFileAccessor& accessor);
diff --git a/ui/variablelist.h b/ui/variablelist.h
index cc1e1de5..bbf0a51a 100644
--- a/ui/variablelist.h
+++ b/ui/variablelist.h
@@ -32,14 +32,13 @@ class VariableListItem
BinaryNinja::PossibleValueSet m_pvs;
bool m_hasUidf;
- public:
+ public:
//! Create a new VariableListItem of the LocalVariable type.
- VariableListItem(FunctionRef func, BinaryNinja::Variable var, BinaryNinja::PossibleValueSet pvs,
- bool hasUidf, std::string name);
+ VariableListItem(
+ FunctionRef func, BinaryNinja::Variable var, BinaryNinja::PossibleValueSet pvs, bool hasUidf, std::string name);
//! Create a new VariableListItem of the DataVariable type.
- VariableListItem(
- FunctionRef func, BinaryNinja::DataVariable dataVar, uint64_t refPoint, std::string name);
+ VariableListItem(FunctionRef func, BinaryNinja::DataVariable dataVar, uint64_t refPoint, std::string name);
//! Get the type of this list item.
VariableListItemType type() const;
@@ -91,7 +90,7 @@ class BINARYNINJAUIAPI VariableListModel : public QAbstractListModel
size_t m_prevVariableCount;
uint64_t m_prevSelectionId;
- public:
+ public:
VariableListModel(QWidget* parent, ViewFrame* view, BinaryViewRef data);
//! Clear the list's content.
@@ -107,8 +106,7 @@ class BINARYNINJAUIAPI VariableListModel : public QAbstractListModel
void setSelectionModel(QItemSelectionModel* model);
virtual QVariant data(const QModelIndex& i, int role) const override;
- virtual QModelIndex index(
- int row, int col, const QModelIndex& parent = QModelIndex()) const override;
+ virtual QModelIndex index(int row, int col, const QModelIndex& parent = QModelIndex()) const override;
virtual int columnCount(const QModelIndex& parent = QModelIndex()) const override;
virtual int rowCount(const QModelIndex& parent = QModelIndex()) const override;
Qt::ItemFlags flags(const QModelIndex& index) const override;
@@ -118,7 +116,8 @@ class BINARYNINJAUIAPI VariableListModel : public QAbstractListModel
class VariableListItemDelegate : public QStyledItemDelegate
{
Q_OBJECT
- public:
+
+ public:
VariableListItemDelegate();
void paint(QPainter* painter, const QStyleOptionViewItem& opt, const QModelIndex& index) const;
@@ -143,7 +142,7 @@ class BINARYNINJAUIAPI VariableList : public SidebarWidget
void processRefresh();
- public:
+ public:
VariableList(ViewFrame* view, BinaryViewRef data);
QWidget* headerWidget() override { return m_header; }
@@ -181,7 +180,7 @@ class BINARYNINJAUIAPI VariableList : public SidebarWidget
class BINARYNINJAUIAPI VariableListSidebarWidgetType : public SidebarWidgetType
{
- public:
+ public:
VariableListSidebarWidgetType();
virtual SidebarWidget* createWidget(ViewFrame* frame, BinaryViewRef data) override;
};
diff --git a/ui/viewframe.h b/ui/viewframe.h
index 713dee56..00ec700a 100644
--- a/ui/viewframe.h
+++ b/ui/viewframe.h
@@ -2,9 +2,9 @@
#include <QtWidgets/QGestureEvent>
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
-#include <QtWidgets/QAction>
+ #include <QtWidgets/QAction>
#else
-#include <QtGui/QAction>
+ #include <QtGui/QAction>
#endif
#include <QtWidgets/QLabel>
#include <QtCore/QPointer>
@@ -43,11 +43,10 @@ struct SelectionInfoForXref
FunctionRef func;
ArchitectureRef arch;
- bool operator== (const SelectionInfoForXref& other) const
+ bool operator==(const SelectionInfoForXref& other) const
{
if (addrValid && other.addrValid)
- return (start == other.start) && (end == other.end) &&
- (func == other.func) && (arch == other.arch);
+ return (start == other.start) && (end == other.end) && (func == other.func) && (arch == other.arch);
else if (typeValid && other.typeValid)
return type == other.type;
else if (typeFieldValid && other.typeFieldValid)
@@ -57,15 +56,15 @@ struct SelectionInfoForXref
return false;
}
- bool operator!= (const SelectionInfoForXref& other) const { return !(*this == other); }
+ bool operator!=(const SelectionInfoForXref& other) const { return !(*this == other); }
bool isValid() const { return addrValid || typeValid || typeFieldValid || localVarValid; }
};
-class BINARYNINJAUIAPI HistoryEntry: public BinaryNinja::RefCountObject
+class BINARYNINJAUIAPI HistoryEntry : public BinaryNinja::RefCountObject
{
QString m_viewType;
-public:
+ public:
virtual ~HistoryEntry() {}
QString getViewType() const { return m_viewType; }
@@ -100,7 +99,7 @@ class ViewPaneHeaderSubtypeWidget;
class BINARYNINJAUIAPI View
{
-protected:
+ protected:
Menu m_contextMenu;
UIActionHandler m_actionHandler;
bool m_binaryDataNavigable = false;
@@ -118,7 +117,7 @@ protected:
virtual void setNavigationMode(std::string mode) { (void)mode; }
virtual std::vector<std::string> getNavigationModes() { return {}; }
-public:
+ public:
View();
virtual ~View() {}
@@ -127,30 +126,25 @@ public:
virtual bool canAssemble() { return false; }
virtual bool canCompile() { return false; }
- virtual bool findNextData(uint64_t start, uint64_t end, const BinaryNinja::DataBuffer& data,
- uint64_t& addr, BNFindFlag flags,
- const std::function<bool (size_t current, size_t total)>& cb);
- virtual bool findNextText(uint64_t start, uint64_t end, const std::string& text,
- uint64_t& addr, DisassemblySettingsRef settings, BNFindFlag flags,
- BNFunctionGraphType graph,
- const std::function<bool (size_t current, size_t total)>& cb);
- virtual bool findNextConstant(uint64_t start, uint64_t end, uint64_t constant,
- uint64_t& addr, DisassemblySettingsRef settings, BNFunctionGraphType graph,
- const std::function<bool (size_t current, size_t total)>& cb);
+ virtual bool findNextData(uint64_t start, uint64_t end, const BinaryNinja::DataBuffer& data, uint64_t& addr,
+ BNFindFlag flags, const std::function<bool(size_t current, size_t total)>& cb);
+ virtual bool findNextText(uint64_t start, uint64_t end, const std::string& text, uint64_t& addr,
+ DisassemblySettingsRef settings, BNFindFlag flags, BNFunctionGraphType graph,
+ const std::function<bool(size_t current, size_t total)>& cb);
+ virtual bool findNextConstant(uint64_t start, uint64_t end, uint64_t constant, uint64_t& addr,
+ DisassemblySettingsRef settings, BNFunctionGraphType graph,
+ const std::function<bool(size_t current, size_t total)>& cb);
virtual bool findAllData(uint64_t start, uint64_t end, const BinaryNinja::DataBuffer& data, BNFindFlag flags,
- const std::function<bool (size_t current, size_t total)>& cb,
- const std::function<bool (uint64_t addr, const BinaryNinja::DataBuffer& match)>& matchCallback);
- virtual bool findAllText(uint64_t start, uint64_t end, const std::string& data,
- DisassemblySettingsRef settings, BNFindFlag flags, BNFunctionGraphType graph,
- const std::function<bool (size_t current, size_t total)>& cb,
- const std::function<bool (uint64_t addr, const std::string& match,
- const BinaryNinja::LinearDisassemblyLine& line)>& matchCallback);
- virtual bool findAllConstant(uint64_t start, uint64_t end, uint64_t constant,
- DisassemblySettingsRef settings, BNFunctionGraphType graph,
- const std::function<bool (size_t current, size_t total)>& cb,
- const std::function<bool (uint64_t addr,
- const BinaryNinja::LinearDisassemblyLine& line)>& matchCallback);
+ const std::function<bool(size_t current, size_t total)>& cb,
+ const std::function<bool(uint64_t addr, const BinaryNinja::DataBuffer& match)>& matchCallback);
+ virtual bool findAllText(uint64_t start, uint64_t end, const std::string& data, DisassemblySettingsRef settings,
+ BNFindFlag flags, BNFunctionGraphType graph, const std::function<bool(size_t current, size_t total)>& cb,
+ const std::function<bool(
+ uint64_t addr, const std::string& match, const BinaryNinja::LinearDisassemblyLine& line)>& matchCallback);
+ virtual bool findAllConstant(uint64_t start, uint64_t end, uint64_t constant, DisassemblySettingsRef settings,
+ BNFunctionGraphType graph, const std::function<bool(size_t current, size_t total)>& cb,
+ const std::function<bool(uint64_t addr, const BinaryNinja::LinearDisassemblyLine& line)>& matchCallback);
virtual BinaryViewRef getData() = 0;
virtual uint64_t getCurrentOffset() = 0;
@@ -169,9 +163,9 @@ public:
void setBinaryDataNavigable(bool navigable) { m_binaryDataNavigable = navigable; }
virtual bool closeRequest() { return true; }
- virtual void closing() { }
- virtual void updateFonts() { }
- virtual void updateTheme() { }
+ virtual void closing() {}
+ virtual void updateFonts() {}
+ virtual void updateTheme() {}
virtual void undo();
virtual void redo();
@@ -214,7 +208,7 @@ public:
virtual MediumLevelILFunctionRef getCurrentMediumLevelILFunction() { return nullptr; }
virtual HighLevelILFunctionRef getCurrentHighLevelILFunction() { return nullptr; }
virtual BNFunctionGraphType getILViewType() { return InvalidILViewType; }
- virtual void setILViewType(BNFunctionGraphType ilViewType) { }
+ virtual void setILViewType(BNFunctionGraphType ilViewType) {}
virtual size_t getCurrentILInstructionIndex() { return BN_INVALID_EXPR; }
virtual QFont getFont() = 0;
@@ -234,8 +228,16 @@ public:
void forceSyncFromView(ViewFrame* frame = nullptr);
virtual void clearRelatedHighlights() {}
- virtual void setRelatedIndexHighlights(FunctionRef func, const std::set<size_t>& related) { (void)func; (void)related; }
- virtual void setRelatedInstructionHighlights(FunctionRef func, const std::set<uint64_t>& related) { (void)func; (void)related; }
+ virtual void setRelatedIndexHighlights(FunctionRef func, const std::set<size_t>& related)
+ {
+ (void)func;
+ (void)related;
+ }
+ virtual void setRelatedInstructionHighlights(FunctionRef func, const std::set<uint64_t>& related)
+ {
+ (void)func;
+ (void)related;
+ }
static void registerActions();
};
@@ -248,8 +250,12 @@ class BINARYNINJAUIAPI ViewNavigationMode
ViewNavigationMode();
-public:
- ViewNavigationMode(View* view, std::string mode) : m_view(view) { m_mode = m_view->getNavigationMode(); m_view->setNavigationMode(mode); }
+ public:
+ ViewNavigationMode(View* view, std::string mode) : m_view(view)
+ {
+ m_mode = m_view->getNavigationMode();
+ m_view->setNavigationMode(mode);
+ }
~ViewNavigationMode() { m_view->setNavigationMode(m_mode); }
};
@@ -263,17 +269,25 @@ class BINARYNINJAUIAPI ViewLocation
BNFunctionGraphType m_ilViewType = NormalFunctionGraph;
size_t m_instrIndex = BN_INVALID_EXPR;
-public:
- ViewLocation() { }
- ViewLocation(const QString& viewType, uint64_t offset) : m_valid(true), m_viewType(viewType), m_offset(offset) { }
- ViewLocation(const QString& viewType, uint64_t offset, BNFunctionGraphType ilViewType) : m_valid(true),
- m_viewType(viewType), m_offset(offset), m_ilViewType(ilViewType) { }
- ViewLocation(const QString& viewType, uint64_t offset, BNFunctionGraphType ilViewType, size_t instrIndex) : m_valid(true),
- m_viewType(viewType), m_offset(offset), m_ilViewType(ilViewType), m_instrIndex(instrIndex) { }
- ViewLocation(const QString& viewType, FunctionRef function, uint64_t offset, BNFunctionGraphType ilViewType, size_t instrIndex) :
- m_valid(true), m_viewType(viewType), m_function(function), m_offset(offset), m_ilViewType(ilViewType), m_instrIndex(instrIndex) { }
- ViewLocation(FunctionRef function, uint64_t offset, BNFunctionGraphType ilViewType, size_t instrIndex = BN_INVALID_EXPR) : m_valid(true),
- m_function(function), m_offset(offset), m_ilViewType(ilViewType), m_instrIndex(instrIndex) { }
+ public:
+ ViewLocation() {}
+ ViewLocation(const QString& viewType, uint64_t offset) : m_valid(true), m_viewType(viewType), m_offset(offset) {}
+ ViewLocation(const QString& viewType, uint64_t offset, BNFunctionGraphType ilViewType) :
+ m_valid(true), m_viewType(viewType), m_offset(offset), m_ilViewType(ilViewType)
+ {}
+ ViewLocation(const QString& viewType, uint64_t offset, BNFunctionGraphType ilViewType, size_t instrIndex) :
+ m_valid(true), m_viewType(viewType), m_offset(offset), m_ilViewType(ilViewType), m_instrIndex(instrIndex)
+ {}
+ ViewLocation(const QString& viewType, FunctionRef function, uint64_t offset, BNFunctionGraphType ilViewType,
+ size_t instrIndex) :
+ m_valid(true),
+ m_viewType(viewType), m_function(function), m_offset(offset), m_ilViewType(ilViewType), m_instrIndex(instrIndex)
+ {}
+ ViewLocation(
+ FunctionRef function, uint64_t offset, BNFunctionGraphType ilViewType, size_t instrIndex = BN_INVALID_EXPR) :
+ m_valid(true),
+ m_function(function), m_offset(offset), m_ilViewType(ilViewType), m_instrIndex(instrIndex)
+ {}
bool isValid() const { return m_valid; }
QString getViewType() const { return m_viewType; }
@@ -290,12 +304,9 @@ public:
bool operator==(const ViewLocation& other) const
{
- return (m_valid == other.m_valid) &&
- (m_viewType == other.m_viewType) &&
- (m_offset == other.m_offset) &&
- (m_ilViewType == other.m_ilViewType) &&
- (m_instrIndex == other.m_instrIndex) &&
- (m_function == other.m_function);
+ return (m_valid == other.m_valid) && (m_viewType == other.m_viewType) && (m_offset == other.m_offset)
+ && (m_ilViewType == other.m_ilViewType) && (m_instrIndex == other.m_instrIndex)
+ && (m_function == other.m_function);
}
bool operator!=(const ViewLocation& other) const { return !((*this) == other); }
};
@@ -303,7 +314,7 @@ public:
class BINARYNINJAUIAPI ViewContainer
{
-public:
+ public:
virtual ~ViewContainer() {}
virtual View* getView() = 0;
};
@@ -315,13 +326,13 @@ class BINARYNINJAUIAPI ViewFrame : public QWidget
{
Q_OBJECT
-private:
+ private:
QWidget* createView(const QString& typeName, ViewType* type, BinaryViewRef data, bool createDynamicWidgets = true);
BinaryNinja::Ref<HistoryEntry> getHistoryEntry();
ViewFrame* searchForOtherPane(const std::function<void(const std::function<void(ViewPane*)>&)>& enumerator);
FileContext* m_context;
- bool m_fileContentsLock = true; // file contents protection from accidental modification in the UI
+ bool m_fileContentsLock = true; // file contents protection from accidental modification in the UI
BinaryViewRef m_data;
QWidget* m_view = nullptr;
QWidget* m_viewContainer;
@@ -335,7 +346,7 @@ private:
UIActionHandler m_actionHandler;
-protected:
+ protected:
QPointer<CompileDialog> compileDialog;
bool event(QEvent* event) override;
@@ -350,7 +361,7 @@ protected:
*/
BinaryNinja::Ref<HistoryEntry> deserializeHistoryEntry(const Json::Value& json);
-public:
+ public:
explicit ViewFrame(QWidget* parent, FileContext* file, const QString& type, bool createDynamicWidgets = false);
virtual ~ViewFrame();
@@ -385,7 +396,7 @@ public:
Sidebar* getSidebar();
- template<class T>
+ template <class T>
T* getSidebarWidget(const QString& name)
{
Sidebar* sidebar = getSidebar();
@@ -398,12 +409,14 @@ public:
}
bool navigate(const QString& type, uint64_t offset, bool updateInfo = true, bool addHistoryEntry = true);
- bool navigate(const QString& type, const std::function<bool(View*)>& handler, bool updateInfo = true, bool addHistoryEntry = true);
+ bool navigate(const QString& type, const std::function<bool(View*)>& handler, bool updateInfo = true,
+ bool addHistoryEntry = true);
bool navigate(BinaryViewRef data, uint64_t offset, bool updateInfo = true, bool addHistoryEntry = true);
bool navigateToFunction(FunctionRef func, uint64_t offset, bool updateInfo = true, bool addHistoryEntry = true);
- bool goToReference(BinaryViewRef data, FunctionRef func, uint64_t source, uint64_t target, bool addHistoryEntry = true);
- bool navigateToViewLocation(BinaryViewRef data, const ViewLocation& viewLocation,
- bool addHistoryEntry = true, bool center = false);
+ bool goToReference(
+ BinaryViewRef data, FunctionRef func, uint64_t source, uint64_t target, bool addHistoryEntry = true);
+ bool navigateToViewLocation(
+ BinaryViewRef data, const ViewLocation& viewLocation, bool addHistoryEntry = true, bool center = false);
bool navigateToHistoryEntry(BinaryNinja::Ref<HistoryEntry> entry);
QString getTypeForView(QWidget* view) const;
QString getDataTypeForView(const QString& type) const;
@@ -432,12 +445,12 @@ public:
void back();
void forward();
- static bool getAddressFromString(QWidget* parent, BinaryViewRef data, uint64_t& offset,
- uint64_t currentAddress, const QString& addrStr, std::string& errorString);
- static bool getAddressFromInput(QWidget* parent, BinaryViewRef data, uint64_t& offset,
- uint64_t currentAddress, const QString& title = "Go to Address", const QString& msg = "Address:", bool defaultToCurrent = false);
- static bool getFileOffsetFromInput(QWidget* parent, BinaryViewRef data, uint64_t& offset,
- uint64_t currentAddress, const QString& title = "Go to File Offset", const QString& msg = "File Offset:", bool defaultToCurrent = false);
+ static bool getAddressFromString(QWidget* parent, BinaryViewRef data, uint64_t& offset, uint64_t currentAddress,
+ const QString& addrStr, std::string& errorString);
+ static bool getAddressFromInput(QWidget* parent, BinaryViewRef data, uint64_t& offset, uint64_t currentAddress,
+ const QString& title = "Go to Address", const QString& msg = "Address:", bool defaultToCurrent = false);
+ static bool getFileOffsetFromInput(QWidget* parent, BinaryViewRef data, uint64_t& offset, uint64_t currentAddress,
+ const QString& title = "Go to File Offset", const QString& msg = "File Offset:", bool defaultToCurrent = false);
void setCurrentFunction(FunctionRef func);
void updateCrossReferences();
@@ -475,11 +488,11 @@ public:
ViewFrame* getOtherPane();
-public Q_SLOTS:
+ public Q_SLOTS:
virtual void assemble();
virtual void compile();
-Q_SIGNALS:
+ Q_SIGNALS:
void notifyCloseFeatureMap(bool recreate);
void notifyViewChanged(ViewFrame* frame);
};
diff --git a/ui/viewlist.h b/ui/viewlist.h
index c1926106..e79f76b5 100644
--- a/ui/viewlist.h
+++ b/ui/viewlist.h
@@ -6,7 +6,7 @@
#include "menus.h"
#include "action.h"
-class BINARYNINJAUIAPI ViewList: public MenuHelper
+class BINARYNINJAUIAPI ViewList : public MenuHelper
{
Q_OBJECT
@@ -16,16 +16,16 @@ class BINARYNINJAUIAPI ViewList: public MenuHelper
UIActionHandler* m_handler;
-public:
+ public:
ViewList(QWidget* parent);
void bindActions(UIActionHandler* handler);
void addMenuActions(Menu* menu, const QString& group);
void setCurrentViewType(ViewFrame* view, const QString& type);
-protected:
+ protected:
virtual void showMenu();
-Q_SIGNALS:
+ Q_SIGNALS:
void viewChanged(QString type);
};
diff --git a/ui/viewtype.h b/ui/viewtype.h
index 2216b9dd..e68c02e2 100644
--- a/ui/viewtype.h
+++ b/ui/viewtype.h
@@ -12,7 +12,7 @@ class BINARYNINJAUIAPI ViewType
{
QString m_name, m_longName;
-public:
+ public:
ViewType(const QString& name, const QString& longName);
virtual ~ViewType();
@@ -33,7 +33,7 @@ public:
class BINARYNINJAUIAPI ViewTypeContainer
{
-public:
+ public:
std::vector<ViewType*> m_types;
static ViewTypeContainer& GetViewTypeContainer();
diff --git a/ui/xreflist.h b/ui/xreflist.h
index 76942954..f1426ee9 100644
--- a/ui/xreflist.h
+++ b/ui/xreflist.h
@@ -28,11 +28,11 @@
class XrefHeader;
class XrefItem
{
-public:
+ public:
enum XrefDirection
{
- Forward, // current address is addressing another address
- Backward // current address is being referenced by another address
+ Forward, // current address is addressing another address
+ Backward // current address is being referenced by another address
};
enum XrefType
@@ -43,7 +43,7 @@ public:
TypeXrefType
};
-protected:
+ protected:
FunctionRef m_func;
ArchitectureRef m_arch;
uint64_t m_addr;
@@ -58,14 +58,15 @@ protected:
mutable int m_size;
-public:
+ public:
explicit XrefItem();
explicit XrefItem(XrefHeader* parent, XrefType type, FunctionRef func);
// The four constructors are used for code/data/type/variable referecens, respectively
explicit XrefItem(BinaryNinja::ReferenceSource ref, XrefType type, XrefDirection direction);
explicit XrefItem(uint64_t addr, XrefType type, XrefDirection direction);
explicit XrefItem(BinaryNinja::TypeReferenceSource ref, XrefType type, XrefDirection direction);
- explicit XrefItem(BinaryNinja::Variable var, BinaryNinja::ILReferenceSource ref, XrefType type, XrefDirection direction);
+ explicit XrefItem(
+ BinaryNinja::Variable var, BinaryNinja::ILReferenceSource ref, XrefType type, XrefDirection direction);
XrefItem(const XrefItem& ref);
virtual ~XrefItem();
@@ -92,11 +93,12 @@ public:
};
-class XrefHeader: public XrefItem
+class XrefHeader : public XrefItem
{
-protected:
+ protected:
QString m_name;
-public:
+
+ public:
XrefHeader();
XrefHeader(const QString& name, XrefItem::XrefType type, XrefHeader* parent, FunctionRef func);
virtual ~XrefHeader() {}
@@ -114,7 +116,8 @@ public:
class XrefFunctionHeader : public XrefHeader
{
std::deque<XrefItem*> m_refs;
-public:
+
+ public:
XrefFunctionHeader();
XrefFunctionHeader(FunctionRef func, XrefHeader* parent, XrefItem* child);
XrefFunctionHeader(const XrefFunctionHeader& header);
@@ -129,7 +132,8 @@ public:
class XrefTypeHeader : public XrefHeader
{
std::deque<XrefItem*> m_refs;
-public:
+
+ public:
XrefTypeHeader();
XrefTypeHeader(BinaryNinja::QualifiedName name, XrefHeader* parent, XrefItem* child);
XrefTypeHeader(const XrefTypeHeader& header);
@@ -143,7 +147,8 @@ public:
class XrefVariableHeader : public XrefHeader
{
std::deque<XrefItem*> m_refs;
-public:
+
+ public:
XrefVariableHeader();
XrefVariableHeader(XrefHeader* parent, XrefItem* child);
XrefVariableHeader(const XrefVariableHeader& header);
@@ -154,11 +159,12 @@ public:
};
-class XrefCodeReferences: public XrefHeader
+class XrefCodeReferences : public XrefHeader
{
std::map<FunctionRef, XrefFunctionHeader*> m_refs;
std::deque<XrefFunctionHeader*> m_refList;
-public:
+
+ public:
XrefCodeReferences(XrefHeader* parent);
virtual ~XrefCodeReferences();
virtual int childCount() const override { return (int)m_refs.size(); }
@@ -169,10 +175,11 @@ public:
};
-class XrefDataReferences: public XrefHeader
+class XrefDataReferences : public XrefHeader
{
std::deque<XrefItem*> m_refs;
-public:
+
+ public:
XrefDataReferences(XrefHeader* parent);
virtual ~XrefDataReferences();
virtual int childCount() const override { return (int)m_refs.size(); };
@@ -182,11 +189,12 @@ public:
};
-class XrefTypeReferences: public XrefHeader
+class XrefTypeReferences : public XrefHeader
{
std::map<BinaryNinja::QualifiedName, XrefTypeHeader*> m_refs;
std::deque<XrefTypeHeader*> m_refList;
-public:
+
+ public:
XrefTypeReferences(XrefHeader* parent);
virtual ~XrefTypeReferences();
virtual int childCount() const override { return (int)m_refs.size(); };
@@ -197,11 +205,12 @@ public:
};
-class XrefVariableReferences: public XrefHeader
+class XrefVariableReferences : public XrefHeader
{
std::map<BinaryNinja::Variable, XrefVariableHeader*> m_refs;
std::deque<XrefVariableHeader*> m_refList;
-public:
+
+ public:
XrefVariableReferences(XrefHeader* parent);
virtual ~XrefVariableReferences();
virtual int childCount() const override { return (int)m_refs.size(); };
@@ -212,10 +221,11 @@ public:
};
-class XrefRoot: public XrefHeader
+class XrefRoot : public XrefHeader
{
std::map<XrefItem::XrefType, XrefHeader*> m_refs;
-public:
+
+ public:
XrefRoot();
XrefRoot(XrefRoot&& root);
~XrefRoot();
@@ -238,7 +248,7 @@ class BINARYNINJAUIAPI CrossReferenceTreeModel : public QAbstractItemModel
size_t m_maxUIItems;
std::optional<BNFunctionGraphType> m_graphType;
-public:
+ public:
CrossReferenceTreeModel(QWidget* parent, BinaryViewRef data, ViewFrame* view);
virtual ~CrossReferenceTreeModel();
@@ -273,7 +283,7 @@ class BINARYNINJAUIAPI CrossReferenceTableModel : public QAbstractTableModel
size_t m_maxUIItems;
std::optional<BNFunctionGraphType> m_graphType;
-public:
+ public:
enum ColumnHeaders
{
Direction = 0,
@@ -288,9 +298,21 @@ public:
virtual QModelIndex index(int row, int col, const QModelIndex& parent = QModelIndex()) const override;
virtual QVariant data(const QModelIndex& i, int role) const override;
Qt::ItemFlags flags(const QModelIndex& index) const override;
- virtual int rowCount(const QModelIndex& parent = QModelIndex()) const override { (void)parent; return (int)m_refs.size(); };
- virtual QModelIndex parent(const QModelIndex& i) const override { (void)i; return QModelIndex(); }
- virtual int columnCount(const QModelIndex& parent = QModelIndex()) const override { (void) parent; return 4;};
+ virtual int rowCount(const QModelIndex& parent = QModelIndex()) const override
+ {
+ (void)parent;
+ return (int)m_refs.size();
+ };
+ virtual QModelIndex parent(const QModelIndex& i) const override
+ {
+ (void)i;
+ return QModelIndex();
+ }
+ virtual int columnCount(const QModelIndex& parent = QModelIndex()) const override
+ {
+ (void)parent;
+ return 4;
+ };
virtual QVariant headerData(int column, Qt::Orientation orientation, int role) const override;
virtual bool hasChildren(const QModelIndex&) const override { return false; }
bool setModelData(std::vector<XrefItem>& refs, QItemSelectionModel* selectionModel, bool& selectionUpdated);
@@ -302,7 +324,7 @@ public:
};
-class BINARYNINJAUIAPI CrossReferenceItemDelegate: public QStyledItemDelegate
+class BINARYNINJAUIAPI CrossReferenceItemDelegate : public QStyledItemDelegate
{
Q_OBJECT
@@ -312,7 +334,7 @@ class BINARYNINJAUIAPI CrossReferenceItemDelegate: public QStyledItemDelegate
bool m_table;
size_t m_maxUIItems;
-public:
+ public:
CrossReferenceItemDelegate(QWidget* parent, bool table);
void updateFonts();
@@ -338,20 +360,20 @@ class BINARYNINJAUIAPI CrossReferenceFilterProxyModel : public QSortFilterProxyM
bool m_showOutgoing = true;
bool m_table;
-public:
+ public:
CrossReferenceFilterProxyModel(QObject* parent, bool table);
QModelIndex nextValidIndex(const QModelIndex& current) const;
QModelIndex getFirstLeaf(const QModelIndex& index) const;
QModelIndex prevValidIndex(const QModelIndex& current) const;
QModelIndex getLastLeaf(const QModelIndex& index) const;
-protected:
+ protected:
virtual bool filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const override;
virtual bool lessThan(const QModelIndex& left, const QModelIndex& right) const override;
virtual QVariant data(const QModelIndex& index, int role) const override;
virtual bool hasChildren(const QModelIndex& parent) const override;
-public Q_SLOTS:
+ public Q_SLOTS:
void directionChanged(int index, bool checked);
void typeChanged(int index, bool checked);
void resetFilter();
@@ -360,12 +382,13 @@ public Q_SLOTS:
class CrossReferenceWidget;
class BINARYNINJAUIAPI CrossReferenceContainer
{
-protected:
+ protected:
ViewFrame* m_view;
CrossReferenceWidget* m_parent;
BinaryViewRef m_data;
UIActionHandler m_actionHandler;
-public:
+
+ public:
CrossReferenceContainer(CrossReferenceWidget* parent, ViewFrame* view, BinaryViewRef data);
virtual ~CrossReferenceContainer() {}
virtual QModelIndex translateIndex(const QModelIndex& idx) const = 0;
@@ -382,7 +405,7 @@ public:
};
-class BINARYNINJAUIAPI CrossReferenceTree: public QTreeView, public CrossReferenceContainer
+class BINARYNINJAUIAPI CrossReferenceTree : public QTreeView, public CrossReferenceContainer
{
Q_OBJECT
@@ -390,11 +413,11 @@ class BINARYNINJAUIAPI CrossReferenceTree: public QTreeView, public CrossReferen
CrossReferenceFilterProxyModel* m_model;
CrossReferenceItemDelegate* m_itemDelegate;
-protected:
- void drawBranches(QPainter *painter, const QRect &rect, const QModelIndex &index) const override;
+ protected:
+ void drawBranches(QPainter* painter, const QRect& rect, const QModelIndex& index) const override;
virtual bool getReference(const QModelIndex& idx, XrefItem** refPtr) const override;
-public:
+ public:
CrossReferenceTree(CrossReferenceWidget* parent, ViewFrame* view, BinaryViewRef data);
virtual ~CrossReferenceTree();
@@ -415,12 +438,12 @@ public:
virtual void updateMaxUIItems(size_t count) override;
void setGraphType(BNFunctionGraphType type) { m_tree->setGraphType(type); }
-Q_SIGNALS:
+ Q_SIGNALS:
void newSelection();
};
-class BINARYNINJAUIAPI CrossReferenceTable: public QTableView, public CrossReferenceContainer
+class BINARYNINJAUIAPI CrossReferenceTable : public QTableView, public CrossReferenceContainer
{
Q_OBJECT
@@ -428,7 +451,7 @@ class BINARYNINJAUIAPI CrossReferenceTable: public QTableView, public CrossRefer
CrossReferenceItemDelegate* m_itemDelegate;
CrossReferenceFilterProxyModel* m_model;
-public:
+ public:
CrossReferenceTable(CrossReferenceWidget* parent, ViewFrame* view, BinaryViewRef data);
virtual ~CrossReferenceTable();
@@ -450,15 +473,15 @@ public:
virtual void updateMaxUIItems(size_t count) override;
void setGraphType(BNFunctionGraphType type) { m_table->setGraphType(type); }
-public Q_SLOTS:
+ public Q_SLOTS:
void updateTextFilter(const QString& filterText);
-Q_SIGNALS:
+ Q_SIGNALS:
void newSelection();
};
class ExpandableGroup;
class QCheckboxCombo;
-class BINARYNINJAUIAPI CrossReferenceWidget: public SidebarWidget, public UIContextNotification
+class BINARYNINJAUIAPI CrossReferenceWidget : public SidebarWidget, public UIContextNotification
{
Q_OBJECT
@@ -494,7 +517,7 @@ class BINARYNINJAUIAPI CrossReferenceWidget: public SidebarWidget, public UICont
virtual void contextMenuEvent(QContextMenuEvent* event) override;
virtual void wheelEvent(QWheelEvent* e) override;
-public:
+ public:
CrossReferenceWidget(ViewFrame* view, BinaryViewRef data, bool pinned);
virtual ~CrossReferenceWidget();
virtual void notifyFontChanged() override;
@@ -522,16 +545,16 @@ public:
virtual void focus() override;
- virtual void OnNewSelectionForXref(UIContext* context, ViewFrame* frame, View* view,
- const SelectionInfoForXref& selection) override;
+ virtual void OnNewSelectionForXref(
+ UIContext* context, ViewFrame* frame, View* view, const SelectionInfoForXref& selection) override;
virtual QWidget* headerWidget() override { return m_header; }
-private Q_SLOTS:
+ private Q_SLOTS:
void hoverTimerEvent();
void newPinnedPane();
-public Q_SLOTS:
+ public Q_SLOTS:
void referenceActivated(const QModelIndex& idx);
void pinnedStateChanged(bool state);
void selectionChanged();
@@ -540,9 +563,9 @@ public Q_SLOTS:
};
-class BINARYNINJAUIAPI CrossReferenceSidebarWidgetType: public SidebarWidgetType
+class BINARYNINJAUIAPI CrossReferenceSidebarWidgetType : public SidebarWidgetType
{
-public:
+ public:
CrossReferenceSidebarWidgetType();
virtual bool isInReferenceArea() const override { return true; }
virtual SidebarWidget* createWidget(ViewFrame* frame, BinaryViewRef data) override;
@@ -559,18 +582,18 @@ class BINARYNINJAUIAPI QCheckboxCombo : public QComboBox
{
Q_OBJECT
-public:
- explicit QCheckboxCombo(QWidget *parent = nullptr);
+ public:
+ explicit QCheckboxCombo(QWidget* parent = nullptr);
bool eventFilter(QObject* watched, QEvent* event);
void hidePopup();
void showPopup();
- void addItem(const QString &text, bool checked = true);
+ void addItem(const QString& text, bool checked = true);
-Q_SIGNALS:
+ Q_SIGNALS:
void selectionChanged(const QString& text);
void itemToggled(int index, bool checked);
-private:
+ private:
bool m_popupVisible = false;
bool m_editable = false;
QString m_selectionString;
diff --git a/update.cpp b/update.cpp
index 3e80b935..3ae4158d 100644
--- a/update.cpp
+++ b/update.cpp
@@ -24,8 +24,7 @@ using namespace BinaryNinja;
using namespace std;
-namespace BinaryNinja
-{
+namespace BinaryNinja {
struct UpdateProgress
{
function<bool(uint64_t progress, uint64_t total)> func;
@@ -36,7 +35,7 @@ namespace BinaryNinja
return self->func(progress, total);
}
};
-}
+} // namespace BinaryNinja
vector<UpdateChannel> UpdateChannel::GetList()
@@ -86,19 +85,19 @@ bool UpdateChannel::AreUpdatesAvailable(uint64_t* expireTime, uint64_t* serverTi
BNUpdateResult UpdateChannel::UpdateToVersion(const string& version)
{
- return UpdateToVersion(version, [](uint64_t, uint64_t){ return true; });
+ return UpdateToVersion(version, [](uint64_t, uint64_t) { return true; });
}
-BNUpdateResult UpdateChannel::UpdateToVersion(const string& version,
- const function<bool(uint64_t progress, uint64_t total)>& progress)
+BNUpdateResult UpdateChannel::UpdateToVersion(
+ const string& version, const function<bool(uint64_t progress, uint64_t total)>& progress)
{
UpdateProgress up;
up.func = progress;
char* errors;
- BNUpdateResult result = BNUpdateToVersion(name.c_str(), version.c_str(), &errors,
- UpdateProgress::UpdateCallback, &up);
+ BNUpdateResult result =
+ BNUpdateToVersion(name.c_str(), version.c_str(), &errors, UpdateProgress::UpdateCallback, &up);
if (errors)
{
@@ -113,7 +112,7 @@ BNUpdateResult UpdateChannel::UpdateToVersion(const string& version,
BNUpdateResult UpdateChannel::UpdateToLatestVersion()
{
- return UpdateToLatestVersion([](uint64_t, uint64_t){ return true; });
+ return UpdateToLatestVersion([](uint64_t, uint64_t) { return true; });
}
diff --git a/websocketprovider.cpp b/websocketprovider.cpp
index cf6483a5..1e6b78ba 100644
--- a/websocketprovider.cpp
+++ b/websocketprovider.cpp
@@ -50,11 +50,11 @@ void WebsocketClient::DestroyClientCallback(void* ctxt)
}
-bool WebsocketClient::ConnectCallback(void* ctxt, const char* host, uint64_t headerCount,
- const char* const* headerKeys, const char* const* headerValues)
+bool WebsocketClient::ConnectCallback(
+ void* ctxt, const char* host, uint64_t headerCount, const char* const* headerKeys, const char* const* headerValues)
{
unordered_map<string, string> headers;
- for (uint64_t i = 0; i < headerCount; i ++)
+ for (uint64_t i = 0; i < headerCount; i++)
{
headers[headerKeys[i]] = headerValues[i];
}
@@ -91,8 +91,8 @@ bool WebsocketClient::ReadData(uint8_t* data, uint64_t len)
}
-bool WebsocketClient::Connect(const std::string& host,
- const std::unordered_map<std::string, std::string>& headers, BNWebsocketClientOutputCallbacks* callbacks)
+bool WebsocketClient::Connect(const std::string& host, const std::unordered_map<std::string, std::string>& headers,
+ BNWebsocketClientOutputCallbacks* callbacks)
{
const char** headerKeys = new const char*[headers.size()];
const char** headerValues = new const char*[headers.size()];
@@ -102,13 +102,13 @@ bool WebsocketClient::Connect(const std::string& host,
{
headerKeys[i] = it->first.c_str();
headerValues[i] = it->second.c_str();
- i ++;
+ i++;
}
bool result = BNConnectWebsocketClient(m_object, host.c_str(), headers.size(), headerKeys, headerValues, callbacks);
- delete [] headerKeys;
- delete [] headerValues;
+ delete[] headerKeys;
+ delete[] headerValues;
return result;
}
@@ -120,9 +120,7 @@ void WebsocketClient::DestroyClient()
}
-CoreWebsocketClient::CoreWebsocketClient(BNWebsocketClient* client): WebsocketClient(client)
-{
-}
+CoreWebsocketClient::CoreWebsocketClient(BNWebsocketClient* client) : WebsocketClient(client) {}
bool CoreWebsocketClient::Connect(const std::string& host, const std::unordered_map<std::string, std::string>& headers)
@@ -145,9 +143,7 @@ bool CoreWebsocketClient::Disconnect()
}
-WebsocketProvider::WebsocketProvider(const string& name): m_nameForRegister(name)
-{
-}
+WebsocketProvider::WebsocketProvider(const string& name) : m_nameForRegister(name) {}
WebsocketProvider::WebsocketProvider(BNWebsocketProvider* provider)
@@ -194,9 +190,7 @@ void WebsocketProvider::Register(WebsocketProvider* provider)
}
-CoreWebsocketProvider::CoreWebsocketProvider(BNWebsocketProvider* provider): WebsocketProvider(provider)
-{
-}
+CoreWebsocketProvider::CoreWebsocketProvider(BNWebsocketProvider* provider) : WebsocketProvider(provider) {}
Ref<WebsocketClient> CoreWebsocketProvider::CreateNewClient()
diff --git a/workflow.cpp b/workflow.cpp
index 1d8c67a1..d3a13950 100644
--- a/workflow.cpp
+++ b/workflow.cpp
@@ -7,9 +7,10 @@ using namespace BinaryNinja;
using namespace std;
-AnalysisContext::AnalysisContext(BNAnalysisContext* analysisContext): m_reader(Json::CharReaderBuilder().newCharReader())
+AnalysisContext::AnalysisContext(BNAnalysisContext* analysisContext) :
+ m_reader(Json::CharReaderBuilder().newCharReader())
{
- //LogError("API-Side AnalysisContext Constructed!");
+ // LogError("API-Side AnalysisContext Constructed!");
m_object = analysisContext;
m_builder["indentation"] = "";
}
@@ -17,7 +18,7 @@ AnalysisContext::AnalysisContext(BNAnalysisContext* analysisContext): m_reader(J
AnalysisContext::~AnalysisContext()
{
- //LogError("API-Side AnalysisContext Destructed!");
+ // LogError("API-Side AnalysisContext Destructed!");
}
@@ -152,7 +153,7 @@ bool Workflow::RegisterActivity(Ref<Activity> activity, const string& descriptio
bool Workflow::RegisterActivity(Ref<Activity> activity, const vector<string>& subactivities, const string& description)
{
- activity->AddRefForRegistration(); // TODO
+ activity->AddRefForRegistration(); // TODO
char** buffer = new char*[subactivities.size()];
if (!buffer)
@@ -161,7 +162,8 @@ bool Workflow::RegisterActivity(Ref<Activity> activity, const vector<string>& su
for (size_t i = 0; i < subactivities.size(); i++)
buffer[i] = BNAllocString(subactivities[i].c_str());
- bool result = BNWorkflowRegisterActivity(m_object, activity->GetObject(), (const char**)buffer, subactivities.size(), description.c_str());
+ bool result = BNWorkflowRegisterActivity(
+ m_object, activity->GetObject(), (const char**)buffer, subactivities.size(), description.c_str());
BNFreeStringList(buffer, subactivities.size());
return result;
}
@@ -317,7 +319,7 @@ void Workflow::ShowReport(const std::string& name)
}
-//bool Workflow::Run(const string& activity, Ref<AnalysisContext> analysisContext)
+// bool Workflow::Run(const string& activity, Ref<AnalysisContext> analysisContext)
// {
// }