| 1 | /* $Id: kInterfaces.h,v 1.3 2001-04-17 04:16:02 bird Exp $
|
|---|
| 2 | *
|
|---|
| 3 | * This headerfile contains interfaces for the common tools classes.
|
|---|
| 4 | *
|
|---|
| 5 | * Copyright (c) 2000 knut st. osmundsen (knut.stange.osmundsen@mynd.no)
|
|---|
| 6 | *
|
|---|
| 7 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 8 | *
|
|---|
| 9 | */
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 | #ifndef _kInterfaces_h_
|
|---|
| 13 | #define _kInterfaces_h_
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 | /*******************************************************************************
|
|---|
| 17 | * Defined Constants And Macros *
|
|---|
| 18 | *******************************************************************************/
|
|---|
| 19 | #define MAXEXPORTNAME 256
|
|---|
| 20 | #define MAXDBGNAME 256
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 | /*******************************************************************************
|
|---|
| 24 | * Structures and Typedefs *
|
|---|
| 25 | *******************************************************************************/
|
|---|
| 26 | class kPageI;
|
|---|
| 27 | class kExportI;
|
|---|
| 28 | class kExportEntry;
|
|---|
| 29 | class kModuleI;
|
|---|
| 30 | class kExecutableI;
|
|---|
| 31 | class kDbgTypeI;
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 | /**
|
|---|
| 35 | * Interface class (ie. virtual) which defines the interface for
|
|---|
| 36 | * executables (resources and object too perhaps) files used to
|
|---|
| 37 | * get and put pages.
|
|---|
| 38 | * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
|
|---|
| 39 | */
|
|---|
| 40 | class kPageI
|
|---|
| 41 | {
|
|---|
| 42 | public:
|
|---|
| 43 | /** @cat Get and put page methods. */
|
|---|
| 44 |
|
|---|
| 45 | /**
|
|---|
| 46 | * Get a code, data or resource page from the file.
|
|---|
| 47 | * @returns Success indicator.
|
|---|
| 48 | * @param pachPage Pointer to a buffer of the size of a page which
|
|---|
| 49 | * will receive the page data on the specified address.
|
|---|
| 50 | * @param ulAddress Page address. This will be page aligned.
|
|---|
| 51 | */
|
|---|
| 52 | virtual BOOL pageGet(char *pachPage, ULONG ulAddress) = 0;
|
|---|
| 53 |
|
|---|
| 54 | /**
|
|---|
| 55 | * Get a code, data or resource page from the file.
|
|---|
| 56 | * @returns Success indicator.
|
|---|
| 57 | * @param pachPage Pointer to a buffer of the size of a page which
|
|---|
| 58 | * will receive the page data on the specified address.
|
|---|
| 59 | * @param iObject Object number. (0-based)
|
|---|
| 60 | * @param offObject Offset into the object.
|
|---|
| 61 | * @remark Object = Section.
|
|---|
| 62 | */
|
|---|
| 63 | virtual BOOL pageGet(char *pachPage, int iObject, int offObject) = 0;
|
|---|
| 64 |
|
|---|
| 65 | /**
|
|---|
| 66 | * Updates or adds a code, data, or resource page to the file.
|
|---|
| 67 | * @returns Success indicator.
|
|---|
| 68 | * @param pachPage Pointer to a buffer of the size of a page which
|
|---|
| 69 | * holds the page data.
|
|---|
| 70 | * @param ulAddress Page address. This will be page aligned.
|
|---|
| 71 | */
|
|---|
| 72 | virtual BOOL pagePut(const char *pachPage, ULONG ulAddress) = 0;
|
|---|
| 73 |
|
|---|
| 74 | /**
|
|---|
| 75 | * Updates or adds a code, data, or resource page to the file.
|
|---|
| 76 | * @returns Success indicator.
|
|---|
| 77 | * @param pachPage Pointer to a buffer of the size of a page which
|
|---|
| 78 | * holds the page data.
|
|---|
| 79 | * @param iObject Object number. (0-based)
|
|---|
| 80 | * @param offObject Offset into the object.
|
|---|
| 81 | */
|
|---|
| 82 | virtual BOOL pagePut(const char *pachPage, int iObject, int offObject) = 0;
|
|---|
| 83 |
|
|---|
| 84 | /**
|
|---|
| 85 | * Get pagesize for the file.
|
|---|
| 86 | * @returns Pagesize in bytes.
|
|---|
| 87 | */
|
|---|
| 88 | virtual int pageGetPageSize() = 0;
|
|---|
| 89 | };
|
|---|
| 90 |
|
|---|
| 91 |
|
|---|
| 92 | /**
|
|---|
| 93 | * ExportEntry used by the findFirstExport/findNextExport functions
|
|---|
| 94 | */
|
|---|
| 95 | class kExportEntry
|
|---|
| 96 | {
|
|---|
| 97 | public:
|
|---|
| 98 | unsigned long ulOrdinal; /* Ordinal of export. 0 if invalid. */
|
|---|
| 99 | char achName[MAXEXPORTNAME]; /* Public or exported name. */
|
|---|
| 100 | char achIntName[MAXEXPORTNAME]; /* Optional. not used by PEFile */
|
|---|
| 101 |
|
|---|
| 102 | unsigned long ulOffset; /* Offset. -1 if invalid. */
|
|---|
| 103 | unsigned long iObject; /* Object number. -1 if invalid. */
|
|---|
| 104 | unsigned long ulAddress; /* Address of symbol. -1 if invalid. */
|
|---|
| 105 |
|
|---|
| 106 | public:
|
|---|
| 107 | /** @cat Internal use - don't mess! */
|
|---|
| 108 | void * pv; /* Internal pointer. */
|
|---|
| 109 | };
|
|---|
| 110 |
|
|---|
| 111 | /**
|
|---|
| 112 | * Interface class (ie. virtual) which defines the interface for executables
|
|---|
| 113 | * (objects and libraries to perhaps) files used to enumerate exports and
|
|---|
| 114 | * public exported names.
|
|---|
| 115 | * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
|
|---|
| 116 | */
|
|---|
| 117 | class kExportI
|
|---|
| 118 | {
|
|---|
| 119 | public:
|
|---|
| 120 | /** @cat Export enumeration methods. */
|
|---|
| 121 |
|
|---|
| 122 | /**
|
|---|
| 123 | * Find the first export/public name.
|
|---|
| 124 | * @returns Success indicator.
|
|---|
| 125 | * @param pExport Communication area.
|
|---|
| 126 | */
|
|---|
| 127 | virtual BOOL exportFindFirst(kExportEntry * pExport) = 0;
|
|---|
| 128 |
|
|---|
| 129 | /**
|
|---|
| 130 | * Find the next export/public name.
|
|---|
| 131 | * @returns Success indicator.
|
|---|
| 132 | * FALSE when no more exports (exportFindClose has been processed then).
|
|---|
| 133 | * @param pExport Communication area which has been successfully
|
|---|
| 134 | * processed by findFirstExport.
|
|---|
| 135 | */
|
|---|
| 136 | virtual BOOL exportFindNext(kExportEntry * pExport) = 0;
|
|---|
| 137 |
|
|---|
| 138 | /**
|
|---|
| 139 | * Frees resources associated with the communicatin area.
|
|---|
| 140 | * It's not necessary to call this when exportFindNext has return FALSE.
|
|---|
| 141 | * @param pExport Communication area which has been successfully
|
|---|
| 142 | * processed by findFirstExport.
|
|---|
| 143 | */
|
|---|
| 144 | virtual void exportFindClose(kExportEntry * pExport) = 0;
|
|---|
| 145 |
|
|---|
| 146 |
|
|---|
| 147 | /** @cat Export Search methods */
|
|---|
| 148 |
|
|---|
| 149 | /**
|
|---|
| 150 | * Lookup information on a spesific export given by ordinal number.
|
|---|
| 151 | * @returns Success indicator.
|
|---|
| 152 | * @param pExport Communication area containing export information
|
|---|
| 153 | * on successful return.
|
|---|
| 154 | */
|
|---|
| 155 | virtual BOOL exportLookup(unsigned long ulOrdinal, kExportEntry *pExport) = 0;
|
|---|
| 156 |
|
|---|
| 157 | /**
|
|---|
| 158 | * Lookup information on a spesific export given by name.
|
|---|
| 159 | * @returns Success indicator.
|
|---|
| 160 | * @param pExport Communication area containing export information
|
|---|
| 161 | * on successful return.
|
|---|
| 162 | */
|
|---|
| 163 | virtual BOOL exportLookup(const char * pszName, kExportEntry *pExport) = 0;
|
|---|
| 164 | };
|
|---|
| 165 |
|
|---|
| 166 |
|
|---|
| 167 | /**
|
|---|
| 168 | * Interface class (ie. virtual) which defines the interface for executables
|
|---|
| 169 | * (objects and libraries to perhaps) files used to enumerate exports and
|
|---|
| 170 | * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
|
|---|
| 171 | */
|
|---|
| 172 | class kModuleI
|
|---|
| 173 | {
|
|---|
| 174 | public:
|
|---|
| 175 | /** @cat Module information methods. */
|
|---|
| 176 | virtual BOOL moduleGetName(char *pszBuffer, int cbBuffer = 260) = 0;
|
|---|
| 177 | };
|
|---|
| 178 |
|
|---|
| 179 |
|
|---|
| 180 | /**
|
|---|
| 181 | * Interface class (ie. virtual) which defines the interface for
|
|---|
| 182 | * executables files.
|
|---|
| 183 | * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
|
|---|
| 184 | */
|
|---|
| 185 | class kExecutableI : public kModuleI, public kExportI
|
|---|
| 186 | {
|
|---|
| 187 | public:
|
|---|
| 188 | /** @cat Executable information methods. */
|
|---|
| 189 | #if 0
|
|---|
| 190 | virtual BOOL execIsDLL(void) = 0;
|
|---|
| 191 | virtual BOOL execIsProgram(void) = 0;
|
|---|
| 192 | virtual BOOL execIsDriver(void) = 0;
|
|---|
| 193 | #endif
|
|---|
| 194 | };
|
|---|
| 195 |
|
|---|
| 196 |
|
|---|
| 197 | /**
|
|---|
| 198 | * Communication class/struct used by kDbgTypeI and others.
|
|---|
| 199 | * This is structure or union member class.
|
|---|
| 200 | * (This might turn out very similar to a normal variable class,
|
|---|
| 201 | * and will if so be changed to that when time comes.)
|
|---|
| 202 | * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
|
|---|
| 203 | */
|
|---|
| 204 | class kDbgMemberEntry
|
|---|
| 205 | {
|
|---|
| 206 | public:
|
|---|
| 207 | char szName[MAXDBGNAME]; /* Member name. */
|
|---|
| 208 | char cb; /* Count of bytes it covers. */
|
|---|
| 209 | char szTypeName[MAXDBGNAME]; /* Type name. */
|
|---|
| 210 | int flFlags; /* Type flags. One of the kDbgTypeI::enm*. optional: defaults to kDbgTypeI::enmAny */
|
|---|
| 211 | };
|
|---|
| 212 |
|
|---|
| 213 |
|
|---|
| 214 | /**
|
|---|
| 215 | * Communication class/struct used by kDbgTypeI.
|
|---|
| 216 | * This is the type.
|
|---|
| 217 | * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
|
|---|
| 218 | */
|
|---|
| 219 | class kDbgTypeEntry
|
|---|
| 220 | {
|
|---|
| 221 | public:
|
|---|
| 222 | char szName[MAXDBGNAME]; /* Name of the type. */
|
|---|
| 223 | char cb; /* Count of bytes it covers. */
|
|---|
| 224 | int flFlags; /* Type flags. One of the kDbgTypeI::enm*. */
|
|---|
| 225 |
|
|---|
| 226 | int cMembers; /* Number of members. This is 0 if not a union or a struct. */
|
|---|
| 227 | kDbgMemberEntry * paMembers; /* Pointer array of member entries if union or struct. */
|
|---|
| 228 |
|
|---|
| 229 | public:
|
|---|
| 230 | /** @cat Internal use only - don't mess! */
|
|---|
| 231 | int flSearchFlags; /* Type flags which this search was started with. One of the kDbgTypeI::enm*. */
|
|---|
| 232 | };
|
|---|
| 233 |
|
|---|
| 234 |
|
|---|
| 235 |
|
|---|
| 236 | /**
|
|---|
| 237 | * Interface class (ie. virtual) which defines the interface for
|
|---|
| 238 | * debug typeinfo on debug module level.
|
|---|
| 239 | * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
|
|---|
| 240 | */
|
|---|
| 241 | class kDbgTypeI
|
|---|
| 242 | {
|
|---|
| 243 | public:
|
|---|
| 244 | /** @cat Debug Type information methods. */
|
|---|
| 245 | virtual kDbgTypeEntry * dbgtypeFindFirst(int flFlags);
|
|---|
| 246 | virtual kDbgTypeEntry * dbgtypeFindNext(kDbgTypeEntry *kDbgTypeEntry);
|
|---|
| 247 | virtual void dbgtypeFindClose(kDbgTypeEntry *kDbgTypeEntry);
|
|---|
| 248 |
|
|---|
| 249 | virtual kDbgTypeEntry * dbgtypeLookup(const char *pszName, int flFlags);
|
|---|
| 250 | enum
|
|---|
| 251 | { enmAny, /* Any/unknown type. */
|
|---|
| 252 | enmStruct, /* Structure: struct _somestruct {..}; */
|
|---|
| 253 | enmUnion, /* Union: union _someunion {..}; */
|
|---|
| 254 | enmEnum, /* Enumeration: enum _someenum {..}; */
|
|---|
| 255 | enmTypedef, /* Type definition: typedef <type expr> sometype; */
|
|---|
| 256 | enmMask = 0x0000000ff, /* Type mask. */
|
|---|
| 257 | enmFlagMask = 0xffffff00, /* Flag mask. */
|
|---|
| 258 | enmflPointer = 0x00000100 /* This is pointer to something. (flag) */
|
|---|
| 259 | };
|
|---|
| 260 | };
|
|---|
| 261 | #endif
|
|---|