51
|
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 |
#include "MemSpyDriverLogChanProcessInspection.h"
|
|
19 |
|
|
20 |
// System includes
|
|
21 |
#include <u32hal.h>
|
|
22 |
#include <e32rom.h>
|
|
23 |
#include <memspy/driver/memspydriverobjectsshared.h>
|
|
24 |
|
|
25 |
// Shared includes
|
|
26 |
#include "MemSpyDriverOpCodes.h"
|
|
27 |
#include "MemSpyDriverObjectsInternal.h"
|
|
28 |
|
|
29 |
// User includes
|
|
30 |
#include "MemSpyDriverUtils.h"
|
|
31 |
#include "MemSpyDriverDevice.h"
|
|
32 |
#include "MemSpyDriverInspectedProcess.h"
|
|
33 |
#include "MemSpyDriverInspectedProcessManager.h"
|
|
34 |
|
|
35 |
|
|
36 |
DMemSpyDriverLogChanProcessInspection::DMemSpyDriverLogChanProcessInspection( DMemSpyDriverDevice& aDevice, DThread& aThread )
|
|
37 |
: DMemSpyDriverLogChanBase( aDevice, aThread )
|
|
38 |
{
|
|
39 |
TRACE( Kern::Printf("DMemSpyDriverLogChanProcessInspection::DMemSpyDriverLogChanProcessInspection() - this: 0x%08x", this ));
|
|
40 |
}
|
|
41 |
|
|
42 |
|
|
43 |
DMemSpyDriverLogChanProcessInspection::~DMemSpyDriverLogChanProcessInspection()
|
|
44 |
{
|
|
45 |
TRACE( Kern::Printf("DMemSpyDriverLogChanProcessInspection::~DMemSpyDriverLogChanProcessInspection() - START - this: 0x%08x", this ));
|
|
46 |
|
|
47 |
TRACE( Kern::Printf("DMemSpyDriverLogChanProcessInspection::~DMemSpyDriverLogChanProcessInspection() - END - this: 0x%08x", this ));
|
|
48 |
}
|
|
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
TInt DMemSpyDriverLogChanProcessInspection::Request( TInt aFunction, TAny* a1, TAny* a2 )
|
|
56 |
{
|
|
57 |
TInt r = DMemSpyDriverLogChanBase::Request( aFunction, a1, a2 );
|
|
58 |
if ( r == KErrNone )
|
|
59 |
{
|
|
60 |
switch( aFunction )
|
|
61 |
{
|
|
62 |
case EMemSpyDriverOpCodeProcessInspectOpen:
|
|
63 |
r = ProcessInspectionOpen( (TUint) a1 );
|
|
64 |
break;
|
|
65 |
case EMemSpyDriverOpCodeProcessInspectClose:
|
|
66 |
r = ProcessInspectionClose( (TUint) a1 );
|
|
67 |
break;
|
|
68 |
case EMemSpyDriverOpCodeProcessInspectRequestChanges:
|
|
69 |
r = ProcessInspectionRequestChanges( (TRequestStatus*) a1, (TMemSpyDriverProcessInspectionInfo*) a2 );
|
|
70 |
break;
|
|
71 |
case EMemSpyDriverOpCodeProcessInspectRequestChangesCancel:
|
|
72 |
r = ProcessInspectionRequestChangesCancel( (TUint) a1 );
|
|
73 |
break;
|
|
74 |
case EMemSpyDriverOpCodeProcessInspectAutoStartListReset:
|
|
75 |
r = ProcessInspectionAutoStartItemsClear();
|
|
76 |
break;
|
|
77 |
case EMemSpyDriverOpCodeProcessInspectAutoStartListAdd:
|
|
78 |
r = ProcessInspectionAutoStartItemsAdd( (TUint) a1 );
|
|
79 |
break;
|
|
80 |
|
|
81 |
default:
|
|
82 |
r = KErrNotSupported;
|
|
83 |
break;
|
|
84 |
}
|
|
85 |
}
|
|
86 |
//
|
|
87 |
return r;
|
|
88 |
}
|
|
89 |
|
|
90 |
|
|
91 |
TBool DMemSpyDriverLogChanProcessInspection::IsHandler( TInt aFunction ) const
|
|
92 |
{
|
|
93 |
return ( aFunction > EMemSpyDriverOpCodeProcessInspectBase && aFunction < EMemSpyDriverOpCodeProcessInspectEnd );
|
|
94 |
}
|
|
95 |
|
|
96 |
|
|
97 |
|
|
98 |
|
|
99 |
|
|
100 |
|
|
101 |
|
|
102 |
|
|
103 |
|
|
104 |
|
|
105 |
|
|
106 |
|
|
107 |
|
|
108 |
|
|
109 |
|
|
110 |
|
|
111 |
|
|
112 |
|
|
113 |
|
|
114 |
|
|
115 |
|
|
116 |
|
|
117 |
|
|
118 |
|
|
119 |
|
|
120 |
|
|
121 |
TInt DMemSpyDriverLogChanProcessInspection::ProcessInspectionOpen( TUint aPid )
|
|
122 |
{
|
|
123 |
TRACE( Kern::Printf("DMemSpyDriverLogChanProcessInspection::ProcessInspectionOpen() - START"));
|
|
124 |
NKern::ThreadEnterCS();
|
|
125 |
|
|
126 |
TInt error = OpenTempObject( aPid, EProcess );
|
|
127 |
if ( error == KErrNone )
|
|
128 |
{
|
|
129 |
DMemSpyInspectedProcessManager& pidManager = MemSpyDevice().ProcessInspectionManager();
|
|
130 |
error = pidManager.ProcessOpen( (DProcess*) TempObject() );
|
|
131 |
CloseTempObject();
|
|
132 |
}
|
|
133 |
//
|
|
134 |
NKern::ThreadLeaveCS();
|
|
135 |
TRACE( Kern::Printf("DMemSpyDriverLogChanProcessInspection::ProcessInspectionOpen() - END - error: %d", error ));
|
|
136 |
return error;
|
|
137 |
}
|
|
138 |
|
|
139 |
|
|
140 |
TInt DMemSpyDriverLogChanProcessInspection::ProcessInspectionClose( TUint aPid )
|
|
141 |
{
|
|
142 |
TRACE( Kern::Printf("DMemSpyDriverLogChanProcessInspection::ProcessInspectionClose() - START"));
|
|
143 |
NKern::ThreadEnterCS();
|
|
144 |
|
|
145 |
TInt error = OpenTempObject( aPid, EProcess );
|
|
146 |
if ( error == KErrNone )
|
|
147 |
{
|
|
148 |
DMemSpyInspectedProcessManager& pidManager = MemSpyDevice().ProcessInspectionManager();
|
|
149 |
error = pidManager.ProcessClose( (DProcess*) TempObject() );
|
|
150 |
CloseTempObject();
|
|
151 |
}
|
|
152 |
|
|
153 |
NKern::ThreadLeaveCS();
|
|
154 |
|
|
155 |
TRACE( Kern::Printf("DMemSpyDriverLogChanProcessInspection::ProcessInspectionClose() - END - error: %d", error ));
|
|
156 |
return error;
|
|
157 |
}
|
|
158 |
|
|
159 |
|
|
160 |
TInt DMemSpyDriverLogChanProcessInspection::ProcessInspectionRequestChanges( TRequestStatus* aStatus, TMemSpyDriverProcessInspectionInfo* aInfo )
|
|
161 |
{
|
|
162 |
TRACE( Kern::Printf("DMemSpyDriverLogChanProcessInspection::ProcessInspectionRequestChanges() - START"));
|
|
163 |
NKern::ThreadEnterCS();
|
|
164 |
|
|
165 |
// Read client info
|
|
166 |
TMemSpyDriverProcessInspectionInfo info;
|
|
167 |
TInt error = Kern::ThreadRawRead( &ClientThread(), aInfo, &info, sizeof(TMemSpyDriverProcessInspectionInfo) );
|
|
168 |
//
|
|
169 |
if ( error == KErrNone )
|
|
170 |
{
|
|
171 |
DMemSpyInspectedProcessManager& pidManager = MemSpyDevice().ProcessInspectionManager();
|
|
172 |
DMemSpyInspectedProcess* pid = pidManager.InspectedProcessByProcessId( info.iProcessId );
|
|
173 |
//
|
|
174 |
if ( pid != NULL )
|
|
175 |
{
|
|
176 |
error = pid->NotifyOnChange( &ClientThread(), aStatus, aInfo );
|
|
177 |
}
|
|
178 |
else
|
|
179 |
{
|
|
180 |
error = KErrNotFound;
|
|
181 |
}
|
|
182 |
}
|
|
183 |
|
|
184 |
// NB: Let client take care of completing request in error situations
|
|
185 |
NKern::ThreadLeaveCS();
|
|
186 |
TRACE( Kern::Printf("DMemSpyDriverLogChanProcessInspection::ProcessInspectionRequestChanges() - END - error: %d", error ));
|
|
187 |
return error;
|
|
188 |
}
|
|
189 |
|
|
190 |
|
|
191 |
TInt DMemSpyDriverLogChanProcessInspection::ProcessInspectionRequestChangesCancel( TUint aPid )
|
|
192 |
{
|
|
193 |
TRACE( Kern::Printf("DMemSpyDriverLogChanProcessInspection::ProcessInspectionRequestChangesCancel() - START"));
|
|
194 |
NKern::ThreadEnterCS();
|
|
195 |
|
|
196 |
TInt error = KErrNotFound;
|
|
197 |
|
|
198 |
DMemSpyInspectedProcessManager& pidManager = MemSpyDevice().ProcessInspectionManager();
|
|
199 |
DMemSpyInspectedProcess* pid = pidManager.InspectedProcessByProcessId( aPid );
|
|
200 |
//
|
|
201 |
if ( pid != NULL )
|
|
202 |
{
|
|
203 |
error = pid->NotifyOnChangeCancel();
|
|
204 |
}
|
|
205 |
|
|
206 |
NKern::ThreadLeaveCS();
|
|
207 |
|
|
208 |
TRACE( Kern::Printf("DMemSpyDriverLogChanProcessInspection::ProcessInspectionRequestChangesCancel() - END - error: %d", error ));
|
|
209 |
return error;
|
|
210 |
}
|
|
211 |
|
|
212 |
|
|
213 |
TInt DMemSpyDriverLogChanProcessInspection::ProcessInspectionAutoStartItemsClear()
|
|
214 |
{
|
|
215 |
TRACE( Kern::Printf("DMemSpyDriverLogChanProcessInspection::ProcessInspectionAutoStartItemsClear() - START"));
|
|
216 |
|
|
217 |
NKern::ThreadEnterCS();
|
|
218 |
|
|
219 |
DMemSpyInspectedProcessManager& pidManager = MemSpyDevice().ProcessInspectionManager();
|
|
220 |
pidManager.AutoStartListReset();
|
|
221 |
|
|
222 |
NKern::ThreadLeaveCS();
|
|
223 |
|
|
224 |
TRACE( Kern::Printf("DMemSpyDriverLogChanProcessInspection::ProcessInspectionAutoStartItemsClear() - END" ));
|
|
225 |
return KErrNone;
|
|
226 |
}
|
|
227 |
|
|
228 |
|
|
229 |
TInt DMemSpyDriverLogChanProcessInspection::ProcessInspectionAutoStartItemsAdd( TUint aSID )
|
|
230 |
{
|
|
231 |
TRACE( Kern::Printf("DMemSpyDriverLogChanProcessInspection::ProcessInspectionAutoStartItemsAdd() - START - aSID: 0x%08x", aSID ));
|
|
232 |
|
|
233 |
NKern::ThreadEnterCS();
|
|
234 |
DMemSpyInspectedProcessManager& pidManager = MemSpyDevice().ProcessInspectionManager();
|
|
235 |
const TInt error = pidManager.AutoStartListAdd( aSID );
|
|
236 |
NKern::ThreadLeaveCS();
|
|
237 |
|
|
238 |
TRACE( Kern::Printf("DMemSpyDriverLogChanProcessInspection::ProcessInspectionAutoStartItemsAdd() - END - error: %d", error ));
|
|
239 |
return error;
|
|
240 |
}
|
|
241 |
|
|
242 |
|
|
243 |
|
|
244 |
|
|
245 |
|
|
246 |
|
|
247 |
|
|
248 |
|
|
249 |
|
|
250 |
|
|
251 |
|
|
252 |
|
|
253 |
|
|
254 |
|
|
255 |
|
|
256 |
|