コード例 #1
0
        private static void DumpTable(ManagedRecvTable table, StreamWriter writer, bool full = false, string depth = "")
        {
            if (table == null)
            {
                return;
            }
            writer.WriteLine("{0}{1}:", depth, table.NetTableName.Value);

            foreach (var prop in table.RecvProps.Value.OrderBy(x => x.Offset))
            {
                writer.WriteLine("{0} {1}",
                                 string.Format("{0}{1} ({2}) -> ",
                                               depth + " ",
                                               prop.VarName.Value,
                                               Enum.GetName(typeof(RecvProp_t.ePropType), prop.Type)
                                               ).PadRight(60, '_'),
                                 prop.Offset.ToString("X8"));
                if (prop.SubTable.Value != null)
                {
                    if (!full)
                    {
                        writer.WriteLine("{0}->{1}",
                                         depth + " ",
                                         prop.SubTable.Value.NetTableName.Value);
                    }
                    else
                    {
                        DumpTable(prop.SubTable.Value, writer, full, depth + "  ");
                    }
                }
            }
            writer.WriteLine("{0}//{1}", depth, table.NetTableName.Value);
        }
コード例 #2
0
        private int GetHighestOffset(ManagedRecvTable table)
        {
            if (table == null)
            {
                return(0);
            }

            int highest = table.RecvProps.Value.Max(x => x == null ? 0 : x.Offset);

            if (table.RecvProps.Value.Any(x => x.SubTable != null))
            {
                int subHighest = table.RecvProps.Value.Where(x => x != null && x.SubTable != null).Max(x => GetHighestOffset(x.SubTable));
                highest = Math.Max(highest, subHighest);
            }
            return(highest);
        }
コード例 #3
0
        public ManagedClientClass(IntPtr address)
        {
            Address = address;

            ClientClass = new LazyCache <ClientClass>(() => Program.Hack.Memory.Read <ClientClass>(address));
            var c = ClientClass;

            NetworkName = new LazyCache <string>(() => Program.Hack.Memory.ReadString(c.Value.m_pNetworkName, 32, Encoding.ASCII));
            if (c.Value.m_pRecvTable == 0xffff || c.Value.m_pRecvTable == -1 || c.Value.m_pRecvTable == 0)
            {
                RecvTable = null;
            }
            else
            {
                RecvTable = new ManagedRecvTable(c.Value.m_pRecvTable);
            }
        }
コード例 #4
0
        private static void CrawlDataTables(ManagedRecvTable table)
        {
            if (table == null)
            {
                return;
            }
            if (!DataTables.ContainsKey(table.NetTableName))
            {
                DataTables[table.NetTableName] = table;
            }

            foreach (var prop in table.RecvProps.Value)
            {
                if (prop.SubTable.Value != null)
                {
                    CrawlDataTables(prop.SubTable.Value);
                }
            }
        }
コード例 #5
0
        private static void DumpCppClass(TextWriter o, ManagedRecvTable table)
        {
            const int padding = 32;

            var bc            = table.BaseClass.Value;
            int currentOffset = 0;
            int pad           = 0;

            if (bc != null)
            {
                currentOffset = bc.Size;
            }

            var props = table.RecvProps.Value.OrderBy(x => x.Offset).ToArray();

            if (bc != null)
            {
                o.WriteLine("class {0} : {1} {{", table.NetTableName.Value, bc.NetTableName.Value);
            }
            else
            {
                o.WriteLine("class {0} {{", table.NetTableName.Value);
            }

            for (int i = 0; i < props.Length; i++)
            {
                var prop = props[i];
                if (prop.VarName.Value == "baseclass")
                {
                    continue;
                }

                //Pad
                if (prop.Offset != currentOffset)
                {
                    o.WriteLine("\t{0} {1}//0x{2}",
                                "char".PadRight(padding, ' '),
                                string.Format("pad{0}[{1}];",
                                              (pad++).ToString().PadLeft(2, '0'),
                                              prop.Offset - currentOffset
                                              ).PadRight(padding, ' '),
                                currentOffset.ToString("X8"));
                    currentOffset = prop.Offset;
                }

                switch (prop.Type)
                {
                case RecvProp_t.ePropType.DataTable:
                    o.WriteLine("\t{0} {1}//0x{2}",
                                prop.SubTable.Value.NetTableName.Value.PadRight(padding, ' '),
                                (prop.VarName.Value + ";").PadRight(padding, ' '),
                                prop.Offset.ToString("X8"));
                    break;

                case RecvProp_t.ePropType.Array:
                    o.WriteLine("\t{0} {1}//0x{2}",
                                (prop.ArrayProp.Value.Length > 0 ? prop.ArrayProp.Value[0].Type.ToString() : "void*").PadRight(padding, ' '),
                                string.Format("{0}[{1}];",
                                              prop.VarName.Value,
                                              prop.ElementCount).PadRight(padding, ' '),
                                prop.Offset.ToString("X8"));
                    break;

                default:
                    o.WriteLine("\t{0} {1}//0x{2}",
                                prop.Type.ToString().PadRight(padding, ' '),
                                (prop.VarName.Value + ";").PadRight(padding, ' '),
                                prop.Offset.ToString("X8"));
                    break;
                }
                if (i < props.Length - 1)
                {
                    currentOffset += Math.Min(prop.Size, props[i + 1].Offset - currentOffset);
                }
                else
                {
                    currentOffset += prop.Size;
                }
            }

            o.WriteLine("}\n");
        }
コード例 #6
0
        public ManagedRecvProp(int address, ManagedRecvTable table)
        {
            Address = address;
            Table   = table;

            RecvProp = new LazyCache <RecvProp_t>(() => Program.Hack.Memory.Read <RecvProp_t>(address));
            var r = RecvProp;

            VarName  = new LazyCache <string>(() => Program.Hack.Memory.ReadString(r.Value.m_pVarName, 32, Encoding.ASCII));
            SubTable = new LazyCache <ManagedRecvTable>(() =>
            {
                if (r.Value.m_pDataTable == 0)
                {
                    return(null);
                }

                return(new ManagedRecvTable(r.Value.m_pDataTable));
            });
            BaseClassDepth = new LazyCache <int>(() => SubTable.Value != null ? 1 + SubTable.Value.BaseClassDepth : 0);
            Size           = new LazyCache <int>(() =>
            {
                if (SubTable.Value != null)
                {
                    return(SubTable.Value.Size);
                }

                int size = RecvProp_t.GetPropTypeSize(Type);
                if (size >= 0)
                {
                    return(size);
                }

                switch (Type)
                {
                case RecvProp_t.ePropType.String:
                    return(StringBufferSize);

                case RecvProp_t.ePropType.Array:
                    if (ArrayProp.Value.Length > 0)
                    {
                        return(ElementCount * ArrayProp.Value[0].Size);
                    }
                    return(0);
                }

                return(0);
            });
            ArrayProp = new LazyCache <ManagedRecvProp[]>(() =>
            {
                if (this.Type != RecvProp_t.ePropType.Array || this.RecvProp.Value.m_pArrayProp == 0 || this.ElementCount == 0)
                {
                    return(new ManagedRecvProp[0]);
                }

                var props = new ManagedRecvProp[this.ElementCount];
                for (int i = 0; i < props.Length; i++)
                {
                    int a = this.RecvProp.Value.m_pArrayProp + SizeCache <RecvProp_t> .Size * i;
                    if (address == a)
                    {
                        props[i] = this;
                    }
                    else
                    {
                        props[i] = new ManagedRecvProp(a, table);
                    }
                }
                return(props);
            });
        }