7#include "../dumper/dumper.h"
8#include "../linker/module.h"
9#include "../linker/options.h"
10#include "../linker/segment.h"
11#include "../linker/segment_manager.h"
12#include "../linker/writer.h"
29 RT_ACCELERATOR = 0x0009,
31 RT_MESSAGETABLE = 0x000B,
32 RT_GROUP_CURSOR = 0x000C,
33 RT_GROUP_ICON = 0x000E,
35 RT_DLGINCLUDE = 0x0011,
38 RT_ANICURSOR = 0x0015,
60 RT_ACCELERATOR = 0x0008,
65 RT_DLGINCLUDE = 0x000B,
69 RT_DISPLAYINFO = 0x000F,
73 RT_HELPTABLE = 0x0012,
74 RT_HELPSUBTABLE = 0x0013,
106 std::shared_ptr<Linker::Image> image;
107 offset_t data_offset = 0;
110 enum flag_type : uint16_t
116 Movable = 0x10, Fixed = 0,
118 Preload = 0x40, LoadOnCall = 0,
119 ExecuteOnly = 0x80|Code, ReadOnly = 0x80|Data,
120 Relocations = 0x0100,
122 Discardable = 0x1000,
124 flag_type flags = flag_type(0);
137 Segment(std::shared_ptr<Linker::Segment> segment,
unsigned flags)
138 : image(segment), flags(flag_type(flags))
144 PrivilegeLevelShift = 10,
198 FIARQQ = 1, FJARQQ = 1,
199 FISRQQ = 2, FJSRQQ = 2,
200 FICRQQ = 3, FJCRQQ = 3,
226 size_t GetSize()
const;
228 std::vector<Relocation> relocations;
233 void Dump(
Dumper::Dumper& dump,
unsigned index,
bool isos2)
const;
262 void Dump(
Dumper::Dumper& dump,
unsigned index,
bool isos2)
const;
269 uint16_t type_id = 0;
270 std::string type_id_name;
271 std::vector<Resource> resources;
370 uint8_t major, minor;
392 GLOBAL_INITIALIZATION = 4,
393 PROTECTED_MODE_ONLY = 8,
417 FAMILY_APPLICATION = 8,
418 ERROR_IN_IMAGE = 0x20,
434 uint16_t ip = 0, cs = 0, sp = 0, ss = 0;
444 std::vector<Segment> segments;
452 uint16_t resource_count = 0;
472 std::vector<Name> resident_names;
480 std::vector<ModuleReference> module_references;
488 std::vector<std::string> imported_names;
495 uint32_t nonresident_name_table_length = 0;
497 std::vector<Name> nonresident_names;
511 std::vector<Entry> entries;
530 enum additional_flag_type : uint8_t
532 SUPPORT_LONGFILENAME = 1,
533 WIN20_PROTECTED_MODE = 2,
534 WIN20_PROPORTIONAL_FONTS = 4,
537 additional_flag_type additional_flags = additional_flag_type(0);
542 uint16_t fast_load_area_offset;
544 uint16_t return_thunks_offset;
549 uint16_t fast_load_area_length;
551 uint16_t segment_reference_thunks_offset;
553 uint16_t code_swap_area_length = 0;
555 version windows_version{0, 0};
557 offset_t file_size = offset_t(-1);
559 bool IsLibrary()
const;
578 fast_load_area_offset(0), fast_load_area_length(0)
591 InitializeFields(stub);
596 std::shared_ptr<Linker::Segment> stack, heap;
597 std::map<std::shared_ptr<Linker::Segment>,
size_t> segment_index;
598 std::map<std::string, uint16_t> module_reference_offsets;
599 std::map<std::string, uint16_t> imported_name_offsets;
600 uint16_t imported_names_length = 0;
603 std::string module_name;
604 std::string program_name;
606 bool option_capitalize_names =
false;
612 memory_model_t memory_model = MODEL_SMALL;
622 unsigned FormatAdditionalSectionFlags(std::string section_name)
const override;
624 enum compatibility_type
631 compatibility_type compatibility = CompatibleNone;
633 std::shared_ptr<NEFormat> SimulateLinker(compatibility_type compatibility);
635 static std::shared_ptr<NEFormat> CreateConsoleApplication(
system_type system =
Windows);
641 unsigned GetCodeSegmentFlags()
const;
642 unsigned GetDataSegmentFlags()
const;
643 void AddSegment(
const Segment& segment);
644 uint16_t FetchModule(std::string name);
645 uint16_t FetchImportedName(std::string name);
646 std::string MakeProcedureName(std::string name);
649 uint8_t CountBundles(
size_t entry_index)
const;
651 void SetModel(std::string model)
override;
652 std::shared_ptr<Linker::OptionCollector>
GetOptions()
override;
653 void SetOptions(std::map<std::string, std::string>& options)
override;
654 void OnNewSegment(std::shared_ptr<Linker::Segment> segment)
override;
An abstract interface that separates structure and presentation of the data inside a file.
Definition dumper.h:586
Encodes an object module file as a collection of sections, symbols and relocations.
Definition module.h:24
Helper class that contains the options interpreted by the format.
Definition options.h:308
Documents and handles command line options.
Definition options.h:196
Stores an absolute address along with the containing segment or address space.
Definition position.h:17
A helper class, encapsulating functionality needed to import binary data.
Definition reader.h:16
A representation of a value within some binary data that has to be fixed up once the exact position o...
Definition relocation.h:27
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
Represents an entry into the binary, typically DLL exported procedures.
Definition neexe.h:276
offset_t GetEntrySize() const
Returns the size of an entry as stored in the file, without the first two bytes of the bundle.
Definition neexe.cc:299
uint8_t segment
The number of the segment, 1 based.
Definition neexe.h:291
void WriteEntry(Linker::Writer &wr) const
Writes an entry within a bundle.
Definition neexe.cc:355
flag_type
Flags present in an entry.
Definition neexe.h:294
@ Exported
Set if the entry is exported.
Definition neexe.h:296
@ SharedData
Set if the data segment used by the entry is global, used in SINGLEDATA modules (libraries)
Definition neexe.h:298
bool same_bundle
Convenience field to signify this entry is part of the same bundle as the previous one.
Definition neexe.h:328
uint16_t offset
Offset within the segment.
Definition neexe.h:302
export_type export_state
Whether the entry is exported. This is not actually stored in the entry table and its value is ignore...
Definition neexe.h:315
static Entry ReadEntry(Linker::Reader &rd, uint8_t indicator_byte)
Reads an entry within a bundle.
Definition neexe.cc:330
uint8_t GetIndicatorByte() const
Retrieves the segment indicator byte. For Fixed entries, this the same as the segment number.
Definition neexe.cc:315
export_type
Definition neexe.h:306
@ NotExported
The entry is not exported, the Exported bit is not set.
Definition neexe.h:308
@ ExportByOrdinal
The entry is exported by ordinal, it is referenced in the nonresident name table.
Definition neexe.h:312
@ ExportByName
The entry is exported by name, it is referenced in the resident name table.
Definition neexe.h:310
std::string entry_name
The name of an exported entry. This is not actually stored in the entry table and its value is ignore...
Definition neexe.h:317
entry_type
This field represents the type of the entry.
Definition neexe.h:280
@ Fixed
The entry references a fixed segment.
Definition neexe.h:284
@ Movable
The entry references a movable segment.
Definition neexe.h:286
@ Unused
The entry is unused, the other fields are meaningless.
Definition neexe.h:282
@ INT_3Fh
Byte code for interrupt call that must be placed in the entry field.
Definition neexe.h:324
entry_type type
The type of entry, based on the first byte in an entry bundle.
Definition neexe.h:289