2014-04-06 18:31:53 +00:00
|
|
|
/* Benjamin DELPY `gentilkiwi`
|
|
|
|
http://blog.gentilkiwi.com
|
|
|
|
benjamin@gentilkiwi.com
|
2015-08-25 09:19:01 +00:00
|
|
|
Licence : https://creativecommons.org/licenses/by/4.0/
|
2014-04-06 18:31:53 +00:00
|
|
|
*/
|
|
|
|
#include "utils.h"
|
|
|
|
|
|
|
|
void klog(FILE * logfile, PCWCHAR format, ...)
|
|
|
|
{
|
|
|
|
if(logfile)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
va_start(args, format);
|
|
|
|
vfwprintf(logfile, format, args);
|
|
|
|
va_end(args);
|
|
|
|
fflush(logfile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void klog_password(FILE * logfile, PUNICODE_STRING pPassword)
|
|
|
|
{
|
|
|
|
int i = IS_TEXT_UNICODE_ODD_LENGTH | IS_TEXT_UNICODE_STATISTICS;
|
|
|
|
if(pPassword->Buffer)
|
|
|
|
{
|
|
|
|
if(IsTextUnicode(pPassword->Buffer, pPassword->Length, &i))
|
|
|
|
klog(logfile, L"%wZ", pPassword);
|
|
|
|
else
|
|
|
|
for(i = 0; i < pPassword->Length; i++)
|
|
|
|
klog(logfile, L"%02x ", ((LPCBYTE) pPassword->Buffer)[i]);
|
|
|
|
}
|
2016-08-12 21:09:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void klog_sid(FILE * logfile, PSID pSid)
|
|
|
|
{
|
|
|
|
LPWSTR stringSid;
|
|
|
|
if(pSid && ConvertSidToStringSid(pSid, &stringSid))
|
|
|
|
{
|
|
|
|
klog(logfile, L"%s", stringSid);
|
|
|
|
LocalFree(stringSid);
|
|
|
|
}
|
2014-04-06 18:31:53 +00:00
|
|
|
}
|