RetroLinker
Linker for several 8-bit, 16-bit and 32-bit formats
Loading...
Searching...
No Matches
epoc.h
1#ifndef EPOC_H
2#define EPOC_H
3
4#include <array>
5#include "../linker/format.h"
6
9
10namespace EPOC
11{
13 {
14 public:
15 /* * * General members * * */
16 enum executable_type
17 {
18 KDirectFileStoreLayoutUid = 0x10000037,
19 KPermanentFileStoreLayoutUid = 0x10000050,
20 KDynamicLibraryUid = 0x10000079,
21 KExecutableImageUid = 0x1000007A,
22 };
23 executable_type uid1 = executable_type(0);
24
25 enum application_type
26 {
27 /* for KDirectFileStoreLayoutUid or KPermanentFileStoreLayoutUid */
28 _OPLObjectModule = 0x10000073,
29 _OPLApplication = 0x10000074,
30 KUidAppDllDoc = 0x10003A12,
31 KUidAppInfoFile = 0x10003A38,
32 /* for KDynamicLibraryUid */
33 _OPLExtensions = 0x1000005D,
34 _Application = 0x1000006C,
35 KSharedLibraryUid = 0x1000008D,
36 KLogicalDeviceDriverUid8 = 0x100000AE,
37 KLogicalDeviceDriverUid16 = 0x100000AF,
38 KUidApp = 0x100039CE,
39 KPhysicalDeviceDriverUid16 = 0x100039D0,
40 KPhysicalDeviceDriverUid8 = 0x100000AD,
41 /* ? */
42 KMachineConfigurationUid = 0x100000F4,
43 KLocaleDllUid16 = 0x100039E6,
44 KLocaleDllUid8 = 0x100000C3,
45 KKeyboardUid = 0x100000DB,
46 KEka1EntryStubUid = 0x101FDF0F,
47 KKeyboardDataUid16 = 0x100039E0,
48 KKeyboardDataUid8 = 0x100000DC,
49 KKeyboardTranUid16 = 0x100039E1,
50 KKeyboardTranUid8 = 0x100000DD,
51 KConsoleDllUid16 = 0x100039E7,
52 KConsoleDllUid8 = 0x100000C5,
53 KSystemStartupModeKey = 0x10204BB5,
54 KSystemEmulatorOrientationKey = 0x10204BB6,
55 KServerProcessUid = 0x1000008C,
56 KFileSystemUid = 0x1000008F,
57 KFileServerUid = 0x100000BB,
58 KLocalFileSystemUid = 0x100000D6,
59 KFileServerDllUid = 0x100000BD,
60 };
61 application_type uid2 = application_type(0);
62
63 uint32_t uid3 = 0;
64 uint32_t uid_checksum = 0;
65
66 bool new_format = true;
67
68 enum cpu_type
69 {
70 ECpuUnknown = 0,
71 ECpuX86 = 0x1000,
72 ECpuArmV4 = 0x2000,
73 ECpuArmV5 = 0x2001,
74 ECpuArmV6 = 0x2002,
75 ECpuMCore = 0x4000,
76 };
77 cpu_type cpu = ECpuUnknown;
78
79 uint32_t header_crc = 0;
80 union
81 {
82 uint32_t code_checksum;
83 uint32_t module_version;
84 };
85 union
86 {
87 uint32_t data_checksum;
88 uint32_t compression_type;
89 };
90
91 uint32_t tool_version;
92 ::Timestamp<Symbian_clock> timestamp;
93 enum flags_type
94 {
95 };
96 flags_type flags = flags_type(0);
97 uint32_t heap_size_min = 0;
98 uint32_t heap_size_max = 0;
99 uint32_t stack_size = 0;
100 uint32_t bss_size = 0;
101 uint32_t entry_point = 0;
102 uint32_t code_address = 0;
103 uint32_t data_address = 0;
104 uint32_t export_table_offset = 0;
105 uint32_t import_table_offset = 0;
106 uint32_t code_offset = 0;
107 uint32_t data_offset = 0;
108 uint32_t import_offset = 0;
109 uint32_t code_relocation_offset = 0;
110 uint32_t data_relocation_offset = 0;
111 uint32_t process_priority = 0;
112
113 // new header
114 uint32_t uncompressed_size = 0;
115 uint32_t secure_id = 0;
116 uint32_t vendor_id = 0;
117 enum capability_type
118 {
119 // TODO
120 };
121 std::array<capability_type, 2> capabilities;
122 uint32_t exception_descriptor = 0;
123 uint8_t export_description_type = 0;
124 std::vector<uint8_t> export_description;
125
126 std::shared_ptr<Linker::Contents> code, data;
127
129 {
130 uint32_t name_offset = 0;
131 std::vector<uint32_t> imports;
132 };
133
134 std::vector<ImportBlock> dll_reference_table;
135 uint32_t dll_reference_table_size = 0;
136
138 {
139 uint16_t offset = 0;
140 enum relocation_type
141 {
142 FromCode = 1,
143 FromData = 2,
144 FromEither = 3,
145 };
146 relocation_type type = relocation_type(0);
147 };
148
150 {
151 uint32_t page_offset = 0;
152 std::vector<Relocation> relocations;
153 };
154
156 {
157 std::vector<RelocationBlock> blocks;
158 uint32_t GetSize() const;
159 uint32_t GetCount() const;
160 void ReadFile(const std::shared_ptr<Linker::Reader>& rd);
161 };
162 RelocationSection code_relocations, data_relocations;
163
165 : code_checksum(0), data_checksum(0)
166 {
167 }
168
169 void ReadFile(const std::shared_ptr<Linker::Reader>& rd) override;
170
171 offset_t ImageSize() const override;
172
174 offset_t WriteFile(const std::shared_ptr<Linker::Writer>& wr) const override;
175
176 void Dump(Dumper::Dumper& dump) const override;
177 };
178}
179
180#endif /* EPOC_H */
An abstract interface that separates structure and presentation of the data inside a file.
Definition dumper.h:1009
Definition epoc.h:13
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition epoc.cc:194
offset_t WriteFile(const std::shared_ptr< Linker::Writer > &wr) const override
Stores data in memory to file.
Definition epoc.cc:170
void ReadFile(const std::shared_ptr< Linker::Reader > &rd) override
Loads file into memory.
Definition epoc.cc:56
offset_t ImageSize() const override
Retrieves the offset of the byte after the last one belonging to this format from the first one.
Definition epoc.cc:164
A class to encode a general file format.
Definition format.h:29
offset_t WriteFile(const std::shared_ptr< Writer > &wr) const override=0
Stores data in memory to file.
Definition epoc.h:138
A static class that encodes a specific timestamp format.
Definition common.h:210