diff -ur -xdist -x 'WINNT*_OPT.OBJ' -x '*.rej' -x '*.orig' -x '*~' nss-3.24.orig/nspr/config/config.mk nss-3.24/nspr/config/config.mk
--- nss-3.24.orig/nspr/config/config.mk	2016-06-17 09:40:19.643148500 -0400
+++ nss-3.24/nspr/config/config.mk	2016-06-17 09:41:48.006276100 -0400
@@ -132,6 +132,15 @@
 DEFINES += -DMOZ_UNICODE
 endif
 
+ifdef WINDDK_BUILD
+OS_CFLAGS += -DWINDDK_BUILD
+ifdef USE_64
+OS_LIBS += msvcrt_win2003.obj
+else
+OS_LIBS += msvcrt_winxp.obj
+endif
+endif
+
 ####################################################################
 #
 # Configuration for the release process
diff -ur -xdist -x 'WINNT*_OPT.OBJ' -x '*.rej' -x '*.orig' -x '*~' nss-3.24.orig/nspr/pr/include/pratom.h nss-3.24/nspr/pr/include/pratom.h
--- nss-3.24.orig/nspr/pr/include/pratom.h	2016-06-17 09:40:21.019148500 -0400
+++ nss-3.24/nspr/pr/include/pratom.h	2016-06-17 09:41:48.016277100 -0400
@@ -79,6 +79,7 @@
 **    interchangeably.
 */
 #if defined(_WIN32) && !defined(_WIN32_WCE) && \
+    !defined(WINDDK_BUILD) && \
     (!defined(_MSC_VER) || (_MSC_VER >= 1310))
 
 #include <intrin.h>
diff -ur -xdist -x 'WINNT*_OPT.OBJ' -x '*.rej' -x '*.orig' -x '*~' nss-3.24.orig/nspr/pr/include/prbit.h nss-3.24/nspr/pr/include/prbit.h
--- nss-3.24.orig/nspr/pr/include/prbit.h	2016-06-17 09:40:20.922148500 -0400
+++ nss-3.24/nspr/pr/include/prbit.h	2016-06-17 09:41:48.027278200 -0400
@@ -14,6 +14,7 @@
 ** functions.
 */
 #if defined(_WIN32) && (_MSC_VER >= 1300) && \
+    !defined(WINDDK_BUILD) && \
     (defined(_M_IX86) || defined(_M_AMD64) || defined(_M_ARM))
 # include <intrin.h>
 # pragma  intrinsic(_BitScanForward,_BitScanReverse)
diff -ur -xdist -x 'WINNT*_OPT.OBJ' -x '*.rej' -x '*.orig' -x '*~' nss-3.24.orig/nspr/pr/src/Makefile.in nss-3.24/nspr/pr/src/Makefile.in
--- nss-3.24.orig/nspr/pr/src/Makefile.in	2016-06-17 09:40:21.305148500 -0400
+++ nss-3.24/nspr/pr/src/Makefile.in	2016-06-17 09:41:48.037279200 -0400
@@ -167,9 +167,17 @@
 ifdef NS_USE_GCC
 OS_LIBS		= -ladvapi32 -lws2_32 -lmswsock -lwinmm
 else
+ifdef WINDDK_BUILD
+ifdef USE_64
+OS_LIBS = advapi32.lib wsock32.lib winmm.lib msvcrt_win2003.obj
+else
+OS_LIBS = advapi32.lib wsock32.lib winmm.lib msvcrt_winxp.obj
+endif
+else
 OS_LIBS		= advapi32.lib ws2_32.lib mswsock.lib winmm.lib
 endif
 endif
+endif
 
 ifeq ($(OS_ARCH),WINCE)
 OS_LIBS		= ws2.lib
diff -ur -xdist -x 'WINNT*_OPT.OBJ' -x '*.rej' -x '*.orig' -x '*~' nss-3.24.orig/nspr/pr/src/md/windows/ntmisc.c nss-3.24/nspr/pr/src/md/windows/ntmisc.c
--- nss-3.24.orig/nspr/pr/src/md/windows/ntmisc.c	2016-06-17 09:40:22.804148500 -0400
+++ nss-3.24/nspr/pr/src/md/windows/ntmisc.c	2016-06-17 09:41:48.046280100 -0400
@@ -593,7 +593,11 @@
      */
     hasFdInheritBuffer = (attr && attr->fdInheritBuffer);
     if ((envp == NULL) && hasFdInheritBuffer) {
+#ifdef WINDDK_BUILD
+        envp = getenv;
+#else
         envp = environ;
+#endif
     }
 
     if (envp != NULL) {
diff -ur -xdist -x 'WINNT*_OPT.OBJ' -x '*.rej' -x '*.orig' -x '*~' nss-3.24.orig/nss/cmd/httpserv/httpserv.c nss-3.24/nss/cmd/httpserv/httpserv.c
--- nss-3.24.orig/nss/cmd/httpserv/httpserv.c	2016-06-17 09:40:37.856148500 -0400
+++ nss-3.24/nss/cmd/httpserv/httpserv.c	2016-06-17 10:54:12.943759300 -0400
@@ -12,8 +12,13 @@
 #endif
 
 #if defined(_WINDOWS)
+#ifdef WINDDK_BUILD
+#include <windows.h>
+#define getpid GetCurrentProcessId
+#else
 #include <process.h> /* for getpid() */
 #endif
+#endif
 
 #include <signal.h>
 #include <stdlib.h>
diff -ur -xdist -x 'WINNT*_OPT.OBJ' -x '*.rej' -x '*.orig' -x '*~' nss-3.24.orig/nss/cmd/platlibs.mk nss-3.24/nss/cmd/platlibs.mk
--- nss-3.24.orig/nss/cmd/platlibs.mk	2016-06-17 09:40:38.216148500 -0400
+++ nss-3.24/nss/cmd/platlibs.mk	2016-06-17 09:41:48.077283200 -0400
@@ -260,3 +260,11 @@
 endif
 
 JAR_LIBS = $(DIST)/lib/$(LIB_PREFIX)jar.$(LIB_SUFFIX)
+
+ifdef WINDDK_BUILD
+ifdef USE_64
+OS_LIBS += msvcrt_win2003.obj
+else
+OS_LIBS += msvcrt_winxp.obj
+endif
+endif
diff -ur -xdist -x 'WINNT*_OPT.OBJ' -x '*.rej' -x '*.orig' -x '*~' nss-3.24.orig/nss/cmd/selfserv/selfserv.c nss-3.24/nss/cmd/selfserv/selfserv.c
--- nss-3.24.orig/nss/cmd/selfserv/selfserv.c	2016-06-17 09:40:38.194148500 -0400
+++ nss-3.24/nss/cmd/selfserv/selfserv.c	2016-06-17 10:55:08.963360700 -0400
@@ -18,8 +18,13 @@
 #endif
 
 #if defined(_WINDOWS)
+#ifdef WINDDK_BUILD
+#include <windows.h>
+#define getpid GetCurrentProcessId
+#else
 #include <process.h> /* for getpid() */
 #endif
+#endif
 
 #include <signal.h>
 #include <stdlib.h>
diff -ur -xdist -x 'WINNT*_OPT.OBJ' -x '*.rej' -x '*.orig' -x '*~' nss-3.24.orig/nss/coreconf/arch.mk nss-3.24/nss/coreconf/arch.mk
--- nss-3.24.orig/nss/coreconf/arch.mk	2016-06-17 09:40:23.906148500 -0400
+++ nss-3.24/nss/coreconf/arch.mk	2016-06-17 09:41:48.113286800 -0400
@@ -210,7 +210,15 @@
 # the uname.exe in the MSYS toolkit.
 #
 ifeq (MINGW32_NT,$(findstring MINGW32_NT,$(OS_ARCH)))
-    OS_RELEASE := $(patsubst MINGW32_NT-%,%,$(OS_ARCH))
+    ifdef WINDDK_BUILD
+        ifdef USE_64
+            OS_RELEASE := 5.2
+        else
+            OS_RELEASE := 5.1
+        endif
+    else
+        OS_RELEASE := $(patsubst MINGW32_NT-%,%,$(OS_ARCH))
+    endif
     OS_ARCH = WINNT
     USE_MSYS = 1
     ifndef CPU_ARCH
diff -ur -xdist -x 'WINNT*_OPT.OBJ' -x '*.rej' -x '*.orig' -x '*~' nss-3.24.orig/nss/coreconf/WIN32.mk nss-3.24/nss/coreconf/WIN32.mk
--- nss-3.24.orig/nss/coreconf/WIN32.mk	2016-06-17 09:40:23.992148500 -0400
+++ nss-3.24/nss/coreconf/WIN32.mk	2016-06-17 10:56:16.564120100 -0400
@@ -132,6 +132,14 @@
     ifeq ($(NSS_ENABLE_WERROR),1)
         WARNING_CFLAGS += -WX
     endif
+    ifdef WINDDK_BUILD
+        OS_CFLAGS += -DWINDDK_BUILD
+        ifdef USE_64
+            OS_LIBS += msvcrt_win2003.obj
+        else
+            OS_LIBS += msvcrt_winxp.obj
+        endif
+    endif
     ifeq ($(_MSC_VER),$(_MSC_VER_6))
     ifndef MOZ_DEBUG_SYMBOLS
 	OS_DLLFLAGS += -PDB:NONE
diff -ur -xdist -x 'WINNT*_OPT.OBJ' -x '*.rej' -x '*.orig' -x '*~' nss-3.24.orig/nss/lib/dbm/include/mcom_db.h nss-3.24/nss/lib/dbm/include/mcom_db.h
--- nss-3.24.orig/nss/lib/dbm/include/mcom_db.h	2016-06-17 09:40:26.430148500 -0400
+++ nss-3.24/nss/lib/dbm/include/mcom_db.h	2016-06-17 09:41:48.146290100 -0400
@@ -35,6 +35,15 @@
 #ifndef _DB_H_
 #define _DB_H_
 
+#ifdef WINDDK_BUILD
+#ifndef stat
+#define stat _stat
+#endif
+#ifndef getpid
+#define getpid GetCurrentProcessId
+#endif
+#endif
+
 #ifndef macintosh
 #include <sys/types.h>
 #endif
diff -ur -xdist -x 'WINNT*_OPT.OBJ' -x '*.rej' -x '*.orig' -x '*~' nss-3.24.orig/nss/lib/dbm/src/mktemp.c nss-3.24/nss/lib/dbm/src/mktemp.c
--- nss-3.24.orig/nss/lib/dbm/src/mktemp.c	2016-06-17 09:40:26.476148500 -0400
+++ nss-3.24/nss/lib/dbm/src/mktemp.c	2016-06-17 09:41:48.158291300 -0400
@@ -45,13 +45,13 @@
 #include <ctype.h>
 #include "mcom_db.h"
 
-#ifndef _WINDOWS
-#include <unistd.h>
-#endif
-
 #ifdef _WINDOWS
+#ifndef WINDDK_BUILD
 #include <process.h>
+#endif
 #include "winfile.h"
+#else
+#include <unistd.h>
 #endif
 
 static int _gettemp(char *path, register int *doopen, int extraFlags);
diff -ur -xdist -x 'WINNT*_OPT.OBJ' -x '*.rej' -x '*.orig' -x '*~' nss-3.24.orig/nss/lib/freebl/chacha20.h nss-3.24/nss/lib/freebl/chacha20.h
--- nss-3.24.orig/nss/lib/freebl/chacha20.h	2016-06-17 09:40:28.920148500 -0400
+++ nss-3.24/nss/lib/freebl/chacha20.h	2016-06-17 11:15:21.176579300 -0400
@@ -8,7 +8,7 @@
 #ifndef FREEBL_CHACHA20_H_
 #define FREEBL_CHACHA20_H_
 
-#if defined(_MSC_VER) && _MSC_VER < 1600
+#if defined(_MSC_VER) && (_MSC_VER < 1600 || defined(WINDDK_BUILD))
 #include "prtypes.h"
 typedef PRUint32 uint32_t;
 typedef PRUint64 uint64_t;
diff -ur -xdist -x 'WINNT*_OPT.OBJ' -x '*.rej' -x '*.orig' -x '*~' nss-3.24.orig/nss/lib/freebl/Makefile nss-3.24/nss/lib/freebl/Makefile
--- nss-3.24.orig/nss/lib/freebl/Makefile	2016-06-17 09:40:29.423148500 -0400
+++ nss-3.24/nss/lib/freebl/Makefile	2016-06-17 09:41:48.167292200 -0400
@@ -153,12 +153,14 @@
     # The Intel AES assembly code requires Visual C++ 2010.
     # if $(_MSC_VER) >= 1600 (Visual C++ 2010)
     ifeq ($(firstword $(sort $(_MSC_VER) 1600)),1600)
+        ifndef WINDDK_BUILD
 	DEFINES += -DUSE_HW_AES -DINTEL_GCM
 	ASFILES += intel-aes-x86-masm.asm intel-gcm-x86-masm.asm
 	EXTRA_SRCS += intel-gcm-wrap.c
 	ifeq ($(CLANG_CL),1)
 	    INTEL_GCM_CLANG_CL = 1
 	endif
+        endif
     endif
 endif
 else
diff -ur -xdist -x 'WINNT*_OPT.OBJ' -x '*.rej' -x '*.orig' -x '*~' nss-3.24.orig/nss/lib/freebl/mpi/mpcpucache.c nss-3.24/nss/lib/freebl/mpi/mpcpucache.c
--- nss-3.24.orig/nss/lib/freebl/mpi/mpcpucache.c	2016-06-17 09:40:30.290148500 -0400
+++ nss-3.24/nss/lib/freebl/mpi/mpcpucache.c	2016-06-17 09:41:48.179293400 -0400
@@ -48,7 +48,11 @@
 
 #elif defined(_MSC_VER)
 
+#ifdef WINDDK_BUILD
+#include <ntddk.h>
+#else
 #include <intrin.h>
+#endif
 
 void freebl_cpuid(unsigned long op, unsigned long *eax, 
            unsigned long *ebx, unsigned long *ecx, 
diff -ur -xdist -x 'WINNT*_OPT.OBJ' -x '*.rej' -x '*.orig' -x '*~' nss-3.24.orig/nss/lib/freebl/poly1305.c nss-3.24/nss/lib/freebl/poly1305.c
--- nss-3.24.orig/nss/lib/freebl/poly1305.c	2016-06-17 09:40:28.935148500 -0400
+++ nss-3.24/nss/lib/freebl/poly1305.c	2016-06-17 11:19:43.124771500 -0400
@@ -10,7 +10,7 @@
 
 #include "poly1305.h"
 
-#if defined(_MSC_VER) && _MSC_VER < 1600
+#if defined(_MSC_VER) && (_MSC_VER < 1600 || defined(WINDDK_BUILD))
 #include "prtypes.h"
 typedef PRUint32 uint32_t;
 typedef PRUint64 uint64_t;
diff -ur -xdist -x 'WINNT*_OPT.OBJ' -x '*.rej' -x '*.orig' -x '*~' nss-3.24.orig/nss/lib/softoken/legacydb/config.mk nss-3.24/nss/lib/softoken/legacydb/config.mk
--- nss-3.24.orig/nss/lib/softoken/legacydb/config.mk	2016-06-17 09:40:27.539148500 -0400
+++ nss-3.24/nss/lib/softoken/legacydb/config.mk	2016-06-17 09:41:48.189294400 -0400
@@ -55,3 +55,11 @@
 	-lnspr4 \
 	$(NULL)
 endif
+
+ifdef WINDDK_BUILD
+ifdef USE_64
+OS_LIBS += msvcrt_win2003.obj
+else
+OS_LIBS += msvcrt_winxp.obj
+endif
+endif
diff -ur -xdist -x 'WINNT*_OPT.OBJ' -x '*.rej' -x '*.orig' -x '*~' nss-3.24.orig/nss/lib/sqlite/sqlite3.c nss-3.24/nss/lib/sqlite/sqlite3.c
--- nss-3.24.orig/nss/lib/sqlite/sqlite3.c	2016-06-17 09:40:27.763148500 -0400
+++ nss-3.24/nss/lib/sqlite/sqlite3.c	2016-06-17 11:27:34.939948300 -0400
@@ -9153,7 +9153,12 @@
 */
 #if !defined(SQLITE_DISABLE_INTRINSIC)
 #  if defined(_MSC_VER) && _MSC_VER>=1300
-#    if !defined(_WIN32_WCE)
+#    if defined(WINDDK_BUILD)
+#      include <emmintrin.h>
+#      pragma intrinsic(_byteswap_ushort)
+#      pragma intrinsic(_byteswap_ulong)
+#      pragma intrinsic(_ReadWriteBarrier)
+#    elif !defined(_WIN32_WCE)
 #      include <intrin.h>
 #      pragma intrinsic(_byteswap_ushort)
 #      pragma intrinsic(_byteswap_ulong)
@@ -16862,7 +16867,8 @@
 ** localtime_s().
 */
 #if !HAVE_LOCALTIME_R && !HAVE_LOCALTIME_S \
-    && defined(_MSC_VER) && defined(_CRT_INSECURE_DEPRECATE)
+    && defined(_MSC_VER) && defined(_CRT_INSECURE_DEPRECATE) \
+    && !defined(WINDDK_BUILD)
 #undef  HAVE_LOCALTIME_S
 #define HAVE_LOCALTIME_S 1
 #endif
diff -ur -xdist -x 'WINNT*_OPT.OBJ' -x '*.rej' -x '*.orig' -x '*~' nss-3.24.orig/nss/lib/ssl/sslimpl.h nss-3.24/nss/lib/ssl/sslimpl.h
--- nss-3.24.orig/nss/lib/ssl/sslimpl.h	2016-06-17 09:40:28.674148500 -0400
+++ nss-3.24/nss/lib/ssl/sslimpl.h	2016-06-17 09:41:48.289304400 -0400
@@ -1991,8 +1991,13 @@
 #if defined(XP_UNIX) || defined(XP_OS2) || defined(XP_BEOS)
 #define SSL_GETPID getpid
 #elif defined(WIN32)
+#ifdef WINDDK_BUILD
+#include <windows.h>
+#define SSL_GETPID GetCurrentProcessId
+#else
 extern int __cdecl _getpid(void);
 #define SSL_GETPID _getpid
+#endif
 #else
 #define SSL_GETPID() 0
 #endif
diff -ur -xdist -x 'WINNT*_OPT.OBJ' -x '*.rej' -x '*.orig' -x '*~' nss-3.24.orig/nss/lib/zlib/config.mk nss-3.24/nss/lib/zlib/config.mk
--- nss-3.24.orig/nss/lib/zlib/config.mk	2016-06-17 09:40:25.693148500 -0400
+++ nss-3.24/nss/lib/zlib/config.mk	2016-06-17 09:41:48.301305600 -0400
@@ -18,3 +18,12 @@
 ifeq ($(OS_TARGET),Linux)
 DEFINES += -DHAVE_UNISTD_H
 endif
+
+ifdef WINDDK_BUILD
+ifdef USE_64
+OS_LIBS += msvcrt_win2003.obj
+else
+OS_LIBS += msvcrt_winxp.obj
+endif
+endif
+
