private static SafeCloseHandle OpenProcessForQuery(int pid) { SafeCloseHandle handle = ListenerUnsafeNativeMethods.OpenProcess(0x400, false, pid); if (handle.IsInvalid) { Exception exception = new Win32Exception(); handle.SetHandleAsInvalid(); throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(exception); } return(handle); }
static SafeCloseHandle OpenProcessForQuery(int pid) { #pragma warning suppress 56523 // Microsoft, Win32Exception ctor calls Marshal.GetLastWin32Error() SafeCloseHandle process = ListenerUnsafeNativeMethods.OpenProcess(ListenerUnsafeNativeMethods.PROCESS_QUERY_INFORMATION, false, pid); if (process.IsInvalid) { Exception exception = new Win32Exception(); process.SetHandleAsInvalid(); throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(exception); } return(process); }
private static SafeCloseHandle OpenCurrentProcessForWrite() { int id = Process.GetCurrentProcess().Id; SafeCloseHandle handle = ListenerUnsafeNativeMethods.OpenProcess(0x60400, false, id); if (handle.IsInvalid) { Exception exception = new Win32Exception(); handle.SetHandleAsInvalid(); throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(exception); } return(handle); }
static SafeCloseHandle OpenCurrentProcessForWrite() { int processId = Process.GetCurrentProcess().Id; #pragma warning suppress 56523 // Microsoft, Win32Exception ctor calls Marshal.GetLastWin32Error() SafeCloseHandle process = ListenerUnsafeNativeMethods.OpenProcess(ListenerUnsafeNativeMethods.PROCESS_QUERY_INFORMATION | ListenerUnsafeNativeMethods.WRITE_DAC | ListenerUnsafeNativeMethods.READ_CONTROL, false, processId); if (process.IsInvalid) { Exception exception = new Win32Exception(); process.SetHandleAsInvalid(); throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(exception); } return(process); }