Example #1
0
        public static void Main(string[] args)
        {
            int    targetPid;
            string targetExe;

            ConsoleAsker.GetTargetExeOrPid(args, out targetExe, out targetPid);

            try
            {
                var dllToInject       = "CreateFileHookLib.dll";
                var notifyClient      = new NotifyClient();
                var formattableString = RemoteInjector.InjectDll(dllToInject, targetExe, ref targetPid, out _channelName, notifyClient);
                if (!string.IsNullOrEmpty(formattableString))
                {
                    Console.WriteLine(formattableString);
                }
                Console.WriteLine("<Press any key to exit>");
                Console.ReadKey();
            }
            catch (Exception extInfo)
            {
                Console.WriteLine("There was an error while connecting to target:\r\n{0}", extInfo);
                Console.WriteLine("<Press any key to exit>");
                Console.ReadKey();
            }
        }
Example #2
0
        public static void CreateProcessWHooker_ProcessCreated(object sender, HookedEventArgs e)
        {
            var processId = Convert.ToInt32(e.Entries["DwProcessId"]);

            Console.WriteLine($"Process ID (PID): {processId}");
            Console.WriteLine($"Process Handle: {e.Entries["HProcess"]}");
            Console.WriteLine("Process Thread : " + e.Entries["HThread"]);
            IntPtr threadHandle = (IntPtr)e.Entries["HThread"];
            var    dllToInject  = _dllWithHook;
            var    notifyClient = new NotifyClient();
            string channelName;
            var    formattableString =
                RemoteInjector.InjectDll(dllToInject, "", ref processId, out channelName, notifyClient);

            if (!string.IsNullOrEmpty(formattableString))
            {
                Console.WriteLine(formattableString);
            }
        }