From: Andy Polyakov Date: Sat, 10 Apr 2010 14:13:12 +0000 (+0000) Subject: cryptlib.c: allow application to override OPENSSL_isservice [from HEAD]. X-Git-Tag: OpenSSL_1_0_0a~49 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=b32d93840e97e53992276bc630f1b49ccfb85716;p=oweals%2Fopenssl.git cryptlib.c: allow application to override OPENSSL_isservice [from HEAD]. --- diff --git a/crypto/cryptlib.c b/crypto/cryptlib.c index 9a39d7e171..b4449b86d6 100644 --- a/crypto/cryptlib.c +++ b/crypto/cryptlib.c @@ -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 */