File tree Expand file tree Collapse file tree 3 files changed +12
-7
lines changed Expand file tree Collapse file tree 3 files changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -106,7 +106,8 @@ where
106
106
) -> Option < LowLevelInstructionIndex > {
107
107
use binaryninjacore_sys:: BNLowLevelILGetInstructionStart ;
108
108
let loc: Location = loc. into ( ) ;
109
- let arch = loc. arch . unwrap_or_else ( || * self . arch ( ) . as_ref ( ) ) ;
109
+ // If the location does not specify an architecture, use the function's architecture.
110
+ let arch = loc. arch . unwrap_or_else ( || self . arch ( ) ) ;
110
111
let instr_idx =
111
112
unsafe { BNLowLevelILGetInstructionStart ( self . handle , arch. handle , loc. addr ) } ;
112
113
// `instr_idx` will equal self.instruction_count() if the instruction is not valid.
Original file line number Diff line number Diff line change @@ -47,11 +47,10 @@ impl MediumLevelILFunction {
47
47
loc : L ,
48
48
) -> Option < MediumLevelInstructionIndex > {
49
49
let loc: Location = loc. into ( ) ;
50
- let arch = loc
51
- . arch
52
- . map ( |a| a. handle )
53
- . unwrap_or_else ( std:: ptr:: null_mut) ;
54
- let instr_idx = unsafe { BNMediumLevelILGetInstructionStart ( self . handle , arch, loc. addr ) } ;
50
+ // If the location does not specify an architecture, use the function's architecture.
51
+ let arch = loc. arch . unwrap_or_else ( || self . function ( ) . arch ( ) ) ;
52
+ let instr_idx =
53
+ unsafe { BNMediumLevelILGetInstructionStart ( self . handle , arch. handle , loc. addr ) } ;
55
54
// `instr_idx` will equal self.instruction_count() if the instruction is not valid.
56
55
if instr_idx >= self . instruction_count ( ) {
57
56
None
Original file line number Diff line number Diff line change @@ -164,9 +164,14 @@ fn test_mlil_possible_values() {
164
164
_ => panic ! ( "Expected SetVar" ) ,
165
165
}
166
166
167
+ // As an aside, we also test to make sure `instruction_index_at` works.
168
+ let instr_21_idx = mlil_function
169
+ . instruction_index_at ( image_base + 0x0002af9a )
170
+ . expect ( "Failed to get instruction index" ) ;
171
+
167
172
// 21 @ 0002af9a (MLIL_RET return (MLIL_VAR.d eax_2))
168
173
let instr_21 = mlil_function
169
- . instruction_from_index ( MediumLevelInstructionIndex ( 21 ) )
174
+ . instruction_from_index ( instr_21_idx )
170
175
. expect ( "Failed to get instruction" ) ;
171
176
let lifted_instr_21 = instr_21. lift ( ) ;
172
177
match lifted_instr_21. kind {
You can’t perform that action at this time.
0 commit comments