[SENDMAIL][INCLUDE][INF] Add sendmail.dll for DeskLink (#2092)

*.DeskLink file realizes SendTo Desktop (Create shortcut) in Windows. DeskLink is implemented in the sendmail.dll module. CORE-12562
This commit is contained in:
Katayama Hirofumi MZ 2019-11-27 19:26:49 +09:00 committed by GitHub
parent 30e0c2430d
commit 004e08383a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 550 additions and 1 deletions

View file

@ -8,6 +8,7 @@ add_subdirectory(fontext)
add_subdirectory(netplwiz)
add_subdirectory(netshell)
add_subdirectory(ntobjshex)
add_subdirectory(sendmail)
add_subdirectory(shellbtrfs)
add_subdirectory(stobject)
add_subdirectory(zipfldr)

View file

@ -0,0 +1,190 @@
/*
* PROJECT: sendmail
* LICENSE: LGPL-2.1+ (https://spdx.org/licenses/LGPL-2.1+)
* PURPOSE: DeskLink implementation
* COPYRIGHT: Copyright 2019 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
*/
#include "precomp.hpp"
WINE_DEFAULT_DEBUG_CHANNEL(sendmail);
CDeskLinkDropHandler::CDeskLinkDropHandler()
{
InterlockedIncrement(&g_ModuleRefCnt);
}
CDeskLinkDropHandler::~CDeskLinkDropHandler()
{
InterlockedDecrement(&g_ModuleRefCnt);
}
// IDropTarget
STDMETHODIMP
CDeskLinkDropHandler::DragEnter(IDataObject *pDataObject, DWORD dwKeyState,
POINTL pt, DWORD *pdwEffect)
{
TRACE("(%p)\n", this);
*pdwEffect &= DROPEFFECT_LINK;
return S_OK;
}
STDMETHODIMP
CDeskLinkDropHandler::DragOver(DWORD dwKeyState, POINTL pt, DWORD *pdwEffect)
{
TRACE("(%p)\n", this);
*pdwEffect &= DROPEFFECT_LINK;
return S_OK;
}
STDMETHODIMP CDeskLinkDropHandler::DragLeave()
{
TRACE("(%p)\n", this);
return S_OK;
}
STDMETHODIMP
CDeskLinkDropHandler::Drop(IDataObject *pDataObject, DWORD dwKeyState,
POINTL pt, DWORD *pdwEffect)
{
TRACE("(%p)\n", this);
if (!pDataObject)
{
ERR("pDataObject is NULL\n");
return E_POINTER;
}
FORMATETC fmt;
fmt.cfFormat = RegisterClipboardFormatW(CFSTR_SHELLIDLIST);
fmt.ptd = NULL;
fmt.dwAspect = DVASPECT_CONTENT;
fmt.lindex = -1;
fmt.tymed = TYMED_HGLOBAL;
WCHAR szDir[MAX_PATH], szDest[MAX_PATH], szSrc[MAX_PATH];
SHGetSpecialFolderPathW(NULL, szDir, CSIDL_DESKTOPDIRECTORY, FALSE);
CComPtr<IShellFolder> pDesktop;
HRESULT hr = SHGetDesktopFolder(&pDesktop);
if (FAILED_UNEXPECTEDLY(hr))
return hr;
STGMEDIUM medium;
hr = pDataObject->GetData(&fmt, &medium);
if (FAILED_UNEXPECTEDLY(hr))
return hr;
LPIDA pida = reinterpret_cast<LPIDA>(GlobalLock(medium.hGlobal));
if (!pida)
{
ERR("Error locking global\n");
ReleaseStgMedium(&medium);
return E_FAIL;
}
LPBYTE pb = reinterpret_cast<LPBYTE>(pida);
LPCITEMIDLIST pidlParent = reinterpret_cast<LPCITEMIDLIST>(pb + pida->aoffset[0]);
for (UINT i = 1; i <= pida->cidl; ++i)
{
LPCITEMIDLIST pidlChild = reinterpret_cast<LPCITEMIDLIST>(pb + pida->aoffset[i]);
CComHeapPtr<ITEMIDLIST> pidl(ILCombine(pidlParent, pidlChild));
if (!pidl)
{
ERR("Out of memory\n");
break;
}
StringCbCopyW(szDest, sizeof(szDest), szDir);
if (SHGetPathFromIDListW(pidl, szSrc))
{
CStringW strTitle;
strTitle.Format(IDS_SHORTCUT, PathFindFileNameW(szSrc));
PathAppendW(szDest, strTitle);
PathRemoveExtensionW(szDest);
StringCbCatW(szDest, sizeof(szDest), L".lnk");
hr = CreateShellLink(szDest, szSrc, NULL, NULL, NULL, NULL, -1, NULL);
}
else
{
STRRET strret;
hr = pDesktop->GetDisplayNameOf(pidl, SHGDN_INFOLDER, &strret);
if (FAILED_UNEXPECTEDLY(hr))
break;
hr = StrRetToBufW(&strret, pidl, szSrc, _countof(szSrc));
if (FAILED_UNEXPECTEDLY(hr))
break;
CStringW strTitle;
strTitle.Format(IDS_SHORTCUT, szSrc);
PathAppendW(szDest, strTitle);
PathRemoveExtensionW(szDest);
StringCbCatW(szDest, sizeof(szDest), L".lnk");
hr = CreateShellLink(szDest, NULL, pidl, NULL, NULL, NULL, -1, NULL);
}
if (FAILED_UNEXPECTEDLY(hr))
break;
}
GlobalUnlock(medium.hGlobal);
ReleaseStgMedium(&medium);
return hr;
}
// IPersistFile
STDMETHODIMP CDeskLinkDropHandler::GetCurFile(LPOLESTR *ppszFileName)
{
FIXME("(%p)\n", this);
return E_NOTIMPL;
}
STDMETHODIMP CDeskLinkDropHandler::IsDirty()
{
FIXME("(%p)\n", this);
return E_NOTIMPL;
}
STDMETHODIMP CDeskLinkDropHandler::Load(LPCOLESTR pszFileName, DWORD dwMode)
{
return S_OK;
}
STDMETHODIMP CDeskLinkDropHandler::Save(LPCOLESTR pszFileName, BOOL fRemember)
{
FIXME("(%p)\n", this);
return E_NOTIMPL;
}
STDMETHODIMP CDeskLinkDropHandler::SaveCompleted(LPCOLESTR pszFileName)
{
FIXME("(%p)\n", this);
return E_NOTIMPL;
}
// IPersist
STDMETHODIMP CDeskLinkDropHandler::GetClassID(CLSID * lpClassId)
{
TRACE("(%p)\n", this);
if (!lpClassId)
{
ERR("lpClassId is NULL\n");
return E_POINTER;
}
*lpClassId = CLSID_DeskLinkDropHandler;
return S_OK;
}

View file

@ -0,0 +1,53 @@
/*
* PROJECT: sendmail
* LICENSE: LGPL-2.1+ (https://spdx.org/licenses/LGPL-2.1+)
* PURPOSE: DeskLink implementation
* COPYRIGHT: Copyright 2019 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
*/
#ifndef _CDESKLINKDROPHANDLER_HPP_
#define _CDESKLINKDROPHANDLER_HPP_
#include "resource.h"
class CDeskLinkDropHandler :
public CComCoClass<CDeskLinkDropHandler, &CLSID_DeskLinkDropHandler>,
public CComObjectRootEx<CComMultiThreadModelNoCS>,
public IDropTarget,
public IPersistFile
{
public:
CDeskLinkDropHandler();
~CDeskLinkDropHandler();
// IDropTarget
STDMETHODIMP DragEnter(IDataObject *pDataObject, DWORD dwKeyState,
POINTL pt, DWORD *pdwEffect);
STDMETHODIMP DragOver(DWORD dwKeyState, POINTL pt, DWORD *pdwEffect);
STDMETHODIMP DragLeave();
STDMETHODIMP Drop(IDataObject *pDataObject, DWORD dwKeyState, POINTL pt,
DWORD *pdwEffect);
// IPersist
STDMETHODIMP GetClassID(CLSID *lpClassId);
// IPersistFile
STDMETHODIMP GetCurFile(LPOLESTR *ppszFileName);
STDMETHODIMP IsDirty();
STDMETHODIMP Load(LPCOLESTR pszFileName, DWORD dwMode);
STDMETHODIMP Save(LPCOLESTR pszFileName, BOOL fRemember);
STDMETHODIMP SaveCompleted(LPCOLESTR pszFileName);
DECLARE_REGISTRY_RESOURCEID(IDR_DESKLINK)
DECLARE_NOT_AGGREGATABLE(CDeskLinkDropHandler)
DECLARE_PROTECT_FINAL_CONSTRUCT()
BEGIN_COM_MAP(CDeskLinkDropHandler)
COM_INTERFACE_ENTRY_IID(IID_IPersist, IPersist)
COM_INTERFACE_ENTRY_IID(IID_IPersistFile, IPersistFile)
COM_INTERFACE_ENTRY_IID(IID_IDropTarget, IDropTarget)
END_COM_MAP()
};
#endif /* _CDESKLINKDROPHANDLER_HPP_ */

View file

@ -0,0 +1,35 @@
set_cpp(WITH_RUNTIME)
spec2def(sendmail.dll sendmail.spec)
add_definitions(
-D_WINE
-D_ATL_NO_EXCEPTIONS)
if(NOT MSVC)
# HACK: this should be enabled globally!
add_compile_flags_language("-std=c++11" "CXX")
endif()
include_directories(
${REACTOS_SOURCE_DIR}/sdk/lib/atl
${REACTOS_SOURCE_DIR})
file(GLOB_RECURSE sendmail_rc_deps res/*.*)
add_rc_deps(sendmail.rc ${sendmail_rc_deps})
list(APPEND SOURCE
CDeskLinkDropHandler.cpp
sendmail.cpp
precomp.hpp)
add_library(sendmail MODULE
${SOURCE}
sendmail.rc
${CMAKE_CURRENT_BINARY_DIR}/sendmail.def)
set_module_type(sendmail win32dll UNICODE)
target_link_libraries(sendmail uuid wine)
add_delay_importlibs(sendmail ole32 oleaut32)
add_importlibs(sendmail advapi32 shell32 user32 comctl32 shlwapi msvcrt kernel32 ntdll)
add_pch(sendmail precomp.hpp SOURCE)
add_cd_file(TARGET sendmail DESTINATION reactos/system32 FOR all)

View file

@ -0,0 +1,6 @@
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
STRINGTABLE
{
IDS_SHORTCUT, "Shortcut to %s"
}

View file

@ -0,0 +1,40 @@
/*
* PROJECT: sendmail
* LICENSE: LGPL-2.1+ (https://spdx.org/licenses/LGPL-2.1+)
* PURPOSE: DeskLink implementation
* COPYRIGHT: Copyright 2019 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
*/
#define COBJMACROS
#define WIN32_NO_STATUS
#include <windows.h>
#include <shlwapi.h>
#include <shlobj.h>
#include <shobjidl.h>
#include <atlbase.h>
#include <atlcom.h>
#include <atlwin.h>
#include <atlstr.h>
#include <shlguid_undoc.h>
#include <shellapi.h>
#include <shellutils.h>
#include <strsafe.h>
#include <wine/debug.h>
#include "CDeskLinkDropHandler.hpp"
#include "sendmail_version.h"
#include "resource.h"
extern LONG g_ModuleRefCnt;
HRESULT
CreateShellLink(
LPCWSTR pszLinkPath,
LPCWSTR pszTargetPath OPTIONAL,
LPCITEMIDLIST pidlTarget OPTIONAL,
LPCWSTR pszArg OPTIONAL,
LPCWSTR pszDir OPTIONAL,
LPCWSTR pszIconPath OPTIONAL,
INT iIconNr OPTIONAL,
LPCWSTR pszComment OPTIONAL);

View file

@ -0,0 +1,24 @@
HKCR
{
NoRemove CLSID
{
ForceRemove {9E56BE61-C50F-11CF-9A2C-00A0C90A90CE} = s 'DeskLink'
{
val 'NeverShowExt' = s ''
DefaultIcon = e '%%SystemRoot%%\explorer.exe,-103'
InprocServer32 = s '%MODULE%'
{
val ThreadingModel = s 'Apartment'
}
'shellex'
{
'DropHandler' = s '{9E56BE61-C50F-11CF-9A2C-00A0C90A90CE}'
{
}
}
}
}
ForceRemove .DeskLink = s 'CLSID\{9E56BE61-C50F-11CF-9A2C-00A0C90A90CE}'
{
}
}

View file

@ -0,0 +1,14 @@
/*
* PROJECT: sendmail
* LICENSE: LGPL-2.1+ (https://spdx.org/licenses/LGPL-2.1+)
* PURPOSE: DeskLink implementation
* COPYRIGHT: Copyright 2019 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
*/
#ifndef RESOURCE_H_
#define RESOURCE_H_
#define IDR_DESKLINK 100
#define IDS_SHORTCUT 1000
#endif

View file

@ -0,0 +1,128 @@
/*
* PROJECT: sendmail
* LICENSE: LGPL-2.1+ (https://spdx.org/licenses/LGPL-2.1+)
* PURPOSE: DeskLink implementation
* COPYRIGHT: Copyright 2019 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
*/
#include "precomp.hpp"
WINE_DEFAULT_DEBUG_CHANNEL(sendmail);
BEGIN_OBJECT_MAP(ObjectMap)
OBJECT_ENTRY(CLSID_DeskLinkDropHandler, CDeskLinkDropHandler)
END_OBJECT_MAP()
CComModule gModule;
LONG g_ModuleRefCnt = 0;
STDAPI DllCanUnloadNow(void)
{
if (g_ModuleRefCnt)
return S_FALSE;
return gModule.DllCanUnloadNow();
}
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
{
TRACE("CLSID:%s,IID:%s\n", wine_dbgstr_guid(&rclsid), wine_dbgstr_guid(&riid));
HRESULT hr = gModule.DllGetClassObject(rclsid, riid, ppv);
TRACE("-- pointer to class factory: %p\n", *ppv);
return hr;
}
STDAPI DllRegisterServer(void)
{
HRESULT hr = gModule.DllRegisterServer(FALSE);
if (FAILED_UNEXPECTEDLY(hr))
return hr;
return S_OK;
}
STDAPI DllUnregisterServer(void)
{
HRESULT hr = gModule.DllUnregisterServer(FALSE);
if (FAILED_UNEXPECTEDLY(hr))
return hr;
return S_OK;
}
HRESULT
CreateShellLink(
LPCWSTR pszLinkPath,
LPCWSTR pszTargetPath OPTIONAL,
LPCITEMIDLIST pidlTarget OPTIONAL,
LPCWSTR pszArg OPTIONAL,
LPCWSTR pszDir OPTIONAL,
LPCWSTR pszIconPath OPTIONAL,
INT iIconNr OPTIONAL,
LPCWSTR pszComment OPTIONAL)
{
CComPtr<IShellLinkW> psl;
HRESULT hr = CoCreateInstance(CLSID_ShellLink, NULL,
CLSCTX_INPROC_SERVER,
IID_PPV_ARG(IShellLinkW, &psl));
if (FAILED_UNEXPECTEDLY(hr))
return hr;
if (pszTargetPath)
{
hr = psl->SetPath(pszTargetPath);
if (FAILED_UNEXPECTEDLY(hr))
return hr;
}
else if (pidlTarget)
{
hr = psl->SetIDList(pidlTarget);
if (FAILED_UNEXPECTEDLY(hr))
return hr;
}
else
{
ERR("invalid argument\n");
return E_INVALIDARG;
}
if (pszArg)
hr = psl->SetArguments(pszArg);
if (pszDir)
hr = psl->SetWorkingDirectory(pszDir);
if (pszIconPath)
hr = psl->SetIconLocation(pszIconPath, iIconNr);
if (pszComment)
hr = psl->SetDescription(pszComment);
CComPtr<IPersistFile> ppf;
hr = psl->QueryInterface(IID_PPV_ARG(IPersistFile, &ppf));
if (FAILED_UNEXPECTEDLY(hr))
return hr;
hr = ppf->Save(pszLinkPath, TRUE);
if (FAILED_UNEXPECTEDLY(hr))
return hr;
return hr;
}
STDAPI_(BOOL) DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID fImpLoad)
{
TRACE("%p 0x%x %p\n", hInstance, dwReason, fImpLoad);
if (dwReason == DLL_PROCESS_ATTACH)
{
gModule.Init(ObjectMap, hInstance, NULL);
DisableThreadLibraryCalls(hInstance);
}
else if (dwReason == DLL_PROCESS_DETACH)
{
gModule.Term();
}
return TRUE;
}

View file

@ -0,0 +1,23 @@
/*
* PROJECT: sendmail
* LICENSE: LGPL-2.1+ (https://spdx.org/licenses/LGPL-2.1+)
* PURPOSE: DeskLink implementation
* COPYRIGHT: Copyright 2019 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
*/
#include <windef.h>
#include <winuser.h>
#include "resource.h"
#include "sendmail_version.rc"
/* UTF-8 */
#pragma code_page(65001)
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDR_DESKLINK REGISTRY "res/desklink.rgs"
#ifdef LANGUAGE_EN_US
#include "lang/en-US.rc"
#endif

View file

@ -0,0 +1,4 @@
@ stdcall -private DllCanUnloadNow()
@ stdcall -private DllGetClassObject(ptr ptr ptr)
@ stdcall -private DllRegisterServer()
@ stdcall -private DllUnregisterServer()

View file

@ -0,0 +1,15 @@
/*
* PROJECT: sendmail
* LICENSE: LGPL-2.1+ (https://spdx.org/licenses/LGPL-2.1+)
* PURPOSE: DeskLink implementation
* COPYRIGHT: Copyright 2019 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
*/
#pragma once
#define WINE_FILEVERSION_MAJOR 6
#define WINE_FILEVERSION_MINOR 0
#define WINE_FILEVERSION_BUILD 3790
#define WINE_FILEVERSION_PLATFORMID 3959
#define WINE_FILEVERSION_STR "6.0.3790.3959"

View file

@ -0,0 +1,14 @@
/*
* PROJECT: sendmail
* LICENSE: LGPL-2.1+ (https://spdx.org/licenses/LGPL-2.1+)
* PURPOSE: DeskLink implementation
* COPYRIGHT: Copyright 2019 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
*/
#include "sendmail_version.h"
#define WINE_OLESELFREGISTER
#define WINE_FILEVERSION WINE_FILEVERSION_MAJOR,WINE_FILEVERSION_MINOR,WINE_FILEVERSION_BUILD,WINE_FILEVERSION_PLATFORMID
#define WINE_FILENAME_STR "sendmail.dll"
#include <wine/wine_common_ver.rc>

View file

@ -102,6 +102,7 @@ AddReg=Classes
11,,rsabase.dll,1
11,,rsaenh.dll,1
11,,scrrun.dll,1
11,,sendmail.dll,1
11,,shdocvw.dll,3
11,,shell32.dll,3
11,,softpub.dll,1

View file

@ -110,7 +110,8 @@ DEFINE_GUID(CLSID_ShellFileDefExt, 0x21B22460, 0x3AEA, 0x1069, 0xA2, 0xD
DEFINE_GUID(CLSID_ShellDrvDefExt, 0x5F5295E0, 0x429F, 0x1069, 0xA2, 0xE2, 0x08, 0x00, 0x2B, 0x30, 0x30, 0x9D);
DEFINE_GUID(CLSID_ShellNetDefExt, 0x86422020, 0x42A0, 0x1069, 0xA2, 0xE5, 0x08, 0x00, 0x2B, 0x30, 0x30, 0x9D);
DEFINE_GUID(CLSID_ExeDropHandler, 0x86C86720, 0x42A0, 0x1069, 0xA2, 0xE8, 0x08, 0x00, 0x2B, 0x30, 0x30, 0x9D);
DEFINE_GUID(CLSID_ExeDropHandler, 0x86C86720, 0x42A0, 0x1069, 0xA2, 0xE8, 0x08, 0x00, 0x2B, 0x30, 0x30, 0x9D);
DEFINE_GUID(CLSID_DeskLinkDropHandler, 0x9E56BE61, 0xC50F, 0x11CF, 0x9A, 0x2C, 0x00, 0xA0, 0xC9, 0x0A, 0x90, 0xCE);
DEFINE_GUID(CLSID_MergedFolder, 0x26FDC864, 0xBE88, 0x46E7, 0x92, 0x35, 0x03, 0x2D, 0x8E, 0xA5, 0x16, 0x2E);
DEFINE_GUID(IID_IAugmentedShellFolder, 0x91EA3F8C, 0xC99B, 0x11D0, 0x98, 0x15, 0x00, 0xC0, 0x4F, 0xD9, 0x19, 0x72);