imgtools/romtools/readimage/src/e32_image_reader.cpp
changeset 0 044383f39525
child 590 360bd6b35136
equal deleted inserted replaced
-1:000000000000 0:044383f39525
       
     1 /*
       
     2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 * @internalComponent 
       
    16 * @released
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #include "e32_image_reader.h"
       
    22 
       
    23 E32ImageReader::E32ImageReader(char *aFile):ImageReader(aFile)
       
    24 {
       
    25 }
       
    26 
       
    27 E32ImageReader::E32ImageReader():ImageReader(NULL)
       
    28 {
       
    29 }
       
    30 
       
    31 
       
    32 E32ImageReader::~E32ImageReader()
       
    33 {
       
    34 	delete iE32Image;
       
    35 }
       
    36 
       
    37 void E32ImageReader::ReadImage()
       
    38 {
       
    39 	ifstream aIf(iImgFileName.c_str(), ios::binary | ios::in);
       
    40 	if( !aIf.is_open() )
       
    41 	{
       
    42 		throw ImageReaderException(iImgFileName.c_str(), "Cannot open file ");
       
    43 	}
       
    44 
       
    45 	iE32Image = new E32ImageFile();
       
    46 
       
    47 	TUint32			aSz;
       
    48 
       
    49 	aIf.seekg(0,ios::end);
       
    50 	aSz = aIf.tellg();
       
    51 
       
    52 	iE32Image->Adjust(aSz);
       
    53 	iE32Image->iFileSize = aSz;
       
    54 
       
    55 	aIf.seekg(0,ios::beg);
       
    56 	aIf >> *iE32Image;
       
    57 }
       
    58 
       
    59 void E32ImageReader::Validate()
       
    60 {
       
    61 }
       
    62 
       
    63 void E32ImageReader::ProcessImage()
       
    64 {
       
    65 }
       
    66 
       
    67 void E32ImageReader::Dump()
       
    68 {
       
    69 	*out << "Image Name................." << iImgFileName.c_str() << endl;
       
    70 	DumpE32Attributes(*iE32Image);
       
    71 }
       
    72 
       
    73 void E32ImageReader::DumpE32Attributes(E32ImageFile& aE32Image)
       
    74 {
       
    75 	bool aContinue = true;
       
    76 
       
    77 	DumpInHex("Size", aE32Image.iSize ) << endl;
       
    78 	DumpInHex("Uids",aE32Image.iOrigHdr->iUid1);
       
    79 	DumpInHex(" ",aE32Image.iOrigHdr->iUid2, aContinue);
       
    80 	DumpInHex(" ",aE32Image.iOrigHdr->iUid3, aContinue);
       
    81 	DumpInHex(" ",aE32Image.iOrigHdr->iUidChecksum, aContinue) << endl;
       
    82 
       
    83 	
       
    84 	DumpInHex("Entry point", aE32Image.iOrigHdr->iEntryPoint ) << endl;
       
    85 	DumpInHex("Code start addr" ,aE32Image.iOrigHdr->iCodeBase)<< endl;
       
    86 	DumpInHex("Data start addr" ,aE32Image.iOrigHdr->iDataBase) << endl;
       
    87 	DumpInHex("Text size" ,aE32Image.iOrigHdr->iTextSize) << endl;
       
    88 	DumpInHex("Code size" ,aE32Image.iOrigHdr->iCodeSize) << endl;
       
    89 	DumpInHex("Data size" ,aE32Image.iOrigHdr->iDataSize) << endl;
       
    90 	DumpInHex("Bss size" ,aE32Image.iOrigHdr->iBssSize) << endl;
       
    91 	DumpInHex("Total data size" ,(aE32Image.iOrigHdr->iBssSize + aE32Image.iOrigHdr->iDataSize)) << endl;
       
    92 	DumpInHex("Heap min" ,aE32Image.iOrigHdr->iHeapSizeMin) << endl;
       
    93 	DumpInHex("Heap max" ,aE32Image.iOrigHdr->iHeapSizeMax) << endl;
       
    94 	DumpInHex("Stack size" ,aE32Image.iOrigHdr->iStackSize) << endl;
       
    95 	DumpInHex("Export directory" ,aE32Image.iOrigHdr->iExportDirOffset) << endl;
       
    96 	DumpInHex("Export dir count" ,aE32Image.iOrigHdr->iExportDirCount) << endl;
       
    97 	DumpInHex("Flags" ,aE32Image.iOrigHdr->iFlags) << endl;
       
    98 
       
    99 	TUint aHeaderFmt = E32ImageHeader::HdrFmtFromFlags(aE32Image.iOrigHdr->iFlags);
       
   100 
       
   101 	if (aHeaderFmt >= KImageHdrFmt_V)
       
   102 	{
       
   103 		//
       
   104 		// Important. Don't change output format of following security info
       
   105 		// because this is relied on by used by "Symbian Signed".
       
   106 		//
       
   107 		E32ImageHeaderV* v = aE32Image.iHdr;
       
   108 		DumpInHex("Secure ID", v->iS.iSecureId) << endl;
       
   109 		DumpInHex("Vendor ID", v->iS.iVendorId) << endl;
       
   110 		DumpInHex("Capability", v->iS.iCaps[1]);
       
   111 		DumpInHex(" ", v->iS.iCaps[0], aContinue) << endl;
       
   112 
       
   113 	}
       
   114 
       
   115 	*out << "Tools Version..............." << dec << (TUint)aE32Image.iOrigHdr->iToolsVersion.iMajor;
       
   116 	*out << ".";
       
   117 	out->width (2);
       
   118 	*out << dec << (TUint)aE32Image.iOrigHdr->iToolsVersion.iMinor ;
       
   119 	*out << "(" << dec << aE32Image.iOrigHdr->iToolsVersion.iBuild << ")" << endl;
       
   120 
       
   121 	*out << "Module Version.............." << dec << (aE32Image.iOrigHdr->iModuleVersion >> 16) << endl;
       
   122 	DumpInHex("Compression", aE32Image.iOrigHdr->iCompressionType) << endl;
       
   123 
       
   124 	if( aHeaderFmt >= KImageHdrFmt_V )
       
   125 	{
       
   126 		E32ImageHeaderV* v = aE32Image.iHdr;
       
   127 		DumpInHex("Exception Descriptor", v->iExceptionDescriptor) << endl;
       
   128 		DumpInHex("Code offset", v->iCodeOffset) << endl;
       
   129 	}
       
   130 
       
   131 	*out << "Priority...................." << dec << aE32Image.iOrigHdr->iProcessPriority << endl;
       
   132 	DumpInHex("Dll ref table size", aE32Image.iOrigHdr->iDllRefTableCount) << endl << endl << endl;
       
   133 }