os/kernelhwsrv/kerneltest/f32test/loader/security/t_ldrtst.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// f32test\loader\t_ldrtst.h
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#ifndef __T_LDRTST_H__
sl@0
    19
#define __T_LDRTST_H__
sl@0
    20
sl@0
    21
#define __INCLUDE_DEPENDENCY_GRAPH
sl@0
    22
sl@0
    23
#include <e32svr.h>
sl@0
    24
#include <e32test.h>
sl@0
    25
#include "dlltree.h"
sl@0
    26
#include "dllt.h"
sl@0
    27
#include "exetifc.h"
sl@0
    28
#include <d_ldrtst.h>
sl@0
    29
#include <f32file.h>
sl@0
    30
#include <f32dbg.h>
sl@0
    31
#include <e32rom.h>
sl@0
    32
sl@0
    33
GLREF_D RTest test;
sl@0
    34
sl@0
    35
class TModuleList;
sl@0
    36
class TModuleSet
sl@0
    37
	{
sl@0
    38
public:
sl@0
    39
	TModuleSet();
sl@0
    40
	TModuleSet(const TModuleList&, TInt aMask, TInt aVal);
sl@0
    41
	void Add(TInt aModule);
sl@0
    42
	void Remove(TInt aModule);
sl@0
    43
	void Remove(const TModuleList&);
sl@0
    44
	void Display(const TDesC& aTitle) const;
sl@0
    45
	inline TBool Present(TInt aModule) const
sl@0
    46
		{ return iBitMap[aModule>>3]&(1<<(aModule&7)); }
sl@0
    47
public:
sl@0
    48
	TInt iCount;
sl@0
    49
	TUint8 iBitMap[(KNumModules+7)/8];
sl@0
    50
	};
sl@0
    51
sl@0
    52
class TModuleList
sl@0
    53
	{
sl@0
    54
public:
sl@0
    55
	TModuleList();
sl@0
    56
	void SetCount();
sl@0
    57
	void Display(const TDesC& aTitle) const;
sl@0
    58
	TBool IsPresent(TInt aModNum) const;
sl@0
    59
	TInt Find(TInt aModNum) const;
sl@0
    60
	void Add(const SDllInfo& a);
sl@0
    61
public:
sl@0
    62
	TInt iCount;
sl@0
    63
	SDllInfo iInfo[KNumModules];
sl@0
    64
	};
sl@0
    65
sl@0
    66
class LoaderTest
sl@0
    67
	{
sl@0
    68
public:
sl@0
    69
	static LoaderTest* New();
sl@0
    70
	void Close();
sl@0
    71
	void Init();
sl@0
    72
public:
sl@0
    73
	void TestOneByOne();
sl@0
    74
	void TestMultipleExeInstances();
sl@0
    75
	void TestOOM();
sl@0
    76
	void TestMultipleLoads();
sl@0
    77
private:
sl@0
    78
	TBool IsRomAddress(TLinAddr a);
sl@0
    79
	TBool IsRamCodeAddress(TLinAddr a);
sl@0
    80
	TBool CheckDataAddress(TLinAddr a, TInt aDllNum, TInt aExeNum);
sl@0
    81
	TInt DetermineDllLoadResult(TInt aDllNum, TInt aExeNum);
sl@0
    82
	TInt DetermineDllLoadResult(TInt aDllNum, TInt aExeNum1, TInt aExeNum2);
sl@0
    83
	TInt DetermineLoadExe2Result(TInt aExeNum);
sl@0
    84
	void DumpModuleList(const TModuleList& aList, TInt aExeNum);
sl@0
    85
	void DumpModuleInfo(const SDllInfo& aInfo, TInt aExeNum);
sl@0
    86
	void CheckModuleList(TInt aRoot, const TModuleList& aList);
sl@0
    87
public:
sl@0
    88
	void TraceOn();
sl@0
    89
	void TraceOff();
sl@0
    90
private:
sl@0
    91
	LoaderTest();
sl@0
    92
	~LoaderTest();
sl@0
    93
public:
sl@0
    94
	RFs iFs;
sl@0
    95
	RLdrTest iDev;
sl@0
    96
	TUint32 iMemModelAtt;
sl@0
    97
	TInt iCmdLine[8];
sl@0
    98
	};
sl@0
    99
sl@0
   100
sl@0
   101
const TInt KMaxHandlesPerDll=4;
sl@0
   102
const TInt KMaxHandles=KMaxHandlesPerDll*KNumModules;
sl@0
   103
sl@0
   104
struct SModuleInstance
sl@0
   105
	{
sl@0
   106
	TInt iAccessCount;
sl@0
   107
	TInt iModNum;
sl@0
   108
	TLinAddr iEntryPointAddress;
sl@0
   109
	TModuleHandle iModuleHandle;
sl@0
   110
	TLinAddr iData;
sl@0
   111
	TAny* iCodeSeg;
sl@0
   112
	};
sl@0
   113
sl@0
   114
class CGlobalModuleList;
sl@0
   115
class CPerProcessInfo : public CBase
sl@0
   116
	{
sl@0
   117
public:
sl@0
   118
	static CPerProcessInfo* New(TInt aExeNum, CGlobalModuleList& aG);
sl@0
   119
	virtual ~CPerProcessInfo();
sl@0
   120
	void GetModuleSet(TModuleSet& aSet);
sl@0
   121
	void Check();
sl@0
   122
	void Unlink(const SDllInfo& a, TModuleList& aList);
sl@0
   123
	TInt Load(TInt aDllNum);
sl@0
   124
	TInt AddModules(TInt aDllNum, TModuleList* aCList, TModuleList* aIList);
sl@0
   125
	TInt CloseHandle(TInt aHandle);
sl@0
   126
private:
sl@0
   127
	CPerProcessInfo();
sl@0
   128
	TInt Init();
sl@0
   129
public:
sl@0
   130
	TInt iExeNum;
sl@0
   131
	TRequestStatus iStatus;
sl@0
   132
	RProcess iProcess;
sl@0
   133
	RLoaderTest iSession;
sl@0
   134
	RLdrTest iDev;
sl@0
   135
	CGlobalModuleList* iGlobalList;
sl@0
   136
	TInt iModuleNum[KMaxHandles];
sl@0
   137
	TInt iHandleCount[KNumModules];
sl@0
   138
	SModuleInstance* iModules[KNumModules];
sl@0
   139
	};
sl@0
   140
sl@0
   141
class CGlobalModuleList : public CBase
sl@0
   142
	{
sl@0
   143
public:
sl@0
   144
	static CGlobalModuleList* New(const LoaderTest&);
sl@0
   145
	virtual ~CGlobalModuleList();
sl@0
   146
	void Close(SModuleInstance* a);
sl@0
   147
	void Free(SModuleInstance* a);
sl@0
   148
	SModuleInstance* GetMI();
sl@0
   149
	TAny* CodeSegFromHandle(TModuleHandle aModHandle);
sl@0
   150
	void CheckAll();
sl@0
   151
	TInt Load(TInt aExeNum, TInt aDllNum);
sl@0
   152
	TInt CloseHandle(TInt aExeNum, TInt aDllNum);
sl@0
   153
private:
sl@0
   154
	CGlobalModuleList();
sl@0
   155
	void Init();
sl@0
   156
public:
sl@0
   157
	TInt iMaxModules;
sl@0
   158
	TInt iNumExes;
sl@0
   159
	TInt iFixedExes;
sl@0
   160
	TInt iParam;
sl@0
   161
	RLdrTest iDev;
sl@0
   162
	TUint32 iMemModelAtt;
sl@0
   163
	CPerProcessInfo* iPPInfo[KNumModules];
sl@0
   164
	RPointerArray<SModuleInstance> iModules;
sl@0
   165
	SModuleInstance* iModuleAlloc;
sl@0
   166
	SModuleInstance* iFreeModules;
sl@0
   167
	};
sl@0
   168
sl@0
   169
#endif