extern ULONG MiNonPagedPoolLength;
extern ULONG MmTotalPagedPoolQuota;
extern ULONG MmTotalNonPagedPoolQuota;
-extern MM_STATS MmStats;
/* FUNCTIONS ***************************************************************/
return(Block);
}
-
-/*
- * @implemented
- */
-#undef ExAllocatePoolWithQuota
-#undef ExAllocatePoolWithQuotaTag
-PVOID NTAPI
-ExAllocatePoolWithQuota (POOL_TYPE PoolType, SIZE_T NumberOfBytes)
-{
- return(ExAllocatePoolWithQuotaTag(PoolType, NumberOfBytes, TAG_NONE));
-}
-
-/*
- * @implemented
- */
-PVOID
-NTAPI
-ExAllocatePoolWithTagPriority(
- IN POOL_TYPE PoolType,
- IN SIZE_T NumberOfBytes,
- IN ULONG Tag,
- IN EX_POOL_PRIORITY Priority
- )
-{
- /* Do the allocation */
- UNIMPLEMENTED;
- return ExAllocatePoolWithTag(PoolType, NumberOfBytes, Tag);
-}
-
-/*
- * @implemented
- */
-PVOID
-NTAPI
-ExAllocatePoolWithQuotaTag (IN POOL_TYPE PoolType,
- IN SIZE_T NumberOfBytes,
- IN ULONG Tag)
-{
- PEPROCESS Process;
- PVOID Block;
-
- /* Allocate the Pool First */
- Block = EiAllocatePool(PoolType,
- NumberOfBytes,
- Tag,
- &ExAllocatePoolWithQuotaTag);
-
- /* "Quota is not charged to the thread for allocations >= PAGE_SIZE" - OSR Docs */
- if (!(NumberOfBytes >= PAGE_SIZE))
- {
- /* Get the Current Process */
- Process = PsGetCurrentProcess();
-
- /* PsChargePoolQuota returns an exception, so this needs SEH */
- _SEH2_TRY
- {
- /* FIXME: Is there a way to get the actual Pool size allocated from the pool header? */
- PsChargePoolQuota(Process,
- PoolType & PAGED_POOL_MASK,
- NumberOfBytes);
- }
- _SEH2_EXCEPT((ExFreePool(Block), EXCEPTION_CONTINUE_SEARCH))
- {
- /* Quota Exceeded and the caller had no SEH! */
- KeBugCheck(STATUS_QUOTA_EXCEEDED);
- }
- _SEH2_END;
- }
-
- /* Return the allocated block */
- return Block;
-}
-
/*
* @implemented
*/
}
}
-/*
- * @unimplemented
- */
-SIZE_T
-NTAPI
-ExQueryPoolBlockSize (
- IN PVOID PoolBlock,
- OUT PBOOLEAN QuotaCharged
- )
-{
- UNIMPLEMENTED;
- return FALSE;
-}
-
-/*
- * @unimplemented
- */
-PVOID
-NTAPI
-MmAllocateMappingAddress (
- IN SIZE_T NumberOfBytes,
- IN ULONG PoolTag
- )
-{
- UNIMPLEMENTED;
- return 0;
-}
-
-
-/*
- * @unimplemented
- */
-VOID
-NTAPI
-MmFreeMappingAddress (
- IN PVOID BaseAddress,
- IN ULONG PoolTag
- )
-{
- UNIMPLEMENTED;
-}
-
-BOOLEAN
-NTAPI
-MiRaisePoolQuota(
- IN POOL_TYPE PoolType,
- IN ULONG CurrentMaxQuota,
- OUT PULONG NewMaxQuota
- )
-{
- /* Different quota raises depending on the type (64K vs 512K) */
- if (PoolType == PagedPool) {
-
- /* Make sure that 4MB is still left */
- if ((MM_PAGED_POOL_SIZE >> 12) < ((MmPagedPoolSize + 4194304) >> 12)) {
- return FALSE;
- }
-
- /* Increase Paged Pool Quota by 512K */
- MmTotalPagedPoolQuota += 524288;
- *NewMaxQuota = CurrentMaxQuota + 524288;
- return TRUE;
-
- } else { /* Nonpaged Pool */
-
- /* Check if we still have 200 pages free*/
- if (MmStats.NrFreePages < 200) return FALSE;
-
- *NewMaxQuota = CurrentMaxQuota + 65536;
- return TRUE;
- }
-}
-
/* EOF */