class Unreflector
Constants
- CLASS_FOR_NAME
- CLASS_LOOKUP_MODIFIER
- CONST_CLASS_REGEX
- STATIC_FIELD_LOOKUP
- VIRTUAL_FIELD_LOOKUP
Attributes
optimizations[R]
Public Class Methods
new(driver, smali_files, methods)
click to toggle source
# File lib/dex-oracle/plugins/unreflector.rb, line 47 def initialize(driver, smali_files, methods) @driver = driver @smali_files = smali_files @methods = methods @optimizations = Hash.new(0) end
Public Instance Methods
process()
click to toggle source
# File lib/dex-oracle/plugins/unreflector.rb, line 54 def process made_changes = false @methods.each do |method| logger.info("Unreflecting #{method.descriptor}") made_changes |= lookup_classes(method) end made_changes end
Private Instance Methods
lookup_classes(method)
click to toggle source
# File lib/dex-oracle/plugins/unreflector.rb, line 66 def lookup_classes(method) target_to_contexts = {} target_id_to_output = {} matches = method.body.scan(CONST_CLASS_REGEX) @optimizations[:class_lookups] += matches.size matches.each do |original, class_name, out_reg| target = { id: Digest::SHA256.hexdigest(original) } smali_class = "L#{class_name.tr('.', '/')};" target_id_to_output[target[:id]] = ['success', smali_class] target_to_contexts[target] = [] unless target_to_contexts.key?(target) target_to_contexts[target] << [original, out_reg] end method_to_target_to_contexts = { method => target_to_contexts } Plugin.apply_outputs(target_id_to_output, method_to_target_to_contexts, CLASS_LOOKUP_MODIFIER) end