chore: warnings pass

This commit is contained in:
goat 2022-10-29 15:19:52 +02:00
parent 505e37fd28
commit b093323acc
No known key found for this signature in database
GPG key ID: 49E2AA8C6A76498B
49 changed files with 352 additions and 254 deletions

View file

@ -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;

View file

@ -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);

View file

@ -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;