dll: FspDebugLog

sys: DEBUGLOG
This commit is contained in:
Bill Zissimopoulos
2015-11-30 21:00:06 -08:00
parent f149301125
commit 7f182ac04d
8 changed files with 87 additions and 28 deletions

20
src/dll/debug.c Normal file
View File

@ -0,0 +1,20 @@
/**
* @file dll/debug.c
*
* @copyright 2015 Bill Zissimopoulos
*/
#include <dll/library.h>
#include <stdarg.h>
#if !defined(NDEBUG)
VOID FspDebugLog(const char *format, ...)
{
char buf[512];
va_list ap;
va_start(ap, format);
StringCbVPrintfA(buf, sizeof buf, format, ap);
va_end(ap);
OutputDebugStringA(buf);
}
#endif

View File

@ -4,9 +4,7 @@
* @copyright 2015 Bill Zissimopoulos
*/
#include <winfsp/winfsp.h>
#include <winfsp/fsctl.h>
#include <strsafe.h>
#include <dll/library.h>
#if !defined(NDEBUG)
#include <sddl.h>
#endif
@ -67,18 +65,6 @@ FSP_API NTSTATUS FspFsctlCreateVolume(PWSTR DevicePath,
Token = 0;
}
#if !defined(NDEBUG)
{
PWSTR Sddl;
if (ConvertSecurityDescriptorToStringSecurityDescriptorW(SecurityDescriptor,
SDDL_REVISION_1, DACL_SECURITY_INFORMATION, &Sddl, 0))
{
OutputDebugStringW(Sddl);
LocalFree(Sddl);
}
}
#endif
SecurityDescriptorSize = 0;
if (!MakeSelfRelativeSD(SecurityDescriptor, 0, &SecurityDescriptorSize) &&
ERROR_INSUFFICIENT_BUFFER != GetLastError())
@ -102,6 +88,20 @@ FSP_API NTSTATUS FspFsctlCreateVolume(PWSTR DevicePath,
*ParamsBuf = *Params;
GlobalDevicePath(DevicePathBuf, sizeof DevicePathBuf, DevicePath);
#if !defined(NDEBUG)
{
PSTR Sddl;
if (ConvertSecurityDescriptorToStringSecurityDescriptorA(SecurityDescriptorBuf,
SDDL_REVISION_1, DACL_SECURITY_INFORMATION, &Sddl, 0))
{
DEBUGLOG("Device=\"%S\", Sddl=\"%s\", SdSize=%lu",
DevicePathBuf, Sddl, SecurityDescriptorSize);
LocalFree(Sddl);
}
}
#endif
DeviceHandle = CreateFileW(DevicePathBuf,
0, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0);
if (INVALID_HANDLE_VALUE == DeviceHandle)

30
src/dll/library.h Normal file
View File

@ -0,0 +1,30 @@
/**
* @file dll/library.h
*
* @copyright 2015 Bill Zissimopoulos
*/
#ifndef WINFSP_DLL_LIBRARY_H_INCLUDED
#define WINFSP_DLL_LIBRARY_H_INCLUDED
#define WINFSP_DLL_INTERNAL
#include <winfsp/winfsp.h>
#include <winfsp/fsctl.h>
#include <strsafe.h>
#define LIBRARY_NAME "WinFsp"
/* DEBUGLOG */
#if !defined(NDEBUG)
#define DEBUGLOG(fmt, ...) \
FspDebugLog("[U] " LIBRARY_NAME "!" __FUNCTION__ ": " fmt "\n", __VA_ARGS__)
#else
#define DEBUGLOG(fmt, ...) ((void)0)
#endif
/* debug */
#if !defined(NDEBUG)
VOID FspDebugLog(const char *format, ...);
#endif
#endif

View File

@ -4,7 +4,7 @@
* @copyright 2015 Bill Zissimopoulos
*/
#include <winfsp/winfsp.h>
#include <dll/library.h>
NTSTATUS FspNtStatusFromWin32(DWORD Error)
{