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.

117 lines
2.4 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. WaveOutUsePreferredDevice.cpp
  5. Abstract:
  6. Force the use of the preferred waveOut device (rather than a specific device)
  7. Notes:
  8. This is a general purpose shim.
  9. History:
  10. 06/02/1999 robkenny Created
  11. --*/
  12. #include "precomp.h"
  13. IMPLEMENT_SHIM_BEGIN(WaveOutUsePreferredDevice)
  14. #include "ShimHookMacro.h"
  15. APIHOOK_ENUM_BEGIN
  16. APIHOOK_ENUM_ENTRY(waveOutOpen)
  17. APIHOOK_ENUM_ENTRY(waveOutGetDevCapsA)
  18. APIHOOK_ENUM_ENTRY(waveOutGetDevCapsW)
  19. APIHOOK_ENUM_ENTRY(wod32Message)
  20. APIHOOK_ENUM_END
  21. /*+
  22. Call waveOutOpen, saving dwCallback if it is a function.
  23. --*/
  24. MMRESULT APIHOOK(waveOutOpen)(
  25. LPHWAVEOUT phwo,
  26. UINT uDeviceID,
  27. LPWAVEFORMATEX pwfx,
  28. DWORD dwCallback,
  29. DWORD dwCallbackInstance,
  30. DWORD fdwOpen
  31. )
  32. {
  33. MMRESULT returnValue = ORIGINAL_API(waveOutOpen)(phwo, WAVE_MAPPER, pwfx, dwCallback, dwCallbackInstance, fdwOpen);
  34. return returnValue;
  35. }
  36. MMRESULT APIHOOK(waveOutGetDevCapsA)(
  37. UINT uDeviceID,
  38. LPWAVEOUTCAPSA pwoc,
  39. UINT cbwoc)
  40. {
  41. MMRESULT returnValue = ORIGINAL_API(waveOutGetDevCapsA)(WAVE_MAPPER, pwoc, cbwoc);
  42. return returnValue;
  43. }
  44. MMRESULT APIHOOK(waveOutGetDevCapsW)(
  45. UINT uDeviceID,
  46. LPWAVEOUTCAPSW pwoc,
  47. UINT cbwoc)
  48. {
  49. MMRESULT returnValue = ORIGINAL_API(waveOutGetDevCapsW)(WAVE_MAPPER, pwoc, cbwoc);
  50. return returnValue;
  51. }
  52. /*+
  53. Catch the 16 bit applications, WOW calls this routine for 16 bit apps.
  54. --*/
  55. #define WODM_GETDEVCAPS 4
  56. #define WODM_OPEN 5
  57. DWORD APIHOOK(wod32Message)(
  58. UINT uDeviceID,
  59. UINT uMessage,
  60. DWORD dwInstance,
  61. DWORD dwParam1,
  62. DWORD dwParam2
  63. )
  64. {
  65. // Change device 0 to WAVE_MAPPER for Open and GetDevCaps
  66. if (uDeviceID == 0) {
  67. if (uMessage == WODM_OPEN ||
  68. uMessage == WODM_GETDEVCAPS) {
  69. uDeviceID = -1; // Force device to WAVE_MAPPER
  70. }
  71. }
  72. MMRESULT returnValue = ORIGINAL_API(wod32Message)(uDeviceID, uMessage, dwInstance, dwParam1, dwParam2);
  73. return returnValue;
  74. }
  75. /*++
  76. Register hooked functions
  77. --*/
  78. HOOK_BEGIN
  79. APIHOOK_ENTRY(WINMM.DLL, waveOutOpen)
  80. APIHOOK_ENTRY(WINMM.DLL, waveOutGetDevCapsA)
  81. APIHOOK_ENTRY(WINMM.DLL, waveOutGetDevCapsW)
  82. APIHOOK_ENTRY(WINMM.DLL, wod32Message)
  83. HOOK_END
  84. IMPLEMENT_SHIM_END