mihaip / dex-method-counts

Command-line tool to count per-package methods in Android .dex files
Apache License 2.0
2.6k stars 376 forks source link

Update DEX file magic #52

Open neomafo88 opened 2 years ago

neomafo88 commented 2 years ago

https://github.com/mihaip/dex-method-counts/blob/master/src/com/android/dexdeps/DexData.java#L571-L572

static class HeaderItem {
  public static final byte[] DEX_FILE_MAGIC = { 0x64, 0x65, 0x78, 0x0a, 0x30, 0x33 }; // , 0x??, 0x00 };
}

private static boolean verifyMagic(byte[] magic) {
  return Arrays.equals(Arrays.copyOfRange(magic,0,HeaderItem.DEX_FILE_MAGIC.length), HeaderItem.DEX_FILE_MAGIC)
  && magic[HeaderItem.DEX_FILE_MAGIC.length] >= 0x30
  && magic[HeaderItem.DEX_FILE_MAGIC.length+1] == 0x00;
}
mihaip commented 2 years ago

Guessing you're asking for the magic values to be updated with more recent versions. https://android.googlesource.com/platform/dalvik.git/+/67b37246c3edd037abc4b4af7e616e335aa64544/tools/dexdeps/src/com/android/dexdeps/DexData.java#547 has the complete list.

I'm no longer using or maintaining this tool, but if you would like to submit a PR with the updates, I'm happy to review it.