Skip to content

Commit

Permalink
Fixed avatar instantiation hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
benaclejames committed Jun 17, 2021
1 parent e5c4a68 commit 5cb2d3d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 5 additions & 6 deletions VRCFaceTracking/Hooking.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ public static unsafe void SetupHooking()

intPtr = (IntPtr) typeof(VRCAvatarManager)
.GetField(
"NativeMethodInfoPtr_Method_Public_Boolean_ApiAvatar_String_Single_MulticastDelegateNPublicSealedVoGaVRBoUnique_0",
"NativeMethodInfoPtr_Method_Internal_Void_MulticastDelegateNPublicSealedVoGaVRBoUnique_PDM_0",
BindingFlags.Static | BindingFlags.NonPublic).GetValue(null);
MelonUtils.NativeHookAttach(intPtr,
new Action<IntPtr, IntPtr, string, float, IntPtr>(OnAvatarSwitch).Method.MethodHandle
new Action<IntPtr, IntPtr, IntPtr>(OnAvatarSwitch).Method.MethodHandle
.GetFunctionPointer());
_avatarSwitch = Marshal.GetDelegateForFunctionPointer<OnAvatarSwitchDelegate>(*(IntPtr*) (void*) intPtr);
}
Expand All @@ -42,7 +42,7 @@ public static unsafe void SetupHooking()
}
}

private static void OnAvatarSwitch(IntPtr @this, IntPtr test1, string string1, float float1, IntPtr ptr1)
private static void OnAvatarSwitch(IntPtr @this, IntPtr test1, IntPtr ptr1)
{
try
{
Expand All @@ -60,7 +60,7 @@ private static void OnAvatarSwitch(IntPtr @this, IntPtr test1, string string1, f
MelonLogger.Error("Error on Avatar Switch: " + e);
}

_avatarSwitch(@this, test1, string1, float1, ptr1);
_avatarSwitch(@this, test1, ptr1);
}

private static void OnAvatarInstantiated(IntPtr @this, IntPtr avatarPtr, IntPtr avatarDescriptorPtr,
Expand All @@ -84,7 +84,6 @@ private static void OnAvatarInstantiated(IntPtr @this, IntPtr avatarPtr, IntPtr
private delegate void AvatarInstantiatedDelegate(IntPtr @this, IntPtr avatarPtr, IntPtr avatarDescriptorPtr,
bool loaded);

private delegate void OnAvatarSwitchDelegate(IntPtr @this, IntPtr test1, string string1, float float1,
IntPtr ptr1);
private delegate void OnAvatarSwitchDelegate(IntPtr @this, IntPtr test1, IntPtr ptr1);
}
}
2 changes: 1 addition & 1 deletion VRCFaceTracking/MainMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
using VRCFaceTracking.QuickMenu;
using VRCFaceTracking.SRanipal;

[assembly: MelonInfo(typeof(MainMod), "VRCFaceTracking", "2.1.2", "benaclejames",
[assembly: MelonInfo(typeof(MainMod), "VRCFaceTracking", "2.1.5", "benaclejames",
"https://github.com/benaclejames/VRCFaceTracking")]
[assembly: MelonGame("VRChat", "VRChat")]

Expand Down

0 comments on commit 5cb2d3d

Please sign in to comment.