하위 서비스 만들기

하위 서비스라는 용어는 다음 표에 나열된 네 가지 구성 요소의 바인딩을 설명하는 데 사용됩니다.

구성 요소 Description

Miniport 개체

미니포트 드라이버의 IMiniportXxx 인터페이스를 노출하는 개체

Port 개체

포트 드라이버의 IPortXxx 인터페이스를 노출하는 개체

리소스 목록 개체

하위 서비스에 할당된 어댑터 드라이버 리소스 목록을 포함하는 개체

참조 문자열

필터를 만드는 동안 하위 서비스를 지정하기 위해 디바이스 경로 이름에 추가된 이름

하위 서비스 IMiniportXxx 및 IPortXxx 인터페이스는 각각 기본 인터페이스 IMiniportIPort에서 상속됩니다.

PortCls 시스템 드라이버는 포트 드라이버와 미니포트 드라이버를 구분하지 않습니다. 시스템 생성 요청을 처리할 수 있는 인터페이스가 있는 포트 개체와 같은 개체만 있으면 됩니다.

마찬가지로 PortCls는 리소스 관리에 직접 관여하지 않습니다. 요청 처리기(포트 드라이버)를 리소스 목록에 바인딩하기만 하면 됩니다. 어댑터 드라이버는 포트, 미니포트 및 리소스 목록 개체를 함께 바인딩해야 합니다.

다음 코드 예제에서는 어댑터 드라이버가 이러한 작업을 수행하는 방법을 보여 줍니다.

  //
  // Instantiate the port by calling a function supplied by PortCls.
  //
  PPORT    port;
  NTSTATUS ntStatus = PcNewPort(&port, PortClassId);

  if (NT_SUCCESS(ntStatus))
  {
      PUNKNOWN miniport;
      //
      // Create the miniport object.
      //
      if (MiniportCreate)   // a function to create a proprietary miniport
      {
          ntStatus = MiniportCreate(&miniport,
                                    MiniportClassId, NULL, NonPagedPool);
      }
      else   // Ask PortCls for one of its built-in miniports.
      {
          ntStatus = PcNewMiniport((PMINIPORT*)&miniport,
                                   MiniportClassId);
      }

      if (NT_SUCCESS(ntStatus))
      {
          //
          // Bind the port, miniport, and resources.
          //
          ntStatus = port->Init(DeviceObject,
                                Irp, miniport, UnknownAdapter, ResourceList);
          if (NT_SUCCESS(ntStatus))
          {
              //
              // Hand the port driver and the reference
              // string to PortCls.
              //
              ntStatus = PcRegisterSubdevice(DeviceObject,
                                             Name, port);
          }

          //
          // We no longer need to reference the miniport driver.
          // Either the port driver now references it,
          // or binding failed and it should be deleted.
          //
          miniport->Release();
      }

      //
      // Release the reference that existed when PcNewPort() gave us
      // the pointer in the first place. This reference must be released
      // regardless of whether the binding of the port and miniport
      // drivers succeeded.
      //
      port->Release();
  }

이전 코드 예제의 PortCls 함수 호출에 대한 자세한 내용은 PcNewPort, PcNewMiniportPcRegisterSubdevice를 참조하세요.