ifndef __DPAPI_H__
define __DPAPI_H__

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)

ifndef CRYPTO_BLOBS_DEFINED
CRYPTO_BLOBS_DEFINED equ 1
CRYPTOAPI_BLOB		STRUC
cbData			dd ?
pbData			LPBYTE ?
CRYPT_INTEGER_BLOB	ENDS
PCRYPT_INTEGER_BLOB	typedef ptr CRYPT_INTEGER_BLOB
CRYPT_UINT_BLOB		typedef CRYPT_INTEGER_BLOB
PCRYPT_UINT_BLOB	typedef ptr CRYPT_INTEGER_BLOB
CRYPT_OBJID_BLOB	typedef CRYPT_INTEGER_BLOB
PCRYPT_OBJID_BLOB	typedef ptr CRYPT_INTEGER_BLOB
CERT_NAME_BLOB		typedef CRYPT_INTEGER_BLOB
PCERT_NAME_BLOB		typedef ptr CRYPT_INTEGER_BLOB
CERT_RDN_VALUE_BLOB	typedef CRYPT_INTEGER_BLOB
PCERT_RDN_VALUE_BLOB	typedef ptr CRYPT_INTEGER_BLOB
CERT_BLOB		typedef CRYPT_INTEGER_BLOB
PCERT_BLOB		typedef ptr CRYPT_INTEGER_BLOB
CRL_BLOB		typedef CRYPT_INTEGER_BLOB
PCRL_BLOB		typedef ptr CRYPT_INTEGER_BLOB
DATA_BLOB		typedef CRYPT_INTEGER_BLOB
PDATA_BLOB		typedef ptr CRYPT_INTEGER_BLOB
CRYPT_DATA_BLOB		typedef CRYPT_INTEGER_BLOB
PCRYPT_DATA_BLOB	typedef ptr CRYPT_INTEGER_BLOB
CRYPT_HASH_BLOB		typedef CRYPT_INTEGER_BLOB
PCRYPT_HASH_BLOB	typedef ptr CRYPT_INTEGER_BLOB
CRYPT_DIGEST_BLOB	typedef CRYPT_INTEGER_BLOB
PCRYPT_DIGEST_BLOB	typedef ptr CRYPT_INTEGER_BLOB
CRYPT_DER_BLOB		typedef CRYPT_INTEGER_BLOB
PCRYPT_DER_BLOB		typedef ptr CRYPT_INTEGER_BLOB
CRYPT_ATTR_BLOB		typedef CRYPT_INTEGER_BLOB
PCRYPT_ATTR_BLOB	typedef ptr CRYPT_INTEGER_BLOB
endif

szFORCE_KEY_PROTECTION	equ <"ForceKeyProtection">

dwFORCE_KEY_PROTECTION_DISABLED equ 0x0
dwFORCE_KEY_PROTECTION_USER_SELECT equ 0x1
dwFORCE_KEY_PROTECTION_HIGH equ 0x2

CRYPTPROTECT_PROMPTSTRUCT STRUC
cbSize			dd ?
dwPromptFlags		dd ?
hwndApp			HWND ?
szPrompt		LPCWSTR ?
CRYPTPROTECT_PROMPTSTRUCT ENDS
PCRYPTPROTECT_PROMPTSTRUCT typedef ptr CRYPTPROTECT_PROMPTSTRUCT


CRYPTPROTECT_DEFAULT_PROVIDER equ <{ 0xdf9d8cd0, 0x1501, 0x11d1, {0x8c, 0x7a, 0x00, 0xc0, 0x4f, 0xc2, 0x97, 0xeb} }>

CRYPTPROTECT_PROMPT_ON_UNPROTECT equ 0x1
CRYPTPROTECT_PROMPT_ON_PROTECT equ 0x2
CRYPTPROTECT_PROMPT_RESERVED equ 0x04
CRYPTPROTECT_PROMPT_STRONG equ 0x08
CRYPTPROTECT_PROMPT_REQUIRE_STRONG equ 0x10

CRYPTPROTECT_UI_FORBIDDEN equ 0x1
CRYPTPROTECT_LOCAL_MACHINE equ 0x4
CRYPTPROTECT_CRED_SYNC	equ 0x8
CRYPTPROTECT_AUDIT	equ 0x10
CRYPTPROTECT_NO_RECOVERY equ 0x20
CRYPTPROTECT_VERIFY_PROTECTION equ 0x40
CRYPTPROTECT_CRED_REGENERATE equ 0x80

CRYPTPROTECT_FIRST_RESERVED_FLAGVAL equ 0x0FFFFFFF
CRYPTPROTECT_LAST_RESERVED_FLAGVAL equ 0xFFFFFFFF

CryptProtectData proto WINAPI :ptr, :LPCWSTR, :ptr, :ptr, :ptr, :DWORD, :ptr
CryptUnprotectData proto WINAPI :ptr, :ptr, :ptr, :ptr, :ptr, :DWORD, :ptr

if (NTDDI_VERSION GE NTDDI_WIN8)
CryptProtectDataNoUI proto WINAPI :ptr, :LPCWSTR, :ptr, :ptr, :ptr, :DWORD, :ptr, :DWORD, :ptr
CryptUnprotectDataNoUI proto WINAPI :ptr, :ptr, :ptr, :ptr, :ptr, :DWORD, :ptr, :DWORD, :ptr
endif
if (NTDDI_VERSION GE NTDDI_VISTA)
CryptUpdateProtectedState proto WINAPI :PSID, :LPCWSTR, :DWORD, :ptr, :ptr
endif

CRYPTPROTECTMEMORY_BLOCK_SIZE equ 16
CRYPTPROTECTMEMORY_SAME_PROCESS equ 0x00
CRYPTPROTECTMEMORY_CROSS_PROCESS equ 0x01
CRYPTPROTECTMEMORY_SAME_LOGON equ 0x02

CryptProtectMemory proto WINAPI :ptr, :DWORD, :DWORD
CryptUnprotectMemory proto WINAPI :ptr, :DWORD, :DWORD
endif
endif
