コード例 #1
0
ファイル: upper_edge.c プロジェクト: patrick-ken/kernel_808l
/*--------------------------------------------------------------------------
  ssh_interceptor_register_upper_edge()
  
  Registers(Deregisters) the upper-edge (miniport) handlers of driver with 
  NDIS. After registration is done, NDIS can use these handlers for 
  communication with upper layer device (protocol) driver.
  
  Arguments:
  interceptor - SshInterceptor object,
  enable - Register/Deregister flag.
 
  Returns:
  NDIS_STATUS_SUCCESS - operation succeeded
  NDIS_STATUS_FAILURE - otherwise
  
  Notes:
  --------------------------------------------------------------------------*/
NDIS_STATUS
ssh_interceptor_register_upper_edge(SshNdisIMInterceptor interceptor,
                                    BOOLEAN enable)
{
  NDIS_STATUS status = NDIS_STATUS_SUCCESS;
  NDIS_MINIPORT_CHARACTERISTICS mp_chars;

  SSH_ASSERT(interceptor != NULL);

  SSH_DEBUG(SSH_D_NICETOKNOW, ("ssh_interceptor_register_upper_edge()"));

  if (enable == TRUE && interceptor->miniport_handle == NULL)
    {
      NdisZeroMemory(&mp_chars,sizeof(mp_chars));

      mp_chars.MajorNdisVersion = SSH_MAJOR_NDIS_VERSION;
      mp_chars.MinorNdisVersion = SSH_MINOR_NDIS_VERSION;

      mp_chars.CheckForHangHandler = ssh_driver_check_for_hang;
      mp_chars.HaltHandler = ssh_driver_deinitialize;
      mp_chars.InitializeHandler = ssh_driver_initialize;
      mp_chars.ResetHandler = ssh_driver_reset;
      mp_chars.SendHandler = NULL;
#ifdef _WIN32_WCE
      mp_chars.WanSendHandler = ssh_driver_send_wan_packet;
#endif /* _WIN32_WCE */
      mp_chars.SendPacketsHandler = ssh_driver_send_packets;
      mp_chars.TransferDataHandler = ssh_driver_transfer_data;
      mp_chars.ReturnPacketHandler = ssh_driver_return_packet;
      mp_chars.QueryInformationHandler = ssh_driver_query_information;
      mp_chars.SetInformationHandler = ssh_driver_set_information;

      status = NdisIMRegisterLayeredMiniport(interceptor->wrapper_handle,
                                             &mp_chars,
                                             sizeof(mp_chars),
                                             &interceptor->miniport_handle);

      if (status != NDIS_STATUS_SUCCESS)
        {
          interceptor->miniport_handle = NULL;
          SSH_DEBUG(SSH_D_ERROR, ("  - failed!"));
        }

      NdisMRegisterUnloadHandler(interceptor->wrapper_handle, DriverUnload); 
    }

  if (enable == FALSE && interceptor->miniport_handle != NULL)
    {
      /* Deregister upper edge API */
      NdisIMDeregisterLayeredMiniport(interceptor->miniport_handle);
      interceptor->miniport_handle = NULL;
      status = NDIS_STATUS_SUCCESS;
    }

  return (status);
}
コード例 #2
0
ファイル: PASSTHRU.C プロジェクト: Naturekid/MSVR
VOID
PtUnload(
    IN PDRIVER_OBJECT        DriverObject
    )
//
// PassThru driver unload function
//
{
    UNREFERENCED_PARAMETER(DriverObject);
    
    DBGPRINT(("PtUnload: entered\n"));
    PtUnloadProtocol();
    NdisIMDeregisterLayeredMiniport(DriverHandle);
    DBGPRINT(("PtUnload: done!\n"));
}
コード例 #3
0
VOID
GingkoNdisUnload(
    IN PDRIVER_OBJECT        DriverObject
    )
//
// PassThru driver unload function
//
{
    UNREFERENCED_PARAMETER(DriverObject);
    
    KdPrint(("PtUnload: entered\n"));
    
    GingkoNdisUnloadProtocol();
    
    NdisIMDeregisterLayeredMiniport(DriverHandle);
    
    NdisFreeSpinLock(&GlobalLock);

    KdPrint(("PtUnload: done!\n"));
}
コード例 #4
0
VOID unload(PDRIVER_OBJECT driver)
{
	DbgBreakPoint();
	NDIS_STATUS ndissta;
	for (int i = 0; i < global.mininum; i++)
	{
		ndissta = NdisIMDeInitializeDeviceInstance(global.miniportcontext[i]->Miniportadapterhandle);
	}
	if (global.driverhandle != NULL)
	{
		NdisIMDeregisterLayeredMiniport(global.driverhandle);
	}
	if (global.protocolhandle)
	{
		NdisDeregisterProtocol(&ndissta, global.protocolhandle);
	}
	if (global.controlobj)
	{
		UNICODE_STRING symname;
		RtlInitUnicodeString(&symname, SYM_NAME);
		IoDeleteSymbolicLink(&symname);
		IoDeleteDevice(global.controlobj);
	}
}
コード例 #5
0
ファイル: WonARP.c プロジェクト: aldertotori/antiarp
VOID
ProtocolUnload(
    IN PDRIVER_OBJECT        DriverObject
    )
{
    NDIS_STATUS Status;

    if (ProtHandle != NULL)
    {
        NdisDeregisterProtocol(&Status, ProtHandle);
        ProtHandle = NULL;
    }

    NdisIMDeregisterLayeredMiniport(DriverHandle);

//	UnInitPacketList();

    NdisFreeSpinLock(&GlobalLock);

	g_ArpFw_ShareMem = NULL;

	UninitUserShareMemory(&g_Share_User_Mem);

}
コード例 #6
0
ファイル: passthru.c プロジェクト: Acidburn0zzz/tcpcrypt
NTSTATUS
DriverEntry(
    IN PDRIVER_OBJECT        DriverObject,
    IN PUNICODE_STRING       RegistryPath
    )
/*++

Routine Description:

    First entry point to be called, when this driver is loaded.
    Register with NDIS as an intermediate driver.

Arguments:

    DriverObject - pointer to the system's driver object structure
        for this driver
    
    RegistryPath - system's registry path for this driver
    
Return Value:

    STATUS_SUCCESS if all initialization is successful, STATUS_XXX
    error code if not.

--*/
{
    NDIS_STATUS                        Status;
    NDIS_PROTOCOL_CHARACTERISTICS      PChars;
    NDIS_MINIPORT_CHARACTERISTICS      MChars;
    NDIS_STRING                        Name;

    divert_init();

    Status = NDIS_STATUS_SUCCESS;
    NdisAllocateSpinLock(&GlobalLock);

    NdisMInitializeWrapper(&NdisWrapperHandle, DriverObject, RegistryPath, NULL);

    do
    {
        //
        // Register the miniport with NDIS. Note that it is the miniport
        // which was started as a driver and not the protocol. Also the miniport
        // must be registered prior to the protocol since the protocol's BindAdapter
        // handler can be initiated anytime and when it is, it must be ready to
        // start driver instances.
        //

        NdisZeroMemory(&MChars, sizeof(NDIS_MINIPORT_CHARACTERISTICS));

        MChars.MajorNdisVersion = PASSTHRU_MAJOR_NDIS_VERSION;
        MChars.MinorNdisVersion = PASSTHRU_MINOR_NDIS_VERSION;

        MChars.InitializeHandler = MPInitialize;
        MChars.QueryInformationHandler = MPQueryInformation;
        MChars.SetInformationHandler = MPSetInformation;
        MChars.ResetHandler = NULL;
        MChars.TransferDataHandler = MPTransferData;
        MChars.HaltHandler = MPHalt;
#ifdef NDIS51_MINIPORT
        MChars.CancelSendPacketsHandler = MPCancelSendPackets;
        MChars.PnPEventNotifyHandler = MPDevicePnPEvent;
        MChars.AdapterShutdownHandler = MPAdapterShutdown;
#endif // NDIS51_MINIPORT

        //
        // We will disable the check for hang timeout so we do not
        // need a check for hang handler!
        //
        MChars.CheckForHangHandler = NULL;
        MChars.ReturnPacketHandler = MPReturnPacket;

        //
        // Either the Send or the SendPackets handler should be specified.
        // If SendPackets handler is specified, SendHandler is ignored
        //
        MChars.SendHandler = NULL;    // MPSend;
        MChars.SendPacketsHandler = MPSendPackets;

        Status = NdisIMRegisterLayeredMiniport(NdisWrapperHandle,
                                                  &MChars,
                                                  sizeof(MChars),
                                                  &DriverHandle);
        if (Status != NDIS_STATUS_SUCCESS)
        {
            break;
        }

#ifndef WIN9X
        NdisMRegisterUnloadHandler(NdisWrapperHandle, PtUnload);
#endif

        //
        // Now register the protocol.
        //
        NdisZeroMemory(&PChars, sizeof(NDIS_PROTOCOL_CHARACTERISTICS));
        PChars.MajorNdisVersion = PASSTHRU_PROT_MAJOR_NDIS_VERSION;
        PChars.MinorNdisVersion = PASSTHRU_PROT_MINOR_NDIS_VERSION;

        //
        // Make sure the protocol-name matches the service-name
        // (from the INF) under which this protocol is installed.
        // This is needed to ensure that NDIS can correctly determine
        // the binding and call us to bind to miniports below.
        //
        NdisInitUnicodeString(&Name, L"Passthru");    // Protocol name
        PChars.Name = Name;
        PChars.OpenAdapterCompleteHandler = PtOpenAdapterComplete;
        PChars.CloseAdapterCompleteHandler = PtCloseAdapterComplete;
        PChars.SendCompleteHandler = PtSendComplete;
        PChars.TransferDataCompleteHandler = PtTransferDataComplete;
    
        PChars.ResetCompleteHandler = PtResetComplete;
        PChars.RequestCompleteHandler = PtRequestComplete;
        PChars.ReceiveHandler = PtReceive;
        PChars.ReceiveCompleteHandler = PtReceiveComplete;
        PChars.StatusHandler = PtStatus;
        PChars.StatusCompleteHandler = PtStatusComplete;
        PChars.BindAdapterHandler = PtBindAdapter;
        PChars.UnbindAdapterHandler = PtUnbindAdapter;
        PChars.UnloadHandler = PtUnloadProtocol;

        PChars.ReceivePacketHandler = PtReceivePacket;
        PChars.PnPEventHandler= PtPNPHandler;

        NdisRegisterProtocol(&Status,
                             &ProtHandle,
                             &PChars,
                             sizeof(NDIS_PROTOCOL_CHARACTERISTICS));

        if (Status != NDIS_STATUS_SUCCESS)
        {
            NdisIMDeregisterLayeredMiniport(DriverHandle);
            break;
        }

        NdisIMAssociateMiniport(DriverHandle, ProtHandle);
    }
    while (FALSE);

    if (Status != NDIS_STATUS_SUCCESS)
    {
        NdisTerminateWrapper(NdisWrapperHandle, NULL);
    }

    return(Status);
}
コード例 #7
0
NTSTATUS GingkoNdisDriverEntry(
    IN PDRIVER_OBJECT        DriverObject,
    IN PUNICODE_STRING       RegistryPath
    )
{
	NDIS_STATUS                        Status;
    NDIS_PROTOCOL_CHARACTERISTICS      PChars;
    NDIS_MINIPORT_CHARACTERISTICS      MChars;
    NDIS_STRING                        Name;

    Status = NDIS_STATUS_SUCCESS;
    NdisAllocateSpinLock(&GlobalLock);
    NdisMInitializeWrapper(&NdisWrapperHandle, DriverObject, RegistryPath, NULL);
	KdPrint(("Calling NdisMInitializeWrapper Before\n"));

    do
    {
        //
        // Register the miniport with NDIS. Note that it is the miniport
        // which was started as a driver and not the protocol. Also the miniport
        // must be registered prior to the protocol since the protocol's BindAdapter
        // handler can be initiated anytime and when it is, it must be ready to
        // start driver instances.
        //

        NdisZeroMemory(&MChars, sizeof(NDIS_MINIPORT_CHARACTERISTICS));

        MChars.MajorNdisVersion = PASSTHRU_MAJOR_NDIS_VERSION;
        MChars.MinorNdisVersion = PASSTHRU_MINOR_NDIS_VERSION;

        MChars.InitializeHandler = GingkoNdisInitialize;
        MChars.QueryInformationHandler = GingkoNdisQueryInformation;
        MChars.SetInformationHandler = GingkoNdisSetInformation;
        MChars.ResetHandler = NULL;
        MChars.TransferDataHandler = GingkoNdisTransferData;
        MChars.HaltHandler = GingkoNdisHalt;
#ifdef NDIS51_MINIPORT
        MChars.CancelSendPacketsHandler = GingkoNdisCancelSendPackets;
        MChars.PnPEventNotifyHandler = GingkoNdisDevicePnPEvent;
        MChars.AdapterShutdownHandler = GingkoNdisAdapterShutdown;
#endif // NDIS51_MINIPORT

        //
        // We will disable the check for hang timeout so we do not
        // need a check for hang handler!
        //
        MChars.CheckForHangHandler = NULL;
        MChars.ReturnPacketHandler = GingkoNdisReturnPacket;

        //
        // Either the Send or the SendPackets handler should be specified.
        // If SendPackets handler is specified, SendHandler is ignored
        //
        MChars.SendHandler = NULL;    // MPSend;
        MChars.SendPacketsHandler = GingkoNdisSendPackets;

        Status = NdisIMRegisterLayeredMiniport(NdisWrapperHandle,
                                                  &MChars,
                                                  sizeof(MChars),
                                                  &DriverHandle);

		KdPrint(("Calling NdisIMRegisterLayeredMiniport After\n"));
		///return 0;
        if (Status != NDIS_STATUS_SUCCESS)
        {
            break;
        }


#ifndef WIN9X
        NdisMRegisterUnloadHandler(NdisWrapperHandle, GingkoNdisUnload);
#endif

        //
        // Now register the protocol.
        //
        NdisZeroMemory(&PChars, sizeof(NDIS_PROTOCOL_CHARACTERISTICS));
        PChars.MajorNdisVersion = PASSTHRU_PROT_MAJOR_NDIS_VERSION;
        PChars.MinorNdisVersion = PASSTHRU_PROT_MINOR_NDIS_VERSION;

        //
        // Make sure the protocol-name matches the service-name
        // (from the INF) under which this protocol is installed.
        // This is needed to ensure that NDIS can correctly determine
        // the binding and call us to bind to miniports below.
        //
        NdisInitUnicodeString(&Name, L"GingkoFilter");    // Protocol name
        PChars.Name = Name;
        PChars.OpenAdapterCompleteHandler = GingkoNdisOpenAdapterComplete;
        PChars.CloseAdapterCompleteHandler = GingkoNdisCloseAdapterComplete;
        PChars.SendCompleteHandler = GingkoNdisSendComplete;
        PChars.TransferDataCompleteHandler = GingkoNdisTransferDataComplete;
    
        PChars.ResetCompleteHandler = GingkoNdisResetComplete;
        PChars.RequestCompleteHandler = GingkoNdisRequestComplete;
        PChars.ReceiveHandler = GingkoNdisReceive;
        PChars.ReceiveCompleteHandler = GingkoNdisReceiveComplete;
        PChars.StatusHandler = GingkoNdisStatus;
        PChars.StatusCompleteHandler = GingkoNdisStatusComplete;
        PChars.BindAdapterHandler = GingkoNdisBindAdapter;
        PChars.UnbindAdapterHandler = GingkoNdisUnbindAdapter;
        PChars.UnloadHandler = GingkoNdisUnloadProtocol;

        PChars.ReceivePacketHandler = GingkoNdisReceivePacket;
        PChars.PnPEventHandler= GingkoNdisPNPHandler;

        NdisRegisterProtocol(&Status,
                             &ProtHandle,
                             &PChars,
                             sizeof(NDIS_PROTOCOL_CHARACTERISTICS));

		KdPrint(("Calling NdisRegisterProtocol After\n"));
        if (Status != NDIS_STATUS_SUCCESS)
        {
            NdisIMDeregisterLayeredMiniport(DriverHandle);
            break;
        }

        NdisIMAssociateMiniport(DriverHandle, ProtHandle);

		KdPrint(("Calling NdisIMAssociateMiniport After\n"));
    }
    while (FALSE);

    if (Status != NDIS_STATUS_SUCCESS)
    {
        NdisTerminateWrapper(NdisWrapperHandle, NULL);
    }

    return(Status);
}
コード例 #8
0
ファイル: WonARP.c プロジェクト: aldertotori/antiarp
NTSTATUS
DriverEntry(
    IN PDRIVER_OBJECT        DriverObject,
    IN PUNICODE_STRING       RegistryPath
    )
{
    NDIS_STATUS                        Status;
    NDIS40_PROTOCOL_CHARACTERISTICS    PChars40;
    NDIS40_MINIPORT_CHARACTERISTICS    MChars40;
    NDIS50_PROTOCOL_CHARACTERISTICS    PChars50;
    NDIS51_MINIPORT_CHARACTERISTICS    MChars51;
    NDIS_STRING                        Name;

    Status = NDIS_STATUS_SUCCESS;

	g_ArpFw_ShareMem = NULL;

    NdisAllocateSpinLock(&GlobalLock);

	g_CurrentDriver = DriverObject;

	LoadDynamicFunction();  //识别版本并加载额外函数

//	Status = InitPacketList();

//	if( Status != STATUS_SUCCESS)
//	{
//		return Status;
//	}

    NdisMInitializeWrapper(&NdisWrapperHandle, DriverObject, RegistryPath, NULL);

	if(IS_NDIS51())
	{
	    do
	    {
        	//
        	// Register the miniport with NDIS. Note that it is the miniport
        	// which was started as a driver and not the protocol. Also the miniport
        	// must be registered prior to the protocol since the protocol's BindAdapter
        	// handler can be initiated anytime and when it is, it must be ready to
        	// start driver instances.
        	//
        	NdisZeroMemory(&MChars51, sizeof(NDIS51_MINIPORT_CHARACTERISTICS));

        	MChars51.MajorNdisVersion = 5;
        	MChars51.MinorNdisVersion = 1;

        	MChars51.InitializeHandler 			= MiniportInitialize5;
        	MChars51.QueryInformationHandler 	= MiniportQueryInformation5;
        	MChars51.SetInformationHandler 		= MiniportSetInformation5;
        	MChars51.ResetHandler 				= NULL;
        	MChars51.TransferDataHandler 		= MiniportTransferData5;
        	MChars51.HaltHandler 				= MiniportHalt5;

			//NDIS51++
        	MChars51.CancelSendPacketsHandler 	= MiniportCancelSendPackets5;
        	MChars51.PnPEventNotifyHandler 		= MiniportDevicePnPEvent5;
        	MChars51.AdapterShutdownHandler 	= MiniportAdapterShutdown5;
			//--NDIS51

        	//
        	// We will disable the check for hang timeout so we do not
        	// need a check for hang handler!
        	//
        	MChars51.CheckForHangHandler 		= MiniportCheckForHang5;
        	MChars51.ReturnPacketHandler 		= MiniportReturnPacket5;

        	//
        	// Either the Send or the SendPackets handler should be specified.
        	// If SendPackets handler is specified, SendHandler is ignored
        	//
        	MChars51.SendHandler 				= NULL;
        	MChars51.SendPacketsHandler 		= MiniportSendPackets5;

        	Status = NdisIMRegisterLayeredMiniport(NdisWrapperHandle,
                                                  (PVOID)&MChars51,
                                                  sizeof(NDIS51_MINIPORT_CHARACTERISTICS),
                                                  &DriverHandle);
        	if (Status != NDIS_STATUS_SUCCESS)
        	{
            	break;
        	}

        	NdisMRegisterUnloadHandler(NdisWrapperHandle, ProtocolUnload);


        	//
        	// Now register the protocol.
        	//
        	NdisZeroMemory(&PChars50, sizeof(NDIS50_PROTOCOL_CHARACTERISTICS));
        	PChars50.MajorNdisVersion = 5;
        	PChars50.MinorNdisVersion = 0;

        	//
        	// Make sure the protocol-name matches the service-name
        	// (from the INF) under which this protocol is installed.
        	// This is needed to ensure that NDIS can correctly determine
        	// the binding and call us to bind to miniports below.
        	//
        	NdisInitUnicodeString(&Name, PROTOCOL_NAME);    // Protocol name
        	PChars50.Name 							= Name;
        	PChars50.OpenAdapterCompleteHandler 	= ProtocolOpenAdapterComplete5;
        	PChars50.CloseAdapterCompleteHandler 	= ProtocolCloseAdapterComplete5;
        	PChars50.SendCompleteHandler 			= ProtocolSendComplete5;
        	PChars50.TransferDataCompleteHandler 	= ProtocolTransferDataComplete5;
    
        	PChars50.ResetCompleteHandler 			= ProtocolResetComplete5;
        	PChars50.RequestCompleteHandler 		= ProtocolRequestComplete5;
        	PChars50.ReceiveHandler 				= ProtocolReceive5;
        	PChars50.ReceiveCompleteHandler 		= ProtocolReceiveComplete5;
        	PChars50.StatusHandler 					= ProtocolStatus5;
        	PChars50.StatusCompleteHandler 			= ProtocolStatusComplete5;
        	PChars50.BindAdapterHandler 			= ProtocolBindAdapter5;
        	PChars50.UnbindAdapterHandler 			= ProtocolUnbindAdapter5;
        	PChars50.UnloadHandler 					= ProtocolUnloadProtocol5;

        	PChars50.ReceivePacketHandler 			= ProtocolReceivePacket5;
        	PChars50.PnPEventHandler				= ProtocolPNPHandler5;

        	NdisRegisterProtocol(&Status,
                             &ProtHandle,
                             (PVOID)&PChars50,
                             sizeof(NDIS50_PROTOCOL_CHARACTERISTICS));

        	if (Status != NDIS_STATUS_SUCCESS)
        	{
            	NdisIMDeregisterLayeredMiniport(DriverHandle);
            	break;
        	}

        	NdisIMAssociateMiniport(DriverHandle, ProtHandle);
    	}
    	while (FALSE);

	}
	else
	{
		do
		{
			//注册 Miniport
			NdisZeroMemory(&MChars40, sizeof(NDIS40_MINIPORT_CHARACTERISTICS));

			MChars40.MajorNdisVersion = 4;
			MChars40.MinorNdisVersion = 0;

			MChars40.InitializeHandler 			= MiniportInitialize4;
			MChars40.QueryInformationHandler 	= MiniportQueryInformation4;
			MChars40.SetInformationHandler 		= MiniportSetInformation4;
			MChars40.ResetHandler 				= NULL;
			MChars40.TransferDataHandler 		= MiniportTransferData4;
			MChars40.HaltHandler 				= MiniportHalt4;

			MChars40.CheckForHangHandler 		= MiniportCheckForHang4;
			MChars40.ReturnPacketHandler 		= MiniportReturnPacket4;

			MChars40.SendHandler 				= NULL;
			MChars40.SendPacketsHandler 		= MiniportSendPackets4;

			Status = NdisIMRegisterLayeredMiniport(NdisWrapperHandle,
													  (PVOID)&MChars40,
													  sizeof(MChars40),
													  &DriverHandle);
			if (Status != NDIS_STATUS_SUCCESS)
			{
				break;
			}

			NdisMRegisterUnloadHandler(NdisWrapperHandle, ProtocolUnload);

			//
			// Now register the protocol.
			//
			NdisZeroMemory(&PChars40, sizeof(NDIS40_PROTOCOL_CHARACTERISTICS));
			PChars40.MajorNdisVersion = 4;
			PChars40.MinorNdisVersion = 0;

			NdisInitUnicodeString(&Name, PROTOCOL_NAME);    // Protocol name
			PChars40.Name 							= Name;
			PChars40.OpenAdapterCompleteHandler 	= ProtocolOpenAdapterComplete4;
			PChars40.CloseAdapterCompleteHandler 	= ProtocolCloseAdapterComplete4;
			PChars40.SendCompleteHandler 			= ProtocolSendComplete4;
			PChars40.TransferDataCompleteHandler 	= ProtocolTransferDataComplete4;
    
			PChars40.ResetCompleteHandler 			= ProtocolResetComplete4;
			PChars40.RequestCompleteHandler 		= ProtocolRequestComplete4;
			PChars40.ReceiveHandler 				= ProtocolReceive4;
			PChars40.ReceiveCompleteHandler 		= ProtocolReceiveComplete4;
			PChars40.StatusHandler 					= ProtocolStatus4;
			PChars40.StatusCompleteHandler 			= ProtocolStatusComplete4;
			PChars40.BindAdapterHandler 			= ProtocolBindAdapter4;
			PChars40.UnbindAdapterHandler 			= ProtocolUnbindAdapter4;
			PChars40.UnloadHandler 					= ProtocolUnloadProtocol4;

			PChars40.ReceivePacketHandler 			= ProtocolReceivePacket4;
			PChars40.PnPEventHandler				= ProtocolPNPHandler4;

			NdisRegisterProtocol(&Status,
								 &ProtHandle,
								 (PVOID)&PChars40,
								 sizeof(NDIS40_PROTOCOL_CHARACTERISTICS));
			if (Status != NDIS_STATUS_SUCCESS)
			{
				NdisIMDeregisterLayeredMiniport(DriverHandle);
				break;
			}

			NdisIMAssociateMiniport(DriverHandle, ProtHandle);

		}
		while (FALSE);
	}

    if (Status != NDIS_STATUS_SUCCESS)
    {
        NdisTerminateWrapper(NdisWrapperHandle, NULL);
		NdisFreeSpinLock(&GlobalLock);
    }

    return(Status);
}