diff --git a/reactos/ntoskrnl/include/internal/io.h b/reactos/ntoskrnl/include/internal/io.h index 0bfe0370843..08c0ee72d9c 100644 --- a/reactos/ntoskrnl/include/internal/io.h +++ b/reactos/ntoskrnl/include/internal/io.h @@ -245,13 +245,6 @@ IopInitiatePnpIrp( PIO_STACK_LOCATION Stack ); -BOOLEAN -IopCreateUnicodeString( - PUNICODE_STRING Destination, - PWSTR Source, - POOL_TYPE PoolType -); - NTSTATUS IoCreateDriverList(VOID); diff --git a/reactos/ntoskrnl/io/driver.c b/reactos/ntoskrnl/io/driver.c index a61d43ff828..170892008ca 100644 --- a/reactos/ntoskrnl/io/driver.c +++ b/reactos/ntoskrnl/io/driver.c @@ -170,13 +170,16 @@ IopGetDriverObject( /* We don't know which DriverObject we have to open */ return STATUS_INVALID_PARAMETER_2; - if (FileSystem == TRUE) - wcscpy(NameBuffer, FILESYSTEM_ROOT_NAME); - else - wcscpy(NameBuffer, DRIVER_ROOT_NAME); - wcscat(NameBuffer, ServiceName->Buffer); + DriverName.Buffer = NameBuffer; + DriverName.Length = 0; + DriverName.MaximumLength = sizeof(NameBuffer); + + if (FileSystem == TRUE) + RtlAppendUnicodeToString(&DriverName, FILESYSTEM_ROOT_NAME); + else + RtlAppendUnicodeToString(&DriverName, DRIVER_ROOT_NAME); + RtlAppendUnicodeStringToString(&DriverName, ServiceName); - RtlInitUnicodeString(&DriverName, NameBuffer); DPRINT("Driver name: '%wZ'\n", &DriverName); /* Initialize ObjectAttributes for driver object */ @@ -240,7 +243,7 @@ IopCreateDriverObject( RtlInitUnicodeString(&DriverName, NameBuffer); DPRINT("Driver name: '%wZ'\n", &DriverName); - Buffer = (PWSTR)ExAllocatePool(NonPagedPool, DriverName.Length); + Buffer = (PWSTR)ExAllocatePool(PagedPool, DriverName.Length + sizeof(WCHAR)); /* If we don't success, it is not a problem. Our driver * object will not have associated driver name... */ } @@ -313,8 +316,10 @@ IopCreateDriverObject( if (!Object->DriverName.Buffer) { Object->DriverName.Buffer = Buffer; - Object->DriverName.Length = Object->DriverName.MaximumLength = DriverName.Length; + Object->DriverName.Length = DriverName.Length; + Object->DriverName.MaximumLength = DriverName.Length + sizeof(WCHAR); RtlCopyMemory(Object->DriverName.Buffer, DriverName.Buffer, DriverName.Length); + Object->DriverName.Buffer[Object->DriverName.Length / sizeof(WCHAR)] = L'\0'; } else ExFreePool(Buffer); @@ -882,7 +887,7 @@ IopCreateGroupListEntry(PWSTR ValueName, RtlZeroMemory(Group, sizeof(SERVICE_GROUP)); - if (!RtlpCreateUnicodeString(&Group->GroupName, (PWSTR)ValueData, NonPagedPool)) + if (!RtlCreateUnicodeString(&Group->GroupName, (PWSTR)ValueData)) { ExFreePool(Group); return(STATUS_INSUFFICIENT_RESOURCES); @@ -1988,7 +1993,7 @@ NtLoadDriver(IN PUNICODE_STRING DriverServiceName) * Set a service name for the device node */ - RtlpCreateUnicodeString(&DeviceNode->ServiceName, ServiceName.Buffer, NonPagedPool); + RtlCreateUnicodeString(&DeviceNode->ServiceName, ServiceName.Buffer); /* * Initialize the driver module diff --git a/reactos/ntoskrnl/io/pnpmgr.c b/reactos/ntoskrnl/io/pnpmgr.c index 5a1d1a6e65e..7275027f188 100644 --- a/reactos/ntoskrnl/io/pnpmgr.c +++ b/reactos/ntoskrnl/io/pnpmgr.c @@ -436,38 +436,6 @@ IoRequestDeviceEject( } -BOOLEAN -IopCreateUnicodeString( - PUNICODE_STRING Destination, - PWSTR Source, - POOL_TYPE PoolType) -{ - ULONG Length; - - if (!Source) - { - RtlInitUnicodeString(Destination, NULL); - return TRUE; - } - - Length = (wcslen(Source) + 1) * sizeof(WCHAR); - - Destination->Buffer = ExAllocatePool(PoolType, Length); - - if (Destination->Buffer == NULL) - { - return FALSE; - } - - RtlCopyMemory(Destination->Buffer, Source, Length); - - Destination->MaximumLength = Length; - - Destination->Length = Length - sizeof(WCHAR); - - return TRUE; -} - NTSTATUS IopGetSystemPowerDeviceObject(PDEVICE_OBJECT *DeviceObject) { @@ -1272,7 +1240,7 @@ IopActionInterrogateDeviceStack( /* FIXME: Add information from parent bus driver to InstancePath */ } - if (!IopCreateUnicodeString(&DeviceNode->InstancePath, InstancePath, PagedPool)) + if (!RtlCreateUnicodeString(&DeviceNode->InstancePath, InstancePath)) { DPRINT("No resources\n"); /* FIXME: Cleanup and disable device */ @@ -2091,9 +2059,8 @@ PnpInit(VOID) KEBUGCHECKEX(PHASE1_INITIALIZATION_FAILED, Status, 0, 0, 0); } - if (!IopCreateUnicodeString(&IopRootDeviceNode->InstancePath, - L"HTREE\\ROOT\\0", - PagedPool)) + if (!RtlCreateUnicodeString(&IopRootDeviceNode->InstancePath, + L"HTREE\\ROOT\\0")) { CPRINT("Failed to create the instance path!\n"); KEBUGCHECKEX(PHASE1_INITIALIZATION_FAILED, STATUS_UNSUCCESSFUL, 0, 0, 0); diff --git a/reactos/ntoskrnl/io/pnproot.c b/reactos/ntoskrnl/io/pnproot.c index fbd8e8e4f3e..b77e6bbdbd7 100644 --- a/reactos/ntoskrnl/io/pnproot.c +++ b/reactos/ntoskrnl/io/pnproot.c @@ -159,23 +159,21 @@ PnpRootCreateDevice( PdoDeviceExtension->Common.DevicePowerState = PowerDeviceD0; - if (!IopCreateUnicodeString( + if (!RtlCreateUnicodeString( &PdoDeviceExtension->DeviceID, ENUM_NAME_ROOT \ - L"\\LEGACY_UNKNOWN", - PagedPool)) + L"\\LEGACY_UNKNOWN")) { /* FIXME: */ - DPRINT("IopCreateUnicodeString() failed\n"); + DPRINT("RtlCreateUnicodeString() failed\n"); } - if (!IopCreateUnicodeString( + if (!RtlCreateUnicodeString( &PdoDeviceExtension->InstanceID, - L"0000", - PagedPool)) + L"0000")) { /* FIXME: */ - DPRINT("IopCreateUnicodeString() failed\n"); + DPRINT("RtlCreateUnicodeString() failed\n"); } ExInterlockedInsertTailList( @@ -213,12 +211,11 @@ PdoQueryId( switch (IrpSp->Parameters.QueryId.IdType) { case BusQueryDeviceID: - Status = IopCreateUnicodeString( - &String, - DeviceExtension->DeviceID.Buffer, - PagedPool); + Status = RtlDuplicateUnicodeString(TRUE, + &DeviceExtension->DeviceID, + &String); - DPRINT("DeviceID: %S\n", String.Buffer); + DPRINT("DeviceID: %wZ\n", &String); Irp->IoStatus.Information = (ULONG_PTR)String.Buffer; break; @@ -229,10 +226,9 @@ PdoQueryId( break; case BusQueryInstanceID: - Status = IopCreateUnicodeString( - &String, - DeviceExtension->InstanceID.Buffer, - PagedPool); + Status = RtlDuplicateUnicodeString(TRUE, + &DeviceExtension->InstanceID, + &String); DPRINT("InstanceID: %S\n", String.Buffer); @@ -705,31 +701,30 @@ PnpRootFdoEnumerateDevices( RtlZeroMemory(Device, sizeof(PNPROOT_DEVICE)); - if (!IopCreateUnicodeString(&Device->ServiceName, KeyInfo->Name, PagedPool)) + if (!RtlCreateUnicodeString(&Device->ServiceName, KeyInfo->Name)) { /* FIXME: */ - DPRINT("IopCreateUnicodeString() failed\n"); + DPRINT("RtlCreateUnicodeString() failed\n"); } wcscpy(Buffer, ENUM_NAME_ROOT); wcscat(Buffer, L"\\"); wcscat(Buffer, KeyInfo->Name); - if (!IopCreateUnicodeString(&Device->DeviceID, Buffer, PagedPool)) + if (!RtlCreateUnicodeString(&Device->DeviceID, Buffer)) { /* FIXME: */ - DPRINT("IopCreateUnicodeString() failed\n"); + DPRINT("RtlCreateUnicodeString() failed\n"); } DPRINT("Got entry: %S\n", Device->DeviceID.Buffer); - if (!IopCreateUnicodeString( + if (!RtlCreateUnicodeString( &Device->InstanceID, - SubKeyInfo->Name, - PagedPool)) + SubKeyInfo->Name)) { /* FIXME: */ - DPRINT("IopCreateUnicodeString() failed\n"); + DPRINT("RtlCreateUnicodeString() failed\n"); } Status = PnpRootFdoReadDeviceInfo(Device); @@ -843,10 +838,9 @@ PnpRootQueryBusRelations( PdoDeviceExtension->Common.DevicePowerState = PowerDeviceD0; - if (!IopCreateUnicodeString( + if (!RtlCreateUnicodeString( &PdoDeviceExtension->DeviceID, - Device->DeviceID.Buffer, - PagedPool)) + Device->DeviceID.Buffer)) { DPRINT("Insufficient resources\n"); /* FIXME: */ @@ -856,10 +850,9 @@ PnpRootQueryBusRelations( &PdoDeviceExtension->DeviceID, Device->Pdo); - if (!IopCreateUnicodeString( + if (!RtlCreateUnicodeString( &PdoDeviceExtension->InstanceID, - Device->InstanceID.Buffer, - PagedPool)) + Device->InstanceID.Buffer)) { DPRINT("Insufficient resources\n"); /* FIXME: */