コード例 #1
0
        private void LoadAllTypes()
        {
            var ht    = _pImage + Offsets.MonoImage_class_cache;
            var size  = _view.ReadUint(ht + Offsets.MonoInternalHashTable_size);
            var table = _view.ReadUint(ht + Offsets.MonoInternalHashTable_table);

            for (uint i = 0; i < size; i++)
            {
                var pClass = _view.ReadUint(table + 4 * i);
                while (pClass != 0)
                {
                    var klass = new MonoClass(_view, pClass);
                    _classes[klass.FullName] = klass;
                    pClass = _view.ReadUint(pClass + Offsets.MonoClass_next_class_cache);
                }
            }
        }
コード例 #2
0
        public object GetValue(MonoObject o)
        {
            var  offset   = Offset;
            var  type     = Type;
            var  typeType = type.Type;
            bool isRef;

            switch (typeType)
            {
            case MonoTypeEnum.String:
            case MonoTypeEnum.Szarray:
                // Special case since it makes sense to treat these as values.
                isRef = false;
                break;

            case MonoTypeEnum.Object:
            case MonoTypeEnum.Class:
            case MonoTypeEnum.Array:
                isRef = true;
                break;

            case MonoTypeEnum.GenericInst:
                var genericClass = type.Data;
                var container    = new MonoClass(_view, _view.ReadUint(genericClass));
                isRef = !container.IsValueType;
                break;

            default:
                isRef = type.ByRef;
                break;
            }
            if (type.IsStatic)
            {
                var data = _view.ReadUint(Parent.VTable + Offsets.MonoVTable_data);
                if (isRef)
                {
                    var po = _view.ReadUint(data + offset);
                    return(po == 0 ? null : new MonoObject(_view, po));
                }
                if (typeType == MonoTypeEnum.ValueType)
                {
                    var sClass = new MonoClass(_view, type.Data);
                    if (sClass.IsEnum)
                    {
                        return(ReadValue(new MonoClass(_view, _view.ReadUint(type.Data)).ByvalArg.Type, data + offset));
                    }
                    return(new MonoStruct(_view, sClass, (uint)(data + offset)));
                }
                return(typeType == MonoTypeEnum.GenericInst ? null : ReadValue(typeType, data + offset));
            }
            if (isRef)
            {
                var po = _view.ReadUint(o.PObject + offset);
                return(po == 0 ? null : new MonoObject(_view, po));
            }
            if (typeType == MonoTypeEnum.ValueType)
            {
                var sClass = new MonoClass(_view, type.Data);
                if (sClass.IsEnum)
                {
                    return(ReadValue(new MonoClass(_view, _view.ReadUint(type.Data)).ByvalArg.Type, o.PObject + offset));
                }
                return(new MonoStruct(_view, sClass, (uint)(o.PObject + offset)));
            }
            if (typeType == MonoTypeEnum.GenericInst)
            {
                var sClass = new MonoClass(_view, _view.ReadUint(type.Data));
                return(new MonoStruct(_view, sClass, (uint)(o.PObject + offset)));
            }
            return(ReadValue(typeType, o.PObject + offset));
        }
コード例 #3
0
ファイル: MonoObject.cs プロジェクト: 66zjy/AllanHDT
 public MonoObject(ProcessView view, uint pObject)
 {
     PObject = pObject;
     _view   = view;
     _vtable = _view.ReadUint(PObject);
 }