internal static void PrintQDTOTrampoline(QuickDebugTestObject qdto) => Console.WriteLine("SHOULD BE DETOURED");
internal static bool TestRuntimeDetourHelper() { MethodInfo m_PrintA = typeof(ModRuntimePatcher).GetMethod("PrintA", BindingFlags.NonPublic | BindingFlags.Static); MethodInfo m_PrintB = typeof(ModRuntimePatcher).GetMethod("PrintB", BindingFlags.NonPublic | BindingFlags.Static); MethodInfo m_PrintC = typeof(ModRuntimePatcher).GetMethod("PrintC", BindingFlags.NonPublic | BindingFlags.Static); MethodInfo m_PrintATrampoline = typeof(ModRuntimePatcher).GetMethod("PrintATrampoline", BindingFlags.NonPublic | BindingFlags.Static); PrintA(); // A d_PrintA t_FromB = m_PrintA.Detour <d_PrintA>(m_PrintB); PrintA(); // B t_FromB(); // A unsafe { m_PrintATrampoline.Detour( RuntimeDetour.CreateTrampoline(m_PrintA) ); PrintATrampoline(); // A } d_PrintA t_FromC = m_PrintA.Detour <d_PrintA>((Action)PrintC); PrintA(); // C t_FromC(); // B m_PrintA.GetOrigTrampoline <d_PrintA>()(); // A m_PrintB.Detour(m_PrintC); PrintB(); // C m_PrintB.Detour((Action)PrintD); PrintB(); // D m_PrintA.Undetour(); m_PrintA.Undetour(); PrintA(); // A MethodInfo m_PrintQDTO = typeof(QuickDebugTestObject).GetMethod("PrintQDTO", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); MethodInfo m_PrintQDTODetour = typeof(ModRuntimePatcher).GetMethod("PrintQDTODetour", BindingFlags.NonPublic | BindingFlags.Static); MethodInfo m_PrintQDTOTrampoline = typeof(ModRuntimePatcher).GetMethod("PrintQDTOTrampoline", BindingFlags.NonPublic | BindingFlags.Static); QuickDebugTestObject qdto = new QuickDebugTestObject(); qdto.PrintQDTO(); // QDTO d_PrintQDTO t_FromQDTO = m_PrintQDTO.Detour <d_PrintQDTO>(m_PrintQDTODetour); qdto.PrintQDTO(); // QDTO Detour t_FromQDTO(qdto); // QDTO unsafe { m_PrintQDTOTrampoline.Detour( RuntimeDetour.CreateTrampoline(m_PrintQDTO) ); PrintQDTOTrampoline(qdto); // QDTO } return(true); }
internal static void PrintQDTODetour(QuickDebugTestObject qdto) => Console.WriteLine("QDTO Detoured");