fix: change obfuscation relative metadata to public for compatible with mono because mono has more strict access validation, it will raise FieldAccessException if access a private field.
parent
56374bbac7
commit
274f827493
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -9,7 +9,8 @@ namespace Obfuz
|
|||
|
||||
public static class EncryptionService<T> 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
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue