UnivesalDisassembler(2003)
|
00001 // shared.h 00002 // 00003 // uda - universal disassembler 00004 // Date: 2003-05-04 00005 // 00006 // Copyright (c) 2002-2003 Ales Smrcka 00007 // 00008 // This program is licensed under GNU Library GPL. See the file COPYING. 00009 // 00010 // This header file is shared for program uda and their plugins. 00011 // 00012 00013 #ifndef sharedH 00014 #define sharedH 00015 00016 #include <map> 00017 #include <vector> 00018 #include <string> 00019 #include <iostream> 00020 #include <iomanip> 00021 #include <libgen.h> 00022 using namespace std; 00023 00024 #define PLUGIN_SECTIONS 0x01 00025 #define PLUGIN_SYMTABLE 0x02 00026 00028 //base types 00029 00031 typedef unsigned int Address; 00033 typedef unsigned char byte; 00034 00036 //input/output files 00037 00038 /*struct Files { 00039 char *outputfile; 00040 char *mapfile; 00041 char *binaryfile; 00042 };*/ 00043 00044 typedef map<string, string> Parameters; 00045 00047 extern Parameters *Params; 00048 00050 #define pdefined(p) (Params->find(p)!=Params->end()) 00051 00053 #define verbose(t) if(pdefined("-v") || pdefined("--debug")) cerr<<dec<<setfill(' ')<<t;else 00054 00056 #define debug(t) if(pdefined("--debug")) cerr<<dec<<setfill(' ')<<t;else 00057 00058 #define lower(c) (c>='A'&&c<='Z'?c+'a'-'A':c) 00059 00060 typedef void (*Splugin_init)(int &type, const char *&ident, const char *&syntax, Parameters *p); 00061 00063 //Sections 00064 00066 struct SectionData { 00067 Address addr; //address of start 00068 unsigned size; //section size 00069 bool executable; //true if executable 00070 byte *content; //data 00071 string name; //section name 00072 bool scanaddress; //true=scan immediate data for addresses at this section 00073 SectionData() { addr=size=0; content=NULL; executable=scanaddress=false; } 00074 }; 00075 00077 struct BinFileData { 00079 string name; 00081 Address entry; 00083 vector<SectionData*> Sections; 00084 }; 00085 00086 00088 //SymbolTable 00089 00091 typedef map<Address, string> MSymbols; 00092 00094 class AbstractSymbols { 00095 public: 00097 MSymbols symbols; 00098 BinFileData &bfdata; 00099 AbstractSymbols(BinFileData &bfd) : bfdata(bfd) {} 00100 virtual ~AbstractSymbols(){} 00102 // virtual void Load(const char *file) {} 00103 }; 00104 00105 #endif