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.

136 lines
3.5 KiB

  1. /*++
  2. Copyright (c) 2001 Microsoft Corporation
  3. Module Name:
  4. Gizmos.cpp
  5. Abstract:
  6. The Shredder and Vault Explorer extensions both call
  7. SetWindowLong(GWL_STYLE) with improper style values.
  8. Notes:
  9. This is an app specific shim.
  10. History:
  11. 04/12/2001 robkenny Created
  12. --*/
  13. #include "precomp.h"
  14. #include <shlguid.h>
  15. IMPLEMENT_SHIM_BEGIN(Gizmos)
  16. #include "ShimHookMacro.h"
  17. APIHOOK_ENUM_BEGIN
  18. APIHOOK_ENUM_ENTRY_COMSERVER(SHELLX98)
  19. APIHOOK_ENUM_END
  20. // This is the CLSID the application placed in the registry:
  21. // c500687e 11ceab3b 00006884 6b2768b4
  22. // Can't use the DEFINE_GUID macro, since INITGUID was not defined in the PCH.
  23. //DEFINE_GUID(CLSID_Gizmos, 0xc500687d, 0xab3b, 0x11ce, 0x84, 0x68, 0x00, 0x00, 0xb4, 0x68, 0x27, 0x6b);
  24. const GUID CLSID_Vault = { 0xc500687d, 0xab3b, 0x11ce, { 0x84, 0x68, 0x00, 0x00, 0xb4, 0x68, 0x27, 0x6b } };
  25. const GUID CLSID_Shredder = { 0xc500687e, 0xab3b, 0x11ce, { 0x84, 0x68, 0x00, 0x00, 0xb4, 0x68, 0x27, 0x6b } };
  26. typedef HRESULT (*_pfn_IShellFolder_CreateViewObject)(PVOID pThis, HWND hwndOwner, REFIID riid, VOID **ppv);
  27. typedef HRESULT (*_pfn_IShellView_CreateViewWindow)(PVOID pThis, IShellView *psvPrevious, LPCFOLDERSETTINGS pfs, IShellBrowser *psb, RECT *prcView, HWND *phWnd );
  28. IMPLEMENT_COMSERVER_HOOK(SHELLX98)
  29. /*++
  30. Convert Win9x paths to WinNT paths for IShellLinkW::SetPath
  31. --*/
  32. HRESULT COMHOOK(IShellFolder, CreateViewObject)(
  33. PVOID pThis,
  34. HWND hwndOwner,
  35. REFIID riid,
  36. VOID **ppv )
  37. {
  38. HRESULT hReturn = ORIGINAL_COM(IShellFolder, CreateViewObject, pThis)(pThis, hwndOwner, riid, ppv);
  39. if (hReturn == NOERROR)
  40. {
  41. // Only hook IShellView objects
  42. if (IsEqualGUID(riid, IID_IShellView))
  43. {
  44. // We don't know the CLSID, but since this routine is only called
  45. // for IShellFolder's that were created by ShellX98.dll;
  46. // we really don't need to know: it can only be one of the two
  47. // IShellFolder CLSID that we hooked.
  48. HookObject(
  49. NULL,
  50. riid,
  51. ppv,
  52. NULL,
  53. FALSE);
  54. }
  55. }
  56. return hReturn;
  57. }
  58. /*++
  59. Convert Win9x paths to WinNT paths for IShellLinkW::SetPath
  60. --*/
  61. HRESULT COMHOOK(IShellView, CreateViewWindow)(
  62. PVOID pThis,
  63. IShellView *psvPrevious,
  64. LPCFOLDERSETTINGS pfs,
  65. IShellBrowser *psb,
  66. RECT *prcView,
  67. HWND *phWnd
  68. )
  69. {
  70. LPFOLDERSETTINGS lpFolderSettings = const_cast<LPFOLDERSETTINGS>(pfs);
  71. // ShellX98.dll only handles ViewModes FVM_ICON to FVM_THUMBNAIL
  72. if (lpFolderSettings->ViewMode > FVM_THUMBNAIL)
  73. {
  74. LOGN( eDbgLevelError, "[IShellView::CreateViewWindow] forced FOLDERSETTINGS->ViewMode from %d to %d", lpFolderSettings->ViewMode, FVM_ICON);
  75. lpFolderSettings->ViewMode = FVM_ICON;
  76. }
  77. HRESULT hReturn = ORIGINAL_COM(IShellView, CreateViewWindow, pThis)(pThis, psvPrevious, lpFolderSettings, psb, prcView, phWnd);
  78. return hReturn;
  79. }
  80. /*++
  81. Register hooked functions
  82. --*/
  83. HOOK_BEGIN
  84. APIHOOK_ENTRY_COMSERVER(SHELLX98)
  85. // Explorer creates an IShellFolder via ShellX98.dll's class factory.
  86. // Eventually it calls IShellFolder::CreateViewObject to create an
  87. // IShellView object. We want to shim IShellView::CreateViewWindow.
  88. COMHOOK_ENTRY(Vault, IShellFolder, CreateViewObject, 8)
  89. COMHOOK_ENTRY(Shredder, IShellFolder, CreateViewObject, 8)
  90. COMHOOK_ENTRY(Vault, IShellView, CreateViewWindow, 9)
  91. COMHOOK_ENTRY(Shredder, IShellView, CreateViewWindow, 9)
  92. HOOK_END
  93. IMPLEMENT_SHIM_END