EXPORT_C CAsyncHash* CAsyncHash::CopyL()
	{
	MAsyncHash* plugin=((MAsyncHash*)iPlugin)->CopyL();
	CleanupClosePushL(*plugin);
	RLibrary lib;
	lib.SetHandle(iLibHandle);
	RLibrary duplib=lib;
	User::LeaveIfError(duplib.Duplicate(RThread(), EOwnerProcess));
	CleanupClosePushL(duplib);
	CAsyncHash* self=new(ELeave) CAsyncHash(plugin, duplib.Handle());
	CleanupStack::Pop(2, plugin); //duplib, plugin
	return self;	
	}
/**
Gets the dll handle to SwpPolicy and initializes the SwpPolicy
*/
void CSsmSwpPolicyServer::CallSetDllHandleAndInitializeL(const RMessage2& aMessage, const TInt aSessionIndex)
	{
	__ASSERT_DEBUG(IN_RANGE(aSessionIndex, iSessionInfoArray.Count()), PanicNow(KSsmSwpPolicyBadIdx, KSsmSwpPolicySrvArrayIndexInvalid));

	RLibrary library;
	// Sets the swp policy library handle.  Library is owned by the CSsmSwpRequestHandler.
	library.SetHandle(aMessage.Int0());

	DEBUGPRINT1(_L("CSsmSwpPolicyServer: SwpPolicy handle is set"));
	iSessionInfoArray[aSessionIndex].iSwpPolicy = reinterpret_cast<MSsmSwpPolicy*>(library.Lookup(1)());

	DEBUGPRINT1(_L("CSsmSwpPolicyServer: Create CSsmSwpPolicyStepCompletion active object"));
	iSessionInfoArray[aSessionIndex].iSsmSwpPolicyStepCompletion = CSsmSwpPolicyStepCompletion::NewL(iSessionInfoArray[aSessionIndex].iSwpPolicy, *this, aSessionIndex);

	// aMessage will be completed in CSsmSwpPolicyStepCompletion's RunL method,
	// when the Initialization of the swp policy is completed.
	iSessionInfoArray[aSessionIndex].iSsmSwpPolicyStepCompletion->StartInitialize(aMessage);
	}