Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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();
                }
            }
        }