|
1 // proxyallocatorhelper.cpp |
|
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 #include <fshell/heaputils.h> |
|
13 #include <fshell/common.mmh> |
|
14 #include <fshell/ltkutils.h> |
|
15 __ASSERT_COMPILE(sizeof(LtkUtils::RProxyAllocatorHelper) == 11*4); |
|
16 |
|
17 #ifdef FSHELL_MEMORY_ACCESS_SUPPORT |
|
18 #include <fshell/memoryaccess.h> |
|
19 #endif |
|
20 |
|
21 EXPORT_C LtkUtils::RProxyAllocatorHelper::RProxyAllocatorHelper() |
|
22 : RAllocatorHelper() |
|
23 { |
|
24 } |
|
25 |
|
26 EXPORT_C TInt LtkUtils::RProxyAllocatorHelper::Open(RMemoryAccess& aMem, TUint aThreadId) |
|
27 { |
|
28 iMemoryAccess = &aMem; |
|
29 iThreadId = aThreadId; |
|
30 |
|
31 #ifdef FSHELL_MEMORY_ACCESS_SUPPORT |
|
32 TUint8* allocatorAddress; |
|
33 TInt err = iMemoryAccess->GetAllocatorAddress(iThreadId, allocatorAddress); |
|
34 if (!err) |
|
35 { |
|
36 iAllocatorAddress = (TLinAddr)allocatorAddress; |
|
37 TInt udeb = EuserIsUdeb(); |
|
38 if (udeb < 0) return udeb; // error |
|
39 err = IdentifyAllocatorType(udeb); |
|
40 } |
|
41 return err; |
|
42 #else |
|
43 return KErrNotSupported; |
|
44 #endif |
|
45 } |
|
46 |
|
47 EXPORT_C TInt LtkUtils::RProxyAllocatorHelper::OpenChunkHeap(RMemoryAccess& aMem, TAny* aDChunkPtr) |
|
48 { |
|
49 #ifdef FSHELL_MEMORY_ACCESS_SUPPORT |
|
50 iMemoryAccess = &aMem; |
|
51 |
|
52 TChunkKernelInfo chunkInfo; |
|
53 TPckg<TChunkKernelInfo> chunkInfoPckg(chunkInfo); |
|
54 TInt err = iMemoryAccess->GetObjectInfo(EChunk, (TUint8*)aDChunkPtr, chunkInfoPckg); |
|
55 if (err) return err; |
|
56 RProcess process; |
|
57 err = process.Open(chunkInfo.iControllingOwnerProcessId); |
|
58 if (err == KErrNone) |
|
59 { |
|
60 TPckgBuf<TProcessKernelInfo> processInfo; |
|
61 err = iMemoryAccess->GetObjectInfoByHandle(EProcess, RThread().Id(), process.Handle(), processInfo); |
|
62 process.Close(); |
|
63 if (err == KErrNone) |
|
64 { |
|
65 iThreadId = processInfo().iFirstThreadId; |
|
66 return RAllocatorHelper::OpenChunkHeap((TLinAddr)chunkInfo.iBase, chunkInfo.iMaxSize); |
|
67 } |
|
68 } |
|
69 return err; |
|
70 #else |
|
71 (void)aMem; |
|
72 (void)aDChunkPtr; |
|
73 return KErrNotSupported; |
|
74 #endif |
|
75 } |
|
76 |
|
77 TInt LtkUtils::RProxyAllocatorHelper::ReadData(TLinAddr aLocation, TAny* aResult, TInt aSize) const |
|
78 { |
|
79 #ifdef FSHELL_MEMORY_ACCESS_SUPPORT |
|
80 TThreadMemoryAccessParams params; |
|
81 params.iId = iThreadId; |
|
82 params.iAddr = (TUint8*)aLocation; |
|
83 params.iSize = aSize; |
|
84 TPtr8 ptr((TUint8*)aResult, aSize, aSize); |
|
85 return iMemoryAccess->GetThreadMem(params, ptr); |
|
86 #else |
|
87 return KErrNotSupported; |
|
88 #endif |
|
89 } |
|
90 |
|
91 TInt LtkUtils::RProxyAllocatorHelper::WriteData(TLinAddr aLocation, const TAny* aData, TInt aSize) |
|
92 { |
|
93 #ifdef FSHELL_MEMORY_ACCESS_SUPPORT |
|
94 const TPtrC8 ptr((const TUint8*)aData, aSize); |
|
95 return iMemoryAccess->WriteMem(iThreadId, ptr, (TAny*)aLocation); |
|
96 #else |
|
97 return KErrNotSupported; |
|
98 #endif |
|
99 } |
|
100 |
|
101 TInt LtkUtils::RProxyAllocatorHelper::TryLock() |
|
102 { |
|
103 return KErrNotSupported; |
|
104 } |
|
105 |
|
106 void LtkUtils::RProxyAllocatorHelper::TryUnlock() |
|
107 { |
|
108 // Not supported |
|
109 } |
|
110 |
|
111 EXPORT_C void LtkUtils::RProxyAllocatorHelper::Close() |
|
112 { |
|
113 iMemoryAccess = NULL; |
|
114 iThreadId = 0; |
|
115 RAllocatorHelper::Close(); |
|
116 } |