Ejemplo n.º 1
0
            public HookRegistration(HookRegistrationRecord hook, IDcsMarshalledObserver observer, HookManager parent)
            {
                Contract.Requires(observer != null);

                this.HWnd    = hook.HWnd;
                this.Parent  = parent;
                this.Handler = hook.CreateHandler();
                this.Target  = new DcsMarshalledProxy(observer, hook.ResultType);
            }
Ejemplo n.º 2
0
        public ForeignHook <T> HookWindow <T>(IntPtr hWnd, Type tHandler, object oParam = null)
            where T : class
        {
            Contract.Requires(tHandler != null);
            Contract.Requires(typeof(IMessageHookHandler <T>).IsAssignableFrom(tHandler));

            var source = new DcsMarshalledSource <T>();
            var record = HookRegistrationRecord.Create(hWnd, tHandler, typeof(T), oParam);
            var rh     = Hook.RegisterHook(record, source.ComProxy);

            return(new ForeignHook <T>(rh, source));
        }
Ejemplo n.º 3
0
        public IWindowHook AddRegistration(HookRegistrationRecord hook, IDcsMarshalledObserver observer)
        {
            Contract.Requires(observer != null);

            var newReg = new HookRegistration(hook, observer, this);

            lock (syncRegistrations)
            {
                Registrations = Registrations.SetItem(hook.HWnd, newReg);
                Debug.WriteLine("Added hook for {0:x8}", hook.HWnd.ToInt32());

                if (Hook == null)
                {
                    Debug.WriteLine("Starting ITP Hook for thread {0}", mainThreadId);
                    Hook = new HookLifetimeManager(Hook_HookCallback);
                }
            }
            return(newReg);
        }
Ejemplo n.º 4
0
 public IWindowHook RegisterHook(HookRegistrationRecord hook, IDcsMarshalledObserver observer)
 {
     return(HookManager.AddRegistration(hook, observer));
 }