diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Data/ConstFieldAllocator.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Data/ConstFieldAllocator.cs index 7d90f8f..caf1725 100644 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Data/ConstFieldAllocator.cs +++ b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Data/ConstFieldAllocator.cs @@ -109,7 +109,7 @@ namespace Obfuz.Data _module.EnableTypeDefFindCache = true; } - var field = new FieldDefUser($"{ConstValues.ObfuzInternalSymbolNamePrefix}RVA_Value{_holderTypeDef.Fields.Count}", new FieldSig(GetTypeSigOfValue(value)), FieldAttributes.Static | FieldAttributes.Private | FieldAttributes.InitOnly); + 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 { diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Data/RvaDataAllocator.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Data/RvaDataAllocator.cs index ed8e748..3d4d8dd 100644 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Data/RvaDataAllocator.cs +++ b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/Data/RvaDataAllocator.cs @@ -106,7 +106,7 @@ namespace Obfuz.Data 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); + 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); } @@ -117,6 +117,7 @@ namespace Obfuz.Data 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; 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 index da44d86..1164db6 100644 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CallObfus/CallProxyAllocator.cs +++ b/Obfuz/Packages/com.code-philosophy.obfuz/Editor/ObfusPasses/CallObfus/CallProxyAllocator.cs @@ -126,7 +126,7 @@ namespace Obfuz.ObfusPasses.CallObfus } MethodDef methodDef = new MethodDefUser($"{ConstValues.ObfuzInternalSymbolNamePrefix}ProxyCall$Dispatch${_proxyTypeDef.Methods.Count}", methodSig, MethodImplAttributes.IL | MethodImplAttributes.Managed, - MethodAttributes.Static | MethodAttributes.Private); + MethodAttributes.Static | MethodAttributes.Public); methodDef.DeclaringType = _proxyTypeDef; return methodDef; } diff --git a/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/EncryptionService.cs b/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/EncryptionService.cs index bd6cd98..ccd0cea 100644 --- a/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/EncryptionService.cs +++ b/Obfuz/Packages/com.code-philosophy.obfuz/Runtime/EncryptionService.cs @@ -9,7 +9,8 @@ namespace Obfuz public static class EncryptionService where T : IEncryptionScope { - private static IEncryptor _encryptor; + // for compatibility with Mono because Mono will raise FieldAccessException when try access private field + public static IEncryptor _encryptor; public static IEncryptor Encryptor {