// Classic Shell (c) 2009-2017, Ivo Beltchev // Open-Shell (c) 2017-2018, The Open-Shell Team // Confidential information of Ivo Beltchev. Not for disclosure or distribution without prior written consent from the author // ShareOverlay.cpp : Implementation of CShareOverlay #include "stdafx.h" #include "ShareOverlay.h" // CShareOverlay - adds an overlay icon to the shared folders bool CShareOverlay::s_bEnabled=false; bool CShareOverlay::s_bShowHidden=false; int CShareOverlay::s_Index; wchar_t CShareOverlay::s_IconPath[_MAX_PATH]; CShareOverlay::CShareOverlay( void ) { SHGetDesktopFolder(&m_pDesktop); m_pShareInfo=NULL; m_ShareCount=0; m_UpdateTime=0; InitializeCriticalSection(&m_Section); } void CShareOverlay::FinalRelease( void ) { DeleteCriticalSection(&m_Section); if (m_pShareInfo) NetApiBufferFree(m_pShareInfo); m_pShareInfo=NULL; } void CShareOverlay::InitOverlay( const wchar_t *icon, bool showHidden ) { s_bEnabled=true; if (icon) { Strcpy(s_IconPath,_countof(s_IconPath),icon); wchar_t *c=wcsrchr(s_IconPath,','); if (c) { *c=0; s_Index=-_wtol(c+1); } else s_Index=0; } else { Strcpy(s_IconPath,_countof(s_IconPath),L"%windir%\\system32\\imageres.dll"); s_Index=-164; } DoEnvironmentSubst(s_IconPath,_countof(s_IconPath)); s_bShowHidden=showHidden; } HRESULT CShareOverlay::_InternalQueryInterface( REFIID iid, void** ppvObject ) { if (iid==IID_IUnknown) { AddRef(); *ppvObject=static_cast(this); return S_OK; } if (iid==IID_IShellIconOverlayIdentifier && s_bEnabled) { // only support IShellIconOverlayIdentifier if s_bEnabled is true AddRef(); *ppvObject=static_cast(this); return S_OK; } *ppvObject=NULL; return E_NOINTERFACE; } STDMETHODIMP CShareOverlay::IsMemberOf( LPCWSTR pwszPath, DWORD dwAttrib ) { EnterCriticalSection(&m_Section); UpdateShareInfo(); HRESULT res=S_FALSE; if (m_pShareInfo) { for (DWORD i=0;i