diff -ur -xdist -x 'WINNT*_OPT.OBJ' nss-3.15.2/nspr/config/config.mk nss-3.15.2-wdk/nspr/config/config.mk
--- nss-3.15.2/nspr/config/config.mk	2013-09-18 19:49:51.000000000 -0400
+++ nss-3.15.2-wdk/nspr/config/config.mk	2013-11-03 11:21:02.364094500 -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' nss-3.15.2/nspr/pr/src/Makefile.in nss-3.15.2-wdk/nspr/pr/src/Makefile.in
--- nss-3.15.2/nspr/pr/src/Makefile.in	2013-09-18 19:49:51.000000000 -0400
+++ nss-3.15.2-wdk/nspr/pr/src/Makefile.in	2013-11-03 11:21:02.369094500 -0500
@@ -167,9 +167,17 @@
 ifdef NS_USE_GCC
 OS_LIBS		= -ladvapi32 -lwsock32 -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 wsock32.lib winmm.lib
 endif
 endif
+endif
 
 ifeq ($(OS_ARCH),WINCE)
 OS_LIBS		= ws2.lib
diff -ur -xdist -x 'WINNT*_OPT.OBJ' nss-3.15.2/nspr/pr/src/md/windows/ntmisc.c nss-3.15.2-wdk/nspr/pr/src/md/windows/ntmisc.c
--- nss-3.15.2/nspr/pr/src/md/windows/ntmisc.c	2013-09-18 19:49:51.000000000 -0400
+++ nss-3.15.2-wdk/nspr/pr/src/md/windows/ntmisc.c	2013-11-03 11:21:02.375094500 -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' nss-3.15.2/nss/cmd/httpserv/httpserv.c nss-3.15.2-wdk/nss/cmd/httpserv/httpserv.c
--- nss-3.15.2/nss/cmd/httpserv/httpserv.c	2013-09-25 09:57:55.000000000 -0400
+++ nss-3.15.2-wdk/nss/cmd/httpserv/httpserv.c	2013-11-03 11:21:02.394094500 -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' nss-3.15.2/nss/cmd/platlibs.mk nss-3.15.2-wdk/nss/cmd/platlibs.mk
--- nss-3.15.2/nss/cmd/platlibs.mk	2013-09-25 09:57:55.000000000 -0400
+++ nss-3.15.2-wdk/nss/cmd/platlibs.mk	2013-11-03 11:21:02.400094500 -0500
@@ -222,3 +222,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
Only in nss-3.15.2-wdk/nss/cmd: platlibs.mk.orig
diff -ur -xdist -x 'WINNT*_OPT.OBJ' nss-3.15.2/nss/cmd/selfserv/selfserv.c nss-3.15.2-wdk/nss/cmd/selfserv/selfserv.c
--- nss-3.15.2/nss/cmd/selfserv/selfserv.c	2013-09-25 09:57:55.000000000 -0400
+++ nss-3.15.2-wdk/nss/cmd/selfserv/selfserv.c	2013-11-03 11:21:02.407094500 -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' nss-3.15.2/nss/coreconf/arch.mk nss-3.15.2-wdk/nss/coreconf/arch.mk
--- nss-3.15.2/nss/coreconf/arch.mk	2013-09-25 09:57:55.000000000 -0400
+++ nss-3.15.2-wdk/nss/coreconf/arch.mk	2013-11-03 11:21:02.383094500 -0500
@@ -235,7 +235,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' nss-3.15.2/nss/coreconf/WIN32.mk nss-3.15.2-wdk/nss/coreconf/WIN32.mk
--- nss-3.15.2/nss/coreconf/WIN32.mk	2013-09-25 09:57:55.000000000 -0400
+++ nss-3.15.2-wdk/nss/coreconf/WIN32.mk	2013-11-03 14:04:27.791287400 -0500
@@ -114,6 +114,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' nss-3.15.2/nss/lib/dbm/include/mcom_db.h nss-3.15.2-wdk/nss/lib/dbm/include/mcom_db.h
--- nss-3.15.2/nss/lib/dbm/include/mcom_db.h	2013-09-25 09:57:55.000000000 -0400
+++ nss-3.15.2-wdk/nss/lib/dbm/include/mcom_db.h	2013-11-03 11:21:02.349094500 -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' nss-3.15.2/nss/lib/dbm/src/mktemp.c nss-3.15.2-wdk/nss/lib/dbm/src/mktemp.c
--- nss-3.15.2/nss/lib/dbm/src/mktemp.c	2013-09-25 09:57:55.000000000 -0400
+++ nss-3.15.2-wdk/nss/lib/dbm/src/mktemp.c	2013-11-03 11:21:02.359094500 -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' nss-3.15.2/nss/lib/freebl/mpi/mpcpucache.c nss-3.15.2-wdk/nss/lib/freebl/mpi/mpcpucache.c
--- nss-3.15.2/nss/lib/freebl/mpi/mpcpucache.c	2013-09-25 09:57:55.000000000 -0400
+++ nss-3.15.2-wdk/nss/lib/freebl/mpi/mpcpucache.c	2013-11-03 11:21:02.414094500 -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' nss-3.15.2/nss/lib/freebl/win_rand.c nss-3.15.2-wdk/nss/lib/freebl/win_rand.c
--- nss-3.15.2/nss/lib/freebl/win_rand.c	2013-09-25 09:57:55.000000000 -0400
+++ nss-3.15.2-wdk/nss/lib/freebl/win_rand.c	2013-11-03 11:21:02.420094500 -0500
@@ -12,6 +12,11 @@
 #include <io.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#ifdef WINDDK_BUILD
+#ifndef stat
+#define stat _stat
+#endif
+#endif
 #include <stdio.h>
 #include "prio.h"
 #include "prerror.h"
diff -ur -xdist -x 'WINNT*_OPT.OBJ' nss-3.15.2/nss/lib/softoken/legacydb/config.mk nss-3.15.2-wdk/nss/lib/softoken/legacydb/config.mk
--- nss-3.15.2/nss/lib/softoken/legacydb/config.mk	2013-09-25 09:57:55.000000000 -0400
+++ nss-3.15.2-wdk/nss/lib/softoken/legacydb/config.mk	2013-11-03 11:21:02.425094500 -0500
@@ -59,3 +59,11 @@
 ifeq ($(OS_TARGET),SunOS)
 OS_LIBS += -lbsm 
 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' nss-3.15.2/nss/lib/sqlite/sqlite3.c nss-3.15.2-wdk/nss/lib/sqlite/sqlite3.c
--- nss-3.15.2/nss/lib/sqlite/sqlite3.c	2013-09-25 09:57:55.000000000 -0400
+++ nss-3.15.2-wdk/nss/lib/sqlite/sqlite3.c	2013-11-03 11:21:02.479094500 -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' nss-3.15.2/nss/lib/ssl/sslimpl.h nss-3.15.2-wdk/nss/lib/ssl/sslimpl.h
--- nss-3.15.2/nss/lib/ssl/sslimpl.h	2013-09-25 09:57:55.000000000 -0400
+++ nss-3.15.2-wdk/nss/lib/ssl/sslimpl.h	2013-11-03 11:21:02.743094500 -0500
@@ -1855,8 +1855,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
Only in nss-3.15.2-wdk/nss/lib/ssl: sslimpl.h.orig
diff -ur -xdist -x 'WINNT*_OPT.OBJ' nss-3.15.2/nss/lib/zlib/config.mk nss-3.15.2-wdk/nss/lib/zlib/config.mk
--- nss-3.15.2/nss/lib/zlib/config.mk	2013-09-25 09:57:55.000000000 -0400
+++ nss-3.15.2-wdk/nss/lib/zlib/config.mk	2013-11-03 11:21:02.750094500 -0500
@@ -14,3 +14,11 @@
 PROGRAM        =
 
 EXTRA_LIBS     = $(LIBRARY)
+
+ifdef WINDDK_BUILD
+ifdef USE_64
+OS_LIBS += msvcrt_win2003.obj
+else
+OS_LIBS += msvcrt_winxp.obj
+endif
+endif
