@@ -23,7 +23,7 @@ use crate::{
2323 calling_convention:: CoreCallingConvention ,
2424 data_buffer:: DataBuffer ,
2525 disassembly:: InstructionTextToken ,
26- function:: { ArchAndAddr , Function , NativeBlock } ,
26+ function:: { Function , NativeBlock } ,
2727 platform:: Platform ,
2828 rc:: * ,
2929 relocation:: CoreRelocationHandler ,
@@ -47,6 +47,7 @@ use crate::relocation::{CustomRelocationHandlerHandle, RelocationHandler};
4747use crate :: variable:: IndirectBranchInfo ;
4848
4949use crate :: confidence:: Conf ;
50+ use crate :: function:: Location ;
5051use crate :: low_level_il:: expression:: ValueExpr ;
5152use crate :: low_level_il:: lifting:: {
5253 get_default_flag_cond_llil, get_default_flag_write_llil, LowLevelILFlagWriteOp ,
@@ -1959,7 +1960,7 @@ pub struct BasicBlockAnalysisContext {
19591960
19601961 // In
19611962 pub indirect_branches : Vec < IndirectBranchInfo > ,
1962- pub indirect_no_return_calls : HashSet < ArchAndAddr > ,
1963+ pub indirect_no_return_calls : HashSet < Location > ,
19631964 pub analysis_skip_override : BNFunctionAnalysisSkipOverride ,
19641965 pub guided_analysis_mode : bool ,
19651966 pub trigger_guided_on_invalid_instruction : bool ,
@@ -1969,13 +1970,13 @@ pub struct BasicBlockAnalysisContext {
19691970
19701971 // In/Out
19711972 pub max_size_reached : bool ,
1972- contextual_returns : HashMap < ArchAndAddr , bool > ,
1973+ contextual_returns : HashMap < Location , bool > ,
19731974
19741975 // Out
1975- direct_code_references : HashMap < u64 , ArchAndAddr > ,
1976- direct_no_return_calls : HashSet < ArchAndAddr > ,
1977- halted_disassembly_addresses : HashSet < ArchAndAddr > ,
1978- inlined_unresolved_indirect_branches : HashSet < ArchAndAddr > ,
1976+ direct_code_references : HashMap < u64 , Location > ,
1977+ direct_no_return_calls : HashSet < Location > ,
1978+ halted_disassembly_addresses : HashSet < Location > ,
1979+ inlined_unresolved_indirect_branches : HashSet < Location > ,
19791980}
19801981
19811982impl BasicBlockAnalysisContext {
@@ -1995,15 +1996,15 @@ impl BasicBlockAnalysisContext {
19951996 let indirect_no_return_calls = ( 0 ..ctx_ref. indirectNoReturnCallsCount )
19961997 . map ( |i| {
19971998 let raw = unsafe { std:: ptr:: read ( ctx_ref. indirectNoReturnCalls . add ( i) ) } ;
1998- ArchAndAddr :: from ( raw)
1999+ Location :: from ( raw)
19992000 } )
20002001 . collect :: < HashSet < _ > > ( ) ;
20012002
20022003 let contextual_returns = ( 0 ..ctx_ref. contextualFunctionReturnCount )
20032004 . map ( |i| {
20042005 let loc = unsafe {
20052006 let raw = std:: ptr:: read ( ctx_ref. contextualFunctionReturnLocations . add ( i) ) ;
2006- ArchAndAddr :: from ( raw)
2007+ Location :: from ( raw)
20072008 } ;
20082009 let val = unsafe { * ctx_ref. contextualFunctionReturnValues . add ( i) } ;
20092010 ( loc, val)
@@ -2014,7 +2015,7 @@ impl BasicBlockAnalysisContext {
20142015 . map ( |i| {
20152016 let src = unsafe {
20162017 let raw = std:: ptr:: read ( ctx_ref. directRefSources . add ( i) ) ;
2017- ArchAndAddr :: from ( raw)
2018+ Location :: from ( raw)
20182019 } ;
20192020 let tgt = unsafe { * ctx_ref. directRefTargets . add ( i) } ;
20202021 ( tgt, src)
@@ -2024,14 +2025,14 @@ impl BasicBlockAnalysisContext {
20242025 let direct_no_return_calls = ( 0 ..ctx_ref. directNoReturnCallsCount )
20252026 . map ( |i| {
20262027 let raw = unsafe { std:: ptr:: read ( ctx_ref. directNoReturnCalls . add ( i) ) } ;
2027- ArchAndAddr :: from ( raw)
2028+ Location :: from ( raw)
20282029 } )
20292030 . collect :: < HashSet < _ > > ( ) ;
20302031
20312032 let halted_disassembly_addresses = ( 0 ..ctx_ref. haltedDisassemblyAddressesCount )
20322033 . map ( |i| {
20332034 let raw = unsafe { std:: ptr:: read ( ctx_ref. haltedDisassemblyAddresses . add ( i) ) } ;
2034- ArchAndAddr :: from ( raw)
2035+ Location :: from ( raw)
20352036 } )
20362037 . collect :: < HashSet < _ > > ( ) ;
20372038
@@ -2040,7 +2041,7 @@ impl BasicBlockAnalysisContext {
20402041 . map ( |i| {
20412042 let raw =
20422043 unsafe { std:: ptr:: read ( ctx_ref. inlinedUnresolvedIndirectBranches . add ( i) ) } ;
2043- ArchAndAddr :: from ( raw)
2044+ Location :: from ( raw)
20442045 } )
20452046 . collect :: < HashSet < _ > > ( ) ;
20462047
@@ -2064,28 +2065,31 @@ impl BasicBlockAnalysisContext {
20642065 }
20652066 }
20662067
2067- pub fn add_contextual_return ( & mut self , loc : ArchAndAddr , value : bool ) {
2068+ pub fn add_contextual_return ( & mut self , loc : impl Into < Location > , value : bool ) {
2069+ let loc = loc. into ( ) ;
20682070 if !self . contextual_returns . contains_key ( & loc) {
20692071 self . contextual_returns_dirty = true ;
20702072 }
20712073
20722074 self . contextual_returns . insert ( loc, value) ;
20732075 }
20742076
2075- pub fn add_direct_code_reference ( & mut self , target : u64 , src : ArchAndAddr ) {
2076- self . direct_code_references . entry ( target) . or_insert ( src) ;
2077+ pub fn add_direct_code_reference ( & mut self , target : u64 , src : impl Into < Location > ) {
2078+ self . direct_code_references
2079+ . entry ( target)
2080+ . or_insert ( src. into ( ) ) ;
20772081 }
20782082
2079- pub fn add_direct_no_return_call ( & mut self , loc : ArchAndAddr ) {
2080- self . direct_no_return_calls . insert ( loc) ;
2083+ pub fn add_direct_no_return_call ( & mut self , loc : impl Into < Location > ) {
2084+ self . direct_no_return_calls . insert ( loc. into ( ) ) ;
20812085 }
20822086
2083- pub fn add_halted_disassembly_address ( & mut self , loc : ArchAndAddr ) {
2084- self . halted_disassembly_addresses . insert ( loc) ;
2087+ pub fn add_halted_disassembly_address ( & mut self , loc : impl Into < Location > ) {
2088+ self . halted_disassembly_addresses . insert ( loc. into ( ) ) ;
20852089 }
20862090
2087- pub fn add_inlined_unresolved_indirect_branch ( & mut self , loc : ArchAndAddr ) {
2088- self . inlined_unresolved_indirect_branches . insert ( loc) ;
2091+ pub fn add_inlined_unresolved_indirect_branch ( & mut self , loc : impl Into < Location > ) {
2092+ self . inlined_unresolved_indirect_branches . insert ( loc. into ( ) ) ;
20892093 }
20902094
20912095 pub fn create_basic_block (
@@ -2121,7 +2125,7 @@ impl BasicBlockAnalysisContext {
21212125 let mut sources: Vec < BNArchitectureAndAddress > = Vec :: with_capacity ( total) ;
21222126 let mut targets: Vec < u64 > = Vec :: with_capacity ( total) ;
21232127 for ( target, src) in & self . direct_code_references {
2124- sources. push ( src . into_raw ( ) ) ;
2128+ sources. push ( BNArchitectureAndAddress :: from ( src ) ) ;
21252129 targets. push ( * target) ;
21262130 }
21272131 unsafe {
@@ -2138,7 +2142,7 @@ impl BasicBlockAnalysisContext {
21382142 let total = self . direct_no_return_calls . len ( ) ;
21392143 let mut locations: Vec < BNArchitectureAndAddress > = Vec :: with_capacity ( total) ;
21402144 for loc in & self . direct_no_return_calls {
2141- locations. push ( loc . into_raw ( ) ) ;
2145+ locations. push ( BNArchitectureAndAddress :: from ( loc ) ) ;
21422146 }
21432147 unsafe {
21442148 BNAnalyzeBasicBlocksContextSetDirectNoReturnCalls (
@@ -2153,7 +2157,7 @@ impl BasicBlockAnalysisContext {
21532157 let total = self . halted_disassembly_addresses . len ( ) ;
21542158 let mut locations: Vec < BNArchitectureAndAddress > = Vec :: with_capacity ( total) ;
21552159 for loc in & self . halted_disassembly_addresses {
2156- locations. push ( loc . into_raw ( ) ) ;
2160+ locations. push ( BNArchitectureAndAddress :: from ( loc ) ) ;
21572161 }
21582162 unsafe {
21592163 BNAnalyzeBasicBlocksContextSetHaltedDisassemblyAddresses (
@@ -2168,7 +2172,7 @@ impl BasicBlockAnalysisContext {
21682172 let total = self . inlined_unresolved_indirect_branches . len ( ) ;
21692173 let mut locations: Vec < BNArchitectureAndAddress > = Vec :: with_capacity ( total) ;
21702174 for loc in & self . inlined_unresolved_indirect_branches {
2171- locations. push ( loc . into_raw ( ) ) ;
2175+ locations. push ( BNArchitectureAndAddress :: from ( loc ) ) ;
21722176 }
21732177 unsafe {
21742178 BNAnalyzeBasicBlocksContextSetInlinedUnresolvedIndirectBranches (
@@ -2188,7 +2192,7 @@ impl BasicBlockAnalysisContext {
21882192 let mut locations: Vec < BNArchitectureAndAddress > = Vec :: with_capacity ( total) ;
21892193 let mut values: Vec < bool > = Vec :: with_capacity ( total) ;
21902194 for ( loc, value) in & self . contextual_returns {
2191- locations. push ( loc . into_raw ( ) ) ;
2195+ locations. push ( BNArchitectureAndAddress :: from ( loc ) ) ;
21922196 values. push ( * value) ;
21932197 }
21942198 unsafe {
0 commit comments