StorageAdapterEraseDatabase function

Called by the Windows Biometric Framework to erase the database and mark it for deletion.

Syntax


HRESULT WINAPI StorageAdapterEraseDatabase(
  _Inout_  PWINBIO_PIPELINE Pipeline,
  _In_     PWINBIO_UUID DatabaseId,
  _In_     LPCWSTR FilePath,
  _In_     LPCWSTR ConnectString
);

Parameters

Pipeline [in, out]

Pointer to the WINBIO_PIPELINE structure associated with the biometric unit performing the operation.

DatabaseId [in]

A pointer to a GUID that uniquely identifies the database. This is the same GUID used to register the database in the registry.

FilePath [in]

Pointer to a NULL-terminated UNICODE string that contains the fully qualified file path for the database.

ConnectString [in]

A pointer to a NULL-terminated UNICODE connection string for the database.

Return value

If the function succeeds, it returns S_OK. If the function fails, it must return one of the following HRESULT values to indicate the error.

Return codeDescription
E_POINTER

A mandatory pointer argument is NULL.

WINBIO_E_DATABASE_CORRUPTED

The DatabaseId parameter is not the same as the one used when creating the database.

WINBIO_E_DATABASE_CANT_FIND

The specified database cannot be found.

WINBIO_E_INVALID_DEVICE_STATE

The StorageContext member of the pipeline object is NULL.

 

Examples

The following pseudocode shows one possible implementation of this function. The example does not compile. You must adapt it to suit your purpose.


/////////////////////////////////////////////////////////////////////////////////////////
//
// StorageAdapterEraseDatabase
//
// Purpose:
//      Erases the database and marks it for deletion.
//
// Parameters:
//      Pipeline      - Pointer to a WINBIO_PIPELINE structure associated with 
//                      the biometric unit performing the operation.
//      DatabaseId    - Pointer to a GUID that uniquely identifies the database.
//      FilePath      - Pointer to the database file path.
//      ConnectString - Pointer to the database connection string.
//
static HRESULT
WINAPI
StorageAdapterEraseDatabase(
    __inout PWINBIO_PIPELINE Pipeline,
    __in PWINBIO_UUID DatabaseId,
    __in LPCWSTR FilePath,
    __in LPCWSTR ConnectString
   )
{
    HRESULT hr = S_OK;
    HANDLE fileHandle = INVALID_HANDLE_VALUE;
    BOOL fileOpen = FALSE;
    struct _MY_ADAPTER_DPAPI_DATA protectedData = {0};

    // Check that pointer arguments are not NULL.
    if (!ARGUMENT_PRESENT(Pipeline)   ||
        !ARGUMENT_PRESENT(DatabaseId) ||
        !ARGUMENT_PRESENT(FilePath)   ||
        !ARGUMENT_PRESENT(ConnectString) )
    {
        hr = E_POINTER;
        goto cleanup;
    }

    // Retrieve the context from the pipeline.
    PWINBIO_STORAGE_CONTEXT storageContext = 
           (PWINBIO_STORAGE_CONTEXT)Pipeline->StorageContext;

    // Verify the pipeline state.
    if (storageContext == NULL ||
        Pipeline->StorageHandle != INVALID_HANDLE_VALUE)
    {
        hr = WINBIO_E_INVALID_DEVICE_STATE;
        goto cleanup;
    }

    // Call a custom function (_OpenDatabase) to open the database.
    // The database must be opened for EXCLUSIVE access. The custom
    // function should also verify that the database ID specified on 
    // input is the same as the ID used to create the database. If 
    // it is not, return WINBIO_E_DATABASE_CORRUPTED.
    hr = _OpenDatabase(
            DatabaseId,
            FilePath,
            TRUE,           // Exclusive READ/WRITE/DELETE access
            &fileHandle,
            &protectedData
            );
    if (FAILED(hr))
    {
        goto cleanup;
    }
    fileOpen = TRUE;

    // Call a custom function (_EraseDatabase) that marks the database
    // for deletion the next time the file is closed.
    hr = _EraseDatabase( fileHandle );

cleanup:

    // Call the SecureZeroMemory function to overwrite the template encryption key 
    // on the stack.
    SecureZeroMemory( &protectedData, sizeof(struct _MY_ADAPTER_DPAPI_DATA));

    if (fileOpen)
    {
        CloseHandle(fileHandle);
        fileHandle = INVALID_HANDLE_VALUE;
    }

    return hr;
}


Requirements

Minimum supported client

Windows 7 [desktop apps only]

Minimum supported server

Windows Server 2008 R2 [desktop apps only]

Header

Winbio_adapter.h (include Winbio_adapter.h)

See also

Plug-in Functions
StorageAdapterCloseDatabase
StorageAdapterCreateDatabase
StorageAdapterOpenDatabase

 

 

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.