다음을 통해 공유


WdfControlDeviceInitAllocate 함수(wdfcontrol.h)

[KMDF에만 적용]

WdfControlDeviceInitAllocate 메서드는 드라이버가 새 컨트롤 디바이스 개체를 만들 때 사용하는 WDFDEVICE_INIT 구조를 할당합니다.

통사론

PWDFDEVICE_INIT WdfControlDeviceInitAllocate(
  [in] WDFDRIVER            Driver,
  [in] const UNICODE_STRING *SDDLString
);

매개 변수

[in] Driver

프레임워크 드라이버 개체에 대한 핸들입니다.

[in] SDDLString

유니코드 문자열을 설명하는 UNICODE_STRING 구조체에 대한 포인터입니다. 이 문자열은 보안 설명자의 SDDL(보안 설명자 정의 언어) 표현입니다. 자세한 내용은 다음 설명 섹션을 참조하세요.

반환 값

WdfControlDeviceInitAllocate 작업이 성공하면 프레임워크 할당 WDFDEVICE_INIT 구조체에 대한 포인터를 반환합니다. 그렇지 않으면 메서드는 NULL반환합니다.

발언

드라이버에서 제어 디바이스 개체를 만들려면 드라이버가 WdfControlDeviceInitAllocate 호출하여 WdfDeviceCreate전달할 수 있는 WDFDEVICE_INIT 구조를 가져와야 합니다.

드라이버는 SDDL의 하위 집합을 사용하여 보안 설정을 지정할 수 있습니다. Wdmsec.h 파일은 사용할 수 있는 SDDL_DEVOBJ_Xxx형식 상수 집합을 정의합니다. 보안 설명자 및 SDDL에 대한 자세한 내용은 디바이스 개체 보안참조하세요.

WdfDeviceInitAssignSDDLString 메서드는 WdfControlDeviceInitAllocate 지정하는 보안 설정을 덮어씁니다(있는 경우).

WdfControlDeviceInitAllocate 호출하는 방법에 대한 자세한 내용은 제어 디바이스 개체를 사용하는참조하세요.

예제

다음 코드 예제에서는 DEVICE_INIT 구조를 할당하고, 디바이스 개체 이름을 할당하고, 종료 알림 콜백 함수를 등록하고, 제어 디바이스 개체를 만듭니다. WdfControlDeviceInitAllocate사용하는 더 복잡한 예제는 NONPNP 샘플 드라이버 또는 NDISProt 샘플 드라이버를 참조하세요.

PWDFDEVICE_INIT  deviceInit = NULL;
NTSTATUS  status;
WDF_OBJECT_ATTRIBUTES  objectAttribs;

deviceInit = WdfControlDeviceInitAllocate(
                                          hDriver,
                                          &SDDL_DEVOBJ_SYS_ALL_ADM_RWX_WORLD_RW_RES_R
                                          );
if (deviceInit == NULL) {
    status = STATUS_INSUFFICIENT_RESOURCES;
    goto Error;
}
status = WdfDeviceInitAssignName(
                                 deviceInit,
                                 &ntDeviceName
                                 );
if (!NT_SUCCESS(status)) {
    WdfDeviceInitFree(deviceInit);
    deviceInit = NULL;
    goto Error;
}
WdfControlDeviceInitSetShutdownNotification(
                                            deviceInit,
                                            EvtShutdownNotification,
                                            WdfDeviceShutdown
                                            );
WDF_OBJECT_ATTRIBUTES_INIT(&objectAttribs);

status = WdfDeviceCreate(
                         &deviceInit,
                         &objectAttribs,
                         &controlDevice
                         );
if (!NT_SUCCESS(status)) {
    WdfDeviceInitFree(deviceInit);
    deviceInit = NULL;
    goto Error;
}
WdfControlFinishInitializing(controlDevice);

요구 사항

요구
대상 플랫폼 보편적
최소 KMDF 버전 1.0
헤더 wdfcontrol.h(Wdf.h 포함)
라이브러리 Wdf01000.sys(프레임워크 라이브러리 버전 관리 참조)
IRQL PASSIVE_LEVEL
DDI 규정 준수 규칙 ControlDeviceInitAPI(kmdf), CtlDeviceFinishInitDeviceAdd(kmdf), CtlDeviceFinishInitDrEntry(kmdf), DoubleDeviceInitFree(kmdf), DriverCreate(kmdf), InitFreeDeviceCallback(km)df), InitFreeDeviceCreate(kmdf), InitFreeDeviceCreateType2(kmdf), InitFreeDeviceCreateType4(kmdf), KmdfIrql(kmdf), KmdfIrql2(kmdf), KmdfIrqlExplicit(kmdf)

참고 항목

WDFDEVICE_INIT

WDF_OBJECT_ATTRIBUTES_INIT

WdfControlDeviceInitSetShutdownNotification

WdfControlFinishInitializing

WdfDeviceCreate

WdfDeviceInitAssignName

WdfDeviceInitAssignSDDLString