Skip to content

Commit b693d91

Browse files
committed
updat3
1 parent 643d546 commit b693d91

File tree

4 files changed

+34
-5
lines changed

4 files changed

+34
-5
lines changed

libr/arch/p/pyc/plugin.c

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,27 @@ static pyc_opcodes *get_pyc_opcodes(RArchSession *s) {
3737
return ops;
3838
}
3939

40-
static RList *get_pyc_code_obj(RArchSession *as) {
40+
#if 0
41+
struct pyc_version {
42+
ut32 magic;
43+
const char *version;
44+
const char *revision;
45+
};
46+
typedef struct {
47+
ut64 code_start_offset;
48+
struct pyc_version version;
49+
RList *sections_cache; // RList<RBinSection*>
50+
RList *interned_table; // RList<char*>
51+
RList *cobjs; // RList<pyc_code_object*>
52+
} RBinPycObj;
53+
#endif
54+
55+
static inline RList *get_pyc_code_obj(RArchSession *as) {
4156
RBin *b = as->arch->binb.bin;
42-
RBinPlugin *plugin = b->cur && b->cur->bo? b->cur->bo->plugin: NULL;
43-
bool is_pyc = (plugin && strcmp (plugin->meta.name, "pyc") == 0);
44-
return is_pyc? b->cur->bo->bin_obj: NULL;
57+
RBinPlugin *plugin = R_UNWRAP4 (b, cur, bo, plugin);
58+
const bool is_pyc = (plugin && !strcmp (plugin->meta.name, "pyc"));
59+
RBinPycObj *pyc = is_pyc? b->cur->bo->bin_obj: NULL;
60+
return pyc? pyc->cobjs: NULL;
4561
}
4662

4763
static inline pyc_code_object *get_func(ut64 pc, RList *pyobj) {

libr/arch/p/pyc/pyc_dis.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <r_util.h>
77
#include <r_asm.h>
88

9+
#include "../../bin/format/pyc/pyc_magic.h"
910
#include "opcode.h"
1011

1112
typedef struct {

libr/bin/format/pyc/pyc_magic.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
1-
/* radare - LGPL3 - Copyright 2016-2020 - c0riolis, x0urc3 */
1+
/* radare - LGPL3 - Copyright 2016-2025 - c0riolis, x0urc3 */
22

33
#ifndef PYC_MAGIC_H
44
#define PYC_MAGIC_H
55

66
#include <r_types.h>
7+
#include <r_list.h>
78

89
struct pyc_version {
910
ut32 magic;
1011
const char *version;
1112
const char *revision;
1213
};
14+
#if 1
15+
typedef struct {
16+
ut64 code_start_offset;
17+
struct pyc_version version;
18+
RList *sections_cache; // RList<RBinSection*>
19+
RList *interned_table; // RList<char*>
20+
RList *cobjs; // RList<pyc_code_object*>
21+
} RBinPycObj;
22+
#endif
1323

1424
struct pyc_version get_pyc_version(ut32 magic);
1525

libr/bin/p/bin_pyc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
#include <r_bin.h>
44
#include "../format/pyc/pyc.h"
55

6+
#if 0
67
typedef struct {
78
ut64 code_start_offset;
89
struct pyc_version version;
910
RList *sections_cache; // RList<RBinSection*>
1011
RList *interned_table; // RList<char*>
1112
RList *cobjs; // RList<pyc_code_object*>
1213
} RBinPycObj;
14+
#endif
1315

1416
static bool check(RBinFile *bf, RBuffer *b) {
1517
if (r_buf_size (b) > 4) {

0 commit comments

Comments
 (0)