Alexandre Julliard : rpcrt4: Convert the dll registration routines to Unicode.
Alexandre Julliard
julliard at winehq.org
Mon Dec 1 07:34:01 CST 2008
Module: wine
Branch: master
Commit: 77b3864fed23ccd90fded4783346c9cd01373288
URL: http://source.winehq.org/git/wine.git/?a=commit;h=77b3864fed23ccd90fded4783346c9cd01373288
Author: Alexandre Julliard <julliard at winehq.org>
Date: Sat Nov 29 13:01:29 2008 +0100
rpcrt4: Convert the dll registration routines to Unicode.
---
dlls/rpcrt4/cpsf.c | 102 ++++++++++++++++++++++++++-------------------------
1 files changed, 52 insertions(+), 50 deletions(-)
diff --git a/dlls/rpcrt4/cpsf.c b/dlls/rpcrt4/cpsf.c
index 22537fd..d19d229 100644
--- a/dlls/rpcrt4/cpsf.c
+++ b/dlls/rpcrt4/cpsf.c
@@ -36,12 +36,25 @@
#include "rpcproxy.h"
+#include "wine/unicode.h"
#include "wine/debug.h"
#include "cpsf.h"
WINE_DEFAULT_DEBUG_CHANNEL(ole);
+static void format_clsid( WCHAR *buffer, const CLSID *clsid )
+{
+ static const WCHAR clsid_formatW[] = {'{','%','0','8','X','-','%','0','4','X','-','%','0','4','X','-',
+ '%','0','2','X','%','0','2','X','-','%','0','2','X','%','0','2','X',
+ '%','0','2','X','%','0','2','X','%','0','2','X','%','0','2','X','}',0};
+
+ sprintfW( buffer, clsid_formatW, clsid->Data1, clsid->Data2, clsid->Data3,
+ clsid->Data4[0], clsid->Data4[1], clsid->Data4[2], clsid->Data4[3],
+ clsid->Data4[4], clsid->Data4[5], clsid->Data4[6], clsid->Data4[7] );
+
+}
+
static BOOL FindProxyInfo(const ProxyFileInfo **pProxyFileList, REFIID riid, const ProxyFileInfo **pProxyInfo, int *pIndex)
{
while (*pProxyFileList) {
@@ -197,6 +210,7 @@ HRESULT WINAPI NdrDllCanUnloadNow(CStdPSFactoryBuffer *pPSFactoryBuffer)
return !(pPSFactoryBuffer->RefCount);
}
+
/***********************************************************************
* NdrDllRegisterProxy [RPCRT4.@]
*/
@@ -204,13 +218,19 @@ HRESULT WINAPI NdrDllRegisterProxy(HMODULE hDll,
const ProxyFileInfo **pProxyFileList,
const CLSID *pclsid)
{
- LPSTR clsid;
- char keyname[120], module[MAX_PATH];
+ static const WCHAR bothW[] = {'B','o','t','h',0};
+ static const WCHAR clsidW[] = {'C','L','S','I','D','\\',0};
+ static const WCHAR clsid32W[] = {'P','r','o','x','y','S','t','u','b','C','l','s','i','d','3','2',0};
+ static const WCHAR interfaceW[] = {'I','n','t','e','r','f','a','c','e','\\',0};
+ static const WCHAR psfactoryW[] = {'P','S','F','a','c','t','o','r','y','B','u','f','f','e','r',0};
+ static const WCHAR inprocserverW[] = {'I','n','P','r','o','c','S','e','r','v','e','r','3','2',0};
+ static const WCHAR threadingmodelW[] = {'T','h','r','e','a','d','i','n','g','M','o','d','e','l',0};
+ WCHAR clsid[39], keyname[50], module[MAX_PATH];
HKEY key, subkey;
DWORD len;
TRACE("(%p,%p,%s)\n", hDll, pProxyFileList, debugstr_guid(pclsid));
- UuidToStringA((UUID*)pclsid, (unsigned char**)&clsid);
+ format_clsid( clsid, pclsid );
/* register interfaces to point to clsid */
while (*pProxyFileList) {
@@ -218,23 +238,16 @@ HRESULT WINAPI NdrDllRegisterProxy(HMODULE hDll,
for (u=0; u<(*pProxyFileList)->TableSize; u++) {
CInterfaceStubVtbl *proxy = (*pProxyFileList)->pStubVtblList[u];
PCInterfaceName name = (*pProxyFileList)->pNamesArray[u];
- LPSTR iid;
- TRACE("registering %s %s => %s\n", name, debugstr_guid(proxy->header.piid), clsid);
+ TRACE("registering %s %s => %s\n",
+ debugstr_a(name), debugstr_guid(proxy->header.piid), debugstr_w(clsid));
- UuidToStringA((UUID*)proxy->header.piid, (unsigned char**)&iid);
- snprintf(keyname, sizeof(keyname), "Interface\\{%s}", iid);
- RpcStringFreeA((unsigned char**)&iid);
- if (RegCreateKeyExA(HKEY_CLASSES_ROOT, keyname, 0, NULL, 0,
- KEY_WRITE, NULL, &key, NULL) == ERROR_SUCCESS) {
+ strcpyW( keyname, interfaceW );
+ format_clsid( keyname + strlenW(keyname), proxy->header.piid );
+ if (RegCreateKeyW(HKEY_CLASSES_ROOT, keyname, &key) == ERROR_SUCCESS) {
if (name)
- RegSetValueExA(key, NULL, 0, REG_SZ, (const BYTE *)name, strlen(name));
- if (RegCreateKeyExA(key, "ProxyStubClsid32", 0, NULL, 0,
- KEY_WRITE, NULL, &subkey, NULL) == ERROR_SUCCESS) {
- snprintf(module, sizeof(module), "{%s}", clsid);
- RegSetValueExA(subkey, NULL, 0, REG_SZ, (LPBYTE)module, strlen(module));
- RegCloseKey(subkey);
- }
+ RegSetValueExA(key, NULL, 0, REG_SZ, (const BYTE *)name, strlen(name)+1);
+ RegSetValueW( key, clsid32W, REG_SZ, clsid, 0 );
RegCloseKey(key);
}
}
@@ -242,25 +255,22 @@ HRESULT WINAPI NdrDllRegisterProxy(HMODULE hDll,
}
/* register clsid to point to module */
- snprintf(keyname, sizeof(keyname), "CLSID\\{%s}", clsid);
- len = GetModuleFileNameA(hDll, module, sizeof(module));
+ strcpyW( keyname, clsidW );
+ strcatW( keyname, clsid );
+ len = GetModuleFileNameW(hDll, module, sizeof(module)/sizeof(WCHAR));
if (len && len < sizeof(module)) {
- TRACE("registering CLSID %s => %s\n", clsid, module);
- if (RegCreateKeyExA(HKEY_CLASSES_ROOT, keyname, 0, NULL, 0,
- KEY_WRITE, NULL, &key, NULL) == ERROR_SUCCESS) {
- RegSetValueExA(subkey, NULL, 0, REG_SZ, (const BYTE *)"PSFactoryBuffer", strlen("PSFactoryBuffer"));
- if (RegCreateKeyExA(key, "InProcServer32", 0, NULL, 0,
- KEY_WRITE, NULL, &subkey, NULL) == ERROR_SUCCESS) {
- RegSetValueExA(subkey, NULL, 0, REG_SZ, (LPBYTE)module, strlen(module));
- RegSetValueExA(subkey, "ThreadingModel", 0, REG_SZ, (const BYTE *)"Both", strlen("Both"));
- RegCloseKey(subkey);
+ TRACE("registering CLSID %s => %s\n", debugstr_w(clsid), debugstr_w(module));
+ if (RegCreateKeyW(HKEY_CLASSES_ROOT, keyname, &key) == ERROR_SUCCESS) {
+ RegSetValueExW(subkey, NULL, 0, REG_SZ, (const BYTE *)psfactoryW, sizeof(psfactoryW));
+ if (RegCreateKeyW(key, inprocserverW, &subkey) == ERROR_SUCCESS) {
+ RegSetValueExW(subkey, NULL, 0, REG_SZ, (LPBYTE)module, (strlenW(module)+1)*sizeof(WCHAR));
+ RegSetValueExW(subkey, threadingmodelW, 0, REG_SZ, (const BYTE *)bothW, sizeof(bothW));
+ RegCloseKey(subkey);
+ }
+ RegCloseKey(key);
}
- RegCloseKey(key);
- }
}
- /* done */
- RpcStringFreeA((unsigned char**)&clsid);
return S_OK;
}
@@ -271,12 +281,11 @@ HRESULT WINAPI NdrDllUnregisterProxy(HMODULE hDll,
const ProxyFileInfo **pProxyFileList,
const CLSID *pclsid)
{
- LPSTR clsid;
- char keyname[120], module[MAX_PATH];
- DWORD len;
+ static const WCHAR clsidW[] = {'C','L','S','I','D','\\',0};
+ static const WCHAR interfaceW[] = {'I','n','t','e','r','f','a','c','e','\\',0};
+ WCHAR keyname[50];
TRACE("(%p,%p,%s)\n", hDll, pProxyFileList, debugstr_guid(pclsid));
- UuidToStringA((UUID*)pclsid, (unsigned char**)&clsid);
/* unregister interfaces */
while (*pProxyFileList) {
@@ -284,27 +293,20 @@ HRESULT WINAPI NdrDllUnregisterProxy(HMODULE hDll,
for (u=0; u<(*pProxyFileList)->TableSize; u++) {
CInterfaceStubVtbl *proxy = (*pProxyFileList)->pStubVtblList[u];
PCInterfaceName name = (*pProxyFileList)->pNamesArray[u];
- LPSTR iid;
- TRACE("unregistering %s %s <= %s\n", name, debugstr_guid(proxy->header.piid), clsid);
+ TRACE("unregistering %s %s\n", debugstr_a(name), debugstr_guid(proxy->header.piid));
- UuidToStringA((UUID*)proxy->header.piid, (unsigned char**)&iid);
- snprintf(keyname, sizeof(keyname), "Interface\\{%s}", iid);
- RpcStringFreeA((unsigned char**)&iid);
- RegDeleteKeyA(HKEY_CLASSES_ROOT, keyname);
+ strcpyW( keyname, interfaceW );
+ format_clsid( keyname + strlenW(keyname), proxy->header.piid );
+ RegDeleteKeyW(HKEY_CLASSES_ROOT, keyname);
}
pProxyFileList++;
}
/* unregister clsid */
- snprintf(keyname, sizeof(keyname), "CLSID\\{%s}", clsid);
- len = GetModuleFileNameA(hDll, module, sizeof(module));
- if (len && len < sizeof(module)) {
- TRACE("unregistering CLSID %s <= %s\n", clsid, module);
- RegDeleteKeyA(HKEY_CLASSES_ROOT, keyname);
- }
+ strcpyW( keyname, clsidW );
+ format_clsid( keyname + strlenW(keyname), pclsid );
+ RegDeleteKeyW(HKEY_CLASSES_ROOT, keyname);
- /* done */
- RpcStringFreeA((unsigned char**)&clsid);
return S_OK;
}
More information about the wine-cvs
mailing list