00001 #include "BinaryFile.h" 00002 00003 class BinaryFileStub : public BinaryFile 00004 { 00005 public: 00006 BinaryFileStub(); // Constructor 00007 virtual ~BinaryFileStub() { } 00008 virtual void UnLoad() { } // Unload the image 00009 bool GetNextMember() {return false;} // Load next member of archive 00010 virtual bool Open(const char* sName) {return false;} // Open for r/w; pv 00011 virtual void Close() { } // Close file opened with Open() 00012 virtual LOAD_FMT GetFormat() const; // Get format (e.g. LOADFMT_ELF) 00013 virtual MACHINE GetMachine() const; // Get machine (e.g. MACHINE_SPARC) 00014 virtual const char *getFilename() const { return m_pFileName; } 00015 virtual bool isLibrary() const; 00016 virtual std::list<const char *> getDependencyList(); 00017 virtual ADDRESS getImageBase(); 00018 virtual size_t getImageSize(); 00019 00020 // Header functions 00021 virtual ADDRESS GetFirstHeaderAddress(); // Get ADDRESS of main header 00022 virtual ADDRESS* GetImportStubs(int& numImports); 00023 00024 // 00025 // -- -- -- -- -- -- -- -- -- -- -- 00026 // 00027 // Internal information 00028 // Dump headers, etc 00029 virtual bool DisplayDetails(const char* fileName, FILE* f = stdout); 00030 00031 00032 // Analysis functions 00033 virtual std::list<SectionInfo*>& GetEntryPoints(const char* pEntry = "main"); 00034 virtual ADDRESS GetMainEntryPoint(); 00035 virtual ADDRESS GetEntryPoint(); 00036 00037 // Get a map from ADDRESS to const char*. This map contains the native 00038 // addresses and symbolic names of global data items (if any) which are 00039 // shared with dynamically linked libraries. Example: __iob (basis for 00040 // stdout).The ADDRESS is the native address of a pointer to the real 00041 // dynamic data object. 00042 // The caller should delete the returned map. 00043 virtual std::map<ADDRESS, const char*>* GetDynamicGlobalMap(); 00044 00045 // Not meant to be used externally, but sometimes you just 00046 // have to have it. 00047 char* GetStrPtr(int idx, int offset); // Calc string pointer 00048 00049 // Similarly here; sometimes you just need to change a section's 00050 // link and info fields 00051 // idx is the section index; link and info are indices to other 00052 // sections that will be idx's sh_link and sh_info respectively 00053 void SetLinkAndInfo(int idx, int link, int info); 00054 00055 const char* m_pFileName; // Pointer to input file name 00056 protected: 00057 virtual bool RealLoad(const char* sName); // Load the file; pure virtual 00058 virtual bool PostLoad(void* handle); // Called after loading archive member 00059 00060 private: 00061 }; 00062