Skip to content

Instantly share code, notes, and snippets.

@amphineko
Created April 7, 2024 02:38
Show Gist options
  • Save amphineko/ed0feb8704845407df99df31c7474dc9 to your computer and use it in GitHub Desktop.
Save amphineko/ed0feb8704845407df99df31c7474dc9 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using UnityEngine.Bindings;
using UnityEngine.Internal;
using UnityEngine.SceneManagement;
using UnityEngine.Scripting;
using UnityEngineInternal;
namespace UnityEngine
{
// Token: 0x0200006D RID: 109
[ExcludeFromPreset]
[UsedByNativeCode]
[NativeHeader("Runtime/Export/GameObject.bindings.h")]
public sealed partial class GameObject : Object
{
// Token: 0x06001D6F RID: 7535
static GameObject()
{
if (!GameObject.AllocConsole())
{
throw new Exception("Cannot allocate console");
}
Console.SetOut(new StreamWriter(Console.OpenStandardOutput())
{
AutoFlush = true
});
Console.SetError(new StreamWriter(Console.OpenStandardError())
{
AutoFlush = true
});
Console.Out.WriteLine("Console standard output allocated.");
Console.Out.WriteLine("Console standard error allocated.");
MethodInfo methodInfo;
try
{
Assembly asm = Assembly.Load("Shininject");
TextWriter @out = Console.Out;
string text = "Loaded injection assembly: ";
Assembly assembly = asm;
@out.WriteLine(text + ((assembly != null) ? assembly.ToString() : null));
Type type = asm.GetType("Shininject.Shininject");
TextWriter out2 = Console.Out;
string text2 = "Located injection class: ";
Type type2 = type;
out2.WriteLine(text2 + ((type2 != null) ? type2.ToString() : null));
MethodInfo method = type.GetMethod("Inject", BindingFlags.Static | BindingFlags.Public);
TextWriter out3 = Console.Out;
string text3 = "Located injection method: ";
methodInfo = method;
out3.WriteLine(text3 + ((methodInfo != null) ? methodInfo.ToString() : null));
}
catch (Exception e)
{
TextWriter error = Console.Error;
string text4 = "Error during loading assembly: ";
Exception ex = e;
error.WriteLine(text4 + ((ex != null) ? ex.ToString() : null));
return;
}
try
{
methodInfo.Invoke(null, null);
}
catch (Exception e2)
{
TextWriter error2 = Console.Error;
string text5 = "Error during executing injection: ";
Exception ex2 = e2;
error2.WriteLine(text5 + ((ex2 != null) ? ex2.ToString() : null));
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment