From 5846e535dac7ef201fc962d50775634eac9fdcab Mon Sep 17 00:00:00 2001 From: Nodir Temirkhodjaev Date: Wed, 19 Apr 2023 10:18:48 +0300 Subject: [PATCH] Driver: Expand kernel stack for driver entry --- src/driver/fortdrv.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/driver/fortdrv.c b/src/driver/fortdrv.c index 9cf62fe2..ef044941 100644 --- a/src/driver/fortdrv.c +++ b/src/driver/fortdrv.c @@ -82,6 +82,23 @@ static void fort_driver_unload(PDRIVER_OBJECT driver) fort_device_set(NULL); } +static void NTAPI fort_driver_load_device_expand(PVOID param) +{ + NTSTATUS *status = param; + + *status = fort_device_load(); +} + +inline static void fort_driver_load_device(NTSTATUS *status) +{ + const NTSTATUS status_expand = KeExpandKernelStackAndCallout( + &fort_driver_load_device_expand, status, KERNEL_STACK_SIZE); + + if (!NT_SUCCESS(status_expand)) { + *status = status_expand; + } +} + static NTSTATUS fort_driver_load(PDRIVER_OBJECT driver, PUNICODE_STRING reg_path) { NTSTATUS status; @@ -106,7 +123,9 @@ static NTSTATUS fort_driver_load(PDRIVER_OBJECT driver, PUNICODE_STRING reg_path driver->MajorFunction[IRP_MJ_DEVICE_CONTROL] = &fort_device_control; driver->MajorFunction[IRP_MJ_SHUTDOWN] = &fort_device_shutdown; - return fort_device_load(); + fort_driver_load_device(&status); + + return status; } NTSTATUS DriverCallbacksSetup(PFORT_PROXYCB_INFO cb_info)