示例#1
0
        private void Inject_Click(object sender, RoutedEventArgs e)
        {
            var result = Injector.Inject("csgo", $"{AppDomain.CurrentDomain.BaseDirectory}Tauros.dll");

            if (!result)
            {
                MessageBox.Show("Injection failed", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            Application.Current.Shutdown();
        }
示例#2
0
        private void Inject_Click(object sender, RoutedEventArgs e)
        {
            var result = Injector.Inject("csgo", $"{AppDomain.CurrentDomain.BaseDirectory}{_viewModel.Model.DllName}");

            if (!result)
            {
                VerifyIfFileExists();
                MessageBox.Show("Injection failed", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            Application.Current.Shutdown();
        }
示例#3
0
        private void WaitAndInject()
        {
            DateTime start    = DateTime.Now;
            string   procName = Path.GetFileNameWithoutExtension(this.GamePath);

            // Wait 30 seconds for Steam to get its shit together
            while ((DateTime.Now - start).Seconds < 30)
            {
                Process[] procs = Process.GetProcessesByName(procName);
                if (procs[0] == null)
                {
                    continue;
                }

                Process bl2Proc = procs[0];

                string currentDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

                // Yuck.
                try
                {
                    Injector.Inject(Path.Combine(currentDir, "BL2SDKDLL.dll"), bl2Proc);
                }
                catch (Win32Exception e)
                {
                    MessageBox.Show("Failed to inject SDK into Borderlands 2. Exception Message = " + e.Message + " Code = " + e.NativeErrorCode, "Failed to launch", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    //Win32.TerminateProcess(lpProcessInformation.hProcess, 0);
                    bl2Proc.Kill();

                    ResetButton();
                    return;
                }
                catch (Exception e)
                {
                    MessageBox.Show("Failed to inject SDK into Borderlands 2. Exception = " + e.Message, "Failed to launch", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    //Win32.TerminateProcess(lpProcessInformation.hProcess, 0);
                    bl2Proc.Kill();

                    ResetButton();
                    return;
                }

                foreach (ProcessThread thread in bl2Proc.Threads)
                {
                    IntPtr hThread = Win32.OpenThread(
                        Win32.ThreadAccessFlags.SuspendResume,
                        false,
                        (uint)thread.Id);

                    Win32.ResumeThread(hThread);
                    Win32.CloseHandle(hThread);
                }

                return;
            }

            MessageBox.Show("Failed to find game after 30 seconds", "Failed to launch", MessageBoxButtons.OK, MessageBoxIcon.Error);
            ResetButton();
        }