BizHawk/BizHawk.Client.Common/7z/NativeMethods.cs

67 lines
2.0 KiB
C#
Raw Normal View History

2013-10-25 00:59:34 +00:00
/* This file is part of SevenZipSharp.
SevenZipSharp is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
SevenZipSharp is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with SevenZipSharp. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Runtime.InteropServices;
#if MONO
using SevenZip.Mono.COM;
#endif
namespace SevenZip
{
#if UNMANAGED
internal static class NativeMethods
{
#if !WINCE && !MONO
#region Delegates
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate int CreateObjectDelegate(
[In] ref Guid classID,
[In] ref Guid interfaceID,
[MarshalAs(UnmanagedType.Interface)] out object outObject);
#endregion
#endif
Add preliminary Unix compatibility (using Mono; resolves #1384) (#1380) * Move PlatformSpecificLinkedLibs and implementations to common and rename * Specify file ext. at LoadPlatformSpecific call site * Move Client.Common.Global.RunningOnUnix to PlatformLinkedLibSingleton * Inline var Resolver * Use PlatformLinkedLibManager internally * Move plugin load check to LinkedLibManager, use LinkedLibManager * Interpolate * Return exit code from dlclose/FreeLibrary * Skip all calls to externs in BlipBufDll when using mono * Use PlatformLinkedLibManager in SevenZipLibraryManager * Add expected return value to workaround (from testing on Win32) * Remove ".dll" from DllImport attr, remove temporary workaround, see desc. The library can be built by changing the output file name in `.../blip_buf/Makefile` to `libblip_buf.so`, and running `make`. It will be loaded if placed in the `.../output` folder. * Remove unused code, add TODO (this class is req. for Waterbox.PeWrapper) The TODO is to [rewrite with C#](https://docs.microsoft.com/en-us/dotnet/standard/io/memory-mapped-files) instead of importing from `kernel32.dll`. * Update OpenTK again but better (for #1384) * Add Mono run script * Add libblip_buf.so (temporary) Temporary because it should be a separate package which BizHawk depends on. * Add distro detection, add "already running" and "unknown distro" messages * Gray-out Lua Console on Unix * Extract superclass from EmuLuaLibrary, add shell implementation for Unix * Specify libdl version, Fedora doesn't have the versionless symlink * Remove empty `ToolStripMenuItem`, null `Text` caused crash on Unix * Transform OpenTK keyboard input into a `List<KeyEvent>` and read that Also fixes crash on rebind * Remove debug `using ...;`
2019-01-03 22:50:55 +00:00
2013-10-25 00:59:34 +00:00
#if WINCE
[DllImport("7z.dll", EntryPoint="CreateObject")]
public static extern int CreateCOMObject(
[In] ref Guid classID,
[In] ref Guid interfaceID,
[MarshalAs(UnmanagedType.Interface)] out object outObject);
#endif
public static T SafeCast<T>(PropVariant var, T def)
{
object obj;
try
{
obj = var.Object;
}
catch (Exception)
{
return def;
}
if (obj != null && obj is T)
{
return (T) obj;
}
return def;
}
}
#endif
}