public void ConfigureServices(IServiceCollection services) { services .AddRazorPages() .AddApplicationPart(Assembly.GetEntryAssembly()) .AddApplicationPart(Assembly.GetExecutingAssembly()); services .AddSignalR() .AddNewtonsoftJsonProtocol(); services.AddSingleton( provider => new Processor.x86.CSharpExecutor.Cpu( ConfigurationDto.Processor, provider.GetRequiredService <IHostApplicationLifetime>().ApplicationStopping)); services.AddSingleton(p => MethodInfoCollection.Load(ConfigurationDto.BinToCSharp)); services.AddSingleton( p => { var definitionCollection = new DefinitionCollection(); definitionCollection.AddDefinitionsFromAssembly(typeof(Definitions).Assembly); return(definitionCollection); }); services.AddSingleton( p => new RawProgramMain( p.GetRequiredService <Processor.x86.CSharpExecutor.Cpu>(), ConfigurationDto, p.GetRequiredService <MethodInfoCollection>(), p.GetRequiredService <DefinitionCollection>(), p)); }
/// <inheritdoc /> public void GetMethod(out MethodInfoDto methodInfo, out Action method) { while (true) { var fullAddress = cs[eip]; if (fullAddress == 0) { throw new InvalidOperationException("Запрос метода по нулевому указателю."); } var info = FindExactMethod(fullAddress); if (info != null) { methodInfo = info.MethodInfo; method = info.Action; return; } // Всё-таки декодируем. var files = DecodeCurrentMethod(); // Compile and load. try { NonBlockingConsole.WriteLine($"Компилирование новых методов."); var dllPath = Compile(files); NonBlockingConsole.WriteLine($"Загрузка '{dllPath}'."); var assembly = Assembly.LoadFile(dllPath); DefinitionCollection.AddDefinitionsFromAssembly(assembly); ConnectDecodedMethods(assembly); } catch (Exception ex) { NonBlockingConsole.WriteLine(ex); throw; } } //throw new InvalidOperationException("Метод не найдена."); }