Changeset 5531 for trunk/tools/common/kFilePE.cpp
- Timestamp:
- Apr 17, 2001, 2:26:28 AM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note:
See TracChangeset
for help on using the changeset viewer.