Rizin
unix-like reverse engineering framework and cli tools
pyc.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2016-2020 c0riolis
2 // SPDX-FileCopyrightText: 2016-2020 x0urc3
3 // SPDX-License-Identifier: LGPL-3.0-only
4 
5 #include "pyc.h"
6 #include "marshal.h"
7 
9  return get_sections_symbols_from_code_objects(pyc, buf, sections, symbols, cobjs, magic);
10 }
11 
13  return b == type;
14 }
15 
16 bool pyc_is_code(ut8 b, ut32 magic) {
17  if ((magic == 0x00949494 || magic == 0x0099be2a || magic == 0x0099be3a || magic == 0x00999901) && (pyc_is_object((b & ~FLAG_REF), TYPE_CODE_v0))) {
18  // TYPE_CODE_V0 for Python < 1.0
19  return true;
20  }
21  if (pyc_is_object((b & ~FLAG_REF), TYPE_CODE_v1)) {
22  return true;
23  }
24  return false;
25 }
RzList * symbols(RzBinFile *bf)
Definition: bin_ne.c:102
RzList * sections(RzBinFile *bf)
Definition: bin_ne.c:110
uint32_t ut32
voidpf void * buf
Definition: ioapi.h:138
uint8_t ut8
Definition: lh5801.h:11
bool get_sections_symbols_from_code_objects(RzBinPycObj *pyc, RzBuffer *buffer, RzList *sections, RzList *symbols, RzList *cobjs, ut32 magic)
Definition: marshal.c:1190
@ FLAG_REF
Definition: marshal.h:47
pyc_marshal_type
Definition: marshal.h:12
@ TYPE_CODE_v1
Definition: marshal.h:18
@ TYPE_CODE_v0
Definition: marshal.h:17
int type
Definition: mipsasm.c:17
bool pyc_is_code(ut8 b, ut32 magic)
Definition: pyc.c:16
bool pyc_get_sections_symbols(RzBinPycObj *pyc, RzList *sections, RzList *symbols, RzList *cobjs, RzBuffer *buf, ut32 magic)
Definition: pyc.c:8
static bool pyc_is_object(ut8 b, pyc_marshal_type type)
Definition: pyc.c:12
#define b(i)
Definition: sha256.c:42