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 IpcfOpenFileOnILockBytes( [In, MarshalAs(UnmanagedType.Interface)] ILockBytes pFileStream, [In, MarshalAs(UnmanagedType.LPStruct)] IpcPromptContext pContext, [In, MarshalAs(UnmanagedType.U4)] uint dwFlags, [Out] out SafeInformationProtectionFileHandle fileHandle);
internal static extern int IpcfReadFile( [In] SafeInformationProtectionFileHandle handle, [In, MarshalAs(UnmanagedType.LPStruct)] IpcfFileRange pDataRange, [In, MarshalAs(UnmanagedType.LPArray)] byte[] pvBuffer, ref ulong cbBufferSize);