[2/2] scrrun: Added IDispatch support for IFileSystem3
Nikolay Sivov
nsivov at codeweavers.com
Thu Jul 12 02:02:47 CDT 2012
For http://bugs.winehq.org/show_bug.cgi?id=9638 and similar cases
-------------- next part --------------
>From 775c428950d43068f5f8c99f641984537391db75 Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <nsivov at codeweavers.com>
Date: Thu, 12 Jul 2012 10:58:39 +0400
Subject: [PATCH 2/2] Added IDispatch support for IFileSystem3
---
dlls/scrrun/Makefile.in | 2 +-
dlls/scrrun/filesystem.c | 58 +++++++++++++++++++++++++-----------
dlls/scrrun/scrrun.c | 67 ++++++++++++++++++++++++++++++++++++++++++
dlls/scrrun/scrrun_private.h | 34 +++++++++++++++++++++
4 files changed, 142 insertions(+), 19 deletions(-)
create mode 100644 dlls/scrrun/scrrun_private.h
diff --git a/dlls/scrrun/Makefile.in b/dlls/scrrun/Makefile.in
index d2ceb87..f6dcf62 100644
--- a/dlls/scrrun/Makefile.in
+++ b/dlls/scrrun/Makefile.in
@@ -1,5 +1,5 @@
MODULE = scrrun.dll
-IMPORTS = uuid
+IMPORTS = uuid oleaut32
C_SRCS = \
filesystem.c \
diff --git a/dlls/scrrun/filesystem.c b/dlls/scrrun/filesystem.c
index 75c84da..0039306 100644
--- a/dlls/scrrun/filesystem.c
+++ b/dlls/scrrun/filesystem.c
@@ -25,7 +25,9 @@
#include "winbase.h"
#include "ole2.h"
#include "dispex.h"
+#include "oleauto.h"
#include "scrrun.h"
+#include "scrrun_private.h"
#include "wine/debug.h"
@@ -87,33 +89,53 @@ static HRESULT WINAPI filesys_GetTypeInfoCount(IFileSystem3 *iface, UINT *pctinf
return S_OK;
}
-static HRESULT WINAPI filesys_GetTypeInfo(IFileSystem3 *iface, UINT iTInfo,
- LCID lcid, ITypeInfo **ppTInfo)
+static HRESULT WINAPI filesys_GetTypeInfo(IFileSystem3 *iface, UINT index, LCID lcid, ITypeInfo **typeinfo)
{
- FIXME("(%p)->(%u %u %p)\n", iface, iTInfo, lcid, ppTInfo);
-
- return E_NOTIMPL;
+ TRACE("(%p)->(%u %u %p)\n", iface, index, lcid, typeinfo);
+ return get_typeinfo(IFileSystem3_tid, typeinfo);
}
static HRESULT WINAPI filesys_GetIDsOfNames(IFileSystem3 *iface, REFIID riid,
- LPOLESTR *rgszNames, UINT cNames,
- LCID lcid, DISPID *rgDispId)
+ LPOLESTR *names, UINT count,
+ LCID lcid, DISPID *dispid)
{
- FIXME("(%p)->(%s %p %u %u %p)\n", iface, debugstr_guid(riid), rgszNames, cNames,
- lcid, rgDispId);
+ ITypeInfo *typeinfo;
+ HRESULT hr;
- return E_NOTIMPL;
+ TRACE("(%p)->(%s %p %u %u %p)\n", iface, debugstr_guid(riid), names, count, lcid, dispid);
+
+ if(!names || count == 0 || !dispid)
+ return E_INVALIDARG;
+
+ hr = get_typeinfo(IFileSystem3_tid, &typeinfo);
+ if (SUCCEEDED(hr))
+ {
+ hr = ITypeInfo_GetIDsOfNames(typeinfo, names, count, dispid);
+ ITypeInfo_Release(typeinfo);
+ }
+
+ return hr;
}
-static HRESULT WINAPI filesys_Invoke(IFileSystem3 *iface, DISPID dispIdMember,
- REFIID riid, LCID lcid, WORD wFlags,
- DISPPARAMS *pDispParams, VARIANT *pVarResult,
- EXCEPINFO *pExcepInfo, UINT *puArgErr)
+static HRESULT WINAPI filesys_Invoke(IFileSystem3 *iface, DISPID member,
+ REFIID riid, LCID lcid, WORD flags,
+ DISPPARAMS *params, VARIANT *result,
+ EXCEPINFO *excep_info, UINT *arg_err)
{
- FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", iface, dispIdMember, debugstr_guid(riid),
- lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
+ ITypeInfo *typeinfo;
+ HRESULT hr;
- return E_NOTIMPL;
+ TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", iface, member, debugstr_guid(riid),
+ lcid, flags, params, result, excep_info, arg_err);
+
+ hr = get_typeinfo(IFileSystem3_tid, &typeinfo);
+ if (SUCCEEDED(hr))
+ {
+ hr = ITypeInfo_Invoke(typeinfo, iface, member, flags, params, result, excep_info, arg_err);
+ ITypeInfo_Release(typeinfo);
+ }
+
+ return hr;
}
static HRESULT WINAPI filesys_get_Drives(IFileSystem3 *iface, IDriveCollection **ppdrives)
@@ -196,7 +218,7 @@ static HRESULT WINAPI filesys_DriveExists(IFileSystem3 *iface, BSTR DriveSpec,
static HRESULT WINAPI filesys_FileExists(IFileSystem3 *iface, BSTR path, VARIANT_BOOL *ret)
{
- TRACE("%p %s %p\n", iface, debugstr_w(path), ret);
+ TRACE("(%p)->(%s %p)\n", iface, debugstr_w(path), ret);
if (!ret) return E_POINTER;
diff --git a/dlls/scrrun/scrrun.c b/dlls/scrrun/scrrun.c
index d1e2de2..2577049 100644
--- a/dlls/scrrun/scrrun.c
+++ b/dlls/scrrun/scrrun.c
@@ -27,6 +27,7 @@
#include <initguid.h>
#include "scrrun.h"
+#include "scrrun_private.h"
#include "wine/debug.h"
@@ -34,6 +35,71 @@ WINE_DEFAULT_DEBUG_CHANNEL(scrrun);
static HINSTANCE scrrun_instance;
+static REFIID tid_ids[] = {
+ &IID_NULL,
+ &IID_IFileSystem3,
+};
+
+static ITypeLib *typelib;
+static ITypeInfo *typeinfos[LAST_tid];
+
+static HRESULT load_typelib(void)
+{
+ HRESULT hres;
+ ITypeLib *tl;
+
+ hres = LoadRegTypeLib(&LIBID_Scripting, 1, 0, LOCALE_SYSTEM_DEFAULT, &tl);
+ if(FAILED(hres)) {
+ ERR("LoadRegTypeLib failed: %08x\n", hres);
+ return hres;
+ }
+
+ if(InterlockedCompareExchangePointer((void**)&typelib, tl, NULL))
+ ITypeLib_Release(tl);
+ return hres;
+}
+
+HRESULT get_typeinfo(tid_t tid, ITypeInfo **typeinfo)
+{
+ HRESULT hres;
+
+ if (!typelib)
+ hres = load_typelib();
+ if (!typelib)
+ return hres;
+
+ if(!typeinfos[tid]) {
+ ITypeInfo *ti;
+
+ hres = ITypeLib_GetTypeInfoOfGuid(typelib, tid_ids[tid], &ti);
+ if(FAILED(hres)) {
+ ERR("GetTypeInfoOfGuid(%s) failed: %08x\n", debugstr_guid(tid_ids[tid]), hres);
+ return hres;
+ }
+
+ if(InterlockedCompareExchangePointer((void**)(typeinfos+tid), ti, NULL))
+ ITypeInfo_Release(ti);
+ }
+
+ *typeinfo = typeinfos[tid];
+ return S_OK;
+}
+
+static
+void release_typelib(void)
+{
+ unsigned i;
+
+ if(!typelib)
+ return;
+
+ for(i=0; i < sizeof(typeinfos)/sizeof(*typeinfos); i++)
+ if(typeinfos[i])
+ ITypeInfo_Release(typeinfos[i]);
+
+ ITypeLib_Release(typelib);
+}
+
typedef HRESULT (*fnCreateInstance)(LPVOID *ppObj);
extern HRESULT WINAPI FileSystem_CreateInstance(IClassFactory*,IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
@@ -101,6 +167,7 @@ BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved )
scrrun_instance = hinst;
break;
case DLL_PROCESS_DETACH:
+ release_typelib();
break;
}
return TRUE;
diff --git a/dlls/scrrun/scrrun_private.h b/dlls/scrrun/scrrun_private.h
new file mode 100644
index 0000000..79260de
--- /dev/null
+++ b/dlls/scrrun/scrrun_private.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2012 Nikolay Sivov for CodeWeavers
+ *
+ * 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
+ */
+
+#include <stdarg.h>
+
+#define COBJMACROS
+
+#include "windef.h"
+#include "winbase.h"
+#include "ole2.h"
+
+/* typelibs */
+typedef enum tid_t {
+ NULL_tid,
+ IFileSystem3_tid,
+ LAST_tid
+} tid_t;
+
+HRESULT get_typeinfo(tid_t tid, ITypeInfo **typeinfo) DECLSPEC_HIDDEN;
--
1.5.6.5
More information about the wine-patches
mailing list