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
2.9 KiB

  1. /*++
  2. Copyright (c) 2002 Microsoft Corporation
  3. Module Name:
  4. ViaVoice8J.cpp
  5. Abstract:
  6. ViaVoice8J mutes Master and Wave volume on Win XP. Disable mute. ViaVoice8J
  7. installs riched20.dll and riched32.dll. These old dll prevent enroll wizard
  8. richedit working properly on Win XP. Remove those.
  9. Notes:
  10. This is an app specific shim.
  11. History:
  12. 06/03/2002 hioh Created
  13. --*/
  14. #include "precomp.h"
  15. IMPLEMENT_SHIM_BEGIN(ViaVoice8J)
  16. #include "ShimHookMacro.h"
  17. typedef MMRESULT (WINAPI *_pfn_mixerSetControlDetails)(HMIXEROBJ hmxobj, LPMIXERCONTROLDETAILS pmxcd, DWORD fdwDetails);
  18. APIHOOK_ENUM_BEGIN
  19. APIHOOK_ENUM_ENTRY(mixerSetControlDetails)
  20. APIHOOK_ENUM_END
  21. /*++
  22. Disregard mute when fdwDetails is 0.
  23. --*/
  24. MMRESULT
  25. APIHOOK(mixerSetControlDetails)(
  26. HMIXEROBJ hmxobj,
  27. LPMIXERCONTROLDETAILS pmxcd,
  28. DWORD fdwDetails)
  29. {
  30. if (fdwDetails == 0) {
  31. return (0);
  32. }
  33. return ORIGINAL_API(mixerSetControlDetails)(hmxobj, pmxcd, fdwDetails);
  34. }
  35. /*++
  36. Remove installed \bin\riched20.dll & \bin\riched32.dll
  37. --*/
  38. BOOL
  39. NOTIFY_FUNCTION(
  40. DWORD fdwReason)
  41. {
  42. if (fdwReason == DLL_PROCESS_DETACH) {
  43. CSTRING_TRY
  44. {
  45. HKEY hKey;
  46. WCHAR szRegDir[] = L"SOFTWARE\\IBM\\ViaVoice Runtimes\\RTConfig";
  47. // Get ViaVoice Registry
  48. if (ERROR_SUCCESS == RegOpenKeyExW(HKEY_LOCAL_MACHINE, szRegDir, 0,
  49. KEY_QUERY_VALUE, &hKey)) {
  50. WCHAR szRegBin[] = L"bin";
  51. DWORD dwType;
  52. WCHAR szDir[MAX_PATH];
  53. DWORD cbData = sizeof(szDir);
  54. // Get installed directory
  55. if (ERROR_SUCCESS == RegQueryValueExW(hKey, szRegBin, NULL, &dwType,
  56. (LPBYTE) szDir, &cbData)) {
  57. RegCloseKey(hKey);
  58. // Delete problem richedit files
  59. CString csDel;
  60. csDel = szDir;
  61. csDel += L"\\riched20.dll";
  62. if (INVALID_FILE_ATTRIBUTES != GetFileAttributesW(csDel)) {
  63. // Delete riched20.dll
  64. DeleteFileW(csDel);
  65. }
  66. csDel = szDir;
  67. csDel += L"\\riched32.dll";
  68. if (INVALID_FILE_ATTRIBUTES != GetFileAttributesW(csDel)) {
  69. // Delete riched32.dll
  70. DeleteFileW(csDel);
  71. }
  72. }
  73. }
  74. }
  75. CSTRING_CATCH
  76. {
  77. // Do nothing
  78. }
  79. }
  80. return TRUE;
  81. }
  82. /*++
  83. Register hooked functions
  84. --*/
  85. HOOK_BEGIN
  86. CALL_NOTIFY_FUNCTION
  87. APIHOOK_ENTRY(WINMM.DLL, mixerSetControlDetails)
  88. HOOK_END
  89. IMPLEMENT_SHIM_END