2007-10-31 08:58:04 +00:00
|
|
|
|
/*
|
|
|
|
|
* PROJECT: ReactOS i8042 (ps/2 keyboard-mouse controller) driver
|
|
|
|
|
* LICENSE: GPL - See COPYING in the top level directory
|
|
|
|
|
* FILE: drivers/input/i8042prt/misc.c
|
2016-11-13 15:31:39 +00:00
|
|
|
|
* PURPOSE: Miscellaneous operations
|
2007-10-31 08:58:04 +00:00
|
|
|
|
* PROGRAMMERS: Copyright 2006-2007 Herv<EFBFBD> Poussineau (hpoussin@reactos.org)
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* INCLUDES ******************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "i8042prt.h"
|
|
|
|
|
|
2014-01-02 11:11:12 +00:00
|
|
|
|
#include <debug.h>
|
|
|
|
|
|
2007-10-31 08:58:04 +00:00
|
|
|
|
/* FUNCTIONS *****************************************************************/
|
2014-01-29 10:52:04 +00:00
|
|
|
|
|
2007-10-31 08:58:04 +00:00
|
|
|
|
NTSTATUS NTAPI
|
2009-02-11 17:21:10 +00:00
|
|
|
|
ForwardIrpAndForget(
|
|
|
|
|
IN PDEVICE_OBJECT DeviceObject,
|
|
|
|
|
IN PIRP Irp)
|
2007-10-31 08:58:04 +00:00
|
|
|
|
{
|
2009-02-11 17:21:10 +00:00
|
|
|
|
PDEVICE_OBJECT LowerDevice = ((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice;
|
2007-10-31 08:58:04 +00:00
|
|
|
|
|
2009-02-11 17:21:10 +00:00
|
|
|
|
ASSERT(LowerDevice);
|
2007-10-31 08:58:04 +00:00
|
|
|
|
|
2009-02-11 17:21:10 +00:00
|
|
|
|
IoSkipCurrentIrpStackLocation(Irp);
|
|
|
|
|
return IoCallDriver(LowerDevice, Irp);
|
2007-10-31 08:58:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NTSTATUS
|
2009-02-11 17:21:10 +00:00
|
|
|
|
DuplicateUnicodeString(
|
|
|
|
|
IN ULONG Flags,
|
|
|
|
|
IN PCUNICODE_STRING SourceString,
|
|
|
|
|
OUT PUNICODE_STRING DestinationString)
|
2007-10-31 08:58:04 +00:00
|
|
|
|
{
|
2009-02-11 17:21:10 +00:00
|
|
|
|
if (SourceString == NULL || DestinationString == NULL
|
|
|
|
|
|| SourceString->Length > SourceString->MaximumLength
|
|
|
|
|
|| (SourceString->Length == 0 && SourceString->MaximumLength > 0 && SourceString->Buffer == NULL)
|
|
|
|
|
|| Flags == RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING || Flags >= 4)
|
|
|
|
|
{
|
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((SourceString->Length == 0)
|
2021-06-11 12:29:21 +00:00
|
|
|
|
&& (Flags != (RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE |
|
2009-02-11 17:21:10 +00:00
|
|
|
|
RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING)))
|
|
|
|
|
{
|
|
|
|
|
DestinationString->Length = 0;
|
|
|
|
|
DestinationString->MaximumLength = 0;
|
|
|
|
|
DestinationString->Buffer = NULL;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
USHORT DestMaxLength = SourceString->Length;
|
|
|
|
|
|
|
|
|
|
if (Flags & RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE)
|
|
|
|
|
DestMaxLength += sizeof(UNICODE_NULL);
|
|
|
|
|
|
|
|
|
|
DestinationString->Buffer = ExAllocatePoolWithTag(PagedPool, DestMaxLength, I8042PRT_TAG);
|
|
|
|
|
if (DestinationString->Buffer == NULL)
|
|
|
|
|
return STATUS_NO_MEMORY;
|
|
|
|
|
|
|
|
|
|
RtlCopyMemory(DestinationString->Buffer, SourceString->Buffer, SourceString->Length);
|
|
|
|
|
DestinationString->Length = SourceString->Length;
|
|
|
|
|
DestinationString->MaximumLength = DestMaxLength;
|
|
|
|
|
|
|
|
|
|
if (Flags & RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE)
|
|
|
|
|
DestinationString->Buffer[DestinationString->Length / sizeof(WCHAR)] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return STATUS_SUCCESS;
|
2007-10-31 08:58:04 +00:00
|
|
|
|
}
|