@@ -1852,15 +1852,12 @@ def get_low_level_il_at(
18521852 >>> func.get_low_level_il_at(func.start)
18531853 <il: push(rbp)>
18541854 """
1855- if arch is None :
1856- arch = self .arch
1857-
1858- idx = core .BNGetLowLevelILForInstruction (self .handle , arch .handle , addr )
1859-
18601855 llil = self .llil
1861- if llil is None or idx == len (llil ):
1856+ if llil is None :
1857+ return None
1858+ idx = llil .get_instruction_start (addr , arch )
1859+ if idx is None :
18621860 return None
1863-
18641861 return llil [idx ]
18651862
18661863 def get_low_level_ils_at (self , addr : int ,
@@ -1881,19 +1878,7 @@ def get_low_level_ils_at(self, addr: int,
18811878 llil = self .llil
18821879 if llil is None :
18831880 return []
1884-
1885- if arch is None :
1886- arch = self .arch
1887- count = ctypes .c_ulonglong ()
1888- instrs = core .BNGetLowLevelILInstructionsForAddress (self .handle , arch .handle , addr , count )
1889- assert instrs is not None , "core.BNGetLowLevelILInstructionsForAddress returned None"
1890- try :
1891- result = []
1892- for i in range (0 , count .value ):
1893- result .append (llil [instrs [i ]])
1894- return result
1895- finally :
1896- core .BNFreeILInstructionList (instrs )
1881+ return [llil [i ] for i in llil .get_instructions_at (addr , arch )]
18971882
18981883 def get_llil_at (self , addr : int ,
18991884 arch : Optional ['architecture.Architecture' ] = None ) -> Optional ['lowlevelil.LowLevelILInstruction' ]:
@@ -1929,33 +1914,16 @@ def get_llils_at(self, addr: int,
19291914 llil = self .llil
19301915 if llil is None :
19311916 return []
1932-
1933- if arch is None :
1934- arch = self .arch
1935- count = ctypes .c_ulonglong ()
1936- instrs = core .BNGetLowLevelILInstructionsForAddress (self .handle , arch .handle , addr , count )
1937- assert instrs is not None , "core.BNGetLowLevelILInstructionsForAddress returned None"
1938- try :
1939- result = []
1940- for i in range (0 , count .value ):
1941- result .append (llil [instrs [i ]])
1942- return result
1943- finally :
1944- core .BNFreeILInstructionList (instrs )
1917+ return [llil [i ] for i in llil .get_instructions_at (addr , arch )]
19451918
19461919 def get_low_level_il_exits_at (self , addr : int , arch : Optional ['architecture.Architecture' ] = None ) -> List [int ]:
1947- if arch is None :
1948- arch = self .arch
1949- count = ctypes .c_ulonglong ()
1950- exits = core .BNGetLowLevelILExitsForInstruction (self .handle , arch .handle , addr , count )
1951- assert exits is not None , "core.BNGetLowLevelILExitsForInstruction returned None"
1952- try :
1953- result = []
1954- for i in range (0 , count .value ):
1955- result .append (exits [i ])
1956- return result
1957- finally :
1958- core .BNFreeILInstructionList (exits )
1920+ llil = self .llil
1921+ if llil is None :
1922+ return []
1923+ idx = llil .get_instruction_start (addr , arch )
1924+ if idx is None :
1925+ return []
1926+ return llil .get_exits_for_instr (idx )
19591927
19601928 def get_constant_data (self , state : RegisterValueType , value : int , size : int = 0 ) -> databuffer .DataBuffer :
19611929 return databuffer .DataBuffer (handle = core .BNGetConstantData (self .handle , state , value , size , None ))
@@ -2144,15 +2112,13 @@ def get_stack_vars_referenced_by_address_if_available(
21442112 def get_lifted_il_at (
21452113 self , addr : int , arch : Optional ['architecture.Architecture' ] = None
21462114 ) -> Optional ['lowlevelil.LowLevelILInstruction' ]:
2147- if arch is None :
2148- arch = self .arch
2149-
2150- idx = core .BNGetLiftedILForInstruction (self .handle , arch .handle , addr )
2151-
2152- if idx == len (self .lifted_il ):
2115+ lifted_il = self .lifted_il
2116+ if lifted_il is None :
21532117 return None
2154-
2155- return self .lifted_il [idx ]
2118+ idx = lifted_il .get_instruction_start (addr , arch )
2119+ if idx is None :
2120+ return None
2121+ return lifted_il [idx ]
21562122
21572123 def get_lifted_ils_at (
21582124 self , addr : int , arch : Optional ['architecture.Architecture' ] = None
@@ -2168,16 +2134,10 @@ def get_lifted_ils_at(
21682134 >>> func.get_lifted_ils_at(func.start)
21692135 [<il: push(rbp)>]
21702136 """
2171- if arch is None :
2172- arch = self .arch
2173- count = ctypes .c_ulonglong ()
2174- instrs = core .BNGetLiftedILInstructionsForAddress (self .handle , arch .handle , addr , count )
2175- assert instrs is not None , "core.BNGetLiftedILInstructionsForAddress returned None"
2176- result = []
2177- for i in range (0 , count .value ):
2178- result .append (self .lifted_il [instrs [i ]])
2179- core .BNFreeILInstructionList (instrs )
2180- return result
2137+ lifted_il = self .lifted_il
2138+ if lifted_il is None :
2139+ return []
2140+ return [lifted_il [i ] for i in lifted_il .get_instructions_at (addr , arch )]
21812141
21822142 def get_constants_referenced_by (self , addr : int ,
21832143 arch : Optional ['architecture.Architecture' ] = None ) -> List [variable .ConstantReference ]:
0 commit comments