Author: hpoussin
Date: Wed Mar 28 22:47:35 2007
New Revision: 26197
URL:
http://svn.reactos.org/svn/reactos?rev=26197&view=rev
Log:
Don't use ntoskrnl.RtlDuplicateUnicodeString, as it is not exported on MS Windows
Modified:
trunk/reactos/drivers/bus/serenum/detect.c
trunk/reactos/drivers/bus/serenum/fdo.c
trunk/reactos/drivers/bus/serenum/misc.c
trunk/reactos/drivers/bus/serenum/pdo.c
trunk/reactos/drivers/bus/serenum/serenum.c
trunk/reactos/drivers/bus/serenum/serenum.h
trunk/reactos/drivers/bus/serenum/serenum.rbuild
Modified: trunk/reactos/drivers/bus/serenum/detect.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/serenum/detect…
==============================================================================
--- trunk/reactos/drivers/bus/serenum/detect.c (original)
+++ trunk/reactos/drivers/bus/serenum/detect.c Wed Mar 28 22:47:35 2007
@@ -9,7 +9,6 @@
* Hervé Poussineau (hpoussin(a)reactos.com)
*/
-#define NDEBUG
#include "serenum.h"
static NTSTATUS
@@ -129,15 +128,15 @@
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);
- if (!NT_SUCCESS(Status)) goto ByeBye;
- Status = RtlDuplicateUnicodeString(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);
- if (!NT_SUCCESS(Status)) goto ByeBye;
- Status = RtlDuplicateUnicodeString(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,
DeviceDescription, &PdoDeviceExtension->DeviceDescription);
+ if (!NT_SUCCESS(Status)) goto ByeBye;
+ Status = DuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE, DeviceId,
&PdoDeviceExtension->DeviceId);
+ if (!NT_SUCCESS(Status)) goto ByeBye;
+ Status = DuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE, InstanceId,
&PdoDeviceExtension->InstanceId);
+ if (!NT_SUCCESS(Status)) goto ByeBye;
+ Status = DuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
HardwareIds, &PdoDeviceExtension->HardwareIds);
+ if (!NT_SUCCESS(Status)) goto ByeBye;
+ 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
Modified: trunk/reactos/drivers/bus/serenum/fdo.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/serenum/fdo.c?…
==============================================================================
--- trunk/reactos/drivers/bus/serenum/fdo.c (original)
+++ trunk/reactos/drivers/bus/serenum/fdo.c Wed Mar 28 22:47:35 2007
@@ -7,7 +7,6 @@
* PROGRAMMERS: Hervé Poussineau (hpoussin(a)reactos.com)
*/
-#define NDEBUG
#include "serenum.h"
NTSTATUS NTAPI
Modified: trunk/reactos/drivers/bus/serenum/misc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/serenum/misc.c…
==============================================================================
--- trunk/reactos/drivers/bus/serenum/misc.c (original)
+++ trunk/reactos/drivers/bus/serenum/misc.c Wed Mar 28 22:47:35 2007
@@ -7,9 +7,10 @@
* PROGRAMMERS: Hervé Poussineau (hpoussin(a)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
@@ -114,7 +115,7 @@
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 @@
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 @@
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 @@
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;
+}
Modified: trunk/reactos/drivers/bus/serenum/pdo.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/serenum/pdo.c?…
==============================================================================
--- trunk/reactos/drivers/bus/serenum/pdo.c (original)
+++ trunk/reactos/drivers/bus/serenum/pdo.c Wed Mar 28 22:47:35 2007
@@ -7,7 +7,6 @@
* PROGRAMMERS: Hervé Poussineau (hpoussin(a)reactos.com)
*/
-#define NDEBUG
#include "serenum.h"
static NTSTATUS
@@ -70,7 +69,7 @@
return STATUS_NOT_SUPPORTED;
}
- Status = RtlDuplicateUnicodeString(
+ Status = DuplicateUnicodeString(
RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
SourceString,
&String);
Modified: trunk/reactos/drivers/bus/serenum/serenum.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/serenum/serenu…
==============================================================================
--- trunk/reactos/drivers/bus/serenum/serenum.c (original)
+++ trunk/reactos/drivers/bus/serenum/serenum.c Wed Mar 28 22:47:35 2007
@@ -7,9 +7,13 @@
* PROGRAMMERS: Hervé Poussineau (hpoussin(a)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(
Modified: trunk/reactos/drivers/bus/serenum/serenum.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/serenum/serenu…
==============================================================================
--- trunk/reactos/drivers/bus/serenum/serenum.h (original)
+++ trunk/reactos/drivers/bus/serenum/serenum.h Wed Mar 28 22:47:35 2007
@@ -86,10 +86,7 @@
/************************************ fdo.c */
-NTSTATUS NTAPI
-SerenumAddDevice(
- IN PDRIVER_OBJECT DriverObject,
- IN PDEVICE_OBJECT Pdo);
+DRIVER_ADD_DEVICE SerenumAddDevice;
NTSTATUS
SerenumFdoPnp(
@@ -123,6 +120,12 @@
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp);
+NTSTATUS
+DuplicateUnicodeString(
+ IN ULONG Flags,
+ IN PCUNICODE_STRING SourceString,
+ OUT PUNICODE_STRING DestinationString);
+
/************************************ pdo.c */
NTSTATUS
Modified: trunk/reactos/drivers/bus/serenum/serenum.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/serenum/serenu…
==============================================================================
--- trunk/reactos/drivers/bus/serenum/serenum.rbuild (original)
+++ trunk/reactos/drivers/bus/serenum/serenum.rbuild Wed Mar 28 22:47:35 2007
@@ -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>