[PCIIDEX] Implement missing PciIdeXDebugPrint function (#3146)

It's useful for debugging IDE controller minidrivers, and it makes pciidex.sys work on Windows XP/2003.
- https://user-images.githubusercontent.com/37072976/92856412-39d56b80-f415-11ea-880f-48998c11112d.png

CORE-17256
This commit is contained in:
Dmitry Borisov 2020-09-15 18:10:52 +06:00 committed by GitHub
parent 345ad55319
commit 0f8de896aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 2 deletions

View file

@ -11,6 +11,9 @@
#define NDEBUG
#include <debug.h>
/** @brief Global debugging level. Valid values are between 0 (Error) and 3 (Trace). */
ULONG PciIdeDebug = 0;
static DRIVER_DISPATCH PciIdeXForwardOrIgnore;
static NTSTATUS NTAPI
PciIdeXForwardOrIgnore(
@ -90,6 +93,32 @@ PciIdeXPnpDispatch(
return PciIdeXPdoPnpDispatch(DeviceObject, Irp);
}
/**
* @brief Prints the given string with printf-like formatting to the kernel debugger.
* @param[in] DebugPrintLevel Level of the debug message.
* Valid values are between 0 (Error) and 3 (Trace).
* @param[in] DebugMessage Format of the string/arguments.
* @param[in] ... Variable number of arguments matching the format
* specified in \a DebugMessage.
* @sa PciIdeDebug
*/
VOID
PciIdeXDebugPrint(
_In_ ULONG DebugPrintLevel,
_In_z_ _Printf_format_string_ PCCHAR DebugMessage,
...)
{
va_list ap;
/* Check if we can print anything */
if (DebugPrintLevel <= PciIdeDebug)
DebugPrintLevel = 0;
va_start(ap, DebugMessage);
vDbgPrintEx(DPFLTR_PCIIDE_ID, DebugPrintLevel, DebugMessage, ap);
va_end(ap);
}
NTSTATUS NTAPI
PciIdeXInitialize(
IN PDRIVER_OBJECT DriverObject,

View file

@ -1,3 +1,4 @@
@ varargs PciIdeXDebugPrint(long str)
@ stdcall PciIdeXGetBusData(ptr ptr long long)
@ stdcall PciIdeXInitialize(ptr ptr ptr long)
@ stdcall PciIdeXSetBusData(ptr ptr ptr long long)

View file

@ -478,8 +478,8 @@ typedef struct _PCIIDE_CONFIG_HEADER {
VOID
PciIdeXDebugPrint(
ULONG DebugPrintLevel,
PCCHAR DebugMessage,
_In_ ULONG DebugPrintLevel,
_In_z_ _Printf_format_string_ PCCHAR DebugMessage,
...
);