@@ -9,6 +9,23 @@ extern "C"
9
9
10
10
BINARYNINJAPLUGIN bool CorePluginInit ()
11
11
{
12
+ auto settings = Settings::Instance ();
13
+ settings->RegisterGroup (" nativePredicateSolver" , " Native Predicate Solver" );
14
+ settings->RegisterSetting (" nativePredicateSolver.maxPassesPerFunction" ,
15
+ R"~( {
16
+ "title": "Max passes per function",
17
+ "type": "number",
18
+ "default": 10,
19
+ "description": "Maximum number of passes to run when patching opaque predicates in a single function."
20
+ })~" );
21
+ settings->RegisterSetting (" nativePredicateSolver.maxGlobalPasses" ,
22
+ R"~( {
23
+ "title": "Max global passes",
24
+ "type": "number",
25
+ "default": 20,
26
+ "description": "Maximum number of global passes when patching all functions in the binary."
27
+ })~" );
28
+
12
29
PluginCommand::Register (
13
30
" Native Predicate Solver\\ Patch Opaque Predicates (Current Function)" ,
14
31
" Patch opaque predicates in current function" ,
@@ -45,7 +62,8 @@ extern "C"
45
62
46
63
int totalPatches = 0 ;
47
64
int pass = 1 ;
48
- const int maxPasses = 10 ;
65
+ auto settings = Settings::Instance ();
66
+ const int maxPasses = static_cast <int >(settings->Get <int64_t >(" nativePredicateSolver.maxPassesPerFunction" , viewRef));
49
67
50
68
while (pass <= maxPasses) {
51
69
if (task->IsCancelled ()) {
@@ -111,6 +129,8 @@ extern "C"
111
129
112
130
int globalPass = 1 ;
113
131
int totalGlobalPatches = 0 ;
132
+ auto settings = Settings::Instance ();
133
+ const int maxGlobalPasses = static_cast <int >(settings->Get <int64_t >(" nativePredicateSolver.maxGlobalPasses" , viewRef));
114
134
115
135
while (true ) {
116
136
if (task->IsCancelled ()) {
@@ -148,8 +168,10 @@ extern "C"
148
168
149
169
int funcPatches = 0 ;
150
170
int pass = 1 ;
171
+ auto settings = Settings::Instance ();
172
+ const int maxPassesPerFunction = static_cast <int >(settings->Get <int64_t >(" nativePredicateSolver.maxPassesPerFunction" , viewRef));
151
173
152
- while (pass <= 10 ) {
174
+ while (pass <= maxPassesPerFunction ) {
153
175
int patchCount = 0 ;
154
176
155
177
for (size_t i = 0 ; i < mlil->GetInstructionCount (); ++i) {
@@ -196,7 +218,7 @@ extern "C"
196
218
197
219
globalPass++;
198
220
199
- if (globalPass > 20 ) {
221
+ if (globalPass > maxGlobalPasses ) {
200
222
LogWarn (" [!] Maximum passes reached" );
201
223
break ;
202
224
}
0 commit comments