Rizin
unix-like reverse engineering framework and cli tools
marshal.h
Go to the documentation of this file.
1
// SPDX-FileCopyrightText: 2016 c0riolis
2
// SPDX-FileCopyrightText: 2016 Tardy
3
// SPDX-License-Identifier: LGPL-3.0-only
4
5
#ifndef MARSHAL_H
6
#define MARSHAL_H
7
8
#include <
rz_util.h
>
9
#include <
rz_types.h
>
10
#include "
pyc_magic.h
"
11
12
typedef
enum
{
13
TYPE_ASCII
=
'a'
,
14
TYPE_ASCII_INTERNED
=
'A'
,
15
TYPE_BINARY_COMPLEX
=
'y'
,
16
TYPE_BINARY_FLOAT
=
'g'
,
17
TYPE_CODE_v0
=
'C'
,
18
TYPE_CODE_v1
=
'c'
,
19
TYPE_COMPLEX
=
'x'
,
20
TYPE_DICT
=
'{'
,
21
TYPE_ELLIPSIS
=
'.'
,
22
TYPE_FALSE
=
'F'
,
23
TYPE_FLOAT
=
'f'
,
24
TYPE_FROZENSET
=
'>'
,
25
TYPE_INT64
=
'I'
,
26
TYPE_INTERNED
=
't'
,
27
TYPE_INT
=
'i'
,
28
TYPE_LIST
=
'['
,
29
TYPE_LONG
=
'l'
,
30
TYPE_NONE
=
'N'
,
31
TYPE_NULL
=
'0'
,
32
TYPE_REF
=
'r'
,
33
TYPE_SET
=
'<'
,
34
TYPE_SHORT_ASCII_INTERNED
=
'Z'
,
35
TYPE_SHORT_ASCII
=
'z'
,
36
TYPE_SMALL_TUPLE
=
')'
,
37
TYPE_STOPITER
=
'S'
,
38
TYPE_STRINGREF
=
'R'
,
39
TYPE_STRING
=
's'
,
40
TYPE_TRUE
=
'T'
,
41
TYPE_TUPLE
=
'('
,
42
TYPE_UNICODE
=
'u'
,
43
TYPE_UNKNOWN
=
'?'
,
44
}
pyc_marshal_type
;
45
46
typedef
enum
{
47
FLAG_REF
=
'\x80'
,
48
}
pyc_marshal_flag
;
49
50
typedef
struct
{
51
pyc_marshal_type
type
;
52
void
*
data
;
53
}
pyc_object
;
54
55
typedef
struct
{
56
ut32
argcount
;
57
ut32
posonlyargcount
;
58
ut32
kwonlyargcount
;
59
ut32
nlocals
;
60
ut32
stacksize
;
61
ut32
flags
;
62
pyc_object
*
code
;
63
pyc_object
*
consts
;
64
pyc_object
*
names
;
65
pyc_object
*
varnames
;
66
pyc_object
*
freevars
;
67
pyc_object
*
cellvars
;
68
pyc_object
*
filename
;
69
pyc_object
*
name
;
70
ut32
firstlineno
;
71
pyc_object
*
lnotab
;
72
st64
start_offset
;
73
st64
end_offset
;
74
}
pyc_code_object
;
75
76
typedef
struct
pyc_context
{
77
ut64
code_start_offset
;
78
struct
pyc_version
version
;
79
/* used from marshall.c */
80
RzList
*
interned_table
;
81
RzList
*
sections_cache
;
82
RzList
*
shared
;
83
RzList
*
refs
;
// If you don't have a good reason, do not change this. And also checkout !refs in get_code_object()
84
ut32
magic_int
;
85
ut32
symbols_ordinal
;
86
}
RzBinPycObj
;
87
88
bool
get_sections_symbols_from_code_objects
(
RzBinPycObj
*pyc,
RzBuffer
*
buffer
,
RzList
*
sections
,
RzList
*
symbols
,
RzList
*objs,
ut32
magic
);
89
ut64
get_code_object_addr
(
RzBinPycObj
*pyc,
RzBuffer
*
buffer
,
ut32
magic
);
90
91
#endif
symbols
RzList * symbols(RzBinFile *bf)
Definition:
bin_ne.c:102
sections
RzList * sections(RzBinFile *bf)
Definition:
bin_ne.c:110
ut32
uint32_t ut32
Definition:
demangler_util.h:31
pyc_marshal_flag
pyc_marshal_flag
Definition:
marshal.h:46
FLAG_REF
@ FLAG_REF
Definition:
marshal.h:47
pyc_marshal_type
pyc_marshal_type
Definition:
marshal.h:12
TYPE_NONE
@ TYPE_NONE
Definition:
marshal.h:30
TYPE_STRINGREF
@ TYPE_STRINGREF
Definition:
marshal.h:38
TYPE_INT64
@ TYPE_INT64
Definition:
marshal.h:25
TYPE_SHORT_ASCII
@ TYPE_SHORT_ASCII
Definition:
marshal.h:35
TYPE_NULL
@ TYPE_NULL
Definition:
marshal.h:31
TYPE_BINARY_FLOAT
@ TYPE_BINARY_FLOAT
Definition:
marshal.h:16
TYPE_FLOAT
@ TYPE_FLOAT
Definition:
marshal.h:23
TYPE_LIST
@ TYPE_LIST
Definition:
marshal.h:28
TYPE_BINARY_COMPLEX
@ TYPE_BINARY_COMPLEX
Definition:
marshal.h:15
TYPE_TUPLE
@ TYPE_TUPLE
Definition:
marshal.h:41
TYPE_TRUE
@ TYPE_TRUE
Definition:
marshal.h:40
TYPE_LONG
@ TYPE_LONG
Definition:
marshal.h:29
TYPE_INT
@ TYPE_INT
Definition:
marshal.h:27
TYPE_UNKNOWN
@ TYPE_UNKNOWN
Definition:
marshal.h:43
TYPE_DICT
@ TYPE_DICT
Definition:
marshal.h:20
TYPE_UNICODE
@ TYPE_UNICODE
Definition:
marshal.h:42
TYPE_SMALL_TUPLE
@ TYPE_SMALL_TUPLE
Definition:
marshal.h:36
TYPE_INTERNED
@ TYPE_INTERNED
Definition:
marshal.h:26
TYPE_ELLIPSIS
@ TYPE_ELLIPSIS
Definition:
marshal.h:21
TYPE_COMPLEX
@ TYPE_COMPLEX
Definition:
marshal.h:19
TYPE_CODE_v1
@ TYPE_CODE_v1
Definition:
marshal.h:18
TYPE_ASCII_INTERNED
@ TYPE_ASCII_INTERNED
Definition:
marshal.h:14
TYPE_REF
@ TYPE_REF
Definition:
marshal.h:32
TYPE_FALSE
@ TYPE_FALSE
Definition:
marshal.h:22
TYPE_SET
@ TYPE_SET
Definition:
marshal.h:33
TYPE_CODE_v0
@ TYPE_CODE_v0
Definition:
marshal.h:17
TYPE_STRING
@ TYPE_STRING
Definition:
marshal.h:39
TYPE_FROZENSET
@ TYPE_FROZENSET
Definition:
marshal.h:24
TYPE_ASCII
@ TYPE_ASCII
Definition:
marshal.h:13
TYPE_STOPITER
@ TYPE_STOPITER
Definition:
marshal.h:37
TYPE_SHORT_ASCII_INTERNED
@ TYPE_SHORT_ASCII_INTERNED
Definition:
marshal.h:34
get_code_object_addr
ut64 get_code_object_addr(RzBinPycObj *pyc, RzBuffer *buffer, ut32 magic)
Definition:
marshal.c:981
get_sections_symbols_from_code_objects
bool get_sections_symbols_from_code_objects(RzBinPycObj *pyc, RzBuffer *buffer, RzList *sections, RzList *symbols, RzList *objs, ut32 magic)
Definition:
marshal.c:1190
RzBinPycObj
struct pyc_context RzBinPycObj
version
Definition:
version.py:1
pyc_magic.h
rz_types.h
st64
#define st64
Definition:
rz_types_base.h:10
rz_util.h
buffer
Definition:
buffer.h:15
pyc_code_object
Definition:
marshal.h:55
pyc_code_object::kwonlyargcount
ut32 kwonlyargcount
Definition:
marshal.h:58
pyc_code_object::names
pyc_object * names
Definition:
marshal.h:64
pyc_code_object::stacksize
ut32 stacksize
Definition:
marshal.h:60
pyc_code_object::posonlyargcount
ut32 posonlyargcount
Definition:
marshal.h:57
pyc_code_object::end_offset
st64 end_offset
Definition:
marshal.h:73
pyc_code_object::firstlineno
ut32 firstlineno
Definition:
marshal.h:70
pyc_code_object::varnames
pyc_object * varnames
Definition:
marshal.h:65
pyc_code_object::freevars
pyc_object * freevars
Definition:
marshal.h:66
pyc_code_object::code
pyc_object * code
Definition:
marshal.h:62
pyc_code_object::flags
ut32 flags
Definition:
marshal.h:61
pyc_code_object::nlocals
ut32 nlocals
Definition:
marshal.h:59
pyc_code_object::start_offset
st64 start_offset
Definition:
marshal.h:72
pyc_code_object::filename
pyc_object * filename
Definition:
marshal.h:68
pyc_code_object::cellvars
pyc_object * cellvars
Definition:
marshal.h:67
pyc_code_object::lnotab
pyc_object * lnotab
Definition:
marshal.h:71
pyc_code_object::name
pyc_object * name
Definition:
marshal.h:69
pyc_code_object::consts
pyc_object * consts
Definition:
marshal.h:63
pyc_code_object::argcount
ut32 argcount
Definition:
marshal.h:56
pyc_context
Definition:
marshal.h:76
pyc_context::symbols_ordinal
ut32 symbols_ordinal
Definition:
marshal.h:85
pyc_context::refs
RzList * refs
Definition:
marshal.h:83
pyc_context::code_start_offset
ut64 code_start_offset
Definition:
marshal.h:77
pyc_context::sections_cache
RzList * sections_cache
Definition:
marshal.h:81
pyc_context::interned_table
RzList * interned_table
Definition:
marshal.h:80
pyc_context::magic_int
ut32 magic_int
Definition:
marshal.h:84
pyc_context::shared
RzList * shared
Definition:
marshal.h:82
pyc_object
Definition:
marshal.h:50
pyc_object::data
void * data
Definition:
marshal.h:52
pyc_object::type
pyc_marshal_type type
Definition:
marshal.h:51
pyc_version
Definition:
pyc_magic.h:10
pyc_version::magic
ut32 magic
Definition:
pyc_magic.h:11
rz_buf_t
Definition:
rz_buf.h:43
rz_list_t
Definition:
rz_list.h:18
ut64
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
librz
bin
format
pyc
marshal.h
Generated by
1.9.1