mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
Do not import RtlDuplicateUnicodeString from ntoskrnl, it doesn't exist on MS Windows XP
svn path=/trunk/; revision=28340
This commit is contained in:
parent
7278d4e247
commit
d91a924361
6 changed files with 109 additions and 7 deletions
|
@ -297,7 +297,7 @@ PciCreateHardwareIDsString(PUNICODE_STRING HardwareIDs,
|
|||
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 @@ PciCreateCompatibleIDsString(PUNICODE_STRING CompatibleIDs,
|
|||
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 @@ PciCreateDeviceLocationString(PUNICODE_STRING DeviceLocation,
|
|||
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 */
|
||||
|
|
|
@ -158,6 +158,12 @@ PciCreateDeviceLocationString(
|
|||
PUNICODE_STRING DeviceLocation,
|
||||
PPCI_DEVICE Device);
|
||||
|
||||
NTSTATUS
|
||||
PciDuplicateUnicodeString(
|
||||
IN ULONG Flags,
|
||||
IN PCUNICODE_STRING SourceString,
|
||||
OUT PUNICODE_STRING DestinationString);
|
||||
|
||||
/* pdo.c */
|
||||
|
||||
NTSTATUS
|
||||
|
|
|
@ -74,7 +74,7 @@ PdoQueryId(
|
|||
|
||||
switch (IrpSp->Parameters.QueryId.IdType) {
|
||||
case BusQueryDeviceID:
|
||||
Status = RtlDuplicateUnicodeString(
|
||||
Status = PciDuplicateUnicodeString(
|
||||
RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
|
||||
&DeviceExtension->DeviceID,
|
||||
&String);
|
||||
|
@ -85,7 +85,7 @@ PdoQueryId(
|
|||
break;
|
||||
|
||||
case BusQueryHardwareIDs:
|
||||
Status = RtlDuplicateUnicodeString(
|
||||
Status = PciDuplicateUnicodeString(
|
||||
RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
|
||||
&DeviceExtension->HardwareIDs,
|
||||
&String);
|
||||
|
@ -94,7 +94,7 @@ PdoQueryId(
|
|||
break;
|
||||
|
||||
case BusQueryCompatibleIDs:
|
||||
Status = RtlDuplicateUnicodeString(
|
||||
Status = PciDuplicateUnicodeString(
|
||||
RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
|
||||
&DeviceExtension->CompatibleIDs,
|
||||
&String);
|
||||
|
@ -103,7 +103,7 @@ PdoQueryId(
|
|||
break;
|
||||
|
||||
case BusQueryInstanceID:
|
||||
Status = RtlDuplicateUnicodeString(
|
||||
Status = PciDuplicateUnicodeString(
|
||||
RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
|
||||
&DeviceExtension->InstanceID,
|
||||
&String);
|
||||
|
|
|
@ -66,3 +66,48 @@ ForwardIrpAndForget(
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -68,6 +68,12 @@ ForwardIrpAndForget(
|
|||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp);
|
||||
|
||||
NTSTATUS
|
||||
DuplicateUnicodeString(
|
||||
IN ULONG Flags,
|
||||
IN PCUNICODE_STRING SourceString,
|
||||
OUT PUNICODE_STRING DestinationString);
|
||||
|
||||
/* pdo.c */
|
||||
|
||||
NTSTATUS NTAPI
|
||||
|
|
|
@ -111,7 +111,7 @@ PciIdeXPdoQueryId(
|
|||
return STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
Status = RtlDuplicateUnicodeString(
|
||||
Status = DuplicateUnicodeString(
|
||||
RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
|
||||
&SourceString,
|
||||
&String);
|
||||
|
|
Loading…
Reference in a new issue