【反破解】接入代码

main
刘涛 2026-01-27 18:24:36 +08:00
parent db8e6e21e8
commit 31c38fced3
23 changed files with 836 additions and 0 deletions

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 2f924162a120446a945bec50417f2be6
timeCreated: 1769251206

View File

@ -0,0 +1,16 @@
internal static class HashUtil
{
public static uint Hash(string str)
{
const uint prime = 0x1000193;
var hash = 0x811c9dc5;
foreach (var ch in str)
{
hash ^= ch;
hash *= prime;
}
return hash;
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a54fc1c229504366b92fee8c196aff41
timeCreated: 1769351453

View File

@ -0,0 +1,47 @@
using HybridCLR.Editor.Commands;
using Obfuz.Settings;
using Obfuz4HybridCLR;
using HybridCLR.Editor.Installer;
using UnityEditor;
using UnityEditor.Build;
using UnityEngine;
public class KedrExtensionMenu
{
[MenuItem("HybridCLR/KedrExtension/Settings...")]
public static void OpenSettings() => SettingsService.OpenProjectSettings("Project/KedrExtension");
[MenuItem("HybridCLR/KedrExtension/GenerateAll")]
public static void GenerateAll()
{
var installer = new InstallerController();
if (!installer.HasInstalledHybridCLR())
{
throw new BuildFailedException("You have not initialized HybridCLR, please install it via menu 'HybridCLR/Installer'");
}
var target = EditorUserBuildSettings.activeBuildTarget;
CompileDllCommand.CompileDll(target);
Il2CppDefGeneratorCommand.GenerateIl2CppDef();
if (ObfuzSettings.Instance.polymorphicDllSettings.enable)
{
PrebuildCommandExt.GeneratePolymorphicCodes();
}
else
{
Debug.LogWarning("Polymorphic code generation is disabled.");
}
// New
OpCodeShuffleCommand.GenerateOpCodes();
LinkGeneratorCommand.GenerateLinkXml(target);
StripAOTDllCommand.GenerateStripedAOTDlls(target);
var obfuscatedHotUpdateDllPath = PrebuildCommandExt.GetObfuscatedHotUpdateAssemblyOutputPath(target);
ObfuscateUtil.ObfuscateHotUpdateAssemblies(target, obfuscatedHotUpdateDllPath);
PrebuildCommandExt.GenerateMethodBridgeAndReversePInvokeWrapper(target, obfuscatedHotUpdateDllPath);
PrebuildCommandExt.GenerateAOTGenericReference(target, obfuscatedHotUpdateDllPath);
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4bdc7a464a314b2697cf26e0619285f6
timeCreated: 1769251133

View File

@ -0,0 +1,68 @@
using System.IO;
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;
public class KedrExtensionSettings : ScriptableObject
{
private static string SettingsPath => "ProjectSettings/KedrExtensionSettings.asset";
private static KedrExtensionSettings _instance;
public bool enableOpcodeShuffle = false;
public static KedrExtensionSettings Instance
{
get
{
if (_instance) return _instance;
var arr = InternalEditorUtility.LoadSerializedFileAndForget(SettingsPath);
if (arr.Length == 1 && arr[0] is KedrExtensionSettings settings)
{
_instance = settings;
}
else
{
_instance = CreateInstance<KedrExtensionSettings>();
}
return _instance;
}
}
public static void Save()
{
if (!_instance) return;
Directory.CreateDirectory(Path.GetDirectoryName(SettingsPath)!);
Object[] obj = { _instance };
InternalEditorUtility.SaveToSerializedFileAndForget(obj, SettingsPath, true);
}
}
public class KedrExtensionSettingsProvider : SettingsProvider
{
private SerializedObject _serializedObject;
[SettingsProvider]
public static SettingsProvider CreateProvider() => new KedrExtensionSettingsProvider();
private KedrExtensionSettingsProvider() : base("Project/KedrExtension", SettingsScope.Project)
{
}
public override void OnGUI(string searchContext)
{
_serializedObject ??= new SerializedObject(KedrExtensionSettings.Instance);
_serializedObject.Update();
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(_serializedObject.FindProperty("enableOpcodeShuffle"));
if (EditorGUI.EndChangeCheck())
{
_serializedObject.ApplyModifiedProperties();
KedrExtensionSettings.Save();
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f7ff0cf4c5c64d5fa0937a7be361d73f
timeCreated: 1769360995

View File

@ -0,0 +1,50 @@
using System.IO;
using System.Linq;
using HarmonyLib;
using HybridCLR.Editor;
using HybridCLR.Editor.Template;
using Obfuz.Settings;
using UnityEditor;
public static class OpCodeShuffleCommand
{
private static string TemplatePath => "Assets/Editor/KedrExtension/Templates";
[InitializeOnLoadMethod]
private static void Init()
{
var harmony = new Harmony("kedr.polymorphic.il");
harmony.PatchAll();
}
public static void GenerateOpCodes()
{
var opcodeMapping = Enumerable.Range(0, 248).Select(x => (byte)x).ToArray();
if (ObfuzSettings.Instance.polymorphicDllSettings.enable && KedrExtensionSettings.Instance.enableOpcodeShuffle)
{
var seed = HashUtil.Hash(ObfuzSettings.Instance.polymorphicDllSettings.codeGenerationSecretKey);
var rng = new System.Random((int)seed);
RandomUtil.Shuffle(opcodeMapping, rng);
}
var reverseOpcodeMapping = new byte[opcodeMapping.Length];
for (byte i = 0; i < opcodeMapping.Length; i++) reverseOpcodeMapping[opcodeMapping[i]] = i;
{
var frr = new FileRegionReplace(File.ReadAllText($"{TemplatePath}/Opcodes.h.tpl"));
var lines = Opcode.List.Select((op, i) => $"{op.Name} = {opcodeMapping[i]},");
frr.Replace("OPCODE_VALUE", string.Join('\n', lines));
var opcodesPath = $"{SettingsUtil.LocalIl2CppDir}/libil2cpp/hybridclr/metadata/Opcodes.h";
frr.Commit(opcodesPath);
}
{
var frr = new FileRegionReplace(File.ReadAllText($"{TemplatePath}/Opcodes.cpp.tpl"));
var lines = reverseOpcodeMapping.Select(i => Opcode.List[i].Info);
frr.Replace("OPCODE_INFO", string.Join('\n', lines));
var opcodesPath = $"{SettingsUtil.LocalIl2CppDir}/libil2cpp/hybridclr/metadata/Opcodes.cpp";
frr.Commit(opcodesPath);
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d379f53cce6e47908894ad3dae565fd4
timeCreated: 1769359627

View File

@ -0,0 +1,263 @@
public class Opcode
{
public string Name { get; private set; }
public string Info { get; private set; }
private Opcode(string name, string info)
{
Name = name;
Info = info;
}
public static readonly Opcode[] List =
{
new Opcode("NOP", "{ ArgType::None, 0, 255, OpcodeValue::NOP, FlowType::Next, 0 },"),
new Opcode("BREAK", "{ ArgType::None, 0, 255, OpcodeValue::BREAK, FlowType::Break, 0 },"),
new Opcode("LDARG_0", "{ ArgType::None, 0, 255, OpcodeValue::LDARG_0, FlowType::Next, 0 },"),
new Opcode("LDARG_1", "{ ArgType::None, 0, 255, OpcodeValue::LDARG_1, FlowType::Next, 1 },"),
new Opcode("LDARG_2", "{ ArgType::None, 0, 255, OpcodeValue::LDARG_2, FlowType::Next, 2 },"),
new Opcode("LDARG_3", "{ ArgType::None, 0, 255, OpcodeValue::LDARG_3, FlowType::Next, 3 },"),
new Opcode("LDLOC_0", "{ ArgType::None, 0, 255, OpcodeValue::LDLOC_0, FlowType::Next, 0 },"),
new Opcode("LDLOC_1", "{ ArgType::None, 0, 255, OpcodeValue::LDLOC_1, FlowType::Next, 1 },"),
new Opcode("LDLOC_2", "{ ArgType::None, 0, 255, OpcodeValue::LDLOC_2, FlowType::Next, 2 },"),
new Opcode("LDLOC_3", "{ ArgType::None, 0, 255, OpcodeValue::LDLOC_3, FlowType::Next, 3 },"),
new Opcode("STLOC_0", "{ ArgType::None, 0, 255, OpcodeValue::STLOC_0, FlowType::Next, 0 },"),
new Opcode("STLOC_1", "{ ArgType::None, 0, 255, OpcodeValue::STLOC_1, FlowType::Next, 1 },"),
new Opcode("STLOC_2", "{ ArgType::None, 0, 255, OpcodeValue::STLOC_2, FlowType::Next, 2 },"),
new Opcode("STLOC_3", "{ ArgType::None, 0, 255, OpcodeValue::STLOC_3, FlowType::Next, 3 },"),
new Opcode("LDARG_S", "{ ArgType::Data, 1, 255, OpcodeValue::LDARG_S, FlowType::Next, 0 },"),
new Opcode("LDARGA_S", "{ ArgType::Data, 1, 255, OpcodeValue::LDARGA_S, FlowType::Next, 0 },"),
new Opcode("STARG_S", "{ ArgType::Data, 1, 255, OpcodeValue::STARG_S, FlowType::Next, 0 },"),
new Opcode("LDLOC_S", "{ ArgType::Data, 1, 255, OpcodeValue::LDLOC_S, FlowType::Next, 0 },"),
new Opcode("LDLOCA_S", "{ ArgType::Data, 1, 255, OpcodeValue::LDLOCA_S, FlowType::Next, 0 },"),
new Opcode("STLOC_S", "{ ArgType::Data, 1, 255, OpcodeValue::STLOC_S, FlowType::Next, 0 },"),
new Opcode("LDNULL", "{ ArgType::None, 0, 255, OpcodeValue::LDNULL, FlowType::Next, 0 },"),
new Opcode("LDC_I4_M1", "{ ArgType::None, 0, 255, OpcodeValue::LDC_I4_M1, FlowType::Next, -1 },"),
new Opcode("LDC_I4_0", "{ ArgType::None, 0, 255, OpcodeValue::LDC_I4_0, FlowType::Next, 0 },"),
new Opcode("LDC_I4_1", "{ ArgType::None, 0, 255, OpcodeValue::LDC_I4_1, FlowType::Next, 1 },"),
new Opcode("LDC_I4_2", "{ ArgType::None, 0, 255, OpcodeValue::LDC_I4_2, FlowType::Next, 2 },"),
new Opcode("LDC_I4_3", "{ ArgType::None, 0, 255, OpcodeValue::LDC_I4_3, FlowType::Next, 3 },"),
new Opcode("LDC_I4_4", "{ ArgType::None, 0, 255, OpcodeValue::LDC_I4_4, FlowType::Next, 4 },"),
new Opcode("LDC_I4_5", "{ ArgType::None, 0, 255, OpcodeValue::LDC_I4_5, FlowType::Next, 5 },"),
new Opcode("LDC_I4_6", "{ ArgType::None, 0, 255, OpcodeValue::LDC_I4_6, FlowType::Next, 6 },"),
new Opcode("LDC_I4_7", "{ ArgType::None, 0, 255, OpcodeValue::LDC_I4_7, FlowType::Next, 7 },"),
new Opcode("LDC_I4_8", "{ ArgType::None, 0, 255, OpcodeValue::LDC_I4_8, FlowType::Next, 8 },"),
new Opcode("LDC_I4_S", "{ ArgType::Data, 1, 255, OpcodeValue::LDC_I4_S, FlowType::Next, 0 },"),
new Opcode("LDC_I4", "{ ArgType::Data, 4, 255, OpcodeValue::LDC_I4, FlowType::Next, 0 },"),
new Opcode("LDC_I8", "{ ArgType::Data, 8, 255, OpcodeValue::LDC_I8, FlowType::Next, 0 },"),
new Opcode("LDC_R4", "{ ArgType::Data, 4, 255, OpcodeValue::LDC_R4, FlowType::Next, 0 },"),
new Opcode("LDC_R8", "{ ArgType::Data, 8, 255, OpcodeValue::LDC_R8, FlowType::Next, 0 },"),
new Opcode("UNUSED99", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED99, FlowType::Next, 0 },"),
new Opcode("DUP", "{ ArgType::None, 0, 255, OpcodeValue::DUP, FlowType::Next, 0 },"),
new Opcode("POP", "{ ArgType::None, 0, 255, OpcodeValue::POP, FlowType::Next, 0 },"),
new Opcode("JMP", "{ ArgType::Data, 4, 255, OpcodeValue::JMP, FlowType::Call, 0 },"),
new Opcode("CALL", "{ ArgType::Data, 4, 255, OpcodeValue::CALL, FlowType::Call, 0 },"),
new Opcode("CALLI", "{ ArgType::Data, 4, 255, OpcodeValue::CALLI, FlowType::Call, 0 },"),
new Opcode("RET", "{ ArgType::StaticBranch, 0, 255, OpcodeValue::RET, FlowType::Return, 0 },"),
new Opcode("BR_S", "{ ArgType::BranchTarget, 1, 255, OpcodeValue::BR_S, FlowType::Branch, 0 },"),
new Opcode("BRFALSE_S", "{ ArgType::BranchTarget, 1, 255, OpcodeValue::BRFALSE_S, FlowType::CondBranch, 0 },"),
new Opcode("BRTRUE_S", "{ ArgType::BranchTarget, 1, 255, OpcodeValue::BRTRUE_S, FlowType::CondBranch, 0 },"),
new Opcode("BEQ_S", "{ ArgType::BranchTarget, 1, 255, OpcodeValue::BEQ_S, FlowType::CondBranch, 0 },"),
new Opcode("BGE_S", "{ ArgType::BranchTarget, 1, 255, OpcodeValue::BGE_S, FlowType::CondBranch, 0 },"),
new Opcode("BGT_S", "{ ArgType::BranchTarget, 1, 255, OpcodeValue::BGT_S, FlowType::CondBranch, 0 },"),
new Opcode("BLE_S", "{ ArgType::BranchTarget, 1, 255, OpcodeValue::BLE_S, FlowType::CondBranch, 0 },"),
new Opcode("BLT_S", "{ ArgType::BranchTarget, 1, 255, OpcodeValue::BLT_S, FlowType::CondBranch, 0 },"),
new Opcode("BNE_UN_S", "{ ArgType::BranchTarget, 1, 255, OpcodeValue::BNE_UN_S, FlowType::CondBranch, 0 },"),
new Opcode("BGE_UN_S", "{ ArgType::BranchTarget, 1, 255, OpcodeValue::BGE_UN_S, FlowType::CondBranch, 0 },"),
new Opcode("BGT_UN_S", "{ ArgType::BranchTarget, 1, 255, OpcodeValue::BGT_UN_S, FlowType::CondBranch, 0 },"),
new Opcode("BLE_UN_S", "{ ArgType::BranchTarget, 1, 255, OpcodeValue::BLE_UN_S, FlowType::CondBranch, 0 },"),
new Opcode("BLT_UN_S", "{ ArgType::BranchTarget, 1, 255, OpcodeValue::BLT_UN_S, FlowType::CondBranch, 0 },"),
new Opcode("BR", "{ ArgType::BranchTarget, 4, 255, OpcodeValue::BR, FlowType::Branch, 0 },"),
new Opcode("BRFALSE", "{ ArgType::BranchTarget, 4, 255, OpcodeValue::BRFALSE, FlowType::CondBranch, 0 },"),
new Opcode("BRTRUE", "{ ArgType::BranchTarget, 4, 255, OpcodeValue::BRTRUE, FlowType::CondBranch, 0 },"),
new Opcode("BEQ", "{ ArgType::BranchTarget, 4, 255, OpcodeValue::BEQ, FlowType::CondBranch, 0 },"),
new Opcode("BGE", "{ ArgType::BranchTarget, 4, 255, OpcodeValue::BGE, FlowType::CondBranch, 0 },"),
new Opcode("BGT", "{ ArgType::BranchTarget, 4, 255, OpcodeValue::BGT, FlowType::CondBranch, 0 },"),
new Opcode("BLE", "{ ArgType::BranchTarget, 4, 255, OpcodeValue::BLE, FlowType::CondBranch, 0 },"),
new Opcode("BLT", "{ ArgType::BranchTarget, 4, 255, OpcodeValue::BLT, FlowType::CondBranch, 0 },"),
new Opcode("BNE_UN", "{ ArgType::BranchTarget, 4, 255, OpcodeValue::BNE_UN, FlowType::CondBranch, 0 },"),
new Opcode("BGE_UN", "{ ArgType::BranchTarget, 4, 255, OpcodeValue::BGE_UN, FlowType::CondBranch, 0 },"),
new Opcode("BGT_UN", "{ ArgType::BranchTarget, 4, 255, OpcodeValue::BGT_UN, FlowType::CondBranch, 0 },"),
new Opcode("BLE_UN", "{ ArgType::BranchTarget, 4, 255, OpcodeValue::BLE_UN, FlowType::CondBranch, 0 },"),
new Opcode("BLT_UN", "{ ArgType::BranchTarget, 4, 255, OpcodeValue::BLT_UN, FlowType::CondBranch, 0 },"),
new Opcode("SWITCH", "{ ArgType::Switch, -1, 255, OpcodeValue::SWITCH, FlowType::CondBranch, 0 },"),
new Opcode("LDIND_I1", "{ ArgType::None, 0, 255, OpcodeValue::LDIND_I1, FlowType::Next, 0 },"),
new Opcode("LDIND_U1", "{ ArgType::None, 0, 255, OpcodeValue::LDIND_U1, FlowType::Next, 0 },"),
new Opcode("LDIND_I2", "{ ArgType::None, 0, 255, OpcodeValue::LDIND_I2, FlowType::Next, 0 },"),
new Opcode("LDIND_U2", "{ ArgType::None, 0, 255, OpcodeValue::LDIND_U2, FlowType::Next, 0 },"),
new Opcode("LDIND_I4", "{ ArgType::None, 0, 255, OpcodeValue::LDIND_I4, FlowType::Next, 0 },"),
new Opcode("LDIND_U4", "{ ArgType::None, 0, 255, OpcodeValue::LDIND_U4, FlowType::Next, 0 },"),
new Opcode("LDIND_I8", "{ ArgType::None, 0, 255, OpcodeValue::LDIND_I8, FlowType::Next, 0 },"),
new Opcode("LDIND_I", "{ ArgType::None, 0, 255, OpcodeValue::LDIND_I, FlowType::Next, 0 },"),
new Opcode("LDIND_R4", "{ ArgType::None, 0, 255, OpcodeValue::LDIND_R4, FlowType::Next, 0 },"),
new Opcode("LDIND_R8", "{ ArgType::None, 0, 255, OpcodeValue::LDIND_R8, FlowType::Next, 0 },"),
new Opcode("LDIND_REF", "{ ArgType::None, 0, 255, OpcodeValue::LDIND_REF, FlowType::Next, 0 },"),
new Opcode("STIND_REF", "{ ArgType::None, 0, 255, OpcodeValue::STIND_REF, FlowType::Next, 0 },"),
new Opcode("STIND_I1", "{ ArgType::None, 0, 255, OpcodeValue::STIND_I1, FlowType::Next, 0 },"),
new Opcode("STIND_I2", "{ ArgType::None, 0, 255, OpcodeValue::STIND_I2, FlowType::Next, 0 },"),
new Opcode("STIND_I4", "{ ArgType::None, 0, 255, OpcodeValue::STIND_I4, FlowType::Next, 0 },"),
new Opcode("STIND_I8", "{ ArgType::None, 0, 255, OpcodeValue::STIND_I8, FlowType::Next, 0 },"),
new Opcode("STIND_R4", "{ ArgType::None, 0, 255, OpcodeValue::STIND_R4, FlowType::Next, 0 },"),
new Opcode("STIND_R8", "{ ArgType::None, 0, 255, OpcodeValue::STIND_R8, FlowType::Next, 0 },"),
new Opcode("ADD", "{ ArgType::None, 0, 255, OpcodeValue::ADD, FlowType::Next, 0 },"),
new Opcode("SUB", "{ ArgType::None, 0, 255, OpcodeValue::SUB, FlowType::Next, 0 },"),
new Opcode("MUL", "{ ArgType::None, 0, 255, OpcodeValue::MUL, FlowType::Next, 0 },"),
new Opcode("DIV", "{ ArgType::None, 0, 255, OpcodeValue::DIV, FlowType::Next, 0 },"),
new Opcode("DIV_UN", "{ ArgType::None, 0, 255, OpcodeValue::DIV_UN, FlowType::Next, 0 },"),
new Opcode("REM", "{ ArgType::None, 0, 255, OpcodeValue::REM, FlowType::Next, 0 },"),
new Opcode("REM_UN", "{ ArgType::None, 0, 255, OpcodeValue::REM_UN, FlowType::Next, 0 },"),
new Opcode("AND", "{ ArgType::None, 0, 255, OpcodeValue::AND, FlowType::Next, 0 },"),
new Opcode("OR", "{ ArgType::None, 0, 255, OpcodeValue::OR, FlowType::Next, 0 },"),
new Opcode("XOR", "{ ArgType::None, 0, 255, OpcodeValue::XOR, FlowType::Next, 0 },"),
new Opcode("SHL", "{ ArgType::None, 0, 255, OpcodeValue::SHL, FlowType::Next, 0 },"),
new Opcode("SHR", "{ ArgType::None, 0, 255, OpcodeValue::SHR, FlowType::Next, 0 },"),
new Opcode("SHR_UN", "{ ArgType::None, 0, 255, OpcodeValue::SHR_UN, FlowType::Next, 0 },"),
new Opcode("NEG", "{ ArgType::None, 0, 255, OpcodeValue::NEG, FlowType::Next, 0 },"),
new Opcode("NOT", "{ ArgType::None, 0, 255, OpcodeValue::NOT, FlowType::Next, 0 },"),
new Opcode("CONV_I1", "{ ArgType::None, 0, 255, OpcodeValue::CONV_I1, FlowType::Next, 0 },"),
new Opcode("CONV_I2", "{ ArgType::None, 0, 255, OpcodeValue::CONV_I2, FlowType::Next, 0 },"),
new Opcode("CONV_I4", "{ ArgType::None, 0, 255, OpcodeValue::CONV_I4, FlowType::Next, 0 },"),
new Opcode("CONV_I8", "{ ArgType::None, 0, 255, OpcodeValue::CONV_I8, FlowType::Next, 0 },"),
new Opcode("CONV_R4", "{ ArgType::None, 0, 255, OpcodeValue::CONV_R4, FlowType::Next, 0 },"),
new Opcode("CONV_R8", "{ ArgType::None, 0, 255, OpcodeValue::CONV_R8, FlowType::Next, 0 },"),
new Opcode("CONV_U4", "{ ArgType::None, 0, 255, OpcodeValue::CONV_U4, FlowType::Next, 0 },"),
new Opcode("CONV_U8", "{ ArgType::None, 0, 255, OpcodeValue::CONV_U8, FlowType::Next, 0 },"),
new Opcode("CALLVIRT", "{ ArgType::Data, 4, 255, OpcodeValue::CALLVIRT, FlowType::Call, 0 },"),
new Opcode("CPOBJ", "{ ArgType::Data, 4, 255, OpcodeValue::CPOBJ, FlowType::Next, 0 },"),
new Opcode("LDOBJ", "{ ArgType::Data, 4, 255, OpcodeValue::LDOBJ, FlowType::Next, 0 },"),
new Opcode("LDSTR", "{ ArgType::Data, 4, 255, OpcodeValue::LDSTR, FlowType::Next, 0 },"),
new Opcode("NEWOBJ", "{ ArgType::Data, 4, 255, OpcodeValue::NEWOBJ, FlowType::Call, 0 },"),
new Opcode("CASTCLASS", "{ ArgType::Data, 4, 255, OpcodeValue::CASTCLASS, FlowType::Next, 0 },"),
new Opcode("ISINST", "{ ArgType::Data, 4, 255, OpcodeValue::ISINST, FlowType::Next, 0 },"),
new Opcode("CONV_R_UN", "{ ArgType::None, 0, 255, OpcodeValue::CONV_R_UN, FlowType::Next, 0 },"),
new Opcode("UNUSED58", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED58, FlowType::Next, 0 },"),
new Opcode("UNUSED1", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED1, FlowType::Next, 0 },"),
new Opcode("UNBOX", "{ ArgType::Data, 4, 255, OpcodeValue::UNBOX, FlowType::Next, 0 },"),
new Opcode("THROW", "{ ArgType::StaticBranch, 0, 255, OpcodeValue::THROW, FlowType::Throw, 0 },"),
new Opcode("LDFLD", "{ ArgType::Data, 4, 255, OpcodeValue::LDFLD, FlowType::Next, 0 },"),
new Opcode("LDFLDA", "{ ArgType::Data, 4, 255, OpcodeValue::LDFLDA, FlowType::Next, 0 },"),
new Opcode("STFLD", "{ ArgType::Data, 4, 255, OpcodeValue::STFLD, FlowType::Next, 0 },"),
new Opcode("LDSFLD", "{ ArgType::Data, 4, 255, OpcodeValue::LDSFLD, FlowType::Next, 0 },"),
new Opcode("LDSFLDA", "{ ArgType::Data, 4, 255, OpcodeValue::LDSFLDA, FlowType::Next, 0 },"),
new Opcode("STSFLD", "{ ArgType::Data, 4, 255, OpcodeValue::STSFLD, FlowType::Next, 0 },"),
new Opcode("STOBJ", "{ ArgType::Data, 4, 255, OpcodeValue::STOBJ, FlowType::Next, 0 },"),
new Opcode("CONV_OVF_I1_UN", "{ ArgType::None, 0, 255, OpcodeValue::CONV_OVF_I1_UN, FlowType::Next, 0 },"),
new Opcode("CONV_OVF_I2_UN", "{ ArgType::None, 0, 255, OpcodeValue::CONV_OVF_I2_UN, FlowType::Next, 0 },"),
new Opcode("CONV_OVF_I4_UN", "{ ArgType::None, 0, 255, OpcodeValue::CONV_OVF_I4_UN, FlowType::Next, 0 },"),
new Opcode("CONV_OVF_I8_UN", "{ ArgType::None, 0, 255, OpcodeValue::CONV_OVF_I8_UN, FlowType::Next, 0 },"),
new Opcode("CONV_OVF_U1_UN", "{ ArgType::None, 0, 255, OpcodeValue::CONV_OVF_U1_UN, FlowType::Next, 0 },"),
new Opcode("CONV_OVF_U2_UN", "{ ArgType::None, 0, 255, OpcodeValue::CONV_OVF_U2_UN, FlowType::Next, 0 },"),
new Opcode("CONV_OVF_U4_UN", "{ ArgType::None, 0, 255, OpcodeValue::CONV_OVF_U4_UN, FlowType::Next, 0 },"),
new Opcode("CONV_OVF_U8_UN", "{ ArgType::None, 0, 255, OpcodeValue::CONV_OVF_U8_UN, FlowType::Next, 0 },"),
new Opcode("CONV_OVF_I_UN", "{ ArgType::None, 0, 255, OpcodeValue::CONV_OVF_I_UN, FlowType::Next, 0 },"),
new Opcode("CONV_OVF_U_UN", "{ ArgType::None, 0, 255, OpcodeValue::CONV_OVF_U_UN, FlowType::Next, 0 },"),
new Opcode("BOX", "{ ArgType::Data, 4, 255, OpcodeValue::BOX, FlowType::Next, 0 },"),
new Opcode("NEWARR", "{ ArgType::Data, 4, 255, OpcodeValue::NEWARR, FlowType::Next, 0 },"),
new Opcode("LDLEN", "{ ArgType::None, 0, 255, OpcodeValue::LDLEN, FlowType::Next, 0 },"),
new Opcode("LDELEMA", "{ ArgType::Data, 4, 255, OpcodeValue::LDELEMA, FlowType::Next, 0 },"),
new Opcode("LDELEM_I1", "{ ArgType::None, 0, 255, OpcodeValue::LDELEM_I1, FlowType::Next, 0 },"),
new Opcode("LDELEM_U1", "{ ArgType::None, 0, 255, OpcodeValue::LDELEM_U1, FlowType::Next, 0 },"),
new Opcode("LDELEM_I2", "{ ArgType::None, 0, 255, OpcodeValue::LDELEM_I2, FlowType::Next, 0 },"),
new Opcode("LDELEM_U2", "{ ArgType::None, 0, 255, OpcodeValue::LDELEM_U2, FlowType::Next, 0 },"),
new Opcode("LDELEM_I4", "{ ArgType::None, 0, 255, OpcodeValue::LDELEM_I4, FlowType::Next, 0 },"),
new Opcode("LDELEM_U4", "{ ArgType::None, 0, 255, OpcodeValue::LDELEM_U4, FlowType::Next, 0 },"),
new Opcode("LDELEM_I8", "{ ArgType::None, 0, 255, OpcodeValue::LDELEM_I8, FlowType::Next, 0 },"),
new Opcode("LDELEM_I", "{ ArgType::None, 0, 255, OpcodeValue::LDELEM_I, FlowType::Next, 0 },"),
new Opcode("LDELEM_R4", "{ ArgType::None, 0, 255, OpcodeValue::LDELEM_R4, FlowType::Next, 0 },"),
new Opcode("LDELEM_R8", "{ ArgType::None, 0, 255, OpcodeValue::LDELEM_R8, FlowType::Next, 0 },"),
new Opcode("LDELEM_REF", "{ ArgType::None, 0, 255, OpcodeValue::LDELEM_REF, FlowType::Next, 0 },"),
new Opcode("STELEM_I", "{ ArgType::None, 0, 255, OpcodeValue::STELEM_I, FlowType::Next, 0 },"),
new Opcode("STELEM_I1", "{ ArgType::None, 0, 255, OpcodeValue::STELEM_I1, FlowType::Next, 0 },"),
new Opcode("STELEM_I2", "{ ArgType::None, 0, 255, OpcodeValue::STELEM_I2, FlowType::Next, 0 },"),
new Opcode("STELEM_I4", "{ ArgType::None, 0, 255, OpcodeValue::STELEM_I4, FlowType::Next, 0 },"),
new Opcode("STELEM_I8", "{ ArgType::None, 0, 255, OpcodeValue::STELEM_I8, FlowType::Next, 0 },"),
new Opcode("STELEM_R4", "{ ArgType::None, 0, 255, OpcodeValue::STELEM_R4, FlowType::Next, 0 },"),
new Opcode("STELEM_R8", "{ ArgType::None, 0, 255, OpcodeValue::STELEM_R8, FlowType::Next, 0 },"),
new Opcode("STELEM_REF", "{ ArgType::None, 0, 255, OpcodeValue::STELEM_REF, FlowType::Next, 0 },"),
new Opcode("LDELEM", "{ ArgType::Data, 4, 255, OpcodeValue::LDELEM, FlowType::Next, 0 },"),
new Opcode("STELEM", "{ ArgType::Data, 4, 255, OpcodeValue::STELEM, FlowType::Next, 0 },"),
new Opcode("UNBOX_ANY", "{ ArgType::Data, 4, 255, OpcodeValue::UNBOX_ANY, FlowType::Next, 0 },"),
new Opcode("UNUSED5", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED5, FlowType::Next, 0 },"),
new Opcode("UNUSED6", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED6, FlowType::Next, 0 },"),
new Opcode("UNUSED7", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED7, FlowType::Next, 0 },"),
new Opcode("UNUSED8", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED8, FlowType::Next, 0 },"),
new Opcode("UNUSED9", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED9, FlowType::Next, 0 },"),
new Opcode("UNUSED10", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED10, FlowType::Next, 0 },"),
new Opcode("UNUSED11", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED11, FlowType::Next, 0 },"),
new Opcode("UNUSED12", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED12, FlowType::Next, 0 },"),
new Opcode("UNUSED13", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED13, FlowType::Next, 0 },"),
new Opcode("UNUSED14", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED14, FlowType::Next, 0 },"),
new Opcode("UNUSED15", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED15, FlowType::Next, 0 },"),
new Opcode("UNUSED16", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED16, FlowType::Next, 0 },"),
new Opcode("UNUSED17", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED17, FlowType::Next, 0 },"),
new Opcode("CONV_OVF_I1", "{ ArgType::None, 0, 255, OpcodeValue::CONV_OVF_I1, FlowType::Next, 0 },"),
new Opcode("CONV_OVF_U1", "{ ArgType::None, 0, 255, OpcodeValue::CONV_OVF_U1, FlowType::Next, 0 },"),
new Opcode("CONV_OVF_I2", "{ ArgType::None, 0, 255, OpcodeValue::CONV_OVF_I2, FlowType::Next, 0 },"),
new Opcode("CONV_OVF_U2", "{ ArgType::None, 0, 255, OpcodeValue::CONV_OVF_U2, FlowType::Next, 0 },"),
new Opcode("CONV_OVF_I4", "{ ArgType::None, 0, 255, OpcodeValue::CONV_OVF_I4, FlowType::Next, 0 },"),
new Opcode("CONV_OVF_U4", "{ ArgType::None, 0, 255, OpcodeValue::CONV_OVF_U4, FlowType::Next, 0 },"),
new Opcode("CONV_OVF_I8", "{ ArgType::None, 0, 255, OpcodeValue::CONV_OVF_I8, FlowType::Next, 0 },"),
new Opcode("CONV_OVF_U8", "{ ArgType::None, 0, 255, OpcodeValue::CONV_OVF_U8, FlowType::Next, 0 },"),
new Opcode("UNUSED50", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED50, FlowType::Next, 0 },"),
new Opcode("UNUSED18", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED18, FlowType::Next, 0 },"),
new Opcode("UNUSED19", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED19, FlowType::Next, 0 },"),
new Opcode("UNUSED20", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED20, FlowType::Next, 0 },"),
new Opcode("UNUSED21", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED21, FlowType::Next, 0 },"),
new Opcode("UNUSED22", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED22, FlowType::Next, 0 },"),
new Opcode("UNUSED23", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED23, FlowType::Next, 0 },"),
new Opcode("REFANYVAL", "{ ArgType::Data, 4, 255, OpcodeValue::REFANYVAL, FlowType::Next, 0 },"),
new Opcode("CKFINITE", "{ ArgType::None, 0, 255, OpcodeValue::CKFINITE, FlowType::Next, 0 },"),
new Opcode("UNUSED24", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED24, FlowType::Next, 0 },"),
new Opcode("UNUSED25", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED25, FlowType::Next, 0 },"),
new Opcode("MKREFANY", "{ ArgType::Data, 4, 255, OpcodeValue::MKREFANY, FlowType::Next, 0 },"),
new Opcode("UNUSED59", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED59, FlowType::Next, 0 },"),
new Opcode("UNUSED60", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED60, FlowType::Next, 0 },"),
new Opcode("UNUSED61", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED61, FlowType::Next, 0 },"),
new Opcode("UNUSED62", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED62, FlowType::Next, 0 },"),
new Opcode("UNUSED63", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED63, FlowType::Next, 0 },"),
new Opcode("UNUSED64", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED64, FlowType::Next, 0 },"),
new Opcode("UNUSED65", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED65, FlowType::Next, 0 },"),
new Opcode("UNUSED66", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED66, FlowType::Next, 0 },"),
new Opcode("UNUSED67", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED67, FlowType::Next, 0 },"),
new Opcode("LDTOKEN", "{ ArgType::Data, 4, 255, OpcodeValue::LDTOKEN, FlowType::Next, 0 },"),
new Opcode("CONV_U2", "{ ArgType::None, 0, 255, OpcodeValue::CONV_U2, FlowType::Next, 0 },"),
new Opcode("CONV_U1", "{ ArgType::None, 0, 255, OpcodeValue::CONV_U1, FlowType::Next, 0 },"),
new Opcode("CONV_I", "{ ArgType::None, 0, 255, OpcodeValue::CONV_I, FlowType::Next, 0 },"),
new Opcode("CONV_OVF_I", "{ ArgType::None, 0, 255, OpcodeValue::CONV_OVF_I, FlowType::Next, 0 },"),
new Opcode("CONV_OVF_U", "{ ArgType::None, 0, 255, OpcodeValue::CONV_OVF_U, FlowType::Next, 0 },"),
new Opcode("ADD_OVF", "{ ArgType::None, 0, 255, OpcodeValue::ADD_OVF, FlowType::Next, 0 },"),
new Opcode("ADD_OVF_UN", "{ ArgType::None, 0, 255, OpcodeValue::ADD_OVF_UN, FlowType::Next, 0 },"),
new Opcode("MUL_OVF", "{ ArgType::None, 0, 255, OpcodeValue::MUL_OVF, FlowType::Next, 0 },"),
new Opcode("MUL_OVF_UN", "{ ArgType::None, 0, 255, OpcodeValue::MUL_OVF_UN, FlowType::Next, 0 },"),
new Opcode("SUB_OVF", "{ ArgType::None, 0, 255, OpcodeValue::SUB_OVF, FlowType::Next, 0 },"),
new Opcode("SUB_OVF_UN", "{ ArgType::None, 0, 255, OpcodeValue::SUB_OVF_UN, FlowType::Next, 0 },"),
new Opcode("ENDFINALLY", "{ ArgType::StaticBranch, 0, 255, OpcodeValue::ENDFINALLY, FlowType::Return, 0 },"),
new Opcode("LEAVE", "{ ArgType::BranchTarget, 4, 255, OpcodeValue::LEAVE, FlowType::Branch, 0 },"),
new Opcode("LEAVE_S", "{ ArgType::BranchTarget, 1, 255, OpcodeValue::LEAVE_S, FlowType::Branch, 0 },"),
new Opcode("STIND_I", "{ ArgType::None, 0, 255, OpcodeValue::STIND_I, FlowType::Next, 0 },"),
new Opcode("CONV_U", "{ ArgType::None, 0, 255, OpcodeValue::CONV_U, FlowType::Next, 0 },"),
new Opcode("UNUSED26", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED26, FlowType::Next, 0 },"),
new Opcode("UNUSED27", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED27, FlowType::Next, 0 },"),
new Opcode("UNUSED28", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED28, FlowType::Next, 0 },"),
new Opcode("UNUSED29", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED29, FlowType::Next, 0 },"),
new Opcode("UNUSED30", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED30, FlowType::Next, 0 },"),
new Opcode("UNUSED31", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED31, FlowType::Next, 0 },"),
new Opcode("UNUSED32", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED32, FlowType::Next, 0 },"),
new Opcode("UNUSED33", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED33, FlowType::Next, 0 },"),
new Opcode("UNUSED34", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED34, FlowType::Next, 0 },"),
new Opcode("UNUSED35", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED35, FlowType::Next, 0 },"),
new Opcode("UNUSED36", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED36, FlowType::Next, 0 },"),
new Opcode("UNUSED37", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED37, FlowType::Next, 0 },"),
new Opcode("UNUSED38", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED38, FlowType::Next, 0 },"),
new Opcode("UNUSED39", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED39, FlowType::Next, 0 },"),
new Opcode("UNUSED40", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED40, FlowType::Next, 0 },"),
new Opcode("UNUSED41", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED41, FlowType::Next, 0 },"),
new Opcode("UNUSED42", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED42, FlowType::Next, 0 },"),
new Opcode("UNUSED43", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED43, FlowType::Next, 0 },"),
new Opcode("UNUSED44", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED44, FlowType::Next, 0 },"),
new Opcode("UNUSED45", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED45, FlowType::Next, 0 },"),
new Opcode("UNUSED46", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED46, FlowType::Next, 0 },"),
new Opcode("UNUSED47", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED47, FlowType::Next, 0 },"),
new Opcode("UNUSED48", "{ ArgType::None, 0, 255, OpcodeValue::UNUSED48, FlowType::Next, 0 },"),
};
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 93278fac1f0d4baea60db599f3f6affb
timeCreated: 1769252314

View File

@ -0,0 +1,96 @@
using System;
using System.Linq;
using dnlib.DotNet.Emit;
using dnlib.DotNet.PolymorphicWriter;
using dnlib.DotNet.Writer;
using HarmonyLib;
using Obfuz.Settings;
internal static class DnlibPolymorphicContext
{
[ThreadStatic] public static byte[] OpcodeMapping;
}
[HarmonyPatch(typeof(PolymorphicMetadata), "WriteMethodBodies")]
static class WriteMethodBodiesPatch
{
static void Prefix()
{
if (!KedrExtensionSettings.Instance.enableOpcodeShuffle)
return;
var seed = HashUtil.Hash(ObfuzSettings.Instance.polymorphicDllSettings.codeGenerationSecretKey);
var opcodeMapping = Enumerable.Range(0, 248).Select(x => (byte)x).ToArray();
var rng = new System.Random((int)seed);
RandomUtil.Shuffle(opcodeMapping, rng);
DnlibPolymorphicContext.OpcodeMapping = opcodeMapping;
}
static void Finalizer()
{
DnlibPolymorphicContext.OpcodeMapping = null;
}
}
[HarmonyPatch(typeof(MethodBodyWriterBase), "WriteOpCode")]
static class WriteOpCodePatch
{
static bool Prefix(ref ArrayWriter writer, Instruction instr)
{
if (DnlibPolymorphicContext.OpcodeMapping is null)
return true;
WriteOpCode(ref writer, instr);
return false;
}
private static void WriteOpCode(ref ArrayWriter writer, Instruction instr)
{
var code = (int)instr.OpCode.Code;
int num = code >> 8;
if (code <= 255)
{
if (code < (int)dnlib.DotNet.Emit.Code.Prefix7)
{
code = DnlibPolymorphicContext.OpcodeMapping[code];
}
writer.WriteByte((byte)code);
return;
}
switch (num)
{
case 240:
case 241:
case 242:
case 243:
case 244:
case 245:
case 246:
case 247:
case 248:
case 249:
case 250:
case 251:
case 254:
writer.WriteByte((byte)num);
writer.WriteByte((byte)instr.OpCode.Code);
return;
}
switch (instr.OpCode.Code)
{
case dnlib.DotNet.Emit.Code.UNKNOWN1:
writer.WriteByte(0);
break;
case dnlib.DotNet.Emit.Code.UNKNOWN2:
writer.WriteUInt16(0);
break;
default:
throw new Exception("Unknown opcode");
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d90bfe061d4540ae98a5874651d08765
timeCreated: 1769346479

View File

@ -0,0 +1,13 @@
using System;
internal static class RandomUtil
{
public static void Shuffle<T>(T[] array, Random random)
{
for (var num = array.Length - 1; num > 0; num--)
{
var index = random.Next(num + 1);
(array[num], array[index]) = (array[index], array[num]);
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 46e5ded5306d4193a357f9646d60a114
timeCreated: 1769350665

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 45073aab7c974d87a6d7ba3ba2e3b23c
timeCreated: 1769251223

View File

@ -0,0 +1,100 @@
#include "Opcodes.h"
#include "MetadataUtil.h"
namespace hybridclr
{
namespace metadata
{
OpCodeInfo g_opcodeInfos[OpcodeCount] =
{
//!!!{{OPCODE_INFO
//!!!}}OPCODE_INFO
{ ArgType::None, 0, 255, OpcodeValue::PREFIX7, FlowType::Meta, 0 },
{ ArgType::None, 0, 255, OpcodeValue::PREFIX6, FlowType::Meta, 0 },
{ ArgType::None, 0, 255, OpcodeValue::PREFIX5, FlowType::Meta, 0 },
{ ArgType::None, 0, 255, OpcodeValue::PREFIX4, FlowType::Meta, 0 },
{ ArgType::None, 0, 255, OpcodeValue::PREFIX3, FlowType::Meta, 0 },
{ ArgType::None, 0, 255, OpcodeValue::PREFIX2, FlowType::Meta, 0 },
{ ArgType::None, 0, 255, OpcodeValue::PREFIX1, FlowType::Meta, 0 },
{ ArgType::None, 0, 255, OpcodeValue::PREFIXREF, FlowType::Meta, 0 },
{ ArgType::None, 0, 254, OpcodeValue::ARGLIST, FlowType::Next, 0 },
{ ArgType::None, 0, 254, OpcodeValue::CEQ, FlowType::Next, 0 },
{ ArgType::None, 0, 254, OpcodeValue::CGT, FlowType::Next, 0 },
{ ArgType::None, 0, 254, OpcodeValue::CGT_UN, FlowType::Next, 0 },
{ ArgType::None, 0, 254, OpcodeValue::CLT, FlowType::Next, 0 },
{ ArgType::None, 0, 254, OpcodeValue::CLT_UN, FlowType::Next, 0 },
{ ArgType::Data, 4, 254, OpcodeValue::LDFTN, FlowType::Next, 0 },
{ ArgType::Data, 4, 254, OpcodeValue::LDVIRTFTN, FlowType::Next, 0 },
{ ArgType::None, 0, 254, OpcodeValue::UNUSED56, FlowType::Next, 0 },
{ ArgType::Data, 2, 254, OpcodeValue::LDARG, FlowType::Next, 0 },
{ ArgType::Data, 2, 254, OpcodeValue::LDARGA, FlowType::Next, 0 },
{ ArgType::Data, 2, 254, OpcodeValue::STARG, FlowType::Next, 0 },
{ ArgType::Data, 2, 254, OpcodeValue::LDLOC, FlowType::Next, 0 },
{ ArgType::Data, 2, 254, OpcodeValue::LDLOCA, FlowType::Next, 0 },
{ ArgType::Data, 2, 254, OpcodeValue::STLOC, FlowType::Next, 0 },
{ ArgType::None, 0, 254, OpcodeValue::LOCALLOC, FlowType::Next, 0 },
{ ArgType::None, 0, 254, OpcodeValue::UNUSED57, FlowType::Next, 0 },
{ ArgType::None, 0, 254, OpcodeValue::ENDFILTER, FlowType::Return, 0 },
{ ArgType::Data, 1, 254, OpcodeValue::UNALIGNED_, FlowType::Meta, 0 },
{ ArgType::None, 0, 254, OpcodeValue::VOLATILE_, FlowType::Meta, 0 },
{ ArgType::None, 0, 254, OpcodeValue::TAIL_, FlowType::Meta, 0 },
{ ArgType::Data, 4, 254, OpcodeValue::INITOBJ, FlowType::Next, 0 },
{ ArgType::Data, 4, 254, OpcodeValue::CONSTRAINED_, FlowType::Meta, 0 },
{ ArgType::None, 0, 254, OpcodeValue::CPBLK, FlowType::Next, 0 },
{ ArgType::None, 0, 254, OpcodeValue::INITBLK, FlowType::Next, 0 },
{ ArgType::Data, 1, 254, OpcodeValue::NO_, FlowType::Next, 0 },
{ ArgType::StaticBranch, 0, 254, OpcodeValue::RETHROW, FlowType::Throw, 0 },
{ ArgType::None, 0, 254, OpcodeValue::UNUSED, FlowType::Next, 0 },
{ ArgType::Data, 4, 254, OpcodeValue::SIZEOF, FlowType::Next, 0 },
{ ArgType::None, 0, 254, OpcodeValue::REFANYTYPE, FlowType::Next, 0 },
{ ArgType::None, 0, 254, OpcodeValue::READONLY_, FlowType::Meta, 0 },
{ ArgType::None, 0, 254, OpcodeValue::UNUSED53, FlowType::Next, 0 },
{ ArgType::None, 0, 254, OpcodeValue::UNUSED54, FlowType::Next, 0 },
{ ArgType::None, 0, 254, OpcodeValue::UNUSED55, FlowType::Next, 0 },
{ ArgType::None, 0, 254, OpcodeValue::UNUSED70, FlowType::Next, 0 },
{ ArgType::None, 0, 0, OpcodeValue::ILLEGAL, FlowType::Meta, 0 },
{ ArgType::None, 0, 0, OpcodeValue::ENDMAC, FlowType::Meta, 0 },
};
const OpCodeInfo* DecodeOpCodeInfo(const byte*& ip, const byte* end)
{
if (ip >= end)
{
return nullptr;
}
byte c = *ip;
if (c < (byte)OpcodeValue::PREFIX7)
{
return &g_opcodeInfos[c];
}
else if (c == (byte)OpcodeValue::PREFIX1)
{
++ip;
if (ip >= end)
{
return nullptr;
}
return &g_opcodeInfos[(int)(*ip) + (int)256];
}
else
{
IL2CPP_ASSERT(false && "unknown prefix");
return nullptr;
}
}
uint32_t GetOpCodeSize(const byte*& ip, const OpCodeInfo* opCodeInfo)
{
if (opCodeInfo->inlineType != ArgType::Switch)
{
return 1 + opCodeInfo->inlineParam;
}
else
{
return metadata::GetI4LittleEndian(ip + 1) * 4 + 5;
}
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 5bb248beffc141cc9de9051b74dc1114
timeCreated: 1769348363

View File

@ -0,0 +1,106 @@
#pragma once
#include "../CommonDef.h"
namespace hybridclr
{
namespace metadata
{
enum class OpcodeValue : uint8_t
{
//!!!{{OPCODE_VALUE
//!!!}}OPCODE_VALUE
PREFIX7 = 248,
PREFIX6 = 249,
PREFIX5 = 250,
PREFIX4 = 251,
PREFIX3 = 252,
PREFIX2 = 253,
PREFIX1 = 254,
PREFIXREF = 255,
ARGLIST = 0,
CEQ = 1,
CGT = 2,
CGT_UN = 3,
CLT = 4,
CLT_UN = 5,
LDFTN = 6,
LDVIRTFTN = 7,
UNUSED56 = 8,
LDARG = 9,
LDARGA = 10,
STARG = 11,
LDLOC = 12,
LDLOCA = 13,
STLOC = 14,
LOCALLOC = 15,
UNUSED57 = 16,
ENDFILTER = 17,
UNALIGNED_ = 18,
VOLATILE_ = 19,
TAIL_ = 20,
INITOBJ = 21,
CONSTRAINED_ = 22,
CPBLK = 23,
INITBLK = 24,
NO_ = 25,
RETHROW = 26,
UNUSED = 27,
SIZEOF = 28,
REFANYTYPE = 29,
READONLY_ = 30,
UNUSED53 = 31,
UNUSED54 = 32,
UNUSED55 = 33,
UNUSED70 = 34,
ILLEGAL = 0,
ENDMAC = 0,
};
enum class FlowType
{
Next,
Branch,
CondBranch,
Call,
Return,
Meta,
Throw,
Break,
};
enum class ArgType
{
None,
Data,
StaticBranch,
BranchTarget,
Switch,
};
enum class OpCodeKind
{
Primitive,
ObjModel,
Macro,
Prefix,
Nternal,
};
struct OpCodeInfo
{
ArgType inlineType;
int32_t inlineParam;
uint8_t flag;
OpcodeValue baseOpValue;
FlowType flow;
int32_t constValue;
};
const int OpcodeCount = 293;
extern OpCodeInfo g_opcodeInfos[OpcodeCount];
const OpCodeInfo* DecodeOpCodeInfo(const byte*& ip, const byte* end);
uint32_t GetOpCodeSize(const byte*& ip, const OpCodeInfo* opCodeInfo);
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: aac9ffefb7d94ade9f9b20c3b7d72119
timeCreated: 1769251256

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 476d5384fffe3ae49aec8684c3f03a8e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

BIN
ProjectNLD/Assets/Editor/KedrExtension/ThirdParty/0Harmony.dll (Stored with Git LFS) vendored Normal file

Binary file not shown.

View File

@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: c79e180049bafa24bba6eca16558f653
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant: