|
4 | 4 | using System.Reflection; |
5 | 5 | using System.Reflection.Emit; |
6 | 6 | using System.Runtime.InteropServices; |
| 7 | +using System.Text; |
7 | 8 | using BepInEx.Logging; |
8 | 9 | using HarmonyLib; |
9 | 10 | using HarmonyLib.Public.Patching; |
| 11 | +using Mono.Cecil.Cil; |
10 | 12 | using MonoMod.Cil; |
11 | 13 | using MonoMod.RuntimeDetour; |
12 | 14 | using MonoMod.Utils; |
13 | 15 | using UnhollowerBaseLib; |
14 | 16 | using UnhollowerBaseLib.Runtime; |
15 | 17 | using UnhollowerBaseLib.Runtime.VersionSpecific.MethodInfo; |
| 18 | +using OpCode = System.Reflection.Emit.OpCode; |
| 19 | +using OpCodes = System.Reflection.Emit.OpCodes; |
16 | 20 | using ValueType = Il2CppSystem.ValueType; |
17 | 21 | using Void = Il2CppSystem.Void; |
18 | 22 |
|
@@ -289,9 +293,9 @@ private static Type ConvertManagedTypeToIL2CPPType(Type managedType) |
289 | 293 | if (directType == typeof(string) || directType.IsSubclassOf(typeof(Il2CppObjectBase))) |
290 | 294 | return typeof(IntPtr*); |
291 | 295 | } |
292 | | - else if (managedType.IsSubclassOf(typeof(ValueType)) |
293 | | - ) // Struct that's passed on the stack => handle as general struct |
| 296 | + else if (managedType.IsSubclassOf(typeof(ValueType)) && !PlatformHelper.Is(Platform.Bits64)) |
294 | 297 | { |
| 298 | + // Struct that's passed on the stack => handle as general struct |
295 | 299 | uint align = 0; |
296 | 300 | var fixedSize = |
297 | 301 | UnhollowerBaseLib.IL2CPP.il2cpp_class_value_size(Il2CppTypeToClassPointer(managedType), ref align); |
@@ -329,10 +333,10 @@ private static void EmitConvertArgumentToManaged(ILGenerator il, |
329 | 333 | { |
330 | 334 | variable = null; |
331 | 335 |
|
332 | | - // Box struct into object first before conversion |
333 | | - // This will likely incur struct copying down the line, but it shouldn't be a massive loss |
334 | | - if (managedParamType.IsSubclassOf(typeof(ValueType))) |
| 336 | + if (managedParamType.IsSubclassOf(typeof(ValueType)) && !PlatformHelper.Is(Platform.Bits64)) |
335 | 337 | { |
| 338 | + // Box struct into object first before conversion |
| 339 | + // This will likely incur struct copying down the line, but it shouldn't be a massive loss |
336 | 340 | il.Emit(OpCodes.Ldc_I8, Il2CppTypeToClassPointer(managedParamType).ToInt64()); |
337 | 341 | il.Emit(OpCodes.Conv_I); |
338 | 342 | il.Emit(OpCodes.Ldarga_S, argIndex); |
|
0 commit comments