From 174caaf13962013ebef1429769d7702375d58a40 Mon Sep 17 00:00:00 2001 From: wolfcomp <4028289+wolfcomp@users.noreply.github.com> Date: Tue, 27 Jan 2026 16:02:48 +0100 Subject: [PATCH] Fix SizeOf calls --- Dalamud/Hooking/Internal/Verification/HookVerifier.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Dalamud/Hooking/Internal/Verification/HookVerifier.cs b/Dalamud/Hooking/Internal/Verification/HookVerifier.cs index 550429075..45fde1dce 100644 --- a/Dalamud/Hooking/Internal/Verification/HookVerifier.cs +++ b/Dalamud/Hooking/Internal/Verification/HookVerifier.cs @@ -120,10 +120,10 @@ internal static class HookVerifier _ when type == typeof(char) || type == typeof(short) || type == typeof(ushort) || type == typeof(Half) => 2, _ when type == typeof(int) || type == typeof(uint) || type == typeof(float) => 4, _ when type == typeof(long) || type == typeof(ulong) || type == typeof(double) || type.IsPointer || type.IsFunctionPointer || type.IsUnmanagedFunctionPointer || (type.Name == "Pointer`1" && type.Namespace.AsSpan().SequenceEqual(ClientStructsInteropNamespacePrefix)) || type == typeof(CStringPointer) => 8, - _ when type.Name.StartsWith("FixedSizeArray") => type.GetGenericArguments()[0].SizeOf() * int.Parse(type.Name[14..type.Name.IndexOf('`')]), - _ when type.GetCustomAttribute() is { Length: var length } => type.GetGenericArguments()[0].SizeOf() * length, + _ when type.Name.StartsWith("FixedSizeArray") => SizeOf(type.GetGenericArguments()[0]) * int.Parse(type.Name[14..type.Name.IndexOf('`')]), + _ when type.GetCustomAttribute() is { Length: var length } => SizeOf(type.GetGenericArguments()[0]) * length, _ when type.IsStruct() && !type.IsGenericType && (type.StructLayoutAttribute?.Value ?? LayoutKind.Sequential) != LayoutKind.Sequential => type.StructLayoutAttribute?.Size ?? (int?)typeof(Unsafe).GetMethod("SizeOf")?.MakeGenericMethod(type).Invoke(null, null) ?? 0, - _ when type.IsEnum => Enum.GetUnderlyingType(type).SizeOf(), + _ when type.IsEnum => SizeOf(Enum.GetUnderlyingType(type)), _ when type.IsGenericType => Marshal.SizeOf(Activator.CreateInstance(type)!), _ => GetSizeOf(type) }; @@ -137,7 +137,7 @@ internal static class HookVerifier } } - private static bool IsStruct(this Type type) { + private static bool IsStruct(Type type) { return type != typeof(decimal) && type is { IsValueType: true, IsPrimitive: false, IsEnum: false }; }