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.

126 lines
2.9 KiB

  1. /*++
  2. Copyright (c) 2002 Microsoft Corporation
  3. Module Name:
  4. EA3dSetup.cpp
  5. Abstract:
  6. EA Sports titles use something called a "Thrash driver", which is just a
  7. graphics wrapper library. They currently appear to have at least 2 types,
  8. one for DX and one for Voodoo. The Voodoo version is not supported on NT,
  9. because it uses Glide.
  10. The fix is to modify the registry to prevent the voodoo driver from
  11. being used. The DirectX fallback works fine.
  12. Notes:
  13. This is a application specific shim.
  14. History:
  15. 01/29/2001 linstev Created
  16. --*/
  17. #include "precomp.h"
  18. IMPLEMENT_SHIM_BEGIN(EA3dSetup)
  19. #include "ShimHookMacro.h"
  20. APIHOOK_ENUM_BEGIN
  21. APIHOOK_ENUM_END
  22. /*++
  23. Cleanup voodoo thrash drivers if they're there.
  24. --*/
  25. void CleanupVoodoo()
  26. {
  27. #define EA_SPORTS_KEY L"SOFTWARE\\EA SPORTS"
  28. #define THRASH_DRIVER L"Thrash Driver"
  29. #define VOODOOX L"voodoo"
  30. #define DIRECTX L"dx"
  31. HKEY hKey;
  32. if (RegOpenKeyW(HKEY_LOCAL_MACHINE, EA_SPORTS_KEY, &hKey) == ERROR_SUCCESS) {
  33. //
  34. // At least 1 EA Sports title exists, so enumerate through them
  35. //
  36. for (int i=0;; i++) {
  37. WCHAR wzSubKey[MAX_PATH];
  38. if (RegEnumKeyW(hKey, i, wzSubKey, MAX_PATH) == ERROR_SUCCESS) {
  39. //
  40. // Check the THRASH_DRIVER key for voodoo*
  41. //
  42. HKEY hSubKey;
  43. if (RegOpenKeyW(hKey, wzSubKey, &hSubKey) == ERROR_SUCCESS) {
  44. //
  45. // Set the value to "dx" if it's voodoo
  46. //
  47. LONG lRet;
  48. DWORD dwType;
  49. WCHAR wzValue[MAX_PATH] = L"\0";
  50. DWORD dwLen = sizeof(wzValue);
  51. lRet = RegQueryValueExW(hSubKey, THRASH_DRIVER, NULL, &dwType,
  52. (LPBYTE) wzValue, &dwLen);
  53. if ((lRet == ERROR_SUCCESS) && (dwType == REG_SZ) &&
  54. (_wcsnicmp(wzValue, VOODOOX, wcslen(VOODOOX)) == 0)) {
  55. lRet = RegSetValueExW(hSubKey, THRASH_DRIVER, 0, REG_SZ,
  56. (LPBYTE) DIRECTX, wcslen(DIRECTX) * sizeof(WCHAR));
  57. if (lRet == ERROR_SUCCESS) {
  58. LOGN(eDbgLevelError, "Modified VOODOO Thrash driver to DX");
  59. } else {
  60. LOGN(eDbgLevelError, "Failed to set VOODOO Thrash driver to DX");
  61. }
  62. }
  63. RegCloseKey(hSubKey);
  64. }
  65. } else {
  66. // Done
  67. break;
  68. }
  69. }
  70. RegCloseKey(hKey);
  71. }
  72. }
  73. /*++
  74. Register hooked functions
  75. --*/
  76. BOOL
  77. NOTIFY_FUNCTION(
  78. DWORD fdwReason)
  79. {
  80. if (fdwReason == DLL_PROCESS_DETACH) {
  81. CleanupVoodoo();
  82. }
  83. return TRUE;
  84. }
  85. HOOK_BEGIN
  86. CALL_NOTIFY_FUNCTION
  87. HOOK_END
  88. IMPLEMENT_SHIM_END