A local copy of OpenSSL from GitHub
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.4 KiB

  1. #include "internal/cryptlib_int.h"
  2. #if defined(_WIN32) || defined(__CYGWIN__)
  3. # ifdef __CYGWIN__
  4. /* pick DLL_[PROCESS|THREAD]_[ATTACH|DETACH] definitions */
  5. # include <windows.h>
  6. /*
  7. * this has side-effect of _WIN32 getting defined, which otherwise is
  8. * mutually exclusive with __CYGWIN__...
  9. */
  10. # endif
  11. /*
  12. * All we really need to do is remove the 'error' state when a thread
  13. * detaches
  14. */
  15. BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);
  16. BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
  17. {
  18. switch (fdwReason) {
  19. case DLL_PROCESS_ATTACH:
  20. OPENSSL_cpuid_setup();
  21. # if defined(_WIN32_WINNT)
  22. {
  23. IMAGE_DOS_HEADER *dos_header = (IMAGE_DOS_HEADER *) hinstDLL;
  24. IMAGE_NT_HEADERS *nt_headers;
  25. if (dos_header->e_magic == IMAGE_DOS_SIGNATURE) {
  26. nt_headers = (IMAGE_NT_HEADERS *) ((char *)dos_header
  27. + dos_header->e_lfanew);
  28. if (nt_headers->Signature == IMAGE_NT_SIGNATURE &&
  29. hinstDLL !=
  30. (HINSTANCE) (nt_headers->OptionalHeader.ImageBase))
  31. OPENSSL_NONPIC_relocated = 1;
  32. }
  33. }
  34. # endif
  35. break;
  36. case DLL_THREAD_ATTACH:
  37. break;
  38. case DLL_THREAD_DETACH:
  39. OPENSSL_thread_stop();
  40. break;
  41. case DLL_PROCESS_DETACH:
  42. break;
  43. }
  44. return (TRUE);
  45. }
  46. #endif