コード例 #1
0
        public IntPtr Load(string dllToLoad)
        {
            var res = WindowsLoader.LoadLibrary(dllToLoad);

            if (res == IntPtr.Zero)
            {
                throw new DllNotFoundException($"Could not load {dllToLoad}", new Win32Exception());
            }
            return(res);
        }
コード例 #2
0
        public IntPtr GetFunction(IntPtr hModule, string procedureName)
        {
            var res = WindowsLoader.GetProcAddress(hModule, procedureName);

            if (res == IntPtr.Zero)
            {
                throw new MissingMethodException($"Failed to load symbol {procedureName}", new Win32Exception());
            }
            return(res);
        }
コード例 #3
0
        public IntPtr GetFunction(IntPtr hModule, string procedureName)
        {
            if (hModule == IntPtr.Zero)
            {
                foreach (var module in GetAllModules())
                {
                    var func = GetProcAddress(module, procedureName);
                    if (func != IntPtr.Zero)
                    {
                        return(func);
                    }
                }
            }

            var res = WindowsLoader.GetProcAddress(hModule, procedureName);

            if (res == IntPtr.Zero)
            {
                throw new MissingMethodException($"Failed to load symbol {procedureName}", new Win32Exception());
            }
            return(res);
        }
コード例 #4
0
 public void Free(IntPtr hModule) => WindowsLoader.FreeLibrary(hModule);