--- a/pjsip/build/pjsip_core.vcxproj
+++ b/pjsip/build/pjsip_core.vcxproj
@@ -211,7 +211,7 @@
     </Midl>
     <ClCompile>
       <AdditionalIncludeDirectories>../include;../../pjlib/include;../../pjlib-util/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>PJ_OS_HAS_CHECK_STACK=0;PJ_HAS_SSL_SOCK;_LIB;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <PrecompiledHeaderOutputFile />
     </ClCompile>
     <Lib>
--- a/pjsip/build/pjsip_simple.vcxproj
+++ b/pjsip/build/pjsip_simple.vcxproj
@@ -235,7 +235,7 @@
     </Midl>
     <ClCompile>
       <AdditionalIncludeDirectories>../include;../../pjlib-util/include;../../pjlib/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>PJ_OS_HAS_CHECK_STACK=0;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <PrecompiledHeaderOutputFile />
     </ClCompile>
     <Lib>
--- a/pjsip/build/pjsip_ua.vcxproj
+++ b/pjsip/build/pjsip_ua.vcxproj
@@ -211,7 +211,7 @@
     </Midl>
     <ClCompile>
       <AdditionalIncludeDirectories>../include;../../pjlib/include;../../pjlib-util/include;../../pjmedia/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>PJ_OS_HAS_CHECK_STACK=0;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <PrecompiledHeaderOutputFile />
     </ClCompile>
     <Lib>
--- a/pjsip/build/pjsua2_lib.vcxproj
+++ b/pjsip/build/pjsua2_lib.vcxproj
@@ -235,7 +235,7 @@
     </Midl>
     <ClCompile>
       <AdditionalIncludeDirectories>../include;../../pjmedia/include;../../pjlib-util/include;../../pjlib/include;../../pjnath/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>PJ_OS_HAS_CHECK_STACK=0;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <PrecompiledHeaderOutputFile />
     </ClCompile>
     <Lib>
--- a/pjsip/build/pjsua_lib.vcxproj
+++ b/pjsip/build/pjsua_lib.vcxproj
@@ -235,7 +235,7 @@
     </Midl>
     <ClCompile>
       <AdditionalIncludeDirectories>../include;../../pjmedia/include;../../pjlib-util/include;../../pjlib/include;../../pjnath/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>PJ_OS_HAS_CHECK_STACK=0;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <PrecompiledHeaderOutputFile />
     </ClCompile>
     <Lib>
--- a/pjsip/src/pjsip/sip_dialog.c
+++ b/pjsip/src/pjsip/sip_dialog.c
@@ -888,7 +888,11 @@ PJ_DEF(void) pjsip_dlg_inc_lock(pjsip_dialog *dlg)
     PJ_LOG(6,(dlg->obj_name, "Entering pjsip_dlg_inc_lock(), sess_count=%d",
 	      dlg->sess_count));
 
+#if _WIN32 && (_WIN32_WINNT >= 0x0400)
+    pj_mutex_trylock(dlg->mutex_);
+#else
     pj_mutex_lock(dlg->mutex_);
+#endif
     dlg->sess_count++;
 
     PJ_LOG(6,(dlg->obj_name, "Leaving pjsip_dlg_inc_lock(), sess_count=%d",
--- a/pjlib-util/build/pjlib_util.vcxproj
+++ b/pjlib-util/build/pjlib_util.vcxproj
@@ -211,7 +211,7 @@
     </Midl>
     <ClCompile>
       <AdditionalIncludeDirectories>../include;../../pjlib/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>PJ_OS_HAS_CHECK_STACK=0;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <PrecompiledHeaderOutputFile />
     </ClCompile>
     <Lib>
--- a/pjlib/build/pjlib.vcxproj
+++ b/pjlib/build/pjlib.vcxproj
@@ -224,8 +224,8 @@
       <TargetEnvironment>X64</TargetEnvironment>
     </Midl>
     <ClCompile>
-      <AdditionalIncludeDirectories>../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <AdditionalIncludeDirectories>..\..\..\include;../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>_WIN32_WINNT=0x0A00;PJ_TERM_HAS_COLOR=0;PJ_OS_HAS_CHECK_STACK=0;WIN32_NATIVE;PJ_HAS_SSL_SOCK;PJ_HAS_TLS_SOCK;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <PrecompiledHeaderOutputFile />
     </ClCompile>
   </ItemDefinitionGroup>
@@ -424,9 +424,11 @@
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release-Static|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release-Static|x64'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
+    </ClCompile>
+    <ClCompile Include="..\src\pj\ip_helper_win32.c">
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
     </ClCompile>
-    <ClCompile Include="..\src\pj\ip_helper_win32.c" />
     <ClCompile Include="..\src\pj\list.c" />
     <ClCompile Include="..\src\pj\lock.c" />
     <ClCompile Include="..\src\pj\log.c" />
@@ -593,6 +595,7 @@
     <ClCompile Include="..\src\pj\sock_select.c" />
     <ClCompile Include="..\src\pj\ssl_sock_common.c" />
     <ClCompile Include="..\src\pj\ssl_sock_dump.c" />
+    <ClCompile Include="..\src\pj\ssl_sock_gtls.c" />
     <ClCompile Include="..\src\pj\ssl_sock_ossl.c" />
     <ClCompile Include="..\src\pj\string.c" />
     <ClCompile Include="..\src\pj\symbols.c">
--- a/pjlib/include/pj/compat/string.h
+++ b/pjlib/include/pj/compat/string.h
@@ -43,7 +43,7 @@
 #   include <stdlib.h>
 #endif
 
-#if defined(_MSC_VER)
+#if defined(PJ_WIN32)
 #   define strcasecmp	_stricmp
 #   define strncasecmp	_strnicmp
 #   define snprintf	_snprintf
--- /dev/null
+++ b/pjlib/include/pj/config_site.h
@@ -0,0 +1,8 @@
+#include "config_site_sample.h"
+
+#undef PJMEDIA_AUDIO_DEV_HAS_PORTAUDIO
+#undef PJMEDIA_AUDIO_DEV_HAS_WMME
+
+#define PJMEDIA_AUDIO_DEV_HAS_PORTAUDIO 0
+#define PJMEDIA_AUDIO_DEV_HAS_WMME 0
+#define PJMEDIA_RESAMPLE_IMP PJMEDIA_RESAMPLE_SPEEX
\ No newline at end of file
--- a/pjlib/src/pj/file_access_win32.c
+++ b/pjlib/src/pj/file_access_win32.c
@@ -44,7 +44,7 @@ PJ_DEF(pj_bool_t) pj_file_exists(const char *filename)
 
     PJ_ASSERT_RETURN(filename != NULL, 0);
 
-    hFile = CreateFile(PJ_STRING_TO_NATIVE(filename,wfilename,sizeof(wfilename)), 
+    hFile = CreateFile2(PJ_STRING_TO_NATIVE(filename,wfilename,sizeof(wfilename)), 
 		       CONTROL_ACCESS, 
 		       FILE_SHARE_READ, NULL,
                        OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
@@ -68,14 +68,14 @@ PJ_DEF(pj_off_t) pj_file_size(const char *filename)
 
     PJ_ASSERT_RETURN(filename != NULL, -1);
 
-    hFile = CreateFile(PJ_STRING_TO_NATIVE(filename, wfilename,sizeof(wfilename)), 
+    hFile = CreateFile2(PJ_STRING_TO_NATIVE(filename, wfilename,sizeof(wfilename)), 
 		       CONTROL_ACCESS, 
                        FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
                        OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
     if (hFile == INVALID_HANDLE_VALUE)
         return -1;
 
-    sizeLo = GetFileSize(hFile, &sizeHi);
+    sizeLo = GetFileSizeEx(hFile, &sizeHi);
     if (sizeLo == INVALID_FILE_SIZE) {
         DWORD dwStatus = GetLastError();
         if (dwStatus != NO_ERROR) {
@@ -177,14 +177,14 @@ PJ_DEF(pj_status_t) pj_file_getstat(const char *filename, pj_file_stat *stat)
 
     PJ_ASSERT_RETURN(filename!=NULL && stat!=NULL, PJ_EINVAL);
 
-    hFile = CreateFile(PJ_STRING_TO_NATIVE(filename,wfilename,sizeof(wfilename)), 
+    hFile = CreateFile2(PJ_STRING_TO_NATIVE(filename,wfilename,sizeof(wfilename)), 
 		       CONTROL_ACCESS, 
 		       FILE_SHARE_READ, NULL,
                        OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
     if (hFile == INVALID_HANDLE_VALUE)
         return PJ_RETURN_OS_ERROR(GetLastError());
 
-    sizeLo = GetFileSize(hFile, &sizeHi);
+    sizeLo = GetFileSizeEx(hFile, &sizeHi);
     if (sizeLo == INVALID_FILE_SIZE) {
         DWORD dwStatus = GetLastError();
         if (dwStatus != NO_ERROR) {
--- a/pjlib/src/pj/file_io_win32.c
+++ b/pjlib/src/pj/file_io_win32.c
@@ -88,7 +88,7 @@ PJ_DEF(pj_status_t) pj_file_open( pj_pool_t *pool,
     dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
     dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL;
 
-    hFile = CreateFile(PJ_STRING_TO_NATIVE(pathname,wpathname,sizeof(wpathname)), 
+    hFile = CreateFile2(PJ_STRING_TO_NATIVE(pathname,wpathname,sizeof(wpathname)), 
 		       dwDesiredAccess, dwShareMode, NULL,
                        dwCreationDisposition, dwFlagsAndAttributes, NULL);
     if (hFile == INVALID_HANDLE_VALUE) {
--- a/pjmedia/build/pjmedia.vcxproj
+++ b/pjmedia/build/pjmedia.vcxproj
@@ -207,7 +207,7 @@
     </Midl>
     <ClCompile>
       <AdditionalIncludeDirectories>../include;../../pjlib/include;../../pjlib-util/include;../../pjnath/include;../../third_party/portaudio/include;../../third_party/speex/include;../../third_party/build/srtp;../../third_party/srtp/include;../../third_party/srtp/crypto/include;../../third_party/yuv/include;../..;$(DXSDK_DIR)include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>PJ_OS_HAS_CHECK_STACK=0;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <PrecompiledHeaderOutputFile />
     </ClCompile>
   </ItemDefinitionGroup>
--- a/pjnath/build/pjnath.vcxproj
+++ b/pjnath/build/pjnath.vcxproj
@@ -267,7 +267,7 @@
     </Midl>
     <ClCompile>
       <AdditionalIncludeDirectories>../include;../../pjlib/include;../../pjlib-util/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>PJ_OS_HAS_CHECK_STACK=0;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <PrecompiledHeaderOutputFile />
     </ClCompile>
   </ItemDefinitionGroup>
   