diff --git a/Obfuz/Assets/Bootstrap.cs b/Obfuz/Assets/Bootstrap.cs deleted file mode 100644 index 6adb0b8..0000000 --- a/Obfuz/Assets/Bootstrap.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Obfuz; -using Obfuz.EncryptionVM; -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - - -public class Bootstrap : MonoBehaviour -{ - [ObfuzIgnore] - [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterAssembliesLoaded)] - private static void SetUpStaticSecret() - { - Debug.Log("SetUpStaticSecret begin"); - EncryptionService.Encryptor = new GeneratedEncryptionVirtualMachine(Resources.Load("Obfuz/defaultStaticSecretKey").bytes); - Debug.Log("SetUpStaticSecret end"); - } - - public int Add(int a, int b) - { - return a + b; - } - - void Start() - { - int a = Add(100, 200); - Debug.Log($"a = {a}"); - } -} diff --git a/Obfuz/Assets/Bootstrap.cs.meta b/Obfuz/Assets/Bootstrap.cs.meta deleted file mode 100644 index ff424e0..0000000 --- a/Obfuz/Assets/Bootstrap.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 639006a739675484884778c298eebdc4 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Assets/Obfuz.meta b/Obfuz/Assets/Obfuz.meta deleted file mode 100644 index 5b730e1..0000000 --- a/Obfuz/Assets/Obfuz.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 5eee1172624990e4cb08bd171f20cbaf -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Assets/Obfuz/GeneratedEncryptionVirtualMachine.cs b/Obfuz/Assets/Obfuz/GeneratedEncryptionVirtualMachine.cs deleted file mode 100644 index 3e74008..0000000 --- a/Obfuz/Assets/Obfuz/GeneratedEncryptionVirtualMachine.cs +++ /dev/null @@ -1,4522 +0,0 @@ -/// This file is auto-generated by Obfuz. Do not modify it. -/// -/// Version: 0 -/// SecretKey: Obfuz -/// OpCodeCount: 256 - -namespace Obfuz.EncryptionVM -{ - public class GeneratedEncryptionVirtualMachine : Obfuz.EncryptorBase - { - - private const int kOpCodeBits = 8; - - private const int kOpCodeCount = 256; - - private const int kOpCodeMask = 255; - - - - private readonly int[] _secretKey; - - public GeneratedEncryptionVirtualMachine(byte[] secretKey) - { - this._secretKey = ConvertToIntKey(secretKey); - } - - public override int OpCodeCount => kOpCodeCount; - - public override int Encrypt(int value, int opts, int salt) - { - uint uopts = (uint)opts; - uint revertOps = 0; - while (uopts != 0) - { - uint opCode = uopts & kOpCodeMask; - revertOps <<= kOpCodeBits; - revertOps |= opCode; - uopts >>= kOpCodeBits; - } - - while (revertOps != 0) - { - uint opCode = revertOps & kOpCodeMask; - value = ExecuteEncrypt(value, (int)opCode, salt); - revertOps >>= kOpCodeBits; - } - return value; - } - - public override int Decrypt(int value, int opts, int salt) - { - uint uopts = (uint)opts; - while (uopts != 0) - { - uint opCode = uopts & kOpCodeMask; - value = ExecuteDecrypt(value, (int)opCode, salt); - uopts >>= kOpCodeBits; - } - return value; - } - - - private int ExecuteEncrypt(int value, int opCode, int salt) - { - switch (opCode) - { - case 0: - { - // MultipleInstruction - value = value * 598188269 + _secretKey[84] + salt; - return value; - } - case 1: - { - // MultipleRotateXorInstruction - value = value * 1350058129 + _secretKey[136]; - uint part1 = (uint)value << 4; - uint part2 = (uint)value >> (32 - 4); - value = (int)(part1 | part2); - value ^= 1817406469 ^ salt; - return value; - } - case 2: - { - // MultipleXorRotateInstruction - value = value * -1144218503 + _secretKey[246]; - value ^= -1498541961 ^ salt; - uint part1 = (uint)value << 5; - uint part2 = (uint)value >> (32 - 5); - value = (int)(part1 | part2); - return value; - } - case 3: - { - // AddRotateXorInstruction - value += -1207833585 + _secretKey[26]; - uint part1 = (uint)value << 0; - uint part2 = (uint)value >> (32 - 0); - value = (int)(part1 | part2); - value ^= 29411710 ^ salt; - return value; - } - case 4: - { - // BitRotateInstruction - uint part1 = (uint)value << 18; - uint part2 = (uint)value >> (32 - 18); - value = ((int)(part1 | part2) ^ _secretKey[85]) + salt; - return value; - } - case 5: - { - // MultipleXorRotateInstruction - value = value * -1447238259 + _secretKey[165]; - value ^= 86149918 ^ salt; - uint part1 = (uint)value << 0; - uint part2 = (uint)value >> (32 - 0); - value = (int)(part1 | part2); - return value; - } - case 6: - { - // AddRotateXorInstruction - value += -1856354856 + _secretKey[178]; - uint part1 = (uint)value << 29; - uint part2 = (uint)value >> (32 - 29); - value = (int)(part1 | part2); - value ^= -1262500500 ^ salt; - return value; - } - case 7: - { - // XorInstruction - value = ((value ^ _secretKey[53]) + salt) ^ 665464645; - return value; - } - case 8: - { - // XorMultipleRotateInstruction - value ^= -1044567439 ^ salt; - value = value * -1860181607 + _secretKey[206]; - uint part1 = (uint)value << 16; - uint part2 = (uint)value >> (32 - 16); - value = (int)(part1 | part2); - return value; - } - case 9: - { - // MultipleInstruction - value = value * 522878123 + _secretKey[196] + salt; - return value; - } - case 10: - { - // XorAddRotateInstruction - value ^= -755609206 ^ salt; - value += -1035239660 + _secretKey[199]; - uint part1 = (uint)value << 10; - uint part2 = (uint)value >> (32 - 10); - value = (int)(part1 | part2); - return value; - } - case 11: - { - // AddInstruction - value = ((value + _secretKey[89]) ^ salt) + -1177184477; - return value; - } - case 12: - { - // BitRotateInstruction - uint part1 = (uint)value << 29; - uint part2 = (uint)value >> (32 - 29); - value = ((int)(part1 | part2) ^ _secretKey[23]) + salt; - return value; - } - case 13: - { - // XorMultipleRotateInstruction - value ^= -1510419150 ^ salt; - value = value * -93709937 + _secretKey[68]; - uint part1 = (uint)value << 19; - uint part2 = (uint)value >> (32 - 19); - value = (int)(part1 | part2); - return value; - } - case 14: - { - // MultipleRotateXorInstruction - value = value * 2015893433 + _secretKey[156]; - uint part1 = (uint)value << 6; - uint part2 = (uint)value >> (32 - 6); - value = (int)(part1 | part2); - value ^= -1134639492 ^ salt; - return value; - } - case 15: - { - // BitRotateInstruction - uint part1 = (uint)value << 7; - uint part2 = (uint)value >> (32 - 7); - value = ((int)(part1 | part2) ^ _secretKey[95]) + salt; - return value; - } - case 16: - { - // XorMultipleRotateInstruction - value ^= -759315565 ^ salt; - value = value * -436699251 + _secretKey[79]; - uint part1 = (uint)value << 6; - uint part2 = (uint)value >> (32 - 6); - value = (int)(part1 | part2); - return value; - } - case 17: - { - // MultipleRotateXorInstruction - value = value * 1266530571 + _secretKey[75]; - uint part1 = (uint)value << 2; - uint part2 = (uint)value >> (32 - 2); - value = (int)(part1 | part2); - value ^= -3885258 ^ salt; - return value; - } - case 18: - { - // MultipleXorRotateInstruction - value = value * -259404705 + _secretKey[153]; - value ^= 1207613963 ^ salt; - uint part1 = (uint)value << 9; - uint part2 = (uint)value >> (32 - 9); - value = (int)(part1 | part2); - return value; - } - case 19: - { - // MultipleRotateXorInstruction - value = value * 1042624059 + _secretKey[86]; - uint part1 = (uint)value << 11; - uint part2 = (uint)value >> (32 - 11); - value = (int)(part1 | part2); - value ^= 792769043 ^ salt; - return value; - } - case 20: - { - // AddInstruction - value = ((value + _secretKey[194]) ^ salt) + -512520382; - return value; - } - case 21: - { - // XorInstruction - value = ((value ^ _secretKey[195]) + salt) ^ -1864951858; - return value; - } - case 22: - { - // BitRotateInstruction - uint part1 = (uint)value << 15; - uint part2 = (uint)value >> (32 - 15); - value = ((int)(part1 | part2) ^ _secretKey[2]) + salt; - return value; - } - case 23: - { - // MultipleInstruction - value = value * -463118297 + _secretKey[203] + salt; - return value; - } - case 24: - { - // AddInstruction - value = ((value + _secretKey[110]) ^ salt) + 2026667919; - return value; - } - case 25: - { - // AddXorRotateInstruction - value += 848657810 + _secretKey[133]; - value ^= 392708821 ^ salt; - uint part1 = (uint)value << 15; - uint part2 = (uint)value >> (32 - 15); - value = (int)(part1 | part2); - return value; - } - case 26: - { - // BitRotateInstruction - uint part1 = (uint)value << 5; - uint part2 = (uint)value >> (32 - 5); - value = ((int)(part1 | part2) ^ _secretKey[93]) + salt; - return value; - } - case 27: - { - // XorAddRotateInstruction - value ^= 1294662302 ^ salt; - value += 1284012732 + _secretKey[58]; - uint part1 = (uint)value << 30; - uint part2 = (uint)value >> (32 - 30); - value = (int)(part1 | part2); - return value; - } - case 28: - { - // XorMultipleRotateInstruction - value ^= -1438081752 ^ salt; - value = value * -1171400509 + _secretKey[138]; - uint part1 = (uint)value << 29; - uint part2 = (uint)value >> (32 - 29); - value = (int)(part1 | part2); - return value; - } - case 29: - { - // BitRotateInstruction - uint part1 = (uint)value << 6; - uint part2 = (uint)value >> (32 - 6); - value = ((int)(part1 | part2) ^ _secretKey[240]) + salt; - return value; - } - case 30: - { - // MultipleRotateXorInstruction - value = value * 1892661727 + _secretKey[215]; - uint part1 = (uint)value << 24; - uint part2 = (uint)value >> (32 - 24); - value = (int)(part1 | part2); - value ^= 1594594445 ^ salt; - return value; - } - case 31: - { - // BitRotateInstruction - uint part1 = (uint)value << 19; - uint part2 = (uint)value >> (32 - 19); - value = ((int)(part1 | part2) ^ _secretKey[49]) + salt; - return value; - } - case 32: - { - // XorAddRotateInstruction - value ^= 226193183 ^ salt; - value += -1038657413 + _secretKey[247]; - uint part1 = (uint)value << 17; - uint part2 = (uint)value >> (32 - 17); - value = (int)(part1 | part2); - return value; - } - case 33: - { - // XorAddRotateInstruction - value ^= -484591087 ^ salt; - value += 459902223 + _secretKey[252]; - uint part1 = (uint)value << 23; - uint part2 = (uint)value >> (32 - 23); - value = (int)(part1 | part2); - return value; - } - case 34: - { - // MultipleXorRotateInstruction - value = value * -1382643267 + _secretKey[211]; - value ^= 1186351980 ^ salt; - uint part1 = (uint)value << 14; - uint part2 = (uint)value >> (32 - 14); - value = (int)(part1 | part2); - return value; - } - case 35: - { - // XorAddRotateInstruction - value ^= 1658142493 ^ salt; - value += -283413931 + _secretKey[235]; - uint part1 = (uint)value << 15; - uint part2 = (uint)value >> (32 - 15); - value = (int)(part1 | part2); - return value; - } - case 36: - { - // XorInstruction - value = ((value ^ _secretKey[90]) + salt) ^ -1892941953; - return value; - } - case 37: - { - // XorMultipleRotateInstruction - value ^= -1297440001 ^ salt; - value = value * -1166749617 + _secretKey[111]; - uint part1 = (uint)value << 31; - uint part2 = (uint)value >> (32 - 31); - value = (int)(part1 | part2); - return value; - } - case 38: - { - // MultipleRotateXorInstruction - value = value * -375439505 + _secretKey[213]; - uint part1 = (uint)value << 31; - uint part2 = (uint)value >> (32 - 31); - value = (int)(part1 | part2); - value ^= 1353158598 ^ salt; - return value; - } - case 39: - { - // XorAddRotateInstruction - value ^= -934836680 ^ salt; - value += 873171360 + _secretKey[72]; - uint part1 = (uint)value << 20; - uint part2 = (uint)value >> (32 - 20); - value = (int)(part1 | part2); - return value; - } - case 40: - { - // MultipleXorRotateInstruction - value = value * 1427441479 + _secretKey[140]; - value ^= -28088263 ^ salt; - uint part1 = (uint)value << 18; - uint part2 = (uint)value >> (32 - 18); - value = (int)(part1 | part2); - return value; - } - case 41: - { - // AddRotateXorInstruction - value += 969234286 + _secretKey[116]; - uint part1 = (uint)value << 1; - uint part2 = (uint)value >> (32 - 1); - value = (int)(part1 | part2); - value ^= -312111197 ^ salt; - return value; - } - case 42: - { - // MultipleInstruction - value = value * -1130955295 + _secretKey[29] + salt; - return value; - } - case 43: - { - // BitRotateInstruction - uint part1 = (uint)value << 28; - uint part2 = (uint)value >> (32 - 28); - value = ((int)(part1 | part2) ^ _secretKey[1]) + salt; - return value; - } - case 44: - { - // BitRotateInstruction - uint part1 = (uint)value << 4; - uint part2 = (uint)value >> (32 - 4); - value = ((int)(part1 | part2) ^ _secretKey[184]) + salt; - return value; - } - case 45: - { - // MultipleXorRotateInstruction - value = value * -1782633617 + _secretKey[199]; - value ^= 1068062556 ^ salt; - uint part1 = (uint)value << 18; - uint part2 = (uint)value >> (32 - 18); - value = (int)(part1 | part2); - return value; - } - case 46: - { - // XorMultipleRotateInstruction - value ^= 196245895 ^ salt; - value = value * -1852817781 + _secretKey[200]; - uint part1 = (uint)value << 1; - uint part2 = (uint)value >> (32 - 1); - value = (int)(part1 | part2); - return value; - } - case 47: - { - // MultipleXorRotateInstruction - value = value * -50587953 + _secretKey[10]; - value ^= -1964107221 ^ salt; - uint part1 = (uint)value << 7; - uint part2 = (uint)value >> (32 - 7); - value = (int)(part1 | part2); - return value; - } - case 48: - { - // MultipleXorRotateInstruction - value = value * 1216851115 + _secretKey[238]; - value ^= -38668552 ^ salt; - uint part1 = (uint)value << 18; - uint part2 = (uint)value >> (32 - 18); - value = (int)(part1 | part2); - return value; - } - case 49: - { - // MultipleInstruction - value = value * -2133817615 + _secretKey[172] + salt; - return value; - } - case 50: - { - // AddXorRotateInstruction - value += 1412414820 + _secretKey[219]; - value ^= -2098495662 ^ salt; - uint part1 = (uint)value << 11; - uint part2 = (uint)value >> (32 - 11); - value = (int)(part1 | part2); - return value; - } - case 51: - { - // BitRotateInstruction - uint part1 = (uint)value << 10; - uint part2 = (uint)value >> (32 - 10); - value = ((int)(part1 | part2) ^ _secretKey[97]) + salt; - return value; - } - case 52: - { - // MultipleRotateXorInstruction - value = value * -1791837593 + _secretKey[63]; - uint part1 = (uint)value << 24; - uint part2 = (uint)value >> (32 - 24); - value = (int)(part1 | part2); - value ^= -21948406 ^ salt; - return value; - } - case 53: - { - // BitRotateInstruction - uint part1 = (uint)value << 7; - uint part2 = (uint)value >> (32 - 7); - value = ((int)(part1 | part2) ^ _secretKey[221]) + salt; - return value; - } - case 54: - { - // MultipleInstruction - value = value * -1220403071 + _secretKey[96] + salt; - return value; - } - case 55: - { - // MultipleRotateXorInstruction - value = value * -867896207 + _secretKey[29]; - uint part1 = (uint)value << 29; - uint part2 = (uint)value >> (32 - 29); - value = (int)(part1 | part2); - value ^= -1022882984 ^ salt; - return value; - } - case 56: - { - // XorMultipleRotateInstruction - value ^= 2122077674 ^ salt; - value = value * 957274637 + _secretKey[235]; - uint part1 = (uint)value << 12; - uint part2 = (uint)value >> (32 - 12); - value = (int)(part1 | part2); - return value; - } - case 57: - { - // AddRotateXorInstruction - value += -503448718 + _secretKey[175]; - uint part1 = (uint)value << 21; - uint part2 = (uint)value >> (32 - 21); - value = (int)(part1 | part2); - value ^= -720824840 ^ salt; - return value; - } - case 58: - { - // MultipleInstruction - value = value * -280528271 + _secretKey[231] + salt; - return value; - } - case 59: - { - // BitRotateInstruction - uint part1 = (uint)value << 19; - uint part2 = (uint)value >> (32 - 19); - value = ((int)(part1 | part2) ^ _secretKey[75]) + salt; - return value; - } - case 60: - { - // MultipleRotateXorInstruction - value = value * -1403438719 + _secretKey[171]; - uint part1 = (uint)value << 27; - uint part2 = (uint)value >> (32 - 27); - value = (int)(part1 | part2); - value ^= 1420744071 ^ salt; - return value; - } - case 61: - { - // XorMultipleRotateInstruction - value ^= 1366253139 ^ salt; - value = value * -1583570963 + _secretKey[84]; - uint part1 = (uint)value << 15; - uint part2 = (uint)value >> (32 - 15); - value = (int)(part1 | part2); - return value; - } - case 62: - { - // MultipleXorRotateInstruction - value = value * 24444809 + _secretKey[132]; - value ^= -1974823163 ^ salt; - uint part1 = (uint)value << 6; - uint part2 = (uint)value >> (32 - 6); - value = (int)(part1 | part2); - return value; - } - case 63: - { - // BitRotateInstruction - uint part1 = (uint)value << 22; - uint part2 = (uint)value >> (32 - 22); - value = ((int)(part1 | part2) ^ _secretKey[119]) + salt; - return value; - } - case 64: - { - // XorInstruction - value = ((value ^ _secretKey[15]) + salt) ^ 1262347216; - return value; - } - case 65: - { - // AddInstruction - value = ((value + _secretKey[126]) ^ salt) + 1780280992; - return value; - } - case 66: - { - // MultipleXorRotateInstruction - value = value * -1871888237 + _secretKey[85]; - value ^= -1198162446 ^ salt; - uint part1 = (uint)value << 13; - uint part2 = (uint)value >> (32 - 13); - value = (int)(part1 | part2); - return value; - } - case 67: - { - // MultipleInstruction - value = value * 931252767 + _secretKey[128] + salt; - return value; - } - case 68: - { - // BitRotateInstruction - uint part1 = (uint)value << 24; - uint part2 = (uint)value >> (32 - 24); - value = ((int)(part1 | part2) ^ _secretKey[178]) + salt; - return value; - } - case 69: - { - // XorInstruction - value = ((value ^ _secretKey[61]) + salt) ^ 1649427052; - return value; - } - case 70: - { - // MultipleRotateXorInstruction - value = value * -100486091 + _secretKey[83]; - uint part1 = (uint)value << 17; - uint part2 = (uint)value >> (32 - 17); - value = (int)(part1 | part2); - value ^= 849172121 ^ salt; - return value; - } - case 71: - { - // BitRotateInstruction - uint part1 = (uint)value << 16; - uint part2 = (uint)value >> (32 - 16); - value = ((int)(part1 | part2) ^ _secretKey[169]) + salt; - return value; - } - case 72: - { - // XorAddRotateInstruction - value ^= 1068287172 ^ salt; - value += -2092062916 + _secretKey[138]; - uint part1 = (uint)value << 20; - uint part2 = (uint)value >> (32 - 20); - value = (int)(part1 | part2); - return value; - } - case 73: - { - // MultipleInstruction - value = value * -729679733 + _secretKey[34] + salt; - return value; - } - case 74: - { - // MultipleRotateXorInstruction - value = value * -1624925351 + _secretKey[30]; - uint part1 = (uint)value << 29; - uint part2 = (uint)value >> (32 - 29); - value = (int)(part1 | part2); - value ^= -145743337 ^ salt; - return value; - } - case 75: - { - // MultipleRotateXorInstruction - value = value * -1768166349 + _secretKey[142]; - uint part1 = (uint)value << 4; - uint part2 = (uint)value >> (32 - 4); - value = (int)(part1 | part2); - value ^= 280941267 ^ salt; - return value; - } - case 76: - { - // MultipleInstruction - value = value * -1708700487 + _secretKey[156] + salt; - return value; - } - case 77: - { - // AddRotateXorInstruction - value += 314625916 + _secretKey[192]; - uint part1 = (uint)value << 7; - uint part2 = (uint)value >> (32 - 7); - value = (int)(part1 | part2); - value ^= 827331935 ^ salt; - return value; - } - case 78: - { - // MultipleInstruction - value = value * 875189907 + _secretKey[141] + salt; - return value; - } - case 79: - { - // AddXorRotateInstruction - value += 1607953190 + _secretKey[133]; - value ^= -11549173 ^ salt; - uint part1 = (uint)value << 11; - uint part2 = (uint)value >> (32 - 11); - value = (int)(part1 | part2); - return value; - } - case 80: - { - // XorAddRotateInstruction - value ^= -1454482890 ^ salt; - value += 687186546 + _secretKey[95]; - uint part1 = (uint)value << 25; - uint part2 = (uint)value >> (32 - 25); - value = (int)(part1 | part2); - return value; - } - case 81: - { - // XorInstruction - value = ((value ^ _secretKey[195]) + salt) ^ 814860713; - return value; - } - case 82: - { - // AddRotateXorInstruction - value += 1998643542 + _secretKey[171]; - uint part1 = (uint)value << 19; - uint part2 = (uint)value >> (32 - 19); - value = (int)(part1 | part2); - value ^= 213310246 ^ salt; - return value; - } - case 83: - { - // AddRotateXorInstruction - value += 542686146 + _secretKey[249]; - uint part1 = (uint)value << 14; - uint part2 = (uint)value >> (32 - 14); - value = (int)(part1 | part2); - value ^= -696314173 ^ salt; - return value; - } - case 84: - { - // AddRotateXorInstruction - value += 1734820207 + _secretKey[2]; - uint part1 = (uint)value << 9; - uint part2 = (uint)value >> (32 - 9); - value = (int)(part1 | part2); - value ^= 118718247 ^ salt; - return value; - } - case 85: - { - // XorInstruction - value = ((value ^ _secretKey[143]) + salt) ^ 1553710234; - return value; - } - case 86: - { - // AddRotateXorInstruction - value += -217984331 + _secretKey[146]; - uint part1 = (uint)value << 5; - uint part2 = (uint)value >> (32 - 5); - value = (int)(part1 | part2); - value ^= -1402843691 ^ salt; - return value; - } - case 87: - { - // MultipleInstruction - value = value * 1078374119 + _secretKey[5] + salt; - return value; - } - case 88: - { - // MultipleRotateXorInstruction - value = value * -975647447 + _secretKey[158]; - uint part1 = (uint)value << 28; - uint part2 = (uint)value >> (32 - 28); - value = (int)(part1 | part2); - value ^= -2044505542 ^ salt; - return value; - } - case 89: - { - // AddInstruction - value = ((value + _secretKey[40]) ^ salt) + -1213654475; - return value; - } - case 90: - { - // XorMultipleRotateInstruction - value ^= -1886972278 ^ salt; - value = value * 275510141 + _secretKey[206]; - uint part1 = (uint)value << 6; - uint part2 = (uint)value >> (32 - 6); - value = (int)(part1 | part2); - return value; - } - case 91: - { - // AddRotateXorInstruction - value += -1724625239 + _secretKey[223]; - uint part1 = (uint)value << 23; - uint part2 = (uint)value >> (32 - 23); - value = (int)(part1 | part2); - value ^= -979249928 ^ salt; - return value; - } - case 92: - { - // XorInstruction - value = ((value ^ _secretKey[83]) + salt) ^ -1104541704; - return value; - } - case 93: - { - // XorInstruction - value = ((value ^ _secretKey[31]) + salt) ^ 311150152; - return value; - } - case 94: - { - // XorMultipleRotateInstruction - value ^= 116496631 ^ salt; - value = value * 13120561 + _secretKey[176]; - uint part1 = (uint)value << 17; - uint part2 = (uint)value >> (32 - 17); - value = (int)(part1 | part2); - return value; - } - case 95: - { - // MultipleRotateXorInstruction - value = value * -1932552195 + _secretKey[87]; - uint part1 = (uint)value << 2; - uint part2 = (uint)value >> (32 - 2); - value = (int)(part1 | part2); - value ^= 2133438141 ^ salt; - return value; - } - case 96: - { - // MultipleRotateXorInstruction - value = value * 126641773 + _secretKey[174]; - uint part1 = (uint)value << 16; - uint part2 = (uint)value >> (32 - 16); - value = (int)(part1 | part2); - value ^= 225535005 ^ salt; - return value; - } - case 97: - { - // MultipleRotateXorInstruction - value = value * -1013570837 + _secretKey[175]; - uint part1 = (uint)value << 1; - uint part2 = (uint)value >> (32 - 1); - value = (int)(part1 | part2); - value ^= -1703839105 ^ salt; - return value; - } - case 98: - { - // XorAddRotateInstruction - value ^= -447564571 ^ salt; - value += -1783079937 + _secretKey[78]; - uint part1 = (uint)value << 15; - uint part2 = (uint)value >> (32 - 15); - value = (int)(part1 | part2); - return value; - } - case 99: - { - // XorInstruction - value = ((value ^ _secretKey[111]) + salt) ^ -316631669; - return value; - } - case 100: - { - // XorMultipleRotateInstruction - value ^= -405694625 ^ salt; - value = value * 1711408839 + _secretKey[252]; - uint part1 = (uint)value << 24; - uint part2 = (uint)value >> (32 - 24); - value = (int)(part1 | part2); - return value; - } - case 101: - { - // MultipleXorRotateInstruction - value = value * -910384311 + _secretKey[212]; - value ^= -1551058348 ^ salt; - uint part1 = (uint)value << 6; - uint part2 = (uint)value >> (32 - 6); - value = (int)(part1 | part2); - return value; - } - case 102: - { - // AddInstruction - value = ((value + _secretKey[18]) ^ salt) + -853736135; - return value; - } - case 103: - { - // AddInstruction - value = ((value + _secretKey[116]) ^ salt) + 1321376878; - return value; - } - case 104: - { - // MultipleRotateXorInstruction - value = value * 1039555235 + _secretKey[7]; - uint part1 = (uint)value << 0; - uint part2 = (uint)value >> (32 - 0); - value = (int)(part1 | part2); - value ^= 541697309 ^ salt; - return value; - } - case 105: - { - // AddRotateXorInstruction - value += -822594180 + _secretKey[1]; - uint part1 = (uint)value << 4; - uint part2 = (uint)value >> (32 - 4); - value = (int)(part1 | part2); - value ^= 1176608900 ^ salt; - return value; - } - case 106: - { - // AddInstruction - value = ((value + _secretKey[110]) ^ salt) + -882893600; - return value; - } - case 107: - { - // MultipleRotateXorInstruction - value = value * -346726819 + _secretKey[114]; - uint part1 = (uint)value << 23; - uint part2 = (uint)value >> (32 - 23); - value = (int)(part1 | part2); - value ^= -1566546809 ^ salt; - return value; - } - case 108: - { - // MultipleInstruction - value = value * -981516343 + _secretKey[97] + salt; - return value; - } - case 109: - { - // XorAddRotateInstruction - value ^= -72794161 ^ salt; - value += 1161425930 + _secretKey[43]; - uint part1 = (uint)value << 7; - uint part2 = (uint)value >> (32 - 7); - value = (int)(part1 | part2); - return value; - } - case 110: - { - // AddInstruction - value = ((value + _secretKey[238]) ^ salt) + -1619543125; - return value; - } - case 111: - { - // XorAddRotateInstruction - value ^= 1170459122 ^ salt; - value += -1766468683 + _secretKey[241]; - uint part1 = (uint)value << 12; - uint part2 = (uint)value >> (32 - 12); - value = (int)(part1 | part2); - return value; - } - case 112: - { - // AddXorRotateInstruction - value += 251687012 + _secretKey[219]; - value ^= 323019346 ^ salt; - uint part1 = (uint)value << 11; - uint part2 = (uint)value >> (32 - 11); - value = (int)(part1 | part2); - return value; - } - case 113: - { - // AddInstruction - value = ((value + _secretKey[97]) ^ salt) + -1049972438; - return value; - } - case 114: - { - // XorMultipleRotateInstruction - value ^= -492239002 ^ salt; - value = value * -1496840897 + _secretKey[216]; - uint part1 = (uint)value << 10; - uint part2 = (uint)value >> (32 - 10); - value = (int)(part1 | part2); - return value; - } - case 115: - { - // AddInstruction - value = ((value + _secretKey[221]) ^ salt) + -748126329; - return value; - } - case 116: - { - // AddXorRotateInstruction - value += -441051263 + _secretKey[96]; - value ^= -5933889 ^ salt; - uint part1 = (uint)value << 17; - uint part2 = (uint)value >> (32 - 17); - value = (int)(part1 | part2); - return value; - } - case 117: - { - // MultipleRotateXorInstruction - value = value * -1850062787 + _secretKey[88]; - uint part1 = (uint)value << 11; - uint part2 = (uint)value >> (32 - 11); - value = (int)(part1 | part2); - value ^= 543895274 ^ salt; - return value; - } - case 118: - { - // MultipleInstruction - value = value * -747527445 + _secretKey[140] + salt; - return value; - } - case 119: - { - // BitRotateInstruction - uint part1 = (uint)value << 18; - uint part2 = (uint)value >> (32 - 18); - value = ((int)(part1 | part2) ^ _secretKey[175]) + salt; - return value; - } - case 120: - { - // MultipleRotateXorInstruction - value = value * 345252089 + _secretKey[57]; - uint part1 = (uint)value << 16; - uint part2 = (uint)value >> (32 - 16); - value = (int)(part1 | part2); - value ^= 1300544743 ^ salt; - return value; - } - case 121: - { - // XorAddRotateInstruction - value ^= -547380749 ^ salt; - value += 678597707 + _secretKey[119]; - uint part1 = (uint)value << 1; - uint part2 = (uint)value >> (32 - 1); - value = (int)(part1 | part2); - return value; - } - case 122: - { - // XorMultipleRotateInstruction - value ^= 683601851 ^ salt; - value = value * -145367929 + _secretKey[191]; - uint part1 = (uint)value << 19; - uint part2 = (uint)value >> (32 - 19); - value = (int)(part1 | part2); - return value; - } - case 123: - { - // BitRotateInstruction - uint part1 = (uint)value << 20; - uint part2 = (uint)value >> (32 - 20); - value = ((int)(part1 | part2) ^ _secretKey[15]) + salt; - return value; - } - case 124: - { - // BitRotateInstruction - uint part1 = (uint)value << 8; - uint part2 = (uint)value >> (32 - 8); - value = ((int)(part1 | part2) ^ _secretKey[132]) + salt; - return value; - } - case 125: - { - // MultipleInstruction - value = value * 1436085223 + _secretKey[120] + salt; - return value; - } - case 126: - { - // AddInstruction - value = ((value + _secretKey[197]) ^ salt) + -1374139785; - return value; - } - case 127: - { - // BitRotateInstruction - uint part1 = (uint)value << 15; - uint part2 = (uint)value >> (32 - 15); - value = ((int)(part1 | part2) ^ _secretKey[26]) + salt; - return value; - } - case 128: - { - // XorAddRotateInstruction - value ^= 1415280510 ^ salt; - value += 723646816 + _secretKey[146]; - uint part1 = (uint)value << 21; - uint part2 = (uint)value >> (32 - 21); - value = (int)(part1 | part2); - return value; - } - case 129: - { - // AddRotateXorInstruction - value += 1410706317 + _secretKey[165]; - uint part1 = (uint)value << 30; - uint part2 = (uint)value >> (32 - 30); - value = (int)(part1 | part2); - value ^= 2132310656 ^ salt; - return value; - } - case 130: - { - // XorAddRotateInstruction - value ^= 1264971736 ^ salt; - value += -483221582 + _secretKey[93]; - uint part1 = (uint)value << 12; - uint part2 = (uint)value >> (32 - 12); - value = (int)(part1 | part2); - return value; - } - case 131: - { - // AddXorRotateInstruction - value += -1872731835 + _secretKey[53]; - value ^= 1531807059 ^ salt; - uint part1 = (uint)value << 17; - uint part2 = (uint)value >> (32 - 17); - value = (int)(part1 | part2); - return value; - } - case 132: - { - // AddXorRotateInstruction - value += 264114638 + _secretKey[240]; - value ^= 306666665 ^ salt; - uint part1 = (uint)value << 10; - uint part2 = (uint)value >> (32 - 10); - value = (int)(part1 | part2); - return value; - } - case 133: - { - // AddRotateXorInstruction - value += 824712252 + _secretKey[138]; - uint part1 = (uint)value << 20; - uint part2 = (uint)value >> (32 - 20); - value = (int)(part1 | part2); - value ^= -1266414649 ^ salt; - return value; - } - case 134: - { - // AddRotateXorInstruction - value += -766337246 + _secretKey[35]; - uint part1 = (uint)value << 25; - uint part2 = (uint)value >> (32 - 25); - value = (int)(part1 | part2); - value ^= 2133737246 ^ salt; - return value; - } - case 135: - { - // AddXorRotateInstruction - value += -1997614825 + _secretKey[165]; - value ^= 1683555122 ^ salt; - uint part1 = (uint)value << 14; - uint part2 = (uint)value >> (32 - 14); - value = (int)(part1 | part2); - return value; - } - case 136: - { - // MultipleXorRotateInstruction - value = value * 278699987 + _secretKey[57]; - value ^= -1305042504 ^ salt; - uint part1 = (uint)value << 28; - uint part2 = (uint)value >> (32 - 28); - value = (int)(part1 | part2); - return value; - } - case 137: - { - // BitRotateInstruction - uint part1 = (uint)value << 28; - uint part2 = (uint)value >> (32 - 28); - value = ((int)(part1 | part2) ^ _secretKey[192]) + salt; - return value; - } - case 138: - { - // XorInstruction - value = ((value ^ _secretKey[135]) + salt) ^ 1715223135; - return value; - } - case 139: - { - // MultipleInstruction - value = value * 1809423757 + _secretKey[79] + salt; - return value; - } - case 140: - { - // AddRotateXorInstruction - value += -408450171 + _secretKey[11]; - uint part1 = (uint)value << 11; - uint part2 = (uint)value >> (32 - 11); - value = (int)(part1 | part2); - value ^= 806320034 ^ salt; - return value; - } - case 141: - { - // AddInstruction - value = ((value + _secretKey[95]) ^ salt) + -433941646; - return value; - } - case 142: - { - // AddXorRotateInstruction - value += 1775820811 + _secretKey[169]; - value ^= 2132471747 ^ salt; - uint part1 = (uint)value << 26; - uint part2 = (uint)value >> (32 - 26); - value = (int)(part1 | part2); - return value; - } - case 143: - { - // MultipleXorRotateInstruction - value = value * 457346731 + _secretKey[19]; - value ^= 114258470 ^ salt; - uint part1 = (uint)value << 2; - uint part2 = (uint)value >> (32 - 2); - value = (int)(part1 | part2); - return value; - } - case 144: - { - // AddRotateXorInstruction - value += -650723591 + _secretKey[206]; - uint part1 = (uint)value << 3; - uint part2 = (uint)value >> (32 - 3); - value = (int)(part1 | part2); - value ^= -1181275232 ^ salt; - return value; - } - case 145: - { - // MultipleInstruction - value = value * 1369495811 + _secretKey[169] + salt; - return value; - } - case 146: - { - // XorInstruction - value = ((value ^ _secretKey[154]) + salt) ^ -1297404981; - return value; - } - case 147: - { - // MultipleRotateXorInstruction - value = value * 787548271 + _secretKey[181]; - uint part1 = (uint)value << 18; - uint part2 = (uint)value >> (32 - 18); - value = (int)(part1 | part2); - value ^= 801710213 ^ salt; - return value; - } - case 148: - { - // AddXorRotateInstruction - value += -1933121809 + _secretKey[230]; - value ^= 1566976773 ^ salt; - uint part1 = (uint)value << 29; - uint part2 = (uint)value >> (32 - 29); - value = (int)(part1 | part2); - return value; - } - case 149: - { - // BitRotateInstruction - uint part1 = (uint)value << 30; - uint part2 = (uint)value >> (32 - 30); - value = ((int)(part1 | part2) ^ _secretKey[188]) + salt; - return value; - } - case 150: - { - // BitRotateInstruction - uint part1 = (uint)value << 30; - uint part2 = (uint)value >> (32 - 30); - value = ((int)(part1 | part2) ^ _secretKey[53]) + salt; - return value; - } - case 151: - { - // AddInstruction - value = ((value + _secretKey[138]) ^ salt) + -2119615805; - return value; - } - case 152: - { - // MultipleRotateXorInstruction - value = value * 1289692111 + _secretKey[102]; - uint part1 = (uint)value << 16; - uint part2 = (uint)value >> (32 - 16); - value = (int)(part1 | part2); - value ^= 221292457 ^ salt; - return value; - } - case 153: - { - // MultipleRotateXorInstruction - value = value * -414757417 + _secretKey[248]; - uint part1 = (uint)value << 13; - uint part2 = (uint)value >> (32 - 13); - value = (int)(part1 | part2); - value ^= 1486712056 ^ salt; - return value; - } - case 154: - { - // MultipleInstruction - value = value * 1625437745 + _secretKey[72] + salt; - return value; - } - case 155: - { - // MultipleRotateXorInstruction - value = value * 1500723835 + _secretKey[247]; - uint part1 = (uint)value << 17; - uint part2 = (uint)value >> (32 - 17); - value = (int)(part1 | part2); - value ^= -81016400 ^ salt; - return value; - } - case 156: - { - // MultipleRotateXorInstruction - value = value * -939493617 + _secretKey[252]; - uint part1 = (uint)value << 23; - uint part2 = (uint)value >> (32 - 23); - value = (int)(part1 | part2); - value ^= -1187848798 ^ salt; - return value; - } - case 157: - { - // AddXorRotateInstruction - value += 605454035 + _secretKey[108]; - value ^= 1185916334 ^ salt; - uint part1 = (uint)value << 16; - uint part2 = (uint)value >> (32 - 16); - value = (int)(part1 | part2); - return value; - } - case 158: - { - // AddXorRotateInstruction - value += 2112611413 + _secretKey[235]; - value ^= -451761745 ^ salt; - uint part1 = (uint)value << 1; - uint part2 = (uint)value >> (32 - 1); - value = (int)(part1 | part2); - return value; - } - case 159: - { - // XorInstruction - value = ((value ^ _secretKey[229]) + salt) ^ 1660696922; - return value; - } - case 160: - { - // MultipleRotateXorInstruction - value = value * 1280312911 + _secretKey[111]; - uint part1 = (uint)value << 31; - uint part2 = (uint)value >> (32 - 31); - value = (int)(part1 | part2); - value ^= -431219573 ^ salt; - return value; - } - case 161: - { - // XorMultipleRotateInstruction - value ^= 1658933717 ^ salt; - value = value * 642349663 + _secretKey[198]; - uint part1 = (uint)value << 28; - uint part2 = (uint)value >> (32 - 28); - value = (int)(part1 | part2); - return value; - } - case 162: - { - // AddRotateXorInstruction - value += -1278798944 + _secretKey[72]; - uint part1 = (uint)value << 20; - uint part2 = (uint)value >> (32 - 20); - value = (int)(part1 | part2); - value ^= 609336148 ^ salt; - return value; - } - case 163: - { - // MultipleXorRotateInstruction - value = value * -1217570675 + _secretKey[57]; - value ^= -1055021038 ^ salt; - uint part1 = (uint)value << 26; - uint part2 = (uint)value >> (32 - 26); - value = (int)(part1 | part2); - return value; - } - case 164: - { - // MultipleXorRotateInstruction - value = value * 1129428085 + _secretKey[225]; - value ^= 1389308323 ^ salt; - uint part1 = (uint)value << 7; - uint part2 = (uint)value >> (32 - 7); - value = (int)(part1 | part2); - return value; - } - case 165: - { - // XorAddRotateInstruction - value ^= 318043677 ^ salt; - value += -1939584600 + _secretKey[124]; - uint part1 = (uint)value << 1; - uint part2 = (uint)value >> (32 - 1); - value = (int)(part1 | part2); - return value; - } - case 166: - { - // MultipleXorRotateInstruction - value = value * 601748357 + _secretKey[184]; - value ^= 2047590880 ^ salt; - uint part1 = (uint)value << 14; - uint part2 = (uint)value >> (32 - 14); - value = (int)(part1 | part2); - return value; - } - case 167: - { - // XorInstruction - value = ((value ^ _secretKey[114]) + salt) ^ -312123044; - return value; - } - case 168: - { - // AddXorRotateInstruction - value += 1897551751 + _secretKey[139]; - value ^= -1299860280 ^ salt; - uint part1 = (uint)value << 1; - uint part2 = (uint)value >> (32 - 1); - value = (int)(part1 | part2); - return value; - } - case 169: - { - // BitRotateInstruction - uint part1 = (uint)value << 15; - uint part2 = (uint)value >> (32 - 15); - value = ((int)(part1 | part2) ^ _secretKey[10]) + salt; - return value; - } - case 170: - { - // MultipleInstruction - value = value * -1716044921 + _secretKey[60] + salt; - return value; - } - case 171: - { - // XorMultipleRotateInstruction - value ^= 820953326 ^ salt; - value = value * 1295924473 + _secretKey[242]; - uint part1 = (uint)value << 21; - uint part2 = (uint)value >> (32 - 21); - value = (int)(part1 | part2); - return value; - } - case 172: - { - // XorInstruction - value = ((value ^ _secretKey[89]) + salt) ^ 921116076; - return value; - } - case 173: - { - // AddInstruction - value = ((value + _secretKey[82]) ^ salt) + -1261901861; - return value; - } - case 174: - { - // MultipleRotateXorInstruction - value = value * 1029416329 + _secretKey[42]; - uint part1 = (uint)value << 1; - uint part2 = (uint)value >> (32 - 1); - value = (int)(part1 | part2); - value ^= -1758870671 ^ salt; - return value; - } - case 175: - { - // XorAddRotateInstruction - value ^= -99371457 ^ salt; - value += 1254595032 + _secretKey[10]; - uint part1 = (uint)value << 14; - uint part2 = (uint)value >> (32 - 14); - value = (int)(part1 | part2); - return value; - } - case 176: - { - // AddXorRotateInstruction - value += 1901168605 + _secretKey[131]; - value ^= -2036462975 ^ salt; - uint part1 = (uint)value << 0; - uint part2 = (uint)value >> (32 - 0); - value = (int)(part1 | part2); - return value; - } - case 177: - { - // MultipleRotateXorInstruction - value = value * 383500913 + _secretKey[29]; - uint part1 = (uint)value << 29; - uint part2 = (uint)value >> (32 - 29); - value = (int)(part1 | part2); - value ^= -805817000 ^ salt; - return value; - } - case 178: - { - // AddXorRotateInstruction - value += 28490730 + _secretKey[13]; - value ^= 762578411 ^ salt; - uint part1 = (uint)value << 12; - uint part2 = (uint)value >> (32 - 12); - value = (int)(part1 | part2); - return value; - } - case 179: - { - // XorAddRotateInstruction - value ^= 1812019570 ^ salt; - value += -41308497 + _secretKey[85]; - uint part1 = (uint)value << 24; - uint part2 = (uint)value >> (32 - 24); - value = (int)(part1 | part2); - return value; - } - case 180: - { - // XorInstruction - value = ((value ^ _secretKey[231]) + salt) ^ 1563652208; - return value; - } - case 181: - { - // AddRotateXorInstruction - value += -542613261 + _secretKey[75]; - uint part1 = (uint)value << 23; - uint part2 = (uint)value >> (32 - 23); - value = (int)(part1 | part2); - value ^= -1148350591 ^ salt; - return value; - } - case 182: - { - // AddXorRotateInstruction - value += 1462569147 + _secretKey[135]; - value ^= 1842755263 ^ salt; - uint part1 = (uint)value << 19; - uint part2 = (uint)value >> (32 - 19); - value = (int)(part1 | part2); - return value; - } - case 183: - { - // MultipleXorRotateInstruction - value = value * 934570325 + _secretKey[15]; - value ^= -159244912 ^ salt; - uint part1 = (uint)value << 8; - uint part2 = (uint)value >> (32 - 8); - value = (int)(part1 | part2); - return value; - } - case 184: - { - // BitRotateInstruction - uint part1 = (uint)value << 5; - uint part2 = (uint)value >> (32 - 5); - value = ((int)(part1 | part2) ^ _secretKey[230]) + salt; - return value; - } - case 185: - { - // AddRotateXorInstruction - value += 45305078 + _secretKey[119]; - uint part1 = (uint)value << 5; - uint part2 = (uint)value >> (32 - 5); - value = (int)(part1 | part2); - value ^= 1218428368 ^ salt; - return value; - } - case 186: - { - // AddXorRotateInstruction - value += 148564506 + _secretKey[160]; - value ^= 567100030 ^ salt; - uint part1 = (uint)value << 0; - uint part2 = (uint)value >> (32 - 0); - value = (int)(part1 | part2); - return value; - } - case 187: - { - // BitRotateInstruction - uint part1 = (uint)value << 21; - uint part2 = (uint)value >> (32 - 21); - value = ((int)(part1 | part2) ^ _secretKey[242]) + salt; - return value; - } - case 188: - { - // MultipleRotateXorInstruction - value = value * -1881635163 + _secretKey[30]; - uint part1 = (uint)value << 0; - uint part2 = (uint)value >> (32 - 0); - value = (int)(part1 | part2); - value ^= 730302816 ^ salt; - return value; - } - case 189: - { - // BitRotateInstruction - uint part1 = (uint)value << 18; - uint part2 = (uint)value >> (32 - 18); - value = ((int)(part1 | part2) ^ _secretKey[93]) + salt; - return value; - } - case 190: - { - // BitRotateInstruction - uint part1 = (uint)value << 29; - uint part2 = (uint)value >> (32 - 29); - value = ((int)(part1 | part2) ^ _secretKey[69]) + salt; - return value; - } - case 191: - { - // XorMultipleRotateInstruction - value ^= 1474104403 ^ salt; - value = value * 1888537457 + _secretKey[153]; - uint part1 = (uint)value << 14; - uint part2 = (uint)value >> (32 - 14); - value = (int)(part1 | part2); - return value; - } - case 192: - { - // AddInstruction - value = ((value + _secretKey[170]) ^ salt) + 1345231273; - return value; - } - case 193: - { - // BitRotateInstruction - uint part1 = (uint)value << 28; - uint part2 = (uint)value >> (32 - 28); - value = ((int)(part1 | part2) ^ _secretKey[138]) + salt; - return value; - } - case 194: - { - // AddRotateXorInstruction - value += -1649692985 + _secretKey[138]; - uint part1 = (uint)value << 2; - uint part2 = (uint)value >> (32 - 2); - value = (int)(part1 | part2); - value ^= -1086752221 ^ salt; - return value; - } - case 195: - { - // XorMultipleRotateInstruction - value ^= 216360478 ^ salt; - value = value * 198928957 + _secretKey[23]; - uint part1 = (uint)value << 5; - uint part2 = (uint)value >> (32 - 5); - value = (int)(part1 | part2); - return value; - } - case 196: - { - // XorAddRotateInstruction - value ^= 1736125070 ^ salt; - value += -922639548 + _secretKey[211]; - uint part1 = (uint)value << 25; - uint part2 = (uint)value >> (32 - 25); - value = (int)(part1 | part2); - return value; - } - case 197: - { - // XorAddRotateInstruction - value ^= -1590872932 ^ salt; - value += -1729078426 + _secretKey[124]; - uint part1 = (uint)value << 0; - uint part2 = (uint)value >> (32 - 0); - value = (int)(part1 | part2); - return value; - } - case 198: - { - // AddXorRotateInstruction - value += -2086916257 + _secretKey[135]; - value ^= 2101329043 ^ salt; - uint part1 = (uint)value << 13; - uint part2 = (uint)value >> (32 - 13); - value = (int)(part1 | part2); - return value; - } - case 199: - { - // XorInstruction - value = ((value ^ _secretKey[133]) + salt) ^ -1188487898; - return value; - } - case 200: - { - // MultipleInstruction - value = value * -165216181 + _secretKey[162] + salt; - return value; - } - case 201: - { - // XorAddRotateInstruction - value ^= 2087683186 ^ salt; - value += -1882888353 + _secretKey[153]; - uint part1 = (uint)value << 11; - uint part2 = (uint)value >> (32 - 11); - value = (int)(part1 | part2); - return value; - } - case 202: - { - // MultipleRotateXorInstruction - value = value * -1941291837 + _secretKey[58]; - uint part1 = (uint)value << 22; - uint part2 = (uint)value >> (32 - 22); - value = (int)(part1 | part2); - value ^= -1855365205 ^ salt; - return value; - } - case 203: - { - // MultipleInstruction - value = value * 2036569383 + _secretKey[66] + salt; - return value; - } - case 204: - { - // MultipleXorRotateInstruction - value = value * 795577849 + _secretKey[206]; - value ^= 1668989123 ^ salt; - uint part1 = (uint)value << 0; - uint part2 = (uint)value >> (32 - 0); - value = (int)(part1 | part2); - return value; - } - case 205: - { - // MultipleInstruction - value = value * -1063887357 + _secretKey[169] + salt; - return value; - } - case 206: - { - // XorMultipleRotateInstruction - value ^= -387621173 ^ salt; - value = value * 413706907 + _secretKey[143]; - uint part1 = (uint)value << 14; - uint part2 = (uint)value >> (32 - 14); - value = (int)(part1 | part2); - return value; - } - case 207: - { - // XorInstruction - value = ((value ^ _secretKey[133]) + salt) ^ -1302837102; - return value; - } - case 208: - { - // XorMultipleRotateInstruction - value ^= 1201861103 ^ salt; - value = value * -1349002009 + _secretKey[5]; - uint part1 = (uint)value << 29; - uint part2 = (uint)value >> (32 - 29); - value = (int)(part1 | part2); - return value; - } - case 209: - { - // AddInstruction - value = ((value + _secretKey[188]) ^ salt) + -1698116194; - return value; - } - case 210: - { - // XorAddRotateInstruction - value ^= 955827838 ^ salt; - value += -5412811 + _secretKey[40]; - uint part1 = (uint)value << 3; - uint part2 = (uint)value >> (32 - 3); - value = (int)(part1 | part2); - return value; - } - case 211: - { - // MultipleXorRotateInstruction - value = value * 1209501053 + _secretKey[206]; - value ^= -261186202 ^ salt; - uint part1 = (uint)value << 16; - uint part2 = (uint)value >> (32 - 16); - value = (int)(part1 | part2); - return value; - } - case 212: - { - // XorInstruction - value = ((value ^ _secretKey[215]) + salt) ^ 1451245279; - return value; - } - case 213: - { - // AddInstruction - value = ((value + _secretKey[248]) ^ salt) + -48271475; - return value; - } - case 214: - { - // MultipleRotateXorInstruction - value = value * -685299407 + _secretKey[72]; - uint part1 = (uint)value << 31; - uint part2 = (uint)value >> (32 - 31); - value = (int)(part1 | part2); - value ^= 280704379 ^ salt; - return value; - } - case 215: - { - // MultipleRotateXorInstruction - value = value * 1188587057 + _secretKey[176]; - uint part1 = (uint)value << 17; - uint part2 = (uint)value >> (32 - 17); - value = (int)(part1 | part2); - value ^= -1507466225 ^ salt; - return value; - } - case 216: - { - // BitRotateInstruction - uint part1 = (uint)value << 23; - uint part2 = (uint)value >> (32 - 23); - value = ((int)(part1 | part2) ^ _secretKey[162]) + salt; - return value; - } - case 217: - { - // XorInstruction - value = ((value ^ _secretKey[108]) + salt) ^ -1329546797; - return value; - } - case 218: - { - // XorAddRotateInstruction - value ^= 846489904 ^ salt; - value += 1710889501 + _secretKey[85]; - uint part1 = (uint)value << 11; - uint part2 = (uint)value >> (32 - 11); - value = (int)(part1 | part2); - return value; - } - case 219: - { - // XorInstruction - value = ((value ^ _secretKey[127]) + salt) ^ -339712479; - return value; - } - case 220: - { - // XorAddRotateInstruction - value ^= -1008587035 ^ salt; - value += -308188673 + _secretKey[78]; - uint part1 = (uint)value << 15; - uint part2 = (uint)value >> (32 - 15); - value = (int)(part1 | part2); - return value; - } - case 221: - { - // MultipleInstruction - value = value * -2016434293 + _secretKey[111] + salt; - return value; - } - case 222: - { - // MultipleInstruction - value = value * -491329185 + _secretKey[198] + salt; - return value; - } - case 223: - { - // AddInstruction - value = ((value + _secretKey[160]) ^ salt) + -449129672; - return value; - } - case 224: - { - // MultipleXorRotateInstruction - value = value * -86469931 + _secretKey[84]; - value ^= -180027834 ^ salt; - uint part1 = (uint)value << 12; - uint part2 = (uint)value >> (32 - 12); - value = (int)(part1 | part2); - return value; - } - case 225: - { - // XorInstruction - value = ((value ^ _secretKey[58]) + salt) ^ 946019090; - return value; - } - case 226: - { - // AddRotateXorInstruction - value += 694016884 + _secretKey[225]; - uint part1 = (uint)value << 3; - uint part2 = (uint)value >> (32 - 3); - value = (int)(part1 | part2); - value ^= 1350981383 ^ salt; - return value; - } - case 227: - { - // AddRotateXorInstruction - value += -870643939 + _secretKey[168]; - uint part1 = (uint)value << 28; - uint part2 = (uint)value >> (32 - 28); - value = (int)(part1 | part2); - value ^= 1680252929 ^ salt; - return value; - } - case 228: - { - // BitRotateInstruction - uint part1 = (uint)value << 4; - uint part2 = (uint)value >> (32 - 4); - value = ((int)(part1 | part2) ^ _secretKey[184]) + salt; - return value; - } - case 229: - { - // AddRotateXorInstruction - value += 1785715822 + _secretKey[199]; - uint part1 = (uint)value << 28; - uint part2 = (uint)value >> (32 - 28); - value = (int)(part1 | part2); - value ^= -1727043214 ^ salt; - return value; - } - case 230: - { - // XorInstruction - value = ((value ^ _secretKey[139]) + salt) ^ -1277148537; - return value; - } - case 231: - { - // MultipleXorRotateInstruction - value = value * 1298248033 + _secretKey[226]; - value ^= 1940873679 ^ salt; - uint part1 = (uint)value << 10; - uint part2 = (uint)value >> (32 - 10); - value = (int)(part1 | part2); - return value; - } - case 232: - { - // XorMultipleRotateInstruction - value ^= -879839609 ^ salt; - value = value * 1286764861 + _secretKey[171]; - uint part1 = (uint)value << 14; - uint part2 = (uint)value >> (32 - 14); - value = (int)(part1 | part2); - return value; - } - case 233: - { - // AddInstruction - value = ((value + _secretKey[181]) ^ salt) + 328489970; - return value; - } - case 234: - { - // MultipleInstruction - value = value * -1393808723 + _secretKey[89] + salt; - return value; - } - case 235: - { - // XorAddRotateInstruction - value ^= 1290000091 ^ salt; - value += -1977097134 + _secretKey[203]; - uint part1 = (uint)value << 8; - uint part2 = (uint)value >> (32 - 8); - value = (int)(part1 | part2); - return value; - } - case 236: - { - // AddInstruction - value = ((value + _secretKey[113]) ^ salt) + 1890859361; - return value; - } - case 237: - { - // AddRotateXorInstruction - value += 1045620543 + _secretKey[216]; - uint part1 = (uint)value << 10; - uint part2 = (uint)value >> (32 - 10); - value = (int)(part1 | part2); - value ^= 1434413518 ^ salt; - return value; - } - case 238: - { - // AddXorRotateInstruction - value += -1706485027 + _secretKey[131]; - value ^= 1591345537 ^ salt; - uint part1 = (uint)value << 0; - uint part2 = (uint)value >> (32 - 0); - value = (int)(part1 | part2); - return value; - } - case 239: - { - // AddXorRotateInstruction - value += 1271081841 + _secretKey[29]; - value ^= 1117669949 ^ salt; - uint part1 = (uint)value << 24; - uint part2 = (uint)value >> (32 - 24); - value = (int)(part1 | part2); - return value; - } - case 240: - { - // XorMultipleRotateInstruction - value ^= -842525462 ^ salt; - value = value * 1426591501 + _secretKey[235]; - uint part1 = (uint)value << 12; - uint part2 = (uint)value >> (32 - 12); - value = (int)(part1 | part2); - return value; - } - case 241: - { - // AddInstruction - value = ((value + _secretKey[175]) ^ salt) + 1030822002; - return value; - } - case 242: - { - // MultipleRotateXorInstruction - value = value * 1176352505 + _secretKey[57]; - uint part1 = (uint)value << 16; - uint part2 = (uint)value >> (32 - 16); - value = (int)(part1 | part2); - value ^= 811922151 ^ salt; - return value; - } - case 243: - { - // AddRotateXorInstruction - value += 656680947 + _secretKey[75]; - uint part1 = (uint)value << 23; - uint part2 = (uint)value >> (32 - 23); - value = (int)(part1 | part2); - value ^= -1258702719 ^ salt; - return value; - } - case 244: - { - // XorMultipleRotateInstruction - value ^= 90809787 ^ salt; - value = value * -1741148537 + _secretKey[191]; - uint part1 = (uint)value << 19; - uint part2 = (uint)value >> (32 - 19); - value = (int)(part1 | part2); - return value; - } - case 245: - { - // AddRotateXorInstruction - value += -532913580 + _secretKey[15]; - uint part1 = (uint)value << 16; - uint part2 = (uint)value >> (32 - 16); - value = (int)(part1 | part2); - value ^= 99436168 ^ salt; - return value; - } - case 246: - { - // MultipleXorRotateInstruction - value = value * 1306804229 + _secretKey[230]; - value ^= 1471598712 ^ salt; - uint part1 = (uint)value << 22; - uint part2 = (uint)value >> (32 - 22); - value = (int)(part1 | part2); - return value; - } - case 247: - { - // XorMultipleRotateInstruction - value ^= 1941306053 ^ salt; - value = value * -939631919 + _secretKey[15]; - uint part1 = (uint)value << 26; - uint part2 = (uint)value >> (32 - 26); - value = (int)(part1 | part2); - return value; - } - case 248: - { - // AddRotateXorInstruction - value += 883137918 + _secretKey[96]; - uint part1 = (uint)value << 18; - uint part2 = (uint)value >> (32 - 18); - value = (int)(part1 | part2); - value ^= 2045091157 ^ salt; - return value; - } - case 249: - { - // BitRotateInstruction - uint part1 = (uint)value << 13; - uint part2 = (uint)value >> (32 - 13); - value = ((int)(part1 | part2) ^ _secretKey[165]) + salt; - return value; - } - case 250: - { - // AddInstruction - value = ((value + _secretKey[96]) ^ salt) + -394947456; - return value; - } - case 251: - { - // BitRotateInstruction - uint part1 = (uint)value << 18; - uint part2 = (uint)value >> (32 - 18); - value = ((int)(part1 | part2) ^ _secretKey[93]) + salt; - return value; - } - case 252: - { - // AddInstruction - value = ((value + _secretKey[69]) ^ salt) + 1917332797; - return value; - } - case 253: - { - // AddXorRotateInstruction - value += 1006809939 + _secretKey[113]; - value ^= -1509317223 ^ salt; - uint part1 = (uint)value << 14; - uint part2 = (uint)value >> (32 - 14); - value = (int)(part1 | part2); - return value; - } - case 254: - { - // BitRotateInstruction - uint part1 = (uint)value << 9; - uint part2 = (uint)value >> (32 - 9); - value = ((int)(part1 | part2) ^ _secretKey[170]) + salt; - return value; - } - case 255: - { - // AddInstruction - value = ((value + _secretKey[138]) ^ salt) + 683715132; - return value; - } - - default: - throw new System.Exception($"Invalid opCode:{opCode}"); - } - } - - private int ExecuteDecrypt(int value, int opCode, int salt) - { - switch (opCode) - { - case 0: - { - // MultipleInstruction - value = (value - _secretKey[84] - salt) * -1954824987; - return value; - } - case 1: - { - // MultipleRotateXorInstruction - value ^= 1817406469 ^ salt; - uint value2 = (uint)value >> 4; - uint part1 = (uint)value << (32 - 4); - value = (int)(value2 | part1); - value = (value - _secretKey[136]) * -2114748303; - return value; - } - case 2: - { - // MultipleXorRotateInstruction - uint value2 = (uint)value >> 5; - uint part1 = (uint)value << (32 - 5); - value = (int)(value2 | part1); - value ^= -1498541961 ^ salt; - value = (value - _secretKey[246]) * -203485751; - return value; - } - case 3: - { - // AddRotateXorInstruction - value ^= 29411710 ^ salt; - uint value2 = (uint)value >> 0; - uint part1 = (uint)value << (32 - 0); - value = (int)(value2 | part1); - value -= -1207833585 + _secretKey[26]; - return value; - } - case 4: - { - // BitRotateInstruction - uint value2 = (uint)((value - salt) ^ _secretKey[85]); - uint part1 = value2 >> 18; - uint part2 = value2 << (32 - 18); - value = (int)(part1 | part2); - return value; - } - case 5: - { - // MultipleXorRotateInstruction - uint value2 = (uint)value >> 0; - uint part1 = (uint)value << (32 - 0); - value = (int)(value2 | part1); - value ^= 86149918 ^ salt; - value = (value - _secretKey[165]) * -327424699; - return value; - } - case 6: - { - // AddRotateXorInstruction - value ^= -1262500500 ^ salt; - uint value2 = (uint)value >> 29; - uint part1 = (uint)value << (32 - 29); - value = (int)(value2 | part1); - value -= -1856354856 + _secretKey[178]; - return value; - } - case 7: - { - // XorInstruction - value = ((value ^ 665464645) - salt) ^ _secretKey[53]; - return value; - } - case 8: - { - // XorMultipleRotateInstruction - uint value2 = (uint)value >> 16; - uint part1 = (uint)value << (32 - 16); - value = (int)(value2 | part1); - value = (value - _secretKey[206]) * -1476140375; - value ^= -1044567439 ^ salt; - return value; - } - case 9: - { - // MultipleInstruction - value = (value - _secretKey[196] - salt) * 2125307395; - return value; - } - case 10: - { - // XorAddRotateInstruction - uint value2 = (uint)value >> 10; - uint part1 = (uint)value << (32 - 10); - value = (int)(value2 | part1); - value -= -1035239660 + _secretKey[199]; - value ^= -755609206 ^ salt; - return value; - } - case 11: - { - // AddInstruction - value = ((value - -1177184477) ^ salt) - _secretKey[89]; - return value; - } - case 12: - { - // BitRotateInstruction - uint value2 = (uint)((value - salt) ^ _secretKey[23]); - uint part1 = value2 >> 29; - uint part2 = value2 << (32 - 29); - value = (int)(part1 | part2); - return value; - } - case 13: - { - // XorMultipleRotateInstruction - uint value2 = (uint)value >> 19; - uint part1 = (uint)value << (32 - 19); - value = (int)(value2 | part1); - value = (value - _secretKey[68]) * 1170138479; - value ^= -1510419150 ^ salt; - return value; - } - case 14: - { - // MultipleRotateXorInstruction - value ^= -1134639492 ^ salt; - uint value2 = (uint)value >> 6; - uint part1 = (uint)value << (32 - 6); - value = (int)(value2 | part1); - value = (value - _secretKey[156]) * 275824265; - return value; - } - case 15: - { - // BitRotateInstruction - uint value2 = (uint)((value - salt) ^ _secretKey[95]); - uint part1 = value2 >> 7; - uint part2 = value2 << (32 - 7); - value = (int)(part1 | part2); - return value; - } - case 16: - { - // XorMultipleRotateInstruction - uint value2 = (uint)value >> 6; - uint part1 = (uint)value << (32 - 6); - value = (int)(value2 | part1); - value = (value - _secretKey[79]) * 1552472901; - value ^= -759315565 ^ salt; - return value; - } - case 17: - { - // MultipleRotateXorInstruction - value ^= -3885258 ^ salt; - uint value2 = (uint)value >> 2; - uint part1 = (uint)value << (32 - 2); - value = (int)(value2 | part1); - value = (value - _secretKey[75]) * -1943909725; - return value; - } - case 18: - { - // MultipleXorRotateInstruction - uint value2 = (uint)value >> 9; - uint part1 = (uint)value << (32 - 9); - value = (int)(value2 | part1); - value ^= 1207613963 ^ salt; - value = (value - _secretKey[153]) * 1985974175; - return value; - } - case 19: - { - // MultipleRotateXorInstruction - value ^= 792769043 ^ salt; - uint value2 = (uint)value >> 11; - uint part1 = (uint)value << (32 - 11); - value = (int)(value2 | part1); - value = (value - _secretKey[86]) * 1412922099; - return value; - } - case 20: - { - // AddInstruction - value = ((value - -512520382) ^ salt) - _secretKey[194]; - return value; - } - case 21: - { - // XorInstruction - value = ((value ^ -1864951858) - salt) ^ _secretKey[195]; - return value; - } - case 22: - { - // BitRotateInstruction - uint value2 = (uint)((value - salt) ^ _secretKey[2]); - uint part1 = value2 >> 15; - uint part2 = value2 << (32 - 15); - value = (int)(part1 | part2); - return value; - } - case 23: - { - // MultipleInstruction - value = (value - _secretKey[203] - salt) * 891162519; - return value; - } - case 24: - { - // AddInstruction - value = ((value - 2026667919) ^ salt) - _secretKey[110]; - return value; - } - case 25: - { - // AddXorRotateInstruction - uint part1 = (uint)value >> 15; - uint part2 = (uint)value << (32 - 15); - value = (int)(part1 | part2); - value ^= 392708821 ^ salt; - value -= 848657810 + _secretKey[133]; - return value; - } - case 26: - { - // BitRotateInstruction - uint value2 = (uint)((value - salt) ^ _secretKey[93]); - uint part1 = value2 >> 5; - uint part2 = value2 << (32 - 5); - value = (int)(part1 | part2); - return value; - } - case 27: - { - // XorAddRotateInstruction - uint value2 = (uint)value >> 30; - uint part1 = (uint)value << (32 - 30); - value = (int)(value2 | part1); - value -= 1284012732 + _secretKey[58]; - value ^= 1294662302 ^ salt; - return value; - } - case 28: - { - // XorMultipleRotateInstruction - uint value2 = (uint)value >> 29; - uint part1 = (uint)value << (32 - 29); - value = (int)(value2 | part1); - value = (value - _secretKey[138]) * -708470805; - value ^= -1438081752 ^ salt; - return value; - } - case 29: - { - // BitRotateInstruction - uint value2 = (uint)((value - salt) ^ _secretKey[240]); - uint part1 = value2 >> 6; - uint part2 = value2 << (32 - 6); - value = (int)(part1 | part2); - return value; - } - case 30: - { - // MultipleRotateXorInstruction - value ^= 1594594445 ^ salt; - uint value2 = (uint)value >> 24; - uint part1 = (uint)value << (32 - 24); - value = (int)(value2 | part1); - value = (value - _secretKey[215]) * 1857241631; - return value; - } - case 31: - { - // BitRotateInstruction - uint value2 = (uint)((value - salt) ^ _secretKey[49]); - uint part1 = value2 >> 19; - uint part2 = value2 << (32 - 19); - value = (int)(part1 | part2); - return value; - } - case 32: - { - // XorAddRotateInstruction - uint value2 = (uint)value >> 17; - uint part1 = (uint)value << (32 - 17); - value = (int)(value2 | part1); - value -= -1038657413 + _secretKey[247]; - value ^= 226193183 ^ salt; - return value; - } - case 33: - { - // XorAddRotateInstruction - uint value2 = (uint)value >> 23; - uint part1 = (uint)value << (32 - 23); - value = (int)(value2 | part1); - value -= 459902223 + _secretKey[252]; - value ^= -484591087 ^ salt; - return value; - } - case 34: - { - // MultipleXorRotateInstruction - uint value2 = (uint)value >> 14; - uint part1 = (uint)value << (32 - 14); - value = (int)(value2 | part1); - value ^= 1186351980 ^ salt; - value = (value - _secretKey[211]) * 1159592341; - return value; - } - case 35: - { - // XorAddRotateInstruction - uint value2 = (uint)value >> 15; - uint part1 = (uint)value << (32 - 15); - value = (int)(value2 | part1); - value -= -283413931 + _secretKey[235]; - value ^= 1658142493 ^ salt; - return value; - } - case 36: - { - // XorInstruction - value = ((value ^ -1892941953) - salt) ^ _secretKey[90]; - return value; - } - case 37: - { - // XorMultipleRotateInstruction - uint value2 = (uint)value >> 31; - uint part1 = (uint)value << (32 - 31); - value = (int)(value2 | part1); - value = (value - _secretKey[111]) * -674216273; - value ^= -1297440001 ^ salt; - return value; - } - case 38: - { - // MultipleRotateXorInstruction - value ^= 1353158598 ^ salt; - uint value2 = (uint)value >> 31; - uint part1 = (uint)value << (32 - 31); - value = (int)(value2 | part1); - value = (value - _secretKey[213]) * 803536783; - return value; - } - case 39: - { - // XorAddRotateInstruction - uint value2 = (uint)value >> 20; - uint part1 = (uint)value << (32 - 20); - value = (int)(value2 | part1); - value -= 873171360 + _secretKey[72]; - value ^= -934836680 ^ salt; - return value; - } - case 40: - { - // MultipleXorRotateInstruction - uint value2 = (uint)value >> 18; - uint part1 = (uint)value << (32 - 18); - value = (int)(value2 | part1); - value ^= -28088263 ^ salt; - value = (value - _secretKey[140]) * 1881436791; - return value; - } - case 41: - { - // AddRotateXorInstruction - value ^= -312111197 ^ salt; - uint value2 = (uint)value >> 1; - uint part1 = (uint)value << (32 - 1); - value = (int)(value2 | part1); - value -= 969234286 + _secretKey[116]; - return value; - } - case 42: - { - // MultipleInstruction - value = (value - _secretKey[29] - salt) * 2102789665; - return value; - } - case 43: - { - // BitRotateInstruction - uint value2 = (uint)((value - salt) ^ _secretKey[1]); - uint part1 = value2 >> 28; - uint part2 = value2 << (32 - 28); - value = (int)(part1 | part2); - return value; - } - case 44: - { - // BitRotateInstruction - uint value2 = (uint)((value - salt) ^ _secretKey[184]); - uint part1 = value2 >> 4; - uint part2 = value2 << (32 - 4); - value = (int)(part1 | part2); - return value; - } - case 45: - { - // MultipleXorRotateInstruction - uint value2 = (uint)value >> 18; - uint part1 = (uint)value << (32 - 18); - value = (int)(value2 | part1); - value ^= 1068062556 ^ salt; - value = (value - _secretKey[199]) * 85627791; - return value; - } - case 46: - { - // XorMultipleRotateInstruction - uint value2 = (uint)value >> 1; - uint part1 = (uint)value << (32 - 1); - value = (int)(value2 | part1); - value = (value - _secretKey[200]) * 1138735395; - value ^= 196245895 ^ salt; - return value; - } - case 47: - { - // MultipleXorRotateInstruction - uint value2 = (uint)value >> 7; - uint part1 = (uint)value << (32 - 7); - value = (int)(value2 | part1); - value ^= -1964107221 ^ salt; - value = (value - _secretKey[10]) * -1413533649; - return value; - } - case 48: - { - // MultipleXorRotateInstruction - uint value2 = (uint)value >> 18; - uint part1 = (uint)value << (32 - 18); - value = (int)(value2 | part1); - value ^= -38668552 ^ salt; - value = (value - _secretKey[238]) * 665251331; - return value; - } - case 49: - { - // MultipleInstruction - value = (value - _secretKey[172] - salt) * -818173423; - return value; - } - case 50: - { - // AddXorRotateInstruction - uint part1 = (uint)value >> 11; - uint part2 = (uint)value << (32 - 11); - value = (int)(part1 | part2); - value ^= -2098495662 ^ salt; - value -= 1412414820 + _secretKey[219]; - return value; - } - case 51: - { - // BitRotateInstruction - uint value2 = (uint)((value - salt) ^ _secretKey[97]); - uint part1 = value2 >> 10; - uint part2 = value2 << (32 - 10); - value = (int)(part1 | part2); - return value; - } - case 52: - { - // MultipleRotateXorInstruction - value ^= -21948406 ^ salt; - uint value2 = (uint)value >> 24; - uint part1 = (uint)value << (32 - 24); - value = (int)(value2 | part1); - value = (value - _secretKey[63]) * -99761833; - return value; - } - case 53: - { - // BitRotateInstruction - uint value2 = (uint)((value - salt) ^ _secretKey[221]); - uint part1 = value2 >> 7; - uint part2 = value2 << (32 - 7); - value = (int)(part1 | part2); - return value; - } - case 54: - { - // MultipleInstruction - value = (value - _secretKey[96] - salt) * -2034360447; - return value; - } - case 55: - { - // MultipleRotateXorInstruction - value ^= -1022882984 ^ salt; - uint value2 = (uint)value >> 29; - uint part1 = (uint)value << (32 - 29); - value = (int)(value2 | part1); - value = (value - _secretKey[29]) * -899658607; - return value; - } - case 56: - { - // XorMultipleRotateInstruction - uint value2 = (uint)value >> 12; - uint part1 = (uint)value << (32 - 12); - value = (int)(value2 | part1); - value = (value - _secretKey[235]) * 340919493; - value ^= 2122077674 ^ salt; - return value; - } - case 57: - { - // AddRotateXorInstruction - value ^= -720824840 ^ salt; - uint value2 = (uint)value >> 21; - uint part1 = (uint)value << (32 - 21); - value = (int)(value2 | part1); - value -= -503448718 + _secretKey[175]; - return value; - } - case 58: - { - // MultipleInstruction - value = (value - _secretKey[231] - salt) * 913639057; - return value; - } - case 59: - { - // BitRotateInstruction - uint value2 = (uint)((value - salt) ^ _secretKey[75]); - uint part1 = value2 >> 19; - uint part2 = value2 << (32 - 19); - value = (int)(part1 | part2); - return value; - } - case 60: - { - // MultipleRotateXorInstruction - value ^= 1420744071 ^ salt; - uint value2 = (uint)value >> 27; - uint part1 = (uint)value << (32 - 27); - value = (int)(value2 | part1); - value = (value - _secretKey[171]) * 238093953; - return value; - } - case 61: - { - // XorMultipleRotateInstruction - uint value2 = (uint)value >> 15; - uint part1 = (uint)value << (32 - 15); - value = (int)(value2 | part1); - value = (value - _secretKey[84]) * -2096065051; - value ^= 1366253139 ^ salt; - return value; - } - case 62: - { - // MultipleXorRotateInstruction - uint value2 = (uint)value >> 6; - uint part1 = (uint)value << (32 - 6); - value = (int)(value2 | part1); - value ^= -1974823163 ^ salt; - value = (value - _secretKey[132]) * 303900345; - return value; - } - case 63: - { - // BitRotateInstruction - uint value2 = (uint)((value - salt) ^ _secretKey[119]); - uint part1 = value2 >> 22; - uint part2 = value2 << (32 - 22); - value = (int)(part1 | part2); - return value; - } - case 64: - { - // XorInstruction - value = ((value ^ 1262347216) - salt) ^ _secretKey[15]; - return value; - } - case 65: - { - // AddInstruction - value = ((value - 1780280992) ^ salt) - _secretKey[126]; - return value; - } - case 66: - { - // MultipleXorRotateInstruction - uint value2 = (uint)value >> 13; - uint part1 = (uint)value << (32 - 13); - value = (int)(value2 | part1); - value ^= -1198162446 ^ salt; - value = (value - _secretKey[85]) * 1314512283; - return value; - } - case 67: - { - // MultipleInstruction - value = (value - _secretKey[128] - salt) * 463417823; - return value; - } - case 68: - { - // BitRotateInstruction - uint value2 = (uint)((value - salt) ^ _secretKey[178]); - uint part1 = value2 >> 24; - uint part2 = value2 << (32 - 24); - value = (int)(part1 | part2); - return value; - } - case 69: - { - // XorInstruction - value = ((value ^ 1649427052) - salt) ^ _secretKey[61]; - return value; - } - case 70: - { - // MultipleRotateXorInstruction - value ^= 849172121 ^ salt; - uint value2 = (uint)value >> 17; - uint part1 = (uint)value << (32 - 17); - value = (int)(value2 | part1); - value = (value - _secretKey[83]) * 368180765; - return value; - } - case 71: - { - // BitRotateInstruction - uint value2 = (uint)((value - salt) ^ _secretKey[169]); - uint part1 = value2 >> 16; - uint part2 = value2 << (32 - 16); - value = (int)(part1 | part2); - return value; - } - case 72: - { - // XorAddRotateInstruction - uint value2 = (uint)value >> 20; - uint part1 = (uint)value << (32 - 20); - value = (int)(value2 | part1); - value -= -2092062916 + _secretKey[138]; - value ^= 1068287172 ^ salt; - return value; - } - case 73: - { - // MultipleInstruction - value = (value - _secretKey[34] - salt) * -495145181; - return value; - } - case 74: - { - // MultipleRotateXorInstruction - value ^= -145743337 ^ salt; - uint value2 = (uint)value >> 29; - uint part1 = (uint)value << (32 - 29); - value = (int)(value2 | part1); - value = (value - _secretKey[30]) * 1735064809; - return value; - } - case 75: - { - // MultipleRotateXorInstruction - value ^= 280941267 ^ salt; - uint value2 = (uint)value >> 4; - uint part1 = (uint)value << (32 - 4); - value = (int)(value2 | part1); - value = (value - _secretKey[142]) * 442035963; - return value; - } - case 76: - { - // MultipleInstruction - value = (value - _secretKey[156] - salt) * -971441783; - return value; - } - case 77: - { - // AddRotateXorInstruction - value ^= 827331935 ^ salt; - uint value2 = (uint)value >> 7; - uint part1 = (uint)value << (32 - 7); - value = (int)(value2 | part1); - value -= 314625916 + _secretKey[192]; - return value; - } - case 78: - { - // MultipleInstruction - value = (value - _secretKey[141] - salt) * -1649657957; - return value; - } - case 79: - { - // AddXorRotateInstruction - uint part1 = (uint)value >> 11; - uint part2 = (uint)value << (32 - 11); - value = (int)(part1 | part2); - value ^= -11549173 ^ salt; - value -= 1607953190 + _secretKey[133]; - return value; - } - case 80: - { - // XorAddRotateInstruction - uint value2 = (uint)value >> 25; - uint part1 = (uint)value << (32 - 25); - value = (int)(value2 | part1); - value -= 687186546 + _secretKey[95]; - value ^= -1454482890 ^ salt; - return value; - } - case 81: - { - // XorInstruction - value = ((value ^ 814860713) - salt) ^ _secretKey[195]; - return value; - } - case 82: - { - // AddRotateXorInstruction - value ^= 213310246 ^ salt; - uint value2 = (uint)value >> 19; - uint part1 = (uint)value << (32 - 19); - value = (int)(value2 | part1); - value -= 1998643542 + _secretKey[171]; - return value; - } - case 83: - { - // AddRotateXorInstruction - value ^= -696314173 ^ salt; - uint value2 = (uint)value >> 14; - uint part1 = (uint)value << (32 - 14); - value = (int)(value2 | part1); - value -= 542686146 + _secretKey[249]; - return value; - } - case 84: - { - // AddRotateXorInstruction - value ^= 118718247 ^ salt; - uint value2 = (uint)value >> 9; - uint part1 = (uint)value << (32 - 9); - value = (int)(value2 | part1); - value -= 1734820207 + _secretKey[2]; - return value; - } - case 85: - { - // XorInstruction - value = ((value ^ 1553710234) - salt) ^ _secretKey[143]; - return value; - } - case 86: - { - // AddRotateXorInstruction - value ^= -1402843691 ^ salt; - uint value2 = (uint)value >> 5; - uint part1 = (uint)value << (32 - 5); - value = (int)(value2 | part1); - value -= -217984331 + _secretKey[146]; - return value; - } - case 87: - { - // MultipleInstruction - value = (value - _secretKey[5] - salt) * -814971689; - return value; - } - case 88: - { - // MultipleRotateXorInstruction - value ^= -2044505542 ^ salt; - uint value2 = (uint)value >> 28; - uint part1 = (uint)value << (32 - 28); - value = (int)(value2 | part1); - value = (value - _secretKey[158]) * 681320217; - return value; - } - case 89: - { - // AddInstruction - value = ((value - -1213654475) ^ salt) - _secretKey[40]; - return value; - } - case 90: - { - // XorMultipleRotateInstruction - uint value2 = (uint)value >> 6; - uint part1 = (uint)value << (32 - 6); - value = (int)(value2 | part1); - value = (value - _secretKey[206]) * 583163349; - value ^= -1886972278 ^ salt; - return value; - } - case 91: - { - // AddRotateXorInstruction - value ^= -979249928 ^ salt; - uint value2 = (uint)value >> 23; - uint part1 = (uint)value << (32 - 23); - value = (int)(value2 | part1); - value -= -1724625239 + _secretKey[223]; - return value; - } - case 92: - { - // XorInstruction - value = ((value ^ -1104541704) - salt) ^ _secretKey[83]; - return value; - } - case 93: - { - // XorInstruction - value = ((value ^ 311150152) - salt) ^ _secretKey[31]; - return value; - } - case 94: - { - // XorMultipleRotateInstruction - uint value2 = (uint)value >> 17; - uint part1 = (uint)value << (32 - 17); - value = (int)(value2 | part1); - value = (value - _secretKey[176]) * 1535026385; - value ^= 116496631 ^ salt; - return value; - } - case 95: - { - // MultipleRotateXorInstruction - value ^= 2133438141 ^ salt; - uint value2 = (uint)value >> 2; - uint part1 = (uint)value << (32 - 2); - value = (int)(value2 | part1); - value = (value - _secretKey[87]) * 1779203413; - return value; - } - case 96: - { - // MultipleRotateXorInstruction - value ^= 225535005 ^ salt; - uint value2 = (uint)value >> 16; - uint part1 = (uint)value << (32 - 16); - value = (int)(value2 | part1); - value = (value - _secretKey[174]) * 521638757; - return value; - } - case 97: - { - // MultipleRotateXorInstruction - value ^= -1703839105 ^ salt; - uint value2 = (uint)value >> 1; - uint part1 = (uint)value << (32 - 1); - value = (int)(value2 | part1); - value = (value - _secretKey[175]) * -1131776573; - return value; - } - case 98: - { - // XorAddRotateInstruction - uint value2 = (uint)value >> 15; - uint part1 = (uint)value << (32 - 15); - value = (int)(value2 | part1); - value -= -1783079937 + _secretKey[78]; - value ^= -447564571 ^ salt; - return value; - } - case 99: - { - // XorInstruction - value = ((value ^ -316631669) - salt) ^ _secretKey[111]; - return value; - } - case 100: - { - // XorMultipleRotateInstruction - uint value2 = (uint)value >> 24; - uint part1 = (uint)value << (32 - 24); - value = (int)(value2 | part1); - value = (value - _secretKey[252]) * 898292471; - value ^= -405694625 ^ salt; - return value; - } - case 101: - { - // MultipleXorRotateInstruction - uint value2 = (uint)value >> 6; - uint part1 = (uint)value << (32 - 6); - value = (int)(value2 | part1); - value ^= -1551058348 ^ salt; - value = (value - _secretKey[212]) * -22167815; - return value; - } - case 102: - { - // AddInstruction - value = ((value - -853736135) ^ salt) - _secretKey[18]; - return value; - } - case 103: - { - // AddInstruction - value = ((value - 1321376878) ^ salt) - _secretKey[116]; - return value; - } - case 104: - { - // MultipleRotateXorInstruction - value ^= 541697309 ^ salt; - uint value2 = (uint)value >> 0; - uint part1 = (uint)value << (32 - 0); - value = (int)(value2 | part1); - value = (value - _secretKey[7]) * -1964889845; - return value; - } - case 105: - { - // AddRotateXorInstruction - value ^= 1176608900 ^ salt; - uint value2 = (uint)value >> 4; - uint part1 = (uint)value << (32 - 4); - value = (int)(value2 | part1); - value -= -822594180 + _secretKey[1]; - return value; - } - case 106: - { - // AddInstruction - value = ((value - -882893600) ^ salt) - _secretKey[110]; - return value; - } - case 107: - { - // MultipleRotateXorInstruction - value ^= -1566546809 ^ salt; - uint value2 = (uint)value >> 23; - uint part1 = (uint)value << (32 - 23); - value = (int)(value2 | part1); - value = (value - _secretKey[114]) * 406480373; - return value; - } - case 108: - { - // MultipleInstruction - value = (value - _secretKey[97] - salt) * 200608377; - return value; - } - case 109: - { - // XorAddRotateInstruction - uint value2 = (uint)value >> 7; - uint part1 = (uint)value << (32 - 7); - value = (int)(value2 | part1); - value -= 1161425930 + _secretKey[43]; - value ^= -72794161 ^ salt; - return value; - } - case 110: - { - // AddInstruction - value = ((value - -1619543125) ^ salt) - _secretKey[238]; - return value; - } - case 111: - { - // XorAddRotateInstruction - uint value2 = (uint)value >> 12; - uint part1 = (uint)value << (32 - 12); - value = (int)(value2 | part1); - value -= -1766468683 + _secretKey[241]; - value ^= 1170459122 ^ salt; - return value; - } - case 112: - { - // AddXorRotateInstruction - uint part1 = (uint)value >> 11; - uint part2 = (uint)value << (32 - 11); - value = (int)(part1 | part2); - value ^= 323019346 ^ salt; - value -= 251687012 + _secretKey[219]; - return value; - } - case 113: - { - // AddInstruction - value = ((value - -1049972438) ^ salt) - _secretKey[97]; - return value; - } - case 114: - { - // XorMultipleRotateInstruction - uint value2 = (uint)value >> 10; - uint part1 = (uint)value << (32 - 10); - value = (int)(value2 | part1); - value = (value - _secretKey[216]) * 594045631; - value ^= -492239002 ^ salt; - return value; - } - case 115: - { - // AddInstruction - value = ((value - -748126329) ^ salt) - _secretKey[221]; - return value; - } - case 116: - { - // AddXorRotateInstruction - uint part1 = (uint)value >> 17; - uint part2 = (uint)value << (32 - 17); - value = (int)(part1 | part2); - value ^= -5933889 ^ salt; - value -= -441051263 + _secretKey[96]; - return value; - } - case 117: - { - // MultipleRotateXorInstruction - value ^= 543895274 ^ salt; - uint value2 = (uint)value >> 11; - uint part1 = (uint)value << (32 - 11); - value = (int)(value2 | part1); - value = (value - _secretKey[88]) * 1253478165; - return value; - } - case 118: - { - // MultipleInstruction - value = (value - _secretKey[140] - salt) * 1897067971; - return value; - } - case 119: - { - // BitRotateInstruction - uint value2 = (uint)((value - salt) ^ _secretKey[175]); - uint part1 = value2 >> 18; - uint part2 = value2 << (32 - 18); - value = (int)(part1 | part2); - return value; - } - case 120: - { - // MultipleRotateXorInstruction - value ^= 1300544743 ^ salt; - uint value2 = (uint)value >> 16; - uint part1 = (uint)value << (32 - 16); - value = (int)(value2 | part1); - value = (value - _secretKey[57]) * -927555255; - return value; - } - case 121: - { - // XorAddRotateInstruction - uint value2 = (uint)value >> 1; - uint part1 = (uint)value << (32 - 1); - value = (int)(value2 | part1); - value -= 678597707 + _secretKey[119]; - value ^= -547380749 ^ salt; - return value; - } - case 122: - { - // XorMultipleRotateInstruction - uint value2 = (uint)value >> 19; - uint part1 = (uint)value << (32 - 19); - value = (int)(value2 | part1); - value = (value - _secretKey[191]) * -1394333385; - value ^= 683601851 ^ salt; - return value; - } - case 123: - { - // BitRotateInstruction - uint value2 = (uint)((value - salt) ^ _secretKey[15]); - uint part1 = value2 >> 20; - uint part2 = value2 << (32 - 20); - value = (int)(part1 | part2); - return value; - } - case 124: - { - // BitRotateInstruction - uint value2 = (uint)((value - salt) ^ _secretKey[132]); - uint part1 = value2 >> 8; - uint part2 = value2 << (32 - 8); - value = (int)(part1 | part2); - return value; - } - case 125: - { - // MultipleInstruction - value = (value - _secretKey[120] - salt) * 412809175; - return value; - } - case 126: - { - // AddInstruction - value = ((value - -1374139785) ^ salt) - _secretKey[197]; - return value; - } - case 127: - { - // BitRotateInstruction - uint value2 = (uint)((value - salt) ^ _secretKey[26]); - uint part1 = value2 >> 15; - uint part2 = value2 << (32 - 15); - value = (int)(part1 | part2); - return value; - } - case 128: - { - // XorAddRotateInstruction - uint value2 = (uint)value >> 21; - uint part1 = (uint)value << (32 - 21); - value = (int)(value2 | part1); - value -= 723646816 + _secretKey[146]; - value ^= 1415280510 ^ salt; - return value; - } - case 129: - { - // AddRotateXorInstruction - value ^= 2132310656 ^ salt; - uint value2 = (uint)value >> 30; - uint part1 = (uint)value << (32 - 30); - value = (int)(value2 | part1); - value -= 1410706317 + _secretKey[165]; - return value; - } - case 130: - { - // XorAddRotateInstruction - uint value2 = (uint)value >> 12; - uint part1 = (uint)value << (32 - 12); - value = (int)(value2 | part1); - value -= -483221582 + _secretKey[93]; - value ^= 1264971736 ^ salt; - return value; - } - case 131: - { - // AddXorRotateInstruction - uint part1 = (uint)value >> 17; - uint part2 = (uint)value << (32 - 17); - value = (int)(part1 | part2); - value ^= 1531807059 ^ salt; - value -= -1872731835 + _secretKey[53]; - return value; - } - case 132: - { - // AddXorRotateInstruction - uint part1 = (uint)value >> 10; - uint part2 = (uint)value << (32 - 10); - value = (int)(part1 | part2); - value ^= 306666665 ^ salt; - value -= 264114638 + _secretKey[240]; - return value; - } - case 133: - { - // AddRotateXorInstruction - value ^= -1266414649 ^ salt; - uint value2 = (uint)value >> 20; - uint part1 = (uint)value << (32 - 20); - value = (int)(value2 | part1); - value -= 824712252 + _secretKey[138]; - return value; - } - case 134: - { - // AddRotateXorInstruction - value ^= 2133737246 ^ salt; - uint value2 = (uint)value >> 25; - uint part1 = (uint)value << (32 - 25); - value = (int)(value2 | part1); - value -= -766337246 + _secretKey[35]; - return value; - } - case 135: - { - // AddXorRotateInstruction - uint part1 = (uint)value >> 14; - uint part2 = (uint)value << (32 - 14); - value = (int)(part1 | part2); - value ^= 1683555122 ^ salt; - value -= -1997614825 + _secretKey[165]; - return value; - } - case 136: - { - // MultipleXorRotateInstruction - uint value2 = (uint)value >> 28; - uint part1 = (uint)value << (32 - 28); - value = (int)(value2 | part1); - value ^= -1305042504 ^ salt; - value = (value - _secretKey[57]) * 949096539; - return value; - } - case 137: - { - // BitRotateInstruction - uint value2 = (uint)((value - salt) ^ _secretKey[192]); - uint part1 = value2 >> 28; - uint part2 = value2 << (32 - 28); - value = (int)(part1 | part2); - return value; - } - case 138: - { - // XorInstruction - value = ((value ^ 1715223135) - salt) ^ _secretKey[135]; - return value; - } - case 139: - { - // MultipleInstruction - value = (value - _secretKey[79] - salt) * -307106491; - return value; - } - case 140: - { - // AddRotateXorInstruction - value ^= 806320034 ^ salt; - uint value2 = (uint)value >> 11; - uint part1 = (uint)value << (32 - 11); - value = (int)(value2 | part1); - value -= -408450171 + _secretKey[11]; - return value; - } - case 141: - { - // AddInstruction - value = ((value - -433941646) ^ salt) - _secretKey[95]; - return value; - } - case 142: - { - // AddXorRotateInstruction - uint part1 = (uint)value >> 26; - uint part2 = (uint)value << (32 - 26); - value = (int)(part1 | part2); - value ^= 2132471747 ^ salt; - value -= 1775820811 + _secretKey[169]; - return value; - } - case 143: - { - // MultipleXorRotateInstruction - uint value2 = (uint)value >> 2; - uint part1 = (uint)value << (32 - 2); - value = (int)(value2 | part1); - value ^= 114258470 ^ salt; - value = (value - _secretKey[19]) * 1566112771; - return value; - } - case 144: - { - // AddRotateXorInstruction - value ^= -1181275232 ^ salt; - uint value2 = (uint)value >> 3; - uint part1 = (uint)value << (32 - 3); - value = (int)(value2 | part1); - value -= -650723591 + _secretKey[206]; - return value; - } - case 145: - { - // MultipleInstruction - value = (value - _secretKey[169] - salt) * 39803307; - return value; - } - case 146: - { - // XorInstruction - value = ((value ^ -1297404981) - salt) ^ _secretKey[154]; - return value; - } - case 147: - { - // MultipleRotateXorInstruction - value ^= 801710213 ^ salt; - uint value2 = (uint)value >> 18; - uint part1 = (uint)value << (32 - 18); - value = (int)(value2 | part1); - value = (value - _secretKey[181]) * -1217833329; - return value; - } - case 148: - { - // AddXorRotateInstruction - uint part1 = (uint)value >> 29; - uint part2 = (uint)value << (32 - 29); - value = (int)(part1 | part2); - value ^= 1566976773 ^ salt; - value -= -1933121809 + _secretKey[230]; - return value; - } - case 149: - { - // BitRotateInstruction - uint value2 = (uint)((value - salt) ^ _secretKey[188]); - uint part1 = value2 >> 30; - uint part2 = value2 << (32 - 30); - value = (int)(part1 | part2); - return value; - } - case 150: - { - // BitRotateInstruction - uint value2 = (uint)((value - salt) ^ _secretKey[53]); - uint part1 = value2 >> 30; - uint part2 = value2 << (32 - 30); - value = (int)(part1 | part2); - return value; - } - case 151: - { - // AddInstruction - value = ((value - -2119615805) ^ salt) - _secretKey[138]; - return value; - } - case 152: - { - // MultipleRotateXorInstruction - value ^= 221292457 ^ salt; - uint value2 = (uint)value >> 16; - uint part1 = (uint)value << (32 - 16); - value = (int)(value2 | part1); - value = (value - _secretKey[102]) * -1630338257; - return value; - } - case 153: - { - // MultipleRotateXorInstruction - value ^= 1486712056 ^ salt; - uint value2 = (uint)value >> 13; - uint part1 = (uint)value << (32 - 13); - value = (int)(value2 | part1); - value = (value - _secretKey[248]) * -1360595481; - return value; - } - case 154: - { - // MultipleInstruction - value = (value - _secretKey[72] - salt) * 1812161233; - return value; - } - case 155: - { - // MultipleRotateXorInstruction - value ^= -81016400 ^ salt; - uint value2 = (uint)value >> 17; - uint part1 = (uint)value << (32 - 17); - value = (int)(value2 | part1); - value = (value - _secretKey[247]) * -47344461; - return value; - } - case 156: - { - // MultipleRotateXorInstruction - value ^= -1187848798 ^ salt; - uint value2 = (uint)value >> 23; - uint part1 = (uint)value << (32 - 23); - value = (int)(value2 | part1); - value = (value - _secretKey[252]) * -1858496529; - return value; - } - case 157: - { - // AddXorRotateInstruction - uint part1 = (uint)value >> 16; - uint part2 = (uint)value << (32 - 16); - value = (int)(part1 | part2); - value ^= 1185916334 ^ salt; - value -= 605454035 + _secretKey[108]; - return value; - } - case 158: - { - // AddXorRotateInstruction - uint part1 = (uint)value >> 1; - uint part2 = (uint)value << (32 - 1); - value = (int)(part1 | part2); - value ^= -451761745 ^ salt; - value -= 2112611413 + _secretKey[235]; - return value; - } - case 159: - { - // XorInstruction - value = ((value ^ 1660696922) - salt) ^ _secretKey[229]; - return value; - } - case 160: - { - // MultipleRotateXorInstruction - value ^= -431219573 ^ salt; - uint value2 = (uint)value >> 31; - uint part1 = (uint)value << (32 - 31); - value = (int)(value2 | part1); - value = (value - _secretKey[111]) * 1706905775; - return value; - } - case 161: - { - // XorMultipleRotateInstruction - uint value2 = (uint)value >> 28; - uint part1 = (uint)value << (32 - 28); - value = (int)(value2 | part1); - value = (value - _secretKey[198]) * -580820577; - value ^= 1658933717 ^ salt; - return value; - } - case 162: - { - // AddRotateXorInstruction - value ^= 609336148 ^ salt; - uint value2 = (uint)value >> 20; - uint part1 = (uint)value << (32 - 20); - value = (int)(value2 | part1); - value -= -1278798944 + _secretKey[72]; - return value; - } - case 163: - { - // MultipleXorRotateInstruction - uint value2 = (uint)value >> 26; - uint part1 = (uint)value << (32 - 26); - value = (int)(value2 | part1); - value ^= -1055021038 ^ salt; - value = (value - _secretKey[57]) * -620746171; - return value; - } - case 164: - { - // MultipleXorRotateInstruction - uint value2 = (uint)value >> 7; - uint part1 = (uint)value << (32 - 7); - value = (int)(value2 | part1); - value ^= 1389308323 ^ salt; - value = (value - _secretKey[225]) * 2035776477; - return value; - } - case 165: - { - // XorAddRotateInstruction - uint value2 = (uint)value >> 1; - uint part1 = (uint)value << (32 - 1); - value = (int)(value2 | part1); - value -= -1939584600 + _secretKey[124]; - value ^= 318043677 ^ salt; - return value; - } - case 166: - { - // MultipleXorRotateInstruction - uint value2 = (uint)value >> 14; - uint part1 = (uint)value << (32 - 14); - value = (int)(value2 | part1); - value ^= 2047590880 ^ salt; - value = (value - _secretKey[184]) * -748679859; - return value; - } - case 167: - { - // XorInstruction - value = ((value ^ -312123044) - salt) ^ _secretKey[114]; - return value; - } - case 168: - { - // AddXorRotateInstruction - uint part1 = (uint)value >> 1; - uint part2 = (uint)value << (32 - 1); - value = (int)(part1 | part2); - value ^= -1299860280 ^ salt; - value -= 1897551751 + _secretKey[139]; - return value; - } - case 169: - { - // BitRotateInstruction - uint value2 = (uint)((value - salt) ^ _secretKey[10]); - uint part1 = value2 >> 15; - uint part2 = value2 << (32 - 15); - value = (int)(part1 | part2); - return value; - } - case 170: - { - // MultipleInstruction - value = (value - _secretKey[60] - salt) * 609589815; - return value; - } - case 171: - { - // XorMultipleRotateInstruction - uint value2 = (uint)value >> 21; - uint part1 = (uint)value << (32 - 21); - value = (int)(value2 | part1); - value = (value - _secretKey[242]) * 893240649; - value ^= 820953326 ^ salt; - return value; - } - case 172: - { - // XorInstruction - value = ((value ^ 921116076) - salt) ^ _secretKey[89]; - return value; - } - case 173: - { - // AddInstruction - value = ((value - -1261901861) ^ salt) - _secretKey[82]; - return value; - } - case 174: - { - // MultipleRotateXorInstruction - value ^= -1758870671 ^ salt; - uint value2 = (uint)value >> 1; - uint part1 = (uint)value << (32 - 1); - value = (int)(value2 | part1); - value = (value - _secretKey[42]) * -1163763527; - return value; - } - case 175: - { - // XorAddRotateInstruction - uint value2 = (uint)value >> 14; - uint part1 = (uint)value << (32 - 14); - value = (int)(value2 | part1); - value -= 1254595032 + _secretKey[10]; - value ^= -99371457 ^ salt; - return value; - } - case 176: - { - // AddXorRotateInstruction - uint part1 = (uint)value >> 0; - uint part2 = (uint)value << (32 - 0); - value = (int)(part1 | part2); - value ^= -2036462975 ^ salt; - value -= 1901168605 + _secretKey[131]; - return value; - } - case 177: - { - // MultipleRotateXorInstruction - value ^= -805817000 ^ salt; - uint value2 = (uint)value >> 29; - uint part1 = (uint)value << (32 - 29); - value = (int)(value2 | part1); - value = (value - _secretKey[29]) * -1809334639; - return value; - } - case 178: - { - // AddXorRotateInstruction - uint part1 = (uint)value >> 12; - uint part2 = (uint)value << (32 - 12); - value = (int)(part1 | part2); - value ^= 762578411 ^ salt; - value -= 28490730 + _secretKey[13]; - return value; - } - case 179: - { - // XorAddRotateInstruction - uint value2 = (uint)value >> 24; - uint part1 = (uint)value << (32 - 24); - value = (int)(value2 | part1); - value -= -41308497 + _secretKey[85]; - value ^= 1812019570 ^ salt; - return value; - } - case 180: - { - // XorInstruction - value = ((value ^ 1563652208) - salt) ^ _secretKey[231]; - return value; - } - case 181: - { - // AddRotateXorInstruction - value ^= -1148350591 ^ salt; - uint value2 = (uint)value >> 23; - uint part1 = (uint)value << (32 - 23); - value = (int)(value2 | part1); - value -= -542613261 + _secretKey[75]; - return value; - } - case 182: - { - // AddXorRotateInstruction - uint part1 = (uint)value >> 19; - uint part2 = (uint)value << (32 - 19); - value = (int)(part1 | part2); - value ^= 1842755263 ^ salt; - value -= 1462569147 + _secretKey[135]; - return value; - } - case 183: - { - // MultipleXorRotateInstruction - uint value2 = (uint)value >> 8; - uint part1 = (uint)value << (32 - 8); - value = (int)(value2 | part1); - value ^= -159244912 ^ salt; - value = (value - _secretKey[15]) * -663204867; - return value; - } - case 184: - { - // BitRotateInstruction - uint value2 = (uint)((value - salt) ^ _secretKey[230]); - uint part1 = value2 >> 5; - uint part2 = value2 << (32 - 5); - value = (int)(part1 | part2); - return value; - } - case 185: - { - // AddRotateXorInstruction - value ^= 1218428368 ^ salt; - uint value2 = (uint)value >> 5; - uint part1 = (uint)value << (32 - 5); - value = (int)(value2 | part1); - value -= 45305078 + _secretKey[119]; - return value; - } - case 186: - { - // AddXorRotateInstruction - uint part1 = (uint)value >> 0; - uint part2 = (uint)value << (32 - 0); - value = (int)(part1 | part2); - value ^= 567100030 ^ salt; - value -= 148564506 + _secretKey[160]; - return value; - } - case 187: - { - // BitRotateInstruction - uint value2 = (uint)((value - salt) ^ _secretKey[242]); - uint part1 = value2 >> 21; - uint part2 = value2 << (32 - 21); - value = (int)(part1 | part2); - return value; - } - case 188: - { - // MultipleRotateXorInstruction - value ^= 730302816 ^ salt; - uint value2 = (uint)value >> 0; - uint part1 = (uint)value << (32 - 0); - value = (int)(value2 | part1); - value = (value - _secretKey[30]) * -1488719571; - return value; - } - case 189: - { - // BitRotateInstruction - uint value2 = (uint)((value - salt) ^ _secretKey[93]); - uint part1 = value2 >> 18; - uint part2 = value2 << (32 - 18); - value = (int)(part1 | part2); - return value; - } - case 190: - { - // BitRotateInstruction - uint value2 = (uint)((value - salt) ^ _secretKey[69]); - uint part1 = value2 >> 29; - uint part2 = value2 << (32 - 29); - value = (int)(part1 | part2); - return value; - } - case 191: - { - // XorMultipleRotateInstruction - uint value2 = (uint)value >> 14; - uint part1 = (uint)value << (32 - 14); - value = (int)(value2 | part1); - value = (value - _secretKey[153]) * 1590990225; - value ^= 1474104403 ^ salt; - return value; - } - case 192: - { - // AddInstruction - value = ((value - 1345231273) ^ salt) - _secretKey[170]; - return value; - } - case 193: - { - // BitRotateInstruction - uint value2 = (uint)((value - salt) ^ _secretKey[138]); - uint part1 = value2 >> 28; - uint part2 = value2 << (32 - 28); - value = (int)(part1 | part2); - return value; - } - case 194: - { - // AddRotateXorInstruction - value ^= -1086752221 ^ salt; - uint value2 = (uint)value >> 2; - uint part1 = (uint)value << (32 - 2); - value = (int)(value2 | part1); - value -= -1649692985 + _secretKey[138]; - return value; - } - case 195: - { - // XorMultipleRotateInstruction - uint value2 = (uint)value >> 5; - uint part1 = (uint)value << (32 - 5); - value = (int)(value2 | part1); - value = (value - _secretKey[23]) * -718602987; - value ^= 216360478 ^ salt; - return value; - } - case 196: - { - // XorAddRotateInstruction - uint value2 = (uint)value >> 25; - uint part1 = (uint)value << (32 - 25); - value = (int)(value2 | part1); - value -= -922639548 + _secretKey[211]; - value ^= 1736125070 ^ salt; - return value; - } - case 197: - { - // XorAddRotateInstruction - uint value2 = (uint)value >> 0; - uint part1 = (uint)value << (32 - 0); - value = (int)(value2 | part1); - value -= -1729078426 + _secretKey[124]; - value ^= -1590872932 ^ salt; - return value; - } - case 198: - { - // AddXorRotateInstruction - uint part1 = (uint)value >> 13; - uint part2 = (uint)value << (32 - 13); - value = (int)(part1 | part2); - value ^= 2101329043 ^ salt; - value -= -2086916257 + _secretKey[135]; - return value; - } - case 199: - { - // XorInstruction - value = ((value ^ -1188487898) - salt) ^ _secretKey[133]; - return value; - } - case 200: - { - // MultipleInstruction - value = (value - _secretKey[162] - salt) * -1592735389; - return value; - } - case 201: - { - // XorAddRotateInstruction - uint value2 = (uint)value >> 11; - uint part1 = (uint)value << (32 - 11); - value = (int)(value2 | part1); - value -= -1882888353 + _secretKey[153]; - value ^= 2087683186 ^ salt; - return value; - } - case 202: - { - // MultipleRotateXorInstruction - value ^= -1855365205 ^ salt; - uint value2 = (uint)value >> 22; - uint part1 = (uint)value << (32 - 22); - value = (int)(value2 | part1); - value = (value - _secretKey[58]) * -1429384213; - return value; - } - case 203: - { - // MultipleInstruction - value = (value - _secretKey[66] - salt) * 180652695; - return value; - } - case 204: - { - // MultipleXorRotateInstruction - uint value2 = (uint)value >> 0; - uint part1 = (uint)value << (32 - 0); - value = (int)(value2 | part1); - value ^= 1668989123 ^ salt; - value = (value - _secretKey[206]) * 715760713; - return value; - } - case 205: - { - // MultipleInstruction - value = (value - _secretKey[169] - salt) * -19415893; - return value; - } - case 206: - { - // XorMultipleRotateInstruction - uint value2 = (uint)value >> 14; - uint part1 = (uint)value << (32 - 14); - value = (int)(value2 | part1); - value = (value - _secretKey[143]) * 408562579; - value ^= -387621173 ^ salt; - return value; - } - case 207: - { - // XorInstruction - value = ((value ^ -1302837102) - salt) ^ _secretKey[133]; - return value; - } - case 208: - { - // XorMultipleRotateInstruction - uint value2 = (uint)value >> 29; - uint part1 = (uint)value << (32 - 29); - value = (int)(value2 | part1); - value = (value - _secretKey[5]) * 199587543; - value ^= 1201861103 ^ salt; - return value; - } - case 209: - { - // AddInstruction - value = ((value - -1698116194) ^ salt) - _secretKey[188]; - return value; - } - case 210: - { - // XorAddRotateInstruction - uint value2 = (uint)value >> 3; - uint part1 = (uint)value << (32 - 3); - value = (int)(value2 | part1); - value -= -5412811 + _secretKey[40]; - value ^= 955827838 ^ salt; - return value; - } - case 211: - { - // MultipleXorRotateInstruction - uint value2 = (uint)value >> 16; - uint part1 = (uint)value << (32 - 16); - value = (int)(value2 | part1); - value ^= -261186202 ^ salt; - value = (value - _secretKey[206]) * 250403797; - return value; - } - case 212: - { - // XorInstruction - value = ((value ^ 1451245279) - salt) ^ _secretKey[215]; - return value; - } - case 213: - { - // AddInstruction - value = ((value - -48271475) ^ salt) - _secretKey[248]; - return value; - } - case 214: - { - // MultipleRotateXorInstruction - value ^= 280704379 ^ salt; - uint value2 = (uint)value >> 31; - uint part1 = (uint)value << (32 - 31); - value = (int)(value2 | part1); - value = (value - _secretKey[72]) * -1743417391; - return value; - } - case 215: - { - // MultipleRotateXorInstruction - value ^= -1507466225 ^ salt; - uint value2 = (uint)value >> 17; - uint part1 = (uint)value << (32 - 17); - value = (int)(value2 | part1); - value = (value - _secretKey[176]) * -795921711; - return value; - } - case 216: - { - // BitRotateInstruction - uint value2 = (uint)((value - salt) ^ _secretKey[162]); - uint part1 = value2 >> 23; - uint part2 = value2 << (32 - 23); - value = (int)(part1 | part2); - return value; - } - case 217: - { - // XorInstruction - value = ((value ^ -1329546797) - salt) ^ _secretKey[108]; - return value; - } - case 218: - { - // XorAddRotateInstruction - uint value2 = (uint)value >> 11; - uint part1 = (uint)value << (32 - 11); - value = (int)(value2 | part1); - value -= 1710889501 + _secretKey[85]; - value ^= 846489904 ^ salt; - return value; - } - case 219: - { - // XorInstruction - value = ((value ^ -339712479) - salt) ^ _secretKey[127]; - return value; - } - case 220: - { - // XorAddRotateInstruction - uint value2 = (uint)value >> 15; - uint part1 = (uint)value << (32 - 15); - value = (int)(value2 | part1); - value -= -308188673 + _secretKey[78]; - value ^= -1008587035 ^ salt; - return value; - } - case 221: - { - // MultipleInstruction - value = (value - _secretKey[111] - salt) * 773277731; - return value; - } - case 222: - { - // MultipleInstruction - value = (value - _secretKey[198] - salt) * 1149219487; - return value; - } - case 223: - { - // AddInstruction - value = ((value - -449129672) ^ salt) - _secretKey[160]; - return value; - } - case 224: - { - // MultipleXorRotateInstruction - uint value2 = (uint)value >> 12; - uint part1 = (uint)value << (32 - 12); - value = (int)(value2 | part1); - value ^= -180027834 ^ salt; - value = (value - _secretKey[84]) * 102372989; - return value; - } - case 225: - { - // XorInstruction - value = ((value ^ 946019090) - salt) ^ _secretKey[58]; - return value; - } - case 226: - { - // AddRotateXorInstruction - value ^= 1350981383 ^ salt; - uint value2 = (uint)value >> 3; - uint part1 = (uint)value << (32 - 3); - value = (int)(value2 | part1); - value -= 694016884 + _secretKey[225]; - return value; - } - case 227: - { - // AddRotateXorInstruction - value ^= 1680252929 ^ salt; - uint value2 = (uint)value >> 28; - uint part1 = (uint)value << (32 - 28); - value = (int)(value2 | part1); - value -= -870643939 + _secretKey[168]; - return value; - } - case 228: - { - // BitRotateInstruction - uint value2 = (uint)((value - salt) ^ _secretKey[184]); - uint part1 = value2 >> 4; - uint part2 = value2 << (32 - 4); - value = (int)(part1 | part2); - return value; - } - case 229: - { - // AddRotateXorInstruction - value ^= -1727043214 ^ salt; - uint value2 = (uint)value >> 28; - uint part1 = (uint)value << (32 - 28); - value = (int)(value2 | part1); - value -= 1785715822 + _secretKey[199]; - return value; - } - case 230: - { - // XorInstruction - value = ((value ^ -1277148537) - salt) ^ _secretKey[139]; - return value; - } - case 231: - { - // MultipleXorRotateInstruction - uint value2 = (uint)value >> 10; - uint part1 = (uint)value << (32 - 10); - value = (int)(value2 | part1); - value ^= 1940873679 ^ salt; - value = (value - _secretKey[226]) * -528829791; - return value; - } - case 232: - { - // XorMultipleRotateInstruction - uint value2 = (uint)value >> 14; - uint part1 = (uint)value << (32 - 14); - value = (int)(value2 | part1); - value = (value - _secretKey[171]) * 1486956053; - value ^= -879839609 ^ salt; - return value; - } - case 233: - { - // AddInstruction - value = ((value - 328489970) ^ salt) - _secretKey[181]; - return value; - } - case 234: - { - // MultipleInstruction - value = (value - _secretKey[89] - salt) * -1387476699; - return value; - } - case 235: - { - // XorAddRotateInstruction - uint value2 = (uint)value >> 8; - uint part1 = (uint)value << (32 - 8); - value = (int)(value2 | part1); - value -= -1977097134 + _secretKey[203]; - value ^= 1290000091 ^ salt; - return value; - } - case 236: - { - // AddInstruction - value = ((value - 1890859361) ^ salt) - _secretKey[113]; - return value; - } - case 237: - { - // AddRotateXorInstruction - value ^= 1434413518 ^ salt; - uint value2 = (uint)value >> 10; - uint part1 = (uint)value << (32 - 10); - value = (int)(value2 | part1); - value -= 1045620543 + _secretKey[216]; - return value; - } - case 238: - { - // AddXorRotateInstruction - uint part1 = (uint)value >> 0; - uint part2 = (uint)value << (32 - 0); - value = (int)(part1 | part2); - value ^= 1591345537 ^ salt; - value -= -1706485027 + _secretKey[131]; - return value; - } - case 239: - { - // AddXorRotateInstruction - uint part1 = (uint)value >> 24; - uint part2 = (uint)value << (32 - 24); - value = (int)(part1 | part2); - value ^= 1117669949 ^ salt; - value -= 1271081841 + _secretKey[29]; - return value; - } - case 240: - { - // XorMultipleRotateInstruction - uint value2 = (uint)value >> 12; - uint part1 = (uint)value << (32 - 12); - value = (int)(value2 | part1); - value = (value - _secretKey[235]) * 1588287429; - value ^= -842525462 ^ salt; - return value; - } - case 241: - { - // AddInstruction - value = ((value - 1030822002) ^ salt) - _secretKey[175]; - return value; - } - case 242: - { - // MultipleRotateXorInstruction - value ^= 811922151 ^ salt; - uint value2 = (uint)value >> 16; - uint part1 = (uint)value << (32 - 16); - value = (int)(value2 | part1); - value = (value - _secretKey[57]) * 769862473; - return value; - } - case 243: - { - // AddRotateXorInstruction - value ^= -1258702719 ^ salt; - uint value2 = (uint)value >> 23; - uint part1 = (uint)value << (32 - 23); - value = (int)(value2 | part1); - value -= 656680947 + _secretKey[75]; - return value; - } - case 244: - { - // XorMultipleRotateInstruction - uint value2 = (uint)value >> 19; - uint part1 = (uint)value << (32 - 19); - value = (int)(value2 | part1); - value = (value - _secretKey[191]) * -883345609; - value ^= 90809787 ^ salt; - return value; - } - case 245: - { - // AddRotateXorInstruction - value ^= 99436168 ^ salt; - uint value2 = (uint)value >> 16; - uint part1 = (uint)value << (32 - 16); - value = (int)(value2 | part1); - value -= -532913580 + _secretKey[15]; - return value; - } - case 246: - { - // MultipleXorRotateInstruction - uint value2 = (uint)value >> 22; - uint part1 = (uint)value << (32 - 22); - value = (int)(value2 | part1); - value ^= 1471598712 ^ salt; - value = (value - _secretKey[230]) * -599880499; - return value; - } - case 247: - { - // XorMultipleRotateInstruction - uint value2 = (uint)value >> 26; - uint part1 = (uint)value << (32 - 26); - value = (int)(value2 | part1); - value = (value - _secretKey[15]) * -1447936463; - value ^= 1941306053 ^ salt; - return value; - } - case 248: - { - // AddRotateXorInstruction - value ^= 2045091157 ^ salt; - uint value2 = (uint)value >> 18; - uint part1 = (uint)value << (32 - 18); - value = (int)(value2 | part1); - value -= 883137918 + _secretKey[96]; - return value; - } - case 249: - { - // BitRotateInstruction - uint value2 = (uint)((value - salt) ^ _secretKey[165]); - uint part1 = value2 >> 13; - uint part2 = value2 << (32 - 13); - value = (int)(part1 | part2); - return value; - } - case 250: - { - // AddInstruction - value = ((value - -394947456) ^ salt) - _secretKey[96]; - return value; - } - case 251: - { - // BitRotateInstruction - uint value2 = (uint)((value - salt) ^ _secretKey[93]); - uint part1 = value2 >> 18; - uint part2 = value2 << (32 - 18); - value = (int)(part1 | part2); - return value; - } - case 252: - { - // AddInstruction - value = ((value - 1917332797) ^ salt) - _secretKey[69]; - return value; - } - case 253: - { - // AddXorRotateInstruction - uint part1 = (uint)value >> 14; - uint part2 = (uint)value << (32 - 14); - value = (int)(part1 | part2); - value ^= -1509317223 ^ salt; - value -= 1006809939 + _secretKey[113]; - return value; - } - case 254: - { - // BitRotateInstruction - uint value2 = (uint)((value - salt) ^ _secretKey[170]); - uint part1 = value2 >> 9; - uint part2 = value2 << (32 - 9); - value = (int)(part1 | part2); - return value; - } - case 255: - { - // AddInstruction - value = ((value - 683715132) ^ salt) - _secretKey[138]; - return value; - } - - default: - throw new System.Exception($"Invalid opCode:{opCode}"); - } - } - - } -} - diff --git a/Obfuz/Assets/Obfuz/GeneratedEncryptionVirtualMachine.cs.meta b/Obfuz/Assets/Obfuz/GeneratedEncryptionVirtualMachine.cs.meta deleted file mode 100644 index 8752a2b..0000000 --- a/Obfuz/Assets/Obfuz/GeneratedEncryptionVirtualMachine.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 406c63e9d464ca544ac337bc8fcce30e -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Assets/Obfuz/SymbolObfus.meta b/Obfuz/Assets/Obfuz/SymbolObfus.meta deleted file mode 100644 index c4c116b..0000000 --- a/Obfuz/Assets/Obfuz/SymbolObfus.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 75e20a8abe7b86247837ffce1117762a -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Assets/Obfuz/SymbolObfus/symbol-mapping.xml b/Obfuz/Assets/Obfuz/SymbolObfus/symbol-mapping.xml deleted file mode 100644 index 32d891a..0000000 --- a/Obfuz/Assets/Obfuz/SymbolObfus/symbol-mapping.xml +++ /dev/null @@ -1,482 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Obfuz/Assets/Obfuz/SymbolObfus/symbol-mapping.xml.meta b/Obfuz/Assets/Obfuz/SymbolObfus/symbol-mapping.xml.meta deleted file mode 100644 index cdb1441..0000000 --- a/Obfuz/Assets/Obfuz/SymbolObfus/symbol-mapping.xml.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: b8e3f4340cc69fa4889a61a211cf24c5 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Assets/Resources.meta b/Obfuz/Assets/Resources.meta deleted file mode 100644 index 56aa397..0000000 --- a/Obfuz/Assets/Resources.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 4d42a5aa28dcabc428e7a06b13421410 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Assets/Resources/Obfuz.meta b/Obfuz/Assets/Resources/Obfuz.meta deleted file mode 100644 index 3a82b4c..0000000 --- a/Obfuz/Assets/Resources/Obfuz.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 5be12685e3d38a24ab47ccfde4f424a1 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Assets/Resources/Obfuz/defaultDynamicSecretKey.bytes b/Obfuz/Assets/Resources/Obfuz/defaultDynamicSecretKey.bytes deleted file mode 100644 index 6662034..0000000 Binary files a/Obfuz/Assets/Resources/Obfuz/defaultDynamicSecretKey.bytes and /dev/null differ diff --git a/Obfuz/Assets/Resources/Obfuz/defaultDynamicSecretKey.bytes.meta b/Obfuz/Assets/Resources/Obfuz/defaultDynamicSecretKey.bytes.meta deleted file mode 100644 index cfaf37d..0000000 --- a/Obfuz/Assets/Resources/Obfuz/defaultDynamicSecretKey.bytes.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: c05b06a0efaf2b1449760b6e43a887d3 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Assets/Resources/Obfuz/defaultStaticSecretKey.bytes b/Obfuz/Assets/Resources/Obfuz/defaultStaticSecretKey.bytes deleted file mode 100644 index d91a82d..0000000 Binary files a/Obfuz/Assets/Resources/Obfuz/defaultStaticSecretKey.bytes and /dev/null differ diff --git a/Obfuz/Assets/Resources/Obfuz/defaultStaticSecretKey.bytes.meta b/Obfuz/Assets/Resources/Obfuz/defaultStaticSecretKey.bytes.meta deleted file mode 100644 index 841f2a2..0000000 --- a/Obfuz/Assets/Resources/Obfuz/defaultStaticSecretKey.bytes.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 8d8f2c4f77ee26b44a448add3a0657fe -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Assets/main.unity b/Obfuz/Assets/main.unity deleted file mode 100644 index c92c3ad..0000000 --- a/Obfuz/Assets/main.unity +++ /dev/null @@ -1,362 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!29 &1 -OcclusionCullingSettings: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_OcclusionBakeSettings: - smallestOccluder: 5 - smallestHole: 0.25 - backfaceThreshold: 100 - m_SceneGUID: 00000000000000000000000000000000 - m_OcclusionCullingData: {fileID: 0} ---- !u!104 &2 -RenderSettings: - m_ObjectHideFlags: 0 - serializedVersion: 9 - m_Fog: 0 - m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} - m_FogMode: 3 - m_FogDensity: 0.01 - m_LinearFogStart: 0 - m_LinearFogEnd: 300 - m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} - m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} - m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} - m_AmbientIntensity: 1 - m_AmbientMode: 0 - m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} - m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} - m_HaloStrength: 0.5 - m_FlareStrength: 1 - m_FlareFadeSpeed: 3 - m_HaloTexture: {fileID: 0} - m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} - m_DefaultReflectionMode: 0 - m_DefaultReflectionResolution: 128 - m_ReflectionBounces: 1 - m_ReflectionIntensity: 1 - m_CustomReflection: {fileID: 0} - m_Sun: {fileID: 0} - m_IndirectSpecularColor: {r: 0.18028378, g: 0.22571412, b: 0.30692285, a: 1} - m_UseRadianceAmbientProbe: 0 ---- !u!157 &3 -LightmapSettings: - m_ObjectHideFlags: 0 - serializedVersion: 12 - m_GIWorkflowMode: 1 - m_GISettings: - serializedVersion: 2 - m_BounceScale: 1 - m_IndirectOutputScale: 1 - m_AlbedoBoost: 1 - m_EnvironmentLightingMode: 0 - m_EnableBakedLightmaps: 1 - m_EnableRealtimeLightmaps: 0 - m_LightmapEditorSettings: - serializedVersion: 12 - m_Resolution: 2 - m_BakeResolution: 40 - m_AtlasSize: 1024 - m_AO: 0 - m_AOMaxDistance: 1 - m_CompAOExponent: 1 - m_CompAOExponentDirect: 0 - m_ExtractAmbientOcclusion: 0 - m_Padding: 2 - m_LightmapParameters: {fileID: 0} - m_LightmapsBakeMode: 1 - m_TextureCompression: 1 - m_FinalGather: 0 - m_FinalGatherFiltering: 1 - m_FinalGatherRayCount: 256 - m_ReflectionCompression: 2 - m_MixedBakeMode: 2 - m_BakeBackend: 1 - m_PVRSampling: 1 - m_PVRDirectSampleCount: 32 - m_PVRSampleCount: 512 - m_PVRBounces: 2 - m_PVREnvironmentSampleCount: 256 - m_PVREnvironmentReferencePointCount: 2048 - m_PVRFilteringMode: 1 - m_PVRDenoiserTypeDirect: 1 - m_PVRDenoiserTypeIndirect: 1 - m_PVRDenoiserTypeAO: 1 - m_PVRFilterTypeDirect: 0 - m_PVRFilterTypeIndirect: 0 - m_PVRFilterTypeAO: 0 - m_PVREnvironmentMIS: 1 - m_PVRCulling: 1 - m_PVRFilteringGaussRadiusDirect: 1 - m_PVRFilteringGaussRadiusIndirect: 5 - m_PVRFilteringGaussRadiusAO: 2 - m_PVRFilteringAtrousPositionSigmaDirect: 0.5 - m_PVRFilteringAtrousPositionSigmaIndirect: 2 - m_PVRFilteringAtrousPositionSigmaAO: 1 - m_ExportTrainingData: 0 - m_TrainingDataDestination: TrainingData - m_LightProbeSampleCountMultiplier: 4 - m_LightingDataAsset: {fileID: 0} - m_LightingSettings: {fileID: 0} ---- !u!196 &4 -NavMeshSettings: - serializedVersion: 2 - m_ObjectHideFlags: 0 - m_BuildSettings: - serializedVersion: 3 - agentTypeID: 0 - agentRadius: 0.5 - agentHeight: 2 - agentSlope: 45 - agentClimb: 0.4 - ledgeDropHeight: 0 - maxJumpAcrossDistance: 0 - minRegionArea: 2 - manualCellSize: 0 - cellSize: 0.16666667 - manualTileSize: 0 - tileSize: 256 - buildHeightMesh: 0 - maxJobWorkers: 0 - preserveTilesOutsideBounds: 0 - debug: - m_Flags: 0 - m_NavMeshData: {fileID: 0} ---- !u!1 &1475525420 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1475525423} - - component: {fileID: 1475525422} - - component: {fileID: 1475525421} - m_Layer: 0 - m_Name: Main Camera - m_TagString: MainCamera - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!81 &1475525421 -AudioListener: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1475525420} - m_Enabled: 1 ---- !u!20 &1475525422 -Camera: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1475525420} - m_Enabled: 1 - serializedVersion: 2 - m_ClearFlags: 1 - m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} - m_projectionMatrixMode: 1 - m_GateFitMode: 2 - m_FOVAxisMode: 0 - m_Iso: 200 - m_ShutterSpeed: 0.005 - m_Aperture: 16 - m_FocusDistance: 10 - m_FocalLength: 50 - m_BladeCount: 5 - m_Curvature: {x: 2, y: 11} - m_BarrelClipping: 0.25 - m_Anamorphism: 0 - m_SensorSize: {x: 36, y: 24} - m_LensShift: {x: 0, y: 0} - m_NormalizedViewPortRect: - serializedVersion: 2 - x: 0 - y: 0 - width: 1 - height: 1 - near clip plane: 0.3 - far clip plane: 1000 - field of view: 60 - orthographic: 0 - orthographic size: 5 - m_Depth: -1 - m_CullingMask: - serializedVersion: 2 - m_Bits: 4294967295 - m_RenderingPath: -1 - m_TargetTexture: {fileID: 0} - m_TargetDisplay: 0 - m_TargetEye: 3 - m_HDR: 1 - m_AllowMSAA: 1 - m_AllowDynamicResolution: 0 - m_ForceIntoRT: 0 - m_OcclusionCulling: 1 - m_StereoConvergence: 10 - m_StereoSeparation: 0.022 ---- !u!4 &1475525423 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1475525420} - serializedVersion: 2 - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 1, z: -10} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 0} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &1674109924 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1674109926} - - component: {fileID: 1674109925} - m_Layer: 0 - m_Name: Bootstrap - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!114 &1674109925 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1674109924} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 639006a739675484884778c298eebdc4, type: 3} - m_Name: - m_EditorClassIdentifier: ---- !u!4 &1674109926 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1674109924} - serializedVersion: 2 - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 0} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &2040361796 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 2040361798} - - component: {fileID: 2040361797} - m_Layer: 0 - m_Name: Directional Light - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!108 &2040361797 -Light: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2040361796} - m_Enabled: 1 - serializedVersion: 10 - m_Type: 1 - m_Shape: 0 - m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} - m_Intensity: 1 - m_Range: 10 - m_SpotAngle: 30 - m_InnerSpotAngle: 21.80208 - m_CookieSize: 10 - m_Shadows: - m_Type: 2 - m_Resolution: -1 - m_CustomResolution: -1 - m_Strength: 1 - m_Bias: 0.05 - m_NormalBias: 0.4 - m_NearPlane: 0.2 - m_CullingMatrixOverride: - e00: 1 - e01: 0 - e02: 0 - e03: 0 - e10: 0 - e11: 1 - e12: 0 - e13: 0 - e20: 0 - e21: 0 - e22: 1 - e23: 0 - e30: 0 - e31: 0 - e32: 0 - e33: 1 - m_UseCullingMatrixOverride: 0 - m_Cookie: {fileID: 0} - m_DrawHalo: 0 - m_Flare: {fileID: 0} - m_RenderMode: 0 - m_CullingMask: - serializedVersion: 2 - m_Bits: 4294967295 - m_RenderingLayerMask: 1 - m_Lightmapping: 4 - m_LightShadowCasterMode: 0 - m_AreaSize: {x: 1, y: 1} - m_BounceIntensity: 1 - m_ColorTemperature: 6570 - m_UseColorTemperature: 0 - m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} - m_UseBoundingSphereOverride: 0 - m_UseViewFrustumForShadowCasterCull: 1 - m_ShadowRadius: 0 - m_ShadowAngle: 0 ---- !u!4 &2040361798 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2040361796} - serializedVersion: 2 - m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} - m_LocalPosition: {x: 0, y: 3, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 0} - m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} ---- !u!1660057539 &9223372036854775807 -SceneRoots: - m_ObjectHideFlags: 0 - m_Roots: - - {fileID: 1475525423} - - {fileID: 2040361798} - - {fileID: 1674109926} diff --git a/Obfuz/Assets/main.unity.meta b/Obfuz/Assets/main.unity.meta deleted file mode 100644 index 55aa0b4..0000000 --- a/Obfuz/Assets/main.unity.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 528018d8add4a724bb1e36008449a904 -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor.meta deleted file mode 100644 index e4fe3a4..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 2326b426d539e084dbddf7f7c23ed1bd -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Conf.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Conf.meta deleted file mode 100644 index d42ac4f..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Conf.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 241df8eaf3a34dc47a0873c37ddb2695 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Conf/XmlAssemblyTypeMethodRuleParser.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Conf/XmlAssemblyTypeMethodRuleParser.cs deleted file mode 100644 index aac0a66..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Conf/XmlAssemblyTypeMethodRuleParser.cs +++ /dev/null @@ -1,267 +0,0 @@ -using dnlib.DotNet; -using Obfuz.Utils; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Xml; -using UnityEditor.VersionControl; -using UnityEngine; - -namespace Obfuz.Conf -{ - public interface IRule - { - void InheritParent(T parentRule); - } - - - public interface IMethodRule where R: IRule - { - string Name { get; set; } - NameMatcher NameMatcher { get; set; } - - R Rule { get; set; } - } - - public abstract class MethodRuleBase : IMethodRule where R : IRule - { - public string Name { get; set; } - public NameMatcher NameMatcher { get; set; } - - public R Rule { get; set; } - } - - public interface ITypeRule where T: IMethodRule where R : IRule - { - string Name { get; set; } - - NameMatcher NameMatcher { get; set; } - - R Rule { get; set; } - - List Methods { get; set; } - } - - public abstract class TypeRuleBase : ITypeRule where T : IMethodRule where R : IRule - { - public string Name { get; set; } - - public NameMatcher NameMatcher { get; set; } - - public R Rule { get; set; } - - public List Methods { get; set; } - } - - public interface IAssemblyRule where TType : ITypeRule where TMethod : IMethodRule where TRule : IRule - { - string Name { get; set; } - - TRule Rule { get; set; } - - List Types { get; set; } - } - public abstract class AssemblyRuleBase : IAssemblyRule where TType : ITypeRule where TMethod : IMethodRule where TRule : IRule - { - public string Name { get; set; } - - public TRule Rule { get; set; } - - public List Types { get; set; } - } - - public class XmlAssemblyTypeMethodRuleParser - where TMethod : IMethodRule, new() - where TType : ITypeRule, new() - where TAssembly : IAssemblyRule, new() - where TRule : IRule, new() - { - private readonly HashSet _toObfuscatedAssemblyNames; - private readonly Func _ruleParser; - private readonly Action _unknownNodeTypeHandler; - private readonly Dictionary _assemblySpecs = new Dictionary(); - - public XmlAssemblyTypeMethodRuleParser(IEnumerable toObfuscatedAssemblyNames, Func ruleParser, Action unknownNodeTypeHandler) - { - _toObfuscatedAssemblyNames = new HashSet(toObfuscatedAssemblyNames); - _ruleParser = ruleParser; - _unknownNodeTypeHandler = unknownNodeTypeHandler; - } - - public Dictionary AssemblySpecs => _assemblySpecs; - - public void LoadConfigs(IEnumerable configFiles) - { - foreach (var configFile in configFiles) - { - LoadConfig(configFile); - } - } - - public void LoadConfig(string configFile) - { - if (string.IsNullOrEmpty(configFile)) - { - throw new Exception($"Invalid xml file {configFile}, file name is empty"); - } - Debug.Log($"ConfigurableObfuscationPolicy::LoadConfig {configFile}"); - var doc = new XmlDocument(); - doc.Load(configFile); - var root = doc.DocumentElement; - if (root.Name != "obfuz") - { - throw new Exception($"Invalid xml file {configFile}, root name should be 'obfuz'"); - } - foreach (XmlNode node in root.ChildNodes) - { - if (!(node is XmlElement ele)) - { - continue; - } - switch (ele.Name) - { - case "assembly": - { - TAssembly assSpec = ParseAssembly(configFile, ele); - _assemblySpecs.Add(assSpec.Name, assSpec); - break; - } - default: - { - if (_unknownNodeTypeHandler == null) - { - throw new Exception($"Invalid xml file {configFile}, unknown node {ele.Name}"); - } - _unknownNodeTypeHandler(configFile, ele); - break; - } - } - } - } - - private TAssembly ParseAssembly(string configFile, XmlElement ele) - { - var assemblySpec = new TAssembly(); - string name = ele.GetAttribute("name"); - if (!_toObfuscatedAssemblyNames.Contains(name)) - { - throw new Exception($"Invalid xml file {configFile}, assembly name {name} isn't in toObfuscatedAssemblyNames"); - } - if (_assemblySpecs.ContainsKey(name)) - { - throw new Exception($"Invalid xml file {configFile}, assembly name {name} is duplicated"); - } - assemblySpec.Name = name; - assemblySpec.Rule = _ruleParser(configFile, ele); - - var types = new List(); - assemblySpec.Types = types; - foreach (XmlNode node in ele.ChildNodes) - { - if (!(node is XmlElement childEle)) - { - continue; - } - switch (childEle.Name) - { - case "type": - { - types.Add(ParseType(configFile, childEle)); - break; - } - default: - { - throw new Exception($"Invalid xml file, unknown node {childEle.Name}"); - } - } - } - return assemblySpec; - } - - private TType ParseType(string configFile, XmlElement element) - { - var typeSpec = new TType(); - - string name = element.GetAttribute("name"); - typeSpec.Name = name; - typeSpec.NameMatcher = new NameMatcher(name); - typeSpec.Rule = _ruleParser(configFile, element); - - var methods = new List(); - typeSpec.Methods = methods; - foreach (XmlNode node in element.ChildNodes) - { - if (!(node is XmlElement ele)) - { - continue; - } - switch (ele.Name) - { - case "method": - { - methods.Add(ParseMethod(configFile, ele)); - break; - } - default: - { - throw new Exception($"Invalid xml file, unknown node {ele.Name}"); - } - } - } - return typeSpec; - } - - private TMethod ParseMethod(string configFile, XmlElement element) - { - var methodSpec = new TMethod(); - string name = element.GetAttribute("name"); - methodSpec.Name = name; - methodSpec.NameMatcher = new NameMatcher(name); - methodSpec.Rule = _ruleParser(configFile, element); - return methodSpec; - } - - public TRule GetMethodRule(MethodDef method, TRule defaultRule) - { - var assemblyName = method.DeclaringType.Module.Assembly.Name; - if (!_assemblySpecs.TryGetValue(assemblyName, out var assSpec)) - { - return defaultRule; - } - string declaringTypeName = method.DeclaringType.FullName; - foreach (var typeSpec in assSpec.Types) - { - if (typeSpec.NameMatcher.IsMatch(declaringTypeName)) - { - foreach (var methodSpec in typeSpec.Methods) - { - if (methodSpec.NameMatcher.IsMatch(method.Name)) - { - return methodSpec.Rule; - } - } - return typeSpec.Rule; - } - } - return assSpec.Rule; - } - - public void InheritParentRules(TRule defaultRule) - { - foreach (TAssembly assSpec in _assemblySpecs.Values) - { - assSpec.Rule.InheritParent(defaultRule); - foreach (TType typeSpec in assSpec.Types) - { - typeSpec.Rule.InheritParent(assSpec.Rule); - foreach (TMethod methodSpec in typeSpec.Methods) - { - methodSpec.Rule.InheritParent(typeSpec.Rule); - } - } - } - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Conf/XmlAssemblyTypeMethodRuleParser.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Conf/XmlAssemblyTypeMethodRuleParser.cs.meta deleted file mode 100644 index 84f5aa9..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Conf/XmlAssemblyTypeMethodRuleParser.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 36a3e142db81f6d4bb54938525e31973 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Conf/XmlFieldRuleParser.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Conf/XmlFieldRuleParser.cs deleted file mode 100644 index 591271e..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Conf/XmlFieldRuleParser.cs +++ /dev/null @@ -1,208 +0,0 @@ -using dnlib.DotNet; -using Obfuz.Utils; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Xml; -using UnityEditor.VersionControl; -using UnityEngine; - -namespace Obfuz.Conf -{ - - - - public class XmlFieldRuleParser where R : class, new() - { - private readonly HashSet _toObfuscatedAssemblyNames; - private readonly Func _ruleParser; - private readonly Action _unknownNodeTypeHandler; - private readonly Dictionary _assemblySpecs = new Dictionary(); - - - private class FieldSpec - { - public string Name { get; set; } - public NameMatcher NameMatcher { get; set; } - - public R Rule { get; set; } - } - - private class TypeSpec - { - public string Name { get; set; } - - public NameMatcher NameMatcher { get; set; } - - public List Fields { get; set; } - } - - private class AssemblySpec - { - public string Name { get; set; } - - public List Types { get; set; } - } - - public XmlFieldRuleParser(IEnumerable toObfuscatedAssemblyNames, Func ruleParser, Action unknownNodeTypeHandler) - { - _toObfuscatedAssemblyNames = new HashSet(toObfuscatedAssemblyNames); - _ruleParser = ruleParser; - _unknownNodeTypeHandler = unknownNodeTypeHandler; - } - - public void LoadConfigs(IEnumerable configFiles) - { - foreach (var configFile in configFiles) - { - LoadConfig(configFile); - } - } - - public void LoadConfig(string configFile) - { - if (string.IsNullOrEmpty(configFile)) - { - throw new Exception($"Invalid xml file {configFile}, file name is empty"); - } - var doc = new XmlDocument(); - doc.Load(configFile); - var root = doc.DocumentElement; - if (root.Name != "obfuz") - { - throw new Exception($"Invalid xml file {configFile}, root name should be 'obfuz'"); - } - foreach (XmlNode node in root.ChildNodes) - { - if (!(node is XmlElement ele)) - { - continue; - } - switch (ele.Name) - { - case "assembly": - { - AssemblySpec assSpec = ParseAssembly(configFile, ele); - _assemblySpecs.Add(assSpec.Name, assSpec); - break; - } - default: - { - if (_unknownNodeTypeHandler == null) - { - throw new Exception($"Invalid xml file {configFile}, unknown node {ele.Name}"); - } - _unknownNodeTypeHandler(configFile, ele); - break; - } - } - } - } - - private AssemblySpec ParseAssembly(string configFile, XmlElement ele) - { - var assemblySpec = new AssemblySpec(); - string name = ele.GetAttribute("name"); - if (!_toObfuscatedAssemblyNames.Contains(name)) - { - throw new Exception($"Invalid xml file {configFile}, assembly name {name} isn't in toObfuscatedAssemblyNames"); - } - if (_assemblySpecs.ContainsKey(name)) - { - throw new Exception($"Invalid xml file {configFile}, assembly name {name} is duplicated"); - } - assemblySpec.Name = name; - - var types = new List(); - assemblySpec.Types = types; - foreach (XmlNode node in ele.ChildNodes) - { - if (!(node is XmlElement childEle)) - { - continue; - } - switch (childEle.Name) - { - case "type": - { - types.Add(ParseType(configFile, childEle)); - break; - } - default: - { - throw new Exception($"Invalid xml file, unknown node {childEle.Name}"); - } - } - } - return assemblySpec; - } - - private TypeSpec ParseType(string configFile, XmlElement element) - { - var typeSpec = new TypeSpec(); - - string name = element.GetAttribute("name"); - typeSpec.Name = name; - typeSpec.NameMatcher = new NameMatcher(name); - - var fields = new List(); - typeSpec.Fields = fields; - foreach (XmlNode node in element.ChildNodes) - { - if (!(node is XmlElement ele)) - { - continue; - } - switch (ele.Name) - { - case "field": - { - fields.Add(ParseField(configFile, ele)); - break; - } - default: - { - throw new Exception($"Invalid xml file, unknown node {ele.Name}"); - } - } - } - return typeSpec; - } - - private FieldSpec ParseField(string configFile, XmlElement element) - { - var fieldSpec = new FieldSpec(); - string name = element.GetAttribute("name"); - fieldSpec.Name = name; - fieldSpec.NameMatcher = new NameMatcher(name); - fieldSpec.Rule = _ruleParser(configFile, element); - return fieldSpec; - } - - public R GetFieldRule(FieldDef field) - { - var assemblyName = field.DeclaringType.Module.Assembly.Name; - if (!_assemblySpecs.TryGetValue(assemblyName, out var assSpec)) - { - return null; - } - string declaringTypeName = field.DeclaringType.FullName; - foreach (var typeSpec in assSpec.Types) - { - if (typeSpec.NameMatcher.IsMatch(declaringTypeName)) - { - foreach (var fieldSpec in typeSpec.Fields) - { - if (fieldSpec.NameMatcher.IsMatch(field.Name)) - { - return fieldSpec.Rule; - } - } - } - } - return null; - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Conf/XmlFieldRuleParser.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Conf/XmlFieldRuleParser.cs.meta deleted file mode 100644 index d8995b9..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Conf/XmlFieldRuleParser.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 1578270b9b81e1e4dba84d562c91090f -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ConfigurablePassPolicy.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ConfigurablePassPolicy.cs deleted file mode 100644 index 6d0fc7e..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ConfigurablePassPolicy.cs +++ /dev/null @@ -1,547 +0,0 @@ -using dnlib.DotNet; -using Obfuz.ObfusPasses; -using Obfuz.Utils; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Xml; -using UnityEngine; - -namespace Obfuz -{ - public class ConfigurablePassPolicy - { - class PassRule - { - public ObfuscationPassType? enablePasses; - public ObfuscationPassType? disablePasses; - public ObfuscationPassType? addPasses; - public ObfuscationPassType? removePasses; - public ObfuscationPassType finalPasses; - - public void InheritParent(PassRule parentRule, ObfuscationPassType globalEnabledPasses) - { - finalPasses = parentRule.finalPasses; - if (enablePasses != null) - { - finalPasses = enablePasses.Value; - } - if (disablePasses != null) - { - finalPasses = ~disablePasses.Value; - } - if (addPasses != null) - { - finalPasses |= addPasses.Value; - } - if (removePasses != null) - { - finalPasses &= ~removePasses.Value; - } - finalPasses &= globalEnabledPasses; - } - } - - class SpecBase - { - public string name; - public NameMatcher nameMatcher; - public PassRule rule; - } - - class MethodSpec : SpecBase - { - } - - class FieldSpec : SpecBase - { - } - - class PropertySpec : SpecBase - { - } - - class EventSpec : SpecBase - { - } - - class TypeSpec : SpecBase - { - public List fields = new List(); - public List methods = new List(); - public List properties = new List(); - public List events = new List(); - } - - class AssemblySpec - { - public string name; - public NameMatcher nameMatcher; - public PassRule rule; - public List types = new List(); - } - - private readonly ObfuscationPassType _enabledPasses; - private readonly HashSet _toObfuscatedAssemblyNames; - private readonly List _assemblySpecs = new List(); - private readonly PassRule _defaultPassRule; - - private string _curLoadingConfig; - - public ConfigurablePassPolicy(IEnumerable toObfuscatedAssemblyNames, ObfuscationPassType enabledPasses, List configFiles) - { - _toObfuscatedAssemblyNames = new HashSet(toObfuscatedAssemblyNames); - _enabledPasses = enabledPasses; - _defaultPassRule = new PassRule { finalPasses = enabledPasses }; - LoadConfigs(configFiles); - InheritParentRules(enabledPasses); - } - - private void LoadConfigs(IEnumerable configFiles) - { - foreach (var configFile in configFiles) - { - LoadConfig(configFile); - } - } - - private void InheritParentRules(ObfuscationPassType enablePasses) - { - var defaultRule = new PassRule - { - enablePasses = enablePasses, - finalPasses = enablePasses, - }; - foreach (AssemblySpec assSpec in _assemblySpecs) - { - assSpec.rule.InheritParent(defaultRule, enablePasses); - foreach (TypeSpec typeSpec in assSpec.types) - { - typeSpec.rule.InheritParent(assSpec.rule, enablePasses); - foreach (FieldSpec fieldSpec in typeSpec.fields) - { - fieldSpec.rule.InheritParent(typeSpec.rule, enablePasses); - } - foreach (MethodSpec methodSpec in typeSpec.methods) - { - methodSpec.rule.InheritParent(typeSpec.rule, enablePasses); - } - foreach (PropertySpec propertySpec in typeSpec.properties) - { - propertySpec.rule.InheritParent(typeSpec.rule, enablePasses); - } - foreach (EventSpec eventSpec in typeSpec.events) - { - eventSpec.rule.InheritParent(typeSpec.rule, enablePasses); - } - } - } - } - - public void LoadConfig(string configFile) - { - if (string.IsNullOrEmpty(configFile)) - { - throw new Exception($"Invalid xml file {configFile}, file name is empty"); - } - _curLoadingConfig = configFile; - - Debug.Log($"ConfigurablePassPolicy::LoadConfig {configFile}"); - var doc = new XmlDocument(); - doc.Load(configFile); - var root = doc.DocumentElement; - if (root.Name != "obfuz") - { - throw new Exception($"Invalid xml file {configFile}, root name should be 'obfuz'"); - } - foreach (XmlNode node in root.ChildNodes) - { - if (!(node is XmlElement ele)) - { - continue; - } - switch (ele.Name) - { - case "assembly": - { - AssemblySpec assSpec = ParseAssembly(ele); - _assemblySpecs.Add(assSpec); - break; - } - default: - { - throw new Exception($"Invalid xml file {configFile}, unknown node {ele.Name}"); - } - } - } - } - - (bool, ObfuscationPassType) ParseObfuscationType(string obfuscationPassTypesStr) - { - bool delta = false; - if (obfuscationPassTypesStr[0] == '+' || obfuscationPassTypesStr[0] == '-') - { - delta = true; - obfuscationPassTypesStr = obfuscationPassTypesStr.Substring(1); - } - ObfuscationPassType passType = ObfuscationPassType.None; - foreach (var passName in obfuscationPassTypesStr.Split('|')) - { - if (Enum.TryParse< ObfuscationPassType>(passName, out var pass)) - { - passType |= pass; - } - else - { - throw new Exception($"Invalid xml file {_curLoadingConfig}, unknown pass type {passName}"); - } - } - return (delta, passType); - } - - private PassRule ParseRule(XmlElement ele) - { - var r = new PassRule(); - if (ele.HasAttribute("enable")) - { - string enablePassStr = ele.GetAttribute("enable"); - if (string.IsNullOrEmpty(enablePassStr)) - { - throw new Exception($"Invalid xml file {_curLoadingConfig}, enable attribute is empty"); - } - var (delta, passType) = ParseObfuscationType(enablePassStr); - if (delta) - { - r.addPasses = passType; - } - else - { - r.enablePasses = passType; - } - } - if (ele.HasAttribute("disable")) - { - string disablePassStr = ele.GetAttribute("disable"); - if (string.IsNullOrEmpty(disablePassStr)) - { - throw new Exception($"Invalid xml file {_curLoadingConfig}, disable attribute is empty"); - } - var (delta, passType) = ParseObfuscationType(disablePassStr); - if (delta) - { - r.removePasses = passType; - } - else - { - r.disablePasses = passType; - } - } - if (r.enablePasses != null && (r.disablePasses != null || r.addPasses != null || r.removePasses != null)) - { - throw new Exception($"Invalid xml file {_curLoadingConfig}, enable and disable can't be used together"); - } - if (r.disablePasses != null && (r.enablePasses != null || r.addPasses != null || r.removePasses != null)) - { - throw new Exception($"Invalid xml file {_curLoadingConfig}, disable and enable can't be used together"); - } - return r; - } - - private AssemblySpec ParseAssembly(XmlElement ele) - { - var assemblySpec = new AssemblySpec(); - string name = ele.GetAttribute("name"); - if (!_toObfuscatedAssemblyNames.Contains(name)) - { - throw new Exception($"Invalid xml file {_curLoadingConfig}, assembly name {name} isn't in toObfuscatedAssemblyNames"); - } - assemblySpec.name = name; - assemblySpec.nameMatcher = new NameMatcher(name); - assemblySpec.rule = ParseRule(ele); - - - var types = assemblySpec.types; - foreach (XmlNode node in ele.ChildNodes) - { - if (!(node is XmlElement childEle)) - { - continue; - } - switch (childEle.Name) - { - case "type": - { - types.Add(ParseType(childEle)); - break; - } - default: - { - throw new Exception($"Invalid xml file, unknown node {childEle.Name}"); - } - } - } - return assemblySpec; - } - - private TypeSpec ParseType(XmlElement element) - { - var typeSpec = new TypeSpec(); - - string name = element.GetAttribute("name"); - typeSpec.name = name; - typeSpec.nameMatcher = new NameMatcher(name); - typeSpec.rule = ParseRule(element); - - List fields = typeSpec.fields; - List methods = typeSpec.methods; - List properties = typeSpec.properties; - List events = typeSpec.events; - foreach (XmlNode node in element.ChildNodes) - { - if (!(node is XmlElement ele)) - { - continue; - } - switch (ele.Name) - { - case "field": - { - fields.Add(ParseField(ele)); - break; - } - case "method": - { - methods.Add(ParseMethod(ele)); - break; - } - case "property": - { - properties.Add(ParseProperty(ele)); - break; - } - case "event": - { - events.Add(ParseEvent(ele)); - break; - } - default: - { - throw new Exception($"Invalid xml file, unknown node {ele.Name}"); - } - } - } - return typeSpec; - } - - private void ParseSpecObject(XmlElement element, SpecBase obj) - { - string name = element.GetAttribute("name"); - obj.name = name; - obj.nameMatcher = new NameMatcher(name); - obj.rule = ParseRule(element); - } - - private FieldSpec ParseField(XmlElement element) - { - var fieldSpec = new FieldSpec(); - ParseSpecObject(element, fieldSpec); - return fieldSpec; - } - - private MethodSpec ParseMethod(XmlElement element) - { - var methodSpec = new MethodSpec(); - ParseSpecObject(element, methodSpec); - return methodSpec; - } - - private PropertySpec ParseProperty(XmlElement element) - { - var propertySpec = new PropertySpec(); - ParseSpecObject(element, propertySpec); - return propertySpec; - } - - private EventSpec ParseEvent(XmlElement element) - { - var eventSpec = new EventSpec(); - ParseSpecObject(element, eventSpec); - return eventSpec; - } - - private readonly Dictionary _modulePassRuleCaches = new Dictionary(); - private readonly Dictionary _typePassRuleCaches = new Dictionary(); - private readonly Dictionary _methodPassRuleCaches = new Dictionary(); - private readonly Dictionary _fieldPassRuleCaches = new Dictionary(); - private readonly Dictionary _propertyPassRuleCaches = new Dictionary(); - private readonly Dictionary _eventPassRuleCaches = new Dictionary(); - - - private (AssemblySpec, PassRule) GetAssemblySpec(ModuleDef module) - { - if (!_modulePassRuleCaches.TryGetValue(module, out var result)) - { - result = (null, _defaultPassRule); - string assName = module.Assembly.Name; - foreach (var ass in _assemblySpecs) - { - if (ass.nameMatcher.IsMatch(assName)) - { - result = (ass, _defaultPassRule); - break; - } - } - _modulePassRuleCaches.Add(module, result); - } - return result; - } - - private (TypeSpec, PassRule) GetTypeSpec(TypeDef type) - { - if (!_typePassRuleCaches.TryGetValue(type, out var result)) - { - var assResult = GetAssemblySpec(type.Module); - result = (null, assResult.Item2); - if (assResult.Item1 != null) - { - string typeName = type.FullName; - foreach (var typeSpec in assResult.Item1.types) - { - if (typeSpec.nameMatcher.IsMatch(typeName)) - { - result = (typeSpec, typeSpec.rule); - break; - } - } - } - _typePassRuleCaches.Add(type, result); - } - return result; - } - - private (MethodSpec, PassRule) GetMethodSpec(MethodDef method) - { - if (!_methodPassRuleCaches.TryGetValue(method, out var result)) - { - var typeResult = GetTypeSpec(method.DeclaringType); - result = (null, typeResult.Item2); - if (typeResult.Item1 != null) - { - string methodName = method.Name; - foreach (var methodSpec in typeResult.Item1.methods) - { - if (methodSpec.nameMatcher.IsMatch(methodName)) - { - result = (methodSpec, methodSpec.rule); - break; - } - } - } - _methodPassRuleCaches.Add(method, result); - } - return result; - } - - private (FieldSpec, PassRule) GetFieldSpec(FieldDef field) - { - if (!_fieldPassRuleCaches.TryGetValue(field, out var result)) - { - var typeResult = GetTypeSpec(field.DeclaringType); - result = (null, typeResult.Item2); - if (typeResult.Item1 != null) - { - string fieldName = field.Name; - foreach (var fieldSpec in typeResult.Item1.fields) - { - if (fieldSpec.nameMatcher.IsMatch(fieldName)) - { - result = (fieldSpec, fieldSpec.rule); - break; - } - } - } - _fieldPassRuleCaches.Add(field, result); - } - return result; - } - - private (PropertySpec, PassRule) GetPropertySpec(PropertyDef property) - { - if (!_propertyPassRuleCaches.TryGetValue(property, out var result)) - { - var typeResult = GetTypeSpec(property.DeclaringType); - result = (null, typeResult.Item2); - if (typeResult.Item1 != null) - { - string propertyName = property.Name; - foreach (var propertySpec in typeResult.Item1.properties) - { - if (propertySpec.nameMatcher.IsMatch(propertyName)) - { - result = (propertySpec, propertySpec.rule); - break; - } - } - } - _propertyPassRuleCaches.Add(property, result); - } - return result; - } - - private (EventSpec, PassRule) GetEventSpec(EventDef eventDef) - { - if (!_eventPassRuleCaches.TryGetValue(eventDef, out var result)) - { - var typeResult = GetTypeSpec(eventDef.DeclaringType); - result = (null, typeResult.Item2); - if (typeResult.Item1 != null) - { - string eventName = eventDef.Name; - foreach (var eventSpec in typeResult.Item1.events) - { - if (eventSpec.nameMatcher.IsMatch(eventName)) - { - result = (eventSpec, eventSpec.rule); - break; - } - } - } - _eventPassRuleCaches.Add(eventDef, result); - } - return result; - } - - - public ObfuscationPassType GetAssemblyObfuscationPasses(ModuleDef module) - { - return GetAssemblySpec(module).Item2.finalPasses; - } - - public ObfuscationPassType GetTypeObfuscationPasses(TypeDef type) - { - return GetTypeSpec(type).Item2.finalPasses; - } - - public ObfuscationPassType GetMethodObfuscationPasses(MethodDef method) - { - return GetMethodSpec(method).Item2.finalPasses; - } - - public ObfuscationPassType GetFieldObfuscationPasses(FieldDef field) - { - return GetFieldSpec(field).Item2.finalPasses; - } - - public ObfuscationPassType GetPropertyObfuscationPasses(PropertyDef property) - { - return GetPropertySpec(property).Item2.finalPasses; - } - - public ObfuscationPassType GetEventObfuscationPasses(EventDef eventDef) - { - return GetEventSpec(eventDef).Item2.finalPasses; - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ConfigurablePassPolicy.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ConfigurablePassPolicy.cs.meta deleted file mode 100644 index 9b85183..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ConfigurablePassPolicy.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 41044699810a34f4780e14de084bf7d7 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ConstValues.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ConstValues.cs deleted file mode 100644 index 2792a00..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ConstValues.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Obfuz.Editor -{ - public static class ConstValues - { - public const string ObfuzInternalSymbolNamePrefix = "$Obfuz$"; - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ConstValues.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ConstValues.cs.meta deleted file mode 100644 index 33f4160..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ConstValues.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: aee7817ed523a5e4ea42104013e8a775 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Data.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Data.meta deleted file mode 100644 index d162ae8..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Data.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 3319ebe75a42f3d4d996846ca09ed099 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Data/ConstFieldAllocator.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Data/ConstFieldAllocator.cs deleted file mode 100644 index caf1725..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Data/ConstFieldAllocator.cs +++ /dev/null @@ -1,344 +0,0 @@ -using dnlib.DotNet; -using dnlib.DotNet.Emit; -using Obfuz.Editor; -using Obfuz.Emit; -using Obfuz.Utils; -using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using System.Net.NetworkInformation; -using System.Text; -using System.Threading.Tasks; -using UnityEngine; -using UnityEngine.Assertions; - -namespace Obfuz.Data -{ - public class ModuleConstFieldAllocator : IGroupByModuleEntity - { - private ModuleDef _module; - private readonly EncryptionScopeProvider _encryptionScopeProvider; - private readonly RvaDataAllocator _rvaDataAllocator; - private readonly GroupByModuleEntityManager _moduleEntityManager; - private EncryptionScopeInfo _encryptionScope; - private RandomCreator _randomCreator; - private IEncryptor _encryptor; - - private TypeDef _holderTypeDef; - - class ConstFieldInfo - { - public FieldDef field; - public object value; - } - - class AnyComparer : IEqualityComparer - { - public new bool Equals(object x, object y) - { - if (x is byte[] xBytes && y is byte[] yBytes) - { - return StructuralComparisons.StructuralEqualityComparer.Equals(xBytes, yBytes); - } - return x.Equals(y); - } - - public static int ComputeHashCode(object obj) - { - return HashUtil.ComputePrimitiveOrStringOrBytesHashCode(obj); - } - - public int GetHashCode(object obj) - { - return ComputeHashCode(obj); - } - } - - private readonly Dictionary _allocatedFields = new Dictionary(new AnyComparer()); - private readonly Dictionary _field2Fields = new Dictionary(); - - private readonly List _holderTypeDefs = new List(); - private bool _done; - - - public ModuleConstFieldAllocator(EncryptionScopeProvider encryptionScopeProvider, RvaDataAllocator rvaDataAllocator, GroupByModuleEntityManager moduleEntityManager) - { - _encryptionScopeProvider = encryptionScopeProvider; - _rvaDataAllocator = rvaDataAllocator; - _moduleEntityManager = moduleEntityManager; - } - - public void Init(ModuleDef mod) - { - _module = mod; - _encryptionScope = _encryptionScopeProvider.GetScope(mod); - _randomCreator = _encryptionScope.localRandomCreator; - _encryptor = _encryptionScope.encryptor; - } - - const int maxFieldCount = 1000; - - - private TypeSig GetTypeSigOfValue(object value) - { - if (value is int) - return _module.CorLibTypes.Int32; - if (value is long) - return _module.CorLibTypes.Int64; - if (value is float) - return _module.CorLibTypes.Single; - if (value is double) - return _module.CorLibTypes.Double; - if (value is string) - return _module.CorLibTypes.String; - if (value is byte[]) - return new SZArraySig(_module.CorLibTypes.Byte); - throw new NotSupportedException($"Unsupported type: {value.GetType()}"); - } - - private ConstFieldInfo CreateConstFieldInfo(object value) - { - if (_holderTypeDef == null || _holderTypeDef.Fields.Count >= maxFieldCount) - { - _module.EnableTypeDefFindCache = false; - ITypeDefOrRef objectTypeRef = _module.Import(typeof(object)); - _holderTypeDef = new TypeDefUser($"{ConstValues.ObfuzInternalSymbolNamePrefix}ConstFieldHolder${_holderTypeDefs.Count}", objectTypeRef); - _module.Types.Add(_holderTypeDef); - _holderTypeDefs.Add(_holderTypeDef); - _module.EnableTypeDefFindCache = true; - } - - var field = new FieldDefUser($"{ConstValues.ObfuzInternalSymbolNamePrefix}RVA_Value{_holderTypeDef.Fields.Count}", new FieldSig(GetTypeSigOfValue(value)), FieldAttributes.Static | FieldAttributes.Public | FieldAttributes.InitOnly); - field.DeclaringType = _holderTypeDef; - return new ConstFieldInfo - { - field = field, - value = value, - }; - } - - private FieldDef AllocateAny(object value) - { - if (_done) - { - throw new Exception("can't Allocate after done"); - } - if (!_allocatedFields.TryGetValue(value, out var field)) - { - field = CreateConstFieldInfo(value); - _allocatedFields.Add(value, field); - _field2Fields.Add(field.field, field); - } - return field.field; - } - - public FieldDef Allocate(int value) - { - return AllocateAny(value); - } - - public FieldDef Allocate(long value) - { - return AllocateAny(value); - } - - public FieldDef Allocate(float value) - { - return AllocateAny(value); - } - - public FieldDef Allocate(double value) - { - return AllocateAny(value); - } - - public FieldDef Allocate(string value) - { - return AllocateAny(value); - } - - public FieldDef Allocate(byte[] value) - { - return AllocateAny(value); - } - - private DefaultMetadataImporter GetModuleMetadataImporter() - { - return _moduleEntityManager.GetDefaultModuleMetadataImporter(_module, _encryptionScopeProvider); - } - - private void CreateCCtorOfRvaTypeDef(TypeDef type) - { - var cctor = new MethodDefUser(".cctor", - MethodSig.CreateStatic(_module.CorLibTypes.Void), - MethodImplAttributes.IL | MethodImplAttributes.Managed, - MethodAttributes.Static | MethodAttributes.HideBySig | MethodAttributes.SpecialName | MethodAttributes.RTSpecialName | MethodAttributes.Private); - cctor.DeclaringType = type; - //_rvaTypeDef.Methods.Add(cctor); - var body = new CilBody(); - cctor.Body = body; - var ins = body.Instructions; - - //IMethod method = _module.Import(typeof(System.Runtime.CompilerServices.RuntimeHelpers).GetMethod("InitializeArray", new[] { typeof(Array), typeof(RuntimeFieldHandle) })); - //Assert.IsNotNull(method); - - - DefaultMetadataImporter importer = GetModuleMetadataImporter(); - // TODO. obfuscate init codes - foreach (var field in type.Fields) - { - ConstFieldInfo constInfo = _field2Fields[field]; - IRandom localRandom = _randomCreator(HashUtil.ComputePrimitiveOrStringOrBytesHashCode(constInfo.value)); - int ops = EncryptionUtil.GenerateEncryptionOpCodes(localRandom, _encryptor, 4); - int salt = localRandom.NextInt(); - switch (constInfo.value) - { - case int i: - { - int encryptedValue = _encryptor.Encrypt(i, ops, salt); - RvaData rvaData = _rvaDataAllocator.Allocate(_module, encryptedValue); - ins.Add(Instruction.Create(OpCodes.Ldsfld, rvaData.field)); - ins.Add(Instruction.CreateLdcI4(rvaData.offset)); - ins.Add(Instruction.CreateLdcI4(ops)); - ins.Add(Instruction.CreateLdcI4(salt)); - ins.Add(Instruction.Create(OpCodes.Call, importer.DecryptFromRvaInt)); - break; - } - case long l: - { - long encryptedValue = _encryptor.Encrypt(l, ops, salt); - RvaData rvaData = _rvaDataAllocator.Allocate(_module, encryptedValue); - ins.Add(Instruction.Create(OpCodes.Ldsfld, rvaData.field)); - ins.Add(Instruction.CreateLdcI4(rvaData.offset)); - ins.Add(Instruction.CreateLdcI4(ops)); - ins.Add(Instruction.CreateLdcI4(salt)); - ins.Add(Instruction.Create(OpCodes.Call, importer.DecryptFromRvaLong)); - break; - } - case float f: - { - float encryptedValue = _encryptor.Encrypt(f, ops, salt); - RvaData rvaData = _rvaDataAllocator.Allocate(_module, encryptedValue); - ins.Add(Instruction.Create(OpCodes.Ldsfld, rvaData.field)); - ins.Add(Instruction.CreateLdcI4(rvaData.offset)); - ins.Add(Instruction.CreateLdcI4(ops)); - ins.Add(Instruction.CreateLdcI4(salt)); - ins.Add(Instruction.Create(OpCodes.Call, importer.DecryptFromRvaFloat)); - break; - } - case double d: - { - double encryptedValue = _encryptor.Encrypt(d, ops, salt); - RvaData rvaData = _rvaDataAllocator.Allocate(_module, encryptedValue); - ins.Add(Instruction.Create(OpCodes.Ldsfld, rvaData.field)); - ins.Add(Instruction.CreateLdcI4(rvaData.offset)); - ins.Add(Instruction.CreateLdcI4(ops)); - ins.Add(Instruction.CreateLdcI4(salt)); - ins.Add(Instruction.Create(OpCodes.Call, importer.DecryptFromRvaDouble)); - break; - } - case string s: - { - byte[] encryptedValue = _encryptor.Encrypt(s, ops, salt); - RvaData rvaData = _rvaDataAllocator.Allocate(_module, encryptedValue); - ins.Add(Instruction.Create(OpCodes.Ldsfld, rvaData.field)); - ins.Add(Instruction.CreateLdcI4(rvaData.offset)); - Assert.AreEqual(encryptedValue.Length, rvaData.size); - ins.Add(Instruction.CreateLdcI4(encryptedValue.Length)); - ins.Add(Instruction.CreateLdcI4(ops)); - ins.Add(Instruction.CreateLdcI4(salt)); - ins.Add(Instruction.Create(OpCodes.Call, importer.DecryptFromRvaString)); - break; - } - case byte[] bs: - { - byte[] encryptedValue = _encryptor.Encrypt(bs, 0, bs.Length, ops, salt); - Assert.AreEqual(encryptedValue.Length, bs.Length); - RvaData rvaData = _rvaDataAllocator.Allocate(_module, encryptedValue); - ins.Add(Instruction.Create(OpCodes.Ldsfld, rvaData.field)); - ins.Add(Instruction.CreateLdcI4(rvaData.offset)); - ins.Add(Instruction.CreateLdcI4(bs.Length)); - ins.Add(Instruction.CreateLdcI4(ops)); - ins.Add(Instruction.CreateLdcI4(salt)); - ins.Add(Instruction.Create(OpCodes.Call, importer.DecryptFromRvaBytes)); - break; - } - default: throw new NotSupportedException($"Unsupported type: {constInfo.value.GetType()}"); - } - ins.Add(Instruction.Create(OpCodes.Stsfld, field)); - } - ins.Add(Instruction.Create(OpCodes.Ret)); - } - - public void Done() - { - if (_done) - { - throw new Exception("Already done"); - } - _done = true; - foreach (var typeDef in _holderTypeDefs) - { - CreateCCtorOfRvaTypeDef(typeDef); - } - } - } - - public class ConstFieldAllocator - { - private readonly EncryptionScopeProvider _encryptionScopeProvider; - private readonly RvaDataAllocator _rvaDataAllocator; - private readonly GroupByModuleEntityManager _moduleEntityManager; - - public ConstFieldAllocator(EncryptionScopeProvider encryptionScopeProvider, RvaDataAllocator rvaDataAllocator, GroupByModuleEntityManager moduleEntityManager) - { - _encryptionScopeProvider = encryptionScopeProvider; - _rvaDataAllocator = rvaDataAllocator; - _moduleEntityManager = moduleEntityManager; - } - - private ModuleConstFieldAllocator GetModuleAllocator(ModuleDef mod) - { - return _moduleEntityManager.GetEntity(mod, () => new ModuleConstFieldAllocator(_encryptionScopeProvider, _rvaDataAllocator, _moduleEntityManager)); - } - - public FieldDef Allocate(ModuleDef mod, int value) - { - return GetModuleAllocator(mod).Allocate(value); - } - - public FieldDef Allocate(ModuleDef mod, long value) - { - return GetModuleAllocator(mod).Allocate(value); - } - - public FieldDef Allocate(ModuleDef mod, float value) - { - return GetModuleAllocator(mod).Allocate(value); - } - - public FieldDef Allocate(ModuleDef mod, double value) - { - return GetModuleAllocator(mod).Allocate(value); - } - - public FieldDef Allocate(ModuleDef mod, byte[] value) - { - return GetModuleAllocator(mod).Allocate(value); - } - - public FieldDef Allocate(ModuleDef mod, string value) - { - return GetModuleAllocator(mod).Allocate(value); - } - - public void Done() - { - foreach (var moduleAllocator in _moduleEntityManager.GetEntities()) - { - moduleAllocator.Done(); - } - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Data/ConstFieldAllocator.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Data/ConstFieldAllocator.cs.meta deleted file mode 100644 index 8e64e42..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Data/ConstFieldAllocator.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: e75f5cdfd47370d4ea6c4dee7e55a881 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Data/RvaDataAllocator.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Data/RvaDataAllocator.cs deleted file mode 100644 index 3d4d8dd..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Data/RvaDataAllocator.cs +++ /dev/null @@ -1,355 +0,0 @@ -using dnlib.DotNet; -using dnlib.DotNet.Emit; -using Obfuz.Emit; -using Obfuz.Utils; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using UnityEngine.Assertions; - -namespace Obfuz.Data -{ - public struct RvaData - { - public readonly FieldDef field; - public readonly int offset; - public readonly int size; - - public RvaData(FieldDef field, int offset, int size) - { - this.field = field; - this.offset = offset; - this.size = size; - } - } - - public class ModuleRvaDataAllocator : GroupByModuleEntityBase - { - // randomized - const int maxRvaDataSize = 0x1000; - - private ModuleDef _module; - private readonly EncryptionScopeProvider _encryptionScopeProvider; - private readonly GroupByModuleEntityManager _moduleEntityManager; - - private EncryptionScopeInfo _encryptionScope; - private IRandom _random; - - class RvaField - { - public FieldDef holderDataField; - public FieldDef runtimeValueField; - public int encryptionOps; - public uint size; - public List bytes; - public int salt; - - public void FillPaddingToSize(int newSize) - { - for (int i = bytes.Count; i < newSize; i++) - { - bytes.Add(0xAB); - } - } - - public void FillPaddingToEnd() - { - // fill with random value - for (int i = bytes.Count; i < size; i++) - { - bytes.Add(0xAB); - } - } - } - - private readonly List _rvaFields = new List(); - private RvaField _currentField; - - - private TypeDef _rvaTypeDef; - - private readonly Dictionary _dataHolderTypeBySizes = new Dictionary(); - private bool _done; - - public ModuleRvaDataAllocator(EncryptionScopeProvider encryptionScopeProvider, GroupByModuleEntityManager moduleEntityManager) - { - _encryptionScopeProvider = encryptionScopeProvider; - _moduleEntityManager = moduleEntityManager; - } - - public override void Init(ModuleDef mod) - { - _module = mod; - _encryptionScope = _encryptionScopeProvider.GetScope(mod); - _random = _encryptionScope.localRandomCreator(HashUtil.ComputeHash(mod.Name)); - } - - private (FieldDef, FieldDef) CreateDataHolderRvaField(TypeDef dataHolderType) - { - if (_rvaTypeDef == null) - { - _module.EnableTypeDefFindCache = false; - //_rvaTypeDef = _module.Find("$ObfuzRVA$", true); - //if (_rvaTypeDef != null) - //{ - // throw new Exception($"can't obfuscate a obfuscated assembly"); - //} - ITypeDefOrRef objectTypeRef = _module.Import(typeof(object)); - _rvaTypeDef = new TypeDefUser("$Obfuz$RVA$", objectTypeRef); - _module.Types.Add(_rvaTypeDef); - _module.EnableTypeDefFindCache = true; - } - - - var holderField = new FieldDefUser($"$RVA_Data{_rvaFields.Count}", new FieldSig(dataHolderType.ToTypeSig()), FieldAttributes.InitOnly | FieldAttributes.Static | FieldAttributes.HasFieldRVA); - holderField.DeclaringType = _rvaTypeDef; - - var runtimeValueField = new FieldDefUser($"$RVA_Value{_rvaFields.Count}", new FieldSig(new SZArraySig(_module.CorLibTypes.Byte)), FieldAttributes.Static | FieldAttributes.Public); - runtimeValueField.DeclaringType = _rvaTypeDef; - return (holderField, runtimeValueField); - } - - private TypeDef GetDataHolderType(int size) - { - size = (size + 15) & ~15; // align to 6 bytes - if (_dataHolderTypeBySizes.TryGetValue(size, out var type)) - return type; - var dataHolderType = new TypeDefUser($"$ObfuzRVA$DataHolder{size}", _module.Import(typeof(ValueType))); - dataHolderType.Attributes = TypeAttributes.Public | TypeAttributes.Sealed; - dataHolderType.Layout = TypeAttributes.ExplicitLayout; - dataHolderType.PackingSize = 1; - dataHolderType.ClassSize = (uint)size; - _dataHolderTypeBySizes.Add(size, dataHolderType); - _module.Types.Add(dataHolderType); - return dataHolderType; - } - - private static int AlignTo(int size, int alignment) - { - return (size + alignment - 1) & ~(alignment - 1); - } - - private RvaField CreateRvaField(int size) - { - TypeDef dataHolderType = GetDataHolderType(size); - var (holderDataField, runtimeValueField) = CreateDataHolderRvaField(dataHolderType); - var newRvaField = new RvaField - { - holderDataField = holderDataField, - runtimeValueField = runtimeValueField, - size = dataHolderType.ClassSize, - bytes = new List((int)dataHolderType.ClassSize), - encryptionOps = _random.NextInt(), - salt = _random.NextInt(), - }; - _rvaFields.Add(newRvaField); - return newRvaField; - } - - private RvaField GetRvaField(int preservedSize, int alignment) - { - if (_done) - { - throw new Exception("can't GetRvaField after done"); - } - Assert.IsTrue(preservedSize % alignment == 0); - // for big size, create a new field - if (preservedSize >= maxRvaDataSize) - { - return CreateRvaField(preservedSize); - } - - if (_currentField != null) - { - int offset = AlignTo(_currentField.bytes.Count, alignment); - - int expectedSize = offset + preservedSize; - if (expectedSize <= _currentField.size) - { - _currentField.FillPaddingToSize(offset); - return _currentField; - } - - _currentField.FillPaddingToEnd(); - } - _currentField = CreateRvaField(maxRvaDataSize); - return _currentField; - } - - public RvaData Allocate(int value) - { - RvaField field = GetRvaField(4, 4); - int offset = field.bytes.Count; - Assert.IsTrue(offset % 4 == 0); - field.bytes.AddRange(BitConverter.GetBytes(value)); - return new RvaData(field.runtimeValueField, offset, 4); - } - - public RvaData Allocate(long value) - { - RvaField field = GetRvaField(8, 8); - int offset = field.bytes.Count; - Assert.IsTrue(offset % 8 == 0); - field.bytes.AddRange(BitConverter.GetBytes(value)); - return new RvaData(field.runtimeValueField, offset, 8); - } - - public RvaData Allocate(float value) - { - RvaField field = GetRvaField(4, 4); - int offset = field.bytes.Count; - Assert.IsTrue(offset % 4 == 0); - field.bytes.AddRange(BitConverter.GetBytes(value)); - return new RvaData(field.runtimeValueField, offset, 4); - } - - public RvaData Allocate(double value) - { - RvaField field = GetRvaField(8, 8); - int offset = field.bytes.Count; - Assert.IsTrue(offset % 8 == 0); - field.bytes.AddRange(BitConverter.GetBytes(value)); - return new RvaData(field.runtimeValueField, offset, 8); - } - - public RvaData Allocate(string value) - { - byte[] bytes = Encoding.UTF8.GetBytes(value); - return Allocate(bytes); - } - - public RvaData Allocate(byte[] value) - { - RvaField field = GetRvaField(value.Length, 1); - int offset = field.bytes.Count; - field.bytes.AddRange(value); - return new RvaData(field.runtimeValueField, offset, value.Length); - } - - private void CreateCCtorOfRvaTypeDef() - { - if (_rvaTypeDef == null) - { - return; - } - ModuleDef mod = _rvaTypeDef.Module; - var cctorMethod = new MethodDefUser(".cctor", - MethodSig.CreateStatic(_module.CorLibTypes.Void), - MethodImplAttributes.IL | MethodImplAttributes.Managed, - MethodAttributes.Static | MethodAttributes.HideBySig | MethodAttributes.SpecialName | MethodAttributes.RTSpecialName | MethodAttributes.Private); - cctorMethod.DeclaringType = _rvaTypeDef; - //_rvaTypeDef.Methods.Add(cctor); - var body = new CilBody(); - cctorMethod.Body = body; - var ins = body.Instructions; - - DefaultMetadataImporter importer = _moduleEntityManager.GetDefaultModuleMetadataImporter(mod, _encryptionScopeProvider); - foreach (var field in _rvaFields) - { - // ldc - // newarr - // dup - // stsfld - // ldtoken - // RuntimeHelpers.InitializeArray(array, fieldHandle); - ins.Add(Instruction.Create(OpCodes.Ldc_I4, (int)field.size)); - ins.Add(Instruction.Create(OpCodes.Newarr, field.runtimeValueField.FieldType.Next.ToTypeDefOrRef())); - ins.Add(Instruction.Create(OpCodes.Dup)); - ins.Add(Instruction.Create(OpCodes.Dup)); - ins.Add(Instruction.Create(OpCodes.Stsfld, field.runtimeValueField)); - ins.Add(Instruction.Create(OpCodes.Ldtoken, field.holderDataField)); - ins.Add(Instruction.Create(OpCodes.Call, importer.InitializedArrayMethod)); - - // EncryptionService.DecryptBlock(array, field.encryptionOps, field.salt); - ins.Add(Instruction.CreateLdcI4(field.encryptionOps)); - ins.Add(Instruction.Create(OpCodes.Ldc_I4, field.salt)); - ins.Add(Instruction.Create(OpCodes.Call, importer.DecryptBlock)); - - } - ins.Add(Instruction.Create(OpCodes.Ret)); - } - - private void SetFieldsRVA() - { - foreach (var field in _rvaFields) - { - Assert.IsTrue(field.bytes.Count <= field.size); - if (field.bytes.Count < field.size) - { - field.FillPaddingToEnd(); - } - byte[] data = field.bytes.ToArray(); - _encryptionScope.encryptor.EncryptBlock(data, field.encryptionOps, field.salt); - field.holderDataField.InitialValue = data; - } - } - - public void Done() - { - if (_done) - { - throw new Exception("can't call Done twice"); - } - _done = true; - SetFieldsRVA(); - CreateCCtorOfRvaTypeDef(); - } - } - - public class RvaDataAllocator - { - private readonly EncryptionScopeProvider _encryptionScopeProvider; - private readonly GroupByModuleEntityManager _moduleEntityManager; - - public RvaDataAllocator(EncryptionScopeProvider encryptionScopeProvider, GroupByModuleEntityManager moduleEntityManager) - { - _encryptionScopeProvider = encryptionScopeProvider; - _moduleEntityManager = moduleEntityManager; - } - - private ModuleRvaDataAllocator GetModuleRvaDataAllocator(ModuleDef mod) - { - return _moduleEntityManager.GetEntity(mod, () => new ModuleRvaDataAllocator(_encryptionScopeProvider, _moduleEntityManager)); - } - - public RvaData Allocate(ModuleDef mod, int value) - { - return GetModuleRvaDataAllocator(mod).Allocate(value); - } - - public RvaData Allocate(ModuleDef mod, long value) - { - return GetModuleRvaDataAllocator(mod).Allocate(value); - } - - public RvaData Allocate(ModuleDef mod, float value) - { - return GetModuleRvaDataAllocator(mod).Allocate(value); - } - - public RvaData Allocate(ModuleDef mod, double value) - { - return GetModuleRvaDataAllocator(mod).Allocate(value); - } - - public RvaData Allocate(ModuleDef mod, string value) - { - return GetModuleRvaDataAllocator(mod).Allocate(value); - } - - public RvaData Allocate(ModuleDef mod, byte[] value) - { - return GetModuleRvaDataAllocator(mod).Allocate(value); - } - - public void Done() - { - foreach (var allocator in _moduleEntityManager.GetEntities()) - { - allocator.Done(); - } - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Data/RvaDataAllocator.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Data/RvaDataAllocator.cs.meta deleted file mode 100644 index c1f94e8..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Data/RvaDataAllocator.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c00ca514f46605645bf40b0135e7e504 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Emit.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Emit.meta deleted file mode 100644 index d13f8ab..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Emit.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: a513a192808ba5f47b1ef8a3ecf02533 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Emit/BasicBlockCollection.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Emit/BasicBlockCollection.cs deleted file mode 100644 index acd80a7..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Emit/BasicBlockCollection.cs +++ /dev/null @@ -1,295 +0,0 @@ -using dnlib.DotNet; -using dnlib.DotNet.Emit; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.Remoting.Messaging; -using System.Text; -using System.Threading.Tasks; - -namespace Obfuz.Emit -{ - public class BasicBlock - { - public readonly List instructions = new List(); - - public readonly List inBlocks = new List(); - - public readonly List outBlocks = new List(); - - public bool inLoop; - - public void AddTargetBasicBlock(BasicBlock target) - { - if (!outBlocks.Contains(target)) - { - outBlocks.Add(target); - } - if (!target.inBlocks.Contains(this)) - { - target.inBlocks.Add(this); - } - } - } - - public class BasicBlockCollection - { - private readonly MethodDef _method; - - private readonly List _blocks = new List(); - private readonly Dictionary _inst2BlockMap = new Dictionary(); - - public IList Blocks => _blocks; - - public BasicBlockCollection(MethodDef method) - { - _method = method; - HashSet splitPoints = BuildSplitPoint(method); - BuildBasicBlocks(method, splitPoints); - BuildInOutGraph(method); - - var loopBlocks = FindLoopBlocks(_blocks); - foreach (var block in loopBlocks) - { - block.inLoop = true; - } - } - - public BasicBlock GetBasicBlockByInstruction(Instruction inst) - { - return _inst2BlockMap[inst]; - } - - private HashSet BuildSplitPoint(MethodDef method) - { - var insts = method.Body.Instructions; - var splitPoints = new HashSet(); - foreach (ExceptionHandler eh in method.Body.ExceptionHandlers) - { - if (eh.TryStart != null) - { - splitPoints.Add(eh.TryStart); - } - if (eh.TryEnd != null) - { - splitPoints.Add(eh.TryEnd); - } - if (eh.HandlerStart != null) - { - splitPoints.Add(eh.HandlerStart); - } - if (eh.HandlerEnd != null) - { - splitPoints.Add(eh.HandlerEnd); - } - if (eh.FilterStart != null) - { - splitPoints.Add(eh.FilterStart); - } - } - - for (int i = 0, n = insts.Count; i < n; i++) - { - Instruction curInst = insts[i]; - Instruction nextInst = i + 1 < n ? insts[i + 1] : null; - switch (curInst.OpCode.FlowControl) - { - case FlowControl.Branch: - { - if (nextInst != null) - { - splitPoints.Add(nextInst); - } - break; - } - case FlowControl.Cond_Branch: - { - if (nextInst != null) - { - splitPoints.Add(nextInst); - } - if (curInst.Operand is Instruction targetInst) - { - splitPoints.Add(targetInst); - } - else if (curInst.Operand is Instruction[] targetInsts) - { - foreach (var target in targetInsts) - { - splitPoints.Add(target); - } - } - break; - } - case FlowControl.Return: - { - if (nextInst != null) - { - splitPoints.Add(nextInst); - } - break; - } - case FlowControl.Throw: - { - if (nextInst != null) - { - splitPoints.Add(nextInst); - } - break; - } - } - } - return splitPoints; - } - - - private void BuildBasicBlocks(MethodDef method, HashSet splitPoints) - { - var insts = method.Body.Instructions; - - - BasicBlock curBlock = new BasicBlock(); - foreach (Instruction inst in insts) - { - if (splitPoints.Contains(inst) && curBlock.instructions.Count > 0) - { - _blocks.Add(curBlock); - curBlock = new BasicBlock(); - } - curBlock.instructions.Add(inst); - _inst2BlockMap.Add(inst, curBlock); - } - if (curBlock.instructions.Count > 0) - { - _blocks.Add(curBlock); - } - } - - private void BuildInOutGraph(MethodDef method) - { - var insts = method.Body.Instructions; - for (int i = 0, n = _blocks.Count; i < n; i++) - { - BasicBlock curBlock = _blocks[i]; - BasicBlock nextBlock = i + 1 < n ? _blocks[i + 1] : null; - Instruction lastInst = curBlock.instructions.Last(); - switch (lastInst.OpCode.FlowControl) - { - case FlowControl.Branch: - { - Instruction targetInst = (Instruction)lastInst.Operand; - BasicBlock targetBlock = GetBasicBlockByInstruction(targetInst); - curBlock.AddTargetBasicBlock(targetBlock); - break; - } - case FlowControl.Cond_Branch: - { - if (lastInst.Operand is Instruction targetInst) - { - BasicBlock targetBlock = GetBasicBlockByInstruction(targetInst); - curBlock.AddTargetBasicBlock(targetBlock); - } - else if (lastInst.Operand is Instruction[] targetInsts) - { - foreach (var target in targetInsts) - { - BasicBlock targetBlock = GetBasicBlockByInstruction(target); - curBlock.AddTargetBasicBlock(targetBlock); - } - } - else - { - throw new Exception("Invalid operand type for conditional branch"); - } - if (nextBlock != null) - { - curBlock.AddTargetBasicBlock(nextBlock); - } - break; - } - case FlowControl.Return: - case FlowControl.Throw: - { - break; - } - } - } - } - - private static HashSet FindLoopBlocks(List allBlocks) - { - // Tarjan算法找强连通分量 - var sccList = FindStronglyConnectedComponents(allBlocks); - - // 筛选有效循环 - var loopBlocks = new HashSet(); - foreach (var scc in sccList) - { - // 有效循环需满足以下条件之一: - // 1. 分量包含多个块 - // 2. 单个块有自环(跳转自己) - if (scc.Count > 1 || - (scc.Count == 1 && scc[0].outBlocks.Contains(scc[0]))) - { - foreach (var block in scc) - { - loopBlocks.Add(block); - } - } - } - return loopBlocks; - } - - private static List> FindStronglyConnectedComponents(List allBlocks) - { - int index = 0; - var stack = new Stack(); - var indexes = new Dictionary(); - var lowLinks = new Dictionary(); - var onStack = new HashSet(); - var sccList = new List>(); - - foreach (var block in allBlocks.Where(b => !indexes.ContainsKey(b))) - { - StrongConnect(block); - } - - return sccList; - - void StrongConnect(BasicBlock v) - { - indexes[v] = index; - lowLinks[v] = index; - index++; - stack.Push(v); - onStack.Add(v); - - foreach (var w in v.outBlocks) - { - if (!indexes.ContainsKey(w)) - { - StrongConnect(w); - lowLinks[v] = System.Math.Min(lowLinks[v], lowLinks[w]); - } - else if (onStack.Contains(w)) - { - lowLinks[v] = System.Math.Min(lowLinks[v], indexes[w]); - } - } - - if (lowLinks[v] == indexes[v]) - { - var scc = new List(); - BasicBlock w; - do - { - w = stack.Pop(); - onStack.Remove(w); - scc.Add(w); - } while (!w.Equals(v)); - sccList.Add(scc); - } - } - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Emit/BasicBlockCollection.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Emit/BasicBlockCollection.cs.meta deleted file mode 100644 index dabfa3b..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Emit/BasicBlockCollection.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 77c19c023bb7f77489998d994a3be1bd -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Emit/DefaultMetadataImporter.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Emit/DefaultMetadataImporter.cs deleted file mode 100644 index 8a3c30d..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Emit/DefaultMetadataImporter.cs +++ /dev/null @@ -1,193 +0,0 @@ -using dnlib.DotNet; -using System; -using UnityEngine.Assertions; - -namespace Obfuz.Emit -{ - public class EncryptionServiceMetadataImporter - { - private readonly ModuleDef _module; - private readonly Type _encryptionServiceType; - - private IMethod _encryptBlock; - private IMethod _decryptBlock; - private IMethod _encryptInt; - private IMethod _decryptInt; - private IMethod _encryptLong; - private IMethod _decryptLong; - private IMethod _encryptFloat; - private IMethod _decryptFloat; - private IMethod _encryptDouble; - private IMethod _decryptDouble; - private IMethod _encryptString; - private IMethod _decryptString; - private IMethod _encryptBytes; - private IMethod _decryptBytes; - - private IMethod _decryptFromRvaInt; - private IMethod _decryptFromRvaLong; - private IMethod _decryptFromRvaFloat; - private IMethod _decryptFromRvaDouble; - private IMethod _decryptFromRvaString; - private IMethod _decryptFromRvaBytes; - - public IMethod EncryptBlock => _encryptBlock; - public IMethod DecryptBlock => _decryptBlock; - - public IMethod EncryptInt => _encryptInt; - public IMethod DecryptInt => _decryptInt; - public IMethod EncryptLong => _encryptLong; - public IMethod DecryptLong => _decryptLong; - public IMethod EncryptFloat => _encryptFloat; - public IMethod DecryptFloat => _decryptFloat; - public IMethod EncryptDouble => _encryptDouble; - public IMethod DecryptDouble => _decryptDouble; - public IMethod EncryptString => _encryptString; - public IMethod DecryptString => _decryptString; - public IMethod EncryptBytes => _encryptBytes; - public IMethod DecryptBytes => _decryptBytes; - - public IMethod DecryptFromRvaInt => _decryptFromRvaInt; - public IMethod DecryptFromRvaLong => _decryptFromRvaLong; - public IMethod DecryptFromRvaFloat => _decryptFromRvaFloat; - public IMethod DecryptFromRvaDouble => _decryptFromRvaDouble; - public IMethod DecryptFromRvaBytes => _decryptFromRvaBytes; - public IMethod DecryptFromRvaString => _decryptFromRvaString; - - public EncryptionServiceMetadataImporter(ModuleDef mod, Type encryptionServiceType) - { - _module = mod; - _encryptionServiceType = encryptionServiceType; - _encryptBlock = mod.Import(encryptionServiceType.GetMethod("EncryptBlock", new[] { typeof(byte[]), typeof(int), typeof(int) })); - Assert.IsNotNull(_encryptBlock); - _decryptBlock = mod.Import(encryptionServiceType.GetMethod("DecryptBlock", new[] { typeof(byte[]), typeof(int), typeof(int) })); - Assert.IsNotNull(_decryptBlock); - _encryptInt = mod.Import(encryptionServiceType.GetMethod("Encrypt", new[] { typeof(int), typeof(int), typeof(int) })); - Assert.IsNotNull(_encryptInt); - _decryptInt = mod.Import(encryptionServiceType.GetMethod("Decrypt", new[] { typeof(int), typeof(int), typeof(int) })); - Assert.IsNotNull(_decryptInt); - _encryptLong = mod.Import(encryptionServiceType.GetMethod("Encrypt", new[] { typeof(long), typeof(int), typeof(int) })); - Assert.IsNotNull(_encryptLong); - _decryptLong = mod.Import(encryptionServiceType.GetMethod("Decrypt", new[] { typeof(long), typeof(int), typeof(int) })); - Assert.IsNotNull(_decryptLong); - _encryptFloat = mod.Import(encryptionServiceType.GetMethod("Encrypt", new[] { typeof(float), typeof(int), typeof(int) })); - Assert.IsNotNull(_encryptFloat); - _decryptFloat = mod.Import(encryptionServiceType.GetMethod("Decrypt", new[] { typeof(float), typeof(int), typeof(int) })); - Assert.IsNotNull(_decryptFloat); - _encryptDouble = mod.Import(encryptionServiceType.GetMethod("Encrypt", new[] { typeof(double), typeof(int), typeof(int) })); - Assert.IsNotNull(_encryptDouble); - _decryptDouble = mod.Import(encryptionServiceType.GetMethod("Decrypt", new[] { typeof(double), typeof(int), typeof(int) })); - Assert.IsNotNull(_decryptDouble); - _encryptString = mod.Import(encryptionServiceType.GetMethod("Encrypt", new[] { typeof(string), typeof(int), typeof(int) })); - Assert.IsNotNull(_encryptString); - _decryptString = mod.Import(encryptionServiceType.GetMethod("DecryptString", new[] { typeof(byte[]), typeof(int), typeof(int), typeof(int), typeof(int) })); - Assert.IsNotNull(_decryptString); - _encryptBytes = mod.Import(encryptionServiceType.GetMethod("Encrypt", new[] { typeof(byte[]), typeof(int), typeof(int), typeof(int), typeof(int) })); - Assert.IsNotNull(_encryptBytes); - _decryptBytes = mod.Import(encryptionServiceType.GetMethod("Decrypt", new[] { typeof(byte[]), typeof(int), typeof(int), typeof(int), typeof(int) })); - Assert.IsNotNull(_decryptBytes); - - _decryptFromRvaInt = mod.Import(encryptionServiceType.GetMethod("DecryptFromRvaInt", new[] { typeof(byte[]), typeof(int), typeof(int), typeof(int) })); - Assert.IsNotNull(_decryptFromRvaInt); - _decryptFromRvaLong = mod.Import(encryptionServiceType.GetMethod("DecryptFromRvaLong", new[] { typeof(byte[]), typeof(int), typeof(int), typeof(int) })); - Assert.IsNotNull(_decryptFromRvaLong); - _decryptFromRvaFloat = mod.Import(encryptionServiceType.GetMethod("DecryptFromRvaFloat", new[] { typeof(byte[]), typeof(int), typeof(int), typeof(int) })); - Assert.IsNotNull(_decryptFromRvaFloat); - _decryptFromRvaDouble = mod.Import(encryptionServiceType.GetMethod("DecryptFromRvaDouble", new[] { typeof(byte[]), typeof(int), typeof(int), typeof(int) })); - Assert.IsNotNull(_decryptFromRvaDouble); - _decryptFromRvaBytes = mod.Import(encryptionServiceType.GetMethod("DecryptFromRvaBytes", new[] { typeof(byte[]), typeof(int), typeof(int), typeof(int), typeof(int) })); - Assert.IsNotNull(_decryptFromRvaBytes); - _decryptFromRvaString = mod.Import(encryptionServiceType.GetMethod("DecryptFromRvaString", new[] { typeof(byte[]), typeof(int), typeof(int), typeof(int), typeof(int) })); - Assert.IsNotNull(_decryptFromRvaString); - } - } - - public class DefaultMetadataImporter : GroupByModuleEntityBase - { - private readonly EncryptionScopeProvider _encryptionScopeProvider; - private EncryptionScopeInfo _encryptionScope; - private EncryptionServiceMetadataImporter _defaultEncryptionServiceMetadataImporter; - - - private EncryptionServiceMetadataImporter _staticDefaultEncryptionServiceMetadataImporter; - private EncryptionServiceMetadataImporter _dynamicDefaultEncryptionServiceMetadataImporter; - - public DefaultMetadataImporter(EncryptionScopeProvider encryptionScopeProvider) - { - _encryptionScopeProvider = encryptionScopeProvider; - } - - public override void Init(ModuleDef mod) - { - _module = mod; - _encryptionScope = _encryptionScopeProvider.GetScope(mod); - var constUtilityType = typeof(ConstUtility); - - _castIntAsFloat = mod.Import(constUtilityType.GetMethod("CastIntAsFloat")); - Assert.IsNotNull(_castIntAsFloat, "CastIntAsFloat not found"); - _castLongAsDouble = mod.Import(constUtilityType.GetMethod("CastLongAsDouble")); - Assert.IsNotNull(_castLongAsDouble, "CastLongAsDouble not found"); - _castFloatAsInt = mod.Import(constUtilityType.GetMethod("CastFloatAsInt")); - Assert.IsNotNull(_castFloatAsInt, "CastFloatAsInt not found"); - _castDoubleAsLong = mod.Import(constUtilityType.GetMethod("CastDoubleAsLong")); - Assert.IsNotNull(_castDoubleAsLong, "CastDoubleAsLong not found"); - - _initializeArray = mod.Import(typeof(System.Runtime.CompilerServices.RuntimeHelpers).GetMethod("InitializeArray", new[] { typeof(Array), typeof(RuntimeFieldHandle) })); - Assert.IsNotNull(_initializeArray); - - _staticDefaultEncryptionServiceMetadataImporter = new EncryptionServiceMetadataImporter(mod, typeof(EncryptionService)); - _dynamicDefaultEncryptionServiceMetadataImporter = new EncryptionServiceMetadataImporter(mod, typeof(EncryptionService)); - if (_encryptionScopeProvider.IsDynamicSecretAssembly(mod)) - { - _defaultEncryptionServiceMetadataImporter = _dynamicDefaultEncryptionServiceMetadataImporter; - } - else - { - _defaultEncryptionServiceMetadataImporter = _staticDefaultEncryptionServiceMetadataImporter; - } - } - - public EncryptionServiceMetadataImporter GetEncryptionServiceMetadataImporterOfModule(ModuleDef mod) - { - return _encryptionScopeProvider.IsDynamicSecretAssembly(mod) ? _dynamicDefaultEncryptionServiceMetadataImporter : _staticDefaultEncryptionServiceMetadataImporter; - } - - private ModuleDef _module; - private IMethod _castIntAsFloat; - private IMethod _castLongAsDouble; - private IMethod _castFloatAsInt; - private IMethod _castDoubleAsLong; - private IMethod _initializeArray; - - public IMethod CastIntAsFloat => _castIntAsFloat; - public IMethod CastLongAsDouble => _castLongAsDouble; - public IMethod CastFloatAsInt => _castFloatAsInt; - public IMethod CastDoubleAsLong => _castDoubleAsLong; - - public IMethod InitializedArrayMethod => _initializeArray; - - public IMethod EncryptBlock => _defaultEncryptionServiceMetadataImporter.EncryptBlock; - public IMethod DecryptBlock => _defaultEncryptionServiceMetadataImporter.DecryptBlock; - - public IMethod EncryptInt => _defaultEncryptionServiceMetadataImporter.EncryptInt; - public IMethod DecryptInt => _defaultEncryptionServiceMetadataImporter.DecryptInt; - public IMethod EncryptLong => _defaultEncryptionServiceMetadataImporter.EncryptLong; - public IMethod DecryptLong => _defaultEncryptionServiceMetadataImporter.DecryptLong; - public IMethod EncryptFloat => _defaultEncryptionServiceMetadataImporter.EncryptFloat; - public IMethod DecryptFloat => _defaultEncryptionServiceMetadataImporter.DecryptFloat; - public IMethod EncryptDouble => _defaultEncryptionServiceMetadataImporter.EncryptDouble; - public IMethod DecryptDouble => _defaultEncryptionServiceMetadataImporter.DecryptDouble; - public IMethod EncryptString => _defaultEncryptionServiceMetadataImporter.EncryptString; - public IMethod DecryptString => _defaultEncryptionServiceMetadataImporter.DecryptString; - public IMethod EncryptBytes => _defaultEncryptionServiceMetadataImporter.EncryptBytes; - public IMethod DecryptBytes => _defaultEncryptionServiceMetadataImporter.DecryptBytes; - - public IMethod DecryptFromRvaInt => _defaultEncryptionServiceMetadataImporter.DecryptFromRvaInt; - public IMethod DecryptFromRvaLong => _defaultEncryptionServiceMetadataImporter.DecryptFromRvaLong; - public IMethod DecryptFromRvaFloat => _defaultEncryptionServiceMetadataImporter.DecryptFromRvaFloat; - public IMethod DecryptFromRvaDouble => _defaultEncryptionServiceMetadataImporter.DecryptFromRvaDouble; - public IMethod DecryptFromRvaBytes => _defaultEncryptionServiceMetadataImporter.DecryptFromRvaBytes; - public IMethod DecryptFromRvaString => _defaultEncryptionServiceMetadataImporter.DecryptFromRvaString; - - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Emit/DefaultMetadataImporter.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Emit/DefaultMetadataImporter.cs.meta deleted file mode 100644 index c29c6a9..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Emit/DefaultMetadataImporter.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 76438ce96146edd469872feada7857ba -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Emit/GroupByModuleEntityManager.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Emit/GroupByModuleEntityManager.cs deleted file mode 100644 index 860bdf8..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Emit/GroupByModuleEntityManager.cs +++ /dev/null @@ -1,66 +0,0 @@ -using dnlib.DotNet; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Obfuz.Emit -{ - public interface IGroupByModuleEntity - { - void Init(ModuleDef mod); - } - - public abstract class GroupByModuleEntityBase : IGroupByModuleEntity - { - public abstract void Init(ModuleDef mod); - } - - public class GroupByModuleEntityManager - { - private readonly Dictionary<(ModuleDef, Type), IGroupByModuleEntity> _moduleEntityManagers = new Dictionary<(ModuleDef, Type), IGroupByModuleEntity>(); - - public T GetEntity(ModuleDef mod, Func creator = null) where T : IGroupByModuleEntity - { - var key = (mod, typeof(T)); - if (_moduleEntityManagers.TryGetValue(key, out var emitManager)) - { - return (T)emitManager; - } - else - { - T newEmitManager; - if (creator != null) - { - newEmitManager = creator(); - } - else - { - newEmitManager = (T)Activator.CreateInstance(typeof(T)); - } - newEmitManager.Init(mod); - _moduleEntityManagers[key] = newEmitManager; - return newEmitManager; - } - } - - public List GetEntities() where T: IGroupByModuleEntity - { - var managers = new List(); - foreach (var kv in _moduleEntityManagers) - { - if (kv.Key.Item2 == typeof(T)) - { - managers.Add((T)kv.Value); - } - } - return managers; - } - - public DefaultMetadataImporter GetDefaultModuleMetadataImporter(ModuleDef module, EncryptionScopeProvider encryptionScopeProvider) - { - return GetEntity(module, () => new DefaultMetadataImporter(encryptionScopeProvider)); - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Emit/GroupByModuleEntityManager.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Emit/GroupByModuleEntityManager.cs.meta deleted file mode 100644 index a6b7602..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Emit/GroupByModuleEntityManager.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 0bfcb2b5a87851f469d201fc8978c109 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM.meta deleted file mode 100644 index e8e65c1..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: fec4187cc1b96d5439ff908bcecd988f -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/EncryptionInstructionWithOpCode.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/EncryptionInstructionWithOpCode.cs deleted file mode 100644 index 19ded45..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/EncryptionInstructionWithOpCode.cs +++ /dev/null @@ -1,25 +0,0 @@ -namespace Obfuz.EncryptionVM -{ - public class EncryptionInstructionWithOpCode - { - public readonly ushort code; - - public readonly IEncryptionInstruction function; - - public EncryptionInstructionWithOpCode(ushort code, IEncryptionInstruction function) - { - this.code = code; - this.function = function; - } - - public int Encrypt(int value, int[] secretKey, int salt) - { - return function.Encrypt(value, secretKey, salt); - } - - public int Decrypt(int value, int[] secretKey, int salt) - { - return function.Decrypt(value, secretKey, salt); - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/EncryptionInstructionWithOpCode.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/EncryptionInstructionWithOpCode.cs.meta deleted file mode 100644 index cd63f21..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/EncryptionInstructionWithOpCode.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ca9bd232ed2583f4bb5f330886a329e6 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/IEncryptionInstruction.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/IEncryptionInstruction.cs deleted file mode 100644 index 49808c4..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/IEncryptionInstruction.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Collections.Generic; - -namespace Obfuz.EncryptionVM -{ - public interface IEncryptionInstruction - { - int Encrypt(int value, int[] secretKey, int salt); - - int Decrypt(int value, int[] secretKey, int salt); - - void GenerateEncryptCode(List lines, string indent); - - void GenerateDecryptCode(List lines, string indent); - } - - public abstract class EncryptionInstructionBase : IEncryptionInstruction - { - public abstract int Encrypt(int value, int[] secretKey, int salt); - public abstract int Decrypt(int value, int[] secretKey, int salt); - - public abstract void GenerateEncryptCode(List lines, string indent); - public abstract void GenerateDecryptCode(List lines, string indent); - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/IEncryptionInstruction.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/IEncryptionInstruction.cs.meta deleted file mode 100644 index ab7f3a6..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/IEncryptionInstruction.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f7b9d087de770a5488a9069ddf697c2f -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions.meta deleted file mode 100644 index fa56988..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 981355cf75a9d234883b2a15c446f478 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/AddInstruction.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/AddInstruction.cs deleted file mode 100644 index 2681fff..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/AddInstruction.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Collections.Generic; - -namespace Obfuz.EncryptionVM.Instructions -{ - public class AddInstruction : EncryptionInstructionBase - { - private readonly int _addValue; - private readonly int _opKeyIndex; - - public AddInstruction(int addValue, int opKeyIndex) - { - _addValue = addValue; - _opKeyIndex = opKeyIndex; - } - public override int Encrypt(int value, int[] secretKey, int salt) - { - return ((value + secretKey[_opKeyIndex]) ^ salt) + _addValue; - } - - public override int Decrypt(int value, int[] secretKey, int salt) - { - return ((value - _addValue) ^ salt) - secretKey[_opKeyIndex]; - } - - public override void GenerateEncryptCode(List lines, string indent) - { - lines.Add(indent + $"value = ((value + _secretKey[{_opKeyIndex}]) ^ salt) + {_addValue};"); - } - - public override void GenerateDecryptCode(List lines, string indent) - { - lines.Add(indent + $"value = ((value - {_addValue}) ^ salt) - _secretKey[{_opKeyIndex}];"); - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/AddInstruction.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/AddInstruction.cs.meta deleted file mode 100644 index d1d2031..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/AddInstruction.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 6bdbdc5fd983f044a87e7b8ab8647aeb -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/AddRotateXorInstruction.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/AddRotateXorInstruction.cs deleted file mode 100644 index 099a566..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/AddRotateXorInstruction.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Obfuz.EncryptionVM.Instructions -{ - public class AddRotateXorInstruction : EncryptionInstructionBase - { - // x = x + p1 + secretKey[index1]; - // x = Rotate(x, p2) - // x = x ^ p3 ^ salt; - - private readonly int _addValue; - private readonly int _index1; - private readonly int _rotateBitNum; - private readonly int _xorValue; - - public AddRotateXorInstruction(int addValue, int index1, int rotateBitNum, int xorValue) - { - _addValue = addValue; - _index1 = index1; - _rotateBitNum = rotateBitNum; - _xorValue = xorValue; - } - - public override int Encrypt(int value, int[] secretKey, int salt) - { - value += _addValue + secretKey[_index1]; - uint part1 = (uint)value << _rotateBitNum; - uint part2 = (uint)value >> (32 - _rotateBitNum); - value = (int)(part1 | part2); - value ^= _xorValue ^ salt; - return value; - } - - public override int Decrypt(int value, int[] secretKey, int salt) - { - value ^= _xorValue ^ salt; - uint value2 = (uint)value >> _rotateBitNum; - uint part1 = (uint)value << (32 - _rotateBitNum); - value = (int)(value2 | part1); - value -= _addValue + secretKey[_index1]; - return value; - } - - public override void GenerateEncryptCode(List lines, string indent) - { - lines.Add(indent + $"value += {_addValue} + _secretKey[{_index1}];"); - lines.Add(indent + $"uint part1 = (uint)value << {_rotateBitNum};"); - lines.Add(indent + $"uint part2 = (uint)value >> (32 - {_rotateBitNum});"); - lines.Add(indent + $"value = (int)(part1 | part2);"); - lines.Add(indent + $"value ^= {_xorValue} ^ salt;"); - } - - public override void GenerateDecryptCode(List lines, string indent) - { - lines.Add(indent + $"value ^= {_xorValue} ^ salt;"); - lines.Add(indent + $"uint value2 = (uint)value >> {_rotateBitNum};"); - lines.Add(indent + $"uint part1 = (uint)value << (32 - {_rotateBitNum});"); - lines.Add(indent + $"value = (int)(value2 | part1);"); - lines.Add(indent + $"value -= {_addValue} + _secretKey[{_index1}];"); - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/AddRotateXorInstruction.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/AddRotateXorInstruction.cs.meta deleted file mode 100644 index 6101fdb..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/AddRotateXorInstruction.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: cda67c0dd0cadd24ea02c2988e34281a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/AddXorRotateInstruction.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/AddXorRotateInstruction.cs deleted file mode 100644 index cc453a7..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/AddXorRotateInstruction.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Obfuz.EncryptionVM.Instructions -{ - public class AddXorRotateInstruction : EncryptionInstructionBase - { - // x = x + p1 + secretKey[index1]; - // x = x ^ p3 ^ salt; - // x = Rotate(x, p2) - - private readonly int _addValue; - private readonly int _index1; - private readonly int _rotateBitNum; - private readonly int _xorValue; - - public AddXorRotateInstruction(int addValue, int index1, int xorValue, int rotateBitNum) - { - _addValue = addValue; - _index1 = index1; - _rotateBitNum = rotateBitNum; - _xorValue = xorValue; - } - - public override int Encrypt(int value, int[] secretKey, int salt) - { - value += _addValue + secretKey[_index1]; - value ^= _xorValue ^ salt; - uint part1 = (uint)value << _rotateBitNum; - uint part2 = (uint)value >> (32 - _rotateBitNum); - value = (int)(part1 | part2); - return value; - } - - public override int Decrypt(int value, int[] secretKey, int salt) - { - uint value2 = (uint)value >> _rotateBitNum; - uint part1 = (uint)value << (32 - _rotateBitNum); - value = (int)(value2 | part1); - value ^= _xorValue ^ salt; - value -= _addValue + secretKey[_index1]; - return value; - } - - public override void GenerateEncryptCode(List lines, string indent) - { - lines.Add(indent + $"value += {_addValue} + _secretKey[{_index1}];"); - lines.Add(indent + $"value ^= {_xorValue} ^ salt;"); - lines.Add(indent + $"uint part1 = (uint)value << {_rotateBitNum};"); - lines.Add(indent + $"uint part2 = (uint)value >> (32 - {_rotateBitNum});"); - lines.Add(indent + $"value = (int)(part1 | part2);"); - } - - public override void GenerateDecryptCode(List lines, string indent) - { - lines.Add(indent + $"uint part1 = (uint)value >> {_rotateBitNum};"); - lines.Add(indent + $"uint part2 = (uint)value << (32 - {_rotateBitNum});"); - lines.Add(indent + $"value = (int)(part1 | part2);"); - lines.Add(indent + $"value ^= {_xorValue} ^ salt;"); - lines.Add(indent + $"value -= {_addValue} + _secretKey[{_index1}];"); - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/AddXorRotateInstruction.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/AddXorRotateInstruction.cs.meta deleted file mode 100644 index abde16f..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/AddXorRotateInstruction.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d806305e627be06469fb2d2c2cf98816 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/BitRotateInstruction.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/BitRotateInstruction.cs deleted file mode 100644 index 2d9dcd1..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/BitRotateInstruction.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System.Collections.Generic; - -namespace Obfuz.EncryptionVM.Instructions -{ - public class BitRotateInstruction : EncryptionInstructionBase - { - private readonly int _rotateBitNum; - private readonly int _opKeyIndex; - - public BitRotateInstruction(int rotateBitNum, int opKeyIndex) - { - _rotateBitNum = rotateBitNum; - _opKeyIndex = opKeyIndex; - } - - public override int Encrypt(int value, int[] secretKey, int salt) - { - uint part1 = (uint)value << _rotateBitNum; - uint part2 = (uint)value >> (32 - _rotateBitNum); - return ((int)(part1 | part2) ^ secretKey[_opKeyIndex]) + salt; - } - - public override int Decrypt(int value, int[] secretKey, int salt) - { - uint value2 = (uint)((value - salt) ^ secretKey[_opKeyIndex]); - uint part1 = value2 >> _rotateBitNum; - uint part2 = value2 << (32 - _rotateBitNum); - return (int)(part1 | part2); - } - - public override void GenerateEncryptCode(List lines, string indent) - { - lines.Add(indent + $"uint part1 = (uint)value << {_rotateBitNum};"); - lines.Add(indent + $"uint part2 = (uint)value >> (32 - {_rotateBitNum});"); - lines.Add(indent + $"value = ((int)(part1 | part2) ^ _secretKey[{_opKeyIndex}]) + salt;"); - } - - public override void GenerateDecryptCode(List lines, string indent) - { - lines.Add(indent + $"uint value2 = (uint)((value - salt) ^ _secretKey[{_opKeyIndex}]);"); - lines.Add(indent + $"uint part1 = value2 >> {_rotateBitNum};"); - lines.Add(indent + $"uint part2 = value2 << (32 - {_rotateBitNum});"); - lines.Add(indent + $"value = (int)(part1 | part2);"); - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/BitRotateInstruction.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/BitRotateInstruction.cs.meta deleted file mode 100644 index b4b0b9a..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/BitRotateInstruction.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: bccff31b9f07fcf4f821cee671f82caf -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/EncryptFunction.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/EncryptFunction.cs deleted file mode 100644 index ed59848..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/EncryptFunction.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Obfuz.EncryptionVM.Instructions -{ - - public class EncryptFunction : EncryptionInstructionBase - { - private readonly IEncryptionInstruction[] _instructions; - - public EncryptFunction(IEncryptionInstruction[] instructions) - { - _instructions = instructions; - } - - public override int Encrypt(int value, int[] secretKey, int salt) - { - foreach (var instruction in _instructions) - { - value = instruction.Encrypt(value, secretKey, salt); - } - return value; - } - - public override int Decrypt(int value, int[] secretKey, int salt) - { - for (int i = _instructions.Length - 1; i >= 0; i--) - { - value = _instructions[i].Decrypt(value, secretKey, salt); - } - return value; - } - - public override void GenerateEncryptCode(List lines, string indent) - { - throw new NotImplementedException(); - } - - public override void GenerateDecryptCode(List lines, string indent) - { - throw new NotImplementedException(); - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/EncryptFunction.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/EncryptFunction.cs.meta deleted file mode 100644 index 0ee2250..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/EncryptFunction.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: feafdb30f7b6d5143a89c7659bc16171 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/MultipleInstruction.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/MultipleInstruction.cs deleted file mode 100644 index 2635f5e..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/MultipleInstruction.cs +++ /dev/null @@ -1,64 +0,0 @@ -using NUnit.Framework; -using System; -using System.Collections.Generic; - -namespace Obfuz.EncryptionVM.Instructions -{ - public class MultipleInstruction : EncryptionInstructionBase - { - private readonly int _multiValue; - private readonly int _revertMultiValue; - private readonly int _opKeyIndex; - - public MultipleInstruction(int addValue, int opKeyIndex) - { - _multiValue = addValue; - _opKeyIndex = opKeyIndex; - _revertMultiValue = (int)ModInverseOdd((uint)addValue); - Verify(); - } - - private void Verify() - { - int a = 1122334; - Assert.AreEqual(a, a * _multiValue * _revertMultiValue); - } - - public static uint ModInverseOdd(uint a) - { - if (a % 2 == 0) - throw new ArgumentException("Input must be an odd number.", nameof(a)); - - uint x = 1; // 初始解:x₀ = 1 (mod 2) - for (int i = 0; i < 5; i++) // 迭代5次(2^1 → 2^32) - { - int shift = 2 << i; // 当前模数为 2^(2^(i+1)) - ulong mod = 1UL << shift; // 使用 ulong 避免溢出 - ulong ax = (ulong)a * x; // 计算 a*x(64位避免截断) - ulong term = (2 - ax) % mod; - x = (uint)((x * term) % mod); // 更新 x,结果截断为 uint - } - return x; // 最终解为 x₅ mod 2^32 - } - - public override int Encrypt(int value, int[] secretKey, int salt) - { - return value * _multiValue + secretKey[_opKeyIndex] + salt; - } - - public override int Decrypt(int value, int[] secretKey, int salt) - { - return (value - secretKey[_opKeyIndex] - salt) * _revertMultiValue; - } - - public override void GenerateEncryptCode(List lines, string indent) - { - lines.Add(indent + $"value = value * {_multiValue} + _secretKey[{_opKeyIndex}] + salt;"); - } - - public override void GenerateDecryptCode(List lines, string indent) - { - lines.Add(indent + $"value = (value - _secretKey[{_opKeyIndex}] - salt) * {_revertMultiValue};"); - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/MultipleInstruction.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/MultipleInstruction.cs.meta deleted file mode 100644 index 478ba08..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/MultipleInstruction.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: fd5fdfad694e0ae469bf6ca04c913220 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/MultipleRotateXorInstruction.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/MultipleRotateXorInstruction.cs deleted file mode 100644 index 75e4c5c..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/MultipleRotateXorInstruction.cs +++ /dev/null @@ -1,68 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Obfuz.EncryptionVM.Instructions -{ - public class MultipleRotateXorInstruction : EncryptionInstructionBase - { - // x = x * p1 + secretKey[index1]; - // x = Rotate(x, p2) - // x = x ^ p3 ^ salt; - - private readonly int _multipleValue; - private readonly int _revertMultipleValue; - private readonly int _index1; - private readonly int _rotateBitNum; - private readonly int _xorValue; - - public MultipleRotateXorInstruction(int multipleValue, int index1, int rotateBitNum, int xorValue) - { - _multipleValue = multipleValue; - _revertMultipleValue = (int)MultipleInstruction.ModInverseOdd((uint)multipleValue); - _index1 = index1; - _rotateBitNum = rotateBitNum; - _xorValue = xorValue; - } - - public override int Encrypt(int value, int[] secretKey, int salt) - { - value = value * _multipleValue + secretKey[_index1]; - uint part1 = (uint)value << _rotateBitNum; - uint part2 = (uint)value >> (32 - _rotateBitNum); - value = (int)(part1 | part2); - value ^= _xorValue ^ salt; - return value; - } - - public override int Decrypt(int value, int[] secretKey, int salt) - { - value ^= _xorValue ^ salt; - uint value2 = (uint)value >> _rotateBitNum; - uint part1 = (uint)value << (32 - _rotateBitNum); - value = (int)(value2 | part1); - value = (value - secretKey[_index1]) * _revertMultipleValue; - return value; - } - - public override void GenerateEncryptCode(List lines, string indent) - { - lines.Add(indent + $"value = value * {_multipleValue} + _secretKey[{_index1}];"); - lines.Add(indent + $"uint part1 = (uint)value << {_rotateBitNum};"); - lines.Add(indent + $"uint part2 = (uint)value >> (32 - {_rotateBitNum});"); - lines.Add(indent + $"value = (int)(part1 | part2);"); - lines.Add(indent + $"value ^= {_xorValue} ^ salt;"); - } - - public override void GenerateDecryptCode(List lines, string indent) - { - lines.Add(indent + $"value ^= {_xorValue} ^ salt;"); - lines.Add(indent + $"uint value2 = (uint)value >> {_rotateBitNum};"); - lines.Add(indent + $"uint part1 = (uint)value << (32 - {_rotateBitNum});"); - lines.Add(indent + $"value = (int)(value2 | part1);"); - lines.Add(indent + $"value = (value - _secretKey[{_index1}]) * {_revertMultipleValue};"); - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/MultipleRotateXorInstruction.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/MultipleRotateXorInstruction.cs.meta deleted file mode 100644 index 7f4e53a..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/MultipleRotateXorInstruction.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: e3c8b55b35ff1554489fa657a714f485 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/MultipleXorRotateInstruction.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/MultipleXorRotateInstruction.cs deleted file mode 100644 index 9733776..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/MultipleXorRotateInstruction.cs +++ /dev/null @@ -1,68 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Obfuz.EncryptionVM.Instructions -{ - public class MultipleXorRotateInstruction : EncryptionInstructionBase - { - // x = x * p1 + secretKey[index1]; - // x = x ^ p3 ^ salt; - // x = Rotate(x, p2) - - private readonly int _multipleValue; - private readonly int _revertMultipleValue; - private readonly int _index1; - private readonly int _rotateBitNum; - private readonly int _xorValue; - - public MultipleXorRotateInstruction(int multipleValue, int index1, int xorValue, int rotateBitNum) - { - _multipleValue = multipleValue; - _revertMultipleValue = (int)MultipleInstruction.ModInverseOdd((uint)multipleValue); - _index1 = index1; - _rotateBitNum = rotateBitNum; - _xorValue = xorValue; - } - - public override int Encrypt(int value, int[] secretKey, int salt) - { - value = value * _multipleValue + secretKey[_index1]; - value ^= _xorValue ^ salt; - uint part1 = (uint)value << _rotateBitNum; - uint part2 = (uint)value >> (32 - _rotateBitNum); - value = (int)(part1 | part2); - return value; - } - - public override int Decrypt(int value, int[] secretKey, int salt) - { - uint value2 = (uint)value >> _rotateBitNum; - uint part1 = (uint)value << (32 - _rotateBitNum); - value = (int)(value2 | part1); - value ^= _xorValue ^ salt; - value = (value - secretKey[_index1]) * _revertMultipleValue; - return value; - } - - public override void GenerateEncryptCode(List lines, string indent) - { - lines.Add(indent + $"value = value * {_multipleValue} + _secretKey[{_index1}];"); - lines.Add(indent + $"value ^= {_xorValue} ^ salt;"); - lines.Add(indent + $"uint part1 = (uint)value << {_rotateBitNum};"); - lines.Add(indent + $"uint part2 = (uint)value >> (32 - {_rotateBitNum});"); - lines.Add(indent + $"value = (int)(part1 | part2);"); - } - - public override void GenerateDecryptCode(List lines, string indent) - { - lines.Add(indent + $"uint value2 = (uint)value >> {_rotateBitNum};"); - lines.Add(indent + $"uint part1 = (uint)value << (32 - {_rotateBitNum});"); - lines.Add(indent + $"value = (int)(value2 | part1);"); - lines.Add(indent + $"value ^= {_xorValue} ^ salt;"); - lines.Add(indent + $"value = (value - _secretKey[{_index1}]) * {_revertMultipleValue};"); - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/MultipleXorRotateInstruction.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/MultipleXorRotateInstruction.cs.meta deleted file mode 100644 index 0e6a653..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/MultipleXorRotateInstruction.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: adc3dcde66795744fa4bdc753a2c599f -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/XorAddRotateInstruction.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/XorAddRotateInstruction.cs deleted file mode 100644 index 10a9226..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/XorAddRotateInstruction.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Obfuz.EncryptionVM.Instructions -{ - public class XorAddRotateInstruction : EncryptionInstructionBase - { - // x = x ^ p3 ^ salt; - // x = x + p1 + secretKey[index1]; - // x = Rotate(x, p2) - - private readonly int _addValue; - private readonly int _index1; - private readonly int _rotateBitNum; - private readonly int _xorValue; - - public XorAddRotateInstruction(int xorValue, int addValue, int index1, int rotateBitNum) - { - _addValue = addValue; - _index1 = index1; - _rotateBitNum = rotateBitNum; - _xorValue = xorValue; - } - - public override int Encrypt(int value, int[] secretKey, int salt) - { - value ^= _xorValue ^ salt; - value += _addValue + secretKey[_index1]; - uint part1 = (uint)value << _rotateBitNum; - uint part2 = (uint)value >> (32 - _rotateBitNum); - value = (int)(part1 | part2); - return value; - } - - public override int Decrypt(int value, int[] secretKey, int salt) - { - uint value2 = (uint)value >> _rotateBitNum; - uint part1 = (uint)value << (32 - _rotateBitNum); - value = (int)(value2 | part1); - value -= _addValue + secretKey[_index1]; - value ^= _xorValue ^ salt; - return value; - } - - public override void GenerateEncryptCode(List lines, string indent) - { - lines.Add(indent + $"value ^= {_xorValue} ^ salt;"); - lines.Add(indent + $"value += {_addValue} + _secretKey[{_index1}];"); - lines.Add(indent + $"uint part1 = (uint)value << {_rotateBitNum};"); - lines.Add(indent + $"uint part2 = (uint)value >> (32 - {_rotateBitNum});"); - lines.Add(indent + $"value = (int)(part1 | part2);"); - } - - public override void GenerateDecryptCode(List lines, string indent) - { - lines.Add(indent + $"uint value2 = (uint)value >> {_rotateBitNum};"); - lines.Add(indent + $"uint part1 = (uint)value << (32 - {_rotateBitNum});"); - lines.Add(indent + $"value = (int)(value2 | part1);"); - lines.Add(indent + $"value -= {_addValue} + _secretKey[{_index1}];"); - lines.Add(indent + $"value ^= {_xorValue} ^ salt;"); - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/XorAddRotateInstruction.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/XorAddRotateInstruction.cs.meta deleted file mode 100644 index d1a6d08..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/XorAddRotateInstruction.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ad8f4dd724d7ff845b0dd65861054d37 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/XorInstruction.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/XorInstruction.cs deleted file mode 100644 index ec5fb9f..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/XorInstruction.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Collections.Generic; - -namespace Obfuz.EncryptionVM.Instructions -{ - public class XorInstruction : EncryptionInstructionBase - { - private readonly int _xorValue; - private readonly int _opKeyIndex; - - public XorInstruction(int xorValue, int opKeyIndex) - { - _xorValue = xorValue; - _opKeyIndex = opKeyIndex; - } - - public override int Encrypt(int value, int[] secretKey, int salt) - { - return ((value ^ secretKey[_opKeyIndex]) + salt) ^ _xorValue; - } - - public override int Decrypt(int value, int[] secretKey, int salt) - { - return ((value ^ _xorValue) - salt) ^ secretKey[_opKeyIndex]; - } - - public override void GenerateEncryptCode(List lines, string indent) - { - lines.Add(indent + $"value = ((value ^ _secretKey[{_opKeyIndex}]) + salt) ^ {_xorValue};"); - } - - public override void GenerateDecryptCode(List lines, string indent) - { - lines.Add(indent + $"value = ((value ^ {_xorValue}) - salt) ^ _secretKey[{_opKeyIndex}];"); - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/XorInstruction.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/XorInstruction.cs.meta deleted file mode 100644 index e246896..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/XorInstruction.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 2f16dd868e4473b45bfa9daaf7fabaf8 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/XorMultipleRotateInstruction.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/XorMultipleRotateInstruction.cs deleted file mode 100644 index 7a10395..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/XorMultipleRotateInstruction.cs +++ /dev/null @@ -1,68 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Obfuz.EncryptionVM.Instructions -{ - public class XorMultipleRotateInstruction : EncryptionInstructionBase - { - // x = x ^ p3 ^ salt; - // x = x * p1 + secretKey[index1]; - // x = Rotate(x, p2) - - private readonly int _multipleValue; - private readonly int _revertMultipleValue; - private readonly int _index1; - private readonly int _rotateBitNum; - private readonly int _xorValue; - - public XorMultipleRotateInstruction(int xorValue, int multipleValue, int index1, int rotateBitNum) - { - _multipleValue = multipleValue; - _revertMultipleValue = (int)MultipleInstruction.ModInverseOdd((uint)multipleValue); - _index1 = index1; - _rotateBitNum = rotateBitNum; - _xorValue = xorValue; - } - - public override int Encrypt(int value, int[] secretKey, int salt) - { - value ^= _xorValue ^ salt; - value = value * _multipleValue + secretKey[_index1]; - uint part1 = (uint)value << _rotateBitNum; - uint part2 = (uint)value >> (32 - _rotateBitNum); - value = (int)(part1 | part2); - return value; - } - - public override int Decrypt(int value, int[] secretKey, int salt) - { - uint value2 = (uint)value >> _rotateBitNum; - uint part1 = (uint)value << (32 - _rotateBitNum); - value = (int)(value2 | part1); - value = (value - secretKey[_index1]) * _revertMultipleValue; - value ^= _xorValue ^ salt; - return value; - } - - public override void GenerateEncryptCode(List lines, string indent) - { - lines.Add(indent + $"value ^= {_xorValue} ^ salt;"); - lines.Add(indent + $"value = value * {_multipleValue} + _secretKey[{_index1}];"); - lines.Add(indent + $"uint part1 = (uint)value << {_rotateBitNum};"); - lines.Add(indent + $"uint part2 = (uint)value >> (32 - {_rotateBitNum});"); - lines.Add(indent + $"value = (int)(part1 | part2);"); - } - - public override void GenerateDecryptCode(List lines, string indent) - { - lines.Add(indent + $"uint value2 = (uint)value >> {_rotateBitNum};"); - lines.Add(indent + $"uint part1 = (uint)value << (32 - {_rotateBitNum});"); - lines.Add(indent + $"value = (int)(value2 | part1);"); - lines.Add(indent + $"value = (value - _secretKey[{_index1}]) * {_revertMultipleValue};"); - lines.Add(indent + $"value ^= {_xorValue} ^ salt;"); - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/XorMultipleRotateInstruction.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/XorMultipleRotateInstruction.cs.meta deleted file mode 100644 index e95af06..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/Instructions/XorMultipleRotateInstruction.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 3eb7e6d475cfc14459d3850c5964ba52 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/VirtualMachine.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/VirtualMachine.cs deleted file mode 100644 index 1ca1a59..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/VirtualMachine.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace Obfuz.EncryptionVM -{ - public class VirtualMachine - { - public const int SecretKeyLength = 1024; - - public readonly int version; - public readonly string codeGenerationSecretKey; - public readonly EncryptionInstructionWithOpCode[] opCodes; - - public VirtualMachine(int version, string codeGenerationSecretKey, EncryptionInstructionWithOpCode[] opCodes) - { - this.codeGenerationSecretKey = codeGenerationSecretKey; - this.opCodes = opCodes; - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/VirtualMachine.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/VirtualMachine.cs.meta deleted file mode 100644 index e932d33..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/VirtualMachine.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c6970e037654dcb49912783a40f3e1ba -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/VirtualMachineCodeGenerator.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/VirtualMachineCodeGenerator.cs deleted file mode 100644 index b05f000..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/VirtualMachineCodeGenerator.cs +++ /dev/null @@ -1,207 +0,0 @@ -using Obfuz.Utils; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Text.RegularExpressions; -using System.Threading.Tasks; -using UnityEngine; - -namespace Obfuz.EncryptionVM -{ - public class VirtualMachineCodeGenerator - { - private readonly int _opCodeCount; - private readonly int _opCodeBits; - private readonly VirtualMachine _vm; - - public VirtualMachineCodeGenerator(string vmCodeGenerateSecretKey, int opCodeCount) - { - _opCodeCount = opCodeCount; - _opCodeBits = EncryptionUtil.GetBitCount(opCodeCount - 1); - _vm = new VirtualMachineCreator(vmCodeGenerateSecretKey).CreateVirtualMachine(opCodeCount); - } - - public VirtualMachineCodeGenerator(VirtualMachine vm) - { - _opCodeCount = vm.opCodes.Length; - _opCodeBits = EncryptionUtil.GetBitCount(_opCodeCount - 1); - _vm = vm; - } - - - public bool ValidateMatch(string outputFile) - { - if (!File.Exists(outputFile)) - { - return false; - } - string oldCode = NormalizeText(File.ReadAllText(outputFile, Encoding.UTF8)); - string newCode = NormalizeText(GenerateCode()); - return oldCode == newCode; - } - - private static string NormalizeText(string input) - { - return Regex.Replace(input, @"\s+", string.Empty); - } - - public void Generate(string outputFile) - { - FileUtil.CreateParentDir(outputFile); - - string code = GenerateCode(); - - File.WriteAllText(outputFile, code, Encoding.UTF8); - Debug.Log($"Generate EncryptionVM code to {outputFile}"); - UnityEditor.AssetDatabase.Refresh(); - } - - private string GenerateCode() - { - var lines = new List(); - AppendHeader(lines); - AppendEncryptCodes(lines); - AppendDecryptCodes(lines); - AppendTailer(lines); - return string.Join("\n", lines); - } - - private void AppendEncryptCodes(List lines) - { - lines.Add(@" - private int ExecuteEncrypt(int value, int opCode, int salt) - { - switch (opCode) - {"); - foreach (var opCode in _vm.opCodes) - { - lines.Add($@" case {opCode.code}: - {{ - // {opCode.function.GetType().Name}"); - AppendEncryptCode(lines, opCode.function); - lines.Add(@" return value; - }"); - } - - lines.Add(@" - default: - throw new System.Exception($""Invalid opCode:{opCode}""); - } - }"); - } - - private void AppendDecryptCodes(List lines) - { - lines.Add(@" - private int ExecuteDecrypt(int value, int opCode, int salt) - { - switch (opCode) - {"); - foreach (var opCode in _vm.opCodes) - { - lines.Add($@" case {opCode.code}: - {{ - // {opCode.function.GetType().Name}"); - AppendDecryptCode(lines, opCode.function); - lines.Add(@" return value; - }"); - } - - lines.Add(@" - default: - throw new System.Exception($""Invalid opCode:{opCode}""); - } - }"); - } - - private void AppendHeader(List lines) - { - - lines.Add($"/// This file is auto-generated by Obfuz. Do not modify it."); - lines.Add($"///"); - //lines.Add($"/// Created Time: {DateTime.Now}"); - - lines.Add($"/// Version: {_vm.version}"); - lines.Add($"/// SecretKey: {_vm.codeGenerationSecretKey}"); - lines.Add($"/// OpCodeCount: {_vm.opCodes.Length}"); - - lines.Add(@" -namespace Obfuz.EncryptionVM -{ - public class GeneratedEncryptionVirtualMachine : Obfuz.EncryptorBase - {"); - lines.Add($@" - private const int kOpCodeBits = {_opCodeBits}; - - private const int kOpCodeCount = {_opCodeCount}; - - private const int kOpCodeMask = {_opCodeCount - 1}; -"); - lines.Add(@" - - private readonly int[] _secretKey; - - public GeneratedEncryptionVirtualMachine(byte[] secretKey) - { - this._secretKey = ConvertToIntKey(secretKey); - } - - public override int OpCodeCount => kOpCodeCount; - - public override int Encrypt(int value, int opts, int salt) - { - uint uopts = (uint)opts; - uint revertOps = 0; - while (uopts != 0) - { - uint opCode = uopts & kOpCodeMask; - revertOps <<= kOpCodeBits; - revertOps |= opCode; - uopts >>= kOpCodeBits; - } - - while (revertOps != 0) - { - uint opCode = revertOps & kOpCodeMask; - value = ExecuteEncrypt(value, (int)opCode, salt); - revertOps >>= kOpCodeBits; - } - return value; - } - - public override int Decrypt(int value, int opts, int salt) - { - uint uopts = (uint)opts; - while (uopts != 0) - { - uint opCode = uopts & kOpCodeMask; - value = ExecuteDecrypt(value, (int)opCode, salt); - uopts >>= kOpCodeBits; - } - return value; - } -"); - } - - private void AppendTailer(List lines) - { - lines.Add(@" - } -} - -"); - } - - private void AppendEncryptCode(List lines, IEncryptionInstruction instruction) - { - instruction.GenerateEncryptCode(lines, " "); - } - - private void AppendDecryptCode(List lines, IEncryptionInstruction instruction) - { - instruction.GenerateDecryptCode(lines, " "); - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/VirtualMachineCodeGenerator.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/VirtualMachineCodeGenerator.cs.meta deleted file mode 100644 index 956402c..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/VirtualMachineCodeGenerator.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 2246e9d3369eb3c45bc19ae0748d76ba -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/VirtualMachineCreator.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/VirtualMachineCreator.cs deleted file mode 100644 index 8035ad0..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/VirtualMachineCreator.cs +++ /dev/null @@ -1,71 +0,0 @@ -using NUnit.Framework; -using Obfuz.EncryptionVM.Instructions; -using Obfuz.Utils; -using System; -using System.Collections.Generic; -using UnityEngine.Assertions; -using UnityEngine.UIElements; - -namespace Obfuz.EncryptionVM -{ - public class VirtualMachineCreator - { - private readonly string _vmGenerationSecretKey; - private readonly IRandom _random; - - public const int CodeGenerationSecretKeyLength = 1024; - - public const int VirtualMachineVersion = 1; - - public VirtualMachineCreator(string vmGenerationSecretKey) - { - _vmGenerationSecretKey = vmGenerationSecretKey; - byte[] byteGenerationSecretKey = KeyGenerator.GenerateKey(vmGenerationSecretKey, CodeGenerationSecretKeyLength); - int[] intGenerationSecretKey = KeyGenerator.ConvertToIntKey(byteGenerationSecretKey); - _random = new RandomWithKey(intGenerationSecretKey, 0); - } - - private readonly List> _instructionCreators = new List> - { - (r, len) => new AddInstruction(r.NextInt(), r.NextInt(len)), - (r, len) => new XorInstruction(r.NextInt(), r.NextInt(len)), - (r, len) => new BitRotateInstruction(r.NextInt(32), r.NextInt(len)), - (r, len) => new MultipleInstruction(r.NextInt() | 0x1, r.NextInt(len)), - (r, len) => new AddRotateXorInstruction(r.NextInt(), r.NextInt(len), r.NextInt(32), r.NextInt()), - (r, len) => new AddXorRotateInstruction(r.NextInt(), r.NextInt(len), r.NextInt(), r.NextInt(32)), - (r, len) => new XorAddRotateInstruction(r.NextInt(), r.NextInt(), r.NextInt(len), r.NextInt(32)), - (r, len) => new MultipleRotateXorInstruction(r.NextInt() | 0x1, r.NextInt(len), r.NextInt(32), r.NextInt()), - (r, len) => new MultipleXorRotateInstruction(r.NextInt() | 0x1, r.NextInt(len), r.NextInt(), r.NextInt(32)), - (r, len) => new XorMultipleRotateInstruction(r.NextInt(), r.NextInt() | 0x1, r.NextInt(len), r.NextInt(32)), - }; - - private IEncryptionInstruction CreateRandomInstruction(int intSecretKeyLength) - { - return _instructionCreators[_random.NextInt(_instructionCreators.Count)](_random, intSecretKeyLength); - } - - private EncryptionInstructionWithOpCode CreateEncryptOpCode(ushort code) - { - IEncryptionInstruction inst = CreateRandomInstruction(VirtualMachine.SecretKeyLength / sizeof(int)); - return new EncryptionInstructionWithOpCode(code, inst); - } - - public VirtualMachine CreateVirtualMachine(int opCodeCount) - { - if (opCodeCount < 64) - { - throw new System.Exception("OpCode count should be >= 64"); - } - if ((opCodeCount & (opCodeCount - 1)) != 0) - { - throw new System.Exception("OpCode count should be power of 2"); - } - var opCodes = new EncryptionInstructionWithOpCode[opCodeCount]; - for (int i = 0; i < opCodes.Length; i++) - { - opCodes[i] = CreateEncryptOpCode((ushort)i); - } - return new VirtualMachine(VirtualMachineVersion, _vmGenerationSecretKey, opCodes); - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/VirtualMachineCreator.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/VirtualMachineCreator.cs.meta deleted file mode 100644 index 3124bb7..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/VirtualMachineCreator.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 77d95ff5cf0b3aa4e96a055e37c381ba -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/VirtualMachineSimulator.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/VirtualMachineSimulator.cs deleted file mode 100644 index a8e25c8..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/VirtualMachineSimulator.cs +++ /dev/null @@ -1,96 +0,0 @@ -using Obfuz.Utils; -using System; -using System.Collections.Generic; -using System.Linq.Expressions; -using System.Runtime.CompilerServices; -using System.Text; -using UnityEngine; -using UnityEngine.Assertions; -using UnityEngine.UIElements; - -namespace Obfuz.EncryptionVM -{ - - public class VirtualMachineSimulator : EncryptorBase - { - private readonly EncryptionInstructionWithOpCode[] _opCodes; - private readonly int[] _secretKey; - - public override int OpCodeCount => _opCodes.Length; - - public VirtualMachineSimulator(VirtualMachine vm, byte[] byteSecretKey) - { - _opCodes = vm.opCodes; - _secretKey = KeyGenerator.ConvertToIntKey(byteSecretKey); - - VerifyInstructions(); - } - - private void VerifyInstructions() - { - int value = 0x11223344; - for (int i = 0; i < _opCodes.Length; i++) - { - int encryptedValue = _opCodes[i].Encrypt(value, _secretKey, i); - int decryptedValue = _opCodes[i].Decrypt(encryptedValue, _secretKey, i); - //Debug.Log($"instruction type:{_opCodes[i].function.GetType()}"); - Assert.AreEqual(value, decryptedValue); - } - - int ops = 11223344; - int salt = 789; - Assert.AreEqual(1, Decrypt(Encrypt(1, ops, salt), ops, salt)); - Assert.AreEqual(1L, Decrypt(Encrypt(1L, ops, salt), ops, salt)); - Assert.AreEqual(1.0f, Decrypt(Encrypt(1.0f, ops, salt), ops, salt)); - Assert.AreEqual(1.0, Decrypt(Encrypt(1.0, ops, salt), ops, salt)); - - byte[] strBytes = Encrypt("abcdef", ops, salt); - Assert.AreEqual("abcdef", DecryptString(strBytes, 0, strBytes.Length, ops, salt)); - var arr = new byte[100]; - for (int i = 0; i < arr.Length ; i++) - { - arr[i] = (byte)i; - } - EncryptBlock(arr, ops, salt); - DecryptBlock(arr, ops, salt); - for (int i = 0; i < arr.Length; i++) - { - Assert.AreEqual(i, arr[i]); - } - } - - private List DecodeOps(uint ops) - { - var codes = new List(); - while (ops != 0) - { - uint code = ops % (uint)_opCodes.Length; - codes.Add(code); - ops /= (uint)_opCodes.Length; - } - return codes; - } - - public override int Encrypt(int value, int ops, int salt) - { - var codes = DecodeOps((uint)ops); - for (int i = codes.Count - 1; i >= 0; i--) - { - var opCode = _opCodes[codes[i]]; - value = opCode.Encrypt(value, _secretKey, salt); - } - return value; - } - - public override int Decrypt(int value, int ops, int salt) - { - var codes = DecodeOps((uint)ops); - foreach (var code in codes) - { - var opCode = _opCodes[code]; - value = opCode.Decrypt(value, _secretKey, salt); - } - return value; - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/VirtualMachineSimulator.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/VirtualMachineSimulator.cs.meta deleted file mode 100644 index 532a498..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/EncryptionVM/VirtualMachineSimulator.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4f86f4d6faf49764a915d5c675091375 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/IObfuscationPass.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/IObfuscationPass.cs deleted file mode 100644 index 16d875f..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/IObfuscationPass.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Obfuz.ObfusPasses; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Obfuz -{ - public interface IObfuscationPass - { - ObfuscationPassType Type { get; } - - void Start(); - - void Stop(); - - void Process(); - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/IObfuscationPass.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/IObfuscationPass.cs.meta deleted file mode 100644 index cd501ad..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/IObfuscationPass.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: b7003f9503025794b8aa775d9ade335c -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses.meta deleted file mode 100644 index ed7f92c..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 120b2dcffd582e84dbb92003240824d1 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/BasicBlockObfuscationPassBase.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/BasicBlockObfuscationPassBase.cs deleted file mode 100644 index 916a9ef..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/BasicBlockObfuscationPassBase.cs +++ /dev/null @@ -1,87 +0,0 @@ -using dnlib.DotNet.Emit; -using dnlib.DotNet; -using System.Collections.Generic; -using System.Linq; -using Obfuz.Emit; - -namespace Obfuz.ObfusPasses -{ - public abstract class BasicBlockObfuscationPassBase : ObfuscationPassBase - { - protected abstract bool NeedObfuscateMethod(MethodDef method); - - public override void Process() - { - var ctx = ObfuscationPassContext.Current; - ObfuscationMethodWhitelist whiteList = ctx.whiteList; - ConfigurablePassPolicy passPolicy = ctx.passPolicy; - foreach (ModuleDef mod in ctx.modulesToObfuscate) - { - if (whiteList.IsInWhiteList(mod) || !Support(passPolicy.GetAssemblyObfuscationPasses(mod))) - { - continue; - } - // ToArray to avoid modify list exception - foreach (TypeDef type in mod.GetTypes().ToArray()) - { - if (whiteList.IsInWhiteList(type) || !Support(passPolicy.GetTypeObfuscationPasses(type))) - { - continue; - } - // ToArray to avoid modify list exception - foreach (MethodDef method in type.Methods.ToArray()) - { - if (!method.HasBody || ctx.whiteList.IsInWhiteList(method) || !Support(passPolicy.GetMethodObfuscationPasses(method)) || !NeedObfuscateMethod(method)) - { - continue; - } - // TODO if isGeneratedBy Obfuscator, continue - ObfuscateData(method); - } - } - } - } - - - protected abstract bool TryObfuscateInstruction(MethodDef callingMethod, Instruction inst, BasicBlock block, int instructionIndex, - IList globalInstructions, List outputInstructions, List totalFinalInstructions); - - private void ObfuscateData(MethodDef method) - { - BasicBlockCollection bbc = new BasicBlockCollection(method); - - IList instructions = method.Body.Instructions; - - var outputInstructions = new List(); - var totalFinalInstructions = new List(); - for (int i = 0; i < instructions.Count; i++) - { - Instruction inst = instructions[i]; - BasicBlock block = bbc.GetBasicBlockByInstruction(inst); - outputInstructions.Clear(); - if (TryObfuscateInstruction(method, inst, block, i, instructions, outputInstructions, totalFinalInstructions)) - { - // current instruction may be the target of control flow instruction, so we can't remove it directly. - // we replace it with nop now, then remove it in CleanUpInstructionPass - inst.OpCode = outputInstructions[0].OpCode; - inst.Operand = outputInstructions[0].Operand; - totalFinalInstructions.Add(inst); - for (int k = 1; k < outputInstructions.Count; k++) - { - totalFinalInstructions.Add(outputInstructions[k]); - } - } - else - { - totalFinalInstructions.Add(inst); - } - } - - instructions.Clear(); - foreach (var obInst in totalFinalInstructions) - { - instructions.Add(obInst); - } - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/BasicBlockObfuscationPassBase.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/BasicBlockObfuscationPassBase.cs.meta deleted file mode 100644 index 027d02b..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/BasicBlockObfuscationPassBase.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ae83aaf003665614092aabceabff3cf8 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CallObfus.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CallObfus.meta deleted file mode 100644 index a5ed333..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CallObfus.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: cf68e45551825c547b137f6e5189937e -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CallObfus/CallObfusPass.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CallObfus/CallObfusPass.cs deleted file mode 100644 index 9b32359..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CallObfus/CallObfusPass.cs +++ /dev/null @@ -1,92 +0,0 @@ -using dnlib.DotNet; -using dnlib.DotNet.Emit; -using Obfuz.Utils; -using Obfuz.Emit; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.CompilerServices; -using System.Text; -using System.Threading.Tasks; -using UnityEngine.Assertions; -using Obfuz.Settings; - -namespace Obfuz.ObfusPasses.CallObfus -{ - public class CallObfusPass : BasicBlockObfuscationPassBase - { - private readonly List _configFiles; - private readonly int _obfuscationLevel; - private IObfuscator _dynamicProxyObfuscator; - private IObfuscationPolicy _dynamicProxyPolicy; - - public override ObfuscationPassType Type => ObfuscationPassType.CallObfus; - - public CallObfusPass(CallObfuscationSettings settings) - { - _configFiles = settings.ruleFiles.ToList(); - _obfuscationLevel = settings.obfuscationLevel; - } - - public override void Stop() - { - _dynamicProxyObfuscator.Done(); - } - - public override void Start() - { - var ctx = ObfuscationPassContext.Current; - _dynamicProxyObfuscator = new DefaultCallProxyObfuscator(ctx.encryptionScopeProvider, ctx.constFieldAllocator, ctx.moduleEntityManager, _obfuscationLevel); - _dynamicProxyPolicy = new ConfigurableObfuscationPolicy(ctx.assembliesToObfuscate, _configFiles); - } - - protected override bool NeedObfuscateMethod(MethodDef method) - { - return _dynamicProxyPolicy.NeedObfuscateCallInMethod(method); - } - - protected override bool TryObfuscateInstruction(MethodDef callerMethod, Instruction inst, BasicBlock block, - int instructionIndex, IList globalInstructions, List outputInstructions, List totalFinalInstructions) - { - IMethod calledMethod = inst.Operand as IMethod; - if (calledMethod == null || !calledMethod.IsMethod) - { - return false; - } - if (MetaUtil.ContainsContainsGenericParameter(calledMethod)) - { - return false; - } - - bool callVir; - switch (inst.OpCode.Code) - { - case Code.Call: - { - callVir = false; - break; - } - case Code.Callvirt: - { - if (instructionIndex > 0 && globalInstructions[instructionIndex - 1].OpCode.Code == Code.Constrained) - { - return false; - } - callVir = true; - break; - } - default: return false; - } - - if (!_dynamicProxyPolicy.NeedObfuscateCalledMethod(callerMethod, calledMethod, callVir, block.inLoop)) - { - return false; - } - - ObfuscationCachePolicy cachePolicy = _dynamicProxyPolicy.GetMethodObfuscationCachePolicy(callerMethod); - bool cachedCallIndex = block.inLoop ? cachePolicy.cacheInLoop : cachePolicy.cacheNotInLoop; - _dynamicProxyObfuscator.Obfuscate(callerMethod, calledMethod, callVir, cachedCallIndex, outputInstructions); - return true; - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CallObfus/CallObfusPass.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CallObfus/CallObfusPass.cs.meta deleted file mode 100644 index b15eb81..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CallObfus/CallObfusPass.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 112178b770868274fb8119a4997a3420 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CallObfus/CallProxyAllocator.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CallObfus/CallProxyAllocator.cs deleted file mode 100644 index 1164db6..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CallObfus/CallProxyAllocator.cs +++ /dev/null @@ -1,293 +0,0 @@ -using dnlib.DotNet; -using dnlib.DotNet.Emit; -using Obfuz.Editor; -using Obfuz.Emit; -using Obfuz.Utils; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using MethodImplAttributes = dnlib.DotNet.MethodImplAttributes; -using TypeAttributes = dnlib.DotNet.TypeAttributes; - -namespace Obfuz.ObfusPasses.CallObfus -{ - public struct ProxyCallMethodData - { - public readonly MethodDef proxyMethod; - public readonly int encryptOps; - public readonly int salt; - public readonly int encryptedIndex; - public readonly int index; - - public ProxyCallMethodData(MethodDef proxyMethod, int encryptOps, int salt, int encryptedIndex, int index) - { - this.proxyMethod = proxyMethod; - this.encryptOps = encryptOps; - this.salt = salt; - this.encryptedIndex = encryptedIndex; - this.index = index; - } - } - - class ModuleCallProxyAllocator : IGroupByModuleEntity - { - private ModuleDef _module; - private readonly EncryptionScopeProvider _encryptionScopeProvider; - private readonly int _encryptionLevel; - - private EncryptionScopeInfo _encryptionScope; - private bool _done; - - class MethodKey : IEquatable - { - public readonly IMethod _method; - public readonly bool _callVir; - private readonly int _hashCode; - - public MethodKey(IMethod method, bool callVir) - { - _method = method; - _callVir = callVir; - _hashCode = HashUtil.CombineHash(MethodEqualityComparer.CompareDeclaringTypes.GetHashCode(method), callVir ? 1 : 0); - } - - public override int GetHashCode() - { - return _hashCode; - } - - public bool Equals(MethodKey other) - { - return MethodEqualityComparer.CompareDeclaringTypes.Equals(_method, other._method) && _callVir == other._callVir; - } - } - - class MethodProxyInfo - { - public MethodDef proxyMethod; - - public int index; - public int encryptedOps; - public int salt; - public int encryptedIndex; - } - - private readonly Dictionary _methodProxys = new Dictionary(); - - - const int maxProxyMethodPerDispatchMethod = 1000; - - class CallInfo - { - public IMethod method; - public bool callVir; - } - - class DispatchMethodInfo - { - public MethodDef methodDef; - public List methods = new List(); - } - - private readonly Dictionary> _dispatchMethods = new Dictionary>(SignatureEqualityComparer.Instance); - - - private TypeDef _proxyTypeDef; - - public ModuleCallProxyAllocator(EncryptionScopeProvider encryptionScopeProvider, int encryptionLevel) - { - _encryptionScopeProvider = encryptionScopeProvider; - _encryptionLevel = encryptionLevel; - } - - public void Init(ModuleDef mod) - { - _module = mod; - _encryptionScope = _encryptionScopeProvider.GetScope(mod); - } - - private TypeDef CreateProxyTypeDef() - { - var typeDef = new TypeDefUser($"{ConstValues.ObfuzInternalSymbolNamePrefix}ProxyCall", _module.CorLibTypes.Object.ToTypeDefOrRef()); - typeDef.Attributes = TypeAttributes.NotPublic | TypeAttributes.Sealed; - _module.EnableTypeDefFindCache = false; - _module.Types.Add(typeDef); - _module.EnableTypeDefFindCache = true; - return typeDef; - } - - private MethodDef CreateDispatchMethodInfo(MethodSig methodSig) - { - if (_proxyTypeDef == null) - { - _proxyTypeDef = CreateProxyTypeDef(); - } - MethodDef methodDef = new MethodDefUser($"{ConstValues.ObfuzInternalSymbolNamePrefix}ProxyCall$Dispatch${_proxyTypeDef.Methods.Count}", methodSig, - MethodImplAttributes.IL | MethodImplAttributes.Managed, - MethodAttributes.Static | MethodAttributes.Public); - methodDef.DeclaringType = _proxyTypeDef; - return methodDef; - } - - private MethodSig CreateDispatchMethodSig(IMethod method) - { - MethodSig methodSig = MetaUtil.ToSharedMethodSig(_module.CorLibTypes, MetaUtil.GetInflatedMethodSig(method)); - //MethodSig methodSig = MetaUtil.GetInflatedMethodSig(method).Clone(); - //methodSig.Params - switch (MetaUtil.GetThisArgType(method)) - { - case ThisArgType.Class: - { - methodSig.Params.Insert(0, _module.CorLibTypes.Object); - break; - } - case ThisArgType.ValueType: - { - methodSig.Params.Insert(0, _module.CorLibTypes.IntPtr); - break; - } - } - // extra param for index - methodSig.Params.Add(_module.CorLibTypes.Int32); - return MethodSig.CreateStatic(methodSig.RetType, methodSig.Params.ToArray()); - } - - private int GenerateSalt(IRandom random) - { - return random.NextInt(); - } - - private int GenerateEncryptOps(IRandom random) - { - return EncryptionUtil.GenerateEncryptionOpCodes(random, _encryptionScope.encryptor, _encryptionLevel); - } - - private DispatchMethodInfo GetDispatchMethod(IMethod method) - { - MethodSig methodSig = CreateDispatchMethodSig(method); - if (!_dispatchMethods.TryGetValue(methodSig, out var dispatchMethods)) - { - dispatchMethods = new List(); - _dispatchMethods.Add(methodSig, dispatchMethods); - } - if (dispatchMethods.Count == 0 || dispatchMethods.Last().methods.Count >= maxProxyMethodPerDispatchMethod) - { - var newDispatchMethodInfo = new DispatchMethodInfo - { - methodDef = CreateDispatchMethodInfo(methodSig), - }; - dispatchMethods.Add(newDispatchMethodInfo); - } - return dispatchMethods.Last(); - } - - private IRandom CreateRandomForMethod(IMethod method, bool callVir) - { - int seed = MethodEqualityComparer.CompareDeclaringTypes.GetHashCode(method); - return _encryptionScope.localRandomCreator(seed); - } - - public ProxyCallMethodData Allocate(IMethod method, bool callVir) - { - if (_done) - { - throw new Exception("can't Allocate after done"); - } - var key = new MethodKey(method, callVir); - if (!_methodProxys.TryGetValue(key, out var proxyInfo)) - { - var methodDispatcher = GetDispatchMethod(method); - - int index = methodDispatcher.methods.Count; - IRandom localRandom = CreateRandomForMethod(method, callVir); - int encryptOps = GenerateEncryptOps(localRandom); - int salt = GenerateSalt(localRandom); - int encryptedIndex = _encryptionScope.encryptor.Encrypt(index, encryptOps, salt); - proxyInfo = new MethodProxyInfo() - { - proxyMethod = methodDispatcher.methodDef, - index = index, - encryptedOps = encryptOps, - salt = salt, - encryptedIndex = encryptedIndex, - }; - methodDispatcher.methods.Add(new CallInfo { method = method, callVir = callVir}); - _methodProxys.Add(key, proxyInfo); - } - return new ProxyCallMethodData(proxyInfo.proxyMethod, proxyInfo.encryptedOps, proxyInfo.salt, proxyInfo.encryptedIndex, proxyInfo.index); - } - - public void Done() - { - if (_done) - { - throw new Exception("Already done"); - } - _done = true; - - foreach (DispatchMethodInfo dispatchMethod in _dispatchMethods.Values.SelectMany(ms => ms)) - { - var methodDef = dispatchMethod.methodDef; - var methodSig = methodDef.MethodSig; - - - var body = new CilBody(); - methodDef.Body = body; - var ins = body.Instructions; - - foreach (Parameter param in methodDef.Parameters) - { - ins.Add(Instruction.Create(OpCodes.Ldarg, param)); - } - - var switchCases = new List(); - var switchInst = Instruction.Create(OpCodes.Switch, switchCases); - ins.Add(switchInst); - var ret = Instruction.Create(OpCodes.Ret); - foreach (CallInfo ci in dispatchMethod.methods) - { - var callTargetMethod = Instruction.Create(ci.callVir ? OpCodes.Callvirt : OpCodes.Call, ci.method); - switchCases.Add(callTargetMethod); - ins.Add(callTargetMethod); - ins.Add(Instruction.Create(OpCodes.Br, ret)); - } - ins.Add(ret); - } - } - } - - public class CallProxyAllocator - { - private readonly EncryptionScopeProvider _encryptionScopeProvider; - private GroupByModuleEntityManager _moduleEntityManager; - private readonly int _encryptionLevel; - - public CallProxyAllocator(EncryptionScopeProvider encryptionScopeProvider, GroupByModuleEntityManager moduleEntityManager, int encryptionLevel) - { - _encryptionScopeProvider = encryptionScopeProvider; - _moduleEntityManager = moduleEntityManager; - _encryptionLevel = encryptionLevel; - } - - private ModuleCallProxyAllocator GetModuleAllocator(ModuleDef mod) - { - return _moduleEntityManager.GetEntity(mod, () => new ModuleCallProxyAllocator(_encryptionScopeProvider, _encryptionLevel)); - } - - public ProxyCallMethodData Allocate(ModuleDef mod, IMethod method, bool callVir) - { - ModuleCallProxyAllocator allocator = GetModuleAllocator(mod); - return allocator.Allocate(method, callVir); - } - - public void Done() - { - foreach (var allocator in _moduleEntityManager.GetEntities()) - { - allocator.Done(); - } - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CallObfus/CallProxyAllocator.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CallObfus/CallProxyAllocator.cs.meta deleted file mode 100644 index a6a06f8..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CallObfus/CallProxyAllocator.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 16b960455f093854d927c2dbd47a4826 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CallObfus/ConfigurableObfuscationPolicy.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CallObfus/ConfigurableObfuscationPolicy.cs deleted file mode 100644 index 4deb16a..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CallObfus/ConfigurableObfuscationPolicy.cs +++ /dev/null @@ -1,411 +0,0 @@ -using dnlib.DotNet; -using Obfuz.Conf; -using Obfuz.Utils; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Xml; -using UnityEngine; - -namespace Obfuz.ObfusPasses.CallObfus -{ - public class ConfigurableObfuscationPolicy : ObfuscationPolicyBase - { - class WhiteListAssembly - { - public string name; - public NameMatcher nameMatcher; - public bool? obfuscate; - public List types = new List(); - } - - class WhiteListType - { - public string name; - public NameMatcher nameMatcher; - public bool? obfuscate; - public List methods = new List(); - } - - class WhiteListMethod - { - public string name; - public NameMatcher nameMatcher; - public bool? obfuscate; - } - - class ObfuscationRule : IRule - { - public bool? disableObfuscation; - public bool? obfuscateCallInLoop; - public bool? cacheCallIndexInLoop; - public bool? cacheCallIndexNotLoop; - - public void InheritParent(ObfuscationRule parentRule) - { - if (disableObfuscation == null) - { - disableObfuscation = parentRule.disableObfuscation; - } - if (obfuscateCallInLoop == null) - { - obfuscateCallInLoop = parentRule.obfuscateCallInLoop; - } - if (cacheCallIndexInLoop == null) - { - cacheCallIndexInLoop = parentRule.cacheCallIndexInLoop; - } - if (cacheCallIndexNotLoop == null) - { - cacheCallIndexNotLoop = parentRule.cacheCallIndexNotLoop; - } - } - } - - class AssemblySpec : AssemblyRuleBase - { - } - - class TypeSpec : TypeRuleBase - { - } - - class MethodSpec : MethodRuleBase - { - - } - - private static readonly ObfuscationRule s_default = new ObfuscationRule() - { - disableObfuscation = false, - obfuscateCallInLoop = true, - cacheCallIndexInLoop = true, - cacheCallIndexNotLoop = false, - }; - - private readonly XmlAssemblyTypeMethodRuleParser _configParser; - - private ObfuscationRule _global; - private readonly List _whiteListAssemblies = new List(); - - private readonly Dictionary _whiteListMethodCache = new Dictionary(MethodEqualityComparer.CompareDeclaringTypes); - private readonly Dictionary _methodRuleCache = new Dictionary(); - - public ConfigurableObfuscationPolicy(List toObfuscatedAssemblyNames, List xmlConfigFiles) - { - _configParser = new XmlAssemblyTypeMethodRuleParser(toObfuscatedAssemblyNames, - ParseObfuscationRule, ParseGlobalElement); - LoadConfigs(xmlConfigFiles); - } - - private void LoadConfigs(List configFiles) - { - _configParser.LoadConfigs(configFiles); - - if (_global == null) - { - _global = s_default; - } - else - { - _global.InheritParent(s_default); - } - _configParser.InheritParentRules(_global); - InheritWhitelistRules(); - } - - private void InheritWhitelistRules() - { - foreach (var ass in _whiteListAssemblies) - { - foreach (var type in ass.types) - { - if (type.obfuscate == null) - { - type.obfuscate = ass.obfuscate; - } - foreach (var method in type.methods) - { - if (method.obfuscate == null) - { - method.obfuscate = type.obfuscate; - } - } - } - } - } - - private void ParseGlobalElement(string configFile, XmlElement ele) - { - switch (ele.Name) - { - case "global": _global = ParseObfuscationRule(configFile, ele); break; - case "whitelist": ParseWhitelist(ele); break; - default: throw new Exception($"Invalid xml file {configFile}, unknown node {ele.Name}"); - } - } - - private ObfuscationRule ParseObfuscationRule(string configFile, XmlElement ele) - { - var rule = new ObfuscationRule(); - if (ele.HasAttribute("disableObfuscation")) - { - rule.disableObfuscation = ConfigUtil.ParseBool(ele.GetAttribute("disableObfuscation")); - } - if (ele.HasAttribute("obfuscateCallInLoop")) - { - rule.obfuscateCallInLoop = ConfigUtil.ParseBool(ele.GetAttribute("obfuscateCallInLoop")); - } - if (ele.HasAttribute("cacheCallIndexInLoop")) - { - rule.cacheCallIndexInLoop = ConfigUtil.ParseBool(ele.GetAttribute("cacheCallIndexInLoop")); - } - if (ele.HasAttribute("cacheCallIndexNotLoop")) - { - rule.cacheCallIndexNotLoop = ConfigUtil.ParseBool(ele.GetAttribute("cacheCallIndexNotLoop")); - } - return rule; - } - - private void ParseWhitelist(XmlElement ruleEle) - { - foreach (XmlNode xmlNode in ruleEle.ChildNodes) - { - if (!(xmlNode is XmlElement childEle)) - { - continue; - } - switch (childEle.Name) - { - case "assembly": - { - var ass = ParseWhiteListAssembly(childEle); - _whiteListAssemblies.Add(ass); - break; - } - default: throw new Exception($"Invalid xml file, unknown node {childEle.Name}"); - } - } - } - - private WhiteListAssembly ParseWhiteListAssembly(XmlElement element) - { - var ass = new WhiteListAssembly(); - ass.name = element.GetAttribute("name"); - ass.nameMatcher = new NameMatcher(ass.name); - - ass.obfuscate = ConfigUtil.ParseNullableBool(element.GetAttribute("obfuscate")) ?? false; - - foreach (XmlNode node in element.ChildNodes) - { - if (!(node is XmlElement ele)) - { - continue; - } - switch (ele.Name) - { - case "type": - ass.types.Add(ParseWhiteListType(ele)); - break; - default: - throw new Exception($"Invalid xml file, unknown node {ele.Name}"); - } - } - return ass; - } - - private WhiteListType ParseWhiteListType(XmlElement element) - { - var type = new WhiteListType(); - type.name = element.GetAttribute("name"); - type.nameMatcher = new NameMatcher(type.name); - type.obfuscate = ConfigUtil.ParseNullableBool(element.GetAttribute("obfuscate")); - - foreach (XmlNode node in element.ChildNodes) - { - if (!(node is XmlElement ele)) - { - continue; - } - switch (ele.Name) - { - case "method": - { - type.methods.Add(ParseWhiteListMethod(ele)); - break; - } - default: throw new Exception($"Invalid xml file, unknown node {ele.Name}"); - } - } - - return type; - } - - private WhiteListMethod ParseWhiteListMethod(XmlElement element) - { - var method = new WhiteListMethod(); - method.name = element.GetAttribute("name"); - method.nameMatcher = new NameMatcher(method.name); - method.obfuscate = ConfigUtil.ParseNullableBool(element.GetAttribute("obfuscate")); - return method; - } - - private ObfuscationRule GetMethodObfuscationRule(MethodDef method) - { - if (!_methodRuleCache.TryGetValue(method, out var rule)) - { - rule = _configParser.GetMethodRule(method, s_default); - _methodRuleCache[method] = rule; - } - return rule; - } - - public override bool NeedObfuscateCallInMethod(MethodDef method) - { - ObfuscationRule rule = GetMethodObfuscationRule(method); - return rule.disableObfuscation != true; - } - - public override ObfuscationCachePolicy GetMethodObfuscationCachePolicy(MethodDef method) - { - ObfuscationRule rule = GetMethodObfuscationRule(method); - return new ObfuscationCachePolicy() - { - cacheInLoop = rule.cacheCallIndexInLoop.Value, - cacheNotInLoop = rule.cacheCallIndexNotLoop.Value, - }; - } - - - private bool IsSpecialNotObfuscatedMethod(TypeDef typeDef, IMethod method) - { - if (typeDef.IsDelegate || typeDef.IsEnum) - return true; - - string methodName = method.Name; - - // doesn't proxy call if the method is a constructor - if (methodName == ".ctor") - { - return true; - } - - if (typeDef.Name == "EncryptionService`1") - { - return true; - } - // special handle - // don't proxy call for List.Enumerator GetEnumerator() - if (methodName == "GetEnumerator") - { - return true; - } - return false; - } - - private bool ComputeIsInWhiteList(IMethod calledMethod) - { - ITypeDefOrRef declaringType = calledMethod.DeclaringType; - TypeSig declaringTypeSig = calledMethod.DeclaringType.ToTypeSig(); - declaringTypeSig = declaringTypeSig.RemovePinnedAndModifiers(); - switch (declaringTypeSig.ElementType) - { - case ElementType.ValueType: - case ElementType.Class: - { - break; - } - case ElementType.GenericInst: - { - if (MetaUtil.ContainsContainsGenericParameter(calledMethod)) - { - return true; - } - break; - } - default: return true; - } - - TypeDef typeDef = declaringType.ResolveTypeDef(); - - if (IsSpecialNotObfuscatedMethod(typeDef, calledMethod)) - { - return true; - } - - string assName = typeDef.Module.Assembly.Name; - string typeFullName = typeDef.FullName; - string methodName = calledMethod.Name; - foreach (var ass in _whiteListAssemblies) - { - if (!ass.nameMatcher.IsMatch(assName)) - { - continue; - } - foreach (var type in ass.types) - { - if (!type.nameMatcher.IsMatch(typeFullName)) - { - continue; - } - foreach (var method in type.methods) - { - if (method.nameMatcher.IsMatch(methodName)) - { - return !method.obfuscate.Value; - } - } - return !type.obfuscate.Value; - } - return !ass.obfuscate.Value; - } - return false; - } - - private bool IsInWhiteList(IMethod method) - { - if (!_whiteListMethodCache.TryGetValue(method, out var isWhiteList)) - { - isWhiteList = ComputeIsInWhiteList(method); - _whiteListMethodCache.Add(method, isWhiteList); - } - return isWhiteList; - } - - private bool IsTypeSelfAndParentPublic(TypeDef type) - { - if (type.DeclaringType != null && !IsTypeSelfAndParentPublic(type.DeclaringType)) - { - return false; - } - - return type.IsPublic; - } - - public override bool NeedObfuscateCalledMethod(MethodDef callerMethod, IMethod calledMethod, bool callVir, bool currentInLoop) - { - if (IsInWhiteList(calledMethod)) - { - return false; - } - - // mono has more strict access control, calls non-public method will raise exception. - if (PlatformUtil.IsMonoBackend()) - { - MethodDef calledMethodDef = calledMethod.ResolveMethodDef(); - if (calledMethodDef != null && (!calledMethodDef.IsPublic || !IsTypeSelfAndParentPublic(calledMethodDef.DeclaringType))) - { - return false; - } - } - ObfuscationRule rule = GetMethodObfuscationRule(callerMethod); - if (currentInLoop && rule.obfuscateCallInLoop == false) - { - return false; - } - return true; - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CallObfus/ConfigurableObfuscationPolicy.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CallObfus/ConfigurableObfuscationPolicy.cs.meta deleted file mode 100644 index c970eec..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CallObfus/ConfigurableObfuscationPolicy.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d9ea12b16c4b296459db8a60fb1615d6 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CallObfus/DefaultCallProxyObfuscator.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CallObfus/DefaultCallProxyObfuscator.cs deleted file mode 100644 index e171909..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CallObfus/DefaultCallProxyObfuscator.cs +++ /dev/null @@ -1,53 +0,0 @@ -using dnlib.DotNet.Emit; -using dnlib.DotNet; -using System.Collections.Generic; -using Obfuz.Utils; -using Obfuz.Emit; -using Obfuz.Data; -using UnityEngine; - -namespace Obfuz.ObfusPasses.CallObfus -{ - public class DefaultCallProxyObfuscator : ObfuscatorBase - { - private readonly EncryptionScopeProvider _encryptionScopeProvider; - private readonly ConstFieldAllocator _constFieldAllocator; - private readonly CallProxyAllocator _proxyCallAllocator; - private readonly GroupByModuleEntityManager _moduleEntityManager; - - public DefaultCallProxyObfuscator(EncryptionScopeProvider encryptionScopeProvider, ConstFieldAllocator constFieldAllocator, GroupByModuleEntityManager moduleEntityManager, int encryptionLevel) - { - _encryptionScopeProvider = encryptionScopeProvider; - _constFieldAllocator = constFieldAllocator; - _moduleEntityManager = moduleEntityManager; - _proxyCallAllocator = new CallProxyAllocator(encryptionScopeProvider, moduleEntityManager, encryptionLevel); - } - - public override void Done() - { - _proxyCallAllocator.Done(); - } - - public override void Obfuscate(MethodDef callerMethod, IMethod calledMethod, bool callVir, bool needCacheCall, List obfuscatedInstructions) - { - - MethodSig sharedMethodSig = MetaUtil.ToSharedMethodSig(calledMethod.Module.CorLibTypes, MetaUtil.GetInflatedMethodSig(calledMethod)); - ProxyCallMethodData proxyCallMethodData = _proxyCallAllocator.Allocate(callerMethod.Module, calledMethod, callVir); - DefaultMetadataImporter importer = _moduleEntityManager.GetDefaultModuleMetadataImporter(callerMethod.Module, _encryptionScopeProvider); - - if (needCacheCall) - { - FieldDef cacheField = _constFieldAllocator.Allocate(callerMethod.Module, proxyCallMethodData.index); - obfuscatedInstructions.Add(Instruction.Create(OpCodes.Ldsfld, cacheField)); - } - else - { - obfuscatedInstructions.Add(Instruction.CreateLdcI4(proxyCallMethodData.encryptedIndex)); - obfuscatedInstructions.Add(Instruction.CreateLdcI4(proxyCallMethodData.encryptOps)); - obfuscatedInstructions.Add(Instruction.CreateLdcI4(proxyCallMethodData.salt)); - obfuscatedInstructions.Add(Instruction.Create(OpCodes.Call, importer.DecryptInt)); - } - obfuscatedInstructions.Add(Instruction.Create(OpCodes.Call, proxyCallMethodData.proxyMethod)); - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CallObfus/DefaultCallProxyObfuscator.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CallObfus/DefaultCallProxyObfuscator.cs.meta deleted file mode 100644 index 78ae2a2..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CallObfus/DefaultCallProxyObfuscator.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: e13ba01b03439e049af0e09367825cde -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CallObfus/IObfuscationPolicy.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CallObfus/IObfuscationPolicy.cs deleted file mode 100644 index 43c505f..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CallObfus/IObfuscationPolicy.cs +++ /dev/null @@ -1,34 +0,0 @@ -using dnlib.DotNet; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Obfuz.ObfusPasses.CallObfus -{ - - public struct ObfuscationCachePolicy - { - public bool cacheInLoop; - public bool cacheNotInLoop; - } - - public interface IObfuscationPolicy - { - bool NeedObfuscateCallInMethod(MethodDef method); - - ObfuscationCachePolicy GetMethodObfuscationCachePolicy(MethodDef method); - - bool NeedObfuscateCalledMethod(MethodDef callerMethod, IMethod calledMethod, bool callVir, bool currentInLoop); - } - - public abstract class ObfuscationPolicyBase : IObfuscationPolicy - { - public abstract bool NeedObfuscateCallInMethod(MethodDef method); - - public abstract ObfuscationCachePolicy GetMethodObfuscationCachePolicy(MethodDef method); - - public abstract bool NeedObfuscateCalledMethod(MethodDef callerMethod, IMethod calledMethod, bool callVir, bool currentInLoop); - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CallObfus/IObfuscationPolicy.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CallObfus/IObfuscationPolicy.cs.meta deleted file mode 100644 index 96009d1..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CallObfus/IObfuscationPolicy.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 6af3cd881fdefd14d9a55b77088dd5a4 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CallObfus/IObfuscator.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CallObfus/IObfuscator.cs deleted file mode 100644 index 4135b0d..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CallObfus/IObfuscator.cs +++ /dev/null @@ -1,23 +0,0 @@ -using dnlib.DotNet.Emit; -using dnlib.DotNet; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Obfuz.ObfusPasses.CallObfus -{ - public interface IObfuscator - { - void Obfuscate(MethodDef callingMethod, IMethod calledMethod, bool callVir, bool needCacheCall, List obfuscatedInstructions); - - void Done(); - } - - public abstract class ObfuscatorBase : IObfuscator - { - public abstract void Obfuscate(MethodDef callingMethod, IMethod calledMethod, bool callVir, bool needCacheCall, List obfuscatedInstructions); - public abstract void Done(); - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CallObfus/IObfuscator.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CallObfus/IObfuscator.cs.meta deleted file mode 100644 index c75fd40..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CallObfus/IObfuscator.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4156317478f8b1d438ef6d5a280d409f -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CleanUp.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CleanUp.meta deleted file mode 100644 index 37096d7..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CleanUp.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 2764442d8fc2b914dbc39dcfa2699698 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CleanUp/CleanUpInstructionPass.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CleanUp/CleanUpInstructionPass.cs deleted file mode 100644 index 1a526eb..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CleanUp/CleanUpInstructionPass.cs +++ /dev/null @@ -1,46 +0,0 @@ -using dnlib.DotNet; -using dnlib.DotNet.Emit; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Obfuz.ObfusPasses.CleanUp -{ - public class CleanUpInstructionPass : ObfuscationPassBase - { - public override ObfuscationPassType Type => ObfuscationPassType.None; - - public override void Start() - { - } - - public override void Stop() - { - - } - - public override void Process() - { - var ctx = ObfuscationPassContext.Current; - foreach (ModuleDef mod in ctx.modulesToObfuscate) - { - foreach (TypeDef type in mod.GetTypes()) - { - foreach (MethodDef method in type.Methods) - { - if (method.HasBody) - { - CilBody body = method.Body; - body.SimplifyBranches(); - body.OptimizeMacros(); - body.OptimizeBranches(); - // TODO remove dup - } - } - } - } - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CleanUp/CleanUpInstructionPass.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CleanUp/CleanUpInstructionPass.cs.meta deleted file mode 100644 index cc97432..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CleanUp/CleanUpInstructionPass.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 78cc056cd929d70409a0f0737b571a6d -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CleanUp/RemoveObfuzAttributesPass.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CleanUp/RemoveObfuzAttributesPass.cs deleted file mode 100644 index 2855136..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CleanUp/RemoveObfuzAttributesPass.cs +++ /dev/null @@ -1,71 +0,0 @@ -using dnlib.DotNet; -using dnlib.DotNet.Emit; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Obfuz.ObfusPasses.CleanUp -{ - public class RemoveObfuzAttributesPass : ObfuscationPassBase - { - public override ObfuscationPassType Type => ObfuscationPassType.None; - - public override void Start() - { - } - - public override void Stop() - { - - } - - - private void RemoveObfuzAttributes(IHasCustomAttribute provider) - { - CustomAttributeCollection customAttributes = provider.CustomAttributes; - if (customAttributes.Count == 0) - return; - var toRemove = new List(); - customAttributes.RemoveAll("Obfuz.ObfuzIgnoreAttribute"); - customAttributes.RemoveAll("Obfuz.EncryptFieldAttribute"); - } - - public override void Process() - { - var ctx = ObfuscationPassContext.Current; - foreach (ModuleDef mod in ctx.modulesToObfuscate) - { - RemoveObfuzAttributes(mod); - foreach (TypeDef type in mod.GetTypes()) - { - RemoveObfuzAttributes(type); - foreach (FieldDef field in type.Fields) - { - RemoveObfuzAttributes(field); - } - foreach (MethodDef method in type.Methods) - { - RemoveObfuzAttributes(method); - foreach (Parameter param in method.Parameters) - { - if (param.ParamDef != null) - { - RemoveObfuzAttributes(param.ParamDef); - } - } - } - foreach (PropertyDef property in type.Properties) - { - RemoveObfuzAttributes(property); - } - foreach (EventDef eventDef in type.Events) - { - RemoveObfuzAttributes(eventDef); - } - } - } - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CleanUp/RemoveObfuzAttributesPass.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CleanUp/RemoveObfuzAttributesPass.cs.meta deleted file mode 100644 index ff6039e..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CleanUp/RemoveObfuzAttributesPass.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 6b475010a7656a0439ca8664a3d2dbc0 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ConstEncrypt.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ConstEncrypt.meta deleted file mode 100644 index 1fdfee0..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ConstEncrypt.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 18104d0c3c665ea489e566eec67f2aea -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ConstEncrypt/ConfigurableEncryptPolicy.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ConstEncrypt/ConfigurableEncryptPolicy.cs deleted file mode 100644 index 3b3445c..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ConstEncrypt/ConfigurableEncryptPolicy.cs +++ /dev/null @@ -1,489 +0,0 @@ -using dnlib.DotNet; -using Obfuz.Conf; -using Obfuz.Utils; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Xml; -using UnityEngine; - -namespace Obfuz.ObfusPasses.ConstEncrypt -{ - - public class ConfigurableEncryptPolicy : EncryptPolicyBase - { - class ObfuscationRule : IRule - { - public bool? disableEncrypt; - public bool? encryptInt; - public bool? encryptLong; - public bool? encryptFloat; - public bool? encryptDouble; - public bool? encryptArray; - public bool? encryptString; - - public bool? encryptConstInLoop; - public bool? encryptStringInLoop; - - public bool? cacheConstInLoop; - public bool? cacheConstNotInLoop; - public bool? cacheStringInLoop; - public bool? cacheStringNotInLoop; - - public void InheritParent(ObfuscationRule parentRule) - { - if (disableEncrypt == null) - disableEncrypt = parentRule.disableEncrypt; - if (encryptInt == null) - encryptInt = parentRule.encryptInt; - if (encryptLong == null) - encryptLong = parentRule.encryptLong; - if (encryptFloat == null) - encryptFloat = parentRule.encryptFloat; - if (encryptDouble == null) - encryptDouble = parentRule.encryptDouble; - if (encryptArray == null) - encryptArray = parentRule.encryptArray; - if (encryptString == null) - encryptString = parentRule.encryptString; - - if (encryptConstInLoop == null) - encryptConstInLoop = parentRule.encryptConstInLoop; - if (encryptStringInLoop == null) - encryptStringInLoop = parentRule.encryptStringInLoop; - - if (cacheConstInLoop == null) - cacheConstInLoop = parentRule.cacheConstInLoop; - if (cacheConstNotInLoop == null) - cacheConstNotInLoop = parentRule.cacheConstNotInLoop; - if (cacheStringInLoop == null) - cacheStringInLoop = parentRule.cacheStringInLoop; - if (cacheStringNotInLoop == null) - cacheStringNotInLoop = parentRule.cacheStringNotInLoop; - } - } - - class MethodSpec : MethodRuleBase - { - } - - class TypeSpec : TypeRuleBase - { - } - - class AssemblySpec : AssemblyRuleBase - { - } - - private static readonly ObfuscationRule s_default = new ObfuscationRule() - { - disableEncrypt = false, - encryptInt = true, - encryptLong = true, - encryptFloat = true, - encryptDouble = true, - encryptArray = true, - encryptString = true, - encryptConstInLoop = true, - encryptStringInLoop = true, - cacheConstInLoop = true, - cacheConstNotInLoop = false, - cacheStringInLoop = true, - cacheStringNotInLoop = true, - }; - - private ObfuscationRule _global; - - public HashSet notEncryptInts = new HashSet(); - public HashSet notEncryptLongs = new HashSet(); - public HashSet notEncryptStrings = new HashSet(); - public List> notEncryptIntRanges = new List>(); - public List> notEncryptLongRanges = new List>(); - public List> notEncryptFloatRanges = new List>(); - public List> notEncryptDoubleRanges = new List>(); - public List> notEncryptArrayLengthRanges = new List>(); - public List> notEncryptStringLengthRanges = new List>(); - - private readonly XmlAssemblyTypeMethodRuleParser _xmlParser; - - private readonly Dictionary _assemblySpecs = new Dictionary(); - private readonly Dictionary _methodRuleCache = new Dictionary(); - - public ConfigurableEncryptPolicy(List toObfuscatedAssemblyNames, List xmlConfigFiles) - { - _xmlParser = new XmlAssemblyTypeMethodRuleParser( - toObfuscatedAssemblyNames, ParseObfuscationRule, ParseGlobalElement); - LoadConfigs(xmlConfigFiles); - } - - private void LoadConfigs(List configFiles) - { - _xmlParser.LoadConfigs(configFiles); - if (_global == null) - { - _global = s_default; - } - else - { - _global.InheritParent(s_default); - } - _xmlParser.InheritParentRules(_global); - } - - private void ParseGlobalElement(string configFile, XmlElement ele) - { - switch (ele.Name) - { - case "global": _global = ParseObfuscationRule(configFile, ele); break; - case "whitelist": ParseWhitelist(configFile, ele); break; - default: throw new Exception($"Invalid xml file {configFile}, unknown node {ele.Name}"); - } - } - - private ObfuscationRule ParseObfuscationRule(string configFile, XmlElement ele) - { - var rule = new ObfuscationRule(); - if (ele.HasAttribute("disableEncrypt")) - { - rule.disableEncrypt = ConfigUtil.ParseBool(ele.GetAttribute("disableEncrypt")); - } - if (ele.HasAttribute("encryptInt")) - { - rule.encryptInt = ConfigUtil.ParseBool(ele.GetAttribute("encryptInt")); - } - if (ele.HasAttribute("encryptLong")) - { - rule.encryptLong = ConfigUtil.ParseBool(ele.GetAttribute("encryptLong")); - } - if (ele.HasAttribute("encryptFloat")) - { - rule.encryptFloat = ConfigUtil.ParseBool(ele.GetAttribute("encryptFloat")); - } - if (ele.HasAttribute("encryptDouble")) - { - rule.encryptDouble = ConfigUtil.ParseBool(ele.GetAttribute("encryptDouble")); - } - if (ele.HasAttribute("encryptBytes")) - { - rule.encryptArray = ConfigUtil.ParseBool(ele.GetAttribute("encryptArray")); - } - if (ele.HasAttribute("encryptString")) - { - rule.encryptString = ConfigUtil.ParseBool(ele.GetAttribute("encryptString")); - } - - if (ele.HasAttribute("encryptConstInLoop")) - { - rule.encryptConstInLoop = ConfigUtil.ParseBool(ele.GetAttribute("encryptConstInLoop")); - } - if (ele.HasAttribute("encryptStringInLoop")) - { - rule.encryptStringInLoop = ConfigUtil.ParseBool(ele.GetAttribute("encryptStringInLoop")); - } - if (ele.HasAttribute("cacheConstInLoop")) - { - rule.cacheConstInLoop = ConfigUtil.ParseBool(ele.GetAttribute("cacheConstInLoop")); - } - if (ele.HasAttribute("cacheConstNotInLoop")) - { - rule.cacheConstNotInLoop = ConfigUtil.ParseBool(ele.GetAttribute("cacheConstNotInLoop")); - } - if (ele.HasAttribute("cacheStringInLoop")) - { - rule.cacheStringInLoop = ConfigUtil.ParseBool(ele.GetAttribute("cacheStringInLoop")); - } - if (ele.HasAttribute("cacheStringNotInLoop")) - { - rule.cacheStringNotInLoop = ConfigUtil.ParseBool(ele.GetAttribute("cacheStringNotInLoop")); - } - return rule; - } - - private void ParseWhitelist(string configFile, XmlElement childEle) - { - string type = childEle.GetAttribute("type"); - if (string.IsNullOrEmpty(type)) - { - throw new Exception($"Invalid xml file, whitelist type is empty"); - } - string value = childEle.InnerText; - switch (type) - { - case "int": - { - notEncryptInts.AddRange(value.Split(',').Select(s => int.Parse(s.Trim()))); - break; - } - case "long": - { - notEncryptLongs.AddRange(value.Split(',').Select(s => long.Parse(s.Trim()))); - break; - } - case "string": - { - notEncryptStrings.AddRange(value.Split(',').Select(s => s.Trim())); - break; - } - case "int-range": - { - var parts = value.Split(','); - if (parts.Length != 2) - { - throw new Exception($"Invalid xml file, int-range {value} is invalid"); - } - notEncryptIntRanges.Add(new NumberRange(ConfigUtil.ParseNullableInt(parts[0]), ConfigUtil.ParseNullableInt(parts[1]))); - break; - } - case "long-range": - { - var parts = value.Split(','); - if (parts.Length != 2) - { - throw new Exception($"Invalid xml file, long-range {value} is invalid"); - } - notEncryptLongRanges.Add(new NumberRange(ConfigUtil.ParseNullableLong(parts[0]), ConfigUtil.ParseNullableLong(parts[1]))); - break; - } - case "float-range": - { - var parts = value.Split(','); - if (parts.Length != 2) - { - throw new Exception($"Invalid xml file, float-range {value} is invalid"); - } - notEncryptFloatRanges.Add(new NumberRange(ConfigUtil.ParseNullableFloat(parts[0]), ConfigUtil.ParseNullableFloat(parts[1]))); - break; - } - case "double-range": - { - var parts = value.Split(','); - if (parts.Length != 2) - { - throw new Exception($"Invalid xml file, double-range {value} is invalid"); - } - notEncryptDoubleRanges.Add(new NumberRange(ConfigUtil.ParseNullableDouble(parts[0]), ConfigUtil.ParseNullableDouble(parts[1]))); - break; - } - case "string-length-range": - { - var parts = value.Split(','); - if (parts.Length != 2) - { - throw new Exception($"Invalid xml file, string-length-range {value} is invalid"); - } - notEncryptStringLengthRanges.Add(new NumberRange(ConfigUtil.ParseNullableInt(parts[0]), ConfigUtil.ParseNullableInt(parts[1]))); - break; - } - case "array-length-range": - { - var parts = value.Split(','); - if (parts.Length != 2) - { - throw new Exception($"Invalid xml file, array-length-range {value} is invalid"); - } - notEncryptArrayLengthRanges.Add(new NumberRange(ConfigUtil.ParseNullableInt(parts[0]), ConfigUtil.ParseNullableInt(parts[1]))); - break; - } - default: throw new Exception($"Invalid xml file, unknown whitelist type {type} in {childEle.Name} node"); - } - } - - private ObfuscationRule GetMethodObfuscationRule(MethodDef method) - { - if (!_methodRuleCache.TryGetValue(method, out var rule)) - { - rule = _xmlParser.GetMethodRule(method, _global); - _methodRuleCache[method] = rule; - } - return rule; - } - - public override bool NeedObfuscateMethod(MethodDef method) - { - ObfuscationRule rule = GetMethodObfuscationRule(method); - return rule.disableEncrypt != true; - } - - public override ConstCachePolicy GetMethodConstCachePolicy(MethodDef method) - { - ObfuscationRule rule = GetMethodObfuscationRule(method); - return new ConstCachePolicy - { - cacheConstInLoop = rule.cacheConstInLoop.Value, - cacheConstNotInLoop = rule.cacheConstNotInLoop.Value, - cacheStringInLoop = rule.cacheStringInLoop.Value, - cacheStringNotInLoop = rule.cacheStringNotInLoop.Value, - }; - } - - public override bool NeedObfuscateInt(MethodDef method, bool currentInLoop, int value) - { - ObfuscationRule rule = GetMethodObfuscationRule(method); - if (rule.encryptInt == false) - { - return false; - } - if (currentInLoop && rule.encryptConstInLoop == false) - { - return false; - } - if (notEncryptInts.Contains(value)) - { - return false; - } - foreach (var range in notEncryptIntRanges) - { - if (range.min != null && value < range.min) - { - continue; - } - if (range.max != null && value > range.max) - { - continue; - } - return false; - } - return true; - } - - public override bool NeedObfuscateLong(MethodDef method, bool currentInLoop, long value) - { - ObfuscationRule rule = GetMethodObfuscationRule(method); - if (rule.encryptLong == false) - { - return false; - } - if (currentInLoop && rule.encryptConstInLoop == false) - { - return false; - } - if (notEncryptLongs.Contains(value)) - { - return false; - } - foreach (var range in notEncryptLongRanges) - { - if (range.min != null && value < range.min) - { - continue; - } - if (range.max != null && value > range.max) - { - continue; - } - return false; - } - return true; - } - - public override bool NeedObfuscateFloat(MethodDef method, bool currentInLoop, float value) - { - ObfuscationRule rule = GetMethodObfuscationRule(method); - if (rule.encryptFloat == false) - { - return false; - } - if (currentInLoop && rule.encryptConstInLoop == false) - { - return false; - } - foreach (var range in notEncryptFloatRanges) - { - if (range.min != null && value < range.min) - { - continue; - } - if (range.max != null && value > range.max) - { - continue; - } - return false; - } - return true; - } - - public override bool NeedObfuscateDouble(MethodDef method, bool currentInLoop, double value) - { - ObfuscationRule rule = GetMethodObfuscationRule(method); - if (rule.encryptDouble == false) - { - return false; - } - if (currentInLoop && rule.encryptConstInLoop == false) - { - return false; - } - foreach (var range in notEncryptDoubleRanges) - { - if (range.min != null && value < range.min) - { - continue; - } - if (range.max != null && value > range.max) - { - continue; - } - return false; - } - return true; - } - - public override bool NeedObfuscateString(MethodDef method, bool currentInLoop, string value) - { - ObfuscationRule rule = GetMethodObfuscationRule(method); - if (rule.encryptString == false) - { - return false; - } - if (currentInLoop && rule.encryptConstInLoop == false) - { - return false; - } - if (notEncryptStrings.Contains(value)) - { - return false; - } - foreach (var range in notEncryptStringLengthRanges) - { - if (range.min != null && value.Length < range.min) - { - continue; - } - if (range.max != null && value.Length > range.max) - { - continue; - } - return false; - } - return true; - } - - public override bool NeedObfuscateArray(MethodDef method, bool currentInLoop, byte[] array) - { - ObfuscationRule rule = GetMethodObfuscationRule(method); - if (rule.encryptArray == false) - { - return false; - } - if (currentInLoop && rule.encryptConstInLoop == false) - { - return false; - } - foreach (var range in notEncryptArrayLengthRanges) - { - if (range.min != null && array.Length < range.min) - { - continue; - } - if (range.max != null && array.Length > range.max) - { - continue; - } - return false; - } - return true; - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ConstEncrypt/ConfigurableEncryptPolicy.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ConstEncrypt/ConfigurableEncryptPolicy.cs.meta deleted file mode 100644 index 73c07be..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ConstEncrypt/ConfigurableEncryptPolicy.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: da25453bc1fda394097c052af7733260 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ConstEncrypt/ConstEncryptPass.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ConstEncrypt/ConstEncryptPass.cs deleted file mode 100644 index b39d304..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ConstEncrypt/ConstEncryptPass.cs +++ /dev/null @@ -1,152 +0,0 @@ -using dnlib.DotNet; -using dnlib.DotNet.Emit; -using Obfuz.Emit; -using Obfuz.Settings; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.CompilerServices; -using System.Text; -using System.Threading.Tasks; -using UnityEngine.Assertions; - -namespace Obfuz.ObfusPasses.ConstEncrypt -{ - - public class ConstEncryptPass : BasicBlockObfuscationPassBase - { - private readonly List _configFiles; - private readonly int _encryptionLevel; - private IEncryptPolicy _dataObfuscatorPolicy; - private IConstEncryptor _dataObfuscator; - public override ObfuscationPassType Type => ObfuscationPassType.ConstEncrypt; - - public ConstEncryptPass(ConstEncryptionSettings settings) - { - _configFiles = settings.ruleFiles.ToList(); - _encryptionLevel = settings.encryptionLevel; - } - - public override void Start() - { - var ctx = ObfuscationPassContext.Current; - _dataObfuscatorPolicy = new ConfigurableEncryptPolicy(ctx.assembliesToObfuscate, _configFiles); - _dataObfuscator = new DefaultConstEncryptor(ctx.encryptionScopeProvider, ctx.rvaDataAllocator, ctx.constFieldAllocator, ctx.moduleEntityManager, _encryptionLevel); - } - - public override void Stop() - { - - } - - protected override bool NeedObfuscateMethod(MethodDef method) - { - return _dataObfuscatorPolicy.NeedObfuscateMethod(method); - } - - protected override bool TryObfuscateInstruction(MethodDef method, Instruction inst, BasicBlock block, int instructionIndex, IList globalInstructions, - List outputInstructions, List totalFinalInstructions) - { - bool currentInLoop = block.inLoop; - ConstCachePolicy constCachePolicy = _dataObfuscatorPolicy.GetMethodConstCachePolicy(method); - bool needCache = currentInLoop ? constCachePolicy.cacheConstInLoop : constCachePolicy.cacheConstNotInLoop; - switch (inst.OpCode.Code) - { - case Code.Ldc_I4: - case Code.Ldc_I4_S: - case Code.Ldc_I4_0: - case Code.Ldc_I4_1: - case Code.Ldc_I4_2: - case Code.Ldc_I4_3: - case Code.Ldc_I4_4: - case Code.Ldc_I4_5: - case Code.Ldc_I4_6: - case Code.Ldc_I4_7: - case Code.Ldc_I4_8: - case Code.Ldc_I4_M1: - { - int value = inst.GetLdcI4Value(); - if (_dataObfuscatorPolicy.NeedObfuscateInt(method, currentInLoop, value)) - { - _dataObfuscator.ObfuscateInt(method, needCache, value, outputInstructions); - return true; - } - return false; - } - case Code.Ldc_I8: - { - long value = (long)inst.Operand; - if (_dataObfuscatorPolicy.NeedObfuscateLong(method, currentInLoop, value)) - { - _dataObfuscator.ObfuscateLong(method, needCache, value, outputInstructions); - return true; - } - return false; - } - case Code.Ldc_R4: - { - float value = (float)inst.Operand; - if (_dataObfuscatorPolicy.NeedObfuscateFloat(method, currentInLoop, value)) - { - _dataObfuscator.ObfuscateFloat(method, needCache, value, outputInstructions); - return true; - } - return false; - } - case Code.Ldc_R8: - { - double value = (double)inst.Operand; - if (_dataObfuscatorPolicy.NeedObfuscateDouble(method, currentInLoop, value)) - { - _dataObfuscator.ObfuscateDouble(method, needCache, value, outputInstructions); - return true; - } - return false; - } - case Code.Ldstr: - { - string value = (string)inst.Operand; - if (_dataObfuscatorPolicy.NeedObfuscateString(method, currentInLoop, value)) - { - _dataObfuscator.ObfuscateString(method, needCache, value, outputInstructions); - return true; - } - return false; - } - case Code.Call: - { - //if (((IMethod)inst.Operand).FullName == "System.Void System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(System.Array,System.RuntimeFieldHandle)") - //{ - // Instruction prevInst = globalInstructions[instructionIndex - 1]; - // if (prevInst.OpCode.Code == Code.Ldtoken) - // { - // IField rvaField = (IField)prevInst.Operand; - // FieldDef ravFieldDef = rvaField.ResolveFieldDefThrow(); - // byte[] data = ravFieldDef.InitialValue; - // if (data != null && _dataObfuscatorPolicy.NeedObfuscateArray(method, currentInLoop, data)) - // { - // if (_encryptedRvaFields.Add(ravFieldDef)) - // { - - // } - - // // remove prev ldtoken instruction - // Assert.AreEqual(Code.Ldtoken, totalFinalInstructions.Last().OpCode.Code); - // //totalFinalInstructions.RemoveAt(totalFinalInstructions.Count - 1); - // // dup arr argument for decryption operation - // totalFinalInstructions.Insert(totalFinalInstructions.Count - 1, Instruction.Create(OpCodes.Dup)); - // totalFinalInstructions.Add(inst.Clone()); - // //bool needCache = currentInLoop ? constCachePolicy.cacheStringInLoop : constCachePolicy.cacheStringNotInLoop; - // bool needCache = false; - // _dataObfuscator.ObfuscateBytes(method, needCache, data, outputInstructions); - // return true; - // } - // } - //} - return false; - } - default: return false; - } - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ConstEncrypt/ConstEncryptPass.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ConstEncrypt/ConstEncryptPass.cs.meta deleted file mode 100644 index da7fdfb..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ConstEncrypt/ConstEncryptPass.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: aa0e9191126d4e24c92546b6af2c52cf -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ConstEncrypt/DefaultConstEncryptor.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ConstEncrypt/DefaultConstEncryptor.cs deleted file mode 100644 index 75f98dc..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ConstEncrypt/DefaultConstEncryptor.cs +++ /dev/null @@ -1,204 +0,0 @@ -using dnlib.DotNet; -using dnlib.DotNet.Emit; -using Obfuz.Emit; -using Obfuz.Data; -using Obfuz.Utils; -using System; -using System.Collections.Generic; -using NUnit.Framework; -using System.Text; - -namespace Obfuz.ObfusPasses.ConstEncrypt -{ - public class DefaultConstEncryptor : IConstEncryptor - { - private readonly EncryptionScopeProvider _encryptionScopeProvider; - private readonly RvaDataAllocator _rvaDataAllocator; - private readonly ConstFieldAllocator _constFieldAllocator; - private readonly GroupByModuleEntityManager _moduleEntityManager; - private readonly int _encryptionLevel; - - public DefaultConstEncryptor(EncryptionScopeProvider encryptionScopeProvider, RvaDataAllocator rvaDataAllocator, ConstFieldAllocator constFieldAllocator, GroupByModuleEntityManager moduleEntityManager, int encryptionLevel) - { - _encryptionScopeProvider = encryptionScopeProvider; - _rvaDataAllocator = rvaDataAllocator; - _constFieldAllocator = constFieldAllocator; - _moduleEntityManager = moduleEntityManager; - _encryptionLevel = encryptionLevel; - } - - private IRandom CreateRandomForValue(EncryptionScopeInfo encryptionScope, int value) - { - return encryptionScope.localRandomCreator(value); - } - - private int GenerateEncryptionOperations(EncryptionScopeInfo encryptionScope, IRandom random) - { - return EncryptionUtil.GenerateEncryptionOpCodes(random, encryptionScope.encryptor, _encryptionLevel); - } - - public int GenerateSalt(IRandom random) - { - return random.NextInt(); - } - - private DefaultMetadataImporter GetModuleMetadataImporter(MethodDef method) - { - return _moduleEntityManager.GetDefaultModuleMetadataImporter(method.Module, _encryptionScopeProvider); - } - - public void ObfuscateInt(MethodDef method, bool needCacheValue, int value, List obfuscatedInstructions) - { - if (needCacheValue) - { - FieldDef cacheField = _constFieldAllocator.Allocate(method.Module, value); - obfuscatedInstructions.Add(Instruction.Create(OpCodes.Ldsfld, cacheField)); - return; - } - - EncryptionScopeInfo encryptionScope = _encryptionScopeProvider.GetScope(method.Module); - IRandom random = CreateRandomForValue(encryptionScope, value.GetHashCode()); - int ops = GenerateEncryptionOperations(encryptionScope, random); - int salt = GenerateSalt(random); - int encryptedValue = encryptionScope.encryptor.Encrypt(value, ops, salt); - RvaData rvaData = _rvaDataAllocator.Allocate(method.Module, encryptedValue); - - DefaultMetadataImporter importer = GetModuleMetadataImporter(method); - obfuscatedInstructions.Add(Instruction.Create(OpCodes.Ldsfld, rvaData.field)); - obfuscatedInstructions.Add(Instruction.CreateLdcI4(rvaData.offset)); - obfuscatedInstructions.Add(Instruction.CreateLdcI4(ops)); - obfuscatedInstructions.Add(Instruction.CreateLdcI4(salt)); - obfuscatedInstructions.Add(Instruction.Create(OpCodes.Call, importer.DecryptFromRvaInt)); - } - - public void ObfuscateLong(MethodDef method, bool needCacheValue, long value, List obfuscatedInstructions) - { - if (needCacheValue) - { - FieldDef cacheField = _constFieldAllocator.Allocate(method.Module, value); - obfuscatedInstructions.Add(Instruction.Create(OpCodes.Ldsfld, cacheField)); - return; - } - - EncryptionScopeInfo encryptionScope = _encryptionScopeProvider.GetScope(method.Module); - IRandom random = CreateRandomForValue(encryptionScope, value.GetHashCode()); - int ops = GenerateEncryptionOperations(encryptionScope, random); - int salt = GenerateSalt(random); - long encryptedValue = encryptionScope.encryptor.Encrypt(value, ops, salt); - RvaData rvaData = _rvaDataAllocator.Allocate(method.Module, encryptedValue); - - DefaultMetadataImporter importer = GetModuleMetadataImporter(method); - obfuscatedInstructions.Add(Instruction.Create(OpCodes.Ldsfld, rvaData.field)); - obfuscatedInstructions.Add(Instruction.CreateLdcI4(rvaData.offset)); - obfuscatedInstructions.Add(Instruction.CreateLdcI4(ops)); - obfuscatedInstructions.Add(Instruction.CreateLdcI4(salt)); - obfuscatedInstructions.Add(Instruction.Create(OpCodes.Call, importer.DecryptFromRvaLong)); - } - - public void ObfuscateFloat(MethodDef method, bool needCacheValue, float value, List obfuscatedInstructions) - { - if (needCacheValue) - { - FieldDef cacheField = _constFieldAllocator.Allocate(method.Module, value); - obfuscatedInstructions.Add(Instruction.Create(OpCodes.Ldsfld, cacheField)); - return; - } - - EncryptionScopeInfo encryptionScope = _encryptionScopeProvider.GetScope(method.Module); - IRandom random = CreateRandomForValue(encryptionScope, value.GetHashCode()); - int ops = GenerateEncryptionOperations(encryptionScope, random); - int salt = GenerateSalt(random); - float encryptedValue = encryptionScope.encryptor.Encrypt(value, ops, salt); - RvaData rvaData = _rvaDataAllocator.Allocate(method.Module, encryptedValue); - - DefaultMetadataImporter importer = GetModuleMetadataImporter(method); - obfuscatedInstructions.Add(Instruction.Create(OpCodes.Ldsfld, rvaData.field)); - obfuscatedInstructions.Add(Instruction.CreateLdcI4(rvaData.offset)); - obfuscatedInstructions.Add(Instruction.CreateLdcI4(ops)); - obfuscatedInstructions.Add(Instruction.CreateLdcI4(salt)); - obfuscatedInstructions.Add(Instruction.Create(OpCodes.Call, importer.DecryptFromRvaFloat)); - } - - public void ObfuscateDouble(MethodDef method, bool needCacheValue, double value, List obfuscatedInstructions) - { - if (needCacheValue) - { - FieldDef cacheField = _constFieldAllocator.Allocate(method.Module, value); - obfuscatedInstructions.Add(Instruction.Create(OpCodes.Ldsfld, cacheField)); - return; - } - - EncryptionScopeInfo encryptionScope = _encryptionScopeProvider.GetScope(method.Module); - IRandom random = CreateRandomForValue(encryptionScope, value.GetHashCode()); - int ops = GenerateEncryptionOperations(encryptionScope, random); - int salt = GenerateSalt(random); - double encryptedValue = encryptionScope.encryptor.Encrypt(value, ops, salt); - RvaData rvaData = _rvaDataAllocator.Allocate(method.Module, encryptedValue); - - DefaultMetadataImporter importer = GetModuleMetadataImporter(method); - obfuscatedInstructions.Add(Instruction.Create(OpCodes.Ldsfld, rvaData.field)); - obfuscatedInstructions.Add(Instruction.CreateLdcI4(rvaData.offset)); - obfuscatedInstructions.Add(Instruction.CreateLdcI4(ops)); - obfuscatedInstructions.Add(Instruction.CreateLdcI4(salt)); - obfuscatedInstructions.Add(Instruction.Create(OpCodes.Call, importer.DecryptFromRvaDouble)); - } - - public void ObfuscateBytes(MethodDef method, bool needCacheValue, byte[] value, List obfuscatedInstructions) - { - throw new NotSupportedException("ObfuscateBytes is not supported yet."); - //if (needCacheValue) - //{ - // FieldDef cacheField = _constFieldAllocator.Allocate(method.Module, value); - // obfuscatedInstructions.Add(Instruction.Create(OpCodes.Ldsfld, cacheField)); - // return; - //} - - //int ops = GenerateEncryptionOperations(); - //int salt = GenerateSalt(); - //byte[] encryptedValue = _encryptor.Encrypt(value, 0, value.Length, ops, salt); - //Assert.IsTrue(encryptedValue.Length % 4 == 0); - //RvaData rvaData = _rvaDataAllocator.Allocate(method.Module, encryptedValue); - - //DefaultMetadataImporter importer = GetModuleMetadataImporter(method); - //obfuscatedInstructions.Add(Instruction.Create(OpCodes.Ldsfld, rvaData.field)); - //obfuscatedInstructions.Add(Instruction.CreateLdcI4(rvaData.offset)); - //// should use value.Length, can't use rvaData.size, because rvaData.size is align to 4, it's not the actual length. - //obfuscatedInstructions.Add(Instruction.CreateLdcI4(value.Length)); - //obfuscatedInstructions.Add(Instruction.CreateLdcI4(ops)); - //obfuscatedInstructions.Add(Instruction.CreateLdcI4(salt)); - //obfuscatedInstructions.Add(Instruction.Create(OpCodes.Call, importer.DecryptFromRvaBytes)); - } - - public void ObfuscateString(MethodDef method, bool needCacheValue, string value, List obfuscatedInstructions) - { - if (needCacheValue) - { - FieldDef cacheField = _constFieldAllocator.Allocate(method.Module, value); - obfuscatedInstructions.Add(Instruction.Create(OpCodes.Ldsfld, cacheField)); - return; - } - - EncryptionScopeInfo encryptionScope = _encryptionScopeProvider.GetScope(method.Module); - IRandom random = CreateRandomForValue(encryptionScope, value.GetHashCode()); - int ops = GenerateEncryptionOperations(encryptionScope, random); - int salt = GenerateSalt(random); - int stringByteLength = Encoding.UTF8.GetByteCount(value); - byte[] encryptedValue = encryptionScope.encryptor.Encrypt(value, ops, salt); - Assert.AreEqual(stringByteLength, encryptedValue.Length); - RvaData rvaData = _rvaDataAllocator.Allocate(method.Module, encryptedValue); - - DefaultMetadataImporter importer = GetModuleMetadataImporter(method); - obfuscatedInstructions.Add(Instruction.Create(OpCodes.Ldsfld, rvaData.field)); - obfuscatedInstructions.Add(Instruction.CreateLdcI4(rvaData.offset)); - // should use stringByteLength, can't use rvaData.size, because rvaData.size is align to 4, it's not the actual length. - obfuscatedInstructions.Add(Instruction.CreateLdcI4(stringByteLength)); - obfuscatedInstructions.Add(Instruction.CreateLdcI4(ops)); - obfuscatedInstructions.Add(Instruction.CreateLdcI4(salt)); - obfuscatedInstructions.Add(Instruction.Create(OpCodes.Call, importer.DecryptFromRvaString)); - } - - public void Done() - { - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ConstEncrypt/DefaultConstEncryptor.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ConstEncrypt/DefaultConstEncryptor.cs.meta deleted file mode 100644 index 1e0977a..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ConstEncrypt/DefaultConstEncryptor.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4c6a0ecde97527e4694731e4d4de129a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ConstEncrypt/IConstEncryptor.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ConstEncrypt/IConstEncryptor.cs deleted file mode 100644 index 7043aec..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ConstEncrypt/IConstEncryptor.cs +++ /dev/null @@ -1,32 +0,0 @@ -using dnlib.DotNet; -using dnlib.DotNet.Emit; -using System; -using System.Collections.Generic; - -namespace Obfuz.ObfusPasses.ConstEncrypt -{ - public interface IConstEncryptor - { - void ObfuscateInt(MethodDef method, bool needCacheValue, int value, List obfuscatedInstructions); - - void ObfuscateLong(MethodDef method, bool needCacheValue, long value, List obfuscatedInstructions); - - void ObfuscateFloat(MethodDef method, bool needCacheValue, float value, List obfuscatedInstructions); - - void ObfuscateDouble(MethodDef method, bool needCacheValue, double value, List obfuscatedInstructions); - - void ObfuscateString(MethodDef method, bool needCacheValue, string value, List obfuscatedInstructions); - - void ObfuscateBytes(MethodDef method, bool needCacheValue, byte[] value, List obfuscatedInstructions); - } - - public abstract class ConstEncryptorBase : IConstEncryptor - { - public abstract void ObfuscateBytes(MethodDef method, bool needCacheValue, byte[] value, List obfuscatedInstructions); - public abstract void ObfuscateDouble(MethodDef method, bool needCacheValue, double value, List obfuscatedInstructions); - public abstract void ObfuscateFloat(MethodDef method, bool needCacheValue, float value, List obfuscatedInstructions); - public abstract void ObfuscateInt(MethodDef method, bool needCacheValue, int value, List obfuscatedInstructions); - public abstract void ObfuscateLong(MethodDef method, bool needCacheValue, long value, List obfuscatedInstructions); - public abstract void ObfuscateString(MethodDef method, bool needCacheValue, string value, List obfuscatedInstructions); - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ConstEncrypt/IConstEncryptor.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ConstEncrypt/IConstEncryptor.cs.meta deleted file mode 100644 index 7f8d587..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ConstEncrypt/IConstEncryptor.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 0ccbcdadf1913b6498eaee53abac5d0b -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ConstEncrypt/IEncryptPolicy.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ConstEncrypt/IEncryptPolicy.cs deleted file mode 100644 index 1db7f0e..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ConstEncrypt/IEncryptPolicy.cs +++ /dev/null @@ -1,48 +0,0 @@ -using dnlib.DotNet; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Obfuz.ObfusPasses.ConstEncrypt -{ - public struct ConstCachePolicy - { - public bool cacheConstInLoop; - public bool cacheConstNotInLoop; - public bool cacheStringInLoop; - public bool cacheStringNotInLoop; - } - - public interface IEncryptPolicy - { - bool NeedObfuscateMethod(MethodDef method); - - ConstCachePolicy GetMethodConstCachePolicy(MethodDef method); - - bool NeedObfuscateInt(MethodDef method, bool currentInLoop, int value); - - bool NeedObfuscateLong(MethodDef method, bool currentInLoop, long value); - - bool NeedObfuscateFloat(MethodDef method, bool currentInLoop, float value); - - bool NeedObfuscateDouble(MethodDef method, bool currentInLoop, double value); - - bool NeedObfuscateString(MethodDef method, bool currentInLoop, string value); - - bool NeedObfuscateArray(MethodDef method, bool currentInLoop, byte[] array); - } - - public abstract class EncryptPolicyBase : IEncryptPolicy - { - public abstract bool NeedObfuscateMethod(MethodDef method); - public abstract ConstCachePolicy GetMethodConstCachePolicy(MethodDef method); - public abstract bool NeedObfuscateDouble(MethodDef method, bool currentInLoop, double value); - public abstract bool NeedObfuscateFloat(MethodDef method, bool currentInLoop, float value); - public abstract bool NeedObfuscateInt(MethodDef method, bool currentInLoop, int value); - public abstract bool NeedObfuscateLong(MethodDef method, bool currentInLoop, long value); - public abstract bool NeedObfuscateString(MethodDef method, bool currentInLoop, string value); - public abstract bool NeedObfuscateArray(MethodDef method, bool currentInLoop, byte[] array); - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ConstEncrypt/IEncryptPolicy.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ConstEncrypt/IEncryptPolicy.cs.meta deleted file mode 100644 index 0a44790..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ConstEncrypt/IEncryptPolicy.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 18e57864070430a44ac561bdd7d00b2e -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ExprObfus.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ExprObfus.meta deleted file mode 100644 index 24080ec..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ExprObfus.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 9fdb2c243b1ea0f489e67233fda287c9 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ExprObfus/ExprObfusPass.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ExprObfus/ExprObfusPass.cs deleted file mode 100644 index 468bfce..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ExprObfus/ExprObfusPass.cs +++ /dev/null @@ -1,35 +0,0 @@ -using dnlib.DotNet; -using dnlib.DotNet.Emit; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Obfuz.ObfusPasses.ExprObfus -{ - public class ExprObfusPass : InstructionObfuscationPassBase - { - public override ObfuscationPassType Type => ObfuscationPassType.ExprObfus; - - public override void Start() - { - - } - - public override void Stop() - { - - } - - protected override bool NeedObfuscateMethod(MethodDef method) - { - return false; - } - - protected override bool TryObfuscateInstruction(MethodDef callingMethod, Instruction inst, IList instructions, int instructionIndex, List outputInstructions, List totalFinalInstructions) - { - return false; - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ExprObfus/ExprObfusPass.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ExprObfus/ExprObfusPass.cs.meta deleted file mode 100644 index f108ce3..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ExprObfus/ExprObfusPass.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 477e081ffc0072e4fa1a06100269e4a3 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/FieldEncrypt.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/FieldEncrypt.meta deleted file mode 100644 index 24c7b1d..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/FieldEncrypt.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 0b789725c4848bd4fb4b3ce1f2e2a9c9 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/FieldEncrypt/ConfigurableEncryptPolicy.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/FieldEncrypt/ConfigurableEncryptPolicy.cs deleted file mode 100644 index 15ce929..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/FieldEncrypt/ConfigurableEncryptPolicy.cs +++ /dev/null @@ -1,44 +0,0 @@ -using dnlib.DotNet; -using Obfuz.Conf; -using Obfuz.Utils; -using System; -using System.Collections.Generic; -using System.Xml; - -namespace Obfuz.ObfusPasses.FieldEncrypt -{ - public class ConfigurableEncryptPolicy : EncryptPolicyBase - { - class ObfuscationRule - { - - } - - private readonly XmlFieldRuleParser _configParser; - - public ConfigurableEncryptPolicy(List toObfuscatedAssemblyNames, List configFiles) - { - _configParser = new XmlFieldRuleParser(toObfuscatedAssemblyNames, ParseRule, null); - _configParser.LoadConfigs(configFiles); - } - - private ObfuscationRule ParseRule(string configFile, XmlElement ele) - { - return new ObfuscationRule(); - } - - public override bool NeedEncrypt(FieldDef field) - { - if (MetaUtil.HasEncryptFieldAttribute(field)) - { - return true; - } - if (MetaUtil.HasObfuzIgnoreAttribute(field) || MetaUtil.HasObfuzIgnoreAttributeInSelfOrParent(field.DeclaringType)) - { - return false; - } - var rule = _configParser.GetFieldRule(field); - return rule != null; - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/FieldEncrypt/ConfigurableEncryptPolicy.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/FieldEncrypt/ConfigurableEncryptPolicy.cs.meta deleted file mode 100644 index bcc4d60..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/FieldEncrypt/ConfigurableEncryptPolicy.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 6b17fa09ce58526459f2b9e375c31cad -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/FieldEncrypt/DefaultFieldEncryptor.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/FieldEncrypt/DefaultFieldEncryptor.cs deleted file mode 100644 index 05c9c63..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/FieldEncrypt/DefaultFieldEncryptor.cs +++ /dev/null @@ -1,182 +0,0 @@ -using dnlib.DotNet; -using dnlib.DotNet.Emit; -using Obfuz.Emit; -using Obfuz.Utils; -using System; -using System.Collections.Generic; -using System.Reflection; -using System.Runtime.InteropServices; -using UnityEngine.Assertions; - -namespace Obfuz.ObfusPasses.FieldEncrypt -{ - public class DefaultFieldEncryptor : FieldEncryptorBase - { - private readonly EncryptionScopeProvider _encryptionScopeProvider; - private readonly GroupByModuleEntityManager _moduleEntityManager; - private readonly int _encryptionLevel; - - public DefaultFieldEncryptor(EncryptionScopeProvider encryptionScopeProvider, GroupByModuleEntityManager moduleEntityManager, int encryptionLevel) - { - _encryptionScopeProvider = encryptionScopeProvider; - _moduleEntityManager = moduleEntityManager; - _encryptionLevel = encryptionLevel; - } - - private DefaultMetadataImporter GetMetadataImporter(MethodDef method) - { - return _moduleEntityManager.GetDefaultModuleMetadataImporter(method.Module, _encryptionScopeProvider); - } - - class FieldEncryptInfo - { - public int encryptOps; - public int salt; - public ElementType fieldType; - public long xorValueForZero; - } - - private readonly Dictionary _fieldEncryptInfoCache = new Dictionary(); - - - private long CalcXorValueForZero(IEncryptor encryptor, ElementType type, int encryptOps, int salt) - { - switch (type) - { - case ElementType.I4: - case ElementType.U4: - case ElementType.R4: - return encryptor.Encrypt(0, encryptOps, salt); - case ElementType.I8: - case ElementType.U8: - case ElementType.R8: - return encryptor.Encrypt(0L, encryptOps, salt); - default: - throw new NotSupportedException($"Unsupported field type: {type} for encryption"); - } - } - - - private IRandom CreateRandomForField(RandomCreator randomCreator, FieldDef field) - { - return randomCreator(FieldEqualityComparer.CompareDeclaringTypes.GetHashCode(field)); - } - - private int GenerateEncryptionOperations(IRandom random, IEncryptor encryptor) - { - return EncryptionUtil.GenerateEncryptionOpCodes(random, encryptor, _encryptionLevel); - } - - public int GenerateSalt(IRandom random) - { - return random.NextInt(); - } - - private FieldEncryptInfo GetFieldEncryptInfo(FieldDef field) - { - if (_fieldEncryptInfoCache.TryGetValue(field, out var info)) - { - return info; - } - EncryptionScopeInfo encryptionScope = _encryptionScopeProvider.GetScope(field.Module); - - IRandom random = CreateRandomForField(encryptionScope.localRandomCreator, field); - IEncryptor encryptor = encryptionScope.encryptor; - int encryptOps = GenerateEncryptionOperations(random, encryptor); - int salt = GenerateSalt(random); - ElementType fieldType = field.FieldSig.Type.RemovePinnedAndModifiers().ElementType; - long xorValueForZero = CalcXorValueForZero(encryptor, fieldType, encryptOps, salt); - - info = new FieldEncryptInfo - { - encryptOps = encryptOps, - salt = salt, - fieldType = fieldType, - xorValueForZero = xorValueForZero, - }; - _fieldEncryptInfoCache[field] = info; - return info; - } - - public override void Encrypt(MethodDef method, FieldDef field, List outputInstructions, Instruction currentInstruction) - { - DefaultMetadataImporter importer = GetMetadataImporter(method); - EncryptionServiceMetadataImporter encryptionServiceMetadataImporter = importer.GetEncryptionServiceMetadataImporterOfModule(field.Module); - FieldEncryptInfo fei = GetFieldEncryptInfo(field); - if (fei.fieldType == ElementType.I4 || fei.fieldType == ElementType.U4 || fei.fieldType == ElementType.R4) - { - // value has been put on stack - - // encrypt - outputInstructions.Add(Instruction.CreateLdcI4(fei.encryptOps)); - outputInstructions.Add(Instruction.CreateLdcI4(fei.salt)); - outputInstructions.Add(Instruction.Create(OpCodes.Call, encryptionServiceMetadataImporter.EncryptInt)); - // xor - outputInstructions.Add(Instruction.CreateLdcI4((int)fei.xorValueForZero)); - outputInstructions.Add(Instruction.Create(OpCodes.Xor)); - } - else if (fei.fieldType == ElementType.I8 || fei.fieldType == ElementType.U8 || fei.fieldType == ElementType.R8) - { - // value has been put on stack - - // encrypt - outputInstructions.Add(Instruction.CreateLdcI4(fei.encryptOps)); - outputInstructions.Add(Instruction.CreateLdcI4(fei.salt)); - outputInstructions.Add(Instruction.Create(OpCodes.Call, encryptionServiceMetadataImporter.EncryptLong)); - // xor - outputInstructions.Add(Instruction.Create(OpCodes.Ldc_I8, fei.xorValueForZero)); - outputInstructions.Add(Instruction.Create(OpCodes.Xor)); - } - else - { - Assert.IsTrue(false, $"Unsupported field type: {fei.fieldType} for encryption"); - } - - outputInstructions.Add(currentInstruction.Clone()); - } - - public override void Decrypt(MethodDef method, FieldDef field, List outputInstructions, Instruction currentInstruction) - { - outputInstructions.Add(currentInstruction.Clone()); - DefaultMetadataImporter importer = GetMetadataImporter(method); - EncryptionServiceMetadataImporter encryptionServiceMetadataImporter = importer.GetEncryptionServiceMetadataImporterOfModule(field.Module); - FieldEncryptInfo fei = GetFieldEncryptInfo(field); - if (fei.fieldType == ElementType.I4 || fei.fieldType == ElementType.U4 || fei.fieldType == ElementType.R4) - { - // value has been put on stack - // xor - if (fei.fieldType == ElementType.R4) - { - outputInstructions.Add(Instruction.Create(OpCodes.Call, importer.CastFloatAsInt)); - } - outputInstructions.Add(Instruction.CreateLdcI4((int)fei.xorValueForZero)); - outputInstructions.Add(Instruction.Create(OpCodes.Xor)); - - // decrypt - outputInstructions.Add(Instruction.CreateLdcI4(fei.encryptOps)); - outputInstructions.Add(Instruction.CreateLdcI4(fei.salt)); - outputInstructions.Add(Instruction.Create(OpCodes.Call, encryptionServiceMetadataImporter.DecryptInt)); - } - else if (fei.fieldType == ElementType.I8 || fei.fieldType == ElementType.U8 || fei.fieldType == ElementType.R8) - { - // value has been put on stack - // xor - if (fei.fieldType == ElementType.R8) - { - outputInstructions.Add(Instruction.Create(OpCodes.Call, importer.CastDoubleAsLong)); - } - outputInstructions.Add(Instruction.Create(OpCodes.Ldc_I8, fei.xorValueForZero)); - outputInstructions.Add(Instruction.Create(OpCodes.Xor)); - - // decrypt - outputInstructions.Add(Instruction.CreateLdcI4(fei.encryptOps)); - outputInstructions.Add(Instruction.CreateLdcI4(fei.salt)); - outputInstructions.Add(Instruction.Create(OpCodes.Call, encryptionServiceMetadataImporter.DecryptLong)); - } - else - { - Assert.IsTrue(false, $"Unsupported field type: {fei.fieldType} for decryption"); - } - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/FieldEncrypt/DefaultFieldEncryptor.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/FieldEncrypt/DefaultFieldEncryptor.cs.meta deleted file mode 100644 index 905f446..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/FieldEncrypt/DefaultFieldEncryptor.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: b6707a66ae63e2c498d55088c6e8ef4a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/FieldEncrypt/FieldEncryptPass.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/FieldEncrypt/FieldEncryptPass.cs deleted file mode 100644 index 054044e..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/FieldEncrypt/FieldEncryptPass.cs +++ /dev/null @@ -1,108 +0,0 @@ -using dnlib.DotNet; -using dnlib.DotNet.Emit; -using Obfuz; -using Obfuz.Settings; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using UnityEngine; - -namespace Obfuz.ObfusPasses.FieldEncrypt -{ - - public class FieldEncryptPass : InstructionObfuscationPassBase - { - private readonly List _configFiles; - private readonly int _encryptionLevel; - private IEncryptPolicy _encryptionPolicy; - private IFieldEncryptor _memoryEncryptor; - - public override ObfuscationPassType Type => ObfuscationPassType.FieldEncrypt; - - public FieldEncryptPass(FieldEncryptionSettings settings) - { - _configFiles = settings.ruleFiles.ToList(); - _encryptionLevel = settings.encryptionLevel; - } - - protected override bool ForceProcessAllAssembliesAndIgnoreAllPolicy => true; - - public override void Start() - { - var ctx = ObfuscationPassContext.Current; - _memoryEncryptor = new DefaultFieldEncryptor(ctx.encryptionScopeProvider, ctx.moduleEntityManager, _encryptionLevel); - _encryptionPolicy = new ConfigurableEncryptPolicy(ctx.assembliesToObfuscate, _configFiles); - } - - public override void Stop() - { - - } - - protected override bool NeedObfuscateMethod(MethodDef method) - { - return true; - } - - private bool IsSupportedFieldType(TypeSig type) - { - type = type.RemovePinnedAndModifiers(); - switch (type.ElementType) - { - case ElementType.I4: - case ElementType.I8: - case ElementType.U4: - case ElementType.U8: - case ElementType.R4: - case ElementType.R8: - return true; - default: return false; - } - } - - protected override bool TryObfuscateInstruction(MethodDef callingMethod, Instruction inst, IList instructions, int instructionIndex, List outputInstructions, List totalFinalInstructions) - { - Code code = inst.OpCode.Code; - if (!(inst.Operand is IField field) || !field.IsField) - { - return false; - } - FieldDef fieldDef = field.ResolveFieldDefThrow(); - if (!IsSupportedFieldType(fieldDef.FieldSig.Type) || !_encryptionPolicy.NeedEncrypt(fieldDef)) - { - return false; - } - switch (code) - { - case Code.Ldfld: - { - _memoryEncryptor.Decrypt(callingMethod, fieldDef, outputInstructions, inst); - break; - } - case Code.Stfld: - { - _memoryEncryptor.Encrypt(callingMethod, fieldDef, outputInstructions, inst); - break; - } - case Code.Ldsfld: - { - _memoryEncryptor.Decrypt(callingMethod, fieldDef, outputInstructions, inst); - break; - } - case Code.Stsfld: - { - _memoryEncryptor.Encrypt(callingMethod, fieldDef, outputInstructions, inst); - break; - } - case Code.Ldflda: - case Code.Ldsflda: - { - throw new System.Exception($"You shouldn't get reference to memory encryption field: {field}"); - } - default: return false; - } - //Debug.Log($"memory encrypt field: {field}"); - return true; - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/FieldEncrypt/FieldEncryptPass.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/FieldEncrypt/FieldEncryptPass.cs.meta deleted file mode 100644 index 1e60f28..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/FieldEncrypt/FieldEncryptPass.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f3da24d0f1f1fc7449cbd0e7ddd03aa2 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/FieldEncrypt/IEncryptPolicy.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/FieldEncrypt/IEncryptPolicy.cs deleted file mode 100644 index a1a7705..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/FieldEncrypt/IEncryptPolicy.cs +++ /dev/null @@ -1,19 +0,0 @@ -using dnlib.DotNet; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Obfuz.ObfusPasses.FieldEncrypt -{ - public interface IEncryptPolicy - { - bool NeedEncrypt(FieldDef field); - } - - public abstract class EncryptPolicyBase : IEncryptPolicy - { - public abstract bool NeedEncrypt(FieldDef field); - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/FieldEncrypt/IEncryptPolicy.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/FieldEncrypt/IEncryptPolicy.cs.meta deleted file mode 100644 index d5c1047..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/FieldEncrypt/IEncryptPolicy.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a48d0500d0737404cad9c9ef23a9467c -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/FieldEncrypt/IFieldEncryptor.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/FieldEncrypt/IFieldEncryptor.cs deleted file mode 100644 index 7c9f7c3..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/FieldEncrypt/IFieldEncryptor.cs +++ /dev/null @@ -1,29 +0,0 @@ -using dnlib.DotNet; -using dnlib.DotNet.Emit; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Obfuz.ObfusPasses.FieldEncrypt -{ - public class MemoryEncryptionContext - { - public ModuleDef module; - - public Instruction currentInstruction; - } - - public interface IFieldEncryptor - { - void Encrypt(MethodDef method, FieldDef field, List outputInstructions, Instruction currentInstruction); - - void Decrypt(MethodDef method, FieldDef field, List outputInstructions, Instruction currentInstruction); - } - - public abstract class FieldEncryptorBase : IFieldEncryptor - { - public abstract void Encrypt(MethodDef method, FieldDef field, List outputInstructions, Instruction currentInstruction); - public abstract void Decrypt(MethodDef method, FieldDef field, List outputInstructions, Instruction currentInstruction); - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/FieldEncrypt/IFieldEncryptor.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/FieldEncrypt/IFieldEncryptor.cs.meta deleted file mode 100644 index dca5071..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/FieldEncrypt/IFieldEncryptor.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 8a3ec14fca5169d479529d21b2eeada1 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/InstructionObfuscationPassBase.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/InstructionObfuscationPassBase.cs deleted file mode 100644 index 4028c41..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/InstructionObfuscationPassBase.cs +++ /dev/null @@ -1,85 +0,0 @@ -using dnlib.DotNet.Emit; -using dnlib.DotNet; -using System.Collections.Generic; -using System.Linq; - -namespace Obfuz.ObfusPasses -{ - public abstract class InstructionObfuscationPassBase : ObfuscationPassBase - { - protected virtual bool ForceProcessAllAssembliesAndIgnoreAllPolicy => false; - - protected abstract bool NeedObfuscateMethod(MethodDef method); - - public override void Process() - { - var ctx = ObfuscationPassContext.Current; - var modules = ForceProcessAllAssembliesAndIgnoreAllPolicy ? ctx.allObfuscationRelativeModules : ctx.modulesToObfuscate; - ObfuscationMethodWhitelist whiteList = ctx.whiteList; - ConfigurablePassPolicy passPolicy = ctx.passPolicy; - foreach (ModuleDef mod in modules) - { - if (!ForceProcessAllAssembliesAndIgnoreAllPolicy && (whiteList.IsInWhiteList(mod) || !Support(passPolicy.GetAssemblyObfuscationPasses(mod)))) - { - continue; - } - // ToArray to avoid modify list exception - foreach (TypeDef type in mod.GetTypes().ToArray()) - { - if (!ForceProcessAllAssembliesAndIgnoreAllPolicy && (whiteList.IsInWhiteList(type) || !Support(passPolicy.GetTypeObfuscationPasses(type)))) - { - continue; - } - // ToArray to avoid modify list exception - foreach (MethodDef method in type.Methods.ToArray()) - { - if (!method.HasBody || (!ForceProcessAllAssembliesAndIgnoreAllPolicy && (ctx.whiteList.IsInWhiteList(method) || !Support(passPolicy.GetMethodObfuscationPasses(method)) || !NeedObfuscateMethod(method)))) - { - continue; - } - // TODO if isGeneratedBy Obfuscator, continue - ObfuscateData(method); - } - } - } - } - - - protected abstract bool TryObfuscateInstruction(MethodDef callingMethod, Instruction inst, IList instructions, int instructionIndex, - List outputInstructions, List totalFinalInstructions); - - private void ObfuscateData(MethodDef method) - { - IList instructions = method.Body.Instructions; - var outputInstructions = new List(); - var totalFinalInstructions = new List(); - for (int i = 0; i < instructions.Count; i++) - { - Instruction inst = instructions[i]; - outputInstructions.Clear(); - if (TryObfuscateInstruction(method, inst, instructions, i, outputInstructions, totalFinalInstructions)) - { - // current instruction may be the target of control flow instruction, so we can't remove it directly. - // we replace it with nop now, then remove it in CleanUpInstructionPass - inst.OpCode = outputInstructions[0].OpCode; - inst.Operand = outputInstructions[0].Operand; - totalFinalInstructions.Add(inst); - for (int k = 1; k < outputInstructions.Count; k++) - { - totalFinalInstructions.Add(outputInstructions[k]); - } - } - else - { - totalFinalInstructions.Add(inst); - } - } - - instructions.Clear(); - foreach (var obInst in totalFinalInstructions) - { - instructions.Add(obInst); - } - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/InstructionObfuscationPassBase.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/InstructionObfuscationPassBase.cs.meta deleted file mode 100644 index ba2497a..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/InstructionObfuscationPassBase.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: e0cad4b764050f44f8c9b225056a4f49 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ObfuscationPassBase.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ObfuscationPassBase.cs deleted file mode 100644 index b3aaf0c..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ObfuscationPassBase.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Obfuz.Emit; - -namespace Obfuz.ObfusPasses -{ - public abstract class ObfuscationPassBase : IObfuscationPass - { - public abstract ObfuscationPassType Type { get; } - - public bool Support(ObfuscationPassType passType) - { - return passType.HasFlag(Type); - } - - public abstract void Start(); - - public abstract void Stop(); - - public abstract void Process(); - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ObfuscationPassBase.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ObfuscationPassBase.cs.meta deleted file mode 100644 index 335ee27..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ObfuscationPassBase.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 2f3e7e1d2a3ad3a4fb1a81e97730b5a4 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ObfuscationPassType.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ObfuscationPassType.cs deleted file mode 100644 index ec28ad3..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ObfuscationPassType.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; - -namespace Obfuz.ObfusPasses -{ - [Flags] - public enum ObfuscationPassType - { - None = 0, - - ConstEncrypt = 0x1, - FieldEncrypt = 0x2, - - SymbolObfus = 0x100, - CallObfus = 0x200, - ExprObfus = 0x400, - ControlFlowObfus = 0x800, - - AllObfus = SymbolObfus | CallObfus | ExprObfus | ControlFlowObfus, - AllEncrypt = ConstEncrypt | FieldEncrypt, - - MethodBodyObfusOrEncrypt = ConstEncrypt | CallObfus | ExprObfus | ControlFlowObfus, - - All = ~0, - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ObfuscationPassType.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ObfuscationPassType.cs.meta deleted file mode 100644 index b03ea20..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/ObfuscationPassType.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 5addd02f6f3dc0a4d888a0f74bd5ce4d -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus.meta deleted file mode 100644 index 331b3d1..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: b746569f7c0d9754fa6f2925538eddbd -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/INameMaker.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/INameMaker.cs deleted file mode 100644 index 184ce1b..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/INameMaker.cs +++ /dev/null @@ -1,33 +0,0 @@ -using dnlib.DotNet; - -namespace Obfuz.ObfusPasses.SymbolObfus -{ - public interface INameMaker - { - void AddPreservedName(TypeDef typeDef, string name); - - void AddPreservedNamespace(TypeDef typeDef, string name); - - void AddPreservedName(MethodDef methodDef, string name); - - void AddPreservedName(FieldDef fieldDef, string name); - - void AddPreservedName(PropertyDef propertyDef, string name); - - void AddPreservedName(EventDef eventDef, string name); - - string GetNewName(TypeDef typeDef, string originalName); - - string GetNewNamespace(TypeDef typeDef, string originalNamespace, bool reuse); - - string GetNewName(MethodDef methodDef, string originalName); - - string GetNewName(ParamDef param, string originalName); - - string GetNewName(FieldDef fieldDef, string originalName); - - string GetNewName(PropertyDef propertyDef, string originalName); - - string GetNewName(EventDef eventDef, string originalName); - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/INameMaker.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/INameMaker.cs.meta deleted file mode 100644 index 8062197..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/INameMaker.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 0c24d29f654d00b44bb6aa3b4bf222dd -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/IObfuscationPolicy.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/IObfuscationPolicy.cs deleted file mode 100644 index 2a39e45..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/IObfuscationPolicy.cs +++ /dev/null @@ -1,17 +0,0 @@ -using dnlib.DotNet; - -namespace Obfuz.ObfusPasses.SymbolObfus -{ - public interface IObfuscationPolicy - { - bool NeedRename(TypeDef typeDef); - - bool NeedRename(MethodDef methodDef); - - bool NeedRename(FieldDef fieldDef); - - bool NeedRename(PropertyDef propertyDef); - - bool NeedRename(EventDef eventDef); - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/IObfuscationPolicy.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/IObfuscationPolicy.cs.meta deleted file mode 100644 index ffe0fee..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/IObfuscationPolicy.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: bd640b26c1d868544a7a91a0f986fdde -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/NameMakers.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/NameMakers.meta deleted file mode 100644 index 9cd6e53..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/NameMakers.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: c970ffd992fbc154aaa37a2c48c24d5c -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/NameMakers/DebugNameMaker.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/NameMakers/DebugNameMaker.cs deleted file mode 100644 index b7b4e3f..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/NameMakers/DebugNameMaker.cs +++ /dev/null @@ -1,29 +0,0 @@ -using dnlib.DotNet; -using System.Text; - -namespace Obfuz.ObfusPasses.SymbolObfus.NameMakers -{ - public class DebugNameMaker : NameMakerBase - { - private class TestNameScope : NameScopeBase - { - private int _nextIndex; - protected override void BuildNewName(StringBuilder nameBuilder, string originalName, string lastName) - { - if (string.IsNullOrEmpty(lastName)) - { - nameBuilder.Append($"${originalName}"); - } - else - { - nameBuilder.Append($"${originalName}{_nextIndex++}"); - } - } - } - - protected override INameScope CreateNameScope() - { - return new TestNameScope(); - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/NameMakers/DebugNameMaker.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/NameMakers/DebugNameMaker.cs.meta deleted file mode 100644 index 11b505b..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/NameMakers/DebugNameMaker.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: abc1adfad5c7754499ceed4d4646eb58 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/NameMakers/INameScope.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/NameMakers/INameScope.cs deleted file mode 100644 index 9fb5a98..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/NameMakers/INameScope.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Obfuz.ObfusPasses.SymbolObfus.NameMakers -{ - public interface INameScope - { - void AddPreservedName(string name); - - string GetNewName(string originalName, bool reuse); - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/NameMakers/INameScope.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/NameMakers/INameScope.cs.meta deleted file mode 100644 index 4c63253..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/NameMakers/INameScope.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 6c3884d338faf564eab48d58f02adc39 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/NameMakers/NameMakerBase.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/NameMakers/NameMakerBase.cs deleted file mode 100644 index 157aeab..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/NameMakers/NameMakerBase.cs +++ /dev/null @@ -1,103 +0,0 @@ -using dnlib.DotNet; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Obfuz.ObfusPasses.SymbolObfus.NameMakers -{ - public abstract class NameMakerBase : INameMaker - { - - private readonly Dictionary _nameScopes = new Dictionary(); - - private readonly object _namespaceScope = new object(); - - protected abstract INameScope CreateNameScope(); - - protected INameScope GetNameScope(object key) - { - if (!_nameScopes.TryGetValue(key, out var nameScope)) - { - nameScope = CreateNameScope(); - _nameScopes[key] = nameScope; - } - return nameScope; - } - - public void AddPreservedName(TypeDef typeDef, string name) - { - GetNameScope(typeDef.Module).AddPreservedName(name); - } - - public void AddPreservedName(MethodDef methodDef, string name) - { - GetNameScope(methodDef.DeclaringType).AddPreservedName(name); - } - - public void AddPreservedName(FieldDef fieldDef, string name) - { - GetNameScope(fieldDef.DeclaringType).AddPreservedName(name); - } - - public void AddPreservedName(PropertyDef propertyDef, string name) - { - GetNameScope(propertyDef.DeclaringType).AddPreservedName(name); - } - - public void AddPreservedName(EventDef eventDef, string name) - { - GetNameScope(eventDef.DeclaringType).AddPreservedName(name); - } - - public void AddPreservedNamespace(TypeDef typeDef, string name) - { - GetNameScope(_namespaceScope).AddPreservedName(name); - } - - private string GetDefaultNewName(object scope, string originName) - { - return GetNameScope(scope).GetNewName(originName, false); - } - - public string GetNewNamespace(TypeDef typeDef, string originalNamespace, bool reuse) - { - if (string.IsNullOrEmpty(originalNamespace)) - { - return string.Empty; - } - return GetNameScope(_namespaceScope).GetNewName(originalNamespace, reuse); - } - - public string GetNewName(TypeDef typeDef, string originalName) - { - return GetDefaultNewName(typeDef.Module, originalName); - } - - public string GetNewName(MethodDef methodDef, string originalName) - { - return (methodDef.IsVirtual ? ">" : "") + GetDefaultNewName(methodDef.DeclaringType, originalName); - } - - public virtual string GetNewName(ParamDef param, string originalName) - { - return "1"; - } - - public string GetNewName(FieldDef fieldDef, string originalName) - { - return GetDefaultNewName(fieldDef.DeclaringType, originalName); - } - - public string GetNewName(PropertyDef propertyDef, string originalName) - { - return GetDefaultNewName(propertyDef.DeclaringType, originalName); - } - - public string GetNewName(EventDef eventDef, string originalName) - { - return GetDefaultNewName(eventDef.DeclaringType, originalName); - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/NameMakers/NameMakerBase.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/NameMakers/NameMakerBase.cs.meta deleted file mode 100644 index d3ca8a0..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/NameMakers/NameMakerBase.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 205da3a8ebfd4ae4ba72d27db4b92d3f -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/NameMakers/NameMakerFactory.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/NameMakers/NameMakerFactory.cs deleted file mode 100644 index b0ba913..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/NameMakers/NameMakerFactory.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.Remoting.Messaging; -using System.Text; -using System.Threading.Tasks; - -namespace Obfuz.ObfusPasses.SymbolObfus.NameMakers -{ - public static class NameMakerFactory - { - public static INameMaker CreateDebugNameMaker() - { - return new DebugNameMaker(); - } - - public static INameMaker CreateNameMakerBaseASCIICharSet(string namePrefix) - { - var words = new List(); - for (int i = 0; i < 26; i++) - { - words.Add(((char)('a' + i)).ToString()); - words.Add(((char)('A' + i)).ToString()); - } - return new WordSetNameMaker(namePrefix, words); - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/NameMakers/NameMakerFactory.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/NameMakers/NameMakerFactory.cs.meta deleted file mode 100644 index e1fb22c..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/NameMakers/NameMakerFactory.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: afa0e87123ec9854b806098330c4980a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/NameMakers/NameScope.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/NameMakers/NameScope.cs deleted file mode 100644 index 610f845..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/NameMakers/NameScope.cs +++ /dev/null @@ -1,35 +0,0 @@ -using Microsoft.SqlServer.Server; -using System.Collections.Generic; -using System.Text; - -namespace Obfuz.ObfusPasses.SymbolObfus.NameMakers -{ - - public class NameScope : NameScopeBase - { - private readonly string _namePrefix; - private readonly List _wordSet; - private int _nextIndex; - - public NameScope(string namePrefix, List wordSet) - { - _namePrefix = namePrefix; - _wordSet = wordSet; - _nextIndex = 0; - } - - protected override void BuildNewName(StringBuilder nameBuilder, string originalName, string lastName) - { - nameBuilder.Append(_namePrefix); - for (int i = _nextIndex++; ;) - { - nameBuilder.Append(_wordSet[i % _wordSet.Count]); - i = i / _wordSet.Count; - if (i == 0) - { - break; - } - } - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/NameMakers/NameScope.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/NameMakers/NameScope.cs.meta deleted file mode 100644 index e224237..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/NameMakers/NameScope.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a35c5c4b49c98a84f94b690c26900c33 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/NameMakers/NameScopeBase.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/NameMakers/NameScopeBase.cs deleted file mode 100644 index 4f3d213..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/NameMakers/NameScopeBase.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System.Collections.Generic; -using System.Text; - -namespace Obfuz.ObfusPasses.SymbolObfus.NameMakers -{ - public abstract class NameScopeBase : INameScope - { - - private readonly Dictionary _nameMap = new Dictionary(); - - private readonly HashSet _preservedNames = new HashSet(); - - - public void AddPreservedName(string name) - { - if (!string.IsNullOrEmpty(name)) - { - _preservedNames.Add(name); - } - } - - - protected abstract void BuildNewName(StringBuilder nameBuilder, string originalName, string lastName); - - private string CreateNewName(string originalName) - { - var nameBuilder = new StringBuilder(); - string lastName = null; - while (true) - { - nameBuilder.Clear(); - BuildNewName(nameBuilder, originalName, lastName); - string newName = nameBuilder.ToString(); - lastName = newName; - if (_preservedNames.Add(newName)) - { - return newName; - } - } - } - - public string GetNewName(string originalName, bool reuse) - { - if (!reuse) - { - return CreateNewName(originalName); - } - if (_nameMap.TryGetValue(originalName, out var newName)) - { - return newName; - } - newName = CreateNewName(originalName); - _nameMap[originalName] = newName; - return newName; - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/NameMakers/NameScopeBase.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/NameMakers/NameScopeBase.cs.meta deleted file mode 100644 index 17853c8..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/NameMakers/NameScopeBase.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 26e6ae1f35e7f094c844cf1567b88a19 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/NameMakers/WordSetNameMaker.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/NameMakers/WordSetNameMaker.cs deleted file mode 100644 index 8e8b5db..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/NameMakers/WordSetNameMaker.cs +++ /dev/null @@ -1,26 +0,0 @@ -using dnlib.DotNet; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace Obfuz.ObfusPasses.SymbolObfus.NameMakers -{ - - public class WordSetNameMaker : NameMakerBase - { - private readonly string _namePrefix; - private readonly List _wordSet; - - public WordSetNameMaker(string namePrefix, List wordSet) - { - _namePrefix = namePrefix; - _wordSet = wordSet; - } - - protected override INameScope CreateNameScope() - { - return new NameScope(_namePrefix, _wordSet); - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/NameMakers/WordSetNameMaker.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/NameMakers/WordSetNameMaker.cs.meta deleted file mode 100644 index 23706b3..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/NameMakers/WordSetNameMaker.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 47c92aea40a66e34b92f9eb5c0d380ca -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies.meta deleted file mode 100644 index c16875c..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 98e496436c90c0a4f82711af059471c7 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/CacheRenamePolicy.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/CacheRenamePolicy.cs deleted file mode 100644 index ba6e9c6..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/CacheRenamePolicy.cs +++ /dev/null @@ -1,68 +0,0 @@ -using dnlib.DotNet; -using System.Collections.Generic; -using System.Linq; - -namespace Obfuz.ObfusPasses.SymbolObfus.Policies -{ - public class CacheRenamePolicy : ObfuscationPolicyBase - { - private readonly IObfuscationPolicy _underlyingPolicy; - - private readonly Dictionary _computeCache = new Dictionary(); - - public CacheRenamePolicy(IObfuscationPolicy underlyingPolicy) - { - _underlyingPolicy = underlyingPolicy; - } - - public override bool NeedRename(TypeDef typeDef) - { - if (!_computeCache.TryGetValue(typeDef, out var value)) - { - value = _underlyingPolicy.NeedRename(typeDef); - _computeCache[typeDef] = value; - } - return value; - } - - public override bool NeedRename(MethodDef methodDef) - { - if (!_computeCache.TryGetValue(methodDef, out var value)) - { - value = _underlyingPolicy.NeedRename(methodDef); - _computeCache[methodDef] = value; - } - return value; - } - - public override bool NeedRename(FieldDef fieldDef) - { - if (!_computeCache.TryGetValue(fieldDef, out var value)) - { - value = _underlyingPolicy.NeedRename(fieldDef); - _computeCache[fieldDef] = value; - } - return value; - } - - public override bool NeedRename(PropertyDef propertyDef) - { - if (!_computeCache.TryGetValue(propertyDef, out var value)) - { - value = _underlyingPolicy.NeedRename(propertyDef); - _computeCache[propertyDef] = value; - } - return value; - } - - public override bool NeedRename(EventDef eventDef) - { - if (!_computeCache.TryGetValue(eventDef, out var value)) - { - value = _underlyingPolicy.NeedRename(eventDef); - _computeCache[eventDef] = value; - } - return value; - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/CacheRenamePolicy.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/CacheRenamePolicy.cs.meta deleted file mode 100644 index ab4330f..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/CacheRenamePolicy.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c319b2ad62ad8794f9a8bc234c856d7f -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/CombineRenamePolicy.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/CombineRenamePolicy.cs deleted file mode 100644 index a84a587..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/CombineRenamePolicy.cs +++ /dev/null @@ -1,40 +0,0 @@ -using dnlib.DotNet; -using System.Linq; - -namespace Obfuz.ObfusPasses.SymbolObfus.Policies -{ - public class CombineRenamePolicy : IObfuscationPolicy - { - private readonly IObfuscationPolicy[] _policies; - - public CombineRenamePolicy(params IObfuscationPolicy[] policies) - { - _policies = policies; - } - - public bool NeedRename(TypeDef typeDef) - { - return _policies.All(policy => policy.NeedRename(typeDef)); - } - - public bool NeedRename(MethodDef methodDef) - { - return _policies.All(policy => policy.NeedRename(methodDef)); - } - - public bool NeedRename(FieldDef fieldDef) - { - return _policies.All(policy => policy.NeedRename(fieldDef)); - } - - public bool NeedRename(PropertyDef propertyDef) - { - return _policies.All(policy => policy.NeedRename(propertyDef)); - } - - public bool NeedRename(EventDef eventDef) - { - return _policies.All(policy => policy.NeedRename(eventDef)); - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/CombineRenamePolicy.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/CombineRenamePolicy.cs.meta deleted file mode 100644 index fcf6ea9..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/CombineRenamePolicy.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 97be4546adeb71947bf644949c3a9e82 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/ConfigurableRenamePolicy.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/ConfigurableRenamePolicy.cs deleted file mode 100644 index 7122956..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/ConfigurableRenamePolicy.cs +++ /dev/null @@ -1,699 +0,0 @@ -using dnlib.DotNet; -using Obfuz.Conf; -using Obfuz.Utils; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Xml; -using System.Xml.Linq; -using UnityEngine; - -namespace Obfuz.ObfusPasses.SymbolObfus.Policies -{ - - public class ConfigurableRenamePolicy : ObfuscationPolicyBase - { - enum RuleType - { - Assembly = 1, - Type = 2, - Method = 3, - Field = 4, - Property = 5, - Event = 6, - } - - enum ModifierType - { - None = 0x0, - Private = 0x1, - Protected = 0x2, - Public = 0x3, - } - - class MethodRuleSpec - { - public NameMatcher nameMatcher; - public ModifierType? modifierType; - public bool? obfuscateName; - } - - class FieldRuleSpec - { - public NameMatcher nameMatcher; - public ModifierType? modifierType; - public bool? obfuscateName; - } - - class PropertyRuleSpec - { - public NameMatcher nameMatcher; - public ModifierType? modifierType; - public bool? obfuscateName; - public bool? obfuscateGetter; - public bool? obfuscateSetter; - } - - class EventRuleSpec - { - public NameMatcher nameMatcher; - public ModifierType? modifierType; - public bool? obfuscateName; - public bool? obfuscateAdd; - public bool? obfuscateRemove; - public bool? obfuscateFire; - } - - class TypeRuleSpec - { - public NameMatcher nameMatcher; - public ModifierType? modifierType; - public ClassType? classType; - public bool? obfuscateName; - public bool? obfuscateNamespace; - public List fields; - public List methods; - public List properties; - public List events; - } - - class AssemblyRuleSpec - { - public string assemblyName; - public bool? obfuscateName; - public List types; - } - - private readonly Dictionary _assemblyRuleSpecs = new Dictionary(); - - private AssemblyRuleSpec ParseAssembly(XmlElement ele) - { - string assemblyName = ele.GetAttribute("name"); - if (string.IsNullOrEmpty(assemblyName)) - { - throw new Exception($"Invalid xml file, assembly name is empty"); - } - if (!_obfuscationAssemblyNames.Contains(assemblyName)) - { - throw new Exception($"unknown assembly name:{assemblyName}, not in ObfuzSettings.obfuscationAssemblyNames"); - } - if (_assemblyRuleSpecs.ContainsKey(assemblyName)) - { - throw new Exception($"Invalid xml file, duplicate assembly name {assemblyName}"); - } - var rule = new AssemblyRuleSpec() - { - assemblyName = assemblyName, - obfuscateName = ConfigUtil.ParseNullableBool(ele.GetAttribute("obName")), - types = new List(), - }; - - foreach (XmlNode node in ele.ChildNodes) - { - if (!(node is XmlElement childElement)) - { - continue; - } - if (childElement.Name != "type") - { - throw new Exception($"Invalid xml file, unknown node {childElement.Name}"); - } - TypeRuleSpec type = ParseType(childElement); - rule.types.Add(type); - } - return rule; - } - - private enum ClassType - { - None = 0x0, - Class = 0x1, - Struct = 0x2, - Interface = 0x4, - Enum = 0x8, - Delegate = 0x10, - } - - private ClassType? ParseClassType(string classType) - { - if (string.IsNullOrEmpty(classType)) - { - return null; - } - - ClassType type = ClassType.None; - foreach (var s in classType.Split('|')) - { - switch (s) - { - case "class": type |= ClassType.Class; break; - case "struct": type |= ClassType.Struct; break; - case "interface": type |= ClassType.Interface; break; - case "enum": type |= ClassType.Enum; break; - case "delegate": type |= ClassType.Delegate; break; - default: throw new Exception($"Invalid class type {s}"); - } - } - return type; - } - - private ModifierType? ParseModifierType(string modifierType) - { - if (string.IsNullOrEmpty(modifierType)) - { - return null; - } - ModifierType type = ModifierType.None; - foreach (var s in modifierType.Split('|')) - { - switch (s) - { - case "public": type |= ModifierType.Public; break; - case "protected": type |= ModifierType.Protected; break; - case "private": type |= ModifierType.Private; break; - default: throw new Exception($"Invalid modifier type {s}"); - } - } - return type; - } - - private TypeRuleSpec ParseType(XmlElement element) - { - var rule = new TypeRuleSpec(); - - rule.nameMatcher = new NameMatcher(element.GetAttribute("name")); - rule.obfuscateName = ConfigUtil.ParseNullableBool(element.GetAttribute("obName")); - rule.obfuscateNamespace = ConfigUtil.ParseNullableBool(element.GetAttribute("obNamespace")); - rule.modifierType = ParseModifierType(element.GetAttribute("modifier")); - rule.classType = ParseClassType(element.GetAttribute("classType")); - - //rule.nestTypeRuleSpecs = new List(); - rule.fields = new List(); - rule.methods = new List(); - rule.properties = new List(); - rule.events = new List(); - foreach (XmlNode node in element.ChildNodes) - { - if (!(node is XmlElement childElement)) - { - continue; - } - switch (childElement.Name) - { - case "field": - { - var fieldRuleSpec = new FieldRuleSpec(); - fieldRuleSpec.nameMatcher = new NameMatcher(childElement.GetAttribute("name")); - fieldRuleSpec.modifierType = ParseModifierType(childElement.GetAttribute("modifier")); - fieldRuleSpec.obfuscateName = ConfigUtil.ParseNullableBool(childElement.GetAttribute("obName")); - rule.fields.Add(fieldRuleSpec); - break; - } - case "method": - { - var methodRuleSpec = new MethodRuleSpec(); - methodRuleSpec.nameMatcher = new NameMatcher(childElement.GetAttribute("name")); - methodRuleSpec.modifierType = ParseModifierType(childElement.GetAttribute("modifier")); - methodRuleSpec.obfuscateName = ConfigUtil.ParseNullableBool(childElement.GetAttribute("obName")); - rule.methods.Add(methodRuleSpec); - break; - } - case "property": - { - var propertyRulerSpec = new PropertyRuleSpec(); - propertyRulerSpec.nameMatcher = new NameMatcher(childElement.GetAttribute("name")); - propertyRulerSpec.modifierType = ParseModifierType(childElement.GetAttribute("modifier")); - propertyRulerSpec.obfuscateName = ConfigUtil.ParseNullableBool(childElement.GetAttribute("obName")); - propertyRulerSpec.obfuscateGetter = ConfigUtil.ParseNullableBool(childElement.GetAttribute("obGetter")); - propertyRulerSpec.obfuscateSetter = ConfigUtil.ParseNullableBool(childElement.GetAttribute("obSetter")); - rule.properties.Add(propertyRulerSpec); - break; - } - case "event": - { - var eventRuleSpec = new EventRuleSpec(); - eventRuleSpec.nameMatcher = new NameMatcher(childElement.GetAttribute("name")); - eventRuleSpec.modifierType = ParseModifierType(childElement.GetAttribute("modifier")); - eventRuleSpec.obfuscateName = ConfigUtil.ParseNullableBool(childElement.GetAttribute("obName")); - eventRuleSpec.obfuscateAdd = ConfigUtil.ParseNullableBool(childElement.GetAttribute("obAdd")); - eventRuleSpec.obfuscateRemove = ConfigUtil.ParseNullableBool(childElement.GetAttribute("obRemove")); - eventRuleSpec.obfuscateFire = ConfigUtil.ParseNullableBool(childElement.GetAttribute("obFire")); - rule.events.Add(eventRuleSpec); - break; - } - default: throw new Exception($"Invalid xml file, unknown node {childElement.Name} in type node"); - } - } - return rule; - } - - private void LoadXmls(List xmlFiles) - { - var rawAssemblySpecElements = new List(); - foreach (string file in xmlFiles) - { - LoadRawXml(file, rawAssemblySpecElements); - } - ResolveAssemblySpecs(rawAssemblySpecElements); - } - - private void ResolveAssemblySpecs(List rawAssemblySpecElements) - { - foreach (XmlElement ele in rawAssemblySpecElements) - { - var assemblyRule = ParseAssembly(ele); - _assemblyRuleSpecs.Add(assemblyRule.assemblyName, assemblyRule); - } - } - - private void LoadRawXml(string xmlFile, List rawAssemblyElements) - { - Debug.Log($"ObfuscateRule::LoadXml {xmlFile}"); - var doc = new XmlDocument(); - doc.Load(xmlFile); - var root = doc.DocumentElement; - if (root.Name != "obfuz") - { - throw new Exception($"Invalid xml file {xmlFile}, root name should be 'obfuz'"); - } - foreach (XmlNode node in root.ChildNodes) - { - if (!(node is XmlElement element)) - { - continue; - } - switch (element.Name) - { - case "assembly": - { - rawAssemblyElements.Add(element); - break; - } - default: - { - throw new Exception($"Invalid xml file {xmlFile}, unknown node {element.Name}"); - } - } - } - } - - private ModifierType ComputeModifierType(TypeAttributes visibility) - { - if (visibility == TypeAttributes.NotPublic || visibility == TypeAttributes.NestedPrivate) - { - return ModifierType.Private; - } - if (visibility == TypeAttributes.Public || visibility == TypeAttributes.NestedPublic) - { - return ModifierType.Public; - } - return ModifierType.Protected; - } - - private ModifierType ComputeModifierType(FieldAttributes access) - { - if (access == FieldAttributes.Private || access == FieldAttributes.PrivateScope) - { - return ModifierType.Private; - } - if (access == FieldAttributes.Public) - { - return ModifierType.Public; - } - return ModifierType.Protected; - } - - //private ModifierType ComputeModifierType(MethodAttributes access) - //{ - // if (access == MethodAttributes.Private || access == MethodAttributes.PrivateScope) - // { - // return ModifierType.Private; - // } - // if (access == MethodAttributes.Public) - // { - // return ModifierType.Public; - // } - // return ModifierType.Protected; - //} - - private bool MatchModifier(ModifierType? modifierType, TypeDef typeDef) - { - return modifierType == null || (modifierType & ComputeModifierType(typeDef.Visibility)) != 0; - } - - private bool MatchModifier(ModifierType? modifierType, FieldDef fieldDef) - { - return modifierType == null || (modifierType & ComputeModifierType(fieldDef.Access)) != 0; - } - - private bool MatchModifier(ModifierType? modifierType, MethodDef methodDef) - { - return modifierType == null || (modifierType & ComputeModifierType((FieldAttributes)methodDef.Access)) != 0; - } - - private bool MatchModifier(ModifierType? modifierType, PropertyDef propertyDef) - { - return modifierType == null || (modifierType & ComputeModifierType((FieldAttributes)propertyDef.Attributes)) != 0; - } - - private bool MatchModifier(ModifierType? modifierType, EventDef eventDef) - { - return modifierType == null || (modifierType & ComputeModifierType((FieldAttributes)eventDef.Attributes)) != 0; - } - - private class MethodComputeCache - { - public bool obfuscateName = true; - public bool obfuscateParam = true; - public bool obfuscateBody = true; - } - - //private class TypeDefComputeCache - //{ - // public bool obfuscateName = true; - // public bool obfuscateNamespace = true; - - // public readonly Dictionary methods = new Dictionary(); - - // public readonly HashSet notObfuscatedFields = new HashSet(); - - // public readonly HashSet notObfuscatedProperties = new HashSet(); - - // public readonly HashSet notObfuscatedEvents = new HashSet(); - //} - - private readonly Dictionary _typeSpecCache = new Dictionary(); - private readonly Dictionary _methodSpecCache = new Dictionary(); - private readonly Dictionary _fieldSpecCache = new Dictionary(); - private readonly Dictionary _propertySpecCache = new Dictionary(); - private readonly Dictionary _eventSpecCache = new Dictionary(); - - - private readonly HashSet _obfuscationAssemblyNames; - - public ConfigurableRenamePolicy(List obfuscationAssemblyNames, List xmlFiles) - { - _obfuscationAssemblyNames = new HashSet(obfuscationAssemblyNames); - LoadXmls(xmlFiles); - } - - private void BuildDefaultTypeMemberCache(TypeDef typeDef, TypeRuleSpec typeRule) - { - foreach (var fieldDef in typeDef.Fields) - { - var fieldRule = new FieldRuleSpec() - { - obfuscateName = typeRule.obfuscateName, - }; - _fieldSpecCache.Add(fieldDef, fieldRule); - } - foreach (var eventDef in typeDef.Events) - { - var eventRule = new EventRuleSpec() - { - obfuscateName = typeRule.obfuscateName, - obfuscateAdd = typeRule.obfuscateName, - obfuscateRemove = typeRule.obfuscateName, - obfuscateFire = typeRule.obfuscateName, - }; - _eventSpecCache.Add(eventDef, eventRule); - } - foreach (var propertyDef in typeDef.Properties) - { - var propertyRule = new PropertyRuleSpec() - { - obfuscateName = typeRule.obfuscateName, - obfuscateGetter = typeRule.obfuscateName, - obfuscateSetter = typeRule.obfuscateName, - }; - _propertySpecCache.Add(propertyDef, propertyRule); - } - foreach (MethodDef methodDef in typeDef.Methods) - { - var methodRule = new MethodRuleSpec() - { - obfuscateName = typeRule.obfuscateName, - }; - _methodSpecCache.Add(methodDef, methodRule); - } - } - - private bool MatchClassType(ClassType? classType, TypeDef typeDef) - { - if (classType == null) - { - return true; - } - if (typeDef.IsInterface && (classType & ClassType.Interface) != 0) - { - return true; - } - if (typeDef.IsEnum && (classType & ClassType.Enum) != 0) - { - return true; - } - if (typeDef.IsDelegate && (classType & ClassType.Delegate) != 0) - { - return true; - } - if (typeDef.IsValueType && !typeDef.IsEnum && (classType & ClassType.Struct) != 0) - { - return true; - } - if (!typeDef.IsValueType && !typeDef.IsInterface && !typeDef.IsDelegate && (classType & ClassType.Class) != 0) - { - return true; - } - return false; - } - - private TypeRuleSpec GetOrCreateTypeDefRenameComputeCache(TypeDef typeDef) - { - if (_typeSpecCache.TryGetValue(typeDef, out var typeRule)) - { - return typeRule; - } - typeRule = new TypeRuleSpec(); - _typeSpecCache.Add(typeDef, typeRule); - - if (!_assemblyRuleSpecs.TryGetValue(typeDef.Module.Assembly.Name, out var assemblyRuleSpec)) - { - typeRule.obfuscateName = true; - typeRule.obfuscateNamespace = true; - BuildDefaultTypeMemberCache(typeDef, typeRule); - return typeRule; - } - - typeRule.obfuscateName = assemblyRuleSpec.obfuscateName ?? true; - typeRule.obfuscateNamespace = assemblyRuleSpec.obfuscateName ?? true; - - if (typeDef.DeclaringType != null) - { - TypeRuleSpec declaringTypeSpec = GetOrCreateTypeDefRenameComputeCache(typeDef.DeclaringType); - if (declaringTypeSpec.obfuscateName != null) - { - typeRule.obfuscateName = declaringTypeSpec.obfuscateName; - } - if (declaringTypeSpec.obfuscateNamespace != null) - { - typeRule.obfuscateNamespace = declaringTypeSpec.obfuscateNamespace; - } - } - - string typeName = typeDef.FullName; - bool findMatch = false; - foreach (var typeSpec in assemblyRuleSpec.types) - { - if (!typeSpec.nameMatcher.IsMatch(typeName) || !MatchModifier(typeSpec.modifierType, typeDef) || !MatchClassType(typeSpec.classType, typeDef)) - { - continue; - } - findMatch = true; - if (typeSpec.obfuscateName != null) - { - typeRule.obfuscateName = typeSpec.obfuscateName; - } - if (typeSpec.obfuscateNamespace != null) - { - typeRule.obfuscateNamespace = typeSpec.obfuscateNamespace; - } - - - foreach (var fieldDef in typeDef.Fields) - { - var fieldRule = new FieldRuleSpec() - { - obfuscateName = typeRule.obfuscateName, - }; - _fieldSpecCache.Add(fieldDef, fieldRule); - foreach (var fieldSpec in typeSpec.fields) - { - if (fieldSpec.nameMatcher.IsMatch(fieldDef.Name) && MatchModifier(fieldSpec.modifierType, fieldDef)) - { - if (fieldSpec.obfuscateName != null) - { - fieldRule.obfuscateName = fieldSpec.obfuscateName; - } - break; - } - } - } - - var methodObfuscateFromPropertyOrEvent = new Dictionary(); - - foreach (var eventDef in typeDef.Events) - { - var eventRule = new EventRuleSpec() - { - obfuscateName = typeRule.obfuscateName, - obfuscateAdd = typeRule.obfuscateName, - obfuscateRemove = typeRule.obfuscateName, - obfuscateFire = typeRule.obfuscateName, - }; - _eventSpecCache.Add(eventDef, eventRule); - foreach (var eventSpec in typeSpec.events) - { - if (!eventSpec.nameMatcher.IsMatch(eventDef.Name) || !MatchModifier(eventSpec.modifierType, eventDef)) - { - continue; - } - if (eventSpec.obfuscateName != null) - { - eventRule.obfuscateName = eventSpec.obfuscateName; - } - if (eventSpec.obfuscateAdd != null) - { - eventRule.obfuscateAdd = eventSpec.obfuscateAdd; - } - if (eventSpec.obfuscateRemove != null) - { - eventRule.obfuscateRemove = eventSpec.obfuscateRemove; - } - if (eventSpec.obfuscateFire != null) - { - eventRule.obfuscateFire = eventSpec.obfuscateFire; - } - if (eventDef.AddMethod != null && eventRule.obfuscateAdd != null) - { - methodObfuscateFromPropertyOrEvent.Add(eventDef.AddMethod, eventRule.obfuscateAdd.Value); - } - if (eventDef.RemoveMethod != null && eventRule.obfuscateRemove != null) - { - methodObfuscateFromPropertyOrEvent.Add(eventDef.RemoveMethod, eventRule.obfuscateRemove.Value); - } - if (eventDef.InvokeMethod != null && eventRule.obfuscateFire != null) - { - methodObfuscateFromPropertyOrEvent.Add(eventDef.InvokeMethod, eventRule.obfuscateFire.Value); - } - break; - } - } - foreach (var propertyDef in typeDef.Properties) - { - var propertyRule = new PropertyRuleSpec() - { - obfuscateName = typeRule.obfuscateName, - obfuscateGetter = typeRule.obfuscateName, - obfuscateSetter = typeRule.obfuscateName, - }; - _propertySpecCache.Add(propertyDef, propertyRule); - foreach (var propertySpec in typeSpec.properties) - { - if (!propertySpec.nameMatcher.IsMatch(propertyDef.Name) || !MatchModifier(propertySpec.modifierType, propertyDef)) - { - continue; - } - if (propertySpec.obfuscateName != null) - { - propertyRule.obfuscateName = propertySpec.obfuscateName; - } - if (propertySpec.obfuscateGetter != null) - { - propertyRule.obfuscateGetter = propertySpec.obfuscateGetter; - } - if (propertySpec.obfuscateSetter != null) - { - propertyRule.obfuscateSetter = propertySpec.obfuscateSetter; - } - - if (propertyDef.GetMethod != null && propertyRule.obfuscateGetter != null) - { - methodObfuscateFromPropertyOrEvent.Add(propertyDef.GetMethod, propertyRule.obfuscateGetter.Value); - } - if (propertyDef.SetMethod != null && propertyRule.obfuscateSetter != null) - { - methodObfuscateFromPropertyOrEvent.Add(propertyDef.SetMethod, propertyRule.obfuscateSetter.Value); - } - break; - } - } - foreach (MethodDef methodDef in typeDef.Methods) - { - var methodRule = new MethodRuleSpec() - { - obfuscateName = typeRule.obfuscateName, - }; - _methodSpecCache.Add(methodDef, methodRule); - if (methodObfuscateFromPropertyOrEvent.TryGetValue(methodDef, out var obfuscateName)) - { - methodRule.obfuscateName = obfuscateName; - } - foreach (MethodRuleSpec methodSpec in typeSpec.methods) - { - if (!methodSpec.nameMatcher.IsMatch(methodDef.Name) || !MatchModifier(methodSpec.modifierType, methodDef)) - { - continue; - } - if (methodSpec.obfuscateName != null) - { - methodRule.obfuscateName = methodSpec.obfuscateName; - } - break; - } - } - } - if (!findMatch) - { - BuildDefaultTypeMemberCache(typeDef, typeRule); - } - - return typeRule; - } - - public override bool NeedRename(TypeDef typeDef) - { - var cache = GetOrCreateTypeDefRenameComputeCache(typeDef); - return cache.obfuscateName != false; - } - - public override bool NeedRename(MethodDef methodDef) - { - TypeDef typeDef = methodDef.DeclaringType; - GetOrCreateTypeDefRenameComputeCache(typeDef); - return _methodSpecCache[methodDef].obfuscateName != false; - } - - public override bool NeedRename(FieldDef fieldDef) - { - TypeDef typeDef = fieldDef.DeclaringType; - GetOrCreateTypeDefRenameComputeCache(typeDef); - return _fieldSpecCache[fieldDef].obfuscateName != false; - } - - public override bool NeedRename(PropertyDef propertyDef) - { - TypeDef typeDef = propertyDef.DeclaringType; - GetOrCreateTypeDefRenameComputeCache(typeDef); - return _propertySpecCache[propertyDef].obfuscateName != false; - } - - public override bool NeedRename(EventDef eventDef) - { - TypeDef typeDef = eventDef.DeclaringType; - GetOrCreateTypeDefRenameComputeCache(typeDef); - return _eventSpecCache[eventDef].obfuscateName != false; - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/ConfigurableRenamePolicy.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/ConfigurableRenamePolicy.cs.meta deleted file mode 100644 index e6b4fee..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/ConfigurableRenamePolicy.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 9c063bc949939fe44972c3d99870527e -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/ObfuscationPolicyBase.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/ObfuscationPolicyBase.cs deleted file mode 100644 index 6a271ad..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/ObfuscationPolicyBase.cs +++ /dev/null @@ -1,33 +0,0 @@ -using dnlib.DotNet; - -namespace Obfuz.ObfusPasses.SymbolObfus.Policies -{ - public abstract class ObfuscationPolicyBase : IObfuscationPolicy - { - - public virtual bool NeedRename(TypeDef typeDef) - { - return true; - } - - public virtual bool NeedRename(MethodDef methodDef) - { - return true; - } - - public virtual bool NeedRename(FieldDef fieldDef) - { - return true; - } - - public virtual bool NeedRename(PropertyDef propertyDef) - { - return true; - } - - public virtual bool NeedRename(EventDef eventDef) - { - return true; - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/ObfuscationPolicyBase.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/ObfuscationPolicyBase.cs.meta deleted file mode 100644 index 2d0bf05..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/ObfuscationPolicyBase.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 6ab98107a2ef9624b9b8a53061f682c3 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/SupportPassPolicy.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/SupportPassPolicy.cs deleted file mode 100644 index 1d0cb6b..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/SupportPassPolicy.cs +++ /dev/null @@ -1,50 +0,0 @@ -using dnlib.DotNet; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Obfuz.ObfusPasses.SymbolObfus.Policies -{ - internal class SupportPassPolicy : ObfuscationPolicyBase - { - private readonly ConfigurablePassPolicy _policy; - - - private bool Support(ObfuscationPassType passType) - { - return passType.HasFlag(ObfuscationPassType.SymbolObfus); - } - - public SupportPassPolicy(ConfigurablePassPolicy policy) - { - _policy = policy; - } - - public override bool NeedRename(TypeDef typeDef) - { - return Support(_policy.GetTypeObfuscationPasses(typeDef)); - } - - public override bool NeedRename(MethodDef methodDef) - { - return Support(_policy.GetMethodObfuscationPasses(methodDef)); - } - - public override bool NeedRename(FieldDef fieldDef) - { - return Support(_policy.GetFieldObfuscationPasses(fieldDef)); - } - - public override bool NeedRename(PropertyDef propertyDef) - { - return Support(_policy.GetPropertyObfuscationPasses(propertyDef)); - } - - public override bool NeedRename(EventDef eventDef) - { - return Support(_policy.GetEventObfuscationPasses(eventDef)); - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/SupportPassPolicy.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/SupportPassPolicy.cs.meta deleted file mode 100644 index bf7d3b8..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/SupportPassPolicy.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 584dd4d4e9b9fa64090611d84b50980b -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/SystemRenamePolicy.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/SystemRenamePolicy.cs deleted file mode 100644 index de0854d..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/SystemRenamePolicy.cs +++ /dev/null @@ -1,83 +0,0 @@ -using dnlib.DotNet; -using Obfuz.Utils; - -namespace Obfuz.ObfusPasses.SymbolObfus.Policies -{ - public class SystemRenamePolicy : ObfuscationPolicyBase - { - public override bool NeedRename(TypeDef typeDef) - { - string name = typeDef.Name; - if (name == "" || name == "ObfuzIgnoreAttribute") - { - return false; - } - if (MetaUtil.HasObfuzIgnoreAttributeInSelfOrParent(typeDef)) - { - return false; - } - return true; - } - - public override bool NeedRename(MethodDef methodDef) - { - if (methodDef.DeclaringType.IsDelegate) - { - return false; - } - if (methodDef.Name == ".ctor" || methodDef.Name == ".cctor") - { - return false; - } - - if (MetaUtil.HasObfuzIgnoreAttribute(methodDef) || MetaUtil.HasObfuzIgnoreAttributeInSelfOrParent(methodDef.DeclaringType)) - { - return false; - } - return true; - } - - public override bool NeedRename(FieldDef fieldDef) - { - if (fieldDef.DeclaringType.IsDelegate) - { - return false; - } - if (MetaUtil.HasObfuzIgnoreAttribute(fieldDef) || MetaUtil.HasObfuzIgnoreAttributeInSelfOrParent(fieldDef.DeclaringType)) - { - return false; - } - if (fieldDef.DeclaringType.IsEnum && fieldDef.Name == "value__") - { - return false; - } - return true; - } - - public override bool NeedRename(PropertyDef propertyDef) - { - if (propertyDef.DeclaringType.IsDelegate) - { - return false; - } - if (MetaUtil.HasObfuzIgnoreAttribute(propertyDef) || MetaUtil.HasObfuzIgnoreAttributeInSelfOrParent(propertyDef.DeclaringType)) - { - return false; - } - return true; - } - - public override bool NeedRename(EventDef eventDef) - { - if (eventDef.DeclaringType.IsDelegate) - { - return false; - } - if (MetaUtil.HasObfuzIgnoreAttribute(eventDef) || MetaUtil.HasObfuzIgnoreAttributeInSelfOrParent(eventDef.DeclaringType)) - { - return false; - } - return true; - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/SystemRenamePolicy.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/SystemRenamePolicy.cs.meta deleted file mode 100644 index b7d45e3..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/SystemRenamePolicy.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 7b7b98f2ff075c04aa9bd989f8797f00 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/UnityRenamePolicy.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/UnityRenamePolicy.cs deleted file mode 100644 index 9878973..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/UnityRenamePolicy.cs +++ /dev/null @@ -1,97 +0,0 @@ -using dnlib.DotNet; -using Obfuz.Utils; -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; - -namespace Obfuz.ObfusPasses.SymbolObfus.Policies -{ - - public class UnityRenamePolicy : ObfuscationPolicyBase - { - private static HashSet s_monoBehaviourEvents = new HashSet { - "Awake", - "OnEnable", - "Start", - "FixedUpdate", - "Update", - "LateUpdate", - "OnDisable", - "OnDestroy", - "OnApplicationQuit", - "OnTriggerEnter", - "OnTriggerExit", - "OnTriggerStay", - "OnCollisionEnter", - "OnCollisionExit", - "OnCollisionStay", - "OnMouseDown", - "OnMouseUp", - "OnMouseEnter", - "OnMouseExit", - "OnMouseOver", - "OnMouseDrag", - "OnBecameVisible", - "OnBecameInvisible", - "OnGUI", - "OnPreRender", - "OnPostRender", - "OnRenderObject", - "OnDrawGizmos", - "OnDrawGizmosSelected", - "OnValidate", - "OnAnimatorIK", - "OnAnimatorMove", - "OnApplicationFocus", - "OnApplicationPause", - "OnAudioFilterRead", - "OnJointBreak", - "OnParticleCollision", - "OnTransformChildrenChanged", - "OnTransformParentChanged", - "OnRectTransformDimensionsChange", - "OnWillRenderObject" -}; - public override bool NeedRename(TypeDef typeDef) - { - if (MetaUtil.IsScriptOrSerializableType(typeDef)) - { - return false; - } - if (typeDef.FullName.StartsWith("UnitySourceGeneratedAssemblyMonoScriptTypes_")) - { - return false; - } - return true; - } - - public override bool NeedRename(MethodDef methodDef) - { - if (MetaUtil.IsInheritFromUnityObject(methodDef.DeclaringType)) - { - return !s_monoBehaviourEvents.Contains(methodDef.Name); - } - if (methodDef.DeclaringType.FullName.StartsWith("UnitySourceGeneratedAssemblyMonoScriptTypes_")) - { - return false; - } - return true; - } - - public override bool NeedRename(FieldDef fieldDef) - { - TypeDef typeDef = fieldDef.DeclaringType; - if (MetaUtil.IsScriptOrSerializableType(typeDef)) - { - return !MetaUtil.IsSerializableField(fieldDef); - } - if (fieldDef.DeclaringType.FullName.StartsWith("UnitySourceGeneratedAssemblyMonoScriptTypes_")) - { - return false; - } - return true; - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/UnityRenamePolicy.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/UnityRenamePolicy.cs.meta deleted file mode 100644 index f8f6f99..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/UnityRenamePolicy.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4357f35c667599246b2481b093f41f04 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/RenameRecordMap.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/RenameRecordMap.cs deleted file mode 100644 index 791f95d..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/RenameRecordMap.cs +++ /dev/null @@ -1,706 +0,0 @@ -using dnlib.DotNet; -using Obfuz.Utils; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Xml; -using System.Xml.Linq; -using UnityEngine; - -namespace Obfuz.ObfusPasses.SymbolObfus -{ - - public class RenameRecordMap - { - private enum RenameStatus - { - NotRenamed, - Renamed, - } - - private class RenameRecord - { - public RenameStatus status; - public string signature; - public string oldName; - public string newName; - public string oldStackTraceSignature; // only for MethodDef - public object renameMappingData; - } - - private class RenameMappingField - { - public RenameStatus status; - public string signature; - public string newName; - } - - private class RenameMappingMethod - { - public RenameStatus status; - public string signature; - public string newName; - } - - private class RenameMappingMethodParam - { - public RenameStatus status; - public int index; - public string newName; - } - - private class RenameMappingProperty - { - public RenameStatus status; - public string signature; - public string newName; - } - - private class RenameMappingEvent - { - public RenameStatus status; - public string signature; - public string newName; - } - - private class RenameMappingType - { - public RenameStatus status; - public string oldFullName; - public string newFullName; - - public Dictionary fields = new Dictionary(); - public Dictionary methods = new Dictionary(); - public Dictionary properties = new Dictionary(); - public Dictionary events = new Dictionary(); - } - - private class RenameMappingAssembly - { - public string assName; - - public Dictionary types = new Dictionary(); - } - - private readonly string _mappingFile; - private readonly Dictionary _assemblies = new Dictionary(); - - - private readonly Dictionary _modRenames = new Dictionary(); - private readonly Dictionary _typeRenames = new Dictionary(); - private readonly Dictionary _methodRenames = new Dictionary(); - private readonly Dictionary _paramRenames = new Dictionary(); - private readonly Dictionary _fieldRenames = new Dictionary(); - private readonly Dictionary _propertyRenames = new Dictionary(); - private readonly Dictionary _eventRenames = new Dictionary(); - private readonly Dictionary _virtualMethodGroups = new Dictionary(); - - - public RenameRecordMap(string mappingFile) - { - _mappingFile = mappingFile; - } - - public void Init(List assemblies, INameMaker nameMaker) - { - LoadXmlMappingFile(_mappingFile); - foreach (ModuleDef mod in assemblies) - { - string name = mod.Assembly.Name; - - RenameMappingAssembly rma = _assemblies.GetValueOrDefault(name); - - _modRenames.Add(mod, new RenameRecord - { - status = RenameStatus.NotRenamed, - signature = name, - oldName = name, - newName = null, - renameMappingData = rma, - }); - - foreach (TypeDef type in mod.GetTypes()) - { - nameMaker.AddPreservedName(type, name); - nameMaker.AddPreservedNamespace(type, type.Namespace); - string fullTypeName = type.FullName; - RenameMappingType rmt = rma?.types.GetValueOrDefault(fullTypeName); - if (rmt != null) - { - var (newNamespace, newName) = MetaUtil.SplitNamespaceAndName(rmt.newFullName); - nameMaker.AddPreservedNamespace(type, newNamespace); - nameMaker.AddPreservedName(type, newName); - } - - _typeRenames.Add(type, new RenameRecord - { - status = RenameStatus.NotRenamed, - signature = fullTypeName, - oldName = fullTypeName, - newName = null, - renameMappingData = rmt, - }); - foreach (MethodDef method in type.Methods) - { - nameMaker.AddPreservedName(method, method.Name); - string methodSig = TypeSigUtil.ComputeMethodDefSignature(method); - nameMaker.AddPreservedName(method, method.Name); - - RenameMappingMethod rmm = rmt?.methods.GetValueOrDefault(methodSig); - if (rmm != null) - { - nameMaker.AddPreservedName(method, rmm.newName); - } - _methodRenames.Add(method, new RenameRecord - { - status = RenameStatus.NotRenamed, - signature = methodSig, - oldName = method.Name, - newName = null, - renameMappingData = rmm, - oldStackTraceSignature = MetaUtil.CreateMethodDefIl2CppStackTraceSignature(method), - }); - foreach (Parameter param in method.Parameters) - { - if (param.ParamDef != null) - { - _paramRenames.Add(param.ParamDef, new RenameRecord - { - status = RenameStatus.NotRenamed, - signature = param.Name, - oldName = param.Name, - newName = null, - }); - } - } - } - foreach (FieldDef field in type.Fields) - { - nameMaker.AddPreservedName(field, field.Name); - string fieldSig = TypeSigUtil.ComputeFieldDefSignature(field); - RenameMappingField rmf = rmt?.fields.GetValueOrDefault(fieldSig); - if (rmf != null) - { - nameMaker.AddPreservedName(field, rmf.newName); - } - _fieldRenames.Add(field, new RenameRecord - { - status = RenameStatus.NotRenamed, - signature = fieldSig, - oldName = field.Name, - newName = null, - renameMappingData = rmf, - }); - } - foreach (PropertyDef property in type.Properties) - { - nameMaker.AddPreservedName(property, property.Name); - string propertySig = TypeSigUtil.ComputePropertyDefSignature(property); - RenameMappingProperty rmp = rmt?.properties.GetValueOrDefault(propertySig); - if (rmp != null) - { - nameMaker.AddPreservedName(property, rmp.newName); - } - _propertyRenames.Add(property, new RenameRecord - { - status = RenameStatus.NotRenamed, - signature = propertySig, - oldName = property.Name, - newName = null, - renameMappingData = rmp, - }); - } - foreach (EventDef eventDef in type.Events) - { - nameMaker.AddPreservedName(eventDef, eventDef.Name); - string eventSig = TypeSigUtil.ComputeEventDefSignature(eventDef); - RenameMappingEvent rme = rmt?.events.GetValueOrDefault(eventSig); - if (rme != null) - { - nameMaker.AddPreservedName(eventDef, rme.newName); - } - _eventRenames.Add(eventDef, new RenameRecord - { - status = RenameStatus.NotRenamed, - signature = eventSig, - oldName = eventDef.Name, - newName = null, - renameMappingData = rme, - }); - } - } - } - } - - private void LoadXmlMappingFile(string mappingFile) - { - if (string.IsNullOrEmpty(mappingFile) || !File.Exists(mappingFile)) - { - return; - } - var doc = new XmlDocument(); - doc.Load(mappingFile); - var root = doc.DocumentElement; - foreach (XmlNode node in root.ChildNodes) - { - if (!(node is XmlElement element)) - { - continue; - } - LoadAssemblyMapping(element); - } - } - - private void LoadAssemblyMapping(XmlElement ele) - { - if (ele.Name != "assembly") - { - throw new System.Exception($"Invalid node name: {ele.Name}. Expected 'assembly'."); - } - - var assemblyName = ele.Attributes["name"].Value; - var rma = new RenameMappingAssembly - { - assName = assemblyName, - }; - foreach (XmlNode node in ele.ChildNodes) - { - if (!(node is XmlElement element)) - { - continue; - } - if (element.Name != "type") - { - throw new System.Exception($"Invalid node name: {element.Name}. Expected 'type'."); - } - LoadTypeMapping(element, rma); - } - _assemblies.Add(assemblyName, rma); - } - - private void LoadTypeMapping(XmlElement ele, RenameMappingAssembly ass) - { - var typeName = ele.Attributes["fullName"].Value; - var newTypeName = ele.Attributes["newFullName"].Value; - var rmt = new RenameMappingType - { - oldFullName = typeName, - newFullName = newTypeName, - status = (RenameStatus)System.Enum.Parse(typeof(RenameStatus), ele.Attributes["status"].Value), - }; - foreach (XmlNode node in ele.ChildNodes) - { - if (!(node is XmlElement c)) - { - continue; - } - switch (node.Name) - { - case "field": LoadFieldMapping(c, rmt); break; - case "event": LoadEventMapping(c, rmt); break; - case "property": LoadPropertyMapping(c, rmt); break; - case "method": LoadMethodMapping(c, rmt); break; - default: throw new System.Exception($"Invalid node name:{node.Name}"); - } - } - ass.types.Add(typeName, rmt); - } - - private void LoadMethodMapping(XmlElement ele, RenameMappingType type) - { - string signature = ele.Attributes["signature"].Value; - string newName = ele.Attributes["newName"].Value; - var rmm = new RenameMappingMethod - { - signature = signature, - newName = newName, - status = RenameStatus.Renamed, - }; - type.methods.Add(signature, rmm); - } - - private void LoadFieldMapping(XmlElement ele, RenameMappingType type) - { - string signature = ele.Attributes["signature"].Value; - string newName = ele.Attributes["newName"].Value; - var rmf = new RenameMappingField - { - signature = signature, - newName = newName, - status = RenameStatus.Renamed, - }; - type.fields.Add(signature, rmf); - } - - private void LoadPropertyMapping(XmlElement ele, RenameMappingType type) - { - string signature = ele.Attributes["signature"].Value; - string newName = ele.Attributes["newName"].Value; - var rmp = new RenameMappingProperty - { - signature = signature, - newName = newName, - status = RenameStatus.Renamed, - }; - type.properties.Add(signature, rmp); - } - - private void LoadEventMapping(XmlElement ele, RenameMappingType type) - { - string signature = ele.Attributes["signature"].Value; - string newName = ele.Attributes["newName"].Value; - var rme = new RenameMappingEvent - { - signature = signature, - newName = newName, - status = RenameStatus.Renamed, - }; - type.events.Add(signature, rme); - } - - private List GetSortedValueList(Dictionary dic, Comparison comparer) - { - var list = dic.Values.ToList(); - list.Sort(comparer); - return list; - } - - public void WriteXmlMappingFile() - { - if (string.IsNullOrEmpty(_mappingFile)) - { - return; - } - var doc = new XmlDocument(); - var root = doc.CreateElement("mapping"); - doc.AppendChild(root); - - var sortedModRenames = _modRenames.ToList(); - sortedModRenames.Sort((a, b) => a.Value.oldName.CompareTo(b.Value.oldName)); - foreach (var kvp in sortedModRenames) - { - ModuleDef mod = kvp.Key; - RenameRecord record = kvp.Value; - var assemblyNode = doc.CreateElement("assembly"); - assemblyNode.SetAttribute("name", mod.Assembly.Name); - foreach (TypeDef type in mod.GetTypes()) - { - WriteTypeMapping(assemblyNode, type); - } - root.AppendChild(assemblyNode); - } - - var sortedAsses = GetSortedValueList(_assemblies, (a, b) => a.assName.CompareTo(b.assName)); - foreach (RenameMappingAssembly ass in sortedAsses) - { - if (_modRenames.Keys.Any(m => m.Assembly.Name == ass.assName)) - { - continue; - } - var assemblyNode = doc.CreateElement("assembly"); - assemblyNode.SetAttribute("name", ass.assName); - - var sortedTypes = GetSortedValueList(ass.types, (a, b) => a.oldFullName.CompareTo(b.oldFullName)); - foreach (var type in sortedTypes) - { - WriteTypeMapping(assemblyNode, type.oldFullName, type); - } - root.AppendChild(assemblyNode); - } - Directory.CreateDirectory(Path.GetDirectoryName(_mappingFile)); - doc.Save(_mappingFile); - Debug.Log($"Mapping file saved to {Path.GetFullPath(_mappingFile)}"); - } - - private void WriteTypeMapping(XmlElement assNode, TypeDef type) - { - _typeRenames.TryGetValue(type, out var record); - var typeNode = assNode.OwnerDocument.CreateElement("type"); - typeNode.SetAttribute("fullName", record?.signature ?? type.FullName); - typeNode.SetAttribute("newFullName", record != null && record.status == RenameStatus.Renamed ? record.newName : ""); - typeNode.SetAttribute("status", record != null ? record.status.ToString() : RenameStatus.NotRenamed.ToString()); - - foreach (FieldDef field in type.Fields) - { - WriteFieldMapping(typeNode, field); - } - foreach (PropertyDef property in type.Properties) - { - WritePropertyMapping(typeNode, property); - } - foreach (EventDef eventDef in type.Events) - { - WriteEventMapping(typeNode, eventDef); - } - foreach (MethodDef method in type.Methods) - { - WriteMethodMapping(typeNode, method); - } - if ((record != null && record.status == RenameStatus.Renamed) || typeNode.ChildNodes.Count > 0) - { - assNode.AppendChild(typeNode); - } - } - - private void WriteTypeMapping(XmlElement assNode, string fullName, RenameMappingType type) - { - var typeNode = assNode.OwnerDocument.CreateElement("type"); - typeNode.SetAttribute("fullName", fullName); - typeNode.SetAttribute("newFullName", type.status == RenameStatus.Renamed ? type.newFullName : ""); - typeNode.SetAttribute("status", type.status.ToString()); - - foreach (var e in type.fields) - { - string signature = e.Key; - RenameMappingField field = e.Value; - WriteFieldMapping(typeNode, e.Key, e.Value); - } - foreach (var e in type.properties) - { - WritePropertyMapping(typeNode, e.Key, e.Value); - } - foreach (var e in type.events) - { - WriteEventMapping(typeNode, e.Key, e.Value); - } - foreach (var e in type.methods) - { - WriteMethodMapping(typeNode, e.Key, e.Value); - } - - assNode.AppendChild(typeNode); - } - - private void WriteFieldMapping(XmlElement typeEle, FieldDef field) - { - if (!_fieldRenames.TryGetValue(field, out var record) || record.status == RenameStatus.NotRenamed) - { - return; - } - var fieldNode = typeEle.OwnerDocument.CreateElement("field"); - fieldNode.SetAttribute("signature", record?.signature); - fieldNode.SetAttribute("newName", record.newName); - //fieldNode.SetAttribute("status", record.status.ToString()); - typeEle.AppendChild(fieldNode); - } - - private void WriteFieldMapping(XmlElement typeEle, string signature, RenameMappingField field) - { - var fieldNode = typeEle.OwnerDocument.CreateElement("field"); - fieldNode.SetAttribute("signature", signature); - fieldNode.SetAttribute("newName", field.newName); - //fieldNode.SetAttribute("status", record.status.ToString()); - typeEle.AppendChild(fieldNode); - } - - private void WritePropertyMapping(XmlElement typeEle, PropertyDef property) - { - if (!_propertyRenames.TryGetValue(property, out var record) || record.status == RenameStatus.NotRenamed) - { - return; - } - var propertyNode = typeEle.OwnerDocument.CreateElement("property"); - propertyNode.SetAttribute("signature", record.signature); - propertyNode.SetAttribute("newName", record.newName); - //propertyNode.SetAttribute("status", record.status.ToString()); - typeEle.AppendChild(propertyNode); - } - - private void WritePropertyMapping(XmlElement typeEle, string signature, RenameMappingProperty property) - { - var propertyNode = typeEle.OwnerDocument.CreateElement("property"); - propertyNode.SetAttribute("signature", signature); - propertyNode.SetAttribute("newName", property.newName); - //propertyNode.SetAttribute("status", record.status.ToString()); - typeEle.AppendChild(propertyNode); - } - - private void WriteEventMapping(XmlElement typeEle, EventDef eventDef) - { - if (!_eventRenames.TryGetValue(eventDef, out var record) || record.status == RenameStatus.NotRenamed) - { - return; - } - var eventNode = typeEle.OwnerDocument.CreateElement("event"); - eventNode.SetAttribute("signature", record.signature); - eventNode.SetAttribute("newName", record.newName); - typeEle.AppendChild(eventNode); - } - - private void WriteEventMapping(XmlElement typeEle, string signature, RenameMappingEvent eventDef) - { - var eventNode = typeEle.OwnerDocument.CreateElement("event"); - eventNode.SetAttribute("signature", signature); - eventNode.SetAttribute("newName", eventDef.newName); - typeEle.AppendChild(eventNode); - } - - private void WriteMethodMapping(XmlElement typeEle, MethodDef method) - { - if (!_methodRenames.TryGetValue(method, out var record) || record.status == RenameStatus.NotRenamed) - { - return; - } - var methodNode = typeEle.OwnerDocument.CreateElement("method"); - methodNode.SetAttribute("signature", record.signature); - methodNode.SetAttribute("newName", record.newName); - methodNode.SetAttribute("oldStackTraceSignature", record.oldStackTraceSignature); - methodNode.SetAttribute("newStackTraceSignature", MetaUtil.CreateMethodDefIl2CppStackTraceSignature(method)); - //methodNode.SetAttribute("status", record != null ? record.status.ToString() : RenameStatus.NotRenamed.ToString()); - foreach (Parameter param in method.Parameters) - { - if (param.ParamDef != null) - { - WriteMethodParamMapping(methodNode, param.ParamDef); - } - } - typeEle.AppendChild(methodNode); - } - - private void WriteMethodMapping(XmlElement typeEle, string signature, RenameMappingMethod method) - { - var methodNode = typeEle.OwnerDocument.CreateElement("method"); - methodNode.SetAttribute("signature", signature); - methodNode.SetAttribute("newName", method.newName); - typeEle.AppendChild(methodNode); - } - - private void WriteMethodParamMapping(XmlElement methodEle, ParamDef param) - { - if (!_paramRenames.TryGetValue(param, out var record) || record.status == RenameStatus.NotRenamed) - { - return; - } - var paramNode = methodEle.OwnerDocument.CreateElement("param"); - paramNode.SetAttribute("index", param.Sequence.ToString()); - paramNode.SetAttribute("newName", record.newName); - //paramNode.SetAttribute("status", record.status.ToString()); - methodEle.AppendChild(paramNode); - } - - public void AddRename(ModuleDef mod, string newName) - { - RenameRecord record = _modRenames[mod]; - record.status = RenameStatus.Renamed; - record.newName = newName; - } - - public void AddRename(TypeDef type, string newName) - { - RenameRecord record = _typeRenames[type]; - record.status = RenameStatus.Renamed; - record.newName = newName; - } - - public void AddRename(MethodDef method, string newName) - { - RenameRecord record = _methodRenames[method]; - record.status = RenameStatus.Renamed; - record.newName = newName; - } - - public void InitAndAddRename(VirtualMethodGroup methodGroup, string newName) - { - RenameRecord methodRecord = _methodRenames[methodGroup.methods[0]]; - _virtualMethodGroups.Add(methodGroup, new RenameRecord - { - status = RenameStatus.Renamed, - signature = methodRecord.signature, - oldName = methodRecord.oldName, - newName = newName, - }); - } - - public void AddRename(FieldDef field, string newName) - { - RenameRecord record = _fieldRenames[field]; - record.status = RenameStatus.Renamed; - record.newName = newName; - } - - public void AddRename(PropertyDef property, string newName) - { - RenameRecord record = _propertyRenames[property]; - record.status = RenameStatus.Renamed; - record.newName = newName; - } - - public void AddRename(EventDef eventDef, string newName) - { - RenameRecord record = _eventRenames[eventDef]; - record.status = RenameStatus.Renamed; - record.newName = newName; - } - - public bool TryGetExistRenameMapping(TypeDef type, out string newNamespace, out string newName) - { - if (_typeRenames.TryGetValue(type, out var record) && record.renameMappingData != null) - { - var rmt = (RenameMappingType)record.renameMappingData; - (newNamespace, newName) = MetaUtil.SplitNamespaceAndName(rmt.newFullName); - return true; - } - newNamespace = null; - newName = null; - return false; - } - - public bool TryGetExistRenameMapping(MethodDef method, out string newName) - { - if (_methodRenames.TryGetValue(method, out var record) && record.renameMappingData != null) - { - newName = ((RenameMappingMethod)record.renameMappingData).newName; - return true; - } - newName = null; - return false; - } - - public bool TryGetExistRenameMapping(FieldDef field, out string newName) - { - if (_fieldRenames.TryGetValue(field, out var record) && record.renameMappingData != null) - { - newName = ((RenameMappingField)record.renameMappingData).newName; - return true; - } - newName = null; - return false; - } - - public bool TryGetExistRenameMapping(PropertyDef property, out string newName) - { - if (_propertyRenames.TryGetValue(property, out var record) && record.renameMappingData != null) - { - newName = ((RenameMappingProperty)record.renameMappingData).newName; - return true; - } - newName = null; - return false; - } - - public bool TryGetExistRenameMapping(EventDef eventDef, out string newName) - { - if (_eventRenames.TryGetValue(eventDef, out var record) && record.renameMappingData != null) - { - newName = ((RenameMappingEvent)record.renameMappingData).newName; - return true; - } - newName = null; - return false; - } - - public bool TryGetRename(VirtualMethodGroup group, out string newName) - { - if (_virtualMethodGroups.TryGetValue(group, out var record)) - { - newName = record.newName; - return true; - } - newName = null; - return false; - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/RenameRecordMap.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/RenameRecordMap.cs.meta deleted file mode 100644 index 2a91341..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/RenameRecordMap.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a3ffbd28624d87c4382f62eb4fc19c70 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/SymbolObfusPass.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/SymbolObfusPass.cs deleted file mode 100644 index 2501f1d..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/SymbolObfusPass.cs +++ /dev/null @@ -1,36 +0,0 @@ -using Obfuz.Settings; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Obfuz.ObfusPasses.SymbolObfus -{ - public class SymbolObfusPass : ObfuscationPassBase - { - private SymbolRename _symbolRename; - - public override ObfuscationPassType Type => ObfuscationPassType.SymbolObfus; - - public SymbolObfusPass(SymbolObfuscationSettings settings) - { - _symbolRename = new SymbolRename(settings); - } - - public override void Start() - { - _symbolRename.Init(); - } - - public override void Stop() - { - _symbolRename.Save(); - } - - public override void Process() - { - _symbolRename.Process(); - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/SymbolObfusPass.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/SymbolObfusPass.cs.meta deleted file mode 100644 index a86c04b..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/SymbolObfusPass.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a4c9a37b51ade6b46a299be7ad2155d6 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/SymbolRename.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/SymbolRename.cs deleted file mode 100644 index cda7d4f..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/SymbolRename.cs +++ /dev/null @@ -1,759 +0,0 @@ -using dnlib.DotNet; -using Obfuz.ObfusPasses.SymbolObfus; -using Obfuz.ObfusPasses.SymbolObfus.NameMakers; -using Obfuz.ObfusPasses.SymbolObfus.Policies; -using Obfuz.Settings; -using Obfuz.Utils; -using System; -using System.Collections; -using System.Collections.Generic; -using System.Data.OleDb; -using System.IO; -using System.Linq; -using System.Runtime.InteropServices; -using UnityEditor.SceneManagement; -using UnityEngine; -using UnityEngine.Assertions; - -namespace Obfuz.ObfusPasses.SymbolObfus -{ - public class SymbolRename - { - private readonly bool _useConsistentNamespaceObfuscation; - private readonly List _obfuscationRuleFiles; - private readonly string _mappingXmlPath; - - private AssemblyCache _assemblyCache; - - private List _toObfuscatedModules; - private List _obfuscatedAndNotObfuscatedModules; - private HashSet _toObfuscatedModuleSet; - private IObfuscationPolicy _renamePolicy; - private INameMaker _nameMaker; - private readonly Dictionary> _customAttributeArgumentsWithTypeByMods = new Dictionary>(); - private readonly RenameRecordMap _renameRecordMap; - private readonly VirtualMethodGroupCalculator _virtualMethodGroupCalculator; - - class CustomAttributeInfo - { - public CustomAttributeCollection customAttributes; - public int index; - public List arguments; - public List namedArguments; - } - - public SymbolRename(SymbolObfuscationSettings settings) - { - _useConsistentNamespaceObfuscation = settings.useConsistentNamespaceObfuscation; - _mappingXmlPath = settings.symbolMappingFile; - _obfuscationRuleFiles = settings.ruleFiles.ToList(); - _renameRecordMap = new RenameRecordMap(settings.debug ? null : settings.symbolMappingFile); - _virtualMethodGroupCalculator = new VirtualMethodGroupCalculator(); - _nameMaker = settings.debug ? NameMakerFactory.CreateDebugNameMaker() : NameMakerFactory.CreateNameMakerBaseASCIICharSet(settings.obfuscatedNamePrefix); - } - - public void Init() - { - var ctx = ObfuscationPassContext.Current; - _assemblyCache = ctx.assemblyCache; - _toObfuscatedModules = ctx.modulesToObfuscate; - _obfuscatedAndNotObfuscatedModules = ctx.allObfuscationRelativeModules; - _toObfuscatedModuleSet = new HashSet(ctx.modulesToObfuscate); - var obfuscateRuleConfig = new ConfigurableRenamePolicy(ctx.assembliesToObfuscate, _obfuscationRuleFiles); - _renamePolicy = new CacheRenamePolicy(new CombineRenamePolicy(new SupportPassPolicy(ctx.passPolicy), new SystemRenamePolicy(), new UnityRenamePolicy(), obfuscateRuleConfig)); - BuildCustomAttributeArguments(); - } - - private void CollectCArgumentWithTypeOf(IHasCustomAttribute meta, List customAttributes) - { - int index = 0; - foreach (CustomAttribute ca in meta.CustomAttributes) - { - List arguments = null; - if (ca.ConstructorArguments.Any(a => MetaUtil.MayRenameCustomDataType(a.Type.ElementType))) - { - arguments = ca.ConstructorArguments.ToList(); - } - List namedArguments = null; - if (ca.NamedArguments.Any(a => MetaUtil.MayRenameCustomDataType(a.Type.ElementType))) - { - namedArguments = ca.NamedArguments.ToList(); - } - if (arguments != null | namedArguments != null) - { - customAttributes.Add(new CustomAttributeInfo - { - customAttributes = meta.CustomAttributes, - index = index, - arguments = arguments, - namedArguments = namedArguments - }); - } - ++index; - } - } - - private void BuildCustomAttributeArguments() - { - foreach (ModuleDef mod in _obfuscatedAndNotObfuscatedModules) - { - var customAttributes = new List(); - CollectCArgumentWithTypeOf(mod, customAttributes); - foreach (TypeDef type in mod.GetTypes()) - { - CollectCArgumentWithTypeOf(type, customAttributes); - foreach (FieldDef field in type.Fields) - { - CollectCArgumentWithTypeOf(field, customAttributes); - } - foreach (MethodDef method in type.Methods) - { - CollectCArgumentWithTypeOf(method, customAttributes); - foreach (Parameter param in method.Parameters) - { - if (param.ParamDef != null) - { - CollectCArgumentWithTypeOf(param.ParamDef, customAttributes); - } - } - } - foreach (PropertyDef property in type.Properties) - { - CollectCArgumentWithTypeOf(property, customAttributes); - } - foreach (EventDef eventDef in type.Events) - { - CollectCArgumentWithTypeOf (eventDef, customAttributes); - } - } - - _customAttributeArgumentsWithTypeByMods.Add(mod, customAttributes); - } - } - - public void Process() - { - _renameRecordMap.Init(_toObfuscatedModules, _nameMaker); - - RenameTypes(); - RenameFields(); - RenameMethods(); - RenameProperties(); - RenameEvents(); - } - - class RefTypeDefMetas - { - public readonly List typeRefs = new List(); - - public readonly List customAttributes = new List(); - } - - private void BuildRefTypeDefMetasMap(Dictionary refTypeDefMetasMap) - { - foreach (ModuleDef mod in _obfuscatedAndNotObfuscatedModules) - { - foreach (TypeRef typeRef in mod.GetTypeRefs()) - { - if (typeRef.DefinitionAssembly.IsCorLib()) - { - continue; - } - TypeDef typeDef = typeRef.ResolveThrow(); - if (!refTypeDefMetasMap.TryGetValue(typeDef, out var typeDefMetas)) - { - typeDefMetas = new RefTypeDefMetas(); - refTypeDefMetasMap.Add(typeDef, typeDefMetas); - } - typeDefMetas.typeRefs.Add(typeRef); - } - } - - foreach (CustomAttributeInfo cai in _customAttributeArgumentsWithTypeByMods.Values.SelectMany(cas => cas)) - { - CustomAttribute ca = cai.customAttributes[cai.index]; - TypeDef typeDef = MetaUtil.GetTypeDefOrGenericTypeBaseThrowException(ca.Constructor.DeclaringType); - if (!refTypeDefMetasMap.TryGetValue(typeDef, out var typeDefMetas)) - { - typeDefMetas = new RefTypeDefMetas(); - refTypeDefMetasMap.Add(typeDef, typeDefMetas); - } - typeDefMetas.customAttributes.Add(ca); - } - } - - private void RetargetTypeRefInCustomAttributes() - { - foreach (CustomAttributeInfo cai in _customAttributeArgumentsWithTypeByMods.Values.SelectMany(cas => cas)) - { - CustomAttribute ca = cai.customAttributes[cai.index]; - bool anyChange = false; - if (cai.arguments != null) - { - for (int i = 0; i < cai.arguments.Count; i++) - { - CAArgument oldArg = cai.arguments[i]; - if (MetaUtil.TryRetargetTypeRefInArgument(oldArg, out CAArgument newArg)) - { - anyChange = true; - cai.arguments[i] = newArg; - } - } - } - if (cai.namedArguments != null) - { - for (int i = 0; i < cai.namedArguments.Count; i++) - { - if (MetaUtil.TryRetargetTypeRefInNamedArgument(cai.namedArguments[i])) - { - anyChange = true; - } - } - } - if (anyChange) - { - cai.customAttributes[cai.index] = new CustomAttribute(ca.Constructor, - cai.arguments != null ? cai.arguments : ca.ConstructorArguments, - cai.namedArguments != null ? cai.namedArguments : ca.NamedArguments); - } - } - } - - private readonly Dictionary _refTypeRefMetasMap = new Dictionary(); - - private void RenameTypes() - { - Debug.Log("RenameTypes begin"); - - RetargetTypeRefInCustomAttributes(); - - BuildRefTypeDefMetasMap(_refTypeRefMetasMap); - _assemblyCache.EnableTypeDefCache = false; - - foreach (ModuleDef mod in _toObfuscatedModules) - { - foreach (TypeDef type in mod.GetTypes()) - { - if (_renamePolicy.NeedRename(type)) - { - Rename(type, _refTypeRefMetasMap.GetValueOrDefault(type)); - } - } - } - - // clean cache - _assemblyCache.EnableTypeDefCache = true; - Debug.Log("Rename Types end"); - } - - - class RefFieldMetas - { - public readonly List fieldRefs = new List(); - public readonly List customAttributes = new List(); - } - - - private void BuildHierarchyFields(TypeDef type, List fields) - { - while (type != null) - { - fields.AddRange(type.Fields); - type = MetaUtil.GetBaseTypeDef(type); - } - } - - private IEnumerable WalkMemberRefs(ModuleDef mod) - { - foreach (TypeDef type in mod.GetTypes()) - { - foreach (MethodDef method in type.Methods) - { - if (!method.HasBody) - { - continue; - } - foreach (var instr in method.Body.Instructions) - { - if (instr.Operand is MemberRef memberRef) - { - yield return memberRef; - } - } - } - } - } - - private void BuildRefFieldMetasMap(Dictionary refFieldMetasMap) - { - foreach (ModuleDef mod in _obfuscatedAndNotObfuscatedModules) - { - foreach (MemberRef memberRef in WalkMemberRefs(mod)) - { - if (!memberRef.IsFieldRef) - { - continue; - } - - IMemberRefParent parent = memberRef.Class; - TypeDef parentTypeDef = MetaUtil.GetMemberRefTypeDefParentOrNull(parent); - if (parentTypeDef == null) - { - continue; - } - foreach (FieldDef field in parentTypeDef.Fields) - { - if (field.Name == memberRef.Name && TypeEqualityComparer.Instance.Equals(field.FieldSig.Type, memberRef.FieldSig.Type)) - { - if (!refFieldMetasMap.TryGetValue(field, out var fieldMetas)) - { - fieldMetas = new RefFieldMetas(); - refFieldMetasMap.Add(field, fieldMetas); - } - fieldMetas.fieldRefs.Add(memberRef); - break; - } - } - } - } - foreach (var e in _refTypeRefMetasMap) - { - TypeDef typeDef = e.Key; - var hierarchyFields = new List(); - BuildHierarchyFields(typeDef, hierarchyFields); - RefTypeDefMetas typeDefMetas = e.Value; - foreach (CustomAttribute ca in typeDefMetas.customAttributes) - { - foreach (var arg in ca.NamedArguments) - { - if (arg.IsProperty) - { - continue; - } - foreach (FieldDef field in hierarchyFields) - { - // FIXME. field of Generic Base Type may not be same - if (field.Name == arg.Name && TypeEqualityComparer.Instance.Equals(field.FieldType, arg.Type)) - { - if (!refFieldMetasMap.TryGetValue(field, out var fieldMetas)) - { - fieldMetas = new RefFieldMetas(); - refFieldMetasMap.Add(field, fieldMetas); - } - fieldMetas.customAttributes.Add(ca); - break; - } - } - } - } - } - } - - private void RenameFields() - { - Debug.Log("Rename fields begin"); - var refFieldMetasMap = new Dictionary(); - BuildRefFieldMetasMap(refFieldMetasMap); - - foreach (ModuleDef mod in _toObfuscatedModules) - { - foreach (TypeDef type in mod.GetTypes()) - { - foreach (FieldDef field in type.Fields) - { - if (_renamePolicy.NeedRename(field)) - { - Rename(field, refFieldMetasMap.GetValueOrDefault(field)); - } - } - } - } - Debug.Log("Rename fields end"); - } - - class RefMethodMetas - { - public readonly List memberRefs = new List(); - } - - private void BuildRefMethodMetasMap(Dictionary refMethodMetasMap) - { - foreach (ModuleDef mod in _obfuscatedAndNotObfuscatedModules) - { - foreach (MemberRef memberRef in WalkMemberRefs(mod)) - { - if (!memberRef.IsMethodRef) - { - continue; - } - - IMemberRefParent parent = memberRef.Class; - TypeDef parentTypeDef = MetaUtil.GetMemberRefTypeDefParentOrNull(parent); - if (parentTypeDef == null) - { - continue; - } - foreach (MethodDef method in parentTypeDef.Methods) - { - if (method.Name == memberRef.Name && new SigComparer(default).Equals(method.MethodSig, memberRef.MethodSig)) - { - if (!refMethodMetasMap.TryGetValue(method, out var refMethodMetas)) - { - refMethodMetas = new RefMethodMetas(); - refMethodMetasMap.Add(method, refMethodMetas); - } - refMethodMetas.memberRefs.Add(memberRef); - break; - } - } - } - } - } - - private void RenameMethods() - { - Debug.Log("Rename methods begin"); - Debug.Log("Rename not virtual methods begin"); - var virtualMethods = new List(); - var refMethodMetasMap = new Dictionary(); - BuildRefMethodMetasMap(refMethodMetasMap); - foreach (ModuleDef mod in _toObfuscatedModules) - { - foreach (TypeDef type in mod.GetTypes()) - { - foreach (MethodDef method in type.Methods) - { - if (method.IsVirtual) - { - continue; - } - if (_renamePolicy.NeedRename(method)) - { - Rename(method, refMethodMetasMap.GetValueOrDefault(method)); - } - } - } - } - - foreach (ModuleDef mod in _obfuscatedAndNotObfuscatedModules) - { - foreach (TypeDef type in mod.GetTypes()) - { - _virtualMethodGroupCalculator.CalculateType(type); - foreach (MethodDef method in type.Methods) - { - if (method.IsVirtual) - { - virtualMethods.Add(method); - } - } - } - } - - Debug.Log("Rename not virtual methods end"); - - - Debug.Log("Rename virtual methods begin"); - var visitedVirtualMethods = new HashSet(); - var groupNeedRenames = new Dictionary(); - foreach (var method in virtualMethods) - { - if (!visitedVirtualMethods.Add(method)) - { - continue; - } - VirtualMethodGroup group = _virtualMethodGroupCalculator.GetMethodGroup(method); - if (!groupNeedRenames.TryGetValue(group, out var needRename)) - { - needRename = group.methods.All(m => _toObfuscatedModuleSet.Contains(m.DeclaringType.Module) && _renamePolicy.NeedRename(m)); - groupNeedRenames.Add(group, needRename); - if (needRename) - { - _renameRecordMap.InitAndAddRename(group, _renameRecordMap.TryGetExistRenameMapping(method, out var nn) ? nn : _nameMaker.GetNewName(method, method.Name)); - } - } - if (!needRename) - { - continue; - } - if (_renameRecordMap.TryGetRename(group, out var newName)) - { - Rename(method, refMethodMetasMap.GetValueOrDefault(method), newName); - } - else - { - throw new Exception($"group:{group} method:{method} not found in rename record map"); - } - } - Debug.Log("Rename virtual methods end"); - Debug.Log("Rename methods end"); - } - - class RefPropertyMetas - { - public List customAttributes = new List(); - } - - private void BuildHierarchyProperties(TypeDef type, List properties) - { - while (type != null) - { - properties.AddRange(type.Properties); - type = MetaUtil.GetBaseTypeDef(type); - } - } - - private void BuildRefPropertyMetasMap(Dictionary refPropertyMetasMap) - { - foreach (var e in _refTypeRefMetasMap) - { - TypeDef typeDef = e.Key; - var hierarchyProperties = new List(); - BuildHierarchyProperties(typeDef, hierarchyProperties); - RefTypeDefMetas typeDefMetas = e.Value; - foreach (CustomAttribute ca in typeDefMetas.customAttributes) - { - foreach (var arg in ca.NamedArguments) - { - if (arg.IsField) - { - continue; - } - foreach (PropertyDef field in hierarchyProperties) - { - // FIXME. field of Generic Base Type may not be same - if (field.Name == arg.Name && TypeEqualityComparer.Instance.Equals(arg.Type, field.PropertySig.RetType)) - { - if (!refPropertyMetasMap.TryGetValue(field, out var fieldMetas)) - { - fieldMetas = new RefPropertyMetas(); - refPropertyMetasMap.Add(field, fieldMetas); - } - fieldMetas.customAttributes.Add(ca); - break; - } - } - } - } - } - } - - private void RenameProperties() - { - Debug.Log("Rename properties begin"); - var refPropertyMetasMap = new Dictionary(); - BuildRefPropertyMetasMap(refPropertyMetasMap); - foreach (ModuleDef mod in _toObfuscatedModules) - { - foreach (TypeDef type in mod.GetTypes()) - { - foreach (PropertyDef property in type.Properties) - { - if (_renamePolicy.NeedRename(property)) - { - Rename(property, refPropertyMetasMap.GetValueOrDefault(property)); - } - } - } - } - Debug.Log("Rename properties end"); - } - - private void RenameEvents() - { - Debug.Log("Rename events begin"); - foreach (ModuleDef mod in _toObfuscatedModules) - { - foreach (TypeDef type in mod.GetTypes()) - { - foreach (EventDef eventDef in type.Events) - { - if (_renamePolicy.NeedRename(eventDef)) - { - Rename(eventDef); - } - } - } - } - Debug.Log("Rename events begin"); - } - - //private void Rename(ModuleDef mod) - //{ - // string oldName = mod.Assembly.Name; - // string newName = _renameRecordMap.TryGetExistRenameMapping(mod, out var n) ? n : _nameMaker.GetNewName(mod, oldName); - // _renameRecordMap.AddRename(mod, newName); - // mod.Assembly.Name = newName; - // mod.Name = $"{newName}.dll"; - // //Debug.Log($"rename module. oldName:{oldName} newName:{newName}"); - // foreach (AssemblyReferenceInfo ass in GetReferenceMeAssemblies(mod)) - // { - // foreach (AssemblyRef assRef in ass.module.GetAssemblyRefs()) - // { - // if (assRef.Name == oldName) - // { - // _renameRecordMap.AddRename(mod, newName); - // assRef.Name = newName; - // // Debug.Log($"rename assembly:{ass.name} ref oldName:{oldName} newName:{newName}"); - // } - // } - // } - //} - - private void Rename(TypeDef type, RefTypeDefMetas refTypeDefMeta) - { - string moduleName = MetaUtil.GetModuleNameWithoutExt(type.Module.Name); - string oldFullName = type.FullName; - string oldNamespace = type.Namespace; - - string oldName = type.Name; - - string newNamespace; - string newName; - if (_renameRecordMap.TryGetExistRenameMapping(type, out var nns, out var nn)) - { - newNamespace = nns; - newName = nn; - } - else - { - newNamespace = _nameMaker.GetNewNamespace(type, oldNamespace, _useConsistentNamespaceObfuscation); - newName = _nameMaker.GetNewName(type, oldName); - } - - if (refTypeDefMeta != null) - { - foreach (TypeRef typeRef in refTypeDefMeta.typeRefs) - { - Assert.AreEqual(typeRef.FullName, oldFullName); - Assert.IsTrue(typeRef.DefinitionAssembly.Name == moduleName); - if (!string.IsNullOrEmpty(oldNamespace)) - { - typeRef.Namespace = newNamespace; - } - typeRef.Name = newName; - //Debug.Log($"rename assembly:{typeRef.Module.Name} reference {oldFullName} => {typeRef.FullName}"); - } - } - type.Name = newName; - type.Namespace = newNamespace; - string newFullName = type.FullName; - _renameRecordMap.AddRename(type, newFullName); - //Debug.Log($"rename typedef. assembly:{type.Module.Name} oldName:{oldFullName} => newName:{newFullName}"); - } - - private void Rename(FieldDef field, RefFieldMetas fieldMetas) - { - string oldName = field.Name; - string newName = _renameRecordMap.TryGetExistRenameMapping(field, out var nn) ? nn : _nameMaker.GetNewName(field, oldName); - if (fieldMetas != null) - { - foreach (var memberRef in fieldMetas.fieldRefs) - { - memberRef.Name = newName; - //Debug.Log($"rename assembly:{memberRef.Module.Name} reference {field.FullName} => {memberRef.FullName}"); - } - foreach (var ca in fieldMetas.customAttributes) - { - foreach (var arg in ca.NamedArguments) - { - if (arg.Name == oldName) - { - arg.Name = newName; - } - } - } - } - //Debug.Log($"rename field. {field} => {newName}"); - _renameRecordMap.AddRename(field, newName); - field.Name = newName; - - } - - private void Rename(MethodDef method, RefMethodMetas refMethodMetas) - { - string oldName = method.Name; - string newName = _renameRecordMap.TryGetExistRenameMapping(method, out var nn) ? nn : _nameMaker.GetNewName(method, oldName); - Rename(method, refMethodMetas, newName); - } - - private void Rename(MethodDef method, RefMethodMetas refMethodMetas, string newName) - { - ModuleDefMD mod = (ModuleDefMD)method.DeclaringType.Module; - RenameMethodParams(method); - RenameMethodBody(method); - if (refMethodMetas != null) - { - foreach (MemberRef memberRef in refMethodMetas.memberRefs) - { - string oldMethodFullName = memberRef.ToString(); - memberRef.Name = newName; - //Debug.Log($"rename assembly:{memberRef.Module.Name} method:{oldMethodFullName} => {memberRef}"); - } - } - _renameRecordMap.AddRename(method, newName); - method.Name = newName; - } - - private void RenameMethodBody(MethodDef method) - { - if (method.Body == null) - { - return; - } - } - - private void RenameMethodParams(MethodDef method) - { - foreach (Parameter param in method.Parameters) - { - if (param.ParamDef != null) - { - Rename(param.ParamDef); - } - } - } - - private void Rename(ParamDef param) - { - string newName = _nameMaker.GetNewName(param, param.Name); - param.Name = newName; - } - - private void Rename(EventDef eventDef) - { - string oldName = eventDef.Name; - string newName = _renameRecordMap.TryGetExistRenameMapping(eventDef, out var nn) ? nn : _nameMaker.GetNewName(eventDef, eventDef.Name); - _renameRecordMap.AddRename(eventDef, newName); - eventDef.Name = newName; - } - - private void Rename(PropertyDef property, RefPropertyMetas refPropertyMetas) - { - string oldName = property.Name; - string newName = _renameRecordMap.TryGetExistRenameMapping(property, out var nn) ? nn : _nameMaker.GetNewName(property, oldName); - - if (refPropertyMetas != null) - { - foreach (var ca in refPropertyMetas.customAttributes) - { - foreach (var arg in ca.NamedArguments) - { - if (arg.Name == oldName) - { - arg.Name = newName; - } - } - } - } - _renameRecordMap.AddRename(property, newName); - property.Name = newName; - } - - public void Save() - { - Directory.CreateDirectory(Path.GetDirectoryName(_mappingXmlPath)); - _renameRecordMap.WriteXmlMappingFile(); - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/SymbolRename.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/SymbolRename.cs.meta deleted file mode 100644 index 739a842..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/SymbolRename.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ec29be12f08e90741a59970f029c2eec -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/VirtualMethodGroupCalculator.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/VirtualMethodGroupCalculator.cs deleted file mode 100644 index 03cb1b3..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/VirtualMethodGroupCalculator.cs +++ /dev/null @@ -1,100 +0,0 @@ -using dnlib.DotNet; -using Obfuz.Utils; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Obfuz.ObfusPasses.SymbolObfus -{ - - public class VirtualMethodGroup - { - public List methods; - } - - public class VirtualMethodGroupCalculator - { - - private class TypeFlatMethods - { - public HashSet flatMethods = new HashSet(); - - - public bool TryFindMatchVirtualMethod(MethodDef method, out MethodDef matchMethodDef) - { - foreach (var parentOrInterfaceMethod in flatMethods) - { - if (parentOrInterfaceMethod.Name == method.Name && parentOrInterfaceMethod.GetParamCount() == method.GetParamCount()) - { - matchMethodDef = parentOrInterfaceMethod; - return true; - } - } - matchMethodDef = null; - return false; - } - } - - - private readonly Dictionary _methodGroups = new Dictionary(); - private readonly Dictionary _visitedTypes = new Dictionary(); - - - - public VirtualMethodGroup GetMethodGroup(MethodDef methodDef) - { - if (_methodGroups.TryGetValue(methodDef, out var group)) - { - return group; - } - return null; - } - - public void CalculateType(TypeDef typeDef) - { - if (_visitedTypes.ContainsKey(typeDef)) - { - return; - } - - var typeMethods = new TypeFlatMethods(); - - if (typeDef.BaseType != null) - { - TypeDef baseTypeDef = MetaUtil.GetTypeDefOrGenericTypeBaseThrowException(typeDef.BaseType); - CalculateType(baseTypeDef); - typeMethods.flatMethods.AddRange(_visitedTypes[baseTypeDef].flatMethods); - foreach (var intfType in typeDef.Interfaces) - { - TypeDef intfTypeDef = MetaUtil.GetTypeDefOrGenericTypeBaseThrowException(intfType.Interface); - CalculateType(intfTypeDef); - typeMethods.flatMethods.AddRange(_visitedTypes[intfTypeDef].flatMethods); - } - } - foreach (var method in typeDef.Methods) - { - if (!method.IsVirtual) - { - continue; - } - if (typeMethods.TryFindMatchVirtualMethod(method, out var matchMethodDef)) - { - var group = _methodGroups[matchMethodDef]; - group.methods.Add(method); - _methodGroups.Add(method, group); - } - else - { - _methodGroups.Add(method, new VirtualMethodGroup() { methods = new List { method } }); - } - if (method.IsNewSlot) - { - typeMethods.flatMethods.Add(method); - } - } - _visitedTypes.Add(typeDef, typeMethods); - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/VirtualMethodGroupCalculator.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/VirtualMethodGroupCalculator.cs.meta deleted file mode 100644 index 097106a..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/VirtualMethodGroupCalculator.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 649aeb6306500a04f8b7a3e01f5aaf0d -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfuscationMethodWhitelist.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfuscationMethodWhitelist.cs deleted file mode 100644 index 87ca94f..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfuscationMethodWhitelist.cs +++ /dev/null @@ -1,75 +0,0 @@ -using dnlib.DotNet; -using Obfuz.Editor; -using Obfuz.Utils; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Obfuz -{ - public class ObfuscationMethodWhitelist - { - private bool ShouldBeIgnoredByCustomAttribute(IHasCustomAttribute obj) - { - return MetaUtil.HasObfuzIgnoreAttribute(obj); - } - - public bool IsInWhiteList(ModuleDef module) - { - string modName = module.Assembly.Name; - if (modName == "Obfuz.Runtime") - { - return true; - } - if (ShouldBeIgnoredByCustomAttribute(module)) - { - return true; - } - return false; - } - - public bool IsInWhiteList(MethodDef method) - { - if (IsInWhiteList(method.DeclaringType)) - { - return true; - } - if (method.Name.StartsWith(ConstValues.ObfuzInternalSymbolNamePrefix)) - { - return true; - } - if (ShouldBeIgnoredByCustomAttribute(method)) - { - return true; - } - return false; - } - - public bool IsInWhiteList(TypeDef type) - { - if (type.Name.StartsWith(ConstValues.ObfuzInternalSymbolNamePrefix)) - { - return true; - } - if (IsInWhiteList(type.Module)) - { - return true; - } - if (MetaUtil.HasObfuzIgnoreAttributeInSelfOrParent(type)) - { - return true; - } - if (type.DeclaringType != null && IsInWhiteList(type.DeclaringType)) - { - return true; - } - if (type.FullName == "Obfuz.EncryptionVM.GeneratedEncryptionVirtualMachine") - { - return true; - } - return false; - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfuscationMethodWhitelist.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfuscationMethodWhitelist.cs.meta deleted file mode 100644 index 0ef3bf3..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfuscationMethodWhitelist.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 8824d47fdc31cef41a899294491c8844 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfuscationPassContext.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfuscationPassContext.cs deleted file mode 100644 index f4b5c74..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfuscationPassContext.cs +++ /dev/null @@ -1,83 +0,0 @@ -using dnlib.DotNet; -using Obfuz.Data; -using Obfuz.Emit; -using Obfuz.ObfusPasses; -using Obfuz.ObfusPasses.SymbolObfus; -using Obfuz.Utils; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Obfuz -{ - public delegate IRandom RandomCreator(int seed); - - public class EncryptionScopeInfo - { - public readonly IEncryptor encryptor; - public readonly RandomCreator localRandomCreator; - - public EncryptionScopeInfo(IEncryptor encryptor, RandomCreator localRandomCreator) - { - this.encryptor = encryptor; - this.localRandomCreator = localRandomCreator; - } - } - - public class EncryptionScopeProvider - { - private readonly EncryptionScopeInfo _defaultStaticScope; - private readonly EncryptionScopeInfo _defaultDynamicScope; - private readonly HashSet _dynamicSecretAssemblyNames; - - public EncryptionScopeProvider(EncryptionScopeInfo defaultStaticScope, EncryptionScopeInfo defaultDynamicScope, HashSet dynamicSecretAssemblyNames) - { - _defaultStaticScope = defaultStaticScope; - _defaultDynamicScope = defaultDynamicScope; - _dynamicSecretAssemblyNames = dynamicSecretAssemblyNames; - } - - public EncryptionScopeInfo GetScope(ModuleDef module) - { - if (_dynamicSecretAssemblyNames.Contains(module.Assembly.Name)) - { - return _defaultDynamicScope; - } - else - { - return _defaultStaticScope; - } - } - - public bool IsDynamicSecretAssembly(ModuleDef module) - { - return _dynamicSecretAssemblyNames.Contains(module.Assembly.Name); - } - } - - public class ObfuscationPassContext - { - public static ObfuscationPassContext Current { get; set; } - - - public GroupByModuleEntityManager moduleEntityManager; - - public AssemblyCache assemblyCache; - - public List modulesToObfuscate; - public List allObfuscationRelativeModules; - - public List assembliesToObfuscate; - public List nonObfuscatedButReferencingObfuscatedAssemblies; - - public string obfuscatedAssemblyOutputPath; - - public EncryptionScopeProvider encryptionScopeProvider; - public ConstFieldAllocator constFieldAllocator; - public RvaDataAllocator rvaDataAllocator; - public ObfuscationMethodWhitelist whiteList; - public ConfigurablePassPolicy passPolicy; - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfuscationPassContext.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfuscationPassContext.cs.meta deleted file mode 100644 index 827ddc4..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfuscationPassContext.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 196d07f0366ce4b46bf0333fa4918d40 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Obfuscator.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Obfuscator.cs deleted file mode 100644 index 6b7bcb8..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Obfuscator.cs +++ /dev/null @@ -1,339 +0,0 @@ -using dnlib.DotNet; -using Obfuz.Data; -using Obfuz.Emit; -using Obfuz.EncryptionVM; -using Obfuz.ObfusPasses; -using Obfuz.ObfusPasses.CleanUp; -using Obfuz.ObfusPasses.SymbolObfus; -using Obfuz.Utils; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using UnityEngine; - -namespace Obfuz -{ - - public class Obfuscator - { - private readonly string _obfuscatedAssemblyOutputPath; - - private readonly List _assembliesToObfuscate; - private readonly List _nonObfuscatedButReferencingObfuscatedAssemblies; - private readonly List _assemblySearchPaths; - - private readonly ConfigurablePassPolicy _passPolicy; - - private readonly Pipeline _pipeline1 = new Pipeline(); - private readonly Pipeline _pipeline2 = new Pipeline(); - - private readonly byte[] _defaultStaticByteSecretKey; - private readonly byte[] _defaultDynamicByteSecret; - private readonly HashSet _assembliesUsingDynamicSecretKeys; - - private readonly int _randomSeed; - private readonly string _encryptionVmGenerationSecretKey; - private readonly int _encryptionVmOpCodeCount; - private readonly string _encryptionVmCodeFile; - - private ObfuscationPassContext _ctx; - - public Obfuscator(ObfuscatorBuilder builder) - { - _defaultStaticByteSecretKey = KeyGenerator.GenerateKey(builder.DefaultStaticSecretKey, VirtualMachine.SecretKeyLength); - _defaultDynamicByteSecret = KeyGenerator.GenerateKey(builder.DefaultDynamicSecretKey, VirtualMachine.SecretKeyLength); - _assembliesUsingDynamicSecretKeys = new HashSet(builder.AssembliesUsingDynamicSecretKeys); - - - _randomSeed = builder.RandomSeed; - _encryptionVmGenerationSecretKey = builder.EncryptionVmGenerationSecretKey; - _encryptionVmOpCodeCount = builder.EncryptionVmOpCodeCount; - _encryptionVmCodeFile = builder.EncryptionVmCodeFile; - - _assembliesToObfuscate = builder.AssembliesToObfuscate; - _nonObfuscatedButReferencingObfuscatedAssemblies = builder.NonObfuscatedButReferencingObfuscatedAssemblies; - _obfuscatedAssemblyOutputPath = builder.ObfuscatedAssemblyOutputPath; - _assemblySearchPaths = builder.AssemblySearchPaths; - - _passPolicy = new ConfigurablePassPolicy(_assembliesToObfuscate, builder.EnableObfuscationPasses, builder.ObfuscationPassRuleConfigFiles); - - foreach (var pass in builder.ObfuscationPasses) - { - if (pass is SymbolObfusPass symbolObfusPass) - { - _pipeline2.AddPass(pass); - } - else - { - _pipeline1.AddPass(pass); - } - } - _pipeline1.AddPass(new CleanUpInstructionPass()); - _pipeline2.AddPass(new RemoveObfuzAttributesPass()); - } - - public void Run() - { - Debug.Log($"Obfuscator Run. begin"); - FileUtil.RecreateDir(_obfuscatedAssemblyOutputPath); - RunPipeline(_pipeline1); - _assemblySearchPaths.Insert(0, _obfuscatedAssemblyOutputPath); - RunPipeline(_pipeline2); - Debug.Log($"Obfuscator Run. end"); - } - - private void RunPipeline(Pipeline pipeline) - { - if (pipeline.Empty) - { - return; - } - OnPreObfuscation(pipeline); - DoObfuscation(pipeline); - OnPostObfuscation(pipeline); - } - - private IEncryptor CreateEncryptionVirtualMachine(byte[] secretKey) - { - var vmCreator = new VirtualMachineCreator(_encryptionVmGenerationSecretKey); - var vm = vmCreator.CreateVirtualMachine(_encryptionVmOpCodeCount); - var vmGenerator = new VirtualMachineCodeGenerator(vm); - - if (!File.Exists(_encryptionVmCodeFile)) - { - throw new Exception($"EncryptionVm CodeFile:`{_encryptionVmCodeFile}` not exists! Please run `Obfuz/GenerateVm` to generate it!"); - } - if (!vmGenerator.ValidateMatch(_encryptionVmCodeFile)) - { - throw new Exception($"EncryptionVm CodeFile:`{_encryptionVmCodeFile}` not match with encryptionVM settings! Please run `Obfuz/GenerateVm` to update it!"); - } - var vms = new VirtualMachineSimulator(vm, secretKey); - - var generatedVmTypes = AppDomain.CurrentDomain.GetAssemblies() - .Select(assembly => assembly.GetType("Obfuz.EncryptionVM.GeneratedEncryptionVirtualMachine")) - .Where(type => type != null) - .ToList(); - if (generatedVmTypes.Count == 0) - { - throw new Exception($"class Obfuz.EncryptionVM.GeneratedEncryptionVirtualMachine not found in any assembly! Please run `Obfuz/GenerateVm` to generate it!"); - } - if (generatedVmTypes.Count > 1) - { - throw new Exception($"class Obfuz.EncryptionVM.GeneratedEncryptionVirtualMachine found in multiple assemblies! Please retain only one!"); - } - - var gvmInstance = (IEncryptor)Activator.CreateInstance(generatedVmTypes[0], new object[] { secretKey } ); - - VerifyVm(vm, vms, gvmInstance); - - return vms; - } - - private void VerifyVm(VirtualMachine vm, VirtualMachineSimulator vms, IEncryptor gvm) - { - int testInt = 11223344; - long testLong = 1122334455667788L; - float testFloat = 1234f; - double testDouble = 1122334455.0; - string testString = "hello,world"; - for (int i = 0; i < vm.opCodes.Length; i++) - { - int ops = i * vm.opCodes.Length + i; - //int salt = i; - //int ops = -1135538782; - int salt = -879409147; - { - int encryptedIntOfVms = vms.Encrypt(testInt, ops, salt); - int decryptedIntOfVms = vms.Decrypt(encryptedIntOfVms, ops, salt); - if (decryptedIntOfVms != testInt) - { - throw new Exception($"VirtualMachineSimulator decrypt failed! opCode:{i}, originalValue:{testInt} decryptedValue:{decryptedIntOfVms}"); - } - int encryptedValueOfGvm = gvm.Encrypt(testInt, ops, salt); - int decryptedValueOfGvm = gvm.Decrypt(encryptedValueOfGvm, ops, salt); - if (encryptedValueOfGvm != encryptedIntOfVms) - { - throw new Exception($"encryptedValue not match! opCode:{i}, originalValue:{testInt} encryptedValue VirtualMachineSimulator:{encryptedIntOfVms} GeneratedEncryptionVirtualMachine:{encryptedValueOfGvm}"); - } - if (decryptedValueOfGvm != testInt) - { - throw new Exception($"GeneratedEncryptionVirtualMachine decrypt failed! opCode:{i}, originalValue:{testInt} decryptedValue:{decryptedValueOfGvm}"); - } - } - { - long encryptedLongOfVms = vms.Encrypt(testLong, ops, salt); - long decryptedLongOfVms = vms.Decrypt(encryptedLongOfVms, ops, salt); - if (decryptedLongOfVms != testLong) - { - throw new Exception($"VirtualMachineSimulator decrypt long failed! opCode:{i}, originalValue:{testLong} decryptedValue:{decryptedLongOfVms}"); - } - long encryptedValueOfGvm = gvm.Encrypt(testLong, ops, salt); - long decryptedValueOfGvm = gvm.Decrypt(encryptedValueOfGvm, ops, salt); - if (encryptedValueOfGvm != encryptedLongOfVms) - { - throw new Exception($"encryptedValue not match! opCode:{i}, originalValue:{testLong} encryptedValue VirtualMachineSimulator:{encryptedLongOfVms} GeneratedEncryptionVirtualMachine:{encryptedValueOfGvm}"); - } - if (decryptedValueOfGvm != testLong) - { - throw new Exception($"GeneratedEncryptionVirtualMachine decrypt long failed! opCode:{i}, originalValue:{testLong} decryptedValue:{decryptedValueOfGvm}"); - } - } - { - float encryptedFloatOfVms = vms.Encrypt(testFloat, ops, salt); - float decryptedFloatOfVms = vms.Decrypt(encryptedFloatOfVms, ops, salt); - if (decryptedFloatOfVms != testFloat) - { - throw new Exception("encryptedFloat not match"); - } - float encryptedValueOfGvm = gvm.Encrypt(testFloat, ops, salt); - float decryptedValueOfGvm = gvm.Decrypt(encryptedFloatOfVms, ops, salt); - if (encryptedFloatOfVms != encryptedValueOfGvm) - { - throw new Exception($"encryptedValue not match! opCode:{i}, originalValue:{testFloat} encryptedValue"); - } - if (decryptedValueOfGvm != testFloat) - { - throw new Exception($"GeneratedEncryptionVirtualMachine decrypt float failed! opCode:{i}, originalValue:{testFloat}"); - } - } - { - double encryptedFloatOfVms = vms.Encrypt(testDouble, ops, salt); - double decryptedFloatOfVms = vms.Decrypt(encryptedFloatOfVms, ops, salt); - if (decryptedFloatOfVms != testDouble) - { - throw new Exception("encryptedFloat not match"); - } - double encryptedValueOfGvm = gvm.Encrypt(testDouble, ops, salt); - double decryptedValueOfGvm = gvm.Decrypt(encryptedFloatOfVms, ops, salt); - if (encryptedFloatOfVms != encryptedValueOfGvm) - { - throw new Exception($"encryptedValue not match! opCode:{i}, originalValue:{testDouble} encryptedValue"); - } - if (decryptedValueOfGvm != testDouble) - { - throw new Exception($"GeneratedEncryptionVirtualMachine decrypt float failed! opCode:{i}, originalValue:{testDouble}"); - } - } - - { - byte[] encryptedStrOfVms = vms.Encrypt(testString, ops, salt); - string decryptedStrOfVms = vms.DecryptString(encryptedStrOfVms, 0, encryptedStrOfVms.Length, ops, salt); - if (decryptedStrOfVms != testString) - { - throw new Exception($"VirtualMachineSimulator decrypt string failed! opCode:{i}, originalValue:{testString} decryptedValue:{decryptedStrOfVms}"); - } - byte[] encryptedStrOfGvm = gvm.Encrypt(testString, ops, salt); - string decryptedStrOfGvm = gvm.DecryptString(encryptedStrOfGvm, 0, encryptedStrOfGvm.Length, ops, salt); - if (!encryptedStrOfGvm.SequenceEqual(encryptedStrOfVms)) - { - throw new Exception($"encryptedValue not match! opCode:{i}, originalValue:{testString} encryptedValue VirtualMachineSimulator:{encryptedStrOfVms} GeneratedEncryptionVirtualMachine:{encryptedStrOfGvm}"); - } - if (decryptedStrOfGvm != testString) - { - throw new Exception($"GeneratedEncryptionVirtualMachine decrypt string failed! opCode:{i}, originalValue:{testString} decryptedValue:{decryptedStrOfGvm}"); - } - } - } - } - - private EncryptionScopeInfo CreateEncryptionScope(byte[] byteSecret) - { - int[] intSecretKey = KeyGenerator.ConvertToIntKey(byteSecret); - IEncryptor encryption = CreateEncryptionVirtualMachine(byteSecret); - RandomCreator localRandomCreator = (seed) => new RandomWithKey(intSecretKey, _randomSeed ^ seed); - return new EncryptionScopeInfo(encryption, localRandomCreator); - } - - private EncryptionScopeProvider CreateEncryptionScopeProvider() - { - var defaultStaticScope = CreateEncryptionScope(_defaultStaticByteSecretKey); - var defaultDynamicScope = CreateEncryptionScope(_defaultDynamicByteSecret); - foreach (string dynamicAssName in _assembliesUsingDynamicSecretKeys) - { - if (!_assembliesToObfuscate.Contains(dynamicAssName)) - { - throw new Exception($"Dynamic secret assembly `{dynamicAssName}` should be in the toObfuscatedAssemblyNames list!"); - } - } - return new EncryptionScopeProvider(defaultStaticScope, defaultDynamicScope, _assembliesUsingDynamicSecretKeys); - } - - private void OnPreObfuscation(Pipeline pipeline) - { - AssemblyCache assemblyCache = new AssemblyCache(new PathAssemblyResolver(_assemblySearchPaths.ToArray())); - List modulesToObfuscate = new List(); - List allObfuscationRelativeModules = new List(); - LoadAssemblies(assemblyCache, modulesToObfuscate, allObfuscationRelativeModules); - - EncryptionScopeProvider encryptionScopeProvider = CreateEncryptionScopeProvider(); - var moduleEntityManager = new GroupByModuleEntityManager(); - var rvaDataAllocator = new RvaDataAllocator(encryptionScopeProvider, moduleEntityManager); - var constFieldAllocator = new ConstFieldAllocator(encryptionScopeProvider, rvaDataAllocator, moduleEntityManager); - _ctx = new ObfuscationPassContext - { - assemblyCache = assemblyCache, - modulesToObfuscate = modulesToObfuscate, - allObfuscationRelativeModules = allObfuscationRelativeModules, - assembliesToObfuscate = _assembliesToObfuscate, - nonObfuscatedButReferencingObfuscatedAssemblies = _nonObfuscatedButReferencingObfuscatedAssemblies, - obfuscatedAssemblyOutputPath = _obfuscatedAssemblyOutputPath, - moduleEntityManager = moduleEntityManager, - - encryptionScopeProvider = encryptionScopeProvider, - - rvaDataAllocator = rvaDataAllocator, - constFieldAllocator = constFieldAllocator, - whiteList = new ObfuscationMethodWhitelist(), - passPolicy = _passPolicy, - }; - ObfuscationPassContext.Current = _ctx; - pipeline.Start(); - } - - private void LoadAssemblies(AssemblyCache assemblyCache, List modulesToObfuscate, List allObfuscationRelativeModules) - { - foreach (string assName in _assembliesToObfuscate.Concat(_nonObfuscatedButReferencingObfuscatedAssemblies)) - { - ModuleDefMD mod = assemblyCache.TryLoadModule(assName); - if (mod == null) - { - Debug.Log($"assembly: {assName} not found! ignore."); - continue; - } - if (_assembliesToObfuscate.Contains(assName)) - { - modulesToObfuscate.Add(mod); - } - allObfuscationRelativeModules.Add(mod); - } - } - - private void WriteAssemblies() - { - foreach (ModuleDef mod in _ctx.allObfuscationRelativeModules) - { - string assNameWithExt = mod.Name; - string outputFile = $"{_obfuscatedAssemblyOutputPath}/{assNameWithExt}"; - mod.Write(outputFile); - Debug.Log($"save module. name:{mod.Assembly.Name} output:{outputFile}"); - } - } - - private void DoObfuscation(Pipeline pipeline) - { - pipeline.Run(); - } - - private void OnPostObfuscation(Pipeline pipeline) - { - pipeline.Stop(); - - _ctx.constFieldAllocator.Done(); - _ctx.rvaDataAllocator.Done(); - WriteAssemblies(); - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Obfuscator.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Obfuscator.cs.meta deleted file mode 100644 index 08291f3..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Obfuscator.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ca9c4e108bde2184885e599f2bd19a00 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfuscatorBuilder.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfuscatorBuilder.cs deleted file mode 100644 index 3a3943c..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfuscatorBuilder.cs +++ /dev/null @@ -1,216 +0,0 @@ -using Obfuz.EncryptionVM; -using Obfuz.ObfusPasses; -using Obfuz.ObfusPasses.CallObfus; -using Obfuz.ObfusPasses.ConstEncrypt; -using Obfuz.ObfusPasses.ExprObfus; -using Obfuz.ObfusPasses.FieldEncrypt; -using Obfuz.ObfusPasses.SymbolObfus; -using Obfuz.Settings; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using UnityEditor; - -namespace Obfuz -{ - public class ObfuscatorBuilder - { - private string _defaultStaticSecretKey; - private string _defaultStaticSecretKeyOutputPath; - private string _defaultDynamicSecretKey; - private string _defaultDynamicSecretKeyOutputPath; - private List _assembliesUsingDynamicSecretKeys = new List(); - - private int _randomSeed; - private string _encryptionVmGenerationSecretKey; - private int _encryptionVmOpCodeCount; - private string _encryptionVmCodeFile; - - private List _assembliesToObfuscate = new List(); - private List _nonObfuscatedButReferencingObfuscatedAssemblies = new List(); - private List _assemblySearchPaths = new List(); - - private string _obfuscatedAssemblyOutputPath; - private List _obfuscationPassRuleConfigFiles; - - private ObfuscationPassType _enabledObfuscationPasses; - private List _obfuscationPasses = new List(); - - public string DefaultStaticSecretKey - { - get => _defaultStaticSecretKey; - set => _defaultStaticSecretKey = value; - } - - public string DefaultStaticSecretKeyOutputPath - { - get => _defaultStaticSecretKeyOutputPath; - set => _defaultStaticSecretKeyOutputPath = value; - } - - public string DefaultDynamicSecretKey - { - get => _defaultDynamicSecretKey; - set => _defaultDynamicSecretKey = value; - } - - public string DefaultDynamicSecretKeyOutputPath - { - get => _defaultDynamicSecretKeyOutputPath; - set => _defaultDynamicSecretKeyOutputPath = value; - } - - public List AssembliesUsingDynamicSecretKeys - { - get => _assembliesUsingDynamicSecretKeys; - set => _assembliesUsingDynamicSecretKeys = value; - } - - public int RandomSeed - { - get => _randomSeed; - set => _randomSeed = value; - } - - public string EncryptionVmGenerationSecretKey - { - get => _encryptionVmGenerationSecretKey; - set => _encryptionVmGenerationSecretKey = value; - } - - public int EncryptionVmOpCodeCount - { - get => _encryptionVmOpCodeCount; - set => _encryptionVmOpCodeCount = value; - } - - public string EncryptionVmCodeFile - { - get => _encryptionVmCodeFile; - set => _encryptionVmCodeFile = value; - } - - public List AssembliesToObfuscate - { - get => _assembliesToObfuscate; - set => _assembliesToObfuscate = value; - } - - public List NonObfuscatedButReferencingObfuscatedAssemblies - { - get => _nonObfuscatedButReferencingObfuscatedAssemblies; - set => _nonObfuscatedButReferencingObfuscatedAssemblies = value; - } - - public List AssemblySearchPaths - { - get => _assemblySearchPaths; - set => _assemblySearchPaths = value; - } - - public string ObfuscatedAssemblyOutputPath - { - get => _obfuscatedAssemblyOutputPath; - set => _obfuscatedAssemblyOutputPath = value; - } - - public ObfuscationPassType EnableObfuscationPasses - { - get => _enabledObfuscationPasses; - set => _enabledObfuscationPasses = value; - } - - public List ObfuscationPassRuleConfigFiles - { - get => _obfuscationPassRuleConfigFiles; - set => _obfuscationPassRuleConfigFiles = value; - } - - public List ObfuscationPasses - { - get => _obfuscationPasses; - set => _obfuscationPasses = value; - } - - public void InsertTopPriorityAssemblySearchPaths(List assemblySearchPaths) - { - _assemblySearchPaths.InsertRange(0, assemblySearchPaths); - } - - public ObfuscatorBuilder AddPass(IObfuscationPass pass) - { - _obfuscationPasses.Add(pass); - return this; - } - - public Obfuscator Build() - { - return new Obfuscator(this); - } - - public static List BuildUnityAssemblySearchPaths() - { - string applicationContentsPath = EditorApplication.applicationContentsPath; - return new List - { -#if UNITY_2021_1_OR_NEWER - Path.Combine(applicationContentsPath, "UnityReferenceAssemblies/unity-4.8-api/Facades"), - Path.Combine(applicationContentsPath, "UnityReferenceAssemblies/unity-4.8-api"), -#elif UNITY_2020 || UNITY_2019 - Path.Combine(applicationContentsPath, "MonoBleedingEdge/lib/mono/4.7.1-api/Facades"), - Path.Combine(applicationContentsPath, "MonoBleedingEdge/lib/mono/4.7.1-api"), -#else -#error "Unsupported Unity version" -#endif - Path.Combine(applicationContentsPath, "Managed/UnityEngine"), - }; - } - - public static ObfuscatorBuilder FromObfuzSettings(ObfuzSettings settings, BuildTarget target, bool searchPathIncludeUnityEditorInstallLocation) - { - List searchPaths = searchPathIncludeUnityEditorInstallLocation ? - BuildUnityAssemblySearchPaths().Concat(settings.assemblySettings.additionalAssemblySearchPaths).ToList() - : settings.assemblySettings.additionalAssemblySearchPaths.ToList(); - var builder = new ObfuscatorBuilder - { - _defaultStaticSecretKey = settings.secretSettings.defaultStaticSecretKey, - _defaultStaticSecretKeyOutputPath = settings.secretSettings.DefaultStaticSecretKeyOutputPath, - _defaultDynamicSecretKey = settings.secretSettings.defaultDynamicSecretKey, - _defaultDynamicSecretKeyOutputPath = settings.secretSettings.DefaultDynamicSecretKeyOutputPath, - _assembliesUsingDynamicSecretKeys = settings.secretSettings.assembliesUsingDynamicSecretKeys.ToList(), - _randomSeed = settings.secretSettings.randomSeed, - _encryptionVmGenerationSecretKey = settings.encryptionVMSettings.codeGenerationSecretKey, - _encryptionVmOpCodeCount = settings.encryptionVMSettings.encryptionOpCodeCount, - _encryptionVmCodeFile = settings.encryptionVMSettings.codeOutputPath, - _assembliesToObfuscate = settings.assemblySettings.assembliesToObfuscate.ToList(), - _nonObfuscatedButReferencingObfuscatedAssemblies = settings.assemblySettings.nonObfuscatedButReferencingObfuscatedAssemblies.ToList(), - _assemblySearchPaths = searchPaths, - _obfuscatedAssemblyOutputPath = settings.GetObfuscatedAssemblyOutputPath(target), - _enabledObfuscationPasses = settings.obfuscationPassSettings.enabledPasses, - _obfuscationPassRuleConfigFiles = settings.obfuscationPassSettings.ruleFiles.ToList(), - }; - ObfuscationPassType obfuscationPasses = settings.obfuscationPassSettings.enabledPasses; - if (obfuscationPasses.HasFlag(ObfuscationPassType.ConstEncrypt)) - { - builder.AddPass(new ConstEncryptPass(settings.constEncryptSettings)); - } - if (obfuscationPasses.HasFlag(ObfuscationPassType.FieldEncrypt)) - { - builder.AddPass(new FieldEncryptPass(settings.fieldEncryptSettings)); - } - if (obfuscationPasses.HasFlag(ObfuscationPassType.CallObfus)) - { - builder.AddPass(new CallObfusPass(settings.callObfusSettings)); - } - if (obfuscationPasses.HasFlag(ObfuscationPassType.ExprObfus)) - { - builder.AddPass(new ExprObfusPass()); - } - if (obfuscationPasses.HasFlag(ObfuscationPassType.SymbolObfus)) - { - builder.AddPass(new SymbolObfusPass(settings.symbolObfusSettings)); - } - return builder; - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfuscatorBuilder.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfuscatorBuilder.cs.meta deleted file mode 100644 index 261993b..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfuscatorBuilder.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 77e279242d764ed4d996db96f35e8570 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Obfuz.Editor.asmdef b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Obfuz.Editor.asmdef deleted file mode 100644 index e1b3933..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Obfuz.Editor.asmdef +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "Obfuz.Editor", - "rootNamespace": "", - "references": [ - "GUID:4140bd2e2764f1f47ab93125ecb61942" - ], - "includePlatforms": [ - "Editor" - ], - "excludePlatforms": [], - "allowUnsafeCode": true, - "overrideReferences": false, - "precompiledReferences": [], - "autoReferenced": true, - "defineConstraints": [], - "versionDefines": [], - "noEngineReferences": false -} \ No newline at end of file diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Obfuz.Editor.asmdef.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Obfuz.Editor.asmdef.meta deleted file mode 100644 index d010c09..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Obfuz.Editor.asmdef.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 66e09fc524ec6594b8d6ca1d91aa1a41 -AssemblyDefinitionImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Pipeline.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Pipeline.cs deleted file mode 100644 index 9e92d46..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Pipeline.cs +++ /dev/null @@ -1,43 +0,0 @@ -using Obfuz.ObfusPasses; -using System.Collections.Generic; - -namespace Obfuz -{ - public class Pipeline - { - private readonly List _passes = new List(); - - public bool Empty => _passes.Count == 0; - - public Pipeline AddPass(IObfuscationPass pass) - { - _passes.Add(pass); - return this; - } - - public void Start() - { - foreach (var pass in _passes) - { - pass.Start(); - } - } - - public void Stop() - { - - foreach (var pass in _passes) - { - pass.Stop(); - } - } - - public void Run() - { - foreach (var pass in _passes) - { - pass.Process(); - } - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Pipeline.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Pipeline.cs.meta deleted file mode 100644 index fd3558c..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Pipeline.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 0915452219e923d428b9a408cf413844 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings.meta deleted file mode 100644 index 64d3c0a..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 4939d1f80df50b34c85ffc8fbe530887 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/AssemblySettings.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/AssemblySettings.cs deleted file mode 100644 index ec4898d..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/AssemblySettings.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using System.Linq; -using UnityEngine; - -namespace Obfuz.Settings -{ - [Serializable] - public class AssemblySettings - { - - [Tooltip("name of assemblies to obfuscate")] - public string[] assembliesToObfuscate; - - [Tooltip("name of assemblies not obfuscated but reference assemblies to obfuscated ")] - public string[] nonObfuscatedButReferencingObfuscatedAssemblies; - - [Tooltip("additional assembly search paths")] - public string[] additionalAssemblySearchPaths; - - public string[] GetObfuscationRelativeAssemblyNames() - { - return assembliesToObfuscate - .Concat(nonObfuscatedButReferencingObfuscatedAssemblies) - .ToArray(); - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/AssemblySettings.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/AssemblySettings.cs.meta deleted file mode 100644 index 8a13940..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/AssemblySettings.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 735c01fddc6f0c54a83e1feb9a60e13a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/CallObfuscationSettings.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/CallObfuscationSettings.cs deleted file mode 100644 index 3ea3a1f..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/CallObfuscationSettings.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using UnityEngine; - -namespace Obfuz.Settings -{ - [Serializable] - public class CallObfuscationSettings - { - [Tooltip("The obfuscation level for the obfuscation. Higher levels provide more security but may impact performance.")] - [Range(1, 4)] - public int obfuscationLevel = 1; - - [Tooltip("rule config xml files")] - public string[] ruleFiles; - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/CallObfuscationSettings.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/CallObfuscationSettings.cs.meta deleted file mode 100644 index ce268f1..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/CallObfuscationSettings.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ae4ddc19ecf8d9940b444f5b66c23efa -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/ConstEncryptionSettings.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/ConstEncryptionSettings.cs deleted file mode 100644 index 794d685..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/ConstEncryptionSettings.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using UnityEngine; - -namespace Obfuz.Settings -{ - [Serializable] - public class ConstEncryptionSettings - { - [Tooltip("The encryption level for the obfuscation. Higher levels provide more security but may impact performance.")] - [Range(1, 4)] - public int encryptionLevel = 1; - - [Tooltip("config xml files")] - public string[] ruleFiles; - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/ConstEncryptionSettings.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/ConstEncryptionSettings.cs.meta deleted file mode 100644 index d5cef40..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/ConstEncryptionSettings.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 2b189f76d7da58e4b9403b4fe87265b4 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/EncryptionVMSettings.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/EncryptionVMSettings.cs deleted file mode 100644 index 04a7a22..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/EncryptionVMSettings.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using UnityEngine; - -namespace Obfuz.Settings -{ - [Serializable] - public class EncryptionVMSettings - { - [Tooltip("secret key for generating encryption virtual machine source code")] - public string codeGenerationSecretKey = "Obfuz"; - - [Tooltip("encryption OpCode count, should be power of 2 and >= 64")] - public int encryptionOpCodeCount = 256; - - [Tooltip("encryption virtual machine source code output path")] - public string codeOutputPath = "Assets/Obfuz/GeneratedEncryptionVirtualMachine.cs"; - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/EncryptionVMSettings.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/EncryptionVMSettings.cs.meta deleted file mode 100644 index 0257381..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/EncryptionVMSettings.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f0e626d510710c540bdc36b4dca93340 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/FieldEncryptionSettings.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/FieldEncryptionSettings.cs deleted file mode 100644 index 0b41afe..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/FieldEncryptionSettings.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using UnityEngine; - -namespace Obfuz.Settings -{ - [Serializable] - public class FieldEncryptionSettings - { - [Tooltip("The encryption level for the obfuscation. Higher levels provide more security but may impact performance.")] - [Range(1, 4)] - public int encryptionLevel = 1; - - [Tooltip("rule config xml files")] - public string[] ruleFiles; - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/FieldEncryptionSettings.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/FieldEncryptionSettings.cs.meta deleted file mode 100644 index fbc0e2e..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/FieldEncryptionSettings.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 56cff1f5683d9114e8f13cee917ea582 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/ObfuscationPassSettings.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/ObfuscationPassSettings.cs deleted file mode 100644 index 837c8b0..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/ObfuscationPassSettings.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Obfuz.ObfusPasses; -using System; -using UnityEngine; - -namespace Obfuz.Settings -{ - [Serializable] - public class ObfuscationPassSettings - { - [Tooltip("enable obfuscation pass")] - public ObfuscationPassType enabledPasses = ObfuscationPassType.All; - - [Tooltip("rule config xml files")] - public string[] ruleFiles; - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/ObfuscationPassSettings.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/ObfuscationPassSettings.cs.meta deleted file mode 100644 index 147fed6..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/ObfuscationPassSettings.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 9cb41a6fb7293ce47807e432d80f2b2a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/ObfuzSettings.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/ObfuzSettings.cs deleted file mode 100644 index 70fb15d..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/ObfuzSettings.cs +++ /dev/null @@ -1,101 +0,0 @@ -using System.Collections.Generic; -using System.IO; -using System.Runtime.Remoting.Messaging; -using UnityEditor; -using UnityEditorInternal; -using UnityEngine; - -namespace Obfuz.Settings -{ - - - public class ObfuzSettings : ScriptableObject - { - [Tooltip("enable Obfuz")] - public bool enable = true; - - [Tooltip("assembly settings")] - public AssemblySettings assemblySettings; - - [Tooltip("obfuscation pass settings")] - public ObfuscationPassSettings obfuscationPassSettings; - - [Tooltip("secret settings")] - public SecretSettings secretSettings; - - [Tooltip("encryption virtual machine settings")] - public EncryptionVMSettings encryptionVMSettings; - - [Tooltip("symbol obfuscation settings")] - public SymbolObfuscationSettings symbolObfusSettings; - - [Tooltip("const encryption settings")] - public ConstEncryptionSettings constEncryptSettings; - - [Tooltip("field encryption settings")] - public FieldEncryptionSettings fieldEncryptSettings; - - [Tooltip("call obfuscation settings")] - public CallObfuscationSettings callObfusSettings; - - public string ObfuzRootDir => $"Library/Obfuz"; - - public string GetObfuscatedAssemblyOutputPath(BuildTarget target) - { - return $"{ObfuzRootDir}/{target}/ObfuscatedAssemblies"; - } - - public string GetOriginalAssemblyBackupDir(BuildTarget target) - { - return $"{ObfuzRootDir}/{target}/OriginalAssemblies"; - } - - private static ObfuzSettings s_Instance; - - public static ObfuzSettings Instance - { - get - { - if (!s_Instance) - { - LoadOrCreate(); - } - return s_Instance; - } - } - - protected static string SettingsPath => "ProjectSettings/Obfuz.asset"; - - private static ObfuzSettings LoadOrCreate() - { - string filePath = SettingsPath; - var arr = InternalEditorUtility.LoadSerializedFileAndForget(filePath); - //Debug.Log($"typeof arr:{arr?.GetType()} arr[0]:{(arr != null && arr.Length > 0 ? arr[0].GetType(): null)}"); - - if (arr != null && arr.Length > 0 && arr[0] is ObfuzSettings obfuzSettings) - { - s_Instance = obfuzSettings; - } - else - { - s_Instance ??= CreateInstance(); - } - return s_Instance; - } - - public static void Save() - { - if (!s_Instance) - { - Debug.LogError("Cannot save ScriptableSingleton: no instance!"); - return; - } - - string filePath = SettingsPath; - string directoryName = Path.GetDirectoryName(filePath); - Directory.CreateDirectory(directoryName); - UnityEngine.Object[] obj = new ObfuzSettings[1] { s_Instance }; - InternalEditorUtility.SaveToSerializedFileAndForget(obj, filePath, true); - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/ObfuzSettings.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/ObfuzSettings.cs.meta deleted file mode 100644 index 8bad58f..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/ObfuzSettings.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c414eef017e565c4db1442ec64ec52fe -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/ObfuzSettingsProvider.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/ObfuzSettingsProvider.cs deleted file mode 100644 index 3a5c9e2..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/ObfuzSettingsProvider.cs +++ /dev/null @@ -1,104 +0,0 @@ -using System; -using System.Reflection; -using UnityEditor; -using UnityEditor.Presets; -using UnityEngine; -using UnityEngine.UIElements; - -namespace Obfuz.Settings -{ - public class ObfuzSettingsProvider : SettingsProvider - { - - private static ObfuzSettingsProvider s_provider; - - [SettingsProvider] - public static SettingsProvider CreateMyCustomSettingsProvider() - { - if (s_provider == null) - { - s_provider = new ObfuzSettingsProvider(); - using (var so = new SerializedObject(ObfuzSettings.Instance)) - { - s_provider.keywords = GetSearchKeywordsFromSerializedObject(so); - } - } - return s_provider; - } - - - private SerializedObject _serializedObject; - private SerializedProperty _enable; - private SerializedProperty _assemblySettings; - private SerializedProperty _obfuscationPassSettings; - private SerializedProperty _secretSettings; - private SerializedProperty _encryptionVMSettings; - - private SerializedProperty _symbolObfusSettings; - private SerializedProperty _constEncryptSettings; - private SerializedProperty _fieldEncryptSettings; - private SerializedProperty _callObfusSettings; - - public ObfuzSettingsProvider() : base("Project/Obfuz", SettingsScope.Project) - { - } - - public override void OnActivate(string searchContext, VisualElement rootElement) - { - InitGUI(); - } - - public override void OnDeactivate() - { - base.OnDeactivate(); - ObfuzSettings.Save(); - } - - private void InitGUI() - { - var setting = ObfuzSettings.Instance; - _serializedObject?.Dispose(); - _serializedObject = new SerializedObject(setting); - _enable = _serializedObject.FindProperty("enable"); - _assemblySettings = _serializedObject.FindProperty("assemblySettings"); - _obfuscationPassSettings = _serializedObject.FindProperty("obfuscationPassSettings"); - _secretSettings = _serializedObject.FindProperty("secretSettings"); - - _encryptionVMSettings = _serializedObject.FindProperty("encryptionVMSettings"); - - _symbolObfusSettings = _serializedObject.FindProperty("symbolObfusSettings"); - _constEncryptSettings = _serializedObject.FindProperty("constEncryptSettings"); - _fieldEncryptSettings = _serializedObject.FindProperty("fieldEncryptSettings"); - _callObfusSettings = _serializedObject.FindProperty("callObfusSettings"); - } - - public override void OnGUI(string searchContext) - { - if (_serializedObject == null||!_serializedObject.targetObject) - { - InitGUI(); - } - _serializedObject.Update(); - EditorGUI.BeginChangeCheck(); - - EditorGUILayout.PropertyField(_enable); - EditorGUILayout.PropertyField(_assemblySettings); - EditorGUILayout.PropertyField(_obfuscationPassSettings); - EditorGUILayout.PropertyField(_secretSettings); - - EditorGUILayout.PropertyField(_encryptionVMSettings); - - EditorGUILayout.PropertyField(_symbolObfusSettings); - EditorGUILayout.PropertyField(_constEncryptSettings); - EditorGUILayout.PropertyField(_fieldEncryptSettings); - EditorGUILayout.PropertyField(_callObfusSettings); - - - if (EditorGUI.EndChangeCheck()) - { - _serializedObject.ApplyModifiedProperties(); - ObfuzSettings.Save(); - } - } - } -} \ No newline at end of file diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/ObfuzSettingsProvider.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/ObfuzSettingsProvider.cs.meta deleted file mode 100644 index 471477b..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/ObfuzSettingsProvider.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 9f020d09993a1aa41bae3258ec33d5fc -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/SecretSettings.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/SecretSettings.cs deleted file mode 100644 index 09c2143..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/SecretSettings.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.IO; -using UnityEngine; - -namespace Obfuz.Settings -{ - [Serializable] - public class SecretSettings - { - - [Tooltip("default static secret key")] - public string defaultStaticSecretKey = "Code Philosophy-Static"; - - [Tooltip("default dynamic secret key")] - public string defaultDynamicSecretKey = "Code Philosophy-Dynamic"; - - [Tooltip("secret key output path")] - public string secretKeyOutputPath = $"Assets/Resources/Obfuz"; - - [Tooltip("random seed")] - public int randomSeed = 0; - - [Tooltip("name of assemblies those use dynamic secret key")] - public string[] assembliesUsingDynamicSecretKeys; - - public string DefaultStaticSecretKeyOutputPath => Path.Combine(secretKeyOutputPath, "defaultStaticSecretKey.bytes"); - - public string DefaultDynamicSecretKeyOutputPath => Path.Combine(secretKeyOutputPath, "defaultDynamicSecretKey.bytes"); - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/SecretSettings.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/SecretSettings.cs.meta deleted file mode 100644 index 7e26a78..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/SecretSettings.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 7ac4fe2a6df113444b67412254452a00 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/SymbolObfuscationSettings.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/SymbolObfuscationSettings.cs deleted file mode 100644 index 6e1d765..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/SymbolObfuscationSettings.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using UnityEngine; - -namespace Obfuz.Settings -{ - [Serializable] - public class SymbolObfuscationSettings - { - public bool debug; - - [Tooltip("prefix for obfuscated name to avoid name confliction with original name")] - public string obfuscatedNamePrefix = "$"; - - [Tooltip("obfuscate same namespace to one name")] - public bool useConsistentNamespaceObfuscation = true; - - [Tooltip("symbol mapping file path")] - public string symbolMappingFile = "Assets/Obfuz/SymbolObfus/symbol-mapping.xml"; - - [Tooltip("rule files")] - public string[] ruleFiles; - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/SymbolObfuscationSettings.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/SymbolObfuscationSettings.cs.meta deleted file mode 100644 index 58779d6..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Settings/SymbolObfuscationSettings.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 2484a8a12a689df46b5eb7fc4ccac81f -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Unity.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Unity.meta deleted file mode 100644 index 8456b1d..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Unity.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: bc9b206fbf6a69f4c99a6ec9b0b27c69 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Unity/ObfuscationBeginEventArgs.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Unity/ObfuscationBeginEventArgs.cs deleted file mode 100644 index b8f2397..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Unity/ObfuscationBeginEventArgs.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Obfuz.Unity -{ - public class ObfuscationBeginEventArgs - { - public string scriptAssembliesPath; - public string obfuscatedScriptAssembliesPath; - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Unity/ObfuscationBeginEventArgs.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Unity/ObfuscationBeginEventArgs.cs.meta deleted file mode 100644 index a2d5e11..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Unity/ObfuscationBeginEventArgs.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 8e3d38018839d4844bf1e15631946e65 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Unity/ObfuscationEndEventArgs.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Unity/ObfuscationEndEventArgs.cs deleted file mode 100644 index ac2fa76..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Unity/ObfuscationEndEventArgs.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Obfuz.Unity -{ - public class ObfuscationEndEventArgs - { - public bool success; - public string originalScriptAssembliesPath; - public string obfuscatedScriptAssembliesPath; - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Unity/ObfuscationEndEventArgs.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Unity/ObfuscationEndEventArgs.cs.meta deleted file mode 100644 index fe37681..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Unity/ObfuscationEndEventArgs.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 6b198ad99d0a9c145b1bc2b29b25b8ac -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Unity/ObfuscationProcess.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Unity/ObfuscationProcess.cs deleted file mode 100644 index 4770a57..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Unity/ObfuscationProcess.cs +++ /dev/null @@ -1,124 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using UnityEditor.Build; -using UnityEditor; -using UnityEditor.Build.Reporting; -using UnityEngine; -using UnityEditor.Compilation; -using Obfuz.Utils; -using FileUtil = Obfuz.Utils.FileUtil; -using Obfuz.Settings; - -namespace Obfuz.Unity -{ - -#if UNITY_2019_1_OR_NEWER - public class ObfuscationProcess : IPostBuildPlayerScriptDLLs - { - public int callbackOrder => 10000; - - public static event Action OnObfuscationBegin; - - public static event Action OnObfuscationEnd; - - public void OnPostBuildPlayerScriptDLLs(BuildReport report) - { -#if !UNITY_2022_1_OR_NEWER - RunObfuscate(report.files); -#else - RunObfuscate(report.GetFiles()); -#endif - } - - private static void BackupOriginalDlls(string srcDir, string dstDir, HashSet dllNames) - { - FileUtil.RecreateDir(dstDir); - foreach (string dllName in dllNames) - { - string srcFile = Path.Combine(srcDir, dllName + ".dll"); - string dstFile = Path.Combine(dstDir, dllName + ".dll"); - if (File.Exists(srcFile)) - { - File.Copy(srcFile, dstFile, true); - Debug.Log($"BackupOriginalDll {srcFile} -> {dstFile}"); - } - } - } - - private static void RunObfuscate(BuildFile[] files) - { - ObfuzSettings settings = ObfuzSettings.Instance; - if (!settings.enable) - { - Debug.Log("Obfuscation is disabled."); - return; - } - - Debug.Log("Obfuscation begin..."); - var buildTarget = EditorUserBuildSettings.activeBuildTarget; - - var obfuscationRelativeAssemblyNames = new HashSet(settings.assemblySettings.GetObfuscationRelativeAssemblyNames()); - string stagingAreaTempManagedDllDir = Path.GetDirectoryName(files.First(file => file.path.EndsWith(".dll")).path); - string backupPlayerScriptAssembliesPath = settings.GetOriginalAssemblyBackupDir(buildTarget); - BackupOriginalDlls(stagingAreaTempManagedDllDir, backupPlayerScriptAssembliesPath, obfuscationRelativeAssemblyNames); - - string applicationContentsPath = EditorApplication.applicationContentsPath; - - var obfuscatorBuilder = ObfuscatorBuilder.FromObfuzSettings(settings, buildTarget, false); - - var assemblySearchDirs = new List - { - stagingAreaTempManagedDllDir, - }; - obfuscatorBuilder.InsertTopPriorityAssemblySearchPaths(assemblySearchDirs); - - - OnObfuscationBegin?.Invoke(new ObfuscationBeginEventArgs - { - scriptAssembliesPath = stagingAreaTempManagedDllDir, - obfuscatedScriptAssembliesPath = obfuscatorBuilder.ObfuscatedAssemblyOutputPath, - }); - bool succ = false; - - try - { - Obfuscator obfuz = obfuscatorBuilder.Build(); - obfuz.Run(); - - foreach (var dllName in obfuscationRelativeAssemblyNames) - { - string src = $"{obfuscatorBuilder.ObfuscatedAssemblyOutputPath}/{dllName}.dll"; - string dst = $"{stagingAreaTempManagedDllDir}/{dllName}.dll"; - - if (!File.Exists(src)) - { - Debug.LogWarning($"obfuscation assembly not found! skip copy. path:{src}"); - continue; - } - File.Copy(src, dst, true); - Debug.Log($"obfuscate dll:{dst}"); - } - succ = true; - } - catch (Exception e) - { - succ = false; - Debug.LogException(e); - Debug.LogError($"Obfuscation failed."); - } - OnObfuscationEnd?.Invoke(new ObfuscationEndEventArgs - { - success = succ, - originalScriptAssembliesPath = backupPlayerScriptAssembliesPath, - obfuscatedScriptAssembliesPath = stagingAreaTempManagedDllDir, - }); - - Debug.Log("Obfuscation end."); - } - } -#endif - } diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Unity/ObfuscationProcess.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Unity/ObfuscationProcess.cs.meta deleted file mode 100644 index de6b391..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Unity/ObfuscationProcess.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: fc7a8b1e20c66164699de44d0a302cb7 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Unity/ObfuzMenu.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Unity/ObfuzMenu.cs deleted file mode 100644 index d0162c3..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Unity/ObfuzMenu.cs +++ /dev/null @@ -1,64 +0,0 @@ -using Obfuz.EncryptionVM; -using Obfuz.Settings; -using Obfuz.Utils; -using System.IO; -using UnityEditor; -using UnityEngine; -using FileUtil = Obfuz.Utils.FileUtil; - -namespace Obfuz.Unity -{ - public static class ObfuzMenu - { - - [MenuItem("Obfuz/Settings...", priority = 1)] - public static void OpenSettings() => SettingsService.OpenProjectSettings("Project/Obfuz"); - - [MenuItem("Obfuz/GenerateEncryptionVM", priority = 62)] - public static void GenerateEncryptionVM() - { - EncryptionVMSettings settings = ObfuzSettings.Instance.encryptionVMSettings; - var generator = new VirtualMachineCodeGenerator(settings.codeGenerationSecretKey, settings.encryptionOpCodeCount); - generator.Generate(settings.codeOutputPath); - } - - [MenuItem("Obfuz/GenerateSecretKeyFile", priority = 63)] - public static void SaveSecretFile() - { - SecretSettings settings = ObfuzSettings.Instance.secretSettings; - - var staticSecretBytes = KeyGenerator.GenerateKey(settings.defaultStaticSecretKey, VirtualMachine.SecretKeyLength); - SaveKey(staticSecretBytes, settings.DefaultStaticSecretKeyOutputPath); - Debug.Log($"Save static secret key to {settings.DefaultStaticSecretKeyOutputPath}"); - var dynamicSecretBytes = KeyGenerator.GenerateKey(settings.defaultDynamicSecretKey, VirtualMachine.SecretKeyLength); - SaveKey(dynamicSecretBytes, settings.DefaultDynamicSecretKeyOutputPath); - Debug.Log($"Save dynamic secret key to {settings.DefaultDynamicSecretKeyOutputPath}"); - AssetDatabase.Refresh(); - } - - private static void SaveKey(byte[] secret, string secretOutputPath) - { - FileUtil.CreateParentDir(secretOutputPath); - File.WriteAllBytes(secretOutputPath, secret); - } - - [MenuItem("Obfuz/Documents/Quick Start")] - public static void OpenQuickStart() => Application.OpenURL("https://obfuz.doc.code-philosophy.com/docs/beginner/quickstart"); - - [MenuItem("Obfuz/Documents/FAQ")] - public static void OpenFAQ() => Application.OpenURL("https://obfuz.doc.code-philosophy.com/docs/help/faq"); - - [MenuItem("Obfuz/Documents/Common Errors")] - public static void OpenCommonErrors() => Application.OpenURL("https://obfuz.doc.code-philosophy.com/docs/help/commonerrors"); - - [MenuItem("Obfuz/Documents/Bug Report")] - public static void OpenBugReport() => Application.OpenURL("https://obfuz.doc.code-philosophy.com/docs/help/issue"); - - [MenuItem("Obfuz/Documents/GitHub")] - public static void OpenGitHub() => Application.OpenURL("https://github.com/focus-creative-games/obfuz"); - - [MenuItem("Obfuz/Documents/About")] - public static void OpenAbout() => Application.OpenURL("https://obfuz.doc.code-philosophy.com/docs/intro"); - } - -} \ No newline at end of file diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Unity/ObfuzMenu.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Unity/ObfuzMenu.cs.meta deleted file mode 100644 index ae1f6f8..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Unity/ObfuzMenu.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ce8d804a6c4640e45a3d5c98b30c0c31 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils.meta deleted file mode 100644 index 8a3e253..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: ade28aaad1116b143a4027071e71010f -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/AssemblyCache.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/AssemblyCache.cs deleted file mode 100644 index ecaa587..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/AssemblyCache.cs +++ /dev/null @@ -1,91 +0,0 @@ -using dnlib.DotNet; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Obfuz.Utils -{ - public class AssemblyCache - { - private readonly IAssemblyResolver _assemblyPathResolver; - private readonly ModuleContext _modCtx; - private readonly AssemblyResolver _asmResolver; - private bool _enableTypeDefCache; - - - public ModuleContext ModCtx => _modCtx; - - public Dictionary LoadedModules { get; } = new Dictionary(); - - public AssemblyCache(IAssemblyResolver assemblyResolver) - { - _enableTypeDefCache = true; - _assemblyPathResolver = assemblyResolver; - _modCtx = ModuleDef.CreateModuleContext(); - _asmResolver = (AssemblyResolver)_modCtx.AssemblyResolver; - _asmResolver.EnableTypeDefCache = _enableTypeDefCache; - _asmResolver.UseGAC = false; - } - - public bool EnableTypeDefCache - { - get => _enableTypeDefCache; - set - { - _enableTypeDefCache = value; - _asmResolver.EnableTypeDefCache = value; - foreach (var mod in LoadedModules.Values) - { - mod.EnableTypeDefFindCache = value; - } - } - } - - - public ModuleDefMD TryLoadModule(string moduleName) - { - string dllPath = _assemblyPathResolver.ResolveAssembly(moduleName); - if (string.IsNullOrEmpty(dllPath)) - { - return null; - } - return LoadModule(moduleName); - } - - public ModuleDefMD LoadModule(string moduleName) - { - // Debug.Log($"load module:{moduleName}"); - if (LoadedModules.TryGetValue(moduleName, out var mod)) - { - return mod; - } - string assemblyPath = _assemblyPathResolver.ResolveAssembly(moduleName); - if (string.IsNullOrEmpty(assemblyPath)) - { - throw new FileNotFoundException($"Assembly {moduleName} not found"); - } - mod = DoLoadModule(assemblyPath); - LoadedModules.Add(moduleName, mod); - - - foreach (var refAsm in mod.GetAssemblyRefs()) - { - LoadModule(refAsm.Name); - } - - return mod; - } - - private ModuleDefMD DoLoadModule(string dllPath) - { - //Debug.Log($"do load module:{dllPath}"); - ModuleDefMD mod = ModuleDefMD.Load(File.ReadAllBytes(dllPath), _modCtx); - mod.EnableTypeDefFindCache = _enableTypeDefCache; - _asmResolver.AddToCache(mod); - return mod; - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/AssemblyCache.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/AssemblyCache.cs.meta deleted file mode 100644 index bb92229..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/AssemblyCache.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ce64ad992f9807d4994d4f41a54b170b -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/AssemblyResolverBase.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/AssemblyResolverBase.cs deleted file mode 100644 index 7eb9491..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/AssemblyResolverBase.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Obfuz.Utils -{ - public abstract class AssemblyResolverBase : IAssemblyResolver - { - public abstract string ResolveAssembly(string assemblyName); - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/AssemblyResolverBase.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/AssemblyResolverBase.cs.meta deleted file mode 100644 index 4a7f4a0..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/AssemblyResolverBase.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c7332848ca18498459e6248d06bc5b31 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/CollectionExtensions.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/CollectionExtensions.cs deleted file mode 100644 index f7165ab..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/CollectionExtensions.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Obfuz.Utils -{ - public static class CollectionExtensions - { - public static void AddRange(this HashSet values, IEnumerable newValues) - { - foreach (var value in newValues) - { - values.Add(value); - } - } - - public static V GetValueOrDefault(this Dictionary dic, K key) - { - return dic.TryGetValue(key, out V v) ? v : default(V); - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/CollectionExtensions.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/CollectionExtensions.cs.meta deleted file mode 100644 index ba4aa2a..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/CollectionExtensions.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 58fc4438f86bc174aba662f1d7058f45 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/ConfigUtil.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/ConfigUtil.cs deleted file mode 100644 index 3dc39fe..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/ConfigUtil.cs +++ /dev/null @@ -1,76 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Obfuz.Utils -{ - public static class ConfigUtil - { - - public static bool ParseBool(string str) - { - switch (str.ToLowerInvariant()) - { - case "1": - case "true": return true; - case "0": - case "false": return false; - default: throw new Exception($"Invalid bool value {str}"); - } - } - - public static bool? ParseNullableBool(string str) - { - if (string.IsNullOrEmpty(str)) - { - return null; - } - switch (str.ToLowerInvariant()) - { - case "1": - case "true": return true; - case "0": - case "false": return false; - default: throw new Exception($"Invalid bool value {str}"); - } - } - - public static int? ParseNullableInt(string str) - { - if (string.IsNullOrEmpty(str)) - { - return null; - } - return int.Parse(str); - } - - public static long? ParseNullableLong(string str) - { - if (string.IsNullOrEmpty(str)) - { - return null; - } - return long.Parse(str); - } - - public static float? ParseNullableFloat(string str) - { - if (string.IsNullOrEmpty(str)) - { - return null; - } - return float.Parse(str); - } - - public static double? ParseNullableDouble(string str) - { - if (string.IsNullOrEmpty(str)) - { - return null; - } - return double.Parse(str); - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/ConfigUtil.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/ConfigUtil.cs.meta deleted file mode 100644 index bba160a..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/ConfigUtil.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ff35a8e07f37adf4483eaf5cc5da5c78 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/EncryptionUtil.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/EncryptionUtil.cs deleted file mode 100644 index 5785800..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/EncryptionUtil.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using UnityEngine; - -namespace Obfuz.Utils -{ - public static class EncryptionUtil - { - public static int GetBitCount(int value) - { - int count = 0; - while (value > 0) - { - count++; - value >>= 1; - } - return count; - } - - public static int GenerateEncryptionOpCodes(IRandom random, IEncryptor encryptor, int encryptionLevel) - { - if (encryptionLevel <= 0 || encryptionLevel > 4) - { - throw new ArgumentException($"Invalid encryption level: {encryptionLevel}, should be in range [1,4]"); - } - int vmOpCodeCount = encryptor.OpCodeCount; - long ops = 0; - for (int i = 0; i < encryptionLevel; i++) - { - long newOps = ops * vmOpCodeCount; - // don't use 0 - int op = random.NextInt(1, vmOpCodeCount); - newOps |= (uint)op; - if (newOps > uint.MaxValue) - { - Debug.LogWarning($"OpCode overflow. encryptionLevel:{encryptionLevel}, vmOpCodeCount:{vmOpCodeCount}"); - } - else - { - ops = newOps; - } - } - return (int)ops; - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/EncryptionUtil.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/EncryptionUtil.cs.meta deleted file mode 100644 index 5c82b2b..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/EncryptionUtil.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 0b8fc4c92fa6f0b40a9734b347cd265c -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/FileUtil.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/FileUtil.cs deleted file mode 100644 index ccd210d..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/FileUtil.cs +++ /dev/null @@ -1,100 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; - -namespace Obfuz.Utils -{ - public static class FileUtil - { - public static void CreateParentDir(string path) - { - Directory.CreateDirectory(Path.GetDirectoryName(path)); - } - - public static void RemoveDir(string dir, bool log = false) - { - if (log) - { - UnityEngine.Debug.Log($"removeDir dir:{dir}"); - } - - int maxTryCount = 5; - for (int i = 0; i < maxTryCount; ++i) - { - try - { - if (!Directory.Exists(dir)) - { - return; - } - foreach (var file in Directory.GetFiles(dir)) - { - File.SetAttributes(file, FileAttributes.Normal); - File.Delete(file); - } - foreach (var subDir in Directory.GetDirectories(dir)) - { - RemoveDir(subDir); - } - Directory.Delete(dir, true); - break; - } - catch (Exception e) - { - UnityEngine.Debug.LogError($"removeDir:{dir} with exception:{e}. try count:{i}"); - Thread.Sleep(100); - } - } - } - - public static void RecreateDir(string dir) - { - if (Directory.Exists(dir)) - { - RemoveDir(dir, true); - } - Directory.CreateDirectory(dir); - } - - private static void CopyWithCheckLongFile(string srcFile, string dstFile) - { - var maxPathLength = 255; -#if UNITY_EDITOR_OSX - maxPathLength = 1024; -#endif - if (srcFile.Length > maxPathLength) - { - UnityEngine.Debug.LogError($"srcFile:{srcFile} path is too long. skip copy!"); - return; - } - if (dstFile.Length > maxPathLength) - { - UnityEngine.Debug.LogError($"dstFile:{dstFile} path is too long. skip copy!"); - return; - } - File.Copy(srcFile, dstFile); - } - - public static void CopyDir(string src, string dst, bool log = false) - { - if (log) - { - UnityEngine.Debug.Log($"copyDir {src} => {dst}"); - } - RemoveDir(dst); - Directory.CreateDirectory(dst); - foreach (var file in Directory.GetFiles(src)) - { - CopyWithCheckLongFile(file, $"{dst}/{Path.GetFileName(file)}"); - } - foreach (var subDir in Directory.GetDirectories(src)) - { - CopyDir(subDir, $"{dst}/{Path.GetFileName(subDir)}"); - } - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/FileUtil.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/FileUtil.cs.meta deleted file mode 100644 index c8523ce..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/FileUtil.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: b6385af8bd061b142a3d7dcf41ab7e79 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/GenericArgumentContext.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/GenericArgumentContext.cs deleted file mode 100644 index a9f89be..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/GenericArgumentContext.cs +++ /dev/null @@ -1,126 +0,0 @@ -using dnlib.DotNet; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Obfuz.Utils -{ - /// - /// Replaces generic type/method var with its generic argument - /// - public sealed class GenericArgumentContext - { - List typeArgsStack; - List methodArgsStack; - - public GenericArgumentContext(IList typeArgsStack, IList methodArgsStack) - { - this.typeArgsStack = typeArgsStack?.ToList(); - this.methodArgsStack = methodArgsStack?.ToList(); - } - - - - /// - /// Replaces a generic type/method var with its generic argument (if any). If - /// isn't a generic type/method var or if it can't - /// be resolved, it itself is returned. Else the resolved type is returned. - /// - /// Type signature - /// New which is never null unless - /// is null - public TypeSig Resolve(TypeSig typeSig) - { - if (!typeSig.ContainsGenericParameter) - { - return typeSig; - } - typeSig = typeSig.RemovePinnedAndModifiers(); - switch (typeSig.ElementType) - { - case ElementType.Ptr: return new PtrSig(Resolve(typeSig.Next)); - case ElementType.ByRef: return new PtrSig(Resolve(typeSig.Next)); - - case ElementType.SZArray: return new PtrSig(Resolve(typeSig.Next)); - case ElementType.Array: - { - var ara = (ArraySig)typeSig; - return new ArraySig(Resolve(typeSig.Next), ara.Rank, ara.Sizes, ara.LowerBounds); - } - - case ElementType.Var: - { - GenericVar genericVar = (GenericVar)typeSig; - var newSig = Resolve(typeArgsStack, genericVar.Number, true); - if (newSig == null) - { - throw new Exception(); - } - return newSig; - } - - case ElementType.MVar: - { - GenericMVar genericVar = (GenericMVar)typeSig; - var newSig = Resolve(methodArgsStack, genericVar.Number, true); - if (newSig == null) - { - throw new Exception(); - } - return newSig; - } - case ElementType.GenericInst: - { - var gia = (GenericInstSig)typeSig; - return new GenericInstSig(gia.GenericType, gia.GenericArguments.Select(ga => Resolve(ga)).ToList()); - } - - case ElementType.FnPtr: - { - var fptr = (FnPtrSig)typeSig; - var cs = fptr.Signature; - CallingConventionSig ccs; - switch (cs) - { - case MethodSig ms: - { - ccs = new MethodSig(ms.GetCallingConvention(), ms.GenParamCount, Resolve(ms.RetType), ms.Params.Select(p => Resolve(p)).ToList()); - break; - } - case PropertySig ps: - { - ccs = new PropertySig(ps.HasThis, Resolve(ps.RetType)); - break; - } - case GenericInstMethodSig gims: - { - ccs = new GenericInstMethodSig(gims.GenericArguments.Select(ga => Resolve(ga)).ToArray()); - break; - } - default: throw new NotSupportedException(cs.ToString()); - } - return new FnPtrSig(ccs); - } - - case ElementType.ValueArray: - { - var vas = (ValueArraySig)typeSig; - return new ValueArraySig(Resolve(vas.Next), vas.Size); - } - default: return typeSig; - } - } - - private TypeSig Resolve(List args, uint number, bool isTypeVar) - { - var typeSig = args[(int)number]; - var gvar = typeSig as GenericSig; - if (gvar is null || gvar.IsTypeVar != isTypeVar) - return typeSig; - return gvar; - } - } - -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/GenericArgumentContext.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/GenericArgumentContext.cs.meta deleted file mode 100644 index fd13834..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/GenericArgumentContext.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: cdefb4e144f6a98418c7bd02eab51039 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/HashUtil.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/HashUtil.cs deleted file mode 100644 index 5b0d823..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/HashUtil.cs +++ /dev/null @@ -1,67 +0,0 @@ -using dnlib.DotNet; -using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using UnityEngine.UIElements; - -namespace Obfuz.Utils -{ - public static class HashUtil - { - public static int CombineHash(int hash1, int hash2) - { - return hash1 * 1566083941 + hash2; - } - - public static int ComputeHash(List sigs) - { - int hash = 135781321; - TypeEqualityComparer tc = TypeEqualityComparer.Instance; - foreach (var sig in sigs) - { - hash = hash * 1566083941 + tc.GetHashCode(sig); - } - return hash; - } - - public static unsafe int ComputeHash(string s) - { - fixed (char* ptr = s) - { - int num = 352654597; - int num2 = num; - int* ptr2 = (int*)ptr; - int num3; - for (num3 = s.Length; num3 > 2; num3 -= 4) - { - num = ((num << 5) + num + (num >> 27)) ^ *ptr2; - num2 = ((num2 << 5) + num2 + (num2 >> 27)) ^ ptr2[1]; - ptr2 += 2; - } - - if (num3 > 0) - { - num = ((num << 5) + num + (num >> 27)) ^ *ptr2; - } - - return num + num2 * 1566083941; - } - } - - public static int ComputePrimitiveOrStringOrBytesHashCode(object obj) - { - if (obj is byte[] bytes) - { - return StructuralComparisons.StructuralEqualityComparer.GetHashCode(bytes); - } - if (obj is string s) - { - return HashUtil.ComputeHash(s); - } - return obj.GetHashCode(); - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/HashUtil.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/HashUtil.cs.meta deleted file mode 100644 index d89f8f0..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/HashUtil.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 0b4cd05dd413bfa4ebb9fcbe591b1486 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/IAssemblyResolver.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/IAssemblyResolver.cs deleted file mode 100644 index 4a7578a..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/IAssemblyResolver.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Obfuz.Utils -{ - public interface IAssemblyResolver - { - string ResolveAssembly(string assemblyName); - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/IAssemblyResolver.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/IAssemblyResolver.cs.meta deleted file mode 100644 index 917a107..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/IAssemblyResolver.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: e0254d9726a78e146af99a61641b47d3 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/IRandom.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/IRandom.cs deleted file mode 100644 index e3a68b8..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/IRandom.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace Obfuz.Utils -{ - public interface IRandom - { - int NextInt(int min, int max); - - int NextInt(int max); - - int NextInt(); - - long NextLong(); - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/IRandom.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/IRandom.cs.meta deleted file mode 100644 index 086b073..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/IRandom.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 959c821ff51056c4ebca3f89aeeff03d -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/KeyGenerator.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/KeyGenerator.cs deleted file mode 100644 index 31aa40c..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/KeyGenerator.cs +++ /dev/null @@ -1,41 +0,0 @@ -using NUnit.Framework; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; - -namespace Obfuz.Utils -{ - public static class KeyGenerator - { - public static byte[] GenerateKey(string initialString, int keyLength) - { - byte[] initialBytes = Encoding.UTF8.GetBytes(initialString); - using (var sha512 = SHA512.Create()) - { - byte[] hash = sha512.ComputeHash(initialBytes); - byte[] key = new byte[keyLength]; - int bytesCopied = 0; - while (bytesCopied < key.Length) - { - if (bytesCopied > 0) - { - // 再次哈希之前的哈希值以生成更多数据 - hash = sha512.ComputeHash(hash); - } - int bytesToCopy = Math.Min(hash.Length, key.Length - bytesCopied); - Buffer.BlockCopy(hash, 0, key, bytesCopied, bytesToCopy); - bytesCopied += bytesToCopy; - } - return key; - } - } - - public static int[] ConvertToIntKey(byte[] key) - { - return EncryptorBase.ConvertToIntKey(key); - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/KeyGenerator.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/KeyGenerator.cs.meta deleted file mode 100644 index 7d11ff0..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/KeyGenerator.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 5441ac16fd88a8848af862be23bd2ecb -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/MetaUtil.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/MetaUtil.cs deleted file mode 100644 index 711e957..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/MetaUtil.cs +++ /dev/null @@ -1,813 +0,0 @@ -using dnlib.DotNet; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; -using UnityEngine.Assertions; -using UnityEngine.UIElements; - -namespace Obfuz.Utils -{ - - public static class MetaUtil - { - public static string GetModuleNameWithoutExt(string moduleName) - { - return Path.GetFileNameWithoutExtension(moduleName); - } - - public static (string, string) SplitNamespaceAndName(string fullName) - { - int index = fullName.LastIndexOf('/'); - if (index == -1) - { - int index2 = fullName.IndexOf('.'); - return index2 >= 0 ? (fullName.Substring(0, index2), fullName.Substring(index2 + 1)) : ("", fullName); - } - return ("", fullName.Substring(index + 1)); - } - - - public static TypeDef GetBaseTypeDef(TypeDef type) - { - ITypeDefOrRef baseType = type.BaseType; - if (baseType == null) - { - return null; - } - TypeDef baseTypeDef = baseType.ResolveTypeDef(); - if (baseTypeDef != null) - { - return baseTypeDef; - } - if (baseType is TypeSpec baseTypeSpec) - { - GenericInstSig genericIns = baseTypeSpec.TypeSig.ToGenericInstSig(); - return genericIns.GenericType.TypeDefOrRef.ResolveTypeDefThrow(); - } - else - { - throw new Exception($"GetBaseTypeDef: {type} fail"); - } - } - - public static TypeDef GetTypeDefOrGenericTypeBaseThrowException(ITypeDefOrRef type) - { - if (type.IsTypeDef) - { - return (TypeDef)type; - } - if (type.IsTypeRef) - { - return type.ResolveTypeDefThrow(); - } - if (type.IsTypeSpec) - { - GenericInstSig gis = type.TryGetGenericInstSig(); - return gis.GenericType.ToTypeDefOrRef().ResolveTypeDefThrow(); - } - throw new NotSupportedException($"{type}"); - } - - public static TypeDef GetTypeDefOrGenericTypeBaseOrNull(ITypeDefOrRef type) - { - if (type.IsTypeDef) - { - return (TypeDef)type; - } - if (type.IsTypeRef) - { - return type.ResolveTypeDefThrow(); - } - if (type.IsTypeSpec) - { - GenericInstSig gis = type.TryGetGenericInstSig(); - return gis.GenericType.ToTypeDefOrRef().ResolveTypeDefThrow(); - } - return null; - } - - public static TypeDef GetMemberRefTypeDefParentOrNull(IMemberRefParent parent) - { - if (parent is TypeDef typeDef) - { - return typeDef; - } - if (parent is TypeRef typeRef) - { - return typeRef.ResolveTypeDefThrow(); - } - if (parent is TypeSpec typeSpec) - { - GenericInstSig genericIns = typeSpec.TypeSig.ToGenericInstSig(); - return genericIns.GenericType.TypeDefOrRef.ResolveTypeDefThrow(); - } - return null; - } - - public static bool IsInheritFromUnityObject(TypeDef typeDef) - { - TypeDef cur = typeDef; - while (true) - { - cur = GetBaseTypeDef(cur); - if (cur == null) - { - return false; - } - if (cur.Name == "Object" && cur.Namespace == "UnityEngine" && cur.Module.Name == "UnityEngine.CoreModule.dll") - { - return true; - } - } - } - - - - public static bool IsScriptOrSerializableType(TypeDef type) - { - if (type.ContainsGenericParameter) - { - return false; - } - if (type.IsSerializable) - { - return true; - } - - for (TypeDef parentType = GetBaseTypeDef(type); parentType != null; parentType = GetBaseTypeDef(parentType)) - { - if ((parentType.Name == "MonoBehaviour" || parentType.Name == "ScriptableObject") - && parentType.Namespace == "UnityEngine" - && parentType.Module.Assembly.Name == "UnityEngine.CoreModule") - { - return true; - } - } - - return false; - } - - public static bool IsSerializableTypeSig(TypeSig typeSig) - { - typeSig = typeSig.RemovePinnedAndModifiers(); - switch (typeSig.ElementType) - { - case ElementType.Boolean: - case ElementType.Char: - case ElementType.I1: - case ElementType.U1: - case ElementType.I2: - case ElementType.U2: - case ElementType.I4: - case ElementType.U4: - case ElementType.I8: - case ElementType.U8: - case ElementType.R4: - case ElementType.R8: - case ElementType.String: - return true; - case ElementType.Class: - return IsScriptOrSerializableType(typeSig.ToTypeDefOrRef().ResolveTypeDefThrow()); - case ElementType.ValueType: - { - TypeDef typeDef = typeSig.ToTypeDefOrRef().ResolveTypeDefThrow(); - if (typeDef.IsEnum) - { - return true; - } - return typeDef.IsSerializable; - } - case ElementType.GenericInst: - { - GenericInstSig genericIns = typeSig.ToGenericInstSig(); - TypeDef typeDef = genericIns.GenericType.ToTypeDefOrRef().ResolveTypeDefThrow(); - return typeDef.FullName == "System.Collections.Generic.List`1" && IsSerializableTypeSig(genericIns.GenericArguments[0]); - } - case ElementType.SZArray: - { - return IsSerializableTypeSig(typeSig.RemovePinnedAndModifiers().Next); - } - default: - return false; - } - } - - public static bool IsSerializableField(FieldDef field) - { - if (field.IsStatic) - { - return false; - } - var fieldSig = field.FieldSig.Type; - if (field.IsPublic) - { - return IsSerializableTypeSig(fieldSig); - } - if (field.CustomAttributes.Any(c => c.TypeFullName == "UnityEngine.SerializeField")) - { - //UnityEngine.Debug.Assert(IsSerializableTypeSig(fieldSig)); - return true; - } - return false; - } - - public static bool MayRenameCustomDataType(ElementType type) - { - return type == ElementType.Class || type == ElementType.ValueType || type == ElementType.Object || type == ElementType.SZArray; - } - - public static TypeSig RetargetTypeRefInTypeSig(TypeSig type) - { - TypeSig next = type.Next; - TypeSig newNext = next != null ? RetargetTypeRefInTypeSig(next) : null; - if (type.IsModifier || type.IsPinned) - { - if (next == newNext) - { - return type; - } - if (type is CModReqdSig cmrs) - { - return new CModReqdSig(cmrs.Modifier, newNext); - } - if (type is CModOptSig cmos) - { - return new CModOptSig(cmos.Modifier, newNext); - } - if (type is PinnedSig ps) - { - return new PinnedSig(newNext); - } - throw new System.NotSupportedException(type.ToString()); - } - switch (type.ElementType) - { - case ElementType.Ptr: - { - if (next == newNext) - { - return type; - } - return new PtrSig(newNext); - } - case ElementType.ValueType: - case ElementType.Class: - { - var vts = type as ClassOrValueTypeSig; - TypeDef typeDef = vts.TypeDefOrRef.ResolveTypeDefThrow(); - if (typeDef == vts.TypeDefOrRef) - { - return type; - } - return type.IsClassSig ? (TypeSig)new ClassSig(typeDef) : new ValueTypeSig(typeDef); - } - case ElementType.Array: - { - if (next == newNext) - { - return type; - } - return new ArraySig(newNext); - } - case ElementType.SZArray: - { - if (next == newNext) - { - return type; - } - return new SZArraySig(newNext); - } - case ElementType.GenericInst: - { - var gis = type as GenericInstSig; - ClassOrValueTypeSig genericType = gis.GenericType; - ClassOrValueTypeSig newGenericType = (ClassOrValueTypeSig)RetargetTypeRefInTypeSig(genericType); - bool anyChange = genericType != newGenericType; - var genericArgs = new List(); - foreach (var arg in gis.GenericArguments) - { - TypeSig newArg = RetargetTypeRefInTypeSig(arg); - anyChange |= newArg != genericType; - genericArgs.Add(newArg); - } - if (!anyChange) - { - return type; - } - return new GenericInstSig(newGenericType, genericArgs); - } - case ElementType.FnPtr: - { - var fp = type as FnPtrSig; - MethodSig methodSig = fp.MethodSig; - TypeSig newReturnType = RetargetTypeRefInTypeSig(methodSig.RetType); - bool anyChange = newReturnType != methodSig.RetType; - var newArgs = new List(); - foreach (TypeSig arg in methodSig.Params) - { - TypeSig newArg = RetargetTypeRefInTypeSig(arg); - anyChange |= newArg != newReturnType; - } - if (!anyChange) - { - return type; - } - var newParamsAfterSentinel = new List(); - foreach (TypeSig arg in methodSig.ParamsAfterSentinel) - { - TypeSig newArg = RetargetTypeRefInTypeSig(arg); - anyChange |= newArg != arg; - newParamsAfterSentinel.Add(newArg); - } - - var newMethodSig = new MethodSig(methodSig.CallingConvention, methodSig.GenParamCount, newReturnType, newArgs, newParamsAfterSentinel); - return new FnPtrSig(newMethodSig); - } - case ElementType.ByRef: - { - if (next == newNext) - { - return type; - } - return new ByRefSig(newNext); - } - default: - { - return type; - } - } - } - - - public static object RetargetTypeRefInTypeSigOfValue(object oldValue) - { - if (oldValue == null) - { - return null; - } - string typeName = oldValue.GetType().FullName; - if (oldValue.GetType().IsPrimitive) - { - return oldValue; - } - if (oldValue is string || oldValue is UTF8String) - { - return oldValue; - } - if (oldValue is TypeSig typeSig) - { - return RetargetTypeRefInTypeSig(typeSig); - } - if (oldValue is CAArgument caValue) - { - TypeSig newType = RetargetTypeRefInTypeSig(caValue.Type); - object newValue = RetargetTypeRefInTypeSigOfValue(caValue.Value); - if (newType != caValue.Type || newValue != caValue.Value) - { - return new CAArgument(newType, newValue); - } - return oldValue; - } - if (oldValue is List oldArr) - { - bool anyChange = false; - var newArr = new List(); - foreach (CAArgument oldArg in oldArr) - { - if (TryRetargetTypeRefInArgument(oldArg, out var newArg)) - { - anyChange = true; - newArr.Add(newArg); - } - else - { - newArr.Add(oldArg); - } - } - return anyChange ? newArr : oldArr; - } - throw new NotSupportedException($"type:{oldValue.GetType()} value:{oldValue}"); - } - - - - public static bool TryRetargetTypeRefInArgument(CAArgument oldArg, out CAArgument newArg) - { - TypeSig newType = RetargetTypeRefInTypeSig(oldArg.Type); - object newValue = RetargetTypeRefInTypeSigOfValue(oldArg.Value); - if (newType != oldArg.Type || oldArg.Value != newValue) - { - newArg = new CAArgument(newType, newValue); - return true; - } - newArg = default; - return false; - } - - public static bool TryRetargetTypeRefInNamedArgument(CANamedArgument arg) - { - bool anyChange = false; - TypeSig newType = RetargetTypeRefInTypeSig(arg.Type); - if (newType != arg.Type) - { - anyChange = true; - arg.Type = newType; - } - if (TryRetargetTypeRefInArgument(arg.Argument, out var newArg)) - { - arg.Argument = newArg; - anyChange = true; - } - return anyChange; - } - - //public static bool ContainsContainsGenericParameter1(MethodDef method) - //{ - // Assert.IsTrue(!(method.DeclaringType.ContainsGenericParameter || method.MethodSig.ContainsGenericParameter)); - // return false; - //} - - public static bool ContainsContainsGenericParameter1(MethodSpec methodSpec) - { - if (methodSpec.GenericInstMethodSig.ContainsGenericParameter) - { - return true; - } - IMethodDefOrRef method = methodSpec.Method; - if (method.IsMethodDef) - { - return false;// ContainsContainsGenericParameter1((MethodDef)method); - } - if (method.IsMemberRef) - { - return ContainsContainsGenericParameter1((MemberRef)method); - } - throw new Exception($"unknown method: {method}"); - } - - public static bool ContainsContainsGenericParameter1(MemberRef memberRef) - { - IMemberRefParent parent = memberRef.Class; - if (parent is TypeSpec typeSpec) - { - return typeSpec.ContainsGenericParameter; - } - return false; - } - - public static bool ContainsContainsGenericParameter(IMethod method) - { - Assert.IsTrue(method.IsMethod); - if (method is MethodDef methodDef) - { - return false; - } - - if (method is MethodSpec methodSpec) - { - return ContainsContainsGenericParameter1(methodSpec); - } - if (method is MemberRef memberRef) - { - return ContainsContainsGenericParameter1(memberRef); - } - throw new Exception($"unknown method: {method}"); - } - - - - public static TypeSig Inflate(TypeSig sig, GenericArgumentContext ctx) - { - if (!sig.ContainsGenericParameter) - { - return sig; - } - return ctx.Resolve(sig); - } - - - public static MethodSig InflateMethodSig(MethodSig methodSig, GenericArgumentContext genericArgumentContext) - { - var newReturnType = Inflate(methodSig.RetType, genericArgumentContext); - var newParams = new List(); - foreach (var param in methodSig.Params) - { - newParams.Add(Inflate(param, genericArgumentContext)); - } - var newParamsAfterSentinel = new List(); - if (methodSig.ParamsAfterSentinel != null) - { - throw new NotSupportedException($"methodSig.ParamsAfterSentinel is not supported: {methodSig}"); - //foreach (var param in methodSig.ParamsAfterSentinel) - //{ - // newParamsAfterSentinel.Add(Inflate(param, genericArgumentContext)); - //} - } - return new MethodSig(methodSig.CallingConvention, methodSig.GenParamCount, newReturnType, newParams, null); - } - - public static IList GetGenericArguments(IMemberRefParent type) - { - if (type is TypeDef typeDef) - { - return null; - } - if (type is TypeRef typeRef) - { - return null; - } - if (type is TypeSpec typeSpec) - { - GenericInstSig genericInstSig = typeSpec.TypeSig.ToGenericInstSig(); - return genericInstSig?.GenericArguments; - } - throw new NotSupportedException($"type:{type}"); - } - - public static MethodSig GetInflatedMethodSig(IMethod method) - { - if (method is MethodDef methodDef) - { - return methodDef.MethodSig; - } - if (method is MemberRef memberRef) - { - return InflateMethodSig(memberRef.MethodSig, new GenericArgumentContext(GetGenericArguments(memberRef.Class), null)); - } - if (method is MethodSpec methodSpec) - { - var genericInstMethodSig = methodSpec.GenericInstMethodSig; - if (methodSpec.Method is MethodDef methodDef2) - { - return InflateMethodSig(methodDef2.MethodSig, new GenericArgumentContext(null, genericInstMethodSig.GenericArguments)); - } - if (methodSpec.Method is MemberRef memberRef2) - { - return InflateMethodSig(memberRef2.MethodSig, new GenericArgumentContext(GetGenericArguments(memberRef2.Class), genericInstMethodSig.GenericArguments)); - } - - } - throw new NotSupportedException($" method: {method}"); - } - - public static ThisArgType GetThisArgType(IMethod method) - { - if (!method.MethodSig.HasThis) - { - return ThisArgType.None; - } - if (method is MethodDef methodDef) - { - return methodDef.DeclaringType.IsValueType ? ThisArgType.ValueType : ThisArgType.Class; - } - if (method is MemberRef memberRef) - { - TypeDef typeDef = MetaUtil.GetMemberRefTypeDefParentOrNull(memberRef.Class); - if (typeDef == null) - { - return ThisArgType.Class; - } - return typeDef.IsValueType ? ThisArgType.ValueType : ThisArgType.Class; - } - if (method is MethodSpec methodSpec) - { - return GetThisArgType(methodSpec.Method); - } - throw new NotSupportedException($" method: {method}"); - } - - public static MethodSig ToSharedMethodSig(ICorLibTypes corTypes, MethodSig methodSig) - { - var newReturnType = methodSig.RetType; - var newParams = new List(); - foreach (var param in methodSig.Params) - { - newParams.Add(ToShareTypeSig(corTypes, param)); - } - if (methodSig.ParamsAfterSentinel != null) - { - //foreach (var param in methodSig.ParamsAfterSentinel) - //{ - // newParamsAfterSentinel.Add(ToShareTypeSig(corTypes, param)); - //} - throw new NotSupportedException($"methodSig.ParamsAfterSentinel is not supported: {methodSig}"); - } - return new MethodSig(methodSig.CallingConvention, methodSig.GenParamCount, newReturnType, newParams, null); - } - - public static TypeSig ToShareTypeSig(ICorLibTypes corTypes, TypeSig typeSig) - { - var a = typeSig.RemovePinnedAndModifiers(); - switch (a.ElementType) - { - case ElementType.Void: return corTypes.Void; - case ElementType.Boolean: return corTypes.Byte; - case ElementType.Char: return corTypes.UInt16; - case ElementType.I1: return corTypes.SByte; - case ElementType.U1: return corTypes.Byte; - case ElementType.I2: return corTypes.Int16; - case ElementType.U2: return corTypes.UInt16; - case ElementType.I4: return corTypes.Int32; - case ElementType.U4: return corTypes.UInt32; - case ElementType.I8: return corTypes.Int64; - case ElementType.U8: return corTypes.UInt64; - case ElementType.R4: return corTypes.Single; - case ElementType.R8: return corTypes.Double; - case ElementType.String: return corTypes.Object; - case ElementType.TypedByRef: return corTypes.TypedReference; - case ElementType.I: return corTypes.IntPtr; - case ElementType.U: return corTypes.UIntPtr; - case ElementType.Object: return corTypes.Object; - case ElementType.Sentinel: return typeSig; - case ElementType.Ptr: return corTypes.UIntPtr; - case ElementType.ByRef: return corTypes.UIntPtr; - case ElementType.SZArray: return typeSig; - case ElementType.Array: return typeSig; - case ElementType.ValueType: - { - TypeDef typeDef = a.ToTypeDefOrRef().ResolveTypeDef(); - if (typeDef == null) - { - throw new Exception($"type:{a} definition could not be found"); - } - if (typeDef.IsEnum) - { - return ToShareTypeSig(corTypes, typeDef.GetEnumUnderlyingType()); - } - return typeSig; - } - case ElementType.Var: - case ElementType.MVar: - case ElementType.Class: return corTypes.Object; - case ElementType.GenericInst: - { - var gia = (GenericInstSig)a; - TypeDef typeDef = gia.GenericType.ToTypeDefOrRef().ResolveTypeDef(); - if (typeDef == null) - { - throw new Exception($"type:{a} definition could not be found"); - } - if (typeDef.IsEnum) - { - return ToShareTypeSig(corTypes, typeDef.GetEnumUnderlyingType()); - } - if (!typeDef.IsValueType) - { - return corTypes.Object; - } - // il2cpp will raise error when try to share generic value type - return typeSig; - //return new GenericInstSig(gia.GenericType, gia.GenericArguments.Select(ga => ToShareTypeSig(corTypes, ga)).ToList()); - } - case ElementType.FnPtr: return corTypes.UIntPtr; - case ElementType.ValueArray: return typeSig; - case ElementType.Module: return typeSig; - default: - throw new NotSupportedException(typeSig.ToString()); - } - } - - - public static void AppendIl2CppStackTraceNameOfTypeSig(StringBuilder sb, TypeSig typeSig) - { - typeSig = typeSig.RemovePinnedAndModifiers(); - - switch (typeSig.ElementType) - { - case ElementType.Void: sb.Append("Void"); break; - case ElementType.Boolean: sb.Append("Boolean"); break; - case ElementType.Char: sb.Append("Char"); break; - case ElementType.I1: sb.Append("SByte"); break; - case ElementType.U1: sb.Append("Byte"); break; - case ElementType.I2: sb.Append("Int16"); break; - case ElementType.U2: sb.Append("UInt16"); break; - case ElementType.I4: sb.Append("Int32"); break; - case ElementType.U4: sb.Append("UInt32"); break; - case ElementType.I8: sb.Append("Int64"); break; - case ElementType.U8: sb.Append("UInt64"); break; - case ElementType.R4: sb.Append("Single"); break; - case ElementType.R8: sb.Append("Double"); break; - case ElementType.String: sb.Append("String"); break; - case ElementType.Ptr: AppendIl2CppStackTraceNameOfTypeSig(sb, typeSig.Next); sb.Append("*"); break; - case ElementType.ByRef: AppendIl2CppStackTraceNameOfTypeSig(sb, typeSig.Next); sb.Append("&"); break; - case ElementType.ValueType: - case ElementType.Class: - { - var classOrValueTypeSig = (ClassOrValueTypeSig)typeSig; - TypeDef typeDef = classOrValueTypeSig.TypeDefOrRef.ResolveTypeDef(); - if (typeDef == null) - { - throw new Exception($"type:{classOrValueTypeSig} definition could not be found"); - } - sb.Append(typeDef.Name); - break; - } - case ElementType.GenericInst: - { - var genericInstSig = (GenericInstSig)typeSig; - AppendIl2CppStackTraceNameOfTypeSig(sb, genericInstSig.GenericType); - break; - } - case ElementType.Var: - case ElementType.MVar: - { - var varSig = (GenericSig)typeSig; - sb.Append(varSig.GenericParam.Name); - break; - } - case ElementType.I: sb.Append("IntPtr"); break; - case ElementType.U: sb.Append("UIntPtr"); break; - case ElementType.FnPtr: sb.Append("IntPtr"); break; - case ElementType.Object: sb.Append("Object"); break; - case ElementType.SZArray: - { - var szArraySig = (SZArraySig)typeSig; - AppendIl2CppStackTraceNameOfTypeSig(sb, szArraySig.Next); - sb.Append("[]"); - break; - } - default: - throw new NotSupportedException(typeSig.ToString()); - } - } - - public static TypeDef GetRootDeclaringType(TypeDef type) - { - TypeDef cur = type; - while (true) - { - TypeDef declaringType = cur.DeclaringType; - if (declaringType == null) - { - return cur; - } - cur = declaringType; - } - } - - public static string CreateMethodDefIl2CppStackTraceSignature(MethodDef method) - { - var result = new StringBuilder(); - TypeDef declaringType = method.DeclaringType; - - string namespaze = GetRootDeclaringType(declaringType).Namespace; - if (!string.IsNullOrEmpty(namespaze)) - { - result.Append(namespaze); - result.Append("."); - } - result.Append(declaringType.Name); - result.Append(":"); - result.Append(method.Name); - result.Append("("); - - int index = 0; - foreach (TypeSig p in method.GetParams()) - { - if (index > 0) - { - result.Append(", "); - } - AppendIl2CppStackTraceNameOfTypeSig(result, p); - ++index; - } - result.Append(")"); - return result.ToString(); - } - - public static bool HasObfuzIgnoreAttribute(IHasCustomAttribute obj) - { - return obj.CustomAttributes.Any(ca => ca.AttributeType.FullName == "Obfuz.ObfuzIgnoreAttribute"); - } - - public static bool HasCompilerGeneratedAttribute(IHasCustomAttribute obj) - { - return obj.CustomAttributes.Any(ca => ca.AttributeType.FullName == "System.Runtime.CompilerServices.CompilerGeneratedAttribute"); - } - - public static bool HasEncryptFieldAttribute(IHasCustomAttribute obj) - { - return obj.CustomAttributes.Any(ca => ca.AttributeType.FullName == "Obfuz.EncryptFieldAttribute"); - } - - public static bool HasObfuzIgnoreAttributeInSelfOrParent(TypeDef typeDef) - { - while (true) - { - if (HasObfuzIgnoreAttribute(typeDef)) - { - return true; - } - typeDef = typeDef.DeclaringType; - if (typeDef == null) - { - return false; - } - } - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/MetaUtil.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/MetaUtil.cs.meta deleted file mode 100644 index 9ebbd42..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/MetaUtil.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ded544371a7eb524caa1ccef3daebe55 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/NameMatcher.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/NameMatcher.cs deleted file mode 100644 index ea06a66..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/NameMatcher.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System.Text.RegularExpressions; - -namespace Obfuz.Utils -{ - public class NameMatcher - { - private readonly string _str; - private readonly Regex _regex; - - public string NameOrPattern => _str; - - public NameMatcher(string nameOrPattern) - { - if (string.IsNullOrEmpty(nameOrPattern)) - { - nameOrPattern = "*"; - } - _str = nameOrPattern; - _regex = nameOrPattern.Contains("*") || nameOrPattern.Contains("?") ? new Regex(WildcardToRegex(nameOrPattern)) : null; - } - - public static string WildcardToRegex(string pattern) - { - return "^" + Regex.Escape(pattern). - Replace("\\*", ".*"). - Replace("\\?", ".") + "$"; - } - - public bool IsMatch(string name) - { - if (_regex != null) - { - return _regex.IsMatch(name); - } - else - { - return _str == name; - } - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/NameMatcher.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/NameMatcher.cs.meta deleted file mode 100644 index 6abe4e1..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/NameMatcher.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c3a646fe086ecbd4a8dbf36a395ada71 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/NumberRange.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/NumberRange.cs deleted file mode 100644 index 90d55e0..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/NumberRange.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace Obfuz.Utils -{ - public class NumberRange where T : struct - { - public readonly T? min; - public readonly T? max; - - public NumberRange(T? min, T? max) - { - this.min = min; - this.max = max; - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/NumberRange.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/NumberRange.cs.meta deleted file mode 100644 index f1b17e1..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/NumberRange.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4d147a6853ce57c4d88529fb73823435 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/PathAssemblyResolver.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/PathAssemblyResolver.cs deleted file mode 100644 index 11c0f47..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/PathAssemblyResolver.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using UnityEngine; - -namespace Obfuz.Utils -{ - public class PathAssemblyResolver : AssemblyResolverBase - { - private readonly string[] _searchPaths; - - public PathAssemblyResolver(params string[] searchPaths) - { - _searchPaths = searchPaths; - } - - public override string ResolveAssembly(string assemblyName) - { - foreach(var path in _searchPaths) - { - string assPath = Path.Combine(path, assemblyName + ".dll"); - if (File.Exists(assPath)) - { - //Debug.Log($"resolve {assemblyName} at {assPath}"); - return assPath; - } - } - return null; - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/PathAssemblyResolver.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/PathAssemblyResolver.cs.meta deleted file mode 100644 index 1ae9c58..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/PathAssemblyResolver.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 5a7681737885f604e885ee39d0bedd74 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/PlatformUtil.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/PlatformUtil.cs deleted file mode 100644 index 3a38d23..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/PlatformUtil.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using UnityEditor; - -namespace Obfuz.Utils -{ - public static class PlatformUtil - { - public static bool IsMonoBackend() - { - return PlayerSettings.GetScriptingBackend(EditorUserBuildSettings.selectedBuildTargetGroup) - == ScriptingImplementation.Mono2x; - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/PlatformUtil.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/PlatformUtil.cs.meta deleted file mode 100644 index ec195e6..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/PlatformUtil.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 85d01014c084c56498d292d3b16351d2 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/RandomWithKey.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/RandomWithKey.cs deleted file mode 100644 index 27d1001..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/RandomWithKey.cs +++ /dev/null @@ -1,58 +0,0 @@ -using Obfuz.Emit; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Obfuz.Utils -{ - public class RandomWithKey : IRandom - { - private const long a = 1664525; - private const long c = 1013904223; - private const long m = 4294967296; // 2^32 - - private readonly int[] _key; - - private int _nextIndex; - - private int _seed; - - public RandomWithKey(int[] key, int seed) - { - _key = key; - _seed = seed; - } - - public int NextInt(int min, int max) - { - return min + NextInt(max - min); - } - - public int NextInt(int max) - { - return (int)((uint)NextInt() % (uint)max); - } - - private int GetNextSalt() - { - if (_nextIndex >= _key.Length) - { - _nextIndex = 0; - } - return _key[_nextIndex++]; - } - - public int NextInt() - { - _seed = (int)((a * _seed + c) % m); - return _seed ^ GetNextSalt(); - } - - public long NextLong() - { - return ((long)NextInt() << 32) | (uint)NextInt(); - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/RandomWithKey.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/RandomWithKey.cs.meta deleted file mode 100644 index 41b7f75..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/RandomWithKey.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 6e16d7eb75fe2354d96eca5bb01358a4 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/ThisArgType.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/ThisArgType.cs deleted file mode 100644 index 3f008cc..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/ThisArgType.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Obfuz.Utils -{ - public enum ThisArgType - { - None, - ValueType, - Class, - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/ThisArgType.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/ThisArgType.cs.meta deleted file mode 100644 index c73587a..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/ThisArgType.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 5d5a6303cdb66374f95187ca31b5e82f -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/TypeSigUtil.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/TypeSigUtil.cs deleted file mode 100644 index 11c722f..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/TypeSigUtil.cs +++ /dev/null @@ -1,198 +0,0 @@ -using dnlib.DotNet; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Obfuz.Utils -{ - public static class TypeSigUtil - { - public static string ComputeTypeDefSignature(TypeDef type) - { - return type.FullName; - } - - public static string ComputeMethodDefSignature(MethodDef method) - { - var result = new StringBuilder(); - ComputeTypeSigName(method.MethodSig.RetType, result); - result.Append(" "); - result.Append(method.DeclaringType.FullName); - result.Append("::"); - result.Append(method.Name); - if (method.HasGenericParameters) - { - result.Append($"`{method.GenericParameters.Count}"); - } - result.Append("("); - for (int i = 0; i < method.Parameters.Count; i++) - { - if (i > 0) - { - result.Append(", "); - } - ComputeTypeSigName(method.Parameters[i].Type, result); - } - result.Append(")"); - return result.ToString(); - } - - public static string ComputeFieldDefSignature(FieldDef field) - { - var result = new StringBuilder(); - ComputeTypeSigName(field.FieldSig.Type, result); - result.Append(" "); - result.Append(field.Name); - return result.ToString(); - } - - public static string ComputePropertyDefSignature(PropertyDef property) - { - var result = new StringBuilder(); - ComputeTypeSigName(property.PropertySig.RetType, result); - result.Append(" "); - result.Append(property.Name); - return result.ToString(); - } - - public static string ComputeEventDefSignature(EventDef eventDef) - { - var result = new StringBuilder(); - ComputeTypeSigName(eventDef.EventType.ToTypeSig(), result); - result.Append(" "); - result.Append(eventDef.Name); - return result.ToString(); - } - - public static string ComputeMethodSpecSignature(TypeSig type) - { - var sb = new StringBuilder(); - ComputeTypeSigName(type, sb); - return sb.ToString(); - } - - public static void ComputeTypeSigName(TypeSig type, StringBuilder result) - { - type = type.RemovePinnedAndModifiers(); - switch (type.ElementType) - { - case ElementType.Void: result.Append("void"); break; - case ElementType.Boolean: result.Append("bool"); break; - case ElementType.Char: result.Append("char"); break; - case ElementType.I1: result.Append("sbyte"); break; - case ElementType.U1: result.Append("byte"); break; - case ElementType.I2: result.Append("short"); break; - case ElementType.U2: result.Append("ushort"); break; - case ElementType.I4: result.Append("int"); break; - case ElementType.U4: result.Append("uint"); break; - case ElementType.I8: result.Append("long"); break; - case ElementType.U8: result.Append("ulong"); break; - case ElementType.R4: result.Append("float"); break; - case ElementType.R8: result.Append("double"); break; - case ElementType.String: result.Append("string"); break; - case ElementType.Ptr: - ComputeTypeSigName(((PtrSig)type).Next, result); - result.Append("*"); - break; - case ElementType.ByRef: - ComputeTypeSigName(((ByRefSig)type).Next, result); - result.Append("&"); - break; - case ElementType.ValueType: - case ElementType.Class: - { - var valueOrClassType = type.ToClassOrValueTypeSig(); - var typeDef = valueOrClassType.ToTypeDefOrRef().ResolveTypeDefThrow(); - if (typeDef.Module.IsCoreLibraryModule != true) - { - result.Append($"[{typeDef.Module.Assembly.Name}]"); - } - result.Append(typeDef.FullName); - break; - } - case ElementType.GenericInst: - { - var genInst = (GenericInstSig)type; - ComputeTypeSigName(genInst.GenericType, result); - result.Append("<"); - for (int i = 0; i < genInst.GenericArguments.Count; i++) - { - if (i > 0) - { - result.Append(","); - } - ComputeTypeSigName(genInst.GenericArguments[i], result); - } - result.Append(">"); - break; - } - case ElementType.SZArray: - ComputeTypeSigName(((SZArraySig)type).Next, result); - result.Append("[]"); - break; - case ElementType.Array: - { - var arraySig = (ArraySig)type; - ComputeTypeSigName(arraySig.Next, result); - result.Append("["); - for (int i = 0; i < arraySig.Rank; i++) - { - if (i > 0) - { - result.Append(","); - } - //result.Append(arraySig.Sizes[i]); - } - result.Append("]"); - break; - } - case ElementType.FnPtr: - { - var fnPtr = (FnPtrSig)type; - result.Append("("); - MethodSig ms = fnPtr.MethodSig; - ComputeTypeSigName(ms.RetType, result); - result.Append("("); - for (int i = 0; i < ms.Params.Count; i++) - { - if (i > 0) - { - result.Append(","); - } - ComputeTypeSigName(ms.Params[i], result); - } - result.Append(")*"); - break; - } - case ElementType.TypedByRef: - result.Append("typedref"); - break; - case ElementType.I: - result.Append("nint"); - break; - case ElementType.U: - result.Append("nuint"); - break; - case ElementType.Object: - result.Append("object"); - break; - case ElementType.Var: - { - var var = (GenericVar)type; - result.Append($"!{var.Number}"); - break; - } - case ElementType.MVar: - { - var mvar = (GenericMVar)type; - result.Append($"!!{mvar.Number}"); - break; - } - default: throw new NotSupportedException($"[ComputeTypeSigName] not support :{type}"); - - } - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/TypeSigUtil.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/TypeSigUtil.cs.meta deleted file mode 100644 index fd92512..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Utils/TypeSigUtil.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 83e1214102577b449a933438c41c97bf -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/LICENSE b/Obfuz/Packages/com.code-philosophy.obfuz/LICENSE deleted file mode 100644 index 093e599..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2025 Code Philosophy(代码哲学) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/LICENSE.meta b/Obfuz/Packages/com.code-philosophy.obfuz/LICENSE.meta deleted file mode 100644 index 3bb31e6..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/LICENSE.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 4431597180c05fb46839ded925d40a19 -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Plugins.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Plugins.meta deleted file mode 100644 index c04aee9..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Plugins.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: f98a5dd310a82a64c9cc45cc139773dc -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Plugins/dnlib.dll b/Obfuz/Packages/com.code-philosophy.obfuz/Plugins/dnlib.dll deleted file mode 100644 index ba1f36d..0000000 Binary files a/Obfuz/Packages/com.code-philosophy.obfuz/Plugins/dnlib.dll and /dev/null differ diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Plugins/dnlib.dll.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Plugins/dnlib.dll.meta deleted file mode 100644 index 5bde396..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Plugins/dnlib.dll.meta +++ /dev/null @@ -1,33 +0,0 @@ -fileFormatVersion: 2 -guid: 355f9a0beb9535e4792b15e532d17460 -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 1 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - Any: - second: - enabled: 1 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Windows Store Apps: WindowsStoreApps - second: - enabled: 0 - settings: - CPU: AnyCPU - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Runtime.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Runtime.meta deleted file mode 100644 index a93405f..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Runtime.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: cd1451b864839ad41b5463274b1d171c -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/ConstUtility.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/ConstUtility.cs deleted file mode 100644 index 467cc2b..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/ConstUtility.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Text; -using Unity.Collections.LowLevel.Unsafe; -using UnityEngine; -using UnityEngine.Assertions; - -namespace Obfuz -{ - public static class ConstUtility - { - public static int GetInt(byte[] data, int offset) - { - return BitConverter.ToInt32(data, offset); - } - - public static long GetLong(byte[] data, int offset) - { - return BitConverter.ToInt64(data, offset); - } - - public static float GetFloat(byte[] data, int offset) - { - return BitConverter.ToSingle(data, offset); - } - - public static double GetDouble(byte[] data, int offset) - { - return BitConverter.ToDouble(data, offset); - } - - public static string GetString(byte[] data, int offset, int length) - { - return Encoding.UTF8.GetString(data, offset, length); - } - - public static byte[] GetBytes(byte[] data, int offset, int length) - { - byte[] result = new byte[length]; - Array.Copy(data, offset, result, 0, length); - return result; - } - - public static int[] GetInts(byte[] data, int offset, int byteLength) - { - Assert.IsTrue(byteLength % 4 == 0); - int[] result = new int[byteLength >> 2]; - Buffer.BlockCopy(data, offset, result, 0, byteLength); - return result; - } - - public static void InitializeArray(Array array, byte[] data, int offset, int length) - { - Buffer.BlockCopy(data, offset, array, 0, length); - } - - public static unsafe int CastFloatAsInt(float value) - { - int* intValue = (int*)&value; - return *intValue; - } - - public static unsafe float CastIntAsFloat(int value) - { - float* floatValue = (float*)&value; - return *floatValue; - } - - public static unsafe long CastDoubleAsLong(double value) - { - long* longValue = (long*)&value; - return *longValue; - } - - public static unsafe double CastLongAsDouble(long value) - { - double* doubleValue = (double*)&value; - return *doubleValue; - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/ConstUtility.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/ConstUtility.cs.meta deleted file mode 100644 index f474205..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/ConstUtility.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 48bd592d1a1339643be1fafe4b97c941 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/EncryptFieldAttribute.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/EncryptFieldAttribute.cs deleted file mode 100644 index cf8eecb..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/EncryptFieldAttribute.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Obfuz -{ - [AttributeUsage(AttributeTargets.Field, Inherited = false, AllowMultiple = false)] - public class EncryptFieldAttribute : Attribute - { - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/EncryptFieldAttribute.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/EncryptFieldAttribute.cs.meta deleted file mode 100644 index a76ea9d..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/EncryptFieldAttribute.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 30f22110938816d4cb7e9cc9a176fd1e -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/EncryptionScope.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/EncryptionScope.cs deleted file mode 100644 index fe215ef..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/EncryptionScope.cs +++ /dev/null @@ -1,31 +0,0 @@ -namespace Obfuz -{ - public interface IEncryptionScope - { - - } - - public abstract class EncryptionScopeBase : IEncryptionScope - { - public void ForcePreserveAOT() - { - EncryptionService.Encrypt(0, 0, 0); - } - } - - public struct DefaultDynamicEncryptionScope : IEncryptionScope - { - public void ForcePreserveAOT() - { - EncryptionService.Encrypt(0, 0, 0); - } - } - - public struct DefaultStaticEncryptionScope: IEncryptionScope - { - public void ForcePreserveAOT() - { - EncryptionService.Encrypt(0, 0, 0); - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/EncryptionScope.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/EncryptionScope.cs.meta deleted file mode 100644 index 064f875..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/EncryptionScope.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 1d729fe7cb7d0bc43a69f1ba09f99061 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/EncryptionService.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/EncryptionService.cs deleted file mode 100644 index ccd0cea..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/EncryptionService.cs +++ /dev/null @@ -1,126 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Obfuz -{ - - public static class EncryptionService where T : IEncryptionScope - { - // for compatibility with Mono because Mono will raise FieldAccessException when try access private field - public static IEncryptor _encryptor; - - public static IEncryptor Encryptor - { - get => _encryptor; - set { _encryptor = value; } - } - - public static void EncryptBlock(byte[] data, int ops, int salt) - { - _encryptor.EncryptBlock(data, ops, salt); - } - - public static void DecryptBlock(byte[] data, int ops, int salt) - { - _encryptor.DecryptBlock(data, ops, salt); - } - - public static int Encrypt(int value, int opts, int salt) - { - return _encryptor.Encrypt(value, opts, salt); - } - - public static int Decrypt(int value, int opts, int salt) - { - return _encryptor.Decrypt(value, opts, salt); - } - - public static long Encrypt(long value, int opts, int salt) - { - return _encryptor.Encrypt(value, opts, salt); - } - - public static long Decrypt(long value, int opts, int salt) - { - return _encryptor.Decrypt(value, opts, salt); - } - - public static float Encrypt(float value, int opts, int salt) - { - return _encryptor.Encrypt(value, opts, salt); - } - - public static float Decrypt(float value, int opts, int salt) - { - return _encryptor.Decrypt(value, opts, salt); - } - - public static double Encrypt(double value, int opts, int salt) - { - return _encryptor.Encrypt(value, opts, salt); - } - - public static double Decrypt(double value, int opts, int salt) - { - return _encryptor.Decrypt(value, opts, salt); - } - - public static byte[] Encrypt(byte[] value, int offset, int length, int opts, int salt) - { - return _encryptor.Encrypt(value, offset, length, opts, salt); - } - - public static byte[] Decrypt(byte[] value, int offset, int byteLength, int ops, int salt) - { - return _encryptor.Decrypt(value, offset, byteLength, ops, salt); - } - - public static byte[] Encrypt(string value, int ops, int salt) - { - return _encryptor.Encrypt(value, ops, salt); - } - - public static string DecryptString(byte[] value, int offset, int stringBytesLength, int ops, int salt) - { - return _encryptor.DecryptString(value, offset, stringBytesLength, ops, salt); - } - - - public static int DecryptFromRvaInt(byte[] data, int offset, int ops, int salt) - { - int encryptedValue = ConstUtility.GetInt(data, offset); - return Decrypt(encryptedValue, ops, salt); - } - - public static long DecryptFromRvaLong(byte[] data, int offset, int ops, int salt) - { - long encryptedValue = ConstUtility.GetLong(data, offset); - return Decrypt(encryptedValue, ops, salt); - } - - public static float DecryptFromRvaFloat(byte[] data, int offset, int ops, int salt) - { - float encryptedValue = ConstUtility.GetFloat(data, offset); - return Decrypt(encryptedValue, ops, salt); - } - - public static double DecryptFromRvaDouble(byte[] data, int offset, int ops, int salt) - { - double encryptedValue = ConstUtility.GetDouble(data, offset); - return Decrypt(encryptedValue, ops, salt); - } - - public static string DecryptFromRvaString(byte[] data, int offset, int length, int ops, int salt) - { - return DecryptString(data, offset, length, ops, salt); - } - - public static byte[] DecryptFromRvaBytes(byte[] data, int offset, int bytesLength, int ops, int salt) - { - return Decrypt(data, offset, bytesLength, ops, salt); - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/EncryptionService.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/EncryptionService.cs.meta deleted file mode 100644 index d7364ef..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/EncryptionService.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: bbbeb7501a0d84542828cb1aa7103d1b -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/EncryptorBase.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/EncryptorBase.cs deleted file mode 100644 index 007e4b9..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/EncryptorBase.cs +++ /dev/null @@ -1,258 +0,0 @@ -using JetBrains.Annotations; -using System; -using System.Text; -using Unity.Collections.LowLevel.Unsafe; -using UnityEngine.Assertions; - -namespace Obfuz -{ - public abstract class EncryptorBase : IEncryptor - { - public abstract int OpCodeCount { get; } - - public static int[] ConvertToIntKey(byte[] key) - { - Assert.AreEqual(0, key.Length % 4); - int align4Length = key.Length / 4; - int[] intKey = new int[align4Length]; - Buffer.BlockCopy(key, 0, intKey, 0, key.Length); - return intKey; - } - - public abstract int Encrypt(int value, int opts, int salt); - public abstract int Decrypt(int value, int opts, int salt); - - public virtual long Encrypt(long value, int opts, int salt) - { - int low = (int)value; - int high = (int)(value >> 32); - int encryptedLow = Encrypt(low, opts, salt); - int encryptedHigh = Encrypt(high, opts, salt); - return ((long)encryptedHigh << 32) | (uint)encryptedLow; - } - - public virtual long Decrypt(long value, int opts, int salt) - { - int low = (int)value; - int high = (int)(value >> 32); - int decryptedLow = Decrypt(low, opts, salt); - int decryptedHigh = Decrypt(high, opts, salt); - return ((long)decryptedHigh << 32) | (uint)decryptedLow; - } - - public virtual unsafe float Encrypt(float value, int opts, int salt) - { - if (float.IsNaN(value) || float.IsInfinity(value)) - { - return value; - } - ref int intValue = ref *(int*)&value; - int xorValue = ((1 << 23) - 1) & Decrypt(0xABCD, opts, salt); - intValue ^= xorValue; - return value; - } - - public virtual unsafe float Decrypt(float value, int opts, int salt) - { - if (float.IsNaN(value) || float.IsInfinity(value)) - { - return value; - } - ref int intValue = ref *(int*)&value; - int xorValue = ((1 << 23) - 1) & Decrypt(0xABCD, opts, salt); - intValue ^= xorValue; - return value; - } - - public virtual unsafe double Encrypt(double value, int opts, int salt) - { - if (double.IsNaN(value) || double.IsInfinity(value)) - { - return value; - } - ref long longValue = ref *(long*)&value; - long xorValue = ((1L << 52) - 1) & Decrypt(0xAABBCCDDL, opts, salt); - longValue ^= xorValue; - return value; - } - - public virtual unsafe double Decrypt(double value, int opts, int salt) - { - if (double.IsNaN(value) || double.IsInfinity(value)) - { - return value; - } - ref long longValue = ref *(long*)&value; - long xorValue = ((1L << 52) - 1) & Decrypt(0xAABBCCDDL, opts, salt); - longValue ^= xorValue; - return value; - } - - public virtual unsafe byte[] Encrypt(byte[] value, int offset, int length, int ops, int salt) - { - if (length == 0) - { - return Array.Empty(); - } - - var encryptedBytes = new byte[length]; - int intArrLength = length >> 2; - - // align to 4 - if ((offset & 0x3) != 0) - { - Buffer.BlockCopy(value, offset, encryptedBytes, 0, length); - - // encrypt int - - fixed (byte* dstBytePtr = &encryptedBytes[0]) - { - int* dstIntPtr = (int*)dstBytePtr; - int last = 0; - for (int i = 0; i < intArrLength; i++) - { - last ^= Encrypt(dstIntPtr[i], ops, salt); - dstIntPtr[i] = last; - } - } - for (int i = intArrLength * 4; i < length; i++) - { - encryptedBytes[i] = (byte)(encryptedBytes[i] ^ salt); - } - } - else - { - // encrypt int - fixed (byte* srcBytePtr = &value[offset]) - { - fixed (byte* dstBytePtr = &encryptedBytes[0]) - { - int* srcIntPtr = (int*)srcBytePtr; - int* dstIntPtr = (int*)dstBytePtr; - - int last = 0; - for (int i = 0; i < intArrLength; i++) - { - last ^= Encrypt(srcIntPtr[i], ops, salt); - dstIntPtr[i] = last; - } - } - } - for (int i = intArrLength * 4; i < length; i++) - { - encryptedBytes[i] = (byte)(value[offset + i] ^ salt); - } - } - return encryptedBytes; - } - - public unsafe virtual byte[] Decrypt(byte[] value, int offset, int length, int ops, int salt) - { - var decryptedBytes = new byte[length]; - int intArrLength = length >> 2; - - // align to 4 - if ((offset & 0x3) != 0) - { - Buffer.BlockCopy(value, offset, decryptedBytes, 0, length); - - // encrypt int - - fixed (byte* dstBytePtr = &decryptedBytes[0]) - { - int* dstIntPtr = (int*)dstBytePtr; - int last = 0; - for (int i = 0; i < intArrLength; i++) - { - int oldLast = last; - last = dstIntPtr[i]; - dstIntPtr[i] = Decrypt(last ^ oldLast, ops, salt); - } - } - for (int i = intArrLength * 4; i < length; i++) - { - decryptedBytes[i] = (byte)(decryptedBytes[i] ^ salt); - } - } - else - { - // encrypt int - fixed (byte* srcBytePtr = &value[offset]) - { - fixed (byte* dstBytePtr = &decryptedBytes[0]) - { - int* srcIntPtr = (int*)srcBytePtr; - int* dstIntPtr = (int*)dstBytePtr; - int last = 0; - for (int i = 0; i < intArrLength; i++) - { - int oldLast = last; - last = srcIntPtr[i]; - dstIntPtr[i] = Decrypt(last ^ oldLast, ops, salt); - } - } - } - for (int i = intArrLength * 4; i < length; i++) - { - decryptedBytes[i] = (byte)(value[offset + i] ^ salt); - } - } - return decryptedBytes; - } - - public virtual byte[] Encrypt(string value, int ops, int salt) - { - byte[] bytes = Encoding.UTF8.GetBytes(value); - return Encrypt(bytes, 0, bytes.Length, ops, salt); - } - - public virtual string DecryptString(byte[] value, int offset, int length, int ops, int salt) - { - byte[] bytes = Decrypt(value, offset, length, ops, salt); - return Encoding.UTF8.GetString(bytes); - } - - public virtual unsafe void EncryptBlock(byte[] data, int ops, int salt) - { - int length = data.Length; - int intArrLength = length >> 2; - - fixed (byte* dstBytePtr = &data[0]) - { - int* dstIntPtr = (int*)dstBytePtr; - int last = 0; - for (int i = 0; i < intArrLength; i++) - { - last ^= Encrypt(dstIntPtr[i], ops, salt); - dstIntPtr[i] = last; - } - } - for (int i = intArrLength * 4; i < length; i++) - { - data[i] = (byte)(data[i] ^ salt); - } - } - - public virtual unsafe void DecryptBlock(byte[] data, int ops, int salt) - { - int length = data.Length; - int intArrLength = length >> 2; - - fixed (byte* dstBytePtr = &data[0]) - { - int* dstIntPtr = (int*)dstBytePtr; - int last = 0; - for (int i = 0; i < intArrLength; i++) - { - int oldLast = last; - last = dstIntPtr[i]; - dstIntPtr[i] = Decrypt(oldLast ^ last, ops, salt); - } - } - for (int i = intArrLength * 4; i < length; i++) - { - data[i] = (byte)(data[i] ^ salt); - } - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/EncryptorBase.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/EncryptorBase.cs.meta deleted file mode 100644 index e81d521..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/EncryptorBase.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d1d4c5725e7ad624ba8e55ecb63bb440 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/IEncryptor.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/IEncryptor.cs deleted file mode 100644 index 0d8fdaa..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/IEncryptor.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace Obfuz -{ - public interface IEncryptor - { - int OpCodeCount { get; } - - void EncryptBlock(byte[] data, int ops, int salt); - void DecryptBlock(byte[] data, int ops, int salt); - - int Encrypt(int value, int opts, int salt); - int Decrypt(int value, int opts, int salt); - - long Encrypt(long value, int opts, int salt); - long Decrypt(long value, int opts, int salt); - - float Encrypt(float value, int opts, int salt); - float Decrypt(float value, int opts, int salt); - - double Encrypt(double value, int opts, int salt); - double Decrypt(double value, int opts, int salt); - - byte[] Encrypt(byte[] value, int offset, int length, int opts, int salt); - byte[] Decrypt(byte[] value, int offset, int byteLength, int ops, int salt); - - byte[] Encrypt(string value, int ops, int salt); - string DecryptString(byte[] value, int offset, int stringBytesLength, int ops, int salt); - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/IEncryptor.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/IEncryptor.cs.meta deleted file mode 100644 index 4141821..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/IEncryptor.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 3078fa59ff0af6b4cbbee25e20bc41c1 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/NullEncryptor.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/NullEncryptor.cs deleted file mode 100644 index ec28f36..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/NullEncryptor.cs +++ /dev/null @@ -1,92 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Obfuz -{ - public class NullEncryptor : EncryptorBase - { - private readonly byte[] _key; - - public override int OpCodeCount => 256; - - public NullEncryptor(byte[] key) - { - _key = key; - } - - public override int Encrypt(int value, int opts, int salt) - { - return value; - } - - public override int Decrypt(int value, int opts, int salt) - { - return value; - } - - public override long Encrypt(long value, int opts, int salt) - { - return value; - } - - public override long Decrypt(long value, int opts, int salt) - { - return value; - } - - public override float Encrypt(float value, int opts, int salt) - { - return value; - } - - public override float Decrypt(float value, int opts, int salt) - { - return value; - } - - public override double Encrypt(double value, int opts, int salt) - { - return value; - } - - public override double Decrypt(double value, int opts, int salt) - { - return value; - } - - public override byte[] Encrypt(byte[] value, int offset, int length, int opts, int salt) - { - if (length == 0) - { - return Array.Empty(); - } - var encryptedBytes = new byte[length]; - Buffer.BlockCopy(value, offset, encryptedBytes, 0, length); - return encryptedBytes; - } - - public override byte[] Decrypt(byte[] value, int offset, int length, int ops, int salt) - { - if (length == 0) - { - return Array.Empty(); - } - byte[] byteArr = new byte[length]; - Buffer.BlockCopy(value, 0, byteArr, 0, length); - return byteArr; - } - - public override byte[] Encrypt(string value, int ops, int salt) - { - return Encoding.UTF8.GetBytes(value); - } - - public override string DecryptString(byte[] value, int offset, int length, int ops, int salt) - { - return Encoding.UTF8.GetString(value, offset, length); - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/NullEncryptor.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/NullEncryptor.cs.meta deleted file mode 100644 index b490d29..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/NullEncryptor.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c53481f2ec513be4783a5ae2f76dc6e7 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/Obfuz.Runtime.asmdef b/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/Obfuz.Runtime.asmdef deleted file mode 100644 index 4ee1d16..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/Obfuz.Runtime.asmdef +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "Obfuz.Runtime", - "rootNamespace": "", - "references": [], - "includePlatforms": [], - "excludePlatforms": [], - "allowUnsafeCode": true, - "overrideReferences": false, - "precompiledReferences": [], - "autoReferenced": true, - "defineConstraints": [], - "versionDefines": [], - "noEngineReferences": false -} \ No newline at end of file diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/Obfuz.Runtime.asmdef.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/Obfuz.Runtime.asmdef.meta deleted file mode 100644 index 4868da2..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/Obfuz.Runtime.asmdef.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 4140bd2e2764f1f47ab93125ecb61942 -AssemblyDefinitionImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/ObfuzIgnoreAttribute.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/ObfuzIgnoreAttribute.cs deleted file mode 100644 index 90d2b17..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/ObfuzIgnoreAttribute.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Obfuz -{ - [AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = false)] - public class ObfuzIgnoreAttribute : Attribute - { - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/ObfuzIgnoreAttribute.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/ObfuzIgnoreAttribute.cs.meta deleted file mode 100644 index bc8fb89..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/ObfuzIgnoreAttribute.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c2b4cf04729157b4dab504167ab5f703 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/package.json b/Obfuz/Packages/com.code-philosophy.obfuz/package.json deleted file mode 100644 index 6af9393..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "com.code-philosophy.obfuz", - "version": "1.0.0-alpha", - "displayName": "Obfuz", - "description": "Obfuz is an open-source Unity code obfuscation tool designed to provide Unity developers with a powerful, secure, and user-friendly code protection solution.", - "category": "Editor", - "documentationUrl": "https://www.obfuz.com", - "changelogUrl": "https://github.com/focus-creative-games/obfuz/commits/main/", - "licensesUrl": "https://github.com/focus-creative-games/obfuz/blob/main/LICENSE", - "keywords": [ - "obfuscation", - "obfuscator", - "confuser", - "code-philosophy" - ], - "author": { - "name": "Code Philosophy", - "email": "obfuz@code-philosophy.com", - "url": "https://code-philosophy.com" - } -} \ No newline at end of file diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/package.json.meta b/Obfuz/Packages/com.code-philosophy.obfuz/package.json.meta deleted file mode 100644 index 74168f7..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz/package.json.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 63433d029d2e08c46abd56175e308a15 -PackageManifestImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz4hybridclr/Editor.meta b/Obfuz/Packages/com.code-philosophy.obfuz4hybridclr/Editor.meta deleted file mode 100644 index ec94239..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz4hybridclr/Editor.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 067341936b8cb2242be3bdc83f3ca3cd -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz4hybridclr/Editor/ObfuscateUtil.cs b/Obfuz/Packages/com.code-philosophy.obfuz4hybridclr/Editor/ObfuscateUtil.cs deleted file mode 100644 index ea52e32..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz4hybridclr/Editor/ObfuscateUtil.cs +++ /dev/null @@ -1,82 +0,0 @@ -using HybridCLR.Editor; -using Obfuz.Settings; -using Obfuz; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using UnityEditor; -using HybridCLR.Editor.Commands; -using HybridCLR.Editor.Installer; -using System.IO; -using HybridCLR.Editor.ABI; -using UnityEngine; - -namespace Obfuz4HybridCLR -{ - public static class ObfuscateUtil - { - public static bool AreSameDirectory(string path1, string path2) - { - try - { - var dir1 = new DirectoryInfo(path1); - var dir2 = new DirectoryInfo(path2); - - // 比较完整路径(考虑符号链接) - return dir1.FullName.TrimEnd('\\') == dir2.FullName.TrimEnd('\\'); - } - catch - { - return false; - } - } - - public static void CompileAndObfuscateHotUpdateAssemblies(BuildTarget target) - { - string hotUpdateDllPath = SettingsUtil.GetHotUpdateDllsOutputDirByTarget(target); - BashUtil.RemoveDir(hotUpdateDllPath); - CompileDllCommand.CompileDll(target); - var assemblySearchPaths = new List - { - SettingsUtil.GetHotUpdateDllsOutputDirByTarget(target), - }; - Obfuscate(target, assemblySearchPaths, hotUpdateDllPath); - } - - public static void Obfuscate(BuildTarget target, List assemblySearchPaths, string outputPath) - { - var obfuzSettings = ObfuzSettings.Instance; - - var assemblySearchDirs = assemblySearchPaths; - ObfuscatorBuilder builder = ObfuscatorBuilder.FromObfuzSettings(obfuzSettings, target, true); - builder.InsertTopPriorityAssemblySearchPaths(assemblySearchDirs); - - string obfuscatedAssemblyOutputPath = obfuzSettings.GetObfuscatedAssemblyOutputPath(target); - if (AreSameDirectory(outputPath, obfuscatedAssemblyOutputPath)) - { - throw new Exception($"outputPath:{outputPath} can't be same to ObfuscatedAssemblyOutputPath:{obfuscatedAssemblyOutputPath}"); - } - foreach (var assemblySearchDir in builder.AssemblySearchPaths) - { - if (AreSameDirectory(assemblySearchDir, obfuscatedAssemblyOutputPath)) - { - throw new Exception($"assemblySearchDir:{assemblySearchDir} can't be same to ObfuscatedAssemblyOutputPath:{obfuscatedAssemblyOutputPath}"); - } - } - - Obfuscator obfuz = builder.Build(); - obfuz.Run(); - - Directory.CreateDirectory(outputPath); - foreach (string srcFile in Directory.GetFiles(obfuscatedAssemblyOutputPath, "*.dll")) - { - string fileName = Path.GetFileName(srcFile); - string destFile = $"{outputPath}/{fileName}"; - File.Copy(srcFile, destFile, true); - Debug.Log($"Copy {srcFile} to {destFile}"); - } - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz4hybridclr/Editor/ObfuscateUtil.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz4hybridclr/Editor/ObfuscateUtil.cs.meta deleted file mode 100644 index 3702fdd..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz4hybridclr/Editor/ObfuscateUtil.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: b7f5fe18513bcdd4c8960d908e88402e -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz4hybridclr/Editor/Obfuz4HybridCLR.asmdef b/Obfuz/Packages/com.code-philosophy.obfuz4hybridclr/Editor/Obfuz4HybridCLR.asmdef deleted file mode 100644 index 2af5cd5..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz4hybridclr/Editor/Obfuz4HybridCLR.asmdef +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "Obfuz4HybridCLR.Editor", - "rootNamespace": "", - "references": [ - "GUID:2373f786d14518f44b0f475db77ba4de", - "GUID:66e09fc524ec6594b8d6ca1d91aa1a41" - ], - "includePlatforms": [ - "Editor" - ], - "excludePlatforms": [], - "allowUnsafeCode": false, - "overrideReferences": false, - "precompiledReferences": [], - "autoReferenced": true, - "defineConstraints": [], - "versionDefines": [], - "noEngineReferences": false -} \ No newline at end of file diff --git a/Obfuz/Packages/com.code-philosophy.obfuz4hybridclr/Editor/Obfuz4HybridCLR.asmdef.meta b/Obfuz/Packages/com.code-philosophy.obfuz4hybridclr/Editor/Obfuz4HybridCLR.asmdef.meta deleted file mode 100644 index cc375a6..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz4hybridclr/Editor/Obfuz4HybridCLR.asmdef.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 3743e71edcd5bd8499007797ef02cbfb -AssemblyDefinitionImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz4hybridclr/Editor/PrebuildCommandExt.cs b/Obfuz/Packages/com.code-philosophy.obfuz4hybridclr/Editor/PrebuildCommandExt.cs deleted file mode 100644 index 95a115d..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz4hybridclr/Editor/PrebuildCommandExt.cs +++ /dev/null @@ -1,38 +0,0 @@ -using HybridCLR.Editor.Commands; -using HybridCLR.Editor; -using Obfuz.Settings; -using Obfuz; -using System.Collections; -using System.Collections.Generic; -using UnityEditor; -using UnityEngine; -using System.Reflection; -using System; -using System.IO; -using HybridCLR.Editor.Link; -using HybridCLR.Editor.Meta; -using UnityEditor.Build; -using HybridCLR.Editor.Installer; - -namespace Obfuz4HybridCLR -{ - public static class PrebuildCommandExt - { - [MenuItem("HybridCLR/ObfuzExtension/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'"); - } - BuildTarget target = EditorUserBuildSettings.activeBuildTarget; - ObfuscateUtil.CompileAndObfuscateHotUpdateAssemblies(target); - Il2CppDefGeneratorCommand.GenerateIl2CppDef(); - LinkGeneratorCommand.GenerateLinkXml(target); - StripAOTDllCommand.GenerateStripedAOTDlls(target); - MethodBridgeGeneratorCommand.GenerateMethodBridgeAndReversePInvokeWrapper(target); - AOTReferenceGeneratorCommand.GenerateAOTGenericReference(target); - } - } -} diff --git a/Obfuz/Packages/com.code-philosophy.obfuz4hybridclr/Editor/PrebuildCommandExt.cs.meta b/Obfuz/Packages/com.code-philosophy.obfuz4hybridclr/Editor/PrebuildCommandExt.cs.meta deleted file mode 100644 index 2bcd1c7..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz4hybridclr/Editor/PrebuildCommandExt.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: afc965e1afdfc8e47b8a70be7a93cf25 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz4hybridclr/LICENSE b/Obfuz/Packages/com.code-philosophy.obfuz4hybridclr/LICENSE deleted file mode 100644 index 093e599..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz4hybridclr/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2025 Code Philosophy(代码哲学) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/Obfuz/Packages/com.code-philosophy.obfuz4hybridclr/LICENSE.meta b/Obfuz/Packages/com.code-philosophy.obfuz4hybridclr/LICENSE.meta deleted file mode 100644 index dd09461..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz4hybridclr/LICENSE.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 3036602f815e31341b4445f0e331b58e -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/com.code-philosophy.obfuz4hybridclr/package.json b/Obfuz/Packages/com.code-philosophy.obfuz4hybridclr/package.json deleted file mode 100644 index 76fed77..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz4hybridclr/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "com.code-philosophy.obfuz4hybridclr", - "version": "1.0.0-alpha", - "displayName": "Obfuz4HybridCLR", - "description": "Obfuz Extension for HybridCLR", - "category": "Editor", - "documentationUrl": "https://www.obfuz.com", - "changelogUrl": "https://github.com/focus-creative-games/obfuz/commits/main/", - "licensesUrl": "https://github.com/focus-creative-games/obfuz/blob/main/LICENSE", - "keywords": [ - "obfuscation", - "obfuscator", - "confuser", - "code-philosophy" - ], - "author": { - "name": "Code Philosophy", - "email": "obfuz@code-philosophy.com", - "url": "https://code-philosophy.com" - } -} \ No newline at end of file diff --git a/Obfuz/Packages/com.code-philosophy.obfuz4hybridclr/package.json.meta b/Obfuz/Packages/com.code-philosophy.obfuz4hybridclr/package.json.meta deleted file mode 100644 index 5577b3b..0000000 --- a/Obfuz/Packages/com.code-philosophy.obfuz4hybridclr/package.json.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 9ac66e213a764b840b2533ee30123717 -PackageManifestImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Packages/manifest.json b/Obfuz/Packages/manifest.json deleted file mode 100644 index 3a34c71..0000000 --- a/Obfuz/Packages/manifest.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "dependencies": { - "com.code-philosophy.hybridclr": "https://github.com/focus-creative-games/hybridclr_unity.git", - "com.unity.ide.visualstudio": "2.0.23", - "com.unity.toolchain.win-x86_64-linux-x86_64": "2.0.10", - "com.unity.modules.assetbundle": "1.0.0", - "com.unity.modules.imgui": "1.0.0", - "com.unity.modules.unitywebrequest": "1.0.0", - "com.unity.modules.unitywebrequestwww": "1.0.0" - } -} diff --git a/Obfuz/Packages/packages-lock.json b/Obfuz/Packages/packages-lock.json deleted file mode 100644 index db27b13..0000000 --- a/Obfuz/Packages/packages-lock.json +++ /dev/null @@ -1,143 +0,0 @@ -{ - "dependencies": { - "com.code-philosophy.hybridclr": { - "version": "https://github.com/focus-creative-games/hybridclr_unity.git", - "depth": 0, - "source": "git", - "dependencies": {}, - "hash": "7a0032934b438ad20a4a691f8093ce1865824c42" - }, - "com.code-philosophy.obfuz": { - "version": "file:com.code-philosophy.obfuz", - "depth": 0, - "source": "embedded", - "dependencies": {} - }, - "com.code-philosophy.obfuz4hybridclr": { - "version": "file:com.code-philosophy.obfuz4hybridclr", - "depth": 0, - "source": "embedded", - "dependencies": {} - }, - "com.unity.ext.nunit": { - "version": "1.0.6", - "depth": 2, - "source": "registry", - "dependencies": {}, - "url": "https://packages.unity.com" - }, - "com.unity.ide.visualstudio": { - "version": "2.0.23", - "depth": 0, - "source": "registry", - "dependencies": { - "com.unity.test-framework": "1.1.9" - }, - "url": "https://packages.unity.com" - }, - "com.unity.sysroot": { - "version": "2.0.10", - "depth": 1, - "source": "registry", - "dependencies": {}, - "url": "https://packages.unity.com" - }, - "com.unity.sysroot.linux-x86_64": { - "version": "2.0.9", - "depth": 1, - "source": "registry", - "dependencies": { - "com.unity.sysroot": "2.0.10" - }, - "url": "https://packages.unity.com" - }, - "com.unity.test-framework": { - "version": "1.1.33", - "depth": 1, - "source": "registry", - "dependencies": { - "com.unity.ext.nunit": "1.0.6", - "com.unity.modules.imgui": "1.0.0", - "com.unity.modules.jsonserialize": "1.0.0" - }, - "url": "https://packages.unity.com" - }, - "com.unity.toolchain.win-x86_64-linux-x86_64": { - "version": "2.0.10", - "depth": 0, - "source": "registry", - "dependencies": { - "com.unity.sysroot": "2.0.10", - "com.unity.sysroot.linux-x86_64": "2.0.9" - }, - "url": "https://packages.unity.com" - }, - "com.unity.modules.assetbundle": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.audio": { - "version": "1.0.0", - "depth": 1, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.imageconversion": { - "version": "1.0.0", - "depth": 1, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.imgui": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.jsonserialize": { - "version": "1.0.0", - "depth": 2, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.unitywebrequest": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.unitywebrequestassetbundle": { - "version": "1.0.0", - "depth": 1, - "source": "builtin", - "dependencies": { - "com.unity.modules.assetbundle": "1.0.0", - "com.unity.modules.unitywebrequest": "1.0.0" - } - }, - "com.unity.modules.unitywebrequestaudio": { - "version": "1.0.0", - "depth": 1, - "source": "builtin", - "dependencies": { - "com.unity.modules.unitywebrequest": "1.0.0", - "com.unity.modules.audio": "1.0.0" - } - }, - "com.unity.modules.unitywebrequestwww": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.modules.unitywebrequest": "1.0.0", - "com.unity.modules.unitywebrequestassetbundle": "1.0.0", - "com.unity.modules.unitywebrequestaudio": "1.0.0", - "com.unity.modules.audio": "1.0.0", - "com.unity.modules.assetbundle": "1.0.0", - "com.unity.modules.imageconversion": "1.0.0" - } - } - } -} diff --git a/Obfuz/ProjectSettings/AudioManager.asset b/Obfuz/ProjectSettings/AudioManager.asset deleted file mode 100644 index 07ebfb0..0000000 --- a/Obfuz/ProjectSettings/AudioManager.asset +++ /dev/null @@ -1,19 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!11 &1 -AudioManager: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Volume: 1 - Rolloff Scale: 1 - Doppler Factor: 1 - Default Speaker Mode: 2 - m_SampleRate: 0 - m_DSPBufferSize: 1024 - m_VirtualVoiceCount: 512 - m_RealVoiceCount: 32 - m_SpatializerPlugin: - m_AmbisonicDecoderPlugin: - m_DisableAudio: 0 - m_VirtualizeEffects: 1 - m_RequestedDSPBufferSize: 1024 diff --git a/Obfuz/ProjectSettings/ClusterInputManager.asset b/Obfuz/ProjectSettings/ClusterInputManager.asset deleted file mode 100644 index e7886b2..0000000 --- a/Obfuz/ProjectSettings/ClusterInputManager.asset +++ /dev/null @@ -1,6 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!236 &1 -ClusterInputManager: - m_ObjectHideFlags: 0 - m_Inputs: [] diff --git a/Obfuz/ProjectSettings/DynamicsManager.asset b/Obfuz/ProjectSettings/DynamicsManager.asset deleted file mode 100644 index cdc1f3e..0000000 --- a/Obfuz/ProjectSettings/DynamicsManager.asset +++ /dev/null @@ -1,34 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!55 &1 -PhysicsManager: - m_ObjectHideFlags: 0 - serializedVersion: 11 - m_Gravity: {x: 0, y: -9.81, z: 0} - m_DefaultMaterial: {fileID: 0} - m_BounceThreshold: 2 - m_SleepThreshold: 0.005 - m_DefaultContactOffset: 0.01 - m_DefaultSolverIterations: 6 - m_DefaultSolverVelocityIterations: 1 - m_QueriesHitBackfaces: 0 - m_QueriesHitTriggers: 1 - m_EnableAdaptiveForce: 0 - m_ClothInterCollisionDistance: 0 - m_ClothInterCollisionStiffness: 0 - m_ContactsGeneration: 1 - m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff - m_AutoSimulation: 1 - m_AutoSyncTransforms: 0 - m_ReuseCollisionCallbacks: 1 - m_ClothInterCollisionSettingsToggle: 0 - m_ContactPairsMode: 0 - m_BroadphaseType: 0 - m_WorldBounds: - m_Center: {x: 0, y: 0, z: 0} - m_Extent: {x: 250, y: 250, z: 250} - m_WorldSubdivisions: 8 - m_FrictionType: 0 - m_EnableEnhancedDeterminism: 0 - m_EnableUnifiedHeightmaps: 1 - m_DefaultMaxAngluarSpeed: 7 diff --git a/Obfuz/ProjectSettings/EditorBuildSettings.asset b/Obfuz/ProjectSettings/EditorBuildSettings.asset deleted file mode 100644 index 2a164fd..0000000 --- a/Obfuz/ProjectSettings/EditorBuildSettings.asset +++ /dev/null @@ -1,11 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!1045 &1 -EditorBuildSettings: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Scenes: - - enabled: 1 - path: Assets/main.unity - guid: 528018d8add4a724bb1e36008449a904 - m_configObjects: {} diff --git a/Obfuz/ProjectSettings/EditorSettings.asset b/Obfuz/ProjectSettings/EditorSettings.asset deleted file mode 100644 index 1e44a0a..0000000 --- a/Obfuz/ProjectSettings/EditorSettings.asset +++ /dev/null @@ -1,30 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!159 &1 -EditorSettings: - m_ObjectHideFlags: 0 - serializedVersion: 11 - m_ExternalVersionControlSupport: Visible Meta Files - m_SerializationMode: 2 - m_LineEndingsForNewScripts: 0 - m_DefaultBehaviorMode: 0 - m_PrefabRegularEnvironment: {fileID: 0} - m_PrefabUIEnvironment: {fileID: 0} - m_SpritePackerMode: 0 - m_SpritePackerPaddingPower: 1 - m_EtcTextureCompressorBehavior: 1 - m_EtcTextureFastCompressor: 1 - m_EtcTextureNormalCompressor: 2 - m_EtcTextureBestCompressor: 4 - m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd;asmdef;rsp;asmref - m_ProjectGenerationRootNamespace: - m_CollabEditorSettings: - inProgressEnabled: 1 - m_EnableTextureStreamingInEditMode: 1 - m_EnableTextureStreamingInPlayMode: 1 - m_AsyncShaderCompilation: 1 - m_EnterPlayModeOptionsEnabled: 0 - m_EnterPlayModeOptions: 3 - m_ShowLightmapResolutionOverlay: 1 - m_UseLegacyProbeSampleCount: 0 - m_SerializeInlineMappingsOnOneLine: 1 diff --git a/Obfuz/ProjectSettings/GraphicsSettings.asset b/Obfuz/ProjectSettings/GraphicsSettings.asset deleted file mode 100644 index 4706883..0000000 --- a/Obfuz/ProjectSettings/GraphicsSettings.asset +++ /dev/null @@ -1,66 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!30 &1 -GraphicsSettings: - m_ObjectHideFlags: 0 - serializedVersion: 13 - m_Deferred: - m_Mode: 1 - m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} - m_DeferredReflections: - m_Mode: 1 - m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0} - m_ScreenSpaceShadows: - m_Mode: 1 - m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0} - m_LegacyDeferred: - m_Mode: 1 - m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} - m_DepthNormals: - m_Mode: 1 - m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0} - m_MotionVectors: - m_Mode: 1 - m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0} - m_LightHalo: - m_Mode: 1 - m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0} - m_LensFlare: - m_Mode: 1 - m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0} - m_AlwaysIncludedShaders: - - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} - - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} - - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} - - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} - - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0} - - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} - - {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0} - - {fileID: 16001, guid: 0000000000000000f000000000000000, type: 0} - - {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0} - m_PreloadedShaders: [] - m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, - type: 0} - m_CustomRenderPipeline: {fileID: 0} - m_TransparencySortMode: 0 - m_TransparencySortAxis: {x: 0, y: 0, z: 1} - m_DefaultRenderingPath: 1 - m_DefaultMobileRenderingPath: 1 - m_TierSettings: [] - m_LightmapStripping: 0 - m_FogStripping: 0 - m_InstancingStripping: 0 - m_LightmapKeepPlain: 1 - m_LightmapKeepDirCombined: 1 - m_LightmapKeepDynamicPlain: 1 - m_LightmapKeepDynamicDirCombined: 1 - m_LightmapKeepShadowMask: 1 - m_LightmapKeepSubtractive: 1 - m_FogKeepLinear: 1 - m_FogKeepExp: 1 - m_FogKeepExp2: 1 - m_AlbedoSwatchInfos: [] - m_LightsUseLinearIntensity: 0 - m_LightsUseColorTemperature: 0 - m_LogWhenShaderIsCompiled: 0 - m_AllowEnlightenSupportForUpgradedProject: 0 diff --git a/Obfuz/ProjectSettings/HybridCLRSettings.asset b/Obfuz/ProjectSettings/HybridCLRSettings.asset deleted file mode 100644 index 8c743fe..0000000 --- a/Obfuz/ProjectSettings/HybridCLRSettings.asset +++ /dev/null @@ -1,32 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!114 &1 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 0} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e189374413a3f00468e49d51d8b27a09, type: 3} - m_Name: - m_EditorClassIdentifier: - enable: 1 - useGlobalIl2cpp: 0 - hybridclrRepoURL: https://gitee.com/focus-creative-games/hybridclr - il2cppPlusRepoURL: https://gitee.com/focus-creative-games/il2cpp_plus - hotUpdateAssemblyDefinitions: - - {fileID: 5897886265953266890, guid: bb51ff56468259445b7d23b3d0e0f128, type: 3} - - {fileID: 5897886265953266890, guid: e486716a437ebda49bd80ffa906243cc, type: 3} - - {fileID: 5897886265953266890, guid: b34fdb1dadcceaf4893904ced3c8e655, type: 3} - hotUpdateAssemblies: [] - preserveHotUpdateAssemblies: [] - hotUpdateDllCompileOutputRootDir: HybridCLRData/HotUpdateDlls - externalHotUpdateAssembliyDirs: [] - strippedAOTDllOutputRootDir: HybridCLRData/AssembliesPostIl2CppStrip - patchAOTAssemblies: [] - outputLinkFile: HybridCLRGenerate/link.xml - outputAOTGenericReferenceFile: Main/AOTGenericReferences.cs - maxGenericReferenceIteration: 10 - maxMethodBridgeGenericIteration: 10 diff --git a/Obfuz/ProjectSettings/InputManager.asset b/Obfuz/ProjectSettings/InputManager.asset deleted file mode 100644 index 17c8f53..0000000 --- a/Obfuz/ProjectSettings/InputManager.asset +++ /dev/null @@ -1,295 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!13 &1 -InputManager: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Axes: - - serializedVersion: 3 - m_Name: Horizontal - descriptiveName: - descriptiveNegativeName: - negativeButton: left - positiveButton: right - altNegativeButton: a - altPositiveButton: d - gravity: 3 - dead: 0.001 - sensitivity: 3 - snap: 1 - invert: 0 - type: 0 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Vertical - descriptiveName: - descriptiveNegativeName: - negativeButton: down - positiveButton: up - altNegativeButton: s - altPositiveButton: w - gravity: 3 - dead: 0.001 - sensitivity: 3 - snap: 1 - invert: 0 - type: 0 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Fire1 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: left ctrl - altNegativeButton: - altPositiveButton: mouse 0 - gravity: 1000 - dead: 0.001 - sensitivity: 1000 - snap: 0 - invert: 0 - type: 0 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Fire2 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: left alt - altNegativeButton: - altPositiveButton: mouse 1 - gravity: 1000 - dead: 0.001 - sensitivity: 1000 - snap: 0 - invert: 0 - type: 0 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Fire3 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: left shift - altNegativeButton: - altPositiveButton: mouse 2 - gravity: 1000 - dead: 0.001 - sensitivity: 1000 - snap: 0 - invert: 0 - type: 0 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Jump - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: space - altNegativeButton: - altPositiveButton: - gravity: 1000 - dead: 0.001 - sensitivity: 1000 - snap: 0 - invert: 0 - type: 0 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Mouse X - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0 - sensitivity: 0.1 - snap: 0 - invert: 0 - type: 1 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Mouse Y - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0 - sensitivity: 0.1 - snap: 0 - invert: 0 - type: 1 - axis: 1 - joyNum: 0 - - serializedVersion: 3 - m_Name: Mouse ScrollWheel - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0 - sensitivity: 0.1 - snap: 0 - invert: 0 - type: 1 - axis: 2 - joyNum: 0 - - serializedVersion: 3 - m_Name: Horizontal - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0.19 - sensitivity: 1 - snap: 0 - invert: 0 - type: 2 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Vertical - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0.19 - sensitivity: 1 - snap: 0 - invert: 1 - type: 2 - axis: 1 - joyNum: 0 - - serializedVersion: 3 - m_Name: Fire1 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: joystick button 0 - altNegativeButton: - altPositiveButton: - gravity: 1000 - dead: 0.001 - sensitivity: 1000 - snap: 0 - invert: 0 - type: 0 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Fire2 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: joystick button 1 - altNegativeButton: - altPositiveButton: - gravity: 1000 - dead: 0.001 - sensitivity: 1000 - snap: 0 - invert: 0 - type: 0 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Fire3 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: joystick button 2 - altNegativeButton: - altPositiveButton: - gravity: 1000 - dead: 0.001 - sensitivity: 1000 - snap: 0 - invert: 0 - type: 0 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Jump - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: joystick button 3 - altNegativeButton: - altPositiveButton: - gravity: 1000 - dead: 0.001 - sensitivity: 1000 - snap: 0 - invert: 0 - type: 0 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Submit - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: return - altNegativeButton: - altPositiveButton: joystick button 0 - gravity: 1000 - dead: 0.001 - sensitivity: 1000 - snap: 0 - invert: 0 - type: 0 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Submit - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: enter - altNegativeButton: - altPositiveButton: space - gravity: 1000 - dead: 0.001 - sensitivity: 1000 - snap: 0 - invert: 0 - type: 0 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Cancel - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: escape - altNegativeButton: - altPositiveButton: joystick button 1 - gravity: 1000 - dead: 0.001 - sensitivity: 1000 - snap: 0 - invert: 0 - type: 0 - axis: 0 - joyNum: 0 diff --git a/Obfuz/ProjectSettings/MemorySettings.asset b/Obfuz/ProjectSettings/MemorySettings.asset deleted file mode 100644 index 5b5face..0000000 --- a/Obfuz/ProjectSettings/MemorySettings.asset +++ /dev/null @@ -1,35 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!387306366 &1 -MemorySettings: - m_ObjectHideFlags: 0 - m_EditorMemorySettings: - m_MainAllocatorBlockSize: -1 - m_ThreadAllocatorBlockSize: -1 - m_MainGfxBlockSize: -1 - m_ThreadGfxBlockSize: -1 - m_CacheBlockSize: -1 - m_TypetreeBlockSize: -1 - m_ProfilerBlockSize: -1 - m_ProfilerEditorBlockSize: -1 - m_BucketAllocatorGranularity: -1 - m_BucketAllocatorBucketsCount: -1 - m_BucketAllocatorBlockSize: -1 - m_BucketAllocatorBlockCount: -1 - m_ProfilerBucketAllocatorGranularity: -1 - m_ProfilerBucketAllocatorBucketsCount: -1 - m_ProfilerBucketAllocatorBlockSize: -1 - m_ProfilerBucketAllocatorBlockCount: -1 - m_TempAllocatorSizeMain: -1 - m_JobTempAllocatorBlockSize: -1 - m_BackgroundJobTempAllocatorBlockSize: -1 - m_JobTempAllocatorReducedBlockSize: -1 - m_TempAllocatorSizeGIBakingWorker: -1 - m_TempAllocatorSizeNavMeshWorker: -1 - m_TempAllocatorSizeAudioWorker: -1 - m_TempAllocatorSizeCloudWorker: -1 - m_TempAllocatorSizeGfx: -1 - m_TempAllocatorSizeJobWorker: -1 - m_TempAllocatorSizeBackgroundWorker: -1 - m_TempAllocatorSizePreloadManager: -1 - m_PlatformMemorySettings: {} diff --git a/Obfuz/ProjectSettings/MultiplayerManager.asset b/Obfuz/ProjectSettings/MultiplayerManager.asset deleted file mode 100644 index 2a93664..0000000 --- a/Obfuz/ProjectSettings/MultiplayerManager.asset +++ /dev/null @@ -1,7 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!655991488 &1 -MultiplayerManager: - m_ObjectHideFlags: 0 - m_EnableMultiplayerRoles: 0 - m_StrippingTypes: {} diff --git a/Obfuz/ProjectSettings/NavMeshAreas.asset b/Obfuz/ProjectSettings/NavMeshAreas.asset deleted file mode 100644 index 3b0b7c3..0000000 --- a/Obfuz/ProjectSettings/NavMeshAreas.asset +++ /dev/null @@ -1,91 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!126 &1 -NavMeshProjectSettings: - m_ObjectHideFlags: 0 - serializedVersion: 2 - areas: - - name: Walkable - cost: 1 - - name: Not Walkable - cost: 1 - - name: Jump - cost: 2 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - m_LastAgentTypeID: -887442657 - m_Settings: - - serializedVersion: 2 - agentTypeID: 0 - agentRadius: 0.5 - agentHeight: 2 - agentSlope: 45 - agentClimb: 0.75 - ledgeDropHeight: 0 - maxJumpAcrossDistance: 0 - minRegionArea: 2 - manualCellSize: 0 - cellSize: 0.16666667 - manualTileSize: 0 - tileSize: 256 - accuratePlacement: 0 - debug: - m_Flags: 0 - m_SettingNames: - - Humanoid diff --git a/Obfuz/ProjectSettings/Obfuz.asset b/Obfuz/ProjectSettings/Obfuz.asset deleted file mode 100644 index c4f658e..0000000 --- a/Obfuz/ProjectSettings/Obfuz.asset +++ /dev/null @@ -1,49 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!114 &1 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 0} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: c414eef017e565c4db1442ec64ec52fe, type: 3} - m_Name: - m_EditorClassIdentifier: - enable: 1 - assemblySettings: - assembliesToObfuscate: - - Assembly-CSharp - - Obfuz.Runtime - nonObfuscatedButReferencingObfuscatedAssemblies: [] - additionalAssemblySearchPaths: [] - obfuscationPassSettings: - enabledPasses: -1 - ruleFiles: [] - secretSettings: - defaultStaticSecretKey: Code Philosophy-Static - defaultDynamicSecretKey: Code Philosophy-Dynamic - secretKeyOutputPath: Assets/Resources/Obfuz - randomSeed: 0 - assembliesUsingDynamicSecretKeys: [] - encryptionVMSettings: - codeGenerationSecretKey: Obfuz - encryptionOpCodeCount: 256 - codeOutputPath: Assets/Obfuz/GeneratedEncryptionVirtualMachine.cs - symbolObfusSettings: - debug: 0 - obfuscatedNamePrefix: $ - useConsistentNamespaceObfuscation: 1 - symbolMappingFile: Assets/Obfuz/SymbolObfus/symbol-mapping.xml - ruleFiles: [] - constEncryptSettings: - encryptionLevel: 1 - ruleFiles: [] - fieldEncryptSettings: - encryptionLevel: 1 - ruleFiles: [] - callObfusSettings: - obfuscationLevel: 1 - ruleFiles: [] diff --git a/Obfuz/ProjectSettings/PackageManagerSettings.asset b/Obfuz/ProjectSettings/PackageManagerSettings.asset deleted file mode 100644 index 112a053..0000000 --- a/Obfuz/ProjectSettings/PackageManagerSettings.asset +++ /dev/null @@ -1,35 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!114 &1 -MonoBehaviour: - m_ObjectHideFlags: 61 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 0} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 13964, guid: 0000000000000000e000000000000000, type: 0} - m_Name: - m_EditorClassIdentifier: - m_EnablePreReleasePackages: 0 - m_EnablePackageDependencies: 0 - m_AdvancedSettingsExpanded: 1 - m_ScopedRegistriesSettingsExpanded: 1 - m_SeeAllPackageVersions: 0 - oneTimeWarningShown: 0 - m_Registries: - - m_Id: main - m_Name: - m_Url: https://packages.unity.com - m_Scopes: [] - m_IsDefault: 1 - m_Capabilities: 7 - m_UserSelectedRegistryName: - m_UserAddingNewScopedRegistry: 0 - m_RegistryInfoDraft: - m_Modified: 0 - m_ErrorMessage: - m_UserModificationsInstanceId: -830 - m_OriginalInstanceId: -832 - m_LoadAssets: 0 diff --git a/Obfuz/ProjectSettings/Packages/com.unity.testtools.codecoverage/Settings.json b/Obfuz/ProjectSettings/Packages/com.unity.testtools.codecoverage/Settings.json deleted file mode 100644 index 3c7b4c1..0000000 --- a/Obfuz/ProjectSettings/Packages/com.unity.testtools.codecoverage/Settings.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "m_Dictionary": { - "m_DictionaryValues": [] - } -} \ No newline at end of file diff --git a/Obfuz/ProjectSettings/Physics2DSettings.asset b/Obfuz/ProjectSettings/Physics2DSettings.asset deleted file mode 100644 index 47880b1..0000000 --- a/Obfuz/ProjectSettings/Physics2DSettings.asset +++ /dev/null @@ -1,56 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!19 &1 -Physics2DSettings: - m_ObjectHideFlags: 0 - serializedVersion: 4 - m_Gravity: {x: 0, y: -9.81} - m_DefaultMaterial: {fileID: 0} - m_VelocityIterations: 8 - m_PositionIterations: 3 - m_VelocityThreshold: 1 - m_MaxLinearCorrection: 0.2 - m_MaxAngularCorrection: 8 - m_MaxTranslationSpeed: 100 - m_MaxRotationSpeed: 360 - m_BaumgarteScale: 0.2 - m_BaumgarteTimeOfImpactScale: 0.75 - m_TimeToSleep: 0.5 - m_LinearSleepTolerance: 0.01 - m_AngularSleepTolerance: 2 - m_DefaultContactOffset: 0.01 - m_JobOptions: - serializedVersion: 2 - useMultithreading: 0 - useConsistencySorting: 0 - m_InterpolationPosesPerJob: 100 - m_NewContactsPerJob: 30 - m_CollideContactsPerJob: 100 - m_ClearFlagsPerJob: 200 - m_ClearBodyForcesPerJob: 200 - m_SyncDiscreteFixturesPerJob: 50 - m_SyncContinuousFixturesPerJob: 50 - m_FindNearestContactsPerJob: 100 - m_UpdateTriggerContactsPerJob: 100 - m_IslandSolverCostThreshold: 100 - m_IslandSolverBodyCostScale: 1 - m_IslandSolverContactCostScale: 10 - m_IslandSolverJointCostScale: 10 - m_IslandSolverBodiesPerJob: 50 - m_IslandSolverContactsPerJob: 50 - m_AutoSimulation: 1 - m_QueriesHitTriggers: 1 - m_QueriesStartInColliders: 1 - m_CallbacksOnDisable: 1 - m_ReuseCollisionCallbacks: 1 - m_AutoSyncTransforms: 0 - m_AlwaysShowColliders: 0 - m_ShowColliderSleep: 1 - m_ShowColliderContacts: 0 - m_ShowColliderAABB: 0 - m_ContactArrowScale: 0.2 - m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412} - m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432} - m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745} - m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804} - m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff diff --git a/Obfuz/ProjectSettings/PresetManager.asset b/Obfuz/ProjectSettings/PresetManager.asset deleted file mode 100644 index 67a94da..0000000 --- a/Obfuz/ProjectSettings/PresetManager.asset +++ /dev/null @@ -1,7 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!1386491679 &1 -PresetManager: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_DefaultPresets: {} diff --git a/Obfuz/ProjectSettings/ProjectSettings.asset b/Obfuz/ProjectSettings/ProjectSettings.asset deleted file mode 100644 index 9398732..0000000 --- a/Obfuz/ProjectSettings/ProjectSettings.asset +++ /dev/null @@ -1,994 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!129 &1 -PlayerSettings: - m_ObjectHideFlags: 0 - serializedVersion: 26 - productGUID: e7f1e2f620eaec64485a63083a6d4cd8 - AndroidProfiler: 0 - AndroidFilterTouchesWhenObscured: 0 - AndroidEnableSustainedPerformanceMode: 0 - defaultScreenOrientation: 4 - targetDevice: 2 - useOnDemandResources: 0 - accelerometerFrequency: 60 - companyName: DefaultCompany - productName: ObfuzDemo - defaultCursor: {fileID: 0} - cursorHotspot: {x: 0, y: 0} - m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1} - m_ShowUnitySplashScreen: 1 - m_ShowUnitySplashLogo: 1 - m_SplashScreenOverlayOpacity: 1 - m_SplashScreenAnimation: 1 - m_SplashScreenLogoStyle: 1 - m_SplashScreenDrawMode: 0 - m_SplashScreenBackgroundAnimationZoom: 1 - m_SplashScreenLogoAnimationZoom: 1 - m_SplashScreenBackgroundLandscapeAspect: 1 - m_SplashScreenBackgroundPortraitAspect: 1 - m_SplashScreenBackgroundLandscapeUvs: - serializedVersion: 2 - x: 0 - y: 0 - width: 1 - height: 1 - m_SplashScreenBackgroundPortraitUvs: - serializedVersion: 2 - x: 0 - y: 0 - width: 1 - height: 1 - m_SplashScreenLogos: [] - m_VirtualRealitySplashScreen: {fileID: 0} - m_HolographicTrackingLossScreen: {fileID: 0} - defaultScreenWidth: 800 - defaultScreenHeight: 600 - defaultScreenWidthWeb: 960 - defaultScreenHeightWeb: 600 - m_StereoRenderingPath: 0 - m_ActiveColorSpace: 1 - m_SpriteBatchVertexThreshold: 300 - m_MTRendering: 1 - mipStripping: 0 - numberOfMipsStripped: 0 - numberOfMipsStrippedPerMipmapLimitGroup: {} - m_StackTraceTypes: 010000000100000001000000010000000100000001000000 - iosShowActivityIndicatorOnLoading: -1 - androidShowActivityIndicatorOnLoading: -1 - iosUseCustomAppBackgroundBehavior: 0 - allowedAutorotateToPortrait: 1 - allowedAutorotateToPortraitUpsideDown: 1 - allowedAutorotateToLandscapeRight: 1 - allowedAutorotateToLandscapeLeft: 1 - useOSAutorotation: 1 - use32BitDisplayBuffer: 1 - preserveFramebufferAlpha: 0 - disableDepthAndStencilBuffers: 0 - androidStartInFullscreen: 1 - androidRenderOutsideSafeArea: 1 - androidUseSwappy: 1 - androidBlitType: 0 - androidResizableWindow: 0 - androidDefaultWindowWidth: 1920 - androidDefaultWindowHeight: 1080 - androidMinimumWindowWidth: 400 - androidMinimumWindowHeight: 300 - androidFullscreenMode: 1 - defaultIsNativeResolution: 1 - macRetinaSupport: 1 - runInBackground: 1 - captureSingleScreen: 0 - muteOtherAudioSources: 0 - Prepare IOS For Recording: 0 - Force IOS Speakers When Recording: 0 - deferSystemGesturesMode: 0 - hideHomeButton: 0 - submitAnalytics: 1 - usePlayerLog: 1 - dedicatedServerOptimizations: 0 - bakeCollisionMeshes: 0 - forceSingleInstance: 0 - useFlipModelSwapchain: 1 - resizableWindow: 0 - useMacAppStoreValidation: 0 - macAppStoreCategory: public.app-category.games - gpuSkinning: 1 - xboxPIXTextureCapture: 0 - xboxEnableAvatar: 0 - xboxEnableKinect: 0 - xboxEnableKinectAutoTracking: 0 - xboxEnableFitness: 0 - visibleInBackground: 1 - allowFullscreenSwitch: 1 - fullscreenMode: 3 - xboxSpeechDB: 0 - xboxEnableHeadOrientation: 0 - xboxEnableGuest: 0 - xboxEnablePIXSampling: 0 - metalFramebufferOnly: 0 - xboxOneResolution: 0 - xboxOneSResolution: 0 - xboxOneXResolution: 3 - xboxOneMonoLoggingLevel: 0 - xboxOneLoggingLevel: 1 - xboxOneDisableEsram: 0 - xboxOneEnableTypeOptimization: 0 - xboxOnePresentImmediateThreshold: 0 - switchQueueCommandMemory: 0 - switchQueueControlMemory: 16384 - switchQueueComputeMemory: 262144 - switchNVNShaderPoolsGranularity: 33554432 - switchNVNDefaultPoolsGranularity: 16777216 - switchNVNOtherPoolsGranularity: 16777216 - switchGpuScratchPoolGranularity: 2097152 - switchAllowGpuScratchShrinking: 0 - switchNVNMaxPublicTextureIDCount: 0 - switchNVNMaxPublicSamplerIDCount: 0 - switchNVNGraphicsFirmwareMemory: 32 - switchMaxWorkerMultiple: 8 - stadiaPresentMode: 0 - stadiaTargetFramerate: 0 - vulkanNumSwapchainBuffers: 3 - vulkanEnableSetSRGBWrite: 0 - vulkanEnablePreTransform: 1 - vulkanEnableLateAcquireNextImage: 0 - vulkanEnableCommandBufferRecycling: 1 - loadStoreDebugModeEnabled: 0 - bundleVersion: 0.1 - preloadedAssets: [] - metroInputSource: 0 - wsaTransparentSwapchain: 0 - m_HolographicPauseOnTrackingLoss: 1 - xboxOneDisableKinectGpuReservation: 1 - xboxOneEnable7thCore: 1 - vrSettings: - enable360StereoCapture: 0 - isWsaHolographicRemotingEnabled: 0 - enableFrameTimingStats: 0 - enableOpenGLProfilerGPURecorders: 1 - allowHDRDisplaySupport: 0 - useHDRDisplay: 0 - hdrBitDepth: 0 - m_ColorGamuts: 00000000 - targetPixelDensity: 30 - resolutionScalingMode: 0 - resetResolutionOnWindowResize: 0 - androidSupportedAspectRatio: 1 - androidMaxAspectRatio: 2.1 - applicationIdentifier: - Android: com.DefaultCompany.ObfuzDemo - Standalone: com.DefaultCompany.ObfuzDemo - buildNumber: - Standalone: 0 - VisionOS: 0 - iPhone: 0 - tvOS: 0 - overrideDefaultApplicationIdentifier: 0 - AndroidBundleVersionCode: 1 - AndroidMinSdkVersion: 22 - AndroidTargetSdkVersion: 0 - AndroidPreferredInstallLocation: 1 - aotOptions: - stripEngineCode: 1 - iPhoneStrippingLevel: 0 - iPhoneScriptCallOptimization: 0 - ForceInternetPermission: 0 - ForceSDCardPermission: 0 - CreateWallpaper: 0 - APKExpansionFiles: 0 - keepLoadedShadersAlive: 0 - StripUnusedMeshComponents: 1 - strictShaderVariantMatching: 0 - VertexChannelCompressionMask: 4054 - iPhoneSdkVersion: 988 - iOSTargetOSVersionString: 12.0 - tvOSSdkVersion: 0 - tvOSRequireExtendedGameController: 0 - tvOSTargetOSVersionString: 12.0 - VisionOSSdkVersion: 0 - VisionOSTargetOSVersionString: 1.0 - uIPrerenderedIcon: 0 - uIRequiresPersistentWiFi: 0 - uIRequiresFullScreen: 1 - uIStatusBarHidden: 1 - uIExitOnSuspend: 0 - uIStatusBarStyle: 0 - appleTVSplashScreen: {fileID: 0} - appleTVSplashScreen2x: {fileID: 0} - tvOSSmallIconLayers: [] - tvOSSmallIconLayers2x: [] - tvOSLargeIconLayers: [] - tvOSLargeIconLayers2x: [] - tvOSTopShelfImageLayers: [] - tvOSTopShelfImageLayers2x: [] - tvOSTopShelfImageWideLayers: [] - tvOSTopShelfImageWideLayers2x: [] - iOSLaunchScreenType: 0 - iOSLaunchScreenPortrait: {fileID: 0} - iOSLaunchScreenLandscape: {fileID: 0} - iOSLaunchScreenBackgroundColor: - serializedVersion: 2 - rgba: 0 - iOSLaunchScreenFillPct: 100 - iOSLaunchScreenSize: 100 - iOSLaunchScreenCustomXibPath: - iOSLaunchScreeniPadType: 0 - iOSLaunchScreeniPadImage: {fileID: 0} - iOSLaunchScreeniPadBackgroundColor: - serializedVersion: 2 - rgba: 0 - iOSLaunchScreeniPadFillPct: 100 - iOSLaunchScreeniPadSize: 100 - iOSLaunchScreeniPadCustomXibPath: - iOSLaunchScreenCustomStoryboardPath: - iOSLaunchScreeniPadCustomStoryboardPath: - iOSDeviceRequirements: [] - iOSURLSchemes: [] - macOSURLSchemes: [] - iOSBackgroundModes: 0 - iOSMetalForceHardShadows: 0 - metalEditorSupport: 1 - metalAPIValidation: 1 - iOSRenderExtraFrameOnPause: 0 - iosCopyPluginsCodeInsteadOfSymlink: 0 - appleDeveloperTeamID: - iOSManualSigningProvisioningProfileID: - tvOSManualSigningProvisioningProfileID: - VisionOSManualSigningProvisioningProfileID: - iOSManualSigningProvisioningProfileType: 0 - tvOSManualSigningProvisioningProfileType: 0 - VisionOSManualSigningProvisioningProfileType: 0 - appleEnableAutomaticSigning: 0 - iOSRequireARKit: 0 - iOSAutomaticallyDetectAndAddCapabilities: 1 - appleEnableProMotion: 0 - shaderPrecisionModel: 0 - clonedFromGUID: c0afd0d1d80e3634a9dac47e8a0426ea - templatePackageId: com.unity.template.3d@8.1.3 - templateDefaultScene: Assets/Scenes/SampleScene.unity - useCustomMainManifest: 0 - useCustomLauncherManifest: 0 - useCustomMainGradleTemplate: 0 - useCustomLauncherGradleManifest: 0 - useCustomBaseGradleTemplate: 0 - useCustomGradlePropertiesTemplate: 0 - useCustomGradleSettingsTemplate: 0 - useCustomProguardFile: 0 - AndroidTargetArchitectures: 1 - AndroidTargetDevices: 0 - AndroidSplashScreenScale: 0 - androidSplashScreen: {fileID: 0} - AndroidKeystoreName: - AndroidKeyaliasName: - AndroidEnableArmv9SecurityFeatures: 0 - AndroidBuildApkPerCpuArchitecture: 0 - AndroidTVCompatibility: 0 - AndroidIsGame: 1 - AndroidEnableTango: 0 - androidEnableBanner: 1 - androidUseLowAccuracyLocation: 0 - androidUseCustomKeystore: 0 - m_AndroidBanners: - - width: 320 - height: 180 - banner: {fileID: 0} - androidGamepadSupportLevel: 0 - chromeosInputEmulation: 1 - AndroidMinifyRelease: 0 - AndroidMinifyDebug: 0 - AndroidValidateAppBundleSize: 1 - AndroidAppBundleSizeToValidate: 150 - m_BuildTargetIcons: [] - m_BuildTargetPlatformIcons: - - m_BuildTarget: tvOS - m_Icons: - - m_Textures: [] - m_Width: 1280 - m_Height: 768 - m_Kind: 0 - m_SubKind: - - m_Textures: [] - m_Width: 800 - m_Height: 480 - m_Kind: 0 - m_SubKind: - - m_Textures: [] - m_Width: 400 - m_Height: 240 - m_Kind: 0 - m_SubKind: - - m_Textures: [] - m_Width: 4640 - m_Height: 1440 - m_Kind: 1 - m_SubKind: - - m_Textures: [] - m_Width: 2320 - m_Height: 720 - m_Kind: 1 - m_SubKind: - - m_Textures: [] - m_Width: 3840 - m_Height: 1440 - m_Kind: 1 - m_SubKind: - - m_Textures: [] - m_Width: 1920 - m_Height: 720 - m_Kind: 1 - m_SubKind: - - m_BuildTarget: iPhone - m_Icons: - - m_Textures: [] - m_Width: 180 - m_Height: 180 - m_Kind: 0 - m_SubKind: iPhone - - m_Textures: [] - m_Width: 120 - m_Height: 120 - m_Kind: 0 - m_SubKind: iPhone - - m_Textures: [] - m_Width: 167 - m_Height: 167 - m_Kind: 0 - m_SubKind: iPad - - m_Textures: [] - m_Width: 152 - m_Height: 152 - m_Kind: 0 - m_SubKind: iPad - - m_Textures: [] - m_Width: 76 - m_Height: 76 - m_Kind: 0 - m_SubKind: iPad - - m_Textures: [] - m_Width: 120 - m_Height: 120 - m_Kind: 3 - m_SubKind: iPhone - - m_Textures: [] - m_Width: 80 - m_Height: 80 - m_Kind: 3 - m_SubKind: iPhone - - m_Textures: [] - m_Width: 80 - m_Height: 80 - m_Kind: 3 - m_SubKind: iPad - - m_Textures: [] - m_Width: 40 - m_Height: 40 - m_Kind: 3 - m_SubKind: iPad - - m_Textures: [] - m_Width: 87 - m_Height: 87 - m_Kind: 1 - m_SubKind: iPhone - - m_Textures: [] - m_Width: 58 - m_Height: 58 - m_Kind: 1 - m_SubKind: iPhone - - m_Textures: [] - m_Width: 29 - m_Height: 29 - m_Kind: 1 - m_SubKind: iPhone - - m_Textures: [] - m_Width: 58 - m_Height: 58 - m_Kind: 1 - m_SubKind: iPad - - m_Textures: [] - m_Width: 29 - m_Height: 29 - m_Kind: 1 - m_SubKind: iPad - - m_Textures: [] - m_Width: 60 - m_Height: 60 - m_Kind: 2 - m_SubKind: iPhone - - m_Textures: [] - m_Width: 40 - m_Height: 40 - m_Kind: 2 - m_SubKind: iPhone - - m_Textures: [] - m_Width: 40 - m_Height: 40 - m_Kind: 2 - m_SubKind: iPad - - m_Textures: [] - m_Width: 20 - m_Height: 20 - m_Kind: 2 - m_SubKind: iPad - - m_Textures: [] - m_Width: 1024 - m_Height: 1024 - m_Kind: 4 - m_SubKind: App Store - - m_BuildTarget: Android - m_Icons: - - m_Textures: [] - m_Width: 432 - m_Height: 432 - m_Kind: 2 - m_SubKind: - - m_Textures: [] - m_Width: 324 - m_Height: 324 - m_Kind: 2 - m_SubKind: - - m_Textures: [] - m_Width: 216 - m_Height: 216 - m_Kind: 2 - m_SubKind: - - m_Textures: [] - m_Width: 162 - m_Height: 162 - m_Kind: 2 - m_SubKind: - - m_Textures: [] - m_Width: 108 - m_Height: 108 - m_Kind: 2 - m_SubKind: - - m_Textures: [] - m_Width: 81 - m_Height: 81 - m_Kind: 2 - m_SubKind: - - m_Textures: [] - m_Width: 192 - m_Height: 192 - m_Kind: 1 - m_SubKind: - - m_Textures: [] - m_Width: 144 - m_Height: 144 - m_Kind: 1 - m_SubKind: - - m_Textures: [] - m_Width: 96 - m_Height: 96 - m_Kind: 1 - m_SubKind: - - m_Textures: [] - m_Width: 72 - m_Height: 72 - m_Kind: 1 - m_SubKind: - - m_Textures: [] - m_Width: 48 - m_Height: 48 - m_Kind: 1 - m_SubKind: - - m_Textures: [] - m_Width: 36 - m_Height: 36 - m_Kind: 1 - m_SubKind: - - m_Textures: [] - m_Width: 192 - m_Height: 192 - m_Kind: 0 - m_SubKind: - - m_Textures: [] - m_Width: 144 - m_Height: 144 - m_Kind: 0 - m_SubKind: - - m_Textures: [] - m_Width: 96 - m_Height: 96 - m_Kind: 0 - m_SubKind: - - m_Textures: [] - m_Width: 72 - m_Height: 72 - m_Kind: 0 - m_SubKind: - - m_Textures: [] - m_Width: 48 - m_Height: 48 - m_Kind: 0 - m_SubKind: - - m_Textures: [] - m_Width: 36 - m_Height: 36 - m_Kind: 0 - m_SubKind: - m_BuildTargetBatching: - - m_BuildTarget: Standalone - m_StaticBatching: 1 - m_DynamicBatching: 0 - - m_BuildTarget: tvOS - m_StaticBatching: 1 - m_DynamicBatching: 0 - - m_BuildTarget: Android - m_StaticBatching: 1 - m_DynamicBatching: 0 - - m_BuildTarget: iPhone - m_StaticBatching: 1 - m_DynamicBatching: 0 - - m_BuildTarget: WebGL - m_StaticBatching: 0 - m_DynamicBatching: 0 - m_BuildTargetShaderSettings: [] - m_BuildTargetGraphicsJobs: - - m_BuildTarget: MacStandaloneSupport - m_GraphicsJobs: 0 - - m_BuildTarget: Switch - m_GraphicsJobs: 1 - - m_BuildTarget: MetroSupport - m_GraphicsJobs: 1 - - m_BuildTarget: AppleTVSupport - m_GraphicsJobs: 0 - - m_BuildTarget: BJMSupport - m_GraphicsJobs: 1 - - m_BuildTarget: LinuxStandaloneSupport - m_GraphicsJobs: 1 - - m_BuildTarget: PS4Player - m_GraphicsJobs: 1 - - m_BuildTarget: iOSSupport - m_GraphicsJobs: 0 - - m_BuildTarget: WindowsStandaloneSupport - m_GraphicsJobs: 1 - - m_BuildTarget: XboxOnePlayer - m_GraphicsJobs: 1 - - m_BuildTarget: LuminSupport - m_GraphicsJobs: 0 - - m_BuildTarget: AndroidPlayer - m_GraphicsJobs: 0 - - m_BuildTarget: WebGLSupport - m_GraphicsJobs: 0 - m_BuildTargetGraphicsJobMode: - - m_BuildTarget: PS4Player - m_GraphicsJobMode: 0 - - m_BuildTarget: XboxOnePlayer - m_GraphicsJobMode: 0 - m_BuildTargetGraphicsAPIs: - - m_BuildTarget: AndroidPlayer - m_APIs: 150000000b000000 - m_Automatic: 1 - - m_BuildTarget: iOSSupport - m_APIs: 10000000 - m_Automatic: 1 - - m_BuildTarget: AppleTVSupport - m_APIs: 10000000 - m_Automatic: 1 - - m_BuildTarget: WebGLSupport - m_APIs: 0b000000 - m_Automatic: 1 - m_BuildTargetVRSettings: - - m_BuildTarget: Standalone - m_Enabled: 0 - m_Devices: - - Oculus - - OpenVR - m_DefaultShaderChunkSizeInMB: 16 - m_DefaultShaderChunkCount: 0 - openGLRequireES31: 0 - openGLRequireES31AEP: 0 - openGLRequireES32: 0 - m_TemplateCustomTags: {} - mobileMTRendering: - Android: 1 - iPhone: 1 - tvOS: 1 - m_BuildTargetGroupLightmapEncodingQuality: - - m_BuildTarget: Android - m_EncodingQuality: 1 - - m_BuildTarget: iPhone - m_EncodingQuality: 1 - - m_BuildTarget: tvOS - m_EncodingQuality: 1 - m_BuildTargetGroupHDRCubemapEncodingQuality: - - m_BuildTarget: Android - m_EncodingQuality: 1 - - m_BuildTarget: iPhone - m_EncodingQuality: 1 - - m_BuildTarget: tvOS - m_EncodingQuality: 1 - m_BuildTargetGroupLightmapSettings: [] - m_BuildTargetGroupLoadStoreDebugModeSettings: [] - m_BuildTargetNormalMapEncoding: - - m_BuildTarget: Android - m_Encoding: 1 - - m_BuildTarget: iPhone - m_Encoding: 1 - - m_BuildTarget: tvOS - m_Encoding: 1 - m_BuildTargetDefaultTextureCompressionFormat: - - m_BuildTarget: Android - m_Format: 3 - playModeTestRunnerEnabled: 0 - runPlayModeTestAsEditModeTest: 0 - actionOnDotNetUnhandledException: 1 - enableInternalProfiler: 0 - logObjCUncaughtExceptions: 1 - enableCrashReportAPI: 0 - cameraUsageDescription: - locationUsageDescription: - microphoneUsageDescription: - bluetoothUsageDescription: - macOSTargetOSVersion: 10.13.0 - switchNMETAOverride: - switchNetLibKey: - switchSocketMemoryPoolSize: 6144 - switchSocketAllocatorPoolSize: 128 - switchSocketConcurrencyLimit: 14 - switchScreenResolutionBehavior: 2 - switchUseCPUProfiler: 0 - switchEnableFileSystemTrace: 0 - switchUseGOLDLinker: 0 - switchLTOSetting: 0 - switchApplicationID: 0x01004b9000490000 - switchNSODependencies: - switchCompilerFlags: - switchTitleNames_0: - switchTitleNames_1: - switchTitleNames_2: - switchTitleNames_3: - switchTitleNames_4: - switchTitleNames_5: - switchTitleNames_6: - switchTitleNames_7: - switchTitleNames_8: - switchTitleNames_9: - switchTitleNames_10: - switchTitleNames_11: - switchTitleNames_12: - switchTitleNames_13: - switchTitleNames_14: - switchTitleNames_15: - switchPublisherNames_0: - switchPublisherNames_1: - switchPublisherNames_2: - switchPublisherNames_3: - switchPublisherNames_4: - switchPublisherNames_5: - switchPublisherNames_6: - switchPublisherNames_7: - switchPublisherNames_8: - switchPublisherNames_9: - switchPublisherNames_10: - switchPublisherNames_11: - switchPublisherNames_12: - switchPublisherNames_13: - switchPublisherNames_14: - switchPublisherNames_15: - switchIcons_0: {fileID: 0} - switchIcons_1: {fileID: 0} - switchIcons_2: {fileID: 0} - switchIcons_3: {fileID: 0} - switchIcons_4: {fileID: 0} - switchIcons_5: {fileID: 0} - switchIcons_6: {fileID: 0} - switchIcons_7: {fileID: 0} - switchIcons_8: {fileID: 0} - switchIcons_9: {fileID: 0} - switchIcons_10: {fileID: 0} - switchIcons_11: {fileID: 0} - switchIcons_12: {fileID: 0} - switchIcons_13: {fileID: 0} - switchIcons_14: {fileID: 0} - switchIcons_15: {fileID: 0} - switchSmallIcons_0: {fileID: 0} - switchSmallIcons_1: {fileID: 0} - switchSmallIcons_2: {fileID: 0} - switchSmallIcons_3: {fileID: 0} - switchSmallIcons_4: {fileID: 0} - switchSmallIcons_5: {fileID: 0} - switchSmallIcons_6: {fileID: 0} - switchSmallIcons_7: {fileID: 0} - switchSmallIcons_8: {fileID: 0} - switchSmallIcons_9: {fileID: 0} - switchSmallIcons_10: {fileID: 0} - switchSmallIcons_11: {fileID: 0} - switchSmallIcons_12: {fileID: 0} - switchSmallIcons_13: {fileID: 0} - switchSmallIcons_14: {fileID: 0} - switchSmallIcons_15: {fileID: 0} - switchManualHTML: - switchAccessibleURLs: - switchLegalInformation: - switchMainThreadStackSize: 1048576 - switchPresenceGroupId: - switchLogoHandling: 0 - switchReleaseVersion: 0 - switchDisplayVersion: 1.0.0 - switchStartupUserAccount: 0 - switchSupportedLanguagesMask: 0 - switchLogoType: 0 - switchApplicationErrorCodeCategory: - switchUserAccountSaveDataSize: 0 - switchUserAccountSaveDataJournalSize: 0 - switchApplicationAttribute: 0 - switchCardSpecSize: -1 - switchCardSpecClock: -1 - switchRatingsMask: 0 - switchRatingsInt_0: 0 - switchRatingsInt_1: 0 - switchRatingsInt_2: 0 - switchRatingsInt_3: 0 - switchRatingsInt_4: 0 - switchRatingsInt_5: 0 - switchRatingsInt_6: 0 - switchRatingsInt_7: 0 - switchRatingsInt_8: 0 - switchRatingsInt_9: 0 - switchRatingsInt_10: 0 - switchRatingsInt_11: 0 - switchRatingsInt_12: 0 - switchLocalCommunicationIds_0: - switchLocalCommunicationIds_1: - switchLocalCommunicationIds_2: - switchLocalCommunicationIds_3: - switchLocalCommunicationIds_4: - switchLocalCommunicationIds_5: - switchLocalCommunicationIds_6: - switchLocalCommunicationIds_7: - switchParentalControl: 0 - switchAllowsScreenshot: 1 - switchAllowsVideoCapturing: 1 - switchAllowsRuntimeAddOnContentInstall: 0 - switchDataLossConfirmation: 0 - switchUserAccountLockEnabled: 0 - switchSystemResourceMemory: 16777216 - switchSupportedNpadStyles: 22 - switchNativeFsCacheSize: 32 - switchIsHoldTypeHorizontal: 0 - switchSupportedNpadCount: 8 - switchEnableTouchScreen: 1 - switchSocketConfigEnabled: 0 - switchTcpInitialSendBufferSize: 32 - switchTcpInitialReceiveBufferSize: 64 - switchTcpAutoSendBufferSizeMax: 256 - switchTcpAutoReceiveBufferSizeMax: 256 - switchUdpSendBufferSize: 9 - switchUdpReceiveBufferSize: 42 - switchSocketBufferEfficiency: 4 - switchSocketInitializeEnabled: 1 - switchNetworkInterfaceManagerInitializeEnabled: 1 - switchUseNewStyleFilepaths: 1 - switchUseLegacyFmodPriorities: 0 - switchUseMicroSleepForYield: 1 - switchEnableRamDiskSupport: 0 - switchMicroSleepForYieldTime: 25 - switchRamDiskSpaceSize: 12 - ps4NPAgeRating: 12 - ps4NPTitleSecret: - ps4NPTrophyPackPath: - ps4ParentalLevel: 11 - ps4ContentID: ED1633-NPXX51362_00-0000000000000000 - ps4Category: 0 - ps4MasterVersion: 01.00 - ps4AppVersion: 01.00 - ps4AppType: 0 - ps4ParamSfxPath: - ps4VideoOutPixelFormat: 0 - ps4VideoOutInitialWidth: 1920 - ps4VideoOutBaseModeInitialWidth: 1920 - ps4VideoOutReprojectionRate: 60 - ps4PronunciationXMLPath: - ps4PronunciationSIGPath: - ps4BackgroundImagePath: - ps4StartupImagePath: - ps4StartupImagesFolder: - ps4IconImagesFolder: - ps4SaveDataImagePath: - ps4SdkOverride: - ps4BGMPath: - ps4ShareFilePath: - ps4ShareOverlayImagePath: - ps4PrivacyGuardImagePath: - ps4ExtraSceSysFile: - ps4NPtitleDatPath: - ps4RemotePlayKeyAssignment: -1 - ps4RemotePlayKeyMappingDir: - ps4PlayTogetherPlayerCount: 0 - ps4EnterButtonAssignment: 1 - ps4ApplicationParam1: 0 - ps4ApplicationParam2: 0 - ps4ApplicationParam3: 0 - ps4ApplicationParam4: 0 - ps4DownloadDataSize: 0 - ps4GarlicHeapSize: 2048 - ps4ProGarlicHeapSize: 2560 - playerPrefsMaxSize: 32768 - ps4Passcode: frAQBc8Wsa1xVPfvJcrgRYwTiizs2trQ - ps4pnSessions: 1 - ps4pnPresence: 1 - ps4pnFriends: 1 - ps4pnGameCustomData: 1 - playerPrefsSupport: 0 - enableApplicationExit: 0 - resetTempFolder: 1 - restrictedAudioUsageRights: 0 - ps4UseResolutionFallback: 0 - ps4ReprojectionSupport: 0 - ps4UseAudio3dBackend: 0 - ps4UseLowGarlicFragmentationMode: 1 - ps4SocialScreenEnabled: 0 - ps4ScriptOptimizationLevel: 0 - ps4Audio3dVirtualSpeakerCount: 14 - ps4attribCpuUsage: 0 - ps4PatchPkgPath: - ps4PatchLatestPkgPath: - ps4PatchChangeinfoPath: - ps4PatchDayOne: 0 - ps4attribUserManagement: 0 - ps4attribMoveSupport: 0 - ps4attrib3DSupport: 0 - ps4attribShareSupport: 0 - ps4attribExclusiveVR: 0 - ps4disableAutoHideSplash: 0 - ps4videoRecordingFeaturesUsed: 0 - ps4contentSearchFeaturesUsed: 0 - ps4CompatibilityPS5: 0 - ps4AllowPS5Detection: 0 - ps4GPU800MHz: 1 - ps4attribEyeToEyeDistanceSettingVR: 0 - ps4IncludedModules: [] - ps4attribVROutputEnabled: 0 - monoEnv: - splashScreenBackgroundSourceLandscape: {fileID: 0} - splashScreenBackgroundSourcePortrait: {fileID: 0} - blurSplashScreenBackground: 1 - spritePackerPolicy: - webGLMemorySize: 16 - webGLExceptionSupport: 1 - webGLNameFilesAsHashes: 0 - webGLShowDiagnostics: 0 - webGLDataCaching: 1 - webGLDebugSymbols: 0 - webGLEmscriptenArgs: - webGLModulesDirectory: - webGLTemplate: APPLICATION:Default - webGLAnalyzeBuildSize: 0 - webGLUseEmbeddedResources: 0 - webGLCompressionFormat: 1 - webGLWasmArithmeticExceptions: 0 - webGLLinkerTarget: 1 - webGLThreadsSupport: 0 - webGLDecompressionFallback: 0 - webGLInitialMemorySize: 32 - webGLMaximumMemorySize: 2048 - webGLMemoryGrowthMode: 2 - webGLMemoryLinearGrowthStep: 16 - webGLMemoryGeometricGrowthStep: 0.2 - webGLMemoryGeometricGrowthCap: 96 - webGLPowerPreference: 2 - scriptingDefineSymbols: {} - additionalCompilerArguments: {} - platformArchitecture: {} - scriptingBackend: - Android: 1 - Standalone: 1 - il2cppCompilerConfiguration: - Android: 0 - Standalone: 0 - il2cppCodeGeneration: {} - managedStrippingLevel: - EmbeddedLinux: 1 - GameCoreScarlett: 1 - GameCoreXboxOne: 1 - Nintendo Switch: 1 - PS4: 1 - PS5: 1 - QNX: 1 - Stadia: 1 - VisionOS: 1 - WebGL: 1 - Windows Store Apps: 1 - XboxOne: 1 - iPhone: 1 - tvOS: 1 - incrementalIl2cppBuild: {} - suppressCommonWarnings: 1 - allowUnsafeCode: 0 - useDeterministicCompilation: 1 - additionalIl2CppArgs: - scriptingRuntimeVersion: 1 - gcIncremental: 1 - gcWBarrierValidation: 0 - apiCompatibilityLevelPerPlatform: {} - m_RenderingPath: 1 - m_MobileRenderingPath: 1 - metroPackageName: ObfuzDemo - metroPackageVersion: - metroCertificatePath: - metroCertificatePassword: - metroCertificateSubject: - metroCertificateIssuer: - metroCertificateNotAfter: 0000000000000000 - metroApplicationDescription: ObfuzDemo - wsaImages: {} - metroTileShortName: - metroTileShowName: 0 - metroMediumTileShowName: 0 - metroLargeTileShowName: 0 - metroWideTileShowName: 0 - metroSupportStreamingInstall: 0 - metroLastRequiredScene: 0 - metroDefaultTileSize: 1 - metroTileForegroundText: 2 - metroTileBackgroundColor: {r: 0.13333334, g: 0.17254902, b: 0.21568628, a: 0} - metroSplashScreenBackgroundColor: {r: 0.12941177, g: 0.17254902, b: 0.21568628, a: 1} - metroSplashScreenUseBackgroundColor: 0 - platformCapabilities: {} - metroTargetDeviceFamilies: {} - metroFTAName: - metroFTAFileTypes: [] - metroProtocolName: - vcxProjDefaultLanguage: - XboxOneProductId: - XboxOneUpdateKey: - XboxOneSandboxId: - XboxOneContentId: - XboxOneTitleId: - XboxOneSCId: - XboxOneGameOsOverridePath: - XboxOnePackagingOverridePath: - XboxOneAppManifestOverridePath: - XboxOneVersion: 1.0.0.0 - XboxOnePackageEncryption: 0 - XboxOnePackageUpdateGranularity: 2 - XboxOneDescription: - XboxOneLanguage: - - enus - XboxOneCapability: [] - XboxOneGameRating: {} - XboxOneIsContentPackage: 0 - XboxOneEnhancedXboxCompatibilityMode: 0 - XboxOneEnableGPUVariability: 1 - XboxOneSockets: {} - XboxOneSplashScreen: {fileID: 0} - XboxOneAllowedProductIds: [] - XboxOnePersistentLocalStorageSize: 0 - XboxOneXTitleMemory: 8 - XboxOneOverrideIdentityName: - XboxOneOverrideIdentityPublisher: - vrEditorSettings: {} - cloudServicesEnabled: - UNet: 1 - luminIcon: - m_Name: - m_ModelFolderPath: - m_PortalFolderPath: - luminCert: - m_CertPath: - m_SignPackage: 1 - luminIsChannelApp: 0 - luminVersion: - m_VersionCode: 1 - m_VersionName: - hmiPlayerDataPath: - hmiForceSRGBBlit: 1 - embeddedLinuxEnableGamepadInput: 1 - hmiLogStartupTiming: 0 - hmiCpuConfiguration: - apiCompatibilityLevel: 3 - activeInputHandler: 0 - windowsGamepadBackendHint: 0 - cloudProjectId: - framebufferDepthMemorylessMode: 0 - qualitySettingsNames: [] - projectName: - organizationId: - cloudEnabled: 0 - legacyClampBlendShapeWeights: 0 - hmiLoadingImage: {fileID: 0} - platformRequiresReadableAssets: 0 - virtualTexturingSupportEnabled: 0 - insecureHttpOption: 0 diff --git a/Obfuz/ProjectSettings/ProjectVersion.txt b/Obfuz/ProjectSettings/ProjectVersion.txt deleted file mode 100644 index 37f39b7..0000000 --- a/Obfuz/ProjectSettings/ProjectVersion.txt +++ /dev/null @@ -1,2 +0,0 @@ -m_EditorVersion: 2022.3.11f1 -m_EditorVersionWithRevision: 2022.3.11f1 (d00248457e15) diff --git a/Obfuz/ProjectSettings/QualitySettings.asset b/Obfuz/ProjectSettings/QualitySettings.asset deleted file mode 100644 index 36c0dad..0000000 --- a/Obfuz/ProjectSettings/QualitySettings.asset +++ /dev/null @@ -1,234 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!47 &1 -QualitySettings: - m_ObjectHideFlags: 0 - serializedVersion: 5 - m_CurrentQuality: 5 - m_QualitySettings: - - serializedVersion: 2 - name: Very Low - pixelLightCount: 0 - shadows: 0 - shadowResolution: 0 - shadowProjection: 1 - shadowCascades: 1 - shadowDistance: 15 - shadowNearPlaneOffset: 3 - shadowCascade2Split: 0.33333334 - shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} - shadowmaskMode: 0 - blendWeights: 1 - textureQuality: 1 - anisotropicTextures: 0 - antiAliasing: 0 - softParticles: 0 - softVegetation: 0 - realtimeReflectionProbes: 0 - billboardsFaceCameraPosition: 0 - vSyncCount: 0 - lodBias: 0.3 - maximumLODLevel: 0 - streamingMipmapsActive: 0 - streamingMipmapsAddAllCameras: 1 - streamingMipmapsMemoryBudget: 512 - streamingMipmapsRenderersPerFrame: 512 - streamingMipmapsMaxLevelReduction: 2 - streamingMipmapsMaxFileIORequests: 1024 - particleRaycastBudget: 4 - asyncUploadTimeSlice: 2 - asyncUploadBufferSize: 16 - asyncUploadPersistentBuffer: 1 - resolutionScalingFixedDPIFactor: 1 - excludedTargetPlatforms: [] - - serializedVersion: 2 - name: Low - pixelLightCount: 0 - shadows: 0 - shadowResolution: 0 - shadowProjection: 1 - shadowCascades: 1 - shadowDistance: 20 - shadowNearPlaneOffset: 3 - shadowCascade2Split: 0.33333334 - shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} - shadowmaskMode: 0 - blendWeights: 2 - textureQuality: 0 - anisotropicTextures: 0 - antiAliasing: 0 - softParticles: 0 - softVegetation: 0 - realtimeReflectionProbes: 0 - billboardsFaceCameraPosition: 0 - vSyncCount: 0 - lodBias: 0.4 - maximumLODLevel: 0 - streamingMipmapsActive: 0 - streamingMipmapsAddAllCameras: 1 - streamingMipmapsMemoryBudget: 512 - streamingMipmapsRenderersPerFrame: 512 - streamingMipmapsMaxLevelReduction: 2 - streamingMipmapsMaxFileIORequests: 1024 - particleRaycastBudget: 16 - asyncUploadTimeSlice: 2 - asyncUploadBufferSize: 16 - asyncUploadPersistentBuffer: 1 - resolutionScalingFixedDPIFactor: 1 - excludedTargetPlatforms: [] - - serializedVersion: 2 - name: Medium - pixelLightCount: 1 - shadows: 1 - shadowResolution: 0 - shadowProjection: 1 - shadowCascades: 1 - shadowDistance: 20 - shadowNearPlaneOffset: 3 - shadowCascade2Split: 0.33333334 - shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} - shadowmaskMode: 0 - blendWeights: 2 - textureQuality: 0 - anisotropicTextures: 1 - antiAliasing: 0 - softParticles: 0 - softVegetation: 0 - realtimeReflectionProbes: 0 - billboardsFaceCameraPosition: 0 - vSyncCount: 1 - lodBias: 0.7 - maximumLODLevel: 0 - streamingMipmapsActive: 0 - streamingMipmapsAddAllCameras: 1 - streamingMipmapsMemoryBudget: 512 - streamingMipmapsRenderersPerFrame: 512 - streamingMipmapsMaxLevelReduction: 2 - streamingMipmapsMaxFileIORequests: 1024 - particleRaycastBudget: 64 - asyncUploadTimeSlice: 2 - asyncUploadBufferSize: 16 - asyncUploadPersistentBuffer: 1 - resolutionScalingFixedDPIFactor: 1 - excludedTargetPlatforms: [] - - serializedVersion: 2 - name: High - pixelLightCount: 2 - shadows: 2 - shadowResolution: 1 - shadowProjection: 1 - shadowCascades: 2 - shadowDistance: 40 - shadowNearPlaneOffset: 3 - shadowCascade2Split: 0.33333334 - shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} - shadowmaskMode: 1 - blendWeights: 2 - textureQuality: 0 - anisotropicTextures: 1 - antiAliasing: 0 - softParticles: 0 - softVegetation: 1 - realtimeReflectionProbes: 1 - billboardsFaceCameraPosition: 1 - vSyncCount: 1 - lodBias: 1 - maximumLODLevel: 0 - streamingMipmapsActive: 0 - streamingMipmapsAddAllCameras: 1 - streamingMipmapsMemoryBudget: 512 - streamingMipmapsRenderersPerFrame: 512 - streamingMipmapsMaxLevelReduction: 2 - streamingMipmapsMaxFileIORequests: 1024 - particleRaycastBudget: 256 - asyncUploadTimeSlice: 2 - asyncUploadBufferSize: 16 - asyncUploadPersistentBuffer: 1 - resolutionScalingFixedDPIFactor: 1 - excludedTargetPlatforms: [] - - serializedVersion: 2 - name: Very High - pixelLightCount: 3 - shadows: 2 - shadowResolution: 2 - shadowProjection: 1 - shadowCascades: 2 - shadowDistance: 70 - shadowNearPlaneOffset: 3 - shadowCascade2Split: 0.33333334 - shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} - shadowmaskMode: 1 - blendWeights: 4 - textureQuality: 0 - anisotropicTextures: 2 - antiAliasing: 2 - softParticles: 1 - softVegetation: 1 - realtimeReflectionProbes: 1 - billboardsFaceCameraPosition: 1 - vSyncCount: 1 - lodBias: 1.5 - maximumLODLevel: 0 - streamingMipmapsActive: 0 - streamingMipmapsAddAllCameras: 1 - streamingMipmapsMemoryBudget: 512 - streamingMipmapsRenderersPerFrame: 512 - streamingMipmapsMaxLevelReduction: 2 - streamingMipmapsMaxFileIORequests: 1024 - particleRaycastBudget: 1024 - asyncUploadTimeSlice: 2 - asyncUploadBufferSize: 16 - asyncUploadPersistentBuffer: 1 - resolutionScalingFixedDPIFactor: 1 - excludedTargetPlatforms: [] - - serializedVersion: 2 - name: Ultra - pixelLightCount: 4 - shadows: 2 - shadowResolution: 2 - shadowProjection: 1 - shadowCascades: 4 - shadowDistance: 150 - shadowNearPlaneOffset: 3 - shadowCascade2Split: 0.33333334 - shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} - shadowmaskMode: 1 - blendWeights: 4 - textureQuality: 0 - anisotropicTextures: 2 - antiAliasing: 2 - softParticles: 1 - softVegetation: 1 - realtimeReflectionProbes: 1 - billboardsFaceCameraPosition: 1 - vSyncCount: 1 - lodBias: 2 - maximumLODLevel: 0 - streamingMipmapsActive: 0 - streamingMipmapsAddAllCameras: 1 - streamingMipmapsMemoryBudget: 512 - streamingMipmapsRenderersPerFrame: 512 - streamingMipmapsMaxLevelReduction: 2 - streamingMipmapsMaxFileIORequests: 1024 - particleRaycastBudget: 4096 - asyncUploadTimeSlice: 2 - asyncUploadBufferSize: 16 - asyncUploadPersistentBuffer: 1 - resolutionScalingFixedDPIFactor: 1 - excludedTargetPlatforms: [] - m_PerPlatformDefaultQuality: - Android: 2 - Lumin: 5 - GameCoreScarlett: 5 - GameCoreXboxOne: 5 - Nintendo 3DS: 5 - Nintendo Switch: 5 - PS4: 5 - PS5: 5 - Stadia: 5 - Standalone: 5 - WebGL: 3 - Windows Store Apps: 5 - XboxOne: 5 - iPhone: 2 - tvOS: 2 diff --git a/Obfuz/ProjectSettings/SceneTemplateSettings.json b/Obfuz/ProjectSettings/SceneTemplateSettings.json deleted file mode 100644 index 5e97f83..0000000 --- a/Obfuz/ProjectSettings/SceneTemplateSettings.json +++ /dev/null @@ -1,121 +0,0 @@ -{ - "templatePinStates": [], - "dependencyTypeInfos": [ - { - "userAdded": false, - "type": "UnityEngine.AnimationClip", - "defaultInstantiationMode": 0 - }, - { - "userAdded": false, - "type": "UnityEditor.Animations.AnimatorController", - "defaultInstantiationMode": 0 - }, - { - "userAdded": false, - "type": "UnityEngine.AnimatorOverrideController", - "defaultInstantiationMode": 0 - }, - { - "userAdded": false, - "type": "UnityEditor.Audio.AudioMixerController", - "defaultInstantiationMode": 0 - }, - { - "userAdded": false, - "type": "UnityEngine.ComputeShader", - "defaultInstantiationMode": 1 - }, - { - "userAdded": false, - "type": "UnityEngine.Cubemap", - "defaultInstantiationMode": 0 - }, - { - "userAdded": false, - "type": "UnityEngine.GameObject", - "defaultInstantiationMode": 0 - }, - { - "userAdded": false, - "type": "UnityEditor.LightingDataAsset", - "defaultInstantiationMode": 0 - }, - { - "userAdded": false, - "type": "UnityEngine.LightingSettings", - "defaultInstantiationMode": 0 - }, - { - "userAdded": false, - "type": "UnityEngine.Material", - "defaultInstantiationMode": 0 - }, - { - "userAdded": false, - "type": "UnityEditor.MonoScript", - "defaultInstantiationMode": 1 - }, - { - "userAdded": false, - "type": "UnityEngine.PhysicMaterial", - "defaultInstantiationMode": 0 - }, - { - "userAdded": false, - "type": "UnityEngine.PhysicsMaterial2D", - "defaultInstantiationMode": 0 - }, - { - "userAdded": false, - "type": "UnityEngine.Rendering.PostProcessing.PostProcessProfile", - "defaultInstantiationMode": 0 - }, - { - "userAdded": false, - "type": "UnityEngine.Rendering.PostProcessing.PostProcessResources", - "defaultInstantiationMode": 0 - }, - { - "userAdded": false, - "type": "UnityEngine.Rendering.VolumeProfile", - "defaultInstantiationMode": 0 - }, - { - "userAdded": false, - "type": "UnityEditor.SceneAsset", - "defaultInstantiationMode": 1 - }, - { - "userAdded": false, - "type": "UnityEngine.Shader", - "defaultInstantiationMode": 1 - }, - { - "userAdded": false, - "type": "UnityEngine.ShaderVariantCollection", - "defaultInstantiationMode": 1 - }, - { - "userAdded": false, - "type": "UnityEngine.Texture", - "defaultInstantiationMode": 0 - }, - { - "userAdded": false, - "type": "UnityEngine.Texture2D", - "defaultInstantiationMode": 0 - }, - { - "userAdded": false, - "type": "UnityEngine.Timeline.TimelineAsset", - "defaultInstantiationMode": 0 - } - ], - "defaultDependencyTypeInfo": { - "userAdded": false, - "type": "", - "defaultInstantiationMode": 1 - }, - "newSceneOverride": 0 -} \ No newline at end of file diff --git a/Obfuz/ProjectSettings/TagManager.asset b/Obfuz/ProjectSettings/TagManager.asset deleted file mode 100644 index 1c92a78..0000000 --- a/Obfuz/ProjectSettings/TagManager.asset +++ /dev/null @@ -1,43 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!78 &1 -TagManager: - serializedVersion: 2 - tags: [] - layers: - - Default - - TransparentFX - - Ignore Raycast - - - - Water - - UI - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - m_SortingLayers: - - name: Default - uniqueID: 0 - locked: 0 diff --git a/Obfuz/ProjectSettings/TimeManager.asset b/Obfuz/ProjectSettings/TimeManager.asset deleted file mode 100644 index 558a017..0000000 --- a/Obfuz/ProjectSettings/TimeManager.asset +++ /dev/null @@ -1,9 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!5 &1 -TimeManager: - m_ObjectHideFlags: 0 - Fixed Timestep: 0.02 - Maximum Allowed Timestep: 0.33333334 - m_TimeScale: 1 - Maximum Particle Timestep: 0.03 diff --git a/Obfuz/ProjectSettings/UnityConnectSettings.asset b/Obfuz/ProjectSettings/UnityConnectSettings.asset deleted file mode 100644 index a88bee0..0000000 --- a/Obfuz/ProjectSettings/UnityConnectSettings.asset +++ /dev/null @@ -1,36 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!310 &1 -UnityConnectSettings: - m_ObjectHideFlags: 0 - serializedVersion: 1 - m_Enabled: 0 - m_TestMode: 0 - m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events - m_EventUrl: https://cdp.cloud.unity3d.com/v1/events - m_ConfigUrl: https://config.uca.cloud.unity3d.com - m_DashboardUrl: https://dashboard.unity3d.com - m_TestInitMode: 0 - CrashReportingSettings: - m_EventUrl: https://perf-events.cloud.unity3d.com - m_Enabled: 0 - m_LogBufferSize: 10 - m_CaptureEditorExceptions: 1 - UnityPurchasingSettings: - m_Enabled: 0 - m_TestMode: 0 - UnityAnalyticsSettings: - m_Enabled: 0 - m_TestMode: 0 - m_InitializeOnStartup: 1 - m_PackageRequiringCoreStatsPresent: 0 - UnityAdsSettings: - m_Enabled: 0 - m_InitializeOnStartup: 1 - m_TestMode: 0 - m_IosGameId: - m_AndroidGameId: - m_GameIds: {} - m_GameId: - PerformanceReportingSettings: - m_Enabled: 0 diff --git a/Obfuz/ProjectSettings/VFXManager.asset b/Obfuz/ProjectSettings/VFXManager.asset deleted file mode 100644 index 3a95c98..0000000 --- a/Obfuz/ProjectSettings/VFXManager.asset +++ /dev/null @@ -1,12 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!937362698 &1 -VFXManager: - m_ObjectHideFlags: 0 - m_IndirectShader: {fileID: 0} - m_CopyBufferShader: {fileID: 0} - m_SortShader: {fileID: 0} - m_StripUpdateShader: {fileID: 0} - m_RenderPipeSettingsPath: - m_FixedTimeStep: 0.016666668 - m_MaxDeltaTime: 0.05 diff --git a/Obfuz/ProjectSettings/VersionControlSettings.asset b/Obfuz/ProjectSettings/VersionControlSettings.asset deleted file mode 100644 index dca2881..0000000 --- a/Obfuz/ProjectSettings/VersionControlSettings.asset +++ /dev/null @@ -1,8 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!890905787 &1 -VersionControlSettings: - m_ObjectHideFlags: 0 - m_Mode: Visible Meta Files - m_CollabEditorSettings: - inProgressEnabled: 1 diff --git a/Obfuz/ProjectSettings/XRSettings.asset b/Obfuz/ProjectSettings/XRSettings.asset deleted file mode 100644 index 482590c..0000000 --- a/Obfuz/ProjectSettings/XRSettings.asset +++ /dev/null @@ -1,10 +0,0 @@ -{ - "m_SettingKeys": [ - "VR Device Disabled", - "VR Device User Alert" - ], - "m_SettingValues": [ - "False", - "False" - ] -} \ No newline at end of file diff --git a/Obfuz/README.md b/Obfuz/README.md deleted file mode 100644 index 952c515..0000000 --- a/Obfuz/README.md +++ /dev/null @@ -1,55 +0,0 @@ -# Obfuz - -这是一个极简的Obfuz示例项目。 - -## 配置 - -点击 `Obfuz/Settings...`菜单打开ObfuzSettings页面。 -可以看到`Assembly Settings`里已经添加了两个混淆程序集:Assembly-CSharp和Obfuz.Runtime(没错,Obfuz自身也是可混淆的)。 - -## 构建 - -打开`Build Settings`,运行`Build`或`Build and Run`即可。 - -## 查看混淆文件 - -混淆后的文件在`Library/Obfuz/{buildTarget}/ObfuscatedAssemblies目录下。 - -使用IlSpy打开`Assembly-CSharp.dll`,混淆后的Bootstrap类代码变成这样: - -```csharp - -using System; -using $a; -using $A; -using UnityEngine; - -// Token: 0x02000002 RID: 2 -public class Bootstrap : MonoBehaviour -{ - // Token: 0x06000001 RID: 1 RVA: 0x000030F0 File Offset: 0x000012F0 - [RuntimeInitializeOnLoadMethod(2)] - private static void SetUpStaticSecret() - { - Debug.Log("SetUpStaticSecret begin"); - global::$A.$C<$c>.$L = new $a.$A(Resources.Load("Obfuz/defaultStaticSecretKey").bytes); - Debug.Log("SetUpStaticSecret end"); - } - - // Token: 0x06000002 RID: 2 RVA: 0x0000311F File Offset: 0x0000131F - public int $a(int 1, int 1) - { - return 1 + 1; - } - - // Token: 0x06000003 RID: 3 RVA: 0x00003204 File Offset: 0x00001404 - private void Start() - { - int num = global::$e.$A(this, global::$e.$a(global::$d.$A, 0, 117, -2060908889, global::$A.$C<$c>.$d(-1139589574, 85, -452785586)), global::$e.$a(global::$d.$A, 4, 138, -1222258517, global::$A.$C<$c>.$d(-1139589574, 85, -452785586)), global::$A.$C<$c>.$d(1757957431, 242, 760404455)); - global::$e.$b(string.Format(global::$D.$a, num), global::$A.$C<$c>.$d(1718597184, 154, 2114032877)); - } -} - - - -```