mirror of
https://github.com/BepInEx/BepInEx.git
synced 2026-10-20 01:46:13 +00:00
Apply style
This commit is contained in:
1 parent
5959c03522
commit
c874d4f6b3
34 files changed
+160
-60
No files matched your search
@@ -312,8 +312,8 @@ namespace BepInEx.Bootstrap
|
|||||||
if (missingDependencies.Count != 0)
|
if (missingDependencies.Count != 0)
|
||||||
{
|
{
|
||||||
var message = $@"Could not load [{plugin}] because it has missing dependencies: {
|
var message = $@"Could not load [{plugin}] because it has missing dependencies: {
|
||||||
string.Join(", ", missingDependencies.Select(s => s.VersionRange == null ? s.DependencyGUID : $"{s.DependencyGUID} ({s.VersionRange})").ToArray())
|
string.Join(", ", missingDependencies.Select(s => s.VersionRange == null ? s.DependencyGUID : $"{s.DependencyGUID} ({s.VersionRange})").ToArray())
|
||||||
}";
|
}";
|
||||||
DependencyErrors.Add(message);
|
DependencyErrors.Add(message);
|
||||||
Logger.LogError(message);
|
Logger.LogError(message);
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,10 @@ namespace BepInEx.Configuration
|
|||||||
public abstract class AcceptableValueBase
|
public abstract class AcceptableValueBase
|
||||||
{
|
{
|
||||||
/// <param name="valueType">Type of values that this class can Clamp.</param>
|
/// <param name="valueType">Type of values that this class can Clamp.</param>
|
||||||
protected AcceptableValueBase(Type valueType) => ValueType = valueType;
|
protected AcceptableValueBase(Type valueType)
|
||||||
|
{
|
||||||
|
ValueType = valueType;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Type of the supported values.
|
/// Type of the supported values.
|
||||||
|
|||||||
@@ -17,11 +17,13 @@ namespace BepInEx.Configuration
|
|||||||
ConfigDefinition definition,
|
ConfigDefinition definition,
|
||||||
T defaultValue,
|
T defaultValue,
|
||||||
ConfigDescription configDescription) : base(configFile, definition, typeof(T),
|
ConfigDescription configDescription) : base(configFile, definition, typeof(T),
|
||||||
defaultValue, configDescription) =>
|
defaultValue, configDescription)
|
||||||
|
{
|
||||||
configFile.SettingChanged += (sender, args) =>
|
configFile.SettingChanged += (sender, args) =>
|
||||||
{
|
{
|
||||||
if (args.ChangedSetting == this) SettingChanged?.Invoke(sender, args);
|
if (args.ChangedSetting == this) SettingChanged?.Invoke(sender, args);
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Value of this setting.
|
/// Value of this setting.
|
||||||
|
|||||||
@@ -55,7 +55,10 @@ namespace BepInEx.Configuration
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
lock (_ioLock) return Entries.Keys.ToList().AsReadOnly();
|
lock (_ioLock)
|
||||||
|
{
|
||||||
|
return Entries.Keys.ToList().AsReadOnly();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,7 +80,9 @@ namespace BepInEx.Configuration
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
lock (_ioLock)
|
lock (_ioLock)
|
||||||
|
{
|
||||||
return Entries[key];
|
return Entries[key];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,14 +103,18 @@ namespace BepInEx.Configuration
|
|||||||
KeyValuePair<ConfigDefinition, ConfigEntryBase> item)
|
KeyValuePair<ConfigDefinition, ConfigEntryBase> item)
|
||||||
{
|
{
|
||||||
lock (_ioLock)
|
lock (_ioLock)
|
||||||
|
{
|
||||||
Entries.Add(item.Key, item.Value);
|
Entries.Add(item.Key, item.Value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public bool Contains(KeyValuePair<ConfigDefinition, ConfigEntryBase> item)
|
public bool Contains(KeyValuePair<ConfigDefinition, ConfigEntryBase> item)
|
||||||
{
|
{
|
||||||
lock (_ioLock)
|
lock (_ioLock)
|
||||||
|
{
|
||||||
return ((ICollection<KeyValuePair<ConfigDefinition, ConfigEntryBase>>) Entries).Contains(item);
|
return ((ICollection<KeyValuePair<ConfigDefinition, ConfigEntryBase>>) Entries).Contains(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICollection<KeyValuePair<ConfigDefinition, ConfigEntryBase>>.CopyTo(
|
void ICollection<KeyValuePair<ConfigDefinition, ConfigEntryBase>>.CopyTo(
|
||||||
@@ -113,14 +122,18 @@ namespace BepInEx.Configuration
|
|||||||
int arrayIndex)
|
int arrayIndex)
|
||||||
{
|
{
|
||||||
lock (_ioLock)
|
lock (_ioLock)
|
||||||
|
{
|
||||||
((ICollection<KeyValuePair<ConfigDefinition, ConfigEntryBase>>) Entries).CopyTo(array, arrayIndex);
|
((ICollection<KeyValuePair<ConfigDefinition, ConfigEntryBase>>) Entries).CopyTo(array, arrayIndex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ICollection<KeyValuePair<ConfigDefinition, ConfigEntryBase>>.Remove(
|
bool ICollection<KeyValuePair<ConfigDefinition, ConfigEntryBase>>.Remove(
|
||||||
KeyValuePair<ConfigDefinition, ConfigEntryBase> item)
|
KeyValuePair<ConfigDefinition, ConfigEntryBase> item)
|
||||||
{
|
{
|
||||||
lock (_ioLock)
|
lock (_ioLock)
|
||||||
|
{
|
||||||
return Entries.Remove(item.Key);
|
return Entries.Remove(item.Key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@@ -129,7 +142,9 @@ namespace BepInEx.Configuration
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
lock (_ioLock)
|
lock (_ioLock)
|
||||||
|
{
|
||||||
return Entries.Count;
|
return Entries.Count;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,7 +155,9 @@ namespace BepInEx.Configuration
|
|||||||
public bool ContainsKey(ConfigDefinition key)
|
public bool ContainsKey(ConfigDefinition key)
|
||||||
{
|
{
|
||||||
lock (_ioLock)
|
lock (_ioLock)
|
||||||
|
{
|
||||||
return Entries.ContainsKey(key);
|
return Entries.ContainsKey(key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@@ -151,20 +168,26 @@ namespace BepInEx.Configuration
|
|||||||
public bool Remove(ConfigDefinition key)
|
public bool Remove(ConfigDefinition key)
|
||||||
{
|
{
|
||||||
lock (_ioLock)
|
lock (_ioLock)
|
||||||
|
{
|
||||||
return Entries.Remove(key);
|
return Entries.Remove(key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public void Clear()
|
public void Clear()
|
||||||
{
|
{
|
||||||
lock (_ioLock)
|
lock (_ioLock)
|
||||||
|
{
|
||||||
Entries.Clear();
|
Entries.Clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IDictionary<ConfigDefinition, ConfigEntryBase>.TryGetValue(ConfigDefinition key, out ConfigEntryBase value)
|
bool IDictionary<ConfigDefinition, ConfigEntryBase>.TryGetValue(ConfigDefinition key, out ConfigEntryBase value)
|
||||||
{
|
{
|
||||||
lock (_ioLock)
|
lock (_ioLock)
|
||||||
|
{
|
||||||
return Entries.TryGetValue(key, out value);
|
return Entries.TryGetValue(key, out value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@@ -173,7 +196,9 @@ namespace BepInEx.Configuration
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
lock (_ioLock)
|
lock (_ioLock)
|
||||||
|
{
|
||||||
return Entries[key];
|
return Entries[key];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
set => throw new InvalidOperationException("Directly setting a config entry is not supported");
|
set => throw new InvalidOperationException("Directly setting a config entry is not supported");
|
||||||
}
|
}
|
||||||
@@ -187,7 +212,9 @@ namespace BepInEx.Configuration
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
lock (_ioLock)
|
lock (_ioLock)
|
||||||
|
{
|
||||||
return Entries.Keys.ToArray();
|
return Entries.Keys.ToArray();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,7 +227,9 @@ namespace BepInEx.Configuration
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
lock (_ioLock)
|
lock (_ioLock)
|
||||||
|
{
|
||||||
return Entries.Values.ToArray();
|
return Entries.Values.ToArray();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,7 +243,9 @@ namespace BepInEx.Configuration
|
|||||||
public ConfigEntryBase[] GetConfigEntries()
|
public ConfigEntryBase[] GetConfigEntries()
|
||||||
{
|
{
|
||||||
lock (_ioLock)
|
lock (_ioLock)
|
||||||
|
{
|
||||||
return Entries.Values.ToArray();
|
return Entries.Values.ToArray();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Save/Load
|
#region Save/Load
|
||||||
|
|||||||
@@ -9,7 +9,10 @@ namespace BepInEx.Configuration
|
|||||||
public sealed class SettingChangedEventArgs : EventArgs
|
public sealed class SettingChangedEventArgs : EventArgs
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public SettingChangedEventArgs(ConfigEntryBase changedSetting) => ChangedSetting = changedSetting;
|
public SettingChangedEventArgs(ConfigEntryBase changedSetting)
|
||||||
|
{
|
||||||
|
ChangedSetting = changedSetting;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Setting that was changed
|
/// Setting that was changed
|
||||||
|
|||||||
@@ -23,14 +23,14 @@ namespace BepInEx
|
|||||||
}
|
}
|
||||||
|
|
||||||
private const uint SHIFT_JIS_CP = 932;
|
private const uint SHIFT_JIS_CP = 932;
|
||||||
|
|
||||||
public static bool ConsoleEnabled => EnableConsoleArgOverride ?? ConfigConsoleEnabled.Value;
|
public static bool ConsoleEnabled => EnableConsoleArgOverride ?? ConfigConsoleEnabled.Value;
|
||||||
|
|
||||||
public static readonly ConfigEntry<bool> ConfigConsoleEnabled = ConfigFile.CoreConfig.Bind(
|
public static readonly ConfigEntry<bool> ConfigConsoleEnabled = ConfigFile.CoreConfig.Bind(
|
||||||
"Logging.Console", "Enabled",
|
"Logging.Console", "Enabled",
|
||||||
false,
|
false,
|
||||||
"Enables showing a console for log output.");
|
"Enables showing a console for log output.");
|
||||||
|
|
||||||
public static readonly ConfigEntry<bool> ConfigPreventClose = ConfigFile.CoreConfig.Bind(
|
public static readonly ConfigEntry<bool> ConfigPreventClose = ConfigFile.CoreConfig.Bind(
|
||||||
"Logging.Console", "PreventClose",
|
"Logging.Console", "PreventClose",
|
||||||
false,
|
false,
|
||||||
@@ -69,11 +69,11 @@ namespace BepInEx
|
|||||||
/// The stream that writes to an external console. Null if no such console exists
|
/// The stream that writes to an external console. Null if no such console exists
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static TextWriter ConsoleStream => Driver?.ConsoleOut;
|
public static TextWriter ConsoleStream => Driver?.ConsoleOut;
|
||||||
|
|
||||||
private static readonly bool? EnableConsoleArgOverride;
|
private static readonly bool? EnableConsoleArgOverride;
|
||||||
|
|
||||||
private const string ENABLE_CONSOLE_ARG = "--enable-console";
|
private const string ENABLE_CONSOLE_ARG = "--enable-console";
|
||||||
|
|
||||||
static ConsoleManager()
|
static ConsoleManager()
|
||||||
{
|
{
|
||||||
// Ensure GetCommandLineArgs failing (e.g. on unix) does not kill bepin
|
// Ensure GetCommandLineArgs failing (e.g. on unix) does not kill bepin
|
||||||
@@ -127,7 +127,7 @@ namespace BepInEx
|
|||||||
|
|
||||||
Driver.CreateConsole(codepage);
|
Driver.CreateConsole(codepage);
|
||||||
// Console.SetOut(ConsoleStream);
|
// Console.SetOut(ConsoleStream);
|
||||||
|
|
||||||
if (ConfigPreventClose.Value)
|
if (ConfigPreventClose.Value)
|
||||||
Driver.PreventClose();
|
Driver.PreventClose();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace BepInEx
|
|||||||
|
|
||||||
bool ConsoleActive { get; }
|
bool ConsoleActive { get; }
|
||||||
bool ConsoleIsExternal { get; }
|
bool ConsoleIsExternal { get; }
|
||||||
|
|
||||||
void PreventClose();
|
void PreventClose();
|
||||||
|
|
||||||
void Initialize(bool alreadyActive);
|
void Initialize(bool alreadyActive);
|
||||||
|
|||||||
@@ -15,11 +15,11 @@ namespace BepInEx.Unix
|
|||||||
"ForceBepInExTTYDriver",
|
"ForceBepInExTTYDriver",
|
||||||
false,
|
false,
|
||||||
"If enabled, forces to use custom BepInEx TTY driver for handling terminal output on unix.");
|
"If enabled, forces to use custom BepInEx TTY driver for handling terminal output on unix.");
|
||||||
|
|
||||||
static LinuxConsoleDriver()
|
static LinuxConsoleDriver()
|
||||||
{
|
{
|
||||||
UseMonoTtyDriver = false;
|
UseMonoTtyDriver = false;
|
||||||
|
|
||||||
if (ForceCustomTtyDriverConfig.Value)
|
if (ForceCustomTtyDriverConfig.Value)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -67,6 +67,9 @@ namespace BepInEx.Unix
|
|||||||
base.Dispose(disposing);
|
base.Dispose(disposing);
|
||||||
}
|
}
|
||||||
|
|
||||||
~UnixStream() => Dispose(false);
|
~UnixStream()
|
||||||
|
{
|
||||||
|
Dispose(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -26,9 +26,11 @@ namespace UnityInjector.ConsoleUtil
|
|||||||
[DllImport("kernel32.dll", SetLastError = true)]
|
[DllImport("kernel32.dll", SetLastError = true)]
|
||||||
private static extern int MultiByteToWideChar(uint codePage,
|
private static extern int MultiByteToWideChar(uint codePage,
|
||||||
uint dwFlags,
|
uint dwFlags,
|
||||||
[In] [MarshalAs(UnmanagedType.LPArray)] byte[] lpMultiByteStr,
|
[In] [MarshalAs(UnmanagedType.LPArray)]
|
||||||
|
byte[] lpMultiByteStr,
|
||||||
int cbMultiByte,
|
int cbMultiByte,
|
||||||
[Out] [MarshalAs(UnmanagedType.LPWStr)] char[] lpWideCharStr,
|
[Out] [MarshalAs(UnmanagedType.LPWStr)]
|
||||||
|
char[] lpWideCharStr,
|
||||||
int cchWideChar);
|
int cchWideChar);
|
||||||
|
|
||||||
[DllImport("kernel32.dll")]
|
[DllImport("kernel32.dll")]
|
||||||
@@ -39,7 +41,8 @@ namespace UnityInjector.ConsoleUtil
|
|||||||
uint dwFlags,
|
uint dwFlags,
|
||||||
[In] [MarshalAs(UnmanagedType.LPWStr)] char[] lpWideCharStr,
|
[In] [MarshalAs(UnmanagedType.LPWStr)] char[] lpWideCharStr,
|
||||||
int cchWideChar,
|
int cchWideChar,
|
||||||
[Out] [MarshalAs(UnmanagedType.LPArray)] byte[] lpMultiByteStr,
|
[Out] [MarshalAs(UnmanagedType.LPArray)]
|
||||||
|
byte[] lpMultiByteStr,
|
||||||
int cbMultiByte,
|
int cbMultiByte,
|
||||||
IntPtr lpDefaultChar,
|
IntPtr lpDefaultChar,
|
||||||
IntPtr lpUsedDefaultChar);
|
IntPtr lpUsedDefaultChar);
|
||||||
|
|||||||
@@ -19,7 +19,10 @@ namespace UnityInjector.ConsoleUtil
|
|||||||
{
|
{
|
||||||
private readonly uint _codePage;
|
private readonly uint _codePage;
|
||||||
|
|
||||||
private ConsoleEncoding(uint codePage) => _codePage = codePage;
|
private ConsoleEncoding(uint codePage)
|
||||||
|
{
|
||||||
|
_codePage = codePage;
|
||||||
|
}
|
||||||
|
|
||||||
public override int CodePage => (int) _codePage;
|
public override int CodePage => (int) _codePage;
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ namespace UnityInjector.ConsoleUtil
|
|||||||
if (!SetConsoleTitle(value)) throw new InvalidOperationException("Console title invalid");
|
if (!SetConsoleTitle(value)) throw new InvalidOperationException("Console title invalid");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void PreventClose()
|
public static void PreventClose()
|
||||||
{
|
{
|
||||||
if (!IsAttached)
|
if (!IsAttached)
|
||||||
@@ -129,14 +129,14 @@ namespace UnityInjector.ConsoleUtil
|
|||||||
|
|
||||||
[DllImport("kernel32.dll", BestFitMapping = true, CharSet = CharSet.Auto, SetLastError = true)]
|
[DllImport("kernel32.dll", BestFitMapping = true, CharSet = CharSet.Auto, SetLastError = true)]
|
||||||
private static extern bool SetConsoleTitle(string title);
|
private static extern bool SetConsoleTitle(string title);
|
||||||
|
|
||||||
[DllImport("user32.dll")]
|
[DllImport("user32.dll")]
|
||||||
private static extern IntPtr GetSystemMenu(IntPtr hwnd, bool bRevert);
|
private static extern IntPtr GetSystemMenu(IntPtr hwnd, bool bRevert);
|
||||||
|
|
||||||
const uint SC_CLOSE = 0xF060;
|
private const uint SC_CLOSE = 0xF060;
|
||||||
const uint MF_BYCOMMAND = 0x00000000;
|
private const uint MF_BYCOMMAND = 0x00000000;
|
||||||
|
|
||||||
[DllImport("user32.dll")]
|
[DllImport("user32.dll")]
|
||||||
static extern bool DeleteMenu(IntPtr hMenu, uint uPosition, uint uFlags);
|
private static extern bool DeleteMenu(IntPtr hMenu, uint uPosition, uint uFlags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
#if NET35
|
#if NET35
|
||||||
using System.Security.Permissions;
|
using System.Security.Permissions;
|
||||||
|
|
||||||
|
|||||||
@@ -68,11 +68,8 @@ namespace BepInEx
|
|||||||
};
|
};
|
||||||
ConsoleActive = true;
|
ConsoleActive = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PreventClose()
|
public void PreventClose() => ConsoleWindow.PreventClose();
|
||||||
{
|
|
||||||
ConsoleWindow.PreventClose();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DetachConsole()
|
public void DetachConsole()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -122,7 +122,10 @@ namespace BepInEx
|
|||||||
/// <param name="guid">The GUID of the referenced plugin.</param>
|
/// <param name="guid">The GUID of the referenced plugin.</param>
|
||||||
/// <param name="version">The version range of the referenced plugin.</param>
|
/// <param name="version">The version range of the referenced plugin.</param>
|
||||||
/// <remarks>When version is supplied the dependency is always treated as HardDependency</remarks>
|
/// <remarks>When version is supplied the dependency is always treated as HardDependency</remarks>
|
||||||
public BepInDependency(string guid, string version) : this(guid) => VersionRange = Range.Parse(version);
|
public BepInDependency(string guid, string version) : this(guid)
|
||||||
|
{
|
||||||
|
VersionRange = Range.Parse(version);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The GUID of the referenced plugin.
|
/// The GUID of the referenced plugin.
|
||||||
@@ -179,7 +182,10 @@ namespace BepInEx
|
|||||||
/// If the other plugin exists, this plugin will not be loaded and a warning will be shown.
|
/// If the other plugin exists, this plugin will not be loaded and a warning will be shown.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="IncompatibilityGUID">The GUID of the referenced plugin.</param>
|
/// <param name="IncompatibilityGUID">The GUID of the referenced plugin.</param>
|
||||||
public BepInIncompatibility(string IncompatibilityGUID) => this.IncompatibilityGUID = IncompatibilityGUID;
|
public BepInIncompatibility(string IncompatibilityGUID)
|
||||||
|
{
|
||||||
|
this.IncompatibilityGUID = IncompatibilityGUID;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The GUID of the referenced plugin.
|
/// The GUID of the referenced plugin.
|
||||||
@@ -209,7 +215,10 @@ namespace BepInEx
|
|||||||
public class BepInProcess : Attribute
|
public class BepInProcess : Attribute
|
||||||
{
|
{
|
||||||
/// <param name="ProcessName">The name of the process that this plugin will run under.</param>
|
/// <param name="ProcessName">The name of the process that this plugin will run under.</param>
|
||||||
public BepInProcess(string ProcessName) => this.ProcessName = ProcessName;
|
public BepInProcess(string ProcessName)
|
||||||
|
{
|
||||||
|
this.ProcessName = ProcessName;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The name of the process that this plugin will run under.
|
/// The name of the process that this plugin will run under.
|
||||||
|
|||||||
@@ -108,6 +108,9 @@ namespace BepInEx.Logging
|
|||||||
catch (ObjectDisposedException) { }
|
catch (ObjectDisposedException) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
~DiskLogListener() => Dispose();
|
~DiskLogListener()
|
||||||
|
{
|
||||||
|
Dispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,10 @@ namespace BepInEx.Logging
|
|||||||
/// Creates a manual log source.
|
/// Creates a manual log source.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sourceName">Name of the log source.</param>
|
/// <param name="sourceName">Name of the log source.</param>
|
||||||
public ManualLogSource(string sourceName) => SourceName = sourceName;
|
public ManualLogSource(string sourceName)
|
||||||
|
{
|
||||||
|
SourceName = sourceName;
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public string SourceName { get; }
|
public string SourceName { get; }
|
||||||
|
|||||||
@@ -13,7 +13,10 @@ namespace BepInEx.Logging
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new trace log source.
|
/// Creates a new trace log source.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected TraceLogSource() => LogSource = new ManualLogSource("Trace");
|
protected TraceLogSource()
|
||||||
|
{
|
||||||
|
LogSource = new ManualLogSource("Trace");
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether Trace logs are currently being rerouted.
|
/// Whether Trace logs are currently being rerouted.
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ namespace BepInEx
|
|||||||
/// The name of the currently executing process.
|
/// The name of the currently executing process.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string ProcessName { get; private set; }
|
public static string ProcessName { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// List of directories from where Mono will search assemblies before assembly resolving is invoked.
|
/// List of directories from where Mono will search assemblies before assembly resolving is invoked.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace BepInEx
|
|||||||
/// <see cref="System.Reflection.Emit" /> namespace.
|
/// <see cref="System.Reflection.Emit" /> namespace.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static bool CLRSupportsDynamicAssemblies => CheckSRE();
|
public static bool CLRSupportsDynamicAssemblies => CheckSRE();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// An encoding for UTF-8 which does not emit a byte order mark (BOM).
|
/// An encoding for UTF-8 which does not emit a byte order mark (BOM).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -345,7 +345,7 @@ namespace BepInEx
|
|||||||
var newTrusted = curTrusted == null ? addTrusted : $"{curTrusted}{Path.PathSeparator}{addTrusted}";
|
var newTrusted = curTrusted == null ? addTrusted : $"{curTrusted}{Path.PathSeparator}{addTrusted}";
|
||||||
appDomain.SetData(TRUSTED_PLATFORM_ASSEMBLIES, newTrusted);
|
appDomain.SetData(TRUSTED_PLATFORM_ASSEMBLIES, newTrusted);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets unique files in all given directories. If the file with the same name exists in multiple directories,
|
/// Gets unique files in all given directories. If the file with the same name exists in multiple directories,
|
||||||
/// only the first occurrence is returned.
|
/// only the first occurrence is returned.
|
||||||
@@ -353,7 +353,8 @@ namespace BepInEx
|
|||||||
/// <param name="directories">Directories to search from.</param>
|
/// <param name="directories">Directories to search from.</param>
|
||||||
/// <param name="pattern">File pattern to search.</param>
|
/// <param name="pattern">File pattern to search.</param>
|
||||||
/// <returns>Collection of all files in the directories.</returns>
|
/// <returns>Collection of all files in the directories.</returns>
|
||||||
public static IEnumerable<string> GetUniqueFilesInDirectories(IEnumerable<string> directories, string pattern = "*")
|
public static IEnumerable<string> GetUniqueFilesInDirectories(IEnumerable<string> directories,
|
||||||
|
string pattern = "*")
|
||||||
{
|
{
|
||||||
var result = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase);
|
var result = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase);
|
||||||
foreach (var directory in directories)
|
foreach (var directory in directories)
|
||||||
@@ -363,6 +364,7 @@ namespace BepInEx
|
|||||||
if (!result.ContainsKey(fileName))
|
if (!result.ContainsKey(fileName))
|
||||||
result[fileName] = file;
|
result[fileName] = file;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result.Values;
|
return result.Values;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,7 +117,8 @@ namespace BepInEx.IL2CPP.Hook.Allocator
|
|||||||
|
|
||||||
public static readonly nint MAP_FAILED = -1;
|
public static readonly nint MAP_FAILED = -1;
|
||||||
|
|
||||||
static Unix() =>
|
static Unix()
|
||||||
|
{
|
||||||
typeof(Unix).ResolveDynDllImports(new Dictionary<string, List<DynDllMapping>>
|
typeof(Unix).ResolveDynDllImports(new Dictionary<string, List<DynDllMapping>>
|
||||||
{
|
{
|
||||||
["libc"] = new()
|
["libc"] = new()
|
||||||
@@ -127,6 +128,7 @@ namespace BepInEx.IL2CPP.Hook.Allocator
|
|||||||
"/usr/lib/libSystem.dylib" // OSX POSIX
|
"/usr/lib/libSystem.dylib" // OSX POSIX
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
#pragma warning disable 649 // Set by MonoMod
|
#pragma warning disable 649 // Set by MonoMod
|
||||||
[DynDllImport("mmap")]
|
[DynDllImport("mmap")]
|
||||||
|
|||||||
@@ -69,7 +69,10 @@ namespace BepInEx.IL2CPP.Hook
|
|||||||
/// Constructs a new instance of <see cref="NativeDetour" /> method patcher.
|
/// Constructs a new instance of <see cref="NativeDetour" /> method patcher.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="original"></param>
|
/// <param name="original"></param>
|
||||||
public IL2CPPDetourMethodPatcher(MethodBase original) : base(original) => Init();
|
public IL2CPPDetourMethodPatcher(MethodBase original) : base(original)
|
||||||
|
{
|
||||||
|
Init();
|
||||||
|
}
|
||||||
|
|
||||||
private void Init()
|
private void Init()
|
||||||
{
|
{
|
||||||
@@ -91,15 +94,20 @@ namespace BepInEx.IL2CPP.Hook
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the native MethodInfo struct for the target method
|
// Get the native MethodInfo struct for the target method
|
||||||
originalNativeMethodInfo = UnityVersionHandler.Wrap((Il2CppMethodInfo*) (IntPtr) methodField.GetValue(null));
|
originalNativeMethodInfo =
|
||||||
|
UnityVersionHandler.Wrap((Il2CppMethodInfo*) (IntPtr) methodField.GetValue(null));
|
||||||
|
|
||||||
// Create a trampoline from the original target method
|
// Create a trampoline from the original target method
|
||||||
var trampolinePtr =
|
var trampolinePtr =
|
||||||
DetourGenerator.CreateTrampolineFromFunction(originalNativeMethodInfo.MethodPointer, out _, out _);
|
DetourGenerator.CreateTrampolineFromFunction(originalNativeMethodInfo.MethodPointer, out _, out _);
|
||||||
|
|
||||||
// Create a modified native MethodInfo struct to point towards the trampoline
|
// Create a modified native MethodInfo struct to point towards the trampoline
|
||||||
modifiedNativeMethodInfo = UnityVersionHandler.NewMethod(); //(Il2CppMethodInfo*) Marshal.AllocHGlobal(Marshal.SizeOf<Il2CppMethodInfo>());
|
modifiedNativeMethodInfo =
|
||||||
Buffer.MemoryCopy(originalNativeMethodInfo.Pointer.ToPointer(), modifiedNativeMethodInfo.Pointer.ToPointer(), modifiedNativeMethodInfo.StructSize, originalNativeMethodInfo.StructSize);
|
UnityVersionHandler
|
||||||
|
.NewMethod(); //(Il2CppMethodInfo*) Marshal.AllocHGlobal(Marshal.SizeOf<Il2CppMethodInfo>());
|
||||||
|
Buffer.MemoryCopy(originalNativeMethodInfo.Pointer.ToPointer(),
|
||||||
|
modifiedNativeMethodInfo.Pointer.ToPointer(), modifiedNativeMethodInfo.StructSize,
|
||||||
|
originalNativeMethodInfo.StructSize);
|
||||||
modifiedNativeMethodInfo.MethodPointer = trampolinePtr;
|
modifiedNativeMethodInfo.MethodPointer = trampolinePtr;
|
||||||
isValid = true;
|
isValid = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,10 @@ namespace BepInEx.IL2CPP.Logging
|
|||||||
{
|
{
|
||||||
public class IL2CPPUnityLogSource : ILogSource
|
public class IL2CPPUnityLogSource : ILogSource
|
||||||
{
|
{
|
||||||
public IL2CPPUnityLogSource() =>
|
public IL2CPPUnityLogSource()
|
||||||
|
{
|
||||||
Application.s_LogCallbackHandler = new Action<string, string, LogType>(UnityLogCallback);
|
Application.s_LogCallbackHandler = new Action<string, string, LogType>(UnityLogCallback);
|
||||||
|
}
|
||||||
|
|
||||||
public string SourceName { get; } = "Unity";
|
public string SourceName { get; } = "Unity";
|
||||||
|
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ namespace BepInEx.NetLauncher
|
|||||||
|
|
||||||
Log.LogInfo($"{assemblyPatcher.PatcherPlugins.Count} patcher plugin(s) loaded");
|
Log.LogInfo($"{assemblyPatcher.PatcherPlugins.Count} patcher plugin(s) loaded");
|
||||||
|
|
||||||
assemblyPatcher.LoadAssemblyDirectories(new []{ Paths.GameRootPath }, new []{ "dll", "exe" });
|
assemblyPatcher.LoadAssemblyDirectories(new[] { Paths.GameRootPath }, new[] { "dll", "exe" });
|
||||||
|
|
||||||
Log.LogInfo($"{assemblyPatcher.AssembliesToPatch.Count} assemblies discovered");
|
Log.LogInfo($"{assemblyPatcher.AssembliesToPatch.Count} assemblies discovered");
|
||||||
|
|
||||||
|
|||||||
@@ -79,7 +79,8 @@ namespace BepInEx.NetLauncher
|
|||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
filename =
|
filename =
|
||||||
Path.Combine(Directory.GetCurrentDirectory(), Path.GetFileName(Process.GetCurrentProcess().MainModule.FileName));
|
Path.Combine(Directory.GetCurrentDirectory(),
|
||||||
|
Path.GetFileName(Process.GetCurrentProcess().MainModule.FileName));
|
||||||
ResolveDirectories.Add(Path.GetDirectoryName(filename));
|
ResolveDirectories.Add(Path.GetDirectoryName(filename));
|
||||||
|
|
||||||
// for debugging within VS
|
// for debugging within VS
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace BepInEx.Preloader.Core
|
|||||||
/// Full path to the game executable currently running.
|
/// Full path to the game executable currently running.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string DOORSTOP_PROCESS_PATH { get; private set; }
|
public static string DOORSTOP_PROCESS_PATH { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Array of paths where Mono searches DLLs from before assembly resolvers are invoked.
|
/// Array of paths where Mono searches DLLs from before assembly resolvers are invoked.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -35,7 +35,9 @@ namespace BepInEx.Preloader.Core
|
|||||||
DOORSTOP_INVOKE_DLL_PATH = Environment.GetEnvironmentVariable("DOORSTOP_INVOKE_DLL_PATH");
|
DOORSTOP_INVOKE_DLL_PATH = Environment.GetEnvironmentVariable("DOORSTOP_INVOKE_DLL_PATH");
|
||||||
DOORSTOP_MANAGED_FOLDER_DIR = Environment.GetEnvironmentVariable("DOORSTOP_MANAGED_FOLDER_DIR");
|
DOORSTOP_MANAGED_FOLDER_DIR = Environment.GetEnvironmentVariable("DOORSTOP_MANAGED_FOLDER_DIR");
|
||||||
DOORSTOP_PROCESS_PATH = Environment.GetEnvironmentVariable("DOORSTOP_PROCESS_PATH");
|
DOORSTOP_PROCESS_PATH = Environment.GetEnvironmentVariable("DOORSTOP_PROCESS_PATH");
|
||||||
DOORSTOP_DLL_SEARCH_DIRS = Environment.GetEnvironmentVariable("DOORSTOP_DLL_SEARCH_DIRS")?.Split(Path.PathSeparator) ?? new string[0];
|
DOORSTOP_DLL_SEARCH_DIRS =
|
||||||
|
Environment.GetEnvironmentVariable("DOORSTOP_DLL_SEARCH_DIRS")?.Split(Path.PathSeparator) ??
|
||||||
|
new string[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -214,7 +214,8 @@ namespace BepInEx.Preloader.Core
|
|||||||
/// are skipped.
|
/// are skipped.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="directories">The directories to search.</param>
|
/// <param name="directories">The directories to search.</param>
|
||||||
public void LoadAssemblyDirectories(params string[] directories) => LoadAssemblyDirectories(directories, new []{ "dll" });
|
public void LoadAssemblyDirectories(params string[] directories) =>
|
||||||
|
LoadAssemblyDirectories(directories, new[] { "dll" });
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds all assemblies in given directories to be patched and loaded by this patcher instance. Non-managed assemblies are
|
/// Adds all assemblies in given directories to be patched and loaded by this patcher instance. Non-managed assemblies are
|
||||||
|
|||||||
@@ -42,11 +42,11 @@ namespace BepInEx.Preloader.Unity
|
|||||||
PlatformUtils.SetPlatform();
|
PlatformUtils.SetPlatform();
|
||||||
|
|
||||||
var bepinPath = Utility.ParentDirectory(Path.GetFullPath(EnvVars.DOORSTOP_INVOKE_DLL_PATH), 2);
|
var bepinPath = Utility.ParentDirectory(Path.GetFullPath(EnvVars.DOORSTOP_INVOKE_DLL_PATH), 2);
|
||||||
|
|
||||||
Paths.SetExecutablePath(EnvVars.DOORSTOP_PROCESS_PATH, bepinPath,
|
Paths.SetExecutablePath(EnvVars.DOORSTOP_PROCESS_PATH, bepinPath,
|
||||||
EnvVars.DOORSTOP_MANAGED_FOLDER_DIR,
|
EnvVars.DOORSTOP_MANAGED_FOLDER_DIR,
|
||||||
EnvVars.DOORSTOP_DLL_SEARCH_DIRS);
|
EnvVars.DOORSTOP_DLL_SEARCH_DIRS);
|
||||||
|
|
||||||
LoadCriticalAssemblies();
|
LoadCriticalAssemblies();
|
||||||
AppDomain.CurrentDomain.AssemblyResolve += LocalResolve;
|
AppDomain.CurrentDomain.AssemblyResolve += LocalResolve;
|
||||||
// Remove temporary resolver early so it won't override local resolver
|
// Remove temporary resolver early so it won't override local resolver
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ namespace BepInEx.Preloader.RuntimeFixes
|
|||||||
var type = (TraceEventType) Enum.Parse(typeof(TraceEventType), kind);
|
var type = (TraceEventType) Enum.Parse(typeof(TraceEventType), kind);
|
||||||
|
|
||||||
lock (ListenersSyncRoot)
|
lock (ListenersSyncRoot)
|
||||||
|
{
|
||||||
foreach (var obj in Listeners)
|
foreach (var obj in Listeners)
|
||||||
{
|
{
|
||||||
var traceListener = (TraceListener) obj;
|
var traceListener = (TraceListener) obj;
|
||||||
@@ -65,6 +66,7 @@ namespace BepInEx.Preloader.RuntimeFixes
|
|||||||
|
|
||||||
if (AutoFlush) traceListener.Flush();
|
if (AutoFlush) traceListener.Flush();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,10 @@ namespace BepInEx.Shared
|
|||||||
[AttributeUsage(AttributeTargets.Assembly)]
|
[AttributeUsage(AttributeTargets.Assembly)]
|
||||||
public class BuildInfoAttribute : Attribute
|
public class BuildInfoAttribute : Attribute
|
||||||
{
|
{
|
||||||
public BuildInfoAttribute(string info) => Info = info;
|
public BuildInfoAttribute(string info)
|
||||||
|
{
|
||||||
|
Info = info;
|
||||||
|
}
|
||||||
|
|
||||||
public string Info { get; }
|
public string Info { get; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,8 @@ namespace BepInEx.Unity.Bootstrap
|
|||||||
// TODO: Figure out better version obtaining mechanism (e.g. from globalmanagers)
|
// TODO: Figure out better version obtaining mechanism (e.g. from globalmanagers)
|
||||||
private static string UnityVersion
|
private static string UnityVersion
|
||||||
{
|
{
|
||||||
[MethodImpl(MethodImplOptions.NoInlining)] get => Application.unityVersion;
|
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||||
|
get => Application.unityVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void StaticStart(string gameExePath = null)
|
private static void StaticStart(string gameExePath = null)
|
||||||
|
|||||||
@@ -18,7 +18,8 @@ namespace BepInEx.Configuration
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public struct KeyboardShortcut
|
public struct KeyboardShortcut
|
||||||
{
|
{
|
||||||
static KeyboardShortcut() =>
|
static KeyboardShortcut()
|
||||||
|
{
|
||||||
TomlTypeConverter.AddConverter(
|
TomlTypeConverter.AddConverter(
|
||||||
typeof(KeyboardShortcut),
|
typeof(KeyboardShortcut),
|
||||||
new TypeConverter
|
new TypeConverter
|
||||||
@@ -26,6 +27,7 @@ namespace BepInEx.Configuration
|
|||||||
ConvertToString = (o, type) => ((KeyboardShortcut) o).Serialize(),
|
ConvertToString = (o, type) => ((KeyboardShortcut) o).Serialize(),
|
||||||
ConvertToObject = (s, type) => Deserialize(s)
|
ConvertToObject = (s, type) => Deserialize(s)
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Shortcut that never triggers.
|
/// Shortcut that never triggers.
|
||||||
@@ -59,7 +61,10 @@ namespace BepInEx.Configuration
|
|||||||
ArgumentException($"Can't set {nameof(mainKey)} to KeyCode.None if there are any {nameof(modifiers)}");
|
ArgumentException($"Can't set {nameof(mainKey)} to KeyCode.None if there are any {nameof(modifiers)}");
|
||||||
}
|
}
|
||||||
|
|
||||||
private KeyboardShortcut(KeyCode[] keys) => _allKeys = SanitizeKeys(keys);
|
private KeyboardShortcut(KeyCode[] keys)
|
||||||
|
{
|
||||||
|
_allKeys = SanitizeKeys(keys);
|
||||||
|
}
|
||||||
|
|
||||||
private static KeyCode[] SanitizeKeys(params KeyCode[] keys)
|
private static KeyCode[] SanitizeKeys(params KeyCode[] keys)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,7 +15,10 @@ namespace BepInEx.Unity.Logging
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new Unity log source.
|
/// Creates a new Unity log source.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public UnityLogSource() => InternalUnityLogMessage += UnityLogMessageHandler;
|
public UnityLogSource()
|
||||||
|
{
|
||||||
|
InternalUnityLogMessage += UnityLogMessageHandler;
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public string SourceName { get; } = "Unity Log";
|
public string SourceName { get; } = "Unity Log";
|
||||||
|
|||||||
@@ -75,7 +75,10 @@ namespace BepInEx
|
|||||||
{
|
{
|
||||||
if (action == null) throw new ArgumentNullException(nameof(action));
|
if (action == null) throw new ArgumentNullException(nameof(action));
|
||||||
|
|
||||||
lock (_invokeLock) _invokeList += action;
|
lock (_invokeLock)
|
||||||
|
{
|
||||||
|
_invokeList += action;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -167,7 +170,10 @@ namespace BepInEx
|
|||||||
{
|
{
|
||||||
internal bool ExceptionThrown;
|
internal bool ExceptionThrown;
|
||||||
|
|
||||||
public InvokeResult() => AsyncWaitHandle = new EventWaitHandle(false, EventResetMode.ManualReset);
|
public InvokeResult()
|
||||||
|
{
|
||||||
|
AsyncWaitHandle = new EventWaitHandle(false, EventResetMode.ManualReset);
|
||||||
|
}
|
||||||
|
|
||||||
public bool IsCompleted { get; private set; }
|
public bool IsCompleted { get; private set; }
|
||||||
public WaitHandle AsyncWaitHandle { get; }
|
public WaitHandle AsyncWaitHandle { get; }
|
||||||
|
|||||||
Reference in new issue
Block a user