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

fusion: Convert to Unicode.

parent a76c1535
...@@ -41,24 +41,24 @@ ...@@ -41,24 +41,24 @@
WINE_DEFAULT_DEBUG_CHANNEL(fusion); WINE_DEFAULT_DEBUG_CHANNEL(fusion);
static BOOL create_full_path(LPCSTR path) static BOOL create_full_path(LPCWSTR path)
{ {
LPSTR new_path; LPWSTR new_path;
BOOL ret = TRUE; BOOL ret = TRUE;
int len; int len;
new_path = HeapAlloc(GetProcessHeap(), 0, lstrlenA(path) + 1); new_path = HeapAlloc(GetProcessHeap(), 0, (strlenW(path) + 1) * sizeof(WCHAR));
if (!new_path) if (!new_path)
return FALSE; return FALSE;
lstrcpyA(new_path, path); strcpyW(new_path, path);
while ((len = lstrlenA(new_path)) && new_path[len - 1] == '\\') while ((len = strlenW(new_path)) && new_path[len - 1] == '\\')
new_path[len - 1] = 0; new_path[len - 1] = 0;
while (!CreateDirectoryA(new_path, NULL)) while (!CreateDirectoryW(new_path, NULL))
{ {
LPSTR slash; LPWSTR slash;
DWORD last_error = GetLastError(); DWORD last_error = GetLastError();
if(last_error == ERROR_ALREADY_EXISTS) if(last_error == ERROR_ALREADY_EXISTS)
...@@ -70,7 +70,7 @@ static BOOL create_full_path(LPCSTR path) ...@@ -70,7 +70,7 @@ static BOOL create_full_path(LPCSTR path)
break; break;
} }
if(!(slash = strrchr(new_path, '\\'))) if(!(slash = strrchrW(new_path, '\\')))
{ {
ret = FALSE; ret = FALSE;
break; break;
...@@ -91,6 +91,18 @@ static BOOL create_full_path(LPCSTR path) ...@@ -91,6 +91,18 @@ static BOOL create_full_path(LPCSTR path)
return ret; return ret;
} }
static BOOL get_assembly_directory(LPWSTR dir, DWORD size)
{
static const WCHAR gac[] =
{'\\','a','s','s','e','m','b','l','y','\\','G','A','C','_','M','S','I','L',0};
FIXME("Ignoring assembly architecture\n");
GetWindowsDirectoryW(dir, size);
strcatW(dir, gac);
return TRUE;
}
/* IAssemblyCache */ /* IAssemblyCache */
typedef struct { typedef struct {
...@@ -228,14 +240,17 @@ static HRESULT WINAPI IAssemblyCacheImpl_InstallAssembly(IAssemblyCache *iface, ...@@ -228,14 +240,17 @@ static HRESULT WINAPI IAssemblyCacheImpl_InstallAssembly(IAssemblyCache *iface,
LPCWSTR pszManifestFilePath, LPCWSTR pszManifestFilePath,
LPCFUSION_INSTALL_REFERENCE pRefData) LPCFUSION_INSTALL_REFERENCE pRefData)
{ {
static const WCHAR format[] =
{'%','s','\\','%','s','\\','%','s','_','_','%','s','\\',0};
ASSEMBLY *assembly; ASSEMBLY *assembly;
LPSTR filename; LPWSTR filename;
LPSTR name = NULL; LPWSTR name = NULL;
LPSTR token = NULL; LPWSTR token = NULL;
LPSTR version = NULL; LPWSTR version = NULL;
LPSTR asmpath = NULL; LPWSTR asmpath = NULL;
CHAR path[MAX_PATH]; WCHAR path[MAX_PATH];
CHAR windir[MAX_PATH]; WCHAR asmdir[MAX_PATH];
LPWSTR ext; LPWSTR ext;
HRESULT hr; HRESULT hr;
...@@ -276,12 +291,9 @@ static HRESULT WINAPI IAssemblyCacheImpl_InstallAssembly(IAssemblyCache *iface, ...@@ -276,12 +291,9 @@ static HRESULT WINAPI IAssemblyCacheImpl_InstallAssembly(IAssemblyCache *iface,
if (FAILED(hr)) if (FAILED(hr))
goto done; goto done;
GetWindowsDirectoryA(windir, MAX_PATH); get_assembly_directory(asmdir, MAX_PATH);
FIXME("Ignoring assembly architecture!\n");
sprintf(path, "%s\\assembly\\GAC_MSIL\\%s\\%s__%s\\", windir, name, sprintfW(path, format, asmdir, name, version, token);
version, token);
create_full_path(path); create_full_path(path);
...@@ -289,10 +301,10 @@ static HRESULT WINAPI IAssemblyCacheImpl_InstallAssembly(IAssemblyCache *iface, ...@@ -289,10 +301,10 @@ static HRESULT WINAPI IAssemblyCacheImpl_InstallAssembly(IAssemblyCache *iface,
if (FAILED(hr)) if (FAILED(hr))
goto done; goto done;
filename = PathFindFileNameA(asmpath); filename = PathFindFileNameW(asmpath);
lstrcatA(path, filename); strcatW(path, filename);
if (!CopyFileA(asmpath, path, FALSE)) if (!CopyFileW(asmpath, path, FALSE))
hr = HRESULT_FROM_WIN32(GetLastError()); hr = HRESULT_FROM_WIN32(GetLastError());
done: done:
......
...@@ -52,7 +52,7 @@ typedef struct tagCLRTABLE ...@@ -52,7 +52,7 @@ typedef struct tagCLRTABLE
struct tagASSEMBLY struct tagASSEMBLY
{ {
LPSTR path; LPWSTR path;
HANDLE hfile; HANDLE hfile;
HANDLE hmap; HANDLE hmap;
...@@ -76,22 +76,6 @@ struct tagASSEMBLY ...@@ -76,22 +76,6 @@ struct tagASSEMBLY
BYTE *blobs; BYTE *blobs;
}; };
static LPSTR strdupWtoA(LPCWSTR str)
{
LPSTR ret = NULL;
DWORD len;
if (!str)
return ret;
len = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
ret = HeapAlloc(GetProcessHeap(), 0, len);
if (ret)
WideCharToMultiByte(CP_ACP, 0, str, -1, ret, len, NULL, NULL);
return ret;
}
static DWORD rva_to_offset(IMAGE_NT_HEADERS *nthdrs, DWORD rva) static DWORD rva_to_offset(IMAGE_NT_HEADERS *nthdrs, DWORD rva)
{ {
DWORD offset = rva, limit; DWORD offset = rva, limit;
...@@ -684,7 +668,7 @@ HRESULT assembly_create(ASSEMBLY **out, LPCWSTR file) ...@@ -684,7 +668,7 @@ HRESULT assembly_create(ASSEMBLY **out, LPCWSTR file)
if (!assembly) if (!assembly)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
assembly->path = strdupWtoA(file); assembly->path = strdupW(file);
if (!assembly->path) if (!assembly->path)
{ {
hr = E_OUTOFMEMORY; hr = E_OUTOFMEMORY;
...@@ -743,16 +727,21 @@ HRESULT assembly_release(ASSEMBLY *assembly) ...@@ -743,16 +727,21 @@ HRESULT assembly_release(ASSEMBLY *assembly)
return S_OK; return S_OK;
} }
static LPSTR assembly_dup_str(ASSEMBLY *assembly, DWORD index) static LPWSTR assembly_dup_str(ASSEMBLY *assembly, DWORD index)
{ {
int len;
LPWSTR cpy;
LPSTR str = (LPSTR)&assembly->strings[index]; LPSTR str = (LPSTR)&assembly->strings[index];
LPSTR cpy = HeapAlloc(GetProcessHeap(), 0, strlen(str)+1);
if (cpy) len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
strcpy(cpy, str);
if ((cpy = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR))))
MultiByteToWideChar(CP_ACP, 0, str, -1, cpy, len);
return cpy; return cpy;
} }
HRESULT assembly_get_name(ASSEMBLY *assembly, LPSTR *name) HRESULT assembly_get_name(ASSEMBLY *assembly, LPWSTR *name)
{ {
BYTE *ptr; BYTE *ptr;
LONG offset; LONG offset;
...@@ -779,20 +768,22 @@ HRESULT assembly_get_name(ASSEMBLY *assembly, LPSTR *name) ...@@ -779,20 +768,22 @@ HRESULT assembly_get_name(ASSEMBLY *assembly, LPSTR *name)
return S_OK; return S_OK;
} }
HRESULT assembly_get_path(ASSEMBLY *assembly, LPSTR *path) HRESULT assembly_get_path(ASSEMBLY *assembly, LPWSTR *path)
{ {
LPSTR cpy = HeapAlloc(GetProcessHeap(), 0, strlen(assembly->path)+1); LPWSTR cpy = HeapAlloc(GetProcessHeap(), 0, (strlenW(assembly->path) + 1) * sizeof(WCHAR));
*path = cpy; *path = cpy;
if (cpy) if (cpy)
strcpy(cpy, assembly->path); strcpyW(cpy, assembly->path);
else else
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
return S_OK; return S_OK;
} }
HRESULT assembly_get_version(ASSEMBLY *assembly, LPSTR *version) HRESULT assembly_get_version(ASSEMBLY *assembly, LPWSTR *version)
{ {
static const WCHAR format[] = {'%','u','.','%','u','.','%','u','.','%','u',0};
ASSEMBLYTABLE *asmtbl; ASSEMBLYTABLE *asmtbl;
LONG offset; LONG offset;
...@@ -806,11 +797,11 @@ HRESULT assembly_get_version(ASSEMBLY *assembly, LPSTR *version) ...@@ -806,11 +797,11 @@ HRESULT assembly_get_version(ASSEMBLY *assembly, LPSTR *version)
if (!asmtbl) if (!asmtbl)
return E_FAIL; return E_FAIL;
*version = HeapAlloc(GetProcessHeap(), 0, sizeof("%u.%u.%u.%u") + 4 * strlen("65535")); *version = HeapAlloc(GetProcessHeap(), 0, sizeof(format) + 4 * strlen("65535") * sizeof(WCHAR));
if (!*version) if (!*version)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
sprintf(*version, "%u.%u.%u.%u", asmtbl->MajorVersion, asmtbl->MinorVersion, sprintfW(*version, format, asmtbl->MajorVersion, asmtbl->MinorVersion,
asmtbl->BuildNumber, asmtbl->RevisionNumber); asmtbl->BuildNumber, asmtbl->RevisionNumber);
return S_OK; return S_OK;
...@@ -827,26 +818,7 @@ static BYTE *assembly_get_blob(ASSEMBLY *assembly, WORD index, ULONG *size) ...@@ -827,26 +818,7 @@ static BYTE *assembly_get_blob(ASSEMBLY *assembly, WORD index, ULONG *size)
return GetData(&assembly->blobs[index], size); return GetData(&assembly->blobs[index], size);
} }
static void bytes_to_str(BYTE *bytes, DWORD len, LPSTR str) HRESULT assembly_get_pubkey_token(ASSEMBLY *assembly, LPWSTR *token)
{
DWORD i;
static const char hexval[16] = {
'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'
};
for(i = 0; i < len; i++)
{
str[i * 2] = hexval[((bytes[i] >> 4) & 0xF)];
str[i * 2 + 1] = hexval[(bytes[i]) & 0x0F];
}
}
#define BYTES_PER_TOKEN 8
#define CHARS_PER_BYTE 2
#define TOKEN_LENGTH (BYTES_PER_TOKEN * CHARS_PER_BYTE + 1)
HRESULT assembly_get_pubkey_token(ASSEMBLY *assembly, LPSTR *token)
{ {
ASSEMBLYTABLE *asmtbl; ASSEMBLYTABLE *asmtbl;
ULONG i, size; ULONG i, size;
...@@ -857,7 +829,7 @@ HRESULT assembly_get_pubkey_token(ASSEMBLY *assembly, LPSTR *token) ...@@ -857,7 +829,7 @@ HRESULT assembly_get_pubkey_token(ASSEMBLY *assembly, LPSTR *token)
BYTE *pubkey; BYTE *pubkey;
BYTE tokbytes[BYTES_PER_TOKEN]; BYTE tokbytes[BYTES_PER_TOKEN];
HRESULT hr = E_FAIL; HRESULT hr = E_FAIL;
LPSTR tok; LPWSTR tok;
*token = NULL; *token = NULL;
...@@ -898,15 +870,14 @@ HRESULT assembly_get_pubkey_token(ASSEMBLY *assembly, LPSTR *token) ...@@ -898,15 +870,14 @@ HRESULT assembly_get_pubkey_token(ASSEMBLY *assembly, LPSTR *token)
for (i = size - 1; i >= size - 8; i--) for (i = size - 1; i >= size - 8; i--)
tokbytes[size - i - 1] = hashdata[i]; tokbytes[size - i - 1] = hashdata[i];
tok = HeapAlloc(GetProcessHeap(), 0, TOKEN_LENGTH); tok = HeapAlloc(GetProcessHeap(), 0, (TOKEN_LENGTH + 1) * sizeof(WCHAR));
if (!tok) if (!tok)
{ {
hr = E_OUTOFMEMORY; hr = E_OUTOFMEMORY;
goto done; goto done;
} }
bytes_to_str(tokbytes, BYTES_PER_TOKEN, tok); token_to_str(tokbytes, tok);
tok[TOKEN_LENGTH - 1] = '\0';
*token = tok; *token = tok;
hr = S_OK; hr = S_OK;
......
...@@ -430,11 +430,11 @@ typedef struct tagASSEMBLY ASSEMBLY; ...@@ -430,11 +430,11 @@ typedef struct tagASSEMBLY ASSEMBLY;
HRESULT assembly_create(ASSEMBLY **out, LPCWSTR file); HRESULT assembly_create(ASSEMBLY **out, LPCWSTR file);
HRESULT assembly_release(ASSEMBLY *assembly); HRESULT assembly_release(ASSEMBLY *assembly);
HRESULT assembly_get_name(ASSEMBLY *assembly, LPSTR *name); HRESULT assembly_get_name(ASSEMBLY *assembly, LPWSTR *name);
HRESULT assembly_get_path(ASSEMBLY *assembly, LPSTR *path); HRESULT assembly_get_path(ASSEMBLY *assembly, LPWSTR *path);
HRESULT assembly_get_version(ASSEMBLY *assembly, LPSTR *version); HRESULT assembly_get_version(ASSEMBLY *assembly, LPWSTR *version);
HRESULT assembly_get_architecture(ASSEMBLY *assembly, DWORD fixme); HRESULT assembly_get_architecture(ASSEMBLY *assembly, DWORD fixme);
HRESULT assembly_get_pubkey_token(ASSEMBLY *assembly, LPSTR *token); HRESULT assembly_get_pubkey_token(ASSEMBLY *assembly, LPWSTR *token);
static inline LPWSTR strdupW(LPCWSTR src) static inline LPWSTR strdupW(LPCWSTR src)
{ {
...@@ -450,4 +450,24 @@ static inline LPWSTR strdupW(LPCWSTR src) ...@@ -450,4 +450,24 @@ static inline LPWSTR strdupW(LPCWSTR src)
return dest; return dest;
} }
#define BYTES_PER_TOKEN 8
#define CHARS_PER_BYTE 2
#define TOKEN_LENGTH (BYTES_PER_TOKEN * CHARS_PER_BYTE + 1)
static inline void token_to_str(BYTE *bytes, LPWSTR str)
{
DWORD i;
static const WCHAR hexval[16] = {
'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'
};
for(i = 0; i < BYTES_PER_TOKEN; i++)
{
str[i * 2] = hexval[((bytes[i] >> 4) & 0xF)];
str[i * 2 + 1] = hexval[(bytes[i]) & 0x0F];
}
str[i * 2] = 0;
}
#endif /* __WINE_FUSION_PRIVATE__ */ #endif /* __WINE_FUSION_PRIVATE__ */
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