Need to calculate the number of methods and variables in the smali
file, not through dex
. How?
It's better to use Python
language, please
I simply calculated the number of .field
in the smali file and found a significant difference from the actual system calculation.
def parse_smali_method_num(smali_path):
count = 0
with open(smali_path, 'r', 4096, 'utf-8') as f:
text = f.readline()
if (not text.startswith('.class')):
print('Warning:Not a class smali file:' + str(smali_path))
return 0
while (text):
text = f.readline()
if (text.startswith('.method')):
count += 1
return count
def parse_smali_field_num(smali_path):
count = 0
with open(smali_path, 'r', 4096, 'utf-8') as f:
text = f.readline()
if (not text.startswith('.class')):
print('Warning:Not a class smali file:' + str(smali_path))
return 0
while (text):
text = f.readline()
if (text.startswith('.field')):
count += 1
return count