thcrap
thcrap copied to clipboard
configure v3: incorrect encoding conversion for search result
In https://github.com/thpatch/thcrap/blob/fd10f94d867fde403ef9008e3534a2b2e3d16274/thcrap_configure_v3/ThcrapDll.cs#L180C9-L180C9 , we assume that the members of the game_search_result
struct will contain only ASCII characters, outside of path
which is declared as IntPtr
and converted manually.
But description
can also contain UTF-8 characters. For example, we had an exe in base_tsa/version.js
for th06 with the description "Original with 紅魔郷 removed from the .dat file names", which crashed with a DBCS locale like Chinese or Japanese. We removed it as a quick and dirty fix, but we need to fix the underlying issue (and then to revert thpatch/thcrap-tsa@2e993bd ).
Some more details about the crash:
A C# System.ArgumentOutOfRangeException from https://github.com/thpatch/thcrap/blob/fd10f94d867fde403ef9008e3534a2b2e3d16274/thcrap_configure_v3/Page4.xaml.cs#L339C11-L339C11 , where we take the search results from the C++ search and convert them to C#. That one ends up at https://github.com/thpatch/thcrap/blob/fd10f94d867fde403ef9008e3534a2b2e3d16274/thcrap_configure_v3/ThcrapDll.cs#L48C51-L48C51 , calling Marshal.PtrToStructure with a ThcrapDll.game_search_result defined at https://github.com/thpatch/thcrap/blob/fd10f94d867fde403ef9008e3534a2b2e3d16274/thcrap_configure_v3/ThcrapDll.cs#L180C9-L180C9 .
Fix done. I'm keeping this issue open as a reminder to revert https://github.com/thpatch/thcrap-tsa/commit/2e993bd after the next release.