Beispiel #1
0
        public void Run(RemoteHooking.IContext inContext, string inChannelName)
        {
            try
            {
                //Create the DefaultDevice Hook
                var cci = new COMClassInfo(Type.GetTypeFromCLSID(new Guid(ComIIds.DEVICE_ENUMERATOR_CID)), typeof(IMultimediaDeviceEnumerator), "GetDefaultAudioEndpoint");
                cci.Query();

                var hook = LocalHook.Create(cci.MethodPointers[0], new DGetDefaultAudioEndpoint(GetDefaultAudioEndpoint), this);

                hook.ThreadACL.SetExclusiveACL(new[] { 0 });

                //Sleep here so the hook takes effect
                Thread.Sleep(50);

                //Signal the hook installed, and get the response from the server
                if (!_interface.HookInstalled())
                {
                    return;
                }
            }
            catch (Exception e)
            {
                ReportError(_interface, e);
                return;
            }

            try
            {
                while (!_interface.CanUnload())
                {
                    Thread.Sleep(200);
                }

                _interface.HookUninstalled(RemoteHooking.GetCurrentProcessId());
            }
            catch (Exception e)
            {
                ReportError(_interface, e);
            }
        }
            public void Run(RemoteHooking.IContext inContext, string inChannelName)
            {
                //Create the DefaultDevice Hook
                var cci = new ComClassQuery.ComClassInfo(typeof(MMDeviceEnumeratorComObject),
                                                         typeof(IMMDeviceEnumerator), "GetDefaultAudioEndpoint");

                ComClassQuery.Query(cci);

                var hook = LocalHook.Create(cci.FunctionPointer, new DGetDefaultAudioEndpoint(GetDefaultAudioEndpoint),
                                            this);

                hook.ThreadACL.SetExclusiveACL(new int[] {});

                try
                {
                    while (!Interface.CanUnload())
                    {
                        Thread.Sleep(1000);
                    }

                    hook.Dispose();
                }
                catch (Exception e)
                {
                    try
                    {
                        Interface.ReportError(RemoteHooking.GetCurrentProcessId(), e);
                    }
                    catch
                    {
                        //.NET Remoting timeout etc...
                    }
                }
                finally
                {
                    hook.Dispose();
                }
            }