Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions Refresher.AndroidApp/MainActivity.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using _Microsoft.Android.Resource.Designer;
using Android.Content;
using Refresher.Core.Pipelines;
using Refresher.Core.Pipelines.Lbp;
using Refresher.Core.Patching.Pipelines;
using Refresher.Core.Patching.Pipelines.Lbp;
using Refresher.Core.Patching.Pipelines.Legacy;
using Refresher.Core.Patching.Pipelines.Test;
using SCEToolSharp;

using ConditionalAttribute = System.Diagnostics.ConditionalAttribute;
Expand All @@ -24,7 +26,7 @@ protected override void OnCreate(Bundle? savedInstanceState)

this.AddButtonForPipeline<LbpPS3PatchPipeline>(mainContent, "Patch LBP1/2/3 for PS3");
this.AddButtonForPipeline<PS3PatchPipeline>(mainContent, "Patch any PS3 game");
#if DEBUG
#if DEBUG
this.AddButtonForPipeline<ExamplePipeline>(mainContent, "Example Pipeline");
this.AddSceToolSharpTestButton(mainContent);
#endif
Expand Down
3 changes: 2 additions & 1 deletion Refresher.AndroidApp/PipelineActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
using Android.Views;
using Refresher.Core;
using Refresher.Core.Logging;
using Refresher.Core.Pipelines;
using Refresher.Core.Patching.Pipelines;
using Refresher.Core.Patching.Steps;
using static Android.Views.ViewGroup.LayoutParams;

namespace Refresher.AndroidApp;
Expand All @@ -12,7 +13,7 @@
[Activity]
public class PipelineActivity : RefresherActivity
{
internal static PipelineActivity Instance { get; private set; }

Check warning on line 16 in Refresher.AndroidApp/PipelineActivity.cs

View workflow job for this annotation

GitHub Actions / Build, Test, and Upload Builds (ubuntu-latest)

Non-nullable property 'Instance' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

private Pipeline? _pipeline;
private PipelineController _controller;
Expand All @@ -26,11 +27,11 @@
private ProgressBar _progressBar = null!;
private ProgressBar _currentProgressBar = null!;

private bool _usedAutoDiscover = false;

Check warning on line 30 in Refresher.AndroidApp/PipelineActivity.cs

View workflow job for this annotation

GitHub Actions / Build, Test, and Upload Builds (ubuntu-latest)

The field 'PipelineActivity._usedAutoDiscover' is assigned but its value is never used

private readonly Handler _handler = new(Looper.MainLooper!);

public PipelineActivity()

Check warning on line 34 in Refresher.AndroidApp/PipelineActivity.cs

View workflow job for this annotation

GitHub Actions / Build, Test, and Upload Builds (ubuntu-latest)

Non-nullable field '_controller' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.
{
Instance = this;
}
Expand Down Expand Up @@ -141,7 +142,7 @@
if(this._pipelineInputs.FindViewWithTag("url") is not EditText text)
throw new Exception("URL input was not found");

this._controller.AutoDiscoverButtonClick(text.Text, autoDiscover =>

Check warning on line 145 in Refresher.AndroidApp/PipelineActivity.cs

View workflow job for this annotation

GitHub Actions / Build, Test, and Upload Builds (ubuntu-latest)

Possible null reference argument for parameter 'url' in 'void PipelineController.AutoDiscoverButtonClick(string url, Action<AutoDiscoverResponse> onSuccess)'.
{
this._usedAutoDiscover = true;

Expand Down
14 changes: 7 additions & 7 deletions Refresher.Core/Accessors/ConsolePatchAccessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public ConsolePatchAccessor(string remoteIp)

private byte[]? GetIdps()
{
State.Logger.LogInfo(IDPS, "Getting IDPS from the console...");
State.Logger.LogInfo(LogType.IDPS, "Getting IDPS from the console...");
UriBuilder idpsPs3 = new("http", this._remoteIp, 80, "idps.ps3");
UriBuilder idpsHex = new("http", this._remoteIp, 80, "dev_hdd0/idps.hex");
UriBuilder idpsHexUsb = new("http", this._remoteIp, 80, "dev_usb000/idps.hex");
Expand All @@ -48,7 +48,7 @@ public ConsolePatchAccessor(string remoteIp)
{
HttpResponseMessage response;

State.Logger.LogDebug(IDPS, $" {stepName} ({uri.AbsolutePath})");
State.Logger.LogDebug(LogType.IDPS, $" {stepName} ({uri.AbsolutePath})");
try
{
response = client.GetAsync(uri).Result;
Expand All @@ -62,17 +62,17 @@ public ConsolePatchAccessor(string remoteIp)
{
if (!HandleIdpsRequestError(e))
{
State.Logger.LogError(IDPS, $"Couldn't fetch the IDPS from the PS3 because of an unknown error: {e}");
State.Logger.LogError(LogType.IDPS, $"Couldn't fetch the IDPS from the PS3 because of an unknown error: {e}");
SentrySdk.CaptureException(e);
}
return null;
}
State.Logger.LogDebug(IDPS, $" {(int)response.StatusCode} {response.StatusCode} (success: {response.IsSuccessStatusCode})");
State.Logger.LogDebug(LogType.IDPS, $" {(int)response.StatusCode} {response.StatusCode} (success: {response.IsSuccessStatusCode})");

if (!response.IsSuccessStatusCode)
{
State.Logger.LogError(IDPS, $"Couldn't fetch the IDPS from the PS3 because of a bad status code: {response.StatusCode}");
State.Logger.LogDebug(IDPS, response.Content.ReadAsStringAsync().Result);
State.Logger.LogError(LogType.IDPS, $"Couldn't fetch the IDPS from the PS3 because of a bad status code: {response.StatusCode}");
State.Logger.LogDebug(LogType.IDPS, response.Content.ReadAsStringAsync().Result);
return null;
}

Expand All @@ -83,7 +83,7 @@ private static bool HandleIdpsRequestError(Exception inner)
{
if (inner is HttpRequestException httpException)
{
State.Logger.LogError(IDPS, $"Couldn't fetch the IDPS from the PS3 because we couldn't make the request: {httpException.Message}");
State.Logger.LogError(LogType.IDPS, $"Couldn't fetch the IDPS from the PS3 because we couldn't make the request: {httpException.Message}");
return true;
}

Expand Down
5 changes: 3 additions & 2 deletions Refresher.Core/Accessors/PatchAccessor.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Reflection;
using Refresher.Core.Pipelines;
using Refresher.Core.Patching.Pipelines;
using Refresher.Core.Patching.Steps;

namespace Refresher.Core.Accessors;

Expand Down Expand Up @@ -96,7 +97,7 @@ public static async Task<bool> TryAsync(Step step, Func<Task> action)

private static void CatchAccessorException(Step step, Exception ex)
{
State.Logger.LogError(Accessor, "Filesystem error: " + ex);
State.Logger.LogError(LogType.Accessor, "Filesystem error: " + ex);
step.Fail($"Something went wrong while accessing the filesystem: {ex.GetType().Name}: {ex.Message}");
}
}
1 change: 0 additions & 1 deletion Refresher.Core/GlobalUsings.cs

This file was deleted.

6 changes: 3 additions & 3 deletions Refresher.Core/Patching/EbootPatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
public partial class EbootPatcher : IPatcher
{
private readonly Lazy<List<PatchTargetInfo>> _targets;
private readonly Lazy<string?> _ppuHash = null;

Check warning on line 17 in Refresher.Core/Patching/EbootPatcher.cs

View workflow job for this annotation

GitHub Actions / Build, Test, and Upload Builds (windows-latest)

Cannot convert null literal to non-nullable reference type.

Check warning on line 17 in Refresher.Core/Patching/EbootPatcher.cs

View workflow job for this annotation

GitHub Actions / Build, Test, and Upload Builds (ubuntu-latest)

Cannot convert null literal to non-nullable reference type.

Check warning on line 17 in Refresher.Core/Patching/EbootPatcher.cs

View workflow job for this annotation

GitHub Actions / Build, Test, and Upload Builds (macos-latest)

Cannot convert null literal to non-nullable reference type.

public bool GenerateRpcs3Patch = false;
public string? Rpcs3PatchFolder = null;
Expand Down Expand Up @@ -141,7 +141,7 @@
FindLbpkDomains(reader, lbpkPositions, foundItems);

long end = Stopwatch.GetTimestamp();
State.Logger.LogDebug(Patcher, $"Detecting patchables took {(end - start) / (double)Stopwatch.Frequency} seconds!");
State.Logger.LogDebug(LogType.Patcher, $"Detecting patchables took {(end - start) / (double)Stopwatch.Frequency} seconds!");
return foundItems;
}

Expand Down Expand Up @@ -245,7 +245,7 @@

if (UrlMatch().Matches(str).Count != 0)
{
State.Logger.LogTrace(Patcher, $"Found URL at offset {foundPosition}: '{str}'");
State.Logger.LogTrace(LogType.Patcher, $"Found URL at offset {foundPosition}: '{str}'");
foundItems.Add(new PatchTargetInfo
{
Length = len,
Expand Down Expand Up @@ -344,7 +344,7 @@

string ppuHash = BitConverter.ToString(hash.Hash!).Replace("-", "").ToLower();

State.Logger.LogDebug(PPU, $"PPU hash: PPU-{ppuHash}");
State.Logger.LogDebug(LogType.PPU, $"PPU hash: PPU-{ppuHash}");
return ppuHash;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using Refresher.Core.Pipelines.Steps;
using Refresher.Core.Patching.Steps.Common;
using Refresher.Core.Patching.Steps.PS3;

namespace Refresher.Core.Pipelines.Lbp;
namespace Refresher.Core.Patching.Pipelines.Lbp;

public class LbpPS3PatchPipeline : Pipeline
{
public override string Id => "lbp-ps3-patch";
public override string Name => "LBP PS3 Patch";

protected override Type SetupAccessorStepType => typeof(SetupPS3AccessorStep);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
using Refresher.Core.Accessors;
using Refresher.Core.Pipelines.Steps;
using Refresher.Core.Patching.Steps.Common;
using Refresher.Core.Patching.Steps.RPCS3;

namespace Refresher.Core.Pipelines.Lbp;
namespace Refresher.Core.Patching.Pipelines.Lbp;

public class LbpRPCS3PatchPipeline : Pipeline
{
public override string Id => "lbp-rpcs3-patch";
public override string Name => "LBP RPCS3 Patch";

protected override Type SetupAccessorStepType => typeof(SetupEmulatorAccessorStep);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using Refresher.Core.Pipelines.Steps;
using Refresher.Core.Patching.Steps.Common;

namespace Refresher.Core.Pipelines.Lbp;
namespace Refresher.Core.Patching.Pipelines.Lbp;

public abstract class PatchworkConfigPipeline : Pipeline
{
public override string Id => "patchwork-config-" + this.ConsoleName.ToLower();
public override string Name => $"Patchwork {this.ConsoleName} Config";

public override string? ShorthandUrlId => this.ConsoleName.ToLower();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Refresher.Core.Pipelines.Steps;
using Refresher.Core.Patching.Steps.PS3;

namespace Refresher.Core.Pipelines.Lbp;
namespace Refresher.Core.Patching.Pipelines.Lbp;

public class PatchworkPS3ConfigPipeline : PatchworkConfigPipeline
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Refresher.Core.Pipelines.Steps;
using Refresher.Core.Patching.Steps.RPCS3;

namespace Refresher.Core.Pipelines.Lbp;
namespace Refresher.Core.Patching.Pipelines.Lbp;

public class PatchworkRPCS3ConfigPipeline : PatchworkConfigPipeline
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using Refresher.Core.Pipelines.Steps;
using Refresher.Core.Patching.Steps.Legacy;

namespace Refresher.Core.Pipelines;
namespace Refresher.Core.Patching.Pipelines.Legacy;

public class ElfToElfPatchPipeline : Pipeline
{
public override string Id => "elf-elf-patch";
public override string Name => ".elf->.elf Patch";

protected override List<Type> StepTypes =>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using Refresher.Core.Pipelines.Steps;
using Refresher.Core.Patching.Steps.Common;
using Refresher.Core.Patching.Steps.Legacy;
using Refresher.Core.Patching.Steps.PS3;

namespace Refresher.Core.Pipelines;
namespace Refresher.Core.Patching.Pipelines.Legacy;

public class PS3PatchPipeline : Pipeline
{
public override string Id => "ps3-patch";
public override string Name => "PS3 Patch (any game)";

protected override Type SetupAccessorStepType => typeof(SetupPS3AccessorStep);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using Refresher.Core.Pipelines.Steps;
using Refresher.Core.Patching.Steps.Common;
using Refresher.Core.Patching.Steps.Legacy;
using Refresher.Core.Patching.Steps.RPCS3;

namespace Refresher.Core.Pipelines;
namespace Refresher.Core.Patching.Pipelines.Legacy;

public class RPCS3PatchPipeline : Pipeline
{
public override string Id => "rpcs3-patch";
public override string Name => "RPCS3 Patch (any game)";

protected override Type SetupAccessorStepType => typeof(SetupEmulatorAccessorStep);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
using System.Collections.Frozen;
using System.Diagnostics;
using Refresher.Core.Accessors;
using Refresher.Core.Patching;
using Refresher.Core.Pipelines.Steps;
using Refresher.Core.Patching.Steps;
using Refresher.Core.Patching.Steps.Common;
using Refresher.Core.Platform;
using Refresher.Core.Storage;
using Refresher.Core.Verification.AutoDiscover;
using GlobalState = Refresher.Core.State;

namespace Refresher.Core.Pipelines;
namespace Refresher.Core.Patching.Pipelines;

public abstract class Pipeline : IAccessesPlatform
{
public abstract string Id { get; }
public abstract string Name { get; }

public readonly Dictionary<string, string> Inputs = [];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Refresher.Core.Platform;
using Refresher.Core.Verification.AutoDiscover;

namespace Refresher.Core.Pipelines;
namespace Refresher.Core.Patching.Pipelines;

/// <summary>
/// A set of common utilities to assist in controlling a pipeline from a UI.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Refresher.Core.Pipelines;
namespace Refresher.Core.Patching.Pipelines;

public enum PipelineState : byte
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using Refresher.Core.Pipelines.Steps;
using Refresher.Core.Patching.Steps.Test;

namespace Refresher.Core.Pipelines;
namespace Refresher.Core.Patching.Pipelines.Test;

public class ExamplePipeline : Pipeline
{
public override string Id => "example";
public override string Name => "Example Pipeline";
protected override List<Type> StepTypes { get; } =
[
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
using SPRXPatcher.Elf;
using Refresher.Core.Patching.Pipelines;
using SPRXPatcher.Elf;

namespace Refresher.Core.Pipelines.Steps;
namespace Refresher.Core.Patching.Steps.Common;

public class ApplySprxPatchToEbootStep : Step
{
public ApplySprxPatchToEbootStep(Pipeline pipeline) : base(pipeline)
{}

public override string Name { get; } = "Hooking Patchwork to your EBOOT";
public override float Progress { get; protected set; }
public override async Task ExecuteAsync(CancellationToken cancellationToken = default)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
using Refresher.Core.Accessors;
using Refresher.Core.Patching.Pipelines;
using Refresher.Core.Accessors;

namespace Refresher.Core.Pipelines.Steps;
namespace Refresher.Core.Patching.Steps.Common;

public class BackupGameEbootBeforeReplaceStep : Step
{
public BackupGameEbootBeforeReplaceStep(Pipeline pipeline) : base(pipeline)
{}

public override string Name { get; } = "Backing up your current EBOOT";
public override float Progress { get; protected set; }
public override Task ExecuteAsync(CancellationToken cancellationToken = default)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
using Refresher.Core.Patching.Pipelines;
using SCEToolSharp;

namespace Refresher.Core.Pipelines.Steps;
namespace Refresher.Core.Patching.Steps.Common;

public class DecryptGameEbootStep : Step
{
public DecryptGameEbootStep(Pipeline pipeline) : base(pipeline)
{}

public override string Name { get; } = "Decrypting your EBOOT";
public override float Progress { get; protected set; }
public override Task ExecuteAsync(CancellationToken cancellationToken = default)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
using Refresher.Core.Accessors;
using Refresher.Core.Patching.Pipelines;

namespace Refresher.Core.Pipelines.Steps;
namespace Refresher.Core.Patching.Steps.Common;

public class DownloadGameEbootStep : Step
{
public DownloadGameEbootStep(Pipeline pipeline) : base(pipeline)
{}

public override string Name { get; } = "Downloading your EBOOT";
public override float Progress { get; protected set; }
public override Task ExecuteAsync(CancellationToken cancellationToken = default)
{
Expand All @@ -19,7 +21,7 @@ public override Task ExecuteAsync(CancellationToken cancellationToken = default)
if (this.Pipeline.Accessor!.FileExists(ebootPath)) return;
// If the backup doesn't exist, use the EBOOT.BIN

State.Logger.LogInfo(Accessor, "Couldn't find an original backup of the EBOOT, using active copy. This is not an error.");
State.Logger.LogInfo(LogType.Accessor, "Couldn't find an original backup of the EBOOT, using active copy. This is not an error.");
ebootPath = Path.Combine(usrDir, "EBOOT.BIN");

this.Progress = 0.25f;
Expand Down Expand Up @@ -47,7 +49,7 @@ public override Task ExecuteAsync(CancellationToken cancellationToken = default)
if(this.Failed)
return Task.CompletedTask;

State.Logger.LogDebug(Accessor, $"Downloaded EBOOT Path: {downloadedFile}");
State.Logger.LogDebug(LogType.Accessor, $"Downloaded EBOOT Path: {downloadedFile}");
if (!File.Exists(downloadedFile))
{
return this.Fail("Could not find the EBOOT we downloaded. This is likely a bug. Patching cannot continue.");
Expand Down
Loading
Loading