summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--architecture.cpp15
-rw-r--r--backgroundtask.cpp1
-rw-r--r--basicblock.cpp4
-rw-r--r--binaryninjaapi.h7
-rw-r--r--binaryninjacore.h1
-rw-r--r--binaryview.cpp52
-rw-r--r--binaryviewtype.cpp2
-rw-r--r--docs/about/open-source.md8
-rw-r--r--docs/getting-started.md6
-rw-r--r--function.cpp60
-rw-r--r--functiongraph.cpp2
-rw-r--r--functiongraphblock.cpp3
-rw-r--r--lowlevelil.cpp32
-rw-r--r--lowlevelilinstruction.cpp7
-rw-r--r--mediumlevelil.cpp33
-rw-r--r--mediumlevelilinstruction.cpp6
-rw-r--r--metadata.cpp1
-rw-r--r--platform.cpp6
-rw-r--r--plugin.cpp3
-rw-r--r--python/binaryview.py4
-rw-r--r--python/plugin.py49
-rw-r--r--python/types.py17
-rw-r--r--settings.cpp5
-rw-r--r--transform.cpp2
-rw-r--r--type.cpp48
-rw-r--r--update.cpp2
27 files changed, 223 insertions, 155 deletions
diff --git a/README.md b/README.md
index bfa453d0..74788a28 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-[![slack](https://binaryninja-slack-hwwdinrdce.now.sh/badge.svg)](https://binaryninja-slack-hwwdinrdce.now.sh/)
+[![slack](https://slackin-sbhuzyheck.now.sh/badge.svg)](https://binaryninja-slack-hwwdinrdce.now.sh/)
# Binary Ninja API
diff --git a/architecture.cpp b/architecture.cpp
index 223af13d..90f8e622 100644
--- a/architecture.cpp
+++ b/architecture.cpp
@@ -722,6 +722,7 @@ vector<Ref<Architecture>> Architecture::GetList()
archs = BNGetArchitectureList(&count);
vector<Ref<Architecture>> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
result.push_back(new CoreArchitecture(archs[i]));
@@ -1031,6 +1032,7 @@ vector<uint32_t> Architecture::GetModifiedRegistersOnWrite(uint32_t reg)
uint32_t* regs = BNGetModifiedArchitectureRegistersOnWrite(m_object, reg, &count);
vector<uint32_t> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
result.push_back(regs[i]);
@@ -1142,6 +1144,7 @@ vector<Ref<CallingConvention>> Architecture::GetCallingConventions()
BNCallingConvention** list = BNGetArchitectureCallingConventions(m_object, &count);
vector<Ref<CallingConvention>> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
result.push_back(new CoreCallingConvention(BNNewCallingConventionReference(list[i])));
@@ -1285,10 +1288,11 @@ bool CoreArchitecture::GetInstructionText(const uint8_t* data, uint64_t addr, si
if (!BNGetInstructionText(m_object, data, addr, &len, &tokens, &count))
return false;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
{
- result.push_back(InstructionTextToken(tokens[i].type, tokens[i].context, tokens[i].text, tokens[i].address,
- tokens[i].value, tokens[i].size, tokens[i].operand, tokens[i].confidence));
+ result.emplace_back(tokens[i].type, tokens[i].context, tokens[i].text, tokens[i].address,
+ tokens[i].value, tokens[i].size, tokens[i].operand, tokens[i].confidence);
}
BNFreeInstructionText(tokens, count);
@@ -1353,6 +1357,7 @@ vector<uint32_t> CoreArchitecture::GetFullWidthRegisters()
uint32_t* regs = BNGetFullWidthArchitectureRegisters(m_object, &count);
vector<uint32_t> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
result.push_back(regs[i]);
@@ -1367,6 +1372,7 @@ vector<uint32_t> CoreArchitecture::GetAllRegisters()
uint32_t* regs = BNGetAllArchitectureRegisters(m_object, &count);
vector<uint32_t> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
result.push_back(regs[i]);
@@ -1381,6 +1387,7 @@ vector<uint32_t> CoreArchitecture::GetAllFlags()
uint32_t* regs = BNGetAllArchitectureFlags(m_object, &count);
vector<uint32_t> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
result.push_back(regs[i]);
@@ -1395,6 +1402,7 @@ vector<uint32_t> CoreArchitecture::GetAllFlagWriteTypes()
uint32_t* regs = BNGetAllArchitectureFlagWriteTypes(m_object, &count);
vector<uint32_t> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
result.push_back(regs[i]);
@@ -1457,6 +1465,7 @@ vector<uint32_t> CoreArchitecture::GetFlagsRequiredForSemanticFlagGroup(uint32_t
uint32_t* flags = BNGetArchitectureFlagsRequiredForSemanticFlagGroup(m_object, semGroup, &count);
vector<uint32_t> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
result.push_back(flags[i]);
@@ -1486,6 +1495,7 @@ vector<uint32_t> CoreArchitecture::GetFlagsWrittenByFlagWriteType(uint32_t write
uint32_t* flags = BNGetArchitectureFlagsWrittenByFlagWriteType(m_object, writeType, &count);
vector<uint32_t> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
result.push_back(flags[i]);
@@ -1545,6 +1555,7 @@ vector<uint32_t> CoreArchitecture::GetGlobalRegisters()
uint32_t* regs = BNGetArchitectureGlobalRegisters(m_object, &count);
vector<uint32_t> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
result.push_back(regs[i]);
diff --git a/backgroundtask.cpp b/backgroundtask.cpp
index aebf980c..b2d4a738 100644
--- a/backgroundtask.cpp
+++ b/backgroundtask.cpp
@@ -67,6 +67,7 @@ vector<Ref<BackgroundTask>> BackgroundTask::GetRunningTasks()
BNBackgroundTask** tasks = BNGetRunningBackgroundTasks(&count);
vector<Ref<BackgroundTask>> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
result.push_back(new BackgroundTask(BNNewBackgroundTaskReference(tasks[i])));
diff --git a/basicblock.cpp b/basicblock.cpp
index 89ace134..d42a1038 100644
--- a/basicblock.cpp
+++ b/basicblock.cpp
@@ -120,6 +120,7 @@ vector<BasicBlockEdge> BasicBlock::GetOutgoingEdges() const
BNBasicBlockEdge* array = BNGetBasicBlockOutgoingEdges(m_object, &count);
vector<BasicBlockEdge> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
{
BasicBlockEdge edge;
@@ -140,6 +141,7 @@ vector<BasicBlockEdge> BasicBlock::GetIncomingEdges() const
BNBasicBlockEdge* array = BNGetBasicBlockIncomingEdges(m_object, &count);
vector<BasicBlockEdge> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
{
BasicBlockEdge edge;
@@ -269,10 +271,12 @@ vector<DisassemblyTextLine> BasicBlock::GetDisassemblyText(DisassemblySettings*
BNDisassemblyTextLine* lines = BNGetBasicBlockDisassemblyText(m_object, settings->GetObject(), &count);
vector<DisassemblyTextLine> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
{
DisassemblyTextLine line;
line.addr = lines[i].addr;
+ line.tokens.reserve(lines[i].count);
for (size_t j = 0; j < lines[i].count; j++)
{
InstructionTextToken token;
diff --git a/binaryninjaapi.h b/binaryninjaapi.h
index 187740b9..91162af7 100644
--- a/binaryninjaapi.h
+++ b/binaryninjaapi.h
@@ -486,6 +486,7 @@ namespace BinaryNinja
};
class Architecture;
+ class BackgroundTask;
class Platform;
class Type;
class DataBuffer;
@@ -968,6 +969,7 @@ namespace BinaryNinja
uint64_t address;
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);
InstructionTextToken(BNInstructionTextTokenType type, BNInstructionTextTokenContext context,
@@ -1017,6 +1019,9 @@ namespace BinaryNinja
struct DataVariable
{
+ DataVariable() { }
+ DataVariable(uint64_t a, Type* t, bool d) : address(a), type(t), autoDiscovered(d) { }
+
uint64_t address;
Confidence<Ref<Type>> type;
bool autoDiscovered;
@@ -1262,6 +1267,7 @@ namespace BinaryNinja
Ref<AnalysisCompletionEvent> AddAnalysisCompletionEvent(const std::function<void()>& callback);
BNAnalysisProgress GetAnalysisProgress();
+ Ref<BackgroundTask> GetBackgroundAnalysisTask();
uint64_t GetNextFunctionStartAfterAddress(uint64_t addr);
uint64_t GetNextBasicBlockStartAfterAddress(uint64_t addr);
@@ -1902,6 +1908,7 @@ namespace BinaryNinja
{
Variable();
Variable(BNVariableSourceType type, uint32_t index, uint64_t storage);
+ Variable(BNVariableSourceType type, uint64_t storage);
Variable(const BNVariable& var);
Variable& operator=(const Variable& var);
diff --git a/binaryninjacore.h b/binaryninjacore.h
index 528df6bd..fa7a818a 100644
--- a/binaryninjacore.h
+++ b/binaryninjacore.h
@@ -2424,6 +2424,7 @@ extern "C"
BINARYNINJACOREAPI void BNCancelAnalysisCompletionEvent(BNAnalysisCompletionEvent* event);
BINARYNINJACOREAPI BNAnalysisProgress BNGetAnalysisProgress(BNBinaryView* view);
+ BINARYNINJACOREAPI BNBackgroundTask* BNGetBackgroundAnalysisTask(BNBinaryView* view);
BINARYNINJACOREAPI uint64_t BNGetNextFunctionStartAfterAddress(BNBinaryView* view, uint64_t addr);
BINARYNINJACOREAPI uint64_t BNGetNextBasicBlockStartAfterAddress(BNBinaryView* view, uint64_t addr);
diff --git a/binaryview.cpp b/binaryview.cpp
index 50011a0f..96fd161d 100644
--- a/binaryview.cpp
+++ b/binaryview.cpp
@@ -82,10 +82,7 @@ void BinaryDataNotification::DataVariableAddedCallback(void* ctxt, BNBinaryView*
{
BinaryDataNotification* notify = (BinaryDataNotification*)ctxt;
Ref<BinaryView> view = new BinaryView(BNNewViewReference(object));
- DataVariable varObj;
- varObj.address = var->address;
- varObj.type = Confidence<Ref<Type>>(new Type(BNNewTypeReference(var->type)), var->typeConfidence);
- varObj.autoDiscovered = var->autoDiscovered;
+ DataVariable varObj(var->address, Confidence<Ref<Type>>(new Type(BNNewTypeReference(var->type)), var->typeConfidence), var->autoDiscovered);
notify->OnDataVariableAdded(view, varObj);
}
@@ -94,10 +91,7 @@ void BinaryDataNotification::DataVariableRemovedCallback(void* ctxt, BNBinaryVie
{
BinaryDataNotification* notify = (BinaryDataNotification*)ctxt;
Ref<BinaryView> view = new BinaryView(BNNewViewReference(object));
- DataVariable varObj;
- varObj.address = var->address;
- varObj.type = Confidence<Ref<Type>>(new Type(BNNewTypeReference(var->type)), var->typeConfidence);
- varObj.autoDiscovered = var->autoDiscovered;
+ DataVariable varObj(var->address, Confidence<Ref<Type>>(new Type(BNNewTypeReference(var->type)), var->typeConfidence), var->autoDiscovered);
notify->OnDataVariableRemoved(view, varObj);
}
@@ -106,10 +100,7 @@ void BinaryDataNotification::DataVariableUpdatedCallback(void* ctxt, BNBinaryVie
{
BinaryDataNotification* notify = (BinaryDataNotification*)ctxt;
Ref<BinaryView> view = new BinaryView(BNNewViewReference(object));
- DataVariable varObj;
- varObj.address = var->address;
- varObj.type = Confidence<Ref<Type>>(new Type(BNNewTypeReference(var->type)), var->typeConfidence);
- varObj.autoDiscovered = var->autoDiscovered;
+ DataVariable varObj(var->address, Confidence<Ref<Type>>(new Type(BNNewTypeReference(var->type)), var->typeConfidence), var->autoDiscovered);
notify->OnDataVariableUpdated(view, varObj);
}
@@ -679,6 +670,7 @@ vector<BNModificationStatus> BinaryView::GetModification(uint64_t offset, size_t
len = BNGetModificationArray(m_object, offset, mod, len);
vector<BNModificationStatus> result;
+ result.reserve(len);
for (size_t i = 0; i < len; i++)
result.push_back(mod[i]);
@@ -965,11 +957,8 @@ map<uint64_t, DataVariable> BinaryView::GetDataVariables()
map<uint64_t, DataVariable> result;
for (size_t i = 0; i < count; i++)
{
- DataVariable var;
- var.address = vars[i].address;
- var.type = Confidence<Ref<Type>>(new Type(BNNewTypeReference(vars[i].type)), vars[i].typeConfidence);
- var.autoDiscovered = vars[i].autoDiscovered;
- result[var.address] = var;
+ 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));
}
BNFreeDataVariables(vars, count);
@@ -1000,6 +989,7 @@ vector<Ref<Function>> BinaryView::GetAnalysisFunctionList()
BNFunction** list = BNGetAnalysisFunctionList(m_object, &count);
vector<Ref<Function>> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
result.push_back(new Function(BNNewFunctionReference(list[i])));
@@ -1038,6 +1028,7 @@ vector<Ref<Function>> BinaryView::GetAnalysisFunctionsForAddress(uint64_t addr)
BNFunction** list = BNGetAnalysisFunctionsForAddress(m_object, addr, &count);
vector<Ref<Function>> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
result.push_back(new Function(BNNewFunctionReference(list[i])));
@@ -1070,6 +1061,7 @@ vector<Ref<BasicBlock>> BinaryView::GetBasicBlocksForAddress(uint64_t addr)
BNBasicBlock** blocks = BNGetBasicBlocksForAddress(m_object, addr, &count);
vector<Ref<BasicBlock>> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
result.push_back(new BasicBlock(BNNewBasicBlockReference(blocks[i])));
@@ -1084,6 +1076,7 @@ vector<Ref<BasicBlock>> BinaryView::GetBasicBlocksStartingAtAddress(uint64_t add
BNBasicBlock** blocks = BNGetBasicBlocksStartingAtAddress(m_object, addr, &count);
vector<Ref<BasicBlock>> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
result.push_back(new BasicBlock(BNNewBasicBlockReference(blocks[i])));
@@ -1098,6 +1091,7 @@ vector<ReferenceSource> BinaryView::GetCodeReferences(uint64_t addr)
BNReferenceSource* refs = BNGetCodeReferences(m_object, addr, &count);
vector<ReferenceSource> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
{
ReferenceSource src;
@@ -1118,6 +1112,7 @@ vector<ReferenceSource> BinaryView::GetCodeReferences(uint64_t addr, uint64_t le
BNReferenceSource* refs = BNGetCodeReferencesInRange(m_object, addr, len, &count);
vector<ReferenceSource> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
{
ReferenceSource src;
@@ -1156,6 +1151,7 @@ vector<Ref<Symbol>> BinaryView::GetSymbolsByName(const string& name)
BNSymbol** syms = BNGetSymbolsByName(m_object, name.c_str(), &count);
vector<Ref<Symbol>> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
result.push_back(new Symbol(BNNewSymbolReference(syms[i])));
@@ -1170,6 +1166,7 @@ vector<Ref<Symbol>> BinaryView::GetSymbols()
BNSymbol** syms = BNGetSymbols(m_object, &count);
vector<Ref<Symbol>> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
result.push_back(new Symbol(BNNewSymbolReference(syms[i])));
@@ -1184,6 +1181,7 @@ vector<Ref<Symbol>> BinaryView::GetSymbols(uint64_t start, uint64_t len)
BNSymbol** syms = BNGetSymbolsInRange(m_object, start, len, &count);
vector<Ref<Symbol>> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
result.push_back(new Symbol(BNNewSymbolReference(syms[i])));
@@ -1198,6 +1196,7 @@ vector<Ref<Symbol>> BinaryView::GetSymbolsOfType(BNSymbolType type)
BNSymbol** syms = BNGetSymbolsOfType(m_object, type, &count);
vector<Ref<Symbol>> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
result.push_back(new Symbol(BNNewSymbolReference(syms[i])));
@@ -1212,6 +1211,7 @@ vector<Ref<Symbol>> BinaryView::GetSymbolsOfType(BNSymbolType type, uint64_t sta
BNSymbol** syms = BNGetSymbolsOfTypeInRange(m_object, type, start, len, &count);
vector<Ref<Symbol>> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
result.push_back(new Symbol(BNNewSymbolReference(syms[i])));
@@ -1351,6 +1351,16 @@ BNAnalysisProgress BinaryView::GetAnalysisProgress()
}
+Ref<BackgroundTask> BinaryView::GetBackgroundAnalysisTask()
+{
+ BNBackgroundTask* task = BNGetBackgroundAnalysisTask(m_object);
+ if (!task)
+ return nullptr;
+
+ return new BackgroundTask(BNNewBackgroundTaskReference(task));
+}
+
+
uint64_t BinaryView::GetNextFunctionStartAfterAddress(uint64_t addr)
{
return BNGetNextFunctionStartAfterAddress(m_object, addr);
@@ -1424,6 +1434,7 @@ vector<LinearDisassemblyLine> BinaryView::GetPreviousLinearDisassemblyLines(Line
settings ? settings->GetObject() : nullptr, &count);
vector<LinearDisassemblyLine> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
{
LinearDisassemblyLine line;
@@ -1432,6 +1443,7 @@ vector<LinearDisassemblyLine> BinaryView::GetPreviousLinearDisassemblyLines(Line
line.block = lines[i].block ? new BasicBlock(BNNewBasicBlockReference(lines[i].block)) : nullptr;
line.lineOffset = lines[i].lineOffset;
line.contents.addr = lines[i].contents.addr;
+ line.contents.tokens.reserve(lines[i].contents.count);
for (size_t j = 0; j < lines[i].contents.count; j++)
{
InstructionTextToken token;
@@ -1470,6 +1482,7 @@ vector<LinearDisassemblyLine> BinaryView::GetNextLinearDisassemblyLines(LinearDi
settings ? settings->GetObject() : nullptr, &count);
vector<LinearDisassemblyLine> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
{
LinearDisassemblyLine line;
@@ -1478,6 +1491,7 @@ vector<LinearDisassemblyLine> BinaryView::GetNextLinearDisassemblyLines(LinearDi
line.block = lines[i].block ? new BasicBlock(BNNewBasicBlockReference(lines[i].block)) : nullptr;
line.lineOffset = lines[i].lineOffset;
line.contents.addr = lines[i].contents.addr;
+ line.contents.tokens.reserve(lines[i].contents.count);
for (size_t j = 0; j < lines[i].contents.count; j++)
{
InstructionTextToken token;
@@ -1716,6 +1730,7 @@ vector<Segment> BinaryView::GetSegments()
BNSegment* segments = BNGetSegments(m_object, &count);
vector<Segment> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
{
Segment segment;
@@ -1789,6 +1804,7 @@ vector<Section> BinaryView::GetSections()
BNSection* sections = BNGetSections(m_object, &count);
vector<Section> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
{
Section section;
@@ -1816,6 +1832,7 @@ vector<Section> BinaryView::GetSectionsAt(uint64_t addr)
BNSection* sections = BNGetSectionsAt(m_object, addr, &count);
vector<Section> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
{
Section section;
@@ -1867,6 +1884,7 @@ vector<string> BinaryView::GetUniqueSectionNames(const vector<string>& names)
char** outgoingNames = BNGetUniqueSectionNames(m_object, incomingNames, names.size());
vector<string> result;
+ result.reserve(names.size());
for (size_t i = 0; i < names.size(); i++)
result.push_back(outgoingNames[i]);
diff --git a/binaryviewtype.cpp b/binaryviewtype.cpp
index e23838f6..e8ef4f53 100644
--- a/binaryviewtype.cpp
+++ b/binaryviewtype.cpp
@@ -83,6 +83,7 @@ vector<Ref<BinaryViewType>> BinaryViewType::GetViewTypes()
types = BNGetBinaryViewTypes(&count);
vector<Ref<BinaryViewType>> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
result.push_back(new CoreBinaryViewType(types[i]));
@@ -98,6 +99,7 @@ vector<Ref<BinaryViewType>> BinaryViewType::GetViewTypesForData(BinaryView* data
types = BNGetBinaryViewTypesForData(data->GetObject(), &count);
vector<Ref<BinaryViewType>> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
result.push_back(new CoreBinaryViewType(types[i]));
diff --git a/docs/about/open-source.md b/docs/about/open-source.md
index 9f385633..a25fb24e 100644
--- a/docs/about/open-source.md
+++ b/docs/about/open-source.md
@@ -42,12 +42,12 @@ The previous tools are used in the generation of our documentation, but are not
## Building Qt
-Binary Ninja uses [Qt 5.6] under an LGPLv3 license which requires that we host the original sources used to build Qt for our application along with instructions on how that source may be re-built and can replace the version of Qt shipped with Binary Ninja.
+Binary Ninja uses [Qt 5.10] under an LGPLv3 license which requires that we host the original sources used to build Qt for our application along with instructions on how that source may be re-built and can replace the version of Qt shipped with Binary Ninja.
Please note that we offer no support for running Binary Ninja with modified Qt libraries.
1. Follow the installation requirements on the [Building Qt 5 from Git] page.
-2. Download the Qt 5.6.0 [tarball] from binary.ninja. (Note this is an unmodified 5.6 identical to that available from Qt's source control, but must be hosted locally according to the [Qt 5.6] terms.)
+2. Download the Qt 5.10.0 [tarball] from binary.ninja. (Note this is an unmodified 5.10 identical to that available from Qt's source control, but must be hosted locally according to the [Qt 5.10] terms.)
3. Next, build QT using the aforementioned instructions.
4. On OS X, you will need to disable the code-signing signature since it would otherwise prevent changes to binaries or shared libraries. We recommend a tool such as [unsign].
5. Finally, replace the built libraries:
@@ -56,7 +56,7 @@ Please note that we offer no support for running Binary Ninja with modified Qt l
- On Linux, replace the `libQt5Core.so.5`, `libQt5DBus.so.5`, `libQt5Gui.so.5`, `libQt5Network.so.5`, `libQt5Widgets.so.5`, `libQt5XcbQpa.so.5` files wherever Binary Ninja was extracted
[Building Qt 5 from Git]: https://wiki.qt.io/Building-Qt-5-from-Git
-[Qt 5.6]: https://www.qt.io/qt-licensing-terms/
+[Qt 5.10]: https://www.qt.io/qt-licensing-terms/
[capstone]: https://github.com/aquynh/capstone
[capstone license]: https://github.com/aquynh/capstone/blob/master/LICENSE.TXT
[breathe license]: https://github.com/michaeljones/breathe/blob/master/LICENSE
@@ -97,7 +97,7 @@ Please note that we offer no support for running Binary Ninja with modified Qt l
[sphinx]: http://www.sphinx-doc.org/en/stable/index.html
[sqlite license]: https://www.sqlite.org/copyright.html
[sqlite]: https://www.sqlite.org/index.html
-[tarball]: https://binary.ninja/qt5.6.0.tar.xz
+[tarball]: https://binary.ninja/qt5.10.0.tar.xz
[tomcrypt license]: https://github.com/libtom/libtomcrypt/blob/develop/LICENSE
[tomcrypt]: https://github.com/libtom/libtomcrypt
[unsign]: https://github.com/steakknife/unsign
diff --git a/docs/getting-started.md b/docs/getting-started.md
index 88945f7b..e34121c1 100644
--- a/docs/getting-started.md
+++ b/docs/getting-started.md
@@ -210,15 +210,15 @@ By default the interactive python prompt has a number of convenient helper funct
- `bv` / `current_view` / : the current [BinaryView](https://api.binary.ninja/binaryninja.BinaryView.html)
- `current_function`: the current [Function](https://api.binary.ninja/binaryninja.Function.html)
- `current_basic_block`: the current [BasicBlock](https://api.binary.ninja/binaryninja.BasicBlock.html)
-- `current_llil`: the current [LowLevelILBasicBlock](https://api.binary.ninja/binaryninja.lowlevelil.LowLevelILBasicBlock.html)
-- `current_mlil`: the current [MediumLevelILBasicBlock](https://api.binary.ninja/binaryninja.mediumlevelil.MediumLevelILBasicBlock.html)
+- `current_llil`: the current [LowLevelILFunction](https://api.binary.ninja/binaryninja.lowlevelil.LowLevelILFunction.html)
+- `current_mlil`: the current [MediumLevelILFunction](https://api.binary.ninja/binaryninja.mediumlevelil.MediumLevelILFunction.html)
- `current_selection`: a tuple of the start and end addresses of the current selection
- `write_at_cursor(data)`: function that writes data to the start of the current selection
- `get_selected_data()`: function that returns the data in the current selection
Note
!!! Tip "Note"
- The current script console only supports Python at the moment, but it's fully extensible for other programming languages for advanced users who with to implement their own bindings.
+ The current script console only supports Python at the moment, but it's fully extensible for other programming languages for advanced users who wish to implement their own bindings.
## Using Plugins
diff --git a/function.cpp b/function.cpp
index cd9be4d5..ab5f0ea3 100644
--- a/function.cpp
+++ b/function.cpp
@@ -174,6 +174,7 @@ vector<Ref<BasicBlock>> Function::GetBasicBlocks() const
BNBasicBlock** blocks = BNGetFunctionBasicBlockList(m_object, &count);
vector<Ref<BasicBlock>> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
result.push_back(new BasicBlock(BNNewBasicBlockReference(blocks[i])));
@@ -379,6 +380,7 @@ vector<StackVariableReference> Function::GetStackVariablesReferencedByInstructio
BNStackVariableReference* refs = BNGetStackVariablesReferencedByInstruction(m_object, arch->GetObject(), addr, &count);
vector<StackVariableReference> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
{
StackVariableReference ref;
@@ -514,14 +516,9 @@ Confidence<vector<Variable>> Function::GetParameterVariables() const
{
BNParameterVariablesWithConfidence vars = BNGetFunctionParameterVariables(m_object);
vector<Variable> varList;
+ varList.reserve(vars.count);
for (size_t i = 0; i < vars.count; i++)
- {
- Variable var;
- var.type = vars.vars[i].type;
- var.index = vars.vars[i].index;
- var.storage = vars.vars[i].storage;
- varList.push_back(var);
- }
+ varList.emplace_back(vars.vars[i].type, vars.vars[i].index, vars.vars[i].storage);
Confidence<vector<Variable>> result(varList, vars.confidence);
BNFreeParameterVariables(&vars);
return result;
@@ -606,13 +603,14 @@ void Function::SetAutoCallingConvention(const Confidence<Ref<CallingConvention>>
void Function::SetAutoParameterVariables(const Confidence<vector<Variable>>& vars)
{
BNParameterVariablesWithConfidence varConf;
- varConf.vars = new BNVariable[vars.GetValue().size()];
- varConf.count = vars.GetValue().size();
- for (size_t i = 0; i < vars.GetValue().size(); i++)
+ varConf.vars = new BNVariable[vars->size()];
+ varConf.count = vars->size();
+ size_t i = 0;
+ for (auto it = vars->begin(); it != vars->end(); ++it, ++i)
{
- varConf.vars[i].type = vars.GetValue()[i].type;
- varConf.vars[i].index = vars.GetValue()[i].index;
- varConf.vars[i].storage = vars.GetValue()[i].storage;
+ varConf.vars[i].type = it->type;
+ varConf.vars[i].index = it->index;
+ varConf.vars[i].storage = it->storage;
}
varConf.confidence = vars.GetConfidence();
@@ -667,11 +665,12 @@ void Function::SetAutoRegisterStackAdjustments(const map<uint32_t, Confidence<in
void Function::SetAutoClobberedRegisters(const Confidence<std::set<uint32_t>>& clobbered)
{
BNRegisterSetWithConfidence regs;
- regs.regs = new uint32_t[clobbered.GetValue().size()];
- regs.count = clobbered.GetValue().size();
+ regs.regs = new uint32_t[clobbered->size()];
+ regs.count = clobbered->size();
+
size_t i = 0;
- for (auto reg : clobbered.GetValue())
- regs.regs[i++] = reg;
+ for (auto it = clobbered->begin(); it != clobbered->end(); ++it, ++i)
+ regs.regs[i] = *it;
regs.confidence = clobbered.GetConfidence();
BNSetAutoFunctionClobberedRegisters(m_object, &regs);
delete[] regs.regs;
@@ -718,13 +717,14 @@ void Function::SetCallingConvention(const Confidence<Ref<CallingConvention>>& co
void Function::SetParameterVariables(const Confidence<vector<Variable>>& vars)
{
BNParameterVariablesWithConfidence varConf;
- varConf.vars = new BNVariable[vars.GetValue().size()];
- varConf.count = vars.GetValue().size();
- for (size_t i = 0; i < vars.GetValue().size(); i++)
+ varConf.vars = new BNVariable[vars->size()];
+ varConf.count = vars->size();
+ size_t i = 0;
+ for (auto it = vars->begin(); it != vars->end(); ++it, ++i)
{
- varConf.vars[i].type = vars.GetValue()[i].type;
- varConf.vars[i].index = vars.GetValue()[i].index;
- varConf.vars[i].storage = vars.GetValue()[i].storage;
+ varConf.vars[i].type = it->type;
+ varConf.vars[i].index = it->index;
+ varConf.vars[i].storage = it->storage;
}
varConf.confidence = vars.GetConfidence();
@@ -779,11 +779,11 @@ void Function::SetRegisterStackAdjustments(const map<uint32_t, Confidence<int32_
void Function::SetClobberedRegisters(const Confidence<std::set<uint32_t>>& clobbered)
{
BNRegisterSetWithConfidence regs;
- regs.regs = new uint32_t[clobbered.GetValue().size()];
- regs.count = clobbered.GetValue().size();
+ regs.regs = new uint32_t[clobbered->size()];
+ regs.count = clobbered->size();
size_t i = 0;
- for (auto reg : clobbered.GetValue())
- regs.regs[i++] = reg;
+ for (auto it = clobbered->begin(); it != clobbered->end(); ++it, ++i)
+ regs.regs[i] = *it;
regs.confidence = clobbered.GetConfidence();
BNSetUserFunctionClobberedRegisters(m_object, &regs);
delete[] regs.regs;
@@ -980,6 +980,7 @@ vector<IndirectBranchInfo> Function::GetIndirectBranches()
BNIndirectBranchInfo* branches = BNGetIndirectBranches(m_object, &count);
vector<IndirectBranchInfo> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
{
IndirectBranchInfo b;
@@ -1002,6 +1003,7 @@ vector<IndirectBranchInfo> Function::GetIndirectBranchesAt(Architecture* arch, u
BNIndirectBranchInfo* branches = BNGetIndirectBranchesAt(m_object, arch->GetObject(), addr, &count);
vector<IndirectBranchInfo> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
{
IndirectBranchInfo b;
@@ -1114,9 +1116,11 @@ vector<vector<InstructionTextToken>> Function::GetBlockAnnotations(Architecture*
BNInstructionTextLine* lines = BNGetFunctionBlockAnnotations(m_object, arch->GetObject(), addr, &count);
vector<vector<InstructionTextToken>> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
{
vector<InstructionTextToken> line;
+ line.reserve(lines[i].count);
for (size_t j = 0; j < lines[i].count; j++)
{
InstructionTextToken token;
@@ -1328,10 +1332,12 @@ vector<DisassemblyTextLine> Function::GetTypeTokens(DisassemblySettings* setting
settings ? settings->GetObject() : nullptr, &count);
vector<DisassemblyTextLine> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
{
DisassemblyTextLine line;
line.addr = lines[i].addr;
+ line.tokens.reserve(lines[i].count);
for (size_t j = 0; j < lines[i].count; j++)
{
InstructionTextToken token;
diff --git a/functiongraph.cpp b/functiongraph.cpp
index 7e5ec079..77754913 100644
--- a/functiongraph.cpp
+++ b/functiongraph.cpp
@@ -110,6 +110,7 @@ vector<Ref<FunctionGraphBlock>> FunctionGraph::GetBlocks()
BNFunctionGraphBlock** blocks = BNGetFunctionGraphBlocks(m_graph, &count);
vector<Ref<FunctionGraphBlock>> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
{
auto block = m_cachedBlocks.find(blocks[i]);
@@ -148,6 +149,7 @@ vector<Ref<FunctionGraphBlock>> FunctionGraph::GetBlocksInRegion(int left, int t
BNFunctionGraphBlock** blocks = BNGetFunctionGraphBlocksInRegion(m_graph, left, top, right, bottom, &count);
vector<Ref<FunctionGraphBlock>> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
{
auto block = m_cachedBlocks.find(blocks[i]);
diff --git a/functiongraphblock.cpp b/functiongraphblock.cpp
index 20b2515b..06a35eee 100644
--- a/functiongraphblock.cpp
+++ b/functiongraphblock.cpp
@@ -89,10 +89,12 @@ const vector<DisassemblyTextLine>& FunctionGraphBlock::GetLines()
BNDisassemblyTextLine* lines = BNGetFunctionGraphBlockLines(m_object, &count);
vector<DisassemblyTextLine> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
{
DisassemblyTextLine line;
line.addr = lines[i].addr;
+ line.tokens.reserve(lines[i].count);
for (size_t j = 0; j < lines[i].count; j++)
{
InstructionTextToken token;
@@ -125,6 +127,7 @@ const vector<FunctionGraphEdge>& FunctionGraphBlock::GetOutgoingEdges()
BNFunctionGraphEdge* edges = BNGetFunctionGraphBlockOutgoingEdges(m_object, &count);
vector<FunctionGraphEdge> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
{
FunctionGraphEdge edge;
diff --git a/lowlevelil.cpp b/lowlevelil.cpp
index 0f2b29be..91db6ab3 100644
--- a/lowlevelil.cpp
+++ b/lowlevelil.cpp
@@ -176,6 +176,7 @@ vector<uint64_t> LowLevelILFunction::GetOperandList(ExprId expr, size_t listOper
size_t count;
uint64_t* operands = BNLowLevelILGetOperandList(m_object, expr, listOperand, &count);
vector<uint64_t> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
result.push_back(operands[i]);
BNLowLevelILFreeOperandList(operands);
@@ -429,19 +430,10 @@ bool LowLevelILFunction::GetExprText(Architecture* arch, ExprId expr, vector<Ins
return false;
tokens.clear();
+ tokens.reserve(count);
for (size_t i = 0; i < count; i++)
- {
- InstructionTextToken token;
- token.type = list[i].type;
- token.text = list[i].text;
- token.value = list[i].value;
- token.size = list[i].size;
- token.operand = list[i].operand;
- token.context = list[i].context;
- token.confidence = list[i].confidence;
- token.address = list[i].address;
- tokens.push_back(token);
- }
+ tokens.emplace_back(list[i].type, list[i].context, list[i].text, list[i].address, list[i].value, list[i].size,
+ list[i].operand, list[i].confidence);
BNFreeInstructionText(list, count);
return true;
@@ -458,19 +450,10 @@ bool LowLevelILFunction::GetInstructionText(Function* func, Architecture* arch,
return false;
tokens.clear();
+ tokens.reserve(count);
for (size_t i = 0; i < count; i++)
- {
- InstructionTextToken token;
- token.type = list[i].type;
- token.text = list[i].text;
- token.value = list[i].value;
- token.size = list[i].size;
- token.operand = list[i].operand;
- token.context = list[i].context;
- token.confidence = list[i].confidence;
- token.address = list[i].address;
- tokens.push_back(token);
- }
+ tokens.emplace_back(list[i].type, list[i].context, list[i].text, list[i].address, list[i].value, list[i].size,
+ list[i].operand, list[i].confidence);
BNFreeInstructionText(list, count);
return true;
@@ -495,6 +478,7 @@ vector<Ref<BasicBlock>> LowLevelILFunction::GetBasicBlocks() const
BNBasicBlock** blocks = BNGetLowLevelILBasicBlockList(m_object, &count);
vector<Ref<BasicBlock>> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
result.push_back(new BasicBlock(BNNewBasicBlockReference(blocks[i])));
diff --git a/lowlevelilinstruction.cpp b/lowlevelilinstruction.cpp
index 32425784..8fb87a9e 100644
--- a/lowlevelilinstruction.cpp
+++ b/lowlevelilinstruction.cpp
@@ -241,15 +241,16 @@ unordered_map<BNLowLevelILOperation, vector<LowLevelILOperandUsage>>
};
-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());
for (auto& operation : LowLevelILInstructionBase::operationOperandUsage)
{
result[operation.first] = unordered_map<LowLevelILOperandUsage, size_t>();
size_t operand = 0;
+ result[operation.first].reserve(operation.second.size());
for (auto usage : operation.second)
{
result[operation.first][usage] = operand;
@@ -620,7 +621,7 @@ uint64_t LowLevelILIntegerList::ListIterator::operator*()
LowLevelILIntegerList::LowLevelILIntegerList(LowLevelILFunction* func,
- const BNLowLevelILInstruction& instr, size_t count)
+const BNLowLevelILInstruction& instr, size_t count)
{
m_start.function = func;
#ifdef BINARYNINJACORE_LIBRARY
diff --git a/mediumlevelil.cpp b/mediumlevelil.cpp
index 04a7341f..0a28bd49 100644
--- a/mediumlevelil.cpp
+++ b/mediumlevelil.cpp
@@ -157,6 +157,7 @@ vector<uint64_t> MediumLevelILFunction::GetOperandList(ExprId expr, size_t listO
size_t count;
uint64_t* operands = BNMediumLevelILGetOperandList(m_object, expr, listOperand, &count);
vector<uint64_t> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
result.push_back(operands[i]);
BNMediumLevelILFreeOperandList(operands);
@@ -338,19 +339,10 @@ bool MediumLevelILFunction::GetExprText(Architecture* arch, ExprId expr, vector<
return false;
tokens.clear();
+ tokens.reserve(count);
for (size_t i = 0; i < count; i++)
- {
- InstructionTextToken token;
- token.type = list[i].type;
- token.text = list[i].text;
- token.value = list[i].value;
- token.size = list[i].size;
- token.operand = list[i].operand;
- token.context = list[i].context;
- token.confidence = list[i].confidence;
- token.address = list[i].address;
- tokens.push_back(token);
- }
+ tokens.emplace_back(list[i].type, list[i].context, list[i].text, list[i].address, list[i].value, list[i].size,
+ list[i].operand, list[i].confidence);
BNFreeInstructionText(list, count);
return true;
@@ -367,19 +359,10 @@ bool MediumLevelILFunction::GetInstructionText(Function* func, Architecture* arc
return false;
tokens.clear();
+ tokens.reserve(count);
for (size_t i = 0; i < count; i++)
- {
- InstructionTextToken token;
- token.type = list[i].type;
- token.text = list[i].text;
- token.value = list[i].value;
- token.size = list[i].size;
- token.operand = list[i].operand;
- token.context = list[i].context;
- token.confidence = list[i].confidence;
- token.address = list[i].address;
- tokens.push_back(token);
- }
+ tokens.emplace_back(list[i].type, list[i].context, list[i].text, list[i].address, list[i].value, list[i].size,
+ list[i].operand, list[i].confidence);
BNFreeInstructionText(list, count);
return true;
@@ -412,6 +395,7 @@ vector<Ref<BasicBlock>> MediumLevelILFunction::GetBasicBlocks() const
BNBasicBlock** blocks = BNGetMediumLevelILBasicBlockList(m_object, &count);
vector<Ref<BasicBlock>> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
result.push_back(new BasicBlock(BNNewBasicBlockReference(blocks[i])));
@@ -696,6 +680,7 @@ unordered_map<size_t, BNILBranchDependence> MediumLevelILFunction::GetAllBranchD
BNILBranchInstructionAndDependence* deps = BNGetAllMediumLevelILBranchDependence(m_object, instr, &count);
unordered_map<size_t, BNILBranchDependence> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
result[deps[i].branch] = deps[i].dependence;
diff --git a/mediumlevelilinstruction.cpp b/mediumlevelilinstruction.cpp
index 39ab4f28..586eb470 100644
--- a/mediumlevelilinstruction.cpp
+++ b/mediumlevelilinstruction.cpp
@@ -231,14 +231,14 @@ unordered_map<BNMediumLevelILOperation, vector<MediumLevelILOperandUsage>>
};
-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());
for (auto& operation : MediumLevelILInstructionBase::operationOperandUsage)
{
result[operation.first] = unordered_map<MediumLevelILOperandUsage, size_t>();
-
+ result[operation.first].reserve(operation.second.size());
size_t operand = 0;
for (auto usage : operation.second)
{
diff --git a/metadata.cpp b/metadata.cpp
index f9c48b04..c111233f 100644
--- a/metadata.cpp
+++ b/metadata.cpp
@@ -144,6 +144,7 @@ vector<Ref<Metadata>> Metadata::GetArray()
size_t size = 0;
BNMetadata** data = BNMetadataGetArray(m_object, &size);
vector<Ref<Metadata>> result;
+ result.reserve(size);
for (size_t i = 0; i < size; i++)
result.push_back(new Metadata(data[i]));
return result;
diff --git a/platform.cpp b/platform.cpp
index a9ab888f..724901fe 100644
--- a/platform.cpp
+++ b/platform.cpp
@@ -72,6 +72,7 @@ vector<Ref<Platform>> Platform::GetList()
BNPlatform** list = BNGetPlatformList(&count);
vector<Ref<Platform>> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
result.push_back(new Platform(BNNewPlatformReference(list[i])));
@@ -86,6 +87,7 @@ vector<Ref<Platform>> Platform::GetList(Architecture* arch)
BNPlatform** list = BNGetPlatformListByArchitecture(arch->GetObject(), &count);
vector<Ref<Platform>> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
result.push_back(new Platform(BNNewPlatformReference(list[i])));
@@ -100,6 +102,7 @@ vector<Ref<Platform>> Platform::GetList(const string& os)
BNPlatform** list = BNGetPlatformListByOS(os.c_str(), &count);
vector<Ref<Platform>> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
result.push_back(new Platform(BNNewPlatformReference(list[i])));
@@ -114,6 +117,7 @@ vector<Ref<Platform>> Platform::GetList(const string& os, Architecture* arch)
BNPlatform** list = BNGetPlatformListByOSAndArchitecture(os.c_str(), arch->GetObject(), &count);
vector<Ref<Platform>> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
result.push_back(new Platform(BNNewPlatformReference(list[i])));
@@ -128,6 +132,7 @@ vector<std::string> Platform::GetOSList()
char** list = BNGetPlatformOSList(&count);
vector<string> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
result.push_back(list[i]);
@@ -178,6 +183,7 @@ vector<Ref<CallingConvention>> Platform::GetCallingConventions() const
BNCallingConvention** list = BNGetPlatformCallingConventions(m_object, &count);
vector<Ref<CallingConvention>> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
result.push_back(new CoreCallingConvention(BNNewCallingConventionReference(list[i])));
diff --git a/plugin.cpp b/plugin.cpp
index e8dd881d..972ce28b 100644
--- a/plugin.cpp
+++ b/plugin.cpp
@@ -211,8 +211,9 @@ vector<PluginCommand> PluginCommand::GetList()
vector<PluginCommand> result;
size_t count;
BNPluginCommand* commands = BNGetAllPluginCommands(&count);
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
- result.push_back(PluginCommand(commands[i]));
+ result.emplace_back(commands[i]);
BNFreePluginCommandList(commands);
return result;
}
diff --git a/python/binaryview.py b/python/binaryview.py
index 6eb59db1..fae98c14 100644
--- a/python/binaryview.py
+++ b/python/binaryview.py
@@ -2095,6 +2095,8 @@ class BinaryView(object):
"""
if plat is None:
plat = self.platform
+ if plat is None:
+ return None
func = core.BNGetAnalysisFunction(self.handle, plat.handle, addr)
if func is None:
return None
@@ -3398,7 +3400,7 @@ class BinaryView(object):
return None
result = Section(section.name, section.type, section.start, section.length, section.linkedSection,
section.infoSection, section.infoData, section.align, section.entrySize, section.semantics,
- section_list.autoDefined)
+ section.autoDefined)
core.BNFreeSection(section)
return result
diff --git a/python/plugin.py b/python/plugin.py
index f038d122..e0054d86 100644
--- a/python/plugin.py
+++ b/python/plugin.py
@@ -168,6 +168,17 @@ class PluginCommand(object):
@classmethod
def register(cls, name, description, action, is_valid = None):
+ """
+ ``register`` Register a plugin
+
+ :param str name: name of the plugin
+ :param str description: description of the plugin
+ :param action: function to call with the ``BinaryView`` as an argument
+ :param is_valid: optional argument of a function passed a ``BinaryView`` to determine whether the plugin should be enabled for that view
+ :rtype: None
+
+ .. warning:: Calling ``register`` with the same function name will replace the existing function but will leak the memory of the original plugin.
+ """
startup._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))
@@ -176,6 +187,17 @@ class PluginCommand(object):
@classmethod
def register_for_address(cls, name, description, action, is_valid = None):
+ """
+ ``register_for_address`` Register a plugin to be called with an address argument
+
+ :param str name: name of the plugin
+ :param str description: description of the plugin
+ :param action: function to call with the ``BinaryView`` and address as arguments
+ :param is_valid: optional argument of a function passed a ``BinaryView`` to determine whether the plugin should be enabled for that view
+ :rtype: None
+
+ .. warning:: Calling ``register_for_address`` with the same function name will replace the existing function but will leak the memory of the original plugin.
+ """
startup._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))
@@ -184,6 +206,17 @@ class PluginCommand(object):
@classmethod
def register_for_range(cls, name, description, action, is_valid = None):
+ """
+ ``register_for_range`` Register a plugin to be called with a range argument
+
+ :param str name: name of the plugin
+ :param str description: description of the plugin
+ :param action: function to call with the ``BinaryView`` and ``AddressRange`` as arguments
+ :param is_valid: optional argument of a function passed a ``BinaryView`` to determine whether the plugin should be enabled for that view
+ :rtype: None
+
+ .. warning:: Calling ``register_for_range`` with the same function name will replace the existing function but will leak the memory of the original plugin.
+ """
startup._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))
@@ -192,6 +225,17 @@ class PluginCommand(object):
@classmethod
def register_for_function(cls, name, description, action, is_valid = None):
+ """
+ ``register_for_function`` Register a plugin to be called with a function argument
+
+ :param str name: name of the plugin
+ :param str description: description of the plugin
+ :param action: function to call with the ``BinaryView`` and a ``Function`` as arguments
+ :param is_valid: optional argument of a function passed a ``BinaryView`` to determine whether the plugin should be enabled for that view
+ :rtype: None
+
+ .. warning:: Calling ``register_for_function`` with the same function name will replace the existing function but will leak the memory of the original plugin.
+ """
startup._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))
@@ -200,11 +244,12 @@ class PluginCommand(object):
@classmethod
def get_valid_list(cls, context):
+ """Dict of registered plugins"""
commands = cls.list
- result = []
+ result = {}
for cmd in commands:
if cmd.is_valid(context):
- result.append(cmd)
+ result[cmd.name] = cmd
return result
def is_valid(self, context):
diff --git a/python/types.py b/python/types.py
index d44cc736..42ed7ddd 100644
--- a/python/types.py
+++ b/python/types.py
@@ -471,6 +471,7 @@ class Type(object):
:param int width: width of the integer in bytes
:param bool sign: optional variable representing signedness
+ :param string altname: alternate name for type
"""
if sign is None:
sign = BoolWithConfidence(True, confidence = 0)
@@ -484,8 +485,14 @@ class Type(object):
return Type(core.BNCreateIntegerType(width, sign_conf, altname))
@classmethod
- def float(self, width):
- return Type(core.BNCreateFloatType(width))
+ def float(self, width, altname=""):
+ """
+ ``float`` class method for creating an floating point Types.
+
+ :param int width: width of the floating point number in bytes
+ :param string altname: alternate name for type
+ """
+ return Type(core.BNCreateFloatType(width, altname))
@classmethod
def structure_type(self, structure_type):
@@ -515,10 +522,10 @@ class Type(object):
return Type(core.BNCreateNamedTypeReferenceFromType(view.handle, name))
@classmethod
- def enumeration_type(self, arch, e, width=None):
+ def enumeration_type(self, arch, e, width=None, sign=False):
if width is None:
width = arch.default_int_size
- return Type(core.BNCreateEnumerationType(e.handle, width))
+ return Type(core.BNCreateEnumerationType(arch.handle, e.handle, width, sign))
@classmethod
def pointer(self, arch, t, const=None, volatile=None, ref_type=None):
@@ -634,7 +641,7 @@ class Type(object):
return core.BNGenerateAutoDemangledTypeId(name)
@classmethod
- def get_auto_demanged_type_id_source(self):
+ def get_auto_demangled_type_id_source(self):
return core.BNGetAutoDemangledTypeIdSource()
def with_confidence(self, confidence):
diff --git a/settings.cpp b/settings.cpp
index 328cf0e3..b5899e38 100644
--- a/settings.cpp
+++ b/settings.cpp
@@ -51,8 +51,9 @@ std::vector<std::string> Setting::GetStringList(const std::string& pluginName,
char** outBuffer = (char**)BNSettingGetStringList(pluginName.c_str(), name.c_str(), (const char**)buffer, &size);
vector<string> result;
+ result.reserve(size);
for (size_t i = 0; i < size; i++)
- result.push_back(string(outBuffer[i]));
+ result.emplace_back(outBuffer[i]);
for (size_t i = 0; i < defaultValue.size(); i++)
BNFreeString(buffer[i]);
@@ -171,4 +172,4 @@ bool Setting::RemoveSetting(const std::string& settingGroup, const std::string&
bool Setting::FlushSettings()
{
return BNSettingFlushSettings();
-} \ No newline at end of file
+}
diff --git a/transform.cpp b/transform.cpp
index 29a665d0..0a6fdfe6 100644
--- a/transform.cpp
+++ b/transform.cpp
@@ -157,6 +157,7 @@ vector<Ref<Transform>> Transform::GetTransformTypes()
BNTransform** list = BNGetTransformTypeList(&count);
vector<Ref<Transform>> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
result.push_back(new CoreTransform(list[i]));
@@ -229,6 +230,7 @@ vector<TransformParameter> CoreTransform::GetParameters() const
BNTransformParameterInfo* list = BNGetTransformParameterList(m_object, &count);
vector<TransformParameter> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
{
TransformParameter param;
diff --git a/type.cpp b/type.cpp
index 40a69ae2..08b64713 100644
--- a/type.cpp
+++ b/type.cpp
@@ -355,6 +355,7 @@ vector<FunctionParameter> Type::GetParameters() const
BNFunctionParameter* types = BNGetTypeParameters(m_object, &count);
vector<FunctionParameter> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
{
FunctionParameter param;
@@ -474,19 +475,10 @@ vector<InstructionTextToken> Type::GetTokens(Platform* platform, uint8_t baseCon
platform ? platform->GetObject() : nullptr, baseConfidence, &count);
vector<InstructionTextToken> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
- {
- InstructionTextToken token;
- token.type = tokens[i].type;
- token.text = tokens[i].text;
- token.value = tokens[i].value;
- token.size = tokens[i].size;
- token.operand = tokens[i].operand;
- token.context = tokens[i].context;
- token.confidence = tokens[i].confidence;
- token.address = tokens[i].address;
- result.push_back(token);
- }
+ result.emplace_back(tokens[i].type, tokens[i].context, tokens[i].text, tokens[i].address, tokens[i].value, tokens[i].size,
+ tokens[i].operand, tokens[i].confidence);
BNFreeTokenList(tokens, count);
return result;
@@ -500,19 +492,10 @@ vector<InstructionTextToken> Type::GetTokensBeforeName(Platform* platform, uint8
platform ? platform->GetObject() : nullptr, baseConfidence, &count);
vector<InstructionTextToken> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
- {
- InstructionTextToken token;
- token.type = tokens[i].type;
- token.text = tokens[i].text;
- token.value = tokens[i].value;
- token.size = tokens[i].size;
- token.operand = tokens[i].operand;
- token.context = tokens[i].context;
- token.confidence = tokens[i].confidence;
- token.address = tokens[i].address;
- result.push_back(token);
- }
+ result.emplace_back(tokens[i].type, tokens[i].context, tokens[i].text, tokens[i].address, tokens[i].value, tokens[i].size,
+ tokens[i].operand, tokens[i].confidence);
BNFreeTokenList(tokens, count);
return result;
@@ -526,19 +509,10 @@ vector<InstructionTextToken> Type::GetTokensAfterName(Platform* platform, uint8_
platform ? platform->GetObject() : nullptr, baseConfidence, &count);
vector<InstructionTextToken> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
- {
- InstructionTextToken token;
- token.type = tokens[i].type;
- token.text = tokens[i].text;
- token.value = tokens[i].value;
- token.size = tokens[i].size;
- token.operand = tokens[i].operand;
- token.context = tokens[i].context;
- token.confidence = tokens[i].confidence;
- token.address = tokens[i].address;
- result.push_back(token);
- }
+ result.emplace_back(tokens[i].type, tokens[i].context, tokens[i].text, tokens[i].address, tokens[i].value, tokens[i].size,
+ tokens[i].operand, tokens[i].confidence);
BNFreeTokenList(tokens, count);
return result;
@@ -906,6 +880,7 @@ vector<StructureMember> Structure::GetMembers() const
BNStructureMember* members = BNGetStructureMembers(m_object, &count);
vector<StructureMember> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
{
StructureMember member;
@@ -1025,6 +1000,7 @@ vector<EnumerationMember> Enumeration::GetMembers() const
BNEnumerationMember* members = BNGetEnumerationMembers(m_object, &count);
vector<EnumerationMember> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
{
EnumerationMember member;
diff --git a/update.cpp b/update.cpp
index 0ec69892..ecdf4162 100644
--- a/update.cpp
+++ b/update.cpp
@@ -53,6 +53,7 @@ vector<UpdateChannel> UpdateChannel::GetList()
}
vector<UpdateChannel> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
{
UpdateChannel channel;
@@ -149,6 +150,7 @@ vector<UpdateVersion> UpdateVersion::GetChannelVersions(const string& channel)
}
vector<UpdateVersion> result;
+ result.reserve(count);
for (size_t i = 0; i < count; i++)
{
UpdateVersion version;