⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cfgmgr.c

📁 vc环境下的pgp源码
💻 C
📖 第 1 页 / 共 2 页
字号:
    case OID_PGP_EVENT_CREATE:
        SourceBufferLength = sizeof(PGPEVENT_CONTEXT);
        if (InformationBufferLength >= SourceBufferLength)
        {
            PPGPEVENT_CONTEXT pPgpEvent = (PPGPEVENT_CONTEXT)InformationBuffer;

            PgpEventCreate(pPgpEvent);

			//adapter->pgpEvent = *pPgpEvent;
			NdisMoveMemory(&adapter->pgpEvent, pPgpEvent, sizeof(PGPEVENT_CONTEXT));
            SourceBuffer = InformationBuffer;
			status = NDIS_STATUS_SUCCESS;
        }
        else
        {
            DBG_PRINT(("!!!!! OID_PGP_EVENT_CREATE: Invalid size=%d expected=%d\n",
                      InformationBufferLength, SourceBufferLength););
            status = NDIS_STATUS_INVALID_LENGTH;
        }
        break;

    case OID_PGP_EVENT_DESTROY:
        SourceBufferLength = sizeof(PGPEVENT_CONTEXT);
        if (InformationBufferLength >= SourceBufferLength)
        {
            PPGPEVENT_CONTEXT pPgpEvent = (PPGPEVENT_CONTEXT)InformationBuffer;

            PgpEventClose(pPgpEvent);

			adapter->pgpEvent = *pPgpEvent;
            SourceBuffer = InformationBuffer;
			status = NDIS_STATUS_SUCCESS;
        }
        else
        {
            DBG_PRINT(("!!!!! OID_PGP_EVENT_DESTROY: Invalid size=%d expected=%d\n",
                      InformationBufferLength, SourceBufferLength););
            status = NDIS_STATUS_INVALID_LENGTH;
        }
        break;

	case OID_PGP_EVENT_SET:
        SourceBufferLength = sizeof(PGPEVENT_CONTEXT);
        if (InformationBufferLength >= SourceBufferLength)
        {
            PPGPEVENT_CONTEXT pPgpEvent = (PPGPEVENT_CONTEXT)InformationBuffer;
			if (adapter->SharedMemoryWin32Ptr != NULL)
			{
				ULONG *pData = (ULONG*)(adapter->SharedMemoryPtr);
				*pData = *pData + 1;
			}

            PgpEventSet(&adapter->pgpEvent);

			adapter->pgpEvent = *pPgpEvent;
            SourceBuffer = InformationBuffer;
			status = NDIS_STATUS_SUCCESS;
        }
        else
        {
            DBG_PRINT(("!!!!! OID_PGP_EVENT_Set: Invalid size=%d expected=%d\n",
                      InformationBufferLength, SourceBufferLength););
            status = NDIS_STATUS_INVALID_LENGTH;
        }

		break;

	case OID_PGP_SHARED_MEM_ALLOC:
        SourceBufferLength = sizeof(HANDLE);
		if( adapter->SharedMemoryPtr == NULL)
		{
            DBG_PRINT(("!!!!! OID_PGP_SHARED_MEM_ALLOC: Shared Memory not available!\n"););
			adapter->SharedMemoryWin32Ptr = NULL;
			GenericULong = (ULONG) adapter->SharedMemoryWin32Ptr;
            status = NDIS_STATUS_RESOURCES;
			break;
		}
        if (InformationBufferLength >= SourceBufferLength &&
            adapter->SharedMemoryWin32Ptr == NULL)
        {
            HANDLE ProcessHandle = *(HANDLE *)InformationBuffer;
            adapter->SharedMemoryWin32Ptr = PgpMemoryMapWin32Address(
                                            adapter->SharedMemoryPhysicalAddress,
                                            adapter->SharedMemoryPtr,
                                            adapter->SharedMemorySize,
                                            ProcessHandle
                                            );
#ifdef CHICAGO
			adapter->SharedMemoryWin32Ptr = adapter->SharedMemoryPtr;
#endif
            GenericULong = (ULONG) adapter->SharedMemoryWin32Ptr;
			DBG_PRINT(("kernelSharedMemory Address: %xh\n", adapter->SharedMemoryPtr););
			DBG_PRINT(("Win32SharedMemory Address: %xh\n", adapter->SharedMemoryWin32Ptr););

			if (adapter->SharedMemoryWin32Ptr)
				status = NDIS_STATUS_SUCCESS;
			else
				status = NDIS_STATUS_RESOURCES;
        }
        else
        {
            DBG_PRINT(("!!!!! OID_PGP_SHARED_MEM_ALLOC: Invalid size=%d expected=%d\n",
                      InformationBufferLength, SourceBufferLength););
            status = NDIS_STATUS_INVALID_LENGTH;
        }
        break;

	case OID_PGP_SHARED_MEM_FREE:
        SourceBufferLength = sizeof(HANDLE);
        if (InformationBufferLength >= SourceBufferLength &&
            adapter->SharedMemoryWin32Ptr)
        {
            HANDLE ProcessHandle = *(HANDLE *)InformationBuffer;
            PgpMemoryUnmapWin32Address(
                                        adapter->SharedMemoryWin32Ptr,
                                        adapter->SharedMemorySize,
                                        ProcessHandle
                                        );
            adapter->SharedMemoryWin32Ptr = NULL;
			status = NDIS_STATUS_SUCCESS;
        }
        else
        {
            DBG_PRINT(("!!!!! OID_PGP_SHARED_MEM_FREE: Invalid size=%d expected=%d\n",
                      InformationBufferLength, SourceBufferLength););
            status = NDIS_STATUS_INVALID_LENGTH;
        }
        SourceBufferLength = 0;
        break;

	case OID_PGP_NEWCONFIG:

		status = PGPnetPMNewConfig(PGPnetDriver.PolicyManagerHandle,
			(PVOID)InformationBuffer,
			InformationBufferLength,
			&SourceBufferLength);

		break;

	case OID_PGP_NEWHOST:

		status = PGPnetPMNewHost(
			PGPnetDriver.PolicyManagerHandle,
			(PVOID)InformationBuffer,
			InformationBufferLength,
			&SourceBufferLength);

		break;

	case OID_PGP_ALLHOSTS:

		status = PGPnetPMAllHosts(
			PGPnetDriver.PolicyManagerHandle,
			(PVOID)InformationBuffer,
			InformationBufferLength,
			&SourceBufferLength);

		break;

	case OID_PGP_SHUTDOWN:

		status = PGPnetPMShutdown(
			PGPnetDriver.PolicyManagerHandle,
			(PVOID)InformationBuffer,
			InformationBufferLength,
			&SourceBufferLength);

		break;

	case OID_PGP_LOCALIP:

		GenericULong = adapter->ip_address;
		status = NDIS_STATUS_SUCCESS;

		break;

	case OID_PGP_NEWSA:

		status = PGPnetPMNewSA(
			PGPnetDriver.PolicyManagerHandle,
			(PVOID)InformationBuffer,
			InformationBufferLength,
			&SourceBufferLength);

		break;

	case OID_PGP_SADIED:

		status = PGPnetPMRemoveSA(PGPnetDriver.PolicyManagerHandle,
			(PVOID)InformationBuffer,
			InformationBufferLength,
			&SourceBufferLength);

		break;

	case OID_PGP_SAFAILED:

		status = PGPnetPMFailedSA(PGPnetDriver.PolicyManagerHandle,
			(PVOID)InformationBuffer,
			InformationBufferLength,
			&SourceBufferLength);

		break;
	case OID_PGP_SAUPDATE:

		status = PGPnetPMUpdateSA(PGPnetDriver.PolicyManagerHandle,
			(PVOID)InformationBuffer,
			InformationBufferLength,
			&SourceBufferLength);

		break;
	case OID_PGP_NEW_DUMMY_HOST:

#ifdef PM_EMULATION
		PMAddDummyHost(PGPnetDriver.PolicyManagerHandle,
			(ULONG*)InformationBuffer);
#endif
		status = NDIS_STATUS_SUCCESS;
		SourceBufferLength = 0;

		break;

	case OID_PGP_NEW_DUMMY_SA:
#ifdef PM_EMULATION
		PMAddDummySA(PGPnetDriver.PolicyManagerHandle,
			(PVOID)InformationBuffer);
#endif
		status = NDIS_STATUS_SUCCESS;
		SourceBufferLength = 0;

		break;

	case OID_PGP_QUEUE_INITIALIZE:

		if (adapter->pgpMessage == NULL)
		{

			PPGPMESSAGE_CONTEXT userMessageContext = (PPGPMESSAGE_CONTEXT)InformationBuffer;
			PPGPMESSAGE_CONTEXT kernelMessageContext;

			kernelMessageContext = (PPGPMESSAGE_CONTEXT)adapter->SharedMemoryPtr;

			kernelMessageContext->messageType = userMessageContext->messageType;
			//kernelMessageContext->header.event = 0; // ?? fix
			kernelMessageContext->header.head = userMessageContext->header.head;
			kernelMessageContext->header.tail = userMessageContext->header.tail;
			kernelMessageContext->header.maxSlots = userMessageContext->header.maxSlots;
			kernelMessageContext->header.maxSlotSize = userMessageContext->header.maxSlotSize;

			if ((kernelMessageContext->header.head != 0) |
				(kernelMessageContext->header.tail != 0) |
				((kernelMessageContext->header.maxSlots * kernelMessageContext->header.maxSlotSize) > adapter->SharedMemorySize))
			{
				status = NDIS_STATUS_FAILURE;
			}
			else
			{
				DBG_PRINT(("kernelMessageContext Address: %xh\n", kernelMessageContext););
				adapter->pgpMessage = kernelMessageContext;

				status = NDIS_STATUS_SUCCESS;
			}
		}

	
        SourceBufferLength = 0;

        break;


	case OID_PGP_QUEUE_RELEASE:

		if (adapter->pgpMessage != NULL)
			adapter->pgpMessage = NULL;

		status = NDIS_STATUS_SUCCESS;

		SourceBufferLength = 0;

		break;

    default:

        status = NDIS_STATUS_INVALID_OID;
        SourceBufferLength = 0;

        break;
    }

    if (status == NDIS_STATUS_SUCCESS)
    {
        if (SourceBufferLength > InformationBufferLength)
        {
            *BytesNeeded  = SourceBufferLength;
            *BytesWritten = 0;
            status = NDIS_STATUS_INVALID_LENGTH;
        }
        else if (SourceBufferLength)
        {
            NdisMoveMemory(InformationBuffer, SourceBuffer, SourceBufferLength);
            *BytesWritten = SourceBufferLength;
        }
        else
        {
            *BytesNeeded = *BytesWritten = 0;
        }
    }
    else
    {
        *BytesNeeded = SourceBufferLength;
        *BytesWritten = 0;
    }

    DBG_LEAVE(status);

    return (status);

}

#ifdef CHICAGO
VOID EventTimerRoutine(
    PVOID SystemArg1,
    PVOID Context,
    PVOID SystemArg2,
    PVOID SystemArg3)
{

	DBG_FUNC("EventTimerRoutine")

	PVPN_ADAPTER adapter = (PVPN_ADAPTER)Context;

	DBG_ENTER();

	CallWin32Event( (ULONG) adapter->pgpEvent.DriverEventHandle);

	DBG_LEAVE(0);
}
#endif

VOID RequestTimerRoutine(
	PVOID SystemArg1,
	PVOID Context,
	PVOID SystemArg2,
	PVOID SystemArg3)
{
	DBG_FUNC("RequestTimerRoutine")

	NDIS_STATUS			status;
	PPGPNDIS_REQUEST	pgpRequest;
	PVPN_ADAPTER		adapter = (PVPN_ADAPTER)Context;

	DBG_ENTER();

	pgpRequest = RequestDequeue(adapter, &adapter->wait_request_list);

	RequestEnqueue(adapter, &adapter->send_request_list, pgpRequest);

	NdisRequestTrace(pgpRequest->NdisRequest);

	NdisRequest(
		&status,
		adapter->NdisBindingHandleToRealMac,
		pgpRequest->NdisRequest);

	if (status != NDIS_STATUS_PENDING)
	{
		pgpRequest = RequestRemoveByNdisRequest(adapter, &adapter->send_request_list, pgpRequest->NdisRequest);
		PGPNdisRequestFree(adapter, pgpRequest);
		NdisCompleteRequest (
					pgpRequest->Binding->NdisBindingContextFromProtocol,
					pgpRequest->NdisRequest,
					status
					);


	}
	else
	{
	}

	DBG_LEAVE(status);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -