using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Runtime.InteropServices; namespace Tango.Video.DirectShow { internal static class Win32Interop { /// /// Creates or opens a named or unnamed file mapping object for a specified file. /// /// A handle to the file from which to create a file mapping object. /// A pointer to a SECURITY_ATTRIBUTES structure that determines whether a returned handle can be inherited by child processes. The lpSecurityDescriptor member of the SECURITY_ATTRIBUTES structure specifies a security descriptor for a new file mapping object. /// Specifies the page protection of the file mapping object. All mapped views of the object must be compatible with this protection. /// The high-order DWORD of the maximum size of the file mapping object. /// The low-order DWORD of the maximum size of the file mapping object. /// The name of the file mapping object. /// The value is a handle to the newly created file mapping object. [DllImport("kernel32", SetLastError = true)] internal static extern IntPtr CreateFileMapping(IntPtr hFile, IntPtr lpAttributes, PageAccess flProtect, int dwMaximumSizeLow, int dwMaximumSizeHigh, string lpName); /// /// Maps a view of a file mapping into the address space of a calling process. /// /// A handle to a file mapping object. The CreateFileMapping and OpenFileMapping functions return this handle. /// The type of access to a file mapping object, which determines the protection of the pages. This parameter can be one of the following values. /// A high-order DWORD of the file offset where the view begins. /// A low-order DWORD of the file offset where the view is to begin. The combination of the high and low offsets must specify an offset within the file mapping. /// The number of bytes of a file mapping to map to the view. All bytes must be within the maximum size specified by CreateFileMapping. If this parameter is 0 (zero), the mapping extends from the specified offset to the end of the file mapping. /// The value is the starting address of the mapped view. [DllImport("kernel32.dll", SetLastError = true)] internal static extern IntPtr MapViewOfFile(IntPtr hFileMappingObject, FileMapAccess dwDesiredAccess, uint dwFileOffsetHigh, uint dwFileOffsetLow, uint dwNumberOfBytesToMap); /// /// Unmaps a mapped view of a file from the calling process's address space. /// /// A pointer to the base address of the mapped view of a file that is to be unmapped. This value must be identical to the value returned by a previous call to the MapViewOfFile or MapViewOfFileEx function. /// If the function succeeds, the return value is nonzero. [DllImport("kernel32", SetLastError = true)] internal static extern bool UnmapViewOfFile(IntPtr lpBaseAddress); /// /// Closes an open object handle. /// /// A valid handle to an open object. /// If the function succeeds, the return value is nonzero. [DllImport("kernel32", SetLastError = true)] internal static extern bool CloseHandle(IntPtr handle); } }