From d48651e6683ea8c43f64317582fd85f30cc1ece6 Mon Sep 17 00:00:00 2001 From: upthorn Date: Wed, 13 May 2020 08:57:12 -0700 Subject: [PATCH] Prevent crashes on Set*ExtraPadding Prevent crashes when needing to invoke private methods from MainForm. --- src/BizHawk.Client.EmuHawk/Api/ClientApi.cs | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/BizHawk.Client.EmuHawk/Api/ClientApi.cs b/src/BizHawk.Client.EmuHawk/Api/ClientApi.cs index d8064506ed..208bddc5c9 100644 --- a/src/BizHawk.Client.EmuHawk/Api/ClientApi.cs +++ b/src/BizHawk.Client.EmuHawk/Api/ClientApi.cs @@ -96,9 +96,9 @@ namespace BizHawk.Client.EmuHawk { typeList.Add(obj.GetType()); } - method = MainFormClass.GetMethod(name, typeList.ToArray()); + method = MainFormClass.GetMethod(name, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance, null, typeList.ToArray(), null); } - else method = MainFormClass.GetMethod(name); + else method = MainFormClass.GetMethod(name, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); if(method != null) method.Invoke(ClientMainFormInstance, paramList); @@ -258,11 +258,7 @@ namespace BizHawk.Client.EmuHawk /// Bottom padding public static void SetGameExtraPadding(int left, int top, int right, int bottom) { - FieldInfo f = ClientAssembly.GetType("BizHawk.Client.EmuHawk.GlobalWin").GetField("DisplayManager"); - object displayManager = f.GetValue(null); - f = f.FieldType.GetField("GameExtraPadding"); - f.SetValue(displayManager, new Padding(left, top, right, bottom)); - + GlobalWin.DisplayManager.GameExtraPadding = new Padding(left, top, right, bottom); InvokeMainFormMethod("FrameBufferResized"); } @@ -305,11 +301,7 @@ namespace BizHawk.Client.EmuHawk /// Bottom padding public static void SetExtraPadding(int left, int top, int right, int bottom) { - FieldInfo f = ClientAssembly.GetType("BizHawk.Client.EmuHawk.GlobalWin").GetField("DisplayManager"); - object displayManager = f.GetValue(null); - f = f.FieldType.GetField("ClientExtraPadding"); - f.SetValue(displayManager, new Padding(left, top, right, bottom)); - + GlobalWin.DisplayManager.ClientExtraPadding = new Padding(left, top, right, bottom); InvokeMainFormMethod("FrameBufferResized"); }