예제 #1
0
 public static void PatchType(string strde)
 {
     foreach (var str in PatchUtils.GetSplitString(strde))
     {
         PatchUtils.PatchType(str, pre, post);
     }
 }
예제 #2
0
        public static void ProfilePatch()
        {
            var go   = new HarmonyMethod(typeof(H_JobAI), nameof(Prefix));
            var biff = new HarmonyMethod(typeof(H_JobAI), nameof(Postfix));

            PatchUtils.PatchType("Pawn_JobTracker", go, biff, false);
        }
        public static void UnPatchMethods(bool forceThrough = false)
        {
            Thread.CurrentThread.IsBackground = true;

            if (!forceThrough)
            {
                // this can occur if we 'force' unpatch
                if (AnalyzerState.State == CurrentState.Uninitialised)
                {
                    return;
                }

                AnalyzerState.State = CurrentState.UnpatchingQueued;

                for (int i = 0; i < NumSecondsForPatchClear; i++)
                {
                    // This should result in no overlap
                    // If there are issues regarding spamming open and close, you can lower thread
                    // sleep by x% and multiply NumSecondsForPatchClear to balance
                    // I.e. Thread.Sleep(500), i < NumSecondsForPatchClear * 2;
                    Thread.Sleep(1000);
                    if (AnalyzerState.State != CurrentState.UnpatchingQueued)
                    {
                        return;
                    }
                }
            }

            AnalyzerState.State = CurrentState.Unpatching;

            Log.Message("Beginning to unpatch methods");

            ClearState();
            harmony.UnpatchAll(harmony.Id);

            PatchUtils.UnpatchAllInternalMethods();

            AnalyzerState.State = CurrentState.Uninitialised;

            if (forceThrough) // if not, this has already been done for us by the PostClose();
            {
                AnalyzerState.CurrentlyRunning = false;
                Settings.Write();
            }

            GC.Collect();
            GC.WaitForPendingFinalizers();

            Messages.Message("Analyzer: Successfully finished unpatching methods", MessageTypeDefOf.NeutralEvent);
        }
예제 #4
0
            public static void ExecuteUnPatch()
            {
                switch (unPatchType)
                {
                case UnPatchType.Method: PatchUtils.UnpatchMethod(currentUnPatch); break;

                case UnPatchType.MethodsOnMethod: PatchUtils.UnpatchMethod(currentUnPatch); break;

                case UnPatchType.Type: PatchUtils.UnPatchTypePatches(currentUnPatch); break;

                case UnPatchType.InternalMethod: PatchUtils.UnpatchInternalMethod(currentUnPatch); break;

                case UnPatchType.All: Analyzer.UnPatchMethods(true); break;
                }
            }
예제 #5
0
            public static void ExecutePatch()
            {
                switch (input)
                {
                case CurrentInput.Method:
                    if (patchType == UpdateMode.Tick)
                    {
                        CustomProfilersTick.PatchMeth(currentInput);
                        AnalyzerState.SwapTab("Custom Tick", UpdateMode.Tick);
                    }
                    else
                    {
                        CustomProfilersUpdate.PatchMeth(currentInput);
                        AnalyzerState.SwapTab("Custom Update", UpdateMode.Update);
                    }
                    return;

                case CurrentInput.Type:
                    CustomProfilersUpdate.PatchType(currentInput);
                    AnalyzerState.SwapTab("Custom Update", UpdateMode.Update);
                    return;

                case CurrentInput.MethodHarmony:
                    CustomProfilersHarmony.PatchMeth(currentInput);
                    AnalyzerState.SwapTab("Custom Harmony", UpdateMode.Update);
                    return;

                case CurrentInput.TypeHarmony:
                    CustomProfilersHarmony.PatchType(currentInput);
                    AnalyzerState.SwapTab("Custom Harmony", UpdateMode.Update);
                    return;

                case CurrentInput.InternalMethod:
                    PatchUtils.PatchInternalMethod(currentInput);
                    return;

                case CurrentInput.Assembly:
                    PatchUtils.PatchAssembly(currentInput, false);
                    return;
                }
            }