Skip to content

Commit 207d27e

Browse files
committed
enhanced reliability + installer experience
1 parent b6616b5 commit 207d27e

File tree

10 files changed

+1343
-25
lines changed

10 files changed

+1343
-25
lines changed

BSCP/.vs/BSCP/v14/.suo

5.5 KB
Binary file not shown.

BSCP/BSCP.sln

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RegProvider", "RegProvider\
99
EndProject
1010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Configurator", "Configurator\Configurator.csproj", "{F3A59C01-A7A7-45E6-914A-8206C8DA02F9}"
1111
EndProject
12-
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SampleV2CredentialProvider", "CredentialProvider\SampleV2CredentialProvider.vcxproj", "{98E74D71-5237-41FA-8D36-206C0D110626}"
13-
EndProject
1412
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ConfigurableShell", "ConfigurableShell\ConfigurableShell.vcxproj", "{B8642BA3-D582-4F2B-9CB5-5CD5C089D76F}"
1513
EndProject
14+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BootShellCredentialProvider", "CredentialProvider\BootShellCredentialProvider.vcxproj", "{98E74D71-5237-41FA-8D36-206C0D110626}"
15+
EndProject
16+
Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "Winstaller", "Winstaller\Winstaller.vdproj", "{EDCE4E9D-3C5C-433D-87B0-0D296D5907E5}"
17+
EndProject
1618
Global
1719
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1820
Debug|Any CPU = Debug|Any CPU
@@ -66,19 +68,6 @@ Global
6668
{F3A59C01-A7A7-45E6-914A-8206C8DA02F9}.Release|x64.Build.0 = Release|Any CPU
6769
{F3A59C01-A7A7-45E6-914A-8206C8DA02F9}.Release|x86.ActiveCfg = Release|Any CPU
6870
{F3A59C01-A7A7-45E6-914A-8206C8DA02F9}.Release|x86.Build.0 = Release|Any CPU
69-
{98E74D71-5237-41FA-8D36-206C0D110626}.Debug|Any CPU.ActiveCfg = Debug|Win32
70-
{98E74D71-5237-41FA-8D36-206C0D110626}.Debug|ARM.ActiveCfg = Debug|Win32
71-
{98E74D71-5237-41FA-8D36-206C0D110626}.Debug|x64.ActiveCfg = Debug|x64
72-
{98E74D71-5237-41FA-8D36-206C0D110626}.Debug|x64.Build.0 = Debug|x64
73-
{98E74D71-5237-41FA-8D36-206C0D110626}.Debug|x86.ActiveCfg = Debug|Win32
74-
{98E74D71-5237-41FA-8D36-206C0D110626}.Debug|x86.Build.0 = Debug|Win32
75-
{98E74D71-5237-41FA-8D36-206C0D110626}.Release|Any CPU.ActiveCfg = Release|Win32
76-
{98E74D71-5237-41FA-8D36-206C0D110626}.Release|ARM.ActiveCfg = Release|Win32
77-
{98E74D71-5237-41FA-8D36-206C0D110626}.Release|x64.ActiveCfg = Release|x64
78-
{98E74D71-5237-41FA-8D36-206C0D110626}.Release|x64.Build.0 = Release|x64
79-
{98E74D71-5237-41FA-8D36-206C0D110626}.Release|x64.Deploy.0 = Release|x64
80-
{98E74D71-5237-41FA-8D36-206C0D110626}.Release|x86.ActiveCfg = Release|Win32
81-
{98E74D71-5237-41FA-8D36-206C0D110626}.Release|x86.Build.0 = Release|Win32
8271
{B8642BA3-D582-4F2B-9CB5-5CD5C089D76F}.Debug|Any CPU.ActiveCfg = Debug|Win32
8372
{B8642BA3-D582-4F2B-9CB5-5CD5C089D76F}.Debug|ARM.ActiveCfg = Debug|Win32
8473
{B8642BA3-D582-4F2B-9CB5-5CD5C089D76F}.Debug|x64.ActiveCfg = Debug|x64
@@ -91,6 +80,26 @@ Global
9180
{B8642BA3-D582-4F2B-9CB5-5CD5C089D76F}.Release|x64.Build.0 = Release|x64
9281
{B8642BA3-D582-4F2B-9CB5-5CD5C089D76F}.Release|x86.ActiveCfg = Release|Win32
9382
{B8642BA3-D582-4F2B-9CB5-5CD5C089D76F}.Release|x86.Build.0 = Release|Win32
83+
{98E74D71-5237-41FA-8D36-206C0D110626}.Debug|Any CPU.ActiveCfg = Debug|Win32
84+
{98E74D71-5237-41FA-8D36-206C0D110626}.Debug|ARM.ActiveCfg = Debug|Win32
85+
{98E74D71-5237-41FA-8D36-206C0D110626}.Debug|x64.ActiveCfg = Debug|x64
86+
{98E74D71-5237-41FA-8D36-206C0D110626}.Debug|x64.Build.0 = Debug|x64
87+
{98E74D71-5237-41FA-8D36-206C0D110626}.Debug|x86.ActiveCfg = Debug|Win32
88+
{98E74D71-5237-41FA-8D36-206C0D110626}.Debug|x86.Build.0 = Debug|Win32
89+
{98E74D71-5237-41FA-8D36-206C0D110626}.Release|Any CPU.ActiveCfg = Release|Win32
90+
{98E74D71-5237-41FA-8D36-206C0D110626}.Release|ARM.ActiveCfg = Release|Win32
91+
{98E74D71-5237-41FA-8D36-206C0D110626}.Release|x64.ActiveCfg = Release|x64
92+
{98E74D71-5237-41FA-8D36-206C0D110626}.Release|x64.Build.0 = Release|x64
93+
{98E74D71-5237-41FA-8D36-206C0D110626}.Release|x86.ActiveCfg = Release|Win32
94+
{98E74D71-5237-41FA-8D36-206C0D110626}.Release|x86.Build.0 = Release|Win32
95+
{EDCE4E9D-3C5C-433D-87B0-0D296D5907E5}.Debug|Any CPU.ActiveCfg = Debug
96+
{EDCE4E9D-3C5C-433D-87B0-0D296D5907E5}.Debug|ARM.ActiveCfg = Debug
97+
{EDCE4E9D-3C5C-433D-87B0-0D296D5907E5}.Debug|x64.ActiveCfg = Debug
98+
{EDCE4E9D-3C5C-433D-87B0-0D296D5907E5}.Debug|x86.ActiveCfg = Debug
99+
{EDCE4E9D-3C5C-433D-87B0-0D296D5907E5}.Release|Any CPU.ActiveCfg = Release
100+
{EDCE4E9D-3C5C-433D-87B0-0D296D5907E5}.Release|ARM.ActiveCfg = Release
101+
{EDCE4E9D-3C5C-433D-87B0-0D296D5907E5}.Release|x64.ActiveCfg = Release
102+
{EDCE4E9D-3C5C-433D-87B0-0D296D5907E5}.Release|x86.ActiveCfg = Release
94103
EndGlobalSection
95104
GlobalSection(SolutionProperties) = preSolution
96105
HideSolutionNode = FALSE

BSCP/ConfigurableShell/ConfigurableShell.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
118118
WCHAR* xming_val = prov.pwszGetValueAt_sz(s_RegistryKey_Shell, TEXT("xming"), &cbXming, &ccXming);
119119
//execute shell command
120120
if (_wcsicmp(xming_val, TEXT("true")) == 0) {
121-
char* x = "C:\\Program Files (x86)\\Xming\\Xming.exe :0 -clipboard -fullscreen";
121+
//char* x = "C:\\Program Files (x86)\\Xming\\Xming.exe :0 -clipboard -fullscreen";
122+
char* x = "C:\\Program Files\\VcXsrv\\vcxsrv.exe :0 -clipboard -fullscreen -wgl";
122123
WinExec(x, SW_SHOW);
123124
}
124125
result = prov.EnsureKeyValueSet_sz(s_WinlogonKey, s_WinLogonValue, TEXT("explorer.exe"), &length_logon_value);

BSCP/Configurator/Configurator.csproj

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
1515
<WarningLevel>4</WarningLevel>
1616
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
17+
<IsWebBootstrapper>false</IsWebBootstrapper>
1718
<PublishUrl>publish\</PublishUrl>
1819
<Install>true</Install>
1920
<InstallFrom>Disk</InstallFrom>
@@ -26,7 +27,6 @@
2627
<MapFileExtensions>true</MapFileExtensions>
2728
<ApplicationRevision>0</ApplicationRevision>
2829
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
29-
<IsWebBootstrapper>false</IsWebBootstrapper>
3030
<UseApplicationTrust>false</UseApplicationTrust>
3131
<BootstrapperEnabled>true</BootstrapperEnabled>
3232
</PropertyGroup>
@@ -64,6 +64,9 @@
6464
<PropertyGroup>
6565
<ApplicationIcon>favicon.ico</ApplicationIcon>
6666
</PropertyGroup>
67+
<PropertyGroup>
68+
<StartupObject>Configurator.App</StartupObject>
69+
</PropertyGroup>
6770
<ItemGroup>
6871
<Reference Include="System" />
6972
<Reference Include="System.Data" />
@@ -117,12 +120,18 @@
117120
<Generator>ResXFileCodeGenerator</Generator>
118121
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
119122
</EmbeddedResource>
123+
<Content Include="mate.sh">
124+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
125+
</Content>
120126
<None Include="Properties\app.manifest" />
121127
<None Include="Properties\Settings.settings">
122128
<Generator>SettingsSingleFileGenerator</Generator>
123129
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
124130
</None>
125131
<AppDesigner Include="Properties\" />
132+
<Content Include="wsl_setup.sh">
133+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
134+
</Content>
126135
</ItemGroup>
127136
<ItemGroup>
128137
<None Include="App.config" />
@@ -142,6 +151,11 @@
142151
<ItemGroup>
143152
<Resource Include="favicon.ico" />
144153
</ItemGroup>
154+
<ItemGroup>
155+
<Content Include="ico.ico">
156+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
157+
</Content>
158+
</ItemGroup>
145159
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
146160
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
147161
Other similar extension points exist, see Microsoft.Common.targets.

BSCP/Configurator/MainWindow.xaml.cs

Lines changed: 54 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
using System.Windows.Navigation;
1515
using System.Windows.Shapes;
1616
using Microsoft.Win32;
17+
using System.Security.AccessControl;
1718

1819
namespace Configurator
1920
{
@@ -26,18 +27,38 @@ public partial class MainWindow : Window
2627
ObservableCollection<ConfigModel> context;
2728
static string credential_provider_guid = "ad471e7d-5bb2-4863-b317-faf3ad0f4d9d"; //identifies credential provider to system
2829
static string credential_key = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Authentication\\Credential Providers\\";
30+
static string credential_key_s = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Authentication\\Credential Providers";
2931
static string cp_name = "BootShellCredentialProvider";
3032
static string class_root_key = "HKEY_CLASSES_ROOT\\CLSID\\{" + credential_provider_guid + "}";
31-
32-
33+
static string userInitSetting = "C:\\Windows\\System32\\Userinit.exe,ConfigurableShell.exe";
34+
static string userInitSetting_reset = "C:\\Windows\\System32\\Userinit.exe,";
35+
static string winlogonKey = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\WinLogon";
36+
static string winlogonKey_full = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\WinLogon";
37+
public static string app_key_base_light = "SOFTWARE\\Castle\\BootShellCredentialProvider\\Shells";
3338
public MainWindow()
3439
{
3540
context = new ObservableCollection<ConfigModel>();
36-
37-
context.Add(new ConfigModel("Unity", "-c \"cd ~/ && ./unity.sh\"", "bash.exe"));
38-
context.Add(new ConfigModel("XFCE", "-c \"cd ~/ && ./xfce.sh\"", "bash.exe"));
39-
context.Add(new ConfigModel("Cinnamon", "-c \"cd ~/ && ./cinnamon.sh\"", "bash.exe"));
40-
context.Add(new ConfigModel("Windows Explorer", "/C \"explorer.exe\"", "cmd.exe", false));
41+
var hkcl = Microsoft.Win32.Registry.LocalMachine;
42+
try
43+
{
44+
//load settings if present
45+
var subkey = hkcl.OpenSubKey(app_key_base_light, true);
46+
var subkeys = subkey.GetSubKeyNames();
47+
foreach (var k in subkeys)
48+
{
49+
context.Add(new ConfigModel(k, "x", "y"));
50+
}
51+
} catch (ArgumentException)
52+
{
53+
//create defaults otherwise
54+
context.Add(new ConfigModel("Unity", "-c \"cd ~/ && ./unity.sh\"", "bash.exe"));
55+
context.Add(new ConfigModel("XFCE", "-c \"cd ~/ && ./xfce.sh\"", "bash.exe"));
56+
context.Add(new ConfigModel("Cinnamon", "-c \"cd ~/ && ./cinnamon.sh\"", "bash.exe"));
57+
context.Add(new ConfigModel("Mate", "-c \"cd ~/ && ./mate.sh\"", "bash.exe"));
58+
context.Add(new ConfigModel("Windows Explorer", "/C \"explorer.exe\"", "cmd.exe", false));
59+
}
60+
61+
4162

4263
InitializeComponent();
4364
lstView.ItemsSource = context;
@@ -59,6 +80,25 @@ private void Save_button_click(object sender, RoutedEventArgs e)
5980
Registry.SetValue(class_root_key, "", cp_name);
6081
Registry.SetValue(class_root_key + "\\InprocServer32", "ThreadingModel", "Apartment");
6182
Registry.SetValue(class_root_key + "\\InprocServer32", "", cp_name + ".dll");
83+
//Take ownership of WinLogon Key & update userinit
84+
try
85+
{
86+
string user = Environment.UserDomainName + "\\" + Environment.UserName;
87+
var hklm = Microsoft.Win32.Registry.LocalMachine;
88+
var rs = new RegistrySecurity();
89+
rs.AddAccessRule(new RegistryAccessRule(user,
90+
RegistryRights.FullControl,
91+
InheritanceFlags.None,
92+
PropagationFlags.None,
93+
AccessControlType.Allow));
94+
95+
var subkey = hklm.OpenSubKey(winlogonKey, true);
96+
subkey.SetAccessControl(rs);
97+
//update UserInit setting
98+
99+
Registry.SetValue(winlogonKey_full, "Userinit", userInitSetting);
100+
}
101+
catch (UnauthorizedAccessException) { return; };
62102
}
63103

64104
private void Reset_button_Click(object sender, RoutedEventArgs e)
@@ -103,7 +143,7 @@ private void Disable_button_Click(object sender, RoutedEventArgs e)
103143
var hklm = Microsoft.Win32.Registry.LocalMachine;
104144
try
105145
{
106-
var subkey = hklm.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Authentication\\Credential Providers", true);
146+
var subkey = hklm.OpenSubKey(credential_key_s, true);
107147
subkey.DeleteSubKey("{" + credential_provider_guid + "}");
108148
}
109149
catch (ArgumentException) { }
@@ -115,6 +155,12 @@ private void Disable_button_Click(object sender, RoutedEventArgs e)
115155
var parent_key = hkcl.OpenSubKey("CLSID", true);
116156
parent_key.DeleteSubKey("{" + credential_provider_guid + "}");
117157
} catch (ArgumentException) { }
158+
159+
//unregister configurableShell
160+
try
161+
{
162+
Registry.SetValue(winlogonKey_full, "Userinit", userInitSetting_reset);
163+
} catch (ArgumentException) { }
118164
}
119165

120166
private void New_Button_Click(object sender, RoutedEventArgs e)

BSCP/Configurator/ico.ico

32.2 KB
Binary file not shown.

0 commit comments

Comments
 (0)