We need you! We're working hard on the next version of Developer Fusion -
Let us know what you think we should be up to!
- namespace Microsoft.Win32
- {
- using System.Runtime.InteropServices;
- using System;
- using System.Diagnostics.CodeAnalysis;
- using System.Security.Permissions;
- using System.Collections;
- using System.IO;
- using System.Text;
- using System.Threading;
- using Microsoft.Win32.SafeHandles;
- using System.Runtime.ConstrainedExecution;
- using System.Runtime.Versioning;
- using System.Diagnostics;
-
- [HostProtection(MayLeakOnAbort = true)]
- [System.Security.SuppressUnmanagedCodeSecurity()]
- static internal class SafeNativeMethods
- {
-
- public const int FORMAT_MESSAGE_ALLOCATE_BUFFER = 256, FORMAT_MESSAGE_IGNORE_INSERTS = 512, FORMAT_MESSAGE_FROM_STRING = 1024, FORMAT_MESSAGE_FROM_SYSTEM = 4096, FORMAT_MESSAGE_ARGUMENT_ARRAY = 8192;
-
- public const int MB_RIGHT = 524288, MB_RTLREADING = 1048576;
-
- [DllImport(ExternDll.Kernel32, CharSet = System.Runtime.InteropServices.CharSet.Auto, SetLastError = true, BestFitMapping = true)]
- [SuppressMessage("Microsoft.Security", "CA2101:SpecifyMarshalingForPInvokeStringArguments")]
- [ResourceExposure(ResourceScope.None)]
- unsafe public static extern int FormatMessage(int dwFlags, SafeHandle lpSource, uint dwMessageId, int dwLanguageId, StringBuilder lpBuffer, int nSize, IntPtr[] arguments);
- [DllImport(ExternDll.Kernel32, CharSet = System.Runtime.InteropServices.CharSet.Auto, SetLastError = true, BestFitMapping = true)]
- [ResourceExposure(ResourceScope.None)]
- public static extern int FormatMessage(int dwFlags, HandleRef lpSource, int dwMessageId, int dwLanguageId, StringBuilder lpBuffer, int nSize, IntPtr arguments);
-
- [DllImport(ExternDll.Kernel32, CharSet = System.Runtime.InteropServices.CharSet.Auto, BestFitMapping = true)]
- [ResourceExposure(ResourceScope.None)]
- public static extern void OutputDebugString(string message);
-
- [DllImport(ExternDll.User32, CharSet = System.Runtime.InteropServices.CharSet.Auto, BestFitMapping = true)]
- public static extern int MessageBox(HandleRef hWnd, string text, string caption, int type);
-
- [DllImport(ExternDll.Kernel32, ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Auto, SetLastError = true)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
- public static extern bool CloseHandle(IntPtr handle);
-
- [DllImport(ExternDll.Kernel32, ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Auto, SetLastError = true)]
- public static extern bool CloseHandle(HandleRef handle);
-
- [DllImport(ExternDll.Kernel32)]
- [ResourceExposure(ResourceScope.None)]
- public static extern bool QueryPerformanceCounter(out long value);
-
- [DllImport(ExternDll.Kernel32)]
- [ResourceExposure(ResourceScope.None)]
- public static extern bool QueryPerformanceFrequency(out long value);
-
-
- [DllImport(ExternDll.Kernel32, SetLastError = true, CharSet = CharSet.Auto, BestFitMapping = false)]
- [ResourceExposure(ResourceScope.Machine)]
- static internal extern SafeWaitHandle CreateSemaphore(NativeMethods.SECURITY_ATTRIBUTES lpSecurityAttributes, int initialCount, int maximumCount, string name);
-
- [DllImport(ExternDll.Kernel32, SetLastError = true, CharSet = CharSet.Auto, BestFitMapping = false)]
- [ResourceExposure(ResourceScope.Machine)]
- static internal extern SafeWaitHandle OpenSemaphore(int desiredAccess, bool inheritHandle, string name);
-
- [DllImport(ExternDll.Kernel32, SetLastError = true)]
- [ResourceExposure(ResourceScope.Machine)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
- static internal extern bool ReleaseSemaphore(SafeWaitHandle handle, int releaseCount, out int previousCount);
-
- [StructLayout(LayoutKind.Sequential)]
- internal class PROCESS_INFORMATION
- {
-
-
- public IntPtr hProcess = IntPtr.Zero;
- public IntPtr hThread = IntPtr.Zero;
- public int dwProcessId = 0;
- public int dwThreadId = 0;
-
-
-
-
- }
-
-
-
- }
- }