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.

130 lines
4.1 KiB

  1. /*++
  2. Copyright (c) 2000-2002 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. 03/07/2002 robkenny Security review.
  23. --*/
  24. #include "precomp.h"
  25. IMPLEMENT_SHIM_BEGIN(ShockwaveLocation)
  26. #include "ShimHookMacro.h"
  27. APIHOOK_ENUM_BEGIN
  28. APIHOOK_ENUM_END
  29. /*++
  30. Add coreplayer & coreplayerxtras location in registry
  31. --*/
  32. BOOL
  33. NOTIFY_FUNCTION(
  34. DWORD fdwReason)
  35. {
  36. if (fdwReason == SHIM_STATIC_DLLS_INITIALIZED)
  37. {
  38. HKEY hKey;
  39. WCHAR szRegCP[] = L"Software\\Macromedia\\Shockwave\\location\\coreplayer";
  40. WCHAR szRegCPX[] = L"Software\\Macromedia\\Shockwave\\location\\coreplayerxtras";
  41. WCHAR szLoc[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. UINT cchSystemDir = GetSystemDirectoryW(szLoc, ARRAYSIZE(szLoc));
  50. if (cchSystemDir > 0 && cchSystemDir < ARRAYSIZE(szLoc))
  51. {
  52. if (StringCchCatW(szLoc, MAX_PATH, L"\\Macromed\\Shockwave\\") == S_OK)
  53. {
  54. if (GetFileAttributesW(szLoc) != 0xffffffff)
  55. { // folder exist, create key
  56. if (ERROR_SUCCESS == RegCreateKeyExW(HKEY_CURRENT_USER, szRegCP, 0, 0, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, NULL))
  57. { // set location
  58. DWORD ccbLoc = (lstrlenW(szLoc) + 1) * sizeof(WCHAR);
  59. RegSetValueExW(hKey, NULL, 0, REG_SZ, (BYTE*)szLoc, ccbLoc);
  60. RegCloseKey(hKey);
  61. }
  62. }
  63. }
  64. }
  65. }
  66. // coreplayerxtras
  67. if (ERROR_SUCCESS == RegOpenKeyExW(HKEY_CURRENT_USER, szRegCPX, 0, KEY_QUERY_VALUE, &hKey))
  68. { // key exist, do nothing
  69. RegCloseKey(hKey);
  70. }
  71. else
  72. { // key not exist, set key
  73. UINT cchSystemDir = GetSystemDirectoryW(szLoc, ARRAYSIZE(szLoc));
  74. if (cchSystemDir > 0 && cchSystemDir < ARRAYSIZE(szLoc))
  75. {
  76. if (StringCchCatW(szLoc, MAX_PATH, L"\\Macromed\\Shockwave\\Xtras\\") == S_OK)
  77. {
  78. if (GetFileAttributesW(szLoc) != 0xffffffff)
  79. { // folder exist, create key
  80. if (ERROR_SUCCESS == RegCreateKeyExW(HKEY_CURRENT_USER, szRegCPX, 0, 0, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, NULL))
  81. { // set location
  82. DWORD ccbLoc = (lstrlenW(szLoc) + 1) * sizeof(WCHAR);
  83. RegSetValueExW(hKey, NULL, 0, REG_SZ, (BYTE*)szLoc, ccbLoc);
  84. RegCloseKey(hKey);
  85. }
  86. }
  87. }
  88. }
  89. }
  90. }
  91. return TRUE;
  92. }
  93. /*++
  94. Register hooked functions
  95. --*/
  96. HOOK_BEGIN
  97. CALL_NOTIFY_FUNCTION
  98. HOOK_END
  99. IMPLEMENT_SHIM_END