Esempio n. 1
0
VOID
Primary_Dereference (
	IN PPRIMARY	Primary
	)
{
    LONG result;


    result = InterlockedDecrement (&Primary->ReferenceCount);
    ASSERT (result >= 0);

    if (result == 0) 
	{
		int i;


		LfsDereference (Primary->Lfs);

		//ASSERT(Primary->LfsDeviceExtQueue.Flink == &Primary->LfsDeviceExtQueue);
		for(i=0; i<MAX_SOCKETLPX_INTERFACE; i++)
			ASSERT(Primary->PrimarySessionQueue[i].Flink == &Primary->PrimarySessionQueue[i]);

		ExFreePoolWithTag(
			Primary,
			LFS_ALLOC_TAG
			);

		SPY_LOG_PRINT( LFS_DEBUG_PRIMARY_INFO,
				("Primary_Dereference: Primary is Freed Primary = %p\n", Primary));
	}
}
Esempio n. 2
0
VOID
LfsTable_Dereference (
	IN PLFS_TABLE	LfsTable
	)
{
    LONG result;


    result = InterlockedDecrement (&LfsTable->ReferenceCount);
    ASSERT (result >= 0);

    if (result == 0) 
	{
		ASSERT(LfsTable->EntryCount == 0);

		LfsDereference (LfsTable->Lfs);

		ExFreePoolWithTag(
			LfsTable,
			LFS_ALLOC_TAG
			);

		SPY_LOG_PRINT( LFS_DEBUG_TABLE_INFO,
				("LfsTable_Dereference: Lfs Table is Freed\n"));
	}
}
Esempio n. 3
0
PLFS_TABLE
LfsTable_Create(
	IN PLFS	Lfs
	)
{
	PLFS_TABLE	lfsTable;


	LfsReference (Lfs);

	lfsTable = ExAllocatePoolWithTag( 
						NonPagedPool, 
                        sizeof(LFS_TABLE),
						LFS_ALLOC_TAG
						);
	
	if (lfsTable == NULL)
	{
		ASSERT(LFS_INSUFFICIENT_RESOURCES);
		LfsDereference (Lfs);
		return NULL;
	}

	RtlZeroMemory(
		lfsTable,
		sizeof(LFS_TABLE)
		);

	KeInitializeSpinLock(&lfsTable->SpinLock);
	InitializeListHead(&lfsTable->LfsTabPartitionList) ;
	lfsTable->ReferenceCount = 1;
	lfsTable->Lfs = Lfs;
	

	
	return lfsTable;
}
Esempio n. 4
0
PPRIMARY
Primary_Create (
	IN PLFS	Lfs
	)
{
	PPRIMARY			primary;
 	OBJECT_ATTRIBUTES	objectAttributes;
	LONG				i;
	NTSTATUS			ntStatus;
	LARGE_INTEGER		timeOut;


	SPY_LOG_PRINT( LFS_DEBUG_PRIMARY_INFO,
		("Primary_Create: Entered\n"));

	LfsReference (Lfs);

	primary = ExAllocatePoolWithTag( 
						NonPagedPool, 
                        sizeof(PRIMARY),
						LFS_ALLOC_TAG
						);
	
	if (primary == NULL)
	{
		ASSERT(LFS_INSUFFICIENT_RESOURCES);
		LfsDereference (Lfs);

		return NULL;
	}

	RtlZeroMemory(
		primary,
		sizeof(PRIMARY)
		);

	KeInitializeSpinLock(&primary->SpinLock);	
	primary->ReferenceCount	= 1;

	primary->Lfs = Lfs;

//	InitializeListHead(&primary->LfsDeviceExtQueue);
//	KeInitializeSpinLock(&primary->LfsDeviceExtQSpinLock);

	for(i=0; i<MAX_SOCKETLPX_INTERFACE; i++)
	{
		InitializeListHead(&primary->PrimarySessionQueue[i]);
		KeInitializeSpinLock(&primary->PrimarySessionQSpinLock[i]);
	}

	primary->Agent.ThreadHandle = 0;
	primary->Agent.ThreadObject = NULL;

	primary->Agent.Flags = 0;

	KeInitializeEvent(&primary->Agent.ReadyEvent, NotificationEvent, FALSE);

	InitializeListHead(&primary->Agent.RequestQueue);
	KeInitializeSpinLock(&primary->Agent.RequestQSpinLock);
	KeInitializeEvent(&primary->Agent.RequestEvent, NotificationEvent, FALSE);

	
	primary->Agent.ListenPort = DEFAULT_PRIMARY_PORT;
	primary->Agent.ActiveListenSocketCount = 0;

	
	InitializeObjectAttributes(&objectAttributes, NULL, OBJ_KERNEL_HANDLE, NULL, NULL);

	ntStatus = PsCreateSystemThread(
					&primary->Agent.ThreadHandle,
					THREAD_ALL_ACCESS,
					&objectAttributes,
					NULL,
					NULL,
					PrimaryAgentThreadProc,
					primary
					);
	
	if(!NT_SUCCESS(ntStatus)) 
	{
		ASSERT(LFS_UNEXPECTED);
		Primary_Close(primary);
		
		return NULL;
	}

	ntStatus = ObReferenceObjectByHandle(
					primary->Agent.ThreadHandle,
					FILE_READ_DATA,
					NULL,
					KernelMode,
					&primary->Agent.ThreadObject,
					NULL
					);

	if(!NT_SUCCESS(ntStatus)) 
	{
		ASSERT(LFS_INSUFFICIENT_RESOURCES);
		Primary_Close(primary);
		
		return NULL;
	}

	timeOut.QuadPart = - LFS_TIME_OUT;		// 10 sec
	ntStatus = KeWaitForSingleObject(
					&primary->Agent.ReadyEvent,
					Executive,
					KernelMode,
					FALSE,
					&timeOut
					);

	ASSERT(ntStatus == STATUS_SUCCESS);

	KeClearEvent(&primary->Agent.ReadyEvent);

	if(ntStatus != STATUS_SUCCESS) 
	{
		ASSERT(LFS_BUG);
		Primary_Close(primary);
		
		return NULL;
	}
	
	SPY_LOG_PRINT( LFS_DEBUG_PRIMARY_INFO,
		("Primary_Create: primary = %p\n", primary));

	return primary;
}