|
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 "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 // amastarterexe.cpp |
|
15 // |
|
16 // |
|
17 |
|
18 |
|
19 #include <e32std.h> |
|
20 #include "amastartexe_patch.h" |
|
21 #include "amastart.h" |
|
22 |
|
23 LOCAL_C void AmaStarterL() |
|
24 { |
|
25 //The application should have capabilities at least what AMAStarter has (PowerMgmt, ReadDeviceData, ProtServ) |
|
26 //to prevent a process being able to get AMAStarter to perform operations it doesn't have the capabilities for. |
|
27 //The application should also have SID as expected to ensure that AMAStarter.exe cannot be launched by a malicious process |
|
28 if(!User::CreatorHasCapability(ECapabilityPowerMgmt, ECapabilityProtServ) || |
|
29 !User::CreatorHasCapability(ECapabilityReadDeviceData)|| |
|
30 (User::CreatorSecureId() != KSysStartSID)) |
|
31 { |
|
32 User::Leave(KErrPermissionDenied); // make sure we are being called by a trusted app for startup purposes |
|
33 } |
|
34 |
|
35 CAmaStart* const amaStart = CAmaStart::NewL(); |
|
36 CleanupStack::PushL(amaStart); |
|
37 |
|
38 //default DSC |
|
39 TUid id = TUid::Uid(KDefaultSymbianDsc); |
|
40 const TInt commandSize=User::CommandLineLength(); |
|
41 if (commandSize >0) |
|
42 { |
|
43 RBuf command; |
|
44 command.CreateL(commandSize); |
|
45 CleanupClosePushL(command); |
|
46 |
|
47 //get the command line argument |
|
48 User::CommandLine(command); |
|
49 |
|
50 TLex lex(command); |
|
51 TUint dscId=0; |
|
52 |
|
53 //Parses the string to extract a TUint32, using hexadecimal |
|
54 User::LeaveIfError(lex.Val(dscId, EHex)); |
|
55 id=TUid::Uid(dscId); |
|
56 |
|
57 CleanupStack::PopAndDestroy(&command); |
|
58 } |
|
59 |
|
60 amaStart->StartL(id); |
|
61 CleanupStack::PopAndDestroy(amaStart); |
|
62 } |
|
63 |
|
64 |
|
65 GLDEF_C TInt E32Main() |
|
66 { |
|
67 __UHEAP_MARK; // mark heap state |
|
68 |
|
69 CTrapCleanup* theTrapCleanup=CTrapCleanup::New(); |
|
70 |
|
71 TInt error=KErrNoMemory; |
|
72 |
|
73 if (theTrapCleanup) |
|
74 { |
|
75 TRAP(error, AmaStarterL()); |
|
76 delete theTrapCleanup; |
|
77 } |
|
78 |
|
79 __UHEAP_MARKEND; // check no memory leak |
|
80 |
|
81 return(error); |
|
82 } |