[System.Security.SecurityCritical] // auto-generated static private SecurityContext CaptureCore(ExecutionContext.Reader currThreadEC, ref StackCrawlMark stackMark) { SecurityContext sc = new SecurityContext(); sc.isNewCapture = true; #if !FEATURE_PAL && FEATURE_IMPERSONATION // Force create WindowsIdentity if (!IsWindowsIdentityFlowSuppressed()) { WindowsIdentity currentIdentity = GetCurrentWI(currThreadEC); if (currentIdentity != null) { sc._windowsIdentity = new WindowsIdentity(currentIdentity.AccessToken); } } else { sc._disableFlow = SecurityContextDisableFlow.WI; } #endif // !FEATURE_PAL && FEATURE_IMPERSONATION // Force create CompressedStack sc.CompressedStack = CompressedStack.GetCompressedStack(ref stackMark); return(sc); }
private static void ReflectionTargetDemandHelper(int permission, PermissionSet targetGrant) { StackCrawlMark stackCrawlMark = StackCrawlMark.LookForMyCaller; CompressedStack compressedStack = CompressedStack.GetCompressedStack(ref stackCrawlMark); CodeAccessSecurityEngine.ReflectionTargetDemandHelper(permission, targetGrant, compressedStack); }
private static void ReflectionTargetDemandHelper(int permission, PermissionSet targetGrant) { StackCrawlMark lookForMyCaller = StackCrawlMark.LookForMyCaller; CompressedStack compressedStack = CompressedStack.GetCompressedStack(ref lookForMyCaller); ReflectionTargetDemandHelper(permission, targetGrant, compressedStack); }
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable private static void ReflectionTargetDemandHelper(int permission, PermissionSet targetGrant) { // Capture a compressed stack so that we can make both permission checks without walking the stack // multiple times. StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; CompressedStack cs = CompressedStack.GetCompressedStack(ref stackMark); ReflectionTargetDemandHelper(permission, targetGrant, cs); }
public static void Capture_GetCompressedStack_CreateCopy_Test() { CompressedStack compressedStack = CompressedStack.Capture(); Assert.NotNull(compressedStack); Assert.NotNull(compressedStack.CreateCopy()); Assert.NotNull(CompressedStack.GetCompressedStack()); Assert.NotNull(CompressedStack.GetCompressedStack().CreateCopy()); }
public void GetCompressedStack() { CompressedStack cs1 = CompressedStack.GetCompressedStack (); Assert.IsNotNull (cs1, "GetCompressedStack"); CompressedStack cs2 = CompressedStack.Capture (); Assert.IsNotNull (cs2, "Capture"); Assert.IsFalse (cs1.Equals (cs2), "cs1.Equals (cs2)"); Assert.IsFalse (cs2.Equals (cs1), "cs2.Equals (cs1)"); Assert.IsFalse (cs1.GetHashCode () == cs2.GetHashCode (), "GetHashCode"); }
private static SecurityContext CaptureCore(ExecutionContext.Reader currThreadEC, ref StackCrawlMark stackMark) { SecurityContext securityContext = new SecurityContext(); securityContext.isNewCapture = true; if (!SecurityContext.IsWindowsIdentityFlowSuppressed()) { WindowsIdentity currentWI = SecurityContext.GetCurrentWI(currThreadEC); if (currentWI != null) { securityContext._windowsIdentity = new WindowsIdentity(currentWI.AccessToken); } } else { securityContext._disableFlow = SecurityContextDisableFlow.WI; } securityContext.CompressedStack = CompressedStack.GetCompressedStack(ref stackMark); return(securityContext); }
public void Run_GetCompressedStack() { Assert.IsFalse(success, "pre-check"); CompressedStack.Run(CompressedStack.GetCompressedStack(), new ContextCallback(Callback), true); Assert.IsTrue(success, "post-check"); }