Rizin
unix-like reverse engineering framework and cli tools
parse_53.c
Go to the documentation of this file.
1 // SPDX-License-Identifier: LGPL-3.0-only
2 // SPDX-FileCopyrightText: 2017 pancake <pancake@nopcode.org>
3 // SPDX-FileCopyrightText: 2021 Heersin <teablearcher@gmail.com>
4 
5 #include "luac_specs_53.h"
6 
7 static void lua_load_block(RzBuffer *buffer, void *dest, size_t size, ut64 offset, ut64 data_size) {
8  if (offset + size > data_size) {
9  RZ_LOG_ERROR("Truncated load block at 0x%llx\n", offset);
10  return;
11  }
13 }
14 
16  ut64 x = 0;
18  return x;
19 }
20 
22  double x = 0;
24  return x;
25 }
26 
28  ut32 x = 0;
30  return x;
31 }
32 
34  ut64 size_offset;
35  int line_defined;
36  int last_line_defined;
37 
38  size_offset = sizeof(LUA_INT) + sizeof(LUA_INT);
39 
40  if (size_offset + offset > data_size) {
41  return 0;
42  }
43  line_defined = lua_load_int(buffer, offset);
44  offset += size_offset;
45  last_line_defined = lua_load_int(buffer, offset);
46 
47  /* Set Proto Member */
48  proto->line_defined = line_defined;
49  proto->lastline_defined = last_line_defined;
50 
51  return size_offset;
52 }
53 
54 static ut64 lua_parse_string(RzBuffer *buffer, ut8 **dest, int *str_len, ut64 offset, ut64 data_size) {
55  ut8 string_buf_size;
56  if (!rz_buf_read8_at(buffer, offset, &string_buf_size)) {
57  return 0;
58  }
59 
60  int len = 0;
61  ut64 base_offset = 0;
62  ut64 size_offset = 1;
63  ut8 *ret;
64 
65  base_offset = offset;
66 
67  // Long string
68  if (string_buf_size == 0xFF) {
69  offset += size_offset;
70  if (!rz_buf_read8_at(buffer, offset, &string_buf_size)) {
71  return 0;
72  }
73  size_offset = 1;
74  }
75 
76  offset += size_offset;
77 
78  if (string_buf_size == 0 || size_offset == 0) {
79  ret = NULL;
80  len = 0;
81  } else {
82  len = string_buf_size - 1;
83  if ((ret = RZ_NEWS(ut8, string_buf_size)) == NULL) {
84  len = 0;
85  } else {
87  ret[len] = 0x00;
88  }
89  }
90 
91  if (dest && str_len) {
92  *dest = ret;
93  *str_len = len;
94  } else {
95  RZ_LOG_ERROR("Cannot store string\n");
96  }
97 
98  return offset + len - base_offset;
99 }
100 
101 static ut64 lua_parse_name(LuaProto *proto, RzBuffer *buffer, ut64 offset, ut64 data_size) {
102  return lua_parse_string(buffer, &proto->proto_name, &proto->name_size, offset, data_size);
103 }
104 
105 static ut64 lua_parse_code(LuaProto *proto, RzBuffer *buffer, ut64 offset, ut64 data_size) {
106  ut64 size_offset;
107  ut64 total_size;
108  int code_size;
109 
110  size_offset = sizeof(LUA_INT);
111  if (size_offset + offset > data_size) {
112  return 0;
113  }
114  code_size = lua_load_int(buffer, offset);
115  total_size = code_size * 4 + size_offset;
116 
117  if (total_size + offset > data_size) {
118  RZ_LOG_ERROR("Truncated Code at [0x%llx]\n", offset);
119  return 0;
120  }
121 
122  /* Set Proto Member */
123  proto->code_size = code_size * 4;
124  proto->code_skipped = size_offset;
125 
126  return total_size;
127 }
128 
130  LuaConstEntry *current_entry;
131  ut64 base_offset;
132  ut8 *recv_data;
133  ut64 delta_offset;
134  int data_len;
135 
136  current_entry = lua_new_const_entry();
137  current_entry->offset = offset;
138  base_offset = offset;
139  delta_offset = 0;
140 
141  /* read TAG byte */
142  if (offset + 1 > data_size) {
143  return 0;
144  }
145  if (!rz_buf_read8_at(buffer, offset, &current_entry->tag)) {
146  return 0;
147  }
148  offset += 1;
149 
150  ut8 tmp;
151 
152  /* read data */
153  // TODO : check tag Macro
154  // RIGHT : 0x843
155  switch (current_entry->tag) {
156  case LUA_TNUMFLT:
157  data_len = sizeof(LUA_NUMBER);
158  recv_data = RZ_NEWS(ut8, data_len);
159  lua_load_block(buffer, recv_data, data_len, offset, data_size);
160  if (offset + data_len > data_size) {
161  return 0;
162  }
163  delta_offset = data_len;
164  current_entry->tag = LUA_VNUMFLT; // keep the same with 5.4 tag
165  break;
166  case LUA_TNUMINT:
167  data_len = sizeof(LUA_INTEGER);
168  recv_data = RZ_NEWS(ut8, data_len);
169  lua_load_block(buffer, recv_data, data_len, offset, data_size);
170  if (offset + data_len > data_size) {
171  return 0;
172  }
173  delta_offset = data_len;
174  current_entry->tag = LUA_VNUMINT; // keep the same with 5.4 tag
175  break;
176  case LUA_VSHRSTR:
177  case LUA_VLNGSTR:
178  delta_offset = lua_parse_string(buffer, &recv_data, &data_len, offset, data_size);
179  lua_check_error_offset(delta_offset);
180  break;
181  // BOOLEAN
182  case LUA_TBOOLEAN:
183  if (!rz_buf_read8_at(buffer, offset, &tmp)) {
184  return 0;
185  }
186 
187  current_entry->tag = tmp == 0 ? LUA_VFALSE : LUA_VTRUE;
188  recv_data = NULL;
189  data_len = 0;
190  delta_offset = 1;
191  break;
192  // NIL
193  case LUA_TNIL:
194  default:
195  recv_data = NULL;
196  current_entry->tag = LUA_VNIL;
197  data_len = 0;
198  delta_offset = 0;
199  break;
200  }
201 
202  offset += delta_offset;
203 
204  current_entry->data = recv_data;
205  current_entry->data_len = data_len;
206 
207  /* add to list */
208  rz_list_append(proto->const_entries, current_entry);
209 
210  return offset - base_offset;
211 }
212 
213 static ut64 lua_parse_consts(LuaProto *proto, RzBuffer *buffer, ut64 offset, ut64 data_size) {
214  int consts_cnt;
215  int i;
216  ut64 base_offset;
217  ut64 delta_offset;
218 
219  base_offset = offset;
220 
221  /* parse number of constants */
222  if (offset + sizeof(LUA_INT) > data_size) {
223  return 0;
224  }
225  consts_cnt = lua_load_int(buffer, offset);
226  delta_offset = sizeof(LUA_INT);
227  offset += delta_offset;
228 
229  for (i = 0; i < consts_cnt; ++i) {
230  // add an entry of constant
231  delta_offset = lua_parse_const_entry(proto, buffer, offset, data_size);
232  lua_check_error_offset(delta_offset);
233  offset += delta_offset;
234  }
235 
236  proto->const_size = offset - base_offset + 1;
237  return offset - base_offset;
238 }
239 
241  LuaUpvalueEntry *current_entry;
242  ut64 base_offset;
243 
244  base_offset = offset;
245  current_entry = lua_new_upvalue_entry();
246  current_entry->offset = base_offset;
247 
248  if (offset + 2 > data_size) {
249  return 0;
250  }
251 
252  /* read instack/idx attr */
253  // no kind in lua 5.3
254  if (!rz_buf_read8_at(buffer, offset + 0, &current_entry->instack) ||
255  !rz_buf_read8_at(buffer, offset + 1, &current_entry->idx)) {
256  return 0;
257  }
258  current_entry->kind = 0;
259 
260  offset += 2;
261 
262  /* add to list */
263  rz_list_append(proto->upvalue_entries, current_entry);
264 
265  return offset - base_offset;
266 }
267 
269  int upvalues_cnt;
270  int i;
271  ut64 base_offset;
272  ut64 delta_offset;
273 
274  base_offset = offset;
275 
276  /* parse number of upvalues */
277  delta_offset = sizeof(LUA_INT);
278  if (delta_offset + offset > data_size) {
279  return 0;
280  }
281  upvalues_cnt = lua_load_int(buffer, offset);
282  offset += delta_offset;
283 
284  for (i = 0; i < upvalues_cnt; ++i) {
285  delta_offset = lua_parse_upvalue_entry(proto, buffer, offset, data_size);
286  lua_check_error_offset(delta_offset);
287  offset += delta_offset;
288  }
289 
290  proto->upvalue_size = offset - base_offset + 1;
291 
292  return offset - base_offset;
293 }
294 
295 static ut64 lua_parse_debug(LuaProto *proto, RzBuffer *buffer, ut64 offset, ut64 data_size) {
296  int entries_cnt;
297  int i;
298  ut64 base_offset;
299  ut64 delta_offset;
300 
301  base_offset = offset;
302 
303  /* parse line info */
304  if (offset + sizeof(LUA_INT) > data_size) {
305  return 0;
306  }
307  entries_cnt = lua_load_int(buffer, offset);
308  offset += sizeof(LUA_INT);
309  LuaLineinfoEntry *info_entry;
310  for (i = 0; i < entries_cnt; ++i) {
311  info_entry = lua_new_lineinfo_entry();
312  info_entry->offset = offset;
313  info_entry->info_data = lua_load_int(buffer, offset);
314  rz_list_append(proto->line_info_entries, info_entry);
315  offset += sizeof(int);
316  }
317 
318  /* no parse absline info */
319 
320  /* parse local vars */
321  if (offset + sizeof(LUA_INT) > data_size) {
322  return 0;
323  }
324  entries_cnt = lua_load_int(buffer, offset);
325  offset += sizeof(LUA_INT);
326  LuaLocalVarEntry *var_entry;
327  for (i = 0; i < entries_cnt; ++i) {
328  var_entry = lua_new_local_var_entry();
329  var_entry->offset = offset;
330 
331  /* string */
332  delta_offset = lua_parse_string(
333  buffer,
334  &var_entry->varname, &var_entry->varname_len,
335  offset, data_size);
336  lua_check_error_offset(delta_offset);
337  offset += delta_offset;
338 
339  /* start pc && end pc -- int */
340  if (offset + sizeof(LUA_INT) + sizeof(LUA_INT) > data_size) {
341  return 0;
342  }
343  var_entry->start_pc = lua_load_int(buffer, offset);
344  offset += sizeof(LUA_INT);
345 
346  /* end pc -- int */
347  var_entry->end_pc = lua_load_int(buffer, offset);
348  offset += sizeof(LUA_INT);
349 
350  rz_list_append(proto->local_var_info_entries, var_entry);
351  }
352 
353  /* parse upvalue */
354  if (offset + sizeof(LUA_INT) > data_size) {
355  return 0;
356  }
357  entries_cnt = lua_load_int(buffer, offset);
358  offset += sizeof(LUA_INT);
359  LuaDbgUpvalueEntry *dbg_upvalue_entry;
360  for (i = 0; i < entries_cnt; ++i) {
361  dbg_upvalue_entry = lua_new_dbg_upvalue_entry();
362  dbg_upvalue_entry->offset = offset;
363 
364  delta_offset = lua_parse_string(
365  buffer,
366  &dbg_upvalue_entry->upvalue_name, &dbg_upvalue_entry->name_len,
367  offset, data_size);
368  lua_check_error_offset(delta_offset);
369  offset += delta_offset;
370 
371  rz_list_append(proto->dbg_upvalue_entries, dbg_upvalue_entry);
372  }
373 
374  proto->debug_size = offset - base_offset + 1;
375  return offset - base_offset;
376 }
377 
378 static ut64 lua_parse_protos(LuaProto *proto, RzBuffer *buffer, ut64 offset, ut64 data_size) {
379  rz_return_val_if_fail(proto, 0);
380 
381  int proto_cnt;
382  int i;
383  ut64 base_offset;
384  ut64 delta_offset;
385 
386  base_offset = offset; // store origin offset
387 
388  delta_offset = sizeof(LUA_INT);
389  if (offset + delta_offset > data_size) {
390  return 0;
391  }
392  proto_cnt = lua_load_int(buffer, offset);
393  offset += delta_offset;
394 
395  LuaProto *current_proto;
396  for (i = 0; i < proto_cnt; ++i) {
397  current_proto = lua_parse_body_53(buffer, offset, data_size);
398  lua_return_if_null(current_proto);
399  rz_list_append(proto->proto_entries, current_proto);
400  offset += current_proto->size - 1; // update offset
401  }
402 
403  // return the delta between offset and base_offset
404  return offset - base_offset;
405 }
406 
407 LuaProto *lua_parse_body_53(RzBuffer *buffer, ut64 base_offset, ut64 data_size) {
408  ut64 offset;
409  ut64 delta_offset;
410 
411  LuaProto *ret_proto = lua_new_proto_entry();
412  if (!ret_proto) {
413  return NULL;
414  }
415 
416  // start parsing
417  offset = base_offset;
418 
419  // record offset of main proto
420  ret_proto->offset = offset;
421 
422  // parse proto name
423  delta_offset = lua_parse_name(ret_proto, buffer, offset, data_size);
424  lua_check_error_offset_proto(delta_offset, ret_proto);
425  offset += delta_offset;
426 
427  /* parse line defined info */
428  delta_offset = lua_parse_line_defined(ret_proto, buffer, offset, data_size);
429  lua_check_error_offset_proto(delta_offset, ret_proto);
430  offset += delta_offset;
431 
432  /* parse num params max_stack_size */
433  if (offset + 3 > data_size) {
434  lua_free_proto_entry(ret_proto);
435  return NULL;
436  }
437  if (!rz_buf_read8_at(buffer, offset + 0, &ret_proto->num_params) ||
438  !rz_buf_read8_at(buffer, offset + 1, &ret_proto->is_vararg) ||
439  !rz_buf_read8_at(buffer, offset + 2, &ret_proto->max_stack_size)) {
440  lua_free_proto_entry(ret_proto);
441  return NULL;
442  }
443  offset += 3;
444 
445  /* parse code */
446  ret_proto->code_offset = offset;
447  delta_offset = lua_parse_code(ret_proto, buffer, offset, data_size);
448  lua_check_error_offset_proto(delta_offset, ret_proto);
449  offset += delta_offset;
450 
451  /* parse constants */
452  ret_proto->const_offset = offset;
453  delta_offset = lua_parse_consts(ret_proto, buffer, offset, data_size);
454  lua_check_error_offset_proto(delta_offset, ret_proto);
455  offset += delta_offset;
456 
457  /* parse upvalues */
458  ret_proto->upvalue_offset = offset;
459  delta_offset = lua_parse_upvalues(ret_proto, buffer, offset, data_size);
460  lua_check_error_offset_proto(delta_offset, ret_proto);
461  offset += delta_offset;
462 
463  /* parse inner protos */
464  ret_proto->inner_proto_offset = offset;
465  delta_offset = lua_parse_protos(ret_proto, buffer, offset, data_size);
466  lua_check_error_offset_proto(delta_offset, ret_proto);
467  offset += delta_offset;
468 
469  /* specially handle recursive protos size */
470  ret_proto->inner_proto_size = offset - ret_proto->inner_proto_offset;
471 
472  /* parse debug */
473  ret_proto->debug_offset = offset;
474  delta_offset = lua_parse_debug(ret_proto, buffer, offset, data_size);
475  lua_check_error_offset_proto(delta_offset, ret_proto);
476  offset += delta_offset;
477 
478  ret_proto->size = offset - base_offset + 1;
479 
480  return ret_proto;
481 }
482 
484  RzBinInfo *ret = NULL;
485  RzBuffer *buffer;
486 
487  st64 reat = bf->size;
488  if (reat < LUAC_53_HDRSIZE) {
489  RZ_LOG_ERROR("Truncated header\n");
490  return NULL;
491  }
492  buffer = bf->buf;
493 
494  /* read header members from work buffer */
495  ut8 luac_format;
496  if (!rz_buf_read8_at(buffer, LUAC_53_FORMAT_OFFSET, &luac_format)) {
497  return NULL;
498  }
499  ut8 int_size;
500  if (!rz_buf_read8_at(buffer, LUAC_53_INT_SIZE_OFFSET, &int_size)) {
501  return NULL;
502  }
503  ut8 sizet_size;
504  if (!rz_buf_read8_at(buffer, LUAC_53_SIZET_SIZE_OFFSET, &sizet_size)) {
505  return NULL;
506  }
507  ut8 instruction_size;
508  if (!rz_buf_read8_at(buffer, LUAC_53_INSTRUCTION_SIZE_OFFSET, &instruction_size)) {
509  return NULL;
510  }
511  ut8 integer_size;
512  if (!rz_buf_read8_at(buffer, LUAC_53_INTEGER_SIZE_OFFSET, &integer_size)) {
513  return NULL;
514  }
515  ut8 number_size;
516  if (!rz_buf_read8_at(buffer, LUAC_53_NUMBER_SIZE_OFFSET, &number_size)) {
517  return NULL;
518  }
520  double number_valid = lua_load_number(buffer, LUAC_53_NUMBER_VALID_OFFSET);
521 
522  /* Common Ret */
523  if (!(ret = RZ_NEW0(RzBinInfo))) {
524  return NULL;
525  }
526  ret->file = rz_str_new(bf->file);
527  ret->type = rz_str_newf("Lua %c.%c compiled file", major + '0', minor + '0');
528  ret->bclass = rz_str_new("Lua compiled file");
529  ret->rclass = rz_str_new("luac");
530  ret->arch = rz_str_new("luac");
531  ret->machine = rz_str_newf("Lua %c.%c VM", major + '0', minor + '0');
532  ret->os = rz_str_newf("%c.%c", major + '0', minor + '0');
533  ret->cpu = rz_str_newf("%c.%c", major + '0', minor + '0');
534  ret->bits = 8;
535 
536  /* official format ? */
537  if (luac_format != LUAC_54_FORMAT) {
538  ret->compiler = rz_str_new("Unofficial Lua Compiler");
539  return ret;
540  }
541  ret->compiler = rz_str_new("Official Lua Compiler");
542 
543  /* Check Size */
544  // TODO : remove this check and process different compiler options
545  if ((instruction_size != sizeof(LUA_INSTRUCTION)) ||
546  (integer_size != sizeof(LUA_INTEGER)) ||
547  (number_size != sizeof(LUA_NUMBER)) ||
548  (int_size != sizeof(LUA_INT)) ||
549  (sizet_size != sizeof(size_t))) {
550  RZ_LOG_ERROR("Size definition does not match with the expected size\n");
551  return ret;
552  }
553 
554  /* Check endian */
555  if (integer_valid != LUAC_53_INT_VALIDATION) {
556  RZ_LOG_ERROR("Integer format does not match with the expected integer\n");
557  return ret;
558  } else if (number_valid != LUAC_53_NUMBER_VALIDATION) {
559  RZ_LOG_ERROR("Number format does not match with the expected number\n");
560  return ret;
561  }
562 
563  /* parse source file name */
564  char *src_file_name = NULL;
565  int name_len;
566  lua_parse_string(buffer, ((ut8 **)&(src_file_name)), &name_len, LUAC_FILENAME_OFFSET, bf->size);
567 
568  /* put source file info into GUID */
569  ret->guid = rz_str_new(src_file_name ? src_file_name : "stripped");
570  free(src_file_name);
571 
572  return ret;
573 }
size_t len
Definition: 6502dis.c:15
lzma_index ** i
Definition: index.h:629
struct buffer buffer
#define NULL
Definition: cris-opc.c:27
uint32_t ut32
#define minor(dev)
Definition: fsmagic.c:57
#define major(dev)
Definition: fsmagic.c:56
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
voidpf void uLong size
Definition: ioapi.h:138
voidpf uLong offset
Definition: ioapi.h:144
uint8_t ut8
Definition: lh5801.h:11
RZ_API RZ_BORROW RzListIter * rz_list_append(RZ_NONNULL RzList *list, void *data)
Appends at the end of the list a new element.
Definition: list.c:288
LuaLineinfoEntry * lua_new_lineinfo_entry()
Definition: luac_common.c:23
LuaConstEntry * lua_new_const_entry()
Definition: luac_common.c:33
LuaProto * lua_new_proto_entry()
Definition: luac_common.c:38
LuaDbgUpvalueEntry * lua_new_dbg_upvalue_entry()
Definition: luac_common.c:8
LuaLocalVarEntry * lua_new_local_var_entry()
Definition: luac_common.c:13
LuaUpvalueEntry * lua_new_upvalue_entry()
Definition: luac_common.c:28
void lua_free_proto_entry(LuaProto *proto)
Definition: luac_common.c:119
#define LUA_VNUMFLT
Definition: luac_common.h:35
ut32 LUA_INSTRUCTION
Definition: luac_common.h:13
#define LUA_TBOOLEAN
Definition: luac_common.h:27
#define LUA_VLNGSTR
Definition: luac_common.h:37
#define LUA_VNUMINT
Definition: luac_common.h:34
#define lua_check_error_offset(offset)
Definition: luac_common.h:208
#define LUA_VSHRSTR
Definition: luac_common.h:36
#define lua_check_error_offset_proto(offset, proto)
Definition: luac_common.h:212
#define LUA_VFALSE
Definition: luac_common.h:32
#define LUA_VNIL
Definition: luac_common.h:31
#define lua_return_if_null(proto)
Definition: luac_common.h:217
#define LUA_TNIL
Definition: luac_common.h:26
#define LUA_VTRUE
Definition: luac_common.h:33
ut64 LUA_INTEGER
Definition: luac_specs_53.h:11
#define LUAC_53_HDRSIZE
Definition: luac_specs_53.h:34
#define LUA_TNUMINT
Definition: luac_specs_53.h:42
#define LUAC_53_INSTRUCTION_SIZE_OFFSET
Definition: luac_specs_53.h:27
#define LUAC_53_INT_SIZE_OFFSET
Definition: luac_specs_53.h:25
#define LUAC_53_NUMBER_VALIDATION
Definition: luac_specs_53.h:20
#define LUAC_54_FORMAT
Definition: luac_specs_53.h:17
double LUA_NUMBER
Definition: luac_specs_53.h:10
#define LUAC_FILENAME_OFFSET
Definition: luac_specs_53.h:37
#define LUAC_53_NUMBER_VALID_OFFSET
Definition: luac_specs_53.h:31
#define LUAC_53_NUMBER_SIZE_OFFSET
Definition: luac_specs_53.h:29
ut32 LUA_INT
Definition: luac_specs_53.h:12
#define LUAC_53_FORMAT_OFFSET
Definition: luac_specs_53.h:23
#define LUAC_53_INT_VALIDATION
Definition: luac_specs_53.h:19
#define LUAC_53_SIZET_SIZE_OFFSET
Definition: luac_specs_53.h:26
#define LUAC_53_INTEGER_VALID_OFFSET
Definition: luac_specs_53.h:30
#define LUAC_53_INTEGER_SIZE_OFFSET
Definition: luac_specs_53.h:28
#define LUA_TNUMFLT
Definition: luac_specs_53.h:41
char * dest
Definition: lz4.h:697
int x
Definition: mipsasm.c:20
static ut64 lua_parse_code(LuaProto *proto, RzBuffer *buffer, ut64 offset, ut64 data_size)
Definition: parse_53.c:105
LuaProto * lua_parse_body_53(RzBuffer *buffer, ut64 base_offset, ut64 data_size)
Definition: parse_53.c:407
static ut64 lua_parse_name(LuaProto *proto, RzBuffer *buffer, ut64 offset, ut64 data_size)
Definition: parse_53.c:101
RzBinInfo * lua_parse_header_53(RzBinFile *bf, st32 major, st32 minor)
Definition: parse_53.c:483
static ut64 lua_parse_const_entry(LuaProto *proto, RzBuffer *buffer, ut64 offset, ut64 data_size)
Definition: parse_53.c:129
static ut64 lua_parse_debug(LuaProto *proto, RzBuffer *buffer, ut64 offset, ut64 data_size)
Definition: parse_53.c:295
static ut64 lua_parse_upvalues(LuaProto *proto, RzBuffer *buffer, ut64 offset, ut64 data_size)
Definition: parse_53.c:268
static ut64 lua_parse_string(RzBuffer *buffer, ut8 **dest, int *str_len, ut64 offset, ut64 data_size)
Definition: parse_53.c:54
static double lua_load_number(RzBuffer *buffer, ut64 offset)
Definition: parse_53.c:21
static ut64 lua_parse_line_defined(LuaProto *proto, RzBuffer *buffer, ut64 offset, ut64 data_size)
Definition: parse_53.c:33
static void lua_load_block(RzBuffer *buffer, void *dest, size_t size, ut64 offset, ut64 data_size)
Definition: parse_53.c:7
static ut64 lua_parse_consts(LuaProto *proto, RzBuffer *buffer, ut64 offset, ut64 data_size)
Definition: parse_53.c:213
static ut64 lua_parse_protos(LuaProto *proto, RzBuffer *buffer, ut64 offset, ut64 data_size)
Definition: parse_53.c:378
static ut64 lua_load_integer(RzBuffer *buffer, ut64 offset)
Definition: parse_53.c:15
static ut32 lua_load_int(RzBuffer *buffer, ut64 offset)
Definition: parse_53.c:27
static ut64 lua_parse_upvalue_entry(LuaProto *proto, RzBuffer *buffer, ut64 offset, ut64 data_size)
Definition: parse_53.c:240
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
RZ_API bool rz_buf_read8_at(RzBuffer *b, ut64 addr, RZ_NONNULL RZ_OUT ut8 *result)
Read a byte at the specified address in the buffer.
Definition: buf.c:876
RZ_API st64 rz_buf_read_at(RZ_NONNULL RzBuffer *b, ut64 addr, RZ_NONNULL RZ_OUT ut8 *buf, ut64 len)
Read len bytes of the buffer at the specified address.
Definition: buf.c:1136
#define rz_buf_read_le32_at(b, addr, result)
Definition: rz_buf.h:271
#define rz_buf_read_le64_at(b, addr, result)
Definition: rz_buf.h:272
#define RZ_LOG_ERROR(fmtstr,...)
Definition: rz_log.h:58
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1
RZ_API char * rz_str_new(const char *str)
Definition: str.c:865
#define RZ_NEWS(x, y)
Definition: rz_types.h:283
#define RZ_NEW0(x)
Definition: rz_types.h:284
#define st64
Definition: rz_types_base.h:10
#define st32
Definition: rz_types_base.h:12
static int
Definition: sfsocketcall.h:114
Definition: buffer.h:15
Store constant type, data, and offset of this constant in luac file.
Definition: luac_common.h:93
ut64 offset
addr of this constant
Definition: luac_common.h:97
int data_len
len of data
Definition: luac_common.h:96
void * data
can be Number/Integer/String
Definition: luac_common.h:95
ut8 tag
type of this constant, see LUA_V* macros in luac_common.h
Definition: luac_common.h:94
Store upvalue's debug info.
Definition: luac_common.h:149
int name_len
length of name
Definition: luac_common.h:151
ut8 * upvalue_name
upvalue name
Definition: luac_common.h:150
ut64 offset
Definition: luac_common.h:152
Store line info attributes.
Definition: luac_common.h:118
ut32 info_data
Definition: luac_common.h:119
ut64 offset
Definition: luac_common.h:120
Store local var names and other info.
Definition: luac_common.h:137
int varname_len
length of name
Definition: luac_common.h:139
int end_pc
first deactive position
Definition: luac_common.h:141
ut64 offset
offset of this entry
Definition: luac_common.h:142
int start_pc
first active position
Definition: luac_common.h:140
ut8 * varname
name of this variable
Definition: luac_common.h:138
Store valuable info when parsing. Treat luac file body as a main function.
Definition: luac_common.h:43
int name_size
size of proto name
Definition: luac_common.h:48
ut64 lastline_defined
line number of function end
Definition: luac_common.h:51
RzList * dbg_upvalue_entries
A list to store upvalue names.
Definition: luac_common.h:83
ut64 line_defined
line number of function start
Definition: luac_common.h:50
RzList * upvalue_entries
A list to store upvalue entries.
Definition: luac_common.h:68
ut64 size
current proto size
Definition: luac_common.h:45
ut8 is_vararg
is variable arg?
Definition: luac_common.h:54
ut64 inner_proto_offset
sub proto section offset
Definition: luac_common.h:74
ut64 code_skipped
opcode data offset to code_offset.
Definition: luac_common.h:60
ut64 const_offset
const section offset
Definition: luac_common.h:64
ut8 num_params
number of parameters of this proto
Definition: luac_common.h:53
ut64 upvalue_size
upvalue section size
Definition: luac_common.h:70
RzList * local_var_info_entries
A list to store local var entries.
Definition: luac_common.h:82
RzList * const_entries
A list to store constant entries.
Definition: luac_common.h:63
ut8 * proto_name
current proto name
Definition: luac_common.h:47
ut64 code_offset
code section offset
Definition: luac_common.h:58
RzList * proto_entries
A list to store sub proto entries.
Definition: luac_common.h:73
ut64 upvalue_offset
upvalue section offset
Definition: luac_common.h:69
ut64 offset
proto offset in bytes
Definition: luac_common.h:44
ut64 debug_size
debug section size
Definition: luac_common.h:79
ut64 debug_offset
debug section offset
Definition: luac_common.h:78
RzList * line_info_entries
A list to store line info entries.
Definition: luac_common.h:80
ut8 max_stack_size
max stack size
Definition: luac_common.h:55
ut64 const_size
const section size
Definition: luac_common.h:65
ut64 inner_proto_size
sub proto section size
Definition: luac_common.h:75
ut64 code_size
code section size
Definition: luac_common.h:59
Store upvalue attributes.
Definition: luac_common.h:104
ut64 offset
offset of this upvalue
Definition: luac_common.h:109
ut8 idx
index
Definition: luac_common.h:107
ut8 kind
kind
Definition: luac_common.h:108
ut8 instack
is in stack
Definition: luac_common.h:106
XX curplugin == o->plugin.
Definition: rz_bin.h:298
char * file
Definition: rz_bin.h:299
RzBuffer * buf
Definition: rz_bin.h:303
char * type
Definition: rz_bin.h:211
char * os
Definition: rz_bin.h:219
char * machine
Definition: rz_bin.h:216
char * bclass
Definition: rz_bin.h:212
char * guid
Definition: rz_bin.h:222
char * file
Definition: rz_bin.h:210
char * cpu
Definition: rz_bin.h:215
char * rclass
Definition: rz_bin.h:213
char * arch
Definition: rz_bin.h:214
char * compiler
Definition: rz_bin.h:244
ut64(WINAPI *w32_GetEnabledXStateFeatures)()