Commit 1ba02e93 authored by gr01d's avatar gr01d
Browse files

v14.8src code VS2012

parent 5f72802c
......@@ -30,8 +30,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
//
1 VERSIONINFO
FILEVERSION 1,0,0,2
PRODUCTVERSION 1,0,0,2
FILEVERSION 1,0,0,3
PRODUCTVERSION 1,0,0,3
FILEFLAGSMASK 0x0L
#ifdef _DEBUG
FILEFLAGS 0x1L
......@@ -47,14 +47,14 @@ BEGIN
BLOCK "040904E4"
BEGIN
VALUE "CompanyName", "GPM\0"
VALUE "FileVersion", "1.0.0.2\0"
VALUE "FileVersion", "1.0.0.3\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"
VALUE "ProductVersion", "1.0.0.3\0"
END
END
END
......
......@@ -3,7 +3,7 @@ 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"
@="C:\\Program Files\\Microsoft Visual Studio 11.0\\VC\\cpp\\Release\\ExpShell.dll"
"ThreadingModel"="Apartment"
[HKEY_CLASSES_ROOT\*\shellex\ContextMenuHandlers\GPMAV]
......
This diff is collapsed.
/*
*
* Clamav GUI Wrapper
*
* Copyright (c) 2006-2009 Gianluigi Tiesi <sherpya@netfarm.it>
* Modified by GPM (c) 2010-2014
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this software; if not, write to the
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#define WIN32_LEAN_AND_MEAN
#define _CRT_SECURE_NO_DEPRECATE
#pragma warning(disable: 4311 4312) /* yes, yes I use a bool as a pointer */
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <io.h>
#include <fcntl.h>
#define CLAMSCAN "gpmavscan.exe"
#define FRESHCLAM "gpmavupdate.exe"
#define SIGTOOL "sigtool.exe"
extern HWND MainDlg;
extern BOOL isScanning;
extern void WriteStdOut(LPSTR msg, BOOL freshclam);
extern void GetDestinationFolder(void);
DWORD WINAPI PipeToClamAV(LPVOID lpvThreadParam);
extern HANDLE m_hEvtStop;
extern PROCESS_INFORMATION pi;
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// Neutral resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU)
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
#pragma code_page(1252)
/////////////////////////////////////////////////////////////////////////////
//
// Bitmap
//
IDB_BITMAP BITMAP "GPMBANNER_1.bmp"
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_MAIN DIALOGEX 0, 0, 501, 334
STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_MINIMIZEBOX | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "GPM Antivirus 2014 Scan GUI"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
PUSHBUTTON "Custom Scan",IDC_SCAN,410,46,78,14
EDITTEXT IDC_TARGET,5,29,452,15,ES_AUTOHSCROLL
DEFPUSHBUTTON "...",IDC_BROWSE,464,29,23,15
CONTROL "Scan All Drives",IDC_ALLDRIVES,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,12,58,78,11
CONTROL "Scan Folders ",IDC_RECURSE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,68,78,11
CONTROL "Show only infected",IDC_ONLYINFECTED,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,12,78,78,11
CONTROL "Load Database",IDC_db,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,94,76,78,11
PUSHBUTTON "Cancel Operation",IDC_CANCEL,411,110,79,14
EDITTEXT IDC_STATUS,9,130,490,199,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY | WS_VSCROLL | WS_HSCROLL
GROUPBOX "Scan Options",IDC_STATIC,8,47,171,81,WS_GROUP
PUSHBUTTON "Update VDB",IDC_UPDATE,411,78,77,15
CONTROL "Beep",IDC_BEEP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,89,72,10
CONTROL "Save to Log File",IDC_LOG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,98,69,10
CONTROL "Use Tempdir",IDC_TEMP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,108,77,10
CONTROL "No Summary",IDC_NOSUMMARY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,94,58,72,10
CONTROL "Debug Mode",IDC_DEBUG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,94,66,73,10
CONTROL "Remove Viruses",IDC_RADIO1,"Button",BS_AUTORADIOBUTTON,94,105,67,10
CONTROL "Quarantine Viruses",IDC_RADIO2,"Button",BS_AUTORADIOBUTTON,94,114,77,10
CONTROL "Quiet",IDC_QUIET,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,94,86,33,8
CONTROL "Report Infected File(s)",IDC_REPORT,"Button",BS_AUTORADIOBUTTON,94,96,84,8
CONTROL 101,IDC_STATIC,"Static",SS_BITMAP | SS_REALSIZEIMAGE,0,1,501,24
GROUPBOX "Extra Scan Options",IDC_STATIC,183,44,214,80,WS_GROUP
CONTROL "Verbose",IDC_EXVERBOSE,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,189,57,42,11
CONTROL "Do not Remove Temp Files",IDC_EXDONOTREMTEMP,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,189,68,95,11
CONTROL "Load Official DB Only",IDC_LOADONLYODB,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,189,80,78,11
CONTROL "Detect PUA",IDC_DETECTPUA,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,189,91,99,11
CONTROL "Detect Broken EXE Files",IDC_DETECTBROKENEXE,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,189,101,94,11
CONTROL "Block Encrypted Archives",IDC_BLOCKENCARCH,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,189,111,96,11
CONTROL "Do not scan files > 200MB",IDC_DONOTSCAN150,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,289,56,102,11
CONTROL "Scan Mail Files",IDC_SCANMAIL,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,289,68,78,11
CONTROL "Algorithmic Detection",IDC_USEALGO,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,289,79,78,11
CONTROL "Max Recursion 50",IDC_MAXRECUR,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,289,90,78,11
CONTROL "Max Files 500",IDC_MAXFILES,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,289,101,78,11
CONTROL "Max Scan Size 150MB",IDC_MAXFILESIZE,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,289,111,96,11
PUSHBUTTON "VDB2",IDC_DISPVDB2,440,94,22,14
PUSHBUTTON "VDB3",IDC_DISPVDB3,467,95,22,14
PUSHBUTTON "Scan Memory",IDC_SCANMEM,410,62,79,14
PUSHBUTTON "VDB1",IDC_DISPVDB1,412,95,22,14
END
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_ICON ICON "GPMAV-GUI.ico"
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 14,0,0,8
PRODUCTVERSION 14,0,0,8
FILEFLAGSMASK 0x0L
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x0L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "000004b0"
BEGIN
VALUE "Comments", "GPM Antivirus Scanner GUI"
VALUE "CompanyName", "GPM"
VALUE "FileDescription", "GPMAV SCANGUI"
VALUE "FileVersion", "14.0.0.8"
VALUE "InternalName", "GPMAV-SCANGUI.exe"
VALUE "LegalCopyright", "Copyright (C) 2010-2014 GPM / ClamWin Pty. Ltd."
VALUE "LegalTrademarks", "GPM"
VALUE "OriginalFilename", "GPMAV-SCANGUI.exe"
VALUE "OriginalFileVersion", "14, 0, 0, 8"
VALUE "ProductName", "GPMAV SCANGUI"
VALUE "ProductVersion", "14.0.0.8"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0, 1200
END
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
IDD_MAIN, DIALOG
BEGIN
MOCKUP, 0, 100, 0, 0, ".\GPMBANNER_1.bmp"
VERTGUIDE, 88
VERTGUIDE, 93
VERTGUIDE, 109
VERTGUIDE, 214
BOTTOMMARGIN, 329
END
END
#endif // APSTUDIO_INVOKED
#endif // Neutral resources
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// English (United States) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
3 TEXTINCLUDE
BEGIN
"\r\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\0"
END
#endif // APSTUDIO_INVOKED
#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
/*
* Clamav GUI Wrapper
*
* Copyright (c) 2006-2009 Gianluigi Tiesi <sherpya@netfarm.it>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this software; if not, write to the
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <GPMAV-GUI.h>
#include <resource.h>
#include <windows.h>
#define BUFSIZE 1024
#define BAIL_OUT(code) { isScanning = FALSE; return code; }
HANDLE m_hEvtStop;
HANDLE hChildStdinWrDup = INVALID_HANDLE_VALUE, hChildStdoutRdDup = INVALID_HANDLE_VALUE;
PROCESS_INFORMATION pi;
DWORD exitcode = 0;
void RedirectStdOutput(BOOL freshclam)
{
char chBuf[BUFSIZE];
DWORD dwRead;
DWORD dwAvail = 0;
if (!PeekNamedPipe(hChildStdoutRdDup, NULL, 0, NULL, &dwAvail, NULL) || !dwAvail)
return;
if (!ReadFile(hChildStdoutRdDup, chBuf, min(BUFSIZE - 1, dwAvail), &dwRead, NULL) || !dwRead)
return;
chBuf[dwRead] = 0;
WriteStdOut(chBuf, freshclam);
}
DWORD WINAPI OutputThread(LPVOID lpvThreadParam)
{
char msg[128];
HANDLE Handles[2];
Handles[0] = pi.hProcess;
Handles[1] = m_hEvtStop;
ResumeThread(pi.hThread);
while(1)
{
DWORD dwRc = WaitForMultipleObjects(2, Handles, FALSE, 100);
RedirectStdOutput((BOOL) lpvThreadParam);
if ((dwRc == WAIT_OBJECT_0) || (dwRc == WAIT_OBJECT_0 + 1) || (dwRc == WAIT_FAILED))
break;
}
CloseHandle(hChildStdoutRdDup);
sprintf(msg, "\r\nProcess exited with %d code\r\n", exitcode);
WriteStdOut(msg, FALSE);
EnableWindow(GetDlgItem(MainDlg, IDC_SCAN), TRUE);
EnableWindow(GetDlgItem(MainDlg, IDC_SCANMEM), TRUE);
EnableWindow(GetDlgItem(MainDlg, IDC_UPDATE), TRUE);
EnableWindow(GetDlgItem(MainDlg, IDC_DISPVDB1), TRUE);
EnableWindow(GetDlgItem(MainDlg, IDC_DISPVDB2), TRUE);
EnableWindow(GetDlgItem(MainDlg, IDC_DISPVDB3), TRUE);
isScanning = FALSE;
return 1;
}
BOOL LaunchClamAV(LPSTR pszCmdLine, HANDLE hStdOut, HANDLE hStdErr)
{
STARTUPINFO si;
ZeroMemory(&pi, sizeof(PROCESS_INFORMATION));
ZeroMemory(&si, sizeof(STARTUPINFO));
si.cb = sizeof(STARTUPINFO);
si.hStdOutput = hStdOut;
si.hStdError = hStdErr;
si.wShowWindow = SW_HIDE;
si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
if (!CreateProcess(NULL, pszCmdLine,
NULL, NULL,
TRUE,
CREATE_NEW_CONSOLE | CREATE_SUSPENDED,
NULL, NULL,
&si,
&pi))
return FALSE;
return TRUE;
}
DWORD WINAPI PipeToClamAV(LPVOID lpvThreadParam)
{
HANDLE hChildStdoutRd, hChildStdoutWr, hChildStderrWr;
char *pszCmdLine = (char *) lpvThreadParam;
if (!pszCmdLine) BAIL_OUT(-1);
SECURITY_ATTRIBUTES saAttr;
saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
saAttr.bInheritHandle = TRUE;
saAttr.lpSecurityDescriptor = NULL;
/* Create a pipe for the child process's STDOUT */
if(!CreatePipe(&hChildStdoutRd, &hChildStdoutWr, &saAttr, 0))
BAIL_OUT(-1);
/* Duplicate stdout sto stderr */
if (!DuplicateHandle(GetCurrentProcess(), hChildStdoutWr, GetCurrentProcess(), &hChildStderrWr, 0, TRUE, DUPLICATE_SAME_ACCESS))
BAIL_OUT(-1);
/* Duplicate the pipe HANDLE */
if (!DuplicateHandle(GetCurrentProcess(), hChildStdoutRd, GetCurrentProcess(), &hChildStdoutRdDup, 0, FALSE, DUPLICATE_SAME_ACCESS))
BAIL_OUT(-1);
CloseHandle(hChildStdoutRd);
EnableWindow(GetDlgItem(MainDlg, IDC_SCAN), FALSE);
EnableWindow(GetDlgItem(MainDlg, IDC_SCANMEM), FALSE);
EnableWindow(GetDlgItem(MainDlg, IDC_UPDATE), FALSE);
EnableWindow(GetDlgItem(MainDlg, IDC_DISPVDB1), FALSE);
EnableWindow(GetDlgItem(MainDlg, IDC_DISPVDB2), FALSE);
EnableWindow(GetDlgItem(MainDlg, IDC_DISPVDB3), FALSE);
SetWindowText(GetDlgItem(MainDlg, IDC_STATUS), "");
WriteStdOut(pszCmdLine, FALSE);
WriteStdOut("\r\n\r\n", FALSE);
LaunchClamAV(pszCmdLine, hChildStdoutWr, hChildStderrWr);
BOOL freshclam = !_strnicmp(pszCmdLine, "gpmavupdate", 9);
delete pszCmdLine;
CloseHandle(hChildStdoutWr);
m_hEvtStop = CreateEvent(NULL, TRUE, FALSE, NULL);
DWORD m_dwThreadId;
HANDLE m_hThread = CreateThread(NULL, 0, OutputThread, (LPVOID) freshclam, 0, &m_dwThreadId);
WaitForSingleObject(pi.hProcess, INFINITE);
GetExitCodeProcess(pi.hProcess, &exitcode);
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
pi.hProcess = INVALID_HANDLE_VALUE;
SetEvent(m_hEvtStop);
return 0;
}
This diff is collapsed.
/*
* Clamav GUI Wrapper
*
* Copyright (c) 2006-2009 Gianluigi Tiesi <sherpya@netfarm.it>
* Modified by GPM 2014
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this software; if not, write to the
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Modified by Gian ( GPM Antivirus Software GUI)
*/
#include <GPMAV-UPDATE-GUI.h>
#include <shlobj.h>
#include <resource.h>
#include <string>
#include <windows.h>
#include <stdlib.h>
#include <cstdlib>
#include <iostream>
HWND MainDlg;
BOOL isScanning = FALSE;
HANDLE LogMutex;
#define MAX_OUTPUT 8192
typedef struct _Option
{
const char *param;
UINT dialog;
} Option;
void WriteStdOut(LPSTR msg, BOOL freshclam)
{
char *firstline = NULL;
WaitForSingleObject(LogMutex, INFINITE);
HWND editw = GetDlgItem(MainDlg, IDC_STATUS);
char *buff = 0, *buf = 0;
int length = GetWindowTextLength(editw);
length++;
size_t slen = strlen(msg) + 2;
buff = buf = new char[length + slen];
if(!buf) return;
GetWindowText(editw, buf, length);
buf[length - 1] = 0;
if(length > MAX_OUTPUT)
{
firstline = strstr(buf, "\r\n");
if (firstline) firstline += 2;
buf = firstline;
}
if (!buf)
{
delete buff;
SetWindowText(editw, "");
ReleaseMutex(LogMutex);
return;
}
strcat(buf, msg);
std::string out;
if (freshclam)
{
char o[2], *m, *m1;
o[1] = 0;
for (m = buf; *m; m++)
{
m1 = m + 1;
if ((*m == '\r') && (!m1 || (*m1 != '\n')))
out.append("\r\n");
else
{
o[0] = *m;
out.append(o);
}
}
}
else
out.append(buf);
delete buff;
LockWindowUpdate(editw);
SetWindowText(editw, out.c_str());
int lResult = (int) SendMessage(editw, (UINT) EM_GETLINECOUNT, (WPARAM) 0, (LPARAM) 0);
SendMessage(editw, (UINT) EM_LINESCROLL, (WPARAM) 0, (LPARAM) lResult);
LockWindowUpdate(NULL);
ReleaseMutex(LogMutex);
return;
}
//From: https://stackoverflow.com/questions/4130180/how-to-use-vs-c-getenvironmentvariable-as-cleanly-as-possible
const char * WinGetEnv(const char * name)
{
const DWORD buffSize = 65535;
static char buffer[buffSize];
if (GetEnvironmentVariableA(name, buffer, buffSize))
{
return buffer;
}
else
{
return 0;
}
}
char *MakeCmdLine(UINT id)
{
std::string cmdline;
int length = 0;
int i = 0;
switch (id)
{
case IDC_UPDATE:
//Get GPMAV Location
cmdline.append(WinGetEnv("homedrive"));
cmdline.append("\\GPMAV\\");
cmdline.append(FRESHCLAM );
cmdline.append(" --stdout --log=");
cmdline.append(WinGetEnv("homedrive"));
cmdline.append("\\GPMAV\\logs\\Autoupdatelog.log""");
cmdline.append(" --config-file=");
cmdline.append(WinGetEnv("homedrive"));
cmdline.append("\\GPMAV\\gpmavupdate.conf""");
break;
default:
return NULL;
}
char *cmd = new char[cmdline.size() + 1];
cmd[0] = 0;
strcat(cmd, cmdline.c_str());
return cmd;
}
BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lParam)
{