Exemple #1
0
        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);
        }
Exemple #2
0
 private static void EnsureModule()
 {
     if (!module.Equals(IntPtr.Zero))
     {
         return;
     }
     module = NativeLoader.Load(LIBRARY);
     if (module == IntPtr.Zero)
     {
         throw new DllNotFoundException($"Cannot find \"{LIBRARY}\"");
     }
 }