Move _WIN32_WINNT definition from command line to e_os.h. The change is
authorAndy Polyakov <appro@openssl.org>
Sat, 21 May 2005 13:19:27 +0000 (13:19 +0000)
committerAndy Polyakov <appro@openssl.org>
Sat, 21 May 2005 13:19:27 +0000 (13:19 +0000)
inspired by VC6 failure report. In addition abstain from taking screen
snapshots when running in NT service context.

crypto/cryptlib.c
crypto/cryptlib.h
crypto/rand/rand_win.c
e_os.h
util/pl/VC-32.pl

index 6f8b0ff4e5afb13dc307bddacd69e9762bf86ffa..e73d086eedd099e7be67f3f7b9aea940fe8ec988 100644 (file)
@@ -624,7 +624,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason,
 #include <tchar.h>
 
 #if defined(_WIN32_WINNT) && _WIN32_WINNT>=0x0333
 #include <tchar.h>
 
 #if defined(_WIN32_WINNT) && _WIN32_WINNT>=0x0333
-static int IsService(void)
+int OPENSSL_isservice(void)
 { HWINSTA h;
   DWORD len;
   WCHAR *name;
 { HWINSTA h;
   DWORD len;
   WCHAR *name;
@@ -722,7 +722,7 @@ void OPENSSL_showfatal (const char *fmta,...)
 
 #if defined(_WIN32_WINNT) && _WIN32_WINNT>=0x0333
     /* this -------------v--- guards NT-specific calls */
 
 #if defined(_WIN32_WINNT) && _WIN32_WINNT>=0x0333
     /* this -------------v--- guards NT-specific calls */
-    if (GetVersion() < 0x80000000 && IsService())
+    if (GetVersion() < 0x80000000 && OPENSSL_isservice())
     {  HANDLE h = RegisterEventSource(0,_T("OPENSSL"));
        const TCHAR *pmsg=buf;
        ReportEvent(h,EVENTLOG_ERROR_TYPE,0,0,0,1,0,&pmsg,0);
     {  HANDLE h = RegisterEventSource(0,_T("OPENSSL"));
        const TCHAR *pmsg=buf;
        ReportEvent(h,EVENTLOG_ERROR_TYPE,0,0,0,1,0,&pmsg,0);
@@ -754,6 +754,7 @@ void OPENSSL_showfatal (const char *fmta,...)
     vfprintf (stderr,fmta,ap);
     va_end (ap);
 }
     vfprintf (stderr,fmta,ap);
     va_end (ap);
 }
+int OPENSSL_isservice (void) { return 0; }
 #endif
 
 void OpenSSLDie(const char *file,int line,const char *assertion)
 #endif
 
 void OpenSSLDie(const char *file,int line,const char *assertion)
index fc249c57f3793b4ed277b69c39514a3db9c97512..5ceaa964b5324fa51966bea5db4b6d2f841d84e5 100644 (file)
@@ -103,6 +103,7 @@ extern unsigned long OPENSSL_ia32cap_P;
 void OPENSSL_showfatal(const char *,...);
 void *OPENSSL_stderr(void);
 extern int OPENSSL_NONPIC_relocated;
 void OPENSSL_showfatal(const char *,...);
 void *OPENSSL_stderr(void);
 extern int OPENSSL_NONPIC_relocated;
+int OPENSSL_isservice(void);
 
 #ifdef  __cplusplus
 }
 
 #ifdef  __cplusplus
 }
index 39523d3005a7da238006795585d6b4d92308ea7d..47bf75828296d208b9384f154f0cd994b4f24b45 100644 (file)
@@ -632,7 +632,8 @@ int RAND_event(UINT iMsg, WPARAM wParam, LPARAM lParam)
 void RAND_screen(void) /* function available for backward compatibility */
 {
        RAND_poll();
 void RAND_screen(void) /* function available for backward compatibility */
 {
        RAND_poll();
-       readscreen();
+       if (GetVersion() >= 0x80000000 || !OPENSSL_isservice())
+               readscreen();
 }
 
 
 }
 
 
diff --git a/e_os.h b/e_os.h
index 3ff9f3cd1c4ce2f2816d6d0789b3860846d49043..cf76632b1e07c025bed8154db81da8e3aa110189 100644 (file)
--- a/e_os.h
+++ b/e_os.h
@@ -235,6 +235,23 @@ extern "C" {
 #  define NO_DIRENT
 
 #  ifdef WINDOWS
 #  define NO_DIRENT
 
 #  ifdef WINDOWS
+#    ifndef _WIN32_WINNT
+       /*
+       * Defining _WIN32_WINNT here in e_os.h implies certain "discipline."
+       * Most notably we ought to check for availability of each specific
+       * routine with GetProcAddress() and/or quard NT-specific calls with
+       * GetVersion() < 0x80000000. One can argue that in latter "or" case
+       * we ought to /DELAYLOAD some .DLLs in order to protect ourselves
+       * against run-time link errors. This doesn't seem to be necessary,
+       * because it turned out that already Windows 95, first non-NT Win32
+       * implementation, is equipped with at least NT 3.51 stubs, dummy
+       * routines with same name, but which do nothing. Meaning that it's
+       * apparently appropriate to guard generic NT calls with GetVersion
+       * alone, while NT 4.0 and above calls ought to be additionally
+       * checked upon with GetProcAddress.
+       */
+#      define _WIN32_WINNT 0x0400
+#    endif
 #    include <windows.h>
 #    include <stddef.h>
 #    include <errno.h>
 #    include <windows.h>
 #    include <stddef.h>
 #    include <errno.h>
index 5888dcbfefb1cffc19e06b8a358ec344f2bd7650..710c4cd129f8f022788506680fe4dc64e30708b6 100644 (file)
@@ -11,7 +11,7 @@ $rm='del';
 
 # C compiler stuff
 $cc='cl';
 
 # C compiler stuff
 $cc='cl';
-$cflags=' /MD /W3 /WX /G5 /Ox /O2 /Ob2 /Gs0 /GF /Gy /nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -D_WIN32_WINNT=0x0333 -DL_ENDIAN -DDSO_WIN32';
+$cflags=' /MD /W3 /WX /G5 /Ox /O2 /Ob2 /Gs0 /GF /Gy /nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DDSO_WIN32';
 $lflags="/nologo /subsystem:console /machine:I386 /opt:ref";
 $mlflags='';
 
 $lflags="/nologo /subsystem:console /machine:I386 /opt:ref";
 $mlflags='';