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