nesrak1 / UABEA

c# uabe for newer versions of unity
MIT License
1.15k stars 149 forks source link

Crash on opening a .assets file #348

Open Zirion01 opened 4 months ago

Zirion01 commented 4 months ago

Describe the bug UABEA crashes when opening a .assets file

To Reproduce Steps to reproduce the behavior:

  1. Get a copy of HuniePop's Steam files (by buying it or getting a codex crack, whatever)
  2. Open HuniePop_Data/resources.assets
  3. See error

Expected behavior The assets contained in the file display

Screenshots image

Additional context Here is the error I got from UABEA :

System.ArgumentException: The output char buffer is too small to contain the decoded characters, encoding 'Unicode (UTF-8)' fallback 'System.Text.DecoderReplacementFallback'. (Parameter 'chars')
   at System.Text.Encoding.ThrowCharsOverflow(DecoderNLS decoder, Boolean nothingDecoded)
   at System.Text.Encoding.GetCharsWithFallback(ReadOnlySpan`1 bytes, Int32 originalBytesLength, Span`1 chars, Int32 originalCharsLength, DecoderNLS decoder)
   at System.Text.UTF8Encoding.GetCharsWithFallback(ReadOnlySpan`1 bytes, Int32 originalBytesLength, Span`1 chars, Int32 originalCharsLength, DecoderNLS decoder)
   at System.Text.Encoding.GetCharsWithFallback(Byte* pOriginalBytes, Int32 originalByteCount, Char* pOriginalChars, Int32 originalCharCount, Int32 bytesConsumedSoFar, Int32 charsWrittenSoFar, DecoderNLS decoder)
   at System.Text.DecoderNLS.GetChars(Byte* bytes, Int32 byteCount, Char* chars, Int32 charCount, Boolean flush)
   at System.Text.Decoder.GetChars(ReadOnlySpan`1 bytes, Span`1 chars, Boolean flush)
   at System.IO.BinaryReader.Read()
   at System.IO.BinaryReader.ReadChar()
   at AssetsTools.NET.AssetsFileReader.ReadNullTerminated()
   at AssetsTools.NET.AssetsFileExternal.Read(AssetsFileReader reader)
   at AssetsTools.NET.AssetsFileMetadata.Read(AssetsFileReader reader, UInt32 version, Int64 dataOffset)
   at AssetsTools.NET.AssetsFileMetadata.Read(AssetsFileReader reader, AssetsFileHeader header)
   at AssetsTools.NET.AssetsFile.Read(AssetsFileReader reader)
   at AssetsTools.NET.Extra.AssetsFileInstance..ctor(Stream stream, String filePath)
   at AssetsTools.NET.Extra.AssetsManager.LoadAssetsFileCacheless(Stream stream, String path, Boolean loadDeps, BundleFileInstance bunInst)
   at AssetsTools.NET.Extra.AssetsManager.LoadAssetsFile(FileStream stream, Boolean loadDeps)
   at AssetsTools.NET.Extra.AssetsManager.LoadAssetsFile(String path, Boolean loadDeps)
   at UABEAvalonia.MainWindow.OpenFiles(String[] files) in D:\a\UABEA\UABEA\UABEAvalonia\Forms\MainWindow.axaml.cs:line 109
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object state)
   at Avalonia.Threading.SendOrPostCallbackDispatcherOperation.InvokeCore()
   at Avalonia.Threading.DispatcherOperation.Execute()
   at Avalonia.Threading.Dispatcher.ExecuteJob(DispatcherOperation job)
   at Avalonia.Threading.Dispatcher.ExecuteJobsCore(Boolean fromExplicitBackgroundProcessingCallback)
   at Avalonia.Threading.Dispatcher.Signaled()
   at Avalonia.Win32.Win32Platform.WndProc(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam)
   at Avalonia.Win32.Interop.UnmanagedMethods.DispatchMessage(MSG& lpmsg)
   at Avalonia.Win32.Win32DispatcherImpl.RunLoop(CancellationToken cancellationToken)
   at Avalonia.Threading.DispatcherFrame.Run(IControlledDispatcherImpl impl)
   at Avalonia.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   at Avalonia.Threading.Dispatcher.MainLoop(CancellationToken cancellationToken)
   at Avalonia.Controls.ApplicationLifetimes.ClassicDesktopStyleApplicationLifetime.Start(String[] args)
   at Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime(AppBuilder builder, String[] args, ShutdownMode shutdownMode)
   at UABEAvalonia.Program.Main(String[] args) in D:\a\UABEA\UABEA\UABEAvalonia\Program.cs:line 53
nesrak1 commented 4 months ago

According to #345 asked a few days ago, huniepop is unity 4, but AssetsTools.NET only supports 5 and up. I've kept is this way because A. I don't have any unity 4 games to test with B. in order to work with unity 4, it will take some work on uabea's side to check between unity 4 and unity 5 to do things differently, making things a bit more complicated. For now, this is an unsupported feature. Use UABE if you need something similar, which supports way back to unity 3.something.

Zirion01 commented 4 months ago

I could, indeed, open the assets file thanks to UABE. I feel stupid not noticing this earlier. I'd be glad the tool had a Unity 4 compatibility, because editing the text assets with UABE (on HuniePop) makes crashs happen...

nesrak1 commented 3 months ago

I'm looking into making Unity 4 support a thing in the future, but no promises.