Example #1
0
void
XixFsdFreeCCB(
	PXIFS_CCB pCCB
)
{	

	PAGED_CODE();
	DebugTrace((DEBUG_LEVEL_TRACE|DEBUG_LEVEL_INFO), (DEBUG_TARGET_CREATE|DEBUG_TARGET_CCB), 
		("Enter XixFsdFreeCCB (%p)\n",pCCB));

	ASSERT(pCCB);
	
	if(pCCB->SearchExpression.Buffer != NULL){
		ExFreePool(pCCB->SearchExpression.Buffer);
	}

	/*
	if(pCCB->FullPath.Buffer != NULL){
		ExFreePool(pCCB->FullPath.Buffer);
	}
	*/
		
	// give back memory either to the zone or to the VMM
	if (!(pCCB->CCBFlags& XIFSD_CCB_NOT_FROM_POOL)) {
		ExFreeToNPagedLookasideList(&(XifsCcbLookasideList),pCCB);
	} else {
		ExFreePool(pCCB);
	}

	DebugTrace((DEBUG_LEVEL_TRACE|DEBUG_LEVEL_INFO), (DEBUG_TARGET_CREATE|DEBUG_TARGET_CCB), 
		("Exit XixFsdFreeCCB \n"));
	return;
}
Example #2
0
NTSTATUS Notification_Recieve(NOTIFICATION_QUEUE *queue, PIRP irp) {
	PIO_STACK_LOCATION irpstack = IoGetCurrentIrpStackLocation(irp);
	KIRQL irq;

	if(irpstack->Parameters.DeviceIoControl.OutputBufferLength != sizeof(PGNOTIFICATION)) {
		irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL;
		irp->IoStatus.Information = 0;
		IoCompleteRequest(irp, IO_NO_INCREMENT);

		return STATUS_BUFFER_TOO_SMALL;
	}
	
	KeAcquireSpinLock(&queue->lock, &irq);

	if(IsListEmpty(&queue->notification_list)) {
		PGIRPNODE *irpnode;
		KIRQL crirq;

		irpnode = ExAllocateFromNPagedLookasideList(&queue->lookaside);

		InitializeListHead(&irpnode->entry);

		irpnode->irp = irp;
		//irp->Tail.Overlay.DriverContext[0] = irpnode;

		InsertTailList(&queue->irp_list, &irpnode->entry);

		IoMarkIrpPending(irp);

		IoAcquireCancelSpinLock(&crirq);

#pragma warning(push)
#pragma warning(disable:4311 4312)
		//IoSetCancelRoutine generates warnings in 32-bit due to silly macroisms.
		IoSetCancelRoutine(irp, Notification_OnCancel);
#pragma warning(pop)

		IoReleaseCancelSpinLock(crirq);
		
		KeReleaseSpinLock(&queue->lock, irq);

		return STATUS_PENDING;
	}
	else {
		PGNOTIFYNODE *notifynode = (PGNOTIFYNODE*)RemoveHeadList(&queue->notification_list);
		PGNOTIFICATION *notification = irp->AssociatedIrp.SystemBuffer;

		RtlCopyMemory(notification, &notifynode->notification, sizeof(PGNOTIFICATION));
		ExFreeToNPagedLookasideList(&queue->lookaside, notifynode);
		--queue->queued;
		
		KeReleaseSpinLock(&queue->lock, irq);

		irp->IoStatus.Status = STATUS_SUCCESS;
		irp->IoStatus.Information = sizeof(PGNOTIFICATION);
		IoCompleteRequest(irp, IO_NO_INCREMENT);

		return STATUS_SUCCESS;
	}
}
Example #3
0
VOID
SpyFreeBuffer (
    _In_ PVOID Buffer
    )
/*++

Routine Description:

    Free an allocate buffer.

    NOTE:  This code must be NON-PAGED because it can be called on the
           paging path or at DPC level.

Arguments:

    Buffer - The buffer to free.

Return Value:

    None.

--*/
{
    //
    //  Free the memory, update the counter
    //

    InterlockedDecrement( &MiniSpyData.RecordsAllocated );
    ExFreeToNPagedLookasideList( &MiniSpyData.FreeBufferList, Buffer );
}
Example #4
0
static void Notification_OnCancel(PDEVICE_OBJECT device, PIRP irp) 
{
	KIRQL irq;
	NOTIFICATION_QUEUE *queue = &((PGINTERNAL*)device->DeviceExtension)->queue;
	LIST_ENTRY *iter;
	int found = 0;

	DbgPrint("Canceling IRP...\n");

	KeAcquireSpinLock(&queue->lock, &irq);
	for(iter = queue->irp_list.Flink; iter != &queue->irp_list; iter = iter->Flink) {
		PGIRPNODE *irpnode = (PGIRPNODE*)iter;
		if(irpnode->irp == irp) {
			RemoveEntryList(iter);
			ExFreeToNPagedLookasideList(&queue->lookaside, irpnode);
			found = 1;
			break;
		}
	}
	KeReleaseSpinLock(&queue->lock, irq);

	// if it wasn't found, it has already been dequeued and handled.
	if(found) {
		DbgPrint("IRP found, completing.\n");

		irp->IoStatus.Status = STATUS_CANCELLED;
		irp->IoStatus.Information = 0;
		IoCompleteRequest(irp, IO_NO_INCREMENT);
	}
	
	IoReleaseCancelSpinLock(irp->CancelIrql);
}
BOOLEAN SymRemoveSymbol(IN PCHAR pszSymbolName)
{
	ASSERTMSG("Passed symbol name is NULL", pszSymbolName != NULL);
	ASSERTMSG("SymbolEngine must be initialized prior to this call", bIsSymEngineInitialized == TRUE);

	// try to find the symbol to remove
	PSYMBOL_ENTRY pSymbolEntry = SympFindSymbol(pszSymbolName);
	// if symbol not found, return NULL
	if(pSymbolEntry == NULL)
	{
		return FALSE;
	}

	// symbol found, so we remove it from the list...
	ASSERTMSG("Fast mutex acquire must occur at or below APC_LEVEL", KeGetCurrentIrql() <= APC_LEVEL);
	ExAcquireFastMutex(&SymbolsListMutex);
	RemoveEntryList(&pSymbolEntry->ListEntry);

	// decrease symbol count (do it inside guarded block!)
	--uSymbolCount;

	// and free allocated memory
	ExFreeToNPagedLookasideList(&SymbolsLookasideList, pSymbolEntry);
	ASSERTMSG("Fast mutex release must occur at APC_LEVEL", KeGetCurrentIrql() == APC_LEVEL);
	ExReleaseFastMutex(&SymbolsListMutex);

	return TRUE;
}
Example #6
0
__drv_mustHoldCriticalRegion
VOID
FFSFreeCcb(
	IN PFFS_CCB Ccb)
{
    PAGED_CODE();

	ASSERT(Ccb != NULL);

	ASSERT((Ccb->Identifier.Type == FFSCCB) &&
			(Ccb->Identifier.Size == sizeof(FFS_CCB)));

	if (Ccb->DirectorySearchPattern.Buffer != NULL)
	{
		ExFreePool(Ccb->DirectorySearchPattern.Buffer);
	}

	if (FlagOn(Ccb->Flags, CCB_FROM_POOL))
	{
		ExFreePool(Ccb);
	}
	else
	{
		ExAcquireResourceExclusiveLite(
				&FFSGlobal->LAResource,
				TRUE);

		ExFreeToNPagedLookasideList(&(FFSGlobal->FFSCcbLookasideList), Ccb);

		ExReleaseResourceForThreadLite(
				&FFSGlobal->LAResource,
				ExGetCurrentResourceThread());
	}
}
Example #7
0
char 
SORAAPI 
remove_thread_safe_enlist_head(struct thread_safe_enlist* tslist, 
	void** data,
	char lock) {

	KIRQL irql;
	acquire_spinlock(lock, 
		tslist->m_sync,
		irql);	
	if (IsListEmpty(&tslist->m_head.m_entry)) {
		release_spinlock(lock, 
			tslist->m_sync,
			irql);
		return false;
	}
	struct LIST_ENTRY_EX* entry;
	entry = (LIST_ENTRY_EX*)RemoveHeadList(&tslist->m_head.m_entry);
	*data = entry->m_value;
	ExFreeToNPagedLookasideList(&tslist->m_lookaside,
		entry);
	InterlockedDecrement(&tslist->m_count);
	release_spinlock(lock, 
		tslist->m_sync,
		irql);
	return true;
}
Example #8
0
void DestroyNotificationQueue(NOTIFICATION_QUEUE *queue) {
	while(!IsListEmpty(&queue->notification_list)) {
		PGNOTIFYNODE *notifynode = (PGNOTIFYNODE*)RemoveHeadList(&queue->notification_list);
		ExFreeToNPagedLookasideList(&queue->lookaside, notifynode);
	}

	while(!IsListEmpty(&queue->irp_list)) {
		PGIRPNODE *irpnode = (PGIRPNODE*)RemoveHeadList(&queue->irp_list);
		
		irpnode->irp->IoStatus.Status = STATUS_CANCELLED;
		irpnode->irp->IoStatus.Information = 0;

		IoCompleteRequest(irpnode->irp, IO_NO_INCREMENT);

		ExFreeToNPagedLookasideList(&queue->lookaside, irpnode);
	}

	ExDeleteNPagedLookasideList(&queue->lookaside);
}
Example #9
0
File: fcb.c Project: GYGit/reactos
VOID
NtfsDestroyFCB(PNTFS_FCB Fcb)
{
    ASSERT(Fcb);
    ASSERT(Fcb->Identifier.Type == NTFS_TYPE_FCB);

    ExDeleteResourceLite(&Fcb->MainResource);

    ExFreeToNPagedLookasideList(&NtfsGlobalData->FcbLookasideList, Fcb);
}
Example #10
0
/*
 * @implemented
 */
VOID
NTAPI
FsRtlUninitializeLargeMcb(IN PLARGE_MCB Mcb)
{
    if (Mcb->GuardedMutex)
    {
        ExFreeToNPagedLookasideList(&FsRtlFastMutexLookasideList,
                                    Mcb->GuardedMutex);
        FsRtlUninitializeBaseMcb(&(Mcb->BaseMcb));
    }
}
Example #11
0
INLINE
VOID
LfsFreeNonPagedFcb (
    PNON_PAGED_FCB NonPagedFcb
    )
{
#if FAT_FILL_FREE
    RtlFillMemoryUlong(NonPagedFcb, sizeof(NON_PAGED_FCB), FAT_FILL_FREE);
#endif

    ExFreeToNPagedLookasideList( &GlobalLfs.NonPagedFcbLookasideList, (PVOID) NonPagedFcb );
}
Example #12
0
INLINE
VOID
LfsFreeResource (
    IN PERESOURCE Resource
    )
{
    ExDeleteResourceLite( Resource );

#if FAT_FILL_FREE
    RtlFillMemoryUlong(Resource, sizeof(ERESOURCE), FAT_FILL_FREE);
#endif

    ExFreeToNPagedLookasideList( &GlobalLfs.EResourceLookasideList, (PVOID) Resource );
}
Example #13
0
void mm_free(void *mem)
{
	alloc_block *block = CONTAINING_RECORD(mem, alloc_block, data);               /* get the alloc_block struct */
	char        *p_mem = (block->flags & MEM_PADDED) ? p8(block) - 8 : p8(block); /* get the original memory pointer */

	/* zero block to prevent leaks if needed */
	if (block->flags & MEM_SECURE) burn(block->data, block->size);
	/* free memory */
	if (block->flags & MEM_FAST) {
		ExFreeToNPagedLookasideList(&mem_lists[block->index], p_mem);
	} else {
		ExFreePoolWithTag(p_mem, '1_cd');
	}
}
Example #14
0
void kmem_cache_free (kmem_cache_t *cachep, void *objp)
{
	if (cachep->dtor != NULL) cachep->dtor(objp, cachep, 0); // 0 might be wrong --sadyc

#ifdef USE_NONPAGED_MEMORY
	ExFreeToNPagedLookasideList(&cachep->lookaside, objp);
#else
	ExFreeToPagedLookasideList(&cachep->lookaside, objp);
#endif
#if DBG
	cachep->objects_allocated--;
	printk("kmem_cache: %s: objects: %d [-]\n", cachep->name, cachep->objects_allocated);
#endif
}
Example #15
0
void DestroyTable(PHASHTABLE pHashTable)
{
	PTWOWAY pNode = NULL; 
	PTWOWAY pTmpNode = NULL;
	PLIST_ENTRY pListHead = NULL;
	PLIST_ENTRY pListLink = NULL;
    unsigned int i;

	for (i = 0; i < pHashTable->tableSize; i++)
	{
		pListHead = pListLink = pHashTable->pListHeads[i];
		if (pListHead == NULL)
		{
			DbgPrint("pListHead is NULL!\n");
			continue;
		}
		if (!IsListEmpty(pListHead))
		{
			do
			{
				pNode = CONTAINING_RECORD(pListLink, TWOWAY, linkfield);
				pListLink = pListLink->Flink;
				ExFreeToNPagedLookasideList(pLookasideList_TWOWAY, pNode);
			} while (pListLink != pListHead);
		}
		else
		{
			pNode = CONTAINING_RECORD(pListHead, TWOWAY, linkfield);
			ExFreeToNPagedLookasideList(pLookasideList_TWOWAY, pNode);
		}
	}

	ExDeleteNPagedLookasideList(pLookasideList_TWOWAY);
	ExFreePoolWithTag(pLookasideList_TWOWAY, DRIVERTAG1);
	ExFreePoolWithTag(pHashTable->pListHeads, DRIVERTAG1);
	ExFreePoolWithTag(pHashTable, DRIVERTAG1);
}
Example #16
0
void Remove(DWORD key, PHASHTABLE pHashTable)
{
	PTWOWAY pNode = NULL; 
	PLIST_ENTRY pListHead = NULL;

	pNode = Find(key, pHashTable);

	// The node with the given key was found.
	if (pNode != NULL)
	{
#ifdef MY_DEBUG
		DbgPrint("REMOVE: thread ID = 0x%x process ID = 0x%x image = %s\n", pNode->data.threadID, pNode->data.processID, pNode->data.imageName);
#endif
		RemoveEntryList(&pNode->linkfield);
		ExFreeToNPagedLookasideList(pLookasideList_TWOWAY, pNode);
	}
}
Example #17
0
NTSTATUS
MyCompletionRoutine(
	PDEVICE_OBJECT	DeviceObject,
	PIRP			Irp,
	PVOID			Context
	)
{
	NTSTATUS				status;
	UCHAR					Control;
	PMYCONTEXT				MyContext;
	PIO_COMPLETION_ROUTINE	CompletionRoutine;

	MyContext = (PMYCONTEXT)Context;

	Control = MyContext->Control;
	Context = MyContext->Context;
	CompletionRoutine = MyContext->CompletionRoutine;

	ExFreeToNPagedLookasideList(&ContextLookaside, MyContext);

	status = Irp->IoStatus.Status;
	if( NT_SUCCESS(status) )
	{
		if(Control & SL_INVOKE_ON_SUCCESS)
		{
			return CompletionRoutine(DeviceObject, Irp, Context);
		}
	}
	else if(status == STATUS_CANCELLED)
	{
		if(Control & SL_INVOKE_ON_CANCEL)
		{
			return CompletionRoutine(DeviceObject, Irp, Context);
		}
	}
	else
	{
		if(Control & SL_INVOKE_ON_ERROR)
		{
			return CompletionRoutine(DeviceObject, Irp, Context);
		}
	}
	return status;
}
Example #18
0
/* KphpProtectRemoveEntry
 * 
 * Removes and frees process protection data.
 * 
 * Thread safety: Full
 * IRQL: <= DISPATCH_LEVEL
 */
VOID KphpProtectRemoveEntry(
    __in PKPH_PROCESS_ENTRY Entry
    )
{
    KIRQL oldIrql;
    
    KeAcquireSpinLock(&ProtectedProcessListLock, &oldIrql);
    RemoveEntryList(&Entry->ListEntry);
    
    /* Prevent the lookaside list from being destroyed. */
    ExAcquireRundownProtection(&ProtectedProcessRundownProtect);
    ExFreeToNPagedLookasideList(
        &ProtectedProcessLookasideList,
        Entry
        );
    ExReleaseRundownProtection(&ProtectedProcessRundownProtect);
    
    KeReleaseSpinLock(&ProtectedProcessListLock, oldIrql);
}
Example #19
0
void complete_pending_irp(PPDO_DEVICE_DATA pdodata)
{
    PIRP irp;
    struct urb_req * urb_r;
    PLIST_ENTRY le;
    KIRQL oldirql;
    int count=0;
	LARGE_INTEGER interval;

    //FIXME
    KdPrint(("finish pending irp\n"));
    KeRaiseIrql(DISPATCH_LEVEL, &oldirql);
    do {
	irp=NULL;
	le=NULL;
	KeAcquireSpinLockAtDpcLevel(&pdodata->q_lock);
	if (!IsListEmpty(&pdodata->ioctl_q))
		le = RemoveHeadList(&pdodata->ioctl_q);
	if(le){
		urb_r = CONTAINING_RECORD(le, struct urb_req, list);
		/* FIMXE event */
		irp = urb_r->irp;
	}
	if(irp==NULL){
		KeReleaseSpinLock(&pdodata->q_lock, oldirql);
		break;
	}
	if(count>2){
		KeReleaseSpinLock(&pdodata->q_lock, oldirql);
		KdPrint(("sleep 50ms, let pnp manager send irp"));
		interval.QuadPart=-500000;
		KeDelayExecutionThread(KernelMode, FALSE, &interval);
		KeRaiseIrql(DISPATCH_LEVEL, &oldirql);
	} else {
		KeReleaseSpinLock(&pdodata->q_lock, DISPATCH_LEVEL);
	}
	ExFreeToNPagedLookasideList(&g_lookaside, urb_r);
	irp->IoStatus.Status = STATUS_DEVICE_NOT_CONNECTED;
	IoSetCancelRoutine(irp, NULL);
	IoCompleteRequest (irp, IO_NO_INCREMENT);
	count++;
    }while(1);
}
Example #20
0
void Notification_Send(NOTIFICATION_QUEUE *queue, const PBNOTIFICATION *notification)
{
	KIRQL irq;

	KeAcquireSpinLock(&queue->lock, &irq);

	if(IsListEmpty(&queue->irp_list))
	{
		if(queue->queued < 64)
		{
			PBNOTIFYNODE *notifynode;

			notifynode = ExAllocateFromNPagedLookasideList(&queue->lookaside);

			InitializeListHead(&notifynode->entry);
			RtlCopyMemory(&notifynode->notification, notification, sizeof(PBNOTIFICATION));

			InsertTailList(&queue->notification_list, &notifynode->entry);
			++queue->queued;
		}

		KeReleaseSpinLock(&queue->lock, irq);
	}
	else
	{
		PBIRPNODE *irpnode = (PBIRPNODE*)RemoveHeadList(&queue->irp_list);
		PBNOTIFICATION *irpnotification = irpnode->irp->AssociatedIrp.SystemBuffer;
		PIRP irp;

		RtlCopyMemory(irpnotification, notification, sizeof(PBNOTIFICATION));

		irp = irpnode->irp;
		ExFreeToNPagedLookasideList(&queue->lookaside, irpnode);

		KeReleaseSpinLock(&queue->lock, irq);

		irp->IoStatus.Status = STATUS_SUCCESS;
		irp->IoStatus.Information = sizeof(PBNOTIFICATION);

		IoCompleteRequest(irp, IO_NO_INCREMENT);
	}
}
//
//  Complete the history list.
//
NTSTATUS
CImageHardwareSimulation::
CompleteCloneList()
{
    PAGED_CODE();

    int i = 0;
    while(!IsListEmpty(&m_BurstList))
    {
        LIST_ENTRY *listEntry = RemoveHeadList(&m_BurstList);

        PSCATTER_GATHER_ENTRY SGEntry =
            reinterpret_cast <PSCATTER_GATHER_ENTRY> (
                CONTAINING_RECORD (
                    listEntry,
                    SCATTER_GATHER_ENTRY,
                    ListEntry
                )
            );

        m_pClone = SGEntry->CloneEntry;
        m_PhotoConfirmationInfo = SGEntry->PhotoConfirmationInfo;

        m_NumMappingsCompleted++;
        m_ScatterGatherBytesQueued -= SGEntry -> ByteCount;

        DBG_TRACE( "m_NumMappingsCompleted=%d, m_PhotoConfirmationInfo.isRequired()=%s", m_NumMappingsCompleted, m_PhotoConfirmationInfo.isRequired( )?"TRUE":"FALSE" );
        DBG_TRACE( "Frame %p, PresentationTime=0x%016llX",
                   SGEntry->CloneEntry->StreamHeader,
                   SGEntry->CloneEntry->StreamHeader->PresentationTime.Time );

        m_Sensor -> Interrupt (m_PinID);

        ExFreeToNPagedLookasideList (
            &m_ScatterGatherLookaside,
            reinterpret_cast <PVOID> (SGEntry)
        );
        i++;
    }

    return STATUS_SUCCESS;
}
Example #22
0
__drv_mustHoldCriticalRegion
VOID
FFSFreeIrpContext(
	IN PFFS_IRP_CONTEXT IrpContext)
{
    PAGED_CODE();

	ASSERT(IrpContext != NULL);

	ASSERT((IrpContext->Identifier.Type == FFSICX) &&
			(IrpContext->Identifier.Size == sizeof(FFS_IRP_CONTEXT)));

	FFSUnpinRepinnedBcbs(IrpContext);

	//  Return the Irp context record to the region or to pool depending on
	//  its flag

	if (FlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_FROM_POOL))
	{
		IrpContext->Identifier.Type = 0;
		IrpContext->Identifier.Size = 0;

		ExFreePool(IrpContext);
	}
	else
	{
		IrpContext->Identifier.Type = 0;
		IrpContext->Identifier.Size = 0;

		ExAcquireResourceExclusiveLite(
				&FFSGlobal->LAResource,
				TRUE);

		ExFreeToNPagedLookasideList(&(FFSGlobal->FFSIrpContextLookasideList), IrpContext);

		ExReleaseResourceForThreadLite(
				&FFSGlobal->LAResource,
				ExGetCurrentResourceThread());

	}
}
Example #23
0
void 
XixFsdReleaseIrpContext(
	PXIFS_IRPCONTEXT					PtrIrpContext)
{
	PAGED_CODE();
	DebugTrace((DEBUG_LEVEL_TRACE|DEBUG_LEVEL_INFO), (DEBUG_TARGET_CREATE|DEBUG_TARGET_IRPCONTEXT), 
		("Enter XixFsdReleaseIrpContext(%p)\n", PtrIrpContext));

	ASSERT(PtrIrpContext);

	// give back memory either to the zone or to the VMM
	if (!(PtrIrpContext->IrpContextFlags & XIFSD_IRP_CONTEXT_NOT_FROM_POOL)) {
		ExFreeToNPagedLookasideList(&(XifsIrpContextLookasideList),PtrIrpContext);
	} else {
		ExFreePool(PtrIrpContext);
	}

	DebugTrace((DEBUG_LEVEL_TRACE|DEBUG_LEVEL_INFO), (DEBUG_TARGET_CREATE|DEBUG_TARGET_IRPCONTEXT), 
		("Exit XixFsdReleaseIrpContext\n"));
	return;
}
Example #24
0
/*
 * @implemented
 */
VOID
NTAPI
FsRtlInitializeLargeMcb(IN PLARGE_MCB Mcb,
                        IN POOL_TYPE PoolType)
{
    Mcb->GuardedMutex = ExAllocateFromNPagedLookasideList(&FsRtlFastMutexLookasideList);

    KeInitializeGuardedMutex(Mcb->GuardedMutex);

    _SEH2_TRY
    {
        FsRtlInitializeBaseMcb(&(Mcb->BaseMcb), PoolType);
    }
    _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
    {
        ExFreeToNPagedLookasideList(&FsRtlFastMutexLookasideList,
                                    Mcb->GuardedMutex);
        Mcb->GuardedMutex = NULL;
    }
    _SEH2_END;
}
Example #25
0
/*
 * For packets coming from the generic adapter, netmap expects
 * an mbuf with a persistent copy of the data.
 * For the time being we construct a brand new mbuf and
 * pass it to the handler.
 * We use this routine also in a way similar to m_getcl(),
 * passing a NULL pointer does not initialize the buffer (we need the length).
 * We have two pools, one for the mbuf and one for the cluster.
 * XXX we could do with a single allocation.
 */
struct mbuf *
win_make_mbuf(struct net_device *ifp, uint32_t length, const char *data)
{
	struct mbuf *m = ExAllocateFromNPagedLookasideList(&ifp->mbuf_pool);
	//DbgPrint("win_make_mbuf - Data: %p - length: %i", data, length);
	if (m == NULL) {
		DbgPrint("Netmap.sys: Failed to allocate memory from the mbuf!!!");
		return NULL;
	}
	m->m_len = length;
	m->pkt = ExAllocateFromNPagedLookasideList(&ifp->mbuf_packets_pool);
	if (m->pkt == NULL) {
		DbgPrint("Netmap.sys: Failed to allocate memory from the mbuf packet!!!");
		ExFreeToNPagedLookasideList(&ifp->mbuf_pool, m);
		return NULL;
	}
	m->dev = ifp;
	if (data) // XXX otherwise zero memory ?
		RtlCopyMemory(m->pkt, data, length);
	return m;
}
Example #26
0
static void dc_worker_thread(void *param)
{
	SLIST_ENTRY *entry;
	req_part    *part;
	req_item    *item;
	const char  *in;
	char        *out;
	u64          offset;
	u32          length;

	do
	{
		KeWaitForSingleObject(&pool_signal_event, Executive, KernelMode, FALSE, NULL);
		KeClearEvent(&pool_signal_event);
		
		while (entry = ExInterlockedPopEntrySList(&pool_head, &pool_lock))
		{
			part = CONTAINING_RECORD(entry, req_part, entry);
			item = part->item;

			in     = item->in + part->offset;
			out    = item->out + part->offset;
			offset = item->offset + part->offset;
			length = part->length;

			if (item->is_encrypt != 0) {
				xts_encrypt(in, out, length, offset, item->key);
			} else {
				xts_decrypt(in, out, length, offset, item->key);
			}
			if (lock_xchg_add(&item->length, 0-length) == length)			
			{
				item->on_complete(item->param1, item->param2);
				ExFreeToNPagedLookasideList(&pool_req_mem, item);
			}
		}	
	} while (pool_enabled != 0);

	PsTerminateSystemThread(STATUS_SUCCESS);
}
Example #27
0
void
XixFsdFreeLCB(
	PXIFS_LCB pLCB
)
{	
	PAGED_CODE();
	DebugTrace((DEBUG_LEVEL_TRACE|DEBUG_LEVEL_INFO), (DEBUG_TARGET_CREATE|DEBUG_TARGET_LCB), 
		("Enter XixFsdFreeLCB \n"));


	ASSERT(pLCB);
	

	if(pLCB->FileName.Buffer){
		ExFreePool(pLCB->FileName.Buffer);
		pLCB->FileName.Buffer = NULL;
		pLCB->FileName.Length = 0;
		pLCB->FileName.MaximumLength = 0;
	}

	if(pLCB->IgnoreCaseFileName.Buffer){
		ExFreePool(pLCB->IgnoreCaseFileName.Buffer);
		pLCB->IgnoreCaseFileName.Buffer = NULL;
		pLCB->IgnoreCaseFileName.Length = 0;
		pLCB->IgnoreCaseFileName.MaximumLength = 0;
	}


	// give back memory either to the zone or to the VMM
	if (!(pLCB->LCBFlags& XIFSD_LCB_NOT_FROM_POOL)) {
		ExFreeToNPagedLookasideList(&(XifsLcbLookasideList),pLCB);
	} else {
		ExFreePool(pLCB);
	}

	DebugTrace((DEBUG_LEVEL_TRACE|DEBUG_LEVEL_INFO), (DEBUG_TARGET_CREATE|DEBUG_TARGET_LCB), 
		("Exit XixFsdFreeLCB \n"));
	return;
}
VOID
BalloonLeak(
    IN WDFOBJECT WdfDevice,
    IN size_t num
    )
{
    PPAGE_LIST_ENTRY    pPageListEntry;
    PMDL                pPageMdl;
    PDEVICE_CONTEXT     devCtx = GetDeviceContext(WdfDevice);

    TraceEvents(TRACE_LEVEL_INFORMATION, DBG_HW_ACCESS, "--> %s\n", __FUNCTION__);

    num = min(num, PAGE_SIZE/sizeof(PFN_NUMBER));

    for (devCtx->num_pfns = 0; devCtx->num_pfns < num; devCtx->num_pfns++)
    {

        pPageListEntry = (PPAGE_LIST_ENTRY)PopEntryList(&devCtx->PageListHead);

        if (pPageListEntry == NULL)
        {
           TraceEvents(TRACE_LEVEL_WARNING, DBG_HW_ACCESS, "PopEntryList=NULL\n");
           break;
        }

        devCtx->pfns_table[devCtx->num_pfns] = pPageListEntry->PagePfn;
        pPageMdl = pPageListEntry->PageMdl;
        MmFreePagesFromMdl(pPageMdl);
        ExFreePool(pPageMdl);

        ExFreeToNPagedLookasideList(
                                &devCtx->LookAsideList,
                                pPageListEntry
                                );
        devCtx->num_pages--;
    }

    BalloonTellHost(WdfDevice, devCtx->DefVirtQueue);
}
VOID
BalloonLeak(
    IN WDFOBJECT WdfDevice,
    IN size_t num
    )
{
    PDEVICE_CONTEXT ctx = GetDeviceContext(WdfDevice);
    PPAGE_LIST_ENTRY pPageListEntry;
    PMDL pPageMdl;

    TraceEvents(TRACE_LEVEL_VERBOSE, DBG_HW_ACCESS, "--> %s\n", __FUNCTION__);

    pPageListEntry = (PPAGE_LIST_ENTRY)PopEntryList(&ctx->PageListHead);
    if (pPageListEntry == NULL)
    {
        TraceEvents(TRACE_LEVEL_WARNING, DBG_HW_ACCESS, "No list entries.\n");
        return;
    }

    pPageMdl = pPageListEntry->PageMdl;

    num = MmGetMdlByteCount(pPageMdl) / PAGE_SIZE;
    TraceEvents(TRACE_LEVEL_INFORMATION, DBG_HW_ACCESS,
        "Deflate balloon with %d pages.\n", num);

    ctx->num_pfns = num;
    ctx->num_pages -= ctx->num_pfns;

    RtlCopyMemory(ctx->pfns_table, MmGetMdlPfnArray(pPageMdl),
        ctx->num_pfns * sizeof(PFN_NUMBER));

    MmFreePagesFromMdl(pPageMdl);
    ExFreePool(pPageMdl);
    ExFreeToNPagedLookasideList(&ctx->LookAsideList, pPageListEntry);

    BalloonTellHost(WdfDevice, ctx->DefVirtQueue);

    TraceEvents(TRACE_LEVEL_VERBOSE, DBG_HW_ACCESS, "<-- %s\n", __FUNCTION__);
}
Example #30
0
static
void
LibTCPEmptyQueue(PCONNECTION_ENDPOINT Connection)
{
    PLIST_ENTRY Entry;
    PQUEUE_ENTRY qp = NULL;

    ReferenceObject(Connection);

    while (!IsListEmpty(&Connection->PacketQueue))
    {
        Entry = RemoveHeadList(&Connection->PacketQueue);
        qp = CONTAINING_RECORD(Entry, QUEUE_ENTRY, ListEntry);

        /* We're in the tcpip thread here so this is safe */
        pbuf_free(qp->p);

        ExFreeToNPagedLookasideList(&QueueEntryLookasideList, qp);
    }

    DereferenceObject(Connection);
}