forked from Megazig/rso_ida_loader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrso.h
executable file
·160 lines (139 loc) · 3.73 KB
/
rso.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/*
* IDA Nintendo GameCube RSO Loader Module
* (C) Copyright 2010 Stephen Simpson
*
*/
#ifndef __RSO_H__
#define __RSO_H__
#define START 0x80500000
/* Header Size = 100h bytes */
typedef struct {
void * head;
void * tail;
} queue_t;
typedef struct {
void * next;
void * prev;
} link_t;
typedef struct {
unsigned int align;
unsigned int bssAlign;
} module_v2;
typedef struct {
unsigned int fixSize;
} module_v3;
#define USING_RSO 1
typedef struct {
/* in .rso or .rel, not in .sel */
#if USING_RSO
unsigned int ModuleID;
#endif
/* in .rso or .rel or .sel */
unsigned int Prev;
unsigned int Next;
unsigned int SectionCount;
unsigned int SectionOffset;
unsigned int PathOffset;
unsigned int PathLength;
unsigned int Version;
/* type 1 or later */
unsigned int BssSize;
unsigned int RelOffset;
unsigned int ImpOffset;
unsigned char PrologSection;
unsigned char EpilogSection;
unsigned char UnresolvedSection;
unsigned char BssSection;
unsigned int Prolog;
unsigned int Epilog;
unsigned int Unresolved;
/* type 2 or later */
unsigned int align;
unsigned int bssAlign;
/* type 3 or later */
unsigned int fixSize;
} rsohdr;
typedef struct {
unsigned int internal_table_offset; // 30
unsigned int internal_table_length; // 34
unsigned int external_table_offset; // 38
unsigned int external_table_length; // 3C
unsigned int export_table_offset; // 40
unsigned int export_table_length; // 44
unsigned int export_table_names; // 48
unsigned int import_table_offset; // 4C
unsigned int import_table_length; // 50
unsigned int import_table_names; // 54
} module_v1_extra;
/* usually right after header */
typedef struct {
unsigned int Offset;
unsigned int Length;
} section_entry;
/* usually after section list */
/* usually an export then import */
typedef struct {
unsigned int offset;
unsigned int length;
unsigned int names;
} ex_im_port_entry;
typedef struct {
unsigned int name_off;
unsigned int section_off;
unsigned int section_num;
unsigned int elf_hash;
} export_table_entry;
#define SECTION_EXEC 0x1
#define SECTION_OFF(off) (off&~1)
typedef struct {
unsigned int id;
unsigned int offset;
} import_info;
typedef struct {
unsigned short offset; // byte offset from previous entry
unsigned char type;
unsigned char section;
unsigned int addend;
} rel_t;
const char * rel_names[] = {
"R_PPC_NONE",
"R_PPC_ADDR32",
"R_PPC_ADDR24",
"R_PPC_ADDR16",
"R_PPC_ADDR16_LO",
"R_PPC_ADDR16_HI",
"R_PPC_ADDR16_HA",
"R_PPC_ADDR14",
"R_PPC_ADDR14_BRTAKEN",
"R_PPC_ADDR14_BRNTAKEN",
"R_PPC_REL24",
"R_PPC_REL14",
};
/* calculation */
#define R_PPC_NONE 0 /* none */
#define R_PPC_ADDR32 1 /* S + A */
#define R_PPC_ADDR24 2 /* (S + A) >> 2 */
#define R_PPC_ADDR16 3 /* S + A */
#define R_PPC_ADDR16_LO 4
#define R_PPC_ADDR16_HI 5
#define R_PPC_ADDR16_HA 6
#define R_PPC_ADDR14 7
#define R_PPC_ADDR14_BRTAKEN 8
#define R_PPC_ADDR14_BRNTAKEN 9
#define R_PPC_REL24 10 /* (S + A - P) >> 2 */
#define R_PPC_REL14 11
#define R_DOLPHIN_NOP 201 // C9h current offset += rel.offset
#define R_DOLPHIN_SECTION 202 // CAh current offset = rel.section
#define R_DOLPHIN_END 203 // CBh
#define R_DOLPHIN_MRKREF 204 // CCh
/* OSSetStringTable(const void * stringTable);
* OSLink(OSModuleInfo* newModule, void* bss);
* OSLinkFixed(OSModuleInfo* newModule, void* bss);
* OSUnlink(OSModuleInfo* oldModule);
* OSSearchModule(void* ptr, u32* section, u32* offset);
* OSNotifyLink
* OSNotifyUnlink
* OSNotifyPreLink
* OSNotifyPostLink
*/
#endif