From 828ac9880d540c30dc40f8878436a436ffea8d0c Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Thu, 30 May 2019 13:12:25 +0200 Subject: [PATCH] ntoskrnl.exe: Set IRP caller thread. Signed-off-by: Jacek Caban Signed-off-by: Alexandre Julliard --- dlls/ntoskrnl.exe/ntoskrnl.c | 2 ++ dlls/ntoskrnl.exe/tests/driver.c | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c index df8c4c1e2f9..7ef31590647 100644 --- a/dlls/ntoskrnl.exe/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/ntoskrnl.c @@ -1363,6 +1363,7 @@ PIRP WINAPI IoBuildDeviceIoControlRequest( ULONG code, PDEVICE_OBJECT device, irp->UserBuffer = out_buff; irp->UserIosb = iosb; irp->UserEvent = event; + irp->Tail.Overlay.Thread = (PETHREAD)KeGetCurrentThread(); return irp; } @@ -1415,6 +1416,7 @@ PIRP WINAPI IoBuildAsynchronousFsdRequest(ULONG majorfunc, DEVICE_OBJECT *device irp->UserIosb = iosb; irp->UserEvent = NULL; irp->UserBuffer = buffer; + irp->Tail.Overlay.Thread = (PETHREAD)KeGetCurrentThread(); return irp; } diff --git a/dlls/ntoskrnl.exe/tests/driver.c b/dlls/ntoskrnl.exe/tests/driver.c index c08452b2945..468b1836377 100644 --- a/dlls/ntoskrnl.exe/tests/driver.c +++ b/dlls/ntoskrnl.exe/tests/driver.c @@ -239,6 +239,8 @@ static void test_irp_struct(IRP *irp, DEVICE_OBJECT *device) ok(irpsp->DeviceObject == device, "unexpected DeviceObject\n"); ok(irpsp->FileObject->DeviceObject == device, "unexpected FileObject->DeviceObject\n"); ok(!irp->UserEvent, "UserEvent = %p\n", irp->UserEvent); + ok(irp->Tail.Overlay.Thread == (PETHREAD)KeGetCurrentThread(), + "IRP thread is not the current thread\n"); } static void test_mdl_map(void) @@ -751,6 +753,8 @@ static void test_call_driver(DEVICE_OBJECT *device) ok(!irp->CancelRoutine, "CancelRoutine = %x\n", irp->CancelRoutine); ok(!irp->UserEvent, "UserEvent = %p\n", irp->UserEvent); ok(irp->CurrentLocation == 2, "CurrentLocation = %u\n", irp->CurrentLocation); + ok(irp->Tail.Overlay.Thread == (PETHREAD)KeGetCurrentThread(), + "IRP thread is not the current thread\n"); irpsp = IoGetNextIrpStackLocation(irp); ok(irpsp->MajorFunction == IRP_MJ_FLUSH_BUFFERS, "MajorFunction = %u\n", irpsp->MajorFunction); @@ -773,6 +777,8 @@ static void test_call_driver(DEVICE_OBJECT *device) ok(!irp->CancelRoutine, "CancelRoutine = %x\n", irp->CancelRoutine); ok(irp->UserEvent == &event, "UserEvent = %p\n", irp->UserEvent); ok(irp->CurrentLocation == 2, "CurrentLocation = %u\n", irp->CurrentLocation); + ok(irp->Tail.Overlay.Thread == (PETHREAD)KeGetCurrentThread(), + "IRP thread is not the current thread\n"); irpsp = IoGetNextIrpStackLocation(irp); ok(irpsp->MajorFunction == IRP_MJ_FLUSH_BUFFERS, "MajorFunction = %u\n", irpsp->MajorFunction); @@ -1698,6 +1704,8 @@ static NTSTATUS WINAPI driver_FlushBuffers(DEVICE_OBJECT *device, IRP *irp) { IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation(irp); ok(irpsp->DeviceObject == device, "device != DeviceObject\n"); + ok(irp->Tail.Overlay.Thread == (PETHREAD)KeGetCurrentThread(), + "IRP thread is not the current thread\n"); IoMarkIrpPending(irp); return STATUS_PENDING; }