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.

124 lines
3.0 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 + 1];
  38. if (RegEnumKeyW(hKey, i, wzSubKey, MAX_PATH + 1) == 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. DWORD dwType;
  48. WCHAR wzValue[MAX_PATH + 1] = L"\0";
  49. DWORD cbData = sizeof(wzValue);
  50. LONG lRet = RegQueryValueExW(hSubKey, THRASH_DRIVER, NULL, &dwType, (LPBYTE) wzValue, &cbData);
  51. if ((lRet == ERROR_SUCCESS) &&
  52. (dwType == REG_SZ) &&
  53. (_wcsnicmp(wzValue, VOODOOX, wcslen(VOODOOX)) == 0)) {
  54. cbData = (wcslen(DIRECTX) + 1) * sizeof(WCHAR);
  55. lRet = RegSetValueExW(hSubKey, THRASH_DRIVER, 0, REG_SZ, (LPBYTE) DIRECTX, cbData);
  56. if (lRet == ERROR_SUCCESS) {
  57. LOGN(eDbgLevelError, "Modified VOODOO Thrash driver to DX");
  58. } else {
  59. LOGN(eDbgLevelError, "Failed to set VOODOO Thrash driver to DX");
  60. }
  61. }
  62. RegCloseKey(hSubKey);
  63. }
  64. } else {
  65. // Done
  66. break;
  67. }
  68. }
  69. RegCloseKey(hKey);
  70. }
  71. }
  72. /*++
  73. Register hooked functions
  74. --*/
  75. BOOL
  76. NOTIFY_FUNCTION(
  77. DWORD fdwReason)
  78. {
  79. if (fdwReason == DLL_PROCESS_DETACH) {
  80. CleanupVoodoo();
  81. }
  82. return TRUE;
  83. }
  84. HOOK_BEGIN
  85. CALL_NOTIFY_FUNCTION
  86. HOOK_END
  87. IMPLEMENT_SHIM_END