-
Notifications
You must be signed in to change notification settings - Fork 1
/
CriticalProcess.vb
25 lines (23 loc) · 1.21 KB
/
CriticalProcess.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
Public Class CriticalProcess
<Runtime.InteropServices.DllImport("NTdll.dll", EntryPoint:="RtlSetProcessIsCritical", SetLastError:=True)>
Public Shared Sub SetCurrentProcessIsCritical(
<Runtime.InteropServices.MarshalAs(Runtime.InteropServices.UnmanagedType.Bool)> ByVal isCritical As Boolean,
<Runtime.InteropServices.MarshalAs(Runtime.InteropServices.UnmanagedType.Bool)> ByRef refWasCritical As Boolean,
<Runtime.InteropServices.MarshalAs(Runtime.InteropServices.UnmanagedType.Bool)> ByVal needSystemCriticalBreaks As Boolean)
End Sub
Public Shared Sub CriticalProcess_Enable()
Try
Dim refWasCritical As Boolean
System.Diagnostics.Process.EnterDebugMode()
SetCurrentProcessIsCritical(True, refWasCritical, False)
Catch ex As Exception
End Try
End Sub
Public Shared Sub CriticalProcesses_Disable()
Try
Dim refWasCritical As Boolean
SetCurrentProcessIsCritical(False, refWasCritical, False)
Catch ex As Exception
End Try
End Sub
End Class