|
Definition at line 970 of file poolhack.c.
References APC_LEVEL, BasePoolTypeTable, DbgPrint, DeallocatePoolInternal(), FALSE, HBLOCK_SIZE, KeAcquireSpinLock, KeBugCheck(), KeLowerIrql(), KeRaiseIrql(), KeReleaseSemaphore(), KeReleaseSpinLock(), KernelMode, KeSweepDcache(), KeWaitForSingleObject(), KiFlushSingleTb(), L, Lock, LOCK_POOL, _POOL_DESCRIPTOR::LockAddress, _POOL_HEADER::LogAllocationSize, MaxPoolType, MI_PFN_ELEMENT, MiDecrementShareCountOnly, MiFreePoolPages(), MiGetPteAddress, MiReleaseSystemPtes(), MM_EMPTY_LIST, MmDeterminePoolType(), MmPfnLock, NtFreeVirtualMemory(), NULL, ObDereferenceObject, PAGE_ALIGNED, POOL_OVERHEAD, POOL_TYPE, PoolAllocation, _POOL_HEADER::PoolType, PoolVector, PPOOL_DESCRIPTOR, PPOOL_HEADER, _POOL_HEADER::ProcessBilled, PsGetCurrentThread, PsReturnPoolQuota(), _MMPFN::PteAddress, SystemPteSpace, TRUE, _MMPTE::u, UNLOCK_POOL, VOID(), and ZeroPte.
Referenced by ArbAddOrdering(), ArbBuildAssignmentOrdering(), ArbDeleteArbiterInstance(), ArbFreeOrderingList(), ArbInitializeArbiterInstance(), ArbpBuildAllocationStack(), ArbpGetRegistryValue(), ArbPruneOrdering(), ArbQueryConflict(), BuildQueryDirectoryIrp(), CcDeallocateBcb(), CcDeleteMbcb(), CcDeleteSharedCacheMap(), CcDrainVacbLevelZone(), CcExtendVacbArray(), CcInitializeCacheMap(), CcPostDeferredWrites(), CcUninitializeCacheMap(), CcUnpinData(), CcUnpinDataForThread(), CcWriteBehind(), CcZeroData(), CmDeleteKeyRecursive(), CmInitSystem1(), CmpAddToHiveFileList(), CmpAllocatePostBlock(), CmpAppendStringToMultiSz(), CmpCleanUpKcbValueCache(), CmpCloneControlSet(), CmpCloneHwProfile(), CmpCloseInfFile(), CmpCopySyncTree(), CmpCopySyncTree2(), CmpCreateRegistryRoot(), CmpDelayedDerefKeys(), CmpDestroyTemporaryHive(), CmpDiskFullWarningWorker(), CmpFindACPITable(), CmpFindRSDTTable(), CmpFlushNotify(), CmpFree(), CmpFreeLineList(), CmpFreePostBlock(), CmpFreeSectionList(), CmpFreeValueList(), CmpGetAcpiProfileInformation(), CmpGetRegistryValue(), CmpGetSymbolicLink(), CmpGetValueDataFromCache(), CmpHiveRootSecurityDescriptor(), CmpInitializeHardwareConfiguration(), CmpInitializeHive(), CmpInitializeHiveList(), CmpInitializeMachineDependentConfiguration(), CmpInitializeRegistryNode(), CmpInitializeSystemHive(), CmpLoadHiveVolatile(), CmpMergeKeyValues(), CmpNameFromAttributes(), CmpNotifyChangeKey(), CmpOpenHiveFiles(), CmpOpenRegKey(), CmpParseInfBuffer(), CmpPostNotify(), CmpProcessBitRegLine(), CmpQuotaWarningWorker(), CmpRemoveFromHiveFileList(), CmpSaveBootControlSet(), CmpSaveKeyByFileCopy(), CmpSetSecurityDescriptorInfo(), CmpSetValueKeyExisting(), CmpSetVersionData(), CmpValidateAlternate(), CmpWorker(), CmReplaceKey(), CmSetAcpiHwProfile(), CmUnloadKey(), ComPortDBAdd(), DbgkCreateThread(), DbgkpSectionHandleToFileHandle(), DoPoolTest(), DriverEntry(), EisaBuildEisaDeviceNode(), EisaGetEisaDevicesResources(), ExCreateDebugLogTag(), ExDeleteResourceLite(), ExLockUserBuffer(), ExpAllocateHandleTable(), ExpAllocateHandleTableEntry(), ExpAllocatePoolWithQuotaHandler(), ExpFindCurrentThread(), ExpFreeHandleTable(), ExpGetPoolTagInfo(), ExpProfileDelete(), ExpQueryLegacyDriverInformation(), ExpSystemErrorHandler(), ExRegisterCallback(), ExUnlockUserBuffer(), ExUnregisterCallback(), FatRecFsControl(), FindPathForDevice(), FsgWriteToFrameBuffer(), FsRecUnload(), FsRtlAddLargeEntry(), FsRtlAllocateOplock(), FsRtlCancelNotify(), FsRtlDeregisterUncProvider(), FsRtlFreeTunnelNode(), FsRtlGetCompatibilityModeValue(), FsRtlGetTunnelParameterValue(), FsRtlIsDbcsInExpression(), FsRtlIsNameInExpressionPrivate(), FsRtlNotifyCleanup(), FsRtlNotifyCompleteIrp(), FsRtlNotifyFullChangeDirectory(), FsRtlNotifyFullReportChange(), FsRtlNotifyUninitializeSync(), FsRtlpRegisterProviderWithMUP(), FsRtlRegisterUncProvider(), FsRtlRemoveAndCompleteWaitIrp(), FsRtlStackOverflowRead(), FsRtlTruncateLargeMcb(), FsRtlUninitializeLargeMcb(), FsRtlUninitializeOplock(), FsVgaServiceParameters(), FsVgaWriteToFrameBuffer(), GetNextReparseVolumePath(), HalpGetFullGeometry(), HalpNextMountLetter(), HalpSetMountLetter(), HvpDiscardBins(), HvpDoWriteHive(), HvpReadFileImageAndBuildMap(), HvpRecoverData(), HvpWriteLog(), InitCreateUserCrit(), IoAllocateDriverObjectExtension(), IoBuildDeviceIoControlRequest(), IoConnectInterrupt(), IoCreateDevice(), IoCreateFile(), IoDeleteDevice(), IoDisconnectInterrupt(), IoepFreeErrStack(), IoepGetErrCaseDB(), IoepInitErrLog(), IoepLogErr(), IoErrFreeSavedData(), IoErrGetErrData(), IoErrPropagateErrLog(), IoErrTerminateErrLog(), IoFreeDumpStack(), IoFreeMdl(), IoFreePoDeviceNotifyList(), IoFreeWorkItem(), IoGetBootDiskInformation(), IoGetDeviceInterfaceAlias(), IoGetDeviceProperty(), IoGetLegacyVetoList(), IoInitSystem(), IoIsValidNameGraftingBuffer(), IoOpenDeviceRegistryKey(), IopAllocateResources(), IopApcHardError(), IopAppendLegacyVeto(), IopAppendStringToValueKey(), IopApplyFunctionToServiceInstances(), IopApplyFunctionToSubKeys(), IopApplySystemPartitionProt(), IopArbitrateDeviceResources(), IopBuildCmResourceList(), IopCallDriverAddDevice(), IopCallDriverAddDeviceQueryRoutine(), IopChangeDeviceObjectFromRegistryProperties(), IopCheckDependencies(), IopChildToRootTranslation(), IopCompleteRequest(), IopCompleteUnloadOrDelete(), IopCompressRelationList(), IopCopyBootLogRegistryToFile(), IopCreateArcNames(), IopCreateCmResourceList(), IopCreateMadeupNode(), IopDeallocateApc(), IopDelayedRemoveWorker(), IopDeleteDevice(), IopDeleteDriver(), IopDeleteFile(), IopDeleteLegacyKey(), IopDeleteLockedDeviceNode(), IopDeleteSessionSymLinks(), IopDereferenceNotify(), IopDereferenceVpbAndFree(), IopDestroyDeviceNode(), IopDeviceActionWorker(), IopDeviceObjectFromDeviceInstance(), IopDeviceRelationsComplete(), IopDeviceStartComplete(), IopDoDeferredSetInterfaceState(), IopDoNameTransmogrify(), IopDriverLoadingFailed(), IopDropIrp(), IopDuplicateDetection(), IopEnumerateDevice(), IopErrorLogDpc(), IopErrorLogThread(), IopExceptionCleanup(), IopExecuteHardwareProfileChange(), IopFilterResourceRequirementsList(), IopFreeAllocatedUnicodeString(), IopFreeBuffer(), IopFreeDCB(), IopFreeGroupTree(), IopFreeIrp(), IopFreeMiniPacket(), IopFreePoDeviceNotifyListHead(), IopFreeRelationList(), IopFreeReqAlternative(), IopFreeReqList(), IopFreeResourceRequirementsForAssignTable(), IopFreeUnicodeStringList(), IopGetBusTypeGuidIndex(), IopGetDeviceInstanceCsConfigFlags(), IopGetDeviceInterfaces(), IopGetDeviceResourcesFromRegistry(), IopGetDriverDeviceList(), IopGetDriverNameFromKeyNode(), IopGetDriverTagPriority(), IopGetDumpStack(), IopGetGroupOrderIndex(), IopGetLegacyVetoListDrivers(), IopGetRegistryDwordWithFallback(), IopGetRegistryKeyInformation(), IopGetRegistrySecurityWithFallback(), IopGetRegistryValue(), IopGetRelatedTargetDevice(), IopGetResourceRequirementsForAssignTable(), IopGetRootDevices(), IopGetServiceInstanceCsConfigFlags(), IopGetServiceType(), IopHardErrorThread(), IopHardwareProfileCommitRemovedDock(), IopHardwareProfileMarkDock(), IopInitializeBootDrivers(), IopInitializeDCB(), IopInitializeDeviceInstanceKey(), IopInitializePlugPlayServices(), IopInitializeResourceMap(), IopInitializeSystemDrivers(), IopInvalidateDeviceStateWorker(), IopIsAnyDeviceInstanceEnabled(), IopIsDeviceInstanceEnabled(), IopIsFirmwareMapperDevicePresent(), IopIsReportedAlready(), IopLegacyResourceAllocation(), IopLoadBootFilterDriver(), IopLoadDriver(), IopLoadDumpDriver(), IopLoadUnloadDriver(), IopMakeGloballyUniqueId(), IoPnPDeliverServicePowerNotification(), IopOpenDeviceParametersSubkey(), IopParseDevice(), IopPrepareDriverLoading(), IopProcessAssignResources(), IopProcessCompletedEject(), IopProcessCriticalDeviceRoutine(), IopProcessDeferredRegistrations(), IopProcessNewDeviceNode(), IopProcessNewProfileWorker(), IopProcessRelation(), IopProcessSetInterfaceState(), IopQueryConflictListInternal(), IopQueryDeviceResources(), IopQueryDockRemovalInterface(), IopQueryLegacyBusInformation(), IopQueryName(), IopQueryPnpBusInformation(), IopQueryRebalance(), IopQueryResourceHandlerInterface(), IopRaiseHardError(), IopRaiseInformationalHardError(), IopReadDeviceConfiguration(), IopReadDumpRegistry(), IopRealloc(), IopReallocateResources(), IopRebalance(), IopReleaseFilteredBootResources(), IopReleaseResources(), IopRemoveDeviceInterfaces(), IopRemoveIndirectRelationsFromList(), IopRemoveRelationFromList(), IopRemoveStringFromValueKey(), IopReportTargetDeviceChangeAsyncWorker(), IopRequestDeviceEjectWorker(), IopReserveBootResources(), IopReserveBootResourcesInternal(), IopReserveLegacyBootResources(), IopResizeBuffer(), IopRestartDeviceNode(), IopRestoreResourcesInternal(), IopSafebootDriverLoad(), IopServiceInstanceToDeviceInstance(), IopSetDefaultGateway(), IopSetDeviceSecurityDescriptors(), IopSetEaOrQuotaInformationFile(), IopSetSecurityObjectFromRegistry(), IopStartAndEnumerateDevice(), IopStartApcHardError(), IopStartDriverDevices(), IopStartNetworkForRemoteBoot(), IopSynchronousApiServiceTail(), IopTCPSetInformationEx(), IopTrackLink(), IopTranslateAndAdjustReqDesc(), IopUncacheInterfaceInformation(), IopUnloadAttachedDriver(), IopUnregisterDeviceInterface(), IopUpdateHardwareProfile(), IoQueryDeviceDescription(), IoRaiseInformationalHardError(), IoRegisterPlugPlayNotification(), IoReleaseRemoveLockAndWaitEx(), IoReleaseRemoveLockEx(), IoReportDetectedDevice(), IoReportResourceUsageInternal(), IoShutdownSystem(), IoUnregisterFsRegistrationChange(), IoUnregisterPlugPlayNotification(), IoUnregisterShutdownNotification(), IovpInternalCompleteAfterWait(), IovpInternalDeferredCompletion(), IovpProtectedIrpMakeUntouchable(), IovpSessionDataDereference(), IovpThrowChaffAtStartedPdoStack(), IovpTrackingDataFree(), IoWriteErrorLogEntry(), IsUdfsVolume(), Ke386CallBios(), KeRestoreFloatingPointState(), KeSetAutoAlignmentThread(), KeStartAllProcessors(), KeStartProfile(), KeStopProfile(), KiAddRange(), KiCompleteEffectiveRangeChange(), KiInitializeMTRR(), LfsDeallocateLbcb(), LfsDeallocateLcb(), LfsDeallocateLfcb(), LfsDeleteLogHandle(), LfsWriteLfsRestart(), LpcpDestroyPortQueue(), LpcpExtendPortZone(), LpcpInitializePortZone(), MapperAdjustResourceList(), MapperCallback(), MapperConstructRootEnumTree(), MapperFreeList(), MapperMarkKey(), MapperPeripheralCallback(), MapperPhantomizeDetectedComPorts(), MapperSeedKey(), MiAllocateContiguousMemory(), MiBuildImportsForBootDrivers(), MiCleanPhysicalProcessPages(), MiClearImports(), MiCloneProcessAddressSpace(), MiCreateDataFileMap(), MiCreateImageFileMap(), MiCreatePagingFileMap(), MiCreatePebOrTeb(), MiDecrementCloneBlockReference(), MiDereferenceImports(), MiDereferenceSegmentThread(), MiDoPoolCopy(), MiFindContiguousMemory(), MiFlushEventCounter(), MiFlushInPageSupportBlock(), MiFreeMdlTracker(), MiFreeSessionPoolBitMaps(), MiFreeSessionSpaceMap(), MiGetInPageSupportBlock(), MiGetWorkingSetInfo(), MiInitializeLoadedModuleList(), MiInsertInSystemSpace(), MiLoadSystemImage(), MiMapLockedPagesInUserSpace(), MiMapViewOfDataSection(), MiMapViewOfImageSection(), MiMapViewOfPhysicalSection(), MiPhysicalViewRemover(), MiReleaseDeadPteTrackers(), MiRemoveMappedView(), MiRemoveVad(), MiResolveImageReferences(), MiSectionInitialization(), MiSegmentDelete(), MiSessionRemoveImage(), MiSessionWideDereferenceImage(), MiSessionWideInsertImageAddress(), MiSnapThunk(), MiUnmapLockedPagesInUserSpace(), MiVerifierCheckThunks(), MiVerifyingDriverUnloading(), MmAddPhysicalMemory(), MmAddVerifierThunks(), MmAllocatePagesForMdl(), MmCallDllInitialize(), MmCleanProcessAddressSpace(), MmCreateSection(), MmDeleteTeb(), MmExtendSection(), MmFreeContiguousMemory(), MmFreeContiguousMemorySpecifyCache(), MmGetFileNameForSection(), MmInitializeProcessAddressSpace(), MmMapLockedPagesSpecifyCache(), MmMapVideoDisplay(), MmRemovePhysicalMemory(), MmSecureVirtualMemory(), MmUnloadSystemImage(), MmUnmapVideoDisplay(), MmUnmapViewOfSection(), MmUnsecureVirtualMemory(), NtAddAtom(), NtAllocateUserPhysicalPages(), NtAllocateVirtualMemory(), NtCloseObjectAuditAlarm(), NtCreatePagingFile(), NtDeleteObjectAuditAlarm(), NtFindAtom(), NtFlushBuffersFile(), NtFreeUserPhysicalPages(), NtFreeVirtualMemory(), NtfsRecFsControl(), NtLoadDriver(), NtLoadKey2(), NtMapUserPhysicalPages(), NtMapUserPhysicalPagesScatter(), NtOpenObjectAuditAlarm(), NtOpenThreadToken(), NtPrivilegedServiceAuditAlarm(), NtPrivilegeObjectAuditAlarm(), NtQueryDirectoryObject(), NtQueryEaFile(), NtQueryInformationFile(), NtQueryQuotaInformationFile(), NtQuerySystemEnvironmentValue(), NtQueryVolumeInformationFile(), NtQueueApcThread(), NtRaiseHardError(), NtReadFileScatter(), NtReplaceKey(), NtSecureConnectPort(), NtSetEaFile(), NtSetInformationFile(), NtSetInformationJobObject(), NtSetInformationProcess(), NtSetLdtEntries(), NtSetSystemEnvironmentValue(), NtSetSystemInformation(), NtSetValueKey(), NtSetVolumeInformationFile(), NtStartProfile(), NtStopProfile(), NtUnloadDriver(), NtUnlockFile(), NtWaitForMultipleObjects(), NtWriteFileGather(), ObCreateObjectType(), ObDereferenceDeviceMap(), ObGetObjectSecurity(), ObpCaptureObjectName(), ObpDeleteDirectoryEntry(), ObpDeleteNameCheck(), ObpDeleteSymbolicLink(), ObpDestroySecurityDescriptorHeader(), ObpFreeDosDevicesProtection(), ObpFreeObject(), ObpFreeObjectNameBuffer(), ObpInitSecurityDescriptorCache(), ObpInsertHandleCount(), ObpLogSecurityDescriptor(), ObpLookupObjectName(), ObpParseSymbolicLink(), ObpProcessDosDeviceSymbolicLink(), ObpRemoveObjectRoutine(), ObReleaseObjectSecurity(), ObSetSecurityDescriptorInfo(), OpenDeviceReparseIndex(), pIoQueryBusDescription(), pIoQueryDeviceDescription(), PnPBiosCopyDeviceParamKey(), PnPBiosCopyIoDecode(), PnPBiosEliminateDupes(), PnPBiosFreeDevNodeInfo(), PnPBiosGetBiosInfo(), PnPBiosMapper(), PnPBiosTranslateInfo(), PnPBiosWriteInfo(), PnPCheckFixedIoOverrideDecodes(), PsExitSpecialApc(), Psp386CreateVdmIoListHead(), Psp386InstallIoHandler(), PspApplyJobLimitsToProcessSet(), PspCaptureTokenFilter(), PspDeleteLdt(), PspDeleteThreadSecurity(), PspDeleteVdmObjects(), PspDereferenceQuota(), PspExitNormalApc(), PspExitThread(), PspJobDelete(), PspNullSpecialApc(), PspProcessDelete(), PspQueueApcSpecialApc(), PspSetLdtInformation(), PspSetLdtSize(), PspSetQuotaLimits(), PspTerminateThreadByPointer(), PspUserThreadStartup(), PsReturnSharedPoolQuota(), QueryDeviceNameForPath(), QuerySymbolicLink(), RtlpAllocDeallocQueryBuffer(), RtlpComputeMergedAcl(), RtlpConvertAclToAutoInherit(), RtlpConvertToAutoInheritSecurityObject(), RtlpFreeAtom(), RtlpInheritAcl(), RtlpNewSecurityObject(), RtlpSetSecurityObject(), RtlReleaseRemoveLock(), RtlReleaseRemoveLockAndWait(), RtlVolumeDeviceToDosName(), SeAccessCheckByType(), SeAppendPrivileges(), SeCaptureAcl(), SeCaptureLuidAndAttributesArray(), SeCaptureObjectTypeList(), SeCaptureSecurityDescriptor(), SeCaptureSecurityQos(), SeCaptureSid(), SeCaptureSidAndAttributesArray(), SeCreateObjectAuditAlarm(), SeDeassignSecurity(), SeDeleteAccessState(), SeFreeCapturedObjectTypeList(), SeFreeCapturedSecurityQos(), SeFreePrivileges(), SeMakeAnonymousLogonToken(), SeMakeSystemToken(), SeOpenObjectAuditAlarm(), SeOpenObjectForDeleteAuditAlarm(), SepAccessCheckAndAuditAlarm(), SepAdtInitializeBounds(), SepAdtLogAuditRecord(), SepAdtObjectReferenceAuditAlarm(), SepAdtOpenObjectAuditAlarm(), SepCopyProxyData(), SepCreateLogonSessionTrack(), SepDeleteLogonSessionTrack(), SepDequeueWorkItem(), SepDeReferenceLogonSession(), SepDuplicateToken(), SepFilterToken(), SepFreeCapturedString(), SepFreeProxyData(), SepInformLsaOfDeletedLogon(), SepInitializationPhase1(), SepNotifyFileSystems(), SepProbeAndCaptureQosData(), SepProbeAndCaptureString_U(), SepQueryNameString(), SepRmCallLsa(), SepTokenDeleteMethod(), SeReleaseAcl(), SeReleaseLuidAndAttributesArray(), SeReleaseSecurityDescriptor(), SeReleaseSid(), SeReleaseSidAndAttributesArray(), SeRmInitPhase1(), SeUnregisterLogonSessionTerminatedRoutine(), SmbTraceCompleteRdr(), SmbTraceCompleteSrv(), SmbTraceDeferredDereferenceHeap(), SmbTraceEmptyQueue(), SmbTraceInitialize(), SmbTraceTerminate(), SmbTraceThreadEntry(), TestCaptureSecurityDescriptor(), TestDefaultObjectMethod(), TestMakeSystemToken(), TestTokenCopy(), TestTokenSize(), UdfDeallocateTable(), UdfDeletePcb(), UdfFreePool(), UdfNormalizeFileNames(), UdfRemovePrefix(), UdfUpdateVcbPhase0(), VdmpDelayInterrupt(), VdmpInitialize(), VdmQueryDirectoryFile(), VerifierFreePool(), ViReservePoolAllocation(), Win32KDriverUnload(), Win32kNtUserCleanup(), xHalExamineMBR(), xHalGetPartialGeometry(), xHalIoAssignDriveLetters(), xHalIoClearPartitionTable(), xHalIoReadPartitionTable(), xHalIoSetPartitionInformation(), and xHalIoWritePartitionTable().
00976 :
00977
00978 This function deallocates a block of pool. This function is used to
00979 deallocate to both the page aligned pools, and the binary buddy
00980 (less than a page) pools.
00981
00982 If the address of the block being deallocated is page-aligned, then
00983 the page-aliged pool deallocator is used.
00984
00985 Otherwise, the binary buddy pool deallocator is used. Deallocation
00986 looks at the allocated block's pool header to determine the pool
00987 type and block size being deallocated. If the pool was allocated
00988 using ExAllocatePoolWithQuota, then after the deallocation is
00989 complete, the appropriate process's pool quota is adjusted to reflect
00990 the deallocation, and the process object is dereferenced.
00991
00992 Arguments:
00993
00994 P - Supplies the address of the block of pool being deallocated.
00995
00996 Return Value:
00997
00998 None.
00999
01000 --*/
01001
01002 {
01003 PPOOL_HEADER Entry;
01004 POOL_TYPE PoolType;
01005 KIRQL LockHandle;
01006 PVOID Lock;
01007 PPOOL_DESCRIPTOR PoolDesc;
01008
01009 KIRQL OldIrql;
01010 BOOLEAN ReleaseSpinLock = TRUE;
01011 PMMPTE PointerPte;
01012 PMMPFN Pfn1;
01013
01014 #ifdef TRACE_ALLOC
01015
01016 PULONG xFp, xPrevFp, xR1, xPrevR1;
01017
01018 xFp = RtlpGetFramePointer();
01019 xR1 = (PULONG)*(xFp+1);
01020 xPrevFp = (PULONG)*xFp;
01021 xPrevR1 = (PULONG)*(xPrevFp+1);
01022
01023 #endif // TRACE_ALLOC
01024
01025
01026
01027
01028
01029 if ( PAGE_ALIGNED(P) ) {
01030
01031 PoolType = MmDeterminePoolType(P);
01032
01033 Lock = PoolVector[PoolType]-> LockAddress;
01034
01035 LOCK_POOL(Lock,PoolType,LockHandle);
01036 MiFreePoolPages (P);
01037 UNLOCK_POOL(Lock,PoolType,LockHandle,FALSE);
01038 return;
01039 }
01040
01041 PointerPte = MiGetPteAddress (P);
01042
01043 if (PointerPte-> u.Hard.Valid == 0) {
01044 DbgPrint( "bad pool deallocation\n");
01045 KeBugCheck (12345);
01046 }
01047
01048 if (KeGetCurrentIrql() >= 2) {
01049 DbgPrint( "deallocating pool at irql >= 2\n");
01050 ReleaseSpinLock = FALSE;
01051 } else {
01052 KeAcquireSpinLock ( &MmPfnLock, &OldIrql);
01053 }
01054
01055 KeSweepDcache(TRUE);
01056
01057 Pfn1 = MI_PFN_ELEMENT (PointerPte-> u.Hard.PageFrameNumber);
01058 Pfn1-> PteAddress = ( PMMPTE) MM_EMPTY_LIST;
01059 MiDecrementShareCountOnly (PointerPte-> u.Hard.PageFrameNumber);
01060 *PointerPte = ZeroPte;
01061 MiReleaseSystemPtes (PointerPte, 2, SystemPteSpace);
01062
01063
01064
01065 KiFlushSingleTb (P,TRUE);
01066 if (ReleaseSpinLock) {
01067 KeReleaseSpinLock ( &MmPfnLock, OldIrql );
01068 }
01069 return;
01070
01071 Entry = ( PPOOL_HEADER)((PCH)P - POOL_OVERHEAD);
01072
01073 PoolType = Entry-> PoolType;
01074
01075 PoolDesc = PoolVector[PoolType];
01076 Lock = PoolDesc-> LockAddress;
01077
01078
01079
01080
01081
01082 if ( (Entry-> LogAllocationSize == 0) || (Entry-> PoolType >= MaxPoolType) ) {
01083 DbgPrint( "Invalid pool header 0x%lx 0x%lx\n",P,*(PULONG)P);
01084 KeBugCheck(BAD_POOL_HEADER);
01085 return;
01086 }
01087
01088 if ( (ULONG)P & 0x0000000f != 8 ) {
01089 DbgPrint( "Misaligned Deallocation 0x%lx\n",P);
01090 KeBugCheck(BAD_POOL_HEADER);
01091 return;
01092 }
01093
01094 #ifdef TRACE_ALLOC
01095 {
01096 KIRQL xIrql;
01097 PLIST_ENTRY Next, Target;
01098 BOOLEAN Found;
01099
01100 KeRaiseIrql(APC_LEVEL, &xIrql);
01101
01102 KeWaitForSingleObject(
01103 &TracePoolLock,
01104 PoolAllocation,
01105 KernelMode,
01106 FALSE,
01107 NULL
01108 );
01109
01110 Found = FALSE;
01111 Target = &Entry->TraceLinks;
01112 Next = TracePoolListHead[PoolType].Flink;
01113 while( Next != &TracePoolListHead[PoolType] ){
01114 if ( Next == Target ) {
01115
01116 RemoveEntryList(&Entry->TraceLinks);
01117 Found = TRUE;
01118 break;
01119 }
01120 Next = Next->Flink;
01121 }
01122
01123 if ( !Found ) {
01124 DbgPrint( "Block Not in Allocated Pool List 0x%lx\n",P);
01125 KeBugCheck(BAD_POOL_HEADER);
01126 return;
01127 }
01128
01129 DeallocTrace[NextDeallocTrace].BufferAddress = P;
01130 DeallocTrace[NextDeallocTrace].Thread = PsGetCurrentThread();
01131 DeallocTrace[NextDeallocTrace].xR1 = xR1;
01132 DeallocTrace[NextDeallocTrace++].xPrevR1 = xPrevR1;
01133 if ( NextDeallocTrace >= MAXTRACE ) {
01134 NextDeallocTrace = 0;
01135 }
01136
01137 ( VOID) KeReleaseSemaphore(
01138 &TracePoolLock,
01139 0L,
01140 1L,
01141 FALSE
01142 );
01143 KeLowerIrql(xIrql);
01144
01145 }
01146 #endif // TRACE_ALLOC
01147
01148 #ifndef TRACE_ALLOC
01149
01150
01151
01152
01153
01154
01155 if ( Entry-> ProcessBilled ) {
01156
01157 PsReturnPoolQuota(
01158 Entry-> ProcessBilled,
01159 BasePoolTypeTable[PoolType],
01160 (1 << Entry-> LogAllocationSize)
01161 );
01162
01163 ObDereferenceObject(Entry-> ProcessBilled);
01164
01165 }
01166 #endif // TRACE_ALLOC
01167
01168 LOCK_POOL(Lock,PoolType,LockHandle);
01169
01170 DeallocatePoolInternal(PoolDesc,Entry);
01171
01172 UNLOCK_POOL(Lock,PoolType,LockHandle,FALSE);
01173
01174 }
|