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: PCI IDE bus driver extension 00004 * FILE: drivers/storage/pciidex/misc.c 00005 * PURPOSE: Misceallenous operations 00006 * PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.org) 00007 */ 00008 00009 #include "pciidex.h" 00010 00011 #define NDEBUG 00012 #include <debug.h> 00013 00014 NTSTATUS NTAPI 00015 PciIdeXGenericCompletion( 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)->IsFDO); 00035 LowerDevice = ((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice; 00036 ASSERT(LowerDevice); 00037 00038 KeInitializeEvent(&Event, NotificationEvent, FALSE); 00039 IoCopyCurrentIrpStackLocationToNext(Irp); 00040 00041 DPRINT("Calling lower device %p [%wZ]\n", LowerDevice, &LowerDevice->DriverObject->DriverName); 00042 IoSetCompletionRoutine(Irp, PciIdeXGenericCompletion, &Event, TRUE, TRUE, TRUE); 00043 00044 Status = IoCallDriver(LowerDevice, Irp); 00045 if (Status == STATUS_PENDING) 00046 { 00047 Status = KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL); 00048 if (NT_SUCCESS(Status)) 00049 Status = Irp->IoStatus.Status; 00050 } 00051 00052 return Status; 00053 } 00054 00055 NTSTATUS NTAPI 00056 ForwardIrpAndForget( 00057 IN PDEVICE_OBJECT DeviceObject, 00058 IN PIRP Irp) 00059 { 00060 PDEVICE_OBJECT LowerDevice; 00061 00062 ASSERT(((PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO); 00063 LowerDevice = ((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice; 00064 ASSERT(LowerDevice); 00065 00066 IoSkipCurrentIrpStackLocation(Irp); 00067 return IoCallDriver(LowerDevice, Irp); 00068 } 00069 00070 NTSTATUS 00071 DuplicateUnicodeString( 00072 IN ULONG Flags, 00073 IN PCUNICODE_STRING SourceString, 00074 OUT PUNICODE_STRING DestinationString) 00075 { 00076 if (SourceString == NULL || DestinationString == NULL 00077 || SourceString->Length > SourceString->MaximumLength 00078 || (SourceString->Length == 0 && SourceString->MaximumLength > 0 && SourceString->Buffer == NULL) 00079 || Flags == RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING || Flags >= 4) 00080 { 00081 return STATUS_INVALID_PARAMETER; 00082 } 00083 00084 00085 if ((SourceString->Length == 0) 00086 && (Flags != (RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE | 00087 RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING))) 00088 { 00089 DestinationString->Length = 0; 00090 DestinationString->MaximumLength = 0; 00091 DestinationString->Buffer = NULL; 00092 } 00093 else 00094 { 00095 USHORT DestMaxLength = SourceString->Length; 00096 00097 if (Flags & RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE) 00098 DestMaxLength += sizeof(UNICODE_NULL); 00099 00100 DestinationString->Buffer = ExAllocatePool(PagedPool, DestMaxLength); 00101 if (DestinationString->Buffer == NULL) 00102 return STATUS_NO_MEMORY; 00103 00104 RtlCopyMemory(DestinationString->Buffer, SourceString->Buffer, SourceString->Length); 00105 DestinationString->Length = SourceString->Length; 00106 DestinationString->MaximumLength = DestMaxLength; 00107 00108 if (Flags & RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE) 00109 DestinationString->Buffer[DestinationString->Length / sizeof(WCHAR)] = 0; 00110 } 00111 00112 return STATUS_SUCCESS; 00113 } Generated on Wed May 23 2012 04:15:09 for ReactOS by
1.7.6.1
|