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.

205 lines
4.0 KiB

  1. /*++
  2. Copyright (c) 1996-1999 Microsoft Corporation
  3. Module Name
  4. dllinit.cxx
  5. Abstract:
  6. Author:
  7. Mark Enstrom (marke) 23-Jun-1996
  8. Enviornment:
  9. User Mode
  10. Revision History:
  11. --*/
  12. #include "precomp.hxx"
  13. #pragma hdrstop
  14. INT gbCheckHandleLevel = 0;
  15. OSVERSIONINFO Win32VersionInformation;
  16. HMODULE ghddrawlib = 0;
  17. BOOL gbddraw = FALSE;
  18. PFNTRANSBLT gpfnTransparentBlt;
  19. PFNGRFILL gpfnGradientFill;
  20. PFNALPHABLEND gpfnAlphaBlend;
  21. PFN_GETSURFACEFROMDC pfnGetSurfaceFromDC=NULL;
  22. extern "C" {
  23. BOOLEAN
  24. DllInitialize(
  25. PVOID pvDllHandle,
  26. ULONG ulReason,
  27. PCONTEXT pcontext
  28. );
  29. }
  30. /*++
  31. Routine Description:
  32. Arguments
  33. Return Value
  34. --*/
  35. BOOLEAN
  36. DllInitialize(
  37. PVOID pvDllHandle,
  38. ULONG ulReason,
  39. PCONTEXT pcontext)
  40. {
  41. NTSTATUS status = 0;
  42. INT i;
  43. BOOLEAN fServer;
  44. PTEB pteb = NtCurrentTeb();
  45. BOOLEAN bRet = TRUE;
  46. HMODULE hlib;
  47. switch (ulReason)
  48. {
  49. case DLL_PROCESS_ATTACH:
  50. //
  51. // We don't want to get DLL_THREAD_ATTACH and DLL_THREAD_DETACH messages
  52. //
  53. DisableThreadLibraryCalls ((HMODULE) pvDllHandle);
  54. //
  55. // determine os version
  56. //
  57. Win32VersionInformation.dwOSVersionInfoSize = sizeof(Win32VersionInformation);
  58. if (!GetVersionEx(&Win32VersionInformation))
  59. {
  60. //
  61. // default win95
  62. //
  63. Win32VersionInformation.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS;
  64. }
  65. //
  66. // resolve API enrty points
  67. //
  68. #if !(_WIN32_WINNT >= 0x500)
  69. hlib=LoadLibrary (TEXT("gdi32.dll"));
  70. gpfnTransparentBlt = (PFNTRANSBLT)GetProcAddress (hlib, "GdiTransparentBlt");
  71. if (!gpfnTransparentBlt)
  72. {
  73. gpfnTransparentBlt = WinTransparentBlt;
  74. }
  75. gpfnGradientFill = (PFNGRFILL)GetProcAddress (hlib, "GdiGradientFill");
  76. if (!gpfnGradientFill)
  77. {
  78. gpfnGradientFill = WinGradientFill;
  79. }
  80. gpfnAlphaBlend = (PFNALPHABLEND)GetProcAddress (hlib, "GdiAlphaBlend");
  81. if (!gpfnAlphaBlend)
  82. {
  83. gpfnAlphaBlend = WinAlphaBlend;
  84. }
  85. FreeLibrary(hlib);
  86. //
  87. // Is this an MMX processor
  88. //
  89. #if defined(_X86_)
  90. gbMMX = bIsMMXProcessor();
  91. #endif
  92. //
  93. // alpha blending init
  94. //
  95. bInitAlpha();
  96. ghddrawlib = GetModuleHandleA("ddraw");
  97. if (ghddrawlib)
  98. {
  99. Dprintf("GetModuleHandleA succeed\n");
  100. //
  101. // ddraw is already loaded, increment the reference count
  102. // so it won't get released while we are using it
  103. //
  104. ghddrawlib = LoadLibrary (TEXT("ddraw.dll"));
  105. Dprintf("LoadLibrary returns %x", ghddrawlib);
  106. if (ghddrawlib)
  107. {
  108. gbddraw = TRUE;
  109. pfnGetSurfaceFromDC = (PFN_GETSURFACEFROMDC)GetProcAddress(
  110. ghddrawlib, "GetSurfaceFromDC");
  111. }
  112. }
  113. #else
  114. gpfnTransparentBlt = GdiTransparentBlt;
  115. gpfnGradientFill = GdiGradientFill;
  116. gpfnAlphaBlend = GdiAlphaBlend;
  117. #endif
  118. #if 0
  119. gpfnAlphaBlend = WinAlphaBlend;
  120. gpfnGradientFill = WinGradientFill;
  121. gpfnTransparentBlt = WinTransparentBlt;
  122. #endif
  123. break;
  124. case DLL_THREAD_ATTACH:
  125. break;
  126. case DLL_PROCESS_DETACH:
  127. #if !(_WIN32_WINNT >= 0x500)
  128. CleanupGlobals();
  129. #endif
  130. if (ghddrawlib)
  131. {
  132. FreeLibrary(ghddrawlib);
  133. }
  134. break;
  135. case DLL_THREAD_DETACH:
  136. break;
  137. }
  138. return(bRet);
  139. pcontext;
  140. }