2016-02-18 01:17:49 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
2016-03-11 03:00:52 +00:00
|
|
|
|
namespace BizHawk.Common
|
2016-02-18 01:17:49 +00:00
|
|
|
|
{
|
2016-03-23 00:17:28 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// interface for a dynamic link library or similar
|
|
|
|
|
/// </summary>
|
2016-02-18 01:17:49 +00:00
|
|
|
|
public interface IImportResolver
|
|
|
|
|
{
|
|
|
|
|
IntPtr Resolve(string entryPoint);
|
|
|
|
|
}
|
2016-02-20 16:30:05 +00:00
|
|
|
|
|
|
|
|
|
public static class ImportResolverExtensions
|
|
|
|
|
{
|
|
|
|
|
public static IntPtr SafeResolve(this IImportResolver dll, string entryPoint)
|
|
|
|
|
{
|
|
|
|
|
var ret = dll.Resolve(entryPoint);
|
|
|
|
|
if (ret == IntPtr.Zero)
|
2017-04-13 18:57:58 +00:00
|
|
|
|
{
|
|
|
|
|
throw new NullReferenceException($"Couldn't resolve entry point \"{entryPoint}\"");
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-20 16:30:05 +00:00
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-02-18 01:17:49 +00:00
|
|
|
|
}
|