- replaced IopCreateUnicodeString with RtlCreateUnicodeString

- allocate the DriverName from paged pool

svn path=/trunk/; revision=16694
This commit is contained in:
Thomas Bluemel 2005-07-22 22:40:54 +00:00
parent 5518114830
commit 7aad44a4f5
4 changed files with 42 additions and 84 deletions

View file

@ -245,13 +245,6 @@ IopInitiatePnpIrp(
PIO_STACK_LOCATION Stack PIO_STACK_LOCATION Stack
); );
BOOLEAN
IopCreateUnicodeString(
PUNICODE_STRING Destination,
PWSTR Source,
POOL_TYPE PoolType
);
NTSTATUS NTSTATUS
IoCreateDriverList(VOID); IoCreateDriverList(VOID);

View file

@ -170,13 +170,16 @@ IopGetDriverObject(
/* We don't know which DriverObject we have to open */ /* We don't know which DriverObject we have to open */
return STATUS_INVALID_PARAMETER_2; return STATUS_INVALID_PARAMETER_2;
if (FileSystem == TRUE) DriverName.Buffer = NameBuffer;
wcscpy(NameBuffer, FILESYSTEM_ROOT_NAME); DriverName.Length = 0;
else DriverName.MaximumLength = sizeof(NameBuffer);
wcscpy(NameBuffer, DRIVER_ROOT_NAME);
wcscat(NameBuffer, ServiceName->Buffer); 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); DPRINT("Driver name: '%wZ'\n", &DriverName);
/* Initialize ObjectAttributes for driver object */ /* Initialize ObjectAttributes for driver object */
@ -240,7 +243,7 @@ IopCreateDriverObject(
RtlInitUnicodeString(&DriverName, NameBuffer); RtlInitUnicodeString(&DriverName, NameBuffer);
DPRINT("Driver name: '%wZ'\n", &DriverName); 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 /* If we don't success, it is not a problem. Our driver
* object will not have associated driver name... */ * object will not have associated driver name... */
} }
@ -313,8 +316,10 @@ IopCreateDriverObject(
if (!Object->DriverName.Buffer) if (!Object->DriverName.Buffer)
{ {
Object->DriverName.Buffer = 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); RtlCopyMemory(Object->DriverName.Buffer, DriverName.Buffer, DriverName.Length);
Object->DriverName.Buffer[Object->DriverName.Length / sizeof(WCHAR)] = L'\0';
} }
else else
ExFreePool(Buffer); ExFreePool(Buffer);
@ -882,7 +887,7 @@ IopCreateGroupListEntry(PWSTR ValueName,
RtlZeroMemory(Group, sizeof(SERVICE_GROUP)); RtlZeroMemory(Group, sizeof(SERVICE_GROUP));
if (!RtlpCreateUnicodeString(&Group->GroupName, (PWSTR)ValueData, NonPagedPool)) if (!RtlCreateUnicodeString(&Group->GroupName, (PWSTR)ValueData))
{ {
ExFreePool(Group); ExFreePool(Group);
return(STATUS_INSUFFICIENT_RESOURCES); return(STATUS_INSUFFICIENT_RESOURCES);
@ -1988,7 +1993,7 @@ NtLoadDriver(IN PUNICODE_STRING DriverServiceName)
* Set a service name for the device node * Set a service name for the device node
*/ */
RtlpCreateUnicodeString(&DeviceNode->ServiceName, ServiceName.Buffer, NonPagedPool); RtlCreateUnicodeString(&DeviceNode->ServiceName, ServiceName.Buffer);
/* /*
* Initialize the driver module * Initialize the driver module

View file

@ -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 NTSTATUS
IopGetSystemPowerDeviceObject(PDEVICE_OBJECT *DeviceObject) IopGetSystemPowerDeviceObject(PDEVICE_OBJECT *DeviceObject)
{ {
@ -1272,7 +1240,7 @@ IopActionInterrogateDeviceStack(
/* FIXME: Add information from parent bus driver to InstancePath */ /* FIXME: Add information from parent bus driver to InstancePath */
} }
if (!IopCreateUnicodeString(&DeviceNode->InstancePath, InstancePath, PagedPool)) if (!RtlCreateUnicodeString(&DeviceNode->InstancePath, InstancePath))
{ {
DPRINT("No resources\n"); DPRINT("No resources\n");
/* FIXME: Cleanup and disable device */ /* FIXME: Cleanup and disable device */
@ -2091,9 +2059,8 @@ PnpInit(VOID)
KEBUGCHECKEX(PHASE1_INITIALIZATION_FAILED, Status, 0, 0, 0); KEBUGCHECKEX(PHASE1_INITIALIZATION_FAILED, Status, 0, 0, 0);
} }
if (!IopCreateUnicodeString(&IopRootDeviceNode->InstancePath, if (!RtlCreateUnicodeString(&IopRootDeviceNode->InstancePath,
L"HTREE\\ROOT\\0", L"HTREE\\ROOT\\0"))
PagedPool))
{ {
CPRINT("Failed to create the instance path!\n"); CPRINT("Failed to create the instance path!\n");
KEBUGCHECKEX(PHASE1_INITIALIZATION_FAILED, STATUS_UNSUCCESSFUL, 0, 0, 0); KEBUGCHECKEX(PHASE1_INITIALIZATION_FAILED, STATUS_UNSUCCESSFUL, 0, 0, 0);

View file

@ -159,23 +159,21 @@ PnpRootCreateDevice(
PdoDeviceExtension->Common.DevicePowerState = PowerDeviceD0; PdoDeviceExtension->Common.DevicePowerState = PowerDeviceD0;
if (!IopCreateUnicodeString( if (!RtlCreateUnicodeString(
&PdoDeviceExtension->DeviceID, &PdoDeviceExtension->DeviceID,
ENUM_NAME_ROOT \ ENUM_NAME_ROOT \
L"\\LEGACY_UNKNOWN", L"\\LEGACY_UNKNOWN"))
PagedPool))
{ {
/* FIXME: */ /* FIXME: */
DPRINT("IopCreateUnicodeString() failed\n"); DPRINT("RtlCreateUnicodeString() failed\n");
} }
if (!IopCreateUnicodeString( if (!RtlCreateUnicodeString(
&PdoDeviceExtension->InstanceID, &PdoDeviceExtension->InstanceID,
L"0000", L"0000"))
PagedPool))
{ {
/* FIXME: */ /* FIXME: */
DPRINT("IopCreateUnicodeString() failed\n"); DPRINT("RtlCreateUnicodeString() failed\n");
} }
ExInterlockedInsertTailList( ExInterlockedInsertTailList(
@ -213,12 +211,11 @@ PdoQueryId(
switch (IrpSp->Parameters.QueryId.IdType) { switch (IrpSp->Parameters.QueryId.IdType) {
case BusQueryDeviceID: case BusQueryDeviceID:
Status = IopCreateUnicodeString( Status = RtlDuplicateUnicodeString(TRUE,
&String, &DeviceExtension->DeviceID,
DeviceExtension->DeviceID.Buffer, &String);
PagedPool);
DPRINT("DeviceID: %S\n", String.Buffer); DPRINT("DeviceID: %wZ\n", &String);
Irp->IoStatus.Information = (ULONG_PTR)String.Buffer; Irp->IoStatus.Information = (ULONG_PTR)String.Buffer;
break; break;
@ -229,10 +226,9 @@ PdoQueryId(
break; break;
case BusQueryInstanceID: case BusQueryInstanceID:
Status = IopCreateUnicodeString( Status = RtlDuplicateUnicodeString(TRUE,
&String, &DeviceExtension->InstanceID,
DeviceExtension->InstanceID.Buffer, &String);
PagedPool);
DPRINT("InstanceID: %S\n", String.Buffer); DPRINT("InstanceID: %S\n", String.Buffer);
@ -705,31 +701,30 @@ PnpRootFdoEnumerateDevices(
RtlZeroMemory(Device, sizeof(PNPROOT_DEVICE)); RtlZeroMemory(Device, sizeof(PNPROOT_DEVICE));
if (!IopCreateUnicodeString(&Device->ServiceName, KeyInfo->Name, PagedPool)) if (!RtlCreateUnicodeString(&Device->ServiceName, KeyInfo->Name))
{ {
/* FIXME: */ /* FIXME: */
DPRINT("IopCreateUnicodeString() failed\n"); DPRINT("RtlCreateUnicodeString() failed\n");
} }
wcscpy(Buffer, ENUM_NAME_ROOT); wcscpy(Buffer, ENUM_NAME_ROOT);
wcscat(Buffer, L"\\"); wcscat(Buffer, L"\\");
wcscat(Buffer, KeyInfo->Name); wcscat(Buffer, KeyInfo->Name);
if (!IopCreateUnicodeString(&Device->DeviceID, Buffer, PagedPool)) if (!RtlCreateUnicodeString(&Device->DeviceID, Buffer))
{ {
/* FIXME: */ /* FIXME: */
DPRINT("IopCreateUnicodeString() failed\n"); DPRINT("RtlCreateUnicodeString() failed\n");
} }
DPRINT("Got entry: %S\n", Device->DeviceID.Buffer); DPRINT("Got entry: %S\n", Device->DeviceID.Buffer);
if (!IopCreateUnicodeString( if (!RtlCreateUnicodeString(
&Device->InstanceID, &Device->InstanceID,
SubKeyInfo->Name, SubKeyInfo->Name))
PagedPool))
{ {
/* FIXME: */ /* FIXME: */
DPRINT("IopCreateUnicodeString() failed\n"); DPRINT("RtlCreateUnicodeString() failed\n");
} }
Status = PnpRootFdoReadDeviceInfo(Device); Status = PnpRootFdoReadDeviceInfo(Device);
@ -843,10 +838,9 @@ PnpRootQueryBusRelations(
PdoDeviceExtension->Common.DevicePowerState = PowerDeviceD0; PdoDeviceExtension->Common.DevicePowerState = PowerDeviceD0;
if (!IopCreateUnicodeString( if (!RtlCreateUnicodeString(
&PdoDeviceExtension->DeviceID, &PdoDeviceExtension->DeviceID,
Device->DeviceID.Buffer, Device->DeviceID.Buffer))
PagedPool))
{ {
DPRINT("Insufficient resources\n"); DPRINT("Insufficient resources\n");
/* FIXME: */ /* FIXME: */
@ -856,10 +850,9 @@ PnpRootQueryBusRelations(
&PdoDeviceExtension->DeviceID, &PdoDeviceExtension->DeviceID,
Device->Pdo); Device->Pdo);
if (!IopCreateUnicodeString( if (!RtlCreateUnicodeString(
&PdoDeviceExtension->InstanceID, &PdoDeviceExtension->InstanceID,
Device->InstanceID.Buffer, Device->InstanceID.Buffer))
PagedPool))
{ {
DPRINT("Insufficient resources\n"); DPRINT("Insufficient resources\n");
/* FIXME: */ /* FIXME: */