Skip to content

Commit ba3ed69

Browse files
committed
rewrite _parse_parameter
1 parent cc6ad00 commit ba3ed69

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

quark/core/rzapkinfo.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,6 @@ def convert_bytecode_to_list(bytecode):
561561
rz = self._get_rz(cache.dexindex)
562562

563563
instruction_flow = rz.cmdj(f"pdfj @ {cache.address}")["ops"]
564-
565564
if instruction_flow:
566565
for ins in instruction_flow:
567566
if ins["disasm"].startswith("invoke"):
@@ -663,21 +662,26 @@ def _get_method_by_address(self, address: int) -> MethodObject:
663662
return None
664663

665664
@staticmethod
666-
def _parse_parameter(mnemonic: str, parameter: str) -> Any:
665+
def _parse_parameter( mnemonic: str, parameter: str, p_type: str="int") -> Any:
667666
"""Parse the value of the parameter based on the mnemonic.
668667
669668
:param mnemonic: the mnemonic of a bytecode
670669
:param parameter: the parameter of a bytecode
671670
:return: the value of the parameter
672671
"""
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)
672+
if p_type == "int":
673+
try:
674+
parameter = int(parameter, 16)
675+
except:
676+
return RizinImp._parse_parameter(mnemonic, parameter, "float")
677+
678+
elif p_type == "float":
679+
try:
680+
parameter = float(parameter)
681+
except:
682+
return RizinImp._parse_parameter(mnemonic, parameter, "str")
683+
elif p_type == "str":
684+
parameter = re.sub(r"\.", "->", parameter, count=1)
681685

682686
return parameter
683687

0 commit comments

Comments
 (0)