Introduction to Debugger Extensions in Software

Draw QR in Software Introduction to Debugger Extensions
Introduction to Debugger Extensions
Making QR-Code In Visual C#
Using Barcode drawer for .NET Control to generate, create QR-Code image in Visual Studio .NET applications.
Prior chapters show a variety of useful debugging sessions and associated extension commands Examples of such include !sid, !token, and !sd Where do these extension commands come from Are they implemented in the debugger itself Most of the debug commands that you have seen so far are implemented as custom debugger extensions Debugging Tools for Windows includes a core set of debugger extensions that include the most commonly used commands during debug sessions Table 111 lists the core debugger extensions available
Draw QR In VS .NET
Using Barcode creation for ASP.NET Control to generate, create QR Code JIS X 0510 image in ASP.NET applications.
11
QR Code ISO/IEC18004 Generator In VS .NET
Using Barcode generation for VS .NET Control to generate, create QR Code JIS X 0510 image in .NET applications.
Writing Custom Debugger Extensions
QR Code Generator In Visual Basic .NET
Using Barcode drawer for .NET framework Control to generate, create Quick Response Code image in VS .NET applications.
Table 111
Scanning Code 128A In .NET Framework
Using Barcode recognizer for Visual Studio .NET Control to read, scan read, scan image in .NET applications.
Extension Extension Name Description
Data Matrix ECC200 Creator In VB.NET
Using Barcode creation for .NET Control to generate, create Data Matrix image in VS .NET applications.
General Extensions
Painting Code 128 In .NET
Using Barcode creator for ASP.NET Control to generate, create USS Code 128 image in ASP.NET applications.
Extdll
EAN13 Maker In Java
Using Barcode encoder for Java Control to generate, create EAN-13 Supplement 5 image in Java applications.
User Mode Extensions
Decode Data Matrix In .NET Framework
Using Barcode reader for .NET framework Control to read, scan read, scan image in VS .NET applications.
Ntsdextsdll
Barcode Drawer In .NET
Using Barcode encoder for VS .NET Control to generate, create barcode image in Visual Studio .NET applications.
RPC extensions rpcextsdll
Print USS Code 39 In Visual C#.NET
Using Barcode drawer for VS .NET Control to generate, create Code 39 image in Visual Studio .NET applications.
General extension commands, such as error cxr std_map Extension commands used frequently in user mode debugging, such as runaway critsec threadtoken Extension commands for debugging RPC, such as authinfo getcallinfo rpcheap
GS1 - 13 Maker In Visual Studio .NET
Using Barcode generator for VS .NET Control to generate, create EAN13 image in .NET applications.
In its most basic form, a debugger extension is nothing more than a DLL that exports a set of entry points Each entry point is invoked by the debug engine when the user types the command (same name as the entry point) in a debug session As an example, consider the following command:
Encoding Universal Product Code Version A In Java
Using Barcode printer for Java Control to generate, create GTIN - 12 image in Java applications.
0:000> !exterror 0 Error code: (Win32) 0 (0) - The operation completed successfully
Printing Data Matrix ECC200 In C#.NET
Using Barcode encoder for .NET framework Control to generate, create ECC200 image in Visual Studio .NET applications.
The command states that the error command is part of the extDLL extension and that the command should be executed In this case, the extDLL exports a matching error function invoked as a result of the preceding command execution The command itself simply prints the textual representation of a Windows error code 0 to the debugger console window
Barcode Drawer In .NET
Using Barcode generator for ASP.NET Control to generate, create bar code image in ASP.NET applications.
Examining Debugger Extensions
Creating EAN 128 In Java
Using Barcode maker for Java Control to generate, create EAN 128 image in Java applications.
Using an SDK tool named dumpbinexe, you can very easily get a list of all exported functions from any extension DLL (including the ones listed in Table 111) For example, running dumpbinexe against the extsdll yields the following:
Encode ANSI/AIM Code 39 In Java
Using Barcode creator for Java Control to generate, create USS Code 39 image in Java applications.
C:\>dumpbin /EXPORTS extsdll
Bar Code Decoder In VS .NET
Using Barcode scanner for Visual Studio .NET Control to read, scan read, scan image in Visual Studio .NET applications.
Microsoft (R) COFF/PE Dumper Version 8005072742 Copyright (C) Microsoft Corporation All rights reserved
Printing GS1 128 In .NET
Using Barcode drawer for ASP.NET Control to generate, create EAN / UCC - 14 image in ASP.NET applications.
Introduction to Debugger Extensions
Paint USS Code 39 In .NET
Using Barcode drawer for ASP.NET Control to generate, create Code 39 image in ASP.NET applications.
Dump of file extsdll File Type: DLL Section contains the following exports for extsdll 00000000 44B0109E 000 1 32 32 characteristics time date stamp Sat Jul 08 13:07:58 2006 version ordinal base number of functions number of names name DebugExtensionInitialize DebugExtensionNotify DebugExtensionUninitialize _EFN_GetEnvironmentVariable acl atom avrf bitcount cs decodeptr dlls dlltree encodeptr envvar gflag heap help kuser mui peb psr rebase sd shipassert sid slist stl teb tls token
ordinal hint RVA 2 3 4 1 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 0 1 2 3 4 5 6 7 8 9 A B C D E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 0002D8F0 0002D9B0 0002DB80 000446E0 0003FE50 0002EC90 00024750 00021D50 000235A0 0002ED70 0002B250 0002C5E0 0002ED70 00044890 0002E000 0001C850 0002DE80 0002E530 000399E0 00045960 0003C3D0 0003D920 0003F4B0 00047260 0003FD70 00040700 00043EC0 00045F70 00047090 00049240
11 WRITING CUSTOM DEBUGGER EXTENSIONS
11
Writing Custom Debugger Extensions
31 32 Summary 5000 6000 1000 54000
1E 00050100 tp 1F 00019A40 udeadlock
data reloc rsrc text
Example Debugger Extension
So far, you ve seen examples of some small, but very useful, extensions To illustrate the real power of debugger extensions, let s assume that you have developed a simple version of a binary tree component that allows developers to add items to a binary tree, as well as traverse the tree (For brevity s sake, other common binary tree operations are omitted) The binary tree is also limited to storing integers The code for the binary tree is shown in Listing 111 and is fairly self-explanatory Listing 111
// bstreeh #ifndef __BSTREE_H #define __BSTREE_H #include <windowsh> #include <strsafeh> class CBinaryTree { public: CBinaryTree(CHAR* pszDescription); BOOL Add(int num); VOID Traverse(); private: class _TreeNode { public: _TreeNode(int num) { pLeftChild = NULL; pRightChild = NULL; data=num;
Example Debugger Extension
} int data; _TreeNode* pLeftChild; _TreeNode* pRightChild; }; BOOL AddNode(_TreeNode* item, _TreeNode* current, DWORD dwRecursiveCount); VOID TraverseTree(_TreeNode* current); _TreeNode* m_pHead; DWORD m_dwDepth; DWORD m_dwNumNodes; }; #endif
11 WRITING CUSTOM DEBUGGER EXTENSIONS
// bstreecpp #include bstreeh #include <stdioh> CBinaryTree::CBinaryTree () : m_pHead(NULL), m_dwDepth(0), m_dwNumNodes(0) { } BOOL CBinaryTree::Add(int num) { BOOL bRet=FALSE; _TreeNode* item=new _TreeNode(num); if(item!=NULL) { bRet=AddNode(item, m_pHead, 1); if(bRet==TRUE) { m_dwNumNodes++; } } return bRet; } VOID CBinaryTree::Traverse() { TraverseTree(m_pHead); }
(continues)