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

◆ LuidFromPrivilege()

static global.Interop.Advapi32.LUID System.Security.AccessControl.Privilege.LuidFromPrivilege ( string privilege)
inlinestaticprivate

Definition at line 190 of file Privilege.cs.

191 {
192 Unsafe.SkipInit(out global::Interop.Advapi32.LUID lpLuid);
193 lpLuid.LowPart = 0;
194 lpLuid.HighPart = 0;
195 try
196 {
197 privilegeLock.EnterReadLock();
198 if (luids.ContainsKey(privilege))
199 {
201 privilegeLock.ExitReadLock();
202 }
203 else
204 {
205 privilegeLock.ExitReadLock();
206 if (!global::Interop.Advapi32.LookupPrivilegeValue(null, privilege, out lpLuid))
207 {
208 switch (Marshal.GetLastWin32Error())
209 {
210 case 8:
211 throw new OutOfMemoryException();
212 case 5:
213 throw new UnauthorizedAccessException();
214 case 1313:
216 default:
217 throw new InvalidOperationException();
218 }
219 }
220 privilegeLock.EnterWriteLock();
221 }
222 }
223 finally
224 {
225 if (privilegeLock.IsReadLockHeld)
226 {
227 privilegeLock.ExitReadLock();
228 }
229 if (privilegeLock.IsWriteLockHeld)
230 {
231 if (!luids.ContainsKey(privilege))
232 {
235 }
236 privilegeLock.ExitWriteLock();
237 }
238 }
239 return lpLuid;
240 }
static string Argument_InvalidPrivilegeName
Definition SR.cs:60
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
Definition SR.cs:7
static readonly ReaderWriterLockSlim privilegeLock
Definition Privilege.cs:174
static readonly Dictionary< global::Interop.Advapi32.LUID, string > privileges
Definition Privilege.cs:170
static readonly Dictionary< string, global::Interop.Advapi32.LUID > luids
Definition Privilege.cs:172

References System.SR.Argument_InvalidPrivilegeName, System.SR.Format(), System.Runtime.InteropServices.Marshal.GetLastWin32Error(), System.Security.AccessControl.Privilege.luids, System.Security.AccessControl.Privilege.privilegeLock, and System.Security.AccessControl.Privilege.privileges.

Referenced by System.Security.AccessControl.Privilege.Privilege().