Example #1
0
        public void TestAfterInject()
        {
            var eventCalled = false;

            IReflectionCache cache = new ReflectionCache();
            IBinder binder = new Binder();
            IInjector injector = new Injector(cache, binder);
            var instanceToInject = new MockClassVerySimple();

            injector.afterInject += delegate(IInjector source, ref object instance, ReflectedClass reflectedClass) {
                //The if below is just to avoid checking when injecting on MockIClass.
                if (reflectedClass.type != typeof(MockClassVerySimple)) return;

                Assert.AreEqual(injector, source);
                Assert.AreEqual(instanceToInject, instance);
                Assert.AreEqual(typeof(MockIClass), instanceToInject.field.GetType());

                eventCalled = true;
            };

            binder.Bind<IMockInterface>().To<MockIClass>();
            injector.Inject(instanceToInject);

            Assert.IsTrue(eventCalled);
        }
Example #2
0
        public async Task Launch(string arguments)
        {
            var tempDirPath = Path.Combine(Path.GetTempPath(), $"FortniteClient-Win64-Shipping_EAC.exe");

            if (!File.Exists("Platanium.dll"))
            {
                return;
            }

            arguments += $" {BaseArguments} -epiclocale=en -noeac -fromfl=be -fltoken=5dh74c635862g575778132fb -frombe";

            var fortniteDirectory = GetEpicInstallLocations().FirstOrDefault(i => i.AppName == "Fortnite")?.InstallLocation;

            try
            {
                var existingAntiCheatProcess = Process.GetProcessesByName("FortniteClient-Win64-Shipping_EAC")?.FirstOrDefault();

                if (existingAntiCheatProcess.MainModule.FileName == tempDirPath && existingAntiCheatProcess != null)
                {
                    existingAntiCheatProcess.Kill();
                    Thread.Sleep(200);
                }
            }
            catch { }

            if (!File.Exists(tempDirPath))
            {
                await new WebClient().DownloadFileTaskAsync("https://cdn.discordapp.com/attachments/788954437510496266/801534129652629514/FortniteClient-Win64-Shipping_EAC.exe", tempDirPath);
            }

            var clientProcess = new Process
            {
                StartInfo = new ProcessStartInfo(Path.Combine(fortniteDirectory, "FortniteGame\\Binaries\\Win64\\FortniteClient-Win64-Shipping.exe"), arguments)
                {
                    UseShellExecute = false,
                    CreateNoWindow  = true
                }
            };
            var antiCheatProcess = new Process
            {
                StartInfo = new ProcessStartInfo(tempDirPath, arguments)
                {
                    UseShellExecute = false,
                    CreateNoWindow  = true
                }
            };

            clientProcess.Start();
            antiCheatProcess.Start();

            Injector.Inject(clientProcess.Id, "Platanium.dll");
            Listener.Listen(Environment.GetCommandLineArgs());
            clientProcess.WaitForExit();

            antiCheatProcess.Kill();
            Thread.Sleep(200);

            File.Delete(tempDirPath);
        }
        protected override void OnInitialize()
        {
            PrepareTransactionManager = Injector.Inject(new PrepareTransactionManager());

            state = LedgerService.State.CreateListener();
            RegisterWaitHandle(state.CancelEvent, HandleLedgerStateChanged, true);
            // load keys from file
        }
Example #4
0
        public void NonOptionalFieldInjectionThrowsExceptionIfNotPossible()
        {
            Injector injector = UniInjectUtils.CreateInjector();

            NeedsNonOptionalFieldInjectionNonOptional needsInjection = new NeedsNonOptionalFieldInjectionNonOptional();

            Assert.Throws <InjectionException>(delegate { injector.Inject(needsInjection); });
        }
Example #5
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddMvc();
     Injector.Inject((t1, t2) => {
         services.AddTransient(t1, t2);
     });
     services.AddCors();
 }
Example #6
0
        public void Inject(int aProcessId, NetFramework aFrameworkVersion, IntPtr aMonoModule)
        {
            _readerTask = new Task(async() => await NamedPipeReader());
            _readerTask.Start();

            var handle = Native.OpenProcess(ProcessAccessRights.PROCESS_ALL_ACCESS, false, aProcessId);

            if (handle == IntPtr.Zero)
            {
                _log.Error("Failed to open process");
                return;
            }

            byte[] file;

            try
            {
                if (aFrameworkVersion == NetFramework.NET45)
                {
                    file = File.ReadAllBytes("./GHRUnityVRModNet45.dll");
                }
                else if (aFrameworkVersion == NetFramework.NET35)
                {
                    file = File.ReadAllBytes("./GHRUnityVRModNet35.dll");
                }
                else
                {
                    throw new ArgumentException($"Passed unusable framework version {aFrameworkVersion} to Inject");
                }
            }
            catch (IOException)
            {
                _log.Error($"Failed to read the mod file");
                return;
            }

            _isExecuting = true;
            _log.Info($"Injecting");

            using (Injector injector = new Injector(handle, aMonoModule))
            {
                try
                {
                    IntPtr asm = injector.Inject(file, "GHRUnityVRMod", "GHRUnityVRModFuncs", "Load");
                    _log.Info("Injection successful");
                }
                catch (InjectorException ie)
                {
                    _log.Error("Injection failed: " + ie.Message);
                }
                catch (Exception e)
                {
                    _log.Error("Injection failed (unknown error): " + e.Message);
                }
            }

            _isExecuting = false;
        }
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            IUsersData usersData = Injector.Inject();
            //await usersData.GetNames(@"https://jsonmock.hackerrank.com/api/article_users/search?page=");
            MainWindow mw = new MainWindow(Injector.Inject());

            mw.Show();
        }
Example #8
0
        protected override void OnInitialize()
        {
            server.OnReceive(OnReceive);
            server.OnClose(OnClose);

            Injector.Inject(this);
            Injector.Inject(dispatcher);
            server.Initialize();
        }
    private void CreateUiIssue(SongIssue issue)
    {
        EditorUiIssue uiIssue = Instantiate(issuePrefab, uiIssueContainer.transform);

        injector.Inject(uiIssue);
        uiIssue.Init(issue);

        PositionUiIssue(uiIssue, issue.StartBeat);
    }
Example #10
0
        private static void Inject(Injector injector, CommandLineArguments args)
        {
            string assemblyPath, @namespace, className, methodName;

            byte[] assembly;

            if (args.GetStringArg("-a", out assemblyPath))
            {
                try {
                    assembly = File.ReadAllBytes(assemblyPath);
                } catch {
                    System.Console.WriteLine("Could not read the file " + assemblyPath);
                    return;
                }
            }
            else
            {
                System.Console.WriteLine("No assembly specified");
                return;
            }

            args.GetStringArg("-n", out @namespace);

            if (!args.GetStringArg("-c", out className))
            {
                System.Console.WriteLine("No class name specified");
                return;
            }

            if (!args.GetStringArg("-m", out methodName))
            {
                System.Console.WriteLine("No method name specified");
                return;
            }

            using (injector) {
                IntPtr remoteAssembly = IntPtr.Zero;

                try {
                    remoteAssembly = injector.Inject(assembly, @namespace, className, methodName);
                } catch (InjectorException ie) {
                    System.Console.WriteLine("Failed to inject assembly: " + ie);
                } catch (Exception exc) {
                    System.Console.WriteLine("Failed to inject assembly (unknown error): " + exc);
                }

                if (remoteAssembly == IntPtr.Zero)
                {
                    return;
                }

                System.Console.WriteLine($"{Path.GetFileName(assemblyPath)}: " +
                                         (injector.Is64Bit
                    ? $"0x{remoteAssembly.ToInt64():X16}"
                    : $"0x{remoteAssembly.ToInt32():X8}"));
            }
        }
Example #11
0
 public void Init()
 {
     Injector.Inject(new MockBindings());
     this.personalInfo = new PersonalInfo
     {
         PhoneNumber = "0731233233",
         Email       = "*****@*****.**"
     };
 }
Example #12
0
    public WarningDialog CreateWarningDialog(string title, string message)
    {
        FindCanvas();

        WarningDialog warningDialog = Instantiate(warningDialogPrefab, canvas.transform);

        injector.Inject(warningDialog);
        warningDialog.GetComponent <RectTransform>().anchoredPosition = Vector2.zero;
        if (title != null)
        {
            warningDialog.Title = title;
        }
        if (message != null)
        {
            warningDialog.Message = message;
        }
        return(warningDialog);
    }
Example #13
0
 private void btInject_Click(object sender, EventArgs e)
 {
     if (dataGridView1.SelectedRows.Count > 0)
     {
         Injector            injector         = new Injector();
         ProcessGUIPresenter processPresenter = (ProcessGUIPresenter)dataGridView1.SelectedRows[0].DataBoundItem;
         injector.Inject((uint)processPresenter.Id, txtDllToInject.Text);
     }
 }
        static void Main(string[] args)
        {
            IModule  module   = new Module();
            Injector injector = DependancyInjector.CreateInjector(module);

            IEngine engine = injector.Inject <Engine>();

            engine.Run();
        }
Example #15
0
        public bool Inject()
        {
            string assemblyPath = Path.Combine(_launcherPath, "ValheimTooler.dll");

            if (!File.Exists(assemblyPath))
            {
                return(DoError("Cannot found ValheimTooler.dll!"));
            }

            Injector injector;

            try
            {
                injector = new Injector("valheim");
            }
            catch (Exception exc)
            {
                return(DoError(exc.Message));
            }

            byte[] assembly;

            try
            {
                assembly = File.ReadAllBytes(assemblyPath);
            }
            catch (Exception exc)
            {
                return(DoError(exc.Message));
            }

            using (injector)
            {
                IntPtr remoteAssembly = IntPtr.Zero;

                try
                {
                    remoteAssembly = injector.Inject(assembly, "ValheimTooler", "Loader", "Init");
                }
                catch (InjectorException ie)
                {
                    return(DoError(ie.Message));
                }
                catch (Exception exc)
                {
                    return(DoError(exc.Message));
                }

                if (remoteAssembly == IntPtr.Zero)
                {
                    return(DoError("Unknown reason"));
                }

                return(true);
            }
        }
Example #16
0
    public void Init(PlayerProfile playerProfile, string voiceName, MicProfile micProfile)
    {
        this.PlayerProfile      = playerProfile;
        this.MicProfile         = micProfile;
        this.Voice              = GetVoice(songMeta, voiceName);
        this.playerUiController = Instantiate(playerUiControllerPrefab, playerUiArea.transform);
        this.childrenInjector   = CreateChildrenInjectorWithAdditionalBindings();

        // Inject all
        foreach (INeedInjection childThatNeedsInjection in GetComponentsInChildren <INeedInjection>())
        {
            childrenInjector.Inject(childThatNeedsInjection);
        }
        childrenInjector.Inject(playerUiController);

        // Init instances
        playerUiController.Init(PlayerProfile, MicProfile);
        PlayerScoreController.Init(Voice);
    }
Example #17
0
        private void button3_Click(object sender, EventArgs e)
        {
            InjectionResult result = Injector.Inject();

            if (result.Result == InjectionError.Success)
            {
                Sentinel.Start();
                MessageBox.Show("Injetado");
            }
        }
Example #18
0
        public void Test1()
        {
            IInjector injector = new Injector();

            injector.Inject(this);
            injector.ToValue(this);

            Assert.Equal(this, injector.Resolve <UnitTest1>());
            Assert.Equal(injector, injector.Resolve <IInjector>());
        }
Example #19
0
    private void CreatePlayerController(PlayerProfile playerProfile, MicProfile micProfile)
    {
        string           voiceName        = GetVoiceName(playerProfile);
        PlayerController playerController = GameObject.Instantiate <PlayerController>(playerControllerPrefab);

        sceneInjector.Inject(playerController);
        playerController.Init(playerProfile, voiceName, micProfile);

        PlayerControllers.Add(playerController);
    }
        public void Initialize(SignedLedger lastLedger, bool needToSetInitial)
        {
            Injector.Inject(this);
            needSetInitialLedger = needToSetInitial;
            var validatorManager = LiveService.ValidatorManager;

            SignedLedgerValidator = new SignedLedgerValidator(validatorManager.GetValidators(), validatorManager.Quorum, Network);

            InitializeLedger(lastLedger);
        }
Example #21
0
 public void Init()
 {
     Injector.Inject(new MockBindings());
     this.publisher = new Publisher
     {
         Name         = "Editura 2000",
         FoundingDate = new DateTime(2000, 1, 1),
         Headquarter  = "Bucuresti"
     };
 }
Example #22
0
        public void TestInjectorGet()
        {
            Injector.Inject(new MockBindings());
            var kernel = Injector.Kernel;

            var service = kernel.Get <IDomainService>();

            Assert.IsNotNull(service);
            Assert.IsNotNull(kernel);
        }
Example #23
0
        TelemetryClient ai = new TelemetryClient(); // or re-use an existing instance
        void Application_Start(object sender, EventArgs e)
        {
            Injector.Inject();
            //AppDomain.CurrentDomain.AssemblyResolve += MyAssemblyResolve;

            // Code that runs on application startup
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
        }
Example #24
0
        static int Main(string[] args)
        {
            #if DEBUG
            //I only have VS Express at home and this is the easiest way to debug
            //the unit tests since there's no test runner and I can't attach to NUnit.
            if (args.Length == 1 && args[0] == "/runtests")
            {
                return TestRunner.RunTests();
            }
            #endif
            var injector = new Injector();
            if (args.Length == 0 || args.Length > 3 || Regex.IsMatch(args[0], @"^((/|--?)(\?|h|help))$"))
            {
                PrintHelp();
                return 1;
            }

            Version version = Assembly.GetExecutingAssembly().GetName().Version;
            Console.WriteLine("InjectModuleInitializer v{0}.{1}", version.Major, version.Minor);
            Console.WriteLine("");

            string assemblyFile, moduleInitializer=null, keyfile=null;
            assemblyFile = args[args.Length - 1];

            for (int i = 0; i < args.Length - 1; i++)
            {
                var initMatch = Regex.Match(args[i], "^/m(oduleinitializer)?:(.+)", RegexOptions.IgnoreCase);
                if (initMatch.Success)
                {
                    moduleInitializer = initMatch.Groups[2].Value;
                }
                var keyMatch = Regex.Match(args[i], "^/k(eyfile)?:(.+)", RegexOptions.IgnoreCase);
                if (keyMatch.Success)
                {
                    keyfile = keyMatch.Groups[2].Value;
                }
                if (!initMatch.Success && !keyMatch.Success)
                {
                    Console.Error.WriteLine("error: Invalid argument '{0}', type InjectModuleInitializer /? for help", args[0]);
                    return 1;
                }
            }

            try
            {
                injector.Inject(assemblyFile, moduleInitializer, keyfile);
                Console.WriteLine("Module Initializer successfully injected in assembly " + assemblyFile);
                return 0;
            }
            catch (InjectionException ex)
            {
                Console.Error.WriteLine("error: " + ex.Message);
                return 1;
            }
        }
Example #25
0
 public void Init()
 {
     Injector.Inject(new MockBindings());
     this.domain = new Domain
     {
         Id             = 1,
         Name           = "Base Domain",
         EntireDomainId = null,
         ParentId       = null
     };
 }
Example #26
0
 public void Init()
 {
     Injector.Inject(new MockBindings());
     this.author = new Author
     {
         Name      = "Mark Manson",
         BirthDate = new DateTime(1970, 1, 1),
         Country   = "USA",
         Id        = 1
     };
 }
Example #27
0
        /// <summary>
        /// Associates the given <paramref name="implementation"/> with the target <paramref name="dependency"/>.
        /// </summary>
        /// <param name="dependency">The dependency that will be associated with the implementation.</param>
        /// <param name="implementation">The implementation itself.</param>
        public void AddService(IDependency dependency, IImplementation implementation)
        {
            var currentImplementation = implementation;

            if (Injector != null)
            {
                currentImplementation = Injector.Inject(dependency, currentImplementation);
            }

            _entries.Add(dependency, currentImplementation);
        }
Example #28
0
    private void StartEditingNoteText()
    {
        if (activeLyricsInputField != null)
        {
            return;
        }

        activeLyricsInputField = Instantiate(lyricsInputFieldPrefab, transform);
        injector.Inject(activeLyricsInputField);
        activeLyricsInputField.Init(this, Note.Text);
    }
Example #29
0
 private void Button_Click_1(object sender, RoutedEventArgs e)
 {
     try
     {
         Console.WriteLine(Injector.Inject("FL64", @"C:\Users\Kevin\Source\Repos\ComposerTools\x64\Debug\Injection.dll").ToString());
     }
     catch (Exception ex)
     {
         System.Windows.MessageBox.Show(ex.Message);
     }
 }
Example #30
0
        static void Main(string[] args)
        {
            //IServiceProvider serviceCollection = ConfigureServices();
            //IEngine engine = serviceCollection.GetService<IEngine>();
            //engine.Run();

            Injector injector = DependencyInjector.CreateInjector(new Module());
            Engine   engine   = injector.Inject <Engine>();

            engine.Run();
        }
        public void Inject()
        {
            Thread.Sleep(3100);
            int remotePlayProcessId = Injector.Inject(TARGET_PROCESS_NAME, INJECT_DLL_NAME);

            RemotePlayProcess = Process.GetProcessById(remotePlayProcessId);
            RemotePlayProcess.EnableRaisingEvents = true;
            RemotePlayProcess.Exited += (sender, args) => { Utility.ShowCursor(true); };

            Injector.Callback += OnReceiveData;
        }
Example #32
0
        public void TestRemoteThreadCreateVirtualAlloc()
        {
            // These options could also be passed in as optional parameters in the constructors

            RemoteThreadCreate injectionTechnique = new RemoteThreadCreate
            {
                api       = RemoteThreadCreate.APIS.CreateRemoteThread,
                suspended = false
            };

            VirtualAllocAllocationTechnique virtAlloc = new VirtualAllocAllocationTechnique(
                Win32.Kernel32.AllocationType.Commit | Win32.Kernel32.AllocationType.Reserve,
                Win32.Kernel32.MemoryProtection.ExecuteReadWrite,
                VirtualAllocAllocationTechnique.AllocationAPI.NtAllocateVirtualMemory,
                VirtualAllocAllocationTechnique.WriteAPI.NtWriteVirtualMemory
                );

            Process notepadProcess = Process.Start("notepad.exe");

            // Check the architecture of the process
            PICPayload payload = Host.IsWow64(notepadProcess) ? new PICPayload(Calc32bitShellCode) : new PICPayload(Calc64bitShellCode);

            virtAlloc.Allocate(payload, notepadProcess);

            // For every payload type, both the injectionTechnique and the allocationTechnique would have
            // overloads of Inject() and Allocate() that handle logic relevant to the specific payload type

            // Perform injection using the magic of OOP polymorphism and function overloads!
            Assert.IsTrue(Injector.Inject(payload, virtAlloc, injectionTechnique, notepadProcess));

            // If this code were for Process Hollowing, you could use the Allocate function in your Allocation Technique on your new, suspended process. Then overwrite the PEB appropriately.
            // Point being, Techniques like that that rely on complex logic beyond simple primitives would be implemented in separate classes, leveraging the Injection API as useful.

            Thread.Sleep(2000);
            notepadProcess.Kill();

            // VirtualAllocEx + WriteProcessMemory + CreateRemoteThread
            VirtualAllocAllocationTechnique virtAlloc2 = new VirtualAllocAllocationTechnique(
                Win32.Kernel32.AllocationType.Commit | Win32.Kernel32.AllocationType.Reserve,
                Win32.Kernel32.MemoryProtection.ExecuteReadWrite,
                VirtualAllocAllocationTechnique.AllocationAPI.VirtualAllocEx,
                VirtualAllocAllocationTechnique.WriteAPI.WriteProcessMemory
                );

            notepadProcess = Process.Start("notepad.exe");
            // Check the architecture of the process
            payload = Host.IsWow64(notepadProcess) ? new PICPayload(this.Calc32bitShellCode) : new PICPayload(this.Calc64bitShellCode);
            virtAlloc.Allocate(payload, notepadProcess);
            // Perform injection using the magic of OOP polymorphism and function overloads!
            Assert.IsTrue(Injector.Inject(payload, virtAlloc2, injectionTechnique, notepadProcess));

            Thread.Sleep(2000);
            notepadProcess.Kill();
        }