少年修仙传客户端基础资源
client_Wu Xijin
2019-01-16 d53a782e2fd91ffc47dad0dd5a080ee451a351b7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
using System;
using UnityEditor.MemoryProfiler;
using UnityEngine;
 
namespace MemoryProfilerWindow
{
    class PrimitiveValueReader
    {
        private readonly VirtualMachineInformation _virtualMachineInformation;
        private readonly MemorySection[] _heapSections;
 
        public PrimitiveValueReader(VirtualMachineInformation virtualMachineInformation, MemorySection[] heapSections)
        {
            _virtualMachineInformation = virtualMachineInformation;
            _heapSections = heapSections;
        }
 
        public System.Int32 ReadInt32(BytesAndOffset bo)
        {
            return BitConverter.ToInt32(bo.bytes, bo.offset);
        }
 
        public System.UInt32 ReadUInt32(BytesAndOffset bo)
        {
            return BitConverter.ToUInt32(bo.bytes, bo.offset);
        }
 
        public System.Int64 ReadInt64(BytesAndOffset bo)
        {
            return BitConverter.ToInt64(bo.bytes, bo.offset);
        }
 
        public System.UInt64 ReadUInt64(BytesAndOffset bo)
        {
            return BitConverter.ToUInt64(bo.bytes, bo.offset);
        }
 
        public System.Int16 ReadInt16(BytesAndOffset bo)
        {
            return BitConverter.ToInt16(bo.bytes, bo.offset);
        }
 
        public System.UInt16 ReadUInt16(BytesAndOffset bo)
        {
            return BitConverter.ToUInt16(bo.bytes, bo.offset);
        }
 
        public System.Byte ReadByte(BytesAndOffset bo)
        {
            return bo.bytes[bo.offset];
        }
 
        public System.SByte ReadSByte(BytesAndOffset bo)
        {
            return (System.SByte)bo.bytes[bo.offset];
        }
 
        public System.Boolean ReadBool(BytesAndOffset bo)
        {
            return ReadByte(bo) != 0;
        }
 
        public UInt64 ReadPointer(BytesAndOffset bo)
        {
            if (_virtualMachineInformation.pointerSize == 4)
                return ReadUInt32(bo);
            else
                return ReadUInt64(bo);
        }
 
        public UInt64 ReadPointer(UInt64 address)
        {
            return ReadPointer(_heapSections.Find(address, _virtualMachineInformation));
        }
 
        public Char ReadChar(BytesAndOffset bytesAndOffset)
        {
            return System.Text.Encoding.Unicode.GetChars(bytesAndOffset.bytes, bytesAndOffset.offset, 2)[0];
        }
 
        public System.Single ReadSingle(BytesAndOffset bytesAndOffset)
        {
            return BitConverter.ToSingle(bytesAndOffset.bytes, bytesAndOffset.offset);
        }
 
        public System.Double ReadDouble(BytesAndOffset bytesAndOffset)
        {
            return BitConverter.ToDouble(bytesAndOffset.bytes, bytesAndOffset.offset);
        }
    }
}