Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package shark
import shark.HprofHeader.Companion.parseHeaderOf
import shark.HprofRecord.HeapDumpEndRecord
import shark.HprofRecord.HeapDumpRecord.ObjectRecord
import shark.HprofRecord.HeapDumpRecord.ObjectRecord.ClassDumpRecord
import shark.HprofRecord.HeapDumpRecord.ObjectRecord.ClassDumpRecord.FieldRecord
import shark.HprofRecord.HeapDumpRecord.ObjectRecord.ClassDumpRecord.StaticFieldRecord
import shark.HprofRecord.HeapDumpRecord.ObjectRecord.InstanceDumpRecord
import shark.HprofRecord.HeapDumpRecord.ObjectRecord.ObjectArrayDumpRecord
import shark.HprofRecord.HeapDumpRecord.ObjectRecord.PrimitiveArrayDumpRecord
import shark.HprofRecord.LoadClassRecord
import shark.HprofRecord.StackFrameRecord
import shark.HprofRecord.StringRecord
import shark.StreamingRecordReaderAdapter.Companion.asStreamingRecordReader
import java.io.File
/**
* Converts a Hprof file to another file with deobfuscated class and field names.
*/
class HprofDeobfuscator {
/**
* @see HprofDeobfuscator
*/
fun deobfuscate(
proguardMapping: ProguardMapping,
inputHprofFile: File,
/**
* Optional output file. Defaults to a file in the same directory as [inputHprofFile], with
* the same name and "-deobfuscated" prepended before the ".hprof" extension. If the file extension
* is not ".hprof", then "-deobfuscated" is added at the end of the file.
*/
outputHprofFile: File = File(
inputHprofFile.parent, inputHprofFile.name.replace(
".hprof", "-deobfuscated.hprof"
).let { if (it != inputHprofFile.name) it else inputHprofFile.name + "-deobfuscated" })
): File {
val (hprofStringCache, classNames, maxId) = readHprofRecords(inputHprofFile)
return writeHprofRecords(
inputHprofFile,
outputHprofFile,
proguardMapping,
hprofStringCache,
classNames,
maxId + 1
)
}
/**
* Reads StringRecords and LoadClassRecord from an Hprof file and tracks maximum HprofRecord id
* value.
*
* @return a Triple of: hprofStringCache map, classNames map and maxId value
*/
private fun readHprofRecords(
inputHprofFile: File
): Triple