author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Mon, 15 Mar 2010 12:45:50 +0200 | |
branch | RCL_3 |
changeset 21 | e7d2d738d3c2 |
parent 0 | a41df078684a |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 |
// All rights reserved. |
|
3 |
// This component and the accompanying materials are made available |
|
4 |
// under the terms of the License "Eclipse Public License v1.0" |
|
5 |
// which accompanies this distribution, and is available |
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 |
// |
|
8 |
// Initial Contributors: |
|
9 |
// Nokia Corporation - initial contribution. |
|
10 |
// |
|
11 |
// Contributors: |
|
12 |
// |
|
13 |
// Description: |
|
14 |
// Asynchronous security server active object class. |
|
15 |
// |
|
16 |
// |
|
17 |
||
18 |
#include <e32base.h> |
|
19 |
#include <e32base_private.h> |
|
20 |
||
21 |
#include "c_security_svr_async.h" |
|
22 |
#include "rm_debug_logging.h" |
|
23 |
||
24 |
using namespace Debug; |
|
25 |
||
26 |
// ctor |
|
27 |
CSecuritySvrAsync::CSecuritySvrAsync(CSecuritySvrSession* aSession, TProcessId aAgentId) |
|
21
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
28 |
: CActive(CActive::EPriorityStandard), |
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
29 |
iSession(aSession), |
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
30 |
iProcessName(NULL), |
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
31 |
iAgentId(aAgentId), |
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
32 |
iEventBalance(0) |
0 | 33 |
{ |
34 |
LOG_MSG("CSecuritySvrAsync::CSecuritySvrAsync()"); |
|
35 |
CActiveScheduler::Add(this); |
|
36 |
} |
|
37 |
||
38 |
// returns a CSecuritySvrAsync active object associated with |
|
39 |
// the specified agent and debugged process. |
|
40 |
CSecuritySvrAsync* CSecuritySvrAsync::NewL(CSecuritySvrSession* aSession, const TDesC8& aProcessName, TProcessId aAgentId) |
|
41 |
{ |
|
42 |
LOG_MSG("CSecuritySvrAsync::NewL()"); |
|
43 |
CSecuritySvrAsync* me = new (ELeave) CSecuritySvrAsync(aSession, aAgentId); |
|
44 |
||
45 |
CleanupStack::PushL(me); |
|
46 |
||
47 |
me->ConstructL(aProcessName); |
|
48 |
||
49 |
CleanupStack::Pop(me); |
|
50 |
||
51 |
return (me); |
|
52 |
} |
|
53 |
||
54 |
// dtor |
|
55 |
CSecuritySvrAsync::~CSecuritySvrAsync() |
|
56 |
{ |
|
57 |
LOG_MSG("CSecuritySvrAsync::~CSecuritySvrAsync()"); |
|
58 |
||
59 |
// NOTE: the Cancel() function calls DoCancel() which may rely on class members so be careful not |
|
60 |
// to destroy/close data members before this call if they are needed |
|
61 |
Cancel(); |
|
62 |
iProcessName.Close(); |
|
63 |
} |
|
64 |
||
65 |
// Associates the agent id and process name with the Active Object being constructed |
|
66 |
void CSecuritySvrAsync::ConstructL(const TDesC8& aProcessName) |
|
67 |
{ |
|
68 |
LOG_MSG("CSecuritySvrAsync::ConstructL()"); |
|
69 |
iProcessName.CreateL(aProcessName.Length()); |
|
70 |
iProcessName.Copy(aProcessName); |
|
71 |
} |
|
72 |
||
73 |
// RunL() completes a previously issued call (currently only GetEvent() completion) |
|
74 |
void CSecuritySvrAsync::RunL() |
|
75 |
{ |
|
21
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
76 |
|
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
77 |
LOG_MSG3("CSecuritySvrAsync::RunL() &iInfo=0x%08x, iEventBalance=%d", (TUint8*)&iInfo, iEventBalance); |
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
78 |
|
0 | 79 |
// Something bad happened in the driver |
80 |
User::LeaveIfError(iStatus.Int()); |
|
81 |
||
82 |
// Write back the event data to the debug agent. |
|
83 |
// For compatibility we need to check the size of the buffer that the |
|
84 |
// client has passed in as the size of TEventInfo will increase over time. |
|
85 |
// Clients can calculate the required size from the EApiConstantsTEventInfoSize entry |
|
86 |
// in the Debug Functionality block but may still pass in buffers which |
|
87 |
// are smaller than the Debug Security Server's calculation of sizeof(TEventInfo), |
|
88 |
// returning KErrTooBig in this case would be |
|
89 |
// inappropriate as we would break compatibility. |
|
90 |
TInt dataLengthToReturn = sizeof(TEventInfo); |
|
91 |
TInt maxLengthClientSide = iMessage.GetDesMaxLengthL(1); |
|
92 |
if(maxLengthClientSide < dataLengthToReturn) |
|
93 |
{ |
|
94 |
dataLengthToReturn = maxLengthClientSide; |
|
95 |
} |
|
96 |
||
97 |
TPtr8 data((TUint8*)&iInfo,dataLengthToReturn,dataLengthToReturn); |
|
98 |
||
99 |
iMessage.WriteL(1,data,0); |
|
100 |
||
101 |
iMessage.Complete(KErrNone); |
|
21
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
102 |
--iEventBalance; |
0 | 103 |
} |
104 |
||
105 |
// Cancels the oustanding GetEvent call. May cope with other async calls in future. |
|
106 |
void CSecuritySvrAsync::DoCancel() |
|
107 |
{ |
|
21
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
108 |
LOG_MSG2("CSecuritySvrAsync::DoCancel() iEventBalance=%d", iEventBalance); |
0 | 109 |
iSession->Server().iKernelDriver.CancelGetEvent(iProcessName,iAgentId.Id()); |
110 |
||
111 |
iMessage.Complete(KErrCancel); |
|
21
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
112 |
iEventBalance=0; |
0 | 113 |
} |
114 |
||
115 |
// Report any leave to the client if possible. |
|
116 |
TInt CSecuritySvrAsync::RunError(TInt aError) |
|
117 |
{ |
|
21
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
118 |
LOG_MSG2("CSecuritySvrAsync::RunError()=%d", aError); |
0 | 119 |
iMessage.Complete(aError); |
120 |
||
121 |
return KErrNone; |
|
122 |
} |
|
123 |
||
21
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
124 |
/* |
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
125 |
* Start an asynchronous GetEvent call to the debug driver |
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
126 |
* and activates this active object. |
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
127 |
*/ |
0 | 128 |
void CSecuritySvrAsync::GetEvent(const RMessage2& aMessage) |
129 |
{ |
|
130 |
iMessage = aMessage; |
|
131 |
||
21
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
132 |
iEventBalance++; |
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
133 |
LOG_MSG5("CSecuritySvrAsync::GetEvent() this = 0x%08x, iInfo=0x%08x, iStatus=0x%08x \ |
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
134 |
iEventBalance=%d : >SetActive() > GetEvent() ", |
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
135 |
this, &iInfo, &iStatus, iEventBalance ); |
0 | 136 |
|
21
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
137 |
/* |
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
138 |
SetActive is called before sending the message to the driver so |
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
139 |
that we do not get stray signal panics, since the driver may complete immediately |
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
140 |
*/ |
0 | 141 |
SetActive(); |
21
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
142 |
iSession->Server().iKernelDriver.GetEvent(iProcessName,iAgentId.Id(),iStatus,iInfo); |
0 | 143 |
} |
144 |
||
145 |
// Used for identifying which AO is associated with a debugged process |
|
146 |
const TDesC8& CSecuritySvrAsync::ProcessName(void) |
|
21
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
147 |
{ |
0 | 148 |
return iProcessName; |
21
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
149 |
} |
0 | 150 |
|
151 |
// End of file - c_security_svr_async.cpp |
|
152 |