mirror of
https://github.com/reactos/reactos.git
synced 2024-07-03 19:24:20 +00:00
Don't use ntoskrnl.RtlDuplicateUnicodeString, as it is not exported on MS Windows
svn path=/trunk/; revision=26197
This commit is contained in:
parent
d8175ef0a6
commit
e2ab9cb060
|
@ -9,7 +9,6 @@
|
|||
* Hervé Poussineau (hpoussin@reactos.com)
|
||||
*/
|
||||
|
||||
#define NDEBUG
|
||||
#include "serenum.h"
|
||||
|
||||
static NTSTATUS
|
||||
|
@ -129,15 +128,15 @@ ReportDetectedDevice(
|
|||
FdoDeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||
RtlZeroMemory(PdoDeviceExtension, sizeof(PDO_DEVICE_EXTENSION));
|
||||
PdoDeviceExtension->Common.IsFDO = FALSE;
|
||||
Status = RtlDuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE, DeviceDescription, &PdoDeviceExtension->DeviceDescription);
|
||||
Status = DuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE, DeviceDescription, &PdoDeviceExtension->DeviceDescription);
|
||||
if (!NT_SUCCESS(Status)) goto ByeBye;
|
||||
Status = RtlDuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE, DeviceId, &PdoDeviceExtension->DeviceId);
|
||||
Status = DuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE, DeviceId, &PdoDeviceExtension->DeviceId);
|
||||
if (!NT_SUCCESS(Status)) goto ByeBye;
|
||||
Status = RtlDuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE, InstanceId, &PdoDeviceExtension->InstanceId);
|
||||
Status = DuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE, InstanceId, &PdoDeviceExtension->InstanceId);
|
||||
if (!NT_SUCCESS(Status)) goto ByeBye;
|
||||
Status = RtlDuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE, HardwareIds, &PdoDeviceExtension->HardwareIds);
|
||||
Status = DuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE, HardwareIds, &PdoDeviceExtension->HardwareIds);
|
||||
if (!NT_SUCCESS(Status)) goto ByeBye;
|
||||
Status = RtlDuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE, CompatibleIds, &PdoDeviceExtension->CompatibleIds);
|
||||
Status = DuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE, CompatibleIds, &PdoDeviceExtension->CompatibleIds);
|
||||
if (!NT_SUCCESS(Status)) goto ByeBye;
|
||||
|
||||
/* Device attached to serial port (Pdo) may delegate work to
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
* PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.com)
|
||||
*/
|
||||
|
||||
#define NDEBUG
|
||||
#include "serenum.h"
|
||||
|
||||
NTSTATUS NTAPI
|
||||
|
|
|
@ -7,10 +7,11 @@
|
|||
* PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.com)
|
||||
*/
|
||||
|
||||
#define NDEBUG
|
||||
#include "serenum.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
static IO_COMPLETION_ROUTINE ForwardIrpAndWaitCompletion;
|
||||
|
||||
/* I really want PCSZ strings as last arguments because
|
||||
* PnP ids are ANSI-encoded in PnP device string
|
||||
* identification */
|
||||
|
@ -114,7 +115,7 @@ ForwardIrpAndWait(
|
|||
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
||||
IoCopyCurrentIrpStackLocationToNext(Irp);
|
||||
|
||||
DPRINT("Calling lower device %p [%wZ]\n", LowerDevice, &LowerDevice->DriverObject->DriverName);
|
||||
DPRINT("Calling lower device %p\n", LowerDevice);
|
||||
IoSetCompletionRoutine(Irp, ForwardIrpAndWaitCompletion, &Event, TRUE, TRUE, TRUE);
|
||||
|
||||
Status = IoCallDriver(LowerDevice, Irp);
|
||||
|
@ -141,8 +142,7 @@ ForwardIrpToLowerDeviceAndForget(
|
|||
|
||||
LowerDevice = DeviceExtension->LowerDevice;
|
||||
ASSERT(LowerDevice);
|
||||
DPRINT("Calling lower device 0x%p [%wZ]\n",
|
||||
LowerDevice, &LowerDevice->DriverObject->DriverName);
|
||||
DPRINT("Calling lower device 0x%p\n", LowerDevice);
|
||||
IoSkipCurrentIrpStackLocation(Irp);
|
||||
return IoCallDriver(LowerDevice, Irp);
|
||||
}
|
||||
|
@ -160,8 +160,7 @@ ForwardIrpToAttachedFdoAndForget(
|
|||
|
||||
Fdo = DeviceExtension->AttachedFdo;
|
||||
ASSERT(Fdo);
|
||||
DPRINT("Calling attached Fdo 0x%p [%wZ]\n",
|
||||
Fdo, &Fdo->DriverObject->DriverName);
|
||||
DPRINT("Calling attached Fdo 0x%p\n", Fdo);
|
||||
IoSkipCurrentIrpStackLocation(Irp);
|
||||
return IoCallDriver(Fdo, Irp);
|
||||
}
|
||||
|
@ -180,3 +179,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 = ExAllocatePoolWithTag(PagedPool, DestMaxLength, SERENUM_TAG);
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
* PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.com)
|
||||
*/
|
||||
|
||||
#define NDEBUG
|
||||
#include "serenum.h"
|
||||
|
||||
static NTSTATUS
|
||||
|
@ -70,7 +69,7 @@ SerenumPdoQueryId(
|
|||
return STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
Status = RtlDuplicateUnicodeString(
|
||||
Status = DuplicateUnicodeString(
|
||||
RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
|
||||
SourceString,
|
||||
&String);
|
||||
|
|
|
@ -7,10 +7,14 @@
|
|||
* PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.com)
|
||||
*/
|
||||
|
||||
#define NDEBUG
|
||||
#define INITGUID
|
||||
#include "serenum.h"
|
||||
|
||||
static DRIVER_DISPATCH SerenumPnp;
|
||||
static DRIVER_DISPATCH IrpStub;
|
||||
static DRIVER_UNLOAD DriverUnload;
|
||||
DRIVER_INITIALIZE DriverEntry;
|
||||
|
||||
static NTSTATUS NTAPI
|
||||
SerenumPnp(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
|
|
|
@ -86,10 +86,7 @@ SerenumDetectLegacyDevice(
|
|||
|
||||
/************************************ fdo.c */
|
||||
|
||||
NTSTATUS NTAPI
|
||||
SerenumAddDevice(
|
||||
IN PDRIVER_OBJECT DriverObject,
|
||||
IN PDEVICE_OBJECT Pdo);
|
||||
DRIVER_ADD_DEVICE SerenumAddDevice;
|
||||
|
||||
NTSTATUS
|
||||
SerenumFdoPnp(
|
||||
|
@ -123,6 +120,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
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<module name="serenum" type="kernelmodedriver" installbase="system32/drivers" installname="serenum.sys">
|
||||
<include base="serenum">.</include>
|
||||
<define name="__USE_W32API" />
|
||||
<define name="NDEBUG" />
|
||||
<library>ntoskrnl</library>
|
||||
<library>hal</library>
|
||||
<file>detect.c</file>
|
||||
|
|
Loading…
Reference in a new issue