dexBytesContainString function

bool dexBytesContainString(
  1. List<int> dexBytes,
  2. String needle
)

Search raw DEX bytes for a UTF-8 needle (class descriptors often appear as plain strings, e.g. Lio/flutter/plugins/GeneratedPluginRegistrant;).

Implementation

bool dexBytesContainString(List<int> dexBytes, String needle) {
  if (needle.isEmpty) return false;
  final n = needle.codeUnits;
  if (n.length > dexBytes.length) return false;
  outer:
  for (var i = 0; i <= dexBytes.length - n.length; i++) {
    for (var j = 0; j < n.length; j++) {
      if (dexBytes[i + j] != n[j]) continue outer;
    }
    return true;
  }
  return false;
}