From f8cebd1f923123c3a892f12188a16d810d606fe6 Mon Sep 17 00:00:00 2001 From: Bill Zissimopoulos Date: Sat, 8 Oct 2016 18:49:28 -0700 Subject: [PATCH] dll: FspDebugLogSetHandle --- inc/winfsp/winfsp.h | 7 ++++--- src/dll/debug.c | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/inc/winfsp/winfsp.h b/inc/winfsp/winfsp.h index 1f94591e..3b74e1df 100644 --- a/inc/winfsp/winfsp.h +++ b/inc/winfsp/winfsp.h @@ -1469,9 +1469,10 @@ FSP_API NTSTATUS FspNtStatusFromWin32(DWORD Error); FSP_API DWORD FspWin32FromNtStatus(NTSTATUS Status); FSP_API VOID FspEventLog(ULONG Type, PWSTR Format, ...); FSP_API VOID FspEventLogV(ULONG Type, PWSTR Format, va_list ap); -FSP_API VOID FspDebugLog(const char *format, ...); -FSP_API VOID FspDebugLogSD(const char *format, PSECURITY_DESCRIPTOR SecurityDescriptor); -FSP_API VOID FspDebugLogFT(const char *format, PFILETIME FileTime); +FSP_API VOID FspDebugLogSetHandle(HANDLE Handle); +FSP_API VOID FspDebugLog(const char *Format, ...); +FSP_API VOID FspDebugLogSD(const char *Format, PSECURITY_DESCRIPTOR SecurityDescriptor); +FSP_API VOID FspDebugLogFT(const char *Format, PFILETIME FileTime); FSP_API VOID FspDebugLogRequest(FSP_FSCTL_TRANSACT_REQ *Request); FSP_API VOID FspDebugLogResponse(FSP_FSCTL_TRANSACT_RSP *Response); FSP_API NTSTATUS FspCallNamedPipeSecurely(PWSTR PipeName, diff --git a/src/dll/debug.c b/src/dll/debug.c index 93fa2914..9afba71c 100644 --- a/src/dll/debug.c +++ b/src/dll/debug.c @@ -19,6 +19,13 @@ #include #include +static HANDLE FspDebugLogHandle = INVALID_HANDLE_VALUE; + +FSP_API VOID FspDebugLogSetHandle(HANDLE Handle) +{ + FspDebugLogHandle = Handle; +} + FSP_API VOID FspDebugLog(const char *format, ...) { char buf[1024]; @@ -28,7 +35,13 @@ FSP_API VOID FspDebugLog(const char *format, ...) wvsprintfA(buf, format, ap); va_end(ap); buf[sizeof buf - 1] = '\0'; - OutputDebugStringA(buf); + if (INVALID_HANDLE_VALUE != FspDebugLogHandle) + { + DWORD bytes; + WriteFile(FspDebugLogHandle, buf, lstrlenA(buf), &bytes, 0); + } + else + OutputDebugStringA(buf); } FSP_API VOID FspDebugLogSD(const char *format, PSECURITY_DESCRIPTOR SecurityDescriptor)