internal static SecurityIdentifier GetCurrentAppContainerSid() { Fx.Assert(AppContainerInfo.IsAppContainerSupported, "AppContainers are not supported."); if (currentAppContainerSid == null) { lock (thisLock) { if (currentAppContainerSid == null) { SafeCloseHandle tokenHandle = null; try { tokenHandle = AppContainerInfo.GetCurrentProcessToken(); currentAppContainerSid = UnsafeNativeMethods.GetAppContainerSid(tokenHandle); } finally { if (tokenHandle != null) { tokenHandle.Dispose(); } } } } } return(currentAppContainerSid); }
static int GetCurrentSessionId() { Fx.Assert(AppContainerInfo.IsAppContainerSupported, "AppContainers are not supported."); SafeCloseHandle tokenHandle = null; try { tokenHandle = AppContainerInfo.GetCurrentProcessToken(); return(UnsafeNativeMethods.GetSessionId(tokenHandle)); } finally { if (tokenHandle != null) { tokenHandle.Dispose(); } } }