Ejemplo n.º 1
0
        public unsafe StructDescriptor BuildStructDescriptor(ulong dllBase, int typeIndex)
        {
            if (Win32.SymGetTypeInfo(_hProcess, dllBase, typeIndex, SymbolTypeInfo.ChildrenCount, out int childrenCount))
            {
                var structDesc = new StructDescriptor(childrenCount);
                if (Win32.SymGetTypeInfo(_hProcess, dllBase, typeIndex, SymbolTypeInfo.Length, out ulong size))
                {
                    structDesc.Length = (int)size;
                }
                var childrenParams = new FindChildrenParams {
                    Count = childrenCount
                };
                structDesc.Length = (int)size;
                if (Win32.SymGetTypeInfo(_hProcess, dllBase, typeIndex, SymbolTypeInfo.FindChildren, ref childrenParams))
                {
                    for (var i = 0; i < childrenParams.Count; i++)
                    {
                        var sym   = SymbolInfo.Create();
                        var child = childrenParams.Child[i];
                        if (GetSymbolFromIndex(dllBase, child, ref sym))
                        {
                            if (Win32.SymGetTypeInfo(_hProcess, dllBase, child, SymbolTypeInfo.Offset, out int offset) &&
                                Win32.SymGetTypeInfo(_hProcess, dllBase, child, SymbolTypeInfo.Tag, out SymbolTag tag))
                            {
                                sym.Tag       = tag;
                                sym.TypeIndex = child;
                                var member = new StructMember(sym, offset);
                                structDesc.AddMember(member);
                            }
                            else if (Win32.SymGetTypeInfo(_hProcess, dllBase, child, SymbolTypeInfo.Value, out Variant value))
                            {
                                sym.Tag       = SymbolTag.Enum;
                                sym.Value     = value.lValue;
                                sym.TypeIndex = child;
                                var member = new StructMember(sym, 0);
                                switch (sym.Size)
                                {
                                case 8:
                                    member.Value = value.lValue;
                                    break;

                                case 2:
                                    member.Value = value.sValue;
                                    break;

                                case 1:
                                    member.Value = value.bValue;
                                    break;

                                default:
                                    member.Value = value.iValue;
                                    break;
                                }
                                structDesc.AddMember(member);
                            }
                        }
                    }
                }
                return(structDesc);
            }
            return(null);
        }
Ejemplo n.º 2
0
        public BasicType GetSymbolBaseType(ulong dllBase, int typeIndex)
        {
            bool success = Win32.SymGetTypeInfo(_hProcess, dllBase, typeIndex, SymbolTypeInfo.BaseType, out int value);

            return((BasicType)value);
        }
Ejemplo n.º 3
0
        public int GetSymbolChildrenCount(ulong dllBase, int typeIndex)
        {
            bool success = Win32.SymGetTypeInfo(_hProcess, dllBase, typeIndex, SymbolTypeInfo.ChildrenCount, out int value);

            return(value);
        }
Ejemplo n.º 4
0
 public int GetSymbolType(ulong dllBase, int typeIndex)
 {
     Win32.SymGetTypeInfo(_hProcess, dllBase, typeIndex, SymbolTypeInfo.Type, out int value);
     return(value);
 }
Ejemplo n.º 5
0
        public int GetSymbolAddressOffset(ulong dllBase, int typeIndex)
        {
            bool success = Win32.SymGetTypeInfo(_hProcess, dllBase, typeIndex, SymbolTypeInfo.AddressOffset, out int value);

            return(value);
        }
Ejemplo n.º 6
0
 public bool Refresh() => Win32.SymRefreshModuleList(_hProcess);
Ejemplo n.º 7
0
 public ulong GetSymbolLength(ulong dllBase, int typeIndex)
 {
     Win32.SymGetTypeInfo(_hProcess, dllBase, typeIndex, SymbolTypeInfo.Length, out ulong value);
     return(value);
 }
Ejemplo n.º 8
0
        public int GetTypeIndexFromName(ulong baseAddress, string name)
        {
            var symbol = SymbolInfo.Create();

            return(Win32.SymGetTypeFromName(_hProcess, baseAddress, name, ref symbol) ? symbol.TypeIndex : 0);
        }
Ejemplo n.º 9
0
 public bool GetTypeFromName(ulong baseAddress, string name, ref SymbolInfo type)
 => Win32.SymGetTypeFromName(_hProcess, baseAddress, name, ref type);
Ejemplo n.º 10
0
 public bool GetSymbolFromIndex(ulong dllBase, int index, ref SymbolInfo symbol)
 {
     return(Win32.SymFromIndex(_hProcess, dllBase, index, ref symbol));
 }
Ejemplo n.º 11
0
 public bool GetSymbolFromName(string name, ref SymbolInfo symbol)
 {
     return(Win32.SymFromName(_hProcess, name, ref symbol));
 }
Ejemplo n.º 12
0
 public bool TryGetSymbolFromAddress(ulong address, ref SymbolInfo symbol, out ulong displacement)
 {
     symbol.Init();
     return(Win32.SymFromAddr(_hProcess, address, out displacement, ref symbol));
 }
Ejemplo n.º 13
0
#pragma warning disable CSE0003 // Use expression-bodied members
        public Task <ulong> TryLoadSymbolsForModuleAsync(string imageName, ulong dllBase = 0, string moduleName = null, IntPtr?hFile = null)
        {
            return(Task.Run(() => Win32.SymLoadModuleEx(_hProcess, hFile ?? IntPtr.Zero, imageName, moduleName, dllBase, 0, IntPtr.Zero, 0)));
        }
Ejemplo n.º 14
0
        public ulong TryLoadSymbolsForModule(string imageName, string moduleName = null, IntPtr?hFile = null)
        {
            var address = Win32.SymLoadModuleEx(_hProcess, hFile ?? IntPtr.Zero, imageName, moduleName, 0, 0, IntPtr.Zero, 0);

            return(address);
        }