https://git.reactos.org/?p=reactos.git;a=commitdiff;h=47bae01cfad2275efb3e68d7b31e7a809d6cb749

commit 47bae01cfad2275efb3e68d7b31e7a809d6cb749
Author:     Eric Kohl <eric.k...@reactos.org>
AuthorDate: Sun Feb 16 21:23:12 2025 +0100
Commit:     Eric Kohl <eric.k...@reactos.org>
CommitDate: Sun Feb 16 21:23:12 2025 +0100

    [NETCFGX][PSDK] Add the interfaces INetCfgClass and INetCfgClassSetup
    
    This will enable us to install networking drivers and services properly.
---
 dll/win32/netcfgx/CMakeLists.txt      |   1 +
 dll/win32/netcfgx/netcfg_iface.c      |   2 +-
 dll/win32/netcfgx/netcfgclass_iface.c | 233 ++++++++++++++++++++++++++++++++++
 dll/win32/netcfgx/precomp.h           |   3 +
 sdk/include/psdk/netcfgx.h            |  69 ++++++++++
 5 files changed, 307 insertions(+), 1 deletion(-)

diff --git a/dll/win32/netcfgx/CMakeLists.txt b/dll/win32/netcfgx/CMakeLists.txt
index bde3f69f9db..3e4dfb3f8b8 100644
--- a/dll/win32/netcfgx/CMakeLists.txt
+++ b/dll/win32/netcfgx/CMakeLists.txt
@@ -11,6 +11,7 @@ list(APPEND SOURCE
     netcfg_iface.c
     netcfgbindinginterface_iface.c
     netcfgbindingpath_iface.c
+    netcfgclass_iface.c
     inetcfgcomp_iface.c
     tcpipconf_notify.c
     propertypage.c
diff --git a/dll/win32/netcfgx/netcfg_iface.c b/dll/win32/netcfgx/netcfg_iface.c
index e292e4c7b4b..72122513843 100644
--- a/dll/win32/netcfgx/netcfg_iface.c
+++ b/dll/win32/netcfgx/netcfg_iface.c
@@ -845,7 +845,7 @@ INetCfg_fnQueryNetCfgClass(
     REFIID riid,
     void **ppvObject)
 {
-    return E_FAIL;
+    return INetCfgClass_Constructor((IUnknown *)iface, riid, ppvObject, 
pguidClass, iface);
 }
 
 static const INetCfgVtbl vt_NetCfg =
diff --git a/dll/win32/netcfgx/netcfgclass_iface.c 
b/dll/win32/netcfgx/netcfgclass_iface.c
new file mode 100644
index 00000000000..10eda26cad6
--- /dev/null
+++ b/dll/win32/netcfgx/netcfgclass_iface.c
@@ -0,0 +1,233 @@
+#include "precomp.h"
+
+typedef struct
+{
+    const INetCfgClass *lpVtbl;
+    const INetCfgClassSetup *lpVtblSetup;
+    LONG ref;
+    GUID ClassGuid;
+    INetCfg *pNetCfg;
+} INetCfgClassImpl, *LPINetCfgClassImpl;
+
+static __inline LPINetCfgClassImpl 
impl_from_INetCfgClassSetup(INetCfgClassSetup *iface)
+{
+    return (INetCfgClassImpl*)((char *)iface - FIELD_OFFSET(INetCfgClassImpl, 
lpVtblSetup));
+}
+
+/***************************************************************
+ * INetCfgClassSetup
+ */
+
+HRESULT
+WINAPI
+INetCfgClassSetup_fnQueryInterface(
+    INetCfgClassSetup *iface,
+    REFIID iid,
+    LPVOID *ppvObj)
+{
+    INetCfgClassImpl *This = impl_from_INetCfgClassSetup(iface);
+    return INetCfgClass_QueryInterface((INetCfgClass*)This, iid, ppvObj);
+}
+
+
+ULONG
+WINAPI
+INetCfgClassSetup_fnAddRef(
+    INetCfgClassSetup *iface)
+{
+    INetCfgClassImpl *This = impl_from_INetCfgClassSetup(iface);
+    return INetCfgClass_AddRef((INetCfgClass*)This);
+}
+
+ULONG
+WINAPI
+INetCfgClassSetup_fnRelease(
+    INetCfgClassSetup *iface)
+{
+    INetCfgClassImpl *This = impl_from_INetCfgClassSetup(iface);
+    return INetCfgClass_Release((INetCfgClass*)This);
+}
+
+HRESULT
+WINAPI
+INetCfgClassSetup_fnSelectAndInstall(
+    _In_ INetCfgClassSetup *iface,
+    _In_ HWND hwndParent,
+    _In_opt_ OBO_TOKEN *pOboToken,
+    _Out_opt_ INetCfgComponent **ppnccItem)
+{
+//    INetCfgClassImpl *This = impl_from_INetCfgClassSetup(iface);
+    return S_OK;
+}
+
+HRESULT
+WINAPI
+INetCfgClassSetup_fnInstall(
+    _In_ INetCfgClassSetup *iface,
+    _In_ LPCWSTR pszwComponentId,
+    _In_opt_ OBO_TOKEN *pOboToken,
+    _In_opt_ DWORD dwSetupFlags,
+    _In_opt_ DWORD dwUpgradeFromBuildNo,
+    _In_opt_ LPCWSTR pszwAnswerFile,
+    _In_opt_ LPCWSTR pszwAnswerSections,
+    _Out_opt_ INetCfgComponent **ppComponent)
+{
+//    INetCfgClassImpl *This = impl_from_INetCfgClassSetup(iface);
+
+    if (ppComponent)
+        *ppComponent = NULL;
+
+    return S_OK;
+}
+
+
+HRESULT
+WINAPI
+INetCfgClassSetup_fnDeInstall(
+    _In_ INetCfgClassSetup *iface,
+    _In_ INetCfgComponent *pComponent,
+    _In_opt_ OBO_TOKEN *pOboToken,
+    _Out_opt_ LPWSTR *pmszwRefs)
+{
+//    INetCfgClassImpl *This = impl_from_INetCfgClassSetup(iface);
+
+    return S_OK;
+}
+
+static const INetCfgClassSetupVtbl vt_NetCfgClassSetup =
+{
+    INetCfgClassSetup_fnQueryInterface,
+    INetCfgClassSetup_fnAddRef,
+    INetCfgClassSetup_fnRelease,
+    INetCfgClassSetup_fnSelectAndInstall,
+    INetCfgClassSetup_fnInstall,
+    INetCfgClassSetup_fnDeInstall
+};
+
+/***************************************************************
+ * INetCfgClass
+ */
+
+HRESULT
+WINAPI
+INetCfgClass_fnQueryInterface(
+    INetCfgClass *iface,
+    REFIID iid,
+    LPVOID *ppvObj)
+{
+    INetCfgClassImpl *This = (INetCfgClassImpl*)iface;
+    *ppvObj = NULL;
+
+    if (IsEqualIID (iid, &IID_IUnknown) ||
+        IsEqualIID (iid, &IID_INetCfgClass))
+    {
+        *ppvObj = This;
+        INetCfgClass_AddRef(iface);
+        return S_OK;
+    }
+    else if (IsEqualIID (iid, &IID_INetCfgClassSetup))
+    {
+        *ppvObj = (LPVOID)&This->lpVtblSetup;
+        INetCfgClass_AddRef(iface);
+        return S_OK;
+    }
+
+    return E_NOINTERFACE;
+}
+
+ULONG
+WINAPI
+INetCfgClass_fnAddRef(
+    INetCfgClass *iface)
+{
+    INetCfgClassImpl *This = (INetCfgClassImpl*)iface;
+    ULONG refCount = InterlockedIncrement(&This->ref);
+
+    return refCount;
+}
+
+ULONG
+WINAPI
+INetCfgClass_fnRelease(
+    INetCfgClass *iface)
+{
+    INetCfgClassImpl *This = (INetCfgClassImpl*)iface;
+    ULONG refCount = InterlockedDecrement(&This->ref);
+
+    if (!refCount)
+    {
+       CoTaskMemFree(This);
+    }
+    return refCount;
+}
+
+HRESULT
+WINAPI
+INetCfgClass_fnFindComponent(
+    INetCfgClass *iface,
+    INetCfgComponent **pComponent)
+{
+//    HRESULT hr;
+//    INetCfgClassImpl *This = (INetCfgClassImpl *)iface;
+
+
+    /* TODO */
+
+    return S_FALSE;
+}
+
+HRESULT
+WINAPI
+INetCfgClass_fnEnumComponents(
+    INetCfgClass *iface,
+    IEnumNetCfgComponent **ppenumComponent)
+{
+//    INetCfgClassImpl *This = (INetCfgClassImpl *)iface;
+
+
+    return E_NOINTERFACE;
+}
+
+static const INetCfgClassVtbl vt_NetCfgClass =
+{
+    INetCfgClass_fnQueryInterface,
+    INetCfgClass_fnAddRef,
+    INetCfgClass_fnRelease,
+    INetCfgClass_fnFindComponent,
+    INetCfgClass_fnEnumComponents,
+};
+
+HRESULT
+WINAPI
+INetCfgClass_Constructor(
+    IUnknown *pUnkOuter,
+    REFIID riid,
+    LPVOID *ppv,
+    const GUID *pguidClass,
+    INetCfg *pNetCfg)
+{
+    INetCfgClassImpl *This;
+
+    if (!ppv)
+        return E_POINTER;
+
+    This = (INetCfgClassImpl *)CoTaskMemAlloc(sizeof(INetCfgClassImpl));
+    if (!This)
+        return E_OUTOFMEMORY;
+
+    This->ref = 1;
+    This->lpVtbl = (const INetCfgClass*)&vt_NetCfgClass;
+    This->lpVtblSetup = (const INetCfgClassSetup*)&vt_NetCfgClassSetup;
+
+    memcpy(&This->ClassGuid, pguidClass, sizeof(GUID));
+    This->pNetCfg = pNetCfg;
+
+    if (!SUCCEEDED(INetCfgClass_QueryInterface((INetCfgClass*)This, riid, 
ppv)))
+    {
+        INetCfgClass_Release((INetCfgClass*)This);
+        return E_NOINTERFACE;
+    }
+
+    INetCfgClass_Release((INetCfgClass*)This);
+    return S_OK;
+}
diff --git a/dll/win32/netcfgx/precomp.h b/dll/win32/netcfgx/precomp.h
index 77ba0e96968..e8551f7c43f 100644
--- a/dll/win32/netcfgx/precomp.h
+++ b/dll/win32/netcfgx/precomp.h
@@ -73,6 +73,9 @@ HRESULT WINAPI 
IEnumNetCfgBindingInterface_Constructor(IUnknown *pUnkOuter, REFI
 HRESULT WINAPI INetCfgBindingPath_Constructor(IUnknown *pUnkOuter, REFIID 
riid, LPVOID *ppv);
 HRESULT WINAPI IEnumNetCfgBindingPath_Constructor(IUnknown *pUnkOuter, REFIID 
riid, LPVOID *ppv, DWORD dwFlags);
 
+/* netcfgclass_iface.c */
+HRESULT WINAPI INetCfgClass_Constructor(IUnknown *pUnkOuter, REFIID riid, 
LPVOID *ppv, const GUID *pguidClass, INetCfg *pNetCfg);
+
 /* tcpipconf_notify.c */
 HRESULT WINAPI TcpipConfigNotify_Constructor (IUnknown * pUnkOuter, REFIID 
riid, LPVOID * ppv);
 
diff --git a/sdk/include/psdk/netcfgx.h b/sdk/include/psdk/netcfgx.h
index 90ef3ae6d25..bcd6758c4c6 100644
--- a/sdk/include/psdk/netcfgx.h
+++ b/sdk/include/psdk/netcfgx.h
@@ -314,5 +314,74 @@ EXTERN_C const IID IID_INetCfg;
 #define NETCFG_S_CAUSED_SETUP_CHANGE                 0x8004A024
 #define NETCFG_S_COMMIT_NOW                          0x8004A025
 
+EXTERN_C const IID IID_INetCfgClass;
+
+#undef  INTERFACE
+#define INTERFACE   INetCfgClass
+DECLARE_INTERFACE_(INetCfgClass, IUnknown)
+{
+    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void **ppv) PURE;
+    STDMETHOD_(ULONG,AddRef)(THIS)  PURE;
+    STDMETHOD_(ULONG,Release)(THIS) PURE;
+    STDMETHOD_(HRESULT,FindComponent) (THIS_ INetCfgComponent **ppnccItem) 
PURE;
+    STDMETHOD_(HRESULT,EnumComponents) (THIS_ IEnumNetCfgComponent 
**ppenumComponent) PURE;
+};
+#undef INTERFACE
+
+#if !defined(__cplusplus) || defined(CINTERFACE)
+/*** IUnknown methods ***/
+#define INetCfgClass_QueryInterface(p,a,b)  (p)->lpVtbl->QueryInterface(p,a,b)
+#define INetCfgClass_AddRef(p)              (p)->lpVtbl->AddRef(p)
+#define INetCfgClass_Release(p)             (p)->lpVtbl->Release(p)
+#define INetCfgClass_FindComponent(p,a)     (p)->lpVtbl->FindComponent(p,a)
+#define INetCfgClass_EnumComponents(p,a)    (p)->lpVtbl->EnumComponents(p,a)
+#endif
+
+typedef 
+enum tagOBO_TOKEN_TYPE
+{
+    OBO_USER = 1,
+    OBO_COMPONENT = 2,
+    OBO_SOFTWARE = 3
+} OBO_TOKEN_TYPE;
+
+typedef struct tagOBO_TOKEN
+{
+    OBO_TOKEN_TYPE Type;
+    INetCfgComponent *pncc;
+    LPCWSTR pszwManufacturer;
+    LPCWSTR pszwProduct;
+    LPCWSTR pszwDisplayName;
+    BOOL fRegistered;
+} OBO_TOKEN;
+
+#define NSF_PRIMARYINSTALL 1
+#define NSF_POSTSYSINSTALL 2
+
+EXTERN_C const IID IID_INetCfgClassSetup;
+
+#undef  INTERFACE
+#define INTERFACE   INetCfgClassSetup
+DECLARE_INTERFACE_(INetCfgClassSetup, IUnknown)
+{
+    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void **ppv) PURE;
+    STDMETHOD_(ULONG,AddRef)(THIS)  PURE;
+    STDMETHOD_(ULONG,Release)(THIS) PURE;
+    STDMETHOD_(HRESULT,SelectAndInstall)(THIS_ HWND hwndParent, OBO_TOKEN 
*pOboToken, INetCfgComponent **ppnccItem) PURE;
+    STDMETHOD_(HRESULT,Install)(THIS_ LPCWSTR pszwInfId, OBO_TOKEN *pOboToken, 
DWORD dwSetupFlags, DWORD dwUpgradeFromBuildNo,
+                                LPCWSTR pszwAnswerFile, LPCWSTR 
pszwAnswerSections, INetCfgComponent **ppnccItem) PURE;
+    STDMETHOD_(HRESULT,DeInstall)(THIS_ INetCfgComponent *pComponent, 
OBO_TOKEN *pOboToken, LPWSTR *pmszwRefs) PURE;
+};
+#undef INTERFACE
+
+#if !defined(__cplusplus) || defined(CINTERFACE)
+/*** IUnknown methods ***/
+#define INetCfgClassSetup_QueryInterface(p,a,b)      
(p)->lpVtbl->QueryInterface(p,a,b)
+#define INetCfgClassSetup_AddRef(p)                  (p)->lpVtbl->AddRef(p)
+#define INetCfgClassSetup_Release(p)                 (p)->lpVtbl->Release(p)
+#define INetCfgClassSetup_SelectAndInstall(p,a,b,c)  
(p)->lpVtbl->SelectAndInstall(p,a,b,c)
+#define INetCfgClassSetup_Install(p,a,b,c,d,e,f,g)   
(p)->lpVtbl->Install(p,a,b,c,d,e,f,g)
+#define INetCfgClassSetup_DeInstall(p,a,b,c)         
(p)->lpVtbl->DeInstall(p,a,b,c)
+#endif
 
 #endif

Reply via email to