From fd86dd450053776de38af887a8cc5c5a2cc915c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sun, 7 Jul 2013 15:57:48 +0000 Subject: [PATCH] [CONDRV] - Hey Arch! You're displaying Major function codes, not IOCTL codes. Also, remove unnecessary casts (coming from some old code), and a use-after free. - Add some memory helpers. svn path=/trunk/; revision=59448 --- reactos/drivers/base/condrv/condrv.c | 17 +++++++++-------- reactos/drivers/base/condrv/condrv.h | 3 +++ reactos/drivers/base/condrv/control.c | 3 +-- reactos/drivers/base/condrv/heap.h | 22 ++++++++++++++++++++++ 4 files changed, 35 insertions(+), 10 deletions(-) create mode 100644 reactos/drivers/base/condrv/heap.h diff --git a/reactos/drivers/base/condrv/condrv.c b/reactos/drivers/base/condrv/condrv.c index b183eac4af1..7d1e2367e30 100644 --- a/reactos/drivers/base/condrv/condrv.c +++ b/reactos/drivers/base/condrv/condrv.c @@ -40,16 +40,16 @@ CompleteRequest(IN PIRP Irp, Irp->IoStatus.Information = Information; IoCompleteRequest(Irp, IO_NO_INCREMENT); - return Irp->IoStatus.Status; + return Status; } NTSTATUS NTAPI ConDrvDispatch(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp) { -#define HANDLE_CTRL_CODE(CtrlCode) \ - case CtrlCode : \ - { \ - DPRINT1("ConDrv: " #CtrlCode ", stack->FileObject = 0x%p\n", stack->FileObject); \ +#define HANDLE_CTRL_CODE(Code) \ + case Code : \ + { \ + DPRINT1("ConDrv: " #Code ", stack->FileObject = 0x%p\n", stack->FileObject); \ if (stack->FileObject) \ { \ DPRINT1("stack->FileObject->FileName = %wZ\n", &stack->FileObject->FileName); \ @@ -58,10 +58,11 @@ ConDrvDispatch(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp) } PIO_STACK_LOCATION stack = IoGetCurrentIrpStackLocation(Irp); - ULONG ctrlCode = stack->Parameters.DeviceIoControl.IoControlCode; + // ULONG ctrlCode = stack->Parameters.DeviceIoControl.IoControlCode; + ULONG MajorFunction = stack->MajorFunction; /* Just display all the IRP codes for now... */ - switch (ctrlCode) + switch (MajorFunction) { HANDLE_CTRL_CODE(IRP_MJ_CREATE); HANDLE_CTRL_CODE(IRP_MJ_CREATE_NAMED_PIPE); @@ -96,7 +97,7 @@ ConDrvDispatch(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp) default: { - DPRINT1("Unknown code %lu\n", ctrlCode); + DPRINT1("Unknown Major %lu\n", MajorFunction); break; } } diff --git a/reactos/drivers/base/condrv/condrv.h b/reactos/drivers/base/condrv/condrv.h index 7424a40ace4..85f4f2199f8 100644 --- a/reactos/drivers/base/condrv/condrv.h +++ b/reactos/drivers/base/condrv/condrv.h @@ -10,7 +10,10 @@ #define __CONDRV_H__ /* This is needed for VisualDDK testing */ +// #define __USE_VISUALDDK_AT_HOME__ + #ifdef __USE_VISUALDDK_AT_HOME__ + #pragma message("Disable __USE_VISUALDDK_AT_HOME__ before committing!!") #include "VisualDDKHelpers.h" #endif diff --git a/reactos/drivers/base/condrv/control.c b/reactos/drivers/base/condrv/control.c index 802283ec7da..819a098f6fc 100644 --- a/reactos/drivers/base/condrv/control.c +++ b/reactos/drivers/base/condrv/control.c @@ -44,8 +44,7 @@ ConDrvCreateController(IN PDRIVER_OBJECT DriverObject, &Controller); if (!NT_SUCCESS(Status)) goto Done; - Status = IoCreateSymbolicLink((PUNICODE_STRING)&SymlinkName, - (PUNICODE_STRING)&DeviceName); + Status = IoCreateSymbolicLink(&SymlinkName, &DeviceName); if (!NT_SUCCESS(Status)) { IoDeleteDevice(Controller); diff --git a/reactos/drivers/base/condrv/heap.h b/reactos/drivers/base/condrv/heap.h new file mode 100644 index 00000000000..d6bbbca4469 --- /dev/null +++ b/reactos/drivers/base/condrv/heap.h @@ -0,0 +1,22 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS Console Driver + * FILE: drivers/base/condrv/heap.h + * PURPOSE: Heap Helpers + * PROGRAMMERS: Hermes Belusca-Maito (hermes.belusca@sfr.fr) + */ + +#pragma once + +#define ConDrvAllocPoolNonPageable(Flags, Size, Tag) \ + __pragma(message("WARNING - Flags parameter ignored. You may encounter problems!")) \ + ExAllocatePoolWithTag(NonPagedPool, Size, Tag) + +#define ConDrvAllocPoolPageable(Flags, Size, Tag) \ + __pragma(message("WARNING - Flags parameter ignored. You may encounter problems!")) \ + ExAllocatePoolWithTag(PagedPool, Size, Tag) + +#define ConDrvFreePool(PoolBase, Tag) \ + ExFreePoolWithTag(PoolBase, Tag) + +/* EOF */