/** *Preptheenvironmentthenrunthetest.
*/ publicstaticvoid main(String[] args) throws Exception { // Load the dex file, this is a pre-requisite to mmap-ing it in. Class<?> AnotherClass = testDexFile(); // Check that the memory maps are clean.
testDexMemoryMaps();
// Prevent garbage collector from collecting our DexFile // (and unmapping too early) by using it after we finish // our verification.
AnotherClass.newInstance();
}
if (!sizeUsuallyInKb.equals("0")) {
System.out.println( "ERROR: Memory mapping for " + CLASS_PATH + " is unexpectedly dirty");
System.out.println(line);
} else {
validated = true;
}
}
// VmFlags marks the "end" of an smaps entry. if (line.startsWith("VmFlags")) { break;
}
}
if (validated) {
System.out.println("Secondary dexfile mmap is clean");
} else {
System.out.println("ERROR: Memory mapping is missing Shared_Dirty/Private_Dirty entries");
}
returntrue;
}
privatestaticvoid testDexMemoryMaps() throws Exception { // Ensure that the secondary dex file is mapped clean (directly from JAR file).
String smaps = new String(Files.readAllBytes(Paths.get("/proc/self/smaps")));
String[] smapsLines = smaps.split("\n"); boolean found = true; for (int i = 0; i < smapsLines.length; ++i) { if (smapsLines[i].contains(CLASS_PATH)) { if (checkSmapsEntry(smapsLines, i)) { return;
} // else we found the wrong one, keep going.
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.