Author: hpoussin Date: Tue Aug 14 21:15:16 2007 New Revision: 28340
URL: http://svn.reactos.org/svn/reactos?rev=28340&view=rev Log: Do not import RtlDuplicateUnicodeString from ntoskrnl, it doesn't exist on MS Windows XP
Modified: trunk/reactos/drivers/bus/pci/pci.c trunk/reactos/drivers/bus/pci/pci.h trunk/reactos/drivers/bus/pci/pdo.c trunk/reactos/drivers/storage/ide/pciidex/misc.c trunk/reactos/drivers/storage/ide/pciidex/pciidex.h trunk/reactos/drivers/storage/ide/pciidex/pdo.c
Modified: trunk/reactos/drivers/bus/pci/pci.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/pci/pci.c?rev=2... ============================================================================== --- trunk/reactos/drivers/bus/pci/pci.c (original) +++ trunk/reactos/drivers/bus/pci/pci.c Tue Aug 14 21:15:16 2007 @@ -297,7 +297,7 @@ BufferU.Length = BufferU.MaximumLength = (USHORT) Index * sizeof(WCHAR); BufferU.Buffer = Buffer;
- return RtlDuplicateUnicodeString(0, &BufferU, HardwareIDs); + return PciDuplicateUnicodeString(0, &BufferU, HardwareIDs); }
@@ -361,7 +361,7 @@ BufferU.Length = BufferU.MaximumLength = (USHORT)Index * sizeof(WCHAR); BufferU.Buffer = Buffer;
- return RtlDuplicateUnicodeString(0, &BufferU, CompatibleIDs); + return PciDuplicateUnicodeString(0, &BufferU, CompatibleIDs); }
@@ -644,4 +644,49 @@ return RtlCreateUnicodeString(DeviceLocation, Buffer) ? STATUS_SUCCESS : STATUS_INSUFFICIENT_RESOURCES; }
+NTSTATUS +PciDuplicateUnicodeString( + IN ULONG Flags, + IN PCUNICODE_STRING SourceString, + OUT PUNICODE_STRING DestinationString) +{ + 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) + && (Flags != (RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE | + 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, TAG_PCI); + 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; +} + /* EOF */
Modified: trunk/reactos/drivers/bus/pci/pci.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/pci/pci.h?rev=2... ============================================================================== --- trunk/reactos/drivers/bus/pci/pci.h (original) +++ trunk/reactos/drivers/bus/pci/pci.h Tue Aug 14 21:15:16 2007 @@ -158,6 +158,12 @@ PUNICODE_STRING DeviceLocation, PPCI_DEVICE Device);
+NTSTATUS +PciDuplicateUnicodeString( + IN ULONG Flags, + IN PCUNICODE_STRING SourceString, + OUT PUNICODE_STRING DestinationString); + /* pdo.c */
NTSTATUS
Modified: trunk/reactos/drivers/bus/pci/pdo.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/pci/pdo.c?rev=2... ============================================================================== --- trunk/reactos/drivers/bus/pci/pdo.c (original) +++ trunk/reactos/drivers/bus/pci/pdo.c Tue Aug 14 21:15:16 2007 @@ -74,7 +74,7 @@
switch (IrpSp->Parameters.QueryId.IdType) { case BusQueryDeviceID: - Status = RtlDuplicateUnicodeString( + Status = PciDuplicateUnicodeString( RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE, &DeviceExtension->DeviceID, &String); @@ -85,7 +85,7 @@ break;
case BusQueryHardwareIDs: - Status = RtlDuplicateUnicodeString( + Status = PciDuplicateUnicodeString( RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE, &DeviceExtension->HardwareIDs, &String); @@ -94,7 +94,7 @@ break;
case BusQueryCompatibleIDs: - Status = RtlDuplicateUnicodeString( + Status = PciDuplicateUnicodeString( RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE, &DeviceExtension->CompatibleIDs, &String); @@ -103,7 +103,7 @@ break;
case BusQueryInstanceID: - Status = RtlDuplicateUnicodeString( + Status = PciDuplicateUnicodeString( RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE, &DeviceExtension->InstanceID, &String);
Modified: trunk/reactos/drivers/storage/ide/pciidex/misc.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/storage/ide/pciidex... ============================================================================== --- trunk/reactos/drivers/storage/ide/pciidex/misc.c (original) +++ trunk/reactos/drivers/storage/ide/pciidex/misc.c Tue Aug 14 21:15:16 2007 @@ -66,3 +66,48 @@ IoSkipCurrentIrpStackLocation(Irp); return IoCallDriver(LowerDevice, Irp); } + +NTSTATUS +DuplicateUnicodeString( + IN ULONG Flags, + IN PCUNICODE_STRING SourceString, + OUT PUNICODE_STRING DestinationString) +{ + 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) + && (Flags != (RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE | + 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 = ExAllocatePool(PagedPool, DestMaxLength); + 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; +}
Modified: trunk/reactos/drivers/storage/ide/pciidex/pciidex.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/storage/ide/pciidex... ============================================================================== --- trunk/reactos/drivers/storage/ide/pciidex/pciidex.h (original) +++ trunk/reactos/drivers/storage/ide/pciidex/pciidex.h Tue Aug 14 21:15:16 2007 @@ -68,6 +68,12 @@ IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp);
+NTSTATUS +DuplicateUnicodeString( + IN ULONG Flags, + IN PCUNICODE_STRING SourceString, + OUT PUNICODE_STRING DestinationString); + /* pdo.c */
NTSTATUS NTAPI
Modified: trunk/reactos/drivers/storage/ide/pciidex/pdo.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/storage/ide/pciidex... ============================================================================== --- trunk/reactos/drivers/storage/ide/pciidex/pdo.c (original) +++ trunk/reactos/drivers/storage/ide/pciidex/pdo.c Tue Aug 14 21:15:16 2007 @@ -111,7 +111,7 @@ return STATUS_NOT_SUPPORTED; }
- Status = RtlDuplicateUnicodeString( + Status = DuplicateUnicodeString( RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE, &SourceString, &String);