/*++ Copyright (c) 1990 Microsoft Corporation Module Name: ntsdexts.c Abstract: This function contains the default ntsd debugger extensions Author: Bob Day (bobday) 29-Feb-1992 Grabbed standard header Revision History: --*/ #include #pragma hdrstop #include VOID DumpMemory( UINT DumpType ) { VDMCONTEXT ThreadContext; int mode; int i, j, lines = 8; WORD selector; ULONG offset; ULONG base; char ch; if (!DumpType) { return; } mode = GetContext( &ThreadContext ); if (!GetNextToken()) { PRINTF("Please specify an address\n"); return; } if (!ParseIntelAddress(&mode, &selector, &offset)) { return; } if (GetNextToken()) { if ((*lpArgumentString == 'l') || (*lpArgumentString == 'L')) { lpArgumentString++; } lines = (EXPRESSION(lpArgumentString)*DumpType+15)/16; } base = GetInfoFromSelector(selector, mode, NULL) + GetIntelBase(); for (i=0; i Base: %08lX", selector, Base); #ifndef i386 PRINTF(" (%08X)", Base+GetIntelBase()); #endif PRINTF(" Limit: %08lX %s %s %s %s\n", si.Limit, si.bPresent ? " P" : "NP", si.bSystem ? "System" : si.bCode ? "Code " : "Data ", si.bSystem ? "" : si.bWrite ? "W" : "R", si.bSystem ? "" : si.bAccessed ? "A" : "" ); selector+=8; } } // // Dump Taskinfo; // // If no argument, dump all wow tasks. // If 0, dump current WOW task // Else dump the specifies task {which is thread-id as shown by // ~ command under ntsd like 37.6b so thread-id is 6b) // void DumpTaskInfo (ptd,mode) PTD ptd; int mode; { ULONG Base; TDB tdb; BOOL b; Base = GetInfoFromSelector( ptd->htask16, mode, NULL ); b = ReadProcessMem( hCurrentProcess, (LPVOID) (Base+GetIntelBase()), &tdb, sizeof(tdb), NULL ); if ( !b ) { PRINTF("Failure reading TDB at %X\n", Base ); return; } PRINTF("\nDump for ThreadId = %x\n",ptd->dwThreadID); PRINTF(" Stack = %x:%x\n",HIWORD(ptd->vpStack),LOWORD(ptd->vpStack)); PRINTF(" HTask (TDB) = %x\n", ptd->htask16); PRINTF(" HInst = %x\n", ptd->hInst16); PRINTF(" HMod16 = %x\n", ptd->hMod16); PRINTF(" CompatFlags = %x\n",ptd->dwWOWCompatFlags); PRINTF(" HThread = %x\n",ptd->hThread); PRINTF(" TDBFlags = %x\n",tdb.TDB_flags); PRINTF(" ExpWinVer = %x\n",tdb.TDB_ExpWinVer); PRINTF(" DTA = %x:%x\n",HIWORD(tdb.TDB_DTA),LOWORD(tdb.TDB_DTA)); PRINTF(" CurDir = %.64s\n",tdb.TDB_Directory); PRINTF(" ModName = %.8s\n",tdb.TDB_ModName); } void TaskInfo ( ) { VDMCONTEXT ThreadContext; DWORD ThreadId; PTD ptd,ptdHead; TD td; int mode; BOOL b,fFound=FALSE; mode = GetContext( &ThreadContext ); ThreadId = (DWORD)-1; // Assume Dump All Tasks if (GetNextToken()) { ThreadId = (DWORD) EXPRESSION( lpArgumentString ); } ptdHead = (PTD)EXPRESSION("wow32!gptdTaskHead"); // get the pointer to first TD b = ReadProcessMem( hCurrentProcess, (LPVOID) (ptdHead), &ptd, sizeof(DWORD), NULL ); if ( !b ) { PRINTF("Failure reading gptdTaskHead at %08lX\n", ptdHead ); return; } // enumerate td list to find the match(es) while (ptd) { b = ReadProcessMem( hCurrentProcess, (LPVOID) (ptd), &td, sizeof(TD), NULL ); if ( !b ) { PRINTF("Failure reading TD At %08lX\n", ptd ); return; } if (ThreadId == -1) { DumpTaskInfo (&td,mode); fFound = TRUE; } else { if (ThreadId == td.dwThreadID) { DumpTaskInfo (&td,mode); fFound = TRUE; break; } } ptd = td.ptdNext; } if (!fFound) { if (ThreadId == -1) { PRINTF("No WOW Task Found.\n"); } else PRINTF("WOW Task With Thread Id = %02x Not Found.\n",ThreadId); } return; }