module Instr: sig
.. end
This module defines types for Dalvik bytecodes and provides utility
functions for generating, parsing and dumping instructions.
Types
type
offset = int32
An address space of DEX is 32-bits
module IM: Map.S
with type key = Int32.t
type
instr = opcode * operand list
type
operand =
| |
OPR_CONST of int64 |
| |
OPR_REGISTER of int |
| |
OPR_INDEX of int |
| |
OPR_OFFSET of offset |
type
opcode =
| |
OP_NOP |
| |
OP_MOVE |
| |
OP_MOVE_FROM16 |
| |
OP_MOVE_16 |
| |
OP_MOVE_WIDE |
| |
OP_MOVE_WIDE_FROM16 |
| |
OP_MOVE_WIDE_16 |
| |
OP_MOVE_OBJECT |
| |
OP_MOVE_OBJECT_FROM16 |
| |
OP_MOVE_OBJECT_16 |
| |
OP_MOVE_RESULT |
| |
OP_MOVE_RESULT_WIDE |
| |
OP_MOVE_RESULT_OBJECT |
| |
OP_MOVE_EXCEPTION |
| |
OP_RETURN_VOID |
| |
OP_RETURN |
| |
OP_RETURN_WIDE |
| |
OP_RETURN_OBJECT |
| |
OP_CONST_4 |
| |
OP_CONST_16 |
| |
OP_CONST |
| |
OP_CONST_HIGH16 |
| |
OP_CONST_WIDE_16 |
| |
OP_CONST_WIDE_32 |
| |
OP_CONST_WIDE |
| |
OP_CONST_WIDE_HIGH16 |
| |
OP_CONST_STRING |
| |
OP_CONST_STRING_JUMBO |
| |
OP_CONST_CLASS |
| |
OP_MONITOR_ENTER |
| |
OP_MONITOR_EXIT |
| |
OP_CHECK_CAST |
| |
OP_INSTANCE_OF |
| |
OP_ARRAY_LENGTH |
| |
OP_NEW_INSTANCE |
| |
OP_NEW_ARRAY |
| |
OP_FILLED_NEW_ARRAY |
| |
OP_FILLED_NEW_ARRAY_RANGE |
| |
OP_FILL_ARRAY_DATA |
| |
OP_THROW |
| |
OP_GOTO |
| |
OP_GOTO_16 |
| |
OP_GOTO_32 |
| |
OP_PACKED_SWITCH |
| |
OP_SPARSE_SWITCH |
| |
OP_CMPL_FLOAT |
| |
OP_CMPG_FLOAT |
| |
OP_CMPL_DOUBLE |
| |
OP_CMPG_DOUBLE |
| |
OP_CMP_LONG |
| |
OP_IF_EQ |
| |
OP_IF_NE |
| |
OP_IF_LT |
| |
OP_IF_GE |
| |
OP_IF_GT |
| |
OP_IF_LE |
| |
OP_IF_EQZ |
| |
OP_IF_NEZ |
| |
OP_IF_LTZ |
| |
OP_IF_GEZ |
| |
OP_IF_GTZ |
| |
OP_IF_LEZ |
| |
OP_AGET |
| |
OP_AGET_WIDE |
| |
OP_AGET_OBJECT |
| |
OP_AGET_BOOLEAN |
| |
OP_AGET_BYTE |
| |
OP_AGET_CHAR |
| |
OP_AGET_SHORT |
| |
OP_APUT |
| |
OP_APUT_WIDE |
| |
OP_APUT_OBJECT |
| |
OP_APUT_BOOLEAN |
| |
OP_APUT_BYTE |
| |
OP_APUT_CHAR |
| |
OP_APUT_SHORT |
| |
OP_IGET |
| |
OP_IGET_WIDE |
| |
OP_IGET_OBJECT |
| |
OP_IGET_BOOLEAN |
| |
OP_IGET_BYTE |
| |
OP_IGET_CHAR |
| |
OP_IGET_SHORT |
| |
OP_IPUT |
| |
OP_IPUT_WIDE |
| |
OP_IPUT_OBJECT |
| |
OP_IPUT_BOOLEAN |
| |
OP_IPUT_BYTE |
| |
OP_IPUT_CHAR |
| |
OP_IPUT_SHORT |
| |
OP_SGET |
| |
OP_SGET_WIDE |
| |
OP_SGET_OBJECT |
| |
OP_SGET_BOOLEAN |
| |
OP_SGET_BYTE |
| |
OP_SGET_CHAR |
| |
OP_SGET_SHORT |
| |
OP_SPUT |
| |
OP_SPUT_WIDE |
| |
OP_SPUT_OBJECT |
| |
OP_SPUT_BOOLEAN |
| |
OP_SPUT_BYTE |
| |
OP_SPUT_CHAR |
| |
OP_SPUT_SHORT |
| |
OP_INVOKE_VIRTUAL |
| |
OP_INVOKE_SUPER |
| |
OP_INVOKE_DIRECT |
| |
OP_INVOKE_STATIC |
| |
OP_INVOKE_INTERFACE |
| |
OP_INVOKE_VIRTUAL_RANGE |
| |
OP_INVOKE_SUPER_RANGE |
| |
OP_INVOKE_DIRECT_RANGE |
| |
OP_INVOKE_STATIC_RANGE |
| |
OP_INVOKE_INTERFACE_RANGE |
| |
OP_NEG_INT |
| |
OP_NOT_INT |
| |
OP_NEG_LONG |
| |
OP_NOT_LONG |
| |
OP_NEG_FLOAT |
| |
OP_NEG_DOUBLE |
| |
OP_INT_TO_LONG |
| |
OP_INT_TO_FLOAT |
| |
OP_INT_TO_DOUBLE |
| |
OP_LONG_TO_INT |
| |
OP_LONG_TO_FLOAT |
| |
OP_LONG_TO_DOUBLE |
| |
OP_FLOAT_TO_INT |
| |
OP_FLOAT_TO_LONG |
| |
OP_FLOAT_TO_DOUBLE |
| |
OP_DOUBLE_TO_INT |
| |
OP_DOUBLE_TO_LONG |
| |
OP_DOUBLE_TO_FLOAT |
| |
OP_INT_TO_BYTE |
| |
OP_INT_TO_CHAR |
| |
OP_INT_TO_SHORT |
| |
OP_ADD_INT |
| |
OP_SUB_INT |
| |
OP_MUL_INT |
| |
OP_DIV_INT |
| |
OP_REM_INT |
| |
OP_AND_INT |
| |
OP_OR_INT |
| |
OP_XOR_INT |
| |
OP_SHL_INT |
| |
OP_SHR_INT |
| |
OP_USHR_INT |
| |
OP_ADD_LONG |
| |
OP_SUB_LONG |
| |
OP_MUL_LONG |
| |
OP_DIV_LONG |
| |
OP_REM_LONG |
| |
OP_AND_LONG |
| |
OP_OR_LONG |
| |
OP_XOR_LONG |
| |
OP_SHL_LONG |
| |
OP_SHR_LONG |
| |
OP_USHR_LONG |
| |
OP_ADD_FLOAT |
| |
OP_SUB_FLOAT |
| |
OP_MUL_FLOAT |
| |
OP_DIV_FLOAT |
| |
OP_REM_FLOAT |
| |
OP_ADD_DOUBLE |
| |
OP_SUB_DOUBLE |
| |
OP_MUL_DOUBLE |
| |
OP_DIV_DOUBLE |
| |
OP_REM_DOUBLE |
| |
OP_ADD_INT_2ADDR |
| |
OP_SUB_INT_2ADDR |
| |
OP_MUL_INT_2ADDR |
| |
OP_DIV_INT_2ADDR |
| |
OP_REM_INT_2ADDR |
| |
OP_AND_INT_2ADDR |
| |
OP_OR_INT_2ADDR |
| |
OP_XOR_INT_2ADDR |
| |
OP_SHL_INT_2ADDR |
| |
OP_SHR_INT_2ADDR |
| |
OP_USHR_INT_2ADDR |
| |
OP_ADD_LONG_2ADDR |
| |
OP_SUB_LONG_2ADDR |
| |
OP_MUL_LONG_2ADDR |
| |
OP_DIV_LONG_2ADDR |
| |
OP_REM_LONG_2ADDR |
| |
OP_AND_LONG_2ADDR |
| |
OP_OR_LONG_2ADDR |
| |
OP_XOR_LONG_2ADDR |
| |
OP_SHL_LONG_2ADDR |
| |
OP_SHR_LONG_2ADDR |
| |
OP_USHR_LONG_2ADDR |
| |
OP_ADD_FLOAT_2ADDR |
| |
OP_SUB_FLOAT_2ADDR |
| |
OP_MUL_FLOAT_2ADDR |
| |
OP_DIV_FLOAT_2ADDR |
| |
OP_REM_FLOAT_2ADDR |
| |
OP_ADD_DOUBLE_2ADDR |
| |
OP_SUB_DOUBLE_2ADDR |
| |
OP_MUL_DOUBLE_2ADDR |
| |
OP_DIV_DOUBLE_2ADDR |
| |
OP_REM_DOUBLE_2ADDR |
| |
OP_ADD_INT_LIT16 |
| |
OP_RSUB_INT |
| |
OP_MUL_INT_LIT16 |
| |
OP_DIV_INT_LIT16 |
| |
OP_REM_INT_LIT16 |
| |
OP_AND_INT_LIT16 |
| |
OP_OR_INT_LIT16 |
| |
OP_XOR_INT_LIT16 |
| |
OP_ADD_INT_LIT8 |
| |
OP_RSUB_INT_LIT8 |
| |
OP_MUL_INT_LIT8 |
| |
OP_DIV_INT_LIT8 |
| |
OP_REM_INT_LIT8 |
| |
OP_AND_INT_LIT8 |
| |
OP_OR_INT_LIT8 |
| |
OP_XOR_INT_LIT8 |
| |
OP_SHL_INT_LIT8 |
| |
OP_SHR_INT_LIT8 |
| |
OP_USHR_INT_LIT8 |
Utilities
val instr_to_string : instr -> string
val opr_to_string : operand -> string
val op_to_string : opcode -> string
val hx_to_op_and_size : int -> opcode * int
val hx_to_op : int -> opcode
val op_to_hx_and_size : opcode -> int * int
val op_to_hx : opcode -> int
type
link_sort =
| |
STRING_IDS |
| |
TYPE_IDS |
| |
FIELD_IDS |
| |
METHOD_IDS |
| |
OFFSET |
| |
NOT_LINK |
sort of links in the dex
val access_link : opcode -> link_sort
val low_reg : opcode -> int
number of "low" registers, registers numbers higher
than this must be moved to a low register before they
can be used for some instructions.
Or, use *_RANGE invoke instructions
val get_argv : instr -> operand list
retrieve actual parameters,
e.g. for invoke-*/range v0 v2 @...
, return a list of v0, v1, and v2
Parsing and Dumping
val make_instr : opcode -> int list -> instr
val instr_to_bytes : int -> instr -> char list
according to given base address, translate
Instr.instr
to bytes
Generating
val new_const : int -> int -> instr
for given a register number and constant,
generate
OP_CONST
-kind
Instr.instr
val new_const_id : int -> int -> int -> instr
for given register number and string or class id,
generate
OP_CONST
-kind
Instr.instr
val new_move : int -> int -> int -> instr
for a given source and destination register,
generate a new
OP_MOVE
-kind
Instr.instr
val new_obj : int -> int -> instr
for a given destination register and type,
generate a new
OP_NEW_INSTANCE
Instr.instr
val new_arr : int -> int -> int -> instr
for a given destination register, size, and type,
generate a new
OP_NEW_ARRAY
Instr.instr
val new_arr_op : int -> int list -> instr
for a given value, array, index registers,
generate a new
OP_A(GET|PUT)
-kind
Instr.instr
val new_stt_fld : int -> int -> int -> instr
for given register number and static field id,
generate
OP_S(GET|PUT)
-kind
Instr.instr
val new_invoke : int -> int list -> instr
for given hex code and a
list
of arguments,
generate
OP_INVOKE
-kind
Instr.instr
val new_move_result : int -> int -> instr
for given hex code and register number,
generate
OP_MOVE_RESULT
-kind
Instr.instr
val new_return : int -> int option -> instr
for given hex code and an
option
of register,
generate
OP_RETURN
-kind
Instr.instr
val rv : instr
void return
Web Accessibility