void CryptoSpiUtil::LoadPluginDllLC(RLibrary& aLib, TFileName& aFileName)
	{
	User::LeaveIfError(aLib.Load(aFileName));
	CleanupClosePushL(aLib);
	RLibrary plugin=aLib;
	CleanupClosePushL(plugin);
	User::LeaveIfError(aLib.Duplicate(RThread(), EOwnerProcess));
	CleanupStack::PopAndDestroy(&plugin);		
	}
Exemple #2
0
extern "C" TLinAddr GetEka1ExeEntryPoint()
	{
	TLinAddr a = 0;
	RLibrary l;
	TInt r = l.Load(KEka1EntryStubName, KNullDesC, TUidType(KDynamicLibraryUid, KEka1EntryStubUid));
	if (r == KErrNone)
		r = l.Duplicate(RThread(), EOwnerProcess);
	if (r == KErrNone)
		{
		a = (TLinAddr)l.Lookup(1);
		if (!a)
			r = KErrNotSupported;
		}
	if (r != KErrNone)
		RThread().Kill(r);
	Exec::SetReentryPoint(a);
	return a;
	}
/**
Construct a policy frame object based on the SWP value supplied

@param aSwp The swp to resolve
@return A policy frame containing a valid policy for the swp value
@leave KErrNotFound If the swp is not registered
@leave Any error returned from LoadLibraryLC
*/
CSsmSwpPolicyFrame* CSsmSwpPolicyResolver::GetSwpPolicyL(const TSsmSwp& aSwp)
	{
	TBuf<KMaxFileName + 2> libraryFilename; //KMaxFileName + KRomDriveLetter().Length()
	GetFileNameForSwpL(aSwp, libraryFilename);

	RLibrary library;
	LoadLibraryLC(library, libraryFilename);

	// make a process-owned copy of the handle as it has to be used by SsmSwpPolicyServer, 
	// which runs in a separate thread
	User::LeaveIfError(library.Duplicate(RThread(), EOwnerProcess));
	
	CSsmSwpPolicyFrame* policy = CreatePolicyLC(library);
	CleanupStack::Pop(policy);
	policy->SetLibrary(library); // takes ownership of open library handle
	CleanupStack::Pop(&library);
	policy->SetSwpKey(aSwp.Key());

	DEBUGPRINT2(_L("Created Swp Policy DLL %S"), &libraryFilename);

	return policy;
	}
CSsmSwpPolicyFrame* CSsmSwpTransitionEngineTest::GetSwpPolicyL(const TSsmSwp& aSwp)
	{
	RLibrary library;
	const TInt fileErr = library.Load(KTestSwpPolicyGenericFile);
	if (fileErr != KErrNone)
		{
		RDebug::Print(_L("Failed to load library file %S, file error-code: %d"), &KTestSwpPolicyGenericFile(), fileErr);
		User::Leave(fileErr);
		}
	
	// make a process-owned copy of the handle as it has to be used by SsmSwpPolicyServer, 
	// which runs in a separate thread
	User::LeaveIfError(library.Duplicate(RThread(), EOwnerProcess));
	
	CSsmSwpPolicyFrame* policy = CreatePolicyLC(library);
	CleanupStack::Pop(policy);
	policy->SetLibrary(library); // takes ownership of open library handle
	policy->SetSwpKey(aSwp.Key());
	
	RDebug::Print(_L("Created Swp Policy DLL %S"), &KTestSwpPolicyGenericFile());
	
	return policy;
	}