void Decrypt(IBinaryReader reader, int delegateTypeToken, ISimpleDeobfuscator simpleDeobfuscator) { var delegateType = module.ResolveToken(delegateTypeToken) as TypeDef; if (delegateType == null) { throw new ApplicationException("Couldn't find delegate type"); } int delToken, encMethToken, encDeclToken; if (!GetTokens(delegateType, out delToken, out encMethToken, out encDeclToken)) { throw new ApplicationException("Could not find encrypted method tokens"); } if (delToken != delegateTypeToken) { throw new ApplicationException("Invalid delegate type token"); } var encType = module.ResolveToken(encDeclToken) as ITypeDefOrRef; if (encType == null) { throw new ApplicationException("Invalid declaring type token"); } var encMethod = module.ResolveToken(encMethToken) as MethodDef; if (encMethod == null) { throw new ApplicationException("Invalid encrypted method token"); } var bodyReader = new MethodBodyReader(module, reader); bodyReader.Read(encMethod); bodyReader.RestoreMethod(encMethod); Logger.v("Restored method {0} ({1:X8}). Instrs:{2}, Locals:{3}, Exceptions:{4}", Utils.RemoveNewlines(encMethod.FullName), encMethod.MDToken.ToInt32(), encMethod.Body.Instructions.Count, encMethod.Body.Variables.Count, encMethod.Body.ExceptionHandlers.Count); delegateTypes.Add(delegateType); simpleDeobfuscator.MethodModified(encMethod); }
void decrypt(BinaryReader reader, int delegateTypeToken) { var delegateType = module.LookupToken(delegateTypeToken) as TypeDefinition; if (delegateType == null) { throw new ApplicationException("Couldn't find delegate type"); } int delToken, encMethToken, encDeclToken; if (!getTokens(delegateType, out delToken, out encMethToken, out encDeclToken)) { throw new ApplicationException("Could not find encrypted method tokens"); } if (delToken != delegateTypeToken) { throw new ApplicationException("Invalid delegate type token"); } var encType = module.LookupToken(encDeclToken) as TypeReference; if (encType == null) { throw new ApplicationException("Invalid declaring type token"); } var encMethod = module.LookupToken(encMethToken) as MethodDefinition; if (encMethod == null) { throw new ApplicationException("Invalid encrypted method token"); } var bodyReader = new MethodBodyReader(module, reader); bodyReader.read(encMethod); bodyReader.restoreMethod(encMethod); Log.v("Restored method {0} ({1:X8}). Instrs:{2}, Locals:{3}, Exceptions:{4}", Utils.removeNewlines(encMethod.FullName), encMethod.MetadataToken.ToInt32(), encMethod.Body.Instructions.Count, encMethod.Body.Variables.Count, encMethod.Body.ExceptionHandlers.Count); delegateTypes.Add(delegateType); }
void decrypt(BinaryReader reader, int delegateTypeToken) { var delegateType = module.LookupToken(delegateTypeToken) as TypeDefinition; if (delegateType == null) throw new ApplicationException("Couldn't find delegate type"); int delToken, encMethToken, encDeclToken; if (!getTokens(delegateType, out delToken, out encMethToken, out encDeclToken)) throw new ApplicationException("Could not find encrypted method tokens"); if (delToken != delegateTypeToken) throw new ApplicationException("Invalid delegate type token"); var encType = module.LookupToken(encDeclToken) as TypeReference; if (encType == null) throw new ApplicationException("Invalid declaring type token"); var encMethod = module.LookupToken(encMethToken) as MethodDefinition; if (encMethod == null) throw new ApplicationException("Invalid encrypted method token"); var bodyReader = new MethodBodyReader(module, reader); bodyReader.read(encMethod); bodyReader.restoreMethod(encMethod); Log.v("Restored method {0} ({1:X8}). Instrs:{2}, Locals:{3}, Exceptions:{4}", Utils.removeNewlines(encMethod.FullName), encMethod.MetadataToken.ToInt32(), encMethod.Body.Instructions.Count, encMethod.Body.Variables.Count, encMethod.Body.ExceptionHandlers.Count); delegateTypes.Add(delegateType); }