Ejemplo n.º 1
0
static HRESULT WINAPI IAssemblyCacheImpl_QueryAssemblyInfo(IAssemblyCache *iface,
                                                           DWORD dwFlags,
                                                           LPCWSTR pszAssemblyName,
                                                           ASSEMBLY_INFO *pAsmInfo)
{
    IAssemblyCacheImpl *cache = impl_from_IAssemblyCache(iface);
    IAssemblyName *asmname, *next = NULL;
    IAssemblyEnum *asmenum = NULL;
    HRESULT hr;

    TRACE("(%p, %d, %s, %p)\n", iface, dwFlags,
          debugstr_w(pszAssemblyName), pAsmInfo);

    if (pAsmInfo)
    {
        if (pAsmInfo->cbAssemblyInfo == 0)
            pAsmInfo->cbAssemblyInfo = sizeof(ASSEMBLY_INFO);
        else if (pAsmInfo->cbAssemblyInfo != sizeof(ASSEMBLY_INFO))
            return E_INVALIDARG;
    }

    hr = CreateAssemblyNameObject(&asmname, pszAssemblyName,
                                  CANOF_PARSE_DISPLAY_NAME, NULL);
    if (FAILED(hr))
        return hr;

    cache_lock( cache );

    hr = CreateAssemblyEnum(&asmenum, NULL, asmname, ASM_CACHE_GAC, NULL);
    if (FAILED(hr))
        goto done;

    for (;;)
    {
        hr = IAssemblyEnum_GetNextAssembly(asmenum, NULL, &next, 0);
        if (hr != S_OK)
        {
            hr = HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
            goto done;
        }
        hr = IAssemblyName_IsEqual(asmname, next, ASM_CMPF_IL_ALL);
        if (hr == S_OK) break;
    }

    if (!pAsmInfo)
        goto done;

    hr = IAssemblyName_GetPath(next, pAsmInfo->pszCurrentAssemblyPathBuf, &pAsmInfo->cchBuf);

    pAsmInfo->dwAssemblyFlags = ASSEMBLYINFO_FLAG_INSTALLED;

done:
    IAssemblyName_Release(asmname);
    if (next) IAssemblyName_Release(next);
    if (asmenum) IAssemblyEnum_Release(asmenum);
    cache_unlock( cache );
    return hr;
}
Ejemplo n.º 2
0
static void test_IAssemblyName_IsEqual(void)
{
    static const WCHAR wine1[] =
        {'w','i','n','e',0};
    static const WCHAR wine2[] =
        {'w','i','n','e',',','v','e','r','s','i','o','n','=','1','.','0','.','0','.','0',0};
    static const WCHAR wine3[] =
        {'w','i','n','e',',','v','e','r','s','i','o','n','=','1','.','0','.','0','.','0',',',
         'c','u','l','t','u','r','e','=','n','e','u','t','r','a','l',0};
    static const WCHAR wine4[] =
        {'w','i','n','e',',','v','e','r','s','i','o','n','=','1','.','0','.','0','.','0',',',
         'c','u','l','t','u','r','e','=','e','n',0};
    static const WCHAR wine5[] =
        {'w','i','n','e',',','v','e','r','s','i','o','n','=','1','.','0','.','0','.','0',',',
         'p','u','b','l','i','c','K','e','y','T','o','k','e','n','=','1','2','3','4','5','6',
         '7','8','9','0','a','b','c','d','e','f',0};
    HRESULT hr;
    IAssemblyName *name1, *name2;

    hr = pCreateAssemblyNameObject( &name1, wine1, CANOF_PARSE_DISPLAY_NAME, NULL );
    ok( hr == S_OK, "got %08x\n", hr );

    hr = pCreateAssemblyNameObject( &name2, wine1, CANOF_PARSE_DISPLAY_NAME, NULL );
    ok( hr == S_OK, "got %08x\n", hr );

    if (0) { /* crashes on some old version */
    hr = IAssemblyName_IsEqual( name1, NULL, 0 );
    ok( hr == S_FALSE, "got %08x\n", hr );

    hr = IAssemblyName_IsEqual( name1, NULL, ASM_CMPF_IL_ALL );
    ok( hr == S_FALSE, "got %08x\n", hr );
    }

    hr = IAssemblyName_IsEqual( name1, name1, ASM_CMPF_IL_ALL );
    ok( hr == S_OK, "got %08x\n", hr );

    hr = IAssemblyName_IsEqual( name1, name2, ASM_CMPF_IL_ALL );
    ok( hr == S_OK, "got %08x\n", hr );

    IAssemblyName_Release( name2 );
    hr = pCreateAssemblyNameObject( &name2, wine2, CANOF_PARSE_DISPLAY_NAME, NULL );
    ok( hr == S_OK, "got %08x\n", hr );

    hr = IAssemblyName_IsEqual( name1, name2, ASM_CMPF_IL_ALL );
    ok( hr == S_OK, "got %08x\n", hr );

    IAssemblyName_Release( name2 );
    hr = pCreateAssemblyNameObject( &name2, wine3, CANOF_PARSE_DISPLAY_NAME, NULL );
    ok( hr == S_OK, "got %08x\n", hr );

    hr = IAssemblyName_IsEqual( name1, name2, ASM_CMPF_IL_ALL );
    ok( hr == S_OK, "got %08x\n", hr );

    IAssemblyName_Release( name1 );
    hr = pCreateAssemblyNameObject( &name1, wine4, CANOF_PARSE_DISPLAY_NAME, NULL );
    ok( hr == S_OK, "got %08x\n", hr );

    hr = IAssemblyName_IsEqual( name1, name2, ASM_CMPF_IL_ALL );
    ok( hr == S_FALSE, "got %08x\n", hr );

    IAssemblyName_Release( name1 );
    hr = pCreateAssemblyNameObject( &name1, wine1, CANOF_PARSE_DISPLAY_NAME, NULL );
    ok( hr == S_OK, "got %08x\n", hr );

    IAssemblyName_Release( name2 );
    hr = pCreateAssemblyNameObject( &name2, wine5, CANOF_PARSE_DISPLAY_NAME, NULL );
    ok( hr == S_OK, "got %08x\n", hr );

    hr = IAssemblyName_IsEqual( name1, name2, ASM_CMPF_IL_ALL );
    ok( hr == S_OK, "got %08x\n", hr );

    IAssemblyName_Release( name1 );
    IAssemblyName_Release( name2 );
}