Beispiel #1
0
 private static void ReportError(RemoteInterface remoteInterface, Exception ex)
 {
     try
     {
         remoteInterface.ReportError(RemoteHooking.GetCurrentProcessId(), ex);
     }
     catch
     {
         // ignored
     }
 }
            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();
                }
            }