Example #1
0
BOOL    CBkServiceCallImp::VerifyExePath( LPCWSTR lpwszExePath )
{
    BOOL    bRet = FALSE;
    HRESULT hr = S_OK;
    CString instpath;
    WinMod::CWinPath    path;

    path.m_strPath = lpwszExePath;

    bRet = path.IsExisting();
    if ( !bRet )
    {
        return bRet;
    }

    hr = CAppPath::Instance().GetLeidianAppPath( instpath );
    if ( SUCCEEDED( hr ) )
    {
        path.RemoveFileSpec();

        path.m_strPath.MakeLower();
        instpath.MakeLower();

        if ( wcsstr( path, instpath ) )
        {
            bRet = TRUE;
        }
    }

    return bRet;
}
Example #2
0
HRESULT CBkBackupProxy::Initialize()
{
    HRESULT hr = E_FAIL;

    WinMod::CWinPath    Path;

    //
    hr = CAppPath::Instance().GetLeidianAppPath( Path.m_strPath ); 
    if ( SUCCEEDED(hr) )
    {   
        Path.Append( BACKUP_DLL_NAME );
        hr = _LoadBkBackup( Path.m_strPath );
        if ( SUCCEEDED(hr) )
        {
            //成功返回
            return hr;
        }
    }
    //执行到这说名之前失败。
    hr = Path.GetModuleFileName(NULL);
    if ( SUCCEEDED(hr) )
    {
        Path.RemoveFileSpec();
        Path.Append( BACKUP_DLL_NAME );
        hr = _LoadBkBackup( Path.m_strPath );
        if ( SUCCEEDED(hr) )
        {
            //成功返回
            return hr;
        }
    }
    //
    return hr;
}
Example #3
0
BOOL    CBkServiceCallImp::VerifyProcess( DWORD dwProcId )
{
    BOOL    bRet = FALSE;
    DWORD   dwRet = 0;
    HRESULT hr = S_OK;
    HANDLE  hProcess = NULL;

    hProcess = OpenProcess(
        PROCESS_QUERY_INFORMATION | PROCESS_VM_READ,
        FALSE,
        dwProcId 
        );
    if ( hProcess )
    {
        TCHAR   wszBuf[ MAX_PATH + 1 ] = { 0 };

        dwRet = GetModuleFileNameEx( hProcess, NULL, wszBuf, MAX_PATH );
        if ( dwRet )
        {
            CString             instpath;
            WinMod::CWinPath    path;

            path.m_strPath = wszBuf;

            WinMod::CWinPathApi::ExpandLongPathName( path.m_strPath );

            hr = CAppPath::Instance().GetLeidianAppPath( instpath );
            if ( SUCCEEDED( hr ) )
            {
                path.RemoveFileSpec();

                path.m_strPath.MakeLower();

                instpath.MakeLower();

                if ( wcsstr( path, instpath ) )
                {
                    bRet = TRUE;
                }
            }
        }
    }

    if ( hProcess )
    {
        CloseHandle( hProcess );
        hProcess = NULL;
    }

    return bRet;
}
Example #4
0
HRESULT CAvpHeurDir::AddHeurDir(LPCWSTR lpszDirectory, BOOL bNormailized)
{
    assert(lpszDirectory && *lpszDirectory);
    if (!lpszDirectory || !*lpszDirectory)
        return E_INVALIDARG;

    assert(lpszDirectory && *lpszDirectory);
    if (!lpszDirectory || !*lpszDirectory)
        return S_FALSE;


    WinMod::CWinPath pathDir = lpszDirectory;
    if (!bNormailized)
    {
        pathDir.ExpandNormalizedPathName();
    }
    pathDir.AddBackslash();
    pathDir.m_strPath.MakeLower();
    m_HeurDirMap.SetAt(pathDir, 0);
    return S_OK;
}
Example #5
0
void CUnique::AddCancelDoubleDir( const CString& ScanDir, BOOL bRecursion )
{
    WinMod::CWinPath DirPath;
    DirPath.m_strPath = ScanDir;
    DirPath.AddBackslash();
  
    if ( FALSE == WinMod::CWinPathApi::IsDirectory(DirPath.m_strPath) )
    {
        _ASSERT(0);
        return;
    }

    BOOL bExit = FALSE;
    POSITION Pos = m_DirPathMap.GetStartPosition();
    if (  NULL == Pos )
    {
        m_DirPathMap.SetAt( DirPath.m_strPath, bRecursion );
        bExit = TRUE;
    }
    else
    {
        //消重判断
        while ( Pos )
        {
            CAtlMap<CString, BOOL>::CPair* pPair = m_DirPathMap.GetNext( Pos );
            if ( -1 != DirPath.m_strPath.Find(pPair->m_key) && pPair->m_value )
            {
                //1 是扫描过的某个目录的子目录,并且扫描过的某个目录是递归扫描。
                //2 是扫描过的某个目录,并且扫描过的目录是递归扫描。
                //不管所要扫描的目录是否递归。它都已经被扫描过来。
                bExit = TRUE;
                break;
            }
        }
    }
    if ( bExit )
    {
        return;
    }

    //消重判断
    if ( bRecursion )
    {
        //1 不是扫描过的目录的子目录,而是已经扫描过目录的父目录,并且当前目录递归扫描(要对消重表进行消重)
        CAtlArray<CString> DelKeyArray;
        POSITION Pos = m_DirPathMap.GetStartPosition();
        while ( Pos )
        {
            CAtlMap<CString, BOOL>::CPair* pPair = m_DirPathMap.GetNext( Pos );
            if ( -1 != pPair->m_key.Find(DirPath.m_strPath) )
            {
                DelKeyArray.Add( pPair->m_key );
            }
        }
        size_t Num = DelKeyArray.GetCount();
        size_t i = 0;
        for(; i<Num; ++i )
        {
            m_DirPathMap.RemoveKey( DelKeyArray[i] );
        }
    }

    //1 并不是扫描过的目录的子目录,而是无关的目录。(添加新项)
    //2 并不是扫描过的目录的子目录,而是以扫描过目录的父目录,并且当前目录递归扫描。(要对消重表进行消重,之后添加新项)
    //3 是扫描过的某个目录的子目录,但扫描过的某个目录,并不是递归扫描。(添加新项)
    //4 有可能DirPath这个目录.已经非递归扫过,这里重新赋下值。(重新赋值)
    m_DirPathMap.SetAt( DirPath.m_strPath, bRecursion );
}
Example #6
0
HRESULT CZlib::InitZlib()
{
#if defined(USE_STATIC_ZLIB)
	zlib_compress       = compress;
	zlib_compress2      = compress2;
	zlib_uncompress     = uncompress;
	zlib_inflate        = inflate;
	zlib_inflateEnd     = inflateEnd;
	zlib_inflateInit_   = inflateInit_;
	zlib_inflateInit2_  = inflateInit2_;
	return S_OK;
#else
	HRESULT             hr = S_OK;
	WinMod::CWinPath    modpath;

    hr = CAppPath::Instance().GetLeidianAppPath( modpath.m_strPath );
    if ( FAILED( hr ) )
    {
        return hr;
    }

    modpath.Append( ZLIB_FILE_NAME );

    m_lock.Lock();
    if ( NULL == g_hZlib )
    {
        g_hZlib = LoadLibrary( modpath );
        if ( NULL == g_hZlib )
        {
            hr = HRESULT_FROM_WIN32( GetLastError() );
            goto Exit0;
        }

        zlib_compress = ( PFN_compress )GetProcAddress( g_hZlib, FN_compress );
        if ( NULL == zlib_compress )
        {
            hr = HRESULT_FROM_WIN32( GetLastError() );
            goto Exit0;
        }

        zlib_compress2 = ( PFN_compress2 )GetProcAddress( g_hZlib, FN_compress2 );
        if ( NULL == zlib_compress )
        {
            hr = HRESULT_FROM_WIN32( GetLastError() );
            goto Exit0;
        }

        zlib_uncompress = ( PFN_uncompress )GetProcAddress( g_hZlib, FN_uncompress );
        if ( NULL == zlib_uncompress )
        {
            hr = HRESULT_FROM_WIN32( GetLastError() );
            goto Exit0;
        }

        zlib_inflate = ( PFN_inflate )GetProcAddress( g_hZlib, FN_inflate );
        if ( NULL == zlib_inflate )
        {
            hr = HRESULT_FROM_WIN32( GetLastError() );
            goto Exit0;
        }

        zlib_inflateEnd = ( PFN_inflateEnd )GetProcAddress( g_hZlib, FN_inflateEnd );
        if ( NULL == zlib_inflateEnd )
        {
            hr = HRESULT_FROM_WIN32( GetLastError() );
            goto Exit0;
        }

        zlib_inflateInit_ = ( PFN_inflateInit_ )GetProcAddress( g_hZlib, FN_inflateInit_ );
        if ( NULL == zlib_inflateInit_ )
        {
            hr = HRESULT_FROM_WIN32( GetLastError() );
            goto Exit0;
        }

        zlib_inflateInit2_ = ( PFN_inflateInit2_ )GetProcAddress( g_hZlib, FN_inflateInit2_ );
        if ( NULL == zlib_inflateInit2_ )
        {
            hr = HRESULT_FROM_WIN32( GetLastError() );
            goto Exit0;
        }
    }
Exit0:
    if ( FAILED( hr ) )
    {
        zlib_compress = NULL;
        zlib_uncompress = NULL;

        FreeLibrary( g_hZlib );
        g_hZlib = NULL;
    }

    m_lock.Unlock();
    return hr;
#endif
}