[HNETCFG] Sync with Wine Staging 4.18. CORE-16441
authorAmine Khaldi <amine.khaldi@reactos.org>
Sun, 20 Oct 2019 19:03:33 +0000 (20:03 +0100)
committerAmine Khaldi <amine.khaldi@reactos.org>
Sun, 20 Oct 2019 19:03:33 +0000 (20:03 +0100)
14 files changed:
dll/win32/hnetcfg/CMakeLists.txt
dll/win32/hnetcfg/apps.c
dll/win32/hnetcfg/hnetcfg.c
dll/win32/hnetcfg/hnetcfg.idl
dll/win32/hnetcfg/hnetcfg.rgs
dll/win32/hnetcfg/hnetcfg_private.h
dll/win32/hnetcfg/hnetcfg_tlb.idl
dll/win32/hnetcfg/hnetcfg_tlb.rgs
dll/win32/hnetcfg/manager.c
dll/win32/hnetcfg/policy.c
dll/win32/hnetcfg/port.c
dll/win32/hnetcfg/profile.c
dll/win32/hnetcfg/service.c
media/doc/README.WINE

index 4e75ba6..14353e9 100644 (file)
@@ -29,6 +29,6 @@ set_source_files_properties(hnetcfg.rc PROPERTIES OBJECT_DEPENDS "${hnetcfg_rc_d
 set_module_type(hnetcfg win32dll)
 add_dependencies(hnetcfg stdole2)
 target_link_libraries(hnetcfg wine uuid)
-add_importlibs(hnetcfg ole32 oleaut32 advapi32 msvcrt kernel32 ntdll)
+add_importlibs(hnetcfg ole32 oleaut32 advapi32 mpr msvcrt kernel32 ntdll)
 add_pch(hnetcfg precomp.h SOURCE)
 add_cd_file(TARGET hnetcfg DESTINATION reactos/system32 FOR all)
index fda714e..e0f2cc3 100644 (file)
@@ -16,7 +16,6 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#include "config.h"
 #include <stdarg.h>
 #include <stdio.h>
 
 #include "winuser.h"
 #include "ole2.h"
 #include "netfw.h"
+#include "natupnp.h"
+#ifdef __REACTOS__
+#include "winnetwk.h"
+#endif
 
 #include "wine/debug.h"
-#include "wine/unicode.h"
+#include "wine/heap.h"
 #include "hnetcfg_private.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(hnetcfg);
@@ -114,7 +117,8 @@ static REFIID tid_id[] =
     &IID_INetFwOpenPorts,
     &IID_INetFwPolicy,
     &IID_INetFwPolicy2,
-    &IID_INetFwProfile
+    &IID_INetFwProfile,
+    &IID_IUPnPNAT
 };
 
 HRESULT get_typeinfo( enum type_id tid, ITypeInfo **ret )
@@ -156,7 +160,7 @@ void release_typelib(void)
 {
     unsigned i;
 
-    for (i = 0; i < sizeof(typeinfo)/sizeof(*typeinfo); i++)
+    for (i = 0; i < ARRAY_SIZE(typeinfo); i++)
         if (typeinfo[i])
             ITypeInfo_Release(typeinfo[i]);
 
@@ -263,18 +267,56 @@ static HRESULT WINAPI fw_app_get_ProcessImageFileName(
 }
 
 static HRESULT WINAPI fw_app_put_ProcessImageFileName(
-    INetFwAuthorizedApplication *iface,
-    BSTR imageFileName )
+    INetFwAuthorizedApplication *iface, BSTR image )
 {
     fw_app *This = impl_from_INetFwAuthorizedApplication( iface );
+    UNIVERSAL_NAME_INFOW *info;
+    DWORD sz, longsz;
+    WCHAR *path;
+    DWORD res;
 
-    FIXME("%p, %s\n", This, debugstr_w(imageFileName));
+    FIXME("%p, %s\n", This, debugstr_w(image));
 
-    if (!imageFileName || !imageFileName[0])
+    if (!image || !image[0])
         return E_INVALIDARG;
 
+    sz = 0;
+    res = WNetGetUniversalNameW(image, UNIVERSAL_NAME_INFO_LEVEL, NULL, &sz);
+    if (res == WN_MORE_DATA)
+    {
+        if (!(path = heap_alloc(sz)))
+            return E_OUTOFMEMORY;
+
+        info = (UNIVERSAL_NAME_INFOW *)&path;
+        res = WNetGetUniversalNameW(image, UNIVERSAL_NAME_INFO_LEVEL, &info, &sz);
+        if (res == NO_ERROR)
+        {
+            SysFreeString(This->filename);
+            This->filename = SysAllocString(info->lpUniversalName);
+        }
+        heap_free(path);
+        return HRESULT_FROM_WIN32(res);
+    }
+
+    sz = GetFullPathNameW(image, 0, NULL, NULL);
+    if (!(path = heap_alloc(++sz * sizeof(WCHAR))))
+        return E_OUTOFMEMORY;
+    GetFullPathNameW(image, sz, path, NULL);
+
+    longsz = GetLongPathNameW(path, path, sz);
+    if (longsz > sz)
+    {
+        if (!(path = heap_realloc(path, longsz * sizeof(WCHAR))))
+        {
+            heap_free(path);
+            return E_OUTOFMEMORY;
+        }
+        GetLongPathNameW(path, path, longsz);
+    }
+
     SysFreeString( This->filename );
-    This->filename = SysAllocString( imageFileName );
+    This->filename = SysAllocString(path);
+    heap_free(path);
     return This->filename ? S_OK : E_OUTOFMEMORY;
 }
 
index e56dbab..5cc24a1 100644 (file)
@@ -25,6 +25,7 @@
 #include "objbase.h"
 #include "rpcproxy.h"
 #include "netfw.h"
+#include "natupnp.h"
 
 #include "wine/debug.h"
 #include "hnetcfg_private.h"
@@ -114,6 +115,8 @@ static hnetcfg_cf fw_manager_cf = { { &hnetcfg_cf_vtbl }, NetFwMgr_create };
 static hnetcfg_cf fw_app_cf = { { &hnetcfg_cf_vtbl }, NetFwAuthorizedApplication_create };
 static hnetcfg_cf fw_openport_cf = { { &hnetcfg_cf_vtbl }, NetFwOpenPort_create };
 static hnetcfg_cf fw_policy2_cf = { { &hnetcfg_cf_vtbl }, NetFwPolicy2_create };
+static hnetcfg_cf upnpnat_cf = { { &hnetcfg_cf_vtbl }, IUPnPNAT_create };
+
 
 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID reserved)
 {
@@ -156,6 +159,10 @@ HRESULT WINAPI DllGetClassObject( REFCLSID rclsid, REFIID iid, LPVOID *ppv )
     {
        cf = &fw_policy2_cf.IClassFactory_iface;
     }
+    else if (IsEqualGUID( rclsid, &CLSID_UPnPNAT ))
+    {
+        cf = &upnpnat_cf.IClassFactory_iface;
+    }
 
     if (!cf) return CLASS_E_CLASSNOTAVAILABLE;
     return IClassFactory_QueryInterface( cf, iid, ppv );
index 763529a..40a3b98 100644 (file)
@@ -51,3 +51,27 @@ coclass NetFwOpenPort { interface INetFwOpenPort; }
     uuid(e2b3c97f-6ae1-41ac-817a-f6f92166d7dd)
 ]
 coclass NetFwPolicy2 { interface INetFwPolicy2; }
+
+[
+    helpstring("HNetCfg.FwRule"),
+    progid("HNetCfg.FwRule"),
+    threading(both),
+    uuid(2c5bc43e-3369-4c33-ab0c-be9469677af4)
+]
+coclass NetFwRule { interface INetFwRule; }
+
+[
+    helpstring("HNetCfg.FwProduct"),
+    progid("HNetCfg.FwProduct"),
+    threading(both),
+    uuid(9d745ed8-c514-4d1d-bf42-751fed2d5ac7)
+]
+coclass NetFwProduct { interface INetFwProduct; }
+
+[
+    helpstring("HNetCfg.FwProducts"),
+    progid("HNetCfg.FwProducts"),
+    threading(both),
+    uuid(cc19079b-8272-4d73-bb70-cdb533527b61)
+]
+coclass NetFwProducts { interface INetFwProducts; }
index eb7f526..4974ebe 100644 (file)
@@ -25,6 +25,21 @@ HKCR
             InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' }
             ProgId = s 'HNetCfg.FwPolicy2'
         }
+        '{2C5BC43E-3369-4C33-AB0C-BE9469677AF4}' = s 'HNetCfg.FwRule'
+        {
+            InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' }
+            ProgId = s 'HNetCfg.FwRule'
+        }
+        '{9D745ED8-C514-4D1D-BF42-751FED2D5AC7}' = s 'HNetCfg.FwProduct'
+        {
+            InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' }
+            ProgId = s 'HNetCfg.FwProduct'
+        }
+        '{CC19079B-8272-4D73-BB70-CDB533527B61}' = s 'HNetCfg.FwProducts'
+        {
+            InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' }
+            ProgId = s 'HNetCfg.FwProducts'
+        }
     }
     'HNetCfg.FwMgr' = s 'HNetCfg.FwMgr'
     {
@@ -42,4 +57,16 @@ HKCR
     {
         CLSID = s '{E2B3C97F-6AE1-41AC-817A-F6F92166D7DD}'
     }
+    'HNetCfg.FwRule' = s 'HNetCfg.FwRule'
+    {
+        CLSID = s '{2C5BC43E-3369-4C33-AB0C-BE9469677AF4}'
+    }
+    'HNetCfg.FwProduct' = s 'HNetCfg.FwProduct'
+    {
+        CLSID = s '{9D745ED8-C514-4D1D-BF42-751FED2D5AC7}'
+    }
+    'HNetCfg.FwProducts' = s 'HNetCfg.FwProducts'
+    {
+        CLSID = s '{CC19079B-8272-4D73-BB70-CDB533527B61}'
+    }
 }
index 26b52d9..0e67d81 100644 (file)
@@ -29,6 +29,7 @@ enum type_id
     INetFwPolicy2_tid,
     INetFwProfile_tid,
     INetFwRules_tid,
+    IUPnPNAT_tid,
     last_tid
 };
 
@@ -44,3 +45,4 @@ HRESULT NetFwAuthorizedApplications_create(IUnknown *, LPVOID *) DECLSPEC_HIDDEN
 HRESULT NetFwOpenPorts_create(IUnknown *, LPVOID *) DECLSPEC_HIDDEN;
 HRESULT NetFwOpenPort_create(IUnknown *, LPVOID *) DECLSPEC_HIDDEN;
 HRESULT NetFwServices_create(IUnknown *, LPVOID *) DECLSPEC_HIDDEN;
+HRESULT IUPnPNAT_create(IUnknown *, void **) DECLSPEC_HIDDEN;
index 33e8cc8..e368fe6 100644 (file)
@@ -21,3 +21,4 @@
 #pragma makedep regtypelib
 
 #include "netfw.idl"
+#include "natupnp.idl"
index 50ff31f..1628f02 100644 (file)
@@ -2,11 +2,11 @@ HKCR
 {
     NoRemove Typelib
     {
-        NoRemove '{DB4F3345-3EF8-45ED-B976-25A6D3B81B71}'
+        NoRemove '{1C565858-F302-471E-B409-F180AA4ABEC6}'
         {
-            '1.0' = s 'NetFwPublicTypeLib'
+            '1.0' = s 'NATUPNPLib'
             {
-                '0' { win32 = s '%MODULE%' }
+                '0' { win32 = s '%MODULE%\2' }
                 FLAGS = s '0'
             }
         }
@@ -16,5 +16,22 @@ HKCR
     }
     NoRemove CLSID
     {
+        '{AE1E00AA-3FD5-403C-8A27-2BBDC30CD0E1}' = s 'UPnPNAT'
+        {
+            InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Apartment' }
+            ProgId = s 'HNetCfg.NATUPnP.1'
+            TypeLib = s '{1C565858-F302-471E-B409-F180AA4ABEC6}'
+            Version = s '1.0'
+            VersionIndependentProgId = s 'HNetCfg.NATUPnP'
+        }
+    }
+    'HNetCfg.NATUPnP.1' = s 'UPnPNAT'
+    {
+        CLSID = s '{AE1E00AA-3FD5-403C-8A27-2BBDC30CD0E1}'
+    }
+    'HNetCfg.NATUPnP' = s 'UPnPNAT'
+    {
+        CLSID = s '{AE1E00AA-3FD5-403C-8A27-2BBDC30CD0E1}'
+        CurVer = s 'HNetCfg.NATUPnP.1'
     }
-}
+}
\ No newline at end of file
index 1d548b4..2c0790a 100644 (file)
@@ -16,7 +16,6 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#include "config.h"
 #include <stdarg.h>
 #include <stdio.h>
 
 #include "windef.h"
 #include "winbase.h"
 #include "winuser.h"
-#include "initguid.h"
 #include "ole2.h"
 #include "netfw.h"
 
 #include "wine/debug.h"
-#include "wine/unicode.h"
 #include "hnetcfg_private.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(hnetcfg);
index c2f3252..1f5b0da 100644 (file)
@@ -16,7 +16,6 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#include "config.h"
 #include <stdarg.h>
 #include <stdio.h>
 
@@ -29,7 +28,6 @@
 #include "netfw.h"
 
 #include "wine/debug.h"
-#include "wine/unicode.h"
 #include "hnetcfg_private.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(hnetcfg);
@@ -238,6 +236,10 @@ static HRESULT WINAPI netfw_rules_get__NewEnum(
     fw_rules *This = impl_from_INetFwRules( iface );
 
     FIXME("%p, %p\n", This, newEnum);
+
+    if (!newEnum) return E_POINTER;
+    *newEnum = NULL;
+
     return E_NOTIMPL;
 }
 
@@ -641,11 +643,8 @@ static HRESULT WINAPI fwpolicy2_get_Rules(INetFwPolicy2 *iface, INetFwRules **ru
     if(!rules)
         return E_POINTER;
 
-    if(rules)
-    {
-        *rules = This->fw_policy2_rules;
-        INetFwRules_AddRef(This->fw_policy2_rules);
-    }
+    *rules = This->fw_policy2_rules;
+    INetFwRules_AddRef(This->fw_policy2_rules);
 
     return S_OK;
 }
index 7d74965..bb33d6a 100644 (file)
@@ -16,7 +16,6 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#include "config.h"
 #include <stdarg.h>
 #include <stdio.h>
 
 #include "winuser.h"
 #include "ole2.h"
 #include "netfw.h"
+#include "natupnp.h"
 
+#include "wine/heap.h"
 #include "wine/debug.h"
-#include "wine/unicode.h"
 #include "hnetcfg_private.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(hnetcfg);
@@ -603,3 +603,173 @@ HRESULT NetFwOpenPorts_create( IUnknown *pUnkOuter, LPVOID *ppObj )
     TRACE("returning iface %p\n", *ppObj);
     return S_OK;
 }
+
+typedef struct _upnpnat
+{
+    IUPnPNAT IUPnPNAT_iface;
+    LONG ref;
+} upnpnat;
+
+static inline upnpnat *impl_from_IUPnPNAT( IUPnPNAT *iface )
+{
+    return CONTAINING_RECORD(iface, upnpnat, IUPnPNAT_iface);
+}
+
+static HRESULT WINAPI upnpnat_QueryInterface(IUPnPNAT *iface, REFIID riid, void **object)
+{
+    upnpnat *This = impl_from_IUPnPNAT( iface );
+
+    TRACE("%p %s %p\n", This, debugstr_guid( riid ), object );
+
+    if ( IsEqualGUID( riid, &IID_IUPnPNAT ) ||
+         IsEqualGUID( riid, &IID_IDispatch ) ||
+         IsEqualGUID( riid, &IID_IUnknown ) )
+    {
+        *object = iface;
+    }
+    else if(IsEqualGUID( riid, &IID_IProvideClassInfo))
+    {
+        TRACE("IProvideClassInfo not supported.\n");
+        return E_NOINTERFACE;
+    }
+    else
+    {
+        FIXME("interface %s not implemented\n", debugstr_guid(riid));
+        return E_NOINTERFACE;
+    }
+    IUPnPNAT_AddRef( iface );
+    return S_OK;
+}
+
+static ULONG WINAPI upnpnat_AddRef(IUPnPNAT *iface)
+{
+    upnpnat *This = impl_from_IUPnPNAT( iface );
+    return InterlockedIncrement( &This->ref );
+}
+
+static ULONG WINAPI upnpnat_Release(IUPnPNAT *iface)
+{
+    upnpnat *This = impl_from_IUPnPNAT( iface );
+    LONG refs = InterlockedDecrement( &This->ref );
+    if (!refs)
+    {
+        heap_free( This );
+    }
+    return refs;
+}
+
+static HRESULT WINAPI upnpnat_GetTypeInfoCount(IUPnPNAT *iface, UINT *pctinfo)
+{
+    upnpnat *This = impl_from_IUPnPNAT( iface );
+
+    TRACE("%p %p\n", This, pctinfo);
+    *pctinfo = 1;
+    return S_OK;
+}
+
+static HRESULT WINAPI upnpnat_GetTypeInfo(IUPnPNAT *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
+{
+    upnpnat *This = impl_from_IUPnPNAT( iface );
+
+    TRACE("%p %u %u %p\n", This, iTInfo, lcid, ppTInfo);
+    return get_typeinfo( IUPnPNAT_tid, ppTInfo );
+}
+
+static HRESULT WINAPI upnpnat_GetIDsOfNames(IUPnPNAT *iface, REFIID riid, LPOLESTR *rgszNames,
+                UINT cNames, LCID lcid, DISPID *rgDispId)
+{
+    upnpnat *This = impl_from_IUPnPNAT( iface );
+    ITypeInfo *typeinfo;
+    HRESULT hr;
+
+    TRACE("%p %s %p %u %u %p\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
+
+    hr = get_typeinfo( IUPnPNAT_tid, &typeinfo );
+    if (SUCCEEDED(hr))
+    {
+        hr = ITypeInfo_GetIDsOfNames( typeinfo, rgszNames, cNames, rgDispId );
+        ITypeInfo_Release( typeinfo );
+    }
+    return hr;
+}
+
+static HRESULT WINAPI upnpnat_Invoke(IUPnPNAT *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
+                WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo,
+                UINT *puArgErr)
+{
+    upnpnat *This = impl_from_IUPnPNAT( iface );
+    ITypeInfo *typeinfo;
+    HRESULT hr;
+
+    TRACE("%p %d %s %d %d %p %p %p %p\n", This, dispIdMember, debugstr_guid(riid),
+          lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
+
+    hr = get_typeinfo( IUPnPNAT_tid, &typeinfo );
+    if (SUCCEEDED(hr))
+    {
+        hr = ITypeInfo_Invoke( typeinfo, &This->IUPnPNAT_iface, dispIdMember,
+                               wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr );
+        ITypeInfo_Release( typeinfo );
+    }
+    return hr;
+}
+
+static HRESULT WINAPI upnpnat_get_StaticPortMappingCollection(IUPnPNAT *iface, IStaticPortMappingCollection **collection)
+{
+    upnpnat *This = impl_from_IUPnPNAT( iface );
+    FIXME("%p, %p\n", This, collection);
+    if(collection)
+        *collection = NULL;
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI upnpnat_get_DynamicPortMappingCollection(IUPnPNAT *iface, IDynamicPortMappingCollection **collection)
+{
+    upnpnat *This = impl_from_IUPnPNAT( iface );
+    FIXME("%p, %p\n", This, collection);
+    if(collection)
+        *collection = NULL;
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI upnpnat_get_NATEventManager(IUPnPNAT *iface, INATEventManager **manager)
+{
+    upnpnat *This = impl_from_IUPnPNAT( iface );
+    FIXME("%p, %p\n", This, manager);
+    if(manager)
+        *manager = NULL;
+    return E_NOTIMPL;
+}
+
+static const IUPnPNATVtbl upnpnat_vtbl =
+{
+    upnpnat_QueryInterface,
+    upnpnat_AddRef,
+    upnpnat_Release,
+    upnpnat_GetTypeInfoCount,
+    upnpnat_GetTypeInfo,
+    upnpnat_GetIDsOfNames,
+    upnpnat_Invoke,
+    upnpnat_get_StaticPortMappingCollection,
+    upnpnat_get_DynamicPortMappingCollection,
+    upnpnat_get_NATEventManager
+};
+
+
+HRESULT IUPnPNAT_create(IUnknown *outer, void **object)
+{
+    upnpnat *nat;
+
+    TRACE("(%p,%p)\n", outer, object);
+
+    nat = heap_alloc( sizeof(*nat) );
+    if (!nat) return E_OUTOFMEMORY;
+
+    nat->IUPnPNAT_iface.lpVtbl = &upnpnat_vtbl;
+    nat->ref = 1;
+
+    *object = &nat->IUPnPNAT_iface;
+
+    TRACE("returning iface %p\n", *object);
+    return S_OK;
+}
index 835e82e..d0e9f48 100644 (file)
@@ -16,7 +16,6 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#include "config.h"
 #include <stdarg.h>
 #include <stdio.h>
 
@@ -29,7 +28,6 @@
 #include "netfw.h"
 
 #include "wine/debug.h"
-#include "wine/unicode.h"
 #include "hnetcfg_private.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(hnetcfg);
index fa214b6..5bfeeda 100644 (file)
@@ -16,7 +16,6 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#include "config.h"
 #include <stdarg.h>
 #include <stdio.h>
 
@@ -29,7 +28,6 @@
 #include "netfw.h"
 
 #include "wine/debug.h"
-#include "wine/unicode.h"
 #include "hnetcfg_private.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(hnetcfg);
index a94f3ca..3d05172 100644 (file)
@@ -72,7 +72,7 @@ dll/win32/fusion              # Synced to WineStaging-3.17
 dll/win32/gdiplus             # Synced to WineStaging-4.0
 dll/win32/hhctrl.ocx          # Synced to WineStaging-4.0
 dll/win32/hlink               # Synced to WineStaging-4.0
-dll/win32/hnetcfg             # Synced to WineStaging-3.9
+dll/win32/hnetcfg             # Synced to WineStaging-4.18
 dll/win32/httpapi             # Synced to WineStaging-3.3
 dll/win32/iccvid              # Synced to WineStaging-4.0
 dll/win32/ieframe             # Synced to WineStaging-4.0