summaryrefslogtreecommitdiffstats
path: root/crypto/cryptlib.c
diff options
context:
space:
mode:
authorAndy Polyakov <appro@openssl.org>2010-03-29 10:06:01 +0000
committerAndy Polyakov <appro@openssl.org>2010-03-29 10:06:01 +0000
commit471d0eb397aac295cfc2a6febcc362b3780f2fe6 (patch)
tree78508a0cfc003c6c33fc78cf1dcdd64e2beed5bc /crypto/cryptlib.c
parent97a6a01f0f775cef912c8b0bf9628080255f892e (diff)
cryptlib.c: allow application to override OPENSSL_isservice.
PR: 2194
Diffstat (limited to 'crypto/cryptlib.c')
-rw-r--r--crypto/cryptlib.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/crypto/cryptlib.c b/crypto/cryptlib.c
index 62bc495d3d..af1dbfb81d 100644
--- a/crypto/cryptlib.c
+++ b/crypto/cryptlib.c
@@ -762,6 +762,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 */