private static IntPtr GetAddress(string name) { EnsureModule(); var address = NativeLoader.GetProcAddress(name, module); if (address.Equals(IntPtr.Zero)) { throw new InvalidOperationException($"Failed to import \"{name}\""); } return(address); }
private static void EnsureModule() { if (!module.Equals(IntPtr.Zero)) { return; } module = NativeLoader.Load(LIBRARY); if (module == IntPtr.Zero) { throw new DllNotFoundException($"Cannot find \"{LIBRARY}\""); } }