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>(
155155 instr_bytes. truncate ( instr_info. length ) ;
156156
157157 // 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) {
159159 // If instruction is blacklisted, don't include the bytes.
160160 if is_blacklisted_instruction ( & lifted_il_instr) {
161161 continue ;
@@ -164,6 +164,7 @@ pub fn basic_block_guid<M: FunctionMutability>(
164164 if is_variant_instruction ( relocatable_regions, & lifted_il_instr) {
165165 // Found a variant instruction, mask off the entire instruction.
166166 instr_bytes. fill ( 0 ) ;
167+ break ;
167168 }
168169 }
169170
@@ -177,10 +178,11 @@ pub fn basic_block_guid<M: FunctionMutability>(
177178 // TODO: A "mapped llil" or having some simple data flow, the simple data flow is the most attractive
178179 // TODO: "solution", but it would require
179180 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) {
181182 if is_computed_variant_instruction ( relocatable_regions, & low_level_instr) {
182183 // Found a computed variant instruction, mask off the entire instruction.
183184 instr_bytes. fill ( 0 ) ;
185+ break ;
184186 }
185187 }
186188 }
Original file line number Diff line number Diff line change @@ -51,15 +51,15 @@ impl HighlightRenderLayer {
5151 let relocatable_regions = relocatable_regions ( & lifted_il. function ( ) . view ( ) ) ;
5252 for line in lines {
5353 // 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 ) {
5555 if is_blacklisted_instruction ( & lifted_il_instr) {
5656 line. highlight = self . blacklist ;
5757 } else if is_variant_instruction ( & relocatable_regions, & lifted_il_instr) {
5858 line. highlight = self . variant ;
5959 }
6060 }
6161
62- if let Some ( llil_instr) = llil. instruction_at ( line. address ) {
62+ for llil_instr in llil. instructions_at ( line. address ) {
6363 if is_computed_variant_instruction ( & relocatable_regions, & llil_instr) {
6464 line. highlight = self . computed_variant ;
6565 }
Original file line number Diff line number Diff line change 9393 }
9494 }
9595
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+
96121 pub fn instruction_at < L : Into < Location > > ( & self , loc : L ) -> Option < LowLevelILInstruction < M , F > > {
97122 Some ( LowLevelILInstruction :: new (
98123 self ,
You can’t perform that action at this time.
0 commit comments