diff -ur -xdist -x 'WINNT*_OPT.OBJ' -x '*.rej' -x '*.orig' nss-3.20.1.vanilla/nspr/config/config.mk nss-3.20.1/nspr/config/config.mk
--- nss-3.20.1.vanilla/nspr/config/config.mk	2015-10-16 09:22:19.000000000 -0400
+++ nss-3.20.1/nspr/config/config.mk	2016-01-01 12:06:19.651464400 -0500
@@ -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' nss-3.20.1.vanilla/nspr/pr/include/pratom.h nss-3.20.1/nspr/pr/include/pratom.h
--- nss-3.20.1.vanilla/nspr/pr/include/pratom.h	2015-10-16 09:22:19.000000000 -0400
+++ nss-3.20.1/nspr/pr/include/pratom.h	2016-01-01 12:16:13.321420400 -0500
@@ -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' nss-3.20.1.vanilla/nspr/pr/include/prbit.h nss-3.20.1/nspr/pr/include/prbit.h
--- nss-3.20.1.vanilla/nspr/pr/include/prbit.h	2015-10-16 09:22:19.000000000 -0400
+++ nss-3.20.1/nspr/pr/include/prbit.h	2016-01-01 12:17:40.097383700 -0500
@@ -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' nss-3.20.1.vanilla/nspr/pr/src/Makefile.in nss-3.20.1/nspr/pr/src/Makefile.in
--- nss-3.20.1.vanilla/nspr/pr/src/Makefile.in	2015-10-16 09:22:19.000000000 -0400
+++ nss-3.20.1/nspr/pr/src/Makefile.in	2016-01-01 12:06:19.674465700 -0500
@@ -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' nss-3.20.1.vanilla/nspr/pr/src/md/windows/ntmisc.c nss-3.20.1/nspr/pr/src/md/windows/ntmisc.c
--- nss-3.20.1.vanilla/nspr/pr/src/md/windows/ntmisc.c	2015-10-16 09:22:19.000000000 -0400
+++ nss-3.20.1/nspr/pr/src/md/windows/ntmisc.c	2016-01-01 12:06:19.696467000 -0500
@@ -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' nss-3.20.1.vanilla/nss/cmd/httpserv/httpserv.c nss-3.20.1/nss/cmd/httpserv/httpserv.c
--- nss-3.20.1.vanilla/nss/cmd/httpserv/httpserv.c	2015-10-15 15:51:18.000000000 -0400
+++ nss-3.20.1/nss/cmd/httpserv/httpserv.c	2016-01-01 12:06:19.721468400 -0500
@@ -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' nss-3.20.1.vanilla/nss/cmd/platlibs.mk nss-3.20.1/nss/cmd/platlibs.mk
--- nss-3.20.1.vanilla/nss/cmd/platlibs.mk	2015-10-15 15:51:18.000000000 -0400
+++ nss-3.20.1/nss/cmd/platlibs.mk	2016-01-01 12:06:19.748469900 -0500
@@ -218,3 +218,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' nss-3.20.1.vanilla/nss/cmd/selfserv/selfserv.c nss-3.20.1/nss/cmd/selfserv/selfserv.c
--- nss-3.20.1.vanilla/nss/cmd/selfserv/selfserv.c	2015-10-15 15:51:18.000000000 -0400
+++ nss-3.20.1/nss/cmd/selfserv/selfserv.c	2016-01-01 12:06:19.771471200 -0500
@@ -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' nss-3.20.1.vanilla/nss/coreconf/arch.mk nss-3.20.1/nss/coreconf/arch.mk
--- nss-3.20.1.vanilla/nss/coreconf/arch.mk	2015-10-15 15:51:18.000000000 -0400
+++ nss-3.20.1/nss/coreconf/arch.mk	2016-01-01 12:06:19.801473000 -0500
@@ -209,7 +209,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' nss-3.20.1.vanilla/nss/coreconf/WIN32.mk nss-3.20.1/nss/coreconf/WIN32.mk
--- nss-3.20.1.vanilla/nss/coreconf/WIN32.mk	2015-10-15 15:51:18.000000000 -0400
+++ nss-3.20.1/nss/coreconf/WIN32.mk	2016-01-01 12:06:19.827474400 -0500
@@ -128,6 +128,14 @@
     OS_CFLAGS += -W3 -nologo -D_CRT_SECURE_NO_WARNINGS \
 		 -D_CRT_NONSTDC_NO_WARNINGS
     OS_DLLFLAGS += -nologo -DLL -SUBSYSTEM:WINDOWS
+    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' nss-3.20.1.vanilla/nss/lib/dbm/include/mcom_db.h nss-3.20.1/nss/lib/dbm/include/mcom_db.h
--- nss-3.20.1.vanilla/nss/lib/dbm/include/mcom_db.h	2015-10-15 15:51:18.000000000 -0400
+++ nss-3.20.1/nss/lib/dbm/include/mcom_db.h	2016-01-01 12:06:19.853475900 -0500
@@ -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' nss-3.20.1.vanilla/nss/lib/dbm/src/mktemp.c nss-3.20.1/nss/lib/dbm/src/mktemp.c
--- nss-3.20.1.vanilla/nss/lib/dbm/src/mktemp.c	2015-10-15 15:51:18.000000000 -0400
+++ nss-3.20.1/nss/lib/dbm/src/mktemp.c	2016-01-01 12:06:19.875477200 -0500
@@ -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' nss-3.20.1.vanilla/nss/lib/freebl/Makefile nss-3.20.1/nss/lib/freebl/Makefile
--- nss-3.20.1.vanilla/nss/lib/freebl/Makefile	2015-10-15 15:51:18.000000000 -0400
+++ nss-3.20.1/nss/lib/freebl/Makefile	2016-01-01 12:36:37.230423900 -0500
@@ -138,12 +138,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' nss-3.20.1.vanilla/nss/lib/freebl/mpi/mpcpucache.c nss-3.20.1/nss/lib/freebl/mpi/mpcpucache.c
--- nss-3.20.1.vanilla/nss/lib/freebl/mpi/mpcpucache.c	2015-10-15 15:51:18.000000000 -0400
+++ nss-3.20.1/nss/lib/freebl/mpi/mpcpucache.c	2016-01-01 12:06:19.897478400 -0500
@@ -47,7 +47,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' nss-3.20.1.vanilla/nss/lib/softoken/legacydb/config.mk nss-3.20.1/nss/lib/softoken/legacydb/config.mk
--- nss-3.20.1.vanilla/nss/lib/softoken/legacydb/config.mk	2015-10-15 15:51:18.000000000 -0400
+++ nss-3.20.1/nss/lib/softoken/legacydb/config.mk	2016-01-01 12:06:19.921479800 -0500
@@ -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' nss-3.20.1.vanilla/nss/lib/sqlite/sqlite3.c nss-3.20.1/nss/lib/sqlite/sqlite3.c
--- nss-3.20.1.vanilla/nss/lib/sqlite/sqlite3.c	2015-10-15 15:51:18.000000000 -0400
+++ nss-3.20.1/nss/lib/sqlite/sqlite3.c	2016-01-01 12:06:20.039486600 -0500
@@ -14204,7 +14204,8 @@
 ** localtime_s().
 */
 #if !defined(HAVE_LOCALTIME_R) && !defined(HAVE_LOCALTIME_S) && \
-     defined(_MSC_VER) && defined(_CRT_INSECURE_DEPRECATE)
+     defined(_MSC_VER) && defined(_CRT_INSECURE_DEPRECATE) && \
+     !defined(WINDDK_BUILD)
 #define HAVE_LOCALTIME_S 1
 #endif
 
diff -ur -xdist -x 'WINNT*_OPT.OBJ' -x '*.rej' -x '*.orig' nss-3.20.1.vanilla/nss/lib/ssl/sslimpl.h nss-3.20.1/nss/lib/ssl/sslimpl.h
--- nss-3.20.1.vanilla/nss/lib/ssl/sslimpl.h	2015-10-15 15:51:18.000000000 -0400
+++ nss-3.20.1/nss/lib/ssl/sslimpl.h	2016-01-01 12:06:20.063487900 -0500
@@ -1956,8 +1956,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' nss-3.20.1.vanilla/nss/lib/zlib/config.mk nss-3.20.1/nss/lib/zlib/config.mk
--- nss-3.20.1.vanilla/nss/lib/zlib/config.mk	2015-10-15 15:51:18.000000000 -0400
+++ nss-3.20.1/nss/lib/zlib/config.mk	2016-01-01 12:06:20.072488500 -0500
@@ -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
+
