internal unsafe bool IsInKernelMode() { // When a thread enters process mode, RuntimeEntryPoint // sets modeMarker=processMarkers. Thus, in process mode: // // modeMarker == processMarkers // // When a thread in process mode calls the kernel, pushStackMark // pushes a child process marker onto the stack, so that // modeMarker is left pointing to the new processMarker's // parent (the old processMarker). Thus, in kernel mode: // // modeMarker == parent(processMarkers) // // This keeps the mode in sync with the process stack markers, // which is convenient though not essential. This assumes that // the only reason a process pushes a stack marker is to enter // kernel mode. // // Since processMarkers may be null, ThreadContext.ParentModeMarker // defines a special definition for parent(null). #if SINGULARITY_PROCESS System.GCs.CallStack.TransitionRecord *processMarkers = stackMarkers; #endif // SINGULARITY_PROCESS if (modeMarker == processMarkers) { return(false); } else { VTable.Assert(modeMarker == ParentModeMarker(processMarkers)); return(true); } }
internal unsafe void SetProcessMode() { #if SINGULARITY_PROCESS System.GCs.CallStack.TransitionRecord *processMarkers = stackMarkers; #endif // SINGULARITY_PROCESS modeMarker = processMarkers; }
ParentModeMarker(System.GCs.CallStack.TransitionRecord * child) { System.GCs.CallStack.TransitionRecord *bottom = (System.GCs.CallStack.TransitionRecord *)(-1); VTable.Assert(child != bottom); if (child == null) { return(bottom); } else { return(child->oldTransitionRecord); } }