예제 #1
0
        private static void Main(string[] args)
        {
            var log = SimpleLogManager.GetLogger(typeof(Program), "Main");

            log.Info(string.Format("Command line: {0} {1}",
                                   Process.GetCurrentProcess().ProcessName,
                                   string.Join(" ", args)));

            InjectorParameters parameters = null;

            try
            {
                parameters = new InjectorParameters(args);
            }
            catch (Exception ex)
            {
                log.Error(string.Format(
                              "Wrong command-line arguments: {0}.\r\n{1}", ex.Message, ex));
                return;
            }

            try
            {
                Injector.Launch(parameters);

                // Make sure we were injected; it not, retry with the main window handle.
                var process = GetProcessFromWindowHandle(parameters.WindowHandle);
                if (process != null && !CheckInjectedStatus(process) && process.MainWindowHandle != parameters.WindowHandle)
                {
                    log.Debug("Could not inject with current handle... retrying with MainWindowHandle");
                    parameters.WindowHandle = process.MainWindowHandle;
                    Injector.Launch(parameters);
                    CheckInjectedStatus(process);
                }
            }
            catch (Exception ex)
            {
                log.Error(string.Format(
                              "There was an error during the injection process: {0}.\r\n{1}", ex.Message, ex));
                return;
            }

            log.Debug(new string('-', 120));
        }
예제 #2
0
파일: Program.cs 프로젝트: odalet/Hawkeye2
        private static void Main(string[] args)
        {
            var log = SimpleLogManager.GetLogger(typeof(Program), "Main");
            log.Info(string.Format("Command line: {0} {1}",
                Process.GetCurrentProcess().ProcessName,
                string.Join(" ", args)));

            InjectorParameters parameters = null;
            try
            {
                parameters = new InjectorParameters(args);
            }
            catch (Exception ex)
            {
                log.Error(string.Format(
                    "Wrong command-line arguments: {0}.\r\n{1}", ex.Message, ex));
                return;
            }

            try
            {
                Injector.Launch(parameters);

                // Make sure we were injected; it not, retry with the main window handle.
                var process = GetProcessFromWindowHandle(parameters.WindowHandle);
                if (process != null && !CheckInjectedStatus(process) && process.MainWindowHandle != parameters.WindowHandle)
                {
                    log.Debug("Could not inject with current handle... retrying with MainWindowHandle");
                    parameters.WindowHandle = process.MainWindowHandle;
                    Injector.Launch(parameters);
                    CheckInjectedStatus(process);
                }
            }
            catch (Exception ex)
            {
                log.Error(string.Format(
                    "There was an error during the injection process: {0}.\r\n{1}", ex.Message, ex));
                return;
            }

            log.Debug(new string('-', 120));
        }