From 79365a9fe6b285c3d8161a02e548a341c9cd048d Mon Sep 17 00:00:00 2001 From: Maschell Date: Tue, 30 Apr 2019 12:04:49 +0200 Subject: [PATCH] Caclulate how much of the stream actually is needed --- .../FSTDataProviderNUSTitle.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/de/mas/wiiu/jnus/implementations/FSTDataProviderNUSTitle.java b/src/de/mas/wiiu/jnus/implementations/FSTDataProviderNUSTitle.java index 860932b..2be617b 100644 --- a/src/de/mas/wiiu/jnus/implementations/FSTDataProviderNUSTitle.java +++ b/src/de/mas/wiiu/jnus/implementations/FSTDataProviderNUSTitle.java @@ -110,12 +110,21 @@ public class FSTDataProviderNUSTitle implements FSTDataProvider, HasNUSTitle { streamFilesize = curVal; } } else { - streamOffset = (payloadOffset / 0x8000) * 0x8000; - // We need the previous IV if we don't start at the first block. - if (payloadOffset >= 0x8000 && payloadOffset % 0x8000 == 0) { - streamOffset -= 16; + if (size != entry.getFileSize()) { + streamOffset = (payloadOffset / 0x8000) * 0x8000; + + // We need the missing bytes of the previous blocks + the size we want to read. + streamFilesize = size; + long offsetInBlock = offset - streamOffset; + streamFilesize += offsetInBlock; + + // We need the previous IV if we don't start at the first block. + if (payloadOffset >= 0x8000 && payloadOffset % 0x8000 == 0) { + streamOffset -= 16; + streamFilesize += 16; + } } - streamFilesize = c.getEncryptedFileSize(); + } NUSDataProvider dataProvider = title.getDataProvider();