Skip to content

Commit

Permalink
port baydock's changes
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamKracker committed Apr 25, 2023
1 parent 1e1fb0e commit 027f890
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 11 deletions.
23 changes: 22 additions & 1 deletion build.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ----------- MelonLoader IL2CPP (net6) -----------
# ----------- MelonLoader IL2CPP Unhollower (net6) -----------
dotnet build src/UnityExplorer.sln -c Release_ML_Cpp_net6
$Path = "Release\UnityExplorer.MelonLoader.IL2CPP.net6preview"
# ILRepack
Expand All @@ -17,6 +17,27 @@ Move-Item -Path $Path/UniverseLib.IL2CPP.Unhollower.dll -Destination $Path/UserL
Remove-Item $Path/../UnityExplorer.MelonLoader.IL2CPP.net6preview.zip -ErrorAction SilentlyContinue
7z a $Path/../UnityExplorer.MelonLoader.IL2CPP.net6preview.zip .\$Path\*

# ----------- MelonLoader IL2CPP Interop (net6) -----------
dotnet build src/UnityExplorer.sln -c Release_ML_Cpp_net6_interop
$Path = "Release\UnityExplorer.MelonLoader.IL2CPP.net6preview.interop"
# ILRepack
lib/ILRepack.exe /target:library /lib:lib/net6 /lib:lib/interop /lib:$Path /internalize /out:$Path/UnityExplorer.ML.IL2CPP.net6preview.interop.dll $Path/UnityExplorer.ML.IL2CPP.net6preview.interop.dll $Path/mcs.dll
# (cleanup and move files)
Remove-Item $Path/UnityExplorer.ML.IL2CPP.net6preview.interop.deps.json
Remove-Item $Path/Tomlet.dll
Remove-Item $Path/mcs.dll
Remove-Item $Path/Iced.dll
Remove-Item $Path/Il2CppInterop.Common.dll
Remove-Item $Path/Il2CppInterop.Runtime.dll
Remove-Item $Path/Microsoft.Extensions.Logging.Abstractions.dll
New-Item -Path "$Path" -Name "Mods" -ItemType "directory" -Force
Move-Item -Path $Path/UnityExplorer.ML.IL2CPP.net6preview.interop.dll -Destination $Path/Mods -Force
New-Item -Path "$Path" -Name "UserLibs" -ItemType "directory" -Force
Move-Item -Path $Path/UniverseLib.IL2CPP.Interop.ML.dll -Destination $Path/UserLibs -Force
# (create zip archive)
Remove-Item $Path/../UnityExplorer.MelonLoader.IL2CPP.net6preview.interop.zip -ErrorAction SilentlyContinue
7z a $Path/../UnityExplorer.MelonLoader.IL2CPP.net6preview.interop.zip .\$Path\*

# ----------- MelonLoader IL2CPP (net472) -----------
dotnet build src/UnityExplorer.sln -c Release_ML_Cpp_net472
$Path = "Release/UnityExplorer.MelonLoader.IL2CPP"
Expand Down
6 changes: 6 additions & 0 deletions src/Config/ConfigManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public static class ConfigManager
public static ConfigElement<KeyCode> UI_MouseInspect_Keybind;
public static ConfigElement<string> CSConsole_Assembly_Blacklist;
public static ConfigElement<string> Reflection_Signature_Blacklist;
public static ConfigElement<bool> Reflection_Hide_NativeInfoPtrs;

// internal configs
internal static InternalConfigHandler InternalHandler { get; private set; }
Expand Down Expand Up @@ -139,6 +140,11 @@ private static void CreateConfigElements()
"Seperate signatures with a semicolon ';'.\r\n" +
"For example, to blacklist Camera.main, you would add 'UnityEngine.Camera.main;'",
"");

Reflection_Hide_NativeInfoPtrs = new("Hide NativeMethodInfoPtr_s and NativeFieldInfoPtr_s",
"Use this to blacklist NativeMethodPtr_s and NativeFieldInfoPtrs_s from the class inspector, mainly to reduce clutter.\r\n" +
"For example, this will hide 'Class.NativeFieldInfoPtr_value' for the field 'Class.value'.",
false);
}
}
}
2 changes: 1 addition & 1 deletion src/ExplorerCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace UnityExplorer
public static class ExplorerCore
{
public const string NAME = "UnityExplorer";
public const string VERSION = "4.9.0";
public const string VERSION = "4.9.4";
public const string AUTHOR = "Sinai";
public const string GUID = "com.sinai.unityexplorer";

Expand Down
2 changes: 1 addition & 1 deletion src/Loader/MelonLoader/ExplorerMelonMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class ExplorerMelonMod : MelonMod, IExplorerLoader

public string UnhollowedModulesFolder => Path.Combine(
Path.GetDirectoryName(MelonHandler.ModsDirectory),
Path.Combine("MelonLoader", "Managed"));
Path.Combine("MelonLoader", "Il2CppAssemblies"));

public ConfigHandler ConfigHandler => _configHandler;
public MelonLoaderConfigHandler _configHandler;
Expand Down
8 changes: 7 additions & 1 deletion src/Runtime/UERuntimeHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,15 @@ public static void LoadBlacklistString(string blacklist)

public static bool IsBlacklisted(MemberInfo member)
{
if (ConfigManager.Reflection_Hide_NativeInfoPtrs.Value) {
bool isNativeInfoPtr = member.Name.StartsWith("NativeFieldInfoPtr_") || member.Name.StartsWith("NativeMethodInfoPtr_");
if (isNativeInfoPtr)
return true;
}

if (string.IsNullOrEmpty(member.DeclaringType?.Namespace))
return false;

string sig = $"{member.DeclaringType.FullName}.{member.Name}";

return currentBlacklist.Contains(sig);
Expand Down
26 changes: 19 additions & 7 deletions src/UnityExplorer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,27 @@
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<AllowedReferenceRelatedFileExtensions>none</AllowedReferenceRelatedFileExtensions>
<DebugSymbols>false</DebugSymbols>
<DebugType>none</DebugType>
<DebugSymbols>true</DebugSymbols>
<DebugType>embedded</DebugType>
<RootNamespace>UnityExplorer</RootNamespace>
<LangVersion>10.0</LangVersion>
<Configurations>BIE_Cpp;BIE_Cpp_CoreCLR;BIE5_Mono;BIE6_Mono;ML_Cpp_net6;ML_Cpp_net472;ML_Mono;STANDALONE_Mono;STANDALONE_Cpp</Configurations>
<LangVersion>latest</LangVersion>
<Configurations>BIE_Cpp;BIE_Cpp_CoreCLR;BIE5_Mono;BIE6_Mono;ML_Cpp_net6;ML_Cpp_net6_interop;ML_Cpp_net472;ML_Mono;STANDALONE_Mono;STANDALONE_Cpp</Configurations>
</PropertyGroup>
<!-- ~~~~~ CONFIGURATIONS ~~~~~ -->
<!-- ML IL2CPP net6 -->
<!-- ML IL2CPP Unhollower net6 -->
<PropertyGroup Condition="'$(Configuration)'=='ML_Cpp_net6'">
<TargetFramework>net6</TargetFramework>
<OutputPath>..\Release\UnityExplorer.MelonLoader.IL2CPP.net6preview\</OutputPath>
<DefineConstants>CPP,ML,UNHOLLOWER</DefineConstants>
<AssemblyName>UnityExplorer.ML.IL2CPP.net6preview</AssemblyName>
</PropertyGroup>
<!-- ML IL2CPP Interop net6 -->
<PropertyGroup Condition="'$(Configuration)'=='ML_Cpp_net6_interop'">
<TargetFramework>net6</TargetFramework>
<OutputPath>..\Release\UnityExplorer.MelonLoader.IL2CPP.net6preview.interop\</OutputPath>
<DefineConstants>CPP,ML,INTEROP</DefineConstants>
<AssemblyName>UnityExplorer.ML.IL2CPP.net6preview.interop</AssemblyName>
</PropertyGroup>
<!-- ML IL2CPP net472 (TEMP) -->
<PropertyGroup Condition="'$(Configuration)'=='ML_Cpp_net472'">
<TargetFramework>net472</TargetFramework>
Expand Down Expand Up @@ -93,6 +100,11 @@
<PackageReference Include="Il2CppInterop.Runtime" Version="1.0.0" />
<PackageReference Include="UniverseLib.IL2CPP.Interop" Version="1.5.1" />
</ItemGroup>
<ItemGroup Condition="'$(Configuration)'=='ML_Cpp_net6_interop'">
<PackageReference Include="Il2CppInterop.Common" Version="1.0.0" />
<PackageReference Include="Il2CppInterop.Runtime" Version="1.0.0" />
<PackageReference Include="UniverseLib.IL2CPP.Interop.ML" Version="1.5.4.1" />
</ItemGroup>
<!-- mono nuget -->
<ItemGroup Condition="'$(Configuration)'=='BIE6_Mono' or '$(Configuration)'=='BIE5_Mono' or '$(Configuration)'=='ML_Mono' or '$(Configuration)'=='STANDALONE_Mono'">
<PackageReference Include="UniverseLib.Mono" Version="1.5.1" />
Expand All @@ -114,7 +126,7 @@
</Reference>
</ItemGroup>
<!-- MelonLoader net6 -->
<ItemGroup Condition="'$(Configuration)'=='ML_Cpp_net6'">
<ItemGroup Condition="'$(Configuration)'=='ML_Cpp_net6' or '$(Configuration)'=='ML_Cpp_net6_interop'">
<Reference Include="MelonLoader">
<HintPath>..\lib\net6\MelonLoader.dll</HintPath>
<Private>False</Private>
Expand Down Expand Up @@ -211,7 +223,7 @@
</Reference>
</ItemGroup>
<!-- Il2Cpp Interop -->
<ItemGroup Condition="'$(Configuration)'=='BIE_Cpp_CoreCLR'">
<ItemGroup Condition="'$(Configuration)'=='BIE_Cpp_CoreCLR' or '$(Configuration)'=='ML_Cpp_net6_interop'">
<Reference Include="Il2Cppmscorlib">
<HintPath>..\lib\interop\Il2Cppmscorlib.dll</HintPath>
<Private>False</Private>
Expand Down
3 changes: 3 additions & 0 deletions src/UnityExplorer.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Global
Release_BIE6_Mono|Any CPU = Release_BIE6_Mono|Any CPU
Release_ML_Cpp_net472|Any CPU = Release_ML_Cpp_net472|Any CPU
Release_ML_Cpp_net6|Any CPU = Release_ML_Cpp_net6|Any CPU
Release_ML_Cpp_net6_interop|Any CPU = Release_ML_Cpp_net6_interop|Any CPU
Release_ML_Mono|Any CPU = Release_ML_Mono|Any CPU
Release_STANDALONE_Cpp|Any CPU = Release_STANDALONE_Cpp|Any CPU
Release_STANDALONE_Mono|Any CPU = Release_STANDALONE_Mono|Any CPU
Expand All @@ -30,6 +31,8 @@ Global
{B21DBDE3-5D6F-4726-93AB-CC3CC68BAE7D}.Release_ML_Cpp_net472|Any CPU.Build.0 = ML_Cpp_net472|Any CPU
{B21DBDE3-5D6F-4726-93AB-CC3CC68BAE7D}.Release_ML_Cpp_net6|Any CPU.ActiveCfg = ML_Cpp_net6|Any CPU
{B21DBDE3-5D6F-4726-93AB-CC3CC68BAE7D}.Release_ML_Cpp_net6|Any CPU.Build.0 = ML_Cpp_net6|Any CPU
{B21DBDE3-5D6F-4726-93AB-CC3CC68BAE7D}.Release_ML_Cpp_net6_interop|Any CPU.ActiveCfg = ML_Cpp_net6_interop|Any CPU
{B21DBDE3-5D6F-4726-93AB-CC3CC68BAE7D}.Release_ML_Cpp_net6_interop|Any CPU.Build.0 = ML_Cpp_net6_interop|Any CPU
{B21DBDE3-5D6F-4726-93AB-CC3CC68BAE7D}.Release_ML_Mono|Any CPU.ActiveCfg = ML_Mono|Any CPU
{B21DBDE3-5D6F-4726-93AB-CC3CC68BAE7D}.Release_ML_Mono|Any CPU.Build.0 = ML_Mono|Any CPU
{B21DBDE3-5D6F-4726-93AB-CC3CC68BAE7D}.Release_STANDALONE_Cpp|Any CPU.ActiveCfg = STANDALONE_Cpp|Any CPU
Expand Down

0 comments on commit 027f890

Please sign in to comment.