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.

102 lines
1.6 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. AliensVsPredator.cpp
  5. Abstract:
  6. The app calls a Bink API to outside of a BinkOpen/BinkClose call. This is
  7. a synchronization issue fixed by delaying the BinkClose call.
  8. Notes:
  9. This is an app specific shim.
  10. History:
  11. 01/12/2001 linstev Created
  12. --*/
  13. #include "precomp.h"
  14. IMPLEMENT_SHIM_BEGIN(AliensVsPredator)
  15. #include "ShimHookMacro.h"
  16. typedef DWORD (WINAPI *_pfn_BinkOpen)(DWORD dw1, DWORD dw2);
  17. typedef BOOL (WINAPI *_pfn_BinkClose)(DWORD dw1);
  18. APIHOOK_ENUM_BEGIN
  19. APIHOOK_ENUM_ENTRY(BinkOpen)
  20. APIHOOK_ENUM_ENTRY(BinkClose)
  21. APIHOOK_ENUM_END
  22. DWORD g_dwLast = 0;
  23. BOOL g_bReal = FALSE;
  24. /*++
  25. Close the last handle.
  26. --*/
  27. DWORD
  28. APIHOOK(BinkOpen)(
  29. DWORD dw1,
  30. DWORD dw2
  31. )
  32. {
  33. if (g_dwLast)
  34. {
  35. DPFN( eDbgLevelInfo, "Closing most recent Bink handle");
  36. g_bReal = TRUE;
  37. ORIGINAL_API(BinkClose)(g_dwLast);
  38. g_bReal = FALSE;
  39. g_dwLast = 0;
  40. }
  41. return ORIGINAL_API(BinkOpen)(dw1, dw2);
  42. }
  43. /*++
  44. Cache the handle
  45. --*/
  46. BOOL
  47. APIHOOK(BinkClose)(
  48. DWORD dw1
  49. )
  50. {
  51. if (g_bReal)
  52. {
  53. return ORIGINAL_API(BinkClose)(dw1);
  54. }
  55. else
  56. {
  57. DPFN( eDbgLevelInfo, "Delaying BinkClose");
  58. g_dwLast = dw1;
  59. return 1;
  60. }
  61. }
  62. /*++
  63. Register hooked functions
  64. --*/
  65. HOOK_BEGIN
  66. APIHOOK_ENTRY_NAME(BINKW32.DLL, BinkOpen, _BinkOpen@8)
  67. APIHOOK_ENTRY_NAME(BINKW32.DLL, BinkClose, _BinkClose@4)
  68. HOOK_END
  69. IMPLEMENT_SHIM_END