home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / sdktools / image / drwatson / context.c < prev    next >
C/C++ Source or Header  |  1995-03-15  |  1KB  |  58 lines

  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.     Wesley Witt (wesw) 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.  
  32. void
  33. GetContextForThread( PDEBUGPACKET dp )
  34. {
  35.     PTHREADCONTEXT ptctx = dp->tctx;
  36.  
  37.     memset(&ptctx->context,0,sizeof(CONTEXT));
  38.  
  39.     ptctx->context.ContextFlags = CONTEXT_FULL |
  40.                                   CONTEXT_FLOATING_POINT |
  41.                                   CONTEXT_DEBUG_REGISTERS;
  42.  
  43.     if (!GetThreadContext( ptctx->hThread, &ptctx->context )) {
  44.         lprintfs( ">>>>> GetThreadContext failed: err(%d), hthread(0x%x)\n",
  45.                   GetLastError(), ptctx->hThread );
  46.         ptctx->pc = 0;
  47.         ptctx->frame = 0;
  48.         ptctx->stack = 0;
  49.     }
  50.     else {
  51.         ptctx->pc = ptctx->context.Eip;
  52.         ptctx->frame = ptctx->context.Ebp;
  53.         ptctx->stack = ptctx->context.Esp;
  54.     }
  55.  
  56.     return;
  57. }
  58.