Do not import RtlDuplicateUnicodeString from ntoskrnl, it doesn't exist on MS Windows XP

svn path=/trunk/; revision=28340
This commit is contained in:
Hervé Poussineau 2007-08-14 17:15:16 +00:00
parent 7278d4e247
commit d91a924361
6 changed files with 109 additions and 7 deletions

View file

@ -297,7 +297,7 @@ PciCreateHardwareIDsString(PUNICODE_STRING HardwareIDs,
BufferU.Length = BufferU.MaximumLength = (USHORT) Index * sizeof(WCHAR); BufferU.Length = BufferU.MaximumLength = (USHORT) Index * sizeof(WCHAR);
BufferU.Buffer = Buffer; BufferU.Buffer = Buffer;
return RtlDuplicateUnicodeString(0, &BufferU, HardwareIDs); return PciDuplicateUnicodeString(0, &BufferU, HardwareIDs);
} }
@ -361,7 +361,7 @@ PciCreateCompatibleIDsString(PUNICODE_STRING CompatibleIDs,
BufferU.Length = BufferU.MaximumLength = (USHORT)Index * sizeof(WCHAR); BufferU.Length = BufferU.MaximumLength = (USHORT)Index * sizeof(WCHAR);
BufferU.Buffer = Buffer; BufferU.Buffer = Buffer;
return RtlDuplicateUnicodeString(0, &BufferU, CompatibleIDs); return PciDuplicateUnicodeString(0, &BufferU, CompatibleIDs);
} }
@ -644,4 +644,49 @@ PciCreateDeviceLocationString(PUNICODE_STRING DeviceLocation,
return RtlCreateUnicodeString(DeviceLocation, Buffer) ? STATUS_SUCCESS : STATUS_INSUFFICIENT_RESOURCES; 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 */ /* EOF */

View file

@ -158,6 +158,12 @@ PciCreateDeviceLocationString(
PUNICODE_STRING DeviceLocation, PUNICODE_STRING DeviceLocation,
PPCI_DEVICE Device); PPCI_DEVICE Device);
NTSTATUS
PciDuplicateUnicodeString(
IN ULONG Flags,
IN PCUNICODE_STRING SourceString,
OUT PUNICODE_STRING DestinationString);
/* pdo.c */ /* pdo.c */
NTSTATUS NTSTATUS

View file

@ -74,7 +74,7 @@ PdoQueryId(
switch (IrpSp->Parameters.QueryId.IdType) { switch (IrpSp->Parameters.QueryId.IdType) {
case BusQueryDeviceID: case BusQueryDeviceID:
Status = RtlDuplicateUnicodeString( Status = PciDuplicateUnicodeString(
RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE, RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
&DeviceExtension->DeviceID, &DeviceExtension->DeviceID,
&String); &String);
@ -85,7 +85,7 @@ PdoQueryId(
break; break;
case BusQueryHardwareIDs: case BusQueryHardwareIDs:
Status = RtlDuplicateUnicodeString( Status = PciDuplicateUnicodeString(
RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE, RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
&DeviceExtension->HardwareIDs, &DeviceExtension->HardwareIDs,
&String); &String);
@ -94,7 +94,7 @@ PdoQueryId(
break; break;
case BusQueryCompatibleIDs: case BusQueryCompatibleIDs:
Status = RtlDuplicateUnicodeString( Status = PciDuplicateUnicodeString(
RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE, RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
&DeviceExtension->CompatibleIDs, &DeviceExtension->CompatibleIDs,
&String); &String);
@ -103,7 +103,7 @@ PdoQueryId(
break; break;
case BusQueryInstanceID: case BusQueryInstanceID:
Status = RtlDuplicateUnicodeString( Status = PciDuplicateUnicodeString(
RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE, RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
&DeviceExtension->InstanceID, &DeviceExtension->InstanceID,
&String); &String);

View file

@ -66,3 +66,48 @@ ForwardIrpAndForget(
IoSkipCurrentIrpStackLocation(Irp); IoSkipCurrentIrpStackLocation(Irp);
return IoCallDriver(LowerDevice, 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;
}

View file

@ -68,6 +68,12 @@ ForwardIrpAndForget(
IN PDEVICE_OBJECT DeviceObject, IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp); IN PIRP Irp);
NTSTATUS
DuplicateUnicodeString(
IN ULONG Flags,
IN PCUNICODE_STRING SourceString,
OUT PUNICODE_STRING DestinationString);
/* pdo.c */ /* pdo.c */
NTSTATUS NTAPI NTSTATUS NTAPI

View file

@ -111,7 +111,7 @@ PciIdeXPdoQueryId(
return STATUS_NOT_SUPPORTED; return STATUS_NOT_SUPPORTED;
} }
Status = RtlDuplicateUnicodeString( Status = DuplicateUnicodeString(
RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE, RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
&SourceString, &SourceString,
&String); &String);