diff --git a/NTwain.Net35/NTwain.Net35.csproj b/NTwain.Net35/NTwain.Net35.csproj index fa555cd..57ebb34 100644 --- a/NTwain.Net35/NTwain.Net35.csproj +++ b/NTwain.Net35/NTwain.Net35.csproj @@ -109,6 +109,9 @@ Internals\IWinMessageFilter.cs + + Internals\LinuxMemoryManager.cs + Internals\TentativeStateCommitable.cs diff --git a/NTwain/Internals/LinuxMemoryManager.cs b/NTwain/Internals/LinuxMemoryManager.cs new file mode 100644 index 0000000..484001d --- /dev/null +++ b/NTwain/Internals/LinuxMemoryManager.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; + +namespace NTwain.Internals +{ + class LinuxMemoryManager : IMemoryManager + { + #region IMemoryManager Members + + public IntPtr Allocate(uint size) + { + return Marshal.AllocHGlobal((int)size); + } + + public void Free(IntPtr handle) + { + Marshal.FreeHGlobal(handle); + } + + public IntPtr Lock(IntPtr handle) + { + return handle; + } + + public void Unlock(IntPtr handle) + { + // no op + } + + #endregion + } +} diff --git a/NTwain/NTwain.csproj b/NTwain/NTwain.csproj index cff6439..653961a 100644 --- a/NTwain/NTwain.csproj +++ b/NTwain/NTwain.csproj @@ -70,6 +70,7 @@ + diff --git a/NTwain/PlatformInfo.cs b/NTwain/PlatformInfo.cs index f04f151..5ab0c36 100644 --- a/NTwain/PlatformInfo.cs +++ b/NTwain/PlatformInfo.cs @@ -34,6 +34,8 @@ namespace NTwain if (IsWindows) { + _defaultMemManager = new WinMemoryManager(); + var newDsmPath = Path.Combine(Environment.SystemDirectory, Dsm.WIN_NEW_DSM_NAME); #if NET35 var oldDsmPath = Path.Combine(Environment.GetEnvironmentVariable("windir"), Dsm.WIN_OLD_DSM_NAME); @@ -63,6 +65,8 @@ namespace NTwain } else if (IsLinux) { + _defaultMemManager = new LinuxMemoryManager(); + ExpectedDsmPath = Dsm.LINUX_DSM_PATH; DsmExists = File.Exists(ExpectedDsmPath); IsSupported = DsmExists && IsOnMono; @@ -71,8 +75,6 @@ namespace NTwain { // mac? not gonna happen } - - _defaultMemManager = new WinMemoryManager(); } ///