Exemple #1
0
 public static ComPtr <IDiaSymbol>[] GetSymbols(this IDiaSymbol symbol, SymTagEnum symTag, string name)
 {
     symbol.findChildren(symTag, name, 1, out IDiaEnumSymbols enumSymbols);
     using (ComPtr.Create(enumSymbols))
     {
         int n = enumSymbols.count;
         ComPtr <IDiaSymbol>[] result = new ComPtr <IDiaSymbol> [n];
         try
         {
             for (int i = 0; i < n; ++i)
             {
                 result[i] = ComPtr.Create(enumSymbols.Item((uint)i));
             }
         }
         catch
         {
             foreach (ComPtr <IDiaSymbol> item in result)
             {
                 item.Dispose();
             }
             throw;
         }
         return(result);
     }
 }
Exemple #2
0
        public static ComPtr <IDiaSymbol> GetTypeSymbol(this IDiaSymbol moduleSym, string name)
        {
            moduleSym.findChildren(SymTagEnum.SymTagUDT, name, 1, out IDiaEnumSymbols enumSymbols);
            using (ComPtr.Create(enumSymbols))
            {
                if (enumSymbols.count > 0)
                {
                    return(ComPtr.Create(enumSymbols.Item(0)));
                }
            }

            moduleSym.findChildren(SymTagEnum.SymTagTypedef, name, 1, out enumSymbols);
            using (ComPtr.Create(enumSymbols))
            {
                if (enumSymbols.count > 0)
                {
                    using (ComPtr <T> item = ComPtr.Create(enumSymbols.Item(0)))
                    {
                        return(ComPtr.Create(item.Object.type));
                    }
                }

                Debug.Fail("Type symbol '" + name + "' was not found.");
                throw new ArgumentException();
            }
        }
Exemple #3
0
 private void CreateInputHostManagerBroker()
 {
     using (var shellBroker = ComPtr <IImmersiveShellBroker> .Create(ComTypes.ImmersiveShellBrokerType))
     {
         Disposer.Dispose(ref _inputHostManagerBroker);
         _inputHostManagerBroker = new ComPtr <IInputHostManagerBroker>(shellBroker.Instance.GetInputHostManagerBroker());
     }
 }
Exemple #4
0
 private static void ToggleByCom()
 {
     try
     {
         using (var tipInvocation = ComPtr <ITipInvocation> .Create(ComTypes.TipInvocationType))
         {
             var window = NativeMethods.GetDesktopWindow();
             tipInvocation.Instance.Toggle(NativeMethods.GetDesktopWindow());
         }
     }
     catch (Exception e)
     {
     }
 }
Exemple #5
0
        public static ComPtr <IDiaSymbol> GetRootSymbol(DkmModule module)
        {
            ComPtr <IDiaSession> session;
            Guid diaSessionGuid = typeof(IDiaSession).GUID;

            using (session = ComPtr.Create((IDiaSession)module.GetSymbolInterface(diaSessionGuid))) {
                IDiaEnumSymbols enumerator;
                session.Ptr.findChildren(null, SymTagEnum.SymTagExe, null, 0, out enumerator);
                if (enumerator.count == 0)
                {
                    return(new ComPtr <IDiaSymbol>());
                }
                return(ComPtr.Create(enumerator.Item(0)));
            }
        }
Exemple #6
0
        public static ComPtr <IDiaSymbol> FindChildSymbol(ComPtr <IDiaSymbol> parent, SymTagEnum tag, string name)
        {
            var result = new ComPtr <IDiaSymbol>();

            IDiaEnumSymbols enumerator;

            parent.Ptr.findChildren(tag, name, 1, out enumerator);
            using (ComPtr.Create(enumerator)) {
                if (enumerator.count == 0)
                {
                    return(new ComPtr <IDiaSymbol>());
                }

                result = ComPtr.Create(enumerator.Item((uint)0));
            }

            return(result);
        }
Exemple #7
0
        public static ComPtr <IDiaSymbol> GetSymbol(this IDiaSymbol symbol, SymTagEnum symTag, string name, Predicate <IDiaSymbol> filter = null)
        {
            ComPtr <IDiaSymbol> result = new ComPtr <IDiaSymbol>();

            symbol.findChildren(symTag, name, 1, out IDiaEnumSymbols enumSymbols);
            using (ComPtr.Create(enumSymbols))
            {
                int n = enumSymbols.count;
                if (n == 0)
                {
                    Debug.Fail("Symbol '" + name + "' was not found.");
                    throw new ArgumentException();
                }

                try
                {
                    for (int i = 0; i < n; ++i)
                    {
                        using (ComPtr <T> item = ComPtr.Create(enumSymbols.Item((uint)i)))
                        {
                            if (filter == null || filter(item.Object))
                            {
                                if (result.Object == null)
                                {
                                    result = item.Detach();
                                }
                                else
                                {
                                    Debug.Fail("Found more than one symbol named '" + name + "' and matching the filter.");
                                    throw new ArgumentException();
                                }
                            }
                        }
                    }
                }
                catch
                {
                    result.Dispose();
                    throw;
                }
            }

            return(result);
        }
        private bool GetInputHostManagerBroker()
        {
            bool ret = false;

            if (_inputHostManagerBroker != null)
            {
                Disposer.Dispose(ref _inputHostManagerBroker);
            }
            try
            {
                using (var shellBroker = ComPtr <IImmersiveShellBroker> .Create(ComTypes.ImmersiveShellBrokerType))
                {
                    _inputHostManagerBroker = new ComPtr <IInputHostManagerBroker>(shellBroker.Instance.GetInputHostManagerBroker());
                    ret = _inputHostManagerBroker != null;
                }
            }
            catch (Exception e)
            {
            }
            return(ret);
        }