mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 14:24:35 +00:00
Use a tag when allocating/freeing some memory
svn path=/trunk/; revision=26990
This commit is contained in:
parent
e4d5c105d9
commit
6b63d35926
9 changed files with 92 additions and 102 deletions
|
@ -10,6 +10,16 @@
|
||||||
#define INITGUID
|
#define INITGUID
|
||||||
#include "kbdclass.h"
|
#include "kbdclass.h"
|
||||||
|
|
||||||
|
static DRIVER_UNLOAD DriverUnload;
|
||||||
|
static DRIVER_DISPATCH ClassCreate;
|
||||||
|
static DRIVER_DISPATCH ClassClose;
|
||||||
|
static DRIVER_DISPATCH ClassCleanup;
|
||||||
|
static DRIVER_DISPATCH ClassRead;
|
||||||
|
static DRIVER_DISPATCH ClassDeviceControl;
|
||||||
|
static DRIVER_DISPATCH IrpStub;
|
||||||
|
static DRIVER_ADD_DEVICE ClassAddDevice;
|
||||||
|
static DRIVER_STARTIO ClassStartIo;
|
||||||
|
|
||||||
static VOID NTAPI
|
static VOID NTAPI
|
||||||
DriverUnload(IN PDRIVER_OBJECT DriverObject)
|
DriverUnload(IN PDRIVER_OBJECT DriverObject)
|
||||||
{
|
{
|
||||||
|
@ -212,11 +222,11 @@ ReadRegistryEntries(
|
||||||
|
|
||||||
ParametersRegistryKey.Length = 0;
|
ParametersRegistryKey.Length = 0;
|
||||||
ParametersRegistryKey.MaximumLength = RegistryPath->Length + sizeof(L"\\Parameters") + sizeof(UNICODE_NULL);
|
ParametersRegistryKey.MaximumLength = RegistryPath->Length + sizeof(L"\\Parameters") + sizeof(UNICODE_NULL);
|
||||||
ParametersRegistryKey.Buffer = ExAllocatePool(PagedPool, ParametersRegistryKey.MaximumLength);
|
ParametersRegistryKey.Buffer = ExAllocatePoolWithTag(PagedPool, ParametersRegistryKey.MaximumLength, CLASS_TAG);
|
||||||
if (!ParametersRegistryKey.Buffer)
|
if (!ParametersRegistryKey.Buffer)
|
||||||
{
|
{
|
||||||
DPRINT("ExAllocatePool() failed\n");
|
DPRINT("ExAllocatePoolWithTag() failed\n");
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
return STATUS_NO_MEMORY;
|
||||||
}
|
}
|
||||||
RtlCopyUnicodeString(&ParametersRegistryKey, RegistryPath);
|
RtlCopyUnicodeString(&ParametersRegistryKey, RegistryPath);
|
||||||
RtlAppendUnicodeToString(&ParametersRegistryKey, L"\\Parameters");
|
RtlAppendUnicodeToString(&ParametersRegistryKey, L"\\Parameters");
|
||||||
|
@ -276,6 +286,7 @@ ReadRegistryEntries(
|
||||||
Status = STATUS_NO_MEMORY;
|
Status = STATUS_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ExFreePoolWithTag(ParametersRegistryKey.Buffer, CLASS_TAG);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,11 +314,11 @@ CreateClassDeviceObject(
|
||||||
+ DriverExtension->DeviceBaseName.Length /* "KeyboardClass" */
|
+ DriverExtension->DeviceBaseName.Length /* "KeyboardClass" */
|
||||||
+ 4 * sizeof(WCHAR) /* Id between 0 and 9999 */
|
+ 4 * sizeof(WCHAR) /* Id between 0 and 9999 */
|
||||||
+ sizeof(UNICODE_NULL); /* Final NULL char */
|
+ sizeof(UNICODE_NULL); /* Final NULL char */
|
||||||
DeviceNameU.Buffer = ExAllocatePool(PagedPool, DeviceNameU.MaximumLength);
|
DeviceNameU.Buffer = ExAllocatePoolWithTag(PagedPool, DeviceNameU.MaximumLength, CLASS_TAG);
|
||||||
if (!DeviceNameU.Buffer)
|
if (!DeviceNameU.Buffer)
|
||||||
{
|
{
|
||||||
DPRINT("ExAllocatePool() failed\n");
|
DPRINT("ExAllocatePoolWithTag() failed\n");
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
return STATUS_NO_MEMORY;
|
||||||
}
|
}
|
||||||
Status = RtlAppendUnicodeToString(&DeviceNameU, L"\\Device\\");
|
Status = RtlAppendUnicodeToString(&DeviceNameU, L"\\Device\\");
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
|
@ -348,7 +359,7 @@ CreateClassDeviceObject(
|
||||||
cleanup:
|
cleanup:
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
ExFreePool(DeviceNameU.Buffer);
|
ExFreePoolWithTag(DeviceNameU.Buffer, CLASS_TAG);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -361,11 +372,11 @@ cleanup:
|
||||||
KeInitializeSpinLock(&DeviceExtension->SpinLock);
|
KeInitializeSpinLock(&DeviceExtension->SpinLock);
|
||||||
DeviceExtension->ReadIsPending = FALSE;
|
DeviceExtension->ReadIsPending = FALSE;
|
||||||
DeviceExtension->InputCount = 0;
|
DeviceExtension->InputCount = 0;
|
||||||
DeviceExtension->PortData = ExAllocatePool(NonPagedPool, DeviceExtension->DriverExtension->DataQueueSize * sizeof(KEYBOARD_INPUT_DATA));
|
DeviceExtension->PortData = ExAllocatePoolWithTag(NonPagedPool, DeviceExtension->DriverExtension->DataQueueSize * sizeof(KEYBOARD_INPUT_DATA), CLASS_TAG);
|
||||||
if (!DeviceExtension->PortData)
|
if (!DeviceExtension->PortData)
|
||||||
{
|
{
|
||||||
ExFreePool(DeviceNameU.Buffer);
|
ExFreePoolWithTag(DeviceNameU.Buffer, CLASS_TAG);
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
return STATUS_NO_MEMORY;
|
||||||
}
|
}
|
||||||
DeviceExtension->DeviceName = DeviceNameU.Buffer;
|
DeviceExtension->DeviceName = DeviceNameU.Buffer;
|
||||||
Fdo->Flags |= DO_POWER_PAGABLE;
|
Fdo->Flags |= DO_POWER_PAGABLE;
|
||||||
|
@ -548,8 +559,7 @@ ConnectPortDriver(
|
||||||
CONNECT_DATA ConnectData;
|
CONNECT_DATA ConnectData;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
DPRINT("Connecting PortDO %p [%wZ] to ClassDO %p\n",
|
DPRINT("Connecting PortDO %p to ClassDO %p\n", PortDO, ClassDO);
|
||||||
PortDO, &PortDO->DriverObject->DriverName, ClassDO);
|
|
||||||
|
|
||||||
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
||||||
|
|
||||||
|
@ -605,8 +615,7 @@ DestroyPortDriver(
|
||||||
KIRQL OldIrql;
|
KIRQL OldIrql;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
DPRINT("Destroying PortDO %p [%wZ]\n",
|
DPRINT("Destroying PortDO %p\n", PortDO);
|
||||||
PortDO, &PortDO->DriverObject->DriverName);
|
|
||||||
|
|
||||||
DeviceExtension = (PPORT_DEVICE_EXTENSION)PortDO->DeviceExtension;
|
DeviceExtension = (PPORT_DEVICE_EXTENSION)PortDO->DeviceExtension;
|
||||||
ClassDeviceExtension = DeviceExtension->ClassDO->DeviceExtension;
|
ClassDeviceExtension = DeviceExtension->ClassDO->DeviceExtension;
|
||||||
|
@ -644,8 +653,8 @@ DestroyPortDriver(
|
||||||
|
|
||||||
if (!DriverExtension->ConnectMultiplePorts && DeviceExtension->ClassDO)
|
if (!DriverExtension->ConnectMultiplePorts && DeviceExtension->ClassDO)
|
||||||
{
|
{
|
||||||
ExFreePool(ClassDeviceExtension->PortData);
|
ExFreePoolWithTag(ClassDeviceExtension->PortData, CLASS_TAG);
|
||||||
ExFreePool((PVOID)ClassDeviceExtension->DeviceName);
|
ExFreePoolWithTag((PVOID)ClassDeviceExtension->DeviceName, CLASS_TAG);
|
||||||
IoDeleteDevice(DeviceExtension->ClassDO);
|
IoDeleteDevice(DeviceExtension->ClassDO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -838,11 +847,11 @@ SearchForLegacyDrivers(
|
||||||
|
|
||||||
/* Allocate memory */
|
/* Allocate memory */
|
||||||
Size = sizeof(KEY_VALUE_BASIC_INFORMATION) + MAX_PATH;
|
Size = sizeof(KEY_VALUE_BASIC_INFORMATION) + MAX_PATH;
|
||||||
KeyValueInformation = ExAllocatePool(PagedPool, Size);
|
KeyValueInformation = ExAllocatePoolWithTag(PagedPool, Size, CLASS_TAG);
|
||||||
if (!KeyValueInformation)
|
if (!KeyValueInformation)
|
||||||
{
|
{
|
||||||
DPRINT("ExAllocatePool() failed\n");
|
DPRINT("ExAllocatePoolWithTag() failed\n");
|
||||||
Status = STATUS_INSUFFICIENT_RESOURCES;
|
Status = STATUS_NO_MEMORY;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -893,7 +902,7 @@ SearchForLegacyDrivers(
|
||||||
DPRINT("IoGetDeviceObjectPointer(%wZ) failed with status 0x%08lx\n", &PortName, Status);
|
DPRINT("IoGetDeviceObjectPointer(%wZ) failed with status 0x%08lx\n", &PortName, Status);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
DPRINT("Legacy driver found: %wZ\n", &PortDeviceObject->DriverObject->DriverName);
|
DPRINT("Legacy driver found\n");
|
||||||
|
|
||||||
Status = ClassAddDevice(DriverObject, PortDeviceObject);
|
Status = ClassAddDevice(DriverObject, PortDeviceObject);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
|
@ -905,7 +914,7 @@ SearchForLegacyDrivers(
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (KeyValueInformation != NULL)
|
if (KeyValueInformation != NULL)
|
||||||
ExFreePool(KeyValueInformation);
|
ExFreePoolWithTag(KeyValueInformation, CLASS_TAG);
|
||||||
if (hDeviceMapKey != (HANDLE)-1)
|
if (hDeviceMapKey != (HANDLE)-1)
|
||||||
ZwClose(hDeviceMapKey);
|
ZwClose(hDeviceMapKey);
|
||||||
if (hPortKey != (HANDLE)-1)
|
if (hPortKey != (HANDLE)-1)
|
||||||
|
|
|
@ -2,27 +2,16 @@
|
||||||
#include <kbdmou.h>
|
#include <kbdmou.h>
|
||||||
#include <ntddkbd.h>
|
#include <ntddkbd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <pseh/pseh.h>
|
||||||
#if defined(__GNUC__)
|
#include <debug.h>
|
||||||
#include <pseh/pseh.h>
|
|
||||||
#include <debug.h>
|
|
||||||
#elif defined(_MSC_VER)
|
|
||||||
#define DPRINT1 DbgPrint("(%s:%d) ", __FILE__, __LINE__), DbgPrint
|
|
||||||
#define CHECKPOINT1 DbgPrint("(%s:%d)\n", __FILE__, __LINE__)
|
|
||||||
#define DPRINT
|
|
||||||
#define CHECKPOINT
|
|
||||||
#define _SEH_TRY __try
|
|
||||||
#define _SEH_HANDLE __except(1)
|
|
||||||
#define _SEH_END
|
|
||||||
#define _SEH_GetExceptionCode() GetExceptionCode()
|
|
||||||
#else
|
|
||||||
#error Unknown compiler!
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define MAX_PATH 260
|
#define MAX_PATH 260
|
||||||
|
|
||||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||||
|
|
||||||
|
#define TAG(A, B, C, D) (ULONG)(((A)<<0) + ((B)<<8) + ((C)<<16) + ((D)<<24))
|
||||||
|
#define CLASS_TAG TAG('K', 'b', 'd', 'C')
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
dsStopped,
|
dsStopped,
|
||||||
|
@ -83,10 +72,7 @@ ForwardIrpAndWait(
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
IN PIRP Irp);
|
IN PIRP Irp);
|
||||||
|
|
||||||
NTSTATUS NTAPI
|
DRIVER_DISPATCH ForwardIrpAndForget;
|
||||||
ForwardIrpAndForget(
|
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
|
||||||
IN PIRP Irp);
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
DuplicateUnicodeString(
|
DuplicateUnicodeString(
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
#include "kbdclass.h"
|
#include "kbdclass.h"
|
||||||
|
|
||||||
|
static IO_COMPLETION_ROUTINE ForwardIrpAndWaitCompletion;
|
||||||
|
|
||||||
static NTSTATUS NTAPI
|
static NTSTATUS NTAPI
|
||||||
ForwardIrpAndWaitCompletion(
|
ForwardIrpAndWaitCompletion(
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
|
@ -35,7 +37,7 @@ ForwardIrpAndWait(
|
||||||
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
||||||
IoCopyCurrentIrpStackLocationToNext(Irp);
|
IoCopyCurrentIrpStackLocationToNext(Irp);
|
||||||
|
|
||||||
DPRINT("Calling lower device %p [%wZ]\n", LowerDevice, &LowerDevice->DriverObject->DriverName);
|
DPRINT("Calling lower device %p\n", LowerDevice);
|
||||||
IoSetCompletionRoutine(Irp, ForwardIrpAndWaitCompletion, &Event, TRUE, TRUE, TRUE);
|
IoSetCompletionRoutine(Irp, ForwardIrpAndWaitCompletion, &Event, TRUE, TRUE, TRUE);
|
||||||
|
|
||||||
Status = IoCallDriver(LowerDevice, Irp);
|
Status = IoCallDriver(LowerDevice, Irp);
|
||||||
|
@ -93,7 +95,7 @@ DuplicateUnicodeString(
|
||||||
if (Flags & RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE)
|
if (Flags & RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE)
|
||||||
DestMaxLength += sizeof(UNICODE_NULL);
|
DestMaxLength += sizeof(UNICODE_NULL);
|
||||||
|
|
||||||
DestinationString->Buffer = ExAllocatePool(PagedPool, DestMaxLength);
|
DestinationString->Buffer = ExAllocatePoolWithTag(PagedPool, DestMaxLength, CLASS_TAG);
|
||||||
if (DestinationString->Buffer == NULL)
|
if (DestinationString->Buffer == NULL)
|
||||||
return STATUS_NO_MEMORY;
|
return STATUS_NO_MEMORY;
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
#include "mouclass.h"
|
#include "mouclass.h"
|
||||||
|
|
||||||
|
static IO_COMPLETION_ROUTINE ForwardIrpAndWaitCompletion;
|
||||||
|
|
||||||
static NTSTATUS NTAPI
|
static NTSTATUS NTAPI
|
||||||
ForwardIrpAndWaitCompletion(
|
ForwardIrpAndWaitCompletion(
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
|
@ -35,7 +37,7 @@ ForwardIrpAndWait(
|
||||||
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
||||||
IoCopyCurrentIrpStackLocationToNext(Irp);
|
IoCopyCurrentIrpStackLocationToNext(Irp);
|
||||||
|
|
||||||
DPRINT("Calling lower device %p [%wZ]\n", LowerDevice, &LowerDevice->DriverObject->DriverName);
|
DPRINT("Calling lower device %p\n", LowerDevice);
|
||||||
IoSetCompletionRoutine(Irp, ForwardIrpAndWaitCompletion, &Event, TRUE, TRUE, TRUE);
|
IoSetCompletionRoutine(Irp, ForwardIrpAndWaitCompletion, &Event, TRUE, TRUE, TRUE);
|
||||||
|
|
||||||
Status = IoCallDriver(LowerDevice, Irp);
|
Status = IoCallDriver(LowerDevice, Irp);
|
||||||
|
@ -93,7 +95,7 @@ DuplicateUnicodeString(
|
||||||
if (Flags & RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE)
|
if (Flags & RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE)
|
||||||
DestMaxLength += sizeof(UNICODE_NULL);
|
DestMaxLength += sizeof(UNICODE_NULL);
|
||||||
|
|
||||||
DestinationString->Buffer = ExAllocatePool(PagedPool, DestMaxLength);
|
DestinationString->Buffer = ExAllocatePoolWithTag(PagedPool, DestMaxLength, CLASS_TAG);
|
||||||
if (DestinationString->Buffer == NULL)
|
if (DestinationString->Buffer == NULL)
|
||||||
return STATUS_NO_MEMORY;
|
return STATUS_NO_MEMORY;
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,16 @@
|
||||||
#define INITGUID
|
#define INITGUID
|
||||||
#include "mouclass.h"
|
#include "mouclass.h"
|
||||||
|
|
||||||
|
static DRIVER_UNLOAD DriverUnload;
|
||||||
|
static DRIVER_DISPATCH ClassCreate;
|
||||||
|
static DRIVER_DISPATCH ClassClose;
|
||||||
|
static DRIVER_DISPATCH ClassCleanup;
|
||||||
|
static DRIVER_DISPATCH ClassRead;
|
||||||
|
static DRIVER_DISPATCH ClassDeviceControl;
|
||||||
|
static DRIVER_DISPATCH IrpStub;
|
||||||
|
static DRIVER_ADD_DEVICE ClassAddDevice;
|
||||||
|
static DRIVER_STARTIO ClassStartIo;
|
||||||
|
|
||||||
static VOID NTAPI
|
static VOID NTAPI
|
||||||
DriverUnload(IN PDRIVER_OBJECT DriverObject)
|
DriverUnload(IN PDRIVER_OBJECT DriverObject)
|
||||||
{
|
{
|
||||||
|
@ -189,11 +199,11 @@ ReadRegistryEntries(
|
||||||
|
|
||||||
ParametersRegistryKey.Length = 0;
|
ParametersRegistryKey.Length = 0;
|
||||||
ParametersRegistryKey.MaximumLength = RegistryPath->Length + sizeof(L"\\Parameters") + sizeof(UNICODE_NULL);
|
ParametersRegistryKey.MaximumLength = RegistryPath->Length + sizeof(L"\\Parameters") + sizeof(UNICODE_NULL);
|
||||||
ParametersRegistryKey.Buffer = ExAllocatePool(PagedPool, ParametersRegistryKey.MaximumLength);
|
ParametersRegistryKey.Buffer = ExAllocatePoolWithTag(PagedPool, ParametersRegistryKey.MaximumLength, CLASS_TAG);
|
||||||
if (!ParametersRegistryKey.Buffer)
|
if (!ParametersRegistryKey.Buffer)
|
||||||
{
|
{
|
||||||
DPRINT("ExAllocatePool() failed\n");
|
DPRINT("ExAllocatePoolWithTag() failed\n");
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
return STATUS_NO_MEMORY;
|
||||||
}
|
}
|
||||||
RtlCopyUnicodeString(&ParametersRegistryKey, RegistryPath);
|
RtlCopyUnicodeString(&ParametersRegistryKey, RegistryPath);
|
||||||
RtlAppendUnicodeToString(&ParametersRegistryKey, L"\\Parameters");
|
RtlAppendUnicodeToString(&ParametersRegistryKey, L"\\Parameters");
|
||||||
|
@ -253,6 +263,7 @@ ReadRegistryEntries(
|
||||||
Status = STATUS_NO_MEMORY;
|
Status = STATUS_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ExFreePoolWithTag(ParametersRegistryKey.Buffer, CLASS_TAG);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,11 +291,11 @@ CreateClassDeviceObject(
|
||||||
+ DriverExtension->DeviceBaseName.Length /* "PointerClass" */
|
+ DriverExtension->DeviceBaseName.Length /* "PointerClass" */
|
||||||
+ 4 * sizeof(WCHAR) /* Id between 0 and 9999 */
|
+ 4 * sizeof(WCHAR) /* Id between 0 and 9999 */
|
||||||
+ sizeof(UNICODE_NULL); /* Final NULL char */
|
+ sizeof(UNICODE_NULL); /* Final NULL char */
|
||||||
DeviceNameU.Buffer = ExAllocatePool(PagedPool, DeviceNameU.MaximumLength);
|
DeviceNameU.Buffer = ExAllocatePoolWithTag(PagedPool, DeviceNameU.MaximumLength, CLASS_TAG);
|
||||||
if (!DeviceNameU.Buffer)
|
if (!DeviceNameU.Buffer)
|
||||||
{
|
{
|
||||||
DPRINT("ExAllocatePool() failed\n");
|
DPRINT("ExAllocatePoolWithTag() failed\n");
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
return STATUS_NO_MEMORY;
|
||||||
}
|
}
|
||||||
Status = RtlAppendUnicodeToString(&DeviceNameU, L"\\Device\\");
|
Status = RtlAppendUnicodeToString(&DeviceNameU, L"\\Device\\");
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
|
@ -325,7 +336,7 @@ CreateClassDeviceObject(
|
||||||
cleanup:
|
cleanup:
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
ExFreePool(DeviceNameU.Buffer);
|
ExFreePoolWithTag(DeviceNameU.Buffer, CLASS_TAG);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,11 +349,11 @@ cleanup:
|
||||||
KeInitializeSpinLock(&DeviceExtension->SpinLock);
|
KeInitializeSpinLock(&DeviceExtension->SpinLock);
|
||||||
DeviceExtension->ReadIsPending = FALSE;
|
DeviceExtension->ReadIsPending = FALSE;
|
||||||
DeviceExtension->InputCount = 0;
|
DeviceExtension->InputCount = 0;
|
||||||
DeviceExtension->PortData = ExAllocatePool(NonPagedPool, DeviceExtension->DriverExtension->DataQueueSize * sizeof(MOUSE_INPUT_DATA));
|
DeviceExtension->PortData = ExAllocatePoolWithTag(NonPagedPool, DeviceExtension->DriverExtension->DataQueueSize * sizeof(KEYBOARD_INPUT_DATA), CLASS_TAG);
|
||||||
if (!DeviceExtension->PortData)
|
if (!DeviceExtension->PortData)
|
||||||
{
|
{
|
||||||
ExFreePool(DeviceNameU.Buffer);
|
ExFreePoolWithTag(DeviceNameU.Buffer, CLASS_TAG);
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
return STATUS_NO_MEMORY;
|
||||||
}
|
}
|
||||||
DeviceExtension->DeviceName = DeviceNameU.Buffer;
|
DeviceExtension->DeviceName = DeviceNameU.Buffer;
|
||||||
Fdo->Flags |= DO_POWER_PAGABLE;
|
Fdo->Flags |= DO_POWER_PAGABLE;
|
||||||
|
@ -524,8 +535,7 @@ ConnectPortDriver(
|
||||||
CONNECT_DATA ConnectData;
|
CONNECT_DATA ConnectData;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
DPRINT("Connecting PortDO %p [%wZ] to ClassDO %p\n",
|
DPRINT("Connecting PortDO %p to ClassDO %p\n", PortDO, ClassDO);
|
||||||
PortDO, &PortDO->DriverObject->DriverName, ClassDO);
|
|
||||||
|
|
||||||
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
||||||
|
|
||||||
|
@ -581,8 +591,7 @@ DestroyPortDriver(
|
||||||
KIRQL OldIrql;
|
KIRQL OldIrql;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
DPRINT("Destroying PortDO %p [%wZ]\n",
|
DPRINT("Destroying PortDO %p\n", PortDO);
|
||||||
PortDO, &PortDO->DriverObject->DriverName);
|
|
||||||
|
|
||||||
DeviceExtension = (PPORT_DEVICE_EXTENSION)PortDO->DeviceExtension;
|
DeviceExtension = (PPORT_DEVICE_EXTENSION)PortDO->DeviceExtension;
|
||||||
ClassDeviceExtension = DeviceExtension->ClassDO->DeviceExtension;
|
ClassDeviceExtension = DeviceExtension->ClassDO->DeviceExtension;
|
||||||
|
@ -620,8 +629,8 @@ DestroyPortDriver(
|
||||||
|
|
||||||
if (!DriverExtension->ConnectMultiplePorts && DeviceExtension->ClassDO)
|
if (!DriverExtension->ConnectMultiplePorts && DeviceExtension->ClassDO)
|
||||||
{
|
{
|
||||||
ExFreePool(ClassDeviceExtension->PortData);
|
ExFreePoolWithTag(ClassDeviceExtension->PortData, CLASS_TAG);
|
||||||
ExFreePool((PVOID)ClassDeviceExtension->DeviceName);
|
ExFreePoolWithTag((PVOID)ClassDeviceExtension->DeviceName, CLASS_TAG);
|
||||||
IoDeleteDevice(DeviceExtension->ClassDO);
|
IoDeleteDevice(DeviceExtension->ClassDO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -814,11 +823,11 @@ SearchForLegacyDrivers(
|
||||||
|
|
||||||
/* Allocate memory */
|
/* Allocate memory */
|
||||||
Size = sizeof(KEY_VALUE_BASIC_INFORMATION) + MAX_PATH;
|
Size = sizeof(KEY_VALUE_BASIC_INFORMATION) + MAX_PATH;
|
||||||
KeyValueInformation = ExAllocatePool(PagedPool, Size);
|
KeyValueInformation = ExAllocatePoolWithTag(PagedPool, Size, CLASS_TAG);
|
||||||
if (!KeyValueInformation)
|
if (!KeyValueInformation)
|
||||||
{
|
{
|
||||||
DPRINT("ExAllocatePool() failed\n");
|
DPRINT("ExAllocatePoolWithTag() failed\n");
|
||||||
Status = STATUS_INSUFFICIENT_RESOURCES;
|
Status = STATUS_NO_MEMORY;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -869,7 +878,7 @@ SearchForLegacyDrivers(
|
||||||
DPRINT("IoGetDeviceObjectPointer(%wZ) failed with status 0x%08lx\n", &PortName, Status);
|
DPRINT("IoGetDeviceObjectPointer(%wZ) failed with status 0x%08lx\n", &PortName, Status);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
DPRINT("Legacy driver found: %wZ\n", &PortDeviceObject->DriverObject->DriverName);
|
DPRINT("Legacy driver found\n");
|
||||||
|
|
||||||
Status = ClassAddDevice(DriverObject, PortDeviceObject);
|
Status = ClassAddDevice(DriverObject, PortDeviceObject);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
|
@ -881,7 +890,7 @@ SearchForLegacyDrivers(
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (KeyValueInformation != NULL)
|
if (KeyValueInformation != NULL)
|
||||||
ExFreePool(KeyValueInformation);
|
ExFreePoolWithTag(KeyValueInformation, CLASS_TAG);
|
||||||
if (hDeviceMapKey != (HANDLE)-1)
|
if (hDeviceMapKey != (HANDLE)-1)
|
||||||
ZwClose(hDeviceMapKey);
|
ZwClose(hDeviceMapKey);
|
||||||
if (hPortKey != (HANDLE)-1)
|
if (hPortKey != (HANDLE)-1)
|
||||||
|
|
|
@ -2,27 +2,16 @@
|
||||||
#include <kbdmou.h>
|
#include <kbdmou.h>
|
||||||
#include <ntddkbd.h>
|
#include <ntddkbd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <pseh/pseh.h>
|
||||||
#if defined(__GNUC__)
|
#include <debug.h>
|
||||||
#include <pseh/pseh.h>
|
|
||||||
#include <debug.h>
|
|
||||||
#elif defined(_MSC_VER)
|
|
||||||
#define DPRINT1 DbgPrint("(%s:%d) ", __FILE__, __LINE__), DbgPrint
|
|
||||||
#define CHECKPOINT1 DbgPrint("(%s:%d)\n", __FILE__, __LINE__)
|
|
||||||
#define DPRINT
|
|
||||||
#define CHECKPOINT
|
|
||||||
#define _SEH_TRY __try
|
|
||||||
#define _SEH_HANDLE __except(1)
|
|
||||||
#define _SEH_END
|
|
||||||
#define _SEH_GetExceptionCode() GetExceptionCode()
|
|
||||||
#else
|
|
||||||
#error Unknown compiler!
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define MAX_PATH 260
|
#define MAX_PATH 260
|
||||||
|
|
||||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||||
|
|
||||||
|
#define TAG(A, B, C, D) (ULONG)(((A)<<0) + ((B)<<8) + ((C)<<16) + ((D)<<24))
|
||||||
|
#define CLASS_TAG TAG('M', 'o', 'u', 'C')
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
dsStopped,
|
dsStopped,
|
||||||
|
@ -83,10 +72,7 @@ ForwardIrpAndWait(
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
IN PIRP Irp);
|
IN PIRP Irp);
|
||||||
|
|
||||||
NTSTATUS NTAPI
|
DRIVER_DISPATCH ForwardIrpAndForget;
|
||||||
ForwardIrpAndForget(
|
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
|
||||||
IN PIRP Irp);
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
DuplicateUnicodeString(
|
DuplicateUnicodeString(
|
||||||
|
|
|
@ -186,9 +186,12 @@ SermousePnp(
|
||||||
PDEVICE_RELATIONS DeviceRelations = NULL;
|
PDEVICE_RELATIONS DeviceRelations = NULL;
|
||||||
DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / TargetDeviceRelation\n");
|
DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / TargetDeviceRelation\n");
|
||||||
|
|
||||||
DeviceRelations = ExAllocatePool(PagedPool, FIELD_OFFSET(DEVICE_RELATIONS, Objects));
|
DeviceRelations = ExAllocatePoolWithTag(PagedPool, FIELD_OFFSET(DEVICE_RELATIONS, Objects), SERMOUSE_TAG);
|
||||||
if (!DeviceRelations)
|
if (!DeviceRelations)
|
||||||
Status = STATUS_INSUFFICIENT_RESOURCES;
|
{
|
||||||
|
DPRINT("ExAllocatePoolWithTag() failed\n");
|
||||||
|
Status = STATUS_NO_MEMORY;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DeviceRelations->Count = 0;
|
DeviceRelations->Count = 0;
|
||||||
|
|
|
@ -43,11 +43,11 @@ ReadRegistryEntries(
|
||||||
|
|
||||||
ParametersRegistryKey.Length = 0;
|
ParametersRegistryKey.Length = 0;
|
||||||
ParametersRegistryKey.MaximumLength = RegistryPath->Length + sizeof(L"\\Parameters") + sizeof(UNICODE_NULL);
|
ParametersRegistryKey.MaximumLength = RegistryPath->Length + sizeof(L"\\Parameters") + sizeof(UNICODE_NULL);
|
||||||
ParametersRegistryKey.Buffer = ExAllocatePool(PagedPool, ParametersRegistryKey.MaximumLength);
|
ParametersRegistryKey.Buffer = ExAllocatePoolWithTag(PagedPool, ParametersRegistryKey.MaximumLength, SERMOUSE_TAG);
|
||||||
if (!ParametersRegistryKey.Buffer)
|
if (!ParametersRegistryKey.Buffer)
|
||||||
{
|
{
|
||||||
DPRINT("ExAllocatePool() failed\n");
|
DPRINT("ExAllocatePoolWithTag() failed\n");
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
return STATUS_NO_MEMORY;
|
||||||
}
|
}
|
||||||
RtlCopyUnicodeString(&ParametersRegistryKey, RegistryPath);
|
RtlCopyUnicodeString(&ParametersRegistryKey, RegistryPath);
|
||||||
RtlAppendUnicodeToString(&ParametersRegistryKey, L"\\Parameters");
|
RtlAppendUnicodeToString(&ParametersRegistryKey, L"\\Parameters");
|
||||||
|
@ -80,7 +80,7 @@ ReadRegistryEntries(
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
ExFreePool(ParametersRegistryKey.Buffer);
|
ExFreePoolWithTag(ParametersRegistryKey.Buffer, SERMOUSE_TAG);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,17 +2,10 @@
|
||||||
#include <kbdmou.h>
|
#include <kbdmou.h>
|
||||||
#include <ntddser.h>
|
#include <ntddser.h>
|
||||||
#include <ntddmou.h>
|
#include <ntddmou.h>
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
#define TAG(A, B, C, D) (ULONG)(((A)<<0) + ((B)<<8) + ((C)<<16) + ((D)<<24))
|
||||||
#include <debug.h>
|
#define SERMOUSE_TAG TAG('S', 'M', 'o', 'u')
|
||||||
#elif defined(_MSC_VER)
|
|
||||||
#define DPRINT1 DbgPrint("(%s:%d) ", __FILE__, __LINE__), DbgPrint
|
|
||||||
#define CHECKPOINT1 DbgPrint("(%s:%d)\n", __FILE__, __LINE__)
|
|
||||||
#define DPRINT
|
|
||||||
#define CHECKPOINT
|
|
||||||
#else
|
|
||||||
#error Unknown compiler!
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue