api: fix up console writing for debug
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
378e8eec27
commit
8edd627f4d
@ -30,18 +30,18 @@ WriteFormatted(_In_ DWORD StdHandle, _In_z_ const WCHAR *Template, ...)
|
|||||||
DWORD SizeWritten;
|
DWORD SizeWritten;
|
||||||
va_list Arguments;
|
va_list Arguments;
|
||||||
va_start(Arguments, Template);
|
va_start(Arguments, Template);
|
||||||
DWORD Len = sizeof(WCHAR) * FormatMessageW(
|
DWORD Len = FormatMessageW(
|
||||||
FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ALLOCATE_BUFFER,
|
FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ALLOCATE_BUFFER,
|
||||||
Template,
|
Template,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
(void *)&FormattedMessage,
|
(void *)&FormattedMessage,
|
||||||
0,
|
0,
|
||||||
&Arguments);
|
&Arguments);
|
||||||
if (WriteToConsole)
|
if (WriteToConsole)
|
||||||
WriteConsoleW(GetStdHandle(StdHandle), FormattedMessage, Len, &SizeWritten, NULL);
|
WriteConsoleW(GetStdHandle(StdHandle), FormattedMessage, Len, &SizeWritten, NULL);
|
||||||
else
|
else
|
||||||
WriteFile(GetStdHandle(StdHandle), FormattedMessage, Len, &SizeWritten, NULL);
|
WriteFile(GetStdHandle(StdHandle), FormattedMessage, Len * sizeof(WCHAR), &SizeWritten, NULL);
|
||||||
LocalFree(FormattedMessage);
|
LocalFree(FormattedMessage);
|
||||||
va_end(Arguments);
|
va_end(Arguments);
|
||||||
return SizeWritten / sizeof(WCHAR);
|
return SizeWritten / sizeof(WCHAR);
|
||||||
@ -157,12 +157,7 @@ VOID __stdcall DoThingsForDebugging(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLin
|
|||||||
AllocConsole();
|
AllocConsole();
|
||||||
WriteToConsole = TRUE;
|
WriteToConsole = TRUE;
|
||||||
Init();
|
Init();
|
||||||
GUID TestGuid = {
|
GUID TestGuid = { 0xdeadbabe, 0xcafe, 0xbeef, { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef } };
|
||||||
0xdeadbabe,
|
|
||||||
0xcafe,
|
|
||||||
0xbeef,
|
|
||||||
{ 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef }
|
|
||||||
};
|
|
||||||
WINTUN_ADAPTER *Adapter;
|
WINTUN_ADAPTER *Adapter;
|
||||||
BOOL RebootRequired;
|
BOOL RebootRequired;
|
||||||
assert(WintunCreateAdapter(L"Wintun", L"Test", &TestGuid, &Adapter, &RebootRequired) == ERROR_SUCCESS);
|
assert(WintunCreateAdapter(L"Wintun", L"Test", &TestGuid, &Adapter, &RebootRequired) == ERROR_SUCCESS);
|
||||||
|
Loading…
Reference in New Issue
Block a user