public override void Install() { FileInfo dll = null; if (Abstractions.Windows.OsInfo.Is64Bit()) { dll = DllUtils.Find64BitDll(this.CpInfo.Path, this.CpInfo.ShortName); } else { dll = DllUtils.Find32BitDll(this.CpInfo.Path, this.CpInfo.ShortName); } if (dll != null) { using (RegistryKey key = Registry.LocalMachine.OpenSubKey(GINA_KEY, true)) { if (key != null) { key.SetValue("GinaDLL", dll.FullName); key.SetValue("NoDomainUI", 1); key.SetValue("DontDisplayLastUserName", 1); } } } else { throw new Exception("GINA DLL not found in " + CpInfo.Path); } }
public static FileInfo Find32BitDll(string path, string baseName) { if (!baseName.EndsWith(".dll", StringComparison.CurrentCultureIgnoreCase)) { baseName += ".dll"; } // Check path directory string fullPath = Path.Combine(path, baseName); if (File.Exists(fullPath)) { if (!DllUtils.Is64BitDll(fullPath)) { return(new FileInfo(fullPath)); } } // Check Win32 subdirectory fullPath = Path.Combine(path, "Win32", baseName); if (File.Exists(fullPath)) { if (!DllUtils.Is64BitDll(fullPath)) { return(new FileInfo(fullPath)); } } return(null); }
public override void Install() { m_logger.InfoFormat("Installing credential provider {0} {{{1}}}", CpInfo.ShortName, CpInfo.ProviderGuid.ToString()); // Copy the DLL if (Abstractions.Windows.OsInfo.Is64Bit()) // Are we on a 64 bit OS? { m_logger.DebugFormat("Win64: Searching for DLLs ({0}, {1})", CpInfo.Path, CpInfo.ShortName); FileInfo x64Dll = DllUtils.Find64BitDll(CpInfo.Path, CpInfo.ShortName); FileInfo x32Dll = DllUtils.Find32BitDll(CpInfo.Path, CpInfo.ShortName); string destination64 = GetCpDllPath(); string destination32 = GetCpDllPath6432(); if (x64Dll == null && x32Dll == null) { throw new Exception("No 64 or 32 bit DLL found in: " + CpInfo.Path); } if (x64Dll != null) { m_logger.DebugFormat("Found 64 bit DLL: {0}", x64Dll.FullName); m_logger.DebugFormat(" copying to: {0}", destination64); File.Copy(x64Dll.FullName, destination64, true); } else { m_logger.Error("WARNING: No 64 bit DLL found."); } if (x32Dll != null) { m_logger.DebugFormat("Found 32 bit DLL: {0}", x32Dll.FullName); m_logger.DebugFormat(" copying to: {0}", destination32); File.Copy(x32Dll.FullName, destination32, true); // Write registry keys for 32 bit DLL // The provider using (RegistryKey key = Registry.LocalMachine.CreateSubKey(this.ProviderKey6432)) { key.SetValue("", CpInfo.ShortName); } // The provider filter using (RegistryKey key = Registry.LocalMachine.CreateSubKey(this.CredentialProviderFilterKey6432)) { key.SetValue("", CpInfo.ShortName); } } else { m_logger.Error("WARNING: No 32 bit DLL found."); } } else { m_logger.DebugFormat("Win32: Searching for DLLs ({0}, {1})", CpInfo.Path, CpInfo.ShortName); FileInfo x32Dll = DllUtils.Find32BitDll(CpInfo.Path, CpInfo.ShortName); string destination = GetCpDllPath(); if (x32Dll != null) { m_logger.DebugFormat("Found 32 bit DLL: {0}", x32Dll.FullName); m_logger.DebugFormat(" copying to: {0}", destination); File.Copy(x32Dll.FullName, destination, true); } else { throw new Exception("No 32 bit DLL found in: " + CpInfo.Path); } } m_logger.Debug("Writing registry entries..."); // Write registry values using (RegistryKey key = Registry.LocalMachine.CreateSubKey(this.ProviderKey)) { m_logger.DebugFormat("{0} @=> {1}", key.ToString(), CpInfo.ShortName); key.SetValue("", CpInfo.ShortName); } using (RegistryKey key = Registry.LocalMachine.CreateSubKey(this.CredentialProviderFilterKey)) { m_logger.DebugFormat("{0} @=> {1}", key.ToString(), CpInfo.ShortName); key.SetValue("", CpInfo.ShortName); } using (RegistryKey key = Registry.ClassesRoot.CreateSubKey(this.ClsidRoot)) { m_logger.DebugFormat("{0} @=> {1}", key.ToString(), CpInfo.ShortName); key.SetValue("", CpInfo.ShortName); } using (RegistryKey key = Registry.ClassesRoot.CreateSubKey(this.ClsidInProc)) { m_logger.DebugFormat("{0} @=> {1}", key.ToString(), CpInfo.ShortName); key.SetValue("", CpInfo.ShortName); m_logger.DebugFormat("{0} {1} => {2}", key.ToString(), "ThreadingModel", "Apartment"); key.SetValue("ThreadingModel", "Apartment"); } }