Skip to content

Commit

Permalink
Fix non-digital patching
Browse files Browse the repository at this point in the history
  • Loading branch information
Beyley committed Jan 18, 2024
1 parent 0341b0c commit 39c7ffe
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions Refresher/UI/IntegratedPatchForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,15 @@ protected virtual void GameChanged(object? sender, EventArgs ev)
return;
}

string contentId = LibSceToolSharp.GetContentId(downloadedFile).TrimEnd('\0');
this._cachedContentIds[game.TitleId] = contentId;

string licenseDir = Path.Join(Path.GetTempPath(), "refresher-" + Random.Shared.Next());
Directory.CreateDirectory(licenseDir);

// if this is a NP game then download the RIF for the right content ID, disc copies don't need anything else
if (game.TitleId.StartsWith('N'))
{
string contentId = LibSceToolSharp.GetContentId(downloadedFile).TrimEnd('\0');
this._cachedContentIds[game.TitleId] = contentId;

string licenseDir = Path.Join(Path.GetTempPath(), "refresher-" + Random.Shared.Next());
Directory.CreateDirectory(licenseDir);

foreach (string user in this.Accessor.GetDirectoriesInDirectory(Path.Combine("home")))
{
Console.WriteLine($"Checking all license files in {user}");
Expand All @@ -139,27 +139,28 @@ protected virtual void GameChanged(object? sender, EventArgs ev)
//If the license file does not contain the content ID in its path, skip it
if (!licenseFile.Contains(contentId))
continue;

//If it is a valid content id, lets download that user's exdata
string downloadedActDat = this.Accessor.DownloadFile(Path.Combine(user, "exdata", "act.dat"));
LibSceToolSharp.SetActDatFilePath(downloadedActDat);

//And the license file
string downloadedLicenseFile = this.Accessor.DownloadFile(licenseFile);
File.Move(downloadedLicenseFile, Path.Join(licenseDir, Path.GetFileName(licenseFile)));

Console.WriteLine($"Downloaded license file {licenseFile}.");
}
}
}

this._tempFile = Path.GetTempFileName();

//If we are using the console patch accessor, fill out the IDPS patch file.
if (this.Accessor is ConsolePatchAccessor consolePatchAccessor)
LibSceToolSharp.SetIdpsKey(consolePatchAccessor.IdpsFile.Value);

//If we are using the console patch accessor, fill out the IDPS patch file.
if (this.Accessor is ConsolePatchAccessor consolePatchAccessor)
LibSceToolSharp.SetIdpsKey(consolePatchAccessor.IdpsFile.Value);
LibSceToolSharp.SetRifPath(licenseDir);
}

LibSceToolSharp.SetRifPath(licenseDir);
this._tempFile = Path.GetTempFileName();

LibSceToolSharp.Decrypt(downloadedFile, this._tempFile);

this.LogMessage($"The EBOOT has been successfully decrypted. It's stored at {this._tempFile}.");
Expand Down

0 comments on commit 39c7ffe

Please sign in to comment.