diff --git a/reactos/ntoskrnl/io/iomgr/device.c b/reactos/ntoskrnl/io/iomgr/device.c index 0710c8c7187..5d7f31e1471 100644 --- a/reactos/ntoskrnl/io/iomgr/device.c +++ b/reactos/ntoskrnl/io/iomgr/device.c @@ -1352,8 +1352,8 @@ IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject) PFILE_OBJECT_EXTENSION FileObjectExtension; ASSERT(FALSE); - /* The extension buffer comes directly after the file object */ - FileObjectExtension = (PFILE_OBJECT_EXTENSION)(FileObject + 1); + /* Cast the buffer to something we understand */ + FileObjectExtension = FileObject->FileObjectExtension; /* Check if have a replacement top level device */ if (FileObjectExtension->TopDeviceObjectHint) diff --git a/reactos/ntoskrnl/io/iomgr/file.c b/reactos/ntoskrnl/io/iomgr/file.c index 3bb43ff7c50..43448792e6c 100644 --- a/reactos/ntoskrnl/io/iomgr/file.c +++ b/reactos/ntoskrnl/io/iomgr/file.c @@ -818,6 +818,7 @@ IopParseDevice(IN PVOID ParseObject, FileObject->Flags |= FO_FILE_OBJECT_HAS_EXTENSION; FileObjectExtension = (PFILE_OBJECT_EXTENSION)(FileObject + 1); + FileObject->FileObjectExtension = FileObjectExtension; /* Add the top level device which we'll send the request to */ if (OpenPacket->InternalFlags & IOP_USE_TOP_LEVEL_DEVICE_HINT) @@ -2669,6 +2670,8 @@ IoCreateFileSpecifyDeviceObjectHint(OUT PHANDLE FileHandle, { ULONG Flags = 0; + PAGED_CODE(); + /* Check if we were passed a device to send the create request to*/ if (DeviceObject) {