smali

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 9, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OpNop Opcode = iota
	OpMove
	OpMoveFrom16
	OpMove16
	OpMoveWide
	OpMoveWideFrom16
	OpMoveWide16
	OpMoveObject
	OpMoveObjectFrom16
	OpMoveObject16
	OpMoveResult
	OpMoveResultWide
	OpMoveResultObject
	OpMoveException

	OpReturnVoid
	OpReturnRegular
	OpReturnWide
	OpReturnObject

	OpConst4
	OpConst16
	OpConstRegular
	OpConstHigh16
	OpConstWide16
	OpConstWide32
	OpConstWide
	OpConstWideHigh16
	OpConstString
	OpConstStringJumbo
	OpConstClass

	OpMonitorEnter
	OpMonitorExit
	OpCheckCast
	OpInstanceOf
	OpArrayLength
	OpNewInstance

	OpNewArray
	OpFilledNewArray
	OpFilledNewArrayRange
	OpFilledArrayData

	OpThrowOp

	OpGotoOp
	OpGoto16
	OpGoto32

	OpPackedSwitch
	OpSparseSwitch

	OpCmplFloat
	OpCmpgFloat
	OpCmplDouble
	OpCmpgDouble
	OpCmpLong

	OpIfEq
	OpIfNe
	OpIfLt
	OpIfGe
	OpIfGt
	OpIfLe

	OpIfEqz
	OpIfNez
	OpIfLtz
	OpIfGez
	OpIfGtz
	OpIfLez

	OpAget = iota + 6
	OpAgetWide
	OpAgetObject
	OpAgetBoolean
	OpAgetByte
	OpAgetChar
	OpAgetShort

	OpAput
	OpAputWide
	OpAputObject
	OpAputBoolean
	OpAputByte
	OpAputChar
	OpAputShort

	OpIget
	OpIgetWide
	OpIgetObject
	OpIgetBoolean
	OpIgetByte
	OpIgetChar
	OpIgetShort
	OpIput
	OpIputWide
	OpIputObject
	OpIputBoolean
	OpIputByte
	OpIputChar
	OpIputShort

	OpSget
	OpSgetWide
	OpSgetObject
	OpSgetBoolean
	OpSgetByte
	OpSgetChar
	OpSgetShort
	OpSput
	OpSputWide
	OpSputObject
	OpSputBoolean
	OpSputByte
	OpSputChar
	OpSputShort

	OpInvokeVirtual
	OpInvokeSuper
	OpInvokeDirect
	OpInvokeStatic
	OpInvokeInterface

	OpInvokeVirtualRange
	OpInvokeSuperRange
	OpInvokeDirectRange
	OpInvokeStaticRange
	OpInvokeInterfaceRange

	OpNegInt = iota + 8
	OpNotInt
	OpNegLong
	OpNotLong
	OpNegFloat
	OpNegDouble
	OpIntToLong
	OpIntToFloat
	OpIntToDouble
	OpLongToInt
	OpLongToFloat
	OpLongToDouble
	OpFloatToInt
	OpFloatToLong
	OpFloatToDouble
	OpDoubleToInt
	OpDoubleToLong
	OpDoubleToFloat
	OpIntToByte
	OpIntToChar
	OpIntToShort

	OpAddInt
	OpSubInt
	OpMulInt
	OpDivInt
	OpRemInt
	OpAndInt
	OpOrInt
	OpXorInt
	OpShlInt
	OpShrInt
	OpUshrInt
	OpAddLong
	OpSubLong
	OpMulLong
	OpDivLong
	OpRemLong
	OpAndLong
	OpOrLong
	OpXorLong
	OpShlLong
	OpShrLong
	OpUshrLong
	OpAddFloat
	OpSubFloat
	OpMulFloat
	OpDivFloat
	OpRemFloat
	OpAddDouble
	OpSubDouble
	OpMulDouble
	OpDivDouble
	OpRemDouble

	OpAddInt2addr
	OpSubInt2addr
	OpMulInt2addr
	OpDivInt2addr
	OpRemInt2addr
	OpAndInt2addr
	OpOrInt2addr
	OpXorInt2addr
	OpShlInt2addr
	OpShrInt2addr
	OpUshrInt2addr
	OpAddLong2addr
	OpSubLong2addr
	OpMulLong2addr
	OpDivLong2addr
	OpRemLong2addr
	OpAndLong2addr
	OpOrLong2addr
	OpXorLong2addr
	OpShlLong2addr
	OpShrLong2addr
	OpUshrLong2addr
	OpAddFloat2addr
	OpSubFloat2addr
	OpMulFloat2addr
	OpDivFloat2addr
	OpRemFloat2addr
	OpAddDouble2addr
	OpSubDouble2addr
	OpMulDouble2addr
	OpDivDouble2addr
	OpRemDouble2addr

	OpAddIntLit16
	OpRsubIntLit16
	OpMulIntLit16
	OpDivIntLit16
	OpRemIntLit16
	OpAndIntLit16
	OpOrIntLit16
	OpXorIntLit16

	OpAddIntLit8
	OpRsubIntLit8
	OpMulIntLit8
	OpDivIntLit8
	OpRemIntLit8
	OpAndIntLit8
	OpOrIntLit8
	OpXorIntLit8
	OpShlIntLit8
	OpShrIntLit8
	OpUshrIntLit8

	OpInvokePolymorphic = iota + 31
	OpInvokePolymorphicRange
	OpInvokeCustom
	OpInvokeCustomRange
	OpConstMethodHandle
	OpConstMethodType
)

ref: https://github.com/google/smali https://source.android.com/docs/core/runtime/dalvik-bytecode

View Source
const ResolveResource = "{{resolve_from_resource}}"

Variables

View Source
var (
	ErrUnknownOperandType = errors.New("unknown operand type")
	ErrULEB128Overflow    = errors.New("ULEB128 overflow")
	ErrULEB128TooLong     = errors.New("ULEB128 too long")
	ErrInvalidType        = errors.New("invalid type")
)

Functions

func NewParser

func NewParser(r *bytes.Reader) *parser

Types

type Class

type Class struct {
	Name           string
	StaticFields   []Field
	InstanceFields []Field
	Methods        []Method
	SuperClass     string
}

func NewClass

func NewClass(name, superClass string) (Class, error)

type Config

type Config struct {
	SanitizeAnnotations bool
}

type Dex

type Dex struct {
	Filename string

	Classes map[string]Class
	Methods map[string]Method
	Fields  map[string]Field

	MethodsByIndex map[int]string
	FieldsByIndex  map[int]string
	// contains filtered or unexported fields
}

func NewDex

func NewDex(r *bytes.Reader, cfg Config) (Dex, error)

type Field

type Field struct {
	DefIdx     int
	Name       string
	Type       string
	ClassName  string
	Descriptor string
	Value      int64 // NOTE: wrap in some sort of value type wrapping any
}

type Instruction

type Instruction struct {
	Opcode      Opcode      // 0x0
	Type        Type        // 0x1
	OperandType OperandType // 0x2
	Pad         byte        // 0x3
	Operands    []int64     // 0x4

} // size: 0x14

type Method

type Method struct {
	Class              string
	Name               string
	ReturnType         string
	ArgumentsSignature string

	Body []Instruction
	// contains filtered or unexported fields
}

func NewMethod

func NewMethod(cls, name, returnType, argumentsSignature string, m internal.Method) (Method, error)

func (*Method) ParseCode

func (m *Method) ParseCode() error

type Opcode

type Opcode byte

type OperandType

type OperandType int8
const (
	OperandTypeNone OperandType = iota
	OperandTypeReg
	OperandType2reg
	OperandTypeRegShort
	OperandTypeShort
	OperandType2short
	OperandType2regShort
	OperandTypeUint
	OperandTypeRegUint
	OperandTypeRegUlong
	OperandType3reg
	OperandRegisterArray
	OperandRegisterArrayRange
	OperandRegHigh32
	OperandRegHigh64
	OperandRegWide16
	OperandRegWide32
)

type Type

type Type int8
const (
	TypeUnknown Type = iota - 1
	TypeMove
	TypeCond
	TypeGoto
	TypeNoop
	TypeCast
	TypeConst
	TypeReturn
	TypeArrayOp
	TypeStaticOp
	TypeSwitchOp
	TypeException
	TypeInvocation
	TypeComparison
	TypeInstanceOp
	TypeMoveResult
	TypeArithmetics
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL