MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / main

Function main

examples/enterprise_test/src/enterprise_test.cpp:24–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22}
23
24int main(int argc, char* argv[])
25{
26 if (argc != 2)
27 {
28 cerr << "USAGE: " << argv[0] << " <file_name>" << endl;
29 exit(-1);
30 }
31
32 char* fname = argv[1];
33 if (!is_file(fname))
34 {
35 cerr << "Error: " << fname << " is not a regular file" << endl;
36 exit(-1);
37 }
38
39 Enterprise::LicenseCheckout _{};
40
41 /* In order to initiate the bundled plugins properly, the location
42 * of where bundled plugins directory is must be set. */
43 SetBundledPluginDirectory(GetBundledPluginDirectory());
44 InitPlugins();
45
46 Ref<BinaryView> bv = BinaryNinja::Load(fname);
47 if (!bv || bv->GetTypeName() == "Raw")
48 {
49 fprintf(stderr, "Input file does not appear to be an executable\n");
50 return -1;
51 }
52
53 cout << "Target: " << fname << endl << endl;
54 cout << "TYPE: " << bv->GetTypeName() << endl;
55 cout << "START: 0x" << hex << bv->GetStart() << endl;
56 cout << "ENTRY: 0x" << hex << bv->GetEntryPoint() << endl;
57 cout << "PLATFORM: " << bv->GetDefaultPlatform()->GetName() << endl;
58 cout << endl;
59
60 cout << "---------- 10 Functions ----------" << endl;
61 int x = 0;
62 for (auto func : bv->GetAnalysisFunctionList())
63 {
64 cout << hex << func->GetStart() << " " << func->GetSymbol()->GetFullName() << endl;
65 if (++x >= 10)
66 break;
67 }
68 cout << endl;
69
70 cout << "---------- 10 Strings ----------" << endl;
71 x = 0;
72 for (auto str_ref : bv->GetStrings())
73 {
74 char* str = (char*)malloc(str_ref.length + 1);
75 bv->Read(str, str_ref.start, str_ref.length);
76 str[str_ref.length] = 0;
77
78 cout << hex << str_ref.start << " (" << dec << str_ref.length << ") " << str << endl;
79 free(str);
80
81 if (++x >= 10)

Callers

nothing calls this directly

Calls 14

GetEntryPointMethod · 0.80
GetDefaultPlatformMethod · 0.80
GetFullNameMethod · 0.80
GetStringsMethod · 0.80
is_fileFunction · 0.70
LoadFunction · 0.50
GetTypeNameMethod · 0.45
GetStartMethod · 0.45
GetNameMethod · 0.45
GetSymbolMethod · 0.45
ReadMethod · 0.45

Tested by

no test coverage detected