[ATL]
authorAmine Khaldi <amine.khaldi@reactos.org>
Wed, 12 Dec 2012 12:48:52 +0000 (12:48 +0000)
committerAmine Khaldi <amine.khaldi@reactos.org>
Wed, 12 Dec 2012 12:48:52 +0000 (12:48 +0000)
* Sync with Wine 1.5.19.
[ATL100]
* Import from Wine 1.5.19.

svn path=/trunk/; revision=57887

19 files changed:
reactos/dll/win32/CMakeLists.txt
reactos/dll/win32/atl/CMakeLists.txt
reactos/dll/win32/atl/atl.rgs
reactos/dll/win32/atl/atl.spec
reactos/dll/win32/atl/atl_classes.idl [new file with mode: 0644]
reactos/dll/win32/atl/atl_main.c
reactos/dll/win32/atl/atliface.idl [deleted file]
reactos/dll/win32/atl/registrar.c
reactos/dll/win32/atl/rsrc.rc
reactos/dll/win32/atl/stubs.c [deleted file]
reactos/dll/win32/atl100/CMakeLists.txt [new file with mode: 0644]
reactos/dll/win32/atl100/atl.c [new file with mode: 0644]
reactos/dll/win32/atl100/atl100.spec [new file with mode: 0644]
reactos/dll/win32/atl100/atl_ax.c [moved from reactos/dll/win32/atl/atl_ax.c with 98% similarity]
reactos/dll/win32/atl100/registrar.c [new file with mode: 0644]
reactos/include/psdk/atliface.idl
reactos/include/reactos/wine/atlbase.h [moved from reactos/dll/win32/atl/atlbase.h with 98% similarity]
reactos/include/reactos/wine/atlwin.h [moved from reactos/dll/win32/atl/atlwin.h with 100% similarity]
reactos/media/doc/README.WINE

index e378863..0f5f3bd 100644 (file)
@@ -6,6 +6,7 @@ add_subdirectory(actxprxy)
 add_subdirectory(advapi32)
 add_subdirectory(advpack)
 add_subdirectory(atl)
+add_subdirectory(atl100)
 add_subdirectory(authz)
 add_subdirectory(avicap32)
 add_subdirectory(avifil32)
index 3aafd05..f930934 100644 (file)
@@ -6,38 +6,17 @@ add_definitions(-D_WIN32_WINNT=0x600)
 
 include_directories(${REACTOS_SOURCE_DIR}/include/reactos/wine)
 
-add_idl_headers(atl_atliface_header atliface.idl)
-generate_idl_iids(atliface.idl)
-
-set_rc_compiler()
 spec2def(atl.dll atl.spec ADD_IMPORTLIB)
 
 list(APPEND SOURCE
-    atl_ax.c
     atl_main.c
     registrar.c
-    stubs.c
-    rsrc.rc
-    ${CMAKE_CURRENT_BINARY_DIR}/atliface_i.c
+    ${CMAKE_CURRENT_BINARY_DIR}/atl_stubs.c
     ${CMAKE_CURRENT_BINARY_DIR}/atl.def)
 
-add_library(atl SHARED ${SOURCE})
-
+add_library(atl SHARED ${SOURCE} rsrc.rc)
 set_module_type(atl win32dll)
-
 target_link_libraries(atl uuid wine)
-
-add_importlibs(atl
-    msvcrt
-    ole32
-    oleaut32
-    user32
-    advapi32
-    gdi32
-    kernel32
-    ntdll)
-
-
-
+add_importlibs(atl atl100 oleaut32 ole32 user32 msvcrt kernel32 ntdll)
 add_dependencies(atl atl_atliface_header)
 add_cd_file(TARGET atl DESTINATION reactos/system32 FOR all)
index ee43249..566bd5e 100644 (file)
@@ -1,17 +1,18 @@
 HKCR
 {
-    ATL.Registrar = s 'Registrar Class'
+    NoRemove Interface
     {
-        CLSID = s '%CLSID_Registrar%'
     }
-    NoRemove CLSID {
-        ForceRemove '%CLSID_Registrar%' = s 'Registrar Class'
+    NoRemove CLSID
+    {
+        '{44EC053A-400F-11D0-9DCD-00A0C90391D3}' = s 'Registrar Class'
         {
-            ProgID = s 'ATL.Registrar'
-            InprocServer32 = s '%MODULE%'
-            {
-               val ThreadingModel = s 'Both' 
-            }
+            InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' }
+            ProgId = s 'ATL.Registrar'
         }
     }
-}
+    'ATL.Registrar' = s 'Registrar Class'
+    {
+        CLSID = s '{44EC053A-400F-11D0-9DCD-00A0C90391D3}'
+    }
+}
\ No newline at end of file
index b1eb26c..ae29b64 100644 (file)
@@ -2,11 +2,11 @@
 @ stdcall -private DllGetClassObject(ptr ptr ptr)
 @ stdcall -private DllRegisterServer()
 @ stdcall -private DllUnregisterServer()
-10 stdcall AtlAdvise(ptr ptr ptr ptr)
-11 stdcall AtlUnadvise(ptr ptr long)
-12 stdcall AtlFreeMarshalStream(ptr)
-13 stdcall AtlMarshalPtrInProc(ptr ptr ptr)
-14 stdcall AtlUnmarshalPtr(ptr ptr ptr)
+10 stdcall AtlAdvise(ptr ptr ptr ptr) atl100.AtlAdvise
+11 stdcall AtlUnadvise(ptr ptr long) atl100.AtlUnadvise
+12 stdcall AtlFreeMarshalStream(ptr) atl100.AtlFreeMarshalStream
+13 stdcall AtlMarshalPtrInProc(ptr ptr ptr) atl100.AtlMarshalPtrInProc
+14 stdcall AtlUnmarshalPtr(ptr ptr ptr) atl100.AtlUnmarshalPtr
 15 stdcall AtlModuleGetClassObject(ptr ptr ptr ptr)
 16 stdcall AtlModuleInit(ptr long long)
 17 stdcall AtlModuleRegisterClassObjects(ptr long long)
 21 stdcall AtlModuleTerm(ptr)
 22 stdcall AtlModuleUnregisterServer(ptr ptr)
 23 stdcall AtlModuleUpdateRegistryFromResourceD(ptr wstr long ptr ptr)
-24 stdcall AtlWaitWithMessageLoop(ptr)
-25 stdcall AtlSetErrorInfo(ptr ptr long ptr ptr ptr ptr)
-26 stdcall AtlCreateTargetDC(long ptr)
-27 stdcall AtlHiMetricToPixel(ptr ptr)
-28 stdcall AtlPixelToHiMetric(ptr ptr)
-29 stdcall AtlDevModeW2A(ptr ptr)
-30 stdcall AtlComPtrAssign(ptr ptr)
-31 stdcall AtlComQIPtrAssign(ptr ptr ptr)
-32 stdcall AtlInternalQueryInterface(ptr ptr ptr ptr)
+24 stub AtlWaitWithMessageLoop
+25 stub AtlSetErrorInfo
+26 stdcall AtlCreateTargetDC(long ptr) atl100.AtlCreateTargetDC
+27 stdcall AtlHiMetricToPixel(ptr ptr) atl100.AtlHiMetricToPixel
+28 stdcall AtlPixelToHiMetric(ptr ptr) atl100.AtlPixelToHiMetric
+29 stub AtlDevModeW2A
+30 stdcall AtlComPtrAssign(ptr ptr) atl100.AtlComPtrAssign
+31 stdcall AtlComQIPtrAssign(ptr ptr ptr) atl100.AtlComQIPtrAssign
+32 stdcall AtlInternalQueryInterface(ptr ptr ptr ptr) atl100.AtlInternalQueryInterface
 34 stdcall AtlGetVersion(ptr)
-35 stdcall AtlAxDialogBoxW(ptr wstr ptr ptr ptr)
-36 stdcall AtlAxDialogBoxA(ptr str ptr ptr ptr)
-37 stdcall AtlAxCreateDialogW(long wstr long ptr long)
-38 stdcall AtlAxCreateDialogA(long str long ptr long)
-39 stdcall AtlAxCreateControl(ptr ptr ptr ptr)
-40 stdcall AtlAxCreateControlEx(ptr ptr ptr ptr ptr ptr ptr)
-41 stdcall AtlAxAttachControl(ptr ptr ptr)
-42 stdcall AtlAxWinInit()
+35 stub AtlAxDialogBoxW
+36 stub AtlAxDialogBoxA
+37 stdcall AtlAxCreateDialogW(long wstr long ptr long) atl100.AtlAxCreateDialogW
+38 stdcall AtlAxCreateDialogA(long str long ptr long) atl100.AtlAxCreateDialogA
+39 stdcall AtlAxCreateControl(ptr ptr ptr ptr) atl100.AtlAxCreateControl
+40 stdcall AtlAxCreateControlEx(ptr ptr ptr ptr ptr ptr ptr) atl100.AtlAxCreateControlEx
+41 stdcall AtlAxAttachControl(ptr ptr ptr) atl100.AtlAxAttachControl
+42 stdcall AtlAxWinInit() atl100.AtlAxWinInit
 43 stdcall AtlModuleAddCreateWndData(ptr ptr ptr)
 44 stdcall AtlModuleExtractCreateWndData(ptr)
 45 stdcall AtlModuleRegisterWndClassInfoW(ptr ptr ptr)
 46 stdcall AtlModuleRegisterWndClassInfoA(ptr ptr ptr)
-47 stdcall AtlAxGetControl(long ptr)
-48 stdcall AtlAxGetHost(long ptr)
-49 stdcall AtlRegisterClassCategoriesHelper(ptr ptr long)
-50 stdcall AtlIPersistStreamInit_Load(ptr ptr ptr ptr)
-51 stdcall AtlIPersistStreamInit_Save(ptr long ptr ptr ptr)
-52 stdcall AtlIPersistPropertyBag_Load(ptr ptr ptr ptr ptr)
-53 stdcall AtlIPersistPropertyBag_Save(ptr long long ptr ptr ptr)
-54 stdcall AtlGetObjectSourceInterface(ptr ptr ptr ptr ptr)
-55 stdcall AtlModuleUnregisterTypeLib(ptr str)
+47 stdcall AtlAxGetControl(long ptr) atl100.AtlAxGetControl
+48 stdcall AtlAxGetHost(long ptr) atl100.AtlAxGetHost
+49 stub AtlRegisterClassCategoriesHelper
+50 stdcall AtlIPersistStreamInit_Load(ptr ptr ptr ptr) atl100.AtlIPersistStreamInit_Load
+51 stdcall AtlIPersistStreamInit_Save(ptr long ptr ptr ptr) atl100.AtlIPersistStreamInit_Save
+52 stub AtlIPersistPropertyBag_Load
+53 stub AtlIPersistPropertyBag_Save
+54 stub AtlGetObjectSourceInterface
+55 stub AtlModuleUnRegisterTypeLib
 56 stdcall AtlModuleLoadTypeLib(ptr wstr ptr ptr)
 57 stdcall AtlModuleUnregisterServerEx(ptr long ptr)
 58 stdcall AtlModuleAddTermFunc(ptr ptr long)
diff --git a/reactos/dll/win32/atl/atl_classes.idl b/reactos/dll/win32/atl/atl_classes.idl
new file mode 100644 (file)
index 0000000..90605b4
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * COM Classes for ATL
+ *
+ * Copyright 2010 Alexandre Julliard
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+[
+    helpstring("Registrar Class"),
+    progid("ATL.Registrar"),
+    threading(both),
+    uuid(44ec053a-400f-11d0-9dcd-00a0c90391d3)
+]
+coclass Registrar { interface IRegistrar; }
index 3369d57..775859f 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#include <stdarg.h>
 #include <stdio.h>
 
 #define COBJMACROS
 
-#include "windef.h"
-#include "winbase.h"
-#include "winerror.h"
-#include "wingdi.h"
-#include "winuser.h"
-#include "wine/debug.h"
-#include "objbase.h"
 #include "objidl.h"
-#include "ole2.h"
 #include "atlbase.h"
-#include "atliface.h"
 #include "atlwin.h"
 
+#include "wine/debug.h"
 #include "wine/unicode.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(atl);
@@ -179,7 +170,6 @@ HRESULT WINAPI AtlModuleRegisterClassObjects(_ATL_MODULEW *pM, DWORD dwClsContex
                                              DWORD dwFlags)
 {
     _ATL_OBJMAP_ENTRYW_V1 *obj;
-    HRESULT hRes = S_OK;
     int i=0;
 
     TRACE("(%p %i %i)\n",pM, dwClsContext, dwFlags);
@@ -199,15 +189,19 @@ HRESULT WINAPI AtlModuleRegisterClassObjects(_ATL_MODULEW *pM, DWORD dwClsContex
                                    (LPVOID*)&pUnknown);
             if (SUCCEEDED (rc) )
             {
-                CoRegisterClassObject(obj->pclsid, pUnknown, dwClsContext,
-                                      dwFlags, &obj->dwRegister);
+                rc = CoRegisterClassObject(obj->pclsid, pUnknown, dwClsContext,
+                                           dwFlags, &obj->dwRegister);
+
+                if (FAILED (rc) )
+                    WARN("Failed to register object %i: 0x%08x\n", i, rc);
+
                 if (pUnknown)
                     IUnknown_Release(pUnknown);
             }
         }
     }
 
-   return hRes;
+   return S_OK;
 }
 
 HRESULT WINAPI AtlModuleUnregisterServerEx(_ATL_MODULEW* pM, BOOL bUnRegTypeLib, const CLSID* pCLSID)
@@ -216,73 +210,6 @@ HRESULT WINAPI AtlModuleUnregisterServerEx(_ATL_MODULEW* pM, BOOL bUnRegTypeLib,
     return S_OK;
 }
 
-
-IUnknown* WINAPI AtlComPtrAssign(IUnknown** pp, IUnknown *p)
-{
-    TRACE("(%p %p)\n", pp, p);
-
-    if (p) IUnknown_AddRef(p);
-    if (*pp) IUnknown_Release(*pp);
-    *pp = p;
-    return p;
-}
-
-IUnknown* WINAPI AtlComQIPtrAssign(IUnknown** pp, IUnknown *p, REFIID riid)
-{
-    IUnknown *new_p = NULL;
-
-    TRACE("(%p %p %s)\n", pp, p, debugstr_guid(riid));
-
-    if (p) IUnknown_QueryInterface(p, riid, (void **)&new_p);
-    if (*pp) IUnknown_Release(*pp);
-    *pp = new_p;
-    return new_p;
-}
-
-
-HRESULT WINAPI AtlInternalQueryInterface(void* this, const _ATL_INTMAP_ENTRY* pEntries,  REFIID iid, void** ppvObject)
-{
-    int i = 0;
-    HRESULT rc = E_NOINTERFACE;
-    TRACE("(%p, %p, %s, %p)\n",this, pEntries, debugstr_guid(iid), ppvObject);
-
-    if (IsEqualGUID(iid,&IID_IUnknown))
-    {
-        TRACE("Returning IUnknown\n");
-        *ppvObject = ((LPSTR)this+pEntries[0].dw);
-        IUnknown_AddRef((IUnknown*)*ppvObject);
-        return S_OK;
-    }
-
-    while (pEntries[i].pFunc != 0)
-    {
-        TRACE("Trying entry %i (%s %i %p)\n",i,debugstr_guid(pEntries[i].piid),
-              pEntries[i].dw, pEntries[i].pFunc);
-
-        if (!pEntries[i].piid || IsEqualGUID(iid,pEntries[i].piid))
-        {
-            TRACE("MATCH\n");
-            if (pEntries[i].pFunc == (_ATL_CREATORARGFUNC*)1)
-            {
-                TRACE("Offset\n");
-                *ppvObject = ((LPSTR)this+pEntries[i].dw);
-                IUnknown_AddRef((IUnknown*)*ppvObject);
-                return S_OK;
-            }
-            else
-            {
-                TRACE("Function\n");
-                rc = pEntries[i].pFunc(this, iid, ppvObject, pEntries[i].dw);
-                if(rc==S_OK || pEntries[i].piid)
-                    return rc;
-            }
-        }
-        i++;
-    }
-    TRACE("Done returning (0x%x)\n",rc);
-    return rc;
-}
-
 /***********************************************************************
  *           AtlModuleRegisterServer         [ATL.@]
  *
@@ -319,51 +246,6 @@ HRESULT WINAPI AtlModuleRegisterServer(_ATL_MODULEW* pM, BOOL bRegTypeLib, const
     return S_OK;
 }
 
-/***********************************************************************
- *           AtlAdvise         [ATL.@]
- */
-HRESULT WINAPI AtlAdvise(IUnknown *pUnkCP, IUnknown *pUnk, const IID *iid, LPDWORD pdw)
-{
-    FIXME("%p %p %p %p\n", pUnkCP, pUnk, iid, pdw);
-    return E_FAIL;
-}
-
-/***********************************************************************
- *           AtlUnadvise         [ATL.@]
- */
-HRESULT WINAPI AtlUnadvise(IUnknown *pUnkCP, const IID *iid, DWORD dw)
-{
-    FIXME("%p %p %d\n", pUnkCP, iid, dw);
-    return S_OK;
-}
-
-/***********************************************************************
- *           AtlFreeMarshalStream         [ATL.@]
- */
-HRESULT WINAPI AtlFreeMarshalStream(IStream *stm)
-{
-    FIXME("%p\n", stm);
-    return S_OK;
-}
-
-/***********************************************************************
- *           AtlMarshalPtrInProc         [ATL.@]
- */
-HRESULT WINAPI AtlMarshalPtrInProc(IUnknown *pUnk, const IID *iid, IStream **pstm)
-{
-    FIXME("%p %p %p\n", pUnk, iid, pstm);
-    return E_FAIL;
-}
-
-/***********************************************************************
- *           AtlUnmarshalPtr              [ATL.@]
- */
-HRESULT WINAPI AtlUnmarshalPtr(IStream *stm, const IID *iid, IUnknown **ppUnk)
-{
-    FIXME("%p %p %p\n", stm, iid, ppUnk);
-    return E_FAIL;
-}
-
 /***********************************************************************
  *           AtlModuleGetClassObject              [ATL.@]
  */
@@ -552,48 +434,6 @@ ATOM WINAPI AtlModuleRegisterWndClassInfoW(_ATL_MODULEW *pm, _ATL_WNDCLASSINFOW
     return atom;
 }
 
-void WINAPI AtlHiMetricToPixel(const SIZEL* lpHiMetric, SIZEL* lpPix)
-{
-    HDC dc = GetDC(NULL);
-    lpPix->cx = lpHiMetric->cx * GetDeviceCaps( dc, LOGPIXELSX ) / 100;
-    lpPix->cy = lpHiMetric->cy * GetDeviceCaps( dc, LOGPIXELSY ) / 100;
-    ReleaseDC( NULL, dc );
-}
-
-void WINAPI AtlPixelToHiMetric(const SIZEL* lpPix, SIZEL* lpHiMetric)
-{
-    HDC dc = GetDC(NULL);
-    lpHiMetric->cx = 100 * lpPix->cx / GetDeviceCaps( dc, LOGPIXELSX );
-    lpHiMetric->cy = 100 * lpPix->cy / GetDeviceCaps( dc, LOGPIXELSY );
-    ReleaseDC( NULL, dc );
-}
-
-/***********************************************************************
- *           AtlCreateTargetDC         [ATL.@]
- */
-HDC WINAPI AtlCreateTargetDC( HDC hdc, DVTARGETDEVICE *dv )
-{
-    static const WCHAR displayW[] = {'d','i','s','p','l','a','y',0};
-    const WCHAR *driver = NULL, *device = NULL, *port = NULL;
-    DEVMODEW *devmode = NULL;
-
-    TRACE( "(%p, %p)\n", hdc, dv );
-
-    if (dv)
-    {
-        if (dv->tdDriverNameOffset) driver  = (WCHAR *)((char *)dv + dv->tdDriverNameOffset);
-        if (dv->tdDeviceNameOffset) device  = (WCHAR *)((char *)dv + dv->tdDeviceNameOffset);
-        if (dv->tdPortNameOffset)   port    = (WCHAR *)((char *)dv + dv->tdPortNameOffset);
-        if (dv->tdExtDevmodeOffset) devmode = (DEVMODEW *)((char *)dv + dv->tdExtDevmodeOffset);
-    }
-    else
-    {
-        if (hdc) return hdc;
-        driver = displayW;
-    }
-    return CreateDCW( driver, device, port, devmode );
-}
-
 /***********************************************************************
  *           AtlModuleAddCreateWndData          [ATL.@]
  */
@@ -633,34 +473,10 @@ void* WINAPI AtlModuleExtractCreateWndData(_ATL_MODULEW *pM)
     return NULL;
 }
 
-/* FIXME: should be in a header file */
-typedef struct ATL_PROPMAP_ENTRY
-{
-    LPCOLESTR szDesc;
-    DISPID dispid;
-    const CLSID* pclsidPropPage;
-    const IID* piidDispatch;
-    DWORD dwOffsetData;
-    DWORD dwSizeData;
-    VARTYPE vt;
-} ATL_PROPMAP_ENTRY;
-
 /***********************************************************************
- *           AtlIPersistStreamInit_Load      [ATL.@]
+ *           AtlGetVersion              [ATL.@]
  */
-HRESULT WINAPI AtlIPersistStreamInit_Load( LPSTREAM pStm, ATL_PROPMAP_ENTRY *pMap,
-                                           void *pThis, IUnknown *pUnk)
+DWORD WINAPI AtlGetVersion(void *pReserved)
 {
-    FIXME("(%p, %p, %p, %p)\n", pStm, pMap, pThis, pUnk);
-
-    return S_OK;
-}
-
-HRESULT WINAPI AtlIPersistStreamInit_Save(LPSTREAM pStm, BOOL fClearDirty,
-                                          ATL_PROPMAP_ENTRY *pMap, void *pThis,
-                                          IUnknown *pUnk)
-{
-    FIXME("(%p, %d, %p, %p, %p)\n", pStm, fClearDirty, pMap, pThis, pUnk);
-
-    return S_OK;
+   return 0x0300;
 }
diff --git a/reactos/dll/win32/atl/atliface.idl b/reactos/dll/win32/atl/atliface.idl
deleted file mode 100644 (file)
index 887338f..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright 2005 Jacek Caban
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
-import "ocidl.idl";
-
-cpp_quote("#ifdef ATL_INITGUID")
-cpp_quote("#include <initguid.h>")
-cpp_quote("#endif")
-
-[
-    object,
-    oleautomation,
-    uuid(44EC053B-400F-11D0-9DCD-00A0C90391D3)
-]
-interface IRegistrar : IUnknown
-{
-    HRESULT AddReplacement(
-        [in] LPCOLESTR Key,
-        [in] LPCOLESTR item);
-
-    HRESULT ClearReplacements();
-
-    HRESULT ResourceRegisterSz(
-        [in] LPCOLESTR resFileName,
-        [in] LPCOLESTR szID,
-        [in] LPCOLESTR szType);
-
-    HRESULT ResourceUnregisterSz(
-        [in] LPCOLESTR resFileName,
-        [in] LPCOLESTR szID,
-        [in] LPCOLESTR szType);
-
-    HRESULT FileRegister(
-        [in] LPCOLESTR fileName);
-
-    HRESULT FileUnregister(
-        [in] LPCOLESTR fileName);
-
-    HRESULT StringRegister(
-        [in] LPCOLESTR data);
-
-    HRESULT StringUnregister(
-        [in] LPCOLESTR data);
-
-    HRESULT ResourceRegister(
-        [in] LPCOLESTR resFileName,
-        [in] UINT nID,
-        [in] LPCOLESTR szType);
-
-    HRESULT ResourceUnregister(
-        [in] LPCOLESTR resFileName,
-        [in] UINT nID,
-        [in] LPCOLESTR szType);
-}
-
-cpp_quote("DEFINE_GUID(CLSID_Registrar,0x44ec053a,0x400f,0x11d0,0x9d,0xcd,0x00,0xa0,0xc9,0x03,0x91,0xd3);")
-
-cpp_quote("HRESULT WINAPI AtlAxCreateControl(LPCOLESTR,HWND,IStream*,IUnknown**);")
-cpp_quote("HRESULT WINAPI AtlAxCreateControlEx(LPCOLESTR,HWND,IStream*,IUnknown**,IUnknown**,REFIID,IUnknown*);")
-cpp_quote("BOOL WINAPI AtlAxWinInit(void);")
-
-cpp_quote("HWND WINAPI AtlAxCreateDialogW(HINSTANCE,LPCWSTR,HWND,DLGPROC,LPARAM);")
-cpp_quote("HWND WINAPI AtlAxCreateDialogA(HINSTANCE,LPCSTR,HWND,DLGPROC,LPARAM);")
-cpp_quote("#define     AtlAxCreateDialog WINELIB_NAME_AW(AtlAxCreateDialog")
index 3ff28bb..6e5ce7b 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-
-#include <stdarg.h>
-
 #define COBJMACROS
 
-#include "windef.h"
-#include "winbase.h"
-#include "winuser.h"
-#include "winreg.h"
-#include "objbase.h"
 #include "oaidl.h"
 #include "rpcproxy.h"
-#include "atliface.h"
 #include "atlbase.h"
 
 #include "wine/debug.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(atl);
 
-static LONG dll_count;
-
-/**************************************************************
- * ATLRegistrar implementation
- */
-
-static const struct {
-    WCHAR name[22];
-    HKEY  key;
-} root_keys[] = {
-    {{'H','K','E','Y','_','C','L','A','S','S','E','S','_','R','O','O','T',0},
-                    HKEY_CLASSES_ROOT},
-    {{'H','K','E','Y','_','C','U','R','R','E','N','T','_','U','S','E','R',0},
-                    HKEY_CURRENT_USER},
-    {{'H','K','E','Y','_','L','O','C','A','L','_','M','A','C','H','I','N','E',0},
-                    HKEY_LOCAL_MACHINE},
-    {{'H','K','E','Y','_','U','S','E','R','S',0},
-                    HKEY_USERS},
-    {{'H','K','E','Y','_','P','E','R','F','O','R','M','A','N','C','E','_','D','A','T','A',0},
-                    HKEY_PERFORMANCE_DATA},
-    {{'H','K','E','Y','_','D','Y','N','_','D','A','T','A',0},
-                    HKEY_DYN_DATA},
-    {{'H','K','E','Y','_','C','U','R','R','E','N','T','_','C','O','N','F','I','G',0},
-                    HKEY_CURRENT_CONFIG},
-    {{'H','K','C','R',0}, HKEY_CLASSES_ROOT},
-    {{'H','K','C','U',0}, HKEY_CURRENT_USER},
-    {{'H','K','L','M',0}, HKEY_LOCAL_MACHINE},
-    {{'H','K','U',0},     HKEY_USERS},
-    {{'H','K','P','D',0}, HKEY_PERFORMANCE_DATA},
-    {{'H','K','D','D',0}, HKEY_DYN_DATA},
-    {{'H','K','C','C',0}, HKEY_CURRENT_CONFIG}
-};
-
-typedef struct rep_list_str {
-    LPOLESTR key;
-    LPOLESTR item;
-    int key_len;
-    struct rep_list_str *next;
-} rep_list;
-
-typedef struct {
-    IRegistrar IRegistrar_iface;
-    LONG ref;
-    rep_list *rep;
-} Registrar;
-
-typedef struct {
-    LPOLESTR str;
-    DWORD alloc;
-    DWORD len;
-} strbuf;
-
-static inline Registrar *impl_from_IRegistrar(IRegistrar *iface)
-{
-    return CONTAINING_RECORD(iface, Registrar, IRegistrar_iface);
-}
-
-static void strbuf_init(strbuf *buf)
-{
-    buf->str = HeapAlloc(GetProcessHeap(), 0, 128*sizeof(WCHAR));
-    buf->alloc = 128;
-    buf->len = 0;
-}
-
-static void strbuf_write(LPCOLESTR str, strbuf *buf, int len)
-{
-    if(len == -1)
-        len = lstrlenW(str);
-    if(buf->len+len+1 >= buf->alloc) {
-        buf->alloc = (buf->len+len)<<1;
-        buf->str = HeapReAlloc(GetProcessHeap(), 0, buf->str, buf->alloc*sizeof(WCHAR));
-    }
-    memcpy(buf->str+buf->len, str, len*sizeof(OLECHAR));
-    buf->len += len;
-    buf->str[buf->len] = '\0';
-}
-
-static HRESULT get_word(LPCOLESTR *str, strbuf *buf)
-{
-    LPCOLESTR iter, iter2 = *str;
-
-    buf->len = 0;
-    buf->str[0] = '\0';
-
-    while(isspaceW(*iter2))
-        iter2++;
-    iter = iter2;
-    if(!*iter) {
-        *str = iter;
-        return S_OK;
-    }
-
-    if(*iter == '}' || *iter == '=') {
-        strbuf_write(iter++, buf, 1);
-    }else if(*iter == '\'') {
-        iter2 = ++iter;
-        iter = strchrW(iter, '\'');
-        if(!iter) {
-            WARN("Unexpected end of script\n");
-            *str = iter;
-            return DISP_E_EXCEPTION;
-        }
-        strbuf_write(iter2, buf, iter-iter2);
-        iter++;
-    }else {
-        while(*iter && !isspaceW(*iter))
-            iter++;
-        strbuf_write(iter2, buf, iter-iter2);
-    }
-
-    while(isspaceW(*iter))
-        iter++;
-    *str = iter;
-    return S_OK;
-}
-
-static HRESULT do_preprocess(const Registrar *This, LPCOLESTR data, strbuf *buf)
-{
-    LPCOLESTR iter, iter2 = data;
-    rep_list *rep_iter;
-    static const WCHAR wstr[] = {'%',0};
-
-    iter = strchrW(data, '%');
-    while(iter) {
-        strbuf_write(iter2, buf, iter-iter2);
-
-        iter2 = ++iter;
-        if(!*iter2)
-            return DISP_E_EXCEPTION;
-        iter = strchrW(iter2, '%');
-        if(!iter)
-            return DISP_E_EXCEPTION;
-
-        if(iter == iter2) {
-            strbuf_write(wstr, buf, 1);
-        }else {
-            for(rep_iter = This->rep; rep_iter; rep_iter = rep_iter->next) {
-                if(rep_iter->key_len == iter-iter2
-                        && !memicmpW(iter2, rep_iter->key, rep_iter->key_len))
-                    break;
-            }
-            if(!rep_iter) {
-                WARN("Could not find replacement: %s\n", debugstr_wn(iter2, iter-iter2));
-                return DISP_E_EXCEPTION;
-            }
-
-            strbuf_write(rep_iter->item, buf, -1);
-        }
-
-        iter2 = ++iter;
-        iter = strchrW(iter, '%');
-    }
-
-    strbuf_write(iter2, buf, -1);
-    TRACE("%s\n", debugstr_w(buf->str));
-
-    return S_OK;
-}
-
-static HRESULT do_process_key(LPCOLESTR *pstr, HKEY parent_key, strbuf *buf, BOOL do_register)
-{
-    LPCOLESTR iter = *pstr;
-    HRESULT hres;
-    LONG lres;
-    HKEY hkey = 0;
-    strbuf name;
-    
-    enum {
-        NORMAL,
-        NO_REMOVE,
-        IS_VAL,
-        FORCE_REMOVE,
-        DO_DELETE
-    } key_type = NORMAL; 
-
-    static const WCHAR wstrNoRemove[] = {'N','o','R','e','m','o','v','e',0};
-    static const WCHAR wstrForceRemove[] = {'F','o','r','c','e','R','e','m','o','v','e',0};
-    static const WCHAR wstrDelete[] = {'D','e','l','e','t','e',0};
-    static const WCHAR wstrval[] = {'v','a','l',0};
-
-    iter = *pstr;
-    hres = get_word(&iter, buf);
-    if(FAILED(hres))
-        return hres;
-    strbuf_init(&name);
-
-    while(buf->str[1] || buf->str[0] != '}') {
-        key_type = NORMAL;
-        if(!lstrcmpiW(buf->str, wstrNoRemove))
-            key_type = NO_REMOVE;
-        else if(!lstrcmpiW(buf->str, wstrForceRemove))
-            key_type = FORCE_REMOVE;
-        else if(!lstrcmpiW(buf->str, wstrval))
-            key_type = IS_VAL;
-        else if(!lstrcmpiW(buf->str, wstrDelete))
-            key_type = DO_DELETE;
-
-        if(key_type != NORMAL) {
-            hres = get_word(&iter, buf);
-            if(FAILED(hres))
-                break;
-        }
-        TRACE("name = %s\n", debugstr_w(buf->str));
-    
-        if(do_register) {
-            if(key_type == IS_VAL) {
-                hkey = parent_key;
-                strbuf_write(buf->str, &name, -1);
-            }else if(key_type == DO_DELETE) {
-                TRACE("Deleting %s\n", debugstr_w(buf->str));
-                RegDeleteTreeW(parent_key, buf->str);
-            }else {
-                if(key_type == FORCE_REMOVE)
-                    RegDeleteTreeW(parent_key, buf->str);
-                lres = RegCreateKeyW(parent_key, buf->str, &hkey);
-                if(lres != ERROR_SUCCESS) {
-                    WARN("Could not create(open) key: %08x\n", lres);
-                    hres = HRESULT_FROM_WIN32(lres);
-                    break;
-                }
-            }
-        }else if(key_type != IS_VAL && key_type != DO_DELETE) {
-            strbuf_write(buf->str, &name, -1);
-            lres = RegOpenKeyW(parent_key, buf->str, &hkey);
-              if(lres != ERROR_SUCCESS)
-                WARN("Could not open key %s: %08x\n", debugstr_w(name.str), lres);
-        }
-
-        if(key_type != DO_DELETE && *iter == '=') {
-            iter++;
-            hres = get_word(&iter, buf);
-            if(FAILED(hres))
-                break;
-            if(buf->len != 1) {
-                WARN("Wrong registry type: %s\n", debugstr_w(buf->str));
-                hres = DISP_E_EXCEPTION;
-                break;
-            }
-            if(do_register) {
-                switch(buf->str[0]) {
-                case 's':
-                    hres = get_word(&iter, buf);
-                    if(FAILED(hres))
-                        break;
-                    lres = RegSetValueExW(hkey, name.len ? name.str :  NULL, 0, REG_SZ, (PBYTE)buf->str,
-                            (lstrlenW(buf->str)+1)*sizeof(WCHAR));
-                    if(lres != ERROR_SUCCESS) {
-                        WARN("Could set value of key: %08x\n", lres);
-                        hres = HRESULT_FROM_WIN32(lres);
-                        break;
-                    }
-                    break;
-                case 'd': {
-                    DWORD dw;
-                    hres = get_word(&iter, buf);
-                    if(FAILED(hres))
-                        break;
-                    dw = atoiW(buf->str);
-                    lres = RegSetValueExW(hkey, name.len ? name.str :  NULL, 0, REG_DWORD,
-                            (PBYTE)&dw, sizeof(dw));
-                    if(lres != ERROR_SUCCESS) {
-                        WARN("Could set value of key: %08x\n", lres);
-                        hres = HRESULT_FROM_WIN32(lres);
-                        break;
-                    }
-                    break;
-                }
-                case 'b': {
-                    BYTE *bytes;
-                    DWORD count;
-                    DWORD i;
-                    hres = get_word(&iter, buf);
-                    if(FAILED(hres))
-                        break;
-                    count = (lstrlenW(buf->str) + 1) / 2;
-                    bytes = HeapAlloc(GetProcessHeap(), 0, count);
-                    if(bytes == NULL) {
-                        hres = E_OUTOFMEMORY;
-                        break;
-                    }
-                    for(i = 0; i < count && buf->str[2*i]; i++) {
-                        WCHAR digits[3];
-                        if(!isxdigitW(buf->str[2*i]) || !isxdigitW(buf->str[2*i + 1])) {
-                            hres = E_FAIL;
-                            break;
-                        }
-                        digits[0] = buf->str[2*i];
-                        digits[1] = buf->str[2*i + 1];
-                        digits[2] = 0;
-                        bytes[i] = (BYTE) strtoulW(digits, NULL, 16);
-                    }
-                    if(SUCCEEDED(hres)) {
-                        lres = RegSetValueExW(hkey, name.len ? name.str :  NULL, 0, REG_BINARY,
-                            bytes, count);
-                        if(lres != ERROR_SUCCESS) {
-                            WARN("Could not set value of key: 0x%08x\n", lres);
-                            hres = HRESULT_FROM_WIN32(lres);
-                        }
-                    }
-                    HeapFree(GetProcessHeap(), 0, bytes);
-                    break;
-                }
-                default:
-                    WARN("Wrong resource type: %s\n", debugstr_w(buf->str));
-                    hres = DISP_E_EXCEPTION;
-                };
-                if(FAILED(hres))
-                    break;
-            }else {
-                if(*iter == '-')
-                    iter++;
-                hres = get_word(&iter, buf);
-                if(FAILED(hres))
-                    break;
-            }
-        }else if(key_type == IS_VAL) {
-            WARN("value not set!\n");
-            hres = DISP_E_EXCEPTION;
-            break;
-        }
-
-        if(key_type != IS_VAL && key_type != DO_DELETE && *iter == '{' && isspaceW(iter[1])) {
-            hres = get_word(&iter, buf);
-            if(FAILED(hres))
-                break;
-            hres = do_process_key(&iter, hkey, buf, do_register);
-            if(FAILED(hres))
-                break;
-        }
-
-        TRACE("%x %x\n", do_register, key_type);
-        if(!do_register && (key_type == NORMAL || key_type == FORCE_REMOVE)) {
-            TRACE("Deleting %s\n", debugstr_w(name.str));
-            RegDeleteKeyW(parent_key, name.str);
-        }
-
-        if(hkey && key_type != IS_VAL)
-            RegCloseKey(hkey);
-        hkey = 0;
-        name.len = 0;
-        
-        hres = get_word(&iter, buf);
-        if(FAILED(hres))
-            break;
-    }
-
-    HeapFree(GetProcessHeap(), 0, name.str);
-    if(hkey && key_type != IS_VAL)
-        RegCloseKey(hkey);
-    *pstr = iter;
-    return hres;
-}
-
-static HRESULT do_process_root_key(LPCOLESTR data, BOOL do_register)
-{
-    LPCOLESTR iter = data;
-    strbuf buf;
-    HRESULT hres = S_OK;
-    unsigned int i;
-
-    strbuf_init(&buf);
-    hres = get_word(&iter, &buf);
-    if(FAILED(hres))
-        return hres;
-
-    while(*iter) {
-        if(!buf.len) {
-            WARN("ward.len == 0, failed\n");
-            hres = DISP_E_EXCEPTION;
-            break;
-        }
-        for(i=0; i<sizeof(root_keys)/sizeof(root_keys[0]); i++) {
-            if(!lstrcmpiW(buf.str, root_keys[i].name))
-                break;
-        }
-        if(i == sizeof(root_keys)/sizeof(root_keys[0])) {
-            WARN("Wrong root key name: %s\n", debugstr_w(buf.str));
-            hres = DISP_E_EXCEPTION;
-            break;
-        }
-        hres = get_word(&iter, &buf);
-        if(FAILED(hres))
-            break;
-        if(buf.str[1] || buf.str[0] != '{') {
-            WARN("Failed, expected '{', got %s\n", debugstr_w(buf.str));
-            hres = DISP_E_EXCEPTION;
-            break;
-        }
-        hres = do_process_key(&iter, root_keys[i].key, &buf, do_register);
-        if(FAILED(hres)) {
-            WARN("Processing key failed: %08x\n", hres);
-            break;
-        }
-        hres = get_word(&iter, &buf);
-        if(FAILED(hres))
-            break;
-    }
-    HeapFree(GetProcessHeap(), 0, buf.str);
-    return hres;
-}
-
-static HRESULT string_register(Registrar *This, LPCOLESTR data, BOOL do_register)
-{
-    strbuf buf;
-    HRESULT hres;
-
-    TRACE("(%p %s %x)\n", This, debugstr_w(data), do_register);
-
-    strbuf_init(&buf);
-    hres = do_preprocess(This, data, &buf);
-    if(FAILED(hres)) {
-        WARN("preprocessing failed!\n");
-        HeapFree(GetProcessHeap(), 0, buf.str);
-        return hres;
-    }
-
-    hres = do_process_root_key(buf.str, do_register);
-    if(FAILED(hres) && do_register)
-        do_process_root_key(buf.str, FALSE);
-
-    HeapFree(GetProcessHeap(), 0, buf.str);
-    return hres;
-}
-
-static HRESULT resource_register(Registrar *This, LPCOLESTR resFileName,
-                        LPCOLESTR szID, LPCOLESTR szType, BOOL do_register)
-{
-    HINSTANCE hins;
-    HRSRC src;
-    LPSTR regstra;
-    LPWSTR regstrw;
-    DWORD len, reslen;
-    HRESULT hres;
-
-    hins = LoadLibraryExW(resFileName, NULL, LOAD_LIBRARY_AS_DATAFILE);
-    if(hins) {
-        src = FindResourceW(hins, szID, szType);
-        if(src) {
-            regstra = LoadResource(hins, src);
-            reslen = SizeofResource(hins, src);
-            if(regstra) {
-                len = MultiByteToWideChar(CP_ACP, 0, regstra, reslen, NULL, 0)+1;
-                regstrw = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len*sizeof(WCHAR));
-                MultiByteToWideChar(CP_ACP, 0, regstra, reslen, regstrw, len);
-                regstrw[len-1] = '\0';
-
-                hres = string_register(This, regstrw, do_register);
-
-                HeapFree(GetProcessHeap(), 0, regstrw);
-            }else {
-                WARN("could not load resource\n");
-                hres = HRESULT_FROM_WIN32(GetLastError());
-            }
-        }else {
-            WARN("Could not find source\n");
-            hres = HRESULT_FROM_WIN32(GetLastError());
-        }
-        FreeLibrary(hins);
-    }else {
-        WARN("Could not load resource file\n");
-        hres = HRESULT_FROM_WIN32(GetLastError());
-    }
-
-    return hres;
-}
-
-static HRESULT file_register(Registrar *This, LPCOLESTR fileName, BOOL do_register)
-{
-    HANDLE file;
-    DWORD filelen, len;
-    LPWSTR regstrw;
-    LPSTR regstra;
-    LRESULT lres;
-    HRESULT hres;
-
-    file = CreateFileW(fileName, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL);
-    if(file != INVALID_HANDLE_VALUE) {
-        filelen = GetFileSize(file, NULL);
-        regstra = HeapAlloc(GetProcessHeap(), 0, filelen);
-        lres = ReadFile(file, regstra, filelen, NULL, NULL);
-        if(lres == ERROR_SUCCESS) {
-            len = MultiByteToWideChar(CP_ACP, 0, regstra, filelen, NULL, 0)+1;
-            regstrw = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len*sizeof(WCHAR));
-            MultiByteToWideChar(CP_ACP, 0, regstra, filelen, regstrw, len);
-            regstrw[len-1] = '\0';
-            
-            hres = string_register(This, regstrw, do_register);
-
-            HeapFree(GetProcessHeap(), 0, regstrw);
-        }else {
-            WARN("Failed to read faile\n");
-            hres = HRESULT_FROM_WIN32(lres);
-        }
-        HeapFree(GetProcessHeap(), 0, regstra);
-        CloseHandle(file);
-    }else {
-        WARN("Could not open file\n");
-        hres = HRESULT_FROM_WIN32(GetLastError());
-    }
-
-    return hres;
-}
-
-static HRESULT WINAPI Registrar_QueryInterface(IRegistrar *iface, REFIID riid, void **ppvObject)
-{
-    TRACE("(%p)->(%s %p\n", iface, debugstr_guid(riid), ppvObject);
-
-    if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IRegistrar, riid)) {
-        IRegistrar_AddRef(iface);
-        *ppvObject = iface;
-        return S_OK;
-    }
-    return E_NOINTERFACE;
-}
-
-static ULONG WINAPI Registrar_AddRef(IRegistrar *iface)
-{
-    Registrar *This = impl_from_IRegistrar(iface);
-    ULONG ref = InterlockedIncrement(&This->ref);
-    TRACE("(%p) ->%d\n", This, ref);
-    return ref;
-}
-
-static ULONG WINAPI Registrar_Release(IRegistrar *iface)
-{
-    Registrar *This = impl_from_IRegistrar(iface);
-    ULONG ref = InterlockedDecrement(&This->ref);
-
-    TRACE("(%p) ->%d\n", This, ref);
-    if(!ref) {
-        IRegistrar_ClearReplacements(iface);
-        HeapFree(GetProcessHeap(), 0, This);
-        InterlockedDecrement(&dll_count);
-    }
-    return ref;
-}
-
-static HRESULT WINAPI Registrar_AddReplacement(IRegistrar *iface, LPCOLESTR Key, LPCOLESTR item)
-{
-    Registrar *This = impl_from_IRegistrar(iface);
-    int len;
-    rep_list *new_rep;
-
-    TRACE("(%p)->(%s %s)\n", This, debugstr_w(Key), debugstr_w(item));
-
-    new_rep = HeapAlloc(GetProcessHeap(), 0, sizeof(rep_list));
-
-    new_rep->key_len  = lstrlenW(Key);
-    new_rep->key = HeapAlloc(GetProcessHeap(), 0, (new_rep->key_len + 1) * sizeof(OLECHAR));
-    memcpy(new_rep->key, Key, (new_rep->key_len+1)*sizeof(OLECHAR));
-
-    len = lstrlenW(item)+1;
-    new_rep->item = HeapAlloc(GetProcessHeap(), 0, len*sizeof(OLECHAR));
-    memcpy(new_rep->item, item, len*sizeof(OLECHAR));
-
-    new_rep->next = This->rep;
-    This->rep = new_rep;
-    
-    return S_OK;
-}
-
-static HRESULT WINAPI Registrar_ClearReplacements(IRegistrar *iface)
-{
-    Registrar *This = impl_from_IRegistrar(iface);
-    rep_list *iter, *iter2;
-
-    TRACE("(%p)\n", This);
-
-    if(!This->rep)
-        return S_OK;
-
-    iter = This->rep;
-    while(iter) {
-        iter2 = iter->next;
-        HeapFree(GetProcessHeap(), 0, iter->key);
-        HeapFree(GetProcessHeap(), 0, iter->item);
-        HeapFree(GetProcessHeap(), 0, iter);
-        iter = iter2;
-    }
-
-    This->rep = NULL;
-    return S_OK;
-}
-
-static HRESULT WINAPI Registrar_ResourceRegisterSz(IRegistrar* iface, LPCOLESTR resFileName,
-                LPCOLESTR szID, LPCOLESTR szType)
-{
-    Registrar *This = impl_from_IRegistrar(iface);
-    TRACE("(%p)->(%s %s %s)\n", This, debugstr_w(resFileName), debugstr_w(szID), debugstr_w(szType));
-    return resource_register(This, resFileName, szID, szType, TRUE);
-}
-
-static HRESULT WINAPI Registrar_ResourceUnregisterSz(IRegistrar* iface, LPCOLESTR resFileName,
-                LPCOLESTR szID, LPCOLESTR szType)
-{
-    Registrar *This = impl_from_IRegistrar(iface);
-    TRACE("(%p)->(%s %s %s)\n", This, debugstr_w(resFileName), debugstr_w(szID), debugstr_w(szType));
-    return resource_register(This, resFileName, szID, szType, FALSE);
-}
-
-static HRESULT WINAPI Registrar_FileRegister(IRegistrar* iface, LPCOLESTR fileName)
-{
-    Registrar *This = impl_from_IRegistrar(iface);
-    TRACE("(%p)->(%s)\n", This, debugstr_w(fileName));
-    return file_register(This, fileName, TRUE);
-}
-
-static HRESULT WINAPI Registrar_FileUnregister(IRegistrar* iface, LPCOLESTR fileName)
-{
-    Registrar *This = impl_from_IRegistrar(iface);
-    FIXME("(%p)->(%s)\n", This, debugstr_w(fileName));
-    return file_register(This, fileName, FALSE);
-}
-
-static HRESULT WINAPI Registrar_StringRegister(IRegistrar* iface, LPCOLESTR data)
-{
-    Registrar *This = impl_from_IRegistrar(iface);
-    TRACE("(%p)->(%s)\n", This, debugstr_w(data));
-    return string_register(This, data, TRUE);
-}
-
-static HRESULT WINAPI Registrar_StringUnregister(IRegistrar* iface, LPCOLESTR data)
-{
-    Registrar *This = impl_from_IRegistrar(iface);
-    TRACE("(%p)->(%s)\n", This, debugstr_w(data));
-    return string_register(This, data, FALSE);
-}
-
-static HRESULT WINAPI Registrar_ResourceRegister(IRegistrar* iface, LPCOLESTR resFileName,
-                UINT nID, LPCOLESTR szType)
-{
-    Registrar *This = impl_from_IRegistrar(iface);
-    TRACE("(%p)->(%s %d %s)\n", iface, debugstr_w(resFileName), nID, debugstr_w(szType));
-    return resource_register(This, resFileName, MAKEINTRESOURCEW(nID), szType, TRUE);
-}
-
-static HRESULT WINAPI Registrar_ResourceUnregister(IRegistrar* iface, LPCOLESTR resFileName,
-                UINT nID, LPCOLESTR szType)
-{
-    Registrar *This = impl_from_IRegistrar(iface);
-    TRACE("(%p)->(%s %d %s)\n", This, debugstr_w(resFileName), nID, debugstr_w(szType));
-    return resource_register(This, resFileName, MAKEINTRESOURCEW(nID), szType, FALSE);
-}
-
-static const IRegistrarVtbl RegistrarVtbl = {
-    Registrar_QueryInterface,
-    Registrar_AddRef,
-    Registrar_Release,
-    Registrar_AddReplacement,
-    Registrar_ClearReplacements,
-    Registrar_ResourceRegisterSz,
-    Registrar_ResourceUnregisterSz,
-    Registrar_FileRegister,
-    Registrar_FileUnregister,
-    Registrar_StringRegister,
-    Registrar_StringUnregister,
-    Registrar_ResourceRegister,
-    Registrar_ResourceUnregister,
-};
-
-static HRESULT Registrar_create(const IUnknown *pUnkOuter, REFIID riid, void **ppvObject)
-{
-    Registrar *ret;
-
-    if(!IsEqualGUID(&IID_IUnknown, riid) && !IsEqualGUID(&IID_IRegistrar, riid))
-        return E_NOINTERFACE;
-
-    ret = HeapAlloc(GetProcessHeap(), 0, sizeof(Registrar));
-    ret->IRegistrar_iface.lpVtbl = &RegistrarVtbl;
-    ret->ref = 1;
-    ret->rep = NULL;
-    *ppvObject = ret;
-
-    InterlockedIncrement(&dll_count);
-
-    return S_OK;
-}
-
 /**************************************************************
  * ClassFactory implementation
  */
@@ -733,32 +46,39 @@ static HRESULT WINAPI RegistrarCF_QueryInterface(IClassFactory *iface, REFIID ri
 
 static ULONG WINAPI RegistrarCF_AddRef(IClassFactory *iface)
 {
-    InterlockedIncrement(&dll_count);
     return 2;
 }
 
 static ULONG WINAPI RegistrarCF_Release(IClassFactory *iface)
 {
-    InterlockedDecrement(&dll_count);
     return 1;
 }
 
 static HRESULT WINAPI RegistrarCF_CreateInstance(IClassFactory *iface, LPUNKNOWN pUnkOuter,
-                                                REFIID riid, void **ppvObject)
+                                                REFIID riid, void **ppv)
 {
-    TRACE("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppvObject);
-    return Registrar_create(pUnkOuter, riid, ppvObject);
+    IRegistrar *registrar;
+    HRESULT hres;
+
+    TRACE("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
+
+    if(pUnkOuter) {
+        *ppv = NULL;
+        return CLASS_E_NOAGGREGATION;
+    }
+
+    hres = AtlCreateRegistrar(&registrar);
+    if(FAILED(hres))
+        return hres;
+
+    hres = IRegistrar_QueryInterface(registrar, riid, ppv);
+    IRegistrar_Release(registrar);
+    return hres;
 }
 
 static HRESULT WINAPI RegistrarCF_LockServer(IClassFactory *iface, BOOL lock)
 {
     TRACE("(%p)->(%x)\n", iface, lock);
-
-    if(lock)
-        InterlockedIncrement(&dll_count);
-    else
-        InterlockedDecrement(&dll_count);
-
     return S_OK;
 }
 
@@ -799,10 +119,13 @@ static HRESULT do_register_dll_server(IRegistrar *pRegistrar, LPCOLESTR wszDll,
     static const WCHAR wszModule[] = {'M','O','D','U','L','E',0};
     static const WCHAR wszRegistry[] = {'R','E','G','I','S','T','R','Y',0};
 
-    if (pRegistrar)
+    if(pRegistrar) {
         registrar = pRegistrar;
-    else
-        Registrar_create(NULL, &IID_IRegistrar, (void**)&registrar);
+    }else {
+        hres = AtlCreateRegistrar(&registrar);
+        if(FAILED(hres))
+            return hres;
+    }
 
     IRegistrar_AddReplacement(registrar, wszModule, wszDll);
 
@@ -879,6 +202,5 @@ HRESULT WINAPI DllUnregisterServer(void)
  */
 HRESULT WINAPI DllCanUnloadNow(void)
 {
-    TRACE("dll_count = %u\n", dll_count);
-    return dll_count ? S_FALSE : S_OK;
+    return S_FALSE;
 }
index c559533..33bc71f 100644 (file)
@@ -1,20 +1,2 @@
-/*
- * Copyright 2005 Jacek Caban
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
 
-/* @makedep: atl.rgs */
 101 REGISTRY atl.rgs
diff --git a/reactos/dll/win32/atl/stubs.c b/reactos/dll/win32/atl/stubs.c
deleted file mode 100644 (file)
index 01f22de..0000000
+++ /dev/null
@@ -1,127 +0,0 @@
-#include <windows.h>
-#include <reactos/debug.h>
-
-#define ATLAPI_(x) x WINAPI
-#define ATLAPI ATLAPI_(HRESULT)
-
-struct _ATL_CATMAP_ENTRY;
-typedef struct _ATL_PROPMAP_ENTRY ATL_PROPMAP_ENTRY;
-typedef struct _ATL_MODULE _ATL_MODULE;
-
-BOOL
-WINAPI
-AtlWaitWithMessageLoop(
-   HANDLE hEvent)
-{
-    UNIMPLEMENTED;
-       return FALSE;
-}
-
-ATLAPI
-AtlSetErrorInfo(
-    const CLSID *pclsid,
-    LPCOLESTR lpszDesc,
-    DWORD dwHelpID,
-    LPCOLESTR lpszHelpFile,
-    const IID *piid,
-    HRESULT hRes,
-    HINSTANCE hInst)
-{
-    UNIMPLEMENTED;
-       return E_NOTIMPL;
-}
-
-ATLAPI_(LPDEVMODEA)
-AtlDevModeW2A(LPDEVMODEA lpDevModeA, LPDEVMODEW lpDevModeW)
-{
-    UNIMPLEMENTED;
-       return NULL;
-}
-
-ATLAPI_(DWORD)
-AtlGetVersion(void* pReserved)
-{
-    UNIMPLEMENTED;
-       return 0;
-}
-
-ATLAPI_(int)
-AtlAxDialogBoxW(
-    HINSTANCE hInstance,
-    LPCWSTR lpTemplateName,
-    HWND hWndParent,
-    DLGPROC lpDialogProc,
-    LPARAM dwInitParam)
-{
-    UNIMPLEMENTED;
-       return 0;
-}
-
-ATLAPI_(int)
-AtlAxDialogBoxA(
-    HINSTANCE hInstance,
-    LPCSTR lpTemplateName,
-    HWND hWndParent,
-    DLGPROC lpDialogProc,
-    LPARAM dwInitParam)
-{
-    UNIMPLEMENTED;
-       return 0;
-}
-
-ATLAPI_(int)
-AtlRegisterClassCategoriesHelper(
-    const CLSID *pclsid,
-    const struct _ATL_CATMAP_ENTRY* pEntry,
-    BOOL arg3)
-{
-    UNIMPLEMENTED;
-       return 0;
-}
-
-ATLAPI
-AtlIPersistPropertyBag_Load(
-    LPPROPERTYBAG pPropBag,
-    LPERRORLOG pErrorLog,
-    const ATL_PROPMAP_ENTRY* pMap,
-    void* pThis,
-    IUnknown* pUnk)
-{
-    UNIMPLEMENTED;
-       return E_NOTIMPL;
-}
-
-ATLAPI
-AtlIPersistPropertyBag_Save(
-    LPPROPERTYBAG pPropBag,
-    BOOL fClearDirty,
-    BOOL fSaveAllProperties,
-    const ATL_PROPMAP_ENTRY* pMap,
-    void* pThis,
-    IUnknown* pUnk)
-{
-    UNIMPLEMENTED;
-       return E_NOTIMPL;
-}
-
-ATLAPI
-AtlGetObjectSourceInterface(
-   IUnknown* punkObj,
-   GUID* plibid,
-   IID* piid,
-   unsigned short* pdwMajor,
-   unsigned short* pdwMinor)
-{
-    UNIMPLEMENTED;
-       return E_NOTIMPL;
-}
-
-ATLAPI
-AtlModuleUnregisterTypeLib(
-   _ATL_MODULE* pM,
-   LPCOLESTR lpszIndex)
-{
-    UNIMPLEMENTED;
-       return E_NOTIMPL;
-}
-
diff --git a/reactos/dll/win32/atl100/CMakeLists.txt b/reactos/dll/win32/atl100/CMakeLists.txt
new file mode 100644 (file)
index 0000000..bb2f12f
--- /dev/null
@@ -0,0 +1,23 @@
+
+add_definitions(-D__WINESRC__)
+
+remove_definitions(-D_WIN32_WINNT=0x502)
+add_definitions(-D_WIN32_WINNT=0x600)
+
+include_directories(${REACTOS_SOURCE_DIR}/include/reactos/wine)
+
+spec2def(atl100.dll atl100.spec ADD_IMPORTLIB)
+
+list(APPEND SOURCE
+    atl.c
+    atl_ax.c
+    registrar.c
+    ${CMAKE_CURRENT_BINARY_DIR}/atl100_stubs.c
+    ${CMAKE_CURRENT_BINARY_DIR}/atl100.def)
+
+add_library(atl100 SHARED ${SOURCE})
+set_module_type(atl100 win32dll)
+target_link_libraries(atl100 uuid wine)
+
+add_importlibs(atl100 ole32 oleaut32 user32 gdi32 advapi32 msvcrt kernel32 ntdll)
+add_cd_file(TARGET atl100 DESTINATION reactos/system32 FOR all)
diff --git a/reactos/dll/win32/atl100/atl.c b/reactos/dll/win32/atl100/atl.c
new file mode 100644 (file)
index 0000000..f1b76a5
--- /dev/null
@@ -0,0 +1,235 @@
+/*
+ * Copyright 2012 Stefan Leichter
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#define COBJMACROS
+
+#include "atlbase.h"
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(atl);
+
+/***********************************************************************
+ *           AtlAdvise         [atl100.@]
+ */
+HRESULT WINAPI AtlAdvise(IUnknown *pUnkCP, IUnknown *pUnk, const IID *iid, LPDWORD pdw)
+{
+    FIXME("%p %p %p %p\n", pUnkCP, pUnk, iid, pdw);
+    return E_FAIL;
+}
+
+/***********************************************************************
+ *           AtlUnadvise         [atl100.@]
+ */
+HRESULT WINAPI AtlUnadvise(IUnknown *pUnkCP, const IID *iid, DWORD dw)
+{
+    FIXME("%p %p %d\n", pUnkCP, iid, dw);
+    return S_OK;
+}
+
+/***********************************************************************
+ *           AtlFreeMarshalStream         [atl100.@]
+ */
+HRESULT WINAPI AtlFreeMarshalStream(IStream *stm)
+{
+    FIXME("%p\n", stm);
+    return S_OK;
+}
+
+/***********************************************************************
+ *           AtlMarshalPtrInProc         [atl100.@]
+ */
+HRESULT WINAPI AtlMarshalPtrInProc(IUnknown *pUnk, const IID *iid, IStream **pstm)
+{
+    FIXME("%p %p %p\n", pUnk, iid, pstm);
+    return E_FAIL;
+}
+
+/***********************************************************************
+ *           AtlUnmarshalPtr              [atl100.@]
+ */
+HRESULT WINAPI AtlUnmarshalPtr(IStream *stm, const IID *iid, IUnknown **ppUnk)
+{
+    FIXME("%p %p %p\n", stm, iid, ppUnk);
+    return E_FAIL;
+}
+
+/***********************************************************************
+ *           AtlCreateTargetDC         [atl100.@]
+ */
+HDC WINAPI AtlCreateTargetDC( HDC hdc, DVTARGETDEVICE *dv )
+{
+    static const WCHAR displayW[] = {'d','i','s','p','l','a','y',0};
+    const WCHAR *driver = NULL, *device = NULL, *port = NULL;
+    DEVMODEW *devmode = NULL;
+
+    TRACE( "(%p, %p)\n", hdc, dv );
+
+    if (dv)
+    {
+        if (dv->tdDriverNameOffset) driver  = (WCHAR *)((char *)dv + dv->tdDriverNameOffset);
+        if (dv->tdDeviceNameOffset) device  = (WCHAR *)((char *)dv + dv->tdDeviceNameOffset);
+        if (dv->tdPortNameOffset)   port    = (WCHAR *)((char *)dv + dv->tdPortNameOffset);
+        if (dv->tdExtDevmodeOffset) devmode = (DEVMODEW *)((char *)dv + dv->tdExtDevmodeOffset);
+    }
+    else
+    {
+        if (hdc) return hdc;
+        driver = displayW;
+    }
+    return CreateDCW( driver, device, port, devmode );
+}
+
+/***********************************************************************
+ *           AtlHiMetricToPixel              [atl100.@]
+ */
+void WINAPI AtlHiMetricToPixel(const SIZEL* lpHiMetric, SIZEL* lpPix)
+{
+    HDC dc = GetDC(NULL);
+    lpPix->cx = lpHiMetric->cx * GetDeviceCaps( dc, LOGPIXELSX ) / 100;
+    lpPix->cy = lpHiMetric->cy * GetDeviceCaps( dc, LOGPIXELSY ) / 100;
+    ReleaseDC( NULL, dc );
+}
+
+/***********************************************************************
+ *           AtlPixelToHiMetric              [atl100.@]
+ */
+void WINAPI AtlPixelToHiMetric(const SIZEL* lpPix, SIZEL* lpHiMetric)
+{
+    HDC dc = GetDC(NULL);
+    lpHiMetric->cx = 100 * lpPix->cx / GetDeviceCaps( dc, LOGPIXELSX );
+    lpHiMetric->cy = 100 * lpPix->cy / GetDeviceCaps( dc, LOGPIXELSY );
+    ReleaseDC( NULL, dc );
+}
+
+/***********************************************************************
+ *           AtlComPtrAssign              [atl100.@]
+ */
+IUnknown* WINAPI AtlComPtrAssign(IUnknown** pp, IUnknown *p)
+{
+    TRACE("(%p %p)\n", pp, p);
+
+    if (p) IUnknown_AddRef(p);
+    if (*pp) IUnknown_Release(*pp);
+    *pp = p;
+    return p;
+}
+
+/***********************************************************************
+ *           AtlComQIPtrAssign              [atl100.@]
+ */
+IUnknown* WINAPI AtlComQIPtrAssign(IUnknown** pp, IUnknown *p, REFIID riid)
+{
+    IUnknown *new_p = NULL;
+
+    TRACE("(%p %p %s)\n", pp, p, debugstr_guid(riid));
+
+    if (p) IUnknown_QueryInterface(p, riid, (void **)&new_p);
+    if (*pp) IUnknown_Release(*pp);
+    *pp = new_p;
+    return new_p;
+}
+
+/***********************************************************************
+ *           AtlInternalQueryInterface     [atl100.@]
+ */
+HRESULT WINAPI AtlInternalQueryInterface(void* this, const _ATL_INTMAP_ENTRY* pEntries,  REFIID iid, void** ppvObject)
+{
+    int i = 0;
+    HRESULT rc = E_NOINTERFACE;
+    TRACE("(%p, %p, %s, %p)\n",this, pEntries, debugstr_guid(iid), ppvObject);
+
+    if (IsEqualGUID(iid,&IID_IUnknown))
+    {
+        TRACE("Returning IUnknown\n");
+        *ppvObject = ((LPSTR)this+pEntries[0].dw);
+        IUnknown_AddRef((IUnknown*)*ppvObject);
+        return S_OK;
+    }
+
+    while (pEntries[i].pFunc != 0)
+    {
+        TRACE("Trying entry %i (%s %i %p)\n",i,debugstr_guid(pEntries[i].piid),
+              pEntries[i].dw, pEntries[i].pFunc);
+
+        if (!pEntries[i].piid || IsEqualGUID(iid,pEntries[i].piid))
+        {
+            TRACE("MATCH\n");
+            if (pEntries[i].pFunc == (_ATL_CREATORARGFUNC*)1)
+            {
+                TRACE("Offset\n");
+                *ppvObject = ((LPSTR)this+pEntries[i].dw);
+                IUnknown_AddRef((IUnknown*)*ppvObject);
+                return S_OK;
+            }
+            else
+            {
+                TRACE("Function\n");
+                rc = pEntries[i].pFunc(this, iid, ppvObject, pEntries[i].dw);
+                if(rc==S_OK || pEntries[i].piid)
+                    return rc;
+            }
+        }
+        i++;
+    }
+    TRACE("Done returning (0x%x)\n",rc);
+    return rc;
+}
+
+/* FIXME: should be in a header file */
+typedef struct ATL_PROPMAP_ENTRY
+{
+    LPCOLESTR szDesc;
+    DISPID dispid;
+    const CLSID* pclsidPropPage;
+    const IID* piidDispatch;
+    DWORD dwOffsetData;
+    DWORD dwSizeData;
+    VARTYPE vt;
+} ATL_PROPMAP_ENTRY;
+
+/***********************************************************************
+ *           AtlIPersistStreamInit_Load      [atl100.@]
+ */
+HRESULT WINAPI AtlIPersistStreamInit_Load( LPSTREAM pStm, ATL_PROPMAP_ENTRY *pMap,
+                                           void *pThis, IUnknown *pUnk)
+{
+    FIXME("(%p, %p, %p, %p)\n", pStm, pMap, pThis, pUnk);
+
+    return S_OK;
+}
+
+/***********************************************************************
+ *           AtlIPersistStreamInit_Save      [atl100.@]
+ */
+HRESULT WINAPI AtlIPersistStreamInit_Save(LPSTREAM pStm, BOOL fClearDirty,
+                                          ATL_PROPMAP_ENTRY *pMap, void *pThis,
+                                          IUnknown *pUnk)
+{
+    FIXME("(%p, %d, %p, %p, %p)\n", pStm, fClearDirty, pMap, pThis, pUnk);
+
+    return S_OK;
+}
+
+/***********************************************************************
+ *           AtlGetVersion              [atl100.@]
+ */
+DWORD WINAPI AtlGetVersion(void *pReserved)
+{
+   return 0x0a00;
+}
diff --git a/reactos/dll/win32/atl100/atl100.spec b/reactos/dll/win32/atl100/atl100.spec
new file mode 100644 (file)
index 0000000..efe6c19
--- /dev/null
@@ -0,0 +1,52 @@
+10 stdcall AtlAdvise(ptr ptr ptr ptr)
+11 stdcall AtlUnadvise(ptr ptr long)
+12 stdcall AtlFreeMarshalStream(ptr)
+13 stdcall AtlMarshalPtrInProc(ptr ptr ptr)
+14 stdcall AtlUnmarshalPtr(ptr ptr ptr)
+15 stub AtlComModuleGetClassObject
+17 stub AtlComModuleRegisterClassObjects
+20 stub AtlComModuleRevokeClassObjects
+22 stub AtlComModuleUnregisterServer
+23 stub AtlUpdateRegistryFromResourceD
+24 stub AtlWaitWithMessageLoop
+25 stub AtlSetErrorInfo
+26 stdcall AtlCreateTargetDC(long ptr)
+27 stdcall AtlHiMetricToPixel(ptr ptr)
+28 stdcall AtlPixelToHiMetric(ptr ptr)
+29 stub AtlDevModeW2A
+30 stdcall AtlComPtrAssign(ptr ptr)
+31 stdcall AtlComQIPtrAssign(ptr ptr ptr)
+32 stdcall AtlInternalQueryInterface(ptr ptr ptr ptr)
+34 stdcall AtlGetVersion(ptr)
+35 stub AtlAxDialogBoxW
+36 stub AtlAxDialogBoxA
+37 stdcall AtlAxCreateDialogW(long wstr long ptr long)
+38 stdcall AtlAxCreateDialogA(long str long ptr long)
+39 stdcall AtlAxCreateControl(ptr ptr ptr ptr)
+40 stdcall AtlAxCreateControlEx(ptr ptr ptr ptr ptr ptr ptr)
+41 stdcall AtlAxAttachControl(ptr ptr ptr)
+42 stdcall AtlAxWinInit()
+43 stub AtlWinModuleAddCreateWndData
+44 stub AtlWinModuleExtractCreateWndData
+45 stub AtlWinModuleRegisterWndClassInfoW
+46 stub AtlWinModuleRegisterWndClassInfoA
+47 stdcall AtlAxGetControl(long ptr)
+48 stdcall AtlAxGetHost(long ptr)
+49 stub AtlRegisterClassCategoriesHelper
+50 stdcall AtlIPersistStreamInit_Load(ptr ptr ptr ptr)
+51 stdcall AtlIPersistStreamInit_Save(ptr long ptr ptr ptr)
+52 stub AtlIPersistPropertyBag_Load
+53 stub AtlIPersistPropertyBag_Save
+54 stub AtlGetObjectSourceInterface
+56 stub AtlLoadTypeLib
+58 stub AtlModuleAddTermFunc
+59 stub AtlAxCreateControlLic
+60 stub AtlAxCreateControlLicEx
+61 stdcall AtlCreateRegistrar(ptr)
+62 stub AtlWinModuleRegisterClassExW
+63 stub AtlWinModuleRegisterClassExA
+64 stub AtlCallTermFunc
+65 stub AtlWinModuleInit
+66 stub AtlWinModuleTerm
+67 stub AtlSetPerUserRegistration
+68 stub AtlGetPerUserRegistration
similarity index 98%
rename from reactos/dll/win32/atl/atl_ax.c
rename to reactos/dll/win32/atl100/atl_ax.c
index c1b74f7..bd0881f 100644 (file)
@@ -75,7 +75,7 @@ static LRESULT CALLBACK AtlAxWin_wndproc( HWND hWnd, UINT wMsg, WPARAM wParam, L
 }
 
 /***********************************************************************
- *           AtlAxWinInit          [ATL.@]
+ *           AtlAxWinInit          [atl100.@]
  * Initializes the control-hosting code: registering the AtlAxWin,
  * AtlAxWin7 and AtlAxWinLic7 window classes and some messages.
  *
@@ -800,6 +800,7 @@ static HRESULT IOCS_Detach( IOCS *This ) /* remove subclassing */
         IOleObject *control = This->control;
 
         This->control = NULL;
+        IOleObject_Close( control, OLECLOSE_NOSAVE );
         IOleObject_SetClientSite( control, NULL );
         IOleObject_Release( control );
     }
@@ -960,7 +961,7 @@ static HRESULT IOCS_Create( HWND hWnd, IUnknown *pUnkControl, IOCS **ppSite )
 
 
 /***********************************************************************
- *           AtlAxCreateControl           [ATL.@]
+ *           AtlAxCreateControl           [atl100.@]
  */
 HRESULT WINAPI AtlAxCreateControl(LPCOLESTR lpszName, HWND hWnd,
         IStream *pStream, IUnknown **ppUnkContainer)
@@ -970,7 +971,7 @@ HRESULT WINAPI AtlAxCreateControl(LPCOLESTR lpszName, HWND hWnd,
 }
 
 /***********************************************************************
- *           AtlAxCreateControlEx            [ATL.@]
+ *           AtlAxCreateControlEx            [atl100.@]
  *
  * REMARKS
  *   See http://www.codeproject.com/com/cwebpage.asp for some background
@@ -988,7 +989,7 @@ HRESULT WINAPI AtlAxCreateControlEx(LPCOLESTR lpszName, HWND hWnd,
     IUnknown *pContainer;
     enum {IsGUID=0,IsHTML=1,IsURL=2} content;
 
-    TRACE("(%s %p %p %p %p %p %p)\n", debugstr_w(lpszName), hWnd, pStream, 
+    TRACE("(%s %p %p %p %p %p %p)\n", debugstr_w(lpszName), hWnd, pStream,
             ppUnkContainer, ppUnkControl, iidSink, punkSink);
 
     hRes = CLSIDFromString( lpszName, &controlId );
@@ -1002,7 +1003,7 @@ HRESULT WINAPI AtlAxCreateControlEx(LPCOLESTR lpszName, HWND hWnd,
         controlId = CLSID_WebBrowser;
     }
 
-    hRes = CoCreateInstance( &controlId, 0, CLSCTX_ALL, &IID_IOleObject, 
+    hRes = CoCreateInstance( &controlId, 0, CLSCTX_ALL, &IID_IOleObject,
             (void**) &pControl );
     if ( FAILED( hRes ) )
     {
@@ -1024,7 +1025,7 @@ HRESULT WINAPI AtlAxCreateControlEx(LPCOLESTR lpszName, HWND hWnd,
 
     IOleObject_QueryInterface( pControl, &IID_IUnknown, (void**) &pUnkControl );
     IOleObject_Release( pControl );
-     
+
 
     hRes = AtlAxAttachControl( pUnkControl, hWnd, &pContainer );
     if ( FAILED( hRes ) )
@@ -1039,7 +1040,7 @@ HRESULT WINAPI AtlAxCreateControlEx(LPCOLESTR lpszName, HWND hWnd,
             WARN( "Cannot query IWebBrowser2 interface: %08x\n", hRes );
         else {
             VARIANT url;
-            
+
             IWebBrowser2_put_Visible( browser, VARIANT_TRUE ); /* it seems that native does this on URL (but do not on MSHTML:! why? */
 
             V_VT(&url) = VT_BSTR;
@@ -1076,7 +1077,7 @@ HRESULT WINAPI AtlAxCreateControlEx(LPCOLESTR lpszName, HWND hWnd,
 }
 
 /***********************************************************************
- *           AtlAxAttachControl           [ATL.@]
+ *           AtlAxAttachControl           [atl100.@]
  */
 HRESULT WINAPI AtlAxAttachControl(IUnknown* pControl, HWND hWnd, IUnknown** ppUnkContainer)
 {
@@ -1128,7 +1129,7 @@ static LPDLGTEMPLATEW AX_ConvertDialogTemplate(LPCDLGTEMPLATEW src_tmpl)
 #define PUT_WORD(x)  do {WORD w = (x);PUT_BLOCK(&w, 1);} while(0)
 #define PUT_DWORD(x)  do {DWORD w = (x);PUT_BLOCK(&w, 2);} while(0)
     const WORD *tmp, *src = (const WORD *)src_tmpl;
-    WORD *output; 
+    WORD *output;
     DWORD allocated, filled; /* in WORDs */
     BOOL ext;
     WORD signature, dlgver, rescount;
@@ -1138,7 +1139,7 @@ static LPDLGTEMPLATEW AX_ConvertDialogTemplate(LPCDLGTEMPLATEW src_tmpl)
     output = HeapAlloc( GetProcessHeap(), 0, allocated * sizeof(WORD) );
     if (!output)
         return NULL;
-    
+
     /* header */
     tmp = src;
     signature = GET_WORD(src);
@@ -1233,7 +1234,7 @@ static LPDLGTEMPLATEW AX_ConvertDialogTemplate(LPCDLGTEMPLATEW src_tmpl)
 }
 
 /***********************************************************************
- *           AtlAxCreateDialogA           [ATL.@]
+ *           AtlAxCreateDialogA           [atl100.@]
  *
  * Creates a dialog window
  *
@@ -1242,7 +1243,7 @@ static LPDLGTEMPLATEW AX_ConvertDialogTemplate(LPCDLGTEMPLATEW src_tmpl)
  *  name    [I] Dialog box template name
  *  owner   [I] Dialog box parent HWND
  *  dlgProc [I] Dialog box procedure
- *  param   [I] This value will be passed to dlgProc as WM_INITDIALOG's message lParam 
+ *  param   [I] This value will be passed to dlgProc as WM_INITDIALOG's message lParam
  *
  * RETURNS
  *  Window handle of dialog window.
@@ -1268,7 +1269,7 @@ HWND WINAPI AtlAxCreateDialogA(HINSTANCE hInst, LPCSTR name, HWND owner, DLGPROC
 }
 
 /***********************************************************************
- *           AtlAxCreateDialogW           [ATL.@]
+ *           AtlAxCreateDialogW           [atl100.@]
  *
  * See AtlAxCreateDialogA
  *
@@ -1307,7 +1308,7 @@ HWND WINAPI AtlAxCreateDialogW(HINSTANCE hInst, LPCWSTR name, HWND owner, DLGPRO
 }
 
 /***********************************************************************
- *           AtlAxGetHost                 [ATL.@]
+ *           AtlAxGetHost                 [atl100.@]
  *
  */
 HRESULT WINAPI AtlAxGetHost(HWND hWnd, IUnknown **pUnk)
@@ -1329,7 +1330,7 @@ HRESULT WINAPI AtlAxGetHost(HWND hWnd, IUnknown **pUnk)
 }
 
 /***********************************************************************
- *           AtlAxGetControl              [ATL.@]
+ *           AtlAxGetControl              [atl100.@]
  *
  */
 HRESULT WINAPI AtlAxGetControl(HWND hWnd, IUnknown **pUnk)
diff --git a/reactos/dll/win32/atl100/registrar.c b/reactos/dll/win32/atl100/registrar.c
new file mode 100644 (file)
index 0000000..f9f5b3c
--- /dev/null
@@ -0,0 +1,704 @@
+/*
+ * Copyright 2005 Jacek Caban
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#define COBJMACROS
+
+#include "atlbase.h"
+
+#include "wine/debug.h"
+#include "wine/unicode.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(atl);
+
+/**************************************************************
+ * ATLRegistrar implementation
+ */
+
+static const struct {
+    WCHAR name[22];
+    HKEY  key;
+} root_keys[] = {
+    {{'H','K','E','Y','_','C','L','A','S','S','E','S','_','R','O','O','T',0},
+                    HKEY_CLASSES_ROOT},
+    {{'H','K','E','Y','_','C','U','R','R','E','N','T','_','U','S','E','R',0},
+                    HKEY_CURRENT_USER},
+    {{'H','K','E','Y','_','L','O','C','A','L','_','M','A','C','H','I','N','E',0},
+                    HKEY_LOCAL_MACHINE},
+    {{'H','K','E','Y','_','U','S','E','R','S',0},
+                    HKEY_USERS},
+    {{'H','K','E','Y','_','P','E','R','F','O','R','M','A','N','C','E','_','D','A','T','A',0},
+                    HKEY_PERFORMANCE_DATA},
+    {{'H','K','E','Y','_','D','Y','N','_','D','A','T','A',0},
+                    HKEY_DYN_DATA},
+    {{'H','K','E','Y','_','C','U','R','R','E','N','T','_','C','O','N','F','I','G',0},
+                    HKEY_CURRENT_CONFIG},
+    {{'H','K','C','R',0}, HKEY_CLASSES_ROOT},
+    {{'H','K','C','U',0}, HKEY_CURRENT_USER},
+    {{'H','K','L','M',0}, HKEY_LOCAL_MACHINE},
+    {{'H','K','U',0},     HKEY_USERS},
+    {{'H','K','P','D',0}, HKEY_PERFORMANCE_DATA},
+    {{'H','K','D','D',0}, HKEY_DYN_DATA},
+    {{'H','K','C','C',0}, HKEY_CURRENT_CONFIG}
+};
+
+typedef struct rep_list_str {
+    LPOLESTR key;
+    LPOLESTR item;
+    int key_len;
+    struct rep_list_str *next;
+} rep_list;
+
+typedef struct {
+    IRegistrar IRegistrar_iface;
+    LONG ref;
+    rep_list *rep;
+} Registrar;
+
+typedef struct {
+    LPOLESTR str;
+    DWORD alloc;
+    DWORD len;
+} strbuf;
+
+static inline Registrar *impl_from_IRegistrar(IRegistrar *iface)
+{
+    return CONTAINING_RECORD(iface, Registrar, IRegistrar_iface);
+}
+
+static void strbuf_init(strbuf *buf)
+{
+    buf->str = HeapAlloc(GetProcessHeap(), 0, 128*sizeof(WCHAR));
+    buf->alloc = 128;
+    buf->len = 0;
+}
+
+static void strbuf_write(LPCOLESTR str, strbuf *buf, int len)
+{
+    if(len == -1)
+        len = lstrlenW(str);
+    if(buf->len+len+1 >= buf->alloc) {
+        buf->alloc = (buf->len+len)<<1;
+        buf->str = HeapReAlloc(GetProcessHeap(), 0, buf->str, buf->alloc*sizeof(WCHAR));
+    }
+    memcpy(buf->str+buf->len, str, len*sizeof(OLECHAR));
+    buf->len += len;
+    buf->str[buf->len] = '\0';
+}
+
+static HRESULT get_word(LPCOLESTR *str, strbuf *buf)
+{
+    LPCOLESTR iter, iter2 = *str;
+
+    buf->len = 0;
+    buf->str[0] = '\0';
+
+    while(isspaceW(*iter2))
+        iter2++;
+    iter = iter2;
+    if(!*iter) {
+        *str = iter;
+        return S_OK;
+    }
+
+    if(*iter == '}' || *iter == '=') {
+        strbuf_write(iter++, buf, 1);
+    }else if(*iter == '\'') {
+        iter2 = ++iter;
+        iter = strchrW(iter, '\'');
+        if(!iter) {
+            WARN("Unexpected end of script\n");
+            *str = iter;
+            return DISP_E_EXCEPTION;
+        }
+        strbuf_write(iter2, buf, iter-iter2);
+        iter++;
+    }else {
+        while(*iter && !isspaceW(*iter))
+            iter++;
+        strbuf_write(iter2, buf, iter-iter2);
+    }
+
+    while(isspaceW(*iter))
+        iter++;
+    *str = iter;
+    return S_OK;
+}
+
+static HRESULT do_preprocess(const Registrar *This, LPCOLESTR data, strbuf *buf)
+{
+    LPCOLESTR iter, iter2 = data;
+    rep_list *rep_iter;
+    static const WCHAR wstr[] = {'%',0};
+
+    iter = strchrW(data, '%');
+    while(iter) {
+        strbuf_write(iter2, buf, iter-iter2);
+
+        iter2 = ++iter;
+        if(!*iter2)
+            return DISP_E_EXCEPTION;
+        iter = strchrW(iter2, '%');
+        if(!iter)
+            return DISP_E_EXCEPTION;
+
+        if(iter == iter2) {
+            strbuf_write(wstr, buf, 1);
+        }else {
+            for(rep_iter = This->rep; rep_iter; rep_iter = rep_iter->next) {
+                if(rep_iter->key_len == iter-iter2
+                        && !memicmpW(iter2, rep_iter->key, rep_iter->key_len))
+                    break;
+            }
+            if(!rep_iter) {
+                WARN("Could not find replacement: %s\n", debugstr_wn(iter2, iter-iter2));
+                return DISP_E_EXCEPTION;
+            }
+
+            strbuf_write(rep_iter->item, buf, -1);
+        }
+
+        iter2 = ++iter;
+        iter = strchrW(iter, '%');
+    }
+
+    strbuf_write(iter2, buf, -1);
+    TRACE("%s\n", debugstr_w(buf->str));
+
+    return S_OK;
+}
+
+static HRESULT do_process_key(LPCOLESTR *pstr, HKEY parent_key, strbuf *buf, BOOL do_register)
+{
+    LPCOLESTR iter = *pstr;
+    HRESULT hres;
+    LONG lres;
+    HKEY hkey = 0;
+    strbuf name;
+
+    enum {
+        NORMAL,
+        NO_REMOVE,
+        IS_VAL,
+        FORCE_REMOVE,
+        DO_DELETE
+    } key_type = NORMAL;
+
+    static const WCHAR wstrNoRemove[] = {'N','o','R','e','m','o','v','e',0};
+    static const WCHAR wstrForceRemove[] = {'F','o','r','c','e','R','e','m','o','v','e',0};
+    static const WCHAR wstrDelete[] = {'D','e','l','e','t','e',0};
+    static const WCHAR wstrval[] = {'v','a','l',0};
+
+    iter = *pstr;
+    hres = get_word(&iter, buf);
+    if(FAILED(hres))
+        return hres;
+    strbuf_init(&name);
+
+    while(buf->str[1] || buf->str[0] != '}') {
+        key_type = NORMAL;
+        if(!lstrcmpiW(buf->str, wstrNoRemove))
+            key_type = NO_REMOVE;
+        else if(!lstrcmpiW(buf->str, wstrForceRemove))
+            key_type = FORCE_REMOVE;
+        else if(!lstrcmpiW(buf->str, wstrval))
+            key_type = IS_VAL;
+        else if(!lstrcmpiW(buf->str, wstrDelete))
+            key_type = DO_DELETE;
+
+        if(key_type != NORMAL) {
+            hres = get_word(&iter, buf);
+            if(FAILED(hres))
+                break;
+        }
+        TRACE("name = %s\n", debugstr_w(buf->str));
+
+        if(do_register) {
+            if(key_type == IS_VAL) {
+                hkey = parent_key;
+                strbuf_write(buf->str, &name, -1);
+            }else if(key_type == DO_DELETE) {
+                TRACE("Deleting %s\n", debugstr_w(buf->str));
+                RegDeleteTreeW(parent_key, buf->str);
+            }else {
+                if(key_type == FORCE_REMOVE)
+                    RegDeleteTreeW(parent_key, buf->str);
+                lres = RegCreateKeyW(parent_key, buf->str, &hkey);
+                if(lres != ERROR_SUCCESS) {
+                    WARN("Could not create(open) key: %08x\n", lres);
+                    hres = HRESULT_FROM_WIN32(lres);
+                    break;
+                }
+            }
+        }else if(key_type != IS_VAL && key_type != DO_DELETE) {
+            strbuf_write(buf->str, &name, -1);
+            lres = RegOpenKeyW(parent_key, buf->str, &hkey);
+              if(lres != ERROR_SUCCESS)
+                WARN("Could not open key %s: %08x\n", debugstr_w(name.str), lres);
+        }
+
+        if(key_type != DO_DELETE && *iter == '=') {
+            iter++;
+            hres = get_word(&iter, buf);
+            if(FAILED(hres))
+                break;
+            if(buf->len != 1) {
+                WARN("Wrong registry type: %s\n", debugstr_w(buf->str));
+                hres = DISP_E_EXCEPTION;
+                break;
+            }
+            if(do_register) {
+                switch(buf->str[0]) {
+                case 's':
+                    hres = get_word(&iter, buf);
+                    if(FAILED(hres))
+                        break;
+                    lres = RegSetValueExW(hkey, name.len ? name.str :  NULL, 0, REG_SZ, (PBYTE)buf->str,
+                            (lstrlenW(buf->str)+1)*sizeof(WCHAR));
+                    if(lres != ERROR_SUCCESS) {
+                        WARN("Could set value of key: %08x\n", lres);
+                        hres = HRESULT_FROM_WIN32(lres);
+                        break;
+                    }
+                    break;
+                case 'd': {
+                    DWORD dw;
+                    hres = get_word(&iter, buf);
+                    if(FAILED(hres))
+                        break;
+                    dw = atoiW(buf->str);
+                    lres = RegSetValueExW(hkey, name.len ? name.str :  NULL, 0, REG_DWORD,
+                            (PBYTE)&dw, sizeof(dw));
+                    if(lres != ERROR_SUCCESS) {
+                        WARN("Could set value of key: %08x\n", lres);
+                        hres = HRESULT_FROM_WIN32(lres);
+                        break;
+                    }
+                    break;
+                }
+                case 'b': {
+                    BYTE *bytes;
+                    DWORD count;
+                    DWORD i;
+                    hres = get_word(&iter, buf);
+                    if(FAILED(hres))
+                        break;
+                    count = (lstrlenW(buf->str) + 1) / 2;
+                    bytes = HeapAlloc(GetProcessHeap(), 0, count);
+                    if(bytes == NULL) {
+                        hres = E_OUTOFMEMORY;
+                        break;
+                    }
+                    for(i = 0; i < count && buf->str[2*i]; i++) {
+                        WCHAR digits[3];
+                        if(!isxdigitW(buf->str[2*i]) || !isxdigitW(buf->str[2*i + 1])) {
+                            hres = E_FAIL;
+                            break;
+                        }
+                        digits[0] = buf->str[2*i];
+                        digits[1] = buf->str[2*i + 1];
+                        digits[2] = 0;
+                        bytes[i] = (BYTE) strtoulW(digits, NULL, 16);
+                    }
+                    if(SUCCEEDED(hres)) {
+                        lres = RegSetValueExW(hkey, name.len ? name.str :  NULL, 0, REG_BINARY,
+                            bytes, count);
+                        if(lres != ERROR_SUCCESS) {
+                            WARN("Could not set value of key: 0x%08x\n", lres);
+                            hres = HRESULT_FROM_WIN32(lres);
+                        }
+                    }
+                    HeapFree(GetProcessHeap(), 0, bytes);
+                    break;
+                }
+                default:
+                    WARN("Wrong resource type: %s\n", debugstr_w(buf->str));
+                    hres = DISP_E_EXCEPTION;
+                };
+                if(FAILED(hres))
+                    break;
+            }else {
+                if(*iter == '-')
+                    iter++;
+                hres = get_word(&iter, buf);
+                if(FAILED(hres))
+                    break;
+            }
+        }else if(key_type == IS_VAL) {
+            WARN("value not set!\n");
+            hres = DISP_E_EXCEPTION;
+            break;
+        }
+
+        if(key_type != IS_VAL && key_type != DO_DELETE && *iter == '{' && isspaceW(iter[1])) {
+            hres = get_word(&iter, buf);
+            if(FAILED(hres))
+                break;
+            hres = do_process_key(&iter, hkey, buf, do_register);
+            if(FAILED(hres))
+                break;
+        }
+
+        TRACE("%x %x\n", do_register, key_type);
+        if(!do_register && (key_type == NORMAL || key_type == FORCE_REMOVE)) {
+            TRACE("Deleting %s\n", debugstr_w(name.str));
+            RegDeleteKeyW(parent_key, name.str);
+        }
+
+        if(hkey && key_type != IS_VAL)
+            RegCloseKey(hkey);
+        hkey = 0;
+        name.len = 0;
+
+        hres = get_word(&iter, buf);
+        if(FAILED(hres))
+            break;
+    }
+
+    HeapFree(GetProcessHeap(), 0, name.str);
+    if(hkey && key_type != IS_VAL)
+        RegCloseKey(hkey);
+    *pstr = iter;
+    return hres;
+}
+
+static HRESULT do_process_root_key(LPCOLESTR data, BOOL do_register)
+{
+    LPCOLESTR iter = data;
+    strbuf buf;
+    HRESULT hres = S_OK;
+    unsigned int i;
+
+    strbuf_init(&buf);
+    hres = get_word(&iter, &buf);
+    if(FAILED(hres))
+        return hres;
+
+    while(*iter) {
+        if(!buf.len) {
+            WARN("ward.len == 0, failed\n");
+            hres = DISP_E_EXCEPTION;
+            break;
+        }
+        for(i=0; i<sizeof(root_keys)/sizeof(root_keys[0]); i++) {
+            if(!lstrcmpiW(buf.str, root_keys[i].name))
+                break;
+        }
+        if(i == sizeof(root_keys)/sizeof(root_keys[0])) {
+            WARN("Wrong root key name: %s\n", debugstr_w(buf.str));
+            hres = DISP_E_EXCEPTION;
+            break;
+        }
+        hres = get_word(&iter, &buf);
+        if(FAILED(hres))
+            break;
+        if(buf.str[1] || buf.str[0] != '{') {
+            WARN("Failed, expected '{', got %s\n", debugstr_w(buf.str));
+            hres = DISP_E_EXCEPTION;
+            break;
+        }
+        hres = do_process_key(&iter, root_keys[i].key, &buf, do_register);
+        if(FAILED(hres)) {
+            WARN("Processing key failed: %08x\n", hres);
+            break;
+        }
+        hres = get_word(&iter, &buf);
+        if(FAILED(hres))
+            break;
+    }
+    HeapFree(GetProcessHeap(), 0, buf.str);
+    return hres;
+}
+
+static HRESULT string_register(Registrar *This, LPCOLESTR data, BOOL do_register)
+{
+    strbuf buf;
+    HRESULT hres;
+
+    TRACE("(%p %s %x)\n", This, debugstr_w(data), do_register);
+
+    strbuf_init(&buf);
+    hres = do_preprocess(This, data, &buf);
+    if(FAILED(hres)) {
+        WARN("preprocessing failed!\n");
+        HeapFree(GetProcessHeap(), 0, buf.str);
+        return hres;
+    }
+
+    hres = do_process_root_key(buf.str, do_register);
+    if(FAILED(hres) && do_register)
+        do_process_root_key(buf.str, FALSE);
+
+    HeapFree(GetProcessHeap(), 0, buf.str);
+    return hres;
+}
+
+static HRESULT resource_register(Registrar *This, LPCOLESTR resFileName,
+                        LPCOLESTR szID, LPCOLESTR szType, BOOL do_register)
+{
+    HINSTANCE hins;
+    HRSRC src;
+    LPSTR regstra;
+    LPWSTR regstrw;
+    DWORD len, reslen;
+    HRESULT hres;
+
+    hins = LoadLibraryExW(resFileName, NULL, LOAD_LIBRARY_AS_DATAFILE);
+    if(hins) {
+        src = FindResourceW(hins, szID, szType);
+        if(src) {
+            regstra = LoadResource(hins, src);
+            reslen = SizeofResource(hins, src);
+            if(regstra) {
+                len = MultiByteToWideChar(CP_ACP, 0, regstra, reslen, NULL, 0)+1;
+                regstrw = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len*sizeof(WCHAR));
+                MultiByteToWideChar(CP_ACP, 0, regstra, reslen, regstrw, len);
+                regstrw[len-1] = '\0';
+
+                hres = string_register(This, regstrw, do_register);
+
+                HeapFree(GetProcessHeap(), 0, regstrw);
+            }else {
+                WARN("could not load resource\n");
+                hres = HRESULT_FROM_WIN32(GetLastError());
+            }
+        }else {
+            WARN("Could not find source\n");
+            hres = HRESULT_FROM_WIN32(GetLastError());
+        }
+        FreeLibrary(hins);
+    }else {
+        WARN("Could not load resource file\n");
+        hres = HRESULT_FROM_WIN32(GetLastError());
+    }
+
+    return hres;
+}
+
+static HRESULT file_register(Registrar *This, LPCOLESTR fileName, BOOL do_register)
+{
+    HANDLE file;
+    DWORD filelen, len;
+    LPWSTR regstrw;
+    LPSTR regstra;
+    LRESULT lres;
+    HRESULT hres;
+
+    file = CreateFileW(fileName, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL);
+    if(file != INVALID_HANDLE_VALUE) {
+        filelen = GetFileSize(file, NULL);
+        regstra = HeapAlloc(GetProcessHeap(), 0, filelen);
+        lres = ReadFile(file, regstra, filelen, NULL, NULL);
+        if(lres == ERROR_SUCCESS) {
+            len = MultiByteToWideChar(CP_ACP, 0, regstra, filelen, NULL, 0)+1;
+            regstrw = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len*sizeof(WCHAR));
+            MultiByteToWideChar(CP_ACP, 0, regstra, filelen, regstrw, len);
+            regstrw[len-1] = '\0';
+
+            hres = string_register(This, regstrw, do_register);
+
+            HeapFree(GetProcessHeap(), 0, regstrw);
+        }else {
+            WARN("Failed to read faile\n");
+            hres = HRESULT_FROM_WIN32(lres);
+        }
+        HeapFree(GetProcessHeap(), 0, regstra);
+        CloseHandle(file);
+    }else {
+        WARN("Could not open file\n");
+        hres = HRESULT_FROM_WIN32(GetLastError());
+    }
+
+    return hres;
+}
+
+static HRESULT WINAPI Registrar_QueryInterface(IRegistrar *iface, REFIID riid, void **ppvObject)
+{
+    TRACE("(%p)->(%s %p\n", iface, debugstr_guid(riid), ppvObject);
+
+    if(IsEqualGUID(&IID_IUnknown, riid)
+       || IsEqualGUID(&IID_IRegistrar, riid)
+       || IsEqualGUID(&IID_IRegistrarBase, riid)) {
+        IRegistrar_AddRef(iface);
+        *ppvObject = iface;
+        return S_OK;
+    }
+    return E_NOINTERFACE;
+}
+
+static ULONG WINAPI Registrar_AddRef(IRegistrar *iface)
+{
+    Registrar *This = impl_from_IRegistrar(iface);
+    ULONG ref = InterlockedIncrement(&This->ref);
+    TRACE("(%p) ->%d\n", This, ref);
+    return ref;
+}
+
+static ULONG WINAPI Registrar_Release(IRegistrar *iface)
+{
+    Registrar *This = impl_from_IRegistrar(iface);
+    ULONG ref = InterlockedDecrement(&This->ref);
+
+    TRACE("(%p) ->%d\n", This, ref);
+    if(!ref) {
+        IRegistrar_ClearReplacements(iface);
+        HeapFree(GetProcessHeap(), 0, This);
+    }
+    return ref;
+}
+
+static HRESULT WINAPI Registrar_AddReplacement(IRegistrar *iface, LPCOLESTR Key, LPCOLESTR item)
+{
+    Registrar *This = impl_from_IRegistrar(iface);
+    int len;
+    rep_list *new_rep;
+
+    TRACE("(%p)->(%s %s)\n", This, debugstr_w(Key), debugstr_w(item));
+
+    new_rep = HeapAlloc(GetProcessHeap(), 0, sizeof(rep_list));
+
+    new_rep->key_len  = lstrlenW(Key);
+    new_rep->key = HeapAlloc(GetProcessHeap(), 0, (new_rep->key_len + 1) * sizeof(OLECHAR));
+    memcpy(new_rep->key, Key, (new_rep->key_len+1)*sizeof(OLECHAR));
+
+    len = lstrlenW(item)+1;
+    new_rep->item = HeapAlloc(GetProcessHeap(), 0, len*sizeof(OLECHAR));
+    memcpy(new_rep->item, item, len*sizeof(OLECHAR));
+
+    new_rep->next = This->rep;
+    This->rep = new_rep;
+
+    return S_OK;
+}
+
+static HRESULT WINAPI Registrar_ClearReplacements(IRegistrar *iface)
+{
+    Registrar *This = impl_from_IRegistrar(iface);
+    rep_list *iter, *iter2;
+
+    TRACE("(%p)\n", This);
+
+    if(!This->rep)
+        return S_OK;
+
+    iter = This->rep;
+    while(iter) {
+        iter2 = iter->next;
+        HeapFree(GetProcessHeap(), 0, iter->key);
+        HeapFree(GetProcessHeap(), 0, iter->item);
+        HeapFree(GetProcessHeap(), 0, iter);
+        iter = iter2;
+    }
+
+    This->rep = NULL;
+    return S_OK;
+}
+
+static HRESULT WINAPI Registrar_ResourceRegisterSz(IRegistrar* iface, LPCOLESTR resFileName,
+                LPCOLESTR szID, LPCOLESTR szType)
+{
+    Registrar *This = impl_from_IRegistrar(iface);
+    TRACE("(%p)->(%s %s %s)\n", This, debugstr_w(resFileName), debugstr_w(szID), debugstr_w(szType));
+    return resource_register(This, resFileName, szID, szType, TRUE);
+}
+
+static HRESULT WINAPI Registrar_ResourceUnregisterSz(IRegistrar* iface, LPCOLESTR resFileName,
+                LPCOLESTR szID, LPCOLESTR szType)
+{
+    Registrar *This = impl_from_IRegistrar(iface);
+    TRACE("(%p)->(%s %s %s)\n", This, debugstr_w(resFileName), debugstr_w(szID), debugstr_w(szType));
+    return resource_register(This, resFileName, szID, szType, FALSE);
+}
+
+static HRESULT WINAPI Registrar_FileRegister(IRegistrar* iface, LPCOLESTR fileName)
+{
+    Registrar *This = impl_from_IRegistrar(iface);
+    TRACE("(%p)->(%s)\n", This, debugstr_w(fileName));
+    return file_register(This, fileName, TRUE);
+}
+
+static HRESULT WINAPI Registrar_FileUnregister(IRegistrar* iface, LPCOLESTR fileName)
+{
+    Registrar *This = impl_from_IRegistrar(iface);
+    FIXME("(%p)->(%s)\n", This, debugstr_w(fileName));
+    return file_register(This, fileName, FALSE);
+}
+
+static HRESULT WINAPI Registrar_StringRegister(IRegistrar* iface, LPCOLESTR data)
+{
+    Registrar *This = impl_from_IRegistrar(iface);
+    TRACE("(%p)->(%s)\n", This, debugstr_w(data));
+    return string_register(This, data, TRUE);
+}
+
+static HRESULT WINAPI Registrar_StringUnregister(IRegistrar* iface, LPCOLESTR data)
+{
+    Registrar *This = impl_from_IRegistrar(iface);
+    TRACE("(%p)->(%s)\n", This, debugstr_w(data));
+    return string_register(This, data, FALSE);
+}
+
+static HRESULT WINAPI Registrar_ResourceRegister(IRegistrar* iface, LPCOLESTR resFileName,
+                UINT nID, LPCOLESTR szType)
+{
+    Registrar *This = impl_from_IRegistrar(iface);
+    TRACE("(%p)->(%s %d %s)\n", iface, debugstr_w(resFileName), nID, debugstr_w(szType));
+    return resource_register(This, resFileName, MAKEINTRESOURCEW(nID), szType, TRUE);
+}
+
+static HRESULT WINAPI Registrar_ResourceUnregister(IRegistrar* iface, LPCOLESTR resFileName,
+                UINT nID, LPCOLESTR szType)
+{
+    Registrar *This = impl_from_IRegistrar(iface);
+    TRACE("(%p)->(%s %d %s)\n", This, debugstr_w(resFileName), nID, debugstr_w(szType));
+    return resource_register(This, resFileName, MAKEINTRESOURCEW(nID), szType, FALSE);
+}
+
+static const IRegistrarVtbl RegistrarVtbl = {
+    Registrar_QueryInterface,
+    Registrar_AddRef,
+    Registrar_Release,
+    Registrar_AddReplacement,
+    Registrar_ClearReplacements,
+    Registrar_ResourceRegisterSz,
+    Registrar_ResourceUnregisterSz,
+    Registrar_FileRegister,
+    Registrar_FileUnregister,
+    Registrar_StringRegister,
+    Registrar_StringUnregister,
+    Registrar_ResourceRegister,
+    Registrar_ResourceUnregister,
+};
+
+/***********************************************************************
+ *           AtlCreateRegistrar              [atl100.@]
+ */
+HRESULT WINAPI AtlCreateRegistrar(IRegistrar **ret)
+{
+    Registrar *registrar;
+
+    registrar = HeapAlloc(GetProcessHeap(), 0, sizeof(*registrar));
+    if(!registrar)
+        return E_OUTOFMEMORY;
+
+    registrar->IRegistrar_iface.lpVtbl = &RegistrarVtbl;
+    registrar->ref = 1;
+    registrar->rep = NULL;
+
+    *ret = &registrar->IRegistrar_iface;
+    return S_OK;
+}
index cbdae28..78d8518 100644 (file)
@@ -24,17 +24,25 @@ cpp_quote("#endif")
 
 [
     object,
-    oleautomation,
-    uuid(44EC053B-400F-11D0-9DCD-00A0C90391D3)
+    uuid(e21f8a85-b05d-4243-8183-c7cb405588f7),
+    pointer_default(unique)
 ]
-interface IRegistrar : IUnknown
+interface IRegistrarBase : IUnknown
 {
     HRESULT AddReplacement(
         [in] LPCOLESTR Key,
         [in] LPCOLESTR item);
 
     HRESULT ClearReplacements();
+}
 
+[
+    object,
+    uuid(44EC053B-400F-11D0-9DCD-00A0C90391D3),
+    pointer_default(unique)
+]
+interface IRegistrar : IRegistrarBase
+{
     HRESULT ResourceRegisterSz(
         [in] LPCOLESTR resFileName,
         [in] LPCOLESTR szID,
similarity index 98%
rename from reactos/dll/win32/atl/atlbase.h
rename to reactos/include/reactos/wine/atlbase.h
index 59cdddf..4033f9a 100644 (file)
@@ -21,9 +21,7 @@
 #ifndef __WINE_ATLBASE_H__
 #define __WINE_ATLBASE_H__
 
-#define COBJMACROS
-
-#include "atliface.h"
+#include <atliface.h>
 
 typedef HRESULT (WINAPI _ATL_CREATORFUNC)(void* pv, REFIID riid, LPVOID* ppv);
 typedef HRESULT (WINAPI _ATL_CREATORARGFUNC)(void* pv, REFIID riid, LPVOID* ppv, DWORD dw);
@@ -184,5 +182,6 @@ HRESULT WINAPI AtlModuleUnregisterServerEx(_ATL_MODULEW* pM, BOOL bUnRegTypeLib,
 HRESULT WINAPI AtlModuleTerm(_ATL_MODULEW* pM);
 HRESULT WINAPI AtlUnadvise(IUnknown *pUnkCP, const IID * iid, DWORD dw);
 HRESULT WINAPI AtlUnmarshalPtr(IStream *pStream, const IID *iid, IUnknown **ppUnk);
+HRESULT WINAPI AtlCreateRegistrar(IRegistrar**);
 
 #endif /* __WINE_ATLBASE_H__ */
index 1ed278c..1c20641 100644 (file)
@@ -40,7 +40,8 @@ reactos/dll/directx/quartz        # Autosync
 reactos/dll/win32/activeds        # Synced to Wine-1.1.43?
 reactos/dll/win32/actxprxy        # Synced to Wine-1.3.29?
 reactos/dll/win32/advpack         # Synced to Wine-1.5.19
-reactos/dll/win32/atl             # Synced to Wine-1.3.37
+reactos/dll/win32/atl             # Synced to Wine-1.5.19
+reactos/dll/win32/atl100          # Synced to Wine-1.5.19
 reactos/dll/win32/avifil32        # Synced to Wine-1.3.37
 reactos/dll/win32/bcrypt          # Synced to Wine-1.5.19
 reactos/dll/win32/browseui        # Out of sync