Rizin
unix-like reverse engineering framework and cli tools
lua_arch.h
Go to the documentation of this file.
1 // SPDX-License-Identifier: LGPL-3.0-only
2 // SPDX-FileCopyrightText: 2021 Heersin <teablearcher@gmail.com>
3 
4 #ifndef BUILD_LUA_ARCH_H
5 #define BUILD_LUA_ARCH_H
6 
7 #include <rz_types.h>
8 #include <rz_asm.h>
9 
10 /* Prefix of lua op arguments */
11 #define LUA_REG_PREF "R"
12 #define LUA_CONST_PREF "CONST"
13 #define LUA_KR_PREF "R/CONST"
14 #define LUA_UPVALUE_PREF "UPV"
15 #define LUA_EVENT_PREF "EVENT"
16 #define LUA_KPROTO_PREF "KPROTO"
17 #define LUA_NO_PREFIX ""
18 
19 /* Comment Mark */
20 #define LUA_EXTRAARG_MARK "#Ex"
21 #define LUA_KFLAG_MARK "#Kflag"
22 #define LUA_JMP_MARK "#To"
23 #define LUA_CLOSURE_MARK "#CLOSURE"
24 #define LUA_KX_MARK " CONST[#Ex]"
25 
26 /* Opcode Instruction Type */
28 
29 /* opcode names */
30 typedef char **LuaOpNameList;
31 
32 /* convert a 4-byte ut8 buffer into a lua instruction (ut32) */
35 int lua_load_next_arg_start(const char *raw_string, char *recv_buf);
36 bool lua_is_valid_num_value_string(const char *str);
37 int lua_convert_str_to_num(const char *str);
38 
39 /* formatted output strings */
40 char *luaop_new_str_3arg(char *opname, int a, int b, int c);
41 char *luaop_new_str_2arg(char *opname, int a, int b);
42 char *luaop_new_str_1arg(char *opname, int a);
43 char *luaop_new_str_3arg_ex(char *opname, int a, int b, int c, int isk);
44 char *luaop_new_str_2arg_ex(char *opname, int a, int b, int isk);
45 char *luaop_new_str_1arg_ex(char *opname, int a, int isk);
46 /* Free Opname List */
48 
49 /* Lua 5.4 specified */
50 int lua54_disasm(RzAsmOp *op, const ut8 *buf, int len, LuaOpNameList oplist);
51 int lua54_anal_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *data, int len);
52 bool lua54_assembly(const char *input, st32 input_size, LuaInstruction *instruction);
54 ut8 get_lua54_opcode_by_name(const char *name, int len);
55 
56 /* Lua 5.3 specified */
57 int lua53_disasm(RzAsmOp *op, const ut8 *buf, int len, LuaOpNameList oplist);
58 int lua53_anal_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *data, int len);
59 bool lua53_assembly(const char *input, st32 input_size, LuaInstruction *instruction);
61 ut8 get_lua53_opcode_by_name(const char *name, int len);
62 
63 #endif // BUILD_LUA_ARCH_H
size_t len
Definition: 6502dis.c:15
uint32_t ut32
voidpf void * buf
Definition: ioapi.h:138
uint8_t ut8
Definition: lh5801.h:11
static void list(RzEgg *egg)
Definition: rz-gg.c:52
char * luaop_new_str_2arg(char *opname, int a, int b)
Definition: lua_arch.c:42
bool lua_is_valid_num_value_string(const char *str)
Definition: lua_arch.c:129
char * luaop_new_str_2arg_ex(char *opname, int a, int b, int isk)
Definition: lua_arch.c:76
int lua54_anal_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *data, int len)
Definition: analysis_54.c:6
char * luaop_new_str_3arg(char *opname, int a, int b, int c)
Definition: lua_arch.c:31
ut32 LuaInstruction
Definition: lua_arch.h:27
ut8 get_lua54_opcode_by_name(const char *name, int len)
Definition: opcode_54.c:105
ut8 get_lua53_opcode_by_name(const char *name, int len)
Definition: opcode_53.c:69
int lua_load_next_arg_start(const char *raw_string, char *recv_buf)
Definition: lua_arch.c:98
char ** LuaOpNameList
Definition: lua_arch.h:30
LuaOpNameList get_lua54_opnames(void)
Definition: opcode_54.c:9
int lua54_disasm(RzAsmOp *op, const ut8 *buf, int len, LuaOpNameList oplist)
Definition: disassembly_54.c:6
char * luaop_new_str_3arg_ex(char *opname, int a, int b, int c, int isk)
Definition: lua_arch.c:65
int lua53_anal_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *data, int len)
Definition: analysis_53.c:7
LuaOpNameList get_lua53_opnames(void)
Definition: opcode_53.c:10
bool free_lua_opnames(LuaOpNameList list)
Definition: lua_arch.c:22
bool lua54_assembly(const char *input, st32 input_size, LuaInstruction *instruction)
Definition: assembly_54.c:96
LuaInstruction lua_build_instruction(const ut8 *buf)
Definition: lua_arch.c:6
int lua_convert_str_to_num(const char *str)
Definition: lua_arch.c:137
bool lua53_assembly(const char *input, st32 input_size, LuaInstruction *instruction)
Definition: assembly_53.c:60
char * luaop_new_str_1arg(char *opname, int a)
Definition: lua_arch.c:53
void lua_set_instruction(LuaInstruction instruction, ut8 *data)
Definition: lua_arch.c:15
int lua53_disasm(RzAsmOp *op, const ut8 *buf, int len, LuaOpNameList oplist)
Definition: disassembly_53.c:7
char * luaop_new_str_1arg_ex(char *opname, int a, int isk)
Definition: lua_arch.c:87
#define st32
Definition: rz_types_base.h:12
#define b(i)
Definition: sha256.c:42
#define c(i)
Definition: sha256.c:43
#define a(i)
Definition: sha256.c:41
Definition: z80asm.h:102
Definition: dis.c:32
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static int addr
Definition: z80asm.c:58
static bool input(void *ud, zip_uint8_t *data, zip_uint64_t length)