ReactOS  0.4.15-dev-3163-gf17c2c0
misc.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS Keyboard class driver
4  * FILE: drivers/input/kbdclass/misc.c
5  * PURPOSE: Miscellaneous operations
6  *
7  * PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.org)
8  */
9 
10 #include "kbdclass.h"
11 
12 #include <debug.h>
13 
14 static IO_COMPLETION_ROUTINE ForwardIrpAndWaitCompletion;
15 
16 static NTSTATUS NTAPI
19  IN PIRP Irp,
21 {
22  if (Irp->PendingReturned)
25 }
26 
30  IN PIRP Irp)
31 {
32  PDEVICE_OBJECT LowerDevice;
33  KEVENT Event;
35 
36  ASSERT(!((PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsClassDO);
37  LowerDevice = ((PPORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice;
38 
41 
42  TRACE_(CLASS_NAME, "Calling lower device %p\n", LowerDevice);
44 
45  Status = IoCallDriver(LowerDevice, Irp);
46  if (Status == STATUS_PENDING)
47  {
49  if (NT_SUCCESS(Status))
50  Status = Irp->IoStatus.Status;
51  }
52 
53  return Status;
54 }
55 
59  IN PIRP Irp)
60 {
61  PDEVICE_OBJECT LowerDevice;
62 
63  ASSERT(!((PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsClassDO);
64  LowerDevice = ((PPORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice;
65 
67  return IoCallDriver(LowerDevice, Irp);
68 }
69 
72  IN ULONG Flags,
75 {
80  {
82  }
83 
84 
85  if ((SourceString->Length == 0)
88  {
92  }
93  else
94  {
95  USHORT DestMaxLength = SourceString->Length;
96 
98  DestMaxLength += sizeof(UNICODE_NULL);
99 
101  if (DestinationString->Buffer == NULL)
102  return STATUS_NO_MEMORY;
103 
106  DestinationString->MaximumLength = DestMaxLength;
107 
110  }
111 
112  return STATUS_SUCCESS;
113 }
#define CLASS_TAG
Definition: kbdclass.h:11
#define IN
Definition: typedefs.h:39
NTSTATUS DuplicateUnicodeString(IN ULONG Flags, IN PCUNICODE_STRING SourceString, OUT PUNICODE_STRING DestinationString)
Definition: misc.c:72
#define STATUS_MORE_PROCESSING_REQUIRED
Definition: shellext.h:68
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING
Definition: green.h:16
LONG NTSTATUS
Definition: precomp.h:26
static IO_COMPLETION_ROUTINE ForwardIrpAndWaitCompletion
Definition: misc.c:14
unsigned short Length
Definition: sprintf.c:451
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
NTSTATUS NTAPI ForwardIrpAndWait(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: misc.c:33
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:498
FORCEINLINE VOID IoCopyCurrentIrpStackLocationToNext(_Inout_ PIRP Irp)
Definition: iofuncs.h:2868
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
void * Buffer
Definition: sprintf.c:453
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define FALSE
Definition: types.h:117
#define UNICODE_NULL
_In_ PIRP Irp
Definition: csq.h:116
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:467
_Out_ _Inout_ POEM_STRING DestinationString
Definition: rtlfuncs.h:1868
Status
Definition: gdiplustypes.h:24
#define TRACE_(x)
Definition: compat.h:76
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define ASSERT(a)
Definition: mode.c:44
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
#define RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE
Definition: green.h:15
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
struct _PORT_DEVICE_EXTENSION * PPORT_DEVICE_EXTENSION
_Out_ _Inout_ POEM_STRING _In_ PCUNICODE_STRING SourceString
Definition: rtlfuncs.h:1868
const TCHAR * CLASS_NAME
Definition: enumwnd.c:16
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
unsigned short USHORT
Definition: pedump.c:61
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
NTSTATUS NTAPI ForwardIrpAndForget(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: misc.c:59
#define NULL
Definition: types.h:112
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
#define OUT
Definition: typedefs.h:40
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_SUCCESS
Definition: shellext.h:65
unsigned short MaximumLength
Definition: sprintf.c:452