dll: FspDebugLogSD

This commit is contained in:
Bill Zissimopoulos 2016-01-15 15:05:19 -08:00
parent 73ca6b30dc
commit 5a1384462b
3 changed files with 23 additions and 0 deletions

View File

@ -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
}

View File

@ -5,6 +5,7 @@
*/
#include <dll/library.h>
#include <sddl.h>
#include <stdarg.h>
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");
}

View File

@ -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)