Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I view zs file in tears of the kingdom #591

Closed
zrzrv5 opened this issue May 3, 2023 · 11 comments
Closed

How do I view zs file in tears of the kingdom #591

zrzrv5 opened this issue May 3, 2023 · 11 comments

Comments

@zrzrv5
Copy link

zrzrv5 commented May 3, 2023

Hi, i want to view some byml.zs file, but the toolbox cannot decompress it.

ZstdNet.ZstdException: Dictionary mismatch
at ZstdNet.ReturnValueExtensions.ThrowException(UIntPtr returnValue, String message)
at ZstdNet.ReturnValueExtensions.EnsureZstdSuccess(UIntPtr returnValue)
at ZstdNet.Decompressor.Unwrap(ArraySegment1 src, Byte[] dst, Int32 offset, Boolean bufferSizePrecheck) at ZstdNet.Decompressor.Unwrap(ArraySegment1 src, Int32 maxDecompressedSize)
at ZstdNet.Decompressor.Unwrap(Byte[] src, Int32 maxDecompressedSize)
at Toolbox.Library.Zstb.SDecompress(Byte[] b)
at Toolbox.Library.Zstb.Decompress(Stream stream)
at Toolbox.Library.IO.CompressionMenus.SaveFileForCompression(Boolean Compress, String[] fileNames, ICompressionFormat compressionFormat)

@zrzrv5 zrzrv5 changed the title byml file in tears of the kingdom How do I view zs file in tears of the kingdom May 3, 2023
@mdtauk
Copy link

mdtauk commented May 3, 2023

I think there was some kind of buffer size issue from what I understand. It must be some new form of Zstandard compression right?

tried to open a bfarc.zs file

ZstdNet.ZstdException: Dictionary mismatch
   at ZstdNet.ReturnValueExtensions.ThrowException(UIntPtr returnValue, String message)
   at ZstdNet.ReturnValueExtensions.EnsureZstdSuccess(UIntPtr returnValue)
   at ZstdNet.Decompressor.Unwrap(ArraySegment`1 src, Byte[] dst, Int32 offset, Boolean bufferSizePrecheck)
   at ZstdNet.Decompressor.Unwrap(ArraySegment`1 src, Int32 maxDecompressedSize)
   at ZstdNet.Decompressor.Unwrap(Byte[] src, Int32 maxDecompressedSize)
   at Toolbox.Library.Zstb.SDecompress(Byte[] b)
   at Toolbox.Library.Zstb.Decompress(Stream stream)
   at Toolbox.Library.IO.CompressionMenus.SaveFileForCompression(Boolean Compress, String[] fileNames, ICompressionFormat compressionFormat)

I tried using a QuickBMS zs script

  offset           filesize   filename
--------------------------------------

Error: the uncompressed data (4294967294) is bigger than the allocated buffer (5604608)

Last script line before the error or that produced the error:
  11  CLog MEMORY_FILE 0 ZSIZE ZSIZE

Press RETURN to quit

@zoeysaurusrex
Copy link

zoeysaurusrex commented May 5, 2023

For the ones that won't open, you need to open ZsDic.zs from the Pack folder, then use the *.dic files with zstd from console to unpack them

@mdtauk
Copy link

mdtauk commented May 5, 2023

For the ones that won't open, you need to open ZsDic.zs from the Pack folder, then use the *.dic files with zstd from console to unpack them

How would you do that with Font/Font.Nin_NX_NVN.bfarc.zs

@kxs-exe
Copy link

kxs-exe commented May 5, 2023

For the ones that won't open, you need to open ZsDic.zs from the Pack folder, then use the *.dic files with zstd from console to unpack them

I was able to unpack stuff externally with zstd, thanks to this. But i have abolutely no Idea how to make zstd in Toolbox use these dictionarys. Any reccomendations?

@blanc-cake
Copy link

blanc-cake commented May 5, 2023

For anyone needing a step-by-step guide -

  1. Download and unzip the latest zstd release from the ZStandard releases page.
  2. Using either zstd.exe or Switch Toolbox, decompress Pack/ZsDic.pack.zs to get ZsDic.pack:
    With zstd -
    zstd --decompress ZsDic.pack.zs -o ZsDic.pack
    With Switch Toolbox -
    Tools > Compression > ZSTD > Decompress, pick ZsDic.pack.zs and save as ZsDic.pack.
  3. Open ZsDic.pack in Switch-Toolbox, and extract the 3 *.zsdic dictionary files inside.

Using these dictionaries with zstd.exe, you can decompress different ZS files for use with Switch Toolbox.
For example:

  • zstd --decompress Font.Nin_NX_NVN.bfarc.zs -D zs.zsdic -o Font.Nin_NX_NVN.bfarc
  • zstd --decompress Bootup.Nin_NX_NVN.pack.zs -D pack.zsdic -o Bootup.Nin_NX_NVN.pack
  • zstd --decompress Dungeon151_Static.bcett.byml.zs -D bcett.byml.zsdic -o Dungeon151_Static.bcett.byml

@ctvicks
Copy link

ctvicks commented May 5, 2023

Its not the same format but does anyone know how to decompress .mc files?

@mdtauk
Copy link

mdtauk commented May 5, 2023

  • zstd --decompress Font.Nin_NX_NVN.bfarc.zs -D zs.zsdic -o Font.Nin_NX_NVN.bfarc

Thank you for posting this. Hopefully Switch Toolbox can add support for Zstd with custom dictionary in the future :D

@zrzrv5 zrzrv5 closed this as completed May 5, 2023
@snoandpetals
Copy link

How would I properly re-compress the file for use in ToTK?

@ArchLeaders
Copy link

You can use https://github.com/TotkMods/Totk.ZstdTool for compression and decompression

@KillzXGaming
Copy link
Owner

KillzXGaming commented May 14, 2023

A fix for this has been added. Open .pack file with this tool.

image

Extract all the files inside into Lib/ZstdDictionaries folder of this tool.

image

Files will now load properly as is.

@ObscenityIB
Copy link

ObscenityIB commented May 30, 2023

None of these tools can unpack the ZsDic.pack.zs files.

Toolbox

ZstdNet.ZstdException: Can't create buffer for data with unspecified decompressed size (provide your own buffer to Unwrap instead)
   at ZstdNet.Decompressor.Unwrap(ArraySegment`1 src, Int32 maxDecompressedSize)
   at ZstdNet.Decompressor.Unwrap(Byte[] src, Int32 maxDecompressedSize)
   at Toolbox.Library.Zstb.SDecompress(Byte[] b)
   at Toolbox.Library.Zstb.Decompress(Stream stream)
   at Toolbox.Library.IO.CompressionMenus.SaveFileForCompression(Boolean Compress, String[] fileNames, ICompressionFormat compressionFormat)

ZSTD Tool

System.TypeInitializationException: The type initializer for 'Totk.ZStdTool.Helpers.ZStdHelper' threw an exception.
 ---> ZstdSharp.ZstdException: Decompressed content size cannot be determined (e.g. invalid magic number, srcSize too small)
   at ZstdSharp.ThrowHelper.EnsureContentSizeOk(UInt64 returnValue)
   at ZstdSharp.Decompressor.GetDecompressedSize(ReadOnlySpan`1 src)
   at ZstdSharp.Decompressor.Unwrap(ReadOnlySpan`1 src, Int32 maxDecompressedSize)
   at Totk.ZStdTool.Helpers.ZStdHelper..cctor() in D:\a\Totk.ZStdTool\Totk.ZStdTool\src\Helpers\ZStdHelper.cs:line 17
   --- End of inner exception stack trace ---
   at Totk.ZStdTool.Helpers.ZStdHelper.Decompress(String file) in D:\a\Totk.ZStdTool\Totk.ZStdTool\src\Helpers\ZStdHelper.cs:line 31
   at Totk.ZStdTool.ViewModels.ShellViewModel.Decompress() in D:\a\Totk.ZStdTool\Totk.ZStdTool\src\ViewModels\ShellViewModel.cs:line 80

zstd

zstd: C:\Users\Obscenity\Downloads\NUT\x\tools\pack\ZsDic.pack.zs: unsupported format

Kinda stuck here now.

Name: ZsDic.pack.zs
Size: 108344 bytes (105 KiB)
SHA256: 4fd553186b6ada4fa3a7befd3a2198f5464e1f0fdd9c519b08d9cfd1c33297a7
SHA1: 186a8c3c8e522cbb5a4aa30e3a20a5400ec4b010

Update:
Got it to work with the base game, but not when the latest update is included.

Name: ZsDic.pack.zs
Size: 108344 bytes (105 KiB)
SHA256: b3fe439759d4ea1786d1ab8c62b75d6f713ac65ebf35c7d734f2ddfcc7a931d3
SHA1: d7d358e28f67058a5e142bf4d153df9de0b7ce42

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

11 participants