Example #1
0
        private static void Run(CliOptions cli)
        {
            uint pid     = GetProcessId(cli);
            var  process = new InjectableProcess(pid);

            Console.WriteLine("PID: " + pid);
            Console.WriteLine("Status: " + process.GetStatus());
            Console.WriteLine("Arch: " + process.GetArchitecture());

            if (process.GetStatus() != ProcessStatus.Ok)
            {
                Console.WriteLine("Cannot inject into target process: " + process.GetStatus());
                return;
            }

            var dllPath = CopyToTempPath(cli.DllPath);

            Console.WriteLine("Copied DLL to " + dllPath);

            process.Inject(dllPath, cli.EntryType, cli.EntryMethod);

            if (process.GetStatus() != ProcessStatus.Ok)
            {
                throw new Exception("Expected OK status for process");
            }
        }