File tree Expand file tree Collapse file tree 3 files changed +31
-4
lines changed Expand file tree Collapse file tree 3 files changed +31
-4
lines changed Original file line number Diff line number Diff line change @@ -155,7 +155,7 @@ pub fn basic_block_guid<M: FunctionMutability>(
155
155
instr_bytes. truncate ( instr_info. length ) ;
156
156
157
157
// Find variant and blacklisted instructions using lifted il.
158
- if let Some ( lifted_il_instr) = lifted_il. instruction_at ( instr_addr) {
158
+ for lifted_il_instr in lifted_il. instructions_at ( instr_addr) {
159
159
// If instruction is blacklisted, don't include the bytes.
160
160
if is_blacklisted_instruction ( & lifted_il_instr) {
161
161
continue ;
@@ -164,6 +164,7 @@ pub fn basic_block_guid<M: FunctionMutability>(
164
164
if is_variant_instruction ( relocatable_regions, & lifted_il_instr) {
165
165
// Found a variant instruction, mask off the entire instruction.
166
166
instr_bytes. fill ( 0 ) ;
167
+ break ;
167
168
}
168
169
}
169
170
@@ -177,10 +178,11 @@ pub fn basic_block_guid<M: FunctionMutability>(
177
178
// TODO: A "mapped llil" or having some simple data flow, the simple data flow is the most attractive
178
179
// TODO: "solution", but it would require
179
180
if let Ok ( llil) = & low_level_il {
180
- if let Some ( low_level_instr) = llil. instruction_at ( instr_addr) {
181
+ for low_level_instr in llil. instructions_at ( instr_addr) {
181
182
if is_computed_variant_instruction ( relocatable_regions, & low_level_instr) {
182
183
// Found a computed variant instruction, mask off the entire instruction.
183
184
instr_bytes. fill ( 0 ) ;
185
+ break ;
184
186
}
185
187
}
186
188
}
Original file line number Diff line number Diff line change @@ -51,15 +51,15 @@ impl HighlightRenderLayer {
51
51
let relocatable_regions = relocatable_regions ( & lifted_il. function ( ) . view ( ) ) ;
52
52
for line in lines {
53
53
// We use address here instead of index since it's more reliable for other IL's.
54
- if let Some ( lifted_il_instr) = lifted_il. instruction_at ( line. address ) {
54
+ for lifted_il_instr in lifted_il. instructions_at ( line. address ) {
55
55
if is_blacklisted_instruction ( & lifted_il_instr) {
56
56
line. highlight = self . blacklist ;
57
57
} else if is_variant_instruction ( & relocatable_regions, & lifted_il_instr) {
58
58
line. highlight = self . variant ;
59
59
}
60
60
}
61
61
62
- if let Some ( llil_instr) = llil. instruction_at ( line. address ) {
62
+ for llil_instr in llil. instructions_at ( line. address ) {
63
63
if is_computed_variant_instruction ( & relocatable_regions, & llil_instr) {
64
64
line. highlight = self . computed_variant ;
65
65
}
Original file line number Diff line number Diff line change 93
93
}
94
94
}
95
95
96
+ /// Get all the contiguous instructions for a given location.
97
+ ///
98
+ /// NOTE: This won't get you every instruction for a location, only the instructions
99
+ /// that are sequential from the starting instruction.
100
+ pub fn instructions_at < L : Into < Location > > ( & self , loc : L ) -> Vec < LowLevelILInstruction < M , F > > {
101
+ let loc = loc. into ( ) ;
102
+ // TODO: Instructions sharing the same address are not always sequential.
103
+ // Gather all of the sequential instructions with the same address and same block.
104
+ self . instruction_index_at ( loc)
105
+ . map ( |mut idx| {
106
+ let mut instructions = Vec :: new ( ) ;
107
+ let block = self . basic_block_containing_index ( idx) ;
108
+ while idx. 0 < self . instruction_count ( ) {
109
+ let instr = LowLevelILInstruction :: new ( self , idx) ;
110
+ if instr. address ( ) != loc. addr || instr. basic_block ( ) != block {
111
+ break ;
112
+ }
113
+ instructions. push ( instr) ;
114
+ idx = idx. next ( ) ;
115
+ }
116
+ instructions
117
+ } )
118
+ . unwrap_or_default ( )
119
+ }
120
+
96
121
pub fn instruction_at < L : Into < Location > > ( & self , loc : L ) -> Option < LowLevelILInstruction < M , F > > {
97
122
Some ( LowLevelILInstruction :: new (
98
123
self ,
You can’t perform that action at this time.
0 commit comments