コード例 #1
0
 public void InitializeIfNecessary()
 {
     if (!this.m_isInitialized)
     {
         lock (this.m_syncRoot)
         {
             if (!this.m_isInitialized)
             {
                 string cardSpaceImplementationDll = this.GetCardSpaceImplementationDll();
                 this.m_implementationDll = System.IdentityModel.Selectors.SafeLibraryHandle.LoadLibraryW(cardSpaceImplementationDll);
                 if (this.m_implementationDll.IsInvalid)
                 {
                     throw System.IdentityModel.Selectors.NativeMethods.ThrowWin32ExceptionWithContext(new Win32Exception(), cardSpaceImplementationDll);
                 }
                 try
                 {
                     IntPtr procAddressWrapper = System.IdentityModel.Selectors.NativeMethods.GetProcAddressWrapper(this.m_implementationDll, "CloseCryptoHandle");
                     this.m_csShimCloseCryptoHandle = (CsV2CloseCryptoHandle)Marshal.GetDelegateForFunctionPointer(procAddressWrapper, typeof(CsV2CloseCryptoHandle));
                     IntPtr ptr = System.IdentityModel.Selectors.NativeMethods.GetProcAddressWrapper(this.m_implementationDll, "Decrypt");
                     this.m_csShimDecrypt = (CsV2Decrypt)Marshal.GetDelegateForFunctionPointer(ptr, typeof(CsV2Decrypt));
                     IntPtr ptr3 = System.IdentityModel.Selectors.NativeMethods.GetProcAddressWrapper(this.m_implementationDll, "Encrypt");
                     this.m_csShimEncrypt = (CsV2Encrypt)Marshal.GetDelegateForFunctionPointer(ptr3, typeof(CsV2Encrypt));
                     IntPtr ptr4 = System.IdentityModel.Selectors.NativeMethods.GetProcAddressWrapper(this.m_implementationDll, "FreeToken");
                     this.m_csShimFreeToken = (CsV2FreeToken)Marshal.GetDelegateForFunctionPointer(ptr4, typeof(CsV2FreeToken));
                     IntPtr ptr5 = System.IdentityModel.Selectors.NativeMethods.GetProcAddressWrapper(this.m_implementationDll, "GenerateDerivedKey");
                     this.m_csShimGenerateDerivedKey = (CsV2GenerateDerivedKey)Marshal.GetDelegateForFunctionPointer(ptr5, typeof(CsV2GenerateDerivedKey));
                     IntPtr ptr6 = System.IdentityModel.Selectors.NativeMethods.GetProcAddressWrapper(this.m_implementationDll, "GetCryptoTransform");
                     this.m_csShimGetCryptoTransform = (CsV2GetCryptoTransform)Marshal.GetDelegateForFunctionPointer(ptr6, typeof(CsV2GetCryptoTransform));
                     IntPtr ptr7 = System.IdentityModel.Selectors.NativeMethods.GetProcAddressWrapper(this.m_implementationDll, "GetKeyedHash");
                     this.m_csShimGetKeyedHash = (CsV2GetKeyedHash)Marshal.GetDelegateForFunctionPointer(ptr7, typeof(CsV2GetKeyedHash));
                     IntPtr ptr8 = System.IdentityModel.Selectors.NativeMethods.GetProcAddressWrapper(this.m_implementationDll, "GetToken");
                     this.m_csShimGetToken = (CsV2GetToken)Marshal.GetDelegateForFunctionPointer(ptr8, typeof(CsV2GetToken));
                     IntPtr ptr9 = System.IdentityModel.Selectors.NativeMethods.GetProcAddressWrapper(this.m_implementationDll, "HashCore");
                     this.m_csShimHashCore = (CsV2HashCore)Marshal.GetDelegateForFunctionPointer(ptr9, typeof(CsV2HashCore));
                     IntPtr ptr10 = System.IdentityModel.Selectors.NativeMethods.GetProcAddressWrapper(this.m_implementationDll, "HashFinal");
                     this.m_csShimHashFinal = (CsV2HashFinal)Marshal.GetDelegateForFunctionPointer(ptr10, typeof(CsV2HashFinal));
                     IntPtr ptr11 = System.IdentityModel.Selectors.NativeMethods.GetProcAddressWrapper(this.m_implementationDll, "ImportInformationCard");
                     this.m_csShimImportInformationCard = (CsV2ImportInformationCard)Marshal.GetDelegateForFunctionPointer(ptr11, typeof(CsV2ImportInformationCard));
                     IntPtr ptr12 = System.IdentityModel.Selectors.NativeMethods.GetProcAddressWrapper(this.m_implementationDll, "ManageCardSpace");
                     this.m_csShimManageCardSpace = (CsV2ManageCardSpace)Marshal.GetDelegateForFunctionPointer(ptr12, typeof(CsV2ManageCardSpace));
                     IntPtr ptr13 = System.IdentityModel.Selectors.NativeMethods.GetProcAddressWrapper(this.m_implementationDll, "SignHash");
                     this.m_csShimSignHash = (CsV2SignHash)Marshal.GetDelegateForFunctionPointer(ptr13, typeof(CsV2SignHash));
                     IntPtr ptr14 = System.IdentityModel.Selectors.NativeMethods.GetProcAddressWrapper(this.m_implementationDll, "TransformBlock");
                     this.m_csShimTransformBlock = (CsV2TransformBlock)Marshal.GetDelegateForFunctionPointer(ptr14, typeof(CsV2TransformBlock));
                     IntPtr ptr15 = System.IdentityModel.Selectors.NativeMethods.GetProcAddressWrapper(this.m_implementationDll, "TransformFinalBlock");
                     this.m_csShimTransformFinalBlock = (CsV2TransformFinalBlock)Marshal.GetDelegateForFunctionPointer(ptr15, typeof(CsV2TransformFinalBlock));
                     IntPtr ptr16 = System.IdentityModel.Selectors.NativeMethods.GetProcAddressWrapper(this.m_implementationDll, "VerifyHash");
                     this.m_csShimVerifyHash = (CsV2VerifyHash)Marshal.GetDelegateForFunctionPointer(ptr16, typeof(CsV2VerifyHash));
                 }
                 catch (Win32Exception)
                 {
                     InfoCardTrace.Assert(!this.m_isInitialized, "If an exception occurred, we expect this to be false", new object[0]);
                     throw;
                 }
                 this.m_isInitialized = true;
             }
         }
     }
 }
コード例 #2
0
 public void InitializeIfNecessary()
 {
     if (!this.m_isInitialized)
     {
         lock (this.m_syncRoot)
         {
             if (!this.m_isInitialized)
             {
                 string cardSpaceImplementationDll = this.GetCardSpaceImplementationDll();
                 this.m_implementationDll = System.IdentityModel.Selectors.SafeLibraryHandle.LoadLibraryW(cardSpaceImplementationDll);
                 if (this.m_implementationDll.IsInvalid)
                 {
                     throw System.IdentityModel.Selectors.NativeMethods.ThrowWin32ExceptionWithContext(new Win32Exception(), cardSpaceImplementationDll);
                 }
                 try
                 {
                     IntPtr procAddressWrapper = System.IdentityModel.Selectors.NativeMethods.GetProcAddressWrapper(this.m_implementationDll, "CloseCryptoHandle");
                     this.m_csShimCloseCryptoHandle = (CsV2CloseCryptoHandle) Marshal.GetDelegateForFunctionPointer(procAddressWrapper, typeof(CsV2CloseCryptoHandle));
                     IntPtr ptr = System.IdentityModel.Selectors.NativeMethods.GetProcAddressWrapper(this.m_implementationDll, "Decrypt");
                     this.m_csShimDecrypt = (CsV2Decrypt) Marshal.GetDelegateForFunctionPointer(ptr, typeof(CsV2Decrypt));
                     IntPtr ptr3 = System.IdentityModel.Selectors.NativeMethods.GetProcAddressWrapper(this.m_implementationDll, "Encrypt");
                     this.m_csShimEncrypt = (CsV2Encrypt) Marshal.GetDelegateForFunctionPointer(ptr3, typeof(CsV2Encrypt));
                     IntPtr ptr4 = System.IdentityModel.Selectors.NativeMethods.GetProcAddressWrapper(this.m_implementationDll, "FreeToken");
                     this.m_csShimFreeToken = (CsV2FreeToken) Marshal.GetDelegateForFunctionPointer(ptr4, typeof(CsV2FreeToken));
                     IntPtr ptr5 = System.IdentityModel.Selectors.NativeMethods.GetProcAddressWrapper(this.m_implementationDll, "GenerateDerivedKey");
                     this.m_csShimGenerateDerivedKey = (CsV2GenerateDerivedKey) Marshal.GetDelegateForFunctionPointer(ptr5, typeof(CsV2GenerateDerivedKey));
                     IntPtr ptr6 = System.IdentityModel.Selectors.NativeMethods.GetProcAddressWrapper(this.m_implementationDll, "GetCryptoTransform");
                     this.m_csShimGetCryptoTransform = (CsV2GetCryptoTransform) Marshal.GetDelegateForFunctionPointer(ptr6, typeof(CsV2GetCryptoTransform));
                     IntPtr ptr7 = System.IdentityModel.Selectors.NativeMethods.GetProcAddressWrapper(this.m_implementationDll, "GetKeyedHash");
                     this.m_csShimGetKeyedHash = (CsV2GetKeyedHash) Marshal.GetDelegateForFunctionPointer(ptr7, typeof(CsV2GetKeyedHash));
                     IntPtr ptr8 = System.IdentityModel.Selectors.NativeMethods.GetProcAddressWrapper(this.m_implementationDll, "GetToken");
                     this.m_csShimGetToken = (CsV2GetToken) Marshal.GetDelegateForFunctionPointer(ptr8, typeof(CsV2GetToken));
                     IntPtr ptr9 = System.IdentityModel.Selectors.NativeMethods.GetProcAddressWrapper(this.m_implementationDll, "HashCore");
                     this.m_csShimHashCore = (CsV2HashCore) Marshal.GetDelegateForFunctionPointer(ptr9, typeof(CsV2HashCore));
                     IntPtr ptr10 = System.IdentityModel.Selectors.NativeMethods.GetProcAddressWrapper(this.m_implementationDll, "HashFinal");
                     this.m_csShimHashFinal = (CsV2HashFinal) Marshal.GetDelegateForFunctionPointer(ptr10, typeof(CsV2HashFinal));
                     IntPtr ptr11 = System.IdentityModel.Selectors.NativeMethods.GetProcAddressWrapper(this.m_implementationDll, "ImportInformationCard");
                     this.m_csShimImportInformationCard = (CsV2ImportInformationCard) Marshal.GetDelegateForFunctionPointer(ptr11, typeof(CsV2ImportInformationCard));
                     IntPtr ptr12 = System.IdentityModel.Selectors.NativeMethods.GetProcAddressWrapper(this.m_implementationDll, "ManageCardSpace");
                     this.m_csShimManageCardSpace = (CsV2ManageCardSpace) Marshal.GetDelegateForFunctionPointer(ptr12, typeof(CsV2ManageCardSpace));
                     IntPtr ptr13 = System.IdentityModel.Selectors.NativeMethods.GetProcAddressWrapper(this.m_implementationDll, "SignHash");
                     this.m_csShimSignHash = (CsV2SignHash) Marshal.GetDelegateForFunctionPointer(ptr13, typeof(CsV2SignHash));
                     IntPtr ptr14 = System.IdentityModel.Selectors.NativeMethods.GetProcAddressWrapper(this.m_implementationDll, "TransformBlock");
                     this.m_csShimTransformBlock = (CsV2TransformBlock) Marshal.GetDelegateForFunctionPointer(ptr14, typeof(CsV2TransformBlock));
                     IntPtr ptr15 = System.IdentityModel.Selectors.NativeMethods.GetProcAddressWrapper(this.m_implementationDll, "TransformFinalBlock");
                     this.m_csShimTransformFinalBlock = (CsV2TransformFinalBlock) Marshal.GetDelegateForFunctionPointer(ptr15, typeof(CsV2TransformFinalBlock));
                     IntPtr ptr16 = System.IdentityModel.Selectors.NativeMethods.GetProcAddressWrapper(this.m_implementationDll, "VerifyHash");
                     this.m_csShimVerifyHash = (CsV2VerifyHash) Marshal.GetDelegateForFunctionPointer(ptr16, typeof(CsV2VerifyHash));
                 }
                 catch (Win32Exception)
                 {
                     InfoCardTrace.Assert(!this.m_isInitialized, "If an exception occurred, we expect this to be false", new object[0]);
                     throw;
                 }
                 this.m_isInitialized = true;
             }
         }
     }
 }