Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ SetPrivilege()

static unsafe void System.Diagnostics.Process.SetPrivilege ( string privilegeName,
int attrib )
inlinestaticprivate

Definition at line 1943 of file Process.cs.

1944 {
1946 try
1947 {
1948 if (!global::Interop.Advapi32.OpenProcessToken(global::Interop.Kernel32.GetCurrentProcess(), 32, out TokenHandle))
1949 {
1950 throw new Win32Exception();
1951 }
1952 if (!global::Interop.Advapi32.LookupPrivilegeValue(null, privilegeName, out var lpLuid))
1953 {
1954 throw new Win32Exception();
1955 }
1956 Unsafe.SkipInit(out global::Interop.Advapi32.TOKEN_PRIVILEGE tOKEN_PRIVILEGE);
1960 global::Interop.Advapi32.AdjustTokenPrivileges(TokenHandle, DisableAllPrivileges: false, &tOKEN_PRIVILEGE, 0u, null, null);
1961 if (Marshal.GetLastWin32Error() != 0)
1962 {
1963 throw new Win32Exception();
1964 }
1965 }
1966 finally
1967 {
1968 TokenHandle?.Dispose();
1969 }
1970 }

References System.Runtime.Serialization.Dictionary, and System.Runtime.InteropServices.Marshal.GetLastWin32Error().

Referenced by System.Diagnostics.Process.EnterDebugMode(), and System.Diagnostics.Process.LeaveDebugMode().