Stop abusing the non-paged pool.

svn path=/trunk/; revision=16869
This commit is contained in:
Filip Navara 2005-07-29 15:08:20 +00:00
parent dd2dc39610
commit 9697817837
3 changed files with 25 additions and 21 deletions

View file

@ -118,6 +118,8 @@ IoGetDeviceInterfaces(
ULONG j = 0; ULONG j = 0;
OBJECT_ATTRIBUTES ObjectAttributes; OBJECT_ATTRIBUTES ObjectAttributes;
ASSERT_IRQL(PASSIVE_LEVEL);
Status = RtlStringFromGUID(InterfaceClassGuid, &GuidString); Status = RtlStringFromGUID(InterfaceClassGuid, &GuidString);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
@ -131,7 +133,7 @@ IoGetDeviceInterfaces(
BaseKeyName.Length = wcslen(BaseKeyString) * sizeof(WCHAR); BaseKeyName.Length = wcslen(BaseKeyString) * sizeof(WCHAR);
BaseKeyName.MaximumLength = BaseKeyName.Length + (38 * sizeof(WCHAR)); BaseKeyName.MaximumLength = BaseKeyName.Length + (38 * sizeof(WCHAR));
BaseKeyName.Buffer = ExAllocatePool( BaseKeyName.Buffer = ExAllocatePool(
NonPagedPool, PagedPool,
BaseKeyName.MaximumLength); BaseKeyName.MaximumLength);
ASSERT(BaseKeyName.Buffer != NULL); ASSERT(BaseKeyName.Buffer != NULL);
wcscpy(BaseKeyName.Buffer, BaseKeyString); wcscpy(BaseKeyName.Buffer, BaseKeyString);
@ -197,7 +199,7 @@ IoGetDeviceInterfaces(
return Status; return Status;
} }
fip = (PKEY_FULL_INFORMATION)ExAllocatePool(NonPagedPool, Size); fip = (PKEY_FULL_INFORMATION)ExAllocatePool(PagedPool, Size);
ASSERT(fip != NULL); ASSERT(fip != NULL);
Status = ZwQueryKey( Status = ZwQueryKey(
@ -237,7 +239,7 @@ IoGetDeviceInterfaces(
return Status; return Status;
} }
bip = (PKEY_BASIC_INFORMATION)ExAllocatePool(NonPagedPool, Size); bip = (PKEY_BASIC_INFORMATION)ExAllocatePool(PagedPool, Size);
ASSERT(bip != NULL); ASSERT(bip != NULL);
Status = ZwEnumerateKey( Status = ZwEnumerateKey(
@ -262,7 +264,7 @@ IoGetDeviceInterfaces(
SubKeyName.Length = 0; SubKeyName.Length = 0;
SubKeyName.MaximumLength = BaseKeyName.Length + bip->NameLength + sizeof(WCHAR); SubKeyName.MaximumLength = BaseKeyName.Length + bip->NameLength + sizeof(WCHAR);
SubKeyName.Buffer = ExAllocatePool(NonPagedPool, SubKeyName.MaximumLength); SubKeyName.Buffer = ExAllocatePool(PagedPool, SubKeyName.MaximumLength);
ASSERT(SubKeyName.Buffer != NULL); ASSERT(SubKeyName.Buffer != NULL);
TempString.Length = TempString.MaximumLength = bip->NameLength; TempString.Length = TempString.MaximumLength = bip->NameLength;
TempString.Buffer = bip->Name; TempString.Buffer = bip->Name;
@ -314,7 +316,7 @@ IoGetDeviceInterfaces(
return Status; return Status;
} }
bfip = (PKEY_FULL_INFORMATION)ExAllocatePool(NonPagedPool, Size); bfip = (PKEY_FULL_INFORMATION)ExAllocatePool(PagedPool, Size);
ASSERT(bfip != NULL); ASSERT(bfip != NULL);
Status = ZwQueryKey( Status = ZwQueryKey(
@ -362,7 +364,7 @@ IoGetDeviceInterfaces(
return Status; return Status;
} }
bip = (PKEY_BASIC_INFORMATION)ExAllocatePool(NonPagedPool, Size); bip = (PKEY_BASIC_INFORMATION)ExAllocatePool(PagedPool, Size);
ASSERT(bip != NULL); ASSERT(bip != NULL);
Status = ZwEnumerateKey( Status = ZwEnumerateKey(
@ -395,7 +397,7 @@ IoGetDeviceInterfaces(
SymbolicLinkKeyName.Length = 0; SymbolicLinkKeyName.Length = 0;
SymbolicLinkKeyName.MaximumLength = SubKeyName.Length + bip->NameLength + sizeof(WCHAR); SymbolicLinkKeyName.MaximumLength = SubKeyName.Length + bip->NameLength + sizeof(WCHAR);
SymbolicLinkKeyName.Buffer = ExAllocatePool(NonPagedPool, SymbolicLinkKeyName.MaximumLength); SymbolicLinkKeyName.Buffer = ExAllocatePool(PagedPool, SymbolicLinkKeyName.MaximumLength);
ASSERT(SymbolicLinkKeyName.Buffer != NULL); ASSERT(SymbolicLinkKeyName.Buffer != NULL);
TempString.Length = TempString.MaximumLength = bip->NameLength; TempString.Length = TempString.MaximumLength = bip->NameLength;
TempString.Buffer = bip->Name; TempString.Buffer = bip->Name;
@ -405,7 +407,7 @@ IoGetDeviceInterfaces(
ControlKeyName.Length = 0; ControlKeyName.Length = 0;
ControlKeyName.MaximumLength = SymbolicLinkKeyName.Length + Control.Length + sizeof(WCHAR); ControlKeyName.MaximumLength = SymbolicLinkKeyName.Length + Control.Length + sizeof(WCHAR);
ControlKeyName.Buffer = ExAllocatePool(NonPagedPool, ControlKeyName.MaximumLength); ControlKeyName.Buffer = ExAllocatePool(PagedPool, ControlKeyName.MaximumLength);
ASSERT(ControlKeyName.Buffer != NULL); ASSERT(ControlKeyName.Buffer != NULL);
RtlCopyUnicodeString(&ControlKeyName, &SymbolicLinkKeyName); RtlCopyUnicodeString(&ControlKeyName, &SymbolicLinkKeyName);
RtlAppendUnicodeStringToString(&ControlKeyName, &Control); RtlAppendUnicodeStringToString(&ControlKeyName, &Control);
@ -466,7 +468,7 @@ IoGetDeviceInterfaces(
return Status; return Status;
} }
vpip = (PKEY_VALUE_PARTIAL_INFORMATION)ExAllocatePool(NonPagedPool, Size); vpip = (PKEY_VALUE_PARTIAL_INFORMATION)ExAllocatePool(PagedPool, Size);
ASSERT(vpip != NULL); ASSERT(vpip != NULL);
Status = ZwQueryValueKey( Status = ZwQueryValueKey(
@ -502,7 +504,7 @@ IoGetDeviceInterfaces(
if (SymLinkList == NULL) if (SymLinkList == NULL)
{ {
SymLinkListSize = vpip->DataLength; SymLinkListSize = vpip->DataLength;
SymLinkList = ExAllocatePool(NonPagedPool, SymLinkListSize + sizeof(WCHAR)); SymLinkList = ExAllocatePool(PagedPool, SymLinkListSize + sizeof(WCHAR));
ASSERT(SymLinkList != NULL); ASSERT(SymLinkList != NULL);
RtlCopyMemory(SymLinkList, vpip->Data, vpip->DataLength); RtlCopyMemory(SymLinkList, vpip->Data, vpip->DataLength);
SymLinkList[vpip->DataLength / sizeof(WCHAR)] = 0; SymLinkList[vpip->DataLength / sizeof(WCHAR)] = 0;
@ -517,7 +519,7 @@ IoGetDeviceInterfaces(
OldSymLinkList = SymLinkList; OldSymLinkList = SymLinkList;
OldSymLinkListSize = SymLinkListSize; OldSymLinkListSize = SymLinkListSize;
SymLinkListSize += vpip->DataLength; SymLinkListSize += vpip->DataLength;
SymLinkList = ExAllocatePool(NonPagedPool, SymLinkListSize + sizeof(WCHAR)); SymLinkList = ExAllocatePool(PagedPool, SymLinkListSize + sizeof(WCHAR));
ASSERT(SymLinkList != NULL); ASSERT(SymLinkList != NULL);
RtlCopyMemory(SymLinkList, OldSymLinkList, OldSymLinkListSize); RtlCopyMemory(SymLinkList, OldSymLinkList, OldSymLinkListSize);
ExFreePool(OldSymLinkList); ExFreePool(OldSymLinkList);
@ -544,7 +546,7 @@ IoGetDeviceInterfaces(
} }
else else
{ {
SymLinkList = ExAllocatePool(NonPagedPool, 2 * sizeof(WCHAR)); SymLinkList = ExAllocatePool(PagedPool, 2 * sizeof(WCHAR));
SymLinkList[0] = 0; SymLinkList[0] = 0;
} }
@ -587,6 +589,8 @@ IoRegisterDeviceInterface(
ULONG i; ULONG i;
NTSTATUS Status; NTSTATUS Status;
ASSERT_IRQL(PASSIVE_LEVEL);
if (!(PhysicalDeviceObject->Flags & DO_BUS_ENUMERATED_DEVICE)) if (!(PhysicalDeviceObject->Flags & DO_BUS_ENUMERATED_DEVICE))
{ {
DPRINT("PhysicalDeviceObject 0x%p is not a valid Pdo\n", PhysicalDeviceObject); DPRINT("PhysicalDeviceObject 0x%p is not a valid Pdo\n", PhysicalDeviceObject);
@ -620,7 +624,7 @@ IoRegisterDeviceInterface(
BaseKeyName.MaximumLength = BaseKeyName.Length BaseKeyName.MaximumLength = BaseKeyName.Length
+ GuidString.Length; + GuidString.Length;
BaseKeyName.Buffer = ExAllocatePool( BaseKeyName.Buffer = ExAllocatePool(
NonPagedPool, PagedPool,
BaseKeyName.MaximumLength); BaseKeyName.MaximumLength);
if (!BaseKeyName.Buffer) if (!BaseKeyName.Buffer)
{ {
@ -662,7 +666,7 @@ IoRegisterDeviceInterface(
sizeof(WCHAR) + /* 1 = size of # */ sizeof(WCHAR) + /* 1 = size of # */
GuidString.Length; GuidString.Length;
InterfaceKeyName.Buffer = ExAllocatePool( InterfaceKeyName.Buffer = ExAllocatePool(
NonPagedPool, PagedPool,
InterfaceKeyName.MaximumLength); InterfaceKeyName.MaximumLength);
if (!InterfaceKeyName.Buffer) if (!InterfaceKeyName.Buffer)
{ {
@ -730,7 +734,7 @@ IoRegisterDeviceInterface(
if (ReferenceString && ReferenceString->Length) if (ReferenceString && ReferenceString->Length)
SubKeyName.MaximumLength += ReferenceString->Length; SubKeyName.MaximumLength += ReferenceString->Length;
SubKeyName.Buffer = ExAllocatePool( SubKeyName.Buffer = ExAllocatePool(
NonPagedPool, PagedPool,
SubKeyName.MaximumLength); SubKeyName.MaximumLength);
if (!SubKeyName.Buffer) if (!SubKeyName.Buffer)
{ {
@ -783,7 +787,7 @@ IoRegisterDeviceInterface(
if (ReferenceString && ReferenceString->Length) if (ReferenceString && ReferenceString->Length)
SymbolicLinkName->MaximumLength += sizeof(WCHAR) + ReferenceString->Length; SymbolicLinkName->MaximumLength += sizeof(WCHAR) + ReferenceString->Length;
SymbolicLinkName->Buffer = ExAllocatePool( SymbolicLinkName->Buffer = ExAllocatePool(
NonPagedPool, PagedPool,
SymbolicLinkName->MaximumLength); SymbolicLinkName->MaximumLength);
if (!SymbolicLinkName->Buffer) if (!SymbolicLinkName->Buffer)
{ {

View file

@ -1525,6 +1525,8 @@ IopUnloadDriver(PUNICODE_STRING DriverServiceName, BOOLEAN UnloadPnpDrivers)
DPRINT("IopUnloadDriver('%wZ', %d)\n", DriverServiceName, UnloadPnpDrivers); DPRINT("IopUnloadDriver('%wZ', %d)\n", DriverServiceName, UnloadPnpDrivers);
PAGED_CODE();
/* /*
* Get the service name from the registry key name * Get the service name from the registry key name
*/ */
@ -1543,7 +1545,7 @@ IopUnloadDriver(PUNICODE_STRING DriverServiceName, BOOLEAN UnloadPnpDrivers)
ObjectName.Length = (wcslen(Start) + 8) * sizeof(WCHAR); ObjectName.Length = (wcslen(Start) + 8) * sizeof(WCHAR);
ObjectName.MaximumLength = ObjectName.Length + sizeof(WCHAR); ObjectName.MaximumLength = ObjectName.Length + sizeof(WCHAR);
ObjectName.Buffer = ExAllocatePool(NonPagedPool, ObjectName.MaximumLength); ObjectName.Buffer = ExAllocatePool(PagedPool, ObjectName.MaximumLength);
wcscpy(ObjectName.Buffer, L"\\Driver\\"); wcscpy(ObjectName.Buffer, L"\\Driver\\");
memcpy(ObjectName.Buffer + 8, Start, (ObjectName.Length - 8) * sizeof(WCHAR)); memcpy(ObjectName.Buffer + 8, Start, (ObjectName.Length - 8) * sizeof(WCHAR));
ObjectName.Buffer[ObjectName.Length/sizeof(WCHAR)] = 0; ObjectName.Buffer[ObjectName.Length/sizeof(WCHAR)] = 0;

View file

@ -129,8 +129,7 @@ IopCreateFile(PVOID ObjectBody,
DeviceObject = DeviceObject->Vpb->DeviceObject; DeviceObject = DeviceObject->Vpb->DeviceObject;
DPRINT("FsDeviceObject %lx\n", DeviceObject); DPRINT("FsDeviceObject %lx\n", DeviceObject);
} }
RtlpCreateUnicodeString(&(FileObject->FileName), RtlCreateUnicodeString(&FileObject->FileName, RemainingPath);
RemainingPath, NonPagedPool);
} }
} }
else else
@ -147,8 +146,7 @@ IopCreateFile(PVOID ObjectBody,
FileObject->RelatedFileObject = (PFILE_OBJECT)Parent; FileObject->RelatedFileObject = (PFILE_OBJECT)Parent;
RtlpCreateUnicodeString(&(FileObject->FileName), RtlCreateUnicodeString(&FileObject->FileName, RemainingPath);
RemainingPath, NonPagedPool);
} }
DPRINT("FileObject->FileName %wZ\n", DPRINT("FileObject->FileName %wZ\n",