public IntManglerPlugin(IContextImpl context) : base(context) { Rng = context.Plugin <IRngPlugin>().Get(NetfuserFactory.IntManglerName); _finj = context.FeatureInjector(); _demanglers = new List <ValueDemangler>(); }
internal Embedding(IContextImpl context, string name, IReadable readable) { Name = name; Context = context; Readable = readable; Properties = new Dictionary <string, string>(); }
public RSAEncryption(IContextImpl context, string name, int bits, RSAParameters privkey, RSAParameters pubkey) : base(context) { Name = name; _bits = bits; _private = privkey; _public = pubkey; }
public FeatureInjectorPlugin(IContextImpl context) : base(context) { Rng = context.Plugin <IRngPlugin>().Get(NetfuserFactory.FeatureInjectorName); _injectableTypes = new List <InjectableType>(); _ns = context.Plugin <INaming>(); }
public EmbedderPlugin(IContextImpl context, string name) : base(context) { Name = name; _entries = new List <Embedding>(); _uniqueNames = new HashSet <string>(); _index = new EmbeddedResource(name, new ReadableDataReaderFactory(this, name), 0, 0); }
public MetadataManglerPlugin(IContextImpl context, MetadataManglerOptions options) : base(context) { _options = options; _root = new MetadataElement.Root(); _rng = context.Plugin <IRngPlugin>().Get(NetfuserFactory.MetadataManglerName); _ns = context.Plugin <INaming>(); }
internal WillMangle(IContextImpl context, TypeMapping tm, MethodDef m, Instruction i) : base(context) { TypeMapping = tm; Method = m; Instruction = i; String = (string)i.Operand; }
protected AbstractPlugin(IContextImpl context) { _context = context; var ln = new StringBuilder(GetType().Name); if (this is INamedPlugin np) { ln.Append('-').Append(np.Name); } Logger = context.Logger.GetLogger(ln.ToString()); }
internal AssemblyWriterPlugin(IContextImpl context, DirectoryInfo dest) : base(context) { if (dest != null) { context.OutputFolder = dest; } else { dest = context.OutputFolder; } _dest = dest ?? throw new ArgumentException(nameof(dest)); }
public IEnumerable <Var> GetIOVars(ValueManglingFeature feature, IContextImpl ctx) { foreach (var a in _arglist) { yield return(new Var.Arg(Method.Parameters[a])); } var t = Type; while (t != null) { foreach (var f in TD.Get(feature, t).Fields) { yield return(new Var.Fld(f, fld => ctx.BasicImporter.Import(fld))); } t = t.Base; } }
public Injectable(IContextImpl context, string name) : base(context, name) { _codecs = new List <ICodec>(); var finj = context.FeatureInjector(); _demanglers = new List <ValueDemangler>(); _subscription = Context.OfType <FeatureInjectorEvent.HaveInjectableTypes>().Subscribe(ime => { _feature = new ValueManglingFeature(Context.TargetModule.CorLibTypes.String); var q = Math.Max(Context.MappedTypes.Count / 100, Mangler.Rng.NextInt32(50, 100)); foreach (var node in finj.Rate(_feature).OrderByDescending(r => r.Score) .SelectMany(ToNodes).Take(q)) { _demanglers.Add(node); } }); }
public Naming(IContextImpl context) : base(context) { _nodes = new Dictionary <TypeDef, INsNode>(); context.OfType <NetfuserEvent.TypeMapped>().Subscribe(ev => { MetaType preserve = 0; var source = ev.Mapping.Source; if (source.IsGlobalModuleType) { preserve |= MetaType.NamespaceAndType; } if (source.IsComImport() || source.IsDelegate) { preserve |= MetaType.Member; } if (source.IsRuntimeSpecialName || source.IsSpecialName) { preserve |= MetaType.All; } if (_preserveNamesIfImplements.Count > 0) { preserve |= source.Interfaces .Select(i => _preserveNamesIfImplements.TryGetValue(i.Interface.FullName, out var v) ? v : 0) .Aggregate(MetaType.None, (a, v) => a | v); } if (_preserveNamesIfAnnotatedBy.Count > 0) { preserve |= source.CustomAttributes .Select(ca => _preserveNamesIfAnnotatedBy.TryGetValue(ca.Constructor.DeclaringType.FullName, out var v) ? v : 0).Aggregate(MetaType.None, (a, v) => a | v); } Preserve(ev.Mapping, preserve); }); }
internal CFManglerPlugin(IContextImpl context, CFMangleOptions options) : base(context) { Options = options; Rng = context.Plugin <IRngPlugin>().Get(NetfuserFactory.CodeFlowManglerName); }
protected Subscribed(IContextImpl context) : base(context) { _subscription = context.Subscribe(Handle); }
internal ResNameFixer(IContextImpl context) : base(context) { }
public FrequencySplitter(IContextImpl context, FrequencySplitterOptions options) : base(context) { Options = options; }
public LzmaCompression(IContextImpl context) : base(context) { }
public IEnumerable <Var> GetIOVars(InjectableMethod r, IContextImpl ctx) { return(((Injectable)r).GetIOVars(this, ctx)); }
public ProjectLoader(IContextImpl context, string path, ProjectOptions options) : base(context) { _options = options ?? new ProjectOptions(); if (_options.Configuration == null) { _options.Configuration = Context.DebugMode ? "Debug" : "Release"; } _allProjects = new Dictionary <string, Project>(); _allReferences = new HashSet <string>(); _allPackageReferences = new HashSet <string>(); if (File.Exists(path)) { _root = GetProject(path); } else if (Directory.Exists(path)) { var files = Directory.GetFiles(path, "*.csproj"); if (files.Length == 0) { throw context.Error($"no .csproj files found in {path}"); } if (files.Length > 1) { throw context.Error($"multiple .csproj files found in {path}"); } _root = GetProject(files[0]); } else { throw context.Error($"path does not exist: {path}"); } if (context.OutputFolder == null) { context.OutputFolder = new DirectoryInfo(Path.Combine(Path.GetDirectoryName(_root.AssemblyPath), NetfuserFactory.NetfuserName)); } if (_options.Building != Building.No) { var builderPath = _options.BuilderPath; if (string.IsNullOrEmpty(builderPath)) { // using https://github.com/Microsoft/vswhere/wiki/Find-MSBuild var vswhere = Environment.ExpandEnvironmentVariables( @"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"); if (File.Exists(vswhere)) { var buildTools = Utils.RunProcess(vswhere, "-latest -prerelease -products * -requires Microsoft.Component.MSBuild -property installationPath") .StdOut.ReadLines().FirstOrDefault(); if (!string.IsNullOrEmpty(buildTools) && Directory.Exists(buildTools)) { var msbuild = Path.Combine(buildTools, @"MSBuild\Current\Bin\MSBuild.exe"); if (!File.Exists(msbuild)) { msbuild = Path.Combine(buildTools, @"MSBuild\15.0\Bin\MSBuild.exe"); } if (File.Exists(msbuild)) { var ver = Utils.RunProcess(msbuild, "/version").StdOut.ReadLines().LastOrDefault(); if (Version.TryParse(ver, out _msbuildVersion)) { builderPath = msbuild; _buildTool = BuildTool.Msbuild; } } } if (string.IsNullOrEmpty(builderPath)) { var devenv = Utils.RunProcess(vswhere, "-latest -prerelease -property productPath") .StdOut; if (File.Exists(devenv)) { builderPath = devenv; _buildTool = BuildTool.Devenv; } } } } if (string.IsNullOrEmpty(builderPath) || _buildTool == BuildTool.None) { throw context.Error( "could not find msbuild.exe or devenv.exe on this computer, please specify path in options or set Building to No"); } _builderPath = builderPath; } }
protected CFMangleMethod(IContextImpl context, string name) : base(context) { Name = name; Mangler = context.Plugin <ICFMangler>() ?? throw context.Error($"add ${nameof(ICFMangler)} to the context first"); }
protected StringMangleMethod(IContextImpl context, string name) : base(context) { Name = name; Mangler = context.Plugin <IStringMangler>(() => new StringMangler(context)); }
public AsInt(IContextImpl context) : base(context, "int") { }
public DelegateCodec(IContextImpl context, Func <TV, TM> mangler, Func <TM, TV> demangler) { Context = context; Mangler = mangler; Demangler = demangler; }
public Switch(IContextImpl context) : base(context, NetfuserFactory.CFManglerSwitchName) { }
internal VTablePlugin(IContextImpl context) : base(context) { VTables = DnextFactory.NewVTables(); }
public AsIs(IContextImpl context) : base(context, "asis") { }
public Jump(IContextImpl context) : base(context, NetfuserFactory.CFManglerJumpName) { }
public MapWriterPluginPlugin(IContextImpl context, string dest) : base(context) { _dest = dest ?? "names.xml"; }
public DepsJsonPlugin(IContextImpl context) : base(context) { }
/// <summary> /// Constructs new feature request /// </summary> /// <param name="context">Netfuser context</param> /// <param name="emitter">IL emitter</param> public FeatureRequest(IContextImpl context, IILEmitter emitter) { Context = context; Emitter = emitter; CallStack = new Stack <MethodDef>(); }