Implementing the Functions Required for a Debugger Extension DLL (Windows Embedded CE 6.0)


This topic describes how to implement the functions that are required for a custom debugger extension DLL. These functions are required by Platform Builder to load and unload the DLL as a debugger extension.

Before you begin to implement these functions, you must complete the steps in Creating a Debugger Extension DLL Project.

  1. In Visual Studio 2005, in Solution Explorer, expand Source Files, and then double-click hello_ext.cpp.

  2. Add an implementation of WinDbgExtensionDllInit that matches the following function signature from wdbgexts_ce.h:

    typedef VOID
        PWINDBG_EXTENSION_APIS lpExtensionApis,
        USHORT                 MajorVersion,
        USHORT                 MinorVersion

    Platform Builder calls this function when it loads the debugger extension. The PWINDBG_EXTENSION_APIS structure contains callback functions for the APIs. Notice that this structure may change for each version, so check its nSize member.

  3. Next, add an implementation of WinDbgExtensionDllShutdown that matches the following function signature:

    void WDBGAPI WinDbgExtensionDllShutdown( void );

    Platform Builder calls this function before it unloads the debugger extension. In the function implementation, add code that should be called before this debugger extension is unloaded, such as terminating threads that you started, or closing open handles.

  4. Next, add an implementation of ExtensionApiVersion that matches the following function signature:


    This function returns a pointer to an EXT_API_VERSION structure, which is defined in wdbgexts_ce.h as follows:

    typedef struct EXT_API_VERSION {
        USHORT  MajorVersion;
        USHORT  MinorVersion;
        USHORT  Revision;
        USHORT  Reserved;

  1. In hello_ext.cpp, use the DECLARE_API macro to add a command called Hello.

    The name of this command must be identical to the name that you want to use for the debugger command.
  2. (Optional) Customize the implementation by adding additional functionality. For more information on the functionality that you can add, see Debugger Extension Functions.

After you have completed these steps, you are ready to create a .def file to export the functions that you implemented in this topic.

The following code shows you a starting point for implementing the required functions for a debugger extension DLL:

// hello_ext.cpp : Defines the entry point for the DLL application.

#include "stdafx.h"

#ifdef _MANAGED
  #pragma managed(push, off)

                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
    return TRUE;

#ifdef _MANAGED
  #pragma managed(pop)

USHORT                 SavedMajorVersion;
USHORT                 SavedMinorVersion;

void WDBGAPI WinDbgExtensionDllInit(
        PWINDBG_EXTENSION_APIS lpExtensionApis,
        USHORT MajorVersion,
        USHORT MinorVersion)
    // Copy lpExtensionApis to ExtensionAPis so that extension
    // functions can 
    // access the Platform Builder Debugger Extension API.
ExtensionApis = *lpExtensionApis;

    SavedMajorVersion = MajorVersion;
    SavedMinorVersion = MinorVersion;

    // Add code that should run after the Extension DLL is loaded 
    // into Platform Builder.

LPEXT_API_VERSION ExtensionApiVersion()
    return &ApiVersion;

     dprintf("HELLO_EXT: Hello!\n");
     // Implement debugger functionality by calling the  
     // Debugger Extension Functions

Community Additions