diff --git a/BepInEx.Core/Console/Windows/ConsoleWindow.cs b/BepInEx.Core/Console/Windows/ConsoleWindow.cs index 32c03dd..2be1d9e 100644 --- a/BepInEx.Core/Console/Windows/ConsoleWindow.cs +++ b/BepInEx.Core/Console/Windows/ConsoleWindow.cs @@ -118,12 +118,15 @@ namespace UnityInjector.ConsoleUtil // Some games may ship user32.dll with some methods missing. As such, we load the DLL explicitly from system folder var user32Dll = LoadLibraryEx("user32.dll", IntPtr.Zero, LOAD_LIBRARY_SEARCH_SYSTEM32); - setForeground = user32Dll.GetFunction("SetForegroundWindow").AsDelegate(); - getForeground = user32Dll.GetFunction("GetForegroundWindow").AsDelegate(); - getSystemMenu = user32Dll.GetFunction("GetSystemMenu").AsDelegate(); - deleteMenu = user32Dll.GetFunction("DeleteMenu").AsDelegate(); + setForeground = GetProcAddress(user32Dll, "SetForegroundWindow").AsDelegate(); + getForeground = GetProcAddress(user32Dll, "GetForegroundWindow").AsDelegate(); + getSystemMenu = GetProcAddress(user32Dll, "GetSystemMenu").AsDelegate(); + deleteMenu = GetProcAddress(user32Dll, "DeleteMenu").AsDelegate(); } + [DllImport("kernel32.dll", SetLastError = true)] + static extern IntPtr GetProcAddress(IntPtr hModule, string procName); + [DllImport("kernel32.dll", SetLastError = true)] private static extern bool AllocConsole();