https://git.reactos.org/?p=reactos.git;a=commitdiff;h=45012aa48632815ca5010…
commit 45012aa48632815ca5010825ab6e386eb438cc03
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Tue Apr 3 02:14:48 2018 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Sun Apr 22 16:52:38 2018 +0200
[NTOSKRNL] Set the DRVO_BUILTIN_DRIVER DriverObject flag when a built-in driver is
created using IoCreateDriver().
---
ntoskrnl/include/internal/io.h | 4 ++--
ntoskrnl/io/iomgr/driver.c | 15 ++++++++++++---
2 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/ntoskrnl/include/internal/io.h b/ntoskrnl/include/internal/io.h
index f536fef5b2..f47768d4a1 100644
--- a/ntoskrnl/include/internal/io.h
+++ b/ntoskrnl/include/internal/io.h
@@ -1091,9 +1091,9 @@ NTSTATUS
NTAPI
IopCreateDriver(IN PUNICODE_STRING DriverName OPTIONAL,
IN PDRIVER_INITIALIZE InitializationFunction,
- IN PUNICODE_STRING RegistryPath,
+ IN PUNICODE_STRING RegistryPath OPTIONAL,
IN PCUNICODE_STRING ServiceName,
- PLDR_DATA_TABLE_ENTRY ModuleObject,
+ IN PLDR_DATA_TABLE_ENTRY ModuleObject OPTIONAL,
OUT PDRIVER_OBJECT *pDriverObject);
VOID
diff --git a/ntoskrnl/io/iomgr/driver.c b/ntoskrnl/io/iomgr/driver.c
index 4f4df52979..f9de2e5065 100644
--- a/ntoskrnl/io/iomgr/driver.c
+++ b/ntoskrnl/io/iomgr/driver.c
@@ -1419,9 +1419,9 @@ NTSTATUS
NTAPI
IopCreateDriver(IN PUNICODE_STRING DriverName OPTIONAL,
IN PDRIVER_INITIALIZE InitializationFunction,
- IN PUNICODE_STRING RegistryPath,
+ IN PUNICODE_STRING RegistryPath OPTIONAL,
IN PCUNICODE_STRING ServiceName,
- PLDR_DATA_TABLE_ENTRY ModuleObject,
+ IN PLDR_DATA_TABLE_ENTRY ModuleObject OPTIONAL,
OUT PDRIVER_OBJECT *pDriverObject)
{
WCHAR NameBuffer[100];
@@ -1479,7 +1479,16 @@ try_again:
RtlZeroMemory(DriverObject, ObjectSize);
DriverObject->Type = IO_TYPE_DRIVER;
DriverObject->Size = sizeof(DRIVER_OBJECT);
- DriverObject->Flags = DRVO_LEGACY_DRIVER;
+
+ /*
+ * Check whether RegistryPath and ModuleObject are both NULL because
+ * IoCreateDriver() was called to initialize a built-in driver.
+ */
+ if ((RegistryPath != NULL) || (ModuleObject != NULL))
+ DriverObject->Flags = DRVO_LEGACY_DRIVER;
+ else
+ DriverObject->Flags = DRVO_BUILTIN_DRIVER;
+
DriverObject->DriverExtension = (PDRIVER_EXTENSION)(DriverObject + 1);
DriverObject->DriverExtension->DriverObject = DriverObject;
DriverObject->DriverInit = InitializationFunction;