netcfgx: Add INetCfg interface support
Alistair Leslie-Hughes
leslie_alistair at hotmail.com
Thu Mar 20 19:19:50 CDT 2014
Hi,
Changelog:
netcfgx: Add INetCfg interface support
Best Regards
Alistair Leslie-Hughes
-------------- next part --------------
>From cbad0ee96a8666c8ef0144d180d99d6177018401 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Date: Thu, 20 Mar 2014 21:00:28 +1100
Subject: [PATCH] Add INetCfg interface support
To: wine-patches <wine-patches at winehq.org>
---
dlls/netcfgx/Makefile.in | 4 +-
dlls/netcfgx/main.c | 107 +++++++++++++++++++++++++-
dlls/netcfgx/netcfg.c | 170 +++++++++++++++++++++++++++++++++++++++++
dlls/netcfgx/netcfg_private.h | 23 ++++++
dlls/netcfgx/tests/Makefile.in | 5 ++
dlls/netcfgx/tests/netcfgx.c | 66 ++++++++++++++++
6 files changed, 372 insertions(+), 3 deletions(-)
create mode 100644 dlls/netcfgx/netcfg.c
create mode 100644 dlls/netcfgx/netcfg_private.h
create mode 100644 dlls/netcfgx/tests/Makefile.in
create mode 100644 dlls/netcfgx/tests/netcfgx.c
diff --git a/dlls/netcfgx/Makefile.in b/dlls/netcfgx/Makefile.in
index 29277db..c384905 100644
--- a/dlls/netcfgx/Makefile.in
+++ b/dlls/netcfgx/Makefile.in
@@ -1,6 +1,8 @@
MODULE = netcfgx.dll
+IMPORTS = uuid
C_SRCS = \
- main.c
+ main.c \
+ netcfg.c
IDL_SRCS = netcfgx_classes.idl
diff --git a/dlls/netcfgx/main.c b/dlls/netcfgx/main.c
index d0213ca..d237aa6 100644
--- a/dlls/netcfgx/main.c
+++ b/dlls/netcfgx/main.c
@@ -19,16 +19,107 @@
*/
#include <stdarg.h>
+#define COBJMACROS
+
#include "windef.h"
#include "winbase.h"
#include "ole2.h"
#include "rpcproxy.h"
#include "wine/debug.h"
+#include "netcfgx.h"
+#include "netcfg_private.h"
+
WINE_DEFAULT_DEBUG_CHANNEL(netcfgx);
static HINSTANCE NETCFGX_hInstance;
+typedef HRESULT (*ClassFactoryCreateInstanceFunc)(IUnknown **);
+
+typedef struct netcfgcf
+{
+ IClassFactory IClassFactory_iface;
+ ClassFactoryCreateInstanceFunc fnCreateInstance;
+} netcfgcf;
+
+static inline netcfgcf *impl_from_IClassFactory( IClassFactory *iface )
+{
+ return CONTAINING_RECORD(iface, netcfgcf, IClassFactory_iface);
+}
+
+static HRESULT WINAPI netcfgcf_QueryInterface(IClassFactory *iface, REFIID riid, LPVOID *ppobj )
+{
+ TRACE("%s %p\n", debugstr_guid(riid), ppobj);
+
+ if (IsEqualGUID(riid, &IID_IUnknown) ||
+ IsEqualGUID(riid, &IID_IClassFactory))
+ {
+ IClassFactory_AddRef( iface );
+ *ppobj = iface;
+ return S_OK;
+ }
+
+ ERR("interface %s not implemented\n", debugstr_guid(riid));
+ return E_NOINTERFACE;
+}
+
+static ULONG WINAPI netcfgcf_AddRef(IClassFactory *iface )
+{
+ TRACE("%p\n", iface);
+
+ return 2;
+}
+
+static ULONG WINAPI netcfgcf_Release(IClassFactory *iface )
+{
+ TRACE("%p\n", iface);
+
+ return 1;
+}
+
+static HRESULT WINAPI netcfgcf_CreateInstance(IClassFactory *iface,LPUNKNOWN pOuter,
+ REFIID riid, LPVOID *ppobj )
+{
+ netcfgcf *This = impl_from_IClassFactory( iface );
+ HRESULT hr;
+ IUnknown *punk;
+
+ TRACE("%p %s %p\n", pOuter, debugstr_guid(riid), ppobj );
+
+ *ppobj = NULL;
+
+ if (pOuter)
+ return CLASS_E_NOAGGREGATION;
+
+ hr = This->fnCreateInstance( &punk );
+ if (SUCCEEDED(hr))
+ {
+ hr = IUnknown_QueryInterface( punk, riid, ppobj );
+
+ IUnknown_Release( punk );
+ }
+ else
+ {
+ WARN("Cannot create an instance object. 0x%08x\n", hr);
+ }
+ return hr;
+}
+
+static HRESULT WINAPI netcfgcf_LockServer(IClassFactory *iface, BOOL dolock)
+{
+ FIXME("(%p)->(%d),stub!\n",iface,dolock);
+ return S_OK;
+}
+
+static const struct IClassFactoryVtbl netcfgcf_vtbl =
+{
+ netcfgcf_QueryInterface,
+ netcfgcf_AddRef,
+ netcfgcf_Release,
+ netcfgcf_CreateInstance,
+ netcfgcf_LockServer
+};
+
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
TRACE("(0x%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved);
@@ -49,11 +140,23 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
return TRUE;
}
+static netcfgcf netconfigcf = { {&netcfgcf_vtbl}, INetCfg_CreateInstance };
+
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
- FIXME("(%s, %s, %p): stub\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
+ IClassFactory *cf = NULL;
+
+ TRACE("(%s, %s, %p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
+
+ if(IsEqualCLSID(rclsid, &CLSID_CNetCfg))
+ {
+ cf = &netconfigcf.IClassFactory_iface;
+ }
+
+ if(!cf)
+ return CLASS_E_CLASSNOTAVAILABLE;
- return CLASS_E_CLASSNOTAVAILABLE;
+ return IClassFactory_QueryInterface(cf, riid, ppv);
}
HRESULT WINAPI DllRegisterServer(void)
diff --git a/dlls/netcfgx/netcfg.c b/dlls/netcfgx/netcfg.c
new file mode 100644
index 0000000..8653d29
--- /dev/null
+++ b/dlls/netcfgx/netcfg.c
@@ -0,0 +1,170 @@
+/*
+ * Copyright 2014 Alistair Leslie-Hughes
+ *
+ * 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 <stdio.h>
+#include <stdarg.h>
+#include <assert.h>
+
+#define COBJMACROS
+
+#include "netcfgx.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL( netcfgx );
+
+
+typedef struct NetConfiguration
+{
+ INetCfg INetCfg_iface;
+ LONG ref;
+} NetConfiguration;
+
+static inline NetConfiguration *impl_from_INetCfg(INetCfg *iface)
+{
+ return CONTAINING_RECORD(iface, NetConfiguration, INetCfg_iface);
+}
+
+static HRESULT WINAPI netcfg_QueryInterface(INetCfg *iface, REFIID riid, void **ppvObject)
+{
+ TRACE("%p %s %p\n", iface, debugstr_guid(riid), ppvObject);
+
+ if (IsEqualGUID(riid, &IID_INetCfg) ||
+ IsEqualGUID(riid, &IID_IUnknown))
+ {
+ *ppvObject = iface;
+ }
+ else
+ {
+ FIXME("Unsupported interface %s\n", debugstr_guid(riid));
+ return E_NOINTERFACE;
+ }
+
+ INetCfg_AddRef( iface );
+
+ return S_OK;
+}
+
+static ULONG WINAPI netcfg_AddRef(INetCfg *iface)
+{
+ NetConfiguration *This = impl_from_INetCfg(iface);
+ ULONG ref = InterlockedIncrement(&This->ref);
+
+ TRACE("%p ref=%u\n", This, ref);
+
+ return ref;
+}
+
+static ULONG WINAPI netcfg_Release(INetCfg *iface)
+{
+ NetConfiguration *This = impl_from_INetCfg(iface);
+ ULONG ref = InterlockedDecrement(&This->ref);
+
+ TRACE("%p ref=%u\n", This, ref);
+
+ if (ref == 0)
+ {
+ HeapFree(GetProcessHeap(), 0, This);
+ }
+
+ return ref;
+}
+
+static HRESULT WINAPI netcfg_Initialize(INetCfg *iface, PVOID pvReserved)
+{
+ NetConfiguration *This = impl_from_INetCfg(iface);
+ FIXME("%p %p\n", This, pvReserved);
+
+ return S_OK;
+}
+
+static HRESULT WINAPI netcfg_Uninitialize(INetCfg *iface)
+{
+ NetConfiguration *This = impl_from_INetCfg(iface);
+ FIXME("%p\n", This);
+
+ return S_OK;
+}
+
+static HRESULT WINAPI netcfg_Apply(INetCfg *iface)
+{
+ NetConfiguration *This = impl_from_INetCfg(iface);
+ FIXME("%p\n", This);
+
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI netcfg_Cancel(INetCfg *iface)
+{
+ NetConfiguration *This = impl_from_INetCfg(iface);
+ FIXME("%p\n", This);
+
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI netcfg_EnumComponents(INetCfg *iface, const GUID *pguidClass, IEnumNetCfgComponent **ppenumComponent)
+{
+ NetConfiguration *This = impl_from_INetCfg(iface);
+ FIXME("%p %s %p\n", This, debugstr_guid(pguidClass), ppenumComponent);
+
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI netcfg_FindComponent(INetCfg *iface, LPCWSTR pszwInfId, INetCfgComponent **pComponent)
+{
+ NetConfiguration *This = impl_from_INetCfg(iface);
+ FIXME("%p %s %p\n", This, debugstr_w(pszwInfId), pComponent);
+
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI netcfg_QueryNetCfgClass(INetCfg *iface, const GUID *pguidClass, REFIID riid, void **ppvObject)
+{
+ NetConfiguration *This = impl_from_INetCfg(iface);
+ FIXME("%p %s %p\n", This, debugstr_guid(pguidClass), ppvObject);
+
+ return E_NOTIMPL;
+}
+
+static const struct INetCfgVtbl NetCfgVtbl =
+{
+ netcfg_QueryInterface,
+ netcfg_AddRef,
+ netcfg_Release,
+ netcfg_Initialize,
+ netcfg_Uninitialize,
+ netcfg_Apply,
+ netcfg_Cancel,
+ netcfg_EnumComponents,
+ netcfg_FindComponent,
+ netcfg_QueryNetCfgClass
+};
+
+HRESULT INetCfg_CreateInstance(IUnknown **ppUnk)
+{
+ NetConfiguration *This;
+
+ This = HeapAlloc(GetProcessHeap(), 0, sizeof(NetConfiguration));
+ if (!This)
+ return E_OUTOFMEMORY;
+
+ This->INetCfg_iface.lpVtbl = &NetCfgVtbl;
+ This->ref = 1;
+
+ *ppUnk = (IUnknown*)This;
+
+ return S_OK;
+}
diff --git a/dlls/netcfgx/netcfg_private.h b/dlls/netcfgx/netcfg_private.h
new file mode 100644
index 0000000..14c5111
--- /dev/null
+++ b/dlls/netcfgx/netcfg_private.h
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2014 Alistair Leslie-Hughes
+ *
+ * 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
+ */
+#ifndef __NETCFG_PRIVATE_H__
+#define __NETCFG_PRIVATE_H__
+
+extern HRESULT INetCfg_CreateInstance(IUnknown **ppUnk) DECLSPEC_HIDDEN;
+
+#endif
diff --git a/dlls/netcfgx/tests/Makefile.in b/dlls/netcfgx/tests/Makefile.in
new file mode 100644
index 0000000..699af30
--- /dev/null
+++ b/dlls/netcfgx/tests/Makefile.in
@@ -0,0 +1,5 @@
+TESTDLL = netcfgx.dll
+IMPORTS = uuid ole32
+
+C_SRCS = \
+ netcfgx.c
diff --git a/dlls/netcfgx/tests/netcfgx.c b/dlls/netcfgx/tests/netcfgx.c
new file mode 100644
index 0000000..6427f85
--- /dev/null
+++ b/dlls/netcfgx/tests/netcfgx.c
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2014 Alistair Leslie-Hughes
+ *
+ * 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 WIN32_LEAN_AND_MEAN
+#include <stdio.h>
+
+#define COBJMACROS
+
+#include "netcfgx.h"
+#include "wine/test.h"
+
+void create_configuration(void)
+{
+ static const WCHAR tcpipW[] = {'M','S','_','T','C','P','I','P',0};
+ HRESULT hr;
+ INetCfg *config = NULL;
+ INetCfgComponent *component = NULL;
+
+ hr = CoCreateInstance( &CLSID_CNetCfg, NULL, CLSCTX_ALL, &IID_INetCfg, (LPVOID*)&config);
+ ok(hr == S_OK, "Failed to create object\n");
+ if(SUCCEEDED(hr))
+ {
+ hr = INetCfg_Initialize(config, NULL);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ hr = INetCfg_FindComponent(config, tcpipW, &component);
+ todo_wine ok(hr == S_OK, "got 0x%08x\n", hr);
+ if(hr == S_OK)
+ {
+ INetCfgComponent_Release(component);
+ }
+
+ hr = INetCfg_Uninitialize(config);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ INetCfg_Release(config);
+ }
+}
+
+START_TEST(netcfgx)
+{
+ HRESULT hr;
+
+ hr = CoInitialize(0);
+ ok( hr == S_OK, "failed to init com\n");
+ if (hr != S_OK)
+ return;
+
+ create_configuration();
+
+ CoUninitialize();
+}
--
1.8.3.2
More information about the wine-patches
mailing list