Kill some more Camels
Disclaimer: No animals were hurt in this commit. Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
parent
03a45fb768
commit
5e87977cf8
44
wintun.c
44
wintun.c
@ -214,18 +214,18 @@ static IRP *TunCsqPeekNextIrp(IO_CSQ *Csq, IRP *Irp, _In_ PVOID PeekContext)
|
|||||||
* we will start from the listhead. This is done under the assumption that
|
* we will start from the listhead. This is done under the assumption that
|
||||||
* new IRPs are always inserted at the tail. */
|
* new IRPs are always inserted at the tail. */
|
||||||
for (LIST_ENTRY
|
for (LIST_ENTRY
|
||||||
*listHead = &ctx->Device.ReadQueue.List,
|
*head = &ctx->Device.ReadQueue.List,
|
||||||
*nextEntry = Irp ? Irp->Tail.Overlay.ListEntry.Flink : listHead->Flink;
|
*next = Irp ? Irp->Tail.Overlay.ListEntry.Flink : head->Flink;
|
||||||
nextEntry != listHead;
|
next != head;
|
||||||
nextEntry = nextEntry->Flink)
|
next = next->Flink)
|
||||||
{
|
{
|
||||||
IRP *nextIrp = CONTAINING_RECORD(nextEntry, IRP, Tail.Overlay.ListEntry);
|
IRP *irp_next = CONTAINING_RECORD(next, IRP, Tail.Overlay.ListEntry);
|
||||||
if (!PeekContext)
|
if (!PeekContext)
|
||||||
return nextIrp;
|
return irp_next;
|
||||||
|
|
||||||
IO_STACK_LOCATION *stack = IoGetCurrentIrpStackLocation(nextIrp);
|
IO_STACK_LOCATION *stack = IoGetCurrentIrpStackLocation(irp_next);
|
||||||
if (stack->FileObject == (FILE_OBJECT *)PeekContext)
|
if (stack->FileObject == (FILE_OBJECT *)PeekContext)
|
||||||
return nextIrp;
|
return irp_next;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -451,7 +451,7 @@ _Requires_lock_not_held_(ctx->PacketQueue.Lock)
|
|||||||
_IRQL_requires_max_(DISPATCH_LEVEL)
|
_IRQL_requires_max_(DISPATCH_LEVEL)
|
||||||
static void TunQueueProcess(_Inout_ TUN_CTX *ctx)
|
static void TunQueueProcess(_Inout_ TUN_CTX *ctx)
|
||||||
{
|
{
|
||||||
IRP *Irp = NULL;
|
IRP *irp = NULL;
|
||||||
NET_BUFFER *nb;
|
NET_BUFFER *nb;
|
||||||
KLOCK_QUEUE_HANDLE lqh;
|
KLOCK_QUEUE_HANDLE lqh;
|
||||||
|
|
||||||
@ -460,14 +460,14 @@ static void TunQueueProcess(_Inout_ TUN_CTX *ctx)
|
|||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
|
|
||||||
KeAcquireInStackQueuedSpinLock(&ctx->PacketQueue.Lock, &lqh);
|
KeAcquireInStackQueuedSpinLock(&ctx->PacketQueue.Lock, &lqh);
|
||||||
if (!Irp) {
|
if (!irp) {
|
||||||
nb = TunQueueRemove(ctx, &nbl);
|
nb = TunQueueRemove(ctx, &nbl);
|
||||||
if (!nb) {
|
if (!nb) {
|
||||||
KeReleaseInStackQueuedSpinLock(&lqh);
|
KeReleaseInStackQueuedSpinLock(&lqh);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Irp = IoCsqRemoveNextIrp(&ctx->Device.ReadQueue.Csq, NULL);
|
irp = IoCsqRemoveNextIrp(&ctx->Device.ReadQueue.Csq, NULL);
|
||||||
if (!Irp) {
|
if (!irp) {
|
||||||
if (!nbl|| !TunNBLRefDec(ctx, nbl, NDIS_SEND_COMPLETE_FLAGS_DISPATCH_LEVEL))
|
if (!nbl|| !TunNBLRefDec(ctx, nbl, NDIS_SEND_COMPLETE_FLAGS_DISPATCH_LEVEL))
|
||||||
TunQueuePrepend(ctx, nb, nbl);
|
TunQueuePrepend(ctx, nb, nbl);
|
||||||
KeReleaseInStackQueuedSpinLock(&lqh);
|
KeReleaseInStackQueuedSpinLock(&lqh);
|
||||||
@ -478,23 +478,23 @@ static void TunQueueProcess(_Inout_ TUN_CTX *ctx)
|
|||||||
}
|
}
|
||||||
KeReleaseInStackQueuedSpinLock(&lqh);
|
KeReleaseInStackQueuedSpinLock(&lqh);
|
||||||
|
|
||||||
if (!nb || (status = TunWriteIntoIrp(Irp, nb)) == STATUS_BUFFER_TOO_SMALL) { /* Irp complete */
|
if (!nb || (status = TunWriteIntoIrp(irp, nb)) == STATUS_BUFFER_TOO_SMALL) { /* irp complete */
|
||||||
Irp->IoStatus.Status = STATUS_SUCCESS;
|
irp->IoStatus.Status = STATUS_SUCCESS;
|
||||||
IoCompleteRequest(Irp, IO_NETWORK_INCREMENT);
|
IoCompleteRequest(irp, IO_NETWORK_INCREMENT);
|
||||||
TunCompletePause(ctx, 1);
|
TunCompletePause(ctx, 1);
|
||||||
Irp = NULL;
|
irp = NULL;
|
||||||
} else if (status == NDIS_STATUS_INVALID_LENGTH || status == NDIS_STATUS_RESOURCES) { /* nb-related errors */
|
} else if (status == NDIS_STATUS_INVALID_LENGTH || status == NDIS_STATUS_RESOURCES) { /* nb-related errors */
|
||||||
KeAcquireInStackQueuedSpinLock(&ctx->PacketQueue.Lock, &lqh);
|
KeAcquireInStackQueuedSpinLock(&ctx->PacketQueue.Lock, &lqh);
|
||||||
if (nbl)
|
if (nbl)
|
||||||
NET_BUFFER_LIST_STATUS(nbl) = status;
|
NET_BUFFER_LIST_STATUS(nbl) = status;
|
||||||
KeReleaseInStackQueuedSpinLock(&lqh);
|
KeReleaseInStackQueuedSpinLock(&lqh);
|
||||||
IoCsqInsertIrpEx(&ctx->Device.ReadQueue.Csq, Irp, NULL, TUN_CSQ_INSERT_HEAD);
|
IoCsqInsertIrpEx(&ctx->Device.ReadQueue.Csq, irp, NULL, TUN_CSQ_INSERT_HEAD);
|
||||||
Irp = NULL;
|
irp = NULL;
|
||||||
} else if (!NT_SUCCESS(status)) { /* Irp-related errors */
|
} else if (!NT_SUCCESS(status)) { /* irp-related errors */
|
||||||
Irp->IoStatus.Status = status;
|
irp->IoStatus.Status = status;
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
IoCompleteRequest(irp, IO_NO_INCREMENT);
|
||||||
TunCompletePause(ctx, 1);
|
TunCompletePause(ctx, 1);
|
||||||
Irp = NULL;
|
irp = NULL;
|
||||||
}
|
}
|
||||||
if (nbl)
|
if (nbl)
|
||||||
TunNBLRefDec(ctx, nbl, 0);
|
TunNBLRefDec(ctx, nbl, 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user