public IntPtr AttachPlugin(m64p_plugin_type type, string PluginName) { if (plugins.ContainsKey(type)) { DetachPlugin(type); } AttachedPlugin plugin; plugin.dllHandle = LoadLibrary(PluginName); if (plugin.dllHandle == IntPtr.Zero) { throw new InvalidOperationException(string.Format("Failed to load plugin {0}, error code: 0x{1:X}", PluginName, GetLastError())); } plugin.dllStartup = (PluginStartup)Marshal.GetDelegateForFunctionPointer(GetProcAddress(plugin.dllHandle, "PluginStartup"), typeof(PluginStartup)); plugin.dllShutdown = (PluginShutdown)Marshal.GetDelegateForFunctionPointer(GetProcAddress(plugin.dllHandle, "PluginShutdown"), typeof(PluginShutdown)); plugin.dllStartup(CoreDll, null, null); m64p_error result = m64pCoreAttachPlugin(type, plugin.dllHandle); if (result != m64p_error.M64ERR_SUCCESS) { FreeLibrary(plugin.dllHandle); throw new InvalidOperationException(string.Format("Error during attaching plugin {0}", PluginName)); } plugins.Add(type, plugin); return(plugin.dllHandle); }
public IntPtr AttachPlugin(m64p_plugin_type type, string PluginName) { if (plugins.ContainsKey(type)) { DetachPlugin(type); } AttachedPlugin plugin; plugin.dllHandle = libLoader.LoadPlatformSpecific(PluginName); plugin.dllStartup = (PluginStartup)Marshal.GetDelegateForFunctionPointer(libLoader.GetProcAddr(plugin.dllHandle, "PluginStartup"), typeof(PluginStartup)); plugin.dllShutdown = (PluginShutdown)Marshal.GetDelegateForFunctionPointer(libLoader.GetProcAddr(plugin.dllHandle, "PluginShutdown"), typeof(PluginShutdown)); plugin.dllStartup(CoreDll, null, null); m64p_error result = m64pCoreAttachPlugin(type, plugin.dllHandle); if (result != m64p_error.M64ERR_SUCCESS) { libLoader.FreePlatformSpecific(plugin.dllHandle); throw new InvalidOperationException(string.Format("Error during attaching plugin {0}", PluginName)); } plugins.Add(type, plugin); return(plugin.dllHandle); }
public void DetachPlugin(m64p_plugin_type type) { AttachedPlugin plugin; if (plugins.TryGetValue(type, out plugin)) { plugins.Remove(type); m64pCoreDetachPlugin(type); plugin.dllShutdown(); FreeLibrary(plugin.dllHandle); } }
public void DetachPlugin(m64p_plugin_type type) { AttachedPlugin plugin; if (plugins.TryGetValue(type, out plugin)) { plugins.Remove(type); m64pCoreDetachPlugin(type); plugin.dllShutdown(); libLoader.FreePlatformSpecific(plugin.dllHandle); } }
public IntPtr AttachPlugin(m64p_plugin_type type, string PluginName) { if (plugins.ContainsKey(type)) DetachPlugin(type); AttachedPlugin plugin; plugin.dllHandle = LoadLibrary(PluginName); if (plugin.dllHandle == IntPtr.Zero) throw new InvalidOperationException(string.Format("Failed to load plugin {0}, error code: 0x{1:X}", PluginName, GetLastError())); plugin.dllStartup = (PluginStartup)Marshal.GetDelegateForFunctionPointer(GetProcAddress(plugin.dllHandle, "PluginStartup"), typeof(PluginStartup)); plugin.dllShutdown = (PluginShutdown)Marshal.GetDelegateForFunctionPointer(GetProcAddress(plugin.dllHandle, "PluginShutdown"), typeof(PluginShutdown)); plugin.dllStartup(CoreDll, null, null); m64p_error result = m64pCoreAttachPlugin(type, plugin.dllHandle); if (result != m64p_error.M64ERR_SUCCESS) { FreeLibrary(plugin.dllHandle); throw new InvalidOperationException(string.Format("Error during attaching plugin {0}", PluginName)); } plugins.Add(type, plugin); return plugin.dllHandle; }