Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
Interop.cs
Go to the documentation of this file.
1using System;
2using System.IO;
6
7internal static class Interop
8{
9 internal enum BOOL
10 {
11 FALSE,
12 TRUE
13 }
14
15 internal static class Kernel32
16 {
17 internal struct SECURITY_ATTRIBUTES
18 {
19 internal uint nLength;
20
22
23 internal BOOL bInheritHandle;
24 }
25
26 [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
27 internal readonly struct FILE_NOTIFY_INFORMATION
28 {
29 internal readonly uint NextEntryOffset;
30
31 internal readonly FileAction Action;
32
33 internal readonly uint FileNameLength;
34 }
35
44
45 [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
46 internal unsafe static extern bool ReadDirectoryChangesW(SafeFileHandle hDirectory, byte[] lpBuffer, uint nBufferLength, bool bWatchSubtree, uint dwNotifyFilter, uint* lpBytesReturned, NativeOverlapped* lpOverlapped, void* lpCompletionRoutine);
47
48 [DllImport("kernel32.dll", BestFitMapping = false, CharSet = CharSet.Unicode, EntryPoint = "CreateFileW", ExactSpelling = true, SetLastError = true)]
49 private unsafe static extern SafeFileHandle CreateFilePrivate(string lpFileName, int dwDesiredAccess, FileShare dwShareMode, SECURITY_ATTRIBUTES* lpSecurityAttributes, FileMode dwCreationDisposition, int dwFlagsAndAttributes, IntPtr hTemplateFile);
50
51 internal unsafe static SafeFileHandle CreateFile(string lpFileName, int dwDesiredAccess, FileShare dwShareMode, FileMode dwCreationDisposition, int dwFlagsAndAttributes)
52 {
53 lpFileName = System.IO.PathInternal.EnsureExtendedPrefixIfNeeded(lpFileName);
54 return CreateFilePrivate(lpFileName, dwDesiredAccess, dwShareMode, null, dwCreationDisposition, dwFlagsAndAttributes, IntPtr.Zero);
55 }
56 }
57}
static void SetLastError(int errorCode)
static unsafe SafeFileHandle CreateFile(string lpFileName, int dwDesiredAccess, FileShare dwShareMode, FileMode dwCreationDisposition, int dwFlagsAndAttributes)
Definition Interop.cs:51
static unsafe SafeFileHandle CreateFilePrivate(string lpFileName, int dwDesiredAccess, FileShare dwShareMode, SECURITY_ATTRIBUTES *lpSecurityAttributes, FileMode dwCreationDisposition, int dwFlagsAndAttributes, IntPtr hTemplateFile)
static unsafe bool ReadDirectoryChangesW(SafeFileHandle hDirectory, byte[] lpBuffer, uint nBufferLength, bool bWatchSubtree, uint dwNotifyFilter, uint *lpBytesReturned, NativeOverlapped *lpOverlapped, void *lpCompletionRoutine)
static string EnsureExtendedPrefixIfNeeded(string path)
static readonly IntPtr Zero
Definition IntPtr.cs:18