haroohie-club / SerialLoops

An editor for Suzumiya Haruhi no Chokuretsu (The Series of Haruhi Suzumiya)
https://haroohie.club/chokuretsu/serial-loops
GNU General Public License v3.0
14 stars 6 forks source link

Drag/drop causes crashes #324

Closed jonko0493 closed 9 months ago

jonko0493 commented 9 months ago
1/14/2024 1:42:58 AM -08:00 - SERIAL LOOPS CRASH: BinaryFormatter serialization and deserialization are disabled within this application. See https://aka.ms/binaryformatter for more information.

   at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph)
   at System.Windows.DataObject.SaveObjectToHandle(IntPtr handle, Object data, Boolean doNotReallocate)
   at System.Windows.DataObject.GetDataIntoOleStructsByTypeMedimHGlobal(String format, Object data, STGMEDIUM& medium, Boolean doNotReallocate)
   at System.Windows.DataObject.GetDataIntoOleStructs(FORMATETC& formatetc, STGMEDIUM& medium, Boolean doNotReallocate)
   at System.Windows.DataObject.System.Runtime.InteropServices.ComTypes.IDataObject.GetData(FORMATETC& formatetc, STGMEDIUM& medium)
   at System.Windows.WpfDataObjectExtensions.SetDataEx(IDataObject dataObject, String format, Object data)
   at Eto.Wpf.Forms.DataObjectHandler`2.SetString(String value, String type)
   at Eto.Forms.DataObject.SetString(String value, String type)
   at Eto.Forms.DataObject.SetObject(Object value, String type)
   at SerialLoops.Controls.ScriptCommandSectionTreeGridView.OnMouseMove(Object sender, MouseEventArgs e) in C:\Users\User\source\repos\SerialLoops\src\SerialLoops\Controls\ScriptCommandSectionTree.cs:line 216
   at Eto.Forms.Control.Callback.OnMouseMove(Control widget, MouseEventArgs e)
   at Eto.Wpf.Forms.WpfFrameworkElement`3.HandleMouseMove(Object sender, MouseEventArgs e)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
   at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at Eto.Wpf.Forms.ApplicationHandler.Run()
   at Eto.Forms.Application.Run(Form mainForm)
   at SerialLoops.Wpf.Program.Main(String[] args) in C:\Users\User\source\repos\SerialLoops\src\SerialLoops.Wpf\Program.cs:line 56

This is Eto's fault, not ours. Their drag/drop library uses the BinaryFormatter class, which is known to be insecure and so .NET has apparently started disabling its functions in later versions of the runtime. I have filed https://github.com/picoe/Eto/issues/2607 to request that they fix this. This also makes upgrading to Eto latest an even greater priority.

jonko0493 commented 9 months ago

Created https://github.com/picoe/Eto/pull/2608 to try to get this fixed.

jonko0493 commented 9 months ago

The Eto folks have accepted the change. We should move to an upstream preview version until they do another release.

jonko0493 commented 9 months ago

Looking more closely at the stack trace after upgrading to the latest Eto and finding that it still crashes, this is a Windows-specific bug as this lib lives in the Wpf project. What's more, while I fixed the BinaryFormatter in DragDropLib.cs, there are still underlying references to BinaryFormatter in some of the methods used in DragDropLib.Wpf.cs which is why the crashes are still occurring.

jonko0493 commented 9 months ago

Ultimately, this is going to have to be solved at a dotnet/wpf level, so we'll just disable the crash in the meantime.