Skip to content
This repository has been archived by the owner on May 11, 2022. It is now read-only.

Commit

Permalink
Added a new automated patcher that doesn't need pre-made patches!
Browse files Browse the repository at this point in the history
Added simpler instructions for DIY patches.
  • Loading branch information
MysteryDash committed Jan 11, 2019
1 parent fa420b4 commit b14cda3
Show file tree
Hide file tree
Showing 18 changed files with 4,244 additions and 20 deletions.
33 changes: 15 additions & 18 deletions License.txt
Original file line number Diff line number Diff line change
@@ -1,37 +1,34 @@
Simple Non Code License (SNCL)

Version 2.1.0
Version 2.3.0
Copyright � 2016-2018 Alexandre Quoniou

The original creator of the data or text under this license is thereby called the licensor.
The person physical or juridical obtaining a copy of the data or text under this license is thereby called the licensee.
The original creator(s) of the data or text under this license is thereby called the licensor.
The physical or juridical person obtaining a copy of the data or text under this license is thereby called the licensee.
The data, source code or text under this license is therefore called the object.

1. The licensee rights and obligations
1. The licensee's rights and obligations

1.1. The licensee has the right to obtain a free copy of the object.
1.2. It is the right of the licensee to redistribute unaltered copies of the object although commercial use is utterly forbidden (except with the original licensor express written consent).
1.3. The licensee is given the right to adapt or modify the object to suit his needs and to redistribute the modified version subject to the following conditions :
1.2. It is the right of the licensee to redistribute unaltered copies of the object although commercial use is utterly forbidden (except with the original licensor's express written consent).
1.3. The licensee is given the right to adapt or modify the object to suit their needs and to redistribute the modified version subject to the following conditions:

1.3.1. You must add the following notice in any copy of the object that you may create : Written originally by {Licensor} in {Year of Creation}.
1.3.1. You must add the following notice in any copy of the object that you may create: Originally written by {Licensor} in {Year of Creation}.
1.3.2. You must not remove the license information (e.g., a header in source code) present in the object.
1.3.3. You must keep a changelog somewhere inside the modified object in the following format : {Version} {YYYY-MM-DD HH:MM (24-hour cycle)} {Description}.
1.3.4. The same rule about commercial use stated in clause 1.1 applies here.
1.3.5. You must include the following notice in any object-modified copies you redistribute : This document or data is a derivative of {Name of the object} and the information contained here may or may not represent the original document or data.
1.3.6. You must include this file along with any object-modified copies you redistribute.
1.3.7. In case of juridical problems that may arise from licensee edits the licensee is liable instead of the licensor.

1.4. The licensee is given the right to redistribute work including any licensor copyrights originally contained in the object but not to use it on its own behalf.
1.3.3. The modified version of the object is subjected to the clauses 1.1 and 1.2 of this license.
1.3.3. You must include the following notice in any object-modified copies you redistribute: This document or data is a derivative of {Name of the object} and the information contained here may or may not represent the original document or data.
1.3.4. You must include this license along with any object-modified copies you redistribute.
1.3.5. In case of juridical issues that may arise from licensee edits the licensee is liable instead of the licensor.

2. The liability of the licensor and of the licensee
2. Liability of the licensor and of the licensee

2.1. The licensor offers the object as-is and as-available, and makes no representations or warranties of any kind concerning the object. Thus, the licensor is not liable for any use made of the object.
2.2. The licensee only is liable for any juridical issue related to the use of the object, edited by third parties or not.

3. Termination

3.1. All of the clauses stated in section 1 are void if the licensee fails to accomplish his obligations established in section 1.
3.2. If the 3.1 clause becomes true the licensee must pay for any costs the licensor may have with juridical actions against him.
3.1. All of the clauses stated in section 1 are void if the licensee fails to accomplish their obligations established in section 1.
3.2. If the clause 3.1 becomes true the licensee must pay for any costs the licensor may have with juridical actions against him.

4. Other terms and conditions

Expand Down
37 changes: 37 additions & 0 deletions PS4 Remote Play Auto-Patcher/License.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Simple Non Code License (SNCL)

Version 2.3.0
Copyright � 2016-2018 Alexandre Quoniou

The original creator(s) of the data or text under this license is thereby called the licensor.
The physical or juridical person obtaining a copy of the data or text under this license is thereby called the licensee.
The data, source code or text under this license is therefore called the object.

1. The licensee's rights and obligations

1.1. The licensee has the right to obtain a free copy of the object.
1.2. It is the right of the licensee to redistribute unaltered copies of the object although commercial use is utterly forbidden (except with the original licensor's express written consent).
1.3. The licensee is given the right to adapt or modify the object to suit their needs and to redistribute the modified version subject to the following conditions:

1.3.1. You must add the following notice in any copy of the object that you may create: Originally written by {Licensor} in {Year of Creation}.
1.3.2. You must not remove the license information (e.g., a header in source code) present in the object.
1.3.3. The modified version of the object is subjected to the clauses 1.1 and 1.2 of this license.
1.3.3. You must include the following notice in any object-modified copies you redistribute: This document or data is a derivative of {Name of the object} and the information contained here may or may not represent the original document or data.
1.3.4. You must include this license along with any object-modified copies you redistribute.
1.3.5. In case of juridical issues that may arise from licensee edits the licensee is liable instead of the licensor.

2. Liability of the licensor and of the licensee

2.1. The licensor offers the object as-is and as-available, and makes no representations or warranties of any kind concerning the object. Thus, the licensor is not liable for any use made of the object.
2.2. The licensee only is liable for any juridical issue related to the use of the object, edited by third parties or not.

3. Termination

3.1. All of the clauses stated in section 1 are void if the licensee fails to accomplish their obligations established in section 1.
3.2. If the clause 3.1 becomes true the licensee must pay for any costs the licensor may have with juridical actions against him.

4. Other terms and conditions

4.1. The licensor shall not be bound by any additional or different terms or conditions communicated by the licensee unless expressly agreed.
4.2. The licensor has the right to edit at any time the content of this license, however, its effects will not be retroactive.
4.3. Any modification made by the licensor shall not affect the already published versions of the object, only the future ones.
30 changes: 30 additions & 0 deletions PS4 Remote Play Auto-Patcher/PS4 Remote Play Auto-Patcher.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.271
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PS4 Remote Play Auto-Patcher", "PS4 Remote Play Auto-Patcher\PS4 Remote Play Auto-Patcher.csproj", "{73D60608-03D3-46B4-954A-25FC69CBE3F5}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{5FC4CF0B-2338-4C60-8D4E-D1E32D8A93EB}"
ProjectSection(SolutionItems) = preProject
License.txt = License.txt
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{73D60608-03D3-46B4-954A-25FC69CBE3F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{73D60608-03D3-46B4-954A-25FC69CBE3F5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{73D60608-03D3-46B4-954A-25FC69CBE3F5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{73D60608-03D3-46B4-954A-25FC69CBE3F5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {CC4F00F1-BBA2-4B30-B49E-B42350A7E059}
EndGlobalSection
EndGlobal
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.7.2" />
</startup>
</configuration>
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

140 changes: 140 additions & 0 deletions PS4 Remote Play Auto-Patcher/PS4 Remote Play Auto-Patcher/Main.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
//
// This file is licensed under the terms of the Simple Non Code License (SNCL) 2.3.0.
// The full license text can be found in the file named License.txt.
// Written originally by Alexandre Quoniou in 2019.
//

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using Microsoft.Win32;
using Mono.Cecil;
using Mono.Cecil.Cil;

namespace Dash.RemotePlayPatcher
{
public partial class Main : Form
{
public Main()
{
InitializeComponent();
}

private void patchButton_Click(object sender, EventArgs e)
{
var remotePlayLocation = FindRemotePlay();
if (string.IsNullOrEmpty(remotePlayLocation))
{
if (MessageBox.Show("The PS4 Remote Play couldn't be found. Please select the file that needs to be patched.",
"Not found",
MessageBoxButtons.OKCancel,
MessageBoxIcon.Exclamation) == DialogResult.Cancel)
{
return;
}

using (var dialog = new OpenFileDialog())
{
dialog.Title = "Select the RemotePlay.exe you want to patch";
dialog.Filter = "RemotePlay.exe|RemotePlay.exe";

if (dialog.ShowDialog() != DialogResult.OK)
{
return;
}

remotePlayLocation = dialog.FileName;
}
}

if (MessageBox.Show("Do you wish to create a backup of your original file?", "Create backup?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
File.Copy(remotePlayLocation, Path.ChangeExtension(remotePlayLocation, ".exe.bak"), true);
}

var module = ModuleDefinition.ReadModule(remotePlayLocation, new ReaderParameters() { ReadWrite = true });
var main = module.EntryPoint;
var il = main.Body.GetILProcessor();

var checkUpdateVariable = main
.Body
.Variables
.FirstOrDefault(v => v.VariableType.Name.Equals("CheckUpdate", StringComparison.InvariantCulture));
if (checkUpdateVariable == null)
{
MessageBox.Show("CheckUpdate couldn't be found in the program's entry point, please ensure that you are trying to patch the RemotePlay.",
"CheckUpdate not found.",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
return;
}

var callvirts = main
.Body
.Instructions
.SelectWithPrevious((prev, curr) => new { prev, curr })
.Where(instrs => instrs.prev.OpCode == OpCodes.Ldloc_S &&
instrs.prev.Operand is VariableDefinition def &&
def.Index == checkUpdateVariable.Index &&
instrs.curr.OpCode == OpCodes.Callvirt)
.ToList();

var showDialogCall = callvirts.FirstOrDefault(instrs => instrs.curr.Operand is MethodReference def && def.Name == "ShowDialog");
if (showDialogCall == null)
{
MessageBox.Show("The ShowDialog expected call could not be found. You might have already patched the RemotePlay.",
"Probably already patched.",
MessageBoxButtons.OK,
MessageBoxIcon.Information);
return;
}

il.Remove(showDialogCall.prev);
il.Remove(showDialogCall.curr.Next);
il.Remove(showDialogCall.curr);
module.Write();

MessageBox.Show("The RemotePlay was patched successfully!", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information);
Close();
}

private string FindRemotePlay()
{
var baseKey = Environment.Is64BitOperatingSystem ?
@"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\" :
@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\";

using (var keys = Registry.LocalMachine.OpenSubKey(baseKey))
{
var remotePlayKey = keys?.GetSubKeyNames()
.Select(name => keys.OpenSubKey(name))
.FirstOrDefault(key => key.GetValue("DisplayName", "").ToString().Contains("PS4") &&
key.GetValue("Publisher", "").ToString().Contains("Sony"));
var path = Path.Combine(remotePlayKey?.GetValue("InstallLocation", null)?.ToString() ?? string.Empty, "RemotePlay.exe");
return File.Exists(path) ? path : null;
}
}
}

public static class LinqExtensions
{
public static IEnumerable<TResult> SelectWithPrevious<TSource, TResult>(this IEnumerable<TSource> source, Func<TSource, TSource, TResult> projection)
{
using (var iterator = source.GetEnumerator())
{
if (!iterator.MoveNext())
{
yield break;
}
var previous = iterator.Current;
while (iterator.MoveNext())
{
yield return projection(previous, iterator.Current);
previous = iterator.Current;
}
}
}
}
}
Loading

0 comments on commit b14cda3

Please sign in to comment.