Exemplo n.º 1
0
        public static byte[] IpcfReadFile(SafeInformationProtectionFileHandle handle, ulong offset, ulong bytesToRead)
        {
            IpcfFileRange fileRange = new IpcfFileRange(offset, bytesToRead);

            byte[] buffer     = new byte[bytesToRead];
            ulong  bufferSize = bytesToRead;
            int    hr         = UnsafeFileApiMethods.IpcfReadFile(handle, fileRange, buffer, ref bufferSize);

            SafeNativeMethods.ThrowOnErrorCode(hr);
            if (bytesToRead != bufferSize)
            {
                Array.Resize(ref buffer, (int)bufferSize);
            }
            return(buffer);
        }
 internal static extern int IpcfReadFile(
     [In] SafeInformationProtectionFileHandle handle,
     [In, MarshalAs(UnmanagedType.LPStruct)] IpcfFileRange pDataRange,
     [In, MarshalAs(UnmanagedType.LPArray)] byte[] pvBuffer,
     ref ulong cbBufferSize);