mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-01-03 14:23:40 +01:00
chore: warnings pass
This commit is contained in:
parent
505e37fd28
commit
b093323acc
49 changed files with 352 additions and 254 deletions
|
|
@ -15,8 +15,12 @@ namespace Dalamud.Hooking
|
|||
/// <typeparam name="T">Delegate type to represents a function prototype. This must be the same prototype as original function do.</typeparam>
|
||||
public class Hook<T> : IDisposable, IDalamudHook where T : Delegate
|
||||
{
|
||||
#pragma warning disable SA1310
|
||||
// ReSharper disable once InconsistentNaming
|
||||
private const ulong IMAGE_ORDINAL_FLAG64 = 0x8000000000000000;
|
||||
// ReSharper disable once InconsistentNaming
|
||||
private const uint IMAGE_ORDINAL_FLAG32 = 0x80000000;
|
||||
#pragma warning restore SA1310
|
||||
|
||||
private readonly IntPtr address;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ using System;
|
|||
using System.ComponentModel;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using Dalamud.Memory;
|
||||
|
||||
namespace Dalamud.Hooking.Internal
|
||||
|
|
@ -96,8 +97,7 @@ namespace Dalamud.Hooking.Internal
|
|||
{
|
||||
lock (HookManager.HookEnableSyncRoot)
|
||||
{
|
||||
if (!NativeFunctions.VirtualProtect(this.Address, (UIntPtr)Marshal.SizeOf<IntPtr>(),
|
||||
MemoryProtection.ExecuteReadWrite, out var oldProtect))
|
||||
if (!NativeFunctions.VirtualProtect(this.Address, (UIntPtr)Marshal.SizeOf<IntPtr>(), MemoryProtection.ExecuteReadWrite, out var oldProtect))
|
||||
throw new Win32Exception(Marshal.GetLastWin32Error());
|
||||
|
||||
Marshal.WriteIntPtr(this.Address, Marshal.GetFunctionPointerForDelegate(this.detourDelegate));
|
||||
|
|
@ -115,8 +115,7 @@ namespace Dalamud.Hooking.Internal
|
|||
{
|
||||
lock (HookManager.HookEnableSyncRoot)
|
||||
{
|
||||
if (!NativeFunctions.VirtualProtect(this.Address, (UIntPtr)Marshal.SizeOf<IntPtr>(),
|
||||
MemoryProtection.ExecuteReadWrite, out var oldProtect))
|
||||
if (!NativeFunctions.VirtualProtect(this.Address, (UIntPtr)Marshal.SizeOf<IntPtr>(), MemoryProtection.ExecuteReadWrite, out var oldProtect))
|
||||
throw new Win32Exception(Marshal.GetLastWin32Error());
|
||||
|
||||
Marshal.WriteIntPtr(this.Address, this.pfnOriginal);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,10 @@ using Reloaded.Hooks;
|
|||
|
||||
namespace Dalamud.Hooking.Internal
|
||||
{
|
||||
/// <summary>
|
||||
/// Class facilitating hooks via reloaded.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Delegate of the hook.</typeparam>
|
||||
internal class ReloadedHook<T> : Hook<T> where T : Delegate
|
||||
{
|
||||
private readonly Reloaded.Hooks.Definitions.IHook<T> hookImpl;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue