Sync with trunk r63174.
[reactos.git] / dll / win32 / atl / atl_ros.diff
1 diff -prudN e:\Wine\dlls\atl/atl_main.c e:\reactos\dll\win32\atl/atl_main.c
2 --- e:\Wine\dlls\atl/atl_main.c 2013-09-03 23:09:36.308717300 +0100
3 +++ e:\reactos\dll\win32\atl/atl_main.c 2013-09-12 12:15:17.112785700 +0100
4 @@ -547,6 +555,53 @@ static const IClassFactoryVtbl IRegistra
5
6 static IClassFactory RegistrarCF = { &IRegistrarCFVtbl };
7
8 +static HRESULT do_register_dll_server(IRegistrar *pRegistrar, LPCOLESTR wszDll,
9 + LPCOLESTR wszId, BOOL do_register,
10 + const struct _ATL_REGMAP_ENTRY* pMapEntries)
11 +{
12 + IRegistrar *registrar;
13 + HRESULT hres;
14 + const struct _ATL_REGMAP_ENTRY *pMapEntry;
15 +
16 + static const WCHAR wszModule[] = {'M','O','D','U','L','E',0};
17 + static const WCHAR wszRegistry[] = {'R','E','G','I','S','T','R','Y',0};
18 +
19 + if(pRegistrar) {
20 + registrar = pRegistrar;
21 + }else {
22 + hres = AtlCreateRegistrar(&registrar);
23 + if(FAILED(hres))
24 + return hres;
25 + }
26 +
27 + IRegistrar_AddReplacement(registrar, wszModule, wszDll);
28 +
29 + for (pMapEntry = pMapEntries; pMapEntry && pMapEntry->szKey; pMapEntry++)
30 + IRegistrar_AddReplacement(registrar, pMapEntry->szKey, pMapEntry->szData);
31 +
32 + if(do_register)
33 + hres = IRegistrar_ResourceRegisterSz(registrar, wszDll, wszId, wszRegistry);
34 + else
35 + hres = IRegistrar_ResourceUnregisterSz(registrar, wszDll, wszId, wszRegistry);
36 +
37 + if(registrar != pRegistrar)
38 + IRegistrar_Release(registrar);
39 + return hres;
40 +}
41 +
42 +static HRESULT do_register_server(BOOL do_register)
43 +{
44 + static const WCHAR CLSID_RegistrarW[] =
45 + {'C','L','S','I','D','_','R','e','g','i','s','t','r','a','r',0};
46 + static const WCHAR atl_dllW[] = {'a','t','l','.','d','l','l',0};
47 +
48 + WCHAR clsid_str[40];
49 + const struct _ATL_REGMAP_ENTRY reg_map[] = {{CLSID_RegistrarW, clsid_str}, {NULL,NULL}};
50 +
51 + StringFromGUID2(&CLSID_Registrar, clsid_str, sizeof(clsid_str)/sizeof(WCHAR));
52 + return do_register_dll_server(NULL, atl_dllW, MAKEINTRESOURCEW(101), do_register, reg_map);
53 +}
54 +
55 /**************************************************************
56 * DllGetClassObject (ATL.2)
57 */
58 @@ -566,7 +621,8 @@ HRESULT WINAPI DllGetClassObject(REFCLSI
59 */
60 HRESULT WINAPI DllRegisterServer(void)
61 {
62 - return __wine_register_resources( hInst );
63 + /* Note: we can't use __wine_register_server here because it uses CLSID_Registrar which isn't registred yet */
64 + return do_register_server(TRUE);
65 }
66
67 /***********************************************************************
68 @@ -574,7 +630,7 @@ HRESULT WINAPI DllRegisterServer(void)
69 */
70 HRESULT WINAPI DllUnregisterServer(void)
71 {
72 - return __wine_unregister_resources( hInst );
73 + return do_register_server(FALSE);
74 }
75
76 /***********************************************************************