From 5833f30cde3c889080fc7fa886c840538e52b786 Mon Sep 17 00:00:00 2001 From: Jade Macho Date: Wed, 23 Mar 2022 23:19:15 +0100 Subject: [PATCH] NativeDetourTest on macOS shall not undo its failed detour either --- MonoMod.UnitTest/RuntimeDetour/NativeDetourTest.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/MonoMod.UnitTest/RuntimeDetour/NativeDetourTest.cs b/MonoMod.UnitTest/RuntimeDetour/NativeDetourTest.cs index c59485cf..e57aae9f 100644 --- a/MonoMod.UnitTest/RuntimeDetour/NativeDetourTest.cs +++ b/MonoMod.UnitTest/RuntimeDetour/NativeDetourTest.cs @@ -136,11 +136,15 @@ public class NativeDetourTest { d.Apply(); } catch (Win32Exception) { // Modern macOS doesn't give us permission to mess with this anymore. - d.Dispose(); + try { + d.Dispose(); + } catch (Win32Exception) { + // Of course it might also throw while trying to undo any made changes. + } } } - if (d.IsValid) { + if (d.IsApplied) { DidNothing = true; Assert.Equal(-1, libc_rand()); Assert.False(DidNothing);