dllmain.c 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /** BEGIN COPYRIGHT BLOCK
  2. * Copyright 2001 Sun Microsystems, Inc.
  3. * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
  4. * All rights reserved.
  5. * END COPYRIGHT BLOCK **/
  6. /*
  7. * Microsoft Windows specifics for LIBPWDSTORAGE DLL
  8. */
  9. #include "rever.h"
  10. #ifdef _WIN32
  11. /* Lifted from Q125688
  12. * How to Port a 16-bit DLL to a Win32 DLL
  13. * on the MSVC 4.0 CD
  14. */
  15. BOOL WINAPI DllMain (HANDLE hModule, DWORD fdwReason, LPVOID lpReserved)
  16. {
  17. switch (fdwReason)
  18. {
  19. case DLL_PROCESS_ATTACH:
  20. /* Code from LibMain inserted here. Return TRUE to keep the
  21. DLL loaded or return FALSE to fail loading the DLL.
  22. You may have to modify the code in your original LibMain to
  23. account for the fact that it may be called more than once.
  24. You will get one DLL_PROCESS_ATTACH for each process that
  25. loads the DLL. This is different from LibMain which gets
  26. called only once when the DLL is loaded. The only time this
  27. is critical is when you are using shared data sections.
  28. If you are using shared data sections for statically
  29. allocated data, you will need to be careful to initialize it
  30. only once. Check your code carefully.
  31. Certain one-time initializations may now need to be done for
  32. each process that attaches. You may also not need code from
  33. your original LibMain because the operating system may now
  34. be doing it for you.
  35. */
  36. /*
  37. * 16 bit code calls UnlockData()
  38. * which is mapped to UnlockSegment in windows.h
  39. * in 32 bit world UnlockData is not defined anywhere
  40. * UnlockSegment is mapped to GlobalUnfix in winbase.h
  41. * and the docs for both UnlockSegment and GlobalUnfix say
  42. * ".. function is oboslete. Segments have no meaning
  43. * in the 32-bit environment". So we do nothing here.
  44. */
  45. break;
  46. case DLL_THREAD_ATTACH:
  47. /* Called each time a thread is created in a process that has
  48. already loaded (attached to) this DLL. Does not get called
  49. for each thread that exists in the process before it loaded
  50. the DLL.
  51. Do thread-specific initialization here.
  52. */
  53. break;
  54. case DLL_THREAD_DETACH:
  55. /* Same as above, but called when a thread in the process
  56. exits.
  57. Do thread-specific cleanup here.
  58. */
  59. break;
  60. case DLL_PROCESS_DETACH:
  61. /* Code from _WEP inserted here. This code may (like the
  62. LibMain) not be necessary. Check to make certain that the
  63. operating system is not doing it for you.
  64. */
  65. break;
  66. }
  67. /* The return value is only used for DLL_PROCESS_ATTACH; all other
  68. conditions are ignored. */
  69. return TRUE; /* successful DLL_PROCESS_ATTACH */
  70. }
  71. #else
  72. int CALLBACK
  73. LibMain( HINSTANCE hinst, WORD wDataSeg, WORD cbHeapSize, LPSTR lpszCmdLine )
  74. {
  75. /*UnlockData( 0 );*/
  76. return( 1 );
  77. }
  78. #endif