yck1509 / ConfuserEx

An open-source, free protector for .NET applications
http://yck1509.github.io/ConfuserEx/
Other
3.56k stars 1.62k forks source link

Obfuscating Xamarin.Android app and async #253

Open desunit opened 9 years ago

desunit commented 9 years ago

I have encountered with obfuscation error caused by async method right in OnCreate:

        protected override void OnCreate(Bundle bundle)
        {
                ThreadPool.QueueUserWorkItem (async _ => {
                        await loader.Prepare ();
                }

the error was:

[ERROR] Failed to resolve a type, check if all dependencies are present in the correct version.
Exception: dnlib.DotNet.TypeResolveException: Could not resolve type: Test.Activities.LoadingActivity/<OnCreate>c__async3 (Test.Android, Version=1.0.5634.20479, Culture=neutral, PublicKeyToken=null)
  at dnlib.DotNet.TypeRef.ResolveThrow (dnlib.DotNet.ModuleDef sourceModule) [0x00000] in <filename unknown>:0
  at dnlib.DotNet.TypeRef.ResolveThrow () [0x00000] in <filename unknown>:0
  at dnlib.DotNet.Extensions.ResolveTypeDefThrow (ITypeDefOrRef tdr) [0x00000] in <filename unknown>:0
  at Confuser.Renamer.Analyzers.TypeBlobAnalyzer.AnalyzeCAArgument (Confuser.Core.ConfuserContext context, INameService service, CAArgument arg) [0x00000] in <filename unknown>:0
  at Confuser.Renamer.Analyzers.TypeBlobAnalyzer.Analyze (Confuser.Core.ConfuserContext context, INameService service, Confuser.Core.ProtectionParameters parameters, IDnlibDef def) [0x00000] in <filename unknown>:0
  at Confuser.Renamer.AnalyzePhase.Analyze (Confuser.Renamer.NameService service, Confuser.Core.ConfuserContext context, Confuser.Core.ProtectionParameters parameters, IDnlibDef def, Boolean runAnalyzer) [0x00000] in <filename unknown>:0
  at Confuser.Renamer.AnalyzePhase.Execute (Confuser.Core.ConfuserContext context, Confuser.Core.ProtectionParameters parameters) [0x00000] in <filename unknown>:0
  at Confuser.Core.ProtectionPipeline.ExecuteStage (PipelineStage stage, System.Action`1 func, System.Func`1 targets, Confuser.Core.ConfuserContext context) [0x00000] in <filename unknown>:0
  at Confuser.Core.ConfuserEngine.RunPipeline (Confuser.Core.ProtectionPipeline pipeline, Confuser.Core.ConfuserContext context) [0x00000] in <filename unknown>:0
  at Confuser.Core.ConfuserEngine.RunInternal (Confuser.Core.ConfuserParameters parameters, CancellationToken token) [0x00000] in <filename unknown>:0
[ERROR] ---BEGIN DEBUG INFO---
[ERROR] Installed Framework Versions:
Failed at 3:18 PM, 0:02 elapsed.
yck1509 commented 9 years ago

Hi, Would it be possible to send me a sample project that demonstrate the issue at confuser.net@gmail.com?

kiwidoggie commented 7 years ago

I'm not sure if I am having the same issue or not.

`private Task CheckForUpdates() { WriteLog(LogsLevel.Info, "Checking for updates...");

        // Download the manifest
        var s_ManifestData = DownloadManifest();

        // Ensure that we got good data back
        if (string.IsNullOrWhiteSpace(s_ManifestData))
            return Task.FromResult(false);

        // Parse the manifest data and create our manifest
        //var s_Manifest = new UpdateManifest(s_ManifestData);

        //// Get the manifest entries that we need to download
        //var s_EntriesToDownload = CompareManifest(s_Manifest, CurrentDirectory);
        //if (s_EntriesToDownload.Length == 0)
        //{
        //    WriteLog(LogsLevel.Info, "There are no updates available.");
        //    return false;
        //}

        WriteLog(LogsLevel.Info, "There is an update available.");
        return Task.FromResult(true);
    }`

The CompareManifest is a async Task<object[]>. The DownloadManifest function was also a async Task function that would crash every time. I converted it to synchronous and it runs just fine. Does ConfuserEx support async/await tasks? (Or tasks within tasks/another thread)