From 1f02e9d41d9e628cc1fc0cc8a7aab841b07b8122 Mon Sep 17 00:00:00 2001 From: Maschell Date: Wed, 24 Apr 2019 13:27:54 +0200 Subject: [PATCH] Give the NUSDataProvider implementation a hint to limit the length of the content stream --- .../FSTDataProviderNUSTitle.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/de/mas/wiiu/jnus/implementations/FSTDataProviderNUSTitle.java b/src/de/mas/wiiu/jnus/implementations/FSTDataProviderNUSTitle.java index b9a8e80..43cb5ab 100644 --- a/src/de/mas/wiiu/jnus/implementations/FSTDataProviderNUSTitle.java +++ b/src/de/mas/wiiu/jnus/implementations/FSTDataProviderNUSTitle.java @@ -119,7 +119,26 @@ public class FSTDataProviderNUSTitle implements FSTDataProvider, HasNUSTitle { NUSDataProvider dataProvider = title.getDataProvider(); - InputStream in = dataProvider.getInputStreamFromContent(c, fileOffsetBlock); + Optional readFilesize = Optional.empty(); + if (c.isHashed()) { + long offsetInBlock = fileOffset - ((fileOffsetBlock / 0x10000) * 0xFC00); + if (offsetInBlock + fileSize < 0xFC00) { + readFilesize = Optional.of(0x10000L); + } else { + long curVal = 0x10000; + long missing = (fileSize - (0xFC00 - offsetInBlock)); + + curVal += (missing / 0xFC00) * 0x10000; + + if (missing % 0xFC00 > 0) { + curVal += 0x10000; + } + + readFilesize = Optional.of(curVal); + } + } + + InputStream in = dataProvider.getInputStreamFromContent(c, fileOffsetBlock, readFilesize); try { NUSDecryption nusdecryption = new NUSDecryption(title.getTicket().get());