Skip to content

Commit

Permalink
Fixed bug if the pattern isn't found
Browse files Browse the repository at this point in the history
  • Loading branch information
Ceiridge committed May 29, 2020
1 parent cb6bef9 commit 73b9c01
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions ChromeDevExtWarningPatcher/DllPatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public bool Patch(BytePatchPattern.WriteToLog log) {
throw new IOException("File not found");

byte[] raw = File.ReadAllBytes(dllFile.FullName);
log("Patching " + dllFile.FullName + "...");

FileInfo dllFileBackup = new FileInfo(dllFile.FullName + ".bck");
if (!dllFileBackup.Exists) {
Expand Down
8 changes: 4 additions & 4 deletions ChromeDevExtWarningPatcher/Patches/BytePatchManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,11 @@ public bool PatchBytes(ref byte[] raw, bool x64, BytePatchPattern.WriteToLog log
byte patchOrigByte = x64 ? patch.origByteX64 : patch.origByteX86;
byte patchPatchByte = x64 ? patch.patchByteX64 : patch.patchByteX86;

if (patchOffset < searchPattern.Length && searchPattern[patchOffset] != 0xFF)
patchOrigByte = searchPattern[patchOffset]; // The patterns can sometimes start at different places (yes, I'm looking at you, Edge), so the byte in the pattern should be always preferred

if (addr != -1) {
REDO_CHECKS:
if (patchOffset < searchPattern.Length && searchPattern[patchOffset] != 0xFF)
patchOrigByte = searchPattern[patchOffset]; // The patterns can sometimes start at different places (yes, I'm looking at you, Edge), so the byte in the pattern should be always preferred

REDO_CHECKS:
long index = addr + patchOffset;
byte sourceByte = raw[index];

Expand Down

0 comments on commit 73b9c01

Please sign in to comment.