From: Andy Polyakov Date: Mon, 29 Mar 2010 10:06:01 +0000 (+0000) Subject: cryptlib.c: allow application to override OPENSSL_isservice. X-Git-Tag: OpenSSL-fips-2_0-rc1~1162 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=471d0eb397aac295cfc2a6febcc362b3780f2fe6;p=oweals%2Fopenssl.git cryptlib.c: allow application to override OPENSSL_isservice. PR: 2194 --- 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 */