Leaked source code of windows server 2003
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.

275 lines
6.5 KiB

  1. /*
  2. init.c initialisation for MSVIDEO.DLL
  3. Copyright (c) Microsoft Corporation 1992. All rights reserved
  4. */
  5. #include <windows.h>
  6. #include <win32.h>
  7. #include <verinfo.h> // to get rup and MMVERSION
  8. #include "mmsystem.h"
  9. #include "msviddrv.h"
  10. #include <vfw.h>
  11. #include "msvideoi.h"
  12. #ifdef _WIN32
  13. #include "profile.h"
  14. #endif
  15. #include "debug.h"
  16. /*
  17. * we have to allow the compman dll to perform load and unload
  18. * processing - among other things, it has a critsec that needs to
  19. * be initialised and freed
  20. */
  21. #ifdef _WIN32
  22. extern BOOL WINAPI ICDllEntryPoint(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);
  23. #else
  24. extern BOOL FAR PASCAL ICDllEntryPoint(DWORD dwReason, HINSTANCE hinstDLL, WORD wDS, WORD wHeapSize, DWORD dwReserved1, WORD wReserved2);
  25. #endif
  26. //
  27. //
  28. //
  29. #ifndef _WIN32
  30. extern void FAR PASCAL videoCleanup(HTASK hTask);
  31. #else
  32. #define videoCleanup(hTask) // Nothing to do for 32 bit code
  33. #endif
  34. extern void FAR PASCAL DrawDibCleanup(HTASK hTask);
  35. extern void FAR PASCAL ICCleanup(HTASK hTask);
  36. //--------------------------------------------------------------------------;
  37. //
  38. //
  39. // -- == DLL Initialization entry points == --
  40. //
  41. //
  42. //--------------------------------------------------------------------------;
  43. /*****************************************************************************
  44. * Variables
  45. *
  46. ****************************************************************************/
  47. HINSTANCE ghInst; // our module handle
  48. BOOL gfIsRTL;
  49. // dont change this without changing DRAWDIB\PROFDISP.C & MSVIDEO.RC
  50. #define IDS_ISRTL 4003
  51. #ifdef _WIN32
  52. /*****************************************************************************
  53. * @doc INTERNAL VIDEO
  54. *
  55. * DLLEntryPoint - Standard 32-bit DLL entry point.
  56. *
  57. ****************************************************************************/
  58. BOOL WINAPI DLLEntryPoint (
  59. HINSTANCE hInstance,
  60. ULONG Reason,
  61. LPVOID pv)
  62. {
  63. BOOL fReturn = TRUE;
  64. switch (Reason)
  65. {
  66. TCHAR ach[2];
  67. case DLL_PROCESS_ATTACH:
  68. DbgInitialize(TRUE);
  69. ghInst = hInstance;
  70. LoadString(ghInst, IDS_ISRTL, ach, sizeof(ach)/sizeof(TCHAR));
  71. gfIsRTL = ach[0] == TEXT('1');
  72. DisableThreadLibraryCalls(hInstance);
  73. fReturn = ICDllEntryPoint(hInstance, Reason, pv);
  74. break;
  75. case DLL_PROCESS_DETACH:
  76. DrawDibCleanup(NULL);
  77. ICCleanup(NULL);
  78. ICDllEntryPoint(hInstance, Reason, pv);
  79. videoCleanup(NULL);
  80. CloseKeys();
  81. break;
  82. //case DLL_THREAD_DETACH:
  83. // break;
  84. //case DLL_THREAD_ATTACH:
  85. // break;
  86. }
  87. return TRUE;
  88. }
  89. #else
  90. //--------------------------------------------------------------------------;
  91. //
  92. // BOOL DllEntryPoint
  93. //
  94. // Description:
  95. // This is a special 16-bit entry point called by the Chicago kernel
  96. // for thunk initialization and cleanup. It is called on each usage
  97. // increment or decrement. Do not call GetModuleUsage within this
  98. // function as it is undefined whether the usage is updated before
  99. // or after this DllEntryPoint is called.
  100. //
  101. // Arguments:
  102. // DWORD dwReason:
  103. // 1 - attach (usage increment)
  104. // 0 - detach (usage decrement)
  105. //
  106. // HINSTANCE hinst:
  107. //
  108. // WORD wDS:
  109. //
  110. // WORD wHeapSize:
  111. //
  112. // DWORD dwReserved1:
  113. //
  114. // WORD wReserved2:
  115. //
  116. // Return (BOOL):
  117. //
  118. // Notes:
  119. // DAYTONA 16-bit builds (ie, WOW):
  120. // We call this function from LibEntry.asm. Daytona WOW does not
  121. // call this function directly. Since we only call it from
  122. // LibEntry and WEP, cUsage just bounces between 0 and 1.
  123. //
  124. // CHICAGO 16-bit builds:
  125. // The Chicago kernel calls this directly for every usage increment
  126. // and decrement. cUsage will track the usages and init or terminate
  127. // appropriately.
  128. //
  129. // History:
  130. // 07/07/94 [frankye]
  131. //
  132. //--------------------------------------------------------------------------;
  133. BOOL FAR PASCAL _export DllEntryPoint
  134. (
  135. DWORD dwReason,
  136. HINSTANCE hInstance,
  137. WORD wDS,
  138. WORD wHeapSize,
  139. DWORD dwReserved1,
  140. WORD wReserved2
  141. )
  142. {
  143. static UINT cUsage = 0;
  144. switch (dwReason)
  145. {
  146. case 1:
  147. {
  148. //
  149. // Usage increment
  150. //
  151. cUsage++;
  152. ASSERT( 0 != cUsage );
  153. if (1 == cUsage)
  154. {
  155. TCHAR ach[2];
  156. DbgInitialize(TRUE);
  157. ghInst = hInstance;
  158. LoadString(ghInst, IDS_ISRTL, ach, sizeof(ach)/sizeof(TCHAR));
  159. gfIsRTL = ach[0] == TEXT('1');
  160. }
  161. //
  162. // Call ICProcessAttach on _every_ usage increment. On Chicago,
  163. // the ICM stuff needs to be aware of all processes that load
  164. // and free this dll. The only way to do this is to allow it to
  165. // look at stuff on every usage delta.
  166. //
  167. ICProcessAttach();
  168. return TRUE;
  169. }
  170. case 0:
  171. {
  172. //
  173. // Usage decrement
  174. //
  175. ASSERT( 0 != cUsage );
  176. cUsage--;
  177. if (0 == cUsage)
  178. {
  179. DrawDibCleanup(NULL);
  180. ICCleanup(NULL);
  181. }
  182. //
  183. // Call ICProcessDetach on _every_ usage increment. On Chicago,
  184. // the ICM stuff needs to be aware of all processes that load
  185. // and free this dll. The only way to do this is to allow it to
  186. // look at stuff on every usage delta.
  187. //
  188. ICProcessDetach();
  189. if (0 == cUsage)
  190. {
  191. videoCleanup(NULL);
  192. }
  193. return TRUE;
  194. }
  195. }
  196. return TRUE;
  197. }
  198. #endif
  199. //--------------------------------------------------------------------------;
  200. //
  201. //
  202. //
  203. //
  204. //--------------------------------------------------------------------------;
  205. /*****************************************************************************
  206. * @doc EXTERNAL VIDEO
  207. *
  208. * @api DWORD | VideoForWindowsVersion | This function returns the version
  209. * of the Microsoft Video for Windows software.
  210. *
  211. * @rdesc Returns a DWORD version, the hiword is the product version the
  212. * loword is the minor revision.
  213. *
  214. * @comm currently returns 0x010A00## (1.10.00.##) ## is the internal build
  215. * number.
  216. *
  217. ****************************************************************************/
  218. #if 0
  219. #ifdef rup
  220. #define MSVIDEO_VERSION (0x01000000l+rup) // 1.00.00.##
  221. #else
  222. #define MSVIDEO_VERSION (0x01000000l) // 1.00.00.00
  223. #endif
  224. #else
  225. #define MSVIDEO_VERSION (0x0L+(((DWORD)MMVERSION)<<24)+(((DWORD)MMREVISION)<<16)+((DWORD)MMRELEASE))
  226. #endif
  227. DWORD FAR PASCAL VideoForWindowsVersion(void)
  228. {
  229. return MSVIDEO_VERSION;
  230. }