接入obfuz->2.0

This commit is contained in:
Alex-Rachel
2025-07-26 08:10:41 +08:00
parent f2c7ff4336
commit cb86d8868e
713 changed files with 57092 additions and 10 deletions

View File

@@ -0,0 +1,10 @@

namespace HybridCLR
{
public enum HomologousImageMode
{
Consistent,
SuperSet,
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0f0351553ad90e74aa586746b5965ded
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,14 @@
{
"name": "HybridCLR.Runtime",
"rootNamespace": "",
"references": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": true,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 13ba8ce62aa80c74598530029cb2d649
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,16 @@

namespace HybridCLR
{
public enum LoadImageErrorCode
{
OK = 0,
BAD_IMAGE, // invalid dll file
NOT_IMPLEMENT, // not implement feature
AOT_ASSEMBLY_NOT_FIND, // AOT assembly not found
HOMOLOGOUS_ONLY_SUPPORT_AOT_ASSEMBLY, // can not load supplementary metadata assembly for non-AOT assembly
HOMOLOGOUS_ASSEMBLY_HAS_LOADED, // can not load supplementary metadata assembly for the same assembly
INVALID_HOMOLOGOUS_MODE, // invalid homologous image mode
PDB_BAD_FILE, // invalid pdb file
};
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2c7d5b71981fba643b4c21ed01bcb675
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HybridCLR
{
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public class ReversePInvokeWrapperGenerationAttribute : Attribute
{
public int ReserveWrapperCount { get; }
public ReversePInvokeWrapperGenerationAttribute(int reserveWrapperCount)
{
ReserveWrapperCount = reserveWrapperCount;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f99dd22d9d81b2540b4663b3bcdf0a79
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,139 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using UnityEditor;
using UnityEngine.Scripting;
namespace HybridCLR
{
[Preserve]
public static class RuntimeApi
{
/// <summary>
/// load supplementary metadata assembly
/// </summary>
/// <param name="dllBytes"></param>
/// <returns></returns>
/// <exception cref="NotSupportedException"></exception>
#if UNITY_EDITOR
public static unsafe LoadImageErrorCode LoadMetadataForAOTAssembly(byte[] dllBytes, HomologousImageMode mode)
{
return LoadImageErrorCode.OK;
}
#else
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern LoadImageErrorCode LoadMetadataForAOTAssembly(byte[] dllBytes, HomologousImageMode mode);
#endif
/// <summary>
/// prejit method to avoid the jit cost of first time running
/// </summary>
/// <param name="method"></param>
/// <returns>return true if method is jited, return false if method can't be jited </returns>
///
#if UNITY_EDITOR
public static bool PreJitMethod(MethodInfo method)
{
return false;
}
#else
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern bool PreJitMethod(MethodInfo method);
#endif
/// <summary>
/// prejit all methods of class to avoid the jit cost of first time running
/// </summary>
/// <param name="type"></param>
/// <returns>return true if class is jited, return false if class can't be jited </returns>
#if UNITY_EDITOR
public static bool PreJitClass(Type type)
{
return false;
}
#else
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern bool PreJitClass(Type type);
#endif
/// <summary>
/// get the maximum number of StackObjects in the interpreter thread stack (size*8 represents the final memory size occupied
/// </summary>
/// <returns></returns>
public static int GetInterpreterThreadObjectStackSize()
{
return GetRuntimeOption(RuntimeOptionId.InterpreterThreadObjectStackSize);
}
/// <summary>
/// set the maximum number of StackObjects for the interpreter thread stack (size*8 represents the final memory size occupied)
/// </summary>
/// <param name="size"></param>
public static void SetInterpreterThreadObjectStackSize(int size)
{
SetRuntimeOption(RuntimeOptionId.InterpreterThreadObjectStackSize, size);
}
/// <summary>
/// get the number of interpreter thread function frames (sizeof(InterpreterFrame)*size represents the final memory size occupied)
/// </summary>
/// <returns></returns>
public static int GetInterpreterThreadFrameStackSize()
{
return GetRuntimeOption(RuntimeOptionId.InterpreterThreadFrameStackSize);
}
/// <summary>
/// set the number of interpreter thread function frames (sizeof(InterpreterFrame)*size represents the final memory size occupied)
/// </summary>
/// <param name="size"></param>
public static void SetInterpreterThreadFrameStackSize(int size)
{
SetRuntimeOption(RuntimeOptionId.InterpreterThreadFrameStackSize, size);
}
#if UNITY_EDITOR
private static readonly Dictionary<RuntimeOptionId, int> s_runtimeOptions = new Dictionary<RuntimeOptionId, int>();
/// <summary>
/// set runtime option value
/// </summary>
/// <param name="optionId"></param>
/// <param name="value"></param>
public static void SetRuntimeOption(RuntimeOptionId optionId, int value)
{
s_runtimeOptions[optionId] = value;
}
#else
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void SetRuntimeOption(RuntimeOptionId optionId, int value);
#endif
/// <summary>
/// get runtime option value
/// </summary>
/// <param name="optionId"></param>
/// <returns></returns>
#if UNITY_EDITOR
public static int GetRuntimeOption(RuntimeOptionId optionId)
{
if (s_runtimeOptions.TryGetValue(optionId, out var value))
{
return value;
}
return 0;
}
#else
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern int GetRuntimeOption(RuntimeOptionId optionId);
#endif
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0d58bdc22b6d6b54ab6791baf16a0a3d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,12 @@
namespace HybridCLR
{
public enum RuntimeOptionId
{
InterpreterThreadObjectStackSize = 1,
InterpreterThreadFrameStackSize = 2,
ThreadExceptionFlowSize = 3,
MaxMethodBodyCacheSize = 4,
MaxMethodInlineDepth = 5,
MaxInlineableMethodBodySize = 6,
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 64be598b47302644a96013c74d945653
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: