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(kmdf), InitFreeDeviceCreate(kmdf), InitFreeDeviceCreateType2(kmdf), InitFreeDeviceCreateType4(kmdf), KmdfIrql(kmdf), KmdfIrql2(kmdf), KmdfIrqlExplicit(kmdf)

추가 정보

WDFDEVICE_INIT

WDF_OBJECT_ATTRIBUTES_INIT

WdfControlDeviceInitSetShutdownNotification

WdfControlFinishInitializing

WdfDeviceCreate

WdfDeviceInitAssignName

WdfDeviceInitAssignSDDLString