2 * TAP-Win32/TAP-Win64 -- A kernel driver to provide virtual tap
3 * device functionality on Windows.
5 * This code was inspired by the CIPE-Win32 driver by Damion K. Wilson.
7 * This source code is Copyright (C) 2002-2009 OpenVPN Technologies, Inc.,
8 * and is released under the GPL version 2 (see below), however due
9 * to the extra costs of supporting Windows Vista, OpenVPN Solutions
10 * LLC reserves the right to change the terms of the TAP-Win32/TAP-Win64
11 * license for versions 9.1 and higher prior to the official release of
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License version 2
16 * as published by the Free Software Foundation.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program (see the file COPYING included with this
25 * distribution); if not, write to the Free Software Foundation, Inc.,
26 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #ifndef TAP_PROTOTYPES_DEFINED
30 #define TAP_PROTOTYPES_DEFINED
34 IN PDRIVER_OBJECT p_DriverObject
,
35 IN PUNICODE_STRING p_RegistryPath
40 IN PDRIVER_OBJECT p_DriverObject
43 NDIS_STATUS AdapterCreate
45 OUT PNDIS_STATUS p_ErrorStatus
,
46 OUT PUINT p_MediaIndex
,
47 IN PNDIS_MEDIUM p_Media
,
49 IN NDIS_HANDLE p_AdapterHandle
,
50 IN NDIS_HANDLE p_ConfigurationHandle
55 IN NDIS_HANDLE p_AdapterContext
58 VOID AdapterFreeResources
60 TapAdapterPointer p_Adapter
63 NDIS_STATUS AdapterReset
65 OUT PBOOLEAN p_AddressingReset
,
66 IN NDIS_HANDLE p_AdapterContext
69 NDIS_STATUS AdapterQuery
71 IN NDIS_HANDLE p_AdapterContext
,
74 IN ULONG p_BufferLength
,
75 OUT PULONG p_BytesWritten
,
76 OUT PULONG p_BytesNeeded
79 NDIS_STATUS AdapterModify
81 IN NDIS_HANDLE p_AdapterContext
,
84 IN ULONG p_BufferLength
,
85 OUT PULONG p_BytesRead
,
86 OUT PULONG p_BytesNeeded
89 NDIS_STATUS AdapterTransmit
91 IN NDIS_HANDLE p_AdapterContext
,
92 IN PNDIS_PACKET p_Packet
,
96 NDIS_STATUS AdapterReceive
98 OUT PNDIS_PACKET p_Packet
,
99 OUT PUINT p_Transferred
,
100 IN NDIS_HANDLE p_AdapterContext
,
101 IN NDIS_HANDLE p_ReceiveContext
,
106 NTSTATUS TapDeviceHook
108 IN PDEVICE_OBJECT p_DeviceObject
,
112 NDIS_STATUS CreateTapDevice
114 TapExtensionPointer p_Extension
,
118 VOID DestroyTapDevice
120 TapExtensionPointer p_Extension
123 VOID TapDeviceFreeResources
125 TapExtensionPointer p_Extension
131 IN TapPacketPointer p_PacketBuffer
,
132 IN CCHAR PriorityBoost
135 VOID CancelIRPCallback
137 IN PDEVICE_OBJECT p_DeviceObject
,
143 TapExtensionPointer p_Extension
,
150 TapExtensionPointer p_Extension
153 VOID ResetTapAdapterState
155 TapAdapterPointer p_Adapter
160 TapAdapterPointer p_Adapter
,
161 const PARP_PACKET src
,
162 const IPADDR adapter_ip
,
163 const IPADDR ip_network
,
164 const IPADDR ip_netmask
,
170 TapAdapterPointer p_Adapter
,
174 VOID InjectPacketDeferred
176 TapAdapterPointer p_Adapter
,
178 const unsigned int len
183 TapAdapterPointer p_Adapter
,
185 const unsigned int len
188 // for KDEFERRED_ROUTINE and Static Driver Verifier
190 //KDEFERRED_ROUTINE InjectPacketDpc;
195 PVOID DeferredContext
,
196 PVOID SystemArgument1
,
197 PVOID SystemArgument2
200 VOID CheckIfDhcpAndTunMode
202 TapAdapterPointer p_Adapter
205 VOID
HookDispatchFunctions();
209 #if DDKVER_MAJOR < 5600
211 * Better solution for use on Vista DDK, but possibly not compatible with
214 * Eliminate the definition of SECURITY_DESCRIPTOR (and even ZwSetSecurityObject),
215 * and at the top of tapdrv.c change:
218 * #include <ntstrsafe.h>
225 * #include <ntstrsafe.h>
227 typedef struct _SECURITY_DESCRIPTOR
{
228 unsigned char opaque
[64];
229 } SECURITY_DESCRIPTOR
;
234 ZwSetSecurityObject (
236 IN SECURITY_INFORMATION SecurityInformation
,
237 IN PSECURITY_DESCRIPTOR SecurityDescriptor
);
241 VOID
AllowNonAdmin (TapExtensionPointer p_Extension
);
245 struct WIN2K_NDIS_MINIPORT_BLOCK
247 unsigned char opaque
[16];
248 UNICODE_STRING MiniportName
; // how mini-port refers to us
251 #if PACKET_TRUNCATION_CHECK
253 VOID IPv4PacketSizeVerify