PIBIO_ENGINE_ATTACH_FN 콜백 함수(winbio_adapter.h)
엔진 어댑터가 생체 인식 단위의 처리 파이프라인에 추가되면 Windows 생체 인식 프레임워크에서 호출됩니다. 이 함수의 목적은 이후 생체 인식 작업에 필요한 초기화를 수행하는 것입니다.
구문
PIBIO_ENGINE_ATTACH_FN PibioEngineAttachFn;
HRESULT PibioEngineAttachFn(
[in, out] PWINBIO_PIPELINE Pipeline
)
{...}
매개 변수
[in, out] Pipeline
작업을 수행하는 생체 인식 단위와 연결된 WINBIO_PIPELINE 구조체에 대한 포인터입니다.
반환 값
함수가 성공하면 S_OK를 반환합니다. 함수가 실패하는 경우 오류를 나타내려면 다음 HRESULT 값 중 하나를 반환해야 합니다.
반환 코드 | 설명 |
---|---|
|
Pipeline 인수는 NULL일 수 없습니다. |
|
메모리가 부족하여 작업을 완료할 수 없습니다. |
|
Pipeline 인수가 가리키는 WINBIO_PIPELINE 구조체의 EngineContext 멤버가 NULL이 아니거나 EngineHandle 멤버가 INVALID_HANDLE_VALUE 설정되지 않았습니다. |
설명
이 함수는 생체 인식 단위에 대해 스토리지 어댑터를 초기화하기 전에 호출됩니다. 따라서 이 함수는 파이프라인 개체의 StorageInterface 멤버가 가리키는 WINBIO_STORAGE_INTERFACE 구조체에서 참조하는 함수를 호출해서는 안 됩니다.
이 함수를 구현할 때 어댑터에 필요한 모든 리소스를 할당 및 관리하고 생체 인식 단위 파이프라인에 연결해야 합니다. 이렇게 하려면 힙에 프라이빗 WINBIO_ENGINE_CONTEXT 구조를 할당하고, 초기화하고, 파이프라인 개체의 EngineContext 멤버에서 주소를 설정합니다.
이 함수에서 사용하는 엔진 어댑터 리소스를 만들고 초기화하는 동안 오류가 발생하는 경우 반환하기 전에 필요한 정리를 수행해야 합니다.
이 함수가 호출될 때 EngineContext 필드가 NULL 이 아닌 경우 파이프라인이 제대로 초기화되지 않았으며 windows 생체 인식 프레임워크에 문제를 알리기 위해 WINBIO_E_INVALID_DEVICE_STATE 반환해야 합니다.
마찬가지로 이 함수를 호출할 때 EngineHandle 필드에 INVALID_HANDLE_VALUE 포함되어 있지 않으면 WINBIO_E_INVALID_DEVICE_STATE 반환해야 합니다.
예제
다음 의사 코드는 이 함수의 가능한 구현 중 하나를 보여 줍니다. 이 예제는 컴파일되지 않습니다. 목적에 맞게 조정해야 합니다.
//////////////////////////////////////////////////////////////////////////////////////////
//
// EngineAdapterAttach
//
// Purpose:
// Performs any initialization required for later biometric operations.
//
// Parameters:
// Pipeline - Pointer to a WINBIO_PIPELINE structure associated with
// the biometric unit performing the operation.
//
static HRESULT
WINAPI
EngineAdapterAttach(
__inout PWINBIO_PIPELINE Pipeline
)
{
HRESULT hr = S_OK;
// Verify that the Pipeline parameter is not NULL.
if (!ARGUMENT_PRESENT(Pipeline))
{
hr = E_POINTER;
goto cleanup;
}
// Retrieve the context from the pipeline.
PWINBIO_ENGINE_CONTEXT newContext = NULL;
// Call a custom function (_AdapterAlloc) to allocate memory to hold the
// engine adapter context.
newContext = (PWINBIO_ENGINE_CONTEXT)_AdapterAlloc(sizeof(WINBIO_ENGINE_CONTEXT));
if (newContext == NULL)
{
E_OUTOFMEMORY;
goto cleanup;
}
// Clear the context memory.
ZeroMemory(newContext, sizeof(WINBIO_ENGINE_CONTEXT));
// Initialize any required context fields.
newContext->SomeField = SomeSpecialValue;
newContext->SomePointerField = _AdapterAlloc(sizeof(SOME_STRUCTURE));
if (newContext->SomePointerField == NULL)
{
E_OUTOFMEMORY;
goto cleanup;
}
// If your adapter supports software-based template hashing, implement the
// following custom function to open a SHA1 hash object handle and store
// the handle in the adapter context. Use Cryptography Next Generation (CNG)
// functions to create the SHA1 hash object.
hr = _AdapterInitializeCrypto(newContext);
if (FAILED(hr))
{
goto cleanup;
}
// If initialization completes successfully, attach the engine context to the
// processing pipeline of the biometric unit.
Pipeline->EngineContext = newContext;
newContext = NULL;
cleanup:
if (FAILED(hr))
{
// If a new context has been created, release any memory
// pointed to by various data members in the context and
// then release the context. The following example assumes
// that your adapter contains a handle
// for a hash object and a pointer to another object.
if (newContext != NULL)
{
// Close any open CNG handles and release the hash object memory.
_AdapterCleanupCrypto(newContext);
// Release any other object pointed to by the context.
if (newContext->SomePointerField != NULL)
{
_AdapterRelease(newContext->SomePointerField);
}
// Release the context
_AdapterRelease(newContext);
}
}
return hr;
}
요구 사항
지원되는 최소 클라이언트 | Windows 7 [데스크톱 앱만 해당] |
지원되는 최소 서버 | Windows Server 2008 R2 [데스크톱 앱만 해당] |
대상 플랫폼 | Windows |
헤더 | winbio_adapter.h(Winbio_adapter.h 포함) |