| 1 |
/* |
| 2 |
genidl - Generate interface defintion language listing from a |
| 3 |
Portable Executable. |
| 4 |
Copyright (C) 2009-2016 mingw-w64 project |
| 5 |
|
| 6 |
This program is free software: you can redistribute it and/or modify |
| 7 |
it under the terms of the GNU General Public License as published by |
| 8 |
the Free Software Foundation, either version 3 of the License, or |
| 9 |
(at your option) any later version. |
| 10 |
|
| 11 |
This program is distributed in the hope that it will be useful, |
| 12 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
GNU General Public License for more details. |
| 15 |
|
| 16 |
You should have received a copy of the GNU General Public License |
| 17 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 |
*/ |
| 19 |
|
| 20 |
#ifndef GETIDL_TYPINFO_HXX |
| 21 |
#define GETIDL_TYPINFO_HXX |
| 22 |
|
| 23 |
#define TITYP_NONE -1 |
| 24 |
#define TITYP_NAME 0 |
| 25 |
#define TITYP_STR 1 |
| 26 |
#define TITYP_GUIDS 2 |
| 27 |
#define TITYP_TYPINFO_NAMES 3 |
| 28 |
#define TITYP_DEREF 4 |
| 29 |
#define TITYP_ARRAY 5 |
| 30 |
#define TITYP_REF 6 |
| 31 |
#define TITYP_IMP 7 |
| 32 |
#define TITYP_UNKNOWN 8 |
| 33 |
#define TITYP_CUSTOMDATA 9 |
| 34 |
#define TITYP_CUSTOMGUID 10 |
| 35 |
#define TITYP_IMPREF 11 |
| 36 |
|
| 37 |
#define TITYP_MAX 12 |
| 38 |
|
| 39 |
typedef struct sTITyp { |
| 40 |
uint32_t memid; /**< TYPINFO offset ID */ |
| 41 |
int32_t kind; /**< TYPINFO kind */ |
| 42 |
int32_t refkind; |
| 43 |
uint32_t refmem; /**< Offset reference */ |
| 44 |
char *refstr; /**< Helper member to form TYPINFO string */ |
| 45 |
char *poststr; /**< Helper member to form TYPINFO string */ |
| 46 |
char name[1]; /**< TYPINFO name */ |
| 47 |
} sTITyp; |
| 48 |
|
| 49 |
typedef struct sTITypsHash |
| 50 |
{ |
| 51 |
size_t count; |
| 52 |
size_t max; |
| 53 |
sTITyp **arr; /**< Directory of TYPEINFO data found */ |
| 54 |
} sTITypsHash; |
| 55 |
|
| 56 |
typedef struct sTITyps { |
| 57 |
sTITypsHash buc[TITYP_MAX]; |
| 58 |
} sTITyps; |
| 59 |
|
| 60 |
/** |
| 61 |
* Initializes sTITyps struct |
| 62 |
* @param[in] ptyp Address of struct to zero |
| 63 |
* @return always 0 |
| 64 |
*/ |
| 65 |
int32_t TI_init_typs (sTITyps *ptyp); |
| 66 |
|
| 67 |
/** |
| 68 |
* Walks over and frees sTITypsHash entries found in sTITyps structure |
| 69 |
* @param[in] ptyp sTITyps structure containing sTITypsHash entries to destroy |
| 70 |
* @return always 0 |
| 71 |
*/ |
| 72 |
int32_t TI_dest_typs (sTITyps *ptyp); |
| 73 |
|
| 74 |
/** |
| 75 |
* Inserts a sTITypsHash entry into a sTITyps |
| 76 |
* @param[in] ptyp Structure to insert entry into |
| 77 |
* @param[in] memid |
| 78 |
* @param[in] kind |
| 79 |
* @param[in] refkind |
| 80 |
* @param[in] refmem |
| 81 |
* @param[in[ refstr |
| 82 |
* @param[in] name typinfo associated name |
| 83 |
* @param[in] poststr |
| 84 |
* @return always 0 |
| 85 |
*/ |
| 86 |
int32_t TI_add_typ (sTITyps *ptyp, uint32_t memid, int32_t kind, int32_t refkind, uint32_t refmem, |
| 87 |
const char *refstr, const char *name, const char *poststr); |
| 88 |
|
| 89 |
/** |
| 90 |
* Searches ptyp for element matching memid and kind. |
| 91 |
* @param[in] ptyp typelib data to search |
| 92 |
* @param[in] memid TTYPINFO offset to match |
| 93 |
* @param[in] kind TYPINFO kind to match |
| 94 |
* @return pointer to matching matching typinfo section |
| 95 |
*/ |
| 96 |
sTITyp *TI_get_typ (sTITyps *ptyp, uint32_t memid, int32_t kind); |
| 97 |
|
| 98 |
/** |
| 99 |
* Returns a string to name the TYPINFO sections |
| 100 |
* @param[in] memid TTYPINFO offset to match |
| 101 |
* @param[in] kind TYPINFO kind to match |
| 102 |
* @param[in] varname |
| 103 |
* @return string to name of TYPINFO section |
| 104 |
*/ |
| 105 |
char *TI_get_typ_name (sTITyps *ptyp, uint32_t memid, int32_t kind, const char *varName); |
| 106 |
|
| 107 |
/** |
| 108 |
* Decodes name from raw data to insert into new entry in sTITyps |
| 109 |
* @return always 0 |
| 110 |
*/ |
| 111 |
int32_t TI2_import_name (sTITyps *nptr, unsigned char *dta, uint32_t len); |
| 112 |
int32_t TI2_import_guid (sTITyps *gptr, unsigned char *dta, uint32_t len); |
| 113 |
int32_t TI2_import_typinfo_names (sTITyps *tptr, unsigned char *dta, uint32_t len); |
| 114 |
int32_t TI2_import_string (sTITyps *sptr, unsigned char *dta, uint32_t len); |
| 115 |
int32_t TI2_import_typedesc (sTITyps *dptr, unsigned char *dta, uint32_t len); |
| 116 |
int32_t TI2_import_customdata (sTITyps *dptr, unsigned char *dta, uint32_t len); |
| 117 |
int32_t TI2_import_customdataguid (sTITyps *gptr, unsigned char *dta, uint32_t len); |
| 118 |
int32_t TI2_import_importlibs (sTITyps *iptr, unsigned char *dta, uint32_t len); |
| 119 |
int32_t TI2_import_ref (sTITyps *gptr, unsigned char *dta, uint32_t len); |
| 120 |
int32_t TI2_import_array (sTITyps *gptr, unsigned char *dta, uint32_t len); |
| 121 |
int32_t TI2_import_importref (sTITyps *gptr, unsigned char *dta, uint32_t len); |
| 122 |
|
| 123 |
const char *decode_VT_name_tmp (unsigned short vt); |
| 124 |
size_t getVT_data (sTITyps *dptr, uint32_t vt, unsigned char *dta, char **ret); |
| 125 |
char *TI_getVTorDref (sTITyps *ptyp,uint32_t vt, const char *varName, int beBase); |
| 126 |
size_t getVT_size (uint32_t vt, unsigned char *dta, size_t *basesz); |
| 127 |
|
| 128 |
typedef struct sTI2TypeBaseMemItem { |
| 129 |
int beFunc; |
| 130 |
#ifdef __GNUC__ |
| 131 |
__extension__ |
| 132 |
#endif |
| 133 |
union { |
| 134 |
unsigned char *mem; |
| 135 |
sMSFT_func *func; |
| 136 |
sMSFT_var *var; |
| 137 |
}; |
| 138 |
uint32_t *customData; |
| 139 |
sMSFT_FuncParam *funcParam; |
| 140 |
uint32_t *extData; |
| 141 |
size_t max; |
| 142 |
} sTI2TypeBaseMemItem; |
| 143 |
|
| 144 |
typedef struct sTI2TypeBaseMem |
| 145 |
{ |
| 146 |
size_t count; |
| 147 |
sTI2TypeBaseMemItem *items; |
| 148 |
} sTI2TypeBaseMem; |
| 149 |
|
| 150 |
typedef struct sTI2TypeBase { |
| 151 |
uint32_t kind; |
| 152 |
uint32_t kflags; |
| 153 |
int32_t cVars; |
| 154 |
int32_t cFuncs; |
| 155 |
int32_t flags; |
| 156 |
char *name; |
| 157 |
char *guid; |
| 158 |
char *docstr; |
| 159 |
char *custData; |
| 160 |
uint32_t version; |
| 161 |
char *dataType; |
| 162 |
sMSFT_TypeInfoBase *tib; |
| 163 |
sTI2TypeBaseMem mem; |
| 164 |
} sTI2TypeBase; |
| 165 |
|
| 166 |
typedef struct sTI2TypLib { |
| 167 |
int16_t ver_major; |
| 168 |
int16_t ver_minor; |
| 169 |
int32_t version; |
| 170 |
char *guid; |
| 171 |
uint32_t lcid1; |
| 172 |
uint32_t lcid2; |
| 173 |
uint32_t flags; |
| 174 |
uint32_t setFlags; |
| 175 |
char *helpstring; |
| 176 |
char *helpfile; |
| 177 |
int32_t helpstringctx; |
| 178 |
int32_t helpctx; |
| 179 |
char *name; |
| 180 |
int32_t dispatch; |
| 181 |
size_t nr_typinfos; |
| 182 |
size_t nr_impinfos; |
| 183 |
uint32_t *typinfos_hash; |
| 184 |
sTITyps ti2_typs; |
| 185 |
sTI2TypeBase *typb; |
| 186 |
} sTI2TypLib; |
| 187 |
|
| 188 |
sTI2TypLib *TI2_typlib_init (unsigned char *dta, size_t len); |
| 189 |
void TI2_typlib_dest (sTI2TypLib *tl); |
| 190 |
void TI2_typlib_hdr (FILE *fp, sTI2TypLib *tl, const char *orgfname); |
| 191 |
void TI2_typlib_idl (FILE *fp, sTI2TypLib *tl, const char *orgname); |
| 192 |
|
| 193 |
/** |
| 194 |
* Returns text string of calling convention type |
| 195 |
* @param[in] cc calling convention type |
| 196 |
* @return pointer to convention type string |
| 197 |
*/ |
| 198 |
const char *getCallConvName (int32_t cc); |
| 199 |
|
| 200 |
/** |
| 201 |
* Returns text string of calling convention type |
| 202 |
* @param[in] fp file to print to |
| 203 |
* @param[in] typs |
| 204 |
*/ |
| 205 |
void printValue(FILE *fp, sTITyps *typs, uint32_t val); |
| 206 |
char *getTypeBOrImpRef (sTITyps *dptr, uint32_t off, const char *var); |
| 207 |
|
| 208 |
#endif |