[WSHOM.OCX] Sync with Wine Staging 2.2. CORE-12823

722c28c wshom: Added IProvideClassInfo support for implemented interfaces.

svn path=/trunk/; revision=73985
This commit is contained in:
Amine Khaldi 2017-02-26 20:33:41 +00:00
parent 70855a91fa
commit bb881d4570
6 changed files with 158 additions and 32 deletions

View file

@ -25,16 +25,23 @@
#include <wine/unicode.h>
static IWshShell3 WshShell3;
typedef struct
{
struct provideclassinfo classinfo;
IWshShell3 IWshShell3_iface;
} WshShellImpl;
static WshShellImpl WshShell3;
typedef struct
{
struct provideclassinfo classinfo;
IWshCollection IWshCollection_iface;
LONG ref;
} WshCollection;
typedef struct
{
struct provideclassinfo classinfo;
IWshShortcut IWshShortcut_iface;
LONG ref;
@ -44,16 +51,18 @@ typedef struct
typedef struct
{
struct provideclassinfo classinfo;
IWshEnvironment IWshEnvironment_iface;
LONG ref;
} WshEnvironment;
typedef struct
{
struct provideclassinfo classinfo;
IWshExec IWshExec_iface;
LONG ref;
PROCESS_INFORMATION info;
} WshExec;
} WshExecImpl;
static inline WshCollection *impl_from_IWshCollection( IWshCollection *iface )
{
@ -70,14 +79,14 @@ static inline WshEnvironment *impl_from_IWshEnvironment( IWshEnvironment *iface
return CONTAINING_RECORD(iface, WshEnvironment, IWshEnvironment_iface);
}
static inline WshExec *impl_from_IWshExec( IWshExec *iface )
static inline WshExecImpl *impl_from_IWshExec( IWshExec *iface )
{
return CONTAINING_RECORD(iface, WshExec, IWshExec_iface);
return CONTAINING_RECORD(iface, WshExecImpl, IWshExec_iface);
}
static HRESULT WINAPI WshExec_QueryInterface(IWshExec *iface, REFIID riid, void **obj)
{
WshExec *This = impl_from_IWshExec(iface);
WshExecImpl *This = impl_from_IWshExec(iface);
TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), obj);
@ -86,19 +95,24 @@ static HRESULT WINAPI WshExec_QueryInterface(IWshExec *iface, REFIID riid, void
IsEqualGUID(riid, &IID_IUnknown))
{
*obj = iface;
}else {
}
else if (IsEqualIID(riid, &IID_IProvideClassInfo))
{
*obj = &This->classinfo.IProvideClassInfo_iface;
}
else {
FIXME("Unknown iface %s\n", debugstr_guid(riid));
*obj = NULL;
return E_NOINTERFACE;
}
IWshExec_AddRef(iface);
IUnknown_AddRef((IUnknown *)*obj);
return S_OK;
}
static ULONG WINAPI WshExec_AddRef(IWshExec *iface)
{
WshExec *This = impl_from_IWshExec(iface);
WshExecImpl *This = impl_from_IWshExec(iface);
LONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) ref = %d\n", This, ref);
return ref;
@ -106,7 +120,7 @@ static ULONG WINAPI WshExec_AddRef(IWshExec *iface)
static ULONG WINAPI WshExec_Release(IWshExec *iface)
{
WshExec *This = impl_from_IWshExec(iface);
WshExecImpl *This = impl_from_IWshExec(iface);
LONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) ref = %d\n", This, ref);
@ -121,7 +135,7 @@ static ULONG WINAPI WshExec_Release(IWshExec *iface)
static HRESULT WINAPI WshExec_GetTypeInfoCount(IWshExec *iface, UINT *pctinfo)
{
WshExec *This = impl_from_IWshExec(iface);
WshExecImpl *This = impl_from_IWshExec(iface);
TRACE("(%p)->(%p)\n", This, pctinfo);
*pctinfo = 1;
return S_OK;
@ -129,7 +143,7 @@ static HRESULT WINAPI WshExec_GetTypeInfoCount(IWshExec *iface, UINT *pctinfo)
static HRESULT WINAPI WshExec_GetTypeInfo(IWshExec *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
{
WshExec *This = impl_from_IWshExec(iface);
WshExecImpl *This = impl_from_IWshExec(iface);
TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
return get_typeinfo(IWshExec_tid, ppTInfo);
}
@ -137,7 +151,7 @@ static HRESULT WINAPI WshExec_GetTypeInfo(IWshExec *iface, UINT iTInfo, LCID lci
static HRESULT WINAPI WshExec_GetIDsOfNames(IWshExec *iface, REFIID riid, LPOLESTR *rgszNames,
UINT cNames, LCID lcid, DISPID *rgDispId)
{
WshExec *This = impl_from_IWshExec(iface);
WshExecImpl *This = impl_from_IWshExec(iface);
ITypeInfo *typeinfo;
HRESULT hr;
@ -156,7 +170,7 @@ static HRESULT WINAPI WshExec_GetIDsOfNames(IWshExec *iface, REFIID riid, LPOLES
static HRESULT WINAPI WshExec_Invoke(IWshExec *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
{
WshExec *This = impl_from_IWshExec(iface);
WshExecImpl *This = impl_from_IWshExec(iface);
ITypeInfo *typeinfo;
HRESULT hr;
@ -176,7 +190,7 @@ static HRESULT WINAPI WshExec_Invoke(IWshExec *iface, DISPID dispIdMember, REFII
static HRESULT WINAPI WshExec_get_Status(IWshExec *iface, WshExecStatus *status)
{
WshExec *This = impl_from_IWshExec(iface);
WshExecImpl *This = impl_from_IWshExec(iface);
DWORD code;
TRACE("(%p)->(%p)\n", This, status);
@ -204,7 +218,7 @@ static HRESULT WINAPI WshExec_get_Status(IWshExec *iface, WshExecStatus *status)
static HRESULT WINAPI WshExec_get_StdIn(IWshExec *iface, ITextStream **stream)
{
WshExec *This = impl_from_IWshExec(iface);
WshExecImpl *This = impl_from_IWshExec(iface);
FIXME("(%p)->(%p): stub\n", This, stream);
@ -213,7 +227,7 @@ static HRESULT WINAPI WshExec_get_StdIn(IWshExec *iface, ITextStream **stream)
static HRESULT WINAPI WshExec_get_StdOut(IWshExec *iface, ITextStream **stream)
{
WshExec *This = impl_from_IWshExec(iface);
WshExecImpl *This = impl_from_IWshExec(iface);
FIXME("(%p)->(%p): stub\n", This, stream);
@ -222,7 +236,7 @@ static HRESULT WINAPI WshExec_get_StdOut(IWshExec *iface, ITextStream **stream)
static HRESULT WINAPI WshExec_get_StdErr(IWshExec *iface, ITextStream **stream)
{
WshExec *This = impl_from_IWshExec(iface);
WshExecImpl *This = impl_from_IWshExec(iface);
FIXME("(%p)->(%p): stub\n", This, stream);
@ -231,7 +245,7 @@ static HRESULT WINAPI WshExec_get_StdErr(IWshExec *iface, ITextStream **stream)
static HRESULT WINAPI WshExec_get_ProcessID(IWshExec *iface, DWORD *pid)
{
WshExec *This = impl_from_IWshExec(iface);
WshExecImpl *This = impl_from_IWshExec(iface);
TRACE("(%p)->(%p)\n", This, pid);
@ -244,7 +258,7 @@ static HRESULT WINAPI WshExec_get_ProcessID(IWshExec *iface, DWORD *pid)
static HRESULT WINAPI WshExec_get_ExitCode(IWshExec *iface, DWORD *code)
{
WshExec *This = impl_from_IWshExec(iface);
WshExecImpl *This = impl_from_IWshExec(iface);
FIXME("(%p)->(%p): stub\n", This, code);
@ -263,7 +277,7 @@ static BOOL CALLBACK enum_thread_wnd_proc(HWND hwnd, LPARAM lParam)
static HRESULT WINAPI WshExec_Terminate(IWshExec *iface)
{
WshExec *This = impl_from_IWshExec(iface);
WshExecImpl *This = impl_from_IWshExec(iface);
BOOL ret, kill = FALSE;
INT count = 0;
@ -304,7 +318,7 @@ static const IWshExecVtbl WshExecVtbl = {
static HRESULT WshExec_create(BSTR command, IWshExec **ret)
{
STARTUPINFOW si = {0};
WshExec *This;
WshExecImpl *This;
*ret = NULL;
@ -320,6 +334,7 @@ static HRESULT WshExec_create(BSTR command, IWshExec **ret)
return HRESULT_FROM_WIN32(GetLastError());
}
init_classinfo(&CLSID_WshExec, (IUnknown *)&This->IWshExec_iface, &This->classinfo);
*ret = &This->IWshExec_iface;
return S_OK;
}
@ -335,7 +350,12 @@ static HRESULT WINAPI WshEnvironment_QueryInterface(IWshEnvironment *iface, REFI
IsEqualGUID(riid, &IID_IWshEnvironment))
{
*obj = iface;
}else {
}
else if (IsEqualIID(riid, &IID_IProvideClassInfo))
{
*obj = &This->classinfo.IProvideClassInfo_iface;
}
else {
FIXME("Unknown iface %s\n", debugstr_guid(riid));
*obj = NULL;
return E_NOINTERFACE;
@ -502,6 +522,7 @@ static HRESULT WshEnvironment_Create(IWshEnvironment **env)
This->IWshEnvironment_iface.lpVtbl = &WshEnvironmentVtbl;
This->ref = 1;
init_classinfo(&IID_IWshEnvironment, (IUnknown *)&This->IWshEnvironment_iface, &This->classinfo);
*env = &This->IWshEnvironment_iface;
return S_OK;
@ -518,7 +539,12 @@ static HRESULT WINAPI WshCollection_QueryInterface(IWshCollection *iface, REFIID
IsEqualGUID(riid, &IID_IWshCollection))
{
*ppv = iface;
}else {
}
else if (IsEqualIID(riid, &IID_IProvideClassInfo))
{
*ppv = &This->classinfo.IProvideClassInfo_iface;
}
else {
FIXME("Unknown iface %s\n", debugstr_guid(riid));
*ppv = NULL;
return E_NOINTERFACE;
@ -698,6 +724,7 @@ static HRESULT WshCollection_Create(IWshCollection **collection)
This->IWshCollection_iface.lpVtbl = &WshCollectionVtbl;
This->ref = 1;
init_classinfo(&IID_IWshCollection, (IUnknown *)&This->IWshCollection_iface, &This->classinfo);
*collection = &This->IWshCollection_iface;
return S_OK;
@ -715,7 +742,12 @@ static HRESULT WINAPI WshShortcut_QueryInterface(IWshShortcut *iface, REFIID rii
IsEqualGUID(riid, &IID_IWshShortcut))
{
*ppv = iface;
}else {
}
else if (IsEqualIID(riid, &IID_IProvideClassInfo))
{
*ppv = &This->classinfo.IProvideClassInfo_iface;
}
else {
FIXME("Unknown iface %s\n", debugstr_guid(riid));
*ppv = NULL;
return E_NOINTERFACE;
@ -1064,6 +1096,7 @@ static HRESULT WshShortcut_Create(const WCHAR *path, IDispatch **shortcut)
return E_OUTOFMEMORY;
}
init_classinfo(&IID_IWshShortcut, (IUnknown *)&This->IWshShortcut_iface, &This->classinfo);
*shortcut = (IDispatch*)&This->IWshShortcut_iface;
return S_OK;
@ -1087,13 +1120,17 @@ static HRESULT WINAPI WshShell3_QueryInterface(IWshShell3 *iface, REFIID riid, v
{
return E_NOINTERFACE;
}
else if (IsEqualIID(riid, &IID_IProvideClassInfo))
{
*ppv = &WshShell3.classinfo.IProvideClassInfo_iface;
}
else
{
WARN("unknown iface %s\n", debugstr_guid(riid));
return E_NOINTERFACE;
}
IWshShell3_AddRef(iface);
IUnknown_AddRef((IUnknown *)*ppv);
return S_OK;
}
@ -1654,11 +1691,11 @@ static const IWshShell3Vtbl WshShell3Vtbl = {
WshShell3_put_CurrentDirectory
};
static IWshShell3 WshShell3 = { &WshShell3Vtbl };
HRESULT WINAPI WshShellFactory_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
{
TRACE("(%p %s %p)\n", outer, debugstr_guid(riid), ppv);
return IWshShell3_QueryInterface(&WshShell3, riid, ppv);
WshShell3.IWshShell3_iface.lpVtbl = &WshShell3Vtbl;
init_classinfo(&IID_IWshShell3, (IUnknown *)&WshShell3.IWshShell3_iface, &WshShell3.classinfo);
return IWshShell3_QueryInterface(&WshShell3.IWshShell3_iface, riid, ppv);
}

View file

@ -663,4 +663,12 @@ library IWshRuntimeLibrary
coclass WshNetwork {
[default] interface IWshNetwork2;
}
[
uuid(08fed191-be19-11d3-a28b-00104bd35090),
threading(apartment)
]
coclass WshExec {
[default] interface IWshExec;
}
}

View file

@ -132,6 +132,12 @@ HKCR
Version = s '1.0'
VersionIndependentProgId = s 'WScript.Network'
}
'{08FED191-BE19-11D3-A28B-00104BD35090}' = s 'WshExec'
{
InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Apartment' }
TypeLib = s '{F935DC20-1CF0-11D0-ADB9-00C04FD58A0B}'
Version = s '1.0'
}
}
'WScript.Shell.1' = s 'Windows Script Host Shell Object'
{

View file

@ -22,6 +22,11 @@
static HINSTANCE wshom_instance;
static inline struct provideclassinfo *impl_from_IProvideClassInfo(IProvideClassInfo *iface)
{
return CONTAINING_RECORD(iface, struct provideclassinfo, IProvideClassInfo_iface);
}
static ITypeLib *typelib;
static ITypeInfo *typeinfos[LAST_tid];
@ -39,6 +44,9 @@ static HRESULT load_typelib(void)
HRESULT hres;
ITypeLib *tl;
if(typelib)
return S_OK;
hres = LoadRegTypeLib(&LIBID_IWshRuntimeLibrary, 1, 0, LOCALE_SYSTEM_DEFAULT, &tl);
if(FAILED(hres)) {
ERR("LoadRegTypeLib failed: %08x\n", hres);
@ -50,13 +58,21 @@ static HRESULT load_typelib(void)
return hres;
}
static HRESULT get_typeinfo_of_guid(const GUID *guid, ITypeInfo **tinfo)
{
HRESULT hres;
if(FAILED(hres = load_typelib()))
return hres;
return ITypeLib_GetTypeInfoOfGuid(typelib, guid, tinfo);
}
HRESULT get_typeinfo(tid_t tid, ITypeInfo **typeinfo)
{
HRESULT hres;
if (!typelib)
hres = load_typelib();
if (!typelib)
if (FAILED(hres = load_typelib()))
return hres;
if(!typeinfos[tid]) {
@ -92,6 +108,56 @@ void release_typelib(void)
ITypeLib_Release(typelib);
}
static HRESULT WINAPI provideclassinfo_QueryInterface(IProvideClassInfo *iface, REFIID riid, void **obj)
{
struct provideclassinfo *This = impl_from_IProvideClassInfo(iface);
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), obj);
if (IsEqualIID(riid, &IID_IProvideClassInfo)) {
*obj = iface;
IProvideClassInfo_AddRef(iface);
return S_OK;
}
else
return IUnknown_QueryInterface(This->outer, riid, obj);
}
static ULONG WINAPI provideclassinfo_AddRef(IProvideClassInfo *iface)
{
struct provideclassinfo *This = impl_from_IProvideClassInfo(iface);
return IUnknown_AddRef(This->outer);
}
static ULONG WINAPI provideclassinfo_Release(IProvideClassInfo *iface)
{
struct provideclassinfo *This = impl_from_IProvideClassInfo(iface);
return IUnknown_Release(This->outer);
}
static HRESULT WINAPI provideclassinfo_GetClassInfo(IProvideClassInfo *iface, ITypeInfo **ti)
{
struct provideclassinfo *This = impl_from_IProvideClassInfo(iface);
TRACE("(%p)->(%p)\n", This, ti);
return get_typeinfo_of_guid(This->guid, ti);
}
static const IProvideClassInfoVtbl provideclassinfovtbl = {
provideclassinfo_QueryInterface,
provideclassinfo_AddRef,
provideclassinfo_Release,
provideclassinfo_GetClassInfo
};
void init_classinfo(const GUID *guid, IUnknown *outer, struct provideclassinfo *classinfo)
{
classinfo->IProvideClassInfo_iface.lpVtbl = &provideclassinfovtbl;
classinfo->outer = outer;
classinfo->guid = guid;
}
static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
{
*ppv = NULL;

View file

@ -26,6 +26,7 @@
#include <windef.h>
#include <winbase.h>
#include <wshom.h>
#include <ocidl.h>
#include <wine/debug.h>
WINE_DEFAULT_DEBUG_CHANNEL(wshom);
@ -43,6 +44,14 @@ typedef enum tid_t {
HRESULT get_typeinfo(tid_t tid, ITypeInfo **typeinfo) DECLSPEC_HIDDEN;
struct provideclassinfo {
IProvideClassInfo IProvideClassInfo_iface;
IUnknown *outer;
const GUID *guid;
};
extern void init_classinfo(const GUID *guid, IUnknown *outer, struct provideclassinfo *classinfo) DECLSPEC_HIDDEN;
HRESULT WINAPI WshShellFactory_CreateInstance(IClassFactory*,IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
#endif /* _WSHOM_PRIVATE_H_ */

View file

@ -211,7 +211,7 @@ reactos/dll/win32/wldap32 # Synced to WineStaging-2.2
reactos/dll/win32/wmi # Synced to WineStaging-1.9.11
reactos/dll/win32/wmiutils # Synced to WineStaging-1.9.11
reactos/dll/win32/wmvcore # Synced to WineStaging-2.2
reactos/dll/win32/wshom.ocx # Synced to WineStaging-1.9.11
reactos/dll/win32/wshom.ocx # Synced to WineStaging-2.2
reactos/dll/win32/wtsapi32 # Synced to WineStaging-1.9.11
reactos/dll/win32/wuapi # Synced to WineStaging-1.9.11
reactos/dll/win32/xinput1_1 # Synced to WineStaging-1.9.11