add way to obtain error message in ILinkedLibManager, use it to display an error code for init lib checks
This commit is contained in:
parent
463780a875
commit
06226e78cf
|
@ -38,7 +38,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
var p = OSTC.LinkedLibManager.LoadOrZero(dllToLoad);
|
var p = OSTC.LinkedLibManager.LoadOrZero(dllToLoad);
|
||||||
if (p == IntPtr.Zero)
|
if (p == IntPtr.Zero)
|
||||||
{
|
{
|
||||||
using (var box = new ExceptionBox($"EmuHawk needs {desc} in order to run! See the readme on GitHub for more info. (EmuHawk will now close.)")) box.ShowDialog();
|
using (var box = new ExceptionBox($"EmuHawk needs {desc} in order to run! See the readme on GitHub for more info. (EmuHawk will now close.) Internal error message: {OSTC.LinkedLibManager.GetErrorMessage()}")) box.ShowDialog();
|
||||||
Process.GetCurrentProcess().Kill();
|
Process.GetCurrentProcess().Kill();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,6 +91,8 @@ namespace BizHawk.Common
|
||||||
|
|
||||||
/// <exception cref="InvalidOperationException">could not find library</exception>
|
/// <exception cref="InvalidOperationException">could not find library</exception>
|
||||||
IntPtr LoadOrThrow(string dllToLoad);
|
IntPtr LoadOrThrow(string dllToLoad);
|
||||||
|
|
||||||
|
string GetErrorMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class UnixMonoLLManager : ILinkedLibManager
|
private class UnixMonoLLManager : ILinkedLibManager
|
||||||
|
@ -128,6 +130,12 @@ namespace BizHawk.Common
|
||||||
return ret != IntPtr.Zero ? ret : throw new InvalidOperationException($"got null pointer from {nameof(dlopen)}, error: {Marshal.PtrToStringAnsi(dlerror())}");
|
return ret != IntPtr.Zero ? ret : throw new InvalidOperationException($"got null pointer from {nameof(dlopen)}, error: {Marshal.PtrToStringAnsi(dlerror())}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string GetErrorMessage()
|
||||||
|
{
|
||||||
|
var errCharPtr = dlerror();
|
||||||
|
return errCharPtr == IntPtr.Zero ? "No error present" : Marshal.PtrToStringAnsi(errCharPtr);
|
||||||
|
}
|
||||||
|
|
||||||
private const int RTLD_NOW = 2;
|
private const int RTLD_NOW = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,7 +171,9 @@ namespace BizHawk.Common
|
||||||
{
|
{
|
||||||
var ret = LoadOrZero(dllToLoad);
|
var ret = LoadOrZero(dllToLoad);
|
||||||
return ret != IntPtr.Zero ? ret : throw new InvalidOperationException($"got null pointer from {nameof(LoadLibrary)}, error code: {GetLastError()}");
|
return ret != IntPtr.Zero ? ret : throw new InvalidOperationException($"got null pointer from {nameof(LoadLibrary)}, error code: {GetLastError()}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string GetErrorMessage() => $"Error Code 0x{GetLastError():X8}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum DistinctOS : byte
|
public enum DistinctOS : byte
|
||||||
|
|
Loading…
Reference in New Issue