From fe416b67dca395e4ad02aa9e6eb83733ea3ee63b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Thu, 17 Jun 2021 00:29:58 +0200 Subject: [PATCH] [NTOS:IO] Revert part of commit a82ff90b2: don't do direct ULONG data access: it might be unaligned. Requested by Victor. --- ntoskrnl/io/iomgr/driver.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ntoskrnl/io/iomgr/driver.c b/ntoskrnl/io/iomgr/driver.c index 6a42dd30f7a..edb64baef7b 100644 --- a/ntoskrnl/io/iomgr/driver.c +++ b/ntoskrnl/io/iomgr/driver.c @@ -213,7 +213,10 @@ IopGetDriverNames( status = STATUS_ILL_FORMED_SERVICE_ENTRY; goto Cleanup; } - driverType = *(PULONG)((ULONG_PTR)kvInfo + kvInfo->DataOffset); + + RtlMoveMemory(&driverType, + (PVOID)((ULONG_PTR)kvInfo + kvInfo->DataOffset), + sizeof(ULONG)); ExFreePool(kvInfo); /* Compute the necessary driver name string size */ @@ -913,7 +916,10 @@ IopInitializeBuiltinDriver(IN PLDR_DATA_TABLE_ENTRY BootLdrEntry) ExFreePool(kvInfo); goto Cleanup; } - instanceCount = *(PULONG)((ULONG_PTR)kvInfo + kvInfo->DataOffset); + + RtlMoveMemory(&instanceCount, + (PVOID)((ULONG_PTR)kvInfo + kvInfo->DataOffset), + sizeof(ULONG)); ExFreePool(kvInfo); DPRINT("Processing %u instances for %wZ module\n", instanceCount, ModuleName);