launcher/engine/inc/e32imageheaders.h
changeset 55 2d9cac8919d3
parent 53 819e59dfc032
child 56 392f7045e621
equal deleted inserted replaced
53:819e59dfc032 55:2d9cac8919d3
     1 /*
       
     2 * Copyright (c) 2010 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 "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 __LAUNCHERE32IMAGEHEADERS_H__
       
    20 #define __LAUNCHERE32IMAGEHEADERS_H__
       
    21 
       
    22 #include <e32uid.h>
       
    23 
       
    24 // from e32Huffman.h
       
    25 
       
    26 /** @file
       
    27     @internalTechnology
       
    28 */
       
    29 
       
    30 /** Bit output stream.
       
    31     Good for writing bit streams for packed, compressed or huffman data algorithms.
       
    32 
       
    33     This class must be derived from and OverflowL() reimplemented if the bitstream data
       
    34     cannot be generated into a single memory buffer.
       
    35 */
       
    36 class TBitOutput
       
    37     {
       
    38 public:
       
    39     IMPORT_C TBitOutput();
       
    40     IMPORT_C TBitOutput(TUint8* aBuf,TInt aSize);
       
    41     inline void Set(TUint8* aBuf,TInt aSize);
       
    42     inline const TUint8* Ptr() const;
       
    43     inline TInt BufferedBits() const;
       
    44 //
       
    45     IMPORT_C void WriteL(TUint aValue, TInt aLength);
       
    46     IMPORT_C void HuffmanL(TUint aHuffCode);
       
    47     IMPORT_C void PadL(TUint aPadding);
       
    48 private:
       
    49     void DoWriteL(TUint aBits, TInt aSize);
       
    50     virtual void OverflowL();
       
    51 private:
       
    52     TUint iCode;        // code in production
       
    53     TInt iBits;
       
    54     TUint8* iPtr;
       
    55     TUint8* iEnd;
       
    56     };
       
    57 
       
    58 /** Set the memory buffer to use for output
       
    59 
       
    60     Data will be written to this buffer until it is full, at which point OverflowL() will
       
    61     be called. This should handle the data and then can Set() again to reset the buffer
       
    62     for further output.
       
    63     
       
    64     @param aBuf The buffer for output
       
    65     @param aSize The size of the buffer in bytes
       
    66 */
       
    67 inline void TBitOutput::Set(TUint8* aBuf,TInt aSize)
       
    68     {iPtr=aBuf;iEnd=aBuf+aSize;}
       
    69     
       
    70 /** Get the current write position in the output buffer
       
    71 
       
    72     In conjunction with the address of the buffer, which should be known to the
       
    73     caller, this describes the data in the bitstream.
       
    74 */
       
    75 inline const TUint8* TBitOutput::Ptr() const
       
    76     {return iPtr;}
       
    77     
       
    78 /** Get the number of bits that are buffered
       
    79 
       
    80     This reports the number of bits that have not yet been written into the
       
    81     output buffer. It will always lie in the range 0..7. Use PadL() to
       
    82     pad the data out to the next byte and write it to the buffer.
       
    83 */
       
    84 inline TInt TBitOutput::BufferedBits() const
       
    85     {return iBits+8;}
       
    86 
       
    87 /** Bit input stream. Good for reading bit streams for packed, compressed or huffman
       
    88     data algorithms.
       
    89 */
       
    90 class TBitInput
       
    91     {
       
    92 public:
       
    93     IMPORT_C TBitInput();
       
    94     IMPORT_C TBitInput(const TUint8* aPtr, TInt aLength, TInt aOffset=0);
       
    95     IMPORT_C void Set(const TUint8* aPtr, TInt aLength, TInt aOffset=0);
       
    96 //
       
    97     IMPORT_C TUint ReadL();
       
    98     IMPORT_C TUint ReadL(TInt aSize);
       
    99     IMPORT_C TUint HuffmanL(const TUint32* aTree);
       
   100 private:
       
   101     virtual void UnderflowL();
       
   102 private:
       
   103     TInt iCount;
       
   104     TUint iBits;
       
   105     TInt iRemain;
       
   106     const TUint32* iPtr;
       
   107     };
       
   108 
       
   109 
       
   110 /** Huffman code toolkit.
       
   111 
       
   112     This class builds a huffman encoding from a frequency table and builds
       
   113     a decoding tree from a code-lengths table
       
   114 
       
   115     The encoding generated is based on the rule that given two symbols s1 and s2, with 
       
   116     code length l1 and l2, and huffman codes h1 and h2:
       
   117 
       
   118         if l1<l2 then h1<h2 when compared lexicographically
       
   119         if l1==l2 and s1<s2 then h1<h2 ditto
       
   120 
       
   121     This allows the encoding to be stored compactly as a table of code lengths
       
   122 */
       
   123 class Huffman
       
   124     {
       
   125 public:
       
   126     enum {KMaxCodeLength=27};
       
   127     enum {KMetaCodes=KMaxCodeLength+1};
       
   128     enum {KMaxCodes=0x8000};
       
   129 public:
       
   130     IMPORT_C static void HuffmanL(const TUint32 aFrequency[],TInt aNumCodes,TUint32 aHuffman[]);
       
   131     IMPORT_C static void Encoding(const TUint32 aHuffman[],TInt aNumCodes,TUint32 aEncodeTable[]);
       
   132     IMPORT_C static void Decoding(const TUint32 aHuffman[],TInt aNumCodes,TUint32 aDecodeTree[],TInt aSymbolBase=0);
       
   133     IMPORT_C static TBool IsValid(const TUint32 aHuffman[],TInt aNumCodes);
       
   134 //
       
   135     IMPORT_C static void ExternalizeL(TBitOutput& aOutput,const TUint32 aHuffman[],TInt aNumCodes);
       
   136     IMPORT_C static void InternalizeL(TBitInput& aInput,TUint32 aHuffman[],TInt aNumCodes);
       
   137     };
       
   138 
       
   139 // end e32Huffman.h
       
   140 
       
   141 enum TCpu
       
   142 	{
       
   143 	ECpuUnknown=0, ECpuX86=0x1000, ECpuArmV4=0x2000, ECpuArmV5=0x2001, ECpuArmV6=0x2002, ECpuMCore=0x4000
       
   144 	};
       
   145 	
       
   146 const TInt KOrdinalBase=1;
       
   147 const TUint KImageDll				= 0x00000001u;
       
   148 const TUint KImageNoCallEntryPoint	= 0x00000002u;
       
   149 const TUint KImageFixedAddressExe	= 0x00000004u;
       
   150 const TUint KImageOldJFlag			= 0x00000008u;	// so we can run binaries built with pre 2.00 tools (hdrfmt=0)
       
   151 const TUint KImageOldElfFlag		= 0x00000010u;	// so we can run binaries built with pre 2.00 tools (hdrfmt=0)
       
   152 const TUint KImageABIMask			= 0x00000018u;	// only if hdr fmt not zero
       
   153 const TInt	KImageABIShift			= 3;
       
   154 const TUint	KImageABI_GCC98r2		= 0x00000000u;	// for ARM
       
   155 const TUint	KImageABI_EABI			= 0x00000008u;	// for ARM
       
   156 const TUint KImageEptMask			= 0x000000e0u;	// entry point type
       
   157 const TInt	KImageEptShift			= 5;
       
   158 const TUint KImageEpt_Eka1			= 0x00000000u;
       
   159 const TUint KImageEpt_Eka2			= 0x00000020u;
       
   160 const TUint KImageHdrFmtMask		= 0x0f000000u;
       
   161 const TInt	KImageHdrFmtShift		= 24;
       
   162 const TUint KImageHdrFmt_Original	= 0x00000000u;	// without compression support
       
   163 const TUint KImageHdrFmt_J			= 0x01000000u;	// with compression support
       
   164 const TUint KImageHdrFmt_V			= 0x02000000u;	// with versioning support
       
   165 const TUint KImageImpFmtMask		= 0xf0000000u;
       
   166 const TInt	KImageImpFmtShift		= 28;
       
   167 const TUint KImageImpFmt_PE			= 0x00000000u;	// PE-derived imports
       
   168 const TUint KImageImpFmt_ELF		= 0x10000000u;	// ELF-derived imports
       
   169 const TUint KImageImpFmt_PE2		= 0x20000000u;	// PE-derived imports without redundant copy of import ordinals
       
   170 const TUint KImageHWFloatMask		= 0x00f00000u;
       
   171 const TInt	KImageHWFloatShift		= 20;
       
   172 const TUint	KImageHWFloat_None		= EFpTypeNone << KImageHWFloatShift; // No hardware floating point used
       
   173 const TUint KImageHWFloat_VFPv2		= EFpTypeVFPv2 << KImageHWFloatShift; // ARM VFPv2 floating point used
       
   174 
       
   175 const TUint KMyFormatNotCompressed=0;
       
   176 const TUint KMyUidCompressionDeflate=0x101F7AFC;
       
   177 
       
   178 const TUint32 KImageCrcInitialiser	= 0xc90fdaa2u;
       
   179 /*
       
   180 const TUint16 KReservedRelocType        = (TUint16)0x0000;
       
   181 const TUint16 KTextRelocType            = (TUint16)0x1000;
       
   182 const TUint16 KDataRelocType            = (TUint16)0x2000;
       
   183 const TUint16 KInferredRelocType        = (TUint16)0x3000;
       
   184 */
       
   185 class RFile;
       
   186 class E32ImageHeader
       
   187 	{
       
   188 public:
       
   189 	inline static TUint ABIFromFlags(TUint aFlags)
       
   190 		{
       
   191 		if (aFlags&KImageHdrFmtMask)
       
   192 			return aFlags & KImageABIMask;
       
   193 		if (aFlags&KImageOldElfFlag)
       
   194 			return KImageABI_EABI;
       
   195 		return KImageABI_GCC98r2;
       
   196 		}
       
   197 	inline static TUint EptFromFlags(TUint aFlags)
       
   198 		{
       
   199 		if (aFlags&KImageHdrFmtMask)
       
   200 			return aFlags & KImageEptMask;
       
   201 		if (aFlags&KImageOldJFlag)
       
   202 			return KImageEpt_Eka2;
       
   203 		return KImageEpt_Eka1;
       
   204 		}
       
   205 	inline static TUint HdrFmtFromFlags(TUint aFlags)
       
   206 		{
       
   207 		if (aFlags&KImageHdrFmtMask)
       
   208 			return aFlags & KImageHdrFmtMask;
       
   209 		if (aFlags&KImageOldJFlag)
       
   210 			return KImageHdrFmt_J;
       
   211 		return KImageHdrFmt_Original;
       
   212 		}
       
   213 	inline static TUint ImpFmtFromFlags(TUint aFlags)
       
   214 		{
       
   215 		if (aFlags&KImageHdrFmtMask)
       
   216 			return aFlags & KImageImpFmtMask;
       
   217 		if (aFlags&KImageOldElfFlag)
       
   218 			return KImageImpFmt_ELF;
       
   219 		return KImageImpFmt_PE;
       
   220 		}
       
   221 	inline TUint32 CompressionType() const
       
   222 		{
       
   223 		if (HdrFmtFromFlags(iFlags) >= KImageHdrFmt_J)
       
   224 			return iCompressionType;
       
   225 		return 0;
       
   226 		}
       
   227 	inline TUint32 ModuleVersion() const
       
   228 		{
       
   229 		if ((iFlags & KImageHdrFmtMask) >= KImageHdrFmt_V)
       
   230 			return iModuleVersion;
       
   231 		return 0x00000000u;
       
   232 		}
       
   233 	inline TInt TotalSize() const;
       
   234 	inline TInt UncompressedFileSize() const;
       
   235 	inline TUint HeaderFormat() const
       
   236 		{ return HdrFmtFromFlags(iFlags); }
       
   237 	inline TUint EntryPointFormat() const
       
   238 		{ return EptFromFlags(iFlags); }
       
   239 	inline TUint ImportFormat() const
       
   240 		{ return ImpFmtFromFlags(iFlags); }
       
   241 	inline TUint ABI() const
       
   242 		{ return ABIFromFlags(iFlags); }
       
   243 	inline void GetSecurityInfo(SSecurityInfo& aInfo) const;
       
   244 	inline TCpu CpuIdentifier() const;
       
   245 	inline TProcessPriority ProcessPriority() const;
       
   246 	inline TUint32 ExceptionDescriptor() const;
       
   247 	TInt IntegrityCheck(TInt aFileSize);
       
   248 	static TInt New(E32ImageHeader*& aHdr, RFile& aFile);
       
   249 public:
       
   250 	TUint32	iUid1;
       
   251 	TUint32	iUid2;
       
   252 	TUint32	iUid3;
       
   253 	TUint32 iUidChecksum;
       
   254 	TUint iSignature;			// 'EPOC'
       
   255 	TUint32	iHeaderCrc;			// CRC-32 of entire header
       
   256 	TUint32 iModuleVersion;		// Version number for this executable (used in link resolution)
       
   257 	TUint32 iCompressionType;	// Type of compression used (UID or 0 for none)
       
   258 	TVersion iToolsVersion;		// Version of PETRAN/ELFTRAN which generated this file
       
   259 	TUint32 iTimeLo;
       
   260 	TUint32 iTimeHi;
       
   261 	TUint iFlags;				// 0 = exe, 1 = dll, 2 = fixed address exe
       
   262 	TInt iCodeSize;				// size of code, import address table, constant data and export dir
       
   263 	TInt iDataSize;				// size of initialised data
       
   264 	TInt iHeapSizeMin;
       
   265 	TInt iHeapSizeMax;
       
   266 	TInt iStackSize;
       
   267 	TInt iBssSize;
       
   268 	TUint iEntryPoint;			// offset into code of entry point
       
   269 	TUint iCodeBase;			// where the code is linked for	
       
   270 	TUint iDataBase;			// where the data is linked for
       
   271 	TInt iDllRefTableCount;		// filling this in enables E32ROM to leave space for it
       
   272 	TUint iExportDirOffset;		// offset into the file of the export address table
       
   273 	TInt iExportDirCount;
       
   274 	TInt iTextSize;				// size of just the text section, also doubles as the offset for the iat w.r.t. the code section
       
   275 	TUint iCodeOffset;			// file offset to code section, also doubles as header size
       
   276 	TUint iDataOffset;			// file offset to data section
       
   277 	TUint iImportOffset;		// file offset to import section
       
   278 	TUint iCodeRelocOffset;		// relocations for code and const
       
   279 	TUint iDataRelocOffset;		// relocations for data
       
   280 	TUint16 iProcessPriority;	// executables priority
       
   281 	TUint16 iCpuIdentifier;		// 0x1000 = X86, 0x2000 = ARM
       
   282 	};
       
   283 
       
   284 class E32ImageHeaderComp : public E32ImageHeader
       
   285 	{
       
   286 public:
       
   287 	TUint32 iUncompressedSize;	// Uncompressed size of file
       
   288 								// For J format this is file size - sizeof(E32ImageHeader)
       
   289 								//  and this is included as part of the compressed data :-(
       
   290 								// For other formats this is file size - total header size
       
   291 	};
       
   292 
       
   293 class E32ImageHeaderV : public E32ImageHeaderComp
       
   294 	{
       
   295 public:
       
   296 	SSecurityInfo iS;
       
   297 
       
   298 	// Use iSpare1 as offset to Exception Descriptor
       
   299 	TUint32 iExceptionDescriptor;   // Offset in bytes from start of code section to Exception Descriptor, bit 0 set if valid
       
   300 	TUint32 iSpare2;
       
   301 	TUint16	iExportDescSize;	// size of bitmap section
       
   302 	TUint8	iExportDescType;	// type of description of holes in export table
       
   303 	TUint8	iExportDesc[1];		// description of holes in export table - extend
       
   304 	};
       
   305 
       
   306 // export description type
       
   307 const TUint	KImageHdr_ExpD_NoHoles			=0x00;	// no holes, all exports present
       
   308 const TUint	KImageHdr_ExpD_FullBitmap		=0x01;	// full bitmap present
       
   309 const TUint	KImageHdr_ExpD_SparseBitmap8	=0x02;	// sparse bitmap present, granularity 8
       
   310 const TUint	KImageHdr_ExpD_Xip				=0xff;	// XIP file
       
   311 
       
   312 
       
   313 inline TInt E32ImageHeader::TotalSize() const
       
   314 	{
       
   315 	if (HeaderFormat() == KImageHdrFmt_J && iCompressionType != 0)
       
   316 		return sizeof(E32ImageHeaderComp);
       
   317 	return iCodeOffset;
       
   318 	}
       
   319 
       
   320 inline TInt E32ImageHeader::UncompressedFileSize() const
       
   321 	{
       
   322 	TUint hdrfmt = HeaderFormat();
       
   323 	if (hdrfmt == KImageHdrFmt_Original || iCompressionType == 0)
       
   324 		return -1;			// not compressed
       
   325 	else if (hdrfmt == KImageHdrFmt_J)
       
   326 		return ((E32ImageHeaderComp*)this)->iUncompressedSize + sizeof(E32ImageHeader);
       
   327 	else
       
   328 		return ((E32ImageHeaderComp*)this)->iUncompressedSize + iCodeOffset;
       
   329 	}
       
   330 
       
   331 extern const SSecurityInfo KDefaultSecurityInfo;
       
   332 inline void E32ImageHeader::GetSecurityInfo(SSecurityInfo& aInfo) const
       
   333 	{
       
   334 	if (HeaderFormat() >= KImageHdrFmt_V)
       
   335 		aInfo = ((E32ImageHeaderV*)this)->iS;
       
   336 	else
       
   337 		aInfo = KDefaultSecurityInfo;
       
   338 	}
       
   339 
       
   340 inline TCpu E32ImageHeader::CpuIdentifier() const
       
   341 	{
       
   342 	if (HeaderFormat() >= KImageHdrFmt_V)
       
   343 		return (TCpu)iCpuIdentifier;
       
   344 	return (TCpu)iHeaderCrc;
       
   345 	}
       
   346 
       
   347 inline TProcessPriority E32ImageHeader::ProcessPriority() const
       
   348 	{
       
   349 	if (HeaderFormat() >= KImageHdrFmt_V)
       
   350 		return (TProcessPriority)iProcessPriority;
       
   351 	return *(const TProcessPriority*)&iProcessPriority;
       
   352 	}
       
   353 
       
   354 inline TUint32 E32ImageHeader::ExceptionDescriptor() const
       
   355 	{
       
   356 	if (HeaderFormat() >= KImageHdrFmt_V)
       
   357 		{
       
   358 		TUint32 xd = ((E32ImageHeaderV*)this)->iExceptionDescriptor;
       
   359 		if ((xd & 1) && (xd != 0xffffffffu))
       
   360 			return (xd & ~1);
       
   361 		}
       
   362 	return 0;
       
   363 	}
       
   364 
       
   365 class E32ImportBlock
       
   366 	{
       
   367 public:
       
   368 	inline const E32ImportBlock* NextBlock(TUint aImpFmt) const;
       
   369 	inline TInt Size(TUint aImpFmt) const;
       
   370 	inline const TUint* Imports() const;	// import list if present
       
   371 public:
       
   372 	TUint32	iOffsetOfDllName;	// offset of name of dll importing from
       
   373 	TInt	iNumberOfImports;	// no of imports from this dll
       
   374 //	TUint	iImport[iNumberOfImports];	// list of imported ordinals, omitted in PE2 import format
       
   375 	};
       
   376 
       
   377 inline TInt E32ImportBlock::Size(TUint aImpFmt) const
       
   378 	{
       
   379 	TInt r = sizeof(E32ImportBlock);
       
   380 	if (aImpFmt!=KImageImpFmt_PE2)
       
   381 		r += iNumberOfImports * sizeof(TUint);
       
   382 	return r;
       
   383 	}
       
   384 
       
   385 inline const E32ImportBlock* E32ImportBlock::NextBlock(TUint aImpFmt) const
       
   386 	{
       
   387 	const E32ImportBlock* next = this + 1;
       
   388 	if (aImpFmt!=KImageImpFmt_PE2)
       
   389 		next = (const E32ImportBlock*)( (TUint8*)next + iNumberOfImports * sizeof(TUint) );
       
   390 	return next;
       
   391 	}
       
   392 
       
   393 inline const TUint* E32ImportBlock::Imports() const
       
   394 	{
       
   395 	return (const TUint*)(this + 1);
       
   396 	}
       
   397 
       
   398 class E32ImportSection
       
   399 	{
       
   400 public:
       
   401 	TInt iSize;					// size of this section
       
   402 //	E32ImportBlock[iDllRefTableCount];
       
   403 	};
       
   404 
       
   405 class E32RelocSection
       
   406 	{
       
   407 public:
       
   408 	TInt iSize;					// size of this relocation section
       
   409 	TInt iNumberOfRelocs;		// number of relocations in this section
       
   410 	};
       
   411 
       
   412 
       
   413 typedef TUint8* (*TMemoryMoveFunction)(TAny* aTrg,const TAny* aSrc,TInt aLength);
       
   414 
       
   415 const TInt KDeflateLengthMag=8;
       
   416 const TInt KDeflateDistanceMag=12;
       
   417 const TInt KDeflateMinLength=3;
       
   418 const TInt KDeflateMaxLength=KDeflateMinLength-1 + (1<<KDeflateLengthMag);
       
   419 const TInt KDeflateMaxDistance=(1<<KDeflateDistanceMag);
       
   420 const TInt KDeflateDistCodeBase=0x200;
       
   421 const TUint KDeflateHashMultiplier=0xAC4B9B19u;
       
   422 const TInt KDeflateHashShift=24;
       
   423 const TInt KInflateWindowSize=0x8000;
       
   424 
       
   425 
       
   426 class TEncoding
       
   427 	{
       
   428 public:
       
   429 	enum {ELiterals=256,ELengths=(KDeflateLengthMag-1)*4,ESpecials=1,EDistances=(KDeflateDistanceMag-1)*4};
       
   430 	enum {ELitLens=ELiterals+ELengths+ESpecials};
       
   431 	enum {EEos=ELiterals+ELengths};
       
   432 public:
       
   433 	TUint32 iLitLen[ELitLens];
       
   434 	TUint32 iDistance[EDistances];
       
   435 	};
       
   436 
       
   437 const TInt KDeflationCodes=TEncoding::ELitLens+TEncoding::EDistances;
       
   438 
       
   439 NONSHARABLE_CLASS(CInflater) : public CBase
       
   440 	{
       
   441 public:
       
   442 	enum {EBufSize = 0x800, ESafetyZone=8};
       
   443 public:
       
   444 	static CInflater* NewLC(TBitInput& aInput);
       
   445 	~CInflater();
       
   446 	TInt ReadL(TUint8* aBuffer,TInt aLength, TMemoryMoveFunction aMemMovefn);
       
   447 	TInt SkipL(TInt aLength);
       
   448 private:
       
   449 	CInflater(TBitInput& aInput);
       
   450 	void ConstructL();
       
   451 	void InitL();
       
   452 	TInt InflateL();
       
   453 private:
       
   454 	TBitInput* iBits;
       
   455 	const TUint8* iRptr;			
       
   456 	TInt iLen;
       
   457 	const TUint8* iAvail;		
       
   458 	const TUint8* iLimit;
       
   459 	TEncoding* iEncoding;
       
   460 	TUint8* iOut;				
       
   461 	};
       
   462 
       
   463 void DeflateL(const TUint8* aBuf, TInt aLength, TBitOutput& aOutput);
       
   464 
       
   465 	
       
   466 NONSHARABLE_CLASS(TFileInput) : public TBitInput
       
   467 	{
       
   468  	enum {KBufSize=KInflateWindowSize};
       
   469 public:
       
   470 	TFileInput(RFile& aFile);
       
   471 	void Cancel();
       
   472 private:
       
   473 	void UnderflowL();
       
   474 private:
       
   475 	RFile& iFile;
       
   476 	TRequestStatus iStat;
       
   477 	TUint8* iReadBuf;
       
   478 	TPtr8 iPtr;
       
   479 	TUint8 iBuf1[KBufSize];
       
   480 	TUint8 iBuf2[KBufSize];
       
   481 	};
       
   482 
       
   483 class TFileNameInfo
       
   484 	{
       
   485 public:
       
   486 	enum
       
   487     	{
       
   488     	EIncludeDrive=1,
       
   489     	EIncludePath=2,
       
   490     	EIncludeBase=4,
       
   491     	EIncludeVer=8,
       
   492     	EForceVer=16,
       
   493     	EIncludeUid=32,
       
   494     	EForceUid=64,
       
   495     	EIncludeExt=128,
       
   496     	EIncludeDrivePath=EIncludeDrive|EIncludePath,
       
   497     	EIncludeBaseExt=EIncludeBase|EIncludeExt,
       
   498     	EIncludeDrivePathBaseExt=EIncludeDrive|EIncludePath|EIncludeBase|EIncludeExt,
       
   499     	};
       
   500 	enum
       
   501 		{
       
   502 		EAllowUid=1,
       
   503 		EAllowPlaceholder=2,
       
   504 		EAllowDecimalVersion=4,
       
   505 		};
       
   506 public:
       
   507 	TFileNameInfo();
       
   508 	TInt Set(const TDesC8& aFileName, TUint aFlags);
       
   509 	void Dump() const;
       
   510 public:
       
   511 	inline TInt DriveLen() const {return iPathPos;}
       
   512 	inline TInt PathLen() const {return iBasePos-iPathPos;}
       
   513 	inline TInt BaseLen() const {return iVerPos-iBasePos;}
       
   514 	inline TInt VerLen() const {return iUidPos-iVerPos;}
       
   515 	inline TInt UidLen() const {return iExtPos-iUidPos;}
       
   516 	inline TInt ExtLen() const {return iLen-iExtPos;}
       
   517 	inline TPtrC8 Drive() const {return TPtrC8(iName, iPathPos);}
       
   518 	inline TPtrC8 Path() const {return TPtrC8(iName+iPathPos, iBasePos-iPathPos);}
       
   519 	inline TPtrC8 DriveAndPath() const {return TPtrC8(iName, iBasePos);}
       
   520 	inline TPtrC8 Base() const {return TPtrC8(iName+iBasePos, iVerPos-iBasePos);}
       
   521 	inline TPtrC8 VerStr() const {return TPtrC8(iName+iVerPos, iUidPos-iVerPos);}
       
   522 	inline TPtrC8 UidStr() const {return TPtrC8(iName+iUidPos, iExtPos-iUidPos);}
       
   523 	inline TPtrC8 Ext() const {return TPtrC8(iName+iExtPos, iLen-iExtPos);}
       
   524 	inline TUint32 Version() const {return iVersion;}
       
   525 	inline TUint32 Uid() const {return iUid;}
       
   526 	void GetName(TDes8& aName, TUint aFlags) const;
       
   527 public:
       
   528 	const TText8* iName;
       
   529 	TInt iPathPos;
       
   530 	TInt iBasePos;
       
   531 	TInt iVerPos;
       
   532 	TInt iUidPos;
       
   533 	TInt iExtPos;
       
   534 	TInt iLen;
       
   535 	TUint32 iVersion;
       
   536 	TUint32 iUid;
       
   537 	};
       
   538 
       
   539 
       
   540 #endif // __LAUNCHERE32IMAGEHEADERS_H__