mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-16 21:07:43 +01:00
Don't throw in HookVerifier if user does not have devPlugins, until api15
This commit is contained in:
parent
dbe61a426e
commit
9c73cbe596
1 changed files with 14 additions and 6 deletions
|
|
@ -3,6 +3,7 @@ using System.Reflection;
|
|||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using Dalamud.Configuration.Internal;
|
||||
using Dalamud.Game;
|
||||
using Dalamud.Logging.Internal;
|
||||
|
||||
|
|
@ -65,6 +66,13 @@ internal static class HookVerifier
|
|||
/// <exception cref="HookVerificationException">Exception thrown when we think the hook is not correctly declared.</exception>
|
||||
public static void Verify<T>(IntPtr address) where T : Delegate
|
||||
{
|
||||
// API15 TODO: Always throw
|
||||
var config = Service<DalamudConfiguration>.GetNullable();
|
||||
if (config != null && config.DevPluginLoadLocations.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var entry = ToVerify.FirstOrDefault(x => x.Address == address);
|
||||
|
||||
// Nothing to verify for this hook?
|
||||
|
|
@ -121,7 +129,7 @@ internal static class HookVerifier
|
|||
return sameType || SizeOf(paramLeft, isMarshaled) == SizeOf(paramRight, false);
|
||||
}
|
||||
|
||||
private static int SizeOf(Type type, bool isMarshaled)
|
||||
private static int SizeOf(Type type, bool isMarshaled)
|
||||
{
|
||||
return type switch {
|
||||
_ when type == typeof(sbyte) || type == typeof(byte) || (type == typeof(bool) && !isMarshaled) => 1,
|
||||
|
|
@ -137,19 +145,19 @@ internal static class HookVerifier
|
|||
};
|
||||
}
|
||||
|
||||
private static int GetSizeOf(Type type)
|
||||
private static int GetSizeOf(Type type)
|
||||
{
|
||||
try
|
||||
try
|
||||
{
|
||||
return Marshal.SizeOf(Activator.CreateInstance(type)!);
|
||||
}
|
||||
catch
|
||||
}
|
||||
catch
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsStruct(Type type)
|
||||
private static bool IsStruct(Type type)
|
||||
{
|
||||
return type != typeof(decimal) && type is { IsValueType: true, IsPrimitive: false, IsEnum: false };
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue