Skip to content

Commit

Permalink
- Refactor driver unload functions.
Browse files Browse the repository at this point in the history
- Packet direction fix for netfilter example.
- Bump version to 1.1.2-rc.
  • Loading branch information
basil00 committed Dec 25, 2013
1 parent 5793471 commit 33f6bec
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 35 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ WinDivert 1.0.4
WinDivert 1.0.5
- Fix the DIVERT_NETWORK_FORWARD_LAYER implementation.
- Upgrade Visual Studio support to 2012.
WinDivert 1.1.0
WinDivert 1.1.0-rc
- Re-brand "DIVERT" to "WINDIVERT" throughout the code-base.
- New flag:
* WINDIVERT_FLAG_NO_CHECKSUM: Do not guarantee that diverted packets
Expand All @@ -36,3 +36,8 @@ WinDivert 1.1.0
load.
WinDivert 1.1.1
- Fixed a BSOD that sometimes occurs when the driver is unloaded.
WinDivert 1.1.2-rc
- Renamed drivers to "WinDivert32.sys" and "WinDivert64.sys". Both can
exist in the same directory, and WinDivert.dll automatically loads the
right correct version.
- Deprecate both the WinDivert.inf and WdfCoInstaller*.dll files.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.1
1.1.2-rc
2 changes: 1 addition & 1 deletion examples/netfilter/netfilter.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ int __cdecl main(int argc, char **argv)
WinDivertHelperCalcChecksums((PVOID)dnrv6, icmpv6_length, 0);

memcpy(&send_addr, &recv_addr, sizeof(send_addr));
send_addr.Direction = WINDIVERT_DIRECTION_OUTBOUND;
send_addr.Direction = !recv_addr.Direction;
if (!WinDivertSend(handle, (PVOID)dnrv6, icmpv6_length,
&send_addr, NULL))
{
Expand Down
70 changes: 38 additions & 32 deletions sys/windivert.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ static UINT32 windivert_context_priority(UINT32 priority0)
/*
* Prototypes.
*/
static void windivert_driver_unload(void);
extern VOID windivert_ioctl(IN WDFQUEUE queue, IN WDFREQUEST request,
IN size_t in_length, IN size_t out_len, IN ULONG code);
static NTSTATUS windivert_read(context_t context, WDFREQUEST request);
Expand Down Expand Up @@ -709,22 +710,7 @@ extern NTSTATUS DriverEntry(IN PDRIVER_OBJECT driver_obj,

if (!NT_SUCCESS(status))
{
if (inject_handle != NULL)
{
FwpsInjectionHandleDestroy0(inject_handle);
}
if (injectv6_handle != NULL)
{
FwpsInjectionHandleDestroy0(injectv6_handle);
}
if (pool_handle != NULL)
{
NdisFreeNetBufferListPool(pool_handle);
}
if (engine_handle != NULL)
{
FwpmEngineClose0(engine_handle);
}
windivert_driver_unload();
}

return status;
Expand All @@ -734,25 +720,45 @@ extern NTSTATUS DriverEntry(IN PDRIVER_OBJECT driver_obj,
* WinDivert driver unload routine.
*/
extern VOID windivert_unload(IN WDFDRIVER Driver)
{
windivert_driver_unload();
}

/*
* WinDivert driver unload.
*/
static void windivert_driver_unload(void)
{
DEBUG("UNLOAD: unloading the WinDivert driver");

FwpmSubLayerDeleteByKey0(engine_handle,
&layer_inbound_network_ipv4->sublayer_guid);
FwpmSubLayerDeleteByKey0(engine_handle,
&layer_outbound_network_ipv4->sublayer_guid);
FwpmSubLayerDeleteByKey0(engine_handle,
&layer_inbound_network_ipv6->sublayer_guid);
FwpmSubLayerDeleteByKey0(engine_handle,
&layer_outbound_network_ipv6->sublayer_guid);
FwpmSubLayerDeleteByKey0(engine_handle,
&layer_forward_network_ipv4->sublayer_guid);
FwpmSubLayerDeleteByKey0(engine_handle,
&layer_forward_network_ipv6->sublayer_guid);
FwpsInjectionHandleDestroy0(inject_handle);
FwpsInjectionHandleDestroy0(injectv6_handle);
NdisFreeNetBufferListPool(pool_handle);
FwpmEngineClose0(engine_handle);
if (inject_handle != NULL)
{
FwpsInjectionHandleDestroy0(inject_handle);
}
if (injectv6_handle != NULL)
{
FwpsInjectionHandleDestroy0(injectv6_handle);
}
if (pool_handle != NULL)
{
NdisFreeNetBufferListPool(pool_handle);
}
if (engine_handle != NULL)
{
FwpmSubLayerDeleteByKey0(engine_handle,
&layer_inbound_network_ipv4->sublayer_guid);
FwpmSubLayerDeleteByKey0(engine_handle,
&layer_outbound_network_ipv4->sublayer_guid);
FwpmSubLayerDeleteByKey0(engine_handle,
&layer_inbound_network_ipv6->sublayer_guid);
FwpmSubLayerDeleteByKey0(engine_handle,
&layer_outbound_network_ipv6->sublayer_guid);
FwpmSubLayerDeleteByKey0(engine_handle,
&layer_forward_network_ipv4->sublayer_guid);
FwpmSubLayerDeleteByKey0(engine_handle,
&layer_forward_network_ipv6->sublayer_guid);
FwpmEngineClose0(engine_handle);
}
}

/*
Expand Down

0 comments on commit 33f6bec

Please sign in to comment.