Fix incorrect pointer marshalling from Variant to managed runtime

#1992
This commit is contained in:
Wojtek Figat
2023-11-28 11:22:14 +01:00
parent 17dca8c5c7
commit fd938e8284
3 changed files with 10 additions and 5 deletions

View File

@@ -1271,6 +1271,9 @@ namespace FlaxEngine.Interop
case Type _ when type == typeof(IntPtr):
monoType = MTypes.Ptr;
break;
case Type _ when type.IsPointer:
monoType = MTypes.Ptr;
break;
case Type _ when type.IsEnum:
monoType = MTypes.Enum;
break;

View File

@@ -1112,11 +1112,9 @@ namespace FlaxEngine.Interop
internal static void ToManagedPointer(ref IntPtr managedValue, IntPtr nativePtr, bool byRef)
{
Type type = typeof(T);
byRef |= type.IsByRef; // Is this needed?
if (type.IsByRef)
Assert.IsTrue(type.GetElementType().IsValueType);
managedValue = byRef ? nativePtr : Unsafe.Read<IntPtr>(nativePtr.ToPointer());
if (byRef)
nativePtr = Unsafe.Read<IntPtr>(nativePtr.ToPointer());
managedValue = nativePtr;
}
internal static void ToManagedHandle(ref ManagedHandle managedValue, IntPtr nativePtr, bool byRef)