コード例 #1
0
        public virtual void Notify(IDelegateTask delegateTask)
        {
            IProcessEngineServices services       = delegateTask.ProcessEngineServices;
            IRuntimeService        runtimeService = services.RuntimeService;

            runtimeService.SetVariable(delegateTask.ExecutionId, "taskListenerCalled", true);
        }
コード例 #2
0
ファイル: Session.cs プロジェクト: LeaderEnemyBoss/ELCP
 public override void OnError(Amplitude.Unity.Session.Session.ErrorLevel errorLevel, string text, int errorCode)
 {
     base.OnError(errorLevel, text, errorCode);
     if (!MessagePanel.Instance.IsVisible)
     {
         string text2 = text;
         if (text2.StartsWith("%"))
         {
             text2 = AgeLocalizer.Instance.LocalizeString(text);
         }
         text2 = text2.Replace("$ErrorCode", errorCode.ToString("X4"));
         MessagePanel.Instance.Show(text2, delegate(object A_1, MessagePanelResultEventArgs A_2)
         {
             if (base.SteamIDLobby == null || !base.SteamIDLobby.IsValid)
             {
                 IRuntimeService service = Services.GetService <IRuntimeService>();
                 if (service != null)
                 {
                     Diagnostics.Log("Switching to RuntimeState_OutGame.");
                     service.Runtime.FiniteStateMachine.PostStateChange(typeof(RuntimeState_OutGame), new object[0]);
                 }
             }
         }, (MessagePanelType)errorLevel);
     }
 }
コード例 #3
0
ファイル: Application.cs プロジェクト: LeaderEnemyBoss/ELCP
        private IEnumerator LoadRuntime()
        {
            IRuntimeService runtimeService = Services.GetService <IRuntimeService>();

            if (runtimeService == null)
            {
                Application.Quit();
                yield break;
            }
            runtimeService.RuntimeException += this.RuntimeService_RuntimeException;
            runtimeService.RuntimeChange    += this.RuntimeService_RuntimeChange;
            List <RuntimeModuleConfiguration> configuration = new List <RuntimeModuleConfiguration>();

            string[] commandLineArgs = Environment.GetCommandLineArgs();
            if (commandLineArgs != null && commandLineArgs.Length > 1)
            {
                for (int index = 1; index < commandLineArgs.Length; index++)
                {
                    if (commandLineArgs[index].Equals("+mod", StringComparison.InvariantCultureIgnoreCase))
                    {
                        if (index >= commandLineArgs.Length - 1)
                        {
                            Diagnostics.LogError("Missing argument while parsing the command line, (+mod command requires additional module argument)...");
                            Application.Quit();
                            yield break;
                        }
                        RuntimeModuleConfiguration runtimeModuleConfiguration = new RuntimeModuleConfiguration(commandLineArgs[index]);
                        configuration.Add(runtimeModuleConfiguration);
                    }
                }
            }
            runtimeService.LoadRuntime(configuration.ToArray());
            yield break;
        }
コード例 #4
0
        /// <summary>
        ///
        /// </summary>
        public ProcessEngineWrapper(ProcessInstanceConverter processInstanceConverter,
                                    PageableProcessInstanceRepositoryService pageableProcessInstanceService,
                                    TaskConverter taskConverter,
                                    PageableTaskRepositoryService pageableTaskService,
                                    MessageProducerActivitiEventListener listener,
                                    SecurityPoliciesApplicationService securityService,
                                    AuthenticationWrapper authenticationWrapper,
                                    IApplicationEventPublisher eventPublisher,
                                    IProcessEngine processEngine,
                                    HistoricInstanceConverter historicInstanceConverter,
                                    ILoggerFactory loggerFactory)
        {
            this.processEngine                  = processEngine;
            this.processInstanceConverter       = processInstanceConverter;
            this.runtimeService                 = processEngine.RuntimeService;
            this.pageableProcessInstanceService = pageableProcessInstanceService;
            this.taskService         = processEngine.TaskService;
            this.taskConverter       = taskConverter;
            this.pageableTaskService = pageableTaskService;
            this.historyService      = processEngine.HistoryService;
#warning 暂时不处理事件侦听
            //this.runtimeService.addEventListener(listener);
            this.securityService           = securityService;
            this.repositoryService         = processEngine.RepositoryService;
            this.authenticationWrapper     = authenticationWrapper;
            this.eventPublisher            = eventPublisher;
            this.historicInstanceConverter = historicInstanceConverter;
            logger = loggerFactory.CreateLogger <ProcessEngineWrapper>();
        }
コード例 #5
0
ファイル: InjectPhase.cs プロジェクト: yeethawe/RzyProtector
        // Token: 0x06000195 RID: 405 RVA: 0x0006142C File Offset: 0x0005F62C
        protected override void Execute(ConfuserContext context, ProtectionParameters parameters)
        {
            bool flag = parameters.Targets.Any <IDnlibDef>();

            if (flag)
            {
                bool flag2 = !UTF8String.IsNullOrEmpty(context.CurrentModule.Assembly.Culture);
                if (flag2)
                {
                    context.Logger.DebugFormat("Skipping resource encryption for satellite assembly '{0}'.", new object[]
                    {
                        context.CurrentModule.Assembly.FullName
                    });
                }
                else
                {
                    ICompressionService service   = context.Registry.GetService <ICompressionService>();
                    INameService        name      = context.Registry.GetService <INameService>();
                    IMarkerService      marker    = context.Registry.GetService <IMarkerService>();
                    IRuntimeService     service2  = context.Registry.GetService <IRuntimeService>();
                    REContext           recontext = new REContext
                    {
                        Random    = context.Registry.GetService <IRandomService>().GetRandomGenerator(base.Parent.Id),
                        Context   = context,
                        Module    = context.CurrentModule,
                        Marker    = marker,
                        DynCipher = context.Registry.GetService <IDynCipherService>(),
                        Name      = name
                    };
                    recontext.Mode = parameters.GetParameter <Mode>(context, context.CurrentModule, "mode", Mode.Normal);
                    Mode mode = recontext.Mode;
                    if (mode != Mode.Normal)
                    {
                        if (mode != Mode.Dynamic)
                        {
                            throw new UnreachableException();
                        }
                        recontext.ModeHandler = new DynamicMode();
                    }
                    else
                    {
                        recontext.ModeHandler = new NormalMode();
                    }
                    MethodDef runtimeDecompressor = service.GetRuntimeDecompressor(context.CurrentModule, delegate(IDnlibDef member)
                    {
                        name.MarkHelper(member, marker, (Protection)this.Parent);
                        bool flag3 = member is MethodDef;
                        if (flag3)
                        {
                            ProtectionParameters.GetParameters(context, member).Remove(this.Parent);
                        }
                    });
                    this.InjectHelpers(context, service, service2, recontext);
                    this.MutateInitializer(recontext, runtimeDecompressor);
                    MethodDef methodDef = context.CurrentModule.GlobalType.FindStaticConstructor();
                    methodDef.Body.Instructions.Insert(0, Instruction.Create(OpCodes.Call, recontext.InitMethod));
                    new MDPhase(recontext).Hook();
                }
            }
        }
コード例 #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DataPropertiesViewModel"/> class.
        /// </summary>
        /// <param name="runtime">The runtime.</param>
        /// <exception cref="ArgumentNullException"><paramref name="runtime"/> is null.</exception>
        public DataPropertiesViewModel(IRuntimeService runtime)
        {
            runtime.NotNull(nameof(runtime));

            Log.Debug("Creating view model instance");
            Runtime = runtime;
        }
コード例 #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SettingsViewModel" /> class.
        /// </summary>
        /// <param name="runtime">The runtime service.</param>
        public SettingsViewModel(IRuntimeService runtime)
        {
            Runtime     = runtime;
            DisplayName = string.Format("{0:D} - {0}", Protocols.Core);

            ConnectionPicker = new ConnectionPickerViewModel(runtime, ConnectionTypes.Etp)
            {
                AutoConnectEnabled  = true,
                OnConnectionChanged = OnConnectionChanged
            };

            EtpProtocols = new BindableCollection <EtpProtocolItem>
            {
                new EtpProtocolItem(Protocols.ChannelStreaming, "consumer"),
                new EtpProtocolItem(Protocols.ChannelStreaming, "producer", true),
                new EtpProtocolItem(Protocols.ChannelDataFrame, "consumer"),
                new EtpProtocolItem(Protocols.ChannelDataFrame, "producer"),
                new EtpProtocolItem(Protocols.Discovery, "store", true),
                new EtpProtocolItem(Protocols.Store, "store", true),
                new EtpProtocolItem(Protocols.StoreNotification, "store", true),
                new EtpProtocolItem(Protocols.GrowingObject, "store", true),
                new EtpProtocolItem(Protocols.DataArray, "store"),
                new EtpProtocolItem(Protocols.WitsmlSoap, "store", isEnabled: false),
            };
        }
コード例 #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RigsMonitor" /> class.
        /// </summary>
        /// <param name="runtime">The runtime.</param>
        /// <param name="context">The context.</param>
        public RigsMonitor(IRuntimeService runtime, IWitsmlContext context)
        {
            Context = context;
            Runtime = runtime;

            Task.Run(() => QueryRigsAsync());
        }
コード例 #9
0
ファイル: Runtime.cs プロジェクト: yp19910928/diagnostics
        public Runtime(ITarget target, IRuntimeService runtimeService, ClrInfo clrInfo, int id)
        {
            Trace.TraceInformation($"Creating runtime #{id} {clrInfo.Flavor} {clrInfo}");
            _target         = target;
            _runtimeService = runtimeService;
            _clrInfo        = clrInfo;
            Id = id;

            RuntimeType = RuntimeType.Unknown;
            if (clrInfo.Flavor == ClrFlavor.Core)
            {
                RuntimeType = RuntimeType.NetCore;
            }
            else if (clrInfo.Flavor == ClrFlavor.Desktop)
            {
                RuntimeType = RuntimeType.Desktop;
            }
            RuntimeModule = target.Services.GetService <IModuleService>().GetModuleFromBaseAddress(clrInfo.ModuleInfo.ImageBase);

            ServiceProvider = new ServiceProvider();
            ServiceProvider.AddService <ClrInfo>(clrInfo);
            ServiceProvider.AddServiceFactoryWithNoCaching <ClrRuntime>(() => CreateRuntime());

            target.OnFlushEvent.Register(() => {
                _clrRuntime?.DacLibrary.DacPrivateInterface.Flush();
            });
        }
コード例 #10
0
 public virtual void setUp()
 {
     authRule.CreateUserAndGroup("userId", "groupId");
     runtimeService = engineRule.RuntimeService;
     managementService = engineRule.ManagementService;
     historyService = engineRule.HistoryService;
 }
コード例 #11
0
 //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
 //ORIGINAL LINE: @Before public void initServices()
 public virtual void initServices()
 {
     runtimeService             = engineRule.RuntimeService;
     repositoryService          = engineRule.RepositoryService;
     managementService          = engineRule.ManagementService;
     processEngineConfiguration = engineRule.ProcessEngineConfiguration;
 }
コード例 #12
0
        public virtual void init()
        {
            runtimeService = engineRule.RuntimeService;
            historyService = engineRule.HistoryService;

            authRule.CreateUserAndGroup("demo", "groupId");
        }
コード例 #13
0
 public virtual void initServices()
 {
     runtimeService    = processEngineRule.RuntimeService;
     taskService       = processEngineRule.TaskService;
     historyService    = processEngineRule.HistoryService;
     managementService = processEngineRule.ManagementService;
 }
コード例 #14
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void Execute(org.Camunda.bpm.Engine.Delegate.IDelegateExecution execution) throws Exception
        public virtual void Execute(IBaseDelegateExecution execution)
        {
            IProcessEngineServices services       = ((IDelegateExecution)execution).ProcessEngineServices;
            IRuntimeService        runtimeService = services.RuntimeService;

            runtimeService.SetVariable(execution.Id, "serviceTaskCalled", true);
        }
コード例 #15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ConnectionViewModel" /> class.
        /// </summary>
        /// <param name="runtime">The runtime service.</param>
        /// <param name="connectionType">Type of the connection.</param>
        public ConnectionViewModel(IRuntimeService runtime, ConnectionTypes connectionType)
        {
            _log.Debug("Creating View Model");

            Runtime          = runtime;
            ConnectionType   = connectionType;
            ConnectionNames  = new string[0];
            IsEtpConnection  = connectionType == ConnectionTypes.Etp;
            IsSoapConnection = connectionType == ConnectionTypes.Witsml;

            DisplayName       = $"{_dialogTitlePrefix} - {ConnectionType.ToString().ToUpper()} Connection";
            CanTestConnection = true;

            WebSocketTypes = new BindableCollection <WebSocketType>(Enum.GetValues(typeof(WebSocketType)).OfType <WebSocketType>());

            SecurityProtocols = new BindableCollection <SecurityProtocolItem>
            {
                new SecurityProtocolItem(SecurityProtocolType.Tls12, "TLS 1.2"),
                new SecurityProtocolItem(SecurityProtocolType.Tls11, "TLS 1.1"),
                new SecurityProtocolItem(SecurityProtocolType.Tls, "TLS 1.0"),
                new SecurityProtocolItem(SecurityProtocolType.Ssl3, "SSL 3.0")
            };

            RevealablePasswordBox      = new RevealablePasswordBoxViewModel();
            RevealableProxyPasswordBox = new RevealablePasswordBoxViewModel {
                Revealable = false
            };
        }
コード例 #16
0
 public virtual void setUp()
 {
     authRule.CreateUserAndGroup("userId", "groupId");
     repositoryService          = engineRule.RepositoryService;
     runtimeService             = engineRule.RuntimeService;
     processEngineConfiguration = engineRule.ProcessEngineConfiguration;
 }
コード例 #17
0
        public virtual bool AreJobsAvailable(IRuntimeService runtimeService)
        {
            var jobManager = runtimeService.GetManager <IJobManager>();

            return(!jobManager.FindJobsByExecutable().IsEmpty());
            //return !managementService.CreateJobQuery() /*.Executable()*/.ToList().IsEmpty();
        }
コード例 #18
0
 //JAVA TO C# CONVERTER TODO Resources.Task: Most Java annotations will not have direct .NET equivalent attributes:
 //ORIGINAL LINE: @After public void tearDown()
 public virtual void tearDown()
 {
     authRule.DeleteUsersAndGroups();
     repositoryService          = null;
     runtimeService             = null;
     processEngineConfiguration = null;
 }
コード例 #19
0
ファイル: MvcBootstrapper.cs プロジェクト: daywrite/OBear
        /// <summary>
        /// 将插件本地程序集添加到ASP.NET页面预编译引用程序集列表。这个方法一般是内部使用。
        /// </summary>
        /// <param name="bundleSymbolicName">插件唯一名称。</param>
        /// <returns>返回插件所有本地程序集。</returns>
        public virtual ICollection <Assembly> AddReferencedAssemblies(string bundleSymbolicName)
        {
            //Check if this bundle still exist or not.
            BundleData bundleData = BundleRuntime.Instance.GetFirstOrDefaultService <IBundleInstallerService>().GetBundleDataByName(bundleSymbolicName);

            if (bundleData == null)
            {
                FileLogUtility.Debug(string.Format("Bundle '{0}' does not exist when trying to add its assemblies to referenced assemblies.",
                                                   bundleSymbolicName));
                return(new List <Assembly>());
            }

            using (ReaderWriterLockHelper.CreateReaderLock(CacheLock))
            {
                //already registered its assembiles
                ICollection <Assembly> registeredItems;
                if (RegisteredBunldeCache.TryGetValue(bundleData, out registeredItems))
                {
                    return(registeredItems);
                }

                IServiceManager serviceContainer = BundleRuntime.Framework.ServiceContainer;
                IRuntimeService service          = serviceContainer.GetFirstOrDefaultService <IRuntimeService>();
                List <Assembly> assemlbies       = service.LoadBundleAssembly(bundleSymbolicName);
                FileLogUtility.Debug(string.Format("Add the assemblies of bundle '{0}' to top level referenced assemblies.", bundleSymbolicName));
                assemlbies.ForEach(AddReferencedAssembly);
                //cache the assemblies
                using (ReaderWriterLockHelper.CreateWriterLock(CacheLock))
                {
                    RegisteredBunldeCache[bundleData] = assemlbies;
                }

                return(assemlbies);
            }
        }
コード例 #20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StreamingViewModel"/> class.
 /// </summary>
 public StreamingViewModel(IRuntimeService runtime)
 {
     Runtime               = runtime;
     DisplayName           = string.Format("{0:D} - Streaming", Protocols.ChannelStreaming);
     Channels              = new List <ChannelMetadataRecord>();
     ChannelStreamingInfos = new List <ChannelStreamingInfo>();
 }
コード例 #21
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FamilyVersionObjectsViewModel"/> class.
        /// </summary>
        /// <param name="runtime">The runtime.</param>
        /// <exception cref="ArgumentNullException"><paramref name="runtime"/> is null.</exception>
        public FamilyVersionObjectsViewModel(IRuntimeService runtime)
        {
            runtime.NotNull(nameof(runtime));

            Log.Debug("Creating view model instance");
            Runtime = runtime;
        }
コード例 #22
0
        public virtual void setup()
        {
            runtimeService    = rule.RuntimeService;
            repositoryService = rule.RepositoryService;

            deploymentId = repositoryService.CreateDeployment().AddClasspathResource(BPMN_FILE).Deploy().Id;
        }
コード例 #23
0
 public Etp12ChannelStreamingProxy(IRuntimeService runtime, string dataSchemaVersion, Action <string> log) : base(runtime, dataSchemaVersion, log)
 {
     _random  = new Random(246);
     Channels = new List <ChannelMetadataRecord>();
     //ChannelStreamingInfo = new List<ChannelStreamingInfo>();
     ChannelStreamingInfo = new Dictionary <long, object>();
 }
コード例 #24
0
 private void OnQuitResult(object sender, MessagePanelResultEventArgs e)
 {
     if (e.Result == MessagePanelResult.Yes)
     {
         IRuntimeService service = Services.GetService <IRuntimeService>();
         if (service != null)
         {
             ISessionService service2 = Services.GetService <ISessionService>();
             Diagnostics.Assert(service2 != null);
             Diagnostics.Assert(service2.Session != null);
             Diagnostics.Assert(service.Runtime != null);
             Diagnostics.Assert(service.Runtime.FiniteStateMachine != null);
             if (!TutorialManager.IsActivated)
             {
                 int          lobbyData = service2.Session.GetLobbyData <int>("NumberOfMajorFactions", 0);
                 EmpireInfo[] array     = new EmpireInfo[lobbyData];
                 for (int i = 0; i < lobbyData; i++)
                 {
                     array[i] = EmpireInfo.Read(service2.Session, i);
                 }
                 service.Runtime.FiniteStateMachine.PostStateChange(typeof(RuntimeState_OutGame), new object[]
                 {
                     "GameEnded",
                     array
                 });
             }
             else
             {
                 service.Runtime.FiniteStateMachine.PostStateChange(typeof(RuntimeState_OutGame), new object[0]);
             }
         }
     }
 }
コード例 #25
0
ファイル: EtpProxy.cs プロジェクト: KaneKing20/Bay
 public EtpProxy(IRuntimeService runtime, string dataSchemaVersion, Action <string> log)
 {
     TaskRunner        = new TaskRunner();
     Runtime           = runtime;
     DataSchemaVersion = dataSchemaVersion;
     Log = log;
 }
コード例 #26
0
 public virtual void setUp()
 {
     authRule.CreateUserAndGroup("userId", "groupId");
     runtimeService         = engineRule.RuntimeService;
     managementService      = engineRule.ManagementService;
     invocationsPerBatchJob = engineRule.ProcessEngineConfiguration.InvocationsPerBatchJob;
 }
コード例 #27
0
        public MainViewModel(IRuntimeService runtime)
        {
            Runtime       = runtime;
            DisplayName   = EtpSettings.EtpSubProtocolName;
            DisplayName   = _pluginDisplayName;
            Resources     = new BindableCollection <ResourceViewModel>();
            _channels     = new ConcurrentDictionary <int, JToken>();
            _protocolTabs = new List <IScreen>();

            Model = new Models.EtpSettings()
            {
                ApplicationName    = Assembly.GetEntryAssembly().GetAssemblyName(),
                ApplicationVersion = _pluginVersion
            };

            Details = new TextEditorViewModel(runtime, "JavaScript", true)
            {
                ShowWriteSettings  = true,
                IsScrollingEnabled = true
            };
            Messages = new TextEditorViewModel(runtime, "JavaScript", true)
            {
                ShowWriteSettings  = true,
                IsScrollingEnabled = true
            };
            DataObject = new TextEditorViewModel(runtime, "XML", true)
            {
                ShowWriteSettings    = true,
                IsPrettyPrintAllowed = true
            };
        }
 public virtual void setUp()
 {
     runtimeService             = engineRule.RuntimeService;
     identityService            = engineRule.IdentityService;
     managementService          = engineRule.ManagementService;
     processEngineConfiguration = engineRule.ProcessEngineConfiguration;
 }
コード例 #29
0
        void InjectHelpers(ConfuserContext context, ICompressionService compression, IRuntimeService rt, REContext moduleCtx)
        {
            var rtName = context.Packer != null ? "Confuser.Runtime.Resource_Packer" : "Confuser.Runtime.Resource";
            IEnumerable <IDnlibDef> members = Core.Helpers.InjectHelper.Inject(rt.GetRuntimeType(rtName), context.CurrentModule.GlobalType, context.CurrentModule);

            foreach (IDnlibDef member in members)
            {
                if (member.Name == "Initialize")
                {
                    moduleCtx.InitMethod = (MethodDef)member;
                }
                moduleCtx.Name.MarkHelper(member, moduleCtx.Marker, (Protection)Parent);
            }

            var dataType = new TypeDefUser("", moduleCtx.Name.RandomName(), context.CurrentModule.CorLibTypes.GetTypeRef("System", "ValueType"));

            dataType.Layout      = TypeAttributes.ExplicitLayout;
            dataType.Visibility  = TypeAttributes.NestedPrivate;
            dataType.IsSealed    = true;
            dataType.ClassLayout = new ClassLayoutUser(1, 0);
            moduleCtx.DataType   = dataType;
            context.CurrentModule.GlobalType.NestedTypes.Add(dataType);
            moduleCtx.Name.MarkHelper(dataType, moduleCtx.Marker, (Protection)Parent);

            moduleCtx.DataField = new FieldDefUser(moduleCtx.Name.RandomName(), new FieldSig(dataType.ToTypeSig()))
            {
                IsStatic     = true,
                HasFieldRVA  = true,
                InitialValue = new byte[0],
                Access       = FieldAttributes.CompilerControlled
            };
            context.CurrentModule.GlobalType.Fields.Add(moduleCtx.DataField);
            moduleCtx.Name.MarkHelper(moduleCtx.DataField, moduleCtx.Marker, (Protection)Parent);
        }
コード例 #30
0
 protected StreamingViewModelBase(IRuntimeService runtime)
 {
     Runtime              = runtime;
     DisplayName          = "Streaming";
     Channels             = new BindableCollection <ChannelMetadataViewModel>();
     ToggleChannelCommand = new DelegateCommand(x => ToggleSelectedChannel());
 }
コード例 #31
0
ファイル: InjectPhase.cs プロジェクト: EmilZhou/ConfuserEx
		void InjectHelpers(ConfuserContext context, ICompressionService compression, IRuntimeService rt, REContext moduleCtx) {
			var rtName = context.Packer != null ? "Confuser.Runtime.Resource_Packer" : "Confuser.Runtime.Resource";
			IEnumerable<IDnlibDef> members = InjectHelper.Inject(rt.GetRuntimeType(rtName), context.CurrentModule.GlobalType, context.CurrentModule);
			foreach (IDnlibDef member in members) {
				if (member.Name == "Initialize")
					moduleCtx.InitMethod = (MethodDef)member;
				moduleCtx.Name.MarkHelper(member, moduleCtx.Marker, (Protection)Parent);
			}

			var dataType = new TypeDefUser("", moduleCtx.Name.RandomName(), context.CurrentModule.CorLibTypes.GetTypeRef("System", "ValueType"));
			dataType.Layout = TypeAttributes.ExplicitLayout;
			dataType.Visibility = TypeAttributes.NestedPrivate;
			dataType.IsSealed = true;
			dataType.ClassLayout = new ClassLayoutUser(1, 0);
			moduleCtx.DataType = dataType;
			context.CurrentModule.GlobalType.NestedTypes.Add(dataType);
			moduleCtx.Name.MarkHelper(dataType, moduleCtx.Marker, (Protection)Parent);

			moduleCtx.DataField = new FieldDefUser(moduleCtx.Name.RandomName(), new FieldSig(dataType.ToTypeSig())) {
				IsStatic = true,
				HasFieldRVA = true,
				InitialValue = new byte[0],
				Access = FieldAttributes.CompilerControlled
			};
			context.CurrentModule.GlobalType.Fields.Add(moduleCtx.DataField);
			moduleCtx.Name.MarkHelper(moduleCtx.DataField, moduleCtx.Marker, (Protection)Parent);
		}
コード例 #32
0
 public static void SetCurrentService(IRuntimeService service)
 {
     Service = service;
 }
コード例 #33
0
ファイル: InjectPhase.cs プロジェクト: GavinHwa/ConfuserEx
        private void InjectHelpers(ConfuserContext context, ICompressionService compression, IRuntimeService rt, CEContext moduleCtx)
        {
            IEnumerable<IDnlibDef> members = InjectHelper.Inject(rt.GetRuntimeType("Confuser.Runtime.Constant"), context.CurrentModule.GlobalType, context.CurrentModule);
            foreach (IDnlibDef member in members) {
                if (member.Name == "Get") {
                    context.CurrentModule.GlobalType.Remove((MethodDef)member);
                    continue;
                }
                if (member.Name == "b")
                    moduleCtx.BufferField = (FieldDef)member;
                else if (member.Name == "Initialize")
                    moduleCtx.InitMethod = (MethodDef)member;
                moduleCtx.Name.MarkHelper(member, moduleCtx.Marker);
            }
            ProtectionParameters.GetParameters(context, moduleCtx.InitMethod).Remove(Parent);

            var dataType = new TypeDefUser("", moduleCtx.Name.RandomName(), context.CurrentModule.CorLibTypes.GetTypeRef("System", "ValueType"));
            dataType.Layout = TypeAttributes.ExplicitLayout;
            dataType.Visibility = TypeAttributes.NestedPrivate;
            dataType.IsSealed = true;
            moduleCtx.DataType = dataType;
            context.CurrentModule.GlobalType.NestedTypes.Add(dataType);
            moduleCtx.Name.MarkHelper(dataType, moduleCtx.Marker);

            moduleCtx.DataField = new FieldDefUser(moduleCtx.Name.RandomName(), new FieldSig(dataType.ToTypeSig())) {
                IsStatic = true,
                Access = FieldAttributes.CompilerControlled
            };
            context.CurrentModule.GlobalType.Fields.Add(moduleCtx.DataField);
            moduleCtx.Name.MarkHelper(moduleCtx.DataField, moduleCtx.Marker);

            MethodDef decoder = rt.GetRuntimeType("Confuser.Runtime.Constant").FindMethod("Get");
            moduleCtx.Decoders = new List<Tuple<MethodDef, DecoderDesc>>();
            for (int i = 0; i < moduleCtx.DecoderCount; i++) {
                MethodDef decoderInst = InjectHelper.Inject(decoder, context.CurrentModule);
                for (int j = 0; j < decoderInst.Body.Instructions.Count; j++) {
                    Instruction instr = decoderInst.Body.Instructions[j];
                    var method = instr.Operand as IMethod;
                    var field = instr.Operand as IField;
                    if (instr.OpCode == OpCodes.Call &&
                        method.DeclaringType.Name == "Mutation" &&
                        method.Name == "Value") {
                        decoderInst.Body.Instructions[j] = Instruction.Create(OpCodes.Sizeof, new GenericMVar(0).ToTypeDefOrRef());
                    }
                    else if (instr.OpCode == OpCodes.Ldsfld &&
                             method.DeclaringType.Name == "Constant") {
                        if (field.Name == "b") instr.Operand = moduleCtx.BufferField;
                        else throw new UnreachableException();
                    }
                }
                context.CurrentModule.GlobalType.Methods.Add(decoderInst);
                moduleCtx.Name.MarkHelper(decoderInst, moduleCtx.Marker);
                ProtectionParameters.GetParameters(context, decoderInst).Remove(Parent);

                var decoderDesc = new DecoderDesc();

                decoderDesc.StringID = (byte)(moduleCtx.Random.NextByte() & 3);

                do decoderDesc.NumberID = (byte)(moduleCtx.Random.NextByte() & 3); while (decoderDesc.NumberID == decoderDesc.StringID);

                do decoderDesc.InitializerID = (byte)(moduleCtx.Random.NextByte() & 3); while (decoderDesc.InitializerID == decoderDesc.StringID || decoderDesc.InitializerID == decoderDesc.NumberID);

                MutationHelper.InjectKeys(decoderInst,
                                          new[] { 0, 1, 2 },
                                          new int[] { decoderDesc.StringID, decoderDesc.NumberID, decoderDesc.InitializerID });
                decoderDesc.Data = moduleCtx.ModeHandler.CreateDecoder(decoderInst, moduleCtx);
                moduleCtx.Decoders.Add(Tuple.Create(decoderInst, decoderDesc));
            }
        }