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.

80 lines
1.8 KiB

  1. /*++
  2. Copyright (c) 2002 Microsoft Corporation
  3. Module Name:
  4. CorrectACMStreamOpen.cpp
  5. Abstract:
  6. This shim corrects the samples per block for acmStreamOpen so that
  7. it will pass IMA ADPCM's parameter validation.
  8. Notes:
  9. This is a general shim.
  10. History:
  11. 08/09/2002 mnikkel Created
  12. --*/
  13. #include "precomp.h"
  14. #include "msacmdrv.h"
  15. typedef MMRESULT (*_pfn_acmStreamOpen)(LPHACMSTREAM phas, HACMDRIVER had, LPWAVEFORMATEX pwfxSrc,
  16. LPWAVEFORMATEX pwfxDst, LPWAVEFILTER pwfltr, DWORD_PTR dwCallback,
  17. DWORD_PTR dwInstance, DWORD fdwOpen );
  18. IMPLEMENT_SHIM_BEGIN(CorrectACMStreamOpen)
  19. #include "ShimHookMacro.h"
  20. APIHOOK_ENUM_BEGIN
  21. APIHOOK_ENUM_ENTRY(acmStreamOpen)
  22. APIHOOK_ENUM_END
  23. /*++
  24. If the wSamplesPerBlock is 1017 samples change it to 505 samples
  25. so it will pass IMA ADPCM's parameter validation.
  26. --*/
  27. MMRESULT
  28. APIHOOK(acmStreamOpen)(
  29. LPHACMSTREAM phas,
  30. HACMDRIVER had,
  31. LPWAVEFORMATEX pwfxSrc,
  32. LPWAVEFORMATEX pwfxDst,
  33. LPWAVEFILTER pwfltr,
  34. DWORD_PTR dwCallback,
  35. DWORD_PTR dwInstance,
  36. DWORD fdwOpen
  37. )
  38. {
  39. if ( pwfxSrc &&
  40. (WAVE_FORMAT_IMA_ADPCM == pwfxSrc->wFormatTag) &&
  41. (256 == pwfxSrc->nBlockAlign) &&
  42. (1017 == ((LPIMAADPCMWAVEFORMAT)(pwfxSrc))->wSamplesPerBlock))
  43. {
  44. ((LPIMAADPCMWAVEFORMAT)(pwfxSrc))->wSamplesPerBlock = 505;
  45. DPFN( eDbgLevelError, "[acmStreamOpen] changing samples per block to 505");
  46. }
  47. return acmStreamOpen( phas, had, pwfxSrc, pwfxDst, pwfltr, dwCallback,
  48. dwInstance, fdwOpen);
  49. }
  50. /*++
  51. Register hooked functions
  52. --*/
  53. HOOK_BEGIN
  54. APIHOOK_ENTRY(MSACM32.DLL, acmStreamOpen)
  55. HOOK_END
  56. IMPLEMENT_SHIM_END