RetroLinker
Linker for several 8-bit, 16-bit and 32-bit formats
Loading...
Searching...
No Matches
xpexp.h
1#ifndef XPEXP_H
2#define XPEXP_H
3
4#include "../common.h"
5#include "../dumper/dumper.h"
6#include "../linker/reader.h"
7#include "../linker/segment_manager.h"
8#include "../linker/writer.h"
9
10/* TODO: unimplemented */
11
12namespace Ergo
13{
17 class XPFormat : public virtual Linker::SegmentManager
18 {
19 public:
20 std::string stub_file; // TODO
21
22 struct Segment
23 {
24 public:
25 uint16_t limit;
26 uint32_t base;
27 enum
28 {
29 ACCESS_DATA = 0x92,
30 ACCESS_CODE = 0x9A,
31
32 ACCESS_E = 0x08,
33 ACCESS_S = 0x10,
34
35 ACCESS_CPL0 = 0x00,
36 ACCESS_CPL1 = 0x20,
37 ACCESS_CPL2 = 0x40,
38 ACCESS_CPL3 = 0x60,
39
40 ACCESS_TYPE_EMPTY = 0x00,
41 ACCESS_TYPE_TSS16_A = 0x01,
42 ACCESS_TYPE_LDT = 0x02,
43 ACCESS_TYPE_TSS16_B = 0x03,
44 ACCESS_TYPE_CALLGATE16 = 0x04,
45 ACCESS_TYPE_TASKGATE = 0x05,
46 ACCESS_TYPE_INTGATE16 = 0x06,
47 ACCESS_TYPE_TRAPGATE16 = 0x07,
48
49 ACCESS_TYPE_TSS32_A = 0x09,
50
51 ACCESS_TYPE_TSS32_B = 0x0B,
52 ACCESS_TYPE_CALLGATE32 = 0x0C,
53
54 ACCESS_TYPE_INTGATE32 = 0x0E,
55 ACCESS_TYPE_TRAPGATE32 = 0x0F,
56 };
57 uint8_t access;
58 enum
59 {
60 FLAG_ALIAS = 0x10,
61 FLAG_WINDOW = 0x20,
62 FLAG_32BIT = 0x40,
63 FLAG_PAGES = 0x80, // instead of bytes, for limit size
64 };
65 uint8_t flags;
66
67 static Segment ReadFile(Linker::Reader& rd);
68 void WriteFile(Linker::Writer& wr) const;
69 void Dump(Dumper::Dumper& dump, const XPFormat& xp, unsigned index) const;
70 };
71
72 uint32_t ldt_offset = 0;
73 uint32_t image_offset = 0;
74 uint32_t relocation_offset = 0; // TODO: unsure
75 uint32_t relocation_count = 0; // TODO: replace with std::vector<Relocation> once the relocation format is known
76 uint32_t minimum_extent = 0;
77 uint32_t maximum_extent = 0;
78 uint32_t unknown_field = 0;
79 uint32_t gs, fs, ds, ss, cs, es, edi, esi, ebp, esp, ebx, edx, ecx, eax, eflags, eip;
80 std::vector<Segment> ldt;
81 std::shared_ptr<Linker::Image> image;
82
83 void Clear() override;
84 void CalculateValues() override;
85 void ReadFile(Linker::Reader& rd) override;
87 offset_t WriteFile(Linker::Writer& wr) const override;
88 offset_t ImageSize() const override;
89 void Dump(Dumper::Dumper& dump) const override;
90 /* TODO */
91
93 std::string GetDefaultExtension(Linker::Module& module, std::string filename) const override;
94 };
95}
96
97#endif /* XPEXP_H */
An abstract interface that separates structure and presentation of the data inside a file.
Definition dumper.h:586
Ergo OS/286 and OS/386 "XP" .exp file (Ergo was formerly A.I. Architects, then Eclipse)
Definition xpexp.h:18
void Clear() override
Resets all fields to their default values, deallocate memory.
Definition xpexp.cc:24
void CalculateValues() override
Intermediate step between processing module and generating output file to set up headers and manageme...
Definition xpexp.cc:10
std::string GetDefaultExtension(Linker::Module &module, std::string filename) const override
Appends a default extension to the filename.
Definition xpexp.cc:174
offset_t ImageSize() const override
Retrieves size of stored data.
Definition xpexp.cc:128
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition xpexp.cc:135
void ReadFile(Linker::Reader &rd) override
Loads file into memory.
Definition xpexp.cc:39
offset_t WriteFile(Linker::Writer &wr) const override
Stores data in memory to file.
Definition xpexp.cc:83
offset_t WriteFile(Writer &wr) const override=0
Stores data in memory to file.
Encodes an object module file as a collection of sections, symbols and relocations.
Definition module.h:24
virtual std::string GetDefaultExtension(Module &module, std::string filename) const
Appends a default extension to the filename.
A helper class, encapsulating functionality needed to import binary data.
Definition reader.h:16
A helper class to collect sections into segments.
Definition segment_manager.h:32
A helper class, encapsulating functionality needed to export binary data.
Definition writer.h:15
Definition xpexp.h:23