cryptlib.c: allow application to override OPENSSL_isservice [from HEAD].
authorAndy Polyakov <appro@openssl.org>
Sat, 10 Apr 2010 14:13:12 +0000 (14:13 +0000)
committerAndy Polyakov <appro@openssl.org>
Sat, 10 Apr 2010 14:13:12 +0000 (14:13 +0000)
crypto/cryptlib.c

index 9a39d7e171ca91ae4205b683eed40ab96460c19a..b4449b86d68fcfa3462ff616737bc4a426a6ae70 100644 (file)
@@ -749,6 +749,18 @@ int OPENSSL_isservice(void)
 { HWINSTA h;
   DWORD len;
   WCHAR *name;
+  static union { void *p; int (*f)(void); } _OPENSSL_isservice = { NULL };
+
+    if (_OPENSSL_isservice.p == NULL) {
+       HANDLE h = GetModuleHandle(NULL);
+       if (h != NULL)
+           _OPENSSL_isservice.p = GetProcAddress(h,"_OPENSSL_isservice");
+       if (_OPENSSL_isservice.p == NULL)
+           _OPENSSL_isservice.p = (void *)-1;
+    }
+
+    if (_OPENSSL_isservice.p != (void *)-1)
+       return (*_OPENSSL_isservice.f)();
 
     (void)GetDesktopWindow(); /* return value is ignored */