-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
482 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,8 @@ | ||
# SMPatcher | ||
Applies patches to Pokemon Sun/Moon code.bin | ||
Applies patches to Pokemon Sun/Moon code.bin from [SunMoonPatches](https://github.com/SciresM/SunMoonPatches) | ||
|
||
|
||
**Licensing:** | ||
|
||
This software is licensed under the terms of the GPLv3. | ||
You can find a copy of the license in the LICENSE.txt file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 14 | ||
VisualStudioVersion = 14.0.25123.0 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SMPatcher", "SMPatcher\SMPatcher.csproj", "{38333EB5-ABC0-454C-9EC6-48B385A267F7}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{38333EB5-ABC0-454C-9EC6-48B385A267F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{38333EB5-ABC0-454C-9EC6-48B385A267F7}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{38333EB5-ABC0-454C-9EC6-48B385A267F7}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{38333EB5-ABC0-454C-9EC6-48B385A267F7}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /> | ||
</startup> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Security; | ||
using System.Security.Cryptography; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
using SMPatcher.Properties; | ||
|
||
namespace SMPatcher | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
uint DebugStub = 0x4DE0; | ||
uint QRDecryptHookOne = 0x2CD558; | ||
uint QRDecryptHookTwo = 0x2CD5F0; | ||
uint ScanHookOne = 0x2CD8AC; | ||
uint BatterySave = 0x33DA80; | ||
uint QRRegistered = 0x3A7008; | ||
|
||
uint ForbiddenQRs = 0x4A3FF0; | ||
|
||
uint NoOutlines = 0x31B748; | ||
|
||
if (args.Length != 1) | ||
{ | ||
Console.WriteLine("Usage: SMPatcher code.bin"); | ||
return; | ||
} | ||
|
||
byte[] code; | ||
|
||
try | ||
{ | ||
code = File.ReadAllBytes(args[0]); | ||
} | ||
catch | ||
{ | ||
Console.WriteLine("Failed to open {0}!", args[0]); | ||
return; | ||
} | ||
|
||
var dir = Path.GetDirectoryName(args[0]); | ||
var fn = Path.GetFileNameWithoutExtension(args[0]); | ||
|
||
Console.WriteLine("Sun/Moon Patcher v1 - SciresM"); | ||
|
||
var hash = (new SHA256CryptoServiceProvider()).ComputeHash(code); | ||
if (hash.SequenceEqual(Resources.moon_hash)) | ||
Console.WriteLine("Pokemon Moon detected."); | ||
else if (hash.SequenceEqual(Resources.sun_hash)) | ||
Console.WriteLine("Pokemon Sun detected"); | ||
else | ||
{ | ||
Console.WriteLine("Unknown code.bin! Contact SciresM to update the program."); | ||
return; | ||
} | ||
|
||
Resources.debug_stub.CopyTo(code, DebugStub); | ||
Resources.battery_save.CopyTo(code, BatterySave); | ||
Resources.qr_is_registered.CopyTo(code, QRRegistered); | ||
new byte[0x24].CopyTo(code, ForbiddenQRs); | ||
|
||
// Hooks | ||
BitConverter.GetBytes(0xEAF4DE23).CopyTo(code, QRDecryptHookOne); | ||
BitConverter.GetBytes(0xEAF4DE07).CopyTo(code, QRDecryptHookTwo); | ||
BitConverter.GetBytes(0xEA01C07B).CopyTo(code, ScanHookOne); | ||
|
||
Console.WriteLine("Patched!"); | ||
var new_fn = Path.Combine(dir, fn + "_patched.bin"); | ||
File.WriteAllBytes(new_fn, code); | ||
Console.WriteLine("Saved to {0}!", new_fn); | ||
|
||
BitConverter.GetBytes(0xE320F000).CopyTo(code, NoOutlines); | ||
var nfn2 = Path.Combine(dir, fn + "_patched_nooutlines.bin"); | ||
File.WriteAllBytes(nfn2, code); | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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("SMPatcher")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("SMPatcher")] | ||
[assembly: AssemblyCopyright("Copyright © 2016")] | ||
[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("38333eb5-abc0-454c-9ec6-48b385a267f7")] | ||
|
||
// 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")] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.