Commit 0aa3c187 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

fusion: Use parsed properties for assembly enumeration instead of trying to…

fusion: Use parsed properties for assembly enumeration instead of trying to parse the display name again. The display name passed in may not be normalized, e.g. if the version number is passed as "1.0.0.00000" instead of "1.0.0.0". This patch should also cut down on case insensitive file searches.
parent 43094e4a
......@@ -162,17 +162,19 @@ static const IAssemblyEnumVtbl AssemblyEnumVtbl = {
static void parse_name(IAssemblyName *name, int depth, LPWSTR path, LPWSTR buf)
{
WCHAR disp[MAX_PATH];
LPWSTR ptr, end;
LPCWSTR verptr, pubkeyptr;
HRESULT hr;
DWORD size;
DWORD size, major_size, minor_size, build_size, revision_size;
WORD major, minor, build, revision;
static const WCHAR star[] = {'*',0};
static const WCHAR ss_fmt[] = {'%','s','\\','%','s',0};
static const WCHAR verpubkey[] = {'%','s','\\','%','s','_','_','%','s',0};
static const WCHAR version[] = {'V','e','r','s','i','o','n','=',0};
static const WCHAR pubkeytok[] = {
'P','u','b','l','i','c','K','e','y','T','o','k','e','n','=',0};
static const WCHAR ver_fmt[] = {'%','u','.','%','u','.','%','u','.','%','u',0};
WCHAR version[24]; /* strlen("65535") * 4 + 3 + 1 */
WCHAR token_str[TOKEN_LENGTH + 1];
BYTE token[BYTES_PER_TOKEN];
if (depth == 0)
{
......@@ -186,36 +188,33 @@ static void parse_name(IAssemblyName *name, int depth, LPWSTR path, LPWSTR buf)
}
else if (depth == 1)
{
size = MAX_PATH;
hr = IAssemblyName_GetDisplayName(name, disp, &size, 0);
if (FAILED(hr))
{
sprintfW(buf, verpubkey, path, star, star);
return;
}
major_size = sizeof(major);
IAssemblyName_GetProperty(name, ASM_NAME_MAJOR_VERSION, &major, &major_size);
ptr = disp;
verptr = strstrW(ptr, version);
if (!verptr)
verptr = star;
minor_size = sizeof(minor);
IAssemblyName_GetProperty(name, ASM_NAME_MINOR_VERSION, &minor, &minor_size);
build_size = sizeof(build);
IAssemblyName_GetProperty(name, ASM_NAME_BUILD_NUMBER, &build, &build_size);
revision_size = sizeof(revision);
IAssemblyName_GetProperty(name, ASM_NAME_REVISION_NUMBER, &revision, &revision_size);
if (!major_size || !minor_size || !build_size || !revision_size) verptr = star;
else
{
verptr = strchrW(verptr, '=') + 1;
if ((end = strchrW(verptr, ',')))
{
*end = '\0';
ptr = end + 1;
}
sprintfW(version, ver_fmt, major, minor, build, revision);
verptr = version;
}
pubkeyptr = strstrW(ptr, pubkeytok);
if (!pubkeyptr)
pubkeyptr = star;
size = sizeof(token);
IAssemblyName_GetProperty(name, ASM_NAME_PUBLIC_KEY_TOKEN, token, &size);
if (!size) pubkeyptr = star;
else
{
pubkeyptr = strchrW(pubkeyptr, '=') + 1;
if ((end = strchrW(pubkeyptr, ',')))
*end = '\0';
token_to_str(token, token_str);
pubkeyptr = token_str;
}
sprintfW(buf, verpubkey, path, verptr, pubkeyptr);
......
......@@ -989,6 +989,8 @@ static void test_QueryAssemblyInfo(void)
static const WCHAR wine[] = {'w','i','n','e',0};
static const WCHAR ver[] = {
'V','e','r','s','i','o','n','=','1','.','0','.','0','.','0',0};
static const WCHAR otherver[] = {
'V','e','r','s','i','o','n','=','1','.','0','.','0','.','0','0','0','0','0',0};
static const WCHAR badver[] = {
'V','e','r','s','i','o','n','=','1','.','0','.','0','.','1',0};
static const WCHAR culture[] = {
......@@ -1303,6 +1305,30 @@ static void test_QueryAssemblyInfo(void)
"Expected %d, got %d\n", lstrlenW(asmpath) + 1, info.cchBuf);
}
/* display name is "wine, Version=1.0.0.00000" */
INIT_ASM_INFO();
lstrcpyW(name, wine);
lstrcatW(name, commasep);
lstrcatW(name, otherver);
hr = IAssemblyCache_QueryAssemblyInfo(cache, QUERYASMINFO_FLAG_GETSIZE,
name, &info);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
ok(info.cbAssemblyInfo == sizeof(ASSEMBLY_INFO),
"Expected sizeof(ASSEMBLY_INFO), got %d\n", info.cbAssemblyInfo);
ok(info.dwAssemblyFlags == ASSEMBLYINFO_FLAG_INSTALLED,
"Expected ASSEMBLYINFO_FLAG_INSTALLED, got %08x\n", info.dwAssemblyFlags);
ok(info.uliAssemblySizeInKB.u.HighPart == 0,
"Expected 0, got %d\n", info.uliAssemblySizeInKB.u.HighPart);
todo_wine
{
ok(info.uliAssemblySizeInKB.u.LowPart == 4,
"Expected 4, got %d\n", info.uliAssemblySizeInKB.u.LowPart);
ok(!lstrcmpW(info.pszCurrentAssemblyPathBuf, asmpath),
"Wrong assembly path returned\n");
ok(info.cchBuf == lstrlenW(asmpath) + 1,
"Expected %d, got %d\n", lstrlenW(asmpath) + 1, info.cchBuf);
}
/* display name is "wine, Version=1.0.0.1", versions don't match */
INIT_ASM_INFO();
lstrcpyW(name, wine);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment