예제 #1
0
        private void DecompileClass_Google(IRClass target, out List <TypeDefinition> references)
        {
            // Fetch properties of the type..
            var props = GoogleCSInspector.ExtractClassProperties(_subject, out references);

            // Store properties.
            target.Properties = props;

            // Container of all parsed tags.
            List <ulong> tags = new List <ulong>();
            var          constructEnumeration = _subject.Methods.Where(GoogleCSInspector.MatchStaticConstructor);

            if (!constructEnumeration.Any())
            {
                throw new ExtractionException("No static constructor found!");
            }
            var construct = constructEnumeration.First();
            Action <CallInfo, List <byte> > cctorOnCall = (CallInfo c, List <byte> w) =>
            {
                GoogleCSInspector.StaticCctorOnCall(c, props, tags);
            };
            Action <StoreInfo, List <byte> > cctorOnStore = (StoreInfo s, List <byte> w) =>
            {
                GoogleCSInspector.StaticCctorOnStore(s, props, tags);
            };

            // Walk static constructor method.
            MethodWalker.WalkMethod(construct, cctorOnCall, cctorOnStore);

            // Extract necesary methods for decompilation.
            var serializeEnumeration = _subject.Methods.Where(GoogleCSInspector.MatchSerializeMethod);

            if (!serializeEnumeration.Any())
            {
                throw new ExtractionException("No serialize method found!");
            }

            // Get serialize method.
            var serialize = serializeEnumeration.First();

            // Handler for serialize oncall action.
            Action <CallInfo, List <byte> > googleSerializeOnCall = (CallInfo info, List <byte> w) =>
            {
                // Just chain the call.
                GoogleCSInspector.SerializeOnCall(info, w, props);
            };

            // Walk serialize method.
            MethodWalker.WalkMethod(serialize, googleSerializeOnCall, null);
        }
예제 #2
0
        private void DecompileClass_SilentOrbit(IRClass target, out List <TypeDefinition> references)
        {
            // Fetch the properties of the type...
            // (At the same time, all references of this class are being collected.)
            var props = SilentOrbitInspector.ExtractClassProperties(_subject, out references);

            // and store the properties.
            target.Properties = props;

            // Extract necessary methods for decompilation
            var serializeEnum   = _subject.Methods.Where(SilentOrbitInspector.MatchSerializeMethod);
            var deserializeEnum = _subject.Methods.Where(SilentOrbitInspector.MatchDeserializeMethod);

            if (!serializeEnum.Any() || !deserializeEnum.Any())
            {
                throw new ExtractionException("No serialize or deserialize methods found!");
            }
            MethodDefinition serialize   = serializeEnum.First();
            MethodDefinition deserialize = deserializeEnum.First();

            // Create a handler for the serialize OnCall action.
            Action <CallInfo, List <byte> > silentOrbitSerializeCallHandler = (CallInfo info,
                                                                               List <byte> w) =>
            {
                // Just chain the call.
                // Property information is updated in place!
                SilentOrbitInspector.SerializeOnCall(info, w, props);
            };

            // Walk the serialize method for additional information.
            MethodWalker.WalkMethod(serialize, silentOrbitSerializeCallHandler, null);

            // Create handler for deserialize oncall action.
            Action <CallInfo, List <byte> > silentOrbitDeserializeCallHandler = (CallInfo info,
                                                                                 List <byte> w) =>
            {
                // Just chain the call.
                // Property information is updated in place!
                SilentOrbitInspector.DeserializeOnCall(info, w, props);
            };

            // Walk the deserialize method for additional information.
            MethodWalker.WalkMethod(deserialize, silentOrbitDeserializeCallHandler, null);
        }
예제 #3
0
        private void DecompileClass_GoogleV1(IRClass target, out List <TypeDefinition> references)
        {
            // Setup containers
            var fieldNames       = new List <string>();
            var targetProperties = new List <IRClassProperty>();
            var allFields        = GoogleV1Inspector.ExtractClassFields(_subject);

            // .. and store the resulting properties into the target class.
            target.Properties = targetProperties;

            // Extract direct fields from the static data of the class.
            var staticConstructor = _subject.Methods.First(GoogleV1Inspector.MatchStaticConstructor);
            Action <CallInfo, List <byte> > cctorOnCall = (CallInfo c, List <byte> w) =>
            {
                GoogleV1Inspector.StaticCctorOnCall(c);
            };
            Action <StoreInfo, List <byte> > cctorOnStore = (StoreInfo s, List <byte> w) =>
            {
                GoogleV1Inspector.StaticCctorOnStore(s, fieldNames);
            };

            // Walk static constructor method.
            MethodWalker.WalkMethod(staticConstructor, cctorOnCall, cctorOnStore);

            // Extract direct fields from the serialize method of the class.
            var serializer      = _subject.Methods.First(GoogleV1Inspector.MatchSerializeMethod);
            var localReferences = new List <TypeDefinition>();
            Action <CallInfo, List <byte> > serializeOnCall = (CallInfo c, List <byte> w) =>
            {
                GoogleV1Inspector.SerializeOnCall(c, fieldNames, allFields, targetProperties, localReferences);
            };
            Action <StoreInfo, List <byte> > serializeOnStore = (StoreInfo s, List <byte> w) =>
            {
                GoogleV1Inspector.SerializeOnStore(s);
            };

            // Walk static constructor method.
            MethodWalker.WalkMethod(serializer, serializeOnCall, serializeOnStore);


            references = localReferences;
        }