void PE_Debug :: FindDebugInfo() { ClearDebugPtrs() ; // Put everything into a try/catch in case the file has wrong fields try { // Verify that fileBase is a valid pointer to a DOS header if( fileBase->e_magic == IMAGE_DOS_SIGNATURE ) { // Get a pointer to the PE header NT_Header = BasedPtr( PIMAGE_NT_HEADERS, fileBase, fileBase->e_lfanew ) ; // Verify that NT_Header is a valid pointer to a NT header if( NT_Header->Signature == IMAGE_NT_SIGNATURE ) { // Get a pointer to the debug header if any COFFDebugInfo = GetDebugHeader() ; // Get a pointer to the symbol table and retrieve the number of symbols if( NT_Header->FileHeader.PointerToSymbolTable ) COFFSymbolTable = BasedPtr( PIMAGE_SYMBOL, fileBase, NT_Header->FileHeader.PointerToSymbolTable ) ; COFFSymbolCount = NT_Header->FileHeader.NumberOfSymbols ; // The string table starts right after the symbol table stringTable = (const char*)(COFFSymbolTable + COFFSymbolCount) ; } } } catch( ... ) { // Header wrong, do nothing } }
// second-phase constructor void CServerCrashDataSource::ConstructL() { LOG_MSG("->CServerCrashDataSource::ConstructL()\n" ); // Get the debug func block and make appropriate changes to our structures TInt err; TUint32 bufsize = 0; LOG_MSG( " -> iSecSess->GetDebugFunctionalityBufSize( &bufsize )\n" ); err = iSecSess.GetDebugFunctionalityBufSize( &bufsize ); if( (err != KErrNone) || (0 == bufsize) ) { // No debug functionality block, cannot do much without that. LOG_MSG2("CServerCrashDataSource::ConstructL() - unable to get debug functionality block! err:%d\n", err); User::Leave( KErrNotSupported ); } RBuf8 DFBlock; DFBlock.CreateL(bufsize); DFBlock.CleanupClosePushL(); LOG_MSG2( " -> HBufC8::NewLC( bufsize=%d )\n", bufsize ); LOG_MSG("CServerCrashDataSource::ConstrucL -> GetDebugFunctionality()\n" ); err = iSecSess.GetDebugFunctionality(DFBlock); if( KErrNone != err ) { LOG_MSG( "CServerCrashDataSource::ConstructL() : ERROR !* : Could not retrieve debug functionality block\n" ); User::Leave( KErrNotSupported ); } LOG_MSG( " -> GetDebugHeader( EDF_TagHdrId_RegistersCore )\n" ); TTagHeader * hdr = GetDebugHeader( ETagHeaderIdRegistersCore, DFBlock ); if( hdr == NULL ) { LOG_MSG( "Could not retrieve ETagHeaderIdRegistersCore register debug block\n" ); } else if( 0 == hdr->iNumTags ) { LOG_MSG( "Zero tags found for ETagHeaderIdRegistersCore register debug block\n" ); } else { iRegisterList.ReserveL( (TInt)hdr->iNumTags ); // Skip the header to get to the tags TUint8 * ptr = ((TUint8 *) hdr) + sizeof( TTagHeader ); TTag * tag = (TTag *) ptr; TRegisterData regData; TRegisterData * reg = ®Data; // Process all the register tags for( TInt regIdx = 0; regIdx < hdr->iNumTags; regIdx ++ ) { reg->iRegClass = 0; // Core = 0 reg->iId = tag->iTagId; // reg->iSubId = 0; // reg->iSize = 2; // Should all be 32 bits == 2. reg->iAvailable = ETrue; reg->iValue64 = 0; iRegisterList.Append( *reg ); tag++; } } hdr = GetDebugHeader( ETagHeaderIdMemory, DFBlock ); if( hdr == NULL ) { LOG_MSG( "Could not retrieve ETagHeaderIdMemory. Cannot read memory\n" ); iMaxMemReadSize = 0; } else if( 0 == hdr->iNumTags ) { LOG_MSG( "Zero tags found for ETagHeaderIdMemory register debug block\n" ); iMaxMemReadSize = 0; } else { TTag* tag = GetTag( hdr, EMemoryMaxBlockSize ); if( tag ) { //LOG_MSG2( " EMemoryMaxBlockSize =0x%X\n", tag->iValue ); iMaxMemReadSize = tag->iValue; } } iLastThreadListSize = 1; iLastProcListSize = 1; iLastRegListSize = 1; CleanupStack::PopAndDestroy(&DFBlock); }