aboutsummaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2020-11-02 22:09:52 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2020-11-02 23:42:43 +0100
commit9a937c7a49ced541f805e8443c993b6de89324ac (patch)
treef5543e08c2dcb36bf53604398207a31a10f260e4 /api
parentapi: free beginning of heap object (diff)
downloadwintun-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')
-rw-r--r--api/api.vcxproj6
-rw-r--r--api/api.vcxproj.filters3
-rw-r--r--api/rundll32.c38
-rw-r--r--api/session.c1
-rw-r--r--api/session.h59
5 files changed, 1 insertions, 106 deletions
diff --git a/api/api.vcxproj b/api/api.vcxproj
index 327ee44..d864f0c 100644
--- a/api/api.vcxproj
+++ b/api/api.vcxproj
@@ -101,11 +101,6 @@
<RunCodeAnalysis>true</RunCodeAnalysis>
<IgnoreImportLibrary>true</IgnoreImportLibrary>
</PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration">
- <LocalDebuggerCommand>rundll32.exe</LocalDebuggerCommand>
- <LocalDebuggerCommandArguments>$(OutDir)$(TargetName)$(TargetExt),DoThingsForDebugging</LocalDebuggerCommandArguments>
- <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
- </PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions>_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@@ -171,7 +166,6 @@ lib.exe /def:nci.def /out:"$(IntDir)nci.lib" /machine:$(PlatformTarget) /nologo
<ClInclude Include="ntldr.h" />
<ClInclude Include="registry.h" />
<ClInclude Include="resource.h" />
- <ClInclude Include="session.h" />
<ClInclude Include="wintun.h" />
</ItemGroup>
<ItemGroup>
diff --git a/api/api.vcxproj.filters b/api/api.vcxproj.filters
index 7d29920..c1db346 100644
--- a/api/api.vcxproj.filters
+++ b/api/api.vcxproj.filters
@@ -58,9 +58,6 @@
<ClInclude Include="entry.h">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="session.h">
- <Filter>Header Files</Filter>
- </ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="namespace.c">
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
diff --git a/api/session.c b/api/session.c
index 9c3d682..ddfa61d 100644
--- a/api/session.c
+++ b/api/session.c
@@ -7,7 +7,6 @@
#include "elevate.h"
#include "entry.h"
#include "logger.h"
-#include "session.h"
#include "wintun.h"
#include <Windows.h>
diff --git a/api/session.h b/api/session.h
deleted file mode 100644
index 6813ef3..0000000
--- a/api/session.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0
- *
- * Copyright (C) 2018-2020 WireGuard LLC. All Rights Reserved.
- */
-
-#pragma once
-
-#include "wintun.h"
-#include <Windows.h>
-
-typedef struct _TUN_SESSION TUN_SESSION;
-
-/**
- * @copydoc WINTUN_START_SESSION_FUNC
- */
-WINTUN_STATUS WINAPI
-WintunStartSession(
- _In_ const WINTUN_ADAPTER *Adapter,
- _In_ DWORD Capacity,
- _Out_ TUN_SESSION **Session);
-
-/**
- * @copydoc WINTUN_END_SESSION_FUNC
- */
-void WINAPI
-WintunEndSession(_In_ TUN_SESSION *Session);
-
-/**
- * @copydoc WINTUN_GET_READ_WAIT_EVENT_FUNC
- */
-HANDLE WINAPI
-WintunGetReadWaitEvent(_In_ TUN_SESSION *Session);
-
-/**
- * @copydoc WINTUN_RECEIVE_PACKET_FUNC
- */
-WINTUN_STATUS WINAPI
-WintunReceivePacket(_In_ TUN_SESSION *Session, _Out_bytecapcount_(*PacketSize) BYTE **Packet, _Out_ DWORD *PacketSize);
-
-/**
- * @copydoc WINTUN_RECEIVE_RELEASE_FUNC
- */
-void WINAPI
-WintunReceiveRelease(_In_ TUN_SESSION *Session, _In_ const BYTE *Packet);
-
-/**
- * @copydoc WINTUN_ALLOCATE_SEND_PACKET
- */
-WINTUN_STATUS WINAPI
-WintunAllocateSendPacket(
- _In_ TUN_SESSION *Session,
- _In_ DWORD PacketSize,
- _Out_bytecapcount_(PacketSize) BYTE **Packet);
-
-/**
- * @copydoc WINTUN_SEND_PACKET
- */
-void WINAPI
-WintunSendPacket(_In_ TUN_SESSION *Session, _In_ const BYTE *Packet);