2024-08-20 23:24:18 +01:00
|
|
|
|
using System.Reflection;
|
|
|
|
|
|
|
|
|
|
namespace DumpLib.Helpers;
|
|
|
|
|
|
|
|
|
|
public class MethodHelper
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Method to get DeserializeObject from Newtonsoft assembly
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>MethodInfo</returns>
|
|
|
|
|
public static MethodInfo GetDeserializerMethodInfo()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return DataHelper._newtonAssembly.GetTypes().First(x =>
|
|
|
|
|
x.Name == "JsonConvert"
|
|
|
|
|
).GetMethods().First(m =>
|
|
|
|
|
m.Name == "DeserializeObject" &&
|
|
|
|
|
m.IsGenericMethodDefinition &&
|
|
|
|
|
m.GetParameters().Length == 1 &&
|
|
|
|
|
m.GetParameters().Any(p =>
|
|
|
|
|
p.ParameterType == typeof(string)
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Utils.LogError("GetDeserializerMethodInfo");
|
|
|
|
|
Utils.LogError(e);
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2024-11-02 17:03:54 +00:00
|
|
|
|
/// Method to get Quit method from EFT (as of 02/11/2024 - GClass2193)
|
2024-08-20 23:24:18 +01:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>MethodInfo</returns>
|
|
|
|
|
public static MethodInfo GetApplicationQuitMethod()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return DataHelper._eftAssembly.GetTypes().First(x =>
|
2024-11-02 17:03:54 +00:00
|
|
|
|
{
|
|
|
|
|
var methods = x.GetMethods();
|
|
|
|
|
|
|
|
|
|
return methods.Any(m => m.Name == "Quit") && methods.Any(m => m.Name == "QuitWithCode");
|
|
|
|
|
}
|
2024-08-20 23:24:18 +01:00
|
|
|
|
).GetMethod("Quit");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Utils.LogError("GetApplicationQuitMethod");
|
|
|
|
|
Utils.LogError(e);
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static MethodInfo GetToUnparsedDataMethod()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return DataHelper._eftAssembly.GetTypes().First(x =>
|
|
|
|
|
x.GetMethods().Any(m =>
|
|
|
|
|
m.Name == "ToUnparsedData"
|
|
|
|
|
)).GetMethod("ToUnparsedData");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Utils.LogError("GetToUnparsedDataMethod");
|
|
|
|
|
Utils.LogError(e);
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|