コード例 #1
0
        public unsafe override void OnApplicationStart()
        {
            Config.LoadConfig();

            IL2CPP_Class API2    = NET_SDK.SDK.GetClass("VRC.Core", "API");
            IL2CPP_Class Amp     = NET_SDK.SDK.GetClass("AmplitudeSDKWrapper", "AmplitudeWrapper");
            IL2CPP_Class WS      = NET_SDK.SDK.GetClass("Transmtn", "WebsocketPipeline"); //Thanks Zoey#9420 for pointing out Websockets
            var          oldhwid = VRC.Core.API.DeviceID;

            H.Patch(API2.GetProperty("DeviceID").GetGetMethod(), AccessTools.Method(typeof(Main), "DeviceID"));
            H.Patch(Amp.GetMethod("InitializeDeviceId"), AccessTools.Method(typeof(Main), "DeviceID1"));
            H.Patch(Amp.GetMethods(x => x.Name == "LogEvent" && x.GetParameterCount() == 4 && NET_SDK.IL2CPP.il2cpp_type_get_name(x.GetParameters()[2].Ptr).Equals("System.Int64")).First(), AccessTools.Method(typeof(Main), "LogEvent"));
            var original = *(IntPtr *)WS.GetMethod("ProcessPipe").Ptr;

            HookMethod((IntPtr)(&original), Marshal.GetFunctionPointerForDelegate(new Action <IntPtr, IntPtr>(ProcessPipeFix)));
            ProcessCall = Marshal.GetDelegateForFunctionPointer <ProcessFix>(original);

            if (Config.CFG.ConsolePrint)
            {
                HVHLogger.Log("Old HWID:");
                HVHLogger.Log(oldhwid);
                HVHLogger.Log("New HWID:");
                HVHLogger.Log(VRC.Core.API.DeviceID);
            }
        }