mirror of
https://github.com/amnezia-vpn/win-split-tunnel.git
synced 2026-05-17 08:16:00 +03:00
Use spinlock to protect IP addresses
This commit is contained in:
@@ -254,7 +254,7 @@ RewriteBind
|
||||
|
||||
const bool ipv4 = FixedValues->layerId == FWPS_LAYER_ALE_BIND_REDIRECT_V4;
|
||||
|
||||
WdfWaitLockAcquire(Context->IpAddresses.Lock, NULL);
|
||||
WdfSpinLockAcquire(Context->IpAddresses.Lock);
|
||||
|
||||
if (ipv4)
|
||||
{
|
||||
@@ -307,7 +307,7 @@ RewriteBind
|
||||
}
|
||||
}
|
||||
|
||||
WdfWaitLockRelease(Context->IpAddresses.Lock);
|
||||
WdfSpinLockRelease(Context->IpAddresses.Lock);
|
||||
|
||||
Cleanup_data:
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace firewall
|
||||
|
||||
struct IP_ADDRESSES_MGMT
|
||||
{
|
||||
WDFWAITLOCK Lock;
|
||||
WDFSPINLOCK Lock;
|
||||
ST_IP_ADDRESSES Addresses;
|
||||
SPLITTING_MODE SplittingMode;
|
||||
};
|
||||
|
||||
@@ -987,11 +987,11 @@ Initialize
|
||||
context->ProcessEventBroker = ProcessEventBroker;
|
||||
context->Eventing = Eventing;
|
||||
|
||||
auto status = WdfWaitLockCreate(WDF_NO_OBJECT_ATTRIBUTES, &context->IpAddresses.Lock);
|
||||
auto status = WdfSpinLockCreate(WDF_NO_OBJECT_ATTRIBUTES, &context->IpAddresses.Lock);
|
||||
|
||||
if (!NT_SUCCESS(status))
|
||||
{
|
||||
DbgPrint("WdfWaitLockCreate() failed 0x%X\n", status);
|
||||
DbgPrint("WdfSpinLockCreate() failed 0x%X\n", status);
|
||||
|
||||
context->IpAddresses.Lock = NULL;
|
||||
|
||||
@@ -1429,12 +1429,14 @@ RegisterUpdatedIpAddresses
|
||||
goto Abort;
|
||||
}
|
||||
|
||||
WdfWaitLockAcquire(Context->IpAddresses.Lock, NULL);
|
||||
auto intermediateNonPagedAddresses = *IpAddresses;
|
||||
|
||||
Context->IpAddresses.Addresses = *IpAddresses;
|
||||
WdfSpinLockAcquire(Context->IpAddresses.Lock);
|
||||
|
||||
Context->IpAddresses.Addresses = intermediateNonPagedAddresses;
|
||||
Context->IpAddresses.SplittingMode = newMode;
|
||||
|
||||
WdfWaitLockRelease(Context->IpAddresses.Lock);
|
||||
WdfSpinLockRelease(Context->IpAddresses.Lock);
|
||||
|
||||
Context->ActiveFilters = newActiveFilters;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user