00001 #ifndef _SectHeader_h_
00002 #define _SectHeader_h_
00003
00004 #include <Base.h>
00005 #include <defines/SectHeader.d>
00006
00007 class RelocationTable;
00008 class LineInfoTable;
00009 class XCoffFile;
00010
00011 class SectHeader : public Base {
00012 protected:
00013 char* rawDataPtr;
00014 char* relocationPtr;
00015 char* lineInfoPointer;
00016 uint32_t numOfRelocations;
00017 uint32_t numOfLineInfo;
00018 RelocationTable* relocationTable;
00019 LineInfoTable* lineInfoTable;
00020
00021 SectHeader* overFlowSection;
00022
00023 uint16_t index;
00024
00025 protected:
00026 SectHeader() : Base(XCoffClassTypes_sect_header),
00027 rawDataPtr(NULL), relocationPtr(NULL), lineInfoPointer(NULL),
00028 numOfRelocations(0),numOfLineInfo(0),
00029 relocationTable(NULL),lineInfoTable(NULL),overFlowSection(NULL),index(0) {}
00030 ~SectHeader() {}
00031 bool verify();
00032
00033 public:
00034
00035 SECTHEADER_MACROS_BASIS("For the get_X field macros check the defines directory");
00036
00037 void print();
00038 void initFilePointers(BinaryInputFile* b);
00039
00040 void setOverFlowSection(SectHeader* sh);
00041 SectHeader* getOverFlowSection() { return overFlowSection; }
00042
00043 const char* getTypeName();
00044
00045 char* getRawDataPtr() { return rawDataPtr; }
00046 uint64_t getRawDataSize() { return GET(s_size); }
00047
00048 RelocationTable* readRelocTable(BinaryInputFile* binaryInputFile,XCoffFile* xcoff);
00049 LineInfoTable* readLineInfoTable(BinaryInputFile* binaryInputFile,XCoffFile* xcoff);
00050
00051 RelocationTable* getRelocationTable() { return relocationTable; }
00052 LineInfoTable* getLineInfoTable() { return lineInfoTable; }
00053
00054 uint16_t getIndex() { return index; }
00055
00056 bool inRange(uint64_t address);
00057
00058 const char* briefName() { return "SectHeader"; }
00059 };
00060
00061 class SectHeader32 : public SectHeader {
00062 protected:
00063 SCNHDR entry;
00064
00065 public:
00066
00067 SECTHEADER_MACROS_CLASS("For the get_X field macros check the defines directory");
00068
00069 SectHeader32(uint16_t idx) { sizeInBytes = Size__32_bit_Section_Header; index = idx; }
00070 ~SectHeader32() {}
00071 uint32_t read(BinaryInputFile* b);
00072 uint32_t instrument(char* buffer,XCoffFileGen* xCoffGen,BaseGen* gen);
00073 };
00074
00075 class SectHeader64 : public SectHeader {
00076 protected:
00077 SCNHDR_64 entry;
00078
00079 public:
00080
00081 SECTHEADER_MACROS_CLASS("For the get_X field macros check the defines directory");
00082
00083 SectHeader64(uint16_t idx) { sizeInBytes = Size__64_bit_Section_Header; index = idx; }
00084 ~SectHeader64() {}
00085 uint32_t read(BinaryInputFile* b);
00086 uint32_t instrument(char* buffer,XCoffFileGen* xCoffGen,BaseGen* gen);
00087 };
00088
00089 #endif