Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

Allow Configurator on secure desktop only (release mode) #95

Merged
merged 17 commits into from
Aug 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 2 additions & 15 deletions SharkCage/CageChooser/CageChooserForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 7 additions & 35 deletions SharkCage/CageChooser/CageChooserForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ private class NativeMethods
{
[DllImport("SharedFunctionality.dll", CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool SendConfigAndExternalProgram(
public static extern bool SendConfig(
[MarshalAs(UnmanagedType.LPWStr)] string config_path,
[MarshalAs(UnmanagedType.LPWStr)] StringBuilder result,
int max_result_length
Expand Down Expand Up @@ -53,7 +53,6 @@ private void LoadConfigList()
config_name_value_mapping.Add(value_name, value);
registeredConfigs.Items.Insert(registeredConfigs.Items.Count, value_name);
}

if (registeredConfigs.Items.Count > 0)
{
registeredConfigs.SelectedIndex = 0;
Expand Down Expand Up @@ -85,6 +84,11 @@ protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
return bHandled;
}

private void registeredConfigs_SelectedIndexChanged(object sender, EventArgs e)
{
openButton.Enabled = registeredConfigs.SelectedItem != null;
}

#endregion

#region Cage Service
Expand All @@ -102,7 +106,7 @@ private void SendToCage()
int capacity = 1000;
StringBuilder sb = new StringBuilder(capacity);

bool result = NativeMethods.SendConfigAndExternalProgram(config_path, sb, capacity);
bool result = NativeMethods.SendConfig(config_path, sb, capacity);

if (!result)
{
Expand All @@ -125,37 +129,5 @@ private void openButton_Click(object sender, EventArgs e)
}

#endregion

#region CageConfigurator

private void openCageConfiguratorButton_Click(object sender, EventArgs e)
{
var install_dir = Registry.GetValue(REGISTRY_KEY, "InstallDir", "") as string ?? String.Empty;

if (install_dir == String.Empty)
{
MessageBox.Show("Could not read installation directory from registry, opening CageConfigurator not possible", "Shark Cage", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}

var p = new System.Diagnostics.Process();
p.StartInfo.FileName = $@"{install_dir}\CageConfigurator.exe";

var selected_item = registeredConfigs.SelectedItem?.ToString() ?? String.Empty;
var config_path = String.Empty;
config_name_value_mapping.TryGetValue(selected_item, out config_path);
if (config_path != String.Empty)
{
p.StartInfo.Arguments = $@"""{config_path}""";
}
p.Start();
}

#endregion

private void registeredConfigs_SelectedIndexChanged(object sender, EventArgs e)
{
openButton.Enabled = registeredConfigs.SelectedItem != null;
}
}
}
3 changes: 0 additions & 3 deletions SharkCage/CageChooser/CageChooserForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,4 @@
<metadata name="refreshTooltip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="refreshTooltip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>
Loading