diff --git a/inc/winfsp/winfsp.h b/inc/winfsp/winfsp.h index e34e653d..8410e5af 100644 --- a/inc/winfsp/winfsp.h +++ b/inc/winfsp/winfsp.h @@ -205,6 +205,7 @@ FSP_API VOID FspPathCombine(PWSTR Prefix, PWSTR Suffix); */ FSP_API NTSTATUS FspNtStatusFromWin32(DWORD Error); FSP_API VOID FspDebugLog(const char *format, ...); +FSP_API VOID FspDebugLogSD(const char *format, PSECURITY_DESCRIPTOR SecurityDescriptor); #ifdef __cplusplus } diff --git a/src/dll/debug.c b/src/dll/debug.c index 7b389e9c..ed4a2d1b 100644 --- a/src/dll/debug.c +++ b/src/dll/debug.c @@ -5,6 +5,7 @@ */ #include +#include #include FSP_API VOID FspDebugLog(const char *format, ...) @@ -18,3 +19,21 @@ FSP_API VOID FspDebugLog(const char *format, ...) buf[sizeof buf - 1] = '\0'; OutputDebugStringA(buf); } + +FSP_API VOID FspDebugLogSD(const char *format, PSECURITY_DESCRIPTOR SecurityDescriptor) +{ + char *Sddl; + + if (0 == SecurityDescriptor) + FspDebugLog(format, "null security descriptor"); + else if (ConvertSecurityDescriptorToStringSecurityDescriptorA(SecurityDescriptor, SDDL_REVISION_1, + OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | + DACL_SECURITY_INFORMATION | SACL_SECURITY_INFORMATION, + &Sddl, 0)) + { + FspDebugLog(format, Sddl); + LocalFree(Sddl); + } + else + FspDebugLog(format, "invalid security descriptor"); +} diff --git a/src/dll/library.h b/src/dll/library.h index 9b102f7b..4ee72dea 100644 --- a/src/dll/library.h +++ b/src/dll/library.h @@ -18,8 +18,11 @@ #if !defined(NDEBUG) #define DEBUGLOG(fmt, ...) \ FspDebugLog("[U] " LIBRARY_NAME "!" __FUNCTION__ ": " fmt "\n", __VA_ARGS__) +#define DEBUGLOGSD(fmt, SD) \ + FspDebugLogSD("[U] " LIBRARY_NAME "!" __FUNCTION__ ": " fmt "\n", SD) #else #define DEBUGLOG(fmt, ...) ((void)0) +#define DEBUGLOGSD(fmt, SD) ((void)0) #endif static inline PVOID MemAlloc(SIZE_T Size)