bool InjectPayload(Process proc, string injectionLibrary) { string channelName = null; RemoteHooking.IpcCreateServer <InjectorInterface>(ref channelName, WellKnownObjectMode.Singleton); var parameter = new EntryPointParameters { Message = "Test Message", HostProcessId = RemoteHooking.GetCurrentProcessId(), ScreenWidth = 640, ScreenHeight = 480 }; try { RemoteHooking.Inject( proc.Id, InjectionOptions.Default | InjectionOptions.DoNotRequireStrongName, injectionLibrary, injectionLibrary, channelName, parameter ); return(true); } catch (Exception ex) { return(false); } }
static async Task Main(string[] args) { const string serviceId = "action-2"; var builder = new ConfigurationBuilder() .AddJsonFile("appsettings.json") .AddEnvironmentVariables(); var configuration = builder.Build(); var web1 = new WebApi1Client(ServiceHttpTransportParameters.FromConfig(configuration, "web1")); var af2 = new AzureFunctionsBusServiceClient(ServiceBusTransportParameters.FromConfig(configuration, "af2")); var services = new ServiceCollection(); ConfigureServices(services); services.AddSingleton(web1); services.AddSingleton(af2); IServiceProvider provider = services.BuildServiceProvider(); var microservice = new MessageBusMicroservice(new MicroserviceOptions <MessageBusMicroserviceOptions>() { ServiceId = serviceId, CommandsRegistry = provider.GetRequiredService <IMicroserviceCommandsRegistry>(), TransportOptions = new MessageBusMicroserviceOptions { EntryPointParameters = EntryPointParameters.FromConfig(configuration, serviceId) } }); microservice.Start(); Console.WriteLine($"Service '{serviceId}' is working, press any key to exit..."); Console.ReadKey(); }
static async Task Main(string[] args) { const string serviceId = "action-3"; var builder = new ConfigurationBuilder() .AddJsonFile("appsettings.json") .AddEnvironmentVariables(); var configuration = builder.Build(); var services = new ServiceCollection(); ConfigureServices(services); IServiceProvider provider = services.BuildServiceProvider(); var microservice = new MessageBusMicroservice(new MicroserviceOptions <MessageBusMicroserviceOptions>() { ServiceId = serviceId, CommandsRegistry = provider.GetRequiredService <IMicroserviceCommandsRegistry>(), TransportOptions = new MessageBusMicroserviceOptions { EntryPointParameters = EntryPointParameters.FromConfig(configuration, serviceId) } }); microservice.Start(); Console.WriteLine($"Service '{serviceId}' is working, press any key to exit..."); Console.WriteLine("Just getting all the data being posted to me and typing it here."); Console.ReadKey(); }
private static unsafe void InitialiseParameters(EntryPointParameters *parameters) { if (parameters != (void *)0) { if (!parameters->IsLatestVersion()) { Logger?.LogWriteLineAsync($"Bootstrapper (Reloaded.Mod.Loader.Bootstrapper.dll) is does not match expected version (Expected Version: {EntryPointParameters.CurrentVersion}, Actual Version: {parameters->Version}). Please upgrade the bootstrapper. If you are using ASI Loader re-deploy, otherwise copy Reloaded.Mod.Loader.Bootstrapper.dll.", Logger.ColorWarning); } _parameters = EntryPointParameters.Copy(parameters); } else { Logger?.LogWriteLineAsync($"Expected EntryPointParameters but did not receive any. Bootstrapper (Reloaded.Mod.Loader.Bootstrapper.dll) is likely outdated. Please upgrade by copying a newer version of Reloaded.Mod.Loader.Bootstrapper.dll if integrating with another mod loader or re-deploy ASI Loader (if using ASI Loader).", Logger.ColorWarning); } }
/// <summary> /// Copies data from the passed in native struct to a new struct. /// This allows for old bootstrappers to work with more recent parameters. /// </summary> /// <param name="pointer">Pointer passed in from native code.</param> public static unsafe EntryPointParameters Copy(EntryPointParameters *pointer) { // Copy whole if possible. if (pointer->IsLatestVersion()) { return(*pointer); } // Otherwise construct from available size. EntryPointParameters result = default; // Version 1 if (pointer->Version >= 1) { result.Version = pointer->Version; result.Flags = pointer->Flags; } return(result); }