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

◆ Revert()

unsafe void System.Security.AccessControl.Privilege.Revert ( )
inline

Definition at line 331 of file Privilege.cs.

332 {
333 int num = 0;
335 {
337 }
338 if (!NeedToRevert)
339 {
340 return;
341 }
342 bool flag = true;
343 try
344 {
346 {
347 Unsafe.SkipInit(out global::Interop.Advapi32.TOKEN_PRIVILEGE tOKEN_PRIVILEGE);
348 tOKEN_PRIVILEGE.PrivilegeCount = 1u;
349 tOKEN_PRIVILEGE.Privileges.Luid = luid;
350 tOKEN_PRIVILEGE.Privileges.Attributes = (initialState ? 2u : 0u);
351 if (!global::Interop.Advapi32.AdjustTokenPrivileges(tlsContents.ThreadHandle, DisableAllPrivileges: false, &tOKEN_PRIVILEGE, 0u, null, null))
352 {
354 flag = false;
355 }
356 }
357 }
358 finally
359 {
360 if (flag)
361 {
362 Reset();
363 }
364 }
365 switch (num)
366 {
367 case 8:
368 throw new OutOfMemoryException();
369 case 5:
370 throw new UnauthorizedAccessException();
371 default:
372 throw new InvalidOperationException();
373 case 0:
374 break;
375 }
376 }
static string InvalidOperation_MustBeSameThread
Definition SR.cs:84
Definition SR.cs:7
global::Interop.Advapi32.LUID luid
Definition Privilege.cs:182
static Thread CurrentThread
Definition Thread.cs:312

References System.Threading.Thread.CurrentThread, System.Security.AccessControl.Privilege.currentThread, System.Runtime.InteropServices.Marshal.GetLastWin32Error(), System.Security.AccessControl.Privilege.initialState, System.SR.InvalidOperation_MustBeSameThread, System.Security.AccessControl.Privilege.TlsContents.IsImpersonating, System.Security.AccessControl.Privilege.luid, System.Security.AccessControl.Privilege.NeedToRevert, System.Security.AccessControl.Privilege.TlsContents.ReferenceCountValue, System.Security.AccessControl.Privilege.Reset(), System.Security.AccessControl.Privilege.stateWasChanged, System.Security.AccessControl.Privilege.TlsContents.ThreadHandle, and System.Security.AccessControl.Privilege.tlsContents.

Referenced by System.Security.AccessControl.Privilege.~Privilege(), System.Security.AccessControl.Win32.GetSecurityInfo(), System.Security.AccessControl.ObjectSecurity< T >.Persist(), and System.Security.AccessControl.Win32.SetSecurityInfo().