Commit 5aebf2c0 authored by GPM's avatar GPM
Browse files

GPMAV 14.5a Initial

Initial Release at Github
parent 1cf02b9d
;ExplorerShell.def : Declares the module parameters for the DLL.
LIBRARY ExpShell
EXPORTS
DllCanUnloadNow PRIVATE ;DLL unloading
DllGetClassObject PRIVATE ;Component object model
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#define APSTUDIO_HIDDEN_SYMBOLS
#include "windows.h"
#undef APSTUDIO_HIDDEN_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
1 VERSIONINFO
FILEVERSION 1,0,0,2
PRODUCTVERSION 1,0,0,2
FILEFLAGSMASK 0x0L
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x0L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "CompanyName", "GPM\0"
VALUE "FileVersion", "1.0.0.2\0"
VALUE "FileDescription", "GPMAV Antivirus\0"
VALUE "InternalName", "ExplorerShell\0"
VALUE "LegalCopyright", "Copyright GPM (c) 2014\0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename", "ExplorerShell\0"
VALUE "ProductName", "GPMAV Antivirus\0"
VALUE "ProductVersion", "1.0.0.2\0"
END
END
END
#endif // !_MAC
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
"#include ""windows.h""\r\n"
"#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
//-----------------------------------------------------------------------------
// Name: ShellExt.cpp
// Product: ClamWin Antivirus
// GPM Antivirus
//
// Author: alch [alch at users dot sourceforge dot net]
// Modified: GPM
//
// Created: 2004/19/03
// Copyright: Copyright alch (c) 2004
// Licence:
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//-----------------------------------------------------------------------------
//
// Initialize GUIDs (should be done only and at-least once per DLL/EXE)
//
#include <windows.h>
#include <shlobj.h>
#define INITGUID
#include <initguid.h>
#include <shlguid.h>
#include "ShellExt.h"
//
// Global variables
//
UINT g_cRefThisDll = 0; // Reference count of this DLL.
HINSTANCE g_hmodThisDll = NULL; // Handle to this DLL itself.
extern "C" int APIENTRY DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
if (dwReason == DLL_PROCESS_ATTACH)
g_hmodThisDll = hInstance;
return TRUE; // ok
}
//---------------------------------------------------------------------------
// DllCanUnloadNow
//---------------------------------------------------------------------------
STDAPI DllCanUnloadNow(void)
{
return (g_cRefThisDll == 0 ? S_OK : S_FALSE);
}
//---------------------------------------------------------------------------
// DllGetClassObject
//---------------------------------------------------------------------------
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppvOut)
{
*ppvOut = NULL;
if (IsEqualIID(rclsid, CLSID_ShellExtension))
{
CShellExtClassFactory *pcf = new CShellExtClassFactory;
return pcf->QueryInterface(riid, ppvOut);
}
return CLASS_E_CLASSNOTAVAILABLE;
}
//---------------------------------------------------------------------------
// CShellExtClassFactory::CShellExtClassFactory
//---------------------------------------------------------------------------
CShellExtClassFactory::CShellExtClassFactory()
{
m_cRef = 0L;
g_cRefThisDll++;
}
//---------------------------------------------------------------------------
// CShellExtClassFactory::~CShellExtClassFactory
//---------------------------------------------------------------------------
CShellExtClassFactory::~CShellExtClassFactory()
{
g_cRefThisDll--;
}
//---------------------------------------------------------------------------
// CShellExtClassFactory::QueryInterface
//---------------------------------------------------------------------------
STDMETHODIMP CShellExtClassFactory::QueryInterface(REFIID riid,
LPVOID FAR *ppv)
{
*ppv = NULL;
// Any interface on this object is the object pointer
if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IClassFactory))
{
*ppv = (LPCLASSFACTORY)this;
AddRef();
return NOERROR;
}
return E_NOINTERFACE;
}
//---------------------------------------------------------------------------
// CShellExtClassFactory::AddRef
//---------------------------------------------------------------------------
STDMETHODIMP_(ULONG) CShellExtClassFactory::AddRef()
{
return ++m_cRef;
}
//---------------------------------------------------------------------------
// CShellExtClassFactory::Release
//---------------------------------------------------------------------------
STDMETHODIMP_(ULONG) CShellExtClassFactory::Release()
{
if (--m_cRef)
return m_cRef;
delete this;
return 0L;
}
//---------------------------------------------------------------------------
// CShellExtClassFactory::CreateInstance
//---------------------------------------------------------------------------
STDMETHODIMP CShellExtClassFactory::CreateInstance(LPUNKNOWN pUnkOuter,
REFIID riid,
LPVOID *ppvObj)
{
*ppvObj = NULL;
// Shell extensions typically don't support aggregation (inheritance)
if (pUnkOuter)
return CLASS_E_NOAGGREGATION;
// Create the main shell extension object. The shell will then call
// QueryInterface with IID_IShellExtInit--this is how shell extensions are
// initialized.
LPCSHELLEXT pShellExt = new CShellExt(); //Create the CShellExt object
if (NULL == pShellExt)
return E_OUTOFMEMORY;
return pShellExt->QueryInterface(riid, ppvObj);
}
//---------------------------------------------------------------------------
// CShellExtClassFactory::LockServer
//---------------------------------------------------------------------------
STDMETHODIMP CShellExtClassFactory::LockServer(BOOL fLock)
{
return NOERROR;
}
// *********************** CShellExt *************************
//---------------------------------------------------------------------------
// CShellExt::CShellExt
//---------------------------------------------------------------------------
CShellExt::CShellExt()
{
m_cRef = 0L;
m_pDataObj = NULL;
m_szPath = NULL;
g_cRefThisDll++;
}
//---------------------------------------------------------------------------
// CShellExt::~CShellExt
//---------------------------------------------------------------------------
CShellExt::~CShellExt()
{
if (m_szPath)
delete [] m_szPath;
if (m_pDataObj)
m_pDataObj->Release();
g_cRefThisDll--;
}
//---------------------------------------------------------------------------
// CShellExt::QueryInterface
//---------------------------------------------------------------------------
STDMETHODIMP CShellExt::QueryInterface(REFIID riid, LPVOID FAR *ppv)
{
*ppv = NULL;
if (IsEqualIID(riid, IID_IShellExtInit) || IsEqualIID(riid, IID_IUnknown))
*ppv = (LPSHELLEXTINIT)this;
else if (IsEqualIID(riid, IID_IContextMenu))
*ppv = (LPCONTEXTMENU)this;
if (*ppv)
{
AddRef();
return NOERROR;
}
return E_NOINTERFACE;
}
//---------------------------------------------------------------------------
// CShellExt::AddRef
//---------------------------------------------------------------------------
STDMETHODIMP_(ULONG) CShellExt::AddRef()
{
return ++m_cRef;
}
//---------------------------------------------------------------------------
// CShellExt::Release
//---------------------------------------------------------------------------
STDMETHODIMP_(ULONG) CShellExt::Release()
{
if (--m_cRef)
return m_cRef;
delete this;
return 0L;
}
//-----------------------------------------------------------------------------
// Name: ShellExt.h
// Product: ClamWin Antivirus
// GPM Antivirus
//
// Author: alch [alch at users dot sourceforge dot net]
// Modified: GPM
//
// YYYY/DD/MM
// Created: 2004/19/03
// Modified: 2014/06/09
// Copyright: Copyright alch (c) 2004
// Licence:
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//-----------------------------------------------------------------------------
//
// The class ID of this Shell extension class.
//
// class id: e76d8ce0-8944-4fed-b363-c2df08724673
//
//
#ifndef _SHELLEXT_H
#define _SHELLEXT_H
#define CF_HDROP 15
// {65713842-C410-4f44-8383-BFE01A398C90}
// {e76d8ce0-8944-4fed-b363-c2df08724673}
DEFINE_GUID(CLSID_ShellExtension,
// 0x65713842, 0xc410, 0x4f44, 0x83, 0x83, 0xbf, 0xe0, 0x1a, 0x39, 0x8c, 0x90);
0xe76d8ce0, 0x8944, 0x4fed, 0xb3, 0x63, 0xc2, 0xdf, 0x08, 0x72, 0x46, 0x73);
class CShellExtClassFactory : public IClassFactory
{
protected:
ULONG m_cRef; // Object reference count
public:
CShellExtClassFactory();
~CShellExtClassFactory();
//IUnknown members
STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
STDMETHODIMP_(ULONG) AddRef();
STDMETHODIMP_(ULONG) Release();
//IClassFactory members
STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID, LPVOID FAR *);
STDMETHODIMP LockServer(BOOL);
};
typedef CShellExtClassFactory *LPCSHELLEXTCLASSFACTORY;
// this is the actual OLE Shell context menu handler
class CShellExt : public IContextMenu,
IShellExtInit
{
protected:
ULONG m_cRef; // Object reference count
LPDATAOBJECT m_pDataObj;
public:
CShellExt();
~CShellExt();
//IUnknown members
STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
STDMETHODIMP_(ULONG) AddRef();
STDMETHODIMP_(ULONG) Release();
//IShell members
STDMETHODIMP QueryContextMenu(HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags);
STDMETHODIMP InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi);
STDMETHODIMP GetCommandString(UINT_PTR idCmd, UINT uType, UINT *pwReserved, LPSTR pszName, UINT cchMax);
//IShellExtInit methods
STDMETHODIMP Initialize(LPCITEMIDLIST pIDFolder, LPDATAOBJECT pDataObj, HKEY hKeyID);
private:
BOOL Scan(HWND hwnd);
PTCHAR m_szPath;
};
typedef CShellExt *LPCSHELLEXT;
#endif // _SHELLEXT_H
REGEDIT4
[HKEY_CLASSES_ROOT\CLSID\{e76d8ce0-8944-4fed-b363-c2df08724673}]
@="GPMAV Shell Extension"
[HKEY_CLASSES_ROOT\CLSID\{e76d8ce0-8944-4fed-b363-c2df08724673}\InProcServer32]
@="C:\\Program Files\\Microsoft Visual Studio 11.0\\VC\\CNTXDLL\\Release\\ExpShell.dll"
"ThreadingModel"="Apartment"
[HKEY_CLASSES_ROOT\*\shellex\ContextMenuHandlers\GPMAV]
@="{e76d8ce0-8944-4fed-b363-c2df08724673}"
[HKEY_CLASSES_ROOT\Folder\shellex\ContextMenuHandlers\GPMAV]
@="{e76d8ce0-8944-4fed-b363-c2df08724673}"
//-----------------------------------------------------------------------------
// Name: ShellExtImpl.cpp
// Product: ClamWin Antivirus
// GPM Antivirus
//
// Author: alch [alch at users dot sourceforge dot net]
// Modified: GPM
//
// YYYY/DD/MM
// Created: 2004/19/03
// Modified: 2014/06/09
// Copyright: Copyright alch (c) 2004
// Licence:
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//-----------------------------------------------------------------------------
#include <windows.h>
#include <tchar.h>
#include <stdio.h>
#include <shlobj.h>
#include "ShellExt.h"
#define ResultFromShort(i) ResultFromScode(MAKE_SCODE(SEVERITY_SUCCESS, 0, (USHORT)(i)))
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <direct.h>
#include <string>
extern HINSTANCE g_hmodThisDll; // Handle to this DLL itself.
int _tcsreplace(LPTSTR sz, TCHAR chr, TCHAR repl_chr)
{
int count = 0;
for (; *sz!=_T('\0'); sz++)
if (*sz == chr) {
*sz = repl_chr;
count++;
}
return count;
}
//
// FUNCTION: CShellExt::Initialize(LPCITEMIDLIST, LPDATAOBJECT, HKEY)
//
// PURPOSE: Called by the shell when initializing a context menu or property
// sheet extension.
//
// PARAMETERS:
// pIDFolder - Specifies the parent folder
// pDataObj - Spefifies the set of items selected in that folder.
// hRegKey - Specifies the type of the focused item in the selection.
//
// RETURN VALUE:
//
// NOERROR in all cases.
//
// COMMENTS: Note that at the time this function is called, we don't know
// (or care) what type of shell extension is being initialized.
// It could be a context menu or a property sheet.
//
STDMETHODIMP CShellExt::Initialize(LPCITEMIDLIST pIDFolder,
LPDATAOBJECT pDataObj,
HKEY hRegKey)
{
HRESULT hres = E_FAIL;
STGMEDIUM medium;
FORMATETC fmte = {CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
TCHAR szPath[MAX_PATH];
INT numFiles;
size_t len;
// Initialize can be called more than once
if (m_pDataObj)
m_pDataObj->Release();
// duplicate the object pointer and registry handle
if (pDataObj)
{
m_pDataObj = pDataObj;
pDataObj->AddRef();
}
// use the given IDataObject to get a list of filenames (CF_HDROP)
hres = pDataObj->GetData(&fmte, &medium);
if(FAILED(hres))
return E_FAIL;
// find out how many files the user selected
// not more than 250 though, otherwise explorer crashes
numFiles = DragQueryFile((HDROP)medium.hGlobal, (UINT)-1, NULL, 0);
if(numFiles > 250)
return E_FAIL;
// free old path (just in case)
if(m_szPath)
{
delete [] m_szPath;
m_szPath = NULL;
}
// allocate memory for our combined path
// add length of [ --path=""]
INT cbPath = (MAX_PATH + 10) * numFiles;
m_szPath = new TCHAR[cbPath];
m_szPath[0] = _T('\0');
for(int i = 0; i < numFiles; i++)
{
DragQueryFile((HDROP)medium.hGlobal, i, szPath, sizeof(szPath));
// check the long path validity for a unicode build
#if defined UNICODE || defined _UNICODE
{
CHAR atemp[MAX_PATH];
BOOL invalid;
if(!WideCharToMultiByte(CP_OEMCP, WC_NO_BEST_FIT_CHARS, szPath, -1,
atemp, sizeof(atemp), NULL, &invalid) || invalid)
{