electron removed

This commit is contained in:
kitbyte
2025-03-21 23:35:16 +02:00
parent 8e33e58939
commit 4049ade4b1
54 changed files with 3635 additions and 828 deletions
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
</configuration>
+21
View File
@@ -0,0 +1,21 @@
<Application x:Class="WeModPatcher.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WeModPatcher"
xmlns:converters="clr-namespace:WeModPatcher.Converters"
StartupUri="/View/MainWindow/MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Style/ColorScheme.xaml"/>
<ResourceDictionary Source="Style/Styles.xaml"/>
<ResourceDictionary Source="Style/Icons.xaml"/>
</ResourceDictionary.MergedDictionaries>
<FontFamily x:Key="Inter" >pack://application:,,,/Style/#Inter 18pt 18pt</FontFamily>
<converters:ToVisibilityConverter x:Key="ToVisibilityConverter"/>
<converters:ToVisibilityInvertedConverter x:Key="ToVisibilityInvertedConverter"/>
</ResourceDictionary>
</Application.Resources>
</Application>
+9
View File
@@ -0,0 +1,9 @@
namespace WeModPatcher
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App
{
}
}
+7
View File
@@ -0,0 +1,7 @@
namespace WeModPatcher
{
public static class Constants
{
public const string RepositoryUrl = "https://github.com/k1tbyte/Wemod-Patcher";
}
}
@@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Windows.Data;
namespace WeModPatcher.Converters
{
public abstract class BaseBooleanConverter<T> : IValueConverter
{
protected BaseBooleanConverter(T trueValue, T falseValue)
{
True = trueValue;
False = falseValue;
}
protected T True { get; set; }
protected T False { get; set; }
public virtual object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
switch (value)
{
case null:
return False;
case bool booleanValue:
return booleanValue ? True : False;
}
if (!(value is int intValue))
{
return True;
}
switch (parameter)
{
case null:
return intValue == 0 ? False : True;
case int param:
return intValue > param ? True : False;
default:
//Because object not null
return True;
}
}
public virtual object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return value is T t && EqualityComparer<T>.Default.Equals(t, True);
}
}
}
@@ -0,0 +1,18 @@
using System.Windows;
namespace WeModPatcher.Converters
{
internal sealed class ToVisibilityConverter : BaseBooleanConverter<Visibility>
{
public ToVisibilityConverter() :
base(Visibility.Visible, Visibility.Collapsed)
{ }
}
internal sealed class ToVisibilityInvertedConverter : BaseBooleanConverter<Visibility>
{
public ToVisibilityInvertedConverter() :
base(Visibility.Collapsed, Visibility.Visible)
{ }
}
}
+12
View File
@@ -0,0 +1,12 @@
<Window x:Class="WeModPatcher.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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:WeModPatcher"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Grid>
</Grid>
</Window>
+13
View File
@@ -0,0 +1,13 @@
namespace WeModPatcher
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow
{
public MainWindow()
{
InitializeComponent();
}
}
}
+10
View File
@@ -0,0 +1,10 @@
namespace WeModPatcher.Models
{
public enum EPatchType
{
ActivatePro = 1,
DisableUpdates = 2,
DisableTelemetry = 4
}
}
+55
View File
@@ -0,0 +1,55 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("WeModPatcher")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("WeModPatcher")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
//In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>. For example, if you are using US english
//in your source files, set the <UICulture> to en-US. Then uncomment
//the NeutralResourceLanguage attribute below. Update the "en-US" in
//the line below to match the UICulture setting in the project file.
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[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)
)]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
+69
View File
@@ -0,0 +1,69 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace WeModPatcher.Properties
{
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder",
"4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance",
"CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState
.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp =
new global::System.Resources.ResourceManager("WeModPatcher.Properties.Resources",
typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState
.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get { return resourceCulture; }
set { resourceCulture = value; }
}
}
}
+117
View File
@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
@@ -0,0 +1,47 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Input;
namespace WeModPatcher.ReactiveCore
{
public sealed class AsyncRelayCommand : ICommand
{
private readonly Func<object, Task> _execute;
private readonly Func<object, bool> _canExecute;
private long _isExecuting;
public AsyncRelayCommand(Func<object, Task> execute, Func<object, bool> canExecute = null)
{
this._execute = execute;
this._canExecute = canExecute ?? (o => true);
}
public event EventHandler CanExecuteChanged
{
add => CommandManager.RequerySuggested += value;
remove => CommandManager.RequerySuggested -= value;
}
private static void RaiseCanExecuteChanged() => CommandManager.InvalidateRequerySuggested();
public bool CanExecute(object parameter) => Interlocked.Read(ref _isExecuting) == 0 && _canExecute(parameter);
public async void Execute(object parameter)
{
Interlocked.Exchange(ref _isExecuting, 1);
RaiseCanExecuteChanged();
try
{
await _execute(parameter);
}
finally
{
Interlocked.Exchange(ref _isExecuting, 0);
RaiseCanExecuteChanged();
}
}
}
}
@@ -0,0 +1,20 @@
using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace WeModPatcher.ReactiveCore
{
public class ObservableObject : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged([CallerMemberName] string name = null) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
protected virtual bool SetProperty<T>(ref T field, T value, [CallerMemberName] string propertyName = null)
{
if (Equals(field, value)) return false;
field = value;
OnPropertyChanged(propertyName);
return true;
}
}
}
+26
View File
@@ -0,0 +1,26 @@
using System;
using System.Windows.Input;
namespace WeModPatcher.ReactiveCore
{
public sealed class RelayCommand : ICommand
{
private readonly Action<object> _execute;
private readonly Func<object, bool> _canExecute;
public event EventHandler CanExecuteChanged
{
add => CommandManager.RequerySuggested += value;
remove => CommandManager.RequerySuggested -= value;
}
public RelayCommand(Action<object> execute, Func<object, bool> canExecute = null)
{
_execute = execute;
_canExecute = canExecute;
}
public bool CanExecute(object parameter) => _canExecute == null || _canExecute(parameter);
public void Execute(object parameter) => _execute(parameter);
}
}
+22
View File
@@ -0,0 +1,22 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Brush x:Key="Background">#09090b</Brush>
<Brush x:Key="Foreground">#FAFAFA</Brush>
<Brush x:Key="Card">#27272A</Brush>
<Brush x:Key="CardForeground">#FAFAFA</Brush>
<Brush x:Key="Popover">#09090b</Brush>
<Brush x:Key="PopoverForeground">#FAFAFA</Brush>
<Brush x:Key="Primary">#FAFAFA</Brush>
<Brush x:Key="PrimaryForeground">#18181B</Brush>
<Brush x:Key="Secondary">#27272A</Brush>
<Brush x:Key="SecondaryForeground">#FAFAFA</Brush>
<Brush x:Key="Muted">#18181a</Brush>
<Brush x:Key="MutedForeground">#A1A1AA</Brush>
<Brush x:Key="Accent">#27272A</Brush>
<Brush x:Key="AccentForeground">#FAFAFA</Brush>
<Brush x:Key="Destructive">Red</Brush>
<Brush x:Key="DestructiveForeground">#FAFAFA</Brush>
<Brush x:Key="Border">#27272A</Brush>
<Brush x:Key="Input">#27272A</Brush>
<Brush x:Key="Ring">#D4D4D8</Brush>
</ResourceDictionary>
+18
View File
@@ -0,0 +1,18 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Geometry x:Key="CloseIcon">
M13.46,12L19,17.54V19H17.54L12,13.46L6.46,19H5V17.54L10.54,12L5,6.46V5H6.46L12,10.54L17.54,5H19V6.46L13.46,12Z
</Geometry>
<Geometry x:Key="CogIcon">
M12,15.5A3.5,3.5 0 0,1 8.5,12A3.5,3.5 0 0,1 12,8.5A3.5,3.5 0 0,1 15.5,12A3.5,3.5 0 0,1 12,15.5M19.43,12.97C19.47,12.65 19.5,12.33 19.5,12C19.5,11.67 19.47,11.34 19.43,11L21.54,9.37C21.73,9.22 21.78,8.95 21.66,8.73L19.66,5.27C19.54,5.05 19.27,4.96 19.05,5.05L16.56,6.05C16.04,5.66 15.5,5.32 14.87,5.07L14.5,2.42C14.46,2.18 14.25,2 14,2H10C9.75,2 9.54,2.18 9.5,2.42L9.13,5.07C8.5,5.32 7.96,5.66 7.44,6.05L4.95,5.05C4.73,4.96 4.46,5.05 4.34,5.27L2.34,8.73C2.21,8.95 2.27,9.22 2.46,9.37L4.57,11C4.53,11.34 4.5,11.67 4.5,12C4.5,12.33 4.53,12.65 4.57,12.97L2.46,14.63C2.27,14.78 2.21,15.05 2.34,15.27L4.34,18.73C4.46,18.95 4.73,19.03 4.95,18.95L7.44,17.94C7.96,18.34 8.5,18.68 9.13,18.93L9.5,21.58C9.54,21.82 9.75,22 10,22H14C14.25,22 14.46,21.82 14.5,21.58L14.87,18.93C15.5,18.67 16.04,18.34 16.56,17.94L19.05,18.95C19.27,19.03 19.54,18.95 19.66,18.73L21.66,15.27C21.78,15.05 21.73,14.78 21.54,14.63L19.43,12.97Z
</Geometry>
<Geometry x:Key="Logo">
M47.845,22.185l-20.03,-20.03c-1.543,-1.543 -4.046,-1.553 -5.729,0.002l-19.931,20.028c-1.542,1.542 -1.554,4.045 0,5.727l19.934,19.934c0.772,0.772 1.785,1.16 2.816,1.16c1.026,0 2.07,-0.385 2.91,-1.16l19.933,-19.934c1.605,-1.605 1.648,-4.175 0.097,-5.727zM18,27c-1.105,0 -2,-0.895 -2,-2c0,-1.105 0.895,-2 2,-2c1.105,0 2,0.895 2,2c0,1.105 -0.895,2 -2,2zM25,34c-1.105,0 -2,-0.895 -2,-2c0,-1.105 0.895,-2 2,-2c1.105,0 2,0.895 2,2c0,1.105 -0.895,2 -2,2zM25,20c-1.105,0 -2,-0.895 -2,-2c0,-1.105 0.895,-2 2,-2c1.105,0 2,0.895 2,2c0,1.105 -0.895,2 -2,2zM32,27c-1.105,0 -2,-0.895 -2,-2c0,-1.105 0.895,-2 2,-2c1.105,0 2,0.895 2,2c0,1.105 -0.895,2 -2,2z
</Geometry>
<Geometry x:Key="GitHub">
M12 2A10 10 0 0122 12c0 4.42-2.86 8.16-6.83 9.5-.51.09-.67-.23-.67-.5 0-.32 0-1.4 0-2.74 0-.93-.33-1.54-.69-1.85 2.23-.25 4.57-1.09 4.57-4.91 0-1.11-.38-2-1.03-2.71.1-.25.45-1.29-.1-2.64 0 0-.84-.27-2.75 1.02-.79-.22-1.65-.33-2.5-.33s-1.71.11-2.5.33C7.59 5.88 6.75 6.15 6.75 6.15c-.55 1.35-.2 2.39-.1 2.64-.65.71-1.03 1.6-1.03 2.71 0 3.81 2.33 4.67 4.55 4.92-.28.25-.54.69-.63 1.34-.57.24-2.04.69-2.91-.83 0 0-.53-.96-1.53-1.03 0 0-.98-.02-.07.6 0 0 .65.31 1.11 1.47 0 0 .59 1.94 3.36 1.34 0 .83 0 1.46 0 1.69 0 .27-.16.58-.66.5C4.87 20.17 2 16.42 2 12A10 10 0 0112 2Z
</Geometry>
</ResourceDictionary>
Binary file not shown.
+245
View File
@@ -0,0 +1,245 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<CircleEase EasingMode="EaseInOut" x:Key="BaseAnimationFunction"/>
<Style TargetType="{x:Type Button}">
<Style.Resources>
<CornerRadius x:Key="CornerRadius">3 3 3 3</CornerRadius>
</Style.Resources>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="BorderBrush" Value="{DynamicResource Border}"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Foreground" Value="{DynamicResource Foreground}"/>
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border CornerRadius="{DynamicResource CornerRadius}"
BorderThickness="{TemplateBinding BorderThickness}"
Padding="{TemplateBinding Padding}"
BorderBrush="{TemplateBinding BorderBrush}"
Background="{TemplateBinding Background}">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="{DynamicResource Secondary}"/>
</Trigger>
</Style.Triggers>
</Style>
<Style x:Key="ColoredButton" TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}">
<Setter Property="Background" Value="{DynamicResource Primary}"/>
<Setter Property="Foreground" Value="{DynamicResource PrimaryForeground}"/>
<Style.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Background" Value="{DynamicResource Muted}"/>
<Setter Property="Foreground" Value="{DynamicResource MutedForeground}"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Margin" Value="0 2 0 2"/>
<Setter Property="Background" Value="{DynamicResource Primary}"/>
</Trigger>
</Style.Triggers>
</Style>
<Style x:Key="IconButton" TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border CornerRadius="{DynamicResource CornerRadius}"
BorderThickness="{TemplateBinding BorderThickness}"
Padding="{TemplateBinding Padding}"
BorderBrush="{TemplateBinding BorderBrush}"
Background="{TemplateBinding Background}">
<Viewbox HorizontalAlignment="Center" VerticalAlignment="Center">
<Path x:Name="Icon" Stretch="Fill" Data="{TemplateBinding Tag}" Fill="{TemplateBinding Foreground}"/>
</Viewbox>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<CircleEase EasingMode="EaseIn" x:Key="DefaultAnimationFunction"/>
<Style TargetType="{x:Type ContextMenu}">
<Setter Property="SnapsToDevicePixels" Value="True"/>
<Setter Property="OverridesDefaultStyle" Value="True"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ContextMenu}">
<Border x:Name="Content" CornerRadius="5" Margin="5"
Background="{StaticResource Background}"
BorderThickness="1"
BorderBrush="{DynamicResource Border}"
Padding="4">
<StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Cycle" />
<Border.Effect>
<DropShadowEffect BlurRadius="5" ShadowDepth="0" Color="Black" Opacity="0.4"/>
</Border.Effect>
<Border.RenderTransform>
<ScaleTransform ScaleX="0" ScaleY="0"/>
</Border.RenderTransform>
</Border>
<ControlTemplate.Triggers>
<EventTrigger RoutedEvent="Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Duration="0:0:0.15" Storyboard.TargetName="Content" EasingFunction="{StaticResource DefaultAnimationFunction}"
Storyboard.TargetProperty="(Border.RenderTransform).(ScaleTransform.ScaleY)" From="0" To="1"/>
<DoubleAnimation Duration="0:0:0.15" Storyboard.TargetName="Content" EasingFunction="{StaticResource DefaultAnimationFunction}"
Storyboard.TargetProperty="(Border.RenderTransform).(ScaleTransform.ScaleX)" From="0" To="1"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type MenuItem}">
<Setter Property="SnapsToDevicePixels" Value="True"/>
<Setter Property="OverridesDefaultStyle" Value="True"/>
<Setter Property="Foreground" Value="{DynamicResource Foreground}"/>
<Setter Property="BorderBrush" Value="{DynamicResource Border}"/>
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="FontWeight" Value="Medium"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type MenuItem}">
<Border Name="Root" Height="30" Background="Transparent" CornerRadius="4">
<ContentPresenter Name="HeaderHost" Margin="10,0,10,0"
ContentSource="Header" MinWidth="100"
RecognizesAccessKey="True"
HorizontalAlignment="Left" VerticalAlignment="Center"
TextOptions.TextRenderingMode="ClearType" TextBlock.FontSize="12" TextBlock.FontWeight="{TemplateBinding FontWeight}" TextBlock.Foreground="{TemplateBinding Foreground}" TextOptions.TextFormattingMode="Display"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground" Value="{DynamicResource Foreground}"/>
<Setter TargetName="Root" Property="Background" Value="{DynamicResource Accent}"/>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Foreground" Value="{DynamicResource Background}"/>
<Setter TargetName="Root" Property="Background" Value="{DynamicResource Foreground}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="LabelCard" TargetType="{x:Type Border}">
<Setter Property="Background" Value="{DynamicResource Card}"/>
<Setter Property="Opacity" Value="0.9"/>
<Setter Property="CornerRadius" Value="10"/>
<Setter Property="Padding" Value="12 6"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
<Style x:Key="Label" TargetType="{x:Type TextBlock}">
<Setter Property="Foreground" Value="{DynamicResource Foreground}"/>
<Setter Property="FontWeight" Value="Medium"/>
<Setter Property="FontSize" Value="13"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="TextAlignment" Value="Center"/>
</Style>
<Style TargetType="CheckBox">
<Setter Property="Cursor" Value="Hand"></Setter>
<Setter Property="Content" Value=""/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type CheckBox}">
<Border x:Name="Border" Height="17" Width="17"
CornerRadius="3"
Background="{DynamicResource Foreground}" BorderBrush="{DynamicResource Border}"
BorderThickness="0">
<TextBlock x:Name="Text" VerticalAlignment="Center" HorizontalAlignment="Center"
Foreground="{DynamicResource PrimaryForeground}"></TextBlock>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="False">
<Setter TargetName="Border"
Property="Background" Value="Transparent"/>
<Setter TargetName="Border"
Property="BorderThickness" Value="1"/>
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="Text"
Property="Text" Value="✓"/>
</Trigger>
<Trigger Property="IsChecked" Value="{x:Null}">
<Setter TargetName="Text"
Property="Text" Value=""/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="TextBox" x:Key="TitledTextBox">
<Setter Property="Background" Value="Transparent" />
<Setter Property="Height" Value="30" />
<Setter Property="Foreground" Value="{StaticResource Foreground}" />
<Setter Property="FontSize" Value="13" />
<Setter Property="CaretBrush" Value="{DynamicResource MutedForeground}" />
<Setter Property="SelectionBrush" Value="{DynamicResource MutedForeground}" />
<Setter Property="FontWeight" Value="Medium" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBox}">
<Border BorderBrush="{StaticResource Border}" Cursor="IBeam"
BorderThickness="1" CornerRadius="3">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Border BorderBrush="{DynamicResource Border}"
BorderThickness="0 0 1 0">
<TextBlock Text="{TemplateBinding Uid}"
VerticalAlignment="Center" Cursor="Hand"
FontSize="12"
Foreground="{DynamicResource MutedForeground}"
Padding="10 0" />
</Border>
<ScrollViewer
Grid.Column="1"
Margin="5 0"
VerticalAlignment="Center"
x:Name="PART_ContentHost" />
<TextBlock IsHitTestVisible="False"
Grid.Column="1"
Opacity="0.3"
Text="{TemplateBinding Tag}"
Margin="7 0 5 1"
VerticalAlignment="Center"
Visibility="Collapsed"
x:Name="Placeholder" />
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="Text" Value="">
<Setter TargetName="Placeholder"
Property="Visibility" Value="Visible" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
+208
View File
@@ -0,0 +1,208 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using AsarSharp;
using WeModPatcher.Models;
using WeModPatcher.View.MainWindow;
namespace WeModPatcher.Utils
{
public class Patcher
{
private class PatchEntry
{
public Regex Target { get; set; }
public string Patch { get; set; }
public bool Applied { get; set; }
public bool SingleMatch { get; set; } = true;
public bool DynamicFieldResolve { get; set; }
}
private static readonly Dictionary<EPatchType, PatchEntry> Patches = new Dictionary<EPatchType, PatchEntry>()
{
{
EPatchType.ActivatePro,
new PatchEntry
{
DynamicFieldResolve = true,
Target = new Regex(@"getUserAccount\(\)\{.*?return\s+this\.#\w+\.fetch\(\{.*?\}\)\}", RegexOptions.Singleline),
Patch = "getUserAccount(){return this.#<fetch_field_name>.fetch({endpoint:\"/v3/account\",method:\"GET\",name:\"/v3/account\",collectMetrics:0}).then(response=>{response.subscription={period:\"yearly\",state:\"active\"};response.flags=78;return response;})}"
}
},
{
EPatchType.DisableUpdates,
new PatchEntry
{
Target = new Regex(@"registerHandler\(""ACTION_CHECK_FOR_UPDATE"".*?\)\)\)\)", RegexOptions.Singleline),
Patch = "registerHandler(\"ACTION_CHECK_FOR_UPDATE\",(e=>expectUpdateFeedUrl(e,(e=>null)))"
}
}
};
// ...
// test eax, eax (0x85 for r/m16/32/64)
// jnz short loc_1403A4DD2 (Integrity check failed)
// call near ptr funk_1445527E0
// ...
private const string PatchSignature = "E8 ?? ?? ?? ?? ?? C0 75 ?? F6 C3 01 74 ?? 48 89 F9 E8 ?? ?? ?? ??";
private static readonly byte[] PatchBytes = { 0x31 };
private const int PatchOffset = 0x5;
private readonly string _weModRootFolder;
private readonly Action<string, ELogType> _logger;
private readonly HashSet<EPatchType> _config;
private readonly string _asarPath;
private readonly string _backupPath;
private readonly string _unpackedPath;
private int _sumOfPatches = 0;
public Patcher(string weModRootFolder, Action<string, ELogType> logger, HashSet<EPatchType> config)
{
_weModRootFolder = weModRootFolder;
_logger = logger;
_config = config;
_asarPath = Path.Combine(weModRootFolder, "resources", "app.asar");
_unpackedPath = Path.Combine(weModRootFolder, "resources", "app.asar.unpacked");
_backupPath = Path.Combine(weModRootFolder, "resources", "app.asar.backup");
}
private static string GetFetchFieldName(string targetFunction)
{
var fetchMatch = Regex.Match(targetFunction, @"return\s+this\.#(\w+)\.fetch");
return fetchMatch.Success ? fetchMatch.Groups[1].Value : null;
}
private void ApplyJsPatch(string fileName, string js, PatchEntry patch, EPatchType patchType)
{
if (patch.Applied)
{
return;
}
var matches = patch.Target.Matches(js);
if (matches.Count == 0)
{
return;
}
if(matches.Count > 1 && patch.SingleMatch)
{
throw new Exception(
$"[PATCHER] [{patchType}] Patch failed. Multiple target functions found. Looks like the version is not supported");
}
if (patch.DynamicFieldResolve)
{
string fetchFieldName = GetFetchFieldName(matches[0].Value);
if (string.IsNullOrEmpty(fetchFieldName))
{
throw new Exception($"[PATCHER] [{patchType}] Fetch field name not found");
}
patch.Patch = patch.Patch.Replace("<fetch_field_name>", fetchFieldName);
}
_logger($"[PATCHER] [{patchType}] Found target function in: " + Path.GetFileName(fileName), ELogType.Info);
File.WriteAllText(fileName, patch.Target.Replace(js, patch.Patch));
_logger($"[PATCHER] [{patchType}] Patch applied", ELogType.Success);
patch.Applied = true;
_sumOfPatches -= (int)patchType;
}
private void PatchAsar()
{
var items = Directory.EnumerateFiles(_unpackedPath)
.Where(file => !Directory.Exists(file) && Regex.IsMatch(Path.GetFileName(file), @"^app-\w+|index\.js"))
.ToList();
if (!items.Any())
{
throw new Exception("[PATCHER] No app bundle found");
}
var requestedPatches = _config.ToList();
requestedPatches.ForEach(patch => _sumOfPatches += (int)patch);
foreach (var item in items)
{
if (_sumOfPatches <= 0)
{
break;
}
string data = File.ReadAllText(item);
foreach (var entry in requestedPatches)
{
ApplyJsPatch(item, data, Patches[entry], entry);
}
}
}
private async Task PatchPE()
{
_logger("[PATCHER] Patching PE...", ELogType.Info);
var pePath = Path.Combine(_weModRootFolder, "WeMod.exe");
var patchResult = await PatternScanner.PatchBySignature(pePath, PatchSignature, PatchBytes, PatchOffset);
if(patchResult == -1)
{
_logger("[PATCHER] Failed to patch PE", ELogType.Error);
return;
}
_logger(patchResult == 0 ? "[PATCHER] PE already patched!" : "[PATCHER] PE patched successfully!", ELogType.Success);
}
public async Task Patch()
{
if (!File.Exists(_backupPath))
{
_logger("[PATCHER] Creating backup...", ELogType.Info);
File.Copy(_asarPath, _backupPath);
}
else
{
_logger("[PATCHER] Backup already exists", ELogType.Warn);
}
if(!File.Exists(_asarPath))
{
_logger("[PATCHER] app.asar not found!", ELogType.Error);
return;
}
try
{
_logger("[PATCHER] Extracting app.asar...", ELogType.Info);
AsarExtractor.ExtractAll(_asarPath, _unpackedPath);
}
catch (Exception e)
{
_logger($"[PATCHER] Failed to unpack app.asar: {e.Message}", ELogType.Error);
return;
}
PatchAsar();
try
{
new AsarCreator(_unpackedPath, _asarPath, new CreateOptions
{
Unpack = new Regex(@"^static\\unpacked.*$")
}).CreatePackageWithOptions();
}
catch (Exception e)
{
_logger($"[PATCHER] Failed to pack app.asar: {e.Message}", ELogType.Error);
return;
}
await PatchPE();
_logger("[PATCHER] Done!", ELogType.Success);
}
}
}
+101
View File
@@ -0,0 +1,101 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WeModPatcher.Utils
{
public class PatternScanner
{
public static int FindPatternInBuffer(byte[] buffer, int bytesRead, byte[] signature, string mask)
{
int bufferLength = bytesRead + signature.Length - 1;
for (int i = 0; i <= bytesRead - signature.Length; i++)
{
if (IsMatch(buffer, signature, mask, i))
return i;
}
return -1;
}
private static bool IsMatch(byte[] buffer, byte[] signature, string mask, int offset)
{
for (int i = 0; i < signature.Length; i++)
{
if (mask[i] == 'x' && buffer[offset + i] != signature[i])
return false;
}
return true;
}
public static (byte[] signature, string mask) ParseSignature(string signature)
{
var signatureBytes = new List<byte>();
var mask = new StringBuilder();
var tokens = signature.Split(' ');
foreach (var token in tokens)
{
if (token == "??" || token == "?")
{
signatureBytes.Add(0);
mask.Append('?');
}
else
{
signatureBytes.Add(Convert.ToByte(token, 16));
mask.Append('x');
}
}
return (signatureBytes.ToArray(), mask.ToString());
}
public static async Task<int> PatchBySignature(string filePath, string functionSignature, byte[] patchBytes, int patchOffset)
{
var (signature, mask) = ParseSignature(functionSignature);
const int bufferSize = 8192;
var buffer = new byte[bufferSize + signature.Length - 1];
using (var fileStream = new FileStream(filePath, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite))
{
int filePosition = 0;
while (true)
{
int bytesRead = await fileStream.ReadAsync(buffer, 0, bufferSize);
if (bytesRead == 0) break;
int matchIndex = FindPatternInBuffer(buffer, bytesRead, signature, mask);
if (matchIndex != -1)
{
int functionStartPosition = filePosition + matchIndex;
var checkBuffer = new byte[patchBytes.Length];
fileStream.Seek(functionStartPosition + patchOffset, SeekOrigin.Begin);
await fileStream.ReadAsync(checkBuffer, 0, patchBytes.Length);
if (checkBuffer.SequenceEqual(patchBytes))
{
return 0; // Memory already patched
}
// Go to patch position
fileStream.Seek(functionStartPosition + patchOffset, SeekOrigin.Begin);
await fileStream.WriteAsync(patchBytes, 0, patchBytes.Length);
return functionStartPosition; // Return the address of the function start by signature
}
filePosition += bytesRead;
Array.Copy(buffer, bufferSize, buffer, 0, signature.Length - 1);
}
}
return -1;
}
}
}
+49
View File
@@ -0,0 +1,49 @@
<Grid x:Class="WeModPatcher.View.Controls.PopupHost"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WeModPatcher.View.Controls"
mc:Ignorable="d"
Visibility="Collapsed">
<Border x:Name="Splash" Background="Black" CornerRadius="7"
Opacity="0.45"
MouseLeftButtonDown="HidePopup"/>
<Border Background="{DynamicResource Background}" d:Margin="0"
Margin="0 40 0 40" x:Name="PopupPresenter" Width="Auto" Height="Auto"
BorderBrush="{DynamicResource Border}" BorderThickness="1" MinWidth="300"
VerticalAlignment="Center" HorizontalAlignment="Center" CornerRadius="4" Padding="15 10 10 15">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Button BorderThickness="0" BorderBrush="Transparent"
Tag="{StaticResource CloseIcon}"
Width="25" Height="25" Padding="8" Background="Transparent"
HorizontalAlignment="Right" VerticalAlignment="Top" Click="HidePopup"
x:Name="cancel">
<Button.Style>
<Style BasedOn="{StaticResource IconButton}" TargetType="Button">
<Setter Property="Foreground" Value="{DynamicResource MutedForeground}"/>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground" Value="{DynamicResource Foreground}"/>
</Trigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
<TextBlock x:Name="Title" Text="This is title" Foreground="{DynamicResource Foreground}"
HorizontalAlignment="Left" FontWeight="Bold" FontSize="16"
VerticalAlignment="Bottom"/>
<ContentPresenter x:Name="Presenter" Margin="0 20 0 0"
Content="{Binding PopupContent}" Grid.Row="2"/>
</Grid>
</Border>
</Grid>
@@ -0,0 +1,100 @@
using System;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media.Animation;
namespace WeModPatcher.View.Controls
{
public partial class PopupHost : Grid
{
internal Action Closed;
public static readonly DependencyProperty PopupContentProperty =
DependencyProperty.Register("PopupContent", typeof(object), typeof(PopupHost), new PropertyMetadata(null));
internal readonly SemaphoreSlim OpenedSemaphore = new SemaphoreSlim(1, 1);
private DoubleAnimation OpeningAnimation;
private DoubleAnimation ClosingAnimation;
public bool IsOpen
{
get => this.Visibility == Visibility.Visible;
set
{
if (value)
{
if(OpenedSemaphore.CurrentCount == 0)
return;
Visibility = Visibility.Visible;
cancel.Focus();
PopupPresenter.BeginAnimation(OpacityProperty, OpeningAnimation);
OpenedSemaphore.Wait();
}
else
{
PopupPresenter.BeginAnimation(OpacityProperty, ClosingAnimation);
}
}
}
public object PopupContent
{
get => GetValue(PopupContentProperty);
set => SetValue(PopupContentProperty, value);
}
private void HidePopup(object sender, EventArgs e)
{
if (OpenedSemaphore.CurrentCount == 1)
return;
IsOpen = false;
}
private void OnClosing(object sender, EventArgs e)
{
if (PopupContent == null)
return;
Visibility = Visibility.Collapsed;
Closed?.Invoke();
PopupContent = null;
Closed = null;
OpenedSemaphore.Release();
}
public PopupHost()
{
InitializeComponent();
PreviewKeyDown += (sender, e) =>
{
if (e.Key != Key.Escape)
return;
HidePopup(null, null);
e.Handled = true;
};
OpeningAnimation = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromSeconds(0.4)))
{
EasingFunction = App.Current.FindResource("BaseAnimationFunction") as IEasingFunction
};
OpeningAnimation.Freeze();
ClosingAnimation = new DoubleAnimation(1, 0, new Duration(TimeSpan.FromSeconds(0.2)));
ClosingAnimation.Completed += OnClosing;
ClosingAnimation.Freeze();
this.Splash.DataContext = this;
this.PopupPresenter.DataContext = this;
}
}
}
+15
View File
@@ -0,0 +1,15 @@
namespace WeModPatcher.View.MainWindow
{
public enum ELogType
{
Info,
Warn,
Error,
Success
}
public class LogEntry
{
public ELogType LogType { get; set; }
public string Message { get; set; }
}
}
@@ -0,0 +1,186 @@
<Window x:Class="WeModPatcher.View.MainWindow.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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:WeModPatcher.View.MainWindow"
xmlns:controls="clr-namespace:WeModPatcher.View.Controls"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance local:MainWindowVm}"
Title="WeMod Patcher"
Height="510" MaxHeight="510"
Width="780" MaxWidth="780"
Opacity="0.97"
Background="Transparent"
WindowStyle="None"
FontFamily="{StaticResource Inter}"
AllowsTransparency="True">
<Border CornerRadius="7" Background="{DynamicResource Background}"
BorderBrush="{DynamicResource Border}"
BorderThickness="1" Margin="10">
<Border.Effect>
<DropShadowEffect BlurRadius="15" Direction="-90"
RenderingBias="Quality" ShadowDepth="2"/>
</Border.Effect>
<Grid>
<Grid Background="Transparent" VerticalAlignment="Top"
MouseLeftButtonDown="OnDragMove" Height="55">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="25 0 0 0">
<Viewbox VerticalAlignment="Center" Width="32" Height="32">
<Path
Fill="White" Data="{StaticResource Logo}"/>
</Viewbox>
<TextBlock Foreground="{DynamicResource Foreground}"
FontWeight="SemiBold" Opacity="0.9"
VerticalAlignment="Center"
FontSize="18" Margin="10 0 0 0">
<Bold>
WeMod Patcher
</Bold>
</TextBlock>
</StackPanel>
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
<Button
Margin="9 0 15 0"
Tag="{StaticResource CloseIcon}"
Width="25" Height="25" Padding="6.5"
HorizontalAlignment="Right"
Click="OnClosing"
VerticalAlignment="Center">
<Button.Resources>
<CornerRadius x:Key="CornerRadius">5 5 5 5</CornerRadius>
</Button.Resources>
<Button.Style>
<Style BasedOn="{StaticResource IconButton}" TargetType="Button">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="{DynamicResource Secondary}"/>
<Setter Property="Foreground" Value="{DynamicResource Destructive}"/>
</Trigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
</StackPanel>
<Border Background="{DynamicResource Border}" Height="1" VerticalAlignment="Bottom"></Border>
</Grid>
<Grid Margin="0 55 0 0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
<RowDefinition Height="50"/>
</Grid.RowDefinitions>
<TextBox Style="{StaticResource TitledTextBox}"
Uid="Folder path" Margin="10" IsReadOnly="True"
Cursor="Hand"
Text="{Binding WeModPath}"
VerticalAlignment="Center" Tag="Folder not found">
<TextBox.InputBindings>
<MouseBinding Gesture="LeftClick" Command="{Binding SetFolderPathCommand}" />
</TextBox.InputBindings>
</TextBox>
<Border Grid.Row="1" BorderBrush="{DynamicResource Border}" BorderThickness="1"
Margin="10 0 10 10"
CornerRadius="5">
<ListBox ItemsSource="{Binding LogList}" SelectionMode="Single"
BorderBrush="Transparent" BorderThickness="0"
Background="Transparent"
Padding="6"
ScrollViewer.VerticalScrollBarVisibility="Hidden"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.CanContentScroll="False">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="Margin" Value="0 0 0 5"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<Border x:Name="Card" HorizontalAlignment="Left"
Background="#08fc81"
BorderBrush="{DynamicResource Border}"
Padding="5 3 5 3" CornerRadius="3">
<TextBox Text="{Binding Message}"
Cursor="IBeam" FontSize="13"
Background="Transparent" TextWrapping="Wrap"
BorderThickness="0"
IsReadOnly="True"/>
</Border>
<ControlTemplate.Triggers>
<DataTrigger Binding="{Binding LogType}" Value="Error">
<Setter TargetName="Card" Property="Background" Value="#f04343"></Setter>
</DataTrigger>
<DataTrigger Binding="{Binding LogType}" Value="Info">
<Setter TargetName="Card" Property="Background" Value="#FFF"></Setter>
</DataTrigger>
<DataTrigger Binding="{Binding LogType}" Value="Warn">
<Setter TargetName="Card" Property="Background" Value="#facc15"></Setter>
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
</Border>
<Grid Grid.Row="2" HorizontalAlignment="Right" Margin="10 0 10 10">
<Grid.Style>
<Style TargetType="{x:Type Grid}">
<Style.Triggers>
<DataTrigger Binding="{Binding IsPatchEnabled}" Value="False">
<Setter Property="Cursor" Value="No"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Grid.Style>
<Button Style="{StaticResource ColoredButton}"
IsEnabled="{Binding IsPatchEnabled}"
FontWeight="Bold" FontSize="16" Width="200"
Command="{Binding ApplyPatchCommand}">Patch</Button>
</Grid>
<Button Grid.Row="2"
Margin="10 0 10 10" HorizontalAlignment="Right"
Command="{Binding RestoreBackupCommand }"
FontWeight="Bold" FontSize="16" Width="200"
Style="{StaticResource ColoredButton}"
Visibility="{Binding AlreadyPatched, Converter={StaticResource ToVisibilityConverter}}"
Content="Restore"/>
<DockPanel Grid.Row="2" Margin="10 0 10 10">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center"
Cursor="Hand"
MouseDown="OpenSourceClicked"
Background="Transparent">
<Viewbox VerticalAlignment="Center" Width="32" Height="32">
<Path
Fill="White" Data="{StaticResource GitHub}"/>
</Viewbox>
<Grid>
<TextBlock Margin="8 0 0 0" FontSize="10" Foreground="{DynamicResource AccentForeground}">
<Hyperlink Foreground="{DynamicResource AccentForeground}">Source code </Hyperlink>
<LineBreak/>
<Run>Made with ❤️ by k1tbyte</Run>
<LineBreak/>
<Run Foreground="{DynamicResource MutedForeground}">Put a star if you found this helpful ;)</Run>
</TextBlock>
</Grid>
</StackPanel>
</DockPanel>
</Grid>
<controls:PopupHost x:Name="PopupHost"/>
</Grid>
</Border>
</Window>
@@ -0,0 +1,49 @@
using System;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
namespace WeModPatcher.View.MainWindow
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow
{
public static MainWindow Instance;
public MainWindow()
{
InitializeComponent();
this.DataContext = new MainWindowVm();
Instance = this;
}
public void OpenPopup(object content, string title = null)
{
this.PopupHost.PopupContent = content;
PopupHost.Title.Text = title;
PopupHost.IsOpen = true;
}
private void OnDragMove(object sender, MouseButtonEventArgs e)
{
this.DragMove();
}
private void OnClosing(object sender, RoutedEventArgs e)
{
Application.Current.Shutdown();
}
public void ClosePopup()
{
PopupHost.IsOpen = false;
}
private void OpenSourceClicked(object sender, MouseButtonEventArgs e)
{
System.Diagnostics.Process.Start(Constants.RepositoryUrl);
}
}
}
@@ -0,0 +1,206 @@
using System;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Threading;
using AsarSharp;
using WeModPatcher.ReactiveCore;
using WeModPatcher.Utils;
using WeModPatcher.View.Popups;
using Application = System.Windows.Application;
namespace WeModPatcher.View.MainWindow
{
public class MainWindowVm : ObservableObject
{
public ObservableCollection<LogEntry> LogList { get; } = new ObservableCollection<LogEntry>();
private string _weModPath;
public string WeModPath
{
get => _weModPath;
set
{
SetProperty(ref _weModPath, value);
if (value == null) return;
Log($"WeMod directory found at '{_weModPath}'", ELogType.Success);
if (File.Exists(Path.Combine(_weModPath, "resources", "app.asar.backup")))
{
Log("WeMod already patched. If you want to patch again, please restore the backup first.", ELogType.Warn);
IsPatchEnabled = false;
AlreadyPatched = true;
return;
}
Log("Ready for patching.", ELogType.Info);
IsPatchEnabled = true;
}
}
private bool _isPatchEnabled = false;
public bool IsPatchEnabled
{
get => _isPatchEnabled;
set => SetProperty(ref _isPatchEnabled, value);
}
private bool _alreadyPatched = false;
public bool AlreadyPatched
{
get => _alreadyPatched;
set => SetProperty(ref _alreadyPatched, value);
}
public RelayCommand SetFolderPathCommand { get; }
public RelayCommand ApplyPatchCommand { get; }
public RelayCommand RestoreBackupCommand { get; }
private bool CheckWeModPath(string root)
{
try
{
return File.Exists(Path.Combine(root, "WeMod.exe")) &&
File.Exists(Path.Combine(root, "resources", "app.asar"));
}
catch
{
return false;
}
}
public string FindWeModDirectory()
{
string localAppDataPath = Environment.GetEnvironmentVariable("LOCALAPPDATA");
string defaultDir = Path.Combine(localAppDataPath, "WeMod");
if (!Directory.Exists(defaultDir))
{
return null;
}
var appFolders = Directory.EnumerateDirectories(defaultDir)
.Select(folderPath => new DirectoryInfo(folderPath))
.Where(dirInfo => Regex.IsMatch(dirInfo.Name, @"^app-\w+"))
.Select(dirInfo => new
{
Name = dirInfo.Name,
Path = dirInfo.FullName,
LastModified = dirInfo.LastWriteTime
})
.OrderByDescending(item => item.LastModified)
.ToList();
return (
from folder
in appFolders
where CheckWeModPath(folder.Path)
select folder.Path
).FirstOrDefault();
}
private void OnFolderPathSelection(object obj)
{
using (var dialog = new FolderBrowserDialog())
{
dialog.SelectedPath = Environment.GetEnvironmentVariable("LOCALAPPDATA");
dialog.Description = "Select the WeMod directory";
dialog.ShowNewFolderButton = false;
if (dialog.ShowDialog() != DialogResult.OK) return;
string selectedPath = dialog.SelectedPath;
string fileName = Path.GetFileName(selectedPath);
if (CheckWeModPath(selectedPath))
{
WeModPath = selectedPath;
return;
}
LogList.Add(new LogEntry
{
LogType = ELogType.Error,
Message = $"The selected folder '{fileName}' is not a valid WeMod directory."
});
}
}
private void OnBackupRestoring(object param)
{
var backupPath = Path.Combine(WeModPath, "resources", "app.asar.backup");
if (!File.Exists(backupPath))
{
Log("Backup not found. Please dont delete it manually", ELogType.Error);
return;
}
try
{
using (File.Open(backupPath, FileMode.Open, FileAccess.ReadWrite, FileShare.None))
{
}
}
catch
{
Log("Backup file is locked. Please close the WeMod and try again.", ELogType.Error);
return;
}
File.Copy(backupPath, Path.Combine(WeModPath, "resources", "app.asar"), true);
Log("Backup restored successfully.", ELogType.Success);
AlreadyPatched = false;
IsPatchEnabled = true;
}
private void OnPatching(object param)
{
if (WeModPath == null)
{
Log("Can't be done. Please specify the directory first.", ELogType.Warn);
return;
}
MainWindow.Instance.OpenPopup(new PatchVectorsPopup(async config =>
{
MainWindow.Instance.ClosePopup();
IsPatchEnabled = false;
await Task.Run(() => new Patcher(WeModPath, Log, config).Patch());
IsPatchEnabled = true;
}), "What are we gonna patch?");
}
private void Log(string message, ELogType logType)
{
Application.Current.Dispatcher.Invoke(() =>
{
message = $"[{logType.ToString().ToUpper()}] {message}";
LogList.Add(new LogEntry
{
LogType = logType,
Message = message
});
});
}
public MainWindowVm()
{
SetFolderPathCommand = new RelayCommand(OnFolderPathSelection);
ApplyPatchCommand = new RelayCommand(OnPatching);
RestoreBackupCommand = new RelayCommand(OnBackupRestoring);
WeModPath = FindWeModDirectory();
if (WeModPath == null)
{
Log("WeMod directory not found.", ELogType.Error);
return;
}
}
}
}
@@ -0,0 +1,31 @@
<UserControl x:Class="WeModPatcher.View.Popups.PatchVectorsPopup"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WeModPatcher.View.Popups"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300"
Foreground="{DynamicResource MutedForeground}"
FontWeight="Medium"
FontSize="13">
<Grid Margin="0 0 5 0">
<Grid.RowDefinitions>
<RowDefinition Height="27"/>
<RowDefinition Height="27"/>
<RowDefinition Height="27"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" VerticalAlignment="Center" Text="Activate WeMod Pro"/>
<CheckBox Grid.Row="0" x:Name="ActivateProBox" HorizontalAlignment="Right" VerticalAlignment="Center" IsChecked="True"/>
<TextBlock Grid.Row="1" VerticalAlignment="Center" Text="Disable telemetry"/>
<CheckBox Grid.Row="1" x:Name="DisableTelemetryBox" HorizontalAlignment="Right" VerticalAlignment="Center"/>
<TextBlock Grid.Row="2" VerticalAlignment="Center" Text="Disable updates"/>
<CheckBox Grid.Row="2" x:Name="DisableUpdateBox" HorizontalAlignment="Right" VerticalAlignment="Center"/>
<Button Grid.Row="3" Padding="0 5 0 5" Margin="0 15 0 0" Content="Continue"
Click="ButtonBase_OnClick"/>
</Grid>
</UserControl>
@@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using WeModPatcher.Models;
namespace WeModPatcher.View.Popups
{
public partial class PatchVectorsPopup : UserControl
{
private readonly Action<HashSet<EPatchType>> _onApply;
public PatchVectorsPopup(Action<HashSet<EPatchType>> onApply)
{
_onApply = onApply;
InitializeComponent();
}
private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
{
if(ActivateProBox.IsChecked != true && DisableUpdateBox.IsChecked != true && DisableTelemetryBox.IsChecked != true)
{
return;
}
var result = new HashSet<EPatchType>();
if (ActivateProBox.IsChecked == true)
{
result.Add(EPatchType.ActivatePro);
}
if (DisableUpdateBox.IsChecked == true)
{
result.Add(EPatchType.DisableUpdates);
}
_onApply(result);
}
}
}
+117
View File
@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props"
Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')"/>
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{106D3E44-ECBB-4EF3-84B2-5FC6BCF77727}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>WeModPatcher</RootNamespace>
<AssemblyName>WeModPatcher</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System"/>
<Reference Include="System.Core"/>
<Reference Include="System.Data"/>
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml"/>
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase"/>
<Reference Include="PresentationCore"/>
<Reference Include="PresentationFramework"/>
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Constants.cs" />
<Compile Include="Converters\BaseBooleanConverter.cs" />
<Compile Include="Converters\ToVisibilityConverter.cs" />
<Compile Include="Models\PatchConfig.cs" />
<Compile Include="ReactiveCore\AsyncRelayCommand.cs" />
<Compile Include="ReactiveCore\ObservableObject.cs" />
<Compile Include="ReactiveCore\RelayCommand.cs" />
<Compile Include="Utils\Patcher.cs" />
<Compile Include="Utils\PatternScanner.cs" />
<Compile Include="View\Controls\PopupHost.xaml.cs" />
<Compile Include="View\MainWindow\Logs.cs" />
<Compile Include="View\MainWindow\MainWindow.xaml.cs" />
<Compile Include="View\MainWindow\MainWindowVm.cs" />
<Compile Include="View\Popups\PatchVectorsPopup.xaml.cs">
<DependentUpon>PatchVectorsPopup.xaml</DependentUpon>
</Compile>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="Style\ColorScheme.xaml" />
<Page Include="Style\Icons.xaml" />
<Page Include="Style\Styles.xaml" />
<Page Include="View\Controls\PopupHost.xaml" />
<Page Include="View\MainWindow\MainWindow.xaml" />
<Page Include="View\Popups\PatchVectorsPopup.xaml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Content Include="Style\Inter_18pt-Regular.ttf" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AsarSharp\AsarSharp.csproj">
<Project>{beaa604a-402a-4387-8903-a53fc913a26e}</Project>
<Name>AsarSharp</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/>
</Project>