Source code of Windows XP (NT5)
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.

218 lines
4.4 KiB

  1. //==========================================================================;
  2. //
  3. // init.c
  4. //
  5. // Copyright (c) 1991-1993 Microsoft Corporation. All Rights Reserved.
  6. //
  7. // Description:
  8. //
  9. //
  10. // History:
  11. // 11/15/92 cjp [curtisp]
  12. //
  13. //==========================================================================;
  14. #include <windows.h>
  15. #include <windowsx.h>
  16. #include <mmsystem.h>
  17. #include <mmddk.h>
  18. #include <mmreg.h>
  19. #include <memory.h>
  20. #include <process.h>
  21. #ifdef WIN4
  22. //
  23. // WIN4 thunk connect function protos
  24. //
  25. #ifdef _WIN32
  26. BOOL PASCAL mciup_ThunkConnect32(LPCSTR pszDll16, LPCSTR pszDll32, HINSTANCE hinst, DWORD dwReason);
  27. #else
  28. BOOL FAR PASCAL mciup_ThunkConnect16(LPCSTR pszDll16, LPCSTR pszDll32, HINSTANCE hinst, DWORD dwReason);
  29. #endif
  30. #endif
  31. //
  32. //
  33. //
  34. //
  35. #ifdef WIN4
  36. char gmbszMCIAVI[] = "mciavi.drv";
  37. char gmbszMCIAVI32[] = "mciavi32.dll";
  38. #endif
  39. //==========================================================================;
  40. //
  41. // WIN 16 SPECIFIC SUPPORT
  42. //
  43. //==========================================================================;
  44. #ifndef _WIN32
  45. #ifdef WIN4
  46. //--------------------------------------------------------------------------;
  47. //
  48. //
  49. //
  50. //
  51. //
  52. //--------------------------------------------------------------------------;
  53. //--------------------------------------------------------------------------;
  54. //
  55. // BOOL DllEntryPoint
  56. //
  57. // Description:
  58. // This is a special 16-bit entry point called by the WIN4 kernel
  59. // for thunk initialization and cleanup. It is called on each usage
  60. // increment or decrement. Do not call GetModuleUsage within this
  61. // function as it is undefined whether the usage is updated before
  62. // or after this DllEntryPoint is called.
  63. //
  64. // Arguments:
  65. // DWORD dwReason:
  66. // 1 - attach (usage increment)
  67. // 0 - detach (usage decrement)
  68. //
  69. // HINSTANCE hinst:
  70. //
  71. // WORD wDS:
  72. //
  73. // WORD wHeapSize:
  74. //
  75. // DWORD dwReserved1:
  76. //
  77. // WORD wReserved2:
  78. //
  79. // Return (BOOL):
  80. //
  81. // Notes:
  82. // cEntered tracks reentry into DllEntryPoint. This may happen due to
  83. // the thunk connections
  84. //
  85. // History:
  86. // 02/02/94 [frankye]
  87. //
  88. //--------------------------------------------------------------------------;
  89. #pragma message ("--- Remove secret MSACM.INI AllowThunks ini switch")
  90. BOOL FAR PASCAL _export DllEntryPoint
  91. (
  92. DWORD dwReason,
  93. HINSTANCE hinst,
  94. WORD wDS,
  95. WORD wHeapSize,
  96. DWORD dwReserved1,
  97. WORD wReserved2
  98. )
  99. {
  100. static UINT cEntered = 0;
  101. BOOL f = TRUE;
  102. //
  103. // Track reentry
  104. //
  105. //
  106. cEntered++;
  107. switch (dwReason)
  108. {
  109. case 0:
  110. case 1:
  111. f = (0 != mciup_ThunkConnect16(gmbszMCIAVI, gmbszMCIAVI32,
  112. hinst, dwReason));
  113. break;
  114. default:
  115. f = TRUE;
  116. break;
  117. }
  118. //
  119. // Track reentry
  120. //
  121. //
  122. cEntered--;
  123. return (f);
  124. }
  125. #endif
  126. #else // _WIN32
  127. //==========================================================================;
  128. //
  129. // WIN 32 SPECIFIC SUPPORT
  130. //
  131. //==========================================================================;
  132. //--------------------------------------------------------------------------;
  133. //
  134. // BOOL DllEntryPoint
  135. //
  136. // Description:
  137. // This is the standard DLL entry point for Win 32.
  138. //
  139. // Arguments:
  140. // HINSTANCE hinst: Our instance handle.
  141. //
  142. // DWORD dwReason: The reason we've been called--process/thread attach
  143. // and detach.
  144. //
  145. // LPVOID lpReserved: Reserved. Should be NULL--so ignore it.
  146. //
  147. // Return (BOOL):
  148. // Returns non-zero if the initialization was successful and 0 otherwise.
  149. //
  150. // History:
  151. // 11/15/92 cjp [curtisp]
  152. // initial
  153. // 04/18/94 fdy [frankye]
  154. // major mods for WIN4. Yes, it looks real ugly now cuz of all
  155. // the conditional compilation for WIN4, daytona, etc. Don't
  156. // have time to think of good way to structure all this right now.
  157. //
  158. //--------------------------------------------------------------------------;
  159. BOOL CALLBACK DllEntryPoint
  160. (
  161. HINSTANCE hinst,
  162. DWORD dwReason,
  163. LPVOID lpReserved
  164. )
  165. {
  166. BOOL f = TRUE;
  167. //
  168. //
  169. //
  170. if (DLL_PROCESS_ATTACH == dwReason)
  171. {
  172. DisableThreadLibraryCalls(hinst);
  173. //
  174. // thunk connect
  175. //
  176. mciup_ThunkConnect32(gmbszMCIAVI, gmbszMCIAVI32, hinst, dwReason);
  177. }
  178. //
  179. //
  180. //
  181. if (DLL_PROCESS_DETACH == dwReason)
  182. {
  183. //
  184. // thunk disconnect
  185. //
  186. mciup_ThunkConnect32(gmbszMCIAVI, gmbszMCIAVI32, hinst, dwReason);
  187. }
  188. return (f);
  189. } // DllEntryPoint()
  190. #endif