-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcsxfile.h
76 lines (58 loc) · 1.68 KB
/
csxfile.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
#ifndef CSXFILE_H
#define CSXFILE_H
#include "csxsection.h"
#include "csximage.h"
typedef struct
{
char fileType[8];
uint32_t unknown1;
uint32_t zero;
char imageType[40];
uint32_t size;
uint32_t unknown2;
} CSXHeader_t;
typedef struct
{
std::u16string name;
int32_t type;
std::u16string type_name;
int init_val_integer;
float init_val_real;
} global_t;
#define offset_type std::pair<uint32_t,std::u16string>
class CSXFile
{
public:
CSXFile();
~CSXFile();
bool load_from_file(std::string file_name);
void read_offsets();
void print_offsets();
void read_conststr();
void print_conststr();
void read_global();
void print_global();
void read_linkinf();
void decompile();
void listing_to_file(std::string fn);
static std::u16string get_conststr(uint32_t offset) { return m_instance->m_conststr[offset]; }
static std::u16string get_linkinf(uint32_t offset) { return m_instance->m_linkinf2[offset]; }
static std::u16string get_function_name(uint32_t offset);
void export_all_sections(std::string dir_name);
private:
static CSXFile *m_instance;
CSXHeader_t m_header;
std::vector<CSXSection*> m_sections;
CSXImage *m_image;
//functions offsets
std::vector<uint32_t> m_init_offsets;
std::vector<offset_type> m_offsets;
//constsrt
std::map<uint32_t,std::u16string> m_conststr;
//global
std::vector<global_t> m_global;
//linkinf
std::vector<uint32_t> m_linkinf1;
std::map<uint32_t,std::u16string> m_linkinf2;
};
#endif // CSXFILE_H