aboutsummaryrefslogtreecommitdiffstats
path: root/api/rundll32.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2020-10-31 16:02:34 +0100
committerSimon Rozman <simon@rozman.si>2020-10-31 19:11:57 +0100
commit8edd627f4db9db0fe0e1961c52973a8467aa0412 (patch)
treee4e9fdca2af592f5f0ce32aac1939d1f8abae812 /api/rundll32.c
parentapi: clear up argument evaluation order (diff)
downloadwintun-8edd627f4db9db0fe0e1961c52973a8467aa0412.tar.xz
wintun-8edd627f4db9db0fe0e1961c52973a8467aa0412.zip
api: fix up console writing for debug
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'api/rundll32.c')
-rw-r--r--api/rundll32.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/api/rundll32.c b/api/rundll32.c
index dce1bd6..1fa0bb1 100644
--- a/api/rundll32.c
+++ b/api/rundll32.c
@@ -30,18 +30,18 @@ WriteFormatted(_In_ DWORD StdHandle, _In_z_ const WCHAR *Template, ...)
DWORD SizeWritten;
va_list Arguments;
va_start(Arguments, Template);
- DWORD Len = sizeof(WCHAR) * FormatMessageW(
- FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ALLOCATE_BUFFER,
- Template,
- 0,
- 0,
- (void *)&FormattedMessage,
- 0,
- &Arguments);
+ DWORD Len = FormatMessageW(
+ FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ALLOCATE_BUFFER,
+ Template,
+ 0,
+ 0,
+ (void *)&FormattedMessage,
+ 0,
+ &Arguments);
if (WriteToConsole)
WriteConsoleW(GetStdHandle(StdHandle), FormattedMessage, Len, &SizeWritten, NULL);
else
- WriteFile(GetStdHandle(StdHandle), FormattedMessage, Len, &SizeWritten, NULL);
+ WriteFile(GetStdHandle(StdHandle), FormattedMessage, Len * sizeof(WCHAR), &SizeWritten, NULL);
LocalFree(FormattedMessage);
va_end(Arguments);
return SizeWritten / sizeof(WCHAR);
@@ -157,12 +157,7 @@ VOID __stdcall DoThingsForDebugging(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLin
AllocConsole();
WriteToConsole = TRUE;
Init();
- GUID TestGuid = {
- 0xdeadbabe,
- 0xcafe,
- 0xbeef,
- { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef }
- };
+ GUID TestGuid = { 0xdeadbabe, 0xcafe, 0xbeef, { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef } };
WINTUN_ADAPTER *Adapter;
BOOL RebootRequired;
assert(WintunCreateAdapter(L"Wintun", L"Test", &TestGuid, &Adapter, &RebootRequired) == ERROR_SUCCESS);