Esempio n. 1
0
inline BOOL CreateDirectory(const WTL::CString& strDir)
{
	BOOL retval = FALSE;
	WTL::CString strTemp = strDir;
	WTL::CString strBase;
	int nFind;

	if (GetFileAttributes(strDir) == FILE_ATTRIBUTE_DIRECTORY)
	{
		retval = TRUE;
		goto clean0;
	}

	if (strTemp[strTemp.GetLength() - 1] != _T('\\'))
		strTemp += _T("\\");

	nFind = strTemp.Find(_T("\\"));
	while (nFind != -1)
	{
		strBase += strTemp.Left(nFind + 1);
		strTemp.Delete(0, nFind + 1);

		if (GetFileAttributes(strBase) == INVALID_FILE_ATTRIBUTES)
		{
			if (!CreateDirectory(strBase, NULL))
				goto clean0;
		}

		nFind = strTemp.Find(_T("\\"));
	}

	retval = TRUE;

clean0:
	return retval;
}
Esempio n. 2
0
DWORD WINAPI CMainDlg::DetectVersion(LPVOID lpParameter)
{
    CMainDlg *pThis = static_cast<CMainDlg *> (lpParameter);
    WTL::CString result;
    const wchar_t *p_versionstr;
    const wchar_t *p_versiondat;
    const wchar_t *p_term;
    DWORD res;
    int pos;

    pThis->m_edit.AppendText(L"Detecting scan executable\r\n");

    pThis->m_process = new Process(L"scan.exe /?");
    res = pThis->m_process->Exec(result);
    delete pThis->m_process;
    pThis->m_process = NULL;

    if (res) return -1;

    pos = result.Find(L"Scan engine v");

    if (pos == -1) /* V2 */
    {
        p_versionstr = L"McAfee VirusScan Command Line for Win32 Version: ";
        p_versiondat = L"Dat set version: ";
        p_term = L"\r";
        pThis->m_process = new Process(L"scan.exe /version");
        res = pThis->m_process->Exec(result);
        delete pThis->m_process;
        pThis->m_process = NULL;
        if (res) return -1;
        pos = result.Find(p_versionstr);
        if (pos == -1)
        {
            pThis->m_edit.AppendText(L"Unknown Version\r\n");
            return -1;
        }
        pThis->m_toolversion = 2;
    }
    else /* V1 */
    {
        p_versionstr = L"Scan engine v";
        p_versiondat = L"Virus data file v";
        p_term = L" ";
        pThis->m_toolversion = 1;
    }

    pos += wcslen(p_versionstr);
    WTL::CString verstr = result.Mid(pos);
    pos = verstr.Find(p_term);
    pThis->m_version = verstr.Left(pos);

    pos = result.Find(p_versiondat);
    if (pos == -1)
    {
        pThis->m_edit.AppendText(L"Cannot parse dat version\r\n");
        return -1;
    }

    pos += wcslen(p_versiondat);
    result = result.Mid(pos);
    pThis->m_datversion = _wtoi(result.GetBuffer(0));

    WTL::CString message;
    message.Format(L"Tool version %s - Dat Version %d\r\n", pThis->m_version,  pThis->m_datversion);
    pThis->m_edit.AppendText(message); 

    return 0;
}