1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/f32test/loader/security/t_ldrtst.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,169 @@
1.4 +// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// f32test\loader\t_ldrtst.h
1.18 +//
1.19 +//
1.20 +
1.21 +#ifndef __T_LDRTST_H__
1.22 +#define __T_LDRTST_H__
1.23 +
1.24 +#define __INCLUDE_DEPENDENCY_GRAPH
1.25 +
1.26 +#include <e32svr.h>
1.27 +#include <e32test.h>
1.28 +#include "dlltree.h"
1.29 +#include "dllt.h"
1.30 +#include "exetifc.h"
1.31 +#include <d_ldrtst.h>
1.32 +#include <f32file.h>
1.33 +#include <f32dbg.h>
1.34 +#include <e32rom.h>
1.35 +
1.36 +GLREF_D RTest test;
1.37 +
1.38 +class TModuleList;
1.39 +class TModuleSet
1.40 + {
1.41 +public:
1.42 + TModuleSet();
1.43 + TModuleSet(const TModuleList&, TInt aMask, TInt aVal);
1.44 + void Add(TInt aModule);
1.45 + void Remove(TInt aModule);
1.46 + void Remove(const TModuleList&);
1.47 + void Display(const TDesC& aTitle) const;
1.48 + inline TBool Present(TInt aModule) const
1.49 + { return iBitMap[aModule>>3]&(1<<(aModule&7)); }
1.50 +public:
1.51 + TInt iCount;
1.52 + TUint8 iBitMap[(KNumModules+7)/8];
1.53 + };
1.54 +
1.55 +class TModuleList
1.56 + {
1.57 +public:
1.58 + TModuleList();
1.59 + void SetCount();
1.60 + void Display(const TDesC& aTitle) const;
1.61 + TBool IsPresent(TInt aModNum) const;
1.62 + TInt Find(TInt aModNum) const;
1.63 + void Add(const SDllInfo& a);
1.64 +public:
1.65 + TInt iCount;
1.66 + SDllInfo iInfo[KNumModules];
1.67 + };
1.68 +
1.69 +class LoaderTest
1.70 + {
1.71 +public:
1.72 + static LoaderTest* New();
1.73 + void Close();
1.74 + void Init();
1.75 +public:
1.76 + void TestOneByOne();
1.77 + void TestMultipleExeInstances();
1.78 + void TestOOM();
1.79 + void TestMultipleLoads();
1.80 +private:
1.81 + TBool IsRomAddress(TLinAddr a);
1.82 + TBool IsRamCodeAddress(TLinAddr a);
1.83 + TBool CheckDataAddress(TLinAddr a, TInt aDllNum, TInt aExeNum);
1.84 + TInt DetermineDllLoadResult(TInt aDllNum, TInt aExeNum);
1.85 + TInt DetermineDllLoadResult(TInt aDllNum, TInt aExeNum1, TInt aExeNum2);
1.86 + TInt DetermineLoadExe2Result(TInt aExeNum);
1.87 + void DumpModuleList(const TModuleList& aList, TInt aExeNum);
1.88 + void DumpModuleInfo(const SDllInfo& aInfo, TInt aExeNum);
1.89 + void CheckModuleList(TInt aRoot, const TModuleList& aList);
1.90 +public:
1.91 + void TraceOn();
1.92 + void TraceOff();
1.93 +private:
1.94 + LoaderTest();
1.95 + ~LoaderTest();
1.96 +public:
1.97 + RFs iFs;
1.98 + RLdrTest iDev;
1.99 + TUint32 iMemModelAtt;
1.100 + TInt iCmdLine[8];
1.101 + };
1.102 +
1.103 +
1.104 +const TInt KMaxHandlesPerDll=4;
1.105 +const TInt KMaxHandles=KMaxHandlesPerDll*KNumModules;
1.106 +
1.107 +struct SModuleInstance
1.108 + {
1.109 + TInt iAccessCount;
1.110 + TInt iModNum;
1.111 + TLinAddr iEntryPointAddress;
1.112 + TModuleHandle iModuleHandle;
1.113 + TLinAddr iData;
1.114 + TAny* iCodeSeg;
1.115 + };
1.116 +
1.117 +class CGlobalModuleList;
1.118 +class CPerProcessInfo : public CBase
1.119 + {
1.120 +public:
1.121 + static CPerProcessInfo* New(TInt aExeNum, CGlobalModuleList& aG);
1.122 + virtual ~CPerProcessInfo();
1.123 + void GetModuleSet(TModuleSet& aSet);
1.124 + void Check();
1.125 + void Unlink(const SDllInfo& a, TModuleList& aList);
1.126 + TInt Load(TInt aDllNum);
1.127 + TInt AddModules(TInt aDllNum, TModuleList* aCList, TModuleList* aIList);
1.128 + TInt CloseHandle(TInt aHandle);
1.129 +private:
1.130 + CPerProcessInfo();
1.131 + TInt Init();
1.132 +public:
1.133 + TInt iExeNum;
1.134 + TRequestStatus iStatus;
1.135 + RProcess iProcess;
1.136 + RLoaderTest iSession;
1.137 + RLdrTest iDev;
1.138 + CGlobalModuleList* iGlobalList;
1.139 + TInt iModuleNum[KMaxHandles];
1.140 + TInt iHandleCount[KNumModules];
1.141 + SModuleInstance* iModules[KNumModules];
1.142 + };
1.143 +
1.144 +class CGlobalModuleList : public CBase
1.145 + {
1.146 +public:
1.147 + static CGlobalModuleList* New(const LoaderTest&);
1.148 + virtual ~CGlobalModuleList();
1.149 + void Close(SModuleInstance* a);
1.150 + void Free(SModuleInstance* a);
1.151 + SModuleInstance* GetMI();
1.152 + TAny* CodeSegFromHandle(TModuleHandle aModHandle);
1.153 + void CheckAll();
1.154 + TInt Load(TInt aExeNum, TInt aDllNum);
1.155 + TInt CloseHandle(TInt aExeNum, TInt aDllNum);
1.156 +private:
1.157 + CGlobalModuleList();
1.158 + void Init();
1.159 +public:
1.160 + TInt iMaxModules;
1.161 + TInt iNumExes;
1.162 + TInt iFixedExes;
1.163 + TInt iParam;
1.164 + RLdrTest iDev;
1.165 + TUint32 iMemModelAtt;
1.166 + CPerProcessInfo* iPPInfo[KNumModules];
1.167 + RPointerArray<SModuleInstance> iModules;
1.168 + SModuleInstance* iModuleAlloc;
1.169 + SModuleInstance* iFreeModules;
1.170 + };
1.171 +
1.172 +#endif