Skip to content

Commit

Permalink
api: build with WDK
Browse files Browse the repository at this point in the history
Makes builds more reproducable, as we can do our next release using the
EWDK, an all-in-one ISO of build tools from Microsoft.

Signed-off-by: Jason A. Donenfeld <[email protected]>
  • Loading branch information
zx2c4 committed Jul 23, 2021
1 parent af83574 commit f9c97ae
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 6 deletions.
5 changes: 3 additions & 2 deletions api/adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@
#include <WinSock2.h>
#include <Windows.h>
#include <winternl.h>
#define _NTDEF_ /* TODO: figure out how to include ntsecapi and winternal together without requiring this */
#include <wincrypt.h>
#include <cfgmgr32.h>
#include <devguid.h>
#include <ws2tcpip.h>
#include <iphlpapi.h>
#include <ndisguid.h>
#include <NTSecAPI.h>
#include <SetupAPI.h>
#include <Shlwapi.h>
#include <shellapi.h>
#include <wchar.h>
#include <initguid.h> /* Keep these two at bottom in this order, so that we only generate extra GUIDs for devpkey. The other keys we'll get from uuid.lib like usual. */
#include <devpkey.h>
#include <devioctl.h>

#include "adapter.h"
#include "entry.h"
Expand Down
17 changes: 15 additions & 2 deletions api/api.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,35 @@
<ProjectGuid>{897F02E3-3EAA-40AF-A6DC-17EB2376EDAF}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>api</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>$(LatestTargetPlatformVersion)</WindowsTargetPlatformVersion>
<ProjectName>api</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>WindowsApplicationForDrivers10.0</PlatformToolset>
<SpectreMitigation>false</SpectreMitigation>
<Driver_SpectreMitigation>false</Driver_SpectreMitigation>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration">
<UseDebugLibraries>true</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration">
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Platform)'=='Win32'" Label="Configuration">
<TargetVersion>Windows7</TargetVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Platform)'=='ARM'" Label="Configuration">
<TargetVersion>Windows8</TargetVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Platform)'=='x64'" Label="Configuration">
<TargetVersion>Windows7</TargetVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Platform)'=='ARM64'" Label="Configuration">
<TargetVersion>Windows10</TargetVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
Expand Down
2 changes: 2 additions & 0 deletions api/entry.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include <delayimp.h>
#pragma warning(pop)
#include <sddl.h>
#include <winefs.h>
#include <stdlib.h>

HINSTANCE ResourceModule;
HANDLE ModuleHeap;
Expand Down
1 change: 1 addition & 0 deletions api/logger.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <Windows.h>
#include <winternl.h>
#include <wchar.h>
#include <stdlib.h>

static BOOL CALLBACK
NopLogger(_In_ WINTUN_LOGGER_LEVEL Level, _In_z_ const WCHAR *LogLine)
Expand Down
2 changes: 2 additions & 0 deletions api/namespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
#include <Windows.h>
#include <winternl.h>
#include <bcrypt.h>
#include <winefs.h>
#include <wchar.h>
#include <stdlib.h>

static HANDLE PrivateNamespace = NULL;
static HANDLE BoundaryDescriptor = NULL;
Expand Down
6 changes: 6 additions & 0 deletions api/ntdll.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,9 @@ NtQueryKey(
_Out_bytecap_post_bytecount_(Length, *ResultLength) PVOID KeyInformation,
_In_ ULONG Length,
_Out_ PULONG ResultLength);

/* This is documented in NTSecAPI.h, which we can't include, due to header conflicts. It actually lives in advapi32.dll. */
#define RtlGenRandom SystemFunction036
BOOLEAN
NTAPI
RtlGenRandom(_Out_writes_bytes_all_(RandomBufferLength) PVOID RandomBuffer, _In_ ULONG RandomBufferLength);
1 change: 1 addition & 0 deletions api/registry.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "registry.h"
#include <Windows.h>
#include <wchar.h>
#include <stdlib.h>
#include <strsafe.h>

static _Return_type_success_(return != NULL) HKEY
Expand Down
1 change: 1 addition & 0 deletions api/rundll32.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

#include "entry.h"
#include <shellapi.h>

#if ACCEPT_WOW64 == 1

Expand Down
5 changes: 3 additions & 2 deletions api/session.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "logger.h"
#include "wintun.h"
#include <Windows.h>
#include <devioctl.h>

#pragma warning(disable : 4200) /* nonstandard: zero-sized array in struct/union */

Expand Down Expand Up @@ -215,7 +216,7 @@ void WINAPI
WintunReleaseReceivePacket(_In_ TUN_SESSION *Session, _In_ const BYTE *Packet)
{
EnterCriticalSection(&Session->Send.Lock);
TUN_PACKET *ReleasedBuffPacket = (TUN_PACKET *)(Packet - offsetof(TUN_PACKET, Data));
TUN_PACKET *ReleasedBuffPacket = (TUN_PACKET *)(Packet - FIELD_OFFSET(TUN_PACKET, Data));
ReleasedBuffPacket->Size |= TUN_PACKET_RELEASE;
while (Session->Send.PacketsToRelease)
{
Expand Down Expand Up @@ -270,7 +271,7 @@ void WINAPI
WintunSendPacket(_In_ TUN_SESSION *Session, _In_ const BYTE *Packet)
{
EnterCriticalSection(&Session->Receive.Lock);
TUN_PACKET *ReleasedBuffPacket = (TUN_PACKET *)(Packet - offsetof(TUN_PACKET, Data));
TUN_PACKET *ReleasedBuffPacket = (TUN_PACKET *)(Packet - FIELD_OFFSET(TUN_PACKET, Data));
ReleasedBuffPacket->Size &= ~TUN_PACKET_RELEASE;
while (Session->Receive.PacketsToRelease)
{
Expand Down

0 comments on commit f9c97ae

Please sign in to comment.