Skip to content

Commit

Permalink
Update permissions granter to create and grant access to registry key…
Browse files Browse the repository at this point in the history
…s, update command line documentation. Started adding licenses. Changed LAA text to Installing Fixes for Mass Effect. Added code to remove admin /xpsp3 compatibility settings for ME1. Added flyout after install for ME1/ME2 if game has origin-only files in it telling user not to update. Added permissions check for ME1's AGEIA technologies key for upcoming fix for origin and steam users.
  • Loading branch information
Mgamerz committed Jan 28, 2018
1 parent 75a90bd commit e74561a
Show file tree
Hide file tree
Showing 12 changed files with 274 additions and 26 deletions.
4 changes: 4 additions & 0 deletions AlotAddOnGUI/AlotAddOnGUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@
<Content Include="7z\7z.exe">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Resource Include="images\origin\me1update.png" />
<Resource Include="images\origin\me2update.png" />
<Resource Include="licenses\nvorbis.txt" />
<Resource Include="licenses\erikjs-binkw32.txt" />
<None Include="licenses\IndirectSound.txt" />
<Resource Include="images\me2_bg_alt.jpg" />
<None Include="Data\bin\PermissionsGranter.exe">
Expand Down
Binary file modified AlotAddOnGUI/Data/bin/PermissionsGranter.exe
Binary file not shown.
57 changes: 57 additions & 0 deletions AlotAddOnGUI/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@

<TextBlock Margin="20,0,0,0" Padding="10,0,0,2" Text="Mass Effect Wiki" ToolTip="This program uses content from the Mass Effect wiki at FANDOM and is licensed under the Creative Commons Attribution-Share Alike License." HorizontalAlignment="Left"/>
<TextBlock Margin="20,0,0,0" Padding="10,0,0,2" Text="ME3Tweaks" ToolTip="Powers the log uploading service to Pastebin" HorizontalAlignment="Left"/>
<TextBlock Margin="20,0,0,0" Padding="10,0,0,2" Text="Erik JS" ToolTip="Developer of binkw32 ASI plugins for ME2 and ME3" HorizontalAlignment="Left"/>
<TextBlock Margin="20,0,0,0" Padding="10,0,0,2" Text="John-Paul Ownby " ToolTip="Developer of IndirectSound. Used to fix audio bugs in Mass Effect" HorizontalAlignment="Left"/>

</StackPanel>
</Expander>
Expand Down Expand Up @@ -497,6 +499,61 @@
</StackPanel>
</StackPanel>
</Controls:Flyout>
<Controls:Flyout x:Name="OriginWarningFlyout" SnapsToDevicePixels="True" TitleVisibility="Hidden" Theme="Accent" CloseButtonVisibility="Hidden" Position="Left" Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Controls:MetroWindow}, Path=ActualWidth}" Height="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Controls:MetroWindow}, Path=ActualHeight}" MouseDoubleClick="InstallingOverlayoutFlyout_DoubleClick" MouseDown="InstallingOverlayFlyout_MouseDown">
<Border x:Name="OriginWarningFlyout_Border" Background="#1e262c" >
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<Image x:Name="OriginWarning_Image" Source="images/origin/me1update.png" Stretch="None"/>
<TextBlock Foreground="#c3c6ce" TextAlignment="Center" FontSize="16" Text="When running the game, you may see this prompt in Origin when you start the game.&#x0a;Never press update or check the box; it will ruin your installation."/>
<Button Content="Got it" Click="OriginWarning_Button_Click" HorizontalAlignment="Center" Margin="5" Padding="20,5,20,5">
<Button.Style>
<Style TargetType="{x:Type Button}">
<Setter Property="Background" Value="#f56c2d" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="FontSize" Value="{DynamicResource FlatButtonFontSize}" />
<Setter Property="Foreground" Value="White" />
<Setter Property="Padding" Value="10 5 10 5" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}" xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro">
<Border x:Name="Border"
Margin="0"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
<Controls:ContentControlEx x:Name="PART_ContentPresenter"
Padding="{TemplateBinding Padding}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{TemplateBinding Content}"
ContentCharacterCasing="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.ContentCharacterCasing)}"
ContentStringFormat="{TemplateBinding ContentStringFormat}"
ContentTemplate="{TemplateBinding ContentTemplate}"
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#c85e36" />
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" Value="{DynamicResource FlatButtonPressedBackgroundBrush}" />
<Setter Property="Foreground" Value="{DynamicResource FlatButtonPressedForegroundBrush}" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="{DynamicResource GrayBrush2}" />
</Trigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
</StackPanel>
</Border>
</Controls:Flyout>
</Controls:FlyoutsControl>
</Controls:MetroWindow.Flyouts>
</Controls:MetroWindow>
50 changes: 50 additions & 0 deletions AlotAddOnGUI/Utilites.cs
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,56 @@ public static bool InstallIndirectSoundFixForME1()
return true;
}

public static void RemoveRunAsAdminXPSP3FromME1()
{
string gamePath = GetGamePath(1);
gamePath += "\\Binaries\\MassEffect.exe";
var compatKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers", true);
string compatString = (string)compatKey.GetValue(gamePath, null);
if (compatString != null) //has compat setting
{
string[] compatsettings = compatString.Split(' ');
List<string> newSettings = new List<string>();

foreach (string str in compatsettings)
{
switch (str)
{
case "~":
case "RUNASADMIN":
case "WINXPSP3":
continue;
default:
newSettings.Add(str);
break;
}
}

if (newSettings.Count > 0)
{
string newcompatString = "~";
foreach (string compatitem in newSettings)
{
newcompatString += " " + compatitem;
}
if (newcompatString == compatString)
{
return;
}
else
{
compatKey.SetValue(gamePath, newcompatString);
Log.Information("New stripped compatibility string: " + newcompatString);
}
}
else
{
compatKey.DeleteValue(gamePath);
Log.Information("Removed compatibility settings for ME1.");
}
}
}

public static bool InstallBinkw32Bypass(int game)
{
if (game == 1)
Expand Down
Binary file added AlotAddOnGUI/images/origin/me1update.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AlotAddOnGUI/images/origin/me2update.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions AlotAddOnGUI/licenses/erikjs-binkw32.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2016 Erik JS

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
20 changes: 20 additions & 0 deletions AlotAddOnGUI/licenses/nvorbis.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright (c) 2015 Andrew Ward, Ms-PL

Microsoft Public License (Ms-PL)

This license governs use of the accompanying software. If you use the software, you accept this license. If you do not accept the license, do not use the software.

Definitions
The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under U.S. copyright law.
A "contribution" is the original software, or any additions or changes to the software.
A "contributor" is any person that distributes its contribution under this license.
"Licensed patents" are a contributor's patent claims that read directly on its contribution.
Grant of Rights
(A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
(B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
Conditions and Limitations
(A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
(B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically.
(C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software.
(D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license.
(E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees, or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement.
41 changes: 38 additions & 3 deletions AlotAddOnGUI/mainwindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using System.Net;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -134,6 +135,7 @@ protected virtual void OnPropertyChanged([CallerMemberName] string propertyName
private string MANIFEST_BUNDLED_LOC = EXE_DIRECTORY + @"Data\\manifest-bundled.xml";
private List<string> COPY_QUEUE = new List<string>();
private List<string> MOVE_QUEUE = new List<string>();
private bool INSTALLED_GAME_IS_ORIGIN_BASED = false;

public bool ShowME1Files
{
Expand Down Expand Up @@ -1311,7 +1313,9 @@ private async void PerformWriteCheck()
me1Installed = (me1Path != null && Directory.Exists(me1Path));
me2Installed = (me2Path != null && Directory.Exists(me2Path));
me3Installed = (me3Path != null && Directory.Exists(me3Path));
Utilities.RemoveRunAsAdminXPSP3FromME1();

bool me1AGEIAKeyNotWritable = false;
string args = "";
List<string> directories = new List<string>();
if (me1Installed)
Expand All @@ -1323,6 +1327,23 @@ private async void PerformWriteCheck()
Log.Information("ME1 not writable: " + me1Path);
directories.Add(me1Path);
}
try
{
var key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\WOW6432Node\AGEIA Technologies", true);
if (key != null)
{
key.Close();
}
else
{
Log.Information("ME1 AGEIA Technologies key is not present or is not writable.");
me1AGEIAKeyNotWritable = true;
}
} catch (SecurityException)
{
Log.Information("ME1 AGEIA Technologies key is not writable.");
me1AGEIAKeyNotWritable = true;
}
}

if (me2Installed)
Expand Down Expand Up @@ -1350,7 +1371,7 @@ private async void PerformWriteCheck()
}
}

if (directories.Count() > 0)
if (directories.Count() > 0 || me1AGEIAKeyNotWritable)
{
foreach (String str in directories)
{
Expand All @@ -1360,6 +1381,11 @@ private async void PerformWriteCheck()
}
args += "\"" + str + "\"";
}

if (me1AGEIAKeyNotWritable)
{
args += "-create-hklm-reg-key \"SOFTWARE\\WOW6432Node\\AGEIA Technologies\"";
}
args = "\"" + System.Security.Principal.WindowsIdentity.GetCurrent().Name + "\" " + args;
//need to run write permissions program
if (isAdmin)
Expand All @@ -1377,11 +1403,15 @@ private async void PerformWriteCheck()
}
else
{
string message = "Some game folders are not writeable by your user account. ALOT Installer will attempt to grant access to these folders with the PermissionsGranter.exe program:\n";
string message = "Some game folders/registry keys are not writeable by your user account. ALOT Installer will attempt to grant access to these folders/registry with the PermissionsGranter.exe program:\n";
foreach (String str in directories)
{
message += "\n" + str;
}
if (me1AGEIAKeyNotWritable)
{
message += "\nRegistry: HKLM\\SOFTWARE\\WOW6432Node\\AGEIA Technologies (Fixes an ME1 launch issue)";
}
await this.ShowMessageAsync("Granting permissions to Mass Effect directories", message);
string exe = BINARY_DIRECTORY + "PermissionsGranter.exe";
int result = Utilities.runProcessAsAdmin(exe, args);
Expand Down Expand Up @@ -2615,7 +2645,7 @@ private async void ImportFiles(List<Tuple<AddonFile, string, string>> filesToImp
long currentBytes = preDownloadStartBytes;
currentBytes += e.BytesReceived;
double progress = (((double)currentBytes / totalBytes));
int taskbarprogress = (int) ((currentBytes * 100 / totalBytes));
int taskbarprogress = (int)((currentBytes * 100 / totalBytes));
TaskbarManager.Instance.SetProgressValue(taskbarprogress, 100);
Expand Down Expand Up @@ -3429,5 +3459,10 @@ private void MainWindow_StateChanged(object sender, EventArgs e)
break;
}
}

private void OriginWarning_Button_Click(object sender, RoutedEventArgs e)
{
OriginWarningFlyout.IsOpen = false;
}
}
}

0 comments on commit e74561a

Please sign in to comment.