Annotation of q_a/samples/ntsd/debug.c, revision 1.1.1.3

1.1       root        1: /******************************Module*Header*******************************\
                      2: * Module Name: debug.c
                      3: *
                      4: * Debugger extension for dumping the INFO structure in NTSD
                      5: *
                      6: * Created: 24-Feb-1992 20:47:03
                      7: * Author: Petrus Wong
                      8: *
                      9: * Copyright (c) 1990 Microsoft Corporation
                     10: *
                     11: * 1. Place the DLL in the correct path
                     12: * 2. Run NTSD -d mdi
                     13: * 3. Upon NTSD prompt, do
                     14: *       !debug.dinfo address
                     15: *       where address is the address of Info
                     16: *
                     17: * Dependencies:
                     18: *
                     19: *   (#defines)
                     20: *   (#includes)
                     21: *
                     22: \**************************************************************************/
1.1.1.2   root       23: #include <stdarg.h>
                     24: #include <stdio.h>
                     25: 
1.1       root       26: #include <stddef.h>
                     27: #include <windows.h>
                     28: #include <winerror.h>
1.1.1.2   root       29: 
1.1       root       30: #include <excpt.h>
1.1.1.2   root       31: 
                     32: typedef LARGE_INTEGER PHYSICAL_ADDRESS, *PPHYSICAL_ADDRESS;
                     33: 
1.1       root       34: #include <ntsdexts.h>
                     35: #include "mditypes.h"
                     36: 
1.1.1.2   root       37: //
                     38: // don't use try/except here.  Otherwise, mip2coff -c chokes with the
                     39: // following fatal error on MIPS:
                     40: //      tried to get local variable absolute addr with no procedure
                     41: //
                     42: // NTSD will catch the fault anyway
                     43: //
                     44: // Alternatively, we can get rid of the -c switch on mip2coff in the
                     45: // module that use try/except, but we won't have any locals for the module
                     46: //
                     47: // Petrus Wong 05-Oct-1992
                     48: //
1.1.1.3 ! root       49: // We use mcl now which eliminates the need for mip2coff so we can use
        !            50: // try/except again
        !            51: //
        !            52: // Petrus Wong 10-Feb-1993
        !            53: //
1.1       root       54: #define move(dst, src)\
1.1.1.3 ! root       55: try {\
1.1       root       56:     ReadProcessMemory(hCurrentProcess, (LPVOID)(src), &(dst), sizeof(dst), NULL);\
1.1.1.3 ! root       57: } except (EXCEPTION_EXECUTE_HANDLER) {\
1.1       root       58:     return;\
                     59: }
                     60: 
                     61: /******************************Public*Routine******************************\
                     62: *
1.1.1.3 ! root       63: * DllMain
1.1       root       64: *
1.1.1.3 ! root       65: * Effects:   DllMain is called by Windows when
1.1       root       66: *            the DLL is initialized, Thread Attached, and other times.
                     67: *
1.1.1.3 ! root       68: * Warnings:  The DllMain function should perform additional initialization
1.1       root       69: *            tasks required by the DLL.  In this example, no initialization
1.1.1.3 ! root       70: *            tasks are required.  DllMain should return a value of 1 if
1.1       root       71: *            the initialization is successful.
                     72: *
                     73: * History:
                     74: *  24-Feb-1992 -by- Petrus Wong
                     75: * Wrote it.
                     76: \**************************************************************************/
                     77: 
1.1.1.3 ! root       78: BOOL  WINAPI DllMain(HANDLE hInst, DWORD ul_reason_being_called, LPVOID lpReserved)
1.1       root       79: {
                     80:     return 1;
                     81:        UNREFERENCED_PARAMETER(hInst);
                     82:        UNREFERENCED_PARAMETER(ul_reason_being_called);
                     83:        UNREFERENCED_PARAMETER(lpReserved);
                     84: }
                     85: 
                     86: 
                     87: /******************************Public*Routine******************************\
                     88: * dinfo
                     89: *
                     90: *
                     91: * Effects: Debugger extension to dump the INFO structure
                     92: *
                     93: * To invoke the routine in NTSD, do the following:
                     94: *
                     95: *   1. place the debug.dll in the path
                     96: *   2. on NTSD prompt, type
                     97: *
                     98: *      !debug.dinfo <address of the INFO structure>
                     99: *
                    100: * Warnings:
                    101: *
                    102: * History:
                    103: *  24-Feb-1992 -by- Petrus Wong
                    104: * Wrote it.
                    105: \**************************************************************************/
                    106: 
                    107: void dinfo (
                    108:     HANDLE hCurrentProcess,
                    109:     HANDLE hCurrentThread,
                    110:     HANDLE dwCurrentPc,
                    111:     PNTSD_EXTENSION_APIS lpExtensionApis,
                    112:     LPSTR lpArgumentString)
                    113: {
                    114:     PNTSD_OUTPUT_ROUTINE Print;
                    115:     PNTSD_GET_EXPRESSION EvalExpression;
                    116:     PNTSD_GET_SYMBOL GetSymbol;
                    117: 
                    118:     PINFO   pInfo;
                    119:     INFO    info;
                    120: 
                    121:     Print = lpExtensionApis->lpOutputRoutine;
                    122:     EvalExpression = lpExtensionApis->lpGetExpressionRoutine;
                    123:     GetSymbol = lpExtensionApis->lpGetSymbolRoutine;
                    124: 
                    125:     pInfo = (PINFO)EvalExpression(lpArgumentString);
                    126:     move(info, pInfo);
                    127:     Print(info.CaptionBarText);
                    128:     Print("\n");
                    129:     Print("hParent             = %x\n", info.hParent         );
                    130:     Print("hTextWnd            = %x\n", info.hTextWnd        );
                    131:     Print("rcClient(l,t,r,b)   = (%d,%d,%d,%d)\n",
                    132:                                  info.rcClient.left,  info.rcClient.top,
                    133:                                  info.rcClient.right, info.rcClient.bottom );
                    134:     return;
                    135: }
                    136: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.