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.

115 lines
3.4 KiB

  1. /*++
  2. Copyright (c) 2000-2001 Microsoft Corporation
  3. Module Name:
  4. ShockwaveLocation.cpp
  5. Abstract:
  6. In Encarta Encyclopedia 2000 J DVD, Shockwave is accessible only by installed user's HKCU.
  7. \WINDOWS\System32\Macromed\Director\SwDir.dll is looking for Shockwave location in HKCU.
  8. For other users, this shim will create Shockwave location registry in HKCU if Shockwave folder exist
  9. and not exist in registry.
  10. Example:
  11. HKCU\Software\Macromedia\Shockwave\location\coreplayer
  12. (Default) REG_SZ "C:\WINDOWS\System32\Macromed\Shockwave\"
  13. HKCU\Software\Macromedia\Shockwave\location\coreplayerxtras
  14. (Default) REG_SZ "C:\WINDOWS\System32\Macromed\Shockwave\Xtras\"
  15. Notes:
  16. PopulateDefaultHKCUSettings shim does not work for this case 'cause the location include
  17. WINDOWS directry as REG_SZ and cannot be a static data.
  18. VirtualRegistry shim Redirector also not work 'cause sw70inst.exe does not use Reg API
  19. and use SWDIR.INF to install in HKCU.
  20. History:
  21. 04/27/2001 hioh Created
  22. --*/
  23. #include "precomp.h"
  24. IMPLEMENT_SHIM_BEGIN(ShockwaveLocation)
  25. #include "ShimHookMacro.h"
  26. APIHOOK_ENUM_BEGIN
  27. APIHOOK_ENUM_END
  28. /*++
  29. Add coreplayer & coreplayerxtras location in registry
  30. --*/
  31. BOOL
  32. NOTIFY_FUNCTION(
  33. DWORD fdwReason)
  34. {
  35. if (fdwReason == SHIM_STATIC_DLLS_INITIALIZED)
  36. {
  37. HKEY hKey;
  38. WCHAR szRegCP[] = L"Software\\Macromedia\\Shockwave\\location\\coreplayer";
  39. WCHAR szRegCPX[] = L"Software\\Macromedia\\Shockwave\\location\\coreplayerxtras";
  40. WCHAR szLocCP[MAX_PATH];
  41. WCHAR szLocCPX[MAX_PATH];
  42. // coreplayer
  43. if (ERROR_SUCCESS == RegOpenKeyExW(HKEY_CURRENT_USER, szRegCP, 0, KEY_QUERY_VALUE, &hKey))
  44. { // key exist, do nothing
  45. RegCloseKey(hKey);
  46. }
  47. else
  48. { // key not exist, set key
  49. GetSystemDirectoryW(szLocCP, sizeof(szLocCP)/sizeof(WCHAR));
  50. lstrcatW(szLocCP, L"\\Macromed\\Shockwave\\");
  51. if (GetFileAttributesW(szLocCP) != 0xffffffff)
  52. { // folder exist, create key
  53. if (ERROR_SUCCESS == RegCreateKeyExW(HKEY_CURRENT_USER, szRegCP, 0, 0, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, NULL))
  54. { // set location
  55. RegSetValueExW(hKey, NULL, 0, REG_SZ, (BYTE*)szLocCP, (DWORD)((lstrlenW(szLocCP)+1)*sizeof(WCHAR)));
  56. RegCloseKey(hKey);
  57. }
  58. }
  59. }
  60. // coreplayerxtras
  61. if (ERROR_SUCCESS == RegOpenKeyExW(HKEY_CURRENT_USER, szRegCPX, 0, KEY_QUERY_VALUE, &hKey))
  62. { // key exist, do nothing
  63. RegCloseKey(hKey);
  64. }
  65. else
  66. { // key not exist, set key
  67. GetSystemDirectoryW(szLocCPX, sizeof(szLocCPX)/sizeof(WCHAR));
  68. lstrcatW(szLocCPX, L"\\Macromed\\Shockwave\\Xtras\\");
  69. if (GetFileAttributesW(szLocCPX) != 0xffffffff)
  70. { // folder exist, create key
  71. if (ERROR_SUCCESS == RegCreateKeyExW(HKEY_CURRENT_USER, szRegCPX, 0, 0, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, NULL))
  72. { // set location
  73. RegSetValueExW(hKey, NULL, 0, REG_SZ, (BYTE*)szLocCPX, (DWORD)((lstrlenW(szLocCPX)+1)*sizeof(WCHAR)));
  74. RegCloseKey(hKey);
  75. }
  76. }
  77. }
  78. }
  79. return TRUE;
  80. }
  81. /*++
  82. Register hooked functions
  83. --*/
  84. HOOK_BEGIN
  85. CALL_NOTIFY_FUNCTION
  86. HOOK_END
  87. IMPLEMENT_SHIM_END