Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenmisc.c
Go to the documentation of this file.
00001 /* 00002 * COPYRIGHT: See COPYING in the top level directory 00003 * PROJECT: ReactOS Mouse class driver 00004 * FILE: drivers/input/mouclass/misc.c 00005 * PURPOSE: Misceallenous operations 00006 * 00007 * PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.org) 00008 */ 00009 00010 #include "mouclass.h" 00011 00012 static IO_COMPLETION_ROUTINE ForwardIrpAndWaitCompletion; 00013 00014 static NTSTATUS NTAPI 00015 ForwardIrpAndWaitCompletion( 00016 IN PDEVICE_OBJECT DeviceObject, 00017 IN PIRP Irp, 00018 IN PVOID Context) 00019 { 00020 if (Irp->PendingReturned) 00021 KeSetEvent((PKEVENT)Context, IO_NO_INCREMENT, FALSE); 00022 return STATUS_MORE_PROCESSING_REQUIRED; 00023 } 00024 00025 NTSTATUS 00026 ForwardIrpAndWait( 00027 IN PDEVICE_OBJECT DeviceObject, 00028 IN PIRP Irp) 00029 { 00030 PDEVICE_OBJECT LowerDevice; 00031 KEVENT Event; 00032 NTSTATUS Status; 00033 00034 ASSERT(!((PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsClassDO); 00035 LowerDevice = ((PPORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice; 00036 00037 KeInitializeEvent(&Event, NotificationEvent, FALSE); 00038 IoCopyCurrentIrpStackLocationToNext(Irp); 00039 00040 TRACE_(CLASS_NAME, "Calling lower device %p\n", LowerDevice); 00041 IoSetCompletionRoutine(Irp, ForwardIrpAndWaitCompletion, &Event, TRUE, TRUE, TRUE); 00042 00043 Status = IoCallDriver(LowerDevice, Irp); 00044 if (Status == STATUS_PENDING) 00045 { 00046 Status = KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL); 00047 if (NT_SUCCESS(Status)) 00048 Status = Irp->IoStatus.Status; 00049 } 00050 00051 return Status; 00052 } 00053 00054 NTSTATUS NTAPI 00055 ForwardIrpAndForget( 00056 IN PDEVICE_OBJECT DeviceObject, 00057 IN PIRP Irp) 00058 { 00059 PDEVICE_OBJECT LowerDevice; 00060 00061 ASSERT(!((PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsClassDO); 00062 LowerDevice = ((PPORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice; 00063 00064 IoSkipCurrentIrpStackLocation(Irp); 00065 return IoCallDriver(LowerDevice, Irp); 00066 } 00067 00068 NTSTATUS 00069 DuplicateUnicodeString( 00070 IN ULONG Flags, 00071 IN PCUNICODE_STRING SourceString, 00072 OUT PUNICODE_STRING DestinationString) 00073 { 00074 if (SourceString == NULL || DestinationString == NULL 00075 || SourceString->Length > SourceString->MaximumLength 00076 || (SourceString->Length == 0 && SourceString->MaximumLength > 0 && SourceString->Buffer == NULL) 00077 || Flags == RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING || Flags >= 4) 00078 { 00079 return STATUS_INVALID_PARAMETER; 00080 } 00081 00082 00083 if ((SourceString->Length == 0) 00084 && (Flags != (RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE | 00085 RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING))) 00086 { 00087 DestinationString->Length = 0; 00088 DestinationString->MaximumLength = 0; 00089 DestinationString->Buffer = NULL; 00090 } 00091 else 00092 { 00093 USHORT DestMaxLength = SourceString->Length; 00094 00095 if (Flags & RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE) 00096 DestMaxLength += sizeof(UNICODE_NULL); 00097 00098 DestinationString->Buffer = ExAllocatePoolWithTag(PagedPool, DestMaxLength, CLASS_TAG); 00099 if (DestinationString->Buffer == NULL) 00100 return STATUS_NO_MEMORY; 00101 00102 RtlCopyMemory(DestinationString->Buffer, SourceString->Buffer, SourceString->Length); 00103 DestinationString->Length = SourceString->Length; 00104 DestinationString->MaximumLength = DestMaxLength; 00105 00106 if (Flags & RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE) 00107 DestinationString->Buffer[DestinationString->Length / sizeof(WCHAR)] = 0; 00108 } 00109 00110 return STATUS_SUCCESS; 00111 } Generated on Wed May 23 2012 04:15:09 for ReactOS by
1.7.6.1
|