Exemple #1
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);
        }