把 DEX 字节解析成六表结构、指令序列、注解与交叉引用,输出可读清单与 smali 风格反汇编。
moon add hnlyxiaobing/dex// 已 `moon add hnlyxiaobing/dex` 后,包名为 dex
fn analyze(dex_bytes : Bytes) -> Unit {
let dex = @dex.parse(dex_bytes)?
println("string count: \(dex.strings().length())")
println("class count: \(dex.classes().length())")
let ok = @dex.signature_ok(dex_bytes)?
println("signature ok: \(ok)")
}moon run cmd/main --target native -- dump <apk|dex> [--view summary|norm|xref] [--json]
moon run cmd/main --target native -- disasm <apk|dex> [--method <ref>]pub(all) enum AnnotationVisibility {
VisibilityBuild
VisibilityRuntime
VisibilitySystem
}pub(all) struct AnnotationsDirectory {
class_annotations : AnnotationSet
field_annotations : Array[FieldAnnotations]
method_annotations : Array[MethodAnnotations]
parameter_annotations : Array[ParameterAnnotations]
}fn AnnotationsIndex::class_annotations(self : AnnotationsIndex, class_index : Int) -> AnnotationsDirectory? raise DexErrorfn AnnotationsIndex::static_values(self : AnnotationsIndex, class_index : Int) -> Array[EncodedValue] raise DexErrorpub(all) struct ClassDef {
class_index : Int
type_descriptor : String
superclass_index : Int?
interfaces : Array[Int]
source_file : String?
access_flags : UInt
class_data_off : Int
static_fields : Array[FieldDef]
instance_fields : Array[FieldDef]
direct_methods : Array[MethodDef]
virtual_methods : Array[MethodDef]
}pub(all) struct CodeItem {
registers_size : Int
ins_size : Int
outs_size : Int
tries_size : Int
debug_info_off : Int
insns : Array[Instruction]
tries : Array[TryItem]
debug_info : Bytes
}pub(all) enum DebugEvent {
AdvancePc(Int)
AdvanceLine(Int)
StartLocal(Int, String, String)
StartLocalExtended(Int, String, String, String)
EndLocal(Int)
RestartLocal(Int)
SetPrologueEnd
SetEpilogueBegin
SetFile(String)
}pub(all) struct DebugInfoView {
line_start : Int
parameter_names : Array[String?]
events : Array[DebugEvent]
}pub(all) struct DexFile {
version : DexVersion
checksum : UInt
signature : Bytes
file_size : Int
header_size : Int
endian_tag : UInt
strings : Array[String]
type_descriptors : Array[String]
protos : Array[ProtoId]
fields : Array[FieldDef]
methods : Array[MethodDef]
classes : Array[ClassDef]
handles : Array[MethodHandleItem]
call_sites : Array[CallSiteItem]
map_list : Bytes
}pub(all) enum DexVersion {
Dex035
Dex037
Dex038
Dex039
Dex040
Dex041
Unknown(Int)
}pub(all) enum EncodedValue {
ValueByte(Int)
ValueShort(Int)
ValueChar(Int)
ValueInt(Int)
ValueLong(Int64)
ValueFloat(Float)
ValueDouble(Double)
ValueString(String)
ValueType(String)
ValueField(String)
ValueMethod(String)
ValueEnum(String)
ValueMethodType(String)
ValueMethodHandle(String)
ValueArray(Array[EncodedValue])
ValueAnnotation(EncodedAnnotation)
ValueNull
ValueBoolean(Bool)
}pub(all) struct FieldDef {
class_index : Int
type_index : Int
name_index : Int
access_flags : UInt
}pub(all) enum IndexKind {
IndexNone
IndexString
IndexType
IndexField
IndexMethod
IndexCallSite
IndexMethodHandle
IndexProto
}pub(all) struct Instruction {
offset : Int
opcode : Int
mnemonic : String
operands : Array[String]
raw : Bytes
}pub(all) struct MethodDef {
class_index : Int
name_index : Int
proto_index : Int
access_flags : UInt
code_off : Int
code : CodeItem?
}pub(all) enum MethodHandleKind {
StaticPut
StaticGet
InstancePut
InstanceGet
InvokeStatic
InvokeInstance
InvokeConstructor
InvokeDirect
InvokeInterface
}pub(all) enum TableKind {
StringId
TypeId
ProtoId
FieldId
MethodId
ClassDef
CallSiteId
MethodHandle
MapList
} derive(Debug)pub(all) struct TryItem {
start_addr : Int
insn_count : Int
handler_off : Int
catch_type_index : Int?
}fn XrefIndexExt::callees(self : XrefIndexExt, method_ref : Int) -> Array[XrefSiteExt] raise DexErrorfn XrefIndexExt::callers(self : XrefIndexExt, target_ref : Int) -> Array[XrefSiteExt] raise DexErrorpub(all) enum XrefKind {
XrefCallVirtual
XrefCallSuper
XrefCallDirect
XrefCallStatic
XrefCallInterface
XrefFieldReadStatic
XrefFieldWriteStatic
XrefFieldReadInstance
XrefFieldWriteInstance
}pub(all) enum XrefKindExt {
XrefExtInvokePolymorphic
XrefExtInvokePolymorphicRange
XrefExtInvokeCustom
XrefExtInvokeCustomRange
}Install
Download zip把 DEX 字节解析成六表结构、指令序列、注解与交叉引用,输出可读清单与 smali 风格反汇编。