Skip to content

Commit

Permalink
Updated module waitfunctions. Updated InfoBox
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCheatsrichter committed Aug 17, 2022
1 parent dae3aa3 commit 901a618
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 18 deletions.
15 changes: 9 additions & 6 deletions Gw2 Launchbuddy/Helpers/BlockerInfo.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,20 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Gw2_Launchbuddy.Helpers"
mc:Ignorable="d"
Title="BlockerInfo" Height="300" Width="300" Icon="/Gw2 Launchbuddy;component/launchbuddy.ico" AllowsTransparency="True" WindowStyle="None" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" Closing="Window_Closing" >
Title="BlockerInfo" Height="280" Width="280" Icon="/Gw2 Launchbuddy;component/launchbuddy.ico" AllowsTransparency="True" WindowStyle="None" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" Closing="Window_Closing" MouseDown="Window_MouseDown" >
<Window.Background>
<ImageBrush ImageSource="/Gw2 Launchbuddy;component/launchbuddy.ico"/>
<ImageBrush Opacity="0.6" ImageSource="/Gw2 Launchbuddy;component/launchbuddy.ico"/>
</Window.Background>
<Window.OpacityMask>
<ImageBrush ImageSource="/Gw2 Launchbuddy;component/launchbuddy.ico"/>
</Window.OpacityMask>
<Grid >
<DockPanel HorizontalAlignment="Center">
<Button Content="Cancel" DockPanel.Dock="Bottom" Margin="15" Width="120" Name="bt_cancel" Click="bt_cancel_Click"/>
<TextBlock Name="tb_message" Text="Launchbuddy is currently waiting for" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center" MaxWidth="230" TextWrapping="Wrap" FontSize="14" FontWeight="Bold" Background="#7F000000"/>
<Grid>
<DockPanel HorizontalAlignment="Center" LastChildFill="True">
<StackPanel Orientation="Vertical" DockPanel.Dock="Bottom" Height="80">
<Button Content="Hide" DockPanel.Dock="Bottom" Width="120" Name="bt_hide" Click="bt_hide_Click"/>
<Button Content="Cancel" DockPanel.Dock="Bottom" Margin="2" Width="120" Name="bt_cancel" Click="bt_cancel_Click"/>
</StackPanel>
<TextBlock Name="tb_message" Text="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center" MaxWidth="230" TextWrapping="Wrap" FontSize="14" FontWeight="Bold" Background="#7F000000"/>
</DockPanel>

</Grid>
Expand Down
10 changes: 10 additions & 0 deletions Gw2 Launchbuddy/Helpers/BlockerInfo.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,15 @@ private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs
GC.Collect();
}
}
private void Window_MouseDown(object sender, MouseButtonEventArgs e)
{
try { this.DragMove(); } catch { }
}

private void bt_hide_Click(object sender, RoutedEventArgs e)
{
this.WindowState = WindowState.Minimized;
this.Topmost = false;
}
}
}
2 changes: 1 addition & 1 deletion Gw2 Launchbuddy/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -1428,7 +1428,7 @@
<CheckBox x:Name="cb_gameclientbuttonpush" Content="Press gameclient 'Login Button' on gamestart. (When disabled: GFX settings might not work)" Margin="5" ToolTip="Should the gameclient loginwindow login button be pressed when an account is launched?" Click="cb_gameclientbuttonpush_Click"/>
<Button x:Name="bt_resetpropertysettings" Content="Reset ALL LB Settings" Height="30" Width="250" MaxWidth="250" HorizontalAlignment="Left" Margin="10,0,0,0" Click="Bt_resetpropertysettings_Click"/>
<Button x:Name="bt_resetinstanceguisettings" Content="Reset Game Instance Manager Settings" Width="250" Height="30" MaxWidth="250" HorizontalAlignment="Left" Margin="10,0,0,0" Click="Bt_resetinstanceguisettings_Click"/>
<Button x:Name="debug_setcolorpalette" Content="Set colorpalette" Click="debug_setcolorpalette_Click"/>
<Button x:Name="debug_setcolorpalette" Content="Set colorpalette" Click="debug_setcolorpalette_Click" Visibility="Collapsed"/>
<Label Content="Launchbuddy Releases" Style="{StaticResource H2}"/>
<Grid Height="250" Margin="3">
<Grid.ColumnDefinitions>
Expand Down
20 changes: 18 additions & 2 deletions Gw2 Launchbuddy/Modifiers/LocalDatManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,22 @@ public static void UpdateLocalDat(LocalDatFile file)

Helpers.BlockerInfo.Run("Loginfile Update", "Launchbuddy waits for the gameclient to be closed.", waitforprocessclose);

Action waitforprocoherentclose = () =>
{
int i = 0;
while (Process.GetProcessesByName("*CoherentUI_Host*.exe").Length == 1 && i <= 50)
{
Thread.Sleep(100);
i++;
}
if (i == 50)
{
MessageBox.Show("An unexpected Guild Wars 2 gameclient still is running. Please wait for the gameclient to update / close. Overwise close the gameclient manually");
}
};

Helpers.BlockerInfo.Run("Loginfile Update", "Launchbuddy waits for the gameclient to be closed.", waitforprocoherentclose);


if (!Apply(file)) return;

Expand All @@ -139,7 +155,7 @@ public static void UpdateLocalDat(LocalDatFile file)
Process pro = new Process { StartInfo = new ProcessStartInfo { FileName = EnviromentManager.GwClientExePath } };
pro.Start();
pro.Refresh();
Action waitforlaunch = () => ModuleReader.WaitForModule("WINNSI.DLL", pro);
Action waitforlaunch = () => ModuleReader.WaitForModule("dwmapi.dll", pro);
Helpers.BlockerInfo.Run("Loginfile Update", "Launchbuddy is updating a Loginfile. This window should automatically close when the launcher login is ready.", waitforlaunch);

try
Expand Down Expand Up @@ -198,7 +214,7 @@ public static LocalDatFile CreateNewFile(string filename, string email = null, s
#endif
if (email != null && password != null)
{
Action blockefunc = () => ModuleReader.WaitForModule("WINNSI.DLL", pro, null);
Action blockefunc = () => ModuleReader.WaitForModule("dwmapi.dll", pro, null);
Helpers.BlockerInfo.Run("Loginfile Creation", "LB is recreating your loginfile", blockefunc);
if (!Helpers.BlockerInfo.Done) MessageBox.Show("No Clean Login. Loginfile might be not set correctly! Proceed with caution.");

Expand Down
7 changes: 4 additions & 3 deletions Gw2 Launchbuddy/Modifiers/Loginfiller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static void Login(string email,string passwd,Process pro, bool clearfield
try
{
pro.Refresh();
ModuleReader.WaitForModule("WINNSI.DLL", pro);
ModuleReader.WaitForModule("CoherentUI64.DLL", pro);
//SetForegroundWindow(pro.MainWindowHandle);
Thread.Sleep(1000);
for (int i = 0; i < 100; i++) PressKeyDown(Keys.Back, pro, false); //Very unclean method, but modifiers onyl work on focus
Expand All @@ -42,8 +42,9 @@ public static void Login(string email,string passwd,Process pro, bool clearfield

public static void PressLoginButton(Account acc)
{
ModuleReader.WaitForModule("WINNSI.DLL", acc.Client.Process);
if(!acc.Client.Process.HasExited)
ModuleReader.WaitForModule("CoherentUI64.DLL", acc.Client.Process);
Thread.Sleep(1000);
if (!acc.Client.Process.HasExited)
{
PressKeyDown(Keys.Enter, acc.Client.Process);
PressKeyUp(Keys.Enter, acc.Client.Process);
Expand Down
6 changes: 3 additions & 3 deletions Gw2 Launchbuddy/Modifiers/ModuleReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ public static void WaitForModule(string name, Process pro, int? timeout=1000)
int ct = 0;
if(timeout!=null)
{
while (!CollectModules(pro).Any<Module>(m => m.ModuleName == name) && ct < timeout)
while (!CollectModules(pro).Any<Module>(m => m.ModuleName == name.ToLower()) && ct < timeout)
{
Thread.Sleep(10);
ct++;
}
}else
{
while (!CollectModules(pro).Any<Module>(m => m.ModuleName == name) )
while (!CollectModules(pro).Any<Module>(m => m.ModuleName == name.ToLower()) )
{
Thread.Sleep(10);
}
Expand Down Expand Up @@ -143,7 +143,7 @@ public static List<Module> CollectModules(Process process)
StringBuilder moduleFilePath = new StringBuilder(1024);
Native.GetModuleFileNameEx(process.Handle, modulePointers[index], moduleFilePath, (uint)(moduleFilePath.Capacity));

string moduleName = Path.GetFileName(moduleFilePath.ToString());
string moduleName = Path.GetFileName(moduleFilePath.ToString()).ToLower();
Native.ModuleInformation moduleInformation = new Native.ModuleInformation();
Native.GetModuleInformation(process.Handle, modulePointers[index], out moduleInformation, (uint)(IntPtr.Size * (modulePointers.Length)));

Expand Down
7 changes: 4 additions & 3 deletions Gw2 Launchbuddy/ObjectManagers/ClientManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ public class Client : INotifyPropertyChanged
public readonly Account account;
private ClientStatus status = ClientStatus.None;
public Process Process = new Process();
//public Process CoherentUIProcess; Could be used to improve login timings; needs more testing
public event EventHandler StatusChanged;
public event PropertyChangedEventHandler PropertyChanged;

Expand Down Expand Up @@ -413,7 +414,7 @@ private void Window_Init()
private void Th_Window_Init()
{
// icm32.dll
ModuleReader.WaitForModule("mscms.dll", Process, null);
ModuleReader.WaitForModule("icm32.dll", Process, null);
Console.WriteLine($"{account.Nickname} configuring Windowsize");

Window_MoveTo_Default();
Expand Down Expand Up @@ -647,14 +648,14 @@ private void PressLoginButton()
}

Action loginwait = () => { Thread.Sleep(timetowait); };
Helpers.BlockerInfo.Run("Delaying Login", $"Launchbuddy is currently delaying the login for {timetowait / 1000} sec(s). This is a safety measure to avoid triggering GW2 DDOS protection. Press cancel to skip.", loginwait);
Helpers.BlockerInfo.Run("Delaying Login", $"Launchbuddy is currently delaying the login for {timetowait / 1000} sec(s). This is a safety measure to avoid triggering GW2 DDOS protection. Press cancel to skip.", loginwait,false);

Loginfiller.PressLoginButton(Account);
}

private void WaitForLogin()
{
Action blockefunc = () => ModuleReader.WaitForModule("winbrand.dll", Process, null);
Action blockefunc = () => ModuleReader.WaitForModule("WINSTA.dll", Process, null);
Helpers.BlockerInfo.Run($"{account.Nickname} Login pending", $"{account.Nickname} Login requiring additional information.", blockefunc);
}

Expand Down

0 comments on commit 901a618

Please sign in to comment.