Skip to content

Commit

Permalink
v0.2.7 Update, See CHANGELOG for Full Details
Browse files Browse the repository at this point in the history
  • Loading branch information
HerpDerpinstine committed Aug 30, 2020
1 parent 15c7180 commit fbcbd88
Show file tree
Hide file tree
Showing 13 changed files with 88 additions and 58 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### Version List:

[v0.2.7 Open-Beta](#v027-open-beta)
[v0.2.6 Open-Beta](#v026-open-beta)
[v0.2.5 Open-Beta](#v025-open-beta)
[v0.2.4 Open-Beta](#v024-open-beta)
Expand All @@ -14,6 +15,19 @@

---

### v0.2.7 Open-Beta:

1. Console no longer has stdout directed to it. (Credits to knah :D)
2. Removed VRChat Auth Token Hider as it's no longer necessary. (Credits to knah :D)
3. Added Try Catch to DisableAnalytics Hooks.
4. Updated Il2CppAssemblyUnhollower and Il2CppDumper Versions. (Credits to knah :D)
5. Implemented potentially dead method detection. (Credits to knah :D)
6. Exposed new Console Output Handle and assign it to Managed Console Class Output. (Credits to knah :D)
7. Added Unity 2019.4.3 Dependencies.
8. Bumped Il2CppAssemblyUnhollower Version.

---

### v0.2.6 Open-Beta:

1. Fixed Issue with Logger Timestamp making New Lines.
Expand Down
3 changes: 2 additions & 1 deletion MelonLoader.AssemblyGenerator/AssemblyGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ private static bool AssemblyGenerate(string gameRoot, string unityVersion, strin
("--output=" + Il2CppAssemblyUnhollower.OutputDirectory),
("--mscorlib=" + MSCORLIB_Path),
("--unity=" + UnityDependencies.BaseFolder),
"--gameassembly=" + GameAssembly_Path,
"--blacklist-assembly=Mono.Security",
"--blacklist-assembly=Newtonsoft.Json",
"--blacklist-assembly=Valve.Newtonsoft.Json"
Expand Down Expand Up @@ -234,7 +235,7 @@ private static void Cleanup()
}
localConfig.OldFiles.Clear();
}
string[] files = Directory.GetFiles(Il2CppAssemblyUnhollower.OutputDirectory, "*.dll", SearchOption.TopDirectoryOnly);
string[] files = Directory.GetFiles(Il2CppAssemblyUnhollower.OutputDirectory, "*", SearchOption.TopDirectoryOnly);
if (files.Length > 0)
{
for (int i = 0; i < files.Length; i++)
Expand Down
4 changes: 2 additions & 2 deletions MelonLoader.AssemblyGenerator/ExternalToolVersions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ namespace MelonLoader.AssemblyGenerator
{
public static class ExternalToolVersions
{
public static string Il2CppDumperVersion = "6.3.3";
public static string Il2CppDumperVersion = "6.4.12";
public static string Il2CppDumperUrl = "https://github.com/Perfare/Il2CppDumper/releases/download/v" + Il2CppDumperVersion + "/Il2CppDumper-v" + Il2CppDumperVersion + ".zip";

public static string Il2CppAssemblyUnhollowerVersion = "0.4.8.0";
public static string Il2CppAssemblyUnhollowerVersion = "0.4.9.1";
public static string Il2CppAssemblyUnhollowerUrl = "https://github.com/knah/Il2CppAssemblyUnhollower/releases/download/v" + Il2CppAssemblyUnhollowerVersion + "/Il2CppAssemblyUnhollower." + Il2CppAssemblyUnhollowerVersion + ".zip";

public static string UnityDependenciesBaseUrl = "https://github.com/HerpDerpinstine/MelonLoader/raw/master/BaseLibs/UnityDependencies/";
Expand Down
4 changes: 2 additions & 2 deletions MelonLoader.Installer/MelonLoader.Installer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<TargetFramework>net472</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<LangVersion>latest</LangVersion>
<Version>2.0.1</Version>
<Version>2.0.2</Version>
<Authors>Lava Gang</Authors>
<Company>discord.gg/2Wn3N2P</Company>
<Copyright>Lava Gang</Copyright>
Expand All @@ -15,7 +15,7 @@
<ApplicationIcon>icon.ico</ApplicationIcon>
<ApplicationManifest>app.manifest</ApplicationManifest>
<StartupObject>MelonLoader.Installer.Program</StartupObject>
<AssemblyVersion>2.0.1.0</AssemblyVersion>
<AssemblyVersion>2.0.2.0</AssemblyVersion>
<Description>Installer for MelonLoader</Description>
<Product>MelonLoader.Installer</Product>
<PackageId>MelonLoader.Installer</PackageId>
Expand Down
18 changes: 14 additions & 4 deletions MelonLoader.Installer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,18 @@ static void Install_NoGUI()
string version = null;
JsonArray data = (JsonArray)JsonValue.Parse(webClient.DownloadString("https://api.github.com/repos/HerpDerpinstine/MelonLoader/releases")).AsJsonArray;
if (data.Count > 0)
version = data[0]["tag_name"].AsString;
{
foreach (var x in data)
{
string versionstr = x["tag_name"].AsString;
if (!versionstr.StartsWith("v0.2") && !versionstr.StartsWith("v0.1"))
continue;
version = versionstr;
break;
}
}
if (version == null)
return;
try
{
Install(silentPath, version, false, true);
Expand Down Expand Up @@ -123,6 +134,8 @@ static void Install_GUI()
foreach (var x in data)
{
string version = x["tag_name"].AsString;
if (!version.StartsWith("v0.2") && !version.StartsWith("v0.1"))
continue;
if (!has_added_latest)
{
has_added_latest = true;
Expand Down Expand Up @@ -323,10 +336,7 @@ private static void Install_Legacy_02(string dirpath, string selectedVersion)
{
string version = Path.GetFileNameWithoutExtension(x["name"].AsString);
if (version.StartsWith(subver))
{
versionlist.Add(version);
string[] semvertbl = version.Split(new char[] { '.' });
}
}
if (versionlist.Count > 0)
{
Expand Down
2 changes: 1 addition & 1 deletion MelonLoader.ModHandler/BuildInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ public static class BuildInfo
public const string Description = "MelonLoader";
public const string Author = "Lava Gang";
public const string Company = "discord.gg/2Wn3N2P";
public const string Version = "0.2.6";
public const string Version = "0.2.7";
}
}
3 changes: 2 additions & 1 deletion MelonLoader.ModHandler/MelonConsole.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.IO;
using System.Runtime.CompilerServices;
using Microsoft.Win32.SafeHandles;

namespace MelonLoader
{
Expand All @@ -22,7 +23,7 @@ private static void Create()
{
Enabled = true;
Allocate();
Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = true });
Console.SetOut(new StreamWriter(new FileStream(new SafeFileHandle(MelonLogger.Native_GetConsoleOutputHandle(), false), FileAccess.Write)) { AutoFlush = true });
Console.SetIn(new StreamReader(Console.OpenStandardInput()));
SetTitle(BuildInfo.Name + " v" + BuildInfo.Version + " Open-Beta");
}
Expand Down
12 changes: 12 additions & 0 deletions MelonLoader.ModHandler/MelonLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ public static void Log(ConsoleColor color, string s, params object[] args)
MelonConsole.RunLogCallbacks(namesection, fmt);
}

public static void Log(object o)
{
Log(o.ToString());
}

public static void Log(ConsoleColor color, object o)
{
Log(color, o.ToString());
}

public static void LogWarning(string s)
{
string namesection = GetNameSection();
Expand Down Expand Up @@ -127,5 +137,7 @@ internal static string GetNameSection()
internal extern static void Native_LogMelonCompatibility(MelonBase.MelonCompatibility comp);
[MethodImpl(MethodImplOptions.InternalCall)]
internal extern static void Native_ThrowInternalError(string txt);
[MethodImpl(MethodImplOptions.InternalCall)]
public extern static IntPtr Native_GetConsoleOutputHandle();
}
}
35 changes: 0 additions & 35 deletions MelonLoader.Support.Il2Cpp/Main.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
using System;
using System.Linq;
using System.Reflection;
using UnhollowerBaseLib;
using UnhollowerBaseLib.Runtime;
using UnhollowerRuntimeLib;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using Harmony;

namespace MelonLoader.Support
{
Expand All @@ -17,8 +15,6 @@ internal static class Main
internal static GameObject obj = null;
internal static MelonLoaderComponent comp = null;
private static Camera OnPostRenderCam = null;
private static MethodInfo Il2CppSystem_Console_WriteLine = null;
private static HarmonyInstance harmonyInstance = null;

private static ISupportModule Initialize()
{
Expand All @@ -30,33 +26,6 @@ private static ISupportModule Initialize()
if (Imports.IsDebugMode())
LogSupport.TraceHandler += MelonLogger.Log;

if (MelonLoaderBase.IsVRChat)
{
try
{
Assembly Transmtn = Assembly.Load("Transmtn");
if (Transmtn != null)
{
Type Transmtn_HttpConnection = Transmtn.GetType("Transmtn.HttpConnection");
if (Transmtn_HttpConnection != null)
{
Il2CppSystem_Console_WriteLine = typeof(Il2CppSystem.Console).GetMethods(BindingFlags.Public | BindingFlags.Static).First(x => (x.Name.Equals("WriteLine") && (x.GetParameters().Count() == 1) && (x.GetParameters()[0].ParameterType == typeof(string))));
if (harmonyInstance == null)
harmonyInstance = HarmonyInstance.Create("MelonLoader.Support.Il2Cpp");
harmonyInstance.Patch(Transmtn_HttpConnection.GetMethod("get", BindingFlags.Public | BindingFlags.Instance), new HarmonyMethod(typeof(Main).GetMethod("Transmtn_HttpConnection_get_Prefix", BindingFlags.NonPublic | BindingFlags.Static)), new HarmonyMethod(typeof(Main).GetMethod("Transmtn_HttpConnection_get_Postfix", BindingFlags.NonPublic | BindingFlags.Static)));
}
else
throw new Exception("Failed to get Type Transmtn.HttpConnection!");
}
else
throw new Exception("Failed to get Assembly Transmtn!");
}
catch (Exception ex)
{
MelonLogger.LogWarning("Exception while setting up Auth Token Hider, Auth Tokens may show in Console: " + ex);
}
}

ClassInjector.DoHook += Imports.Hook;
GetUnityVersionNumbers(out var major, out var minor, out var patch);
UnityVersionHandler.Initialize(major, minor, patch);
Expand Down Expand Up @@ -95,10 +64,6 @@ private static void GetUnityVersionNumbers(out int major, out int minor, out int

internal delegate bool SetAsLastSiblingDelegate(IntPtr u0040this);
internal static SetAsLastSiblingDelegate SetAsLastSiblingDelegateField;

private static bool Il2CppSystem_Console_WriteLine_Patch() => false;
private static void Transmtn_HttpConnection_get_Prefix() => harmonyInstance.Patch(Il2CppSystem_Console_WriteLine, new HarmonyMethod(typeof(Main).GetMethod("Il2CppSystem_Console_WriteLine_Patch", BindingFlags.NonPublic | BindingFlags.Static)));
private static void Transmtn_HttpConnection_get_Postfix() => harmonyInstance.Unpatch(Il2CppSystem_Console_WriteLine, typeof(Main).GetMethod("Il2CppSystem_Console_WriteLine_Patch", BindingFlags.NonPublic | BindingFlags.Static));
}

public class MelonLoaderComponent : MonoBehaviour
Expand Down
6 changes: 4 additions & 2 deletions MelonLoader/Console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ bool Console::HordiniMode_Random = false;
bool Console::ChromiumMode = false;
bool Console::ShouldShowGameLogs = false;
bool Console::AlwaysOnTop = false;
HANDLE Console::OutputHandle = NULL;

void Console::Create()
{
Expand All @@ -21,7 +22,8 @@ void Console::Create()
SetTitle(("MelonLoader " + (MelonLoader::DebugMode ? std::string("Debug") : std::string("Normal")) + " Console").c_str());
SetForegroundWindow(hwndConsole);
AlwaysOnTopCheck();
freopen_s(reinterpret_cast<FILE**>(stdout), "CONOUT$", "w", stdout);
OutputHandle = GetStdHandle(STD_OUTPUT_HANDLE);
SetStdHandle(STD_OUTPUT_HANDLE, NULL);
}
else
MessageBox(NULL, ("Failed to Create the " + (MelonLoader::DebugMode ? std::string("Debug") : std::string("Normal")) + " Console!").c_str(), NULL, MB_OK | MB_ICONEXCLAMATION);
Expand Down Expand Up @@ -68,7 +70,7 @@ void Console::Write(const char* txt)
ChromiumCheck();
RainbowCheck();
AlwaysOnTopCheck();
std::cout << txt;
WriteConsole(OutputHandle, txt, strlen(txt), NULL, NULL);
ResetColor();
}
};
Expand Down
7 changes: 4 additions & 3 deletions MelonLoader/Console.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,13 @@ class Console
static bool ChromiumMode;
static bool ShouldShowGameLogs;
static bool AlwaysOnTop;
static HANDLE OutputHandle;

static bool IsInitialized() { return (hwndConsole != NULL); }
static void Create();

static void SetTitle(const char* title) { SetConsoleTitle(title); }
static void SetColor(ConsoleColor color) { SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color); }
static void SetColor(ConsoleColor color) { SetConsoleTextAttribute(OutputHandle, color); }
static void ResetColor() { SetColor(ConsoleColor_Gray); }
static void RainbowCheck();
static void ChromiumCheck();
Expand All @@ -99,8 +100,8 @@ class Console
static void Write(std::string txt) { Write(txt.c_str()); }
static void Write(std::string txt, ConsoleColor color) { Write(txt.c_str(), color); }

static void WriteLine(const char* txt) { Write(txt); std::cout << std::endl; }
static void WriteLine(const char* txt, ConsoleColor color) { Write(txt, color); std::cout << std::endl; }
static void WriteLine(const char* txt) { Write(txt); Write("\n"); }
static void WriteLine(const char* txt, ConsoleColor color) { Write(txt, color); Write("\n"); }
static void WriteLine(std::string txt) { WriteLine(txt.c_str()); }
static void WriteLine(std::string txt, ConsoleColor color) { WriteLine(txt.c_str(), color); }
};
36 changes: 29 additions & 7 deletions MelonLoader/DisableAnalytics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ std::list<std::string> DisableAnalytics::URL_Blacklist = {
"fbcdn.net",
"fb.me",
"fb.com",
"crashlytics.com"
"crashlytics.com",
"discordapp.com",
"dropbox.com",
"pastebin.com",
"gluehender-aluhut.de",
"softlight.at.ua"
};

void DisableAnalytics::Setup()
Expand Down Expand Up @@ -55,6 +60,7 @@ void DisableAnalytics::Setup()

bool DisableAnalytics::CheckBlacklist(std::string url)
{
std::transform(url.begin(), url.end(), url.begin(), [](unsigned char c){ return std::tolower(c); });
bool url_found = (std::find(URL_Blacklist.begin(), URL_Blacklist.end(), url) != URL_Blacklist.end());
if (url_found)
Logger::DebugLog("Analytics URL Blocked: " + url);
Expand All @@ -63,14 +69,30 @@ bool DisableAnalytics::CheckBlacklist(std::string url)

void* DisableAnalytics::Hooked_gethostbyname(const char* name)
{
if ((name != NULL) && CheckBlacklist(name))
return Original_gethostbyname("localhost");
return Original_gethostbyname(name);
try
{
if ((name != NULL) && CheckBlacklist(name))
return Original_gethostbyname("localhost");
return Original_gethostbyname(name);
}
catch (...)
{
Logger::LogError("Exception caught in gethostbyname! Returning NULL");
return NULL;
}
}

int DisableAnalytics::Hooked_getaddrinfo(PCSTR pNodeName, PCSTR pServiceName, void* pHints, void* ppResult)
{
if ((pNodeName != NULL) && CheckBlacklist(pNodeName))
return Original_getaddrinfo("localhost", pServiceName, pHints, ppResult);
return Original_getaddrinfo(pNodeName, pServiceName, pHints, ppResult);
try
{
if ((pNodeName != NULL) && CheckBlacklist(pNodeName))
return Original_getaddrinfo("localhost", pServiceName, pHints, ppResult);
return Original_getaddrinfo(pNodeName, pServiceName, pHints, ppResult);
}
catch (...)
{
Logger::LogError("Exception caught in getaddrinfo! Returning WSATRY_AGAIN");
return WSATRY_AGAIN;
}
}
2 changes: 2 additions & 0 deletions MelonLoader/Exports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ bool AG_Force_Regenerate() { return MelonLoader::AG_Force_Regenerate; }
MonoString* AG_Force_Version_Unhollower() { if (MelonLoader::ForceUnhollowerVersion != NULL) return Mono::mono_string_new(Mono::Domain, MelonLoader::ForceUnhollowerVersion); return NULL; }
void SetTitleForConsole(MonoString* txt) { Console::SetTitle(Mono::mono_string_to_utf8(txt)); }
void ThrowInternalError(MonoString* txt) { AssertionManager::ThrowInternalError(Mono::mono_string_to_utf8(txt)); }
HANDLE GetConsoleOutputHandle() { return Console::OutputHandle; }

void Exports::AddInternalCalls()
{
Expand Down Expand Up @@ -67,6 +68,7 @@ void Exports::AddInternalCalls()
Mono::mono_add_internal_call("MelonLoader.MelonLogger::Native_LogMelonError", LogMelonError);
Mono::mono_add_internal_call("MelonLoader.MelonLogger::Native_LogMelonCompatibility", LogMelonCompatibility);
Mono::mono_add_internal_call("MelonLoader.MelonLogger::Native_ThrowInternalError", ThrowInternalError);
Mono::mono_add_internal_call("MelonLoader.MelonLogger::Native_GetConsoleOutputHandle", GetConsoleOutputHandle);

Mono::mono_add_internal_call("MelonLoader.AssemblyGenerator::Force_Regenerate", AG_Force_Regenerate);
Mono::mono_add_internal_call("MelonLoader.AssemblyGenerator::Force_Version_Unhollower", AG_Force_Version_Unhollower);
Expand Down

0 comments on commit fbcbd88

Please sign in to comment.