2#ifndef ROSE_SgAsmNEFileHeader_H
3#define ROSE_SgAsmNEFileHeader_H
5#include <Cxx_GrammarDeclarations.h>
6#include <SgAsmGenericHeader.h>
27#include <Rose/BinaryAnalysis/Address.h>
29#ifdef ROSE_SgAsmNEFileHeader_IMPL
30#include <SgAsmDOSExtendedHeader.h>
31#include <SgAsmNEEntryTable.h>
32#include <SgAsmNEModuleTable.h>
33#include <SgAsmNENameTable.h>
34#include <SgAsmNESectionTable.h>
42#if !defined(DOCUMENTATION)
57#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
59 friend class boost::serialization::access;
65 s & BOOST_SERIALIZATION_NVP(p_e_linker_major);
66 s & BOOST_SERIALIZATION_NVP(p_e_linker_minor);
67 s & BOOST_SERIALIZATION_NVP(p_e_checksum);
68 s & BOOST_SERIALIZATION_NVP(p_e_flags1);
69 s & BOOST_SERIALIZATION_NVP(p_e_autodata_sn);
70 s & BOOST_SERIALIZATION_NVP(p_e_bss_size);
71 s & BOOST_SERIALIZATION_NVP(p_e_stack_size);
72 s & BOOST_SERIALIZATION_NVP(p_e_csip);
73 s & BOOST_SERIALIZATION_NVP(p_e_sssp);
74 s & BOOST_SERIALIZATION_NVP(p_e_nsections);
75 s & BOOST_SERIALIZATION_NVP(p_e_nmodrefs);
76 s & BOOST_SERIALIZATION_NVP(p_e_nnonresnames);
77 s & BOOST_SERIALIZATION_NVP(p_e_nmovable_entries);
78 s & BOOST_SERIALIZATION_NVP(p_e_sector_align);
79 s & BOOST_SERIALIZATION_NVP(p_e_nresources);
80 s & BOOST_SERIALIZATION_NVP(p_e_exetype);
81 s & BOOST_SERIALIZATION_NVP(p_e_flags2);
82 s & BOOST_SERIALIZATION_NVP(p_e_res1);
83 s & BOOST_SERIALIZATION_NVP(p_e_winvers);
84 s & BOOST_SERIALIZATION_NVP(p_e_entrytab_rfo);
85 s & BOOST_SERIALIZATION_NVP(p_e_entrytab_size);
86 s & BOOST_SERIALIZATION_NVP(p_e_sectab_rfo);
87 s & BOOST_SERIALIZATION_NVP(p_e_rsrctab_rfo);
88 s & BOOST_SERIALIZATION_NVP(p_e_resnametab_rfo);
89 s & BOOST_SERIALIZATION_NVP(p_e_modreftab_rfo);
90 s & BOOST_SERIALIZATION_NVP(p_e_importnametab_rfo);
91 s & BOOST_SERIALIZATION_NVP(p_e_nonresnametab_offset);
92 s & BOOST_SERIALIZATION_NVP(p_e_fastload_sector);
93 s & BOOST_SERIALIZATION_NVP(p_e_fastload_nsectors);
94 s & BOOST_SERIALIZATION_NVP(p_dos2Header);
95 s & BOOST_SERIALIZATION_NVP(p_sectionTable);
96 s & BOOST_SERIALIZATION_NVP(p_residentNameTable);
97 s & BOOST_SERIALIZATION_NVP(p_nonresidentNameTable);
98 s & BOOST_SERIALIZATION_NVP(p_moduleTable);
99 s & BOOST_SERIALIZATION_NVP(p_entryTable);
117 struct NEFileHeader_disk {
118 unsigned char e_magic[2];
119 unsigned char e_linker_major;
120 unsigned char e_linker_minor;
121 uint16_t e_entrytab_rfo;
122 uint16_t e_entrytab_size;
125 uint16_t e_autodata_sn;
127 uint16_t e_stack_size;
130 uint16_t e_nsections;
132 uint16_t e_nnonresnames;
133 uint16_t e_sectab_rfo;
134 uint16_t e_rsrctab_rfo;
135 uint16_t e_resnametab_rfo;
136 uint16_t e_modreftab_rfo;
137 uint16_t e_importnametab_rfo;
138 uint32_t e_nonresnametab_offset;
139 uint16_t e_nmovable_entries;
140 uint16_t e_sector_align;
141 uint16_t e_nresources;
142 unsigned char e_exetype;
143 unsigned char e_flags2;
144 uint16_t e_fastload_sector;
145 uint16_t e_fastload_nsectors;
152 __attribute__((packed))
166 HF1_RESERVED = 0x57f4,
167 HF1_NO_DATA = 0x0000,
168 HF1_SINGLE_DATA = 0x0001,
169 HF1_MULTIPLE_DATA = 0x0002,
170 HF1_LOADER_SEGMENT = 0x0800,
171 HF1_FATAL_ERRORS = 0x2000,
178 HF2_PROTECTED_MODE = 0x02,
188 unsigned const& get_e_linker_major()
const;
189 void set_e_linker_major(
unsigned const&);
192 unsigned const& get_e_linker_minor()
const;
193 void set_e_linker_minor(
unsigned const&);
196 unsigned const& get_e_checksum()
const;
197 void set_e_checksum(
unsigned const&);
200 unsigned const& get_e_flags1()
const;
201 void set_e_flags1(
unsigned const&);
204 unsigned const& get_e_autodata_sn()
const;
205 void set_e_autodata_sn(
unsigned const&);
208 unsigned const& get_e_bss_size()
const;
209 void set_e_bss_size(
unsigned const&);
212 unsigned const& get_e_stack_size()
const;
213 void set_e_stack_size(
unsigned const&);
216 unsigned const& get_e_csip()
const;
217 void set_e_csip(
unsigned const&);
220 unsigned const& get_e_sssp()
const;
221 void set_e_sssp(
unsigned const&);
224 unsigned const& get_e_nsections()
const;
225 void set_e_nsections(
unsigned const&);
228 unsigned const& get_e_nmodrefs()
const;
229 void set_e_nmodrefs(
unsigned const&);
232 unsigned const& get_e_nnonresnames()
const;
233 void set_e_nnonresnames(
unsigned const&);
236 unsigned const& get_e_nmovable_entries()
const;
237 void set_e_nmovable_entries(
unsigned const&);
240 unsigned const& get_e_sector_align()
const;
241 void set_e_sector_align(
unsigned const&);
244 unsigned const& get_e_nresources()
const;
245 void set_e_nresources(
unsigned const&);
248 unsigned const& get_e_exetype()
const;
249 void set_e_exetype(
unsigned const&);
252 unsigned const& get_e_flags2()
const;
253 void set_e_flags2(
unsigned const&);
256 unsigned const& get_e_res1()
const;
257 void set_e_res1(
unsigned const&);
260 unsigned const& get_e_winvers()
const;
261 void set_e_winvers(
unsigned const&);
264 rose_addr_t
const& get_e_entrytab_rfo()
const;
265 void set_e_entrytab_rfo(rose_addr_t
const&);
268 rose_addr_t
const& get_e_entrytab_size()
const;
269 void set_e_entrytab_size(rose_addr_t
const&);
272 rose_addr_t
const& get_e_sectab_rfo()
const;
273 void set_e_sectab_rfo(rose_addr_t
const&);
276 rose_addr_t
const& get_e_rsrctab_rfo()
const;
277 void set_e_rsrctab_rfo(rose_addr_t
const&);
280 rose_addr_t
const& get_e_resnametab_rfo()
const;
281 void set_e_resnametab_rfo(rose_addr_t
const&);
284 rose_addr_t
const& get_e_modreftab_rfo()
const;
285 void set_e_modreftab_rfo(rose_addr_t
const&);
288 rose_addr_t
const& get_e_importnametab_rfo()
const;
289 void set_e_importnametab_rfo(rose_addr_t
const&);
292 rose_addr_t
const& get_e_nonresnametab_offset()
const;
293 void set_e_nonresnametab_offset(rose_addr_t
const&);
296 rose_addr_t
const& get_e_fastload_sector()
const;
297 void set_e_fastload_sector(rose_addr_t
const&);
300 rose_addr_t
const& get_e_fastload_nsectors()
const;
301 void set_e_fastload_nsectors(rose_addr_t
const&);
334 virtual void unparse(std::ostream&)
const override;
335 virtual const char *
formatName()
const override;
336 virtual void dump(FILE*,
const char *prefix, ssize_t idx)
const override;
349 SgAsmNENameTable* get_resname_table() const ROSE_DEPRECATED("use get_residentNameTable");
350 void set_resname_table(
SgAsmNENameTable*) ROSE_DEPRECATED("use set_residentNameTable");
351 SgAsmNENameTable* get_nonresname_table() const ROSE_DEPRECATED("use get_nonresidentNameTable");
352 void set_nonresname_table(
SgAsmNENameTable*) ROSE_DEPRECATED("use set_nonresidentNameTable");
355 SgAsmNEEntryTable* get_entry_table() const ROSE_DEPRECATED("use get_entryTable");
358 virtual const
char *format_name() const override ROSE_DEPRECATED("use formatName");
374 void initializeProperties();
393 virtual std::
string class_name() const override;
396 virtual VariantT variantT() const override;
401 enum { static_variant = V_SgAsmNEFileHeader };
416 static const unsigned pool_size;
418 static std::vector<unsigned char *> pools;
423 static unsigned long initializeStorageClassArray(SgAsmNEFileHeaderStorageClass *);
426 static void clearMemoryPool();
427 static void deleteMemoryPool();
430 static void extendMemoryPoolForFileIO();
435 static SgAsmNEFileHeader * getPointerFromGlobalIndex(AstSpecificDataManagingClass *,
unsigned long);
438 static unsigned long getNumberOfValidNodesAndSetGlobalIndexInFreepointer(
unsigned long);
440 static void resetValidFreepointers();
442 static unsigned long getNumberOfLastValidPointer();
445#if defined(INLINE_FUNCTIONS)
447 inline void *
operator new (
size_t size);
450 void *
operator new (
size_t size);
453 void operator delete (
void* pointer,
size_t size);
456 void operator delete (
void* pointer)
502#ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
505 virtual RTIReturnType
roseRTI()
override;
519 virtual const char*
sage_class_name() const override ROSE_DEPRECATED_FUNCTION;
525 virtual int variant() const ROSE_DEPRECATED_FUNCTION;
707 friend class SgAsmNEFileHeaderStorageClass;
710 friend class AstSpecificDataManagingClass;
713 friend class AstSpecificDataManagingClassStorageClass;
745#define BUILD_ATERM_SUPPORT 0
746 #if BUILD_ATERM_SUPPORT
747 #ifdef ROSE_USE_ROSE_ATERM_SUPPORT
759 virtual ATerm generate_ATerm()
override;
762 virtual void generate_ATerm_Annotation(ATerm & term)
override;
822unsigned p_e_linker_major;
826unsigned p_e_linker_minor;
830unsigned p_e_checksum;
838unsigned p_e_autodata_sn;
842unsigned p_e_bss_size;
846unsigned p_e_stack_size;
858unsigned p_e_nsections;
862unsigned p_e_nmodrefs;
866unsigned p_e_nnonresnames;
870unsigned p_e_nmovable_entries;
874unsigned p_e_sector_align;
878unsigned p_e_nresources;
898rose_addr_t p_e_entrytab_rfo;
902rose_addr_t p_e_entrytab_size;
906rose_addr_t p_e_sectab_rfo;
910rose_addr_t p_e_rsrctab_rfo;
914rose_addr_t p_e_resnametab_rfo;
918rose_addr_t p_e_modreftab_rfo;
922rose_addr_t p_e_importnametab_rfo;
926rose_addr_t p_e_nonresnametab_offset;
930rose_addr_t p_e_fastload_sector;
934rose_addr_t p_e_fastload_nsectors;
Class holding static data and functions supporting File I/O.
Attribute containing a regex expression as a string.
Base class for binary files.
virtual SgAsmGenericSection * parse()
Parse contents of the section.
Supporting class from copy mechanism within ROSE.
This class represents the base class for all IR nodes within Sage III.
virtual size_t get_numberOfTraversalSuccessors()
return number of children in the traversal successor list
virtual RTIReturnType roseRTI()
return C++ Runtime-Time-Information
virtual std::vector< std::string > get_traversalSuccessorNamesContainer()
container of names of variables or container indices used used in the traversal to access AST success...
virtual void debugSerializationEnd(const char *className)
Called by generated serializers.
static std::string getNodeIdString(SgNode *sgnode)
compute the NodeId for a particular SgNode*.
virtual bool isInMemoryPool()
FOR INTERNAL USE This is used in internal tests to verify that all IR nodes are allocated from the he...
int variant() const
Older version function returns enum value "NODE".
virtual void processDataMemberReferenceToPointers(ReferenceToPointerHandler *)
FOR INTERNAL USE Processes pairs of references to SgNode* and strings for use in AST tools
virtual long getChildIndex(SgNode *childNode) const
FOR INTERNAL USE Returns a unique index value for the childNode in the list of children at this IR no...
virtual size_t get_childIndex(SgNode *child)
index-based access to traversal successors by child node
virtual void debugSerializationBegin(const char *className)
Called by generated serializers.
virtual std::vector< SgNode * > get_traversalSuccessorContainer()
container of pointers to AST successor nodes used in the traversal overridden in every class by gener...
static void visitRepresentativeNode(ROSE_VisitTraversal &visit)
FOR INTERNAL USE Support for type-based traversal.
virtual void checkDataMemberPointersIfInMemoryPool()
FOR INTERNAL USE This is used in internal tests to verify that all IR nodes are allocated from the he...
static size_t numberOfNodes()
Returns the total number of IR nodes of this type.
virtual void accept(ROSE_VisitorPattern &visitor)
support for the classic visitor pattern done in GoF
virtual SgNode * get_traversalSuccessorByIndex(size_t idx)
index-based access to traversal successors by index number
static void traverseMemoryPoolVisitorPattern(ROSE_VisitorPattern &visitor)
FOR INTERNAL USE Support for visitor pattern.
void executeVisitorMemberFunction(ROSE_VisitorPattern &visitor)
FOR INTERNAL USE Support for visitor pattern.
static SgNode * getNodeByNodeId(VariantT variantT, size_t poolIdx, size_t itemIdx)
Find a node by its variant type, pool index, and item index.
static size_t memoryUsage()
Returns the size in bytes of the total memory allocated for all IR nodes of this type.
static void traverseMemoryPoolNodes(ROSE_VisitTraversal &visit)
FOR INTERNAL USE Support for visitor pattern over all IR nodes by type of IR node.
virtual const char * sage_class_name() const
generates string representing the class name: (e.g. for SgNode returns "SgNode").
virtual std::vector< std::pair< SgNode *, std::string > > returnDataMemberPointers() const
FOR INTERNAL USE Returns STL vector of pairs of SgNode* and strings for use in AST tools
static SgNode * getNodeByNodeIdInternal(size_t poolIdx, size_t itemIdx)
FOR INTERNAL USE Find an SgNode from its memory pool and location therin.
SgNode * addRegExpAttribute(std::string s, AstRegExAttribute *a)
Support for AST matching using regular expression.
void serialize(std::ostream &output, Graph &graph)
Serialize a graph into a stream of bytes.
void copy(const Word *src, const BitRange &srcRange, Word *dst, const BitRange &dstRange)
Copy some bits.