Init commit
This commit is contained in:
+55
@@ -0,0 +1,55 @@
|
||||
#include "Common.h"
|
||||
#include "Logger.h"
|
||||
|
||||
#if ARDRV_LOG_ENABLED
|
||||
|
||||
#define ARDRV_LOG_FILE L"C:\\Users\\Public\\ardrv_loader.log"
|
||||
|
||||
void LogImpl(const wchar_t* fmt, ...)
|
||||
{
|
||||
wchar_t buf[8192];
|
||||
buf[0] = L'\0';
|
||||
|
||||
va_list args;
|
||||
|
||||
va_start(args, fmt);
|
||||
int n = _vscwprintf(fmt, args);
|
||||
va_end(args);
|
||||
|
||||
if (n < 0)
|
||||
n = 0;
|
||||
|
||||
if (n > (int)_countof(buf) - 3)
|
||||
n = (int)_countof(buf) - 3;
|
||||
|
||||
va_start(args, fmt);
|
||||
_vsnwprintf_s(buf, (size_t)(_countof(buf) - 1), (size_t)n, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
buf[n] = L'\r';
|
||||
buf[n + 1] = L'\n';
|
||||
buf[n + 2] = L'\0';
|
||||
|
||||
HANDLE hFile = CreateFileW(
|
||||
ARDRV_LOG_FILE,
|
||||
GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
nullptr,
|
||||
OPEN_ALWAYS,
|
||||
0,
|
||||
nullptr);
|
||||
|
||||
if (hFile != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
LARGE_INTEGER zero{};
|
||||
SetFilePointerEx(hFile, zero, nullptr, FILE_END);
|
||||
|
||||
DWORD written = 0;
|
||||
WriteFile(hFile, buf, (DWORD)((n + 2) * sizeof(WCHAR)), &written, nullptr);
|
||||
CloseHandle(hFile);
|
||||
}
|
||||
|
||||
OutputDebugStringW(buf);
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user