1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2025-09-19 17:59:19 +03:00

v4.03-9408-rtm

This commit is contained in:
dnobori
2014-01-04 22:00:08 +09:00
parent d433e567a5
commit 749497dde0
986 changed files with 487216 additions and 339 deletions

2104
src/SeLow/SeLow.c Normal file

File diff suppressed because it is too large Load Diff

361
src/SeLow/SeLow.h Normal file
View File

@ -0,0 +1,361 @@
// SoftEther VPN Source Code
// SeLow - SoftEther Lightweight Network Protocol
//
// SoftEther VPN Server, Client and Bridge are free software under GPLv2.
//
// Copyright (c) 2012-2014 Daiyuu Nobori.
// Copyright (c) 2012-2014 SoftEther VPN Project, University of Tsukuba, Japan.
// Copyright (c) 2012-2014 SoftEther Corporation.
//
// All Rights Reserved.
//
// http://www.softether.org/
//
// Author: Daiyuu Nobori
// Comments: Tetsuo Sugiyama, Ph.D.
//
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// version 2 as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License version 2
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// THE LICENSE AGREEMENT IS ATTACHED ON THE SOURCE-CODE PACKAGE
// AS "LICENSE.TXT" FILE. READ THE TEXT FILE IN ADVANCE TO USE THE SOFTWARE.
//
//
// THIS SOFTWARE IS DEVELOPED IN JAPAN, AND DISTRIBUTED FROM JAPAN,
// UNDER JAPANESE LAWS. YOU MUST AGREE IN ADVANCE TO USE, COPY, MODIFY,
// MERGE, PUBLISH, DISTRIBUTE, SUBLICENSE, AND/OR SELL COPIES OF THIS
// SOFTWARE, THAT ANY JURIDICAL DISPUTES WHICH ARE CONCERNED TO THIS
// SOFTWARE OR ITS CONTENTS, AGAINST US (SOFTETHER PROJECT, SOFTETHER
// CORPORATION, DAIYUU NOBORI OR OTHER SUPPLIERS), OR ANY JURIDICAL
// DISPUTES AGAINST US WHICH ARE CAUSED BY ANY KIND OF USING, COPYING,
// MODIFYING, MERGING, PUBLISHING, DISTRIBUTING, SUBLICENSING, AND/OR
// SELLING COPIES OF THIS SOFTWARE SHALL BE REGARDED AS BE CONSTRUED AND
// CONTROLLED BY JAPANESE LAWS, AND YOU MUST FURTHER CONSENT TO
// EXCLUSIVE JURISDICTION AND VENUE IN THE COURTS SITTING IN TOKYO,
// JAPAN. YOU MUST WAIVE ALL DEFENSES OF LACK OF PERSONAL JURISDICTION
// AND FORUM NON CONVENIENS. PROCESS MAY BE SERVED ON EITHER PARTY IN
// THE MANNER AUTHORIZED BY APPLICABLE LAW OR COURT RULE.
//
// USE ONLY IN JAPAN. DO NOT USE IT IN OTHER COUNTRIES. IMPORTING THIS
// SOFTWARE INTO OTHER COUNTRIES IS AT YOUR OWN RISK. SOME COUNTRIES
// PROHIBIT ENCRYPTED COMMUNICATIONS. USING THIS SOFTWARE IN OTHER
// COUNTRIES MIGHT BE RESTRICTED.
//
//
// DEAR SECURITY EXPERTS
// ---------------------
//
// If you find a bug or a security vulnerability please kindly inform us
// about the problem immediately so that we can fix the security problem
// to protect a lot of users around the world as soon as possible.
//
// Our e-mail address for security reports is:
// softether-vpn-security [at] softether.org
//
// Please note that the above e-mail address is not a technical support
// inquiry address. If you need technical assistance, please visit
// http://www.softether.org/ and ask your question on the users forum.
//
// Thank you for your cooperation.
// SeLow.h
// Header of SeLow.c
#ifndef SELOW_H
#define SELOW_H
// Win32 DDK related
#ifndef CPU_64
#define _X86_
#else // CPU_64
#ifndef NEO_IA64
#define _AMD64_
#define AMD64
#else // NEO_IA64
#define _IA64_
#define IA64
#endif // NEO_IA64
#endif // CPU_64
#define NDIS_MINIPORT_DRIVER
// NDIS 6.2
#define NDIS620_MINIPORT
#define NDIS_SUPPORT_NDIS61 1
#define NDIS_SUPPORT_NDIS620 1
#define NEO_NDIS_MAJOR_VERSION 6
#define NEO_NDIS_MINOR_VERSION 20
#define NDIS_WDM 1
#include <wdm.h>
#include <wdmsec.h>
#include <ndis.h>
#include <stdio.h>
#include <string.h>
// OS determination
#ifdef WIN32
#define OS_WIN32 // Microsoft Windows
#else
#define OS_UNIX // UNIX / Linux
#endif
// Type declaration
#ifndef WINDOWS_H_INCLUDED
#ifndef WIN9X
typedef unsigned long BOOL;
#endif // WIN9X
#define TRUE 1
#define FALSE 0
#endif
typedef unsigned long bool;
#define true 1
#define false 0
typedef unsigned long long UINT64;
typedef signed long long INT64;
typedef unsigned short WORD;
typedef unsigned short USHORT;
typedef signed short SHORT;
typedef unsigned char BYTE;
typedef unsigned char UCHAR;
typedef signed char CHAR;
typedef unsigned long DWORD;
#define INFINITE 0xFFFFFFFF
#define LESS(a, max_value) ((a) < (max_value) ? (a) : (max_value))
#define MORE(a, min_value) ((a) > (min_value) ? (a) : (min_value))
#define INNER(a, b, c) (((b) <= (c) && (a) >= (b) && (a) <= (c)) || ((b) >= (c) && (a) >= (c) && (a) <= (b)))
#define OUTER(a, b, c) (!INNER((a), (b), (c)))
#define MAKESURE(a, b, c) (((b) <= (c)) ? (MORE(LESS((a), (c)), (b))) : (MORE(LESS((a), (b)), (c))))
#define MIN(a, b) ((a) >= (b) ? (b) : (a))
#define MAX(a, b) ((a) >= (b) ? (a) : (b))
#define EQUAL_BOOL(a, b) (((a) && (b)) || ((!(a)) && (!(b))))
// Error checking macro
#define OK(val) ((val) == STATUS_SUCCESS)
#define NG(val) (!OK(val))
#define MAX_PATH 260
#define MAX_SIZE 512
#define STD_SIZE 512
#define SL_WHERE SlCrash(__LINE__, __LINE__, __LINE__, __LINE__)
#define SL_CRUSH(x) SlCrash(__LINE__, (UINT)(x), (UINT)(x), (UINT)(x))
// Common header
#include "SeLowCommon.h"
//// Utility data structure
// Lock
typedef struct SL_LOCK
{
NDIS_SPIN_LOCK spin_lock;
} SL_LOCK;
// Event
typedef struct SL_EVENT
{
KEVENT *event;
HANDLE event_handle;
} SL_EVENT;
// Unicode string
typedef struct SL_UNICODE
{
UNICODE_STRING String;
} SL_UNICODE;
// NDIS packet buffer
typedef struct SL_PACKET_BUFFER
{
NDIS_HANDLE NetBufferListPool; // NET_BUFFER_LIST Pool
NET_BUFFER_LIST *NetBufferList; // NET_BUFFER_LIST
} SL_PACKET_BUFFER;
// List
typedef struct SL_LIST
{
UINT num_item, num_reserved;
void **p;
SL_LOCK *lock;
} SL_LIST;
#define SL_LIST_DATA(o, i) (((o) != NULL) ? ((o)->p[(i)]) : NULL)
#define SL_LIST_NUM(o) (((o) != NULL) ? (o)->num_item : 0)
#define SL_INIT_NUM_RESERVED 32
//// SL data structure
// Packet queue
typedef struct SL_PACKET
{
UCHAR Data[SL_MAX_PACKET_SIZE]; // Data
UINT Size; // Size
struct SL_PACKET *Next; // Next packet
} SL_PACKET;
// File context
typedef struct SL_FILE
{
struct SL_DEVICE *Device; // Device
struct SL_ADAPTER *Adapter; // Adapter
FILE_OBJECT *FileObject; // File object
SL_EVENT *Event; // Event
char EventNameWin32[SL_EVENT_NAME_SIZE]; // Win32 event name
SL_LOCK *RecvLock; // Receive lock
SL_PACKET *RecvPacketHead; // Head of the received packet
SL_PACKET *RecvPacketTail; // Tail of the received packet
UINT NumRecvPackets; // Number of items of the received packet queue
NDIS_HANDLE NetBufferListPool; // NET_BUFFER_LIST Pool
volatile UINT NumSendingPacketets; // Number of packets being transmitted
bool SetEventFlag; // Flag to set an event
bool FinalWakeUp;
} SL_FILE;
// Device context
typedef struct SL_DEVICE
{
DEVICE_OBJECT *DeviceObject; // Device object
SL_UNICODE *DeviceName; // Device name
SL_UNICODE *SymbolicLinkName; // Symbolic link name
volatile bool Halting; // Halting
bool IsBasicDevice; // Whether basic device
struct SL_ADAPTER *Adapter; // Adapter
SL_LIST *FileList; // File List
SL_LOCK *OpenCloseLock; // Open / Close lock of the device
} SL_DEVICE;
// Adapter context
typedef struct SL_ADAPTER
{
volatile bool Halt; // Halt flag
volatile bool Ready; // Ready flag
SL_UNICODE *AdapterName; // Adapter name
NDIS_BIND_PARAMETERS BindParamCopy; // Copy of the bind parameters
UCHAR MacAddress[6]; // MAC address
UINT MtuSize; // MTU size
wchar_t AdapterId[SL_ADAPTER_ID_LEN]; // Adapter ID
volatile bool IsOpenPending; // Whether Open is Pending
volatile bool IsClosePending; // Whether Close is Pending
NDIS_HANDLE BindingContext; // Binding context
NDIS_HANDLE AdapterHandle; // Handle of the adapter
NDIS_HANDLE AdapterHandle2; // Handle of the adapter (receive-only)
NDIS_HANDLE UnbindContext; // Unbind context
SL_LOCK *Lock; // Lock object
volatile UINT NumPendingOidRequests; // Number of running OID requests
volatile UINT NumPendingSendPackets; // Number of packets being transmitted
UCHAR TmpBuffer[SL_MAX_PACKET_SIZE]; // Temporally buffer size
char FriendlyName[256]; // Adapter name
SL_DEVICE *Device; // Handle of the device
} SL_ADAPTER;
// SL context
typedef struct SL_CTX
{
DRIVER_OBJECT *DriverObject; // Driver object
NDIS_HANDLE ProtocolHandle; // NDIS protocol handle
SL_DEVICE *BasicDevice; // Basic device
SL_LIST *AdapterList; // Adapter list
volatile UINT IntCounter1;
UINT DummyInt;
volatile bool IsEnumCompleted; // Enumeration completion flag
volatile UINT NumBoundAdapters;
} SL_CTX;
//// SL function
NDIS_STATUS DriverEntry(DRIVER_OBJECT *driver_object, UNICODE_STRING *registry_path);
NTSTATUS SlDeviceOpenProc(DEVICE_OBJECT *device_object, IRP *irp);
NTSTATUS SlDeviceCloseProc(DEVICE_OBJECT *device_object, IRP *irp);
NTSTATUS SlDeviceReadProc(DEVICE_OBJECT *device_object, IRP *irp);
NTSTATUS SlDeviceWriteProc(DEVICE_OBJECT *device_object, IRP *irp);
NTSTATUS SlDeviceIoControlProc(DEVICE_OBJECT *device_object, IRP *irp);
void SlUnloadProc(DRIVER_OBJECT *driver_object);
NDIS_STATUS SlNdisBindAdapterExProc(NDIS_HANDLE protocol_driver_context, NDIS_HANDLE bind_context, NDIS_BIND_PARAMETERS *bind_parameters);
NDIS_STATUS SlNdisUnbindAdapterExProc(NDIS_HANDLE unbind_context, NDIS_HANDLE protocol_binding_context);
void SlNdisOpenAdapterCompleteExProc(NDIS_HANDLE protocol_binding_context, NDIS_STATUS status);
void SlNdisCloseAdapterCompleteExProc(NDIS_HANDLE protocol_binding_context);
NDIS_STATUS SlNdisNetPnPEventProc(NDIS_HANDLE protocol_binding_context, NET_PNP_EVENT_NOTIFICATION *net_pnp_event);
void SlNdisUninstallProc(void);
void SlNdisOidRequestCompleteProc(NDIS_HANDLE protocol_binding_context, NDIS_OID_REQUEST *oid_request, NDIS_STATUS status);
void SlNdisStatusExProc(NDIS_HANDLE protocol_binding_context, NDIS_STATUS_INDICATION *status_indication);
void SlNdisReceiveNetBufferListsProc(NDIS_HANDLE protocol_binding_context, NET_BUFFER_LIST *net_buffer_lists, NDIS_PORT_NUMBER port_number, ULONG NumberOfNetBufferLists, ULONG receive_flags);
void SlNdisSendNetBufferListsCompleteProc(NDIS_HANDLE protocol_binding_context, NET_BUFFER_LIST *net_buffer_lists, ULONG send_complete_flags);
SL_DEVICE *SlNewDevice(char *device_name, char *symbolic_link_name);
SL_DEVICE *SlNewDeviceUnicode(SL_UNICODE *u_device_name, SL_UNICODE *u_sym_name);
void SlFreeDevice(SL_DEVICE *dev);
void SlFreeAdapter(SL_ADAPTER *a);
void SlSendOidRequest(SL_ADAPTER *a, bool set, NDIS_OID oid, void *data, UINT size);
//// Utility function
void *SlMalloc(UINT size);
void *SlZeroMalloc(UINT size);
void SlFree(void *p);
void SlCopy(void *dst, void *src, UINT size);
void SlZero(void *dst, UINT size);
SL_LOCK *SlNewLock();
void SlLock(SL_LOCK *lock);
void SlUnlock(SL_LOCK *lock);
void SlFreeLock(SL_LOCK *lock);
SL_EVENT *SlNewEvent(char *name);
void SlFreeEvent(SL_EVENT *event);
void SlSet(SL_EVENT *event);
void SlReset(SL_EVENT *event);
SL_UNICODE *SlNewUnicode(char *str);
SL_UNICODE *SlNewUnicodeFromUnicodeString(UNICODE_STRING *src);
void SlFreeUnicode(SL_UNICODE *u);
NDIS_STRING *SlGetUnicode(SL_UNICODE *u);
SL_PACKET_BUFFER *SlNewPacketBuffer();
void SlFreePacketBuffer(SL_PACKET_BUFFER *p);
void SlCrash(UINT a, UINT b, UINT c, UINT d);
SL_LIST *SlNewList();
void SlAdd(SL_LIST *o, void *p);
bool SlDelete(SL_LIST *o, void *p);
void SlDeleteAll(SL_LIST *o);
void SlLockList(SL_LIST *o);
void SlUnlockList(SL_LIST *o);
void SlFreeList(SL_LIST *o);
void *SlClone(void *p, UINT size);
void SlSleep(int milliSeconds);
#endif // SELOW_H
// Developed by SoftEther VPN Project at University of Tsukuba in Japan.
// Department of Computer Science has dozens of overly-enthusiastic geeks.
// Join us: http://www.tsukuba.ac.jp/english/admission/

63
src/SeLow/SeLow.rc Normal file
View File

@ -0,0 +1,63 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// Japanese resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_JPN)
#ifdef _WIN32
LANGUAGE LANG_JAPANESE, SUBLANG_DEFAULT
#pragma code_page(932)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // Japanese resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

278
src/SeLow/SeLow.vcproj Normal file
View File

@ -0,0 +1,278 @@
<?xml version="1.0" encoding="shift_jis"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="SeLow"
ProjectGUID="{94CA5DD2-1543-42F6-9F96-EE7694DDC837}"
RootNamespace="SeLow"
Keyword="Win32Proj"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
<Platform
Name="x64"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)bin"
IntermediateDirectory="$(PlatformName)_$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="2"
WholeProgramOptimization="0"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="3"
InlineFunctionExpansion="0"
EnableIntrinsicFunctions="false"
FavorSizeOrSpeed="0"
AdditionalIncludeDirectories="$(SolutionDir)Mayaqua\win32_inc;C:\WINDDK\7600.16385.0\inc\ddk;C:\WinDDK\7600.16385.0\inc\api;C:\WinDDK\7600.16385.0\inc\crt;$(SolutionDir)"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;VPN_SPEED"
StringPooling="false"
ExceptionHandling="0"
RuntimeLibrary="0"
StructMemberAlignment="4"
BufferSecurityCheck="false"
EnableFunctionLevelLinking="false"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="3"
CallingConvention="2"
CompileAs="1"
DisableSpecificWarnings="4996"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
CommandLine="$(SolutionDir)bin\BuildUtil.exe /CMD:GenerateVersionResource &quot;$(TargetPath)&quot; /OUT:&quot;$(SolutionDir)tmp\VersionResources\$(ProjectName)_$(PlatformName).res&quot;"
/>
<Tool
Name="VCLinkerTool"
IgnoreImportLibrary="true"
LinkLibraryDependencies="false"
AdditionalOptions="/driver /subsystem:native,5.00 /FULLBUILD /align:0x80 /osversion:5.00 /STACK:0x40000,0x1000 /MERGE:_PAGE=PAGE /MERGE:_TEXT=.text /NODEFAULTLIB /stub:C:\WINDDK\7600.16385.0\lib\win7\stub512.com"
AdditionalDependencies="bufferoverflowK.lib wdm.lib ndis.lib wdmsec.lib ntoskrnl.lib fwpkclnt.lib &quot;$(SolutionDir)tmp\VersionResources\$(ProjectName)_$(PlatformName).res&quot;"
OutputFile="$(OutDir)\hamcore\not_signed\SeLow_x86.sys"
LinkIncremental="1"
AdditionalLibraryDirectories="C:\WINDDK\7600.16385.0\lib\win7\i386"
GenerateManifest="false"
IgnoreAllDefaultLibraries="true"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(SolutionDir)DebugFiles\pdb\$(PlatformName)_$(ConfigurationName)\$(ProjectName).pdb"
GenerateMapFile="true"
MapFileName="$(SolutionDir)DebugFiles\map\$(PlatformName)_$(ConfigurationName)\$(ProjectName).map"
SubSystem="0"
OptimizeReferences="1"
EnableCOMDATFolding="1"
EntryPointSymbol="DriverEntry"
BaseAddress="0x10000"
RandomizedBaseAddress="0"
FixedBaseAddress="1"
DataExecutionPrevention="0"
ImportLibrary="$(SolutionDir)tmp\lib\$(PlatformName)_$(ConfigurationName)\$(ProjectName).lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
EmbedManifest="false"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
CommandLine="$(SolutionDir)bin\BuildUtil.exe /CMD:SignCode &quot;$(TargetPath)&quot; /COMMENT:&quot;VPN Software&quot; /KERNEL:yes&#x0D;&#x0A;$(SolutionDir)bin\BuildUtil.exe /CMD:SignSeLowInfFiles x86&#x0D;&#x0A;"
/>
</Configuration>
<Configuration
Name="Release|x64"
OutputDirectory="$(SolutionDir)bin"
IntermediateDirectory="$(PlatformName)_$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="2"
WholeProgramOptimization="0"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="0"
EnableIntrinsicFunctions="false"
FavorSizeOrSpeed="0"
AdditionalIncludeDirectories="$(SolutionDir)Mayaqua\win32_inc;C:\WINDDK\7600.16385.0\inc\ddk;C:\WinDDK\7600.16385.0\inc\api;C:\WinDDK\7600.16385.0\inc\crt;$(SolutionDir)"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;VPN_SPEED;CPU_64"
StringPooling="false"
ExceptionHandling="0"
RuntimeLibrary="0"
StructMemberAlignment="4"
BufferSecurityCheck="false"
EnableFunctionLevelLinking="false"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="3"
CallingConvention="2"
CompileAs="1"
DisableSpecificWarnings="4996"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
CommandLine="$(SolutionDir)bin\BuildUtil.exe /CMD:GenerateVersionResource &quot;$(TargetPath)&quot; /OUT:&quot;$(SolutionDir)tmp\VersionResources\$(ProjectName)_$(PlatformName).res&quot;"
/>
<Tool
Name="VCLinkerTool"
IgnoreImportLibrary="true"
LinkLibraryDependencies="false"
AdditionalOptions="/driver /subsystem:native /FULLBUILD /align:0x80 /osversion:5.00 /STACK:0x40000,0x1000 /MERGE:_PAGE=PAGE /MERGE:_TEXT=.text /NODEFAULTLIB /stub:C:\WINDDK\7600.16385.0\lib\win7\stub512.com"
AdditionalDependencies="bufferoverflowK.lib wdm.lib ndis.lib wdmsec.lib ntoskrnl.lib fwpkclnt.lib &quot;$(SolutionDir)tmp\VersionResources\$(ProjectName)_$(PlatformName).res&quot;"
OutputFile="$(OutDir)\hamcore\not_signed\SeLow_x64.sys"
LinkIncremental="1"
AdditionalLibraryDirectories="C:\WINDDK\7600.16385.0\lib\win7\amd64"
GenerateManifest="false"
IgnoreAllDefaultLibraries="true"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(SolutionDir)DebugFiles\pdb\$(PlatformName)_$(ConfigurationName)\$(ProjectName).pdb"
GenerateMapFile="true"
MapFileName="$(SolutionDir)DebugFiles\map\$(PlatformName)_$(ConfigurationName)\$(ProjectName).map"
SubSystem="0"
OptimizeReferences="1"
EnableCOMDATFolding="1"
EntryPointSymbol="DriverEntry"
BaseAddress="0x10000"
RandomizedBaseAddress="0"
FixedBaseAddress="1"
DataExecutionPrevention="0"
ImportLibrary="$(SolutionDir)tmp\lib\$(PlatformName)_$(ConfigurationName)\$(ProjectName).lib"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
EmbedManifest="false"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
CommandLine="$(SolutionDir)bin\BuildUtil.exe /CMD:SignCode &quot;$(TargetPath)&quot; /COMMENT:&quot;VPN Software&quot; /KERNEL:yes&#x0D;&#x0A;$(SolutionDir)bin\BuildUtil.exe /CMD:SignSeLowInfFiles x64&#x0D;&#x0A;"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\SeLow.c"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\resource.h"
>
</File>
<File
RelativePath=".\SeLow.h"
>
</File>
<File
RelativePath=".\SeLowCommon.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
<File
RelativePath=".\SeLow.rc"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

175
src/SeLow/SeLowCommon.h Normal file
View File

@ -0,0 +1,175 @@
// SoftEther VPN Source Code
// SeLow - SoftEther Lightweight Network Protocol
//
// SoftEther VPN Server, Client and Bridge are free software under GPLv2.
//
// Copyright (c) 2012-2014 Daiyuu Nobori.
// Copyright (c) 2012-2014 SoftEther VPN Project, University of Tsukuba, Japan.
// Copyright (c) 2012-2014 SoftEther Corporation.
//
// All Rights Reserved.
//
// http://www.softether.org/
//
// Author: Daiyuu Nobori
// Comments: Tetsuo Sugiyama, Ph.D.
//
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// version 2 as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License version 2
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// THE LICENSE AGREEMENT IS ATTACHED ON THE SOURCE-CODE PACKAGE
// AS "LICENSE.TXT" FILE. READ THE TEXT FILE IN ADVANCE TO USE THE SOFTWARE.
//
//
// THIS SOFTWARE IS DEVELOPED IN JAPAN, AND DISTRIBUTED FROM JAPAN,
// UNDER JAPANESE LAWS. YOU MUST AGREE IN ADVANCE TO USE, COPY, MODIFY,
// MERGE, PUBLISH, DISTRIBUTE, SUBLICENSE, AND/OR SELL COPIES OF THIS
// SOFTWARE, THAT ANY JURIDICAL DISPUTES WHICH ARE CONCERNED TO THIS
// SOFTWARE OR ITS CONTENTS, AGAINST US (SOFTETHER PROJECT, SOFTETHER
// CORPORATION, DAIYUU NOBORI OR OTHER SUPPLIERS), OR ANY JURIDICAL
// DISPUTES AGAINST US WHICH ARE CAUSED BY ANY KIND OF USING, COPYING,
// MODIFYING, MERGING, PUBLISHING, DISTRIBUTING, SUBLICENSING, AND/OR
// SELLING COPIES OF THIS SOFTWARE SHALL BE REGARDED AS BE CONSTRUED AND
// CONTROLLED BY JAPANESE LAWS, AND YOU MUST FURTHER CONSENT TO
// EXCLUSIVE JURISDICTION AND VENUE IN THE COURTS SITTING IN TOKYO,
// JAPAN. YOU MUST WAIVE ALL DEFENSES OF LACK OF PERSONAL JURISDICTION
// AND FORUM NON CONVENIENS. PROCESS MAY BE SERVED ON EITHER PARTY IN
// THE MANNER AUTHORIZED BY APPLICABLE LAW OR COURT RULE.
//
// USE ONLY IN JAPAN. DO NOT USE IT IN OTHER COUNTRIES. IMPORTING THIS
// SOFTWARE INTO OTHER COUNTRIES IS AT YOUR OWN RISK. SOME COUNTRIES
// PROHIBIT ENCRYPTED COMMUNICATIONS. USING THIS SOFTWARE IN OTHER
// COUNTRIES MIGHT BE RESTRICTED.
//
//
// DEAR SECURITY EXPERTS
// ---------------------
//
// If you find a bug or a security vulnerability please kindly inform us
// about the problem immediately so that we can fix the security problem
// to protect a lot of users around the world as soon as possible.
//
// Our e-mail address for security reports is:
// softether-vpn-security [at] softether.org
//
// Please note that the above e-mail address is not a technical support
// inquiry address. If you need technical assistance, please visit
// http://www.softether.org/ and ask your question on the users forum.
//
// Thank you for your cooperation.
// SeLowCommon.h
// Common Header for Kernel Mode / User Mode
//// Version number
// Change this number every time functions are added or modified on the driver.
// As long as this number does not change, installation of SeLow during the update
// installation of the VPN Server / VPN Client / VPN Bridge is skipped.
#define SL_VER 42
// Constants
#define SL_MAX_PACKET_SIZE 1560
#define SL_MAX_PACKET_SIZE_ANNOUNCE 1514
#define SL_MIN_PACKET_SIZE 14
#define SL_PACKET_HEADER_SIZE 14
#define SL_MAX_FRAME_SIZE (SL_MAX_PACKET_SIZE - SL_MIN_PACKET_SIZE)
#define SL_PROTOCOL_NAME "SeLow"
#define SL_EVENT_NAME_SIZE 128
#define SL_ENUM_COMPLETE_GIVEUP_TICK (15 * 1000)
// IOCTL
#define SL_IOCTL_GET_EVENT_NAME CTL_CODE(0x8000, 1, METHOD_NEITHER, FILE_ANY_ACCESS)
// IOCTL data structure
typedef struct SL_IOCTL_EVENT_NAME
{
char EventNameWin32[SL_EVENT_NAME_SIZE]; // Event name
} SL_IOCTL_EVENT_NAME;
// Device ID
#define SL_BASIC_DEVICE_NAME "\\Device\\SELOW_BASIC_DEVICE"
#define SL_BASIC_DEVICE_NAME_SYMBOLIC "\\DosDevices\\Global\\SELOW_BASIC_DEVICE"
#define SL_BASIC_DEVICE_FILENAME_WIN32 "\\\\.\\SELOW_BASIC_DEVICE"
#define SL_ADAPTER_ID_PREFIX "SELOW_A_"
#define SL_ADAPTER_ID_PREFIX_W L"SELOW_A_"
#define SL_ADAPTER_DEVICE_NAME "\\Device\\SELOW_A_{00000000-0000-0000-0000-000000000000}"
#define SL_ADAPTER_DEVICE_NAME_SYMBOLIC "\\DosDevices\\Global\\SELOW_A_{00000000-0000-0000-0000-000000000000}"
#define SL_ADAPTER_DEVICE_FILENAME_WIN32 "\\\\.\\%s"
// Event name
#define SL_EVENT_NAME "\\BaseNamedObjects\\SELOW_EVENT_%u_%u"
#define SL_EVENT_NAME_WIN32 "Global\\SELOW_EVENT_%u_%u"
// Registry key
#define SL_REG_KEY_NAME "SYSTEM\\CurrentControlSet\\services\\SeLow"
#define SL_REG_VER_VALUE "SlVersion"
// Adapter data
#define SL_ADAPTER_ID_LEN 64
typedef struct SL_ADAPTER_INFO
{
wchar_t AdapterId[SL_ADAPTER_ID_LEN]; // Adapter ID
UCHAR MacAddress[6]; // MAC address
UCHAR Padding1[2];
UINT MtuSize; // MTU size
char FriendlyName[256]; // Display name
UCHAR Reserved[256]; // Reserved area
} SL_ADAPTER_INFO;
#define SL_MAX_ADAPTER_INFO_LIST_ENTRY 256
#define SL_SIGNATURE 0xDEADBEEF
typedef struct SL_ADAPTER_INFO_LIST
{
UINT Signature; // Signature
UINT SeLowVersion; // Version of SeLow
UINT EnumCompleted; // Enumeration completion flag
UINT NumAdapters; // The total number of adapter
SL_ADAPTER_INFO Adapters[SL_MAX_ADAPTER_INFO_LIST_ENTRY]; // Array of adapter
} SL_ADAPTER_INFO_LIST;
// Packet data exchange related
#define SL_MAX_PACKET_EXCHANGE 256 // Number of packets that can be exchanged at a time
#define SL_MAX_PACKET_QUEUED 4096 // Maximum number of packets that can be queued
#define SL_EX_SIZEOF_NUM_PACKET 4 // Packet count data (UINT)
#define SL_EX_SIZEOF_LENGTH_PACKET 4 // Length data of the packet data (UINT)
#define SL_EX_SIZEOF_LEFT_FLAG 4 // Flag to indicate that the packet is left
#define SL_EX_SIZEOF_ONE_PACKET 1600 // Data area occupied by a packet data
#define SL_EXCHANGE_BUFFER_SIZE (SL_EX_SIZEOF_NUM_PACKET + SL_EX_SIZEOF_LEFT_FLAG + \
(SL_EX_SIZEOF_LENGTH_PACKET + SL_EX_SIZEOF_ONE_PACKET) * (SL_MAX_PACKET_EXCHANGE + 1))
#define SL_NUM_PACKET(buf) (*((UINT *)((UCHAR *)buf + 0)))
#define SL_SIZE_OF_PACKET(buf, i) (*((UINT *)((UCHAR *)buf + SL_EX_SIZEOF_NUM_PACKET + \
(i * (SL_EX_SIZEOF_LENGTH_PACKET + SL_EX_SIZEOF_ONE_PACKET)))))
#define SL_ADDR_OF_PACKET(buf, i) (((UINT *)((UCHAR *)buf + SL_EX_SIZEOF_NUM_PACKET + \
SL_EX_SIZEOF_LENGTH_PACKET + \
(i * (SL_EX_SIZEOF_LENGTH_PACKET + SL_EX_SIZEOF_ONE_PACKET)))))
#define SL_LEFT_FLAG(buf) SL_SIZE_OF_PACKET(buf, SL_MAX_PACKET_EXCHANGE)
// Developed by SoftEther VPN Project at University of Tsukuba in Japan.
// Department of Computer Science has dozens of overly-enthusiastic geeks.
// Join us: http://www.tsukuba.ac.jp/english/admission/

84
src/SeLow/resource.h Normal file
View File

@ -0,0 +1,84 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by Neo.rc
//
// Comments: Tetsuo Sugiyama, Ph.D.
//
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// version 2 as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License version 2
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// THE LICENSE AGREEMENT IS ATTACHED ON THE SOURCE-CODE PACKAGE
// AS "LICENSE.TXT" FILE. READ THE TEXT FILE IN ADVANCE TO USE THE SOFTWARE.
//
//
// THIS SOFTWARE IS DEVELOPED IN JAPAN, AND DISTRIBUTED FROM JAPAN,
// UNDER JAPANESE LAWS. YOU MUST AGREE IN ADVANCE TO USE, COPY, MODIFY,
// MERGE, PUBLISH, DISTRIBUTE, SUBLICENSE, AND/OR SELL COPIES OF THIS
// SOFTWARE, THAT ANY JURIDICAL DISPUTES WHICH ARE CONCERNED TO THIS
// SOFTWARE OR ITS CONTENTS, AGAINST US (SOFTETHER PROJECT, SOFTETHER
// CORPORATION, DAIYUU NOBORI OR OTHER SUPPLIERS), OR ANY JURIDICAL
// DISPUTES AGAINST US WHICH ARE CAUSED BY ANY KIND OF USING, COPYING,
// MODIFYING, MERGING, PUBLISHING, DISTRIBUTING, SUBLICENSING, AND/OR
// SELLING COPIES OF THIS SOFTWARE SHALL BE REGARDED AS BE CONSTRUED AND
// CONTROLLED BY JAPANESE LAWS, AND YOU MUST FURTHER CONSENT TO
// EXCLUSIVE JURISDICTION AND VENUE IN THE COURTS SITTING IN TOKYO,
// JAPAN. YOU MUST WAIVE ALL DEFENSES OF LACK OF PERSONAL JURISDICTION
// AND FORUM NON CONVENIENS. PROCESS MAY BE SERVED ON EITHER PARTY IN
// THE MANNER AUTHORIZED BY APPLICABLE LAW OR COURT RULE.
//
// USE ONLY IN JAPAN. DO NOT USE IT IN OTHER COUNTRIES. IMPORTING THIS
// SOFTWARE INTO OTHER COUNTRIES IS AT YOUR OWN RISK. SOME COUNTRIES
// PROHIBIT ENCRYPTED COMMUNICATIONS. USING THIS SOFTWARE IN OTHER
// COUNTRIES MIGHT BE RESTRICTED.
//
//
// DEAR SECURITY EXPERTS
// ---------------------
//
// If you find a bug or a security vulnerability please kindly inform us
// about the problem immediately so that we can fix the security problem
// to protect a lot of users around the world as soon as possible.
//
// Our e-mail address for security reports is:
// softether-vpn-security [at] softether.org
//
// Please note that the above e-mail address is not a technical support
// inquiry address. If you need technical assistance, please visit
// http://www.softether.org/ and ask your question on the users forum.
//
// Thank you for your cooperation.
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
// Developed by SoftEther VPN Project at University of Tsukuba in Japan.
// Department of Computer Science has dozens of overly-enthusiastic geeks.
// Join us: http://www.tsukuba.ac.jp/english/admission/