Exemplo n.º 1
0
 public static extern void IDataWriteToSelfEncryptorNative(
     IntPtr appPtr,
     ulong seHandle,
     IntPtr data,
     IntPtr size,
     IntPtr self,
     IDataWriteToSelfEncryptorCb callback);
Exemplo n.º 2
0
 public void IDataWriteToSelfEncryptor(
     IntPtr appPtr,
     ulong seHandle,
     IntPtr data,
     IntPtr size,
     IntPtr self,
     IDataWriteToSelfEncryptorCb callback)
 {
     IDataWriteToSelfEncryptorNative(appPtr, seHandle, data, size, self, callback);
 }
Exemplo n.º 3
0
        public static Task <object> IDataWriteToSelfEncryptorAsync(ulong seHandle, List <byte> data)
        {
            var tcs     = new TaskCompletionSource <object>();
            var dataPtr = data.ToIntPtr();
            IDataWriteToSelfEncryptorCb callback = null;

            callback = (self, result) => {
                if (result.ErrorCode != 0)
                {
                    tcs.SetException(result.ToException());
                    CallbackManager.Unregister(callback);
                    return;
                }

                tcs.SetResult(null);
                CallbackManager.Unregister(callback);
            };

            CallbackManager.Register(callback);
            NativeBindings.IDataWriteToSelfEncryptor(Session.AppPtr, seHandle, dataPtr, (IntPtr)data.Count, Session.UserData, callback);
            Marshal.FreeHGlobal(dataPtr);

            return(tcs.Task);
        }