#ifndef __DPAPI_H__
#define __DPAPI_H__
#if (_MSC_VER > 1020)
#pragma once
#endif
#if (NTDDI_VERSION >= NTDDI_WIN8)
#if !defined(DPAPI_IMP)
#define DPAPI_IMP
#endif
#else
#if !defined(_CRYPT32_)
#define DPAPI_IMP DECLSPEC_IMPORT
#else
#define DPAPI_IMP
#endif
#endif //(NTDDI_VERSION >= NTDDI_WIN7)
#ifdef __cplusplus
extern
"C"
{
#endif
#pragma region App Family or OneCore Family
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM)
#ifndef CRYPTO_BLOBS_DEFINED
#define CRYPTO_BLOBS_DEFINED
typedef struct _CRYPTOAPI_BLOB {
DWORD cbData;
_Field_size_bytes_(cbData) BYTE *pbData;
} CRYPT_INTEGER_BLOB, *PCRYPT_INTEGER_BLOB,
CRYPT_UINT_BLOB, *PCRYPT_UINT_BLOB,
CRYPT_OBJID_BLOB, *PCRYPT_OBJID_BLOB,
CERT_NAME_BLOB, *PCERT_NAME_BLOB,
CERT_RDN_VALUE_BLOB, *PCERT_RDN_VALUE_BLOB,
CERT_BLOB, *PCERT_BLOB,
CRL_BLOB, *PCRL_BLOB,
DATA_BLOB, *PDATA_BLOB,
CRYPT_DATA_BLOB, *PCRYPT_DATA_BLOB,
CRYPT_HASH_BLOB, *PCRYPT_HASH_BLOB,
CRYPT_DIGEST_BLOB, *PCRYPT_DIGEST_BLOB,
CRYPT_DER_BLOB, *PCRYPT_DER_BLOB,
CRYPT_ATTR_BLOB, *PCRYPT_ATTR_BLOB;
#endif
#define szFORCE_KEY_PROTECTION "ForceKeyProtection"
#define dwFORCE_KEY_PROTECTION_DISABLED 0x0
#define dwFORCE_KEY_PROTECTION_USER_SELECT 0x1
#define dwFORCE_KEY_PROTECTION_HIGH 0x2
typedef
struct
_CRYPTPROTECT_PROMPTSTRUCT
{
;
;
;
;
}
CRYPTPROTECT_PROMPTSTRUCT
, *
PCRYPTPROTECT_PROMPTSTRUCT
;
#define CRYPTPROTECT_DEFAULT_PROVIDER { 0xdf9d8cd0, 0x1501, 0x11d1, {0x8c, 0x7a, 0x00, 0xc0, 0x4f, 0xc2, 0x97, 0xeb} }
#define CRYPTPROTECT_PROMPT_ON_UNPROTECT 0x1 // 1<<0
#define CRYPTPROTECT_PROMPT_ON_PROTECT 0x2 // 1<<1
#define CRYPTPROTECT_PROMPT_RESERVED 0x04 // reserved, do not use.
#define CRYPTPROTECT_PROMPT_STRONG 0x08 // 1<<3
#define CRYPTPROTECT_PROMPT_REQUIRE_STRONG 0x10 // 1<<4
#define CRYPTPROTECT_UI_FORBIDDEN 0x1
#define CRYPTPROTECT_LOCAL_MACHINE 0x4
#define CRYPTPROTECT_CRED_SYNC 0x8
#define CRYPTPROTECT_AUDIT 0x10
#define CRYPTPROTECT_NO_RECOVERY 0x20
#define CRYPTPROTECT_VERIFY_PROTECTION 0x40
#define CRYPTPROTECT_CRED_REGENERATE 0x80
#define CRYPTPROTECT_FIRST_RESERVED_FLAGVAL 0x0FFFFFFF
#define CRYPTPROTECT_LAST_RESERVED_FLAGVAL 0xFFFFFFFF
DPAPI_IMP
(
_In_opt_ LPCWSTR szDataDescr,
_In_opt_ DATA_BLOB* pOptionalEntropy,
_Reserved_ PVOID pvReserved,
_In_opt_ CRYPTPROTECT_PROMPTSTRUCT* pPromptStruct,
CRYPTPROTECT_PROMPTSTRUCT
*
,
_Out_ DATA_BLOB* pDataOut // out encr blob
);
DPAPI_IMP
(
_In_ DATA_BLOB* pDataIn, // in encr blob
_Outptr_opt_result_maybenull_ LPWSTR* ppszDataDescr, // out
_In_opt_ DATA_BLOB* pOptionalEntropy,
_Reserved_ PVOID pvReserved,
_In_opt_ CRYPTPROTECT_PROMPTSTRUCT* pPromptStruct,
CRYPTPROTECT_PROMPTSTRUCT
*
,
_Out_ DATA_BLOB* pDataOut
);
#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM) */
#pragma endregion
#pragma region Desktop Family
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
#if (NTDDI_VERSION >= NTDDI_WIN8)
(
_In_opt_ LPCWSTR szDataDescr,
_In_opt_ DATA_BLOB* pOptionalEntropy,
_Reserved_ PVOID pvReserved,
_In_opt_ CRYPTPROTECT_PROMPTSTRUCT* pPromptStruct,
CRYPTPROTECT_PROMPTSTRUCT
*
,
_In_reads_bytes_opt_(cbOptionalPassword)
const
*
,
,
_Out_ DATA_BLOB* pDataOut // out encr blob
);
(
_In_ DATA_BLOB* pDataIn, // in encr blob
_Outptr_opt_result_maybenull_ LPWSTR* ppszDataDescr, // out
_In_opt_ DATA_BLOB* pOptionalEntropy,
_Reserved_ PVOID pvReserved,
_In_opt_ CRYPTPROTECT_PROMPTSTRUCT* pPromptStruct,
CRYPTPROTECT_PROMPTSTRUCT
*
,
_In_reads_bytes_opt_(cbOptionalPassword)
const
*
,
,
_Out_ DATA_BLOB* pDataOut
);
#endif
#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
#pragma endregion
#pragma region Desktop Family or OneCore Family
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM)
#if (NTDDI_VERSION >= NTDDI_VISTA)
DPAPI_IMP
CryptUpdateProtectedState
(
_In_opt_ LPCWSTR pwszOldPassword,
_Out_opt_ DWORD *pdwSuccessCount,
_Out_opt_ DWORD *pdwFailureCount);
#endif // (NTDDI_VERSION >= NTDDI_VISTA)
#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM) */
#pragma endregion
#pragma region App Family or OneCore Family
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM)
#define CRYPTPROTECTMEMORY_BLOCK_SIZE 16
#define CRYPTPROTECTMEMORY_SAME_PROCESS 0x00
#define CRYPTPROTECTMEMORY_CROSS_PROCESS 0x01
#define CRYPTPROTECTMEMORY_SAME_LOGON 0x02
DPAPI_IMP
(
_Inout_ LPVOID pDataIn, // in out data to encrypt
_In_ DWORD cbDataIn, // multiple of CRYPTPROTECTMEMORY_BLOCK_SIZE
);
DPAPI_IMP
(
_Inout_ LPVOID pDataIn, // in out data to decrypt
_In_ DWORD cbDataIn, // multiple of CRYPTPROTECTMEMORY_BLOCK_SIZE
);
#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM) */
#pragma endregion
#ifdef __cplusplus
}
#endif
#endif // __DPAPI_H__