ReactOS 0.4.15-dev-7834-g00c4b3d
policy.c File Reference
#include <stdio.h>
#include "windows.h"
#include "ole2.h"
#include "oleauto.h"
#include "olectl.h"
#include "dispex.h"
#include "wine/test.h"
#include "netfw.h"
#include "natupnp.h"
Include dependency graph for policy.c:

Go to the source code of this file.

Macros

#define COBJMACROS
 

Functions

static void test_policy2_rules (INetFwPolicy2 *policy2)
 
static void test_interfaces (void)
 
static void test_NetFwAuthorizedApplication (void)
 
static void test_IUPnPNAT (void)
 
 START_TEST (policy)
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 18 of file policy.c.

Function Documentation

◆ START_TEST()

START_TEST ( policy  )

Definition at line 200 of file policy.c.

201{
202 INetFwMgr *manager;
203 HRESULT hr;
204
206
207 hr = CoCreateInstance(&CLSID_NetFwMgr, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
208 &IID_INetFwMgr, (void**)&manager);
209 if(FAILED(hr))
210 {
211 win_skip("NetFwMgr object is not supported: %08x\n", hr);
213 return;
214 }
215
216 INetFwMgr_Release(manager);
217
221
223}
#define NULL
Definition: types.h:112
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
#define FAILED(hr)
Definition: intsafe.h:51
static void test_IUPnPNAT(void)
Definition: policy.c:167
static void test_NetFwAuthorizedApplication(void)
Definition: policy.c:109
static void test_interfaces(void)
Definition: policy.c:70
#define win_skip
Definition: test.h:160
HRESULT hr
Definition: shlfolder.c:183

◆ test_interfaces()

static void test_interfaces ( void  )
static

Definition at line 70 of file policy.c.

71{
72 INetFwMgr *manager;
74 INetFwPolicy2 *policy2;
75 HRESULT hr;
76
77 hr = CoCreateInstance(&CLSID_NetFwMgr, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
78 &IID_INetFwMgr, (void**)&manager);
79 ok(hr == S_OK, "NetFwMgr create failed: %08x\n", hr);
80
81 hr = INetFwMgr_QueryInterface(manager, &IID_INetFwPolicy, (void**)&policy);
82 ok(hr == E_NOINTERFACE, "got 0x%08x\n", hr);
83
84 hr = INetFwMgr_QueryInterface(manager, &IID_INetFwPolicy2, (void**)&policy2);
85 ok(hr == E_NOINTERFACE, "got 0x%08x\n", hr);
86
87 hr = INetFwMgr_get_LocalPolicy(manager, &policy);
88 ok(hr == S_OK, "got 0x%08x\n", hr);
89
90 hr = INetFwPolicy_QueryInterface(policy, &IID_INetFwPolicy2, (void**)&policy2);
91 ok(hr == E_NOINTERFACE, "got 0x%08x\n", hr);
92
93 INetFwPolicy_Release(policy);
94
95 hr = CoCreateInstance(&CLSID_NetFwPolicy2, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
96 &IID_INetFwPolicy2, (void**)&policy2);
97 if(hr == S_OK)
98 {
99 test_policy2_rules(policy2);
100
101 INetFwPolicy2_Release(policy2);
102 }
103 else
104 win_skip("NetFwPolicy2 object is not supported: %08x\n", hr);
105
106 INetFwMgr_Release(manager);
107}
#define ok(value,...)
Definition: atltest.h:57
WDF_INTERRUPT_POLICY policy
#define S_OK
Definition: intsafe.h:52
static void test_policy2_rules(INetFwPolicy2 *policy2)
Definition: policy.c:32
#define E_NOINTERFACE
Definition: winerror.h:2364

Referenced by START_TEST().

◆ test_IUPnPNAT()

static void test_IUPnPNAT ( void  )
static

Definition at line 167 of file policy.c.

168{
169 IUPnPNAT *nat;
170 IStaticPortMappingCollection *static_ports;
172 INATEventManager *manager;
173 IProvideClassInfo *provider;
174 HRESULT hr;
175
176 hr = CoCreateInstance(&CLSID_UPnPNAT, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER, &IID_IUPnPNAT, (void**)&nat);
177 ok(hr == S_OK, "got: %08x\n", hr);
178
179 hr = IUPnPNAT_QueryInterface(nat, &IID_IProvideClassInfo, (void**)&provider);
180 ok(hr == E_NOINTERFACE, "got: %08x\n", hr);
181
182 hr = IUPnPNAT_get_StaticPortMappingCollection(nat, &static_ports);
183 todo_wine ok(hr == S_OK, "got: %08x\n", hr);
184 if(hr == S_OK && static_ports)
185 IStaticPortMappingCollection_Release(static_ports);
186
187 hr = IUPnPNAT_get_DynamicPortMappingCollection(nat, &dync_ports);
188 ok(hr == S_OK || hr == E_NOTIMPL /* Windows 8.1 */, "got: %08x\n", hr);
189 if(hr == S_OK && dync_ports)
190 IDynamicPortMappingCollection_Release(dync_ports);
191
192 hr = IUPnPNAT_get_NATEventManager(nat, &manager);
193 todo_wine ok(hr == S_OK, "got: %08x\n", hr);
194 if(hr == S_OK && manager)
195 INATEventManager_Release(manager);
196
197 IUPnPNAT_Release(nat);
198}
#define E_NOTIMPL
Definition: ddrawi.h:99
#define todo_wine
Definition: custom.c:79
const GUID IID_IProvideClassInfo

Referenced by START_TEST().

◆ test_NetFwAuthorizedApplication()

static void test_NetFwAuthorizedApplication ( void  )
static

Definition at line 109 of file policy.c.

110{
112 static WCHAR empty[] = {0};
114 WCHAR fullpath[MAX_PATH];
115 WCHAR netpath[MAX_PATH];
117 HRESULT hr;
118 BSTR bstr;
119 DWORD sz;
120
121 hr = CoCreateInstance(&CLSID_NetFwAuthorizedApplication, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
122 &IID_INetFwAuthorizedApplication, (void**)&app);
123 ok(hr == S_OK, "got: %08x\n", hr);
124
126 ok(hr, "GetModuleFileName failed: %u\n", GetLastError());
127
128 hr = INetFwAuthorizedApplication_get_ProcessImageFileName(app, NULL);
129 ok(hr == E_POINTER, "got: %08x\n", hr);
130
131 hr = INetFwAuthorizedApplication_get_ProcessImageFileName(app, &bstr);
132 ok(hr == S_OK || hr == HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY), "got: %08x\n", hr);
133 ok(!bstr, "got: %s\n", wine_dbgstr_w(bstr));
134
135 hr = INetFwAuthorizedApplication_put_ProcessImageFileName(app, NULL);
136 ok(hr == E_INVALIDARG || hr == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), "got: %08x\n", hr);
137
138 hr = INetFwAuthorizedApplication_put_ProcessImageFileName(app, empty);
139 ok(hr == E_INVALIDARG || hr == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), "got: %08x\n", hr);
140
141 bstr = SysAllocString(image);
142 hr = INetFwAuthorizedApplication_put_ProcessImageFileName(app, bstr);
143 ok(hr == S_OK, "got: %08x\n", hr);
144 SysFreeString(bstr);
145
146 GetFullPathNameW(image, ARRAY_SIZE(fullpath), fullpath, NULL);
147 GetLongPathNameW(fullpath, fullpath, ARRAY_SIZE(fullpath));
148
149 info = (UNIVERSAL_NAME_INFOW *)&netpath;
150 sz = sizeof(netpath);
152 if (hr != NO_ERROR)
153 {
154 info->lpUniversalName = netpath + sizeof(*info)/sizeof(WCHAR);
155 lstrcpyW(info->lpUniversalName, fullpath);
156 }
157
158 hr = INetFwAuthorizedApplication_get_ProcessImageFileName(app, &bstr);
159 ok(hr == S_OK, "got: %08x\n", hr);
160 ok(!lstrcmpW(bstr,info->lpUniversalName), "expected %s, got %s\n",
161 wine_dbgstr_w(info->lpUniversalName), wine_dbgstr_w(bstr));
162 SysFreeString(bstr);
163
164 INetFwAuthorizedApplication_Release(app);
165}
#define ARRAY_SIZE(A)
Definition: main.h:33
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define NO_ERROR
Definition: dderror.h:5
#define E_INVALIDARG
Definition: ddrawi.h:101
static const WCHAR empty[]
Definition: main.c:47
OLECHAR * BSTR
Definition: compat.h:2293
#define MAX_PATH
Definition: compat.h:34
#define lstrcpyW
Definition: compat.h:749
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
DWORD WINAPI GetLongPathNameW(IN LPCWSTR lpszShortPath, OUT LPWSTR lpszLongPath, IN DWORD cchBuffer)
Definition: path.c:1456
DWORD WINAPI GetFullPathNameW(IN LPCWSTR lpFileName, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart)
Definition: path.c:1106
unsigned long DWORD
Definition: ntddk_ex.h:95
#define wine_dbgstr_w
Definition: kernel32.h:34
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:238
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:271
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:106
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define E_POINTER
Definition: winerror.h:2365
#define UNIVERSAL_NAME_INFO_LEVEL
Definition: winnetwk.h:151
DWORD WINAPI WNetGetUniversalNameW(LPCWSTR lpLocalPath, DWORD dwInfoLevel, LPVOID lpBuffer, LPDWORD lpBufferSize)
Definition: wnet.c:2777
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST().

◆ test_policy2_rules()

static void test_policy2_rules ( INetFwPolicy2 policy2)
static

Definition at line 32 of file policy.c.

33{
34 HRESULT hr;
35 INetFwRules *rules, *rules2;
36 INetFwServiceRestriction *restriction;
37
38 hr = INetFwPolicy2_QueryInterface(policy2, &IID_INetFwRules, (void**)&rules);
39 ok(hr == E_NOINTERFACE, "got 0x%08x\n", hr);
40
41 hr = INetFwPolicy2_get_Rules(policy2, &rules);
42 ok(hr == S_OK, "got %08x\n", hr);
43
44 hr = INetFwPolicy2_get_Rules(policy2, &rules2);
45 ok(hr == S_OK, "got %08x\n", hr);
46 ok(rules == rules2, "Different pointers\n");
47
48 hr = INetFwPolicy2_get_ServiceRestriction(policy2, &restriction);
49 todo_wine ok(hr == S_OK, "got %08x\n", hr);
50 if(hr == S_OK)
51 {
52 INetFwRules *rules3;
53
54 hr = INetFwServiceRestriction_get_Rules(restriction, &rules3);
55 ok(hr == S_OK, "got %08x\n", hr);
56 ok(rules != rules3, "same pointers\n");
57
58 if(rules3)
59 INetFwRules_Release(rules3);
60 INetFwServiceRestriction_Release(restriction);
61 }
62
63 hr = INetFwRules_get__NewEnum(rules, NULL);
64 ok(hr == E_POINTER, "got %08x\n", hr);
65
66 INetFwRules_Release(rules);
67 INetFwRules_Release(rules2);
68}

Referenced by test_interfaces().