mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-01-03 14:23:40 +01:00
revert only the required length of bytes
This commit is contained in:
parent
85bcf3c30f
commit
1d9d383348
1 changed files with 6 additions and 7 deletions
|
|
@ -169,15 +169,14 @@ namespace Dalamud.Hooking.Internal
|
|||
break;
|
||||
}
|
||||
|
||||
var snippet = originalBytes[0..i];
|
||||
|
||||
if (i > 0)
|
||||
{
|
||||
Log.Verbose($"Reverting hook at 0x{address.ToInt64():X}");
|
||||
fixed (byte* original = originalBytes)
|
||||
{
|
||||
MemoryHelper.ChangePermission(address, i, MemoryProtection.ExecuteReadWrite, out var oldPermissions);
|
||||
MemoryHelper.WriteRaw(address, originalBytes);
|
||||
MemoryHelper.ChangePermission(address, i, oldPermissions);
|
||||
}
|
||||
Log.Verbose($"Reverting hook at 0x{address.ToInt64():X} ({snippet.Length} bytes)");
|
||||
MemoryHelper.ChangePermission(address, i, MemoryProtection.ExecuteReadWrite, out var oldPermissions);
|
||||
MemoryHelper.WriteRaw(address, snippet);
|
||||
MemoryHelper.ChangePermission(address, i, oldPermissions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue