[2/5] fusion: Convert to Unicode.
Hans Leidekker
hans at meelstraat.net
Fri Feb 13 02:13:33 CST 2009
diff --git a/dlls/fusion/asmcache.c b/dlls/fusion/asmcache.c
index 57c7aed..73756b3 100644
--- a/dlls/fusion/asmcache.c
+++ b/dlls/fusion/asmcache.c
@@ -41,24 +41,24 @@
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;
int len;
- new_path = HeapAlloc(GetProcessHeap(), 0, lstrlenA(path) + 1);
+ new_path = HeapAlloc(GetProcessHeap(), 0, (strlenW(path) + 1) * sizeof(WCHAR));
if (!new_path)
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;
- while (!CreateDirectoryA(new_path, NULL))
+ while (!CreateDirectoryW(new_path, NULL))
{
- LPSTR slash;
+ LPWSTR slash;
DWORD last_error = GetLastError();
if(last_error == ERROR_ALREADY_EXISTS)
@@ -70,7 +70,7 @@ static BOOL create_full_path(LPCSTR path)
break;
}
- if(!(slash = strrchr(new_path, '\\')))
+ if(!(slash = strrchrW(new_path, '\\')))
{
ret = FALSE;
break;
@@ -91,6 +91,18 @@ static BOOL create_full_path(LPCSTR path)
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 */
typedef struct {
@@ -190,14 +202,17 @@ static HRESULT WINAPI IAssemblyCacheImpl_InstallAssembly(IAssemblyCache *iface,
LPCWSTR pszManifestFilePath,
LPCFUSION_INSTALL_REFERENCE pRefData)
{
+ static const WCHAR format[] =
+ {'%','s','\\','%','s','\\','%','s','_','_','%','s','\\',0};
+
ASSEMBLY *assembly;
- LPSTR filename;
- LPSTR name = NULL;
- LPSTR token = NULL;
- LPSTR version = NULL;
- LPSTR asmpath = NULL;
- CHAR path[MAX_PATH];
- CHAR windir[MAX_PATH];
+ LPWSTR filename;
+ LPWSTR name = NULL;
+ LPWSTR token = NULL;
+ LPWSTR version = NULL;
+ LPWSTR asmpath = NULL;
+ WCHAR path[MAX_PATH];
+ WCHAR asmdir[MAX_PATH];
LPWSTR ext;
HRESULT hr;
@@ -238,12 +253,9 @@ static HRESULT WINAPI IAssemblyCacheImpl_InstallAssembly(IAssemblyCache *iface,
if (FAILED(hr))
goto done;
- GetWindowsDirectoryA(windir, MAX_PATH);
-
- FIXME("Ignoring assembly architecture!\n");
+ get_assembly_directory(asmdir, MAX_PATH);
- sprintf(path, "%s\\assembly\\GAC_MSIL\\%s\\%s__%s\\", windir, name,
- version, token);
+ sprintfW(path, format, asmdir, name, version, token);
create_full_path(path);
@@ -251,10 +263,10 @@ static HRESULT WINAPI IAssemblyCacheImpl_InstallAssembly(IAssemblyCache *iface,
if (FAILED(hr))
goto done;
- filename = PathFindFileNameA(asmpath);
+ filename = PathFindFileNameW(asmpath);
- lstrcatA(path, filename);
- if (!CopyFileA(asmpath, path, FALSE))
+ strcatW(path, filename);
+ if (!CopyFileW(asmpath, path, FALSE))
hr = HRESULT_FROM_WIN32(GetLastError());
done:
diff --git a/dlls/fusion/asmname.c b/dlls/fusion/asmname.c
index 50ae05e..acf0411 100644
--- a/dlls/fusion/asmname.c
+++ b/dlls/fusion/asmname.c
@@ -26,30 +26,18 @@
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
+#include "winver.h"
#include "ole2.h"
#include "guiddef.h"
#include "fusion.h"
#include "corerror.h"
+#include "fusionpriv.h"
#include "wine/debug.h"
#include "wine/unicode.h"
WINE_DEFAULT_DEBUG_CHANNEL(fusion);
-static inline LPWSTR strdupW(LPCWSTR src)
-{
- LPWSTR dest;
-
- if (!src)
- return NULL;
-
- dest = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(src) + 1) * sizeof(WCHAR));
- if (dest)
- lstrcpyW(dest, src);
-
- return dest;
-}
-
typedef struct {
const IAssemblyNameVtbl *lpIAssemblyNameVtbl;
diff --git a/dlls/fusion/assembly.c b/dlls/fusion/assembly.c
index 2373d0f..049bf15 100644
--- a/dlls/fusion/assembly.c
+++ b/dlls/fusion/assembly.c
@@ -52,7 +52,7 @@ typedef struct tagCLRTABLE
struct tagASSEMBLY
{
- LPSTR path;
+ LPWSTR path;
HANDLE hfile;
HANDLE hmap;
@@ -76,22 +76,6 @@ struct tagASSEMBLY
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)
{
DWORD offset = rva, limit;
@@ -684,7 +668,7 @@ HRESULT assembly_create(ASSEMBLY **out, LPCWSTR file)
if (!assembly)
return E_OUTOFMEMORY;
- assembly->path = strdupWtoA(file);
+ assembly->path = strdupW(file);
if (!assembly->path)
{
hr = E_OUTOFMEMORY;
@@ -743,16 +727,21 @@ HRESULT assembly_release(ASSEMBLY *assembly)
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 cpy = HeapAlloc(GetProcessHeap(), 0, strlen(str)+1);
- if (cpy)
- strcpy(cpy, str);
+
+ len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
+
+ if ((cpy = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR))))
+ MultiByteToWideChar(CP_ACP, 0, str, -1, cpy, len);
+
return cpy;
}
-HRESULT assembly_get_name(ASSEMBLY *assembly, LPSTR *name)
+HRESULT assembly_get_name(ASSEMBLY *assembly, LPWSTR *name)
{
BYTE *ptr;
LONG offset;
@@ -779,20 +768,22 @@ HRESULT assembly_get_name(ASSEMBLY *assembly, LPSTR *name)
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;
if (cpy)
- strcpy(cpy, assembly->path);
+ strcpyW(cpy, assembly->path);
else
return E_OUTOFMEMORY;
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;
LONG offset;
@@ -806,12 +797,12 @@ HRESULT assembly_get_version(ASSEMBLY *assembly, LPSTR *version)
if (!asmtbl)
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)
return E_OUTOFMEMORY;
- sprintf(*version, "%u.%u.%u.%u", asmtbl->MajorVersion, asmtbl->MinorVersion,
- asmtbl->BuildNumber, asmtbl->RevisionNumber);
+ sprintfW(*version, format, asmtbl->MajorVersion, asmtbl->MinorVersion,
+ asmtbl->BuildNumber, asmtbl->RevisionNumber);
return S_OK;
}
@@ -827,11 +818,11 @@ static BYTE *assembly_get_blob(ASSEMBLY *assembly, WORD index, ULONG *size)
return GetData(&assembly->blobs[index], size);
}
-static void bytes_to_str(BYTE *bytes, DWORD len, LPSTR str)
+static void bytes_to_str(BYTE *bytes, DWORD len, LPWSTR str)
{
DWORD i;
- static const char hexval[16] = {
+ static const WCHAR hexval[16] = {
'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'
};
@@ -846,7 +837,7 @@ static void bytes_to_str(BYTE *bytes, DWORD len, LPSTR str)
#define CHARS_PER_BYTE 2
#define TOKEN_LENGTH (BYTES_PER_TOKEN * CHARS_PER_BYTE + 1)
-HRESULT assembly_get_pubkey_token(ASSEMBLY *assembly, LPSTR *token)
+HRESULT assembly_get_pubkey_token(ASSEMBLY *assembly, LPWSTR *token)
{
ASSEMBLYTABLE *asmtbl;
ULONG i, size;
@@ -857,7 +848,7 @@ HRESULT assembly_get_pubkey_token(ASSEMBLY *assembly, LPSTR *token)
BYTE *pubkey;
BYTE tokbytes[BYTES_PER_TOKEN];
HRESULT hr = E_FAIL;
- LPSTR tok;
+ LPWSTR tok;
*token = NULL;
@@ -898,7 +889,7 @@ HRESULT assembly_get_pubkey_token(ASSEMBLY *assembly, LPSTR *token)
for (i = size - 1; i >= size - 8; i--)
tokbytes[size - i - 1] = hashdata[i];
- tok = HeapAlloc(GetProcessHeap(), 0, TOKEN_LENGTH);
+ tok = HeapAlloc(GetProcessHeap(), 0, (TOKEN_LENGTH + 1) * sizeof(WCHAR));
if (!tok)
{
hr = E_OUTOFMEMORY;
diff --git a/dlls/fusion/fusionpriv.h b/dlls/fusion/fusionpriv.h
index a4e6193..405133b 100644
--- a/dlls/fusion/fusionpriv.h
+++ b/dlls/fusion/fusionpriv.h
@@ -27,6 +27,8 @@
#include "winbase.h"
#include "winuser.h"
+#include "wine/unicode.h"
+
#include <pshpack1.h>
typedef struct
@@ -429,10 +431,18 @@ typedef struct tagASSEMBLY ASSEMBLY;
HRESULT assembly_create(ASSEMBLY **out, LPCWSTR file);
HRESULT assembly_release(ASSEMBLY *assembly);
-HRESULT assembly_get_name(ASSEMBLY *assembly, LPSTR *name);
-HRESULT assembly_get_path(ASSEMBLY *assembly, LPSTR *path);
-HRESULT assembly_get_version(ASSEMBLY *assembly, LPSTR *version);
+HRESULT assembly_get_name(ASSEMBLY *assembly, LPWSTR *name);
+HRESULT assembly_get_path(ASSEMBLY *assembly, LPWSTR *path);
+HRESULT assembly_get_version(ASSEMBLY *assembly, LPWSTR *version);
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 WCHAR *strdupW(const WCHAR *src)
+{
+ WCHAR *dst;
+ if ((dst = HeapAlloc(GetProcessHeap(), 0, (strlenW(src) + 1) * sizeof(WCHAR))))
+ strcpyW(dst, src);
+ return dst;
+}
#endif /* __WINE_FUSION_PRIVATE__ */
More information about the wine-patches
mailing list