win-pvdrivers

changeset 706:d6f6830dc60d 0.10.0.142

Fixed DbgPrint hooking for Vista and newer
author James Harper <james.harper@bendigoit.com.au>
date Tue Dec 08 21:19:20 2009 +1100 (2009-12-08)
parents b620a1b82e0b
children 206cef08872a
files common/include/xen_windows.h xenpci/xenpci_dbgprint.c
line diff
     1.1 --- a/common/include/xen_windows.h	Tue Dec 08 21:08:12 2009 +1100
     1.2 +++ b/common/include/xen_windows.h	Tue Dec 08 21:19:20 2009 +1100
     1.3 @@ -211,7 +211,7 @@ the wrong width is used with the wrong d
     1.4  static BOOLEAN debug_port_probed = FALSE;
     1.5  static BOOLEAN debug_port_enabled;
     1.6  
     1.7 -static void XenDbgPrint(PCHAR format, ...)
     1.8 +static void XenDbgPrintOld(PCHAR format, ...)
     1.9  {
    1.10    CHAR buf[512];
    1.11    va_list ap;
    1.12 @@ -253,7 +253,7 @@ static void XenDbgPrint(PCHAR format, ..
    1.13  static VOID
    1.14  XenRtlAssert(PCHAR expr, PCHAR filename, ULONG line_number)
    1.15  {
    1.16 -  XenDbgPrint("Failed ASSERTion '%s' at %s:%d\n", expr, filename, line_number);
    1.17 +  XenDbgPrintOld("Failed ASSERTion '%s' at %s:%d\n", expr, filename, line_number);
    1.18    RtlAssert(expr, filename, line_number, NULL);
    1.19  }
    1.20  
    1.21 @@ -262,7 +262,7 @@ XenRtlAssert(PCHAR expr, PCHAR filename,
    1.22  #ifdef KdPrint
    1.23    #undef KdPrint
    1.24  #endif
    1.25 -#define KdPrint(_x_) XenDbgPrint _x_
    1.26 +#define KdPrint(_x_) XenDbgPrintOld _x_
    1.27  #endif
    1.28  
    1.29  #ifdef ASSERT
    1.30 @@ -270,16 +270,16 @@ XenRtlAssert(PCHAR expr, PCHAR filename,
    1.31  #endif
    1.32  #define ASSERT( exp ) ((!(exp)) ? (XenRtlAssert( #exp, __FILE__, __LINE__), FALSE) : TRUE)
    1.33  
    1.34 -#define FUNCTION_ENTER()       XenDbgPrint(__DRIVER_NAME " --> %s\n", __FUNCTION__)
    1.35 -#define FUNCTION_EXIT()        XenDbgPrint(__DRIVER_NAME " <-- %s\n", __FUNCTION__)
    1.36 -#define FUNCTION_EXIT_STATUS(_status) XenDbgPrint(__DRIVER_NAME " <-- %s, status = %08x\n", __FUNCTION__, _status)
    1.37 -#define FUNCTION_ERROR_EXIT()  XenDbgPrint(__DRIVER_NAME " <-- %s (error path)\n", __FUNCTION__)
    1.38 -#define FUNCTION_CALLED()      XenDbgPrint(__DRIVER_NAME " %s called (line %d)\n", __FUNCTION__, __LINE__)
    1.39 +#define FUNCTION_ENTER()       XenDbgPrintOld(__DRIVER_NAME " --> %s\n", __FUNCTION__)
    1.40 +#define FUNCTION_EXIT()        XenDbgPrintOld(__DRIVER_NAME " <-- %s\n", __FUNCTION__)
    1.41 +#define FUNCTION_EXIT_STATUS(_status) XenDbgPrintOld(__DRIVER_NAME " <-- %s, status = %08x\n", __FUNCTION__, _status)
    1.42 +#define FUNCTION_ERROR_EXIT()  XenDbgPrintOld(__DRIVER_NAME " <-- %s (error path)\n", __FUNCTION__)
    1.43 +#define FUNCTION_CALLED()      XenDbgPrintOld(__DRIVER_NAME " %s called (line %d)\n", __FUNCTION__, __LINE__)
    1.44  #ifdef __MINGW32__
    1.45  #define FUNCTION_MSG(_x) _FUNCTION_MSG _x
    1.46 -#define _FUNCTION_MSG(format, args...) XenDbgPrint(__DRIVER_NAME " %s called: " format, __FUNCTION__, ##args)
    1.47 +#define _FUNCTION_MSG(format, args...) XenDbgPrintOld(__DRIVER_NAME " %s called: " format, __FUNCTION__, ##args)
    1.48  #else
    1.49 -#define FUNCTION_MSG(format, ...) XenDbgPrint(__DRIVER_NAME "     " format, __VA_ARGS__)
    1.50 +#define FUNCTION_MSG(format, ...) XenDbgPrintOld(__DRIVER_NAME "     " format, __VA_ARGS__)
    1.51  #endif
    1.52  
    1.53  #else
     2.1 --- a/xenpci/xenpci_dbgprint.c	Tue Dec 08 21:08:12 2009 +1100
     2.2 +++ b/xenpci/xenpci_dbgprint.c	Tue Dec 08 21:19:20 2009 +1100
     2.3 @@ -143,7 +143,13 @@ XenPci_HookDbgPrint()
     2.4      //DbgSetDebugPrintCallback = (PDBG_SET_DEBUGPRINT_CALLBACK)MmGetSystemRoutineAddress((PUNICODE_STRING)&DbgSetDebugPrintCallbackName);
     2.5  #if (NTDDI_VERSION >= NTDDI_VISTA)
     2.6      KdPrint((__DRIVER_NAME "     DbgSetDebugPrintCallback found\n"));
     2.7 -    DbgSetDebugPrintCallback(XenPci_DbgPrintCallback, TRUE);
     2.8 +    status = DbgSetDebugPrintCallback(XenPci_DbgPrintCallback, TRUE);
     2.9 +    if (!NT_SUCCESS(status))
    2.10 +    {
    2.11 +      KdPrint((__DRIVER_NAME "     DbgSetDebugPrintCallback failed - %08x\n", status));
    2.12 +    }
    2.13 +    //DbgSetDebugFilterState(componentid, level, state);
    2.14 +    DbgSetDebugFilterState(DPFLTR_DEFAULT_ID, 0xFFFFFFFF, TRUE);
    2.15  #else
    2.16      KdPrint((__DRIVER_NAME "     DbgSetDebugPrintCallback not found\n"));      
    2.17  #ifndef _AMD64_ // can't patch IDT on AMD64 unfortunately - results in bug check 0x109