Skip to content

Commit

Permalink
Updated patcher so it will accept a signed version of the patcher (#652)
Browse files Browse the repository at this point in the history
Co-authored-by: Martin Barker <martin.barker@vtn.live>
  • Loading branch information
barkermn01 and Martin Barker authored Aug 5, 2024
1 parent cefb9a2 commit eb91591
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions Memoria.Patcher/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,30 @@ private static void Run(String[] args)
String executablePath = Assembly.GetEntryAssembly().Location;
using (FileStream inputFile = File.OpenRead(executablePath))
{
inputFile.Seek(-3 * 8, SeekOrigin.End);
Int64 magicNumber;
BinaryReader br = new BinaryReader(inputFile);
try
{
// if the file is signed
inputFile.Seek(-0x28B2, SeekOrigin.End);

magicNumber = br.ReadInt64();
if (magicNumber != 0x004149524F4D454D)// MEMORIA\0
throw new InvalidDataException("Invalid magic number: " + magicNumber);
}
catch (Exception ex)
{
// if the file is not signed
inputFile.Seek(-3 * 8, SeekOrigin.End);

magicNumber = br.ReadInt64();
if (magicNumber != 0x004149524F4D454D)// MEMORIA\0
throw new InvalidDataException("Invalid magic number: " + magicNumber);
}


Int64 magicNumber = br.ReadInt64();
Int64 uncompressedDataSize = br.ReadInt64();
Int64 compressedDataPosition = br.ReadInt64();
if (magicNumber != 0x004149524F4D454D) // MEMORIA\0
throw new InvalidDataException("Invalid magic number: " + magicNumber);

Boolean isSteamOverlayFixed = GameLocationSteamRegistryProvider.IsSteamOverlayFixed();
Boolean fixReleased = false;
Expand Down

0 comments on commit eb91591

Please sign in to comment.