public static Type FindTypeInGame(string fullName) { return(GameAssembly.GetSafeTypes().FirstOrDefault(t => { return t.FullName.Equals(fullName); })); }
private static AssemblyDefinition DumpAssembly(GameAssembly runtimeAssembly) { // Check stack if (assemblyDumper.IsOnStack(runtimeAssembly)) { return((AssemblyDefinition)assemblyDumper.GrabFromStack(runtimeAssembly)); } // Generate assembly file AssemblyDefinition assembly = AssemblyDefinition.CreateAssembly(new AssemblyNameDefinition(runtimeAssembly.Name, new Version(3, 7, 1, 6)), runtimeAssembly.Name, ModuleKind.Dll); ModuleDefinition mainModule = assembly.MainModule; // Add to stack assemblyDumper.PushToStack(runtimeAssembly, assembly); // Store dumped classes Dictionary <GameClass, TypeDefinition> dumpedClasses = new Dictionary <GameClass, TypeDefinition>(); // Get classes ClassDump classDumper = new ClassDump(runtimeAssembly); while (classDumper.HasNext()) { // Get runtime class GameClass runtimeClass = classDumper.Next(); if (runtimeClass == null) { continue; } // Dump dumpedClasses.Add(runtimeClass, DumpClass(classDumper, mainModule, runtimeClass)); } // Populate classes foreach (GameClass runtimeClass in dumpedClasses.Keys) { // Dump methods MethodDump methodDumper = new MethodDump(runtimeClass); while (methodDumper.HasNext()) { // Get method GameMethod runtimeMethod = methodDumper.Next(); if (runtimeMethod == null) { continue; } // Dump DumpMethod(methodDumper, dumpedClasses[runtimeClass], runtimeMethod); } } // End Logger.Log("Dumped assembly: " + runtimeAssembly.Name); assembly.Write("AtiRoNya\\Dumps\\" + runtimeAssembly.Name + ".dll"); return(assembly); }
public void SplashMod(Func <string, object, object> api = null) { SetApi(api); if (PatchTelemetry(GameAssembly?.GetType("AmplitudeWebClient") ?? typeof(PhoenixTelemetry))) { // Disable tele button TryPatch(typeof(UIModuleGameplayOptionsPanel), "Show", postfix: nameof(DisableTeleToggle)); } }
public Type GetAssemblyType(string namespaceName, string className) { try { Type type = GameAssembly.GetType(namespaceName + "." + className); return(type); } catch (Exception ex) { LogManager.ErrorLog.WriteLine(ex); return(null); } }
private static TypeDefinition GetOrDumpType(IntPtr klass) { if (klass == IntPtr.Zero) { return(null); } GameClass runtimeClass = new GameClass(klass); GameAssembly runtimeAssembly = new GameAssembly(runtimeClass.Assembly); // Run assembly dump AssemblyDefinition assembly = DumpAssembly(runtimeAssembly); if (assembly == null) { return(null); } // Find and return type return(SearchType(assembly.MainModule.Types, runtimeClass)); }
internal static void EnterEvalMode(IConsole console) { if (EvalPatch != null) { return; } var me = new ConsoleShell(); ReadPatch = me.TryPatch(GameAssembly.GetType("Base.Utils.GameConsole.CommandLineParser"), "ReadCommandLine", nameof(BeforeReadCommandLine_Eval)); EvalPatch = me.TryPatch(GameAssembly.GetType("Base.Utils.GameConsole.EmptyCommand"), "Execute", postfix: nameof(AfterExecute_Eval)); if (ReadPatch == null || EvalPatch == null) { Unpatch(ref ReadPatch); Unpatch(ref EvalPatch); return; } ShowLinePatch = me.TryPatch(typeof(GameConsoleWindow).GetMethod("ExecuteCommandLine", new Type[] { typeof(string), typeof(bool), typeof(bool) }), prefix: nameof(BeforeExecuteCommandLine_ShowLine)); SetConsoleInputPlaceholder("Enter C# expression...", Color.blue); console.Write("Entering C# Shell. Type 'Exit' to return."); }
private static void CallStartFunction(string gameInstanceClass, string argument, IntPtr gameInsteance) { try { var dir = Environment.CurrentDirectory; var classType = GameAssembly.GetType(gameInstanceClass); var baseType = classType.BaseType; var gameStart = classType.GetMethod("Start"); if (classType != null && classType.IsSubclassOf(typeof(DotNetGameInstance))) { GameInstance = (DotNetGameInstance)UObject.Make(gameInsteance, classType); GameInstance.Start(argument); } else { Log.Fatal($"Class {gameInstanceClass} not found or is not subclass of DotNetGameInstance"); } } catch (Exception ex) { Log.Fatal($"Calling '{gameInstanceClass}( \"{argument}\" );' threw exception {ex.ToString()}"); } }
public static void Main() { Logger.Log("Starting RuntimeDumper..."); // Initialize assembly dumper assemblyDumper = new AssemblyDump(); // Loop assemblies while (assemblyDumper.HasNext()) { // Get runtime assembly GameAssembly runtimeAssembly = assemblyDumper.Next(); if (runtimeAssembly == null) { continue; } // Dump DumpAssembly(runtimeAssembly); } }
static void Main() { GameAssembly game = new GameAssembly(); game.Run(); }