|
|
1.1 ! root 1: ! 2: /******************************Module*Header*******************************\ ! 3: * Module Name: debug.c ! 4: * ! 5: * This file is for debugging helper routines and extensions. ! 6: * ! 7: * Copyright (c) 1992 Microsoft Corporation ! 8: \**************************************************************************/ ! 9: ! 10: #include <stdio.h> ! 11: #include <stdarg.h> ! 12: ! 13: #include "driver.h" ! 14: #include <ntsdexts.h> ! 15: ! 16: #if DBG ! 17: ! 18: ULONG DebugLevel = 0; ! 19: ! 20: #endif // DBG ! 21: ! 22: /***************************************************************************** ! 23: * ! 24: * Routine Description: ! 25: * ! 26: * This function is variable-argument, level-sensitive debug print ! 27: * routine. ! 28: * If the specified debug level for the print statement is lower or equal ! 29: * to the current debug level, the message will be printed. ! 30: * ! 31: * Arguments: ! 32: * ! 33: * DebugPrintLevel - Specifies at which debugging level the string should ! 34: * be printed ! 35: * ! 36: * DebugMessage - Variable argument ascii c string ! 37: * ! 38: * Return Value: ! 39: * ! 40: * None. ! 41: * ! 42: ***************************************************************************/ ! 43: ! 44: VOID ! 45: DebugPrint( ! 46: ULONG DebugPrintLevel, ! 47: PCHAR DebugMessage, ! 48: ... ! 49: ) ! 50: ! 51: { ! 52: ! 53: #if DBG ! 54: ! 55: va_list ap; ! 56: ! 57: va_start(ap, DebugMessage); ! 58: ! 59: if (DebugPrintLevel <= DebugLevel) { ! 60: ! 61: char buffer[128]; ! 62: ! 63: vsprintf(buffer, DebugMessage, ap); ! 64: ! 65: OutputDebugStringA(buffer); ! 66: } ! 67: ! 68: va_end(ap); ! 69: ! 70: #endif // DBG ! 71: ! 72: } // DebugPrint() ! 73: ! 74: ! 75: #if DBG ! 76: ! 77: // macros ! 78: ! 79: #define move(dst, src)\ ! 80: try { \ ! 81: ReadProcessMemory(hCurrentProcess, (LPVOID) (src), &(dst), sizeof(dst), NULL);\ ! 82: } except (EXCEPTION_EXECUTE_HANDLER) {\ ! 83: return;\ ! 84: } ! 85: ! 86: #define move2(dst, src, bytes)\ ! 87: try {\ ! 88: ReadProcessMemory(hCurrentProcess, (LPVOID) (src), &(dst), (bytes), NULL);\ ! 89: } except (EXCEPTION_EXECUTE_HANDLER) {\ ! 90: return;\ ! 91: } ! 92: ! 93: ! 94: #endif ! 95: ! 96: ! 97: ! 98: /******************************Public*Routine******************************\ ! 99: * dumpdsurf ! 100: * ! 101: * Displays the contents of a DEVSURF structure ! 102: * ! 103: * History: ! 104: * Tue 17-Mar-1992 21:26:21 -by- Walt Moore [waltm] ! 105: * Wrote it. ! 106: \**************************************************************************/ ! 107: ! 108: void dumpdsurf ! 109: ( ! 110: HANDLE hCurrentProcess, ! 111: HANDLE hCurrentThread, ! 112: DWORD dwCurrentPc, ! 113: PNTSD_EXTENSION_APIS lpExtensionApis, ! 114: LPSTR lpArgumentString ! 115: ) ! 116: { ! 117: ! 118: #if DBG ! 119: ! 120: // NTSD stuff required for output ! 121: ! 122: PNTSD_OUTPUT_ROUTINE Print; ! 123: PNTSD_GET_EXPRESSION EvalExpression; ! 124: PNTSD_GET_SYMBOL GetSymbol; ! 125: ! 126: ! 127: // Local variables needed for our own output ! 128: ! 129: DEVSURF dsurf; ! 130: PDEVSURF pdsurf; ! 131: ! 132: ! 133: // Eliminate warnings messages about unused parameters ! 134: ! 135: hCurrentProcess; ! 136: hCurrentThread; ! 137: dwCurrentPc; ! 138: lpExtensionApis; ! 139: lpArgumentString; ! 140: ! 141: ! 142: // Set up function pointers ! 143: ! 144: Print = lpExtensionApis->lpOutputRoutine; ! 145: EvalExpression = lpExtensionApis->lpGetExpressionRoutine; ! 146: GetSymbol = lpExtensionApis->lpGetSymbolRoutine; ! 147: ! 148: ! 149: // Copy the DEVSURF structure into NTSD's address space ! 150: ! 151: pdsurf = (PDEVSURF) EvalExpression(lpArgumentString); ! 152: move(dsurf, pdsurf); ! 153: ! 154: ! 155: // Now print the device surface ! 156: ! 157: Print("--------------------------------------------------\n"); ! 158: Print("DEVSURF 0x%08lx\n", pdsurf); ! 159: Print(" ident %c%c%c%c\n", ((CHAR *)&dsurf.ident)[0],((CHAR *)&dsurf.ident)[1], ! 160: ((CHAR *)&dsurf.ident)[2],((CHAR *)&dsurf.ident)[3]); ! 161: Print(" flSurf 0x%08lx", dsurf.flSurf); ! 162: ! 163: if (dsurf.flSurf & DS_BRUSH) ! 164: { ! 165: Print(" a brush"); ! 166: ! 167: if (dsurf.flSurf & DS_SOLIDBRUSH) ! 168: Print(", solid color index of 0x%02lx", (ULONG) dsurf.iColor); ! 169: if (dsurf.flSurf & DS_GREYBRUSH) ! 170: Print(", gray"); ! 171: Print("\n"); ! 172: } ! 173: else ! 174: { ! 175: Print("\n"); ! 176: Print("iFormat 0x%02lx\n", (ULONG) dsurf.iFormat); ! 177: Print("ppdev 0x%08lx\n", (ULONG) dsurf.ppdev); ! 178: Print("sizlSurf (%lu,%lu)\n", dsurf.sizlSurf.cx, dsurf.sizlSurf.cy); ! 179: Print("lNextScan 0x%08lx\n", (ULONG) dsurf.lNextScan); ! 180: Print("lNextPlane 0x%08lx\n", (ULONG) dsurf.lNextPlane); ! 181: Print("pvScan0 0x%08lx\n", (ULONG) dsurf.pvScan0); ! 182: Print("pvStart 0x%08lx\n", (ULONG) dsurf.pvStart); ! 183: Print("pvConv 0x%08lx\n", (ULONG) dsurf.pvConv); ! 184: } ! 185: Print("--------------------------------------------------\n"); ! 186: ! 187: #endif ! 188: ! 189: return; ! 190: } ! 191: ! 192: ! 193: ! 194: /******************************Public*Routine******************************\ ! 195: * help ! 196: * ! 197: * Displays menu of all extensions ! 198: * ! 199: * History: ! 200: * Tue 17-Mar-1992 21:26:21 -by- Walt Moore [waltm] ! 201: * Wrote it. ! 202: \**************************************************************************/ ! 203: ! 204: void help ! 205: ( ! 206: HANDLE hCurrentProcess, ! 207: HANDLE hCurrentThread, ! 208: DWORD dwCurrentPc, ! 209: PNTSD_EXTENSION_APIS lpExtensionApis, ! 210: LPSTR lpArgumentString ! 211: ) ! 212: { ! 213: ! 214: #if DBG ! 215: ! 216: // NTSD stuff required for output ! 217: ! 218: PNTSD_OUTPUT_ROUTINE Print; ! 219: PNTSD_GET_EXPRESSION EvalExpression; ! 220: PNTSD_GET_SYMBOL GetSymbol; ! 221: ! 222: ! 223: // Eliminate warnings messages about unused parameters ! 224: ! 225: hCurrentProcess; ! 226: hCurrentThread; ! 227: dwCurrentPc; ! 228: lpExtensionApis; ! 229: lpArgumentString; ! 230: ! 231: ! 232: // Set up function pointers ! 233: ! 234: Print = lpExtensionApis->lpOutputRoutine; ! 235: EvalExpression = lpExtensionApis->lpGetExpressionRoutine; ! 236: GetSymbol = lpExtensionApis->lpGetSymbolRoutine; ! 237: ! 238: ! 239: // Now print the help menu ! 240: ! 241: Print("------------------------------------------------------------------\n"); ! 242: Print("VGA NTSD Extensions\n"); ! 243: Print(" dumpsurf <addr> - Display the contents of a DEVSURF structure\n"); ! 244: Print("------------------------------------------------------------------\n"); ! 245: ! 246: #endif ! 247: ! 248: return; ! 249: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.