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); }
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); }
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); }
public void Free(IntPtr hModule) => WindowsLoader.FreeLibrary(hModule);