|
|
1.1 ! root 1: /*++ ! 2: ! 3: Copyright (c) 1993 Microsoft Corporation ! 4: ! 5: Module Name: ! 6: ! 7: context.c ! 8: ! 9: Abstract: ! 10: ! 11: This file provides access to thread context information. ! 12: ! 13: Author: ! 14: ! 15: Miche Baker-Harvey (v-michbh) 1-May-1993 ! 16: ! 17: Environment: ! 18: ! 19: User Mode ! 20: ! 21: --*/ ! 22: ! 23: #include <windows.h> ! 24: #include <stdlib.h> ! 25: #include <stdio.h> ! 26: #include <string.h> ! 27: ! 28: #include "drwatson.h" ! 29: #include "proto.h" ! 30: ! 31: void MoveQuadContextToInt(PCONTEXT); ! 32: ! 33: void ! 34: GetContextForThread( PDEBUGPACKET dp ) ! 35: { ! 36: PTHREADCONTEXT ptctx = dp->tctx; ! 37: ! 38: memset(&ptctx->context,0,sizeof(CONTEXT)); ! 39: ! 40: // ! 41: // The context structure returned from the system contains ! 42: // QUADs. Convert to the PORTABLE_32BIT form. ! 43: // ! 44: ! 45: ptctx->context.ContextFlags = CONTEXT_FULL; ! 46: ptctx->context._QUAD_FLAGS_OFFSET = CONTEXT_FULL; ! 47: ! 48: if (!GetThreadContext( ptctx->hThread, &ptctx->context )) { ! 49: lprintfs( ">>>>> GetThreadContext failed: err(%d), hthread(0x%x)\n", ! 50: GetLastError(), ptctx->hThread ); ! 51: ptctx->pc = 0; ! 52: ptctx->frame = 0; ! 53: ptctx->stack = 0; ! 54: ptctx->mi = NULL; ! 55: } ! 56: else { ! 57: MoveQuadContextToInt(&ptctx->context); ! 58: ! 59: ptctx->pc = ptctx->context.Fir; ! 60: ptctx->frame = ptctx->context.IntSp; ! 61: ptctx->stack = ptctx->context.IntSp; ! 62: ! 63: ptctx->mi = GetModuleForPC( dp, ptctx->pc ); ! 64: } ! 65: ! 66: return; ! 67: } ! 68: ! 69: ! 70: /*** MoveQuadContextToInt ! 71: * ! 72: * Purpose: ! 73: * Transforms the contents of a context structure containing ! 74: * QUAD (on ALPHA) or LARGE_INTEGER (elsewhere) values to ! 75: * one containing two sets of 4-byte values. ! 76: * ! 77: * Input: ! 78: * qc - pointer to the quad context ! 79: * ! 80: * Output: ! 81: * qc - transformed into a _PORTABLE_32BIT_CONTEXT ! 82: * ! 83: * Returns: ! 84: * none ! 85: * ! 86: *************************************************************************/ ! 87: void ! 88: MoveQuadContextToInt( ! 89: PCONTEXT qc // UQUAD context ! 90: ) ! 91: { ! 92: CONTEXT localcontext; ! 93: PCONTEXT lc = &localcontext; ! 94: ULONG index; ! 95: ! 96: PULONG PLc, PHc; // Item in Register and HighPart Contexts ! 97: PLARGE_INTEGER PQc; // Item in Quad Context ! 98: ! 99: // ! 100: // copy the quad elements to the two halfs of the ULONG context ! 101: // This routine assumes that the first 66 elements of the ! 102: // context structure are quads, and the ordering of the struct. ! 103: // ! 104: ! 105: PLc = &lc->FltF0; ! 106: PHc = &lc->HighFltF0; ! 107: PQc = (PLARGE_INTEGER)(&qc->FltF0); ! 108: ! 109: for (index = 0; index < 67; index++) { ! 110: ! 111: // ! 112: // inline version of QuadElementToInt ! 113: // ! 114: ! 115: *PLc++ = PQc->LowPart; ! 116: *PHc++ = PQc->HighPart; ! 117: PQc++; ! 118: } ! 119: ! 120: // ! 121: // The psr and context flags are 32-bit values in both ! 122: // forms of the context structure, so transfer here. ! 123: // ! 124: ! 125: lc->Psr = qc->_QUAD_PSR_OFFSET; ! 126: lc->ContextFlags = qc->_QUAD_FLAGS_OFFSET; ! 127: ! 128: lc->ContextFlags |= CONTEXT_PORTABLE_32BIT; ! 129: ! 130: // ! 131: // The ULONG context is *lc; copy it back to the quad ! 132: // ! 133: ! 134: *qc = *lc; ! 135: return; ! 136: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.