コード例 #1
0
        public unsafe static Hashtable DumpTable(RecvTable *table, int offset = 0)
        {
            Hashtable hashtable = new Hashtable();

            for (int i = 0; i < table->GetPropsCount(); i++)
            {
                RecvProp *prop = (RecvProp *)((IntPtr)table->GetRecvProps() + i * sizeof(RecvProp));

                if (prop == null)
                {
                    continue;
                }
                if (prop->GetName().Contains("baseclass") || prop->GetName().StartsWith("0") || prop->GetName().StartsWith("1") || prop->GetName().StartsWith("2"))
                {
                    continue;
                }

                if (!hashtable.ContainsKey(prop->GetName()))
                {
                    hashtable.Add(prop->GetName(), prop->GetOffset() + offset);
                }

                if (prop->GetDataTable() != null)
                {
                    foreach (DictionaryEntry entry in DumpTable(prop->GetDataTable(), prop->GetOffset() + offset))
                    {
                        if (!hashtable.ContainsKey(entry.Key))
                        {
                            hashtable.Add(entry.Key, entry.Value);
                        }
                    }
                }
            }
            return(hashtable);
        }
コード例 #2
0
        private netvar_table LoadTable(RecvTable *recvTable)
        {
            var table = new netvar_table();

            table.child_props  = new List <IntPtr>();
            table.child_tables = new List <netvar_table>();
            table.offset       = 0;
            table.name         = Marshal.PtrToStringAnsi((IntPtr)recvTable->m_pNetTableName);

            for (int i = 0; i < recvTable->m_nProps; i++)
            {
                count++;
                var pProp = &recvTable->m_pProps[i];
                if ((IntPtr)pProp == IntPtr.Zero || char.IsDigit(Marshal.PtrToStringAnsi((IntPtr)pProp->m_pVarName)[0]))
                {
                    continue;
                }
                if (Marshal.PtrToStringAnsi((IntPtr)pProp->m_pVarName) == "baseclass")
                {
                    continue;
                }

                if (pProp->m_RecvType == 6 && (IntPtr)pProp->m_pDataTable != IntPtr.Zero)
                {
                    table.child_tables.Add(LoadTable(pProp->m_pDataTable));
                    var last = table.child_tables.Last();
                    last.offset = pProp->m_Offset;
                    last.prop   = pProp;
                    table.child_tables[table.child_tables.Count - 1] = last;
                }
                else
                {
                    table.child_props.Add((IntPtr)pProp);
                }
            }

            return(table);
        }