fusion: Convert to Unicode.
This commit is contained in:
parent
a76c15356b
commit
da1f834e09
|
@ -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 {
|
||||
|
@ -228,14 +240,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;
|
||||
|
||||
|
@ -276,12 +291,9 @@ static HRESULT WINAPI IAssemblyCacheImpl_InstallAssembly(IAssemblyCache *iface,
|
|||
if (FAILED(hr))
|
||||
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,
|
||||
version, token);
|
||||
sprintfW(path, format, asmdir, name, version, token);
|
||||
|
||||
create_full_path(path);
|
||||
|
||||
|
@ -289,10 +301,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:
|
||||
|
|
|
@ -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,26 +818,7 @@ 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)
|
||||
{
|
||||
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)
|
||||
HRESULT assembly_get_pubkey_token(ASSEMBLY *assembly, LPWSTR *token)
|
||||
{
|
||||
ASSEMBLYTABLE *asmtbl;
|
||||
ULONG i, size;
|
||||
|
@ -857,7 +829,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,15 +870,14 @@ 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;
|
||||
goto done;
|
||||
}
|
||||
|
||||
bytes_to_str(tokbytes, BYTES_PER_TOKEN, tok);
|
||||
tok[TOKEN_LENGTH - 1] = '\0';
|
||||
token_to_str(tokbytes, tok);
|
||||
|
||||
*token = tok;
|
||||
hr = S_OK;
|
||||
|
|
|
@ -430,11 +430,11 @@ 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 LPWSTR strdupW(LPCWSTR src)
|
||||
{
|
||||
|
@ -450,4 +450,24 @@ static inline LPWSTR strdupW(LPCWSTR src)
|
|||
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__ */
|
||||
|
|
Loading…
Reference in New Issue