]> git.ipfire.org Git - thirdparty/openssl.git/blame - crypto/dllmain.c
Fix no-ec2m in ec_curve.c (1.1.0)
[thirdparty/openssl.git] / crypto / dllmain.c
CommitLineData
b1322259
RS
1/*
2 * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
3 *
4 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
8 */
9
84af71a9
RL
10#include "internal/cryptlib_int.h"
11
12#if defined(_WIN32) || defined(__CYGWIN__)
13# ifdef __CYGWIN__
14/* pick DLL_[PROCESS|THREAD]_[ATTACH|DETACH] definitions */
15# include <windows.h>
16/*
17 * this has side-effect of _WIN32 getting defined, which otherwise is
18 * mutually exclusive with __CYGWIN__...
19 */
20# endif
21
22/*
23 * All we really need to do is remove the 'error' state when a thread
24 * detaches
25 */
26
27BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);
28BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
29{
30 switch (fdwReason) {
31 case DLL_PROCESS_ATTACH:
32 OPENSSL_cpuid_setup();
33# if defined(_WIN32_WINNT)
34 {
35 IMAGE_DOS_HEADER *dos_header = (IMAGE_DOS_HEADER *) hinstDLL;
36 IMAGE_NT_HEADERS *nt_headers;
37
38 if (dos_header->e_magic == IMAGE_DOS_SIGNATURE) {
39 nt_headers = (IMAGE_NT_HEADERS *) ((char *)dos_header
40 + dos_header->e_lfanew);
41 if (nt_headers->Signature == IMAGE_NT_SIGNATURE &&
42 hinstDLL !=
43 (HINSTANCE) (nt_headers->OptionalHeader.ImageBase))
44 OPENSSL_NONPIC_relocated = 1;
45 }
46 }
47# endif
48 break;
49 case DLL_THREAD_ATTACH:
50 break;
51 case DLL_THREAD_DETACH:
52 OPENSSL_thread_stop();
53 break;
54 case DLL_PROCESS_DETACH:
55 break;
56 }
57 return (TRUE);
58}
59#endif
60