Changeset 5531 for trunk/tools
- Timestamp:
- Apr 17, 2001, 2:26:28 AM (24 years ago)
- Location:
- trunk/tools
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/common/kDef2Wat.cpp
r4402 r5531 1 /* $Id: kDef2Wat.cpp,v 1. 1 2000-10-03 05:42:37bird Exp $1 /* $Id: kDef2Wat.cpp,v 1.2 2001-04-17 00:26:10 bird Exp $ 2 2 * 3 3 * Converter for IBM/MS linker definition files (.DEF) to Watcom linker directives and options. … … 18 18 #include "kFile.h" 19 19 #include "kFileFormatBase.h" 20 #include "kInterfaces.h" 20 21 #include "kFileDef.h" 21 22 -
trunk/tools/common/kDump.cpp
r5053 r5531 1 /* $Id: kDump.cpp,v 1. 2 2001-02-02 08:45:41bird Exp $1 /* $Id: kDump.cpp,v 1.3 2001-04-17 00:26:10 bird Exp $ 2 2 * 3 3 * Generic dumper... … … 25 25 #include "kFile.h" 26 26 #include "kFileFormatBase.h" 27 #include "kInterfaces.h" 27 28 #include "kFileDef.h" 28 29 #include "kFileLX.h" -
trunk/tools/common/kFile.cpp
r4426 r5531 1 /* $Id: kFile.cpp,v 1. 7 2000-10-05 07:27:56bird Exp $1 /* $Id: kFile.cpp,v 1.8 2001-04-17 00:26:10 bird Exp $ 2 2 * 3 3 * kFile - Simple (for the time being) file class. … … 945 945 } 946 946 947 948 949 /** 950 * Reads the specified file in to a memory block and returns it. 951 * @returns Pointer to memory mapping on success. 952 * NULL on error. 953 * @param pszFilename Name of the file. 954 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no) 955 * @remark May throw errors. 956 */ 957 void *kFile::readFile(const char *pszFilename) 958 { 959 kFile file(pszFilename); 960 return file.readFile(); 961 } 962 -
trunk/tools/common/kFile.h
r4426 r5531 1 /* $Id: kFile.h,v 1. 7 2000-10-05 07:27:57bird Exp $1 /* $Id: kFile.h,v 1.8 2001-04-17 00:26:10 bird Exp $ 2 2 * 3 3 * kFile - Simple (for the time being) file class. … … 63 63 BOOL readAt(void *pvBuffer, long cbBuffer, long off) throw(int); 64 64 void * readFile() throw(int); 65 static void * readFile(const char *pszFilename) throw(int); 65 66 BOOL readln(char *pszBuffer, long cchBuffer); 66 67 -
trunk/tools/common/kFileDef.cpp
r4804 r5531 29 29 #include "kFile.h" 30 30 #include "kFileFormatBase.h" 31 #include "kInterfaces.h" 31 32 #include "kFileDef.h" 33 34 /******************************************************************************* 35 * Global Variables * 36 *******************************************************************************/ 37 #if 0 38 static kFileDef tst((kFile*)NULL); 39 #endif 32 40 33 41 … … 522 530 /** 523 531 * Query for the module name. 524 * @returns Success indicator. TRUE / FALSE. 525 * @param pszBuffer Pointer to buffer which to put the name into. 526 */ 527 BOOL kFileDef::queryModuleName(char *pszBuffer) 528 { 532 * @returns Success indicator. TRUE / FALSE. 533 * @param pszBuffer Pointer to buffer which to put the name into. 534 * @param cchBuffer Size of the buffer (defaults to 260 chars). 535 */ 536 BOOL kFileDef::moduleGetName(char *pszBuffer, int cchSize/* = 260*/) 537 { 538 int cch; 529 539 if (pszModName == NULL) 530 540 return FALSE; 531 541 532 strcpy(pszBuffer, pszModName); 542 cch = strlen(pszModName) + 1; 543 if (cch > cchSize) 544 return FALSE; 545 memcpy(pszBuffer, pszModName, cch); 533 546 534 547 return TRUE; … … 540 553 * @returns Success indicator. TRUE / FALSE. 541 554 * @param pExport Pointer to export structure. 542 * @remark 543 */ 544 BOOL kFileDef::findFirstExport(PEXPORTENTRY pExport) 555 */ 556 BOOL kFileDef::exportFindFirst(kExportEntry *pExport) 545 557 { 546 558 if (pExports != NULL && pExport != NULL) 547 559 { 548 560 pExport->ulOrdinal = pExports->ulOrdinal; 561 pExport->achName[0] = '\0'; 549 562 if (pExports->pszName != NULL) 550 563 strcpy(&pExport->achName[0], pExports->pszName); 551 else 552 pExport->achName[0] = '\0';564 565 pExport->achIntName[0] = '\0'; 553 566 if (pExports->pszIntName) 554 567 strcpy(&pExport->achIntName[0], pExports->pszIntName); 555 else 556 pExport->achIntName[0] = '\0';568 569 pExport->ulAddress = pExport->iObject = pExport->ulOffset = ~0UL; 557 570 pExport->pv = (void*)pExports->pNext; 558 571 } … … 567 580 * @returns Success indicator. TRUE / FALSE. 568 581 * @param pExport Pointer to export structure. 569 * @remark 570 */ 571 BOOL kFileDef::findNextExport(PEXPORTENTRY pExport) 582 */ 583 BOOL kFileDef::exportFindNext(kExportEntry *pExport) 572 584 { 573 585 if (pExport != NULL && pExport->pv != NULL) … … 576 588 577 589 pExport->ulOrdinal = pExp->ulOrdinal; 590 pExport->achName[0] = '\0'; 578 591 if (pExp->pszName != NULL) 579 592 strcpy(&pExport->achName[0], pExp->pszName); 580 else 581 pExport->achName[0] = '\0'; 593 pExport->achIntName[0] = '\0'; 582 594 if (pExp->pszIntName) 583 595 strcpy(&pExport->achIntName[0], pExp->pszIntName); 584 else 585 pExport->achIntName[0] = '\0'; 596 pExport->ulAddress = pExport->iObject = pExport->ulOffset = ~0UL; 586 597 pExport->pv = (void*)pExp->pNext; 587 598 } … … 589 600 return FALSE; 590 601 return TRUE; 602 } 603 604 605 /** 606 * Frees resources associated with the communicatin area. 607 * It's not necessary to call this when exportFindNext has return FALSE. 608 * (We don't allocate anything so it's not a problem ;-) 609 * @param pExport Communication area which has been successfully 610 * processed by findFirstExport. 611 */ 612 void kFileDef::exportFindClose(kExportEntry *pExport) 613 { 614 pExport = pExport; 615 return; 616 } 617 618 619 /** 620 * Lookup information on a spesific export given by ordinal number. 621 * @returns Success indicator. 622 * @param pExport Communication area containing export information 623 * on successful return. 624 * @remark stub 625 */ 626 BOOL kFileDef::exportLookup(unsigned long ulOrdinal, kExportEntry *pExport) 627 { 628 assert(!"not implemented."); 629 ulOrdinal = ulOrdinal; 630 pExport = pExport; 631 return FALSE; 632 } 633 634 /** 635 * Lookup information on a spesific export given by name. 636 * @returns Success indicator. 637 * @param pExport Communication area containing export information 638 * on successful return. 639 * @remark stub 640 */ 641 BOOL kFileDef::exportLookup(const char * pszName, kExportEntry *pExport) 642 { 643 assert(!"not implemented."); 644 pszName = pszName; 645 pExport = pExport; 646 return FALSE; 591 647 } 592 648 -
trunk/tools/common/kFileDef.h
r4402 r5531 61 61 * @author knut st. osmundsen 62 62 */ 63 class kFileDef : public k FileFormatBase63 class kFileDef : public kExportI, public kFileFormatBase, public kModuleI 64 64 { 65 65 private: … … 104 104 virtual ~kFileDef(); 105 105 106 /** @cat Module information methods. */ 107 BOOL moduleGetName(char *pszBuffer, int cchSize = 260); 108 109 /** @cat Export enumeration methods. */ 110 BOOL exportFindFirst(kExportEntry *pExport); 111 BOOL exportFindNext(kExportEntry *pExport); 112 void exportFindClose(kExportEntry *pExport); 113 114 /** @cat Export Lookup methods */ 115 BOOL exportLookup(unsigned long ulOrdinal, kExportEntry *pExport); 116 BOOL exportLookup(const char * pszName, kExportEntry *pExport); 117 106 118 /**@cat queries... */ 107 BOOL queryModuleName(char *pszBuffer);108 BOOL findFirstExport(PEXPORTENTRY pExport);109 BOOL findNextExport(PEXPORTENTRY pExport);110 119 BOOL isDef() const { return TRUE;} 111 120 char const *queryModuleName(void) const { return pszModName; } … … 128 137 }; 129 138 130 131 139 #endif -
trunk/tools/common/kFileFormatBase.cpp
r5053 r5531 1 /* $Id: kFileFormatBase.cpp,v 1. 3 2001-02-02 08:45:41 bird Exp $1 /* $Id: kFileFormatBase.cpp,v 1.4 2001-04-17 00:26:11 bird Exp $ 2 2 * 3 3 * kFileFormatBase - Base class for kFile<format> classes. … … 21 21 22 22 #include "kFile.h" 23 #include "kInterfaces.h" 23 24 #include "kFileFormatBase.h" 24 25 25 26 27 28 /**29 * Creates a memory buffer for a binary file.30 * @returns Pointer to file memoryblock. NULL on error.31 * @param pszFilename Pointer to filename string.32 * @remark This function is the one using most of the execution33 * time (DosRead + DosOpen) - about 70% of the execution time!34 */35 void *kFileFormatBase::readfile(const char *pszFilename)36 {37 void *pvFile = NULL;38 FILE *phFile;39 40 phFile = fopen(pszFilename, "rb");41 if (phFile != NULL)42 {43 long int cbFile;44 45 if (ftell(phFile) < 046 ||47 fseek(phFile, 0, SEEK_END) != 048 ||49 (cbFile = ftell(phFile)) < 050 ||51 fseek(phFile, 0, SEEK_SET) != 052 )53 cbFile = -1;54 55 if (cbFile > 0)56 {57 pvFile = malloc((size_t)cbFile + 1);58 if (pvFile != NULL)59 {60 memset(pvFile, 0, (size_t)cbFile + 1);61 if (fread(pvFile, 1, (size_t)cbFile, phFile) == 0)62 { /* failed! */63 free(pvFile);64 pvFile = NULL;65 }66 }67 else68 fprintf(stderr, "warning/error: failed to open file %s\n", pszFilename);69 }70 fclose(phFile);71 }72 return pvFile;73 }74 26 75 27 /** -
trunk/tools/common/kFileFormatBase.h
r4358 r5531 1 /* $Id: kFileFormatBase.h,v 1. 4 2000-10-02 04:01:39bird Exp $1 /* $Id: kFileFormatBase.h,v 1.5 2001-04-17 00:26:11 bird Exp $ 2 2 * 3 3 * kFileFormatBase - Base class for kFile<format> classes. … … 15 15 * Defined Constants * 16 16 ******************************************************************************/ 17 #define MAXEXPORTNAME 25618 17 #define ORD_START_INTERNAL_FUNCTIONS 1200 19 18 … … 26 25 class kFile; 27 26 28 /**29 * ExportEntry used by the findFirstExport/findNextExport functions30 */31 typedef struct _ExportEntry32 {33 unsigned long ulOrdinal;34 char achName[MAXEXPORTNAME];35 char achIntName[MAXEXPORTNAME]; /* not used by PEFile */36 37 /* these don't apply for .DEF files. (should have a flag for that...) */38 unsigned long offset;39 unsigned long iObject;40 41 /* internal - do not use! */42 void *pv;43 } EXPORTENTRY, *PEXPORTENTRY;44 45 27 46 28 /** … … 51 33 { 52 34 public: 53 virtual BOOL queryModuleName(char *pszBuffer) = 0;54 virtual BOOL findFirstExport(PEXPORTENTRY pExport) = 0;55 virtual BOOL findNextExport(PEXPORTENTRY pExport) = 0;56 35 virtual BOOL isDef() const { return FALSE;} 57 36 virtual BOOL isPe() const { return FALSE;} 58 37 virtual BOOL isLx() const { return FALSE;} 59 60 static void * readfile(const char *pszFilename);61 38 virtual BOOL dump(kFile *pOut); 62 39 }; -
trunk/tools/common/kFileLX.cpp
r5053 r5531 1 /* $Id: kFileLX.cpp,v 1. 4 2001-02-02 08:45:41 bird Exp $1 /* $Id: kFileLX.cpp,v 1.5 2001-04-17 00:26:11 bird Exp $ 2 2 * 3 3 * … … 64 64 65 65 66 66 /******************************************************************************* 67 * Global Variables * 68 *******************************************************************************/ 69 #if 0 70 static kFileLX tst((kFile*)NULL); 71 #endif 72 73 74 /** 75 * Internal worker which lookup the name corresponding to an ordinal. 76 * @returns Success indicator. 77 * @param iOrdinal ( >= 0). 78 * @param pszBuffer. 79 */ 67 80 BOOL kFileLX::queryExportName(int iOrdinal, char *pszBuffer) 68 81 { … … 119 132 120 133 /* create filemapping */ 121 pvBase = kFile FormatBase::readfile(pszFilename);134 pvBase = kFile::readFile(pszFilename); 122 135 if (pvBase == NULL) 123 136 throw(1); … … 192 205 193 206 194 BOOL kFileLX::queryModuleName(char *pszBuffer) 207 /** 208 * Query for the module name. 209 * @returns Success indicator. TRUE / FALSE. 210 * @param pszBuffer Pointer to buffer which to put the name into. 211 * @param cchBuffer Size of the buffer (defaults to 260 chars). 212 */ 213 BOOL kFileLX::moduleGetName(char *pszBuffer, int cchBuffer/*= 260*/) 195 214 { 196 215 /* The module name is the 0 ordinal entry in resident name table */ 216 assert(cchBuffer >= 255); 197 217 return queryExportName(0, pszBuffer); 198 218 } 199 219 200 220 201 202 BOOL kFileLX::findFirstExport(PEXPORTENTRY pExport) 221 /** 222 * Finds the first exports. 223 * @returns Success indicator. TRUE / FALSE. 224 * @param pExport Pointer to export structure. 225 */ 226 BOOL kFileLX::exportFindFirst(kExportEntry *pExport) 203 227 { 204 228 struct b32_bundle * pBundle = (struct b32_bundle*)((char*)pvBase + pe32->e32_enttab + offLXHdr); … … 239 263 { 240 264 case ENTRY16: 241 pExport-> offset = pEntry->e32_variant.e32_offset.offset16;265 pExport->ulOffset = pEntry->e32_variant.e32_offset.offset16; 242 266 break; 243 267 244 268 case ENTRY32: 245 pExport-> offset = pEntry->e32_variant.e32_offset.offset32;269 pExport->ulOffset = pEntry->e32_variant.e32_offset.offset32; 246 270 break; 247 271 248 272 case GATE16: 249 pExport-> offset = pEntry->e32_variant.e32_callgate.offset;273 pExport->ulOffset = pEntry->e32_variant.e32_callgate.offset; 250 274 break; 251 275 default: … … 260 284 pExpState->pe32 = pEntry; 261 285 pExpState->iOrdinal = iOrdinal; 286 pExport->ulAddress = ~0UL; /* TODO */ 262 287 return TRUE; 263 288 } … … 270 295 271 296 272 273 BOOL kFileLX::findNextExport(PEXPORTENTRY pExport) 297 /** 298 * Finds the next export. 299 * @returns Success indicator. TRUE / FALSE. 300 * @param pExport Pointer to export structure. 301 */ 302 BOOL kFileLX::exportFindNext(kExportEntry *pExport) 274 303 { 275 304 static int acbEntry[] = … … 283 312 284 313 PEXPSTATE pExpState = (PEXPSTATE)pExport->pv; 314 pExport->ulAddress = ~0UL; /* TODO */ 285 315 286 316 /* … … 303 333 pExport->achName[0] = '\0'; 304 334 305 /* offset */335 /* ulOffset */ 306 336 switch (pExpState->pb32->b32_type & ~TYPEINFO) 307 337 { 308 338 case ENTRY16: 309 pExport-> offset = pExpState->pe32->e32_variant.e32_offset.offset16;339 pExport->ulOffset = pExpState->pe32->e32_variant.e32_offset.offset16; 310 340 break; 311 341 312 342 case ENTRY32: 313 pExport-> offset = pExpState->pe32->e32_variant.e32_offset.offset32;343 pExport->ulOffset = pExpState->pe32->e32_variant.e32_offset.offset32; 314 344 break; 315 345 316 346 case GATE16: 317 pExport-> offset = pExpState->pe32->e32_variant.e32_callgate.offset;347 pExport->ulOffset = pExpState->pe32->e32_variant.e32_callgate.offset; 318 348 break; 319 349 } … … 360 390 { 361 391 case ENTRY16: 362 pExport-> offset = pExpState->pe32->e32_variant.e32_offset.offset16;392 pExport->ulOffset = pExpState->pe32->e32_variant.e32_offset.offset16; 363 393 break; 364 394 365 395 case ENTRY32: 366 pExport-> offset = pExpState->pe32->e32_variant.e32_offset.offset32;396 pExport->ulOffset = pExpState->pe32->e32_variant.e32_offset.offset32; 367 397 break; 368 398 369 399 case GATE16: 370 pExport-> offset = pExpState->pe32->e32_variant.e32_callgate.offset;400 pExport->ulOffset = pExpState->pe32->e32_variant.e32_callgate.offset; 371 401 break; 372 402 default: … … 384 414 free(pExport->pv); 385 415 pExport->pv = NULL; 416 return FALSE; 417 } 418 419 420 /** 421 * Frees resources associated with the communicatin area. 422 * It's not necessary to call this when exportFindNext has return FALSE. 423 * @param pExport Communication area which has been successfully 424 * processed by findFirstExport. 425 */ 426 void kFileLX::exportFindClose(kExportEntry *pExport) 427 { 428 free(pExport->pv); 429 pExport->pv = NULL; 430 return; 431 } 432 433 434 /** 435 * Lookup information on a spesific export given by ordinal number. 436 * @returns Success indicator. 437 * @param pExport Communication area containing export information 438 * on successful return. 439 * @remark stub 440 */ 441 BOOL kFileLX::exportLookup(unsigned long ulOrdinal, kExportEntry *pExport) 442 { 443 assert(!"not implemented."); 444 ulOrdinal = ulOrdinal; 445 pExport = pExport; 446 return FALSE; 447 } 448 449 /** 450 * Lookup information on a spesific export given by name. 451 * @returns Success indicator. 452 * @param pExport Communication area containing export information 453 * on successful return. 454 * @remark stub 455 */ 456 BOOL kFileLX::exportLookup(const char * pszName, kExportEntry *pExport) 457 { 458 assert(!"not implemented."); 459 pszName = pszName; 460 pExport = pExport; 386 461 return FALSE; 387 462 } -
trunk/tools/common/kFileLX.h
r5053 r5531 1 /* $Id: kFileLX.h,v 1. 4 2001-02-02 08:45:41 bird Exp $1 /* $Id: kFileLX.h,v 1.5 2001-04-17 00:26:11 bird Exp $ 2 2 * 3 3 * kFileLX - Linear Executable file reader. … … 15 15 16 16 17 class kFileLX : public kFileFormatBase /*, public kPageI*/17 class kFileLX : public kFileFormatBase, public kExecutableI /*, public kPageI*/ 18 18 { 19 19 protected: … … 32 32 ~kFileLX(); 33 33 34 virtual BOOL queryModuleName(char *pszBuffer); 35 virtual BOOL findFirstExport(PEXPORTENTRY pExport); 36 virtual BOOL findNextExport(PEXPORTENTRY pExport); 34 /** @cat Module information methods. */ 35 BOOL moduleGetName(char *pszBuffer, int cchSize = 260); 36 37 /** @cat Export enumeration methods. */ 38 BOOL exportFindFirst(kExportEntry *pExport); 39 BOOL exportFindNext(kExportEntry *pExport); 40 void exportFindClose(kExportEntry *pExport); 41 42 /** @cat Export Lookup methods */ 43 BOOL exportLookup(unsigned long ulOrdinal, kExportEntry *pExport); 44 BOOL exportLookup(const char * pszName, kExportEntry *pExport); 45 37 46 virtual BOOL isLx() const {return TRUE;}; 38 47 -
trunk/tools/common/kFilePE.cpp
r5053 r5531 36 36 #include "kFile.h" 37 37 #include "kFileFormatBase.h" 38 #include "kInterfaces.h" 38 39 #include "kFilePe.h" 39 40 41 /******************************************************************************* 42 * Global Variables * 43 *******************************************************************************/ 44 #if 0 45 kFilePE kFilePE((kFile*)NULL); 46 #endif 40 47 41 48 /** … … 62 69 63 70 /* read dos-header - assumes there is one */ 64 if ( pFile->readAt(&doshdr, sizeof(doshdr), 0) 71 if ( pFile->readAt(&doshdr, sizeof(doshdr), 0) 65 72 && doshdr.e_magic == IMAGE_DOS_SIGNATURE 66 73 && doshdr.e_lfanew > sizeof(doshdr) … … 101 108 cbSection = min(pSectionHdr->Misc.VirtualSize, pSectionHdr->SizeOfRawData); 102 109 if ( cbSection 103 && !pFile->readAt((char*)pvBase + pSectionHdr->VirtualAddress, 104 cbSection, 110 && !pFile->readAt((char*)pvBase + pSectionHdr->VirtualAddress, 111 cbSection, 105 112 pSectionHdr->PointerToRawData) 106 113 ) … … 169 176 /** 170 177 * Query for the module name. 171 * @returns Success indicator. TRUE / FALSE. 172 * @param pszBuffer Pointer to buffer which to put the name into. 173 */ 174 BOOL kFilePE::queryModuleName(char *pszBuffer) 178 * @returns Success indicator. TRUE / FALSE. 179 * @param pszBuffer Pointer to buffer which to put the name into. 180 * @param cchBuffer Size of the buffer (defaults to 260 chars). 181 */ 182 BOOL kFilePE::moduleGetName(char *pszBuffer, int cchSize/* = 260*/) 175 183 { 176 184 if (pExportDir && pExportDir->Name) 177 strcpy(pszBuffer, (char*)((int)pExportDir->Name + (int)pvBase)); 185 { 186 char *psz = (char*)((int)pExportDir->Name + (int)pvBase); 187 int cch = strlen(psz) + 1; 188 if (cch > cchSize) 189 return FALSE; 190 memcpy(pszBuffer, psz, cch); 191 } 178 192 else 179 193 return FALSE; … … 189 203 * @remark 190 204 */ 191 BOOL kFilePE:: findFirstExport(PEXPORTENTRYpExport)205 BOOL kFilePE::exportFindFirst(kExportEntry *pExport) 192 206 { 193 207 if (pExportDir && pExportDir->NumberOfFunctions) 194 208 { 195 memset(pExport, 0, sizeof( EXPORTENTRY));209 memset(pExport, 0, sizeof(kExportEntry)); 196 210 pExport->ulOrdinal = pExportDir->Base - 1; 197 return findNextExport(pExport);211 return exportFindNext(pExport); 198 212 } 199 213 … … 208 222 * @remark 209 223 */ 210 BOOL kFilePE:: findNextExport(PEXPORTENTRYpExport)224 BOOL kFilePE::exportFindNext(kExportEntry *pExport) 211 225 { 212 226 if (pExportDir && pExportDir->NumberOfFunctions) … … 241 255 return FALSE; 242 256 257 pExport->ulAddress = pExport->iObject = pExport->ulOffset = ~0UL; /* FIXME/TODO */ 243 258 pExport->achIntName[0] = '\0'; 244 259 pExport->pv = NULL; 245 260 return TRUE; 261 } 262 263 264 /** 265 * Frees resources associated with the communicatin area. 266 * It's not necessary to call this when exportFindNext has return FALSE. 267 * (We don't allocate anything so it's not a problem ;-) 268 * @param pExport Communication area which has been successfully 269 * processed by findFirstExport. 270 */ 271 void kFilePE::exportFindClose(kExportEntry *pExport) 272 { 273 pExport = pExport; 274 return; 275 } 276 277 278 /** 279 * Lookup information on a spesific export given by ordinal number. 280 * @returns Success indicator. 281 * @param pExport Communication area containing export information 282 * on successful return. 283 * @remark stub 284 */ 285 BOOL kFilePE::exportLookup(unsigned long ulOrdinal, kExportEntry *pExport) 286 { 287 assert(!"not implemented."); 288 ulOrdinal = ulOrdinal; 289 pExport = pExport; 290 return FALSE; 291 } 292 293 /** 294 * Lookup information on a spesific export given by name. 295 * @returns Success indicator. 296 * @param pExport Communication area containing export information 297 * on successful return. 298 * @remark stub 299 */ 300 BOOL kFilePE::exportLookup(const char * pszName, kExportEntry *pExport) 301 { 302 assert(!"not implemented."); 303 pszName = pszName; 304 pExport = pExport; 305 return FALSE; 246 306 } 247 307 … … 327 387 pOut->printf("Import Directory\n" 328 388 "----------------\n"); 329 389 330 390 PIMAGE_IMPORT_DESCRIPTOR pCur = pImportDir; 331 391 while (pCur->u.Characteristics != 0) … … 334 394 pCur++; 335 395 } 336 } 396 } 337 397 338 398 -
trunk/tools/common/kFilePE.h
r5053 r5531 1 /* 1 /* $Id: kFilePE.h,v 1.4 2001-04-17 00:26:11 bird Exp $ 2 2 * kFilePE - PE files. 3 3 * 4 * Copyright (c) 1999 knut st. osmundsen4 * Copyright (c) 1999-2001 knut st. osmundsen 5 5 * 6 6 */ … … 14 14 15 15 #if !defined(__WINE_PEEXE_H) && !defined(_WINNT_) 16 #if 016 #if 1 17 17 #define PIMAGE_DOS_HEADER void* 18 18 #define PIMAGE_FILE_HEADER void* … … 47 47 * @author knut st. osmundsen 48 48 */ 49 class kFilePE : public kFileFormatBase 49 class kFilePE : public kFileFormatBase, public kExecutableI 50 50 { 51 51 private: … … 83 83 virtual ~kFilePE(); 84 84 85 /* operations */ 86 BOOL queryModuleName(char *pszBuffer); 87 BOOL findFirstExport(PEXPORTENTRY pExport); 88 BOOL findNextExport(PEXPORTENTRY pExport); 85 /** @cat Module information methods. */ 86 BOOL moduleGetName(char *pszBuffer, int cchSize = 260); 87 88 /** @cat Export enumeration methods. */ 89 BOOL exportFindFirst(kExportEntry *pExport); 90 BOOL exportFindNext(kExportEntry *pExport); 91 void exportFindClose(kExportEntry *pExport); 92 93 /** @cat Export Lookup methods */ 94 BOOL exportLookup(unsigned long ulOrdinal, kExportEntry *pExport); 95 BOOL exportLookup(const char * pszName, kExportEntry *pExport); 96 89 97 BOOL isPe() const { return TRUE;} 90 98 -
trunk/tools/common/kInterfaces.h
r4751 r5531 1 /* $Id: kInterfaces.h,v 1. 1 2000-12-04 08:49:00bird Exp $1 /* $Id: kInterfaces.h,v 1.2 2001-04-17 00:26:12 bird Exp $ 2 2 * 3 3 * This headerfile contains interfaces for the common tools classes. … … 12 12 #ifndef _kInterfaces_h_ 13 13 #define _kInterfaces_h_ 14 15 16 class kPageI; 17 class kExportI; 18 class kExportEntry; 19 class kModuleI; 20 14 21 15 22 /** … … 31 38 * @param ulAddress Page address. This will be page aligned. 32 39 */ 33 virtual BOOL getPage(char *pachPage, ULONG ulAddress) = 0;40 virtual BOOL pageGet(char *pachPage, ULONG ulAddress) = 0; 34 41 35 42 /** … … 42 49 * @remark Object = Section. 43 50 */ 44 virtual BOOL getPage(char *pachPage, int iObject, int offObject) = 0;51 virtual BOOL pageGet(char *pachPage, int iObject, int offObject) = 0; 45 52 46 53 /** … … 51 58 * @param ulAddress Page address. This will be page aligned. 52 59 */ 53 virtual BOOL p utPage(const char *pachPage, ULONG ulAddress) = 0;60 virtual BOOL pagePut(const char *pachPage, ULONG ulAddress) = 0; 54 61 55 62 /** … … 61 68 * @param offObject Offset into the object. 62 69 */ 63 virtual BOOL p utPage(const char *pachPage, int iObject, int offObject) = 0;70 virtual BOOL pagePut(const char *pachPage, int iObject, int offObject) = 0; 64 71 65 72 /** … … 67 74 * @returns Pagesize in bytes. 68 75 */ 69 virtual int getPageSize() = 0; 76 virtual int pageGetPageSize() = 0; 77 }; 78 79 80 /** 81 * ExportEntry used by the findFirstExport/findNextExport functions 82 */ 83 class kExportEntry 84 { 85 #define MAXEXPORTNAME 256 86 public: 87 unsigned long ulOrdinal; /* Ordinal of export. 0 if invalid. */ 88 char achName[MAXEXPORTNAME]; /* Public or exported name. */ 89 char achIntName[MAXEXPORTNAME]; /* Optional. not used by PEFile */ 90 91 unsigned long ulOffset; /* Offset. -1 if invalid. */ 92 unsigned long iObject; /* Object number. -1 if invalid. */ 93 unsigned long ulAddress; /* Address of symbol. -1 if invalid. */ 94 95 public: 96 /** @cat Internal use - don't mess! */ 97 void * pv; /* Internal pointer. */ 98 }; 99 100 /** 101 * Interface class (ie. virtual) which defines the interface for executables 102 * (objects and libraries to perhaps) files used to enumerate exports and 103 * public exported names. 104 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no) 105 */ 106 class kExportI 107 { 108 public: 109 /** @cat Export enumeration methods. */ 110 111 /** 112 * Find the first export/public name. 113 * @returns Success indicator. 114 * @param pExport Communication area. 115 */ 116 virtual BOOL exportFindFirst(kExportEntry * pExport) = 0; 117 118 /** 119 * Find the next export/public name. 120 * @returns Success indicator. 121 * FALSE when no more exports (exportFindClose has been processed then). 122 * @param pExport Communication area which has been successfully 123 * processed by findFirstExport. 124 */ 125 virtual BOOL exportFindNext(kExportEntry * pExport) = 0; 126 127 /** 128 * Frees resources associated with the communicatin area. 129 * It's not necessary to call this when exportFindNext has return FALSE. 130 * @param pExport Communication area which has been successfully 131 * processed by findFirstExport. 132 */ 133 virtual void exportFindClose(kExportEntry * pExport) = 0; 134 135 136 /** @cat Export Search methods */ 137 138 /** 139 * Lookup information on a spesific export given by ordinal number. 140 * @returns Success indicator. 141 * @param pExport Communication area containing export information 142 * on successful return. 143 */ 144 virtual BOOL exportLookup(unsigned long ulOrdinal, kExportEntry *pExport) = 0; 145 146 /** 147 * Lookup information on a spesific export given by name. 148 * @returns Success indicator. 149 * @param pExport Communication area containing export information 150 * on successful return. 151 */ 152 virtual BOOL exportLookup(const char * pszName, kExportEntry *pExport) = 0; 153 }; 154 155 156 /** 157 * Interface class (ie. virtual) which defines the interface for executables 158 * (objects and libraries to perhaps) files used to enumerate exports and 159 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no) 160 */ 161 class kModuleI 162 { 163 public: 164 /** @cat Module information methods. */ 165 virtual BOOL moduleGetName(char *pszBuffer, int cbBuffer = 260) = 0; 166 }; 167 168 169 /** 170 * Interface class (ie. virtual) which defines the interface for 171 * executables files. 172 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no) 173 */ 174 class kExecutableI : public kModuleI, public kExportI 175 { 176 public: 177 /** @cat Executable information methods. */ 178 #if 0 179 virtual BOOL execIsDLL(void) = 0; 180 virtual BOOL execIsProgram(void) = 0; 181 virtual BOOL execIsDriver(void) = 0; 182 #endif 70 183 }; 71 184 -
trunk/tools/database/APIImport.cpp
r5053 r5531 1 /* $Id: APIImport.cpp,v 1. 8 2001-02-02 08:45:42bird Exp $ */1 /* $Id: APIImport.cpp,v 1.9 2001-04-17 00:24:46 bird Exp $ */ 2 2 /* 3 3 * … … 18 18 #include "APIImport.h" 19 19 #include "kFile.h" 20 #include "kInterfaces.h" 20 21 #include "kFileFormatBase.h" 21 22 #include "kFilePE.h" … … 242 243 static long processFile(const char *pszFilename, const POPTIONS pOptions, long &cFunctions) 243 244 { 244 kFileFormatBase *pFile;245 245 long lRc = 1; 246 246 … … 252 252 try 253 253 { 254 kFileFormatBase * pFileBase = NULL; 255 kExportI * pExportFile; 256 kModuleI * pModuleFile; 254 257 char achDataBuffer[0x200]; 255 258 char *pszModuleName = &achDataBuffer[0]; … … 259 262 try 260 263 { 261 pFile = new kFilePE(&InFile); 264 kFilePE *pFile = new kFilePE(&InFile); 265 pExportFile = pFile; 266 pModuleFile = pFile; 267 pFileBase = pFile; 262 268 } 263 269 catch (int i) 264 270 { 265 271 i = i; 266 pFile = new kFileDef(&InFile); 267 } 268 269 if (pFile->queryModuleName(pszModuleName)) 272 kFileDef *pFile = new kFileDef(&InFile); 273 pExportFile = pFile; 274 pModuleFile = pFile; 275 pFileBase = pFile; 276 } 277 278 if (pModuleFile->moduleGetName(pszModuleName)) 270 279 { 271 280 int cch = strlen(pszModuleName); … … 281 290 BOOL fClearUpdateOk = FALSE; 282 291 BOOL fOk; 283 EXPORTENTRYexport;292 kExportEntry export; 284 293 285 294 /* Clear the update flag for all functions in this DLL. */ … … 288 297 289 298 lRc = 0; 290 fOk = p File->findFirstExport(&export);299 fOk = pExportFile->exportFindFirst(&export); 291 300 while (fOk) 292 301 { 293 302 /* check if name or not */ 294 if (!pFile ->isDef() || export.ulOrdinal < ORD_START_INTERNAL_FUNCTIONS)303 if (!pFileBase->isDef() || export.ulOrdinal < ORD_START_INTERNAL_FUNCTIONS) 295 304 { 296 305 char szIntName[256]; … … 344 353 345 354 /* next */ 346 fOk = p File->findNextExport(&export);355 fOk = pExportFile->exportFindNext(&export); 347 356 } 348 357 … … 362 371 fprintf(phLog, "%s: error - could not get module name.\n", pszFilename); 363 372 364 delete(pFile );373 delete(pFileBase); 365 374 } 366 375 catch (int err) -
trunk/tools/impdef/ImpDef.cpp
r4823 r5531 1 /* $Id: ImpDef.cpp,v 1. 6 2000-12-17 03:26:41bird Exp $ */1 /* $Id: ImpDef.cpp,v 1.7 2001-04-17 00:26:28 bird Exp $ */ 2 2 /* 3 3 * ImpDef - Create export file which use internal names and ordinals. … … 16 16 #include "ImpDef.h" 17 17 #include "kFile.h" 18 #include "kInterFaces.h" 18 19 #include "kFileFormatBase.h" 19 20 #include "kFileDef.h" … … 25 26 static void syntax(void); 26 27 static long processFile(const char *pszInput, const char *pszOutput, const POPTIONS pOptions); 27 static char *generateExportName(const PEXPORTENTRYpExport, char *pszBuffer, const POPTIONS pOptions);28 static char *generateExportName(const kExportEntry * pExport, char *pszBuffer, const POPTIONS pOptions); 28 29 29 30 … … 191 192 try 192 193 { 193 EXPORTENTRYexport;194 kExportEntry export; 194 195 kFile Output(pszOutput, FALSE); 195 196 … … 205 206 206 207 /* Exports */ 207 if (DefFile. findFirstExport(&export))208 if (DefFile.exportFindFirst(&export)) 208 209 { 209 210 Output.printf("EXPORTS\n"); … … 235 236 236 237 Output.printf(" %-*s @%ld\n", 40, pszName, export.ulOrdinal); 237 } while (DefFile. findNextExport(&export));238 } while (DefFile.exportFindNext(&export)); 238 239 Output.setSize(); 239 240 } … … 275 276 * @remark 276 277 */ 277 static char *generateExportName(const PEXPORTENTRYpExport, char *pszBuffer, const POPTIONS pOptions)278 static char *generateExportName(const kExportEntry * pExport, char *pszBuffer, const POPTIONS pOptions) 278 279 { 279 280 if (pExport->ulOrdinal < pOptions->ulOrdStartInternalFunctions)
Note:
See TracChangeset
for help on using the changeset viewer.