imgtools/imglib/inc/e32image.h
changeset 0 044383f39525
child 590 360bd6b35136
equal deleted inserted replaced
-1:000000000000 0:044383f39525
       
     1 /*
       
     2 * Copyright (c) 1996-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 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __E32IMAGE_H__
       
    20 #define __E32IMAGE_H__
       
    21 
       
    22 #if defined(__MSVCDOTNET__) || defined(__TOOLS2__)
       
    23 #include <fstream>
       
    24 using namespace std;
       
    25 #else //!__MSVCDOTNET__
       
    26 #include <fstream.h>
       
    27 #endif //__MSVCDOTNET__
       
    28 
       
    29 #include <e32std.h>
       
    30 #include <e32ldr.h>
       
    31 #include <f32image.h>
       
    32 #include "byte_pair.h"
       
    33 
       
    34 enum TFileSource
       
    35 	{
       
    36 	EE32Image=0,
       
    37 	EPeFile=1,
       
    38 	EElfFile=2,
       
    39 	};
       
    40 
       
    41 class E32ImageFile
       
    42 	{
       
    43 public:
       
    44 	static E32ImageFile* New();
       
    45 	E32ImageFile(CBytePair *aBPE = NULL);
       
    46 	virtual ~E32ImageFile();
       
    47 	virtual TBool Translate(const char* aFileName, TUint aDataBase, TBool aAllowDllData, TBool aSymLkupEnabled = FALSE);
       
    48 	TInt ReadHeader(ifstream& is);
       
    49 	TInt Open(const char* aFileName);
       
    50 #ifndef __LINUX__
       
    51 	TInt Open(const wchar_t* aFileName);
       
    52 #endif
       
    53 	void Adjust(TInt aSize, TBool aAllowShrink=ETrue);
       
    54 	TUint VaOfOrdinal(TUint aOrdinal);
       
    55 	void RelocateSection(char* aPtr, char *aRelocs, TUint aCodeDelta, TUint aDataDelta, char* aImagePtr, TLinAddr** aIATRefs, TBool keepIAT=EFalse);
       
    56 	//
       
    57 	TUint TextOffset();
       
    58 	TUint DataOffset();
       
    59 	TUint BssOffset();
       
    60 	TUint32 Capability();
       
    61 	TUint32 Format();
       
    62 	TInt NumberOfImports();
       
    63 
       
    64 	TInt IsValid();
       
    65 	TInt IsDll();
       
    66 	enum TDumpFlags
       
    67 		{
       
    68 		EDumpHeader = 1<<0,
       
    69 		EDumpSecurityInfo = 1<<1,
       
    70 		EDumpCode = 1<<2,
       
    71 		EDumpData = 1<<3,
       
    72 		EDumpExports = 1<<4,
       
    73 		EDumpImports = 1<<5,
       
    74 		EDumpDefaults = EDumpHeader|EDumpCode|EDumpData|EDumpExports|EDumpImports
       
    75 		};
       
    76 	void Dump(TText *aFileName,TInt aDumpFlags);
       
    77 	void DumpHeader(TInt aDumpFlags);
       
    78 	void DumpData(TInt aDumpFlags);
       
    79 	void SetStackSize(TInt aSize);
       
    80 	void SetHeapSizeMin(TInt aSize);
       
    81 	void SetHeapSizeMax(TInt aSize);
       
    82 	void SetUids(TUid aUid1, TUid aUid2, TUid aUid3);
       
    83 	void SetSecureId(TUint32 aId);
       
    84 	void SetVendorId(TUint32 aId);
       
    85 	void SetCallEntryPoints(TInt aBool);
       
    86 	void SetFixedAddress(TInt aBool);
       
    87 	void SetPriority(TProcessPriority aPri);
       
    88 	void SetCapability(SCapabilitySet& aCapabilities);
       
    89 	void SetFPU(unsigned int aFPU);
       
    90 	static TInt IsE32ImageFile(char *aFileName);
       
    91 	TInt DetermineEntryPointType();
       
    92 	void UpdateHeaderCrc();
       
    93 	void SetDefaultHeader();
       
    94 	void CreateExportBitMap();
       
    95 	void AddExportDescription();
       
    96 	TInt CheckExportDescription();
       
    97 	TInt Validate();
       
    98 public:
       
    99 	inline TUint OrigCodeOffset() const {return OffsetUnadjust(iOrigHdr->iCodeOffset);}
       
   100 	inline TUint OrigDataOffset() const {return OffsetUnadjust(iOrigHdr->iDataOffset);}
       
   101 	inline TUint OrigCodeRelocOffset() const {return OffsetUnadjust(iOrigHdr->iCodeRelocOffset);}
       
   102 	inline TUint OrigDataRelocOffset() const {return OffsetUnadjust(iOrigHdr->iDataRelocOffset);}
       
   103 	inline TUint OrigImportOffset() const {return OffsetUnadjust(iOrigHdr->iImportOffset);}
       
   104 	inline TUint OrigExportDirOffset() const {return OffsetUnadjust(iOrigHdr->iExportDirOffset);}
       
   105 	inline TUint OffsetUnadjust(TUint a) const {return a ? a-iOrigHdrOffsetAdj : 0;}
       
   106 	inline void OffsetAdjust(TUint& a) { if (a) a+=iOrigHdrOffsetAdj; }
       
   107 public:
       
   108 	char* iData;
       
   109 	TInt iSize;
       
   110 	E32ImageHeader* iOrigHdr;
       
   111 	E32ImageHeaderV* iHdr;
       
   112 	char* iFileName;
       
   113 #ifndef __LINUX__
       
   114 	wchar_t* iWideFileName;
       
   115 #endif
       
   116 	TInt iError;
       
   117 	TFileSource iSource;
       
   118 	TUint iOrigHdrOffsetAdj;
       
   119 	TInt iFileSize;
       
   120 	TUint8* iExportBitMap;
       
   121 	TInt iMissingExports;
       
   122 	CBytePair *iBPE;
       
   123 	};
       
   124 
       
   125 #ifdef __VC32__
       
   126 ostream &operator<<(ostream &os, const E32ImageFile &aImage);
       
   127 #else
       
   128 ostream &operator<<(ostream &os, const E32ImageFile &aImage);
       
   129 #endif
       
   130 ifstream &operator>>(ifstream &is, E32ImageFile &aImage);
       
   131 
       
   132 #endif