Skip to content

Commit

Permalink
Add project files.
Browse files Browse the repository at this point in the history
  • Loading branch information
MELVARDEV committed May 25, 2021
1 parent 38e8de7 commit 368dec1
Show file tree
Hide file tree
Showing 8 changed files with 319 additions and 0 deletions.
25 changes: 25 additions & 0 deletions League Pass Manager.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31313.79
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "League Pass Manager", "League Pass Manager\League Pass Manager.csproj", "{AB20FF9E-31F1-409C-92C6-7787FC8DDB53}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{AB20FF9E-31F1-409C-92C6-7787FC8DDB53}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AB20FF9E-31F1-409C-92C6-7787FC8DDB53}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AB20FF9E-31F1-409C-92C6-7787FC8DDB53}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AB20FF9E-31F1-409C-92C6-7787FC8DDB53}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0E961FB7-2FF8-4C0A-B39B-A3ED5CD465B1}
EndGlobalSection
EndGlobal
15 changes: 15 additions & 0 deletions League Pass Manager/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Application x:Class="League_Pass_Manager.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:League_Pass_Manager"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/Dark.Purple.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
17 changes: 17 additions & 0 deletions League Pass Manager/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace League_Pass_Manager
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}
10 changes: 10 additions & 0 deletions League Pass Manager/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Windows;

[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
27 changes: 27 additions & 0 deletions League Pass Manager/League Pass Manager.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net5.0-windows</TargetFramework>
<RootNamespace>League_Pass_Manager</RootNamespace>
<UseWPF>true</UseWPF>
<ApplicationIcon>internet_lock_locked_padlock_password_secure_security_icon_127100.ico</ApplicationIcon>
</PropertyGroup>

<ItemGroup>
<None Remove="internet_lock_locked_padlock_password_secure_security_icon_127100.ico" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="InputSimulator" Version="1.0.4" />
<PackageReference Include="InputSimulatorPlus" Version="1.0.7" />
<PackageReference Include="MahApps.Metro" Version="2.4.5" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Rijndael256" Version="3.2.0" />
</ItemGroup>

<ItemGroup>
<Resource Include="internet_lock_locked_padlock_password_secure_security_icon_127100.ico" />
</ItemGroup>

</Project>
31 changes: 31 additions & 0 deletions League Pass Manager/MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<mah:MetroWindow x:Class="League_Pass_Manager.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:League_Pass_Manager"
mc:Ignorable="d"

Title="League Pass Manager" Height="103" Width="409" MinWidth="300" MinHeight="130" WindowStartupLocation="CenterScreen" Icon="/internet_lock_locked_padlock_password_secure_security_icon_127100.ico">
<Grid>
<Grid Visibility="Hidden" x:Name="mainGrid" >
<Button Content="Fill" Margin="10,38,113,8" Click="Button_Click" RenderTransformOrigin="0.5,1" VerticalAlignment="Bottom" Height="40"/>
<DataGrid x:Name="datagrid1" Margin="0,0,0,59" AutoGenerateColumns="True" ItemsSource="{Binding Path=accounts, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" CellEditEnding="datagrid1_CellEditEnding" GridLinesVisibility="All" RowEditEnding="datagrid1_RowEditEnding" CurrentCellChanged="datagrid1_CurrentCellChanged" >
<DataGrid.Columns>

</DataGrid.Columns>
</DataGrid>
<Button Content="Remove" HorizontalAlignment="Right" Margin="0,0,10,8" VerticalAlignment="Bottom" Height="40" Width="98" Click="Button_Click_1"/>
</Grid>
<Grid x:Name="passwordPromptGrid">
<PasswordBox x:Name="encryptionKey" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="33,0,33,57" mah:TextBoxHelper.Watermark="Encryption Key"/>
<Button x:Name="unlockButton" Content="Unlock" Margin="16,0,16,17" VerticalAlignment="Bottom" Click="unlockButton_Click" IsDefault="True"/>

</Grid>




</Grid>
</mah:MetroWindow>
194 changes: 194 additions & 0 deletions League Pass Manager/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using WindowsInput;
using WindowsInput.Native;
using MahApps.Metro.Controls;
using Newtonsoft.Json;
using Rijndael256;
using System.IO;
using System.ComponentModel;

namespace League_Pass_Manager
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
///

public partial class MainWindow : MetroWindow
{

[DllImport("user32.dll")]
internal static extern IntPtr SetForegroundWindow(IntPtr hWnd);

[DllImport("user32.dll")]
internal static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); //ShowWindow needs an IntPtr

[DllImport("user32.dll")]
static extern bool PostMessage(IntPtr hWnd, UInt32 Msg, int wParam, int lParam);
[DllImport("user32.dll")]
static extern byte VkKeyScan(char ch);

//include SendMessage
[DllImport("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, int uMsg, int wParam, string lParam);

//include FindWindowEx
[DllImport("user32.dll")]
public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);

public class Account
{
public string region { get; set; }
public string description { get; set; }
public string userName { get; set; }
public string password { get; set; }
}

public List<Account> accounts = new List<Account>();
string password;

void saveAccounts(string password)
{
string jsonList = JsonConvert.SerializeObject(accounts);
string aeCiphertext = RijndaelEtM.Encrypt(jsonList, password, KeySize.Aes256);
File.WriteAllText("accounts.txt", aeCiphertext);
}

bool readAccounts()
{
string jsonString = "";
try
{
jsonString = File.ReadAllText("accounts.txt");
} catch(Exception e)
{
MessageBox.Show("Account file doesn't exist yet and will be created now. Double check your encryption key and memorize it or write it down. You won't be able to access your account data without it!" + Environment.NewLine + Environment.NewLine + "Your encryption key: " + password, "WARNING", MessageBoxButton.OK, MessageBoxImage.Exclamation);
return true;
}

string plaintext = "";
try
{
plaintext = RijndaelEtM.Decrypt(jsonString, password, KeySize.Aes256);
} catch (Exception e)
{
MessageBox.Show("Wrong decryption phrase");
return false;
}
try
{
accounts = JsonConvert.DeserializeObject<List<Account>>(plaintext);
}
catch (Exception e)
{
MessageBox.Show("Accounts file corrupted!");
return false;
}
return true;
}

public MainWindow()
{
InitializeComponent();
}

private void Button_Click(object sender, RoutedEventArgs e)
{
IntPtr hWnd;
Process[] processRunning = Process.GetProcesses();
foreach (Process pr in processRunning)
{
if (pr.ProcessName == "RiotClientUx")
{
hWnd = pr.MainWindowHandle;
ShowWindow(hWnd, 3);
SetForegroundWindow(hWnd);
var inputSimulator = new InputSimulator();
Account selectedAccount = new Account();
try
{
selectedAccount = (Account)datagrid1.SelectedItem;
} catch (Exception exce)
{
MessageBox.Show("You need to select an account first!");
return;
}

Account result = accounts.Find(x => x.userName == selectedAccount.userName);

inputSimulator.Keyboard.TextEntry(result.userName);
inputSimulator.Keyboard.KeyDown((VirtualKeyCode.TAB));
inputSimulator.Keyboard.TextEntry(result.password);
inputSimulator.Keyboard.KeyDown((VirtualKeyCode.RETURN));
}
}
}


private void datagrid1_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
{
saveAccounts(password);
}

private void unlockButton_Click(object sender, RoutedEventArgs e)
{
password = encryptionKey.Password;

if (readAccounts())
{
datagrid1.ItemsSource = null;
datagrid1.ItemsSource = accounts;
datagrid1.Items.Refresh();
passwordPromptGrid.Visibility = Visibility.Hidden;
Application.Current.MainWindow.Height = 400;

mainGrid.Visibility = Visibility.Visible;
}

}

private void datagrid1_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e)
{
saveAccounts(password);
}

private void Button_Click_1(object sender, RoutedEventArgs e)
{
Account selectedAccount = new Account();
try
{
selectedAccount = (Account)datagrid1.SelectedItem;
} catch(Exception ex)
{
MessageBox.Show("Select an account first!");
return;
}

if (MessageBox.Show("Are you sure you want to remove this account: " + selectedAccount.userName + "?", "Remove Account", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
{
accounts.RemoveAll(a => a == selectedAccount);
datagrid1.Items.Refresh();
}
}

private void datagrid1_CurrentCellChanged(object sender, EventArgs e)
{
saveAccounts(password);
}
}
}
Binary file not shown.

0 comments on commit 368dec1

Please sign in to comment.