From 8160a29ae6d770496169ba9551634e2a4683331f Mon Sep 17 00:00:00 2001 From: Nick Banks Date: Wed, 12 Feb 2020 12:25:43 -0800 Subject: [PATCH] Fixes for Building Kernel Mode in OS (#129) Fixes a number of build breaks in the OS repo from recent kernel mode code refactoring. --- src/bin/winkernel/driver.c | 7 ------- src/core/crypto.c | 2 +- src/inc/msquic_winkernel.h | 9 --------- src/platform/platform_winkernel.c | 28 ++++++++++++++++++++++++++++ src/platform/tls_schannel.c | 18 ++++++++++++++++++ src/test/bin/winkernel/control.cpp | 7 ------- src/test/bin/winkernel/driver.cpp | 6 ------ 7 files changed, 47 insertions(+), 30 deletions(-) diff --git a/src/bin/winkernel/driver.c b/src/bin/winkernel/driver.c index fc069f6e5..cf13b19b3 100644 --- a/src/bin/winkernel/driver.c +++ b/src/bin/winkernel/driver.c @@ -9,13 +9,6 @@ Abstract: --*/ -#include -#include -#include -#include -#include -#include - #include "quic_platform.h" #include "quic_trace.h" diff --git a/src/core/crypto.c b/src/core/crypto.c index 57a067b60..d37978297 100644 --- a/src/core/crypto.c +++ b/src/core/crypto.c @@ -1375,8 +1375,8 @@ QuicCryptoProcessData( &BufferCount, &Buffer); - QUIC_TEL_ASSERT(DataAvailable); UNREFERENCED_PARAMETER(DataAvailable); + QUIC_TEL_ASSERT(DataAvailable); QUIC_DBG_ASSERT(BufferCount == 1); QUIC_CONNECTION* Connection = QuicCryptoGetConnection(Crypto); diff --git a/src/inc/msquic_winkernel.h b/src/inc/msquic_winkernel.h index 56edce9e4..9b7e3cd02 100644 --- a/src/inc/msquic_winkernel.h +++ b/src/inc/msquic_winkernel.h @@ -35,20 +35,11 @@ typedef UINT16 uint16_t; typedef UINT32 uint32_t; typedef UINT64 uint64_t; -typedef INT_PTR intptr_t; -typedef UINT_PTR uintptr_t; - #define UINT8_MAX 0xffui8 #define UINT16_MAX 0xffffui16 #define UINT32_MAX 0xffffffffui32 #define UINT64_MAX 0xffffffffffffffffui64 -#define UINTPTR_MAX MAXUINT_PTR -#define INTPTR_MAX MAXINT_PTR - -#undef SIZE_MAX -#define SIZE_MAX UINTPTR_MAX - #ifndef STATUS_QUIC_HANDSHAKE_FAILURE #define STATUS_QUIC_HANDSHAKE_FAILURE ((NTSTATUS)0xC0240000L) #endif diff --git a/src/platform/platform_winkernel.c b/src/platform/platform_winkernel.c index b0ff37d95..427b33b8a 100644 --- a/src/platform/platform_winkernel.c +++ b/src/platform/platform_winkernel.c @@ -29,6 +29,10 @@ Environment: textual reference to the "WPP_INIT_TRACING();" macro. */ +typedef enum _SYSTEM_INFORMATION_CLASS { + SystemBasicInformation = 0 +} SYSTEM_INFORMATION_CLASS; + NTSYSAPI // Copied from zwapi.h. NTSTATUS NTAPI @@ -39,6 +43,30 @@ ZwQuerySystemInformation ( __out_opt PULONG ReturnLength ); +typedef struct _SYSTEM_BASIC_INFORMATION { + ULONG Reserved; + ULONG TimerResolution; + ULONG PageSize; + + // + // WARNING: The following fields are 32-bit and may get + // capped to MAXULONG on systems with a lot of RAM! + // + // Use SYSTEM_PHYSICAL_MEMORY_INFORMATION instead. + // + + ULONG NumberOfPhysicalPages; // Deprecated, do not use. + ULONG LowestPhysicalPageNumber; // Deprecated, do not use. + ULONG HighestPhysicalPageNumber; // Deprecated, do not use. + + ULONG AllocationGranularity; + ULONG_PTR MinimumUserModeAddress; + ULONG_PTR MaximumUserModeAddress; + ULONG_PTR ActiveProcessorsAffinityMask; + CCHAR NumberOfProcessors; +} SYSTEM_BASIC_INFORMATION, *PSYSTEM_BASIC_INFORMATION; + + uint64_t QuicPlatformPerfFreq; uint64_t QuicTotalMemory; QUIC_PLATFORM QuicPlatform = { NULL, NULL }; diff --git a/src/platform/tls_schannel.c b/src/platform/tls_schannel.c index bb06762e9..19b029eff 100644 --- a/src/platform/tls_schannel.c +++ b/src/platform/tls_schannel.c @@ -47,6 +47,24 @@ Environment: #include #include #include + +typedef enum _SEC_APPLICATION_PROTOCOL_NEGOTIATION_STATUS +{ + SecApplicationProtocolNegotiationStatus_None, + SecApplicationProtocolNegotiationStatus_Success, + SecApplicationProtocolNegotiationStatus_SelectedClientOnly +} SEC_APPLICATION_PROTOCOL_NEGOTIATION_STATUS, *PSEC_APPLICATION_PROTOCOL_NEGOTIATION_STATUS; + +#define MAX_PROTOCOL_ID_SIZE 0xff + +typedef struct _SecPkgContext_ApplicationProtocol +{ + SEC_APPLICATION_PROTOCOL_NEGOTIATION_STATUS ProtoNegoStatus; // Application protocol negotiation status + SEC_APPLICATION_PROTOCOL_NEGOTIATION_EXT ProtoNegoExt; // Protocol negotiation extension type corresponding to this protocol ID + unsigned char ProtocolIdSize; // Size in bytes of the application protocol ID + unsigned char ProtocolId[MAX_PROTOCOL_ID_SIZE]; // Byte string representing the negotiated application protocol ID +} SecPkgContext_ApplicationProtocol, *PSecPkgContext_ApplicationProtocol; + #endif #define SCHANNEL_USE_BLACKLISTS diff --git a/src/test/bin/winkernel/control.cpp b/src/test/bin/winkernel/control.cpp index a882bcbc3..fe5fd4bbc 100644 --- a/src/test/bin/winkernel/control.cpp +++ b/src/test/bin/winkernel/control.cpp @@ -9,13 +9,6 @@ Abstract: --*/ -#include -#include -#include -#include -#include -#include -#include #include #include diff --git a/src/test/bin/winkernel/driver.cpp b/src/test/bin/winkernel/driver.cpp index 9f628d14b..b398bba9a 100644 --- a/src/test/bin/winkernel/driver.cpp +++ b/src/test/bin/winkernel/driver.cpp @@ -9,12 +9,6 @@ Abstract: --*/ -#include -#include -#include -#include -#include -#include #include #include "quic_trace.h"