byte[] getBytesFromHeap(BytesAndOffset ba, int size)
 {
     byte[] result = new byte[size];
     for (int i = 0; i < size; i++)
     {
         result[i] = ba.bytes[i + ba.offset];
     }
     return(result);
 }
Exemple #2
0
        private void DrawFields(TypeDescription typeDescription, BytesAndOffset bytesAndOffset, bool useStatics = false)
        {
            int counter = 0;

            foreach (var field in TypeTools.AllFieldsOf(typeDescription, _unpackedCrawl.typeDescriptions, useStatics ? TypeTools.FieldFindOptions.OnlyStatic : TypeTools.FieldFindOptions.OnlyInstance))
            {
                counter++;
                var gUIStyle = counter % 2 == 0 ? Styles.entryEven : Styles.entryOdd;
                gUIStyle.margin   = new RectOffset(0, 0, 0, 0);
                gUIStyle.overflow = new RectOffset(0, 0, 0, 0);
                gUIStyle.padding  = EditorStyles.label.padding;
                GUILayout.BeginHorizontal(gUIStyle);
                GUILayout.Label(field.name, labelWidth);
                GUILayout.BeginVertical();
                DrawValueFor(field, bytesAndOffset.Add(field.offset));
                GUILayout.EndVertical();
                GUILayout.EndHorizontal();
            }
        }
Exemple #3
0
        private void DrawValueFor(FieldDescription field, BytesAndOffset bytesAndOffset)
        {
            var typeDescription = _unpackedCrawl.typeDescriptions[field.typeIndex];

            switch (typeDescription.name)
            {
            case "System.Int32":
                GUILayout.Label(_primitiveValueReader.ReadInt32(bytesAndOffset).ToString());
                break;

            case "System.Int64":
                GUILayout.Label(_primitiveValueReader.ReadInt64(bytesAndOffset).ToString());
                break;

            case "System.UInt32":
                GUILayout.Label(_primitiveValueReader.ReadUInt32(bytesAndOffset).ToString());
                break;

            case "System.UInt64":
                GUILayout.Label(_primitiveValueReader.ReadUInt64(bytesAndOffset).ToString());
                break;

            case "System.Int16":
                GUILayout.Label(_primitiveValueReader.ReadInt16(bytesAndOffset).ToString());
                break;

            case "System.UInt16":
                GUILayout.Label(_primitiveValueReader.ReadUInt16(bytesAndOffset).ToString());
                break;

            case "System.Byte":
                GUILayout.Label(_primitiveValueReader.ReadByte(bytesAndOffset).ToString());
                break;

            case "System.SByte":
                GUILayout.Label(_primitiveValueReader.ReadSByte(bytesAndOffset).ToString());
                break;

            case "System.Char":
                GUILayout.Label(_primitiveValueReader.ReadChar(bytesAndOffset).ToString());
                break;

            case "System.Boolean":
                GUILayout.Label(_primitiveValueReader.ReadBool(bytesAndOffset).ToString());
                break;

            case "System.Single":
                GUILayout.Label(_primitiveValueReader.ReadSingle(bytesAndOffset).ToString());
                break;

            case "System.Double":
                GUILayout.Label(_primitiveValueReader.ReadDouble(bytesAndOffset).ToString());
                break;

            case "System.IntPtr":
                GUILayout.Label(_primitiveValueReader.ReadPointer(bytesAndOffset).ToString("X"));
                break;

            default:
                if (!typeDescription.isValueType)
                {
                    ThingInMemory item = GetThingAt(bytesAndOffset.ReadPointer());
                    if (item == null)
                    {
                        EditorGUI.BeginDisabledGroup(true);
                        GUILayout.Button("Null");
                        EditorGUI.EndDisabledGroup();
                    }
                    else
                    {
                        DrawLinks(new ThingInMemory[] { item }, 0);
                    }
                }
                else
                {
                    DrawFields(typeDescription, bytesAndOffset);
                }
                break;
            }
        }