Ejemplo n.º 1
0
        /// <summary>
        /// Injects the hook into the specified process
        /// </summary>
        /// <param name="process">The process to inject into</param>
        public void Inject(Process process)
        {
            // Skip if the process is already hooked, or if there is no main window
            if (this.GraphicsInterface != null || this.SpeedHackInterface != null || (process == null || process.MainWindowHandle == IntPtr.Zero))
            {
                return;
            }

            String projectDirectory = Path.GetDirectoryName(ProjectExplorerViewModel.GetInstance().ProjectFilePath);
            String channelName      = null;

            this.GraphicsInterface  = GraphicsFactory.GetGraphicsInterface(projectDirectory);
            this.SpeedHackInterface = new SpeedHackInterface();

            // Initialize the IPC server, giving the server access to the interfaces defined here
            RemoteHooking.IpcCreateServer <HookClient>(ref channelName, WellKnownObjectMode.Singleton, this);

            try
            {
                // Inject DLL into target process
                RemoteHooking.Inject(
                    process.Id,
                    InjectionOptions.Default,
                    typeof(HookClient).Assembly.Location,
                    typeof(HookClient).Assembly.Location,
                    channelName,
                    projectDirectory);
            }
            catch (Exception ex)
            {
                throw new Exception("Unable to Inject:" + ex);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Uninjects the hook from the external process
 /// </summary>
 public void Uninject()
 {
     this.GraphicsInterface  = null;
     this.SpeedHackInterface = null;
 }