N64: Output an error code when LoadLibrary fails

This commit is contained in:
pjgat09 2014-10-13 23:20:18 +00:00
parent e60c73eaef
commit 502caa2e37
1 changed files with 4 additions and 1 deletions

View File

@ -19,6 +19,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi
AutoResetEvent m64pFrameComplete = new AutoResetEvent(false);
ManualResetEvent m64pStartupComplete = new ManualResetEvent(false);
[DllImport("kernel32.dll")]
public static extern UInt32 GetLastError();
[DllImport("kernel32.dll")]
public static extern IntPtr LoadLibrary(string dllToLoad);
@ -698,7 +701,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi
AttachedPlugin plugin;
plugin.dllHandle = LoadLibrary(PluginName);
if (plugin.dllHandle == IntPtr.Zero)
throw new InvalidOperationException(string.Format("Failed to load plugin {0}", PluginName));
throw new InvalidOperationException(string.Format("Failed to load plugin {0}, error code: 0x{1:X}", PluginName, GetLastError()));
plugin.dllStartup = (PluginStartup)Marshal.GetDelegateForFunctionPointer(GetProcAddress(plugin.dllHandle, "PluginStartup"), typeof(PluginStartup));
plugin.dllShutdown = (PluginShutdown)Marshal.GetDelegateForFunctionPointer(GetProcAddress(plugin.dllHandle, "PluginShutdown"), typeof(PluginShutdown));