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