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.

97 lines
2.1 KiB

  1. /*
  2. Copyright (c) 2001 Microsoft Corporation
  3. Module Name:
  4. NHL2001.cpp
  5. Abstract:
  6. EA Sports' NHL 2001 has a bug where if the platform returned by
  7. GetVersionExA is not windows, they don't call the GetDiskFreeSpace and
  8. then report no free space to create a tournament season or playoff.
  9. Unfortunately, a generic version lie does not work because the game is
  10. safedisk protected, so we both apps to have the same GetVesionExA.
  11. History:
  12. 06/04/2001 pierreys Created
  13. */
  14. #include "precomp.h"
  15. #include <stdio.h>
  16. IMPLEMENT_SHIM_BEGIN(NHL2001)
  17. #include "ShimHookMacro.h"
  18. APIHOOK_ENUM_BEGIN
  19. APIHOOK_ENUM_ENTRY(GetVersionExA)
  20. APIHOOK_ENUM_ENTRY(GetDiskFreeSpaceA)
  21. APIHOOK_ENUM_END
  22. BOOL fGetDiskFreeSpaceCalled = FALSE;
  23. BOOL
  24. APIHOOK(GetDiskFreeSpaceA)(
  25. LPCSTR lpRootPathName,
  26. LPDWORD lpSectorsPerCluster,
  27. LPDWORD lpBytesPerSector,
  28. LPDWORD lpNumberOfFreeClusters,
  29. LPDWORD lpTotalNumberOfClusters
  30. )
  31. {
  32. //
  33. // Take notice of the call
  34. //
  35. fGetDiskFreeSpaceCalled = TRUE;
  36. //
  37. // Call the original API
  38. //
  39. return ORIGINAL_API(GetDiskFreeSpaceA)(
  40. lpRootPathName,
  41. lpSectorsPerCluster,
  42. lpBytesPerSector,
  43. lpNumberOfFreeClusters,
  44. lpTotalNumberOfClusters);
  45. }
  46. BOOL
  47. APIHOOK(GetVersionExA)(LPOSVERSIONINFOA lpVersionInformation)
  48. {
  49. if (fGetDiskFreeSpaceCalled)
  50. {
  51. LOGN(
  52. eDbgLevelInfo,
  53. "[GetVersionExA] called after GetDiskFreeSpace. return Win98.");
  54. // Fixup the structure with the Win98 data
  55. lpVersionInformation->dwMajorVersion = 4;
  56. lpVersionInformation->dwMinorVersion = 10;
  57. lpVersionInformation->dwBuildNumber = 0x040A08AE;
  58. lpVersionInformation->dwPlatformId = 1;
  59. *lpVersionInformation->szCSDVersion = '\0';
  60. return TRUE;
  61. }
  62. else
  63. {
  64. return ORIGINAL_API(GetVersionExA)(lpVersionInformation);
  65. }
  66. }
  67. HOOK_BEGIN
  68. APIHOOK_ENTRY(KERNEL32.DLL, GetVersionExA)
  69. APIHOOK_ENTRY(KERNEL32.DLL, GetDiskFreeSpaceA)
  70. HOOK_END
  71. IMPLEMENT_SHIM_END