diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-11-02 22:09:52 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-11-02 23:42:43 +0100 |
commit | 9a937c7a49ced541f805e8443c993b6de89324ac (patch) | |
tree | f5543e08c2dcb36bf53604398207a31a10f260e4 /api/rundll32.c | |
parent | api: free beginning of heap object (diff) | |
download | wintun-9a937c7a49ced541f805e8443c993b6de89324ac.tar.xz wintun-9a937c7a49ced541f805e8443c993b6de89324ac.zip |
example: rewrite and replace api's debug rundll32 functionality
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'api/rundll32.c')
-rw-r--r-- | api/rundll32.c | 38 |
1 files changed, 1 insertions, 37 deletions
diff --git a/api/rundll32.c b/api/rundll32.c index 05a8323..85121a5 100644 --- a/api/rundll32.c +++ b/api/rundll32.c @@ -5,7 +5,6 @@ #include "adapter.h" #include "logger.h" -#include "session.h" #include "wintun.h" #include <Windows.h> @@ -17,12 +16,6 @@ #if defined(ACCEPT_WOW64) || defined(_DEBUG) -static -#ifndef _DEBUG -const -#endif -BOOL WriteToConsole = FALSE; - static DWORD WriteFormatted(_In_ DWORD StdHandle, _In_z_ const WCHAR *Template, ...) { @@ -38,10 +31,7 @@ WriteFormatted(_In_ DWORD StdHandle, _In_z_ const WCHAR *Template, ...) (void *)&FormattedMessage, 0, &Arguments); - if (WriteToConsole) - WriteConsoleW(GetStdHandle(StdHandle), FormattedMessage, Len, &SizeWritten, NULL); - else - WriteFile(GetStdHandle(StdHandle), FormattedMessage, Len * sizeof(WCHAR), &SizeWritten, NULL); + WriteFile(GetStdHandle(StdHandle), FormattedMessage, Len * sizeof(WCHAR), &SizeWritten, NULL); LocalFree(FormattedMessage); va_end(Arguments); return SizeWritten / sizeof(WCHAR); @@ -158,30 +148,4 @@ VOID __stdcall DeleteDriver(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int n Done(); } -#ifdef _DEBUG -VOID __stdcall DoThingsForDebugging(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow) -{ -# pragma EXPORT - UNREFERENCED_PARAMETER(hwnd); - UNREFERENCED_PARAMETER(hinst); - UNREFERENCED_PARAMETER(lpszCmdLine); - UNREFERENCED_PARAMETER(nCmdShow); - - AllocConsole(); - WriteToConsole = TRUE; - Init(); - 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); - assert(!RebootRequired); - TUN_SESSION *Session; - assert(WintunStartSession(Adapter, WINTUN_MIN_RING_CAPACITY, &Session) == ERROR_SUCCESS); - WintunEndSession(Session); - assert(WintunDeleteAdapter(Adapter, TRUE, &RebootRequired) == ERROR_SUCCESS); - assert(!RebootRequired); - system("pause"); -} -#endif - #endif |