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)
|
|
28 |
: CActive(CActive::EPriorityStandard),
|
|
29 |
iSession(aSession),
|
|
30 |
iProcessName(NULL),
|
|
31 |
iAgentId(aAgentId)
|
|
32 |
{
|
|
33 |
LOG_MSG("CSecuritySvrAsync::CSecuritySvrAsync()");
|
|
34 |
CActiveScheduler::Add(this);
|
|
35 |
}
|
|
36 |
|
|
37 |
// returns a CSecuritySvrAsync active object associated with
|
|
38 |
// the specified agent and debugged process.
|
|
39 |
CSecuritySvrAsync* CSecuritySvrAsync::NewL(CSecuritySvrSession* aSession, const TDesC8& aProcessName, TProcessId aAgentId)
|
|
40 |
{
|
|
41 |
LOG_MSG("CSecuritySvrAsync::NewL()");
|
|
42 |
CSecuritySvrAsync* me = new (ELeave) CSecuritySvrAsync(aSession, aAgentId);
|
|
43 |
|
|
44 |
CleanupStack::PushL(me);
|
|
45 |
|
|
46 |
me->ConstructL(aProcessName);
|
|
47 |
|
|
48 |
CleanupStack::Pop(me);
|
|
49 |
|
|
50 |
return (me);
|
|
51 |
}
|
|
52 |
|
|
53 |
// dtor
|
|
54 |
CSecuritySvrAsync::~CSecuritySvrAsync()
|
|
55 |
{
|
|
56 |
LOG_MSG("CSecuritySvrAsync::~CSecuritySvrAsync()");
|
|
57 |
|
|
58 |
// NOTE: the Cancel() function calls DoCancel() which may rely on class members so be careful not
|
|
59 |
// to destroy/close data members before this call if they are needed
|
|
60 |
Cancel();
|
|
61 |
iProcessName.Close();
|
|
62 |
}
|
|
63 |
|
|
64 |
// Associates the agent id and process name with the Active Object being constructed
|
|
65 |
void CSecuritySvrAsync::ConstructL(const TDesC8& aProcessName)
|
|
66 |
{
|
|
67 |
LOG_MSG("CSecuritySvrAsync::ConstructL()");
|
|
68 |
iProcessName.CreateL(aProcessName.Length());
|
|
69 |
iProcessName.Copy(aProcessName);
|
|
70 |
}
|
|
71 |
|
|
72 |
// RunL() completes a previously issued call (currently only GetEvent() completion)
|
|
73 |
void CSecuritySvrAsync::RunL()
|
|
74 |
{
|
|
75 |
LOG_MSG("CSecuritySvrAsync::RunL()");
|
|
76 |
// Something bad happened in the driver
|
|
77 |
User::LeaveIfError(iStatus.Int());
|
|
78 |
|
|
79 |
// Write back the event data to the debug agent.
|
|
80 |
// For compatibility we need to check the size of the buffer that the
|
|
81 |
// client has passed in as the size of TEventInfo will increase over time.
|
|
82 |
// Clients can calculate the required size from the EApiConstantsTEventInfoSize entry
|
|
83 |
// in the Debug Functionality block but may still pass in buffers which
|
|
84 |
// are smaller than the Debug Security Server's calculation of sizeof(TEventInfo),
|
|
85 |
// returning KErrTooBig in this case would be
|
|
86 |
// inappropriate as we would break compatibility.
|
|
87 |
TInt dataLengthToReturn = sizeof(TEventInfo);
|
|
88 |
TInt maxLengthClientSide = iMessage.GetDesMaxLengthL(1);
|
|
89 |
if(maxLengthClientSide < dataLengthToReturn)
|
|
90 |
{
|
|
91 |
dataLengthToReturn = maxLengthClientSide;
|
|
92 |
}
|
|
93 |
|
|
94 |
TPtr8 data((TUint8*)&iInfo,dataLengthToReturn,dataLengthToReturn);
|
|
95 |
|
|
96 |
iMessage.WriteL(1,data,0);
|
|
97 |
|
|
98 |
iMessage.Complete(KErrNone);
|
|
99 |
}
|
|
100 |
|
|
101 |
// Cancels the oustanding GetEvent call. May cope with other async calls in future.
|
|
102 |
void CSecuritySvrAsync::DoCancel()
|
|
103 |
{
|
|
104 |
LOG_MSG("CSecuritySvrAsync::DoCancel()");
|
|
105 |
iSession->Server().iKernelDriver.CancelGetEvent(iProcessName,iAgentId.Id());
|
|
106 |
|
|
107 |
iMessage.Complete(KErrCancel);
|
|
108 |
}
|
|
109 |
|
|
110 |
// Report any leave to the client if possible.
|
|
111 |
TInt CSecuritySvrAsync::RunError(TInt aError)
|
|
112 |
{
|
|
113 |
LOG_MSG("CSecuritySvrAsync::RunError()");
|
|
114 |
iMessage.Complete(aError);
|
|
115 |
|
|
116 |
return KErrNone;
|
|
117 |
}
|
|
118 |
|
|
119 |
// Start an Asynchronous GetEvent call to the rm_debug.ldd driver
|
|
120 |
// and activate this Active Object.
|
|
121 |
void CSecuritySvrAsync::GetEvent(const RMessage2& aMessage)
|
|
122 |
{
|
|
123 |
LOG_MSG("CSecuritySvrAsync::GetEvent()");
|
|
124 |
iMessage = aMessage;
|
|
125 |
|
|
126 |
iSession->Server().iKernelDriver.GetEvent(iProcessName,iAgentId.Id(),iStatus,iInfo);
|
|
127 |
|
|
128 |
SetActive();
|
|
129 |
}
|
|
130 |
|
|
131 |
// Used for identifying which AO is associated with a debugged process
|
|
132 |
const TDesC8& CSecuritySvrAsync::ProcessName(void)
|
|
133 |
{
|
|
134 |
LOG_MSG("CSecuritySvrAsync::ProcessName()");
|
|
135 |
return iProcessName;
|
|
136 |
}
|
|
137 |
|
|
138 |
// End of file - c_security_svr_async.cpp
|
|
139 |
|