Contrib: Added client patcher, original author @Fabi
This commit is contained in:
1 parent
e085f1d909
commit
543a17a1b9
13 files changed
+804
No files matched your search
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<configuration>
|
||||||
|
<startup>
|
||||||
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/>
|
||||||
|
</startup>
|
||||||
|
</configuration>
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="12.0" DefaultTargets="Build" 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>{137B1355-6A81-4A3A-A01E-93ABAA4FFFDB}</ProjectGuid>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>Connection_Patcher</RootNamespace>
|
||||||
|
<AssemblyName>Connection Patcher</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>TRACE;DEBUG</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
|
||||||
|
<RunCodeAnalysis>false</RunCodeAnalysis>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugType>none</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>
|
||||||
|
</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
|
||||||
|
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<NoWin32Manifest>true</NoWin32Manifest>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Constants\BinaryTypes.cs" />
|
||||||
|
<Compile Include="Helper.cs" />
|
||||||
|
<Compile Include="Offsets\Windows.cs" />
|
||||||
|
<Compile Include="Patcher.cs" />
|
||||||
|
<Compile Include="Patches\Mac.cs" />
|
||||||
|
<Compile Include="Patches\Windows.cs" />
|
||||||
|
<Compile Include="Patterns\Mac.cs" />
|
||||||
|
<Compile Include="Patterns\Windows.cs" />
|
||||||
|
<Compile Include="Program.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="App.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 2013
|
||||||
|
VisualStudioVersion = 12.0.30110.0
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Connection Patcher", "Connection Patcher.csproj", "{137B1355-6A81-4A3A-A01E-93ABAA4FFFDB}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{137B1355-6A81-4A3A-A01E-93ABAA4FFFDB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{137B1355-6A81-4A3A-A01E-93ABAA4FFFDB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{137B1355-6A81-4A3A-A01E-93ABAA4FFFDB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{137B1355-6A81-4A3A-A01E-93ABAA4FFFDB}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2012-2014 Arctium Emulation <http://arctium.org>
|
||||||
|
* Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Connection_Patcher.Constants
|
||||||
|
{
|
||||||
|
enum BinaryTypes : uint
|
||||||
|
{
|
||||||
|
None = 0000000000,
|
||||||
|
Pe32 = 0x0000014C,
|
||||||
|
Pe64 = 0x00008664,
|
||||||
|
Mach32 = 0xFEEDFACE,
|
||||||
|
Mach64 = 0xFEEDFACF
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2012-2014 Arctium Emulation <http://arctium.org>
|
||||||
|
* Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using Connection_Patcher.Constants;
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
|
||||||
|
namespace Connection_Patcher
|
||||||
|
{
|
||||||
|
class Helper
|
||||||
|
{
|
||||||
|
public static BinaryTypes GetBinaryType(byte[] data)
|
||||||
|
{
|
||||||
|
BinaryTypes type = 0u;
|
||||||
|
|
||||||
|
using (var reader = new BinaryReader(new MemoryStream(data)))
|
||||||
|
{
|
||||||
|
var magic = (uint)reader.ReadUInt16();
|
||||||
|
|
||||||
|
// Check MS-DOS magic
|
||||||
|
if (magic == 0x5A4D)
|
||||||
|
{
|
||||||
|
reader.BaseStream.Seek(0x3C, SeekOrigin.Begin);
|
||||||
|
|
||||||
|
// Read PE start offset
|
||||||
|
var peOffset = reader.ReadUInt32();
|
||||||
|
|
||||||
|
reader.BaseStream.Seek(peOffset, SeekOrigin.Begin);
|
||||||
|
|
||||||
|
var peMagic = reader.ReadUInt32();
|
||||||
|
|
||||||
|
// Check PE magic
|
||||||
|
if (peMagic != 0x4550)
|
||||||
|
throw new NotSupportedException("Not a PE file!");
|
||||||
|
|
||||||
|
type = (BinaryTypes)reader.ReadUInt16();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
reader.BaseStream.Seek(0, SeekOrigin.Begin);
|
||||||
|
|
||||||
|
type = (BinaryTypes)reader.ReadUInt32();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string GetFileChecksum(byte[] data)
|
||||||
|
{
|
||||||
|
using (var stream = new BufferedStream(new MemoryStream(data), 1200000))
|
||||||
|
{
|
||||||
|
var sha256 = new SHA256Managed();
|
||||||
|
var checksum = sha256.ComputeHash(stream);
|
||||||
|
|
||||||
|
return BitConverter.ToString(checksum).Replace("-", "").ToLower();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Connection_Patcher.Offsets
|
||||||
|
{
|
||||||
|
static class Windows
|
||||||
|
{
|
||||||
|
public static class x86
|
||||||
|
{
|
||||||
|
public static readonly long BNet = 0xD3259;
|
||||||
|
public static readonly long Send = 0x889CA;
|
||||||
|
public static readonly long Recv = 0x86EEE;
|
||||||
|
public static readonly long Signature = 0x20B79;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class x64
|
||||||
|
{
|
||||||
|
public static readonly long BNet = 0;
|
||||||
|
public static readonly long Send = 0xAAB6B;
|
||||||
|
public static readonly long Recv = 0xA9FA3;
|
||||||
|
public static readonly long Signature = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,130 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2012-2014 Arctium Emulation <http://arctium.org>
|
||||||
|
* Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using Connection_Patcher.Constants;
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace Connection_Patcher
|
||||||
|
{
|
||||||
|
class Patcher : IDisposable
|
||||||
|
{
|
||||||
|
public string Binary { get; set; }
|
||||||
|
public bool Initialized { get; private set; }
|
||||||
|
public BinaryTypes Type { get; private set; }
|
||||||
|
|
||||||
|
public byte[] binary;
|
||||||
|
bool success;
|
||||||
|
|
||||||
|
public Patcher(string file)
|
||||||
|
{
|
||||||
|
Initialized = false;
|
||||||
|
success = false;
|
||||||
|
|
||||||
|
using (var stream = new MemoryStream(File.ReadAllBytes(file)))
|
||||||
|
{
|
||||||
|
Binary = file;
|
||||||
|
binary = stream.ToArray();
|
||||||
|
|
||||||
|
if (binary != null)
|
||||||
|
{
|
||||||
|
Type = Helper.GetBinaryType(binary);
|
||||||
|
|
||||||
|
Initialized = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Patch(byte[] bytes, byte[] pattern, long address = 0)
|
||||||
|
{
|
||||||
|
if (Initialized && (address != 0 || binary.Length >= pattern.Length))
|
||||||
|
{
|
||||||
|
var offset = pattern == null ? address : SearchOffset(pattern);
|
||||||
|
Console.WriteLine("Found offset {0}", offset);
|
||||||
|
|
||||||
|
if (offset != 0 && binary.Length >= bytes.Length)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
for (int i = 0; i < bytes.Length; i++)
|
||||||
|
binary[offset + i] = bytes[i];
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw new NotSupportedException(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
long SearchOffset(byte[] pattern)
|
||||||
|
{
|
||||||
|
var matches = 0;
|
||||||
|
|
||||||
|
for (long i = 0; i < binary.Length; i++)
|
||||||
|
{
|
||||||
|
matches = 0;
|
||||||
|
|
||||||
|
for (int j = 0; j < pattern.Length; j++)
|
||||||
|
{
|
||||||
|
if (pattern.Length > (binary.Length - i))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (pattern[j] == 0)
|
||||||
|
{
|
||||||
|
matches++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (binary[i + j] != pattern[j])
|
||||||
|
break;
|
||||||
|
|
||||||
|
matches++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (matches == pattern.Length)
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Finish()
|
||||||
|
{
|
||||||
|
success = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (File.Exists(Binary))
|
||||||
|
File.Delete(Binary);
|
||||||
|
|
||||||
|
if (success)
|
||||||
|
File.WriteAllBytes(Binary, binary);
|
||||||
|
}
|
||||||
|
catch (UnauthorizedAccessException)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
binary = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2012-2014 Arctium Emulation <http://arctium.org>
|
||||||
|
* Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Connection_Patcher.Patches
|
||||||
|
{
|
||||||
|
class Mac
|
||||||
|
{
|
||||||
|
public static class x86
|
||||||
|
{
|
||||||
|
public static byte[] BNet = { };
|
||||||
|
public static byte[] Send = { };
|
||||||
|
public static byte[] Recv = { };
|
||||||
|
public static byte[] Password = { 0x0F, 0x85 };
|
||||||
|
public static byte[] Signature = { };
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class x64
|
||||||
|
{
|
||||||
|
//public static byte[] BNet = { 0xB8, 0xD5, 0xF8, 0x7F, 0x82, 0x89, 0x47, 0x0C, 0x5D, 0xC3, 0x90, 0x90, 0x90 };
|
||||||
|
public static byte[] BNet = { };
|
||||||
|
//public static byte[] Send = { 0x90, 0x31, 0xDB };
|
||||||
|
public static byte[] Send = { };
|
||||||
|
public static byte[] Recv = { };
|
||||||
|
public static byte[] Password = { 0x0F, 0x85 };
|
||||||
|
//public static byte[] Signature = { 0x45, 0x31, 0xED, 0x4D, 0x89, 0xFC, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0xEB };
|
||||||
|
public static byte[] Signature = { };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2012-2014 Arctium Emulation <http://arctium.org>
|
||||||
|
* Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Connection_Patcher.Patches
|
||||||
|
{
|
||||||
|
class Windows
|
||||||
|
{
|
||||||
|
public static class x86
|
||||||
|
{
|
||||||
|
//public static byte[] BNet = { 0xC7, 0x40, 0x0C, 0xD5, 0xF8, 0x7F, 0x82 };
|
||||||
|
public static byte[] BNet = { 0x89, 0x48, 0x08, 0xC7, 0x40, 0x0C, 0xD5, 0xF8, 0x7F, 0x82, 0x90 };
|
||||||
|
public static byte[] Send = { 0xBA, 0x00, 0x00, 0x00, 0x00, 0x90, 0xEB };
|
||||||
|
public static byte[] Recv = { 0xB8, 0x00, 0x00, 0x00, 0x00 };
|
||||||
|
public static byte[] Password = { 0x75 };
|
||||||
|
public static byte[] Signature = { 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0xE9 };
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class x64
|
||||||
|
{
|
||||||
|
//public static byte[] BNet = { 0xB8, 0xD5, 0xF8, 0x7F, 0x82, 0x89, 0x41, 0x0C, 0x48, 0x8B, 0xC1, 0xC3 };
|
||||||
|
public static byte[] BNet = { };
|
||||||
|
public static byte[] Send = { 0x45, 0x33, 0xED, 0x90, 0x90, 0x90 };
|
||||||
|
public static byte[] Recv = { 0xB8, 0x00, 0x00, 0x00, 0x00, 0x90 };
|
||||||
|
public static byte[] Password = { 0x75 };
|
||||||
|
//public static byte[] Signature = { 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0xE9 };
|
||||||
|
public static byte[] Signature = { };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2012-2014 Arctium Emulation <http://arctium.org>
|
||||||
|
* Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Connection_Patcher.Patterns
|
||||||
|
{
|
||||||
|
class Mac
|
||||||
|
{
|
||||||
|
public static class x86
|
||||||
|
{
|
||||||
|
public static byte[] Password = { 0x0F, 0x84, 0xE3, 0x00, 0x00, 0x00, 0x8B, 0x03, 0x8B, 0x40, 0x04 };
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class x64
|
||||||
|
{
|
||||||
|
public static byte[] Password = { 0x0F, 0x84, 0x00, 0xFF, 0xFF, 0xFF, 0x49, 0x8B, 0x45, 0x00, 0xB9, 0x40 };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2012-2014 Arctium Emulation <http://arctium.org>
|
||||||
|
* Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Connection_Patcher.Patterns
|
||||||
|
{
|
||||||
|
class Windows
|
||||||
|
{
|
||||||
|
public static class x86
|
||||||
|
{
|
||||||
|
public static byte[] Password = { 0x74, 0x89, 0x8B, 0x16, 0x8B, 0x42, 0x04 };
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class x64
|
||||||
|
{
|
||||||
|
public static byte[] Password = { 0x74, 0x84, 0x48, 0x8B, 0x03 };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,244 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2012-2014 Arctium Emulation <http://arctium.org>
|
||||||
|
* Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using Connection_Patcher.Constants;
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Net;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
|
namespace Connection_Patcher
|
||||||
|
{
|
||||||
|
class Program
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
if (args.Length >= 1)
|
||||||
|
{
|
||||||
|
Console.ForegroundColor = ConsoleColor.Cyan;
|
||||||
|
|
||||||
|
Console.WriteLine("Client Connection Patcher");
|
||||||
|
Console.WriteLine("Press Enter to patch...");
|
||||||
|
|
||||||
|
Console.ReadKey(true);
|
||||||
|
|
||||||
|
var commonAppData = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
|
||||||
|
var system32 = Environment.GetFolderPath(Environment.SpecialFolder.System);
|
||||||
|
var hostsPath = Path.Combine(system32, "drivers/etc/hosts");
|
||||||
|
var modulePath = "";
|
||||||
|
var moduleFile = "";
|
||||||
|
|
||||||
|
// Let's use Win32 as default module
|
||||||
|
var patchSend = Patches.Windows.x86.Send;
|
||||||
|
var offsetSend = Offsets.Windows.x86.Send;
|
||||||
|
var patchRecv = Patches.Windows.x86.Recv;
|
||||||
|
var offsetRecv = Offsets.Windows.x86.Recv;
|
||||||
|
var patchBNet = Patches.Windows.x86.BNet;
|
||||||
|
var offsetBNet = Offsets.Windows.x86.BNet;
|
||||||
|
var patchSignature = Patches.Windows.x86.Signature;
|
||||||
|
var offsetSignature = Offsets.Windows.x86.Signature;
|
||||||
|
var fileName = "";
|
||||||
|
var battleNetFileName = args[0].Replace("Wow.exe", "Battle.net.dll");
|
||||||
|
var modulePatch = Patches.Windows.x86.Password;
|
||||||
|
var modulePattern = Patterns.Windows.x86.Password;
|
||||||
|
|
||||||
|
Console.ForegroundColor = ConsoleColor.White;
|
||||||
|
Console.Write("Creating patched binaries for ");
|
||||||
|
|
||||||
|
using (var patcher = new Patcher(args[0]))
|
||||||
|
{
|
||||||
|
switch (patcher.Type)
|
||||||
|
{
|
||||||
|
case BinaryTypes.Pe32:
|
||||||
|
Console.WriteLine("Win32 client...");
|
||||||
|
modulePath = commonAppData + "/Blizzard Entertainment/Battle.net/Cache/";
|
||||||
|
moduleFile = "8f52906a2c85b416a595702251570f96d3522f39237603115f2f1ab24962043c.auth";
|
||||||
|
break;
|
||||||
|
//case BinaryTypes.Pe64:
|
||||||
|
// Console.WriteLine("Win64 client...");
|
||||||
|
// fileName = patcher.Binary.Replace(".exe", "") + "_Patched.exe";
|
||||||
|
|
||||||
|
// modulePath = commonAppData + "/Blizzard Entertainment/Battle.net/Cache/";
|
||||||
|
// moduleFile = "0a3afee2cade3a0e8b458c4b4660104cac7fc50e2ca9bef0d708942e77f15c1d.auth";
|
||||||
|
// break;
|
||||||
|
//case BinaryTypes.Mach32:
|
||||||
|
// break;
|
||||||
|
//case BinaryTypes.Mach64:
|
||||||
|
// Console.WriteLine("Mc64 client...");
|
||||||
|
// patchBNet = Patches.Mac.x64.BNet;
|
||||||
|
// patternBNet = Patterns.Mac.x64.BNet;
|
||||||
|
// patchSend = Patches.Mac.x64.Send;
|
||||||
|
// patternSend = Patterns.Mac.x64.Send;
|
||||||
|
// patchSignature = Patches.Mac.x64.Signature;
|
||||||
|
// patternSignature = Patterns.Mac.x64.Signature;
|
||||||
|
// fileName = patcher.Binary + " Patched";
|
||||||
|
|
||||||
|
// modulePath = "/Users/Shared/Blizzard/Battle.net/Cache/";
|
||||||
|
// moduleFile = "97eeb2e28e9e56ed6a22d09f44e2ff43c93315e006bbad43bafc0defaa6f50ae.auth";
|
||||||
|
// modulePatch = Patches.Mac.x64.Password;
|
||||||
|
// modulePattern = Patterns.Mac.x64.Password;
|
||||||
|
// hostsPath = "/private/etc/hosts";
|
||||||
|
// break;
|
||||||
|
default:
|
||||||
|
throw new NotSupportedException("Type: " + patcher.Type + " not supported!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!File.Exists(battleNetFileName + "_backup"))
|
||||||
|
{
|
||||||
|
File.Copy(battleNetFileName, battleNetFileName + "_backup");
|
||||||
|
File.SetAttributes(battleNetFileName + "_backup", File.GetAttributes(battleNetFileName + "_backup") | FileAttributes.ReadOnly);
|
||||||
|
}
|
||||||
|
|
||||||
|
using (var bnpatcher = new Patcher(battleNetFileName))
|
||||||
|
{
|
||||||
|
bnpatcher.Patch(patchBNet, null, offsetBNet);
|
||||||
|
bnpatcher.Patch(patchSignature, null, offsetSignature);
|
||||||
|
bnpatcher.Finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
patcher.Patch(patchSend, null, offsetSend);
|
||||||
|
patcher.Patch(patchRecv, null, offsetRecv);
|
||||||
|
|
||||||
|
patcher.Binary = fileName;
|
||||||
|
|
||||||
|
patcher.Finish();
|
||||||
|
|
||||||
|
Console.ForegroundColor = ConsoleColor.Green;
|
||||||
|
Console.WriteLine("Patching done.");
|
||||||
|
|
||||||
|
CreateModule(moduleFile, modulePath, modulePatch, modulePattern);
|
||||||
|
|
||||||
|
Console.ForegroundColor = ConsoleColor.Green;
|
||||||
|
Console.WriteLine("Successfully created your patched binaries.");
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.ForegroundColor = ConsoleColor.White;
|
||||||
|
Console.WriteLine("Adding host rewrite...");
|
||||||
|
|
||||||
|
var host = args.Length == 2 ? args[1] : "127.0.0.1";
|
||||||
|
var hostName = args.Length == 3 ? (" " + args[2] + ".logon.battle.net") : " tc.logon.battle.net";
|
||||||
|
var exists = false;
|
||||||
|
|
||||||
|
using (var sr = new StreamReader(hostsPath))
|
||||||
|
{
|
||||||
|
while (!sr.EndOfStream)
|
||||||
|
{
|
||||||
|
var line = sr.ReadLine();
|
||||||
|
|
||||||
|
if (line.Contains(hostName))
|
||||||
|
{
|
||||||
|
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||||
|
Console.WriteLine("Host rewrite not needed.");
|
||||||
|
|
||||||
|
exists = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!exists)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (var stream = new StreamWriter(hostsPath, true, Encoding.UTF8))
|
||||||
|
{
|
||||||
|
stream.WriteLine("");
|
||||||
|
stream.WriteLine("{0}{1}", host, hostName);
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.ForegroundColor = ConsoleColor.Green;
|
||||||
|
Console.WriteLine("Host rewrite successfully added.");
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.ForegroundColor = ConsoleColor.Red;
|
||||||
|
Console.WriteLine(string.Format("Can't write host file! Exception type: {0}", e.GetType()));
|
||||||
|
Console.WriteLine("You must add the following line:");
|
||||||
|
|
||||||
|
Console.ForegroundColor = ConsoleColor.White;
|
||||||
|
Console.WriteLine("{0}{1}", host, hostName);
|
||||||
|
|
||||||
|
Console.ForegroundColor = ConsoleColor.Red;
|
||||||
|
Console.WriteLine("to your host file before using Arctium WoD Sandbox!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.ForegroundColor = ConsoleColor.Red;
|
||||||
|
Console.WriteLine("Wrong number of arguments: Missing client file.");
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.ForegroundColor = ConsoleColor.Gray;
|
||||||
|
Thread.Sleep(5000);
|
||||||
|
Environment.Exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void CreateModule(string moduleName, string path, byte[] patches, byte[] patterns)
|
||||||
|
{
|
||||||
|
var modulePath = path + moduleName[0] + moduleName[1] + "/" + moduleName[2] + moduleName[3];
|
||||||
|
var module = modulePath + "/" + moduleName;
|
||||||
|
|
||||||
|
if (!File.Exists(module))
|
||||||
|
{
|
||||||
|
Console.ForegroundColor = ConsoleColor.White;
|
||||||
|
Console.WriteLine("Base module doesn't exist, downloading it...");
|
||||||
|
|
||||||
|
if (!Directory.Exists(modulePath))
|
||||||
|
Directory.CreateDirectory(modulePath);
|
||||||
|
|
||||||
|
var webClient = new WebClient();
|
||||||
|
|
||||||
|
webClient.DownloadFileCompleted += (o, e) => PatchModule(module, path, patches, patterns);
|
||||||
|
webClient.DownloadFileAsync(new Uri("http://xx.depot.battle.net:1119/" + moduleName), module);
|
||||||
|
|
||||||
|
Console.ForegroundColor = ConsoleColor.Green;
|
||||||
|
Console.WriteLine("Done.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
PatchModule(module, path, patches, patterns);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void PatchModule(string file, string path, byte[] patches, byte[] pattern)
|
||||||
|
{
|
||||||
|
Console.ForegroundColor = ConsoleColor.White;
|
||||||
|
Console.WriteLine("Patching module...");
|
||||||
|
|
||||||
|
using (var patcher2 = new Patcher(file))
|
||||||
|
{
|
||||||
|
patcher2.Patch(patches, pattern);
|
||||||
|
|
||||||
|
var moduleName = Helper.GetFileChecksum(patcher2.binary) + ".auth";
|
||||||
|
var modulePath = path + moduleName[0] + moduleName[1] + "/" + moduleName[2] + moduleName[3];
|
||||||
|
|
||||||
|
if (!Directory.Exists(modulePath))
|
||||||
|
Directory.CreateDirectory(modulePath);
|
||||||
|
|
||||||
|
patcher2.Binary = modulePath + "/" + moduleName;
|
||||||
|
|
||||||
|
patcher2.Finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.ForegroundColor = ConsoleColor.Green;
|
||||||
|
Console.WriteLine("Patching module finished.");
|
||||||
|
|
||||||
|
Console.ForegroundColor = ConsoleColor.Gray;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// 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("Connection Patcher")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("Connection Patcher")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2014")]
|
||||||
|
[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)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("07c6905b-5b42-4804-81fe-73d0f74ebfb1")]
|
||||||
|
|
||||||
|
// 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")]
|
||||||
Reference in new issue
Block a user