Shadowth117 / Aqua-Toolset

A series of tools primarily for PSO2 which also support some other things.
GNU General Public License v3.0
19 stars 5 forks source link

'Value cannot be null. (Parameter 'sourceArray')' or crash when decompressing some Sotc textures #1

Closed 09williamsad closed 5 months ago

09williamsad commented 5 months ago

Pre-compiled build: 4_4_2024 Source build: Latest as of 2024-05-15 OS: Windows 11 Pro 23H2 IDE: Visual Studio 2022

The "Try to Decompress Shadow of the Colossus file" function has two errors I have encountered for some ctxc and ctxr files. _ps4.zip For the ctxc files in the attached zip from "\textures\biome\plains_brown_ps4", it can be "Value cannot be null. (Parameter 'sourceArray')" or the model tool will hard crash. From running the code, it appears the hard crash is caused by a AccessViolationException.

I am able to decompress all the textures before plains_brown, so this does not appear to be a user error issue. The only modification I have made to the code is to replace the file selection with a string array, for batch decompression without having all files in one folder.

The null exception: System.ArgumentNullException: Value cannot be null. (Parameter 'sourceArray') at System.Array.Copy(Array sourceArray, Int32 sourceIndex, Array destinationArray, Int32 destinationIndex, Int32 length, Boolean reliable) at System.Array.Copy(Array sourceArray, Int32 sourceIndex, Array destinationArray, Int32 destinationIndex, Int32 length) at AquaModelTool.AquaModelTool.tryToDecompressShadowOfTheColossusFileToolStripMenuItem_Click(Object sender, EventArgs e) in C:\Users\Shadi\Downloads\GitHub\Aqua Toolset\AquaModelTool\AquaModelToolUI.cs:line 6064 at System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e) at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e) at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e) at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea) at System.Windows.Forms.ToolStripDropDown.OnMouseUp(MouseEventArgs mea) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Message& m) at System.Windows.Forms.ToolStrip.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, WM msg, IntPtr wparam, IntPtr lparam)

Hard crash log from the Windows Event Viewer: Faulting application name: AquaModelTool.exe, version: 1.0.0.0, time stamp: 0x656f0000 Faulting module name: coreclr.dll, version: 6.0.2924.17105, time stamp: 0x65fc6ae4 Exception code: 0xc0000005 Fault offset: 0x00000000001d3c89 Faulting process ID: 0x0x4FE0 Faulting application start time: 0x0x1DA8F5B48DAC94F Faulting application path: C:\Users\adamw\Downloads\AquaToolset\net6.0-windows\AquaModelTool.exe Faulting module path: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.29\coreclr.dll Report ID: 0bc3fd51-a5f3-468c-b0c9-f30d70243364 Faulting package full name: Faulting package-relative application ID:

Application: AquaModelTool.exe CoreCLR Version: 6.0.2924.17105 .NET Version: 6.0.29 Description: The process was terminated due to an internal error in the .NET Runtime at IP 00007FFC66FB3C89 (00007FFC66DE0000) with exit code c0000005.

Visual Studio exception output: 'AquaModelTool.exe' (CoreCLR: clrhost): Loaded 'C:\Users\adamw\Downloads\Aqua-Toolset-main\AquaModelTool\bin\Debug\net6.0-windows\ZamboniLib.dll'. Symbols loaded. An unhandled exception of type 'System.AccessViolationException' occurred in ZamboniLib.dll Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

09williamsad commented 5 months ago

Dmnslyrx8 over on Reshax informed me that I have been trying to decompress decompressed textures. So this is a case of user error/misunderstanding.

So the error/crash can be prevented by incorporating a check for the supplied file/s. If file starts with hex 8C 0A / ASCII Œ, then continue with decompression. Otherwise, do not decompress and inform user that the file is not compressed.

Shadowth117 commented 4 months ago

Just a note, I made the program only attempt decompression now if a file appears to have compression. But past that, textures can also be handled directly without prior decompression via this same program now, so hopefully that smoothens things out a great deal.