Commit ea40a904 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

fusion: Account for the version prefix when building the file mask.

parent de1f2ffd
......@@ -166,23 +166,32 @@ static const IAssemblyEnumVtbl AssemblyEnumVtbl = {
IAssemblyEnumImpl_Clone
};
static void parse_name(IAssemblyName *name, int depth, LPWSTR path, LPWSTR buf)
static void build_file_mask(IAssemblyName *name, int depth, const WCHAR *path,
const WCHAR *prefix, WCHAR *buf)
{
WCHAR disp[MAX_PATH];
static const WCHAR star[] = {'*',0};
static const WCHAR ss_fmt[] = {'%','s','\\','%','s',0};
static const WCHAR sss_fmt[] = {'%','s','\\','%','s','_','_','%','s',0};
static const WCHAR ssss_fmt[] = {'%','s','\\','%','s','%','s','_','_','%','s',0};
static const WCHAR ver_fmt[] = {'%','u','.','%','u','.','%','u','.','%','u',0};
static const WCHAR star_fmt[] = {'%','s','\\','*',0};
static const WCHAR star_prefix_fmt[] = {'%','s','\\','%','s','*',0};
WCHAR disp[MAX_PATH], version[24]; /* strlen("65535") * 4 + 3 + 1 */
LPCWSTR verptr, pubkeyptr;
HRESULT hr;
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 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 (!name)
{
if (prefix && depth == 1)
sprintfW(buf, star_prefix_fmt, path, prefix);
else
sprintfW(buf, star_fmt, path);
return;
}
if (depth == 0)
{
size = MAX_PATH;
......@@ -224,7 +233,10 @@ static void parse_name(IAssemblyName *name, int depth, LPWSTR path, LPWSTR buf)
pubkeyptr = token_str;
}
sprintfW(buf, verpubkey, path, verptr, pubkeyptr);
if (prefix)
sprintfW(buf, ssss_fmt, path, prefix, verptr, pubkeyptr);
else
sprintfW(buf, sss_fmt, path, verptr, pubkeyptr);
}
}
......@@ -289,31 +301,24 @@ static void insert_assembly(struct list *assemblies, ASMNAME *to_insert)
}
static HRESULT enum_gac_assemblies(struct list *assemblies, IAssemblyName *name,
int depth, LPWSTR path)
int depth, const WCHAR *prefix, LPWSTR path)
{
static const WCHAR dot[] = {'.',0};
static const WCHAR dotdot[] = {'.','.',0};
static const WCHAR search_fmt[] = {'%','s','\\','*',0};
static const WCHAR dblunder[] = {'_','_',0};
static const WCHAR path_fmt[] = {'%','s','\\','%','s','\\','%','s','.','d','l','l',0};
static const WCHAR fmt[] = {'%','s',',',' ','V','e','r','s','i','o','n','=','%','s',',',' ',
static const WCHAR name_fmt[] = {'%','s',',',' ','V','e','r','s','i','o','n','=','%','s',',',' ',
'C','u','l','t','u','r','e','=','n','e','u','t','r','a','l',',',' ',
'P','u','b','l','i','c','K','e','y','T','o','k','e','n','=','%','s',0};
static const WCHAR ss_fmt[] = {'%','s','\\','%','s',0};
static const WCHAR v40[] = {'v','4','.','0','_'};
WIN32_FIND_DATAW ffd;
WCHAR buf[MAX_PATH], disp[MAX_PATH], asmpath[MAX_PATH];
WCHAR buf[MAX_PATH], disp[MAX_PATH], asmpath[MAX_PATH], *ptr;
static WCHAR parent[MAX_PATH];
ASMNAME *asmname;
HANDLE hfind;
WCHAR *ptr;
HRESULT hr = S_OK;
if (name)
parse_name(name, depth, path, buf);
else
sprintfW(buf, search_fmt, path);
build_file_mask(name, depth, path, prefix, buf);
hfind = FindFirstFileW(buf, &ffd);
if (hfind == INVALID_HANDLE_VALUE)
return S_OK;
......@@ -334,19 +339,21 @@ static HRESULT enum_gac_assemblies(struct list *assemblies, IAssemblyName *name,
}
else if (depth == 1)
{
unsigned int prefix_len = sizeof(v40)/sizeof(WCHAR);
const WCHAR *token, *version = ffd.cFileName;
sprintfW(asmpath, path_fmt, path, ffd.cFileName, parent);
ptr = strstrW(ffd.cFileName, dblunder);
*ptr = '\0';
token = ptr + 2;
if (strlenW(ffd.cFileName) >= prefix_len &&
!memcmp(ffd.cFileName, v40, sizeof(v40))) version += prefix_len;
sprintfW(disp, fmt, parent, version, token);
if (prefix)
{
unsigned int prefix_len = strlenW(prefix);
if (strlenW(ffd.cFileName) >= prefix_len &&
!memicmpW(ffd.cFileName, prefix, prefix_len))
version += prefix_len;
}
sprintfW(disp, name_fmt, parent, version, token);
asmname = HeapAlloc(GetProcessHeap(), 0, sizeof(ASMNAME));
if (!asmname)
......@@ -376,7 +383,7 @@ static HRESULT enum_gac_assemblies(struct list *assemblies, IAssemblyName *name,
}
sprintfW(buf, ss_fmt, path, ffd.cFileName);
hr = enum_gac_assemblies(assemblies, name, depth + 1, buf);
hr = enum_gac_assemblies(assemblies, name, depth + 1, prefix, buf);
if (FAILED(hr))
break;
} while (FindNextFileW(hfind, &ffd) != 0);
......@@ -391,6 +398,7 @@ static HRESULT enumerate_gac(IAssemblyEnumImpl *asmenum, IAssemblyName *pName)
static const WCHAR gac_32[] = {'\\','G','A','C','_','3','2',0};
static const WCHAR gac_64[] = {'\\','G','A','C','_','6','4',0};
static const WCHAR gac_msil[] = {'\\','G','A','C','_','M','S','I','L',0};
static const WCHAR v40[] = {'v','4','.','0','_',0};
WCHAR path[MAX_PATH], buf[MAX_PATH];
SYSTEM_INFO info;
HRESULT hr;
......@@ -406,17 +414,17 @@ static HRESULT enumerate_gac(IAssemblyEnumImpl *asmenum, IAssemblyName *pName)
if (info.u.s.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
{
strcpyW(path + size - 1, gac_64);
hr = enum_gac_assemblies(&asmenum->assemblies, pName, 0, path);
hr = enum_gac_assemblies(&asmenum->assemblies, pName, 0, v40, path);
if (FAILED(hr))
return hr;
}
strcpyW(path + size - 1, gac_32);
hr = enum_gac_assemblies(&asmenum->assemblies, pName, 0, path);
hr = enum_gac_assemblies(&asmenum->assemblies, pName, 0, v40, path);
if (FAILED(hr))
return hr;
strcpyW(path + size - 1, gac_msil);
hr = enum_gac_assemblies(&asmenum->assemblies, pName, 0, path);
hr = enum_gac_assemblies(&asmenum->assemblies, pName, 0, v40, path);
if (FAILED(hr))
return hr;
......@@ -429,22 +437,22 @@ static HRESULT enumerate_gac(IAssemblyEnumImpl *asmenum, IAssemblyName *pName)
if (info.u.s.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
{
strcpyW(path + size - 1, gac_64);
hr = enum_gac_assemblies(&asmenum->assemblies, pName, 0, path);
hr = enum_gac_assemblies(&asmenum->assemblies, pName, 0, NULL, path);
if (FAILED(hr))
return hr;
}
strcpyW(path + size - 1, gac_32);
hr = enum_gac_assemblies(&asmenum->assemblies, pName, 0, path);
hr = enum_gac_assemblies(&asmenum->assemblies, pName, 0, NULL, path);
if (FAILED(hr))
return hr;
strcpyW(path + size - 1, gac_msil);
hr = enum_gac_assemblies(&asmenum->assemblies, pName, 0, path);
hr = enum_gac_assemblies(&asmenum->assemblies, pName, 0, NULL, path);
if (FAILED(hr))
return hr;
strcpyW(path + size - 1, gac);
hr = enum_gac_assemblies(&asmenum->assemblies, pName, 0, path);
hr = enum_gac_assemblies(&asmenum->assemblies, pName, 0, NULL, path);
if (FAILED(hr))
return hr;
......
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