|
1 // chkdeps.h |
|
2 // |
|
3 // Copyright (c) 2010 Accenture. All rights reserved. |
|
4 // This component and the accompanying materials are made available |
|
5 // under the terms of the "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 // Accenture - Initial contribution |
|
11 // |
|
12 |
|
13 #define __INCLUDE_CAPABILITY_NAMES__ |
|
14 #include <fshell/ioutils.h> |
|
15 #include <f32image.h> |
|
16 #include "sf_deflate.h" |
|
17 #include <e32rom.h> |
|
18 #include "sf_pgcompr.h" |
|
19 |
|
20 using namespace IoUtils; |
|
21 |
|
22 class CDllChecker : public CCommandBase |
|
23 { |
|
24 public: |
|
25 static CCommandBase* NewLC(); |
|
26 private: // From CCommandBase. |
|
27 virtual const TDesC& Name() const; |
|
28 virtual void DoRunL(); |
|
29 virtual void ArgumentsL(RCommandArgumentList& aArguments); |
|
30 virtual void OptionsL(RCommandOptionList& aOptions); |
|
31 |
|
32 // From ts_std.h |
|
33 private: |
|
34 enum TResultCheck {EPending,EAlreadyOpen,ECouldNotOpenFile,ENotFound,EUidNotSupported,ENoImportData,EUidDifference,EFileFoundAndUidSupported, /*BEGIN TOMSCI added*/ ERequiredCapabilitiesMissing, EOrdinalMissing, EVersionMismatch }; |
|
35 class CDllInfo : public CBase |
|
36 { |
|
37 public: |
|
38 TBuf<KMaxFileName> iDllName; |
|
39 TUid iUid; |
|
40 TResultCheck iResult; |
|
41 TCapabilitySet iDllCaps; |
|
42 TInt iNumExports; |
|
43 TInt16 iMajorVersion; |
|
44 TInt16 iMinorVersion; |
|
45 }; |
|
46 |
|
47 RPointerArray<CDllInfo> iDllArray; // Array of Imports already checked |
|
48 TInt iCalls; // Number of recursive calls of GetImportDataL() |
|
49 |
|
50 RFile iFile;//file object for reading data from phisical file |
|
51 TUint32 iConversionOffset; |
|
52 TAny* iStackBase; // Used in debug only to check stack depth |
|
53 private: |
|
54 void GetFileNameAndUid(CDllInfo &aDllInfo, const TDesC8 &aExportName); |
|
55 TInt FindDll(TDes& aDllName,TFileName& aFileName, const TDesC& aPath); |
|
56 TUint8* NextBlock(TUint8* aBlock); |
|
57 |
|
58 void LoadFileInflateL(const E32ImageHeaderComp* aHeader, RBuf8& aCode, RBuf8& aRestOfFile); |
|
59 void LoadFileNoCompressL(const E32ImageHeaderComp* aHeader, RBuf8& aCode, RBuf8& aRestOfFile); |
|
60 void LoadFileBytePairL(const E32ImageHeaderComp* aHeader, RBuf8& aCode, RBuf8& aRestOfFile); |
|
61 |
|
62 TInt CheckUid3(TInt32 aUid3,TUid aUid); |
|
63 void LoadFileL(const E32ImageHeaderComp* aHeader, RBuf8& aCode, RBuf8& aRestOfFile); |
|
64 //void GetDllTableL(TUint8* aImportData,TInt aDllRefTableCount,TUint aFlags); |
|
65 //void GetDllTableL(const TDesC& aFileName, E32ImageHeader* aImageHeader, TUint8* aRestOfFile); |
|
66 void GetDllTableL(const TDesC& aFileName, const E32ImageHeader* aImageHeader, const TUint8* aCode, const TUint8* aImportData); |
|
67 public: |
|
68 CDllChecker(); |
|
69 ~CDllChecker(); |
|
70 void ConstructL(); |
|
71 void GetImportDataL(const TDesC& aFileName, CDllInfo& aInfo); |
|
72 void ListArray(); |
|
73 static TInt CompareDllInfo(const CDllInfo& aDllInfo1, const CDllInfo& aDllInfo2); |
|
74 private: |
|
75 TBool iVerbose, iDebug; |
|
76 TFileName2 iFilename; |
|
77 CDllInfo* iExeInfo; // Argh I've painted myself into an API corner here... cue quick-and-dirty hack. iRequiredCaps has to point into a CDllInfo::iDllCaps because of refactoring I made without thinking it through. Therefore jump through a few hoops to ensure this is so, to save redoing the code that assumes it. V lazy! |
|
78 TCapabilitySet* iRequiredCaps; // Only relevant if we're checking an exe |
|
79 }; |
|
80 |
|
81 |
|
82 |
|
83 // Nicked from sf_image.h |
|
84 |
|
85 class TFileNameInfo |
|
86 { |
|
87 public: |
|
88 enum { |
|
89 EIncludeDrive=1, |
|
90 EIncludePath=2, |
|
91 EIncludeBase=4, |
|
92 EIncludeVer=8, |
|
93 EForceVer=16, |
|
94 EIncludeUid=32, |
|
95 EForceUid=64, |
|
96 EIncludeExt=128, |
|
97 EIncludeDrivePath=EIncludeDrive|EIncludePath, |
|
98 EIncludeBaseExt=EIncludeBase|EIncludeExt, |
|
99 EIncludeDrivePathBaseExt=EIncludeDrive|EIncludePath|EIncludeBase|EIncludeExt, |
|
100 }; |
|
101 enum { |
|
102 EAllowUid=1, |
|
103 EAllowPlaceholder=2, |
|
104 EAllowDecimalVersion=4, |
|
105 }; |
|
106 public: |
|
107 TFileNameInfo(); |
|
108 TInt Set(const TDesC8& aFileName, TUint aFlags); |
|
109 void Dump() const; |
|
110 public: |
|
111 inline TInt DriveLen() const {return iPathPos;} |
|
112 inline TInt PathLen() const {return iBasePos-iPathPos;} |
|
113 inline TInt BaseLen() const {return iVerPos-iBasePos;} |
|
114 inline TInt VerLen() const {return iUidPos-iVerPos;} |
|
115 inline TInt UidLen() const {return iExtPos-iUidPos;} |
|
116 inline TInt ExtLen() const {return iLen-iExtPos;} |
|
117 inline TPtrC8 Drive() const {return TPtrC8(iName, iPathPos);} |
|
118 inline TPtrC8 Path() const {return TPtrC8(iName+iPathPos, iBasePos-iPathPos);} |
|
119 inline TPtrC8 DriveAndPath() const {return TPtrC8(iName, iBasePos);} |
|
120 inline TPtrC8 Base() const {return TPtrC8(iName+iBasePos, iVerPos-iBasePos);} |
|
121 inline TPtrC8 VerStr() const {return TPtrC8(iName+iVerPos, iUidPos-iVerPos);} |
|
122 inline TPtrC8 UidStr() const {return TPtrC8(iName+iUidPos, iExtPos-iUidPos);} |
|
123 inline TPtrC8 Ext() const {return TPtrC8(iName+iExtPos, iLen-iExtPos);} |
|
124 inline TUint32 Version() const {return iVersion;} |
|
125 inline TUint32 Uid() const {return iUid;} |
|
126 void GetName(TDes8& aName, TUint aFlags) const; |
|
127 public: |
|
128 const TText8* iName; |
|
129 TInt iPathPos; |
|
130 TInt iBasePos; |
|
131 TInt iVerPos; |
|
132 TInt iUidPos; |
|
133 TInt iExtPos; |
|
134 TInt iLen; |
|
135 TUint32 iVersion; |
|
136 TUint32 iUid; |
|
137 }; |