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.

99 lines
1.7 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. ForceDirectDrawEmulation.cpp
  5. Abstract:
  6. Some applications don't handle aspects of hardware acceleration correctly.
  7. For example, Dragon Lore 2 creates a surface and assumes that the pitch is
  8. double the width for 16bpp. However, this is not always the case.
  9. DirectDraw exposes this through the lPitch parameter when a surface is
  10. locked.
  11. The fix is to force DirectDraw into emulation, in which case all surfaces
  12. will be in system memory and so the pitch really will be related to the
  13. width.
  14. Notes:
  15. This is a general purpose shim.
  16. History:
  17. 03/11/2000 linstev Created
  18. --*/
  19. #include "precomp.h"
  20. IMPLEMENT_SHIM_BEGIN(ForceDirectDrawEmulation)
  21. #include "ShimHookMacro.h"
  22. APIHOOK_ENUM_BEGIN
  23. APIHOOK_ENUM_ENTRY(RegQueryValueExA)
  24. APIHOOK_ENUM_END
  25. /*++
  26. Force DirectDraw into emulation.
  27. --*/
  28. LONG
  29. APIHOOK(RegQueryValueExA)(
  30. HKEY hKey,
  31. LPSTR lpValueName,
  32. LPDWORD lpReserved,
  33. LPDWORD lpType,
  34. LPBYTE lpData,
  35. LPDWORD lpcbData
  36. )
  37. {
  38. if (_tcsicmp("EmulationOnly", lpValueName) == 0)
  39. {
  40. if (lpType)
  41. {
  42. *lpType = REG_DWORD;
  43. }
  44. if (lpData)
  45. {
  46. *((DWORD *)lpData) = 1;
  47. }
  48. if (lpcbData)
  49. {
  50. *lpcbData = 4;
  51. }
  52. return ERROR_SUCCESS;
  53. }
  54. return ORIGINAL_API(RegQueryValueExA)(
  55. hKey,
  56. lpValueName,
  57. lpReserved,
  58. lpType,
  59. lpData,
  60. lpcbData);
  61. }
  62. /*++
  63. Register hooked functions
  64. --*/
  65. HOOK_BEGIN
  66. APIHOOK_ENTRY(ADVAPI32.DLL, RegQueryValueExA)
  67. HOOK_END
  68. IMPLEMENT_SHIM_END