diff options
| author | Xusheng <xusheng@vector35.com> | 2024-05-17 17:36:54 +0800 |
|---|---|---|
| committer | Xusheng <xusheng@vector35.com> | 2024-05-17 17:36:54 +0800 |
| commit | df3c57d907cc994d8a660684428a75383f34c69a (patch) | |
| tree | 26e951f006be21e2a117d64edb54823bc9e03189 /examples/llil_parser | |
| parent | e07d7c179d2e7a26b92fd713b132e4949df34f58 (diff) | |
Update C++ example code to use BinaryNinja::Load to open a file. Fix https://github.com/Vector35/binaryninja-api/issues/5429
Diffstat (limited to 'examples/llil_parser')
| -rw-r--r-- | examples/llil_parser/src/llil_parser.cpp | 24 |
1 files changed, 5 insertions, 19 deletions
diff --git a/examples/llil_parser/src/llil_parser.cpp b/examples/llil_parser/src/llil_parser.cpp index af05c8f6..463f44f5 100644 --- a/examples/llil_parser/src/llil_parser.cpp +++ b/examples/llil_parser/src/llil_parser.cpp @@ -292,30 +292,13 @@ int main(int argc, char* argv[]) SetBundledPluginDirectory(GetBundledPluginDirectory()); InitPlugins(); - Ref<BinaryData> bd = BinaryData::CreateFromFilename(new FileMetadata(), argv[1]); - if (!bd) - { - fprintf(stderr, "Could not open input file.\n"); - return -1; - } - Ref<BinaryView> bv; - for (auto type : BinaryViewType::GetViewTypes()) - { - if (type->IsTypeValidForData(bd) && type->GetName() != "Raw") - { - bv = type->Create(bd); - break; - } - } - + Ref<BinaryView> bv = BinaryNinja::Load(argv[1]); if (!bv || bv->GetTypeName() == "Raw") { - fprintf(stderr, "Input file does not appear to be an exectuable\n"); + fprintf(stderr, "Input file does not appear to be an executable\n"); return -1; } - bv->UpdateAnalysisAndWait(); - // Go through all functions in the binary for (auto& func : bv->GetAnalysisFunctionList()) { @@ -398,6 +381,9 @@ int main(int argc, char* argv[]) printf("\n"); } + // Close the file so that the resources can be freed + bv->GetFile()->Close(); + // Shutting down is required to allow for clean exit of the core BNShutdown(); |
