@@ -662,27 +662,45 @@ def _get_method_by_address(self, address: int) -> MethodObject:
662662 else :
663663 return None
664664
665+ def _get_string_by_address (self , address : str ) -> str :
666+ """
667+ Find the content of string via the specified string address.
668+
669+ :param address: an address used to find the corresponding method
670+ :return: the content in the given address
671+ """
672+ dexindex = 0
673+
674+ rz = self ._get_rz (dexindex )
675+ content = rz .cmd (f"pr @ { int (address , 16 )} " )
676+ return content
677+
665678 @staticmethod
666- def _parse_parameter (mnemonic : str , parameter : str ) -> Any :
679+ def _parse_parameter (parameter : str , p_type : str = "int" ) -> Any :
667680 """Parse the value of the parameter based on the mnemonic.
668681
669682 :param mnemonic: the mnemonic of a bytecode
670683 :param parameter: the parameter of a bytecode
671684 :return: the value of the parameter
672685 """
673- if mnemonic .startswith ("invoke" ):
674- return re .sub (r"\." , "->" , parameter , count = 1 )
675- elif mnemonic == "const-wide" :
676- return float (parameter )
677- elif mnemonic .startswith ("const" ) and "string" not in mnemonic :
678- return int (parameter , 16 )
679- elif '/lit' in mnemonic :
680- return int (parameter , 16 )
686+ if p_type == "int" :
687+ try :
688+ parameter = int (parameter , 16 )
689+ except (TypeError , ValueError ):
690+ return RizinImp ._parse_parameter (parameter , "float" )
691+
692+ elif p_type == "float" :
693+ try :
694+ parameter = float (parameter )
695+ except (TypeError , ValueError ):
696+ return RizinImp ._parse_parameter (parameter , "str" )
697+
698+ elif p_type == "str" :
699+ parameter = re .sub (r"\." , "->" , parameter , count = 1 )
681700
682701 return parameter
683702
684- @staticmethod
685- def _parse_smali (smali : str ) -> BytecodeObject :
703+ def _parse_smali (self , smali : str ) -> BytecodeObject :
686704 """
687705 Convert a Smali code provided by the Rizin command `pdfj` into a
688706 BytecodeObject.
@@ -705,10 +723,13 @@ def _parse_smali(smali: str) -> BytecodeObject:
705723
706724 args = [arg .strip () for arg in re .split ("[{},]+" , args ) if arg ]
707725
726+ if mnemonic == "const-string" and args [- 1 ][:2 ] == "0x" :
727+ args [- 1 ] = self ._get_string_by_address (args [- 1 ])
728+
708729 parameter = None
709730 # Remove the parameter at the last
710731 if args and not args [- 1 ].startswith ("v" ):
711- parameter = RizinImp ._parse_parameter (mnemonic , args [- 1 ])
732+ parameter = RizinImp ._parse_parameter (args [- 1 ])
712733 args = args [:- 1 ]
713734
714735 register_list = []
0 commit comments