From 6246307bfd45673f7e86a55ec3549c236abb319e Mon Sep 17 00:00:00 2001 From: lhodges1 Date: Sat, 19 Aug 2023 14:03:48 +1000 Subject: [PATCH] e --- driver/ioctl.c | 9 ++------- driver/modules.c | 8 ++++++++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/driver/ioctl.c b/driver/ioctl.c index a978194..96b16c6 100644 --- a/driver/ioctl.c +++ b/driver/ioctl.c @@ -50,14 +50,9 @@ NTSTATUS DeviceControl( if ( !NT_SUCCESS( status ) ) DEBUG_ERROR( "Failed to start thread to validate system drivers" ); - /* - * wait on our thread so we dont complete the IRP before we've filled the - * buffer with information and prevent any weird IRP multithreaded interactions - */ - KeWaitForSingleObject( handle, Executive, KernelMode, FALSE, NULL ); - + /* return early as IRP completion was handled inside the function */ ZwClose( handle ); - break; + return status; default: DEBUG_ERROR( "Invalid IOCTL passed to driver" ); diff --git a/driver/modules.c b/driver/modules.c index c998378..a886142 100644 --- a/driver/modules.c +++ b/driver/modules.c @@ -333,5 +333,13 @@ NTSTATUS HandleValidateDriversIOCTL( ExFreePoolWithTag( head, INVALID_DRIVER_LIST_HEAD_POOL ); ExFreePoolWithTag( system_modules.address, SYSTEM_MODULES_POOL ); + + /* + * Complete the IRP here so we don't have to implement a waiting mechanism + * to prevent an early completion of the IRP. + */ + IoCompleteRequest( Irp, IO_NO_INCREMENT ); + Irp->IoStatus.Status = status; + return status; } \ No newline at end of file