structs.h

Go to the documentation of this file.
00001 #ifndef STRUCTS_H
00002 #define STRUCTS_H
00003 
00004 /**********************************************
00005  *          the Beos Reversing Engine         * 
00006  *                  by Zadig                  *
00007  *                                            *
00008  * This file contains all Structures used     *
00009  * in the project.                            *
00010  **********************************************/
00011 
00012 /* defines */
00013 /* these values are used for offset symbols sorting */
00014 #define OSORT_FUNCTIONS    0x01
00015 #define OSORT_CLASSES      0x02
00016 #define OSORT_OBJECTS      0x04
00017 #define OSORT_STRINGS      0x08
00018 #define OSORT_DFUNCTIONS   0x10
00019 #define OSORT_DCLASSES     0x20
00020 
00021 /*enums*/
00022 typedef enum
00023 {
00024   OBJ_TYPE_UNKNOWN,        /* undefined object */
00025   OBJ_TYPE_STRING,         /* object is a string */
00026   OBJ_TYPE_OBJECT,         /* object is a variable, param... */
00027   OBJ_TYPE_MESSAGE,        /* object is a message */
00028   OBJ_TYPE_PARAM,          /* object is a parameter */
00029   OBJ_TYPE_CLASS,          /* object is a class */
00030   OBJ_TYPE_FUNCTION,       /* object is a function */
00031   OBJ_TYPE_INSTRUCTION,    /* object is an instruction */
00032   OBJ_TYPE_REFERENCE,      /* object is a reference */
00033   OBJ_TYPE_VAR_REFERENCE,  /* object is a reference to a variable or param */
00034   OBJ_TYPE_MAX
00035 } RE_ObjectType;
00036 
00037 /* possible result types for an asm instruction */
00038 typedef enum
00039 {
00040   RESULT_TYPE_INVALID,        /* invalid result */
00041   RESULT_TYPE_DIRECT_VALUE,   /* value that is put in second param (immediate addressing)*/
00042   RESULT_TYPE_INDIRECT_VALUE, /* value that is put in first param (direct or indirect addressing) */
00043   RESULT_TYPE_LOCAL,          /* value refers to a local variable */
00044   RESULT_TYPE_GLOBAL,         /* value refers to a global variable (not implemented) */
00045   RESULT_TYPE_PARAM,          /* value refers to a parameter */
00046   RESULT_TYPE_MESSAGE,        /* value is a message */
00047   RESULT_TYPE_JUMP,           /* value is a jump address */
00048   RESULT_TYPE_MAX
00049 } RE_ResultType;
00050 
00051 typedef enum
00052 {
00053   REG_EAX,   /* Register eax */
00054   REG_EBX,   /* Register ebx */
00055   REG_ECX,   /* Register ecx */
00056   REG_EDX,   /* Register edx */
00057   REG_EBP,   /* Register ebp */
00058   REG_ESP,   /* Register esp */
00059   REG_EDI,   /* Register edi */
00060   REG_ESI,   /* Register esi */
00061   REG_MAX   
00062 } RE_Registers;
00063 
00064 typedef enum
00065 {
00066   DIRECT_REF,  /* Direct reference */
00067   INDIRECT_REF /* Indirect reference */
00068 } RE_RefType;
00069 
00070 typedef enum
00071 {
00072   MAP_STRINGS, /* Strings mapping index */
00073   MAP_SYMBOLS, /* Symbols mapping index */
00074   MAP_DYNSYM,  /* Dynamic symbols mapping index */
00075   MAP_REFS,    /* References mapping index */
00076   MAP_JUMPS,   /* Jumps mapping index */
00077   MAP_MESSAGES,/* Messages mapping index (BeOS specific) */
00078   MAP_PARAMS,  /* Params sizes index */
00079   MAP_MAX 
00080 } RE_mappings;
00081 /*end defines for structs*/
00082 
00083 typedef struct _Reference Reference;   /* Reference struct (chainlist) */
00084 struct _Reference
00085 {
00086   uint32       addr; /* Address of reference */
00087   RE_RefType   type; /* Reference type */
00088   Reference* next;
00089 } ;
00090 
00091 typedef struct
00092 {
00093   Reference *list_Ref;  /* Chainlist entry point */
00094 } LIST_Reference;
00095 
00096 typedef struct _Callee
00097 {
00098    struct _Mapping *mapping;
00099    struct _Callee  *next;
00100 } Callee;
00101 
00102 typedef struct
00103 {
00104    Callee   *list_ref;
00105 } LIST_Callee;
00106 
00107 /* chainlist struct used for all symbols */
00108 typedef struct _Mapping Mapping; /* Mapping struct (chainlist) */
00109 struct _Mapping
00110 {
00111   uint8           is_printed;             /* callees are printed */
00112   uint32          addr;                   /* Addr of symbol or message value  */
00113   uint32          size;                   /* Size of the symbol               */
00114   uint8           label[STRING_MAX_SIZE]; /* Label of symbol                  */
00115   RE_ObjectType   type;                   /* Object type                      */
00116   LIST_Reference  references;             /* References to the object         */
00117   LIST_Callee     callees;               /* list of called functions         */
00118   Mapping         *next;                  /* Next object                      */
00119   Mapping         *prev;                  /* Previous object                  */
00120   Mapping         *next_alpha;            /* Next object alphabeticaly sorted */
00121   Mapping         *prev_alpha;            /* Previous object alphabeticaly sorted */
00122 } ;
00123 
00124 typedef struct
00125 {
00126   Mapping *list_Map;    /* Chainlist entry point */
00127   Mapping *tail;        /* Tail of chainlist */
00128   Mapping *alpha;       /* head of alphabetic chainlist */
00129 } LIST_Mapping;
00130 
00131 typedef struct
00132 {
00133   uint8  name[STRING_MAX_SIZE];
00134   uint32 addr;
00135   uint32 size;
00136 } Section;
00137 
00138 typedef struct
00139 { 
00140   uint8         name[REG_MAX_SIZE];
00141   uint32        value;
00142   RE_ResultType type;
00143   uint8         isValid;
00144 } Register;
00145 
00146 typedef struct
00147 {
00148   Register registers[REG_MAX];
00149   uint32   addr;
00150   uint8    free;
00151 } RegisterContextBase;
00152 
00153 typedef struct
00154 {
00155   RegisterContextBase context[MAX_REG_CNTX];
00156   uint32              nextCntx;
00157 } RegisterContext;
00158 
00159 typedef struct
00160 {
00161   uint32 addr;
00162   uint32 value;
00163 } PLT_Jump;
00164 
00165 /* parameters structs */
00166 typedef struct
00167 {
00168   uint8 name[STRING_MAX_SIZE];
00169   uint8 offset;
00170 } Parameter;
00171 
00172 typedef struct
00173 {
00174   uint8     isValid;
00175   uint8     functionIsC;   /* function is C or C++ */
00176   uint8     functionHasMessage;  
00177   uint8     nbParams;
00178   Parameter param[MAX_PARAMS];
00179 } Function_Params;
00180 
00181 typedef struct
00182 {
00183    uint8    name[STRING_MAX_SIZE];
00184    uint32   size;
00185 } Parameter_Size;
00186 
00187 /* global struct */
00188 typedef struct
00189 {
00190   uint8   exe_FileName[STRING_MAX_SIZE];
00191   uint8   dest_FileName[STRING_MAX_SIZE];
00192   uint8   asm_SrcFileName[STRING_MAX_SIZE];
00193   uint8   objdump_FileName[STRING_MAX_SIZE];
00194   uint8   sym_FileName[STRING_MAX_SIZE];  /* custom symbols definition file   */
00195   Section sections[MAX_SECTIONS];
00196   uint8   splitOutput;                    /* create several files or not   */
00197   uint8   ctags;                          /* create tag file or not        */
00198   uint8   printPlt;                       /* print plt section or not      */
00199   uint8   printDsym;                      /* print dynamic symbols list    */
00200   char    blank_line[16];                 /* blank lines, will be empty if
00201                                              "-nobl" option is active      */
00202   uint8  offsetSort;
00203   uint8  printGraph;                      /* print a call graph            */
00204   uint8  symInject;                       /* Inject custom symbols definition */
00205   uint8  noDupSym;                        /* Remove duplicate symbols         */
00206 } Settings ;
00207 
00208 
00209 #endif

Generated on Tue Nov 29 20:13:16 2005 for REVENG by  doxygen 1.4.5