public InfoCardTraceRecord(string eventID, string message) { InfoCardTrace.Assert(!String.IsNullOrEmpty(eventID), "null eventid"); InfoCardTrace.Assert(!String.IsNullOrEmpty(message), "null message"); m_eventID = eventID; m_message = message; }
public InfoCardTraceRecord(string eventID, string message) { InfoCardTrace.Assert(!string.IsNullOrEmpty(eventID), "null eventid", new object[0]); InfoCardTrace.Assert(!string.IsNullOrEmpty(message), "null message", new object[0]); this.m_eventID = eventID; this.m_message = message; }
// // Summary: // Return the path to the v2 (or a version above v2) implementation dll. // We expect this to be infocardapi2.dll unless overriden by a registry key // // Remarks: It is left upto the caller to check if the v2+ implementation // dll actually exists or not. // private string GetV2ImplementationDllPath() { string v2AndAboveImplementationDll = String.Empty; // // First look in the registry key to see if this is defined // using (RegistryKey implDllKey = Registry.LocalMachine.OpenSubKey(REDIRECT_DLL_REG_KEY)) { if (null != implDllKey) { v2AndAboveImplementationDll = (string)implDllKey.GetValue(REDIRECT_DLL_IMPLEMENTATION_VALUE); if (!String.IsNullOrEmpty(v2AndAboveImplementationDll)) { string v2RegPath = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.System), v2AndAboveImplementationDll + ".dll"); // // Is the filename safe (use alphanumeric like the CSD Main 58552). Does it exist? // If not, discard the registry key we just read. // if (!IsSafeFile(v2AndAboveImplementationDll) || !File.Exists(v2RegPath)) { v2AndAboveImplementationDll = String.Empty; } } } } // // If reg key was not found or not safe, or value was not found, or found to be empty, // then use the default of infocardapi2.dll // if (String.IsNullOrEmpty(v2AndAboveImplementationDll)) { v2AndAboveImplementationDll = REDIRECT_DLL_IMPLEMENTATION_VALUE_DEFAULT; } IDT.Assert(!String.IsNullOrEmpty(v2AndAboveImplementationDll), "v2AndAboveImplementationDll should not be empty"); // // Get the full path to the v2Above dll // return(Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.System), v2AndAboveImplementationDll + ".dll")); }
// // GetBrowserToken not required because that is accomplished via Pheonix bit etc. (not exposed thru // managed interface). // // // Summary: // Performs initialization of the CardSpaceShim if necessary. // The v1 service will only allow one request from the user, // however locking anyway in case we change our behavior in v2. // public void InitializeIfNecessary() { if (!m_isInitialized) { lock (m_syncRoot) { if (!m_isInitialized) { string implDllPath = GetCardSpaceImplementationDll(); m_implementationDll = SafeLibraryHandle.LoadLibraryW(implDllPath); if (m_implementationDll.IsInvalid) { throw NativeMethods.ThrowWin32ExceptionWithContext(new Win32Exception(), implDllPath); } try { // // Functions are listed in alphabetical order // IntPtr procaddr1 = NativeMethods.GetProcAddressWrapper(m_implementationDll, "CloseCryptoHandle"); m_csShimCloseCryptoHandle = (CsV2CloseCryptoHandle)Marshal.GetDelegateForFunctionPointer( procaddr1, typeof(CsV2CloseCryptoHandle)); IntPtr procaddr2 = NativeMethods.GetProcAddressWrapper( m_implementationDll, "Decrypt"); m_csShimDecrypt = (CsV2Decrypt)Marshal.GetDelegateForFunctionPointer( procaddr2, typeof(CsV2Decrypt)); IntPtr procaddr3 = NativeMethods.GetProcAddressWrapper(m_implementationDll, "Encrypt"); m_csShimEncrypt = (CsV2Encrypt)Marshal.GetDelegateForFunctionPointer( procaddr3, typeof(CsV2Encrypt)); IntPtr procaddr4 = NativeMethods.GetProcAddressWrapper(m_implementationDll, "FreeToken"); m_csShimFreeToken = (CsV2FreeToken)Marshal.GetDelegateForFunctionPointer( procaddr4, typeof(CsV2FreeToken)); IntPtr procaddr5 = NativeMethods.GetProcAddressWrapper(m_implementationDll, "GenerateDerivedKey"); m_csShimGenerateDerivedKey = (CsV2GenerateDerivedKey)Marshal.GetDelegateForFunctionPointer( procaddr5, typeof(CsV2GenerateDerivedKey)); IntPtr procaddr6 = NativeMethods.GetProcAddressWrapper(m_implementationDll, "GetCryptoTransform"); m_csShimGetCryptoTransform = (CsV2GetCryptoTransform)Marshal.GetDelegateForFunctionPointer( procaddr6, typeof(CsV2GetCryptoTransform)); IntPtr procaddr7 = NativeMethods.GetProcAddressWrapper(m_implementationDll, "GetKeyedHash"); m_csShimGetKeyedHash = (CsV2GetKeyedHash)Marshal.GetDelegateForFunctionPointer( procaddr7, typeof(CsV2GetKeyedHash)); IntPtr procaddr8 = NativeMethods.GetProcAddressWrapper(m_implementationDll, "GetToken"); m_csShimGetToken = (CsV2GetToken)Marshal.GetDelegateForFunctionPointer( procaddr8, typeof(CsV2GetToken)); IntPtr procaddr9 = NativeMethods.GetProcAddressWrapper(m_implementationDll, "HashCore"); m_csShimHashCore = (CsV2HashCore)Marshal.GetDelegateForFunctionPointer( procaddr9, typeof(CsV2HashCore)); IntPtr procaddr10 = NativeMethods.GetProcAddressWrapper(m_implementationDll, "HashFinal"); m_csShimHashFinal = (CsV2HashFinal)Marshal.GetDelegateForFunctionPointer( procaddr10, typeof(CsV2HashFinal)); IntPtr procaddr11 = NativeMethods.GetProcAddressWrapper(m_implementationDll, "ImportInformationCard"); m_csShimImportInformationCard = (CsV2ImportInformationCard)Marshal.GetDelegateForFunctionPointer( procaddr11, typeof(CsV2ImportInformationCard)); IntPtr procaddr12 = NativeMethods.GetProcAddressWrapper(m_implementationDll, "ManageCardSpace"); m_csShimManageCardSpace = (CsV2ManageCardSpace)Marshal.GetDelegateForFunctionPointer( procaddr12, typeof(CsV2ManageCardSpace)); IntPtr procaddr13 = NativeMethods.GetProcAddressWrapper(m_implementationDll, "SignHash"); m_csShimSignHash = (CsV2SignHash)Marshal.GetDelegateForFunctionPointer( procaddr13, typeof(CsV2SignHash)); IntPtr procaddr14 = NativeMethods.GetProcAddressWrapper(m_implementationDll, "TransformBlock"); m_csShimTransformBlock = (CsV2TransformBlock)Marshal.GetDelegateForFunctionPointer( procaddr14, typeof(CsV2TransformBlock)); IntPtr procaddr15 = NativeMethods.GetProcAddressWrapper(m_implementationDll, "TransformFinalBlock"); m_csShimTransformFinalBlock = (CsV2TransformFinalBlock)Marshal.GetDelegateForFunctionPointer( procaddr15, typeof(CsV2TransformFinalBlock)); IntPtr procaddr16 = NativeMethods.GetProcAddressWrapper(m_implementationDll, "VerifyHash"); m_csShimVerifyHash = (CsV2VerifyHash)Marshal.GetDelegateForFunctionPointer( procaddr16, typeof(CsV2VerifyHash)); } catch (Win32Exception) { // // NB: IDT.ThrowHelperError would have logged for the Win32Exception // IDT.Assert(!m_isInitialized, "If an exception occurred, we expect this to be false"); throw; } m_isInitialized = true; } } } }
// // Summary: // Called back by the indigo diagnostic trace infrastructure during etw trace logging. // Writes the extendedData section out to the TraceRecord. // // internal override void WriteTo(XmlWriter writer) { InfoCardTrace.Assert(null != writer, "null writer"); writer.WriteElementString("message", m_message); }