VirtualBox

source: vbox/trunk/src/VBox/HostDrivers/VBoxNetFlt/win/notifyobj/VBoxNetFltNotify.cpp@ 29217

Last change on this file since 29217 was 29025, checked in by vboxsync, 15 years ago

netflt/win: unregister notify object properly (public bug #5780)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 21.7 KB
Line 
1/*
2 * Copyright (C) 2008 Oracle Corporation
3 *
4 * This file is part of VirtualBox Open Source Edition (OSE), as
5 * available from http://www.virtualbox.org. This file is free software;
6 * you can redistribute it and/or modify it under the terms of the GNU
7 * General Public License (GPL) as published by the Free Software
8 * Foundation, in version 2 as it comes in the "COPYING" file of the
9 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
10 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
11 */
12/*
13 * Based in part on Microsoft DDK sample code for Sample Notify Object
14 *+---------------------------------------------------------------------------
15 *
16 * Microsoft Windows
17 * Copyright (C) Microsoft Corporation, 1992-2001.
18 *
19 * Author: Alok Sinha
20 *
21 *----------------------------------------------------------------------------
22 */
23#include "VBoxNetFltNotify.h"
24#include <Ntddndis.h>
25#include <assert.h>
26#include <stdio.h>
27
28#include <VBoxNetFltNotifyn_i.c>
29
30CComModule _Module;
31
32BEGIN_OBJECT_MAP(ObjectMap)
33 OBJECT_ENTRY(CLSID_VBoxNetFltNotify, VBoxNetFltNotify)
34END_OBJECT_MAP()
35
36#define ReleaseObj( x ) if ( x ) \
37 ((IUnknown*)(x))->Release();
38
39//# define VBOXNETFLTNOTIFY_DEBUG_BIND true
40
41#ifdef DEBUG
42# define Assert(a) assert(a)
43# define AssertBreakpoint() assert(0)
44
45# define TraceMsg DbgTraceMsg
46#else
47# define Assert(a) do{}while(0)
48# define AssertBreakpoint() do{}while(0)
49
50# define TraceMsg
51#endif
52
53
54static void DbgTraceMsg (LPWSTR szFormat, ...)
55{
56 static WCHAR szTempBuf[4096];
57
58 va_list arglist;
59
60 va_start(arglist, szFormat);
61
62 vswprintf( szTempBuf, szFormat, arglist );
63
64 OutputDebugStringW( szTempBuf );
65
66 va_end(arglist);
67}
68
69VBoxNetFltNotify::VBoxNetFltNotify (VOID) : m_pncc (NULL),
70 m_pnc(NULL)
71 /*,
72 m_eApplyAction(eActUnknown),
73 m_pUnkContext(NULL)*/
74{
75 TraceMsg(L"VBoxNetFltNotify\n");
76}
77
78VBoxNetFltNotify::~VBoxNetFltNotify (VOID)
79{
80 TraceMsg(L"-->~VBoxNetFltNotify (destructor)\n");
81 ReleaseObj( m_pncc );
82 ReleaseObj( m_pnc );
83 TraceMsg(L"<--~VBoxNetFltNotify (destructor)\n");
84}
85
86/*
87 * NOTIFY OBJECT FUNCTIONS
88 */
89
90/*
91 * INetCfgComponentControl
92 *
93 * The following functions provide the INetCfgComponentControl interface.
94 */
95
96/**
97 * Initialize the notify object
98 *
99 * @param pnccItem Pointer to INetCfgComponent object
100 * @param pnc Pointer to INetCfg object
101 * @param fInstalling TRUE if we are being installed
102 * @return S_OK on success, otherwise an error code
103 */
104STDMETHODIMP VBoxNetFltNotify::Initialize (INetCfgComponent* pncc,
105 INetCfg* pnc,
106 BOOL fInstalling)
107{
108 HRESULT hr = S_OK;
109
110 TraceMsg(L"-->Initialize\n");
111
112 m_pncc = pncc;
113 m_pnc = pnc;
114
115 if (m_pncc)
116 {
117 m_pncc->AddRef();
118 }
119
120 if (m_pnc)
121 {
122 m_pnc->AddRef();
123 }
124
125 TraceMsg(L"<--Initialize\n");
126
127 return hr;
128}
129
130/**
131 * Cancel any changes made to internal data
132 * @return S_OK on success, otherwise an error code
133 */
134STDMETHODIMP VBoxNetFltNotify::CancelChanges (VOID)
135{
136 TraceMsg(L"CancelChanges\n");
137 return S_OK;
138}
139
140/*
141 * Apply changes. We can make changes to registry etc. here.
142 * @return S_OK on success, otherwise an error code
143 */
144STDMETHODIMP VBoxNetFltNotify::ApplyRegistryChanges(VOID)
145{
146 TraceMsg(L"ApplyRegistryChanges\n");
147 return S_OK;
148}
149
150/**
151 * Apply changes.
152 * @param pfCallback PnPConfigCallback interface.
153 * @return S_OK on success, otherwise an error code
154 */
155STDMETHODIMP VBoxNetFltNotify::ApplyPnpChanges (
156 INetCfgPnpReconfigCallback* pfCallback)
157{
158 TraceMsg(L"ApplyPnpChanges\n");
159 return S_OK;
160}
161
162static HRESULT vboxNetFltWinQueryInstanceKey(IN INetCfgComponent *pComponent, OUT PHKEY phKey)
163{
164 LPWSTR pPnpId;
165 HRESULT hr = pComponent->GetPnpDevNodeId(&pPnpId);
166 if(hr == S_OK)
167 {
168 WCHAR KeyName[MAX_PATH];
169 wcscpy(KeyName, L"SYSTEM\\CurrentControlSet\\Enum\\");
170 wcscat(KeyName,pPnpId);
171
172 LONG winEr = RegOpenKeyExW(HKEY_LOCAL_MACHINE, KeyName,
173 0, /*__reserved DWORD ulOptions*/
174 KEY_READ, /*__in REGSAM samDesired*/
175 phKey);
176
177 if(winEr != ERROR_SUCCESS)
178 {
179 hr = HRESULT_FROM_WIN32(winEr);
180 TraceMsg(L"vboxNetFltWinQueryInstanceKey: RegOpenKeyExW error, hr (0x%x)\n", hr);
181 AssertBreakpoint();
182 }
183
184 CoTaskMemFree(pPnpId);
185 }
186 else
187 {
188 TraceMsg(L"vboxNetFltWinQueryInstanceKey: GetPnpDevNodeId error, hr (0x%x)\n", hr);
189 AssertBreakpoint();
190 }
191
192 return hr;
193}
194
195static HRESULT vboxNetFltWinQueryDriverKey(IN HKEY InstanceKey, OUT PHKEY phKey)
196{
197 DWORD Type = REG_SZ;
198 WCHAR Value[MAX_PATH];
199 DWORD cbValue = sizeof(Value);
200 HRESULT hr = S_OK;
201 LONG winEr = RegQueryValueExW(InstanceKey,
202 L"Driver", /*__in_opt LPCTSTR lpValueName*/
203 0, /*__reserved LPDWORD lpReserved*/
204 &Type, /*__out_opt LPDWORD lpType*/
205 (LPBYTE)Value, /*__out_opt LPBYTE lpData*/
206 &cbValue/*__inout_opt LPDWORD lpcbData*/
207 );
208
209 if(winEr == ERROR_SUCCESS)
210 {
211 WCHAR KeyName[MAX_PATH];
212 wcscpy(KeyName, L"SYSTEM\\CurrentControlSet\\Control\\Class\\");
213 wcscat(KeyName,Value);
214
215 winEr = RegOpenKeyExW(HKEY_LOCAL_MACHINE, KeyName,
216 0, /*__reserved DWORD ulOptions*/
217 KEY_READ, /*__in REGSAM samDesired*/
218 phKey);
219
220 if(winEr != ERROR_SUCCESS)
221 {
222 hr = HRESULT_FROM_WIN32(winEr);
223 TraceMsg(L"vboxNetFltWinQueryDriverKey from instance key: RegOpenKeyExW error, hr (0x%x)\n", hr);
224 AssertBreakpoint();
225 }
226 }
227 else
228 {
229 hr = HRESULT_FROM_WIN32(winEr);
230 TraceMsg(L"vboxNetFltWinQueryDriverKey from instance key: RegQueryValueExW error, hr (0x%x)\n", hr);
231 AssertBreakpoint();
232 }
233
234 return hr;
235}
236
237static HRESULT vboxNetFltWinQueryDriverKey(IN INetCfgComponent *pComponent, OUT PHKEY phKey)
238{
239 HKEY InstanceKey;
240 HRESULT hr = vboxNetFltWinQueryInstanceKey(pComponent, &InstanceKey);
241 if(hr == S_OK)
242 {
243 hr = vboxNetFltWinQueryDriverKey(InstanceKey, phKey);
244 if(hr != S_OK)
245 {
246 TraceMsg(L"vboxNetFltWinQueryDriverKey from Component: vboxNetFltWinQueryDriverKey error, hr (0x%x)\n", hr);
247 AssertBreakpoint();
248 }
249 RegCloseKey(InstanceKey);
250 }
251 else
252 {
253 TraceMsg(L"vboxNetFltWinQueryDriverKey from Component: vboxNetFltWinQueryInstanceKey error, hr (0x%x)\n", hr);
254 AssertBreakpoint();
255 }
256
257 return hr;
258}
259
260static HRESULT vboxNetFltWinNotifyCheckNetAdp(IN INetCfgComponent *pComponent, OUT bool * pbShouldBind)
261{
262 HRESULT hr;
263 LPWSTR pDevId;
264 hr = pComponent->GetId(&pDevId);
265 if(hr == S_OK)
266 {
267 if(!_wcsnicmp(pDevId, L"sun_VBoxNetAdp", sizeof(L"sun_VBoxNetAdp")/2))
268 {
269 *pbShouldBind = false;
270 }
271 else
272 {
273 hr = S_FALSE;
274 }
275 CoTaskMemFree(pDevId);
276 }
277 else
278 {
279 TraceMsg(L"vboxNetFltWinNotifyCheckNetAdp: GetId failed, hr (0x%x)\n", hr);
280 AssertBreakpoint();
281 }
282
283 return hr;
284}
285
286static HRESULT vboxNetFltWinNotifyCheckMsLoop(IN INetCfgComponent *pComponent, OUT bool * pbShouldBind)
287{
288 HRESULT hr;
289 LPWSTR pDevId;
290 hr = pComponent->GetId(&pDevId);
291 if(hr == S_OK)
292 {
293 if(!_wcsnicmp(pDevId, L"*msloop", sizeof(L"*msloop")/2))
294 {
295 /* we need to detect the medium the adapter is presenting
296 * to do that we could examine in the registry the *msloop params */
297 HKEY DriverKey;
298 hr = vboxNetFltWinQueryDriverKey(pComponent, &DriverKey);
299 if(hr == S_OK)
300 {
301 DWORD Type = REG_SZ;
302 WCHAR Value[64]; /* 2 should be enough actually, paranoid check for extra spaces */
303 DWORD cbValue = sizeof(Value);
304 LONG winEr = RegQueryValueExW(DriverKey,
305 L"Medium", /*__in_opt LPCTSTR lpValueName*/
306 0, /*__reserved LPDWORD lpReserved*/
307 &Type, /*__out_opt LPDWORD lpType*/
308 (LPBYTE)Value, /*__out_opt LPBYTE lpData*/
309 &cbValue/*__inout_opt LPDWORD lpcbData*/
310 );
311 if(winEr == ERROR_SUCCESS)
312 {
313 PWCHAR endPrt;
314 ULONG enmMedium = wcstoul(Value,
315 &endPrt,
316 0 /* base*/);
317
318 winEr = errno;
319 if(winEr == ERROR_SUCCESS)
320 {
321 if(enmMedium == 0) /* 0 is Ethernet */
322 {
323 TraceMsg(L"vboxNetFltWinNotifyCheckMsLoop: loopback is configured as ethernet, binding\n", winEr);
324 *pbShouldBind = true;
325 }
326 else
327 {
328 TraceMsg(L"vboxNetFltWinNotifyCheckMsLoop: loopback is configured as NOT ethernet, NOT binding\n", winEr);
329 *pbShouldBind = false;
330 }
331 }
332 else
333 {
334 TraceMsg(L"vboxNetFltWinNotifyCheckMsLoop: wcstoul error, winEr (%d), ignoring and binding\n", winEr);
335 AssertBreakpoint();
336 *pbShouldBind = true;
337 }
338 }
339 else
340 {
341 TraceMsg(L"vboxNetFltWinNotifyCheckMsLoop: RegQueryValueExW failed, winEr (%d), ignoring, binding\n", hr);
342 /* TODO: we should check the default medium in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\<driver_id>\Ndi\Params\Medium, REG_SZ "Default" value */
343 AssertBreakpoint();
344 *pbShouldBind = true;
345 }
346
347 RegCloseKey(DriverKey);
348 }
349 else
350 {
351 TraceMsg(L"vboxNetFltWinNotifyCheckMsLoop: vboxNetFltWinQueryDriverKey for msloop failed, hr (0x%x)\n", hr);
352 AssertBreakpoint();
353 }
354 }
355 else
356 {
357 hr = S_FALSE;
358 }
359 CoTaskMemFree(pDevId);
360 }
361 else
362 {
363 TraceMsg(L"vboxNetFltWinNotifyCheckMsLoop: GetId failed, hr (0x%x)\n", hr);
364 AssertBreakpoint();
365 }
366
367 return hr;
368}
369
370static HRESULT vboxNetFltWinNotifyCheckLowerRange(IN INetCfgComponent *pComponent, OUT bool * pbShouldBind)
371{
372 HKEY DriverKey;
373 HKEY InterfacesKey;
374 HRESULT hr = vboxNetFltWinQueryDriverKey(pComponent, &DriverKey);
375 if(hr == S_OK)
376 {
377 LONG winEr = RegOpenKeyExW(DriverKey, L"Ndi\\Interfaces",
378 0, /*__reserved DWORD ulOptions*/
379 KEY_READ, /*__in REGSAM samDesired*/
380 &InterfacesKey);
381 if(winEr == ERROR_SUCCESS)
382 {
383 DWORD Type = REG_SZ;
384 WCHAR Value[MAX_PATH];
385 DWORD cbValue = sizeof(Value);
386 winEr = RegQueryValueExW(InterfacesKey,
387 L"LowerRange", /*__in_opt LPCTSTR lpValueName*/
388 0, /*__reserved LPDWORD lpReserved*/
389 &Type, /*__out_opt LPDWORD lpType*/
390 (LPBYTE)Value, /*__out_opt LPBYTE lpData*/
391 &cbValue/*__inout_opt LPDWORD lpcbData*/
392 );
393 if(winEr == ERROR_SUCCESS)
394 {
395 if(wcsstr(Value,L"ethernet") || wcsstr(Value, L"wan"))
396 {
397 *pbShouldBind = true;
398 }
399 else
400 {
401 *pbShouldBind = false;
402 }
403 }
404 else
405 {
406 /* do not set err status to it */
407 *pbShouldBind = false;
408 TraceMsg(L"vboxNetFltWinNotifyCheckLowerRange: RegQueryValueExW for LowerRange error, winEr (%d), not binding\n", winEr);
409 AssertBreakpoint();
410 }
411
412 RegCloseKey(InterfacesKey);
413 }
414 else
415 {
416 hr = HRESULT_FROM_WIN32(winEr);
417 TraceMsg(L"vboxNetFltWinNotifyCheckLowerRange: RegOpenKeyExW error, hr (0x%x)\n", hr);
418 AssertBreakpoint();
419 }
420
421 RegCloseKey(DriverKey);
422 }
423 else
424 {
425 TraceMsg(L"vboxNetFltWinNotifyShouldBind for INetCfgComponen: vboxNetFltWinQueryDriverKey failed, hr (0x%x)\n", hr);
426 AssertBreakpoint();
427 }
428
429 return hr;
430}
431
432static HRESULT vboxNetFltWinNotifyShouldBind(IN INetCfgComponent *pComponent, OUT bool *pbShouldBind)
433{
434 TraceMsg(L"-->vboxNetFltWinNotifyShouldBind for INetCfgComponent\n");
435 DWORD fCharacteristics;
436 HRESULT hr;
437
438 do
439 {
440 /* filter out only physical adapters */
441 hr = pComponent->GetCharacteristics(&fCharacteristics);
442 if(hr != S_OK)
443 {
444 TraceMsg(L"vboxNetFltWinNotifyShouldBind for INetCfgComponen: GetCharacteristics failed, hr (0x%x)\n", hr);
445 AssertBreakpoint();
446 break;
447 }
448
449
450 if(fCharacteristics & NCF_HIDDEN)
451 {
452 /* we are not binding to hidden adapters */
453 *pbShouldBind = false;
454 break;
455 }
456
457 hr = vboxNetFltWinNotifyCheckMsLoop(pComponent, pbShouldBind);
458 if(hr == S_OK)
459 {
460 /* this is a loopback adapter,
461 * the pbShouldBind already contains the result */
462 break;
463 }
464 else if(hr != S_FALSE)
465 {
466 /* error occurred */
467 break;
468 }
469
470 hr = vboxNetFltWinNotifyCheckNetAdp(pComponent, pbShouldBind);
471 if(hr == S_OK)
472 {
473 /* this is a VBoxNetAdp adapter,
474 * the pbShouldBind already contains the result */
475 break;
476 }
477 else if(hr != S_FALSE)
478 {
479 /* error occurred */
480 break;
481 }
482
483 /* hr == S_FALSE means this is not a loopback adpater, set it to S_OK */
484 hr = S_OK;
485
486// if(!(fCharacteristics & NCF_PHYSICAL))
487// {
488// /* we are binding to physical adapters only */
489// *pbShouldBind = false;
490// break;
491// }
492
493 hr = vboxNetFltWinNotifyCheckLowerRange(pComponent, pbShouldBind);
494 if(hr == S_OK)
495 {
496 /* the vboxNetFltWinNotifyCheckLowerRange ccucceeded,
497 * the pbShouldBind already contains the result */
498 break;
499 }
500 /* we are here because of the fail, nothing else to do */
501 } while(0);
502
503 TraceMsg(L"<--vboxNetFltWinNotifyShouldBind for INetCfgComponent, hr (0x%x)\n", hr);
504
505 return hr;
506}
507
508
509static HRESULT vboxNetFltWinNotifyShouldBind(IN INetCfgBindingInterface *pIf, OUT bool *pbShouldBind)
510{
511 TraceMsg(L"-->vboxNetFltWinNotifyShouldBind for INetCfgBindingInterface\n");
512
513 INetCfgComponent * pAdapterComponent;
514 HRESULT hr = pIf->GetLowerComponent(&pAdapterComponent);
515 if(hr == S_OK)
516 {
517 hr = vboxNetFltWinNotifyShouldBind(pAdapterComponent, pbShouldBind);
518
519 pAdapterComponent->Release();
520 }
521 else
522 {
523 TraceMsg(L"vboxNetFltWinNotifyShouldBind: GetLowerComponent failed, hr (0x%x)\n", hr);
524 AssertBreakpoint();
525 }
526
527 TraceMsg(L"<--vboxNetFltWinNotifyShouldBind for INetCfgBindingInterface, hr (0x%x)\n", hr);
528 return hr;
529}
530
531static HRESULT vboxNetFltWinNotifyShouldBind(IN INetCfgBindingPath *pPath, OUT bool * pbDoBind)
532{
533 TraceMsg(L"-->vboxNetFltWinNotifyShouldBind for INetCfgBindingPath\n");
534 IEnumNetCfgBindingInterface *pEnumBindingIf;
535 HRESULT hr = pPath->EnumBindingInterfaces(&pEnumBindingIf);
536
537 if(hr == S_OK)
538 {
539 hr = pEnumBindingIf->Reset();
540 if(hr == S_OK)
541 {
542 ULONG ulCount;
543 INetCfgBindingInterface *pBindingIf;
544
545 do
546 {
547 hr = pEnumBindingIf->Next( 1,
548 &pBindingIf,
549 &ulCount );
550 if(hr == S_OK)
551 {
552 hr = vboxNetFltWinNotifyShouldBind(pBindingIf, pbDoBind);
553
554 pBindingIf->Release();
555
556 if(hr == S_OK)
557 {
558 if(!(*pbDoBind))
559 {
560 break;
561 }
562 }
563 else
564 {
565 /* break on failure */
566 break;
567 }
568 }
569 else if(hr == S_FALSE)
570 {
571 /* no more elements */
572 hr = S_OK;
573 break;
574 }
575 else
576 {
577 TraceMsg(L"vboxNetFltWinNotifyShouldBind: Next failed, hr (0x%x)\n", hr);
578 AssertBreakpoint();
579 /* break on falure */
580 break;
581 }
582 } while(true);
583 }
584 else
585 {
586 TraceMsg(L"vboxNetFltWinNotifyShouldBind: Reset failed, hr (0x%x)\n", hr);
587 AssertBreakpoint();
588 }
589
590 pEnumBindingIf->Release();
591 }
592 else
593 {
594 TraceMsg(L"vboxNetFltWinNotifyShouldBind: EnumBindingInterfaces failed, hr (0x%x)\n", hr);
595 AssertBreakpoint();
596 }
597
598 TraceMsg(L"<--vboxNetFltWinNotifyShouldBind for INetCfgBindingPath, hr (0x%x)\n", hr);
599 return hr;
600}
601
602static bool vboxNetFltWinNotifyShouldBind(IN INetCfgBindingPath *pPath)
603{
604#ifdef VBOXNETFLTNOTIFY_DEBUG_BIND
605 return VBOXNETFLTNOTIFY_DEBUG_BIND;
606#else
607 HRESULT hr;
608 bool bShouldBind;
609
610 TraceMsg( L"-->vboxNetFltWinNotifyShouldBind\n");
611
612 hr = vboxNetFltWinNotifyShouldBind(pPath, &bShouldBind) ;
613 if(hr != S_OK)
614 {
615 TraceMsg( L"vboxNetFltWinNotifyShouldBind: vboxNetFltWinNotifyShouldBind failed, hr (0x%x)\n", hr );
616 bShouldBind = VBOXNETFLTNOTIFY_ONFAIL_BINDDEFAULT;
617 }
618
619
620 TraceMsg( L"<--vboxNetFltWinNotifyShouldBind, bShouldBind (%d)\n", bShouldBind);
621 return bShouldBind;
622#endif
623}
624
625/*
626 * INetCfgComponentNotifyBinding
627 * The following functions provide the INetCfgComponentNotifyBinding interface.
628 */
629
630/**
631 * This is specific to the component being installed. This will
632 * ask us if we want to bind to the Item being passed into
633 * this routine. We can disable the binding by returning
634 * NETCFG_S_DISABLE_QUERY
635 *
636 * @param dwChangeFlag Type of binding change
637 * @param pncbpItem Pointer to INetCfgBindingPath object
638 * @return S_OK on success, otherwise an error code.
639 */
640STDMETHODIMP VBoxNetFltNotify::QueryBindingPath (IN DWORD dwChangeFlag,
641 IN INetCfgBindingPath *pPath)
642{
643 HRESULT hr = S_OK;
644 TraceMsg( L"-->QueryBindingPath, flags (0x%x)\n", dwChangeFlag );
645
646 if(!vboxNetFltWinNotifyShouldBind(pPath))
647 {
648 TraceMsg( L"QueryBindingPath: we are NOT supporting the current component\n");
649 hr = NETCFG_S_DISABLE_QUERY;
650 }
651 else
652 {
653 TraceMsg( L"QueryBindingPath: we are supporting the current component\n");
654 }
655 TraceMsg( L"<--QueryBindingPath, hr (0x%x)\n", hr);
656 return hr;
657}
658
659/**
660 * bind to the component passed to us.
661 * @param dwChangeFlag Type of system change
662 * @param pncc Pointer to INetCfgComponent object
663 * @return S_OK on success, otherwise an error code
664 */
665STDMETHODIMP VBoxNetFltNotify::NotifyBindingPath (IN DWORD dwChangeFlag,
666 IN INetCfgBindingPath *pPath)
667{
668 HRESULT hr = S_OK;
669
670 TraceMsg( L"-->NotifyBindingPath, flags (0x%x)\n", dwChangeFlag );
671 /* NCN_ADD | NCN_ENABLE
672 * NCN_REMOVE | NCN_ENABLE
673 * NCN_ADD | NCN_DISABLE
674 * NCN_REMOVE | NCN_DISABLE
675 * */
676 if ( (dwChangeFlag & NCN_ENABLE) && !(dwChangeFlag & NCN_REMOVE))
677 {
678 if(!vboxNetFltWinNotifyShouldBind(pPath))
679 {
680 TraceMsg( L"NotifyBindingPath: binding enabled for the component we are not supporting\n");
681 AssertBreakpoint();
682 hr = NETCFG_S_DISABLE_QUERY;
683 }
684 }
685
686 TraceMsg( L"<--NotifyBindingPath, hr (0x%x)\n", hr);
687
688 return hr;
689}
690
691/*
692 * DLL Entry Point
693 */
694extern "C"
695BOOL WINAPI DllMain (HINSTANCE hInstance,
696 DWORD dwReason,
697 LPVOID /*lpReserved*/)
698{
699 TraceMsg( L"-->DllMain.\n");
700
701 if (dwReason == DLL_PROCESS_ATTACH) {
702
703 TraceMsg( L" Reason: Attach.\n");
704
705 _Module.Init(ObjectMap, hInstance);
706
707 DisableThreadLibraryCalls(hInstance);
708 }
709 else if (dwReason == DLL_PROCESS_DETACH) {
710
711 TraceMsg( L" Reason: Detach.\n");
712
713 _Module.Term();
714 }
715
716 TraceMsg( L"<--DllMain.\n");
717
718 return TRUE;
719}
720
721/*
722 * Used to determine whether the DLL can be unloaded by OLE
723 */
724STDAPI DllCanUnloadNow(void)
725{
726 HRESULT hr;
727
728 TraceMsg( L"-->DllCanUnloadNow.\n");
729
730 hr = (_Module.GetLockCount() == 0) ? S_OK : S_FALSE;
731
732 TraceMsg( L"<--DllCanUnloadNow, hr (0x%x).\n",
733 hr );
734
735 return hr;
736}
737
738/*
739 * Returns a class factory to create an object of the requested type
740 */
741STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
742{
743 TraceMsg( L"DllGetClassObject.\n");
744
745 return _Module.GetClassObject(rclsid, riid, ppv);
746}
747
748
749/*
750 * DllRegisterServer - Adds entries to the system registry
751 */
752STDAPI DllRegisterServer(void)
753{
754 /* Registers object, typelib and all interfaces in typelib */
755
756 TraceMsg( L"DllRegisterServer.\n");
757
758 return _Module.RegisterServer(TRUE);
759}
760
761/*
762 * DllUnregisterServer - Removes entries from the system registry
763 */
764STDAPI DllUnregisterServer(void)
765{
766 TraceMsg( L"DllUnregisterServer.\n");
767 _Module.UnregisterServer(TRUE);
768 return S_OK;
769}
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette