diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c index 258c769ee0e..a3dd7b93621 100644 --- a/dlls/ntoskrnl.exe/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/ntoskrnl.c @@ -528,6 +528,7 @@ static NTSTATUS dispatch_create( struct dispatch_context *context ) irpsp->Parameters.Create.EaLength = 0; irp->Tail.Overlay.OriginalFileObject = file; + irp->Tail.Overlay.Thread = (PETHREAD)KeGetCurrentThread(); irp->RequestorMode = UserMode; irp->AssociatedIrp.SystemBuffer = NULL; irp->UserBuffer = NULL; @@ -565,6 +566,7 @@ static NTSTATUS dispatch_close( struct dispatch_context *context ) irpsp->FileObject = file; irp->Tail.Overlay.OriginalFileObject = file; + irp->Tail.Overlay.Thread = (PETHREAD)KeGetCurrentThread(); irp->RequestorMode = UserMode; irp->AssociatedIrp.SystemBuffer = NULL; irp->UserBuffer = NULL; diff --git a/dlls/ntoskrnl.exe/tests/driver.c b/dlls/ntoskrnl.exe/tests/driver.c index dc583f98c08..6ab3c622aec 100644 --- a/dlls/ntoskrnl.exe/tests/driver.c +++ b/dlls/ntoskrnl.exe/tests/driver.c @@ -60,6 +60,8 @@ static POBJECT_TYPE *pExEventObjectType, *pIoFileObjectType, *pPsThreadType, *pI static PEPROCESS *pPsInitialSystemProcess; static void *create_caller_thread; +static PETHREAD create_irp_thread; + void WINAPI ObfReferenceObject( void *obj ); NTSTATUS WINAPI ZwQueryInformationProcess(HANDLE,PROCESSINFOCLASS,void*,ULONG,ULONG*); @@ -342,7 +344,10 @@ static void test_current_thread(BOOL is_system) ok(PsGetThreadId((PETHREAD)KeGetCurrentThread()) == PsGetCurrentThreadId(), "thread IDs don't match\n"); ok(PsIsSystemThread((PETHREAD)KeGetCurrentThread()) == is_system, "unexpected system thread\n"); if (!is_system) + { ok(create_caller_thread == KeGetCurrentThread(), "thread is not create caller thread\n"); + ok(create_irp_thread == (PETHREAD)KeGetCurrentThread(), "thread of create request is not current thread\n"); + } ret = ObOpenObjectByPointer(current, OBJ_KERNEL_HANDLE, NULL, PROCESS_QUERY_INFORMATION, NULL, KernelMode, &process_handle); ok(!ret, "ObOpenObjectByPointer failed: %#x\n", ret); @@ -1864,6 +1869,7 @@ static NTSTATUS WINAPI driver_Create(DEVICE_OBJECT *device, IRP *irp) *context = create_count; irpsp->FileObject->FsContext = context; create_caller_thread = KeGetCurrentThread(); + create_irp_thread = irp->Tail.Overlay.Thread; irp->IoStatus.Status = STATUS_SUCCESS; IoCompleteRequest(irp, IO_NO_INCREMENT);