CryptUnprotectData function crypt32

Win32Result<bool> CryptUnprotectData(
  1. Pointer<CRYPT_INTEGER_BLOB> pDataIn,
  2. Pointer<Pointer<Utf16>>? ppszDataDescr,
  3. Pointer<CRYPT_INTEGER_BLOB>? pOptionalEntropy,
  4. Pointer<CRYPTPROTECT_PROMPTSTRUCT>? pPromptStruct,
  5. int dwFlags,
  6. Pointer<CRYPT_INTEGER_BLOB> pDataOut,
)

Decrypts and does an integrity check of the data in a DATA_BLOB structure.

To learn more, see learn.microsoft.com/windows/win32/api/dpapi/nf-dpapi-cryptunprotectdata.

Implementation

Win32Result<bool> CryptUnprotectData(
  Pointer<CRYPT_INTEGER_BLOB> pDataIn,
  Pointer<Pointer<Utf16>>? ppszDataDescr,
  Pointer<CRYPT_INTEGER_BLOB>? pOptionalEntropy,
  Pointer<CRYPTPROTECT_PROMPTSTRUCT>? pPromptStruct,
  int dwFlags,
  Pointer<CRYPT_INTEGER_BLOB> pDataOut,
) {
  resolveGetLastError();
  final result_ = _CryptUnprotectData(
    pDataIn,
    ppszDataDescr ?? nullptr,
    pOptionalEntropy ?? nullptr,
    nullptr,
    pPromptStruct ?? nullptr,
    dwFlags,
    pDataOut,
  );
  return .new(value: result_ != FALSE, error: GetLastError());
}