text: // ==++==
  // 
  //   Copyright (c) Microsoft Corporation.  All rights reserved.
  // 
  // ==--==
  //----------------------------------------------------------------------------
  //
  // Debugger engine extension helper library.
  //
  //----------------------------------------------------------------------------
  
  #define DEBUG_NO_IMPLEMENTATION
  #include <engexts.h>
  
  PDEBUG_ADVANCED       g_ExtAdvanced;
  PDEBUG_CLIENT         g_ExtClient;
  PDEBUG_CONTROL        g_ExtControl;
  PDEBUG_DATA_SPACES    g_ExtData;
  PDEBUG_REGISTERS      g_ExtRegisters;
  PDEBUG_SYMBOLS        g_ExtSymbols;
  PDEBUG_SYSTEM_OBJECTS g_ExtSystem;
  
  // Queries for all debugger interfaces.
  HRESULT
  ExtQuery(PDEBUG_CLIENT Client)
  {
      HRESULT Status;
      
      if ((Status = Client->QueryInterface(__uuidof(IDebugAdvanced),
                                           (void **)&g_ExtAdvanced)) != S_OK)
      {
          goto Fail;
      }
      if ((Status = Client->QueryInterface(__uuidof(IDebugControl),
                                           (void **)&g_ExtControl)) != S_OK)
      {
          goto Fail;
      }
      if ((Status = Client->QueryInterface(__uuidof(IDebugDataSpaces),
                                           (void **)&g_ExtData)) != S_OK)
      {
          goto Fail;
      }
      if ((Status = Client->QueryInterface(__uuidof(IDebugRegisters),
                                           (void **)&g_ExtRegisters)) != S_OK)
      {
          goto Fail;
      }
      if ((Status = Client->QueryInterface(__uuidof(IDebugSymbols),
                                           (void **)&g_ExtSymbols)) != S_OK)
      {
          goto Fail;
      }
      if ((Status = Client->QueryInterface(__uuidof(IDebugSystemObjects),
                                           (void **)&g_ExtSystem)) != S_OK)
      {
          goto Fail;
      }
  
      g_ExtClient = Client;
      
      return S_OK;
  
   Fail:
      ExtRelease();
      return Status;
  }
  
  // Cleans up all debugger interfaces.
  void
  ExtRelease(void)
  {
      g_ExtClient = NULL;
      EXT_RELEASE(g_ExtAdvanced);
      EXT_RELEASE(g_ExtControl);
      EXT_RELEASE(g_ExtData);
      EXT_RELEASE(g_ExtRegisters);
      EXT_RELEASE(g_ExtSymbols);
      EXT_RELEASE(g_ExtSystem);
  }
  
  // Normal output.
  void __cdecl
  ExtOut(PCSTR Format, ...)
  {
      va_list Args;
      
      va_start(Args, Format);
      g_ExtControl->OutputVaList(DEBUG_OUTPUT_NORMAL, Format, Args);
      va_end(Args);
  }
  
  // Error output.
  void __cdecl
  ExtErr(PCSTR Format, ...)
  {
      va_list Args;
      
      va_start(Args, Format);
      g_ExtControl->OutputVaList(DEBUG_OUTPUT_ERROR, Format, Args);
      va_end(Args);
  }
  
  // Warning output.
  void __cdecl
  ExtWarn(PCSTR Format, ...)
  {
      va_list Args;
      
      va_start(Args, Format);
      g_ExtControl->OutputVaList(DEBUG_OUTPUT_WARNING, Format, Args);
      va_end(Args);
  }
  
  // Verbose output.
  void __cdecl
  ExtVerb(PCSTR Format, ...)
  {
      va_list Args;
      
      va_start(Args, Format);
      g_ExtControl->OutputVaList(DEBUG_OUTPUT_VERBOSE, Format, Args);
      va_end(Args);
  }
  