2013-04-10 4 views
9

हेई। मैं Digi Traffic Accelerator का डिकंपील्ड स्रोत पढ़ रहा था (मुझे लगता है कि यह सीखने का सबसे अच्छा तरीका है), जब तक कि मुझे कुछ समझने योग्य कोड न मिले! कृपया एक बार देख ले:डॉटपीक डिकंपिल्ड कोड में संकलक-जेनरेट किए गए प्रकार को समझना

internal class ProxyFarm 
    { 
    private static Random rand = new Random(); 
    private static Regex UserPassAtHostPort = new Regex("\r\n    ^\r\n    (?<user>[^:]+?) : (?<pass>[^@]+?)\r\n    @\r\n    (?<host>[^:]+? (?: : \\d+)?)\r\n    $", RegexOptions.IgnorePatternWhitespace); 
    private static Regex HostPortUserPass = new Regex("\r\n    ^\r\n    (?<host>[^:]+? : \\d+) : (?<user>[^:]+?) : (?<pass>.+?)\r\n    $", RegexOptions.IgnorePatternWhitespace); 
    public const string NEW = "new"; 
    public const string ACTIVE = "active"; 
    public const string BLOCKED_BY_GOOGLE = "blocked by Google"; 
    public const string INACTIVE = "inactive"; 
    public const string CHECKING = "Checking..."; 

    static ProxyFarm() 
    { 
    } 

    public static StorageDataSet.ProxiesRow GetRandomProxy(bool WillUseRecaptcha = true) 
    { 
     // some normal code 
    } 

    public static WebProxy MakeWebProxy(StorageDataSet.ProxiesRow row) 
    { 
     // some normal code 
    } 

    public static void CheckProxy(StorageDataSet.ProxiesRow proxy) 
    { 
     // ISSUE: object of a compiler-generated type is created 
     // ISSUE: variable of a compiler-generated type 
     ProxyFarm.\u003C\u003Ec__DisplayClass5 cDisplayClass5 = new ProxyFarm.\u003C\u003Ec__DisplayClass5(); 
     // ISSUE: reference to a compiler-generated field 
     cDisplayClass5.proxy = proxy; 
     // ISSUE: reference to a compiler-generated field 
     if (cDisplayClass5.proxy == null) 
     return; 
     // ISSUE: reference to a compiler-generated field 
     cDisplayClass5.logger = LogManager.GetLogger("Program"); 
     // ISSUE: reference to a compiler-generated field 
     // ISSUE: reference to a compiler-generated field 
     cDisplayClass5.state = new ProxyFarm.CallbackState() 
     { 
     Proxy = cDisplayClass5.proxy, 
     Google = ProxyFarm.CheckStatus.NotChecked, 
     Post = ProxyFarm.CheckStatus.NotChecked 
     }; 
     // ISSUE: reference to a compiler-generated field 
     cDisplayClass5.r = (HttpWebRequest) WebRequest.Create("http://www.digitrafficgenerator.com/post_test.php"); 
     // ISSUE: reference to a compiler-generated field 
     cDisplayClass5.r.Method = "POST"; 
     try 
     { 
     // ISSUE: reference to a compiler-generated field 
     // ISSUE: reference to a compiler-generated field 
     cDisplayClass5.r.Proxy = (IWebProxy) ProxyFarm.MakeWebProxy(cDisplayClass5.proxy); 
     } 
     catch (Exception ex) 
     { 
     // ISSUE: reference to a compiler-generated field 
     // ISSUE: reference to a compiler-generated field 
     cDisplayClass5.logger.Warn((object) ("Invalid proxy entered: " + cDisplayClass5.proxy.Address), ex); 
     // ISSUE: reference to a compiler-generated field 
     ProxyFarm.ChangeStatus(cDisplayClass5.proxy, "inactive"); 
     return; 
     } 
     // ISSUE: reference to a compiler-generated field 
     cDisplayClass5.r.ConnectionGroupName = Guid.NewGuid().ToString(); 
     // ISSUE: reference to a compiler-generated field 
     cDisplayClass5.byteArray = Encoding.UTF8.GetBytes("q=test"); 
     // ISSUE: reference to a compiler-generated field 
     // ISSUE: reference to a compiler-generated field 
     cDisplayClass5.r.ContentLength = (long) cDisplayClass5.byteArray.Length; 
     // ISSUE: reference to a compiler-generated field 
     cDisplayClass5.r.ContentType = "application/x-www-form-urlencoded"; 
     // ISSUE: reference to a compiler-generated field 
     cDisplayClass5.r.Referer = "http://www.digitrafficgenerator.com/post_test.php"; 
     // ISSUE: reference to a compiler-generated field 
     cDisplayClass5.r.Timeout = 20000; 
     // ISSUE: reference to a compiler-generated field 
     // ISSUE: reference to a compiler-generated method 
     IAsyncResult res = cDisplayClass5.r.BeginGetRequestStream(new AsyncCallback(cDisplayClass5.\u003CCheckProxy\u003Eb__1), (object) null); 
     // ISSUE: reference to a compiler-generated field 
     WebObject.AbortRequestAfterTimeout(res, cDisplayClass5.r); 
     try 
     { 
     // ISSUE: reference to a compiler-generated field 
     // ISSUE: reference to a compiler-generated method 
     // ISSUE: reference to a compiler-generated field 
     res = cDisplayClass5.r.BeginGetResponse(new AsyncCallback(cDisplayClass5.\u003CCheckProxy\u003Eb__2), (object) cDisplayClass5.r); 
     } 
     catch (Exception ex) 
     { 
     // ISSUE: reference to a compiler-generated field 
     // ISSUE: reference to a compiler-generated field 
     cDisplayClass5.logger.Info((object) ("Got an exception using " + cDisplayClass5.proxy.Address), ex); 
     } 
     // ISSUE: reference to a compiler-generated field 
     WebObject.AbortRequestAfterTimeout(res, cDisplayClass5.r); 
     HttpWebRequest request = (HttpWebRequest) WebRequest.Create("http://www.google.com/recaptcha/api/js/recaptcha.js"); 
     request.Method = "GET"; 
     // ISSUE: reference to a compiler-generated field 
     request.Proxy = (IWebProxy) ProxyFarm.MakeWebProxy(cDisplayClass5.proxy); 
     request.Timeout = 20000; 
     request.ConnectionGroupName = Guid.NewGuid().ToString(); 
     // ISSUE: reference to a compiler-generated method 
     WebObject.AbortRequestAfterTimeout(request.BeginGetResponse(new AsyncCallback(cDisplayClass5.\u003CCheckProxy\u003Eb__3), (object) request), request); 
    } 

    protected static void ProxyChecked(IAsyncResult result, HttpWebRequest req, ProxyFarm.CallbackState state) 
    { 
     ILog logger = LogManager.GetLogger("Program"); 
     ProxyFarm.CheckStatus checkStatus = ProxyFarm.CheckStatus.NotOk; 
     try 
     { 
     HttpWebResponse httpWebResponse = (HttpWebResponse) req.EndGetResponse(result); 
     if (req.RequestUri == httpWebResponse.ResponseUri) 
     { 
      if (httpWebResponse.StatusCode == HttpStatusCode.OK) 
      checkStatus = ProxyFarm.CheckStatus.Ok; 
     } 
     } 
     catch (Exception ex) 
     { 
     } 
     lock (state) 
     { 
     if (req.RequestUri.Authority.Contains("google.com")) 
      state.Google = checkStatus; 
     else 
      state.Post = checkStatus; 
     if (state.Post == ProxyFarm.CheckStatus.NotOk) 
     { 
      ProxyFarm.ChangeStatus(state.Proxy, "inactive"); 
      logger.Info((object) ("Marking " + state.Proxy.Address + " as inactive as it cannot POST")); 
     } 
     else if (state.Google == ProxyFarm.CheckStatus.NotOk) 
     { 
      ProxyFarm.ChangeStatus(state.Proxy, "inactive"); 
      logger.Info((object) ("Marking " + state.Proxy.Address + " as inactive as it is blocked by google")); 
     } 
     else 
     { 
      if (state.Google != ProxyFarm.CheckStatus.Ok || state.Post != ProxyFarm.CheckStatus.Ok) 
      return; 
      ProxyFarm.ChangeStatus(state.Proxy, "active"); 
     } 
     } 
    } 

    public static void ReportBrokenProxy(StorageDataSet.ProxiesRow proxy, bool recaptcha_fail = false) 
    { 
     // some normal code 
    } 

    private static void ChangeStatus(StorageDataSet.ProxiesRow Proxy, string status) 
    { 
     // some normal code 
    } 

    public enum CheckStatus 
    { 
     NotChecked, 
     Ok, 
     NotOk, 
    } 

    protected class CallbackState 
    { 
     public StorageDataSet.ProxiesRow Proxy { get; set; } 

     public ProxyFarm.CheckStatus Post { get; set; } 

     public ProxyFarm.CheckStatus Google { get; set; } 
    } 
    } 

आप देख सकते हैं, यह CheckProxy विधि में लगता है, संकलक एक नए प्रकार उत्पन्न! क्या आपको पता है कि इस विधि में वास्तव में क्या हो रहा है? मैं कोड कैसे समझ सकता हूं?

+0

यह एक डिकंपेलर की कमी है, इसकी रिपोर्ट करें। – usr

उत्तर

8

\u003C और \u003E क्रमशः < और > के यूनिकोड प्रतिनिधित्व हैं।

ये वर्ण आईएल में मान्य हैं .. इसलिए संकलक टकराव से बचने के लिए ऐसे नामों के साथ चर उत्पन्न करेगा।

आपके डिकंपेलर को यह नहीं पता था कि इसे <> में कैसे परिवर्तित किया जाए और अस्थायी चर को हटाया न जाए।

+0

उत्तर देने के लिए धन्यवाद। मै समझता हुँ। तो यदि आप 'चेकप्रॉक्सी' विधि को फिर से लिखना चाहते हैं, तो आप कैसे करेंगे? मेरा मतलब है, क्यों संकलक '<> __ DisplayClass5' कक्षा उत्पन्न करता है? कौन सी स्थितियां इस सामान को करने के लिए कंपाइलर बनाती हैं? –

+1

संकलक क्लोजर, बेनामी प्रकार, या जब आप किसी ऑब्जेक्ट का उपयोग कर रहे हैं तो 'कोशिश करें..फिनली' क्लॉज के माध्यम से ऐसा करेंगे। सटीक अर्थशास्त्र मैं अपरिचित हूं .. हालांकि यह वास्तव में एक मुद्दा नहीं है। –

3

इसे dnSpy में खोलें और मिलान (आईएसएच) से मेल खाने वाली विधि के लिए चारों ओर देखें। वे एक अलग क्रम में होंगे लेकिन dnSpy lambdas decompiling का एक सभ्य काम करता है।

+0

इसके लिए धन्यवाद, डॉटपीक – liammcdee

+2

की तुलना में इस से बहुत बेहतर परिणाम हुए थे, मैंने इस जवाब का पालन किया और चला गया और dnSpy मिला, लेकिन इसे बनाने के लिए इसे बनाने की कोशिश करने के आसपास बहुत अधिक चकित करने के बाद डीबग (इसे प्रकाशित करने का प्रयास न करें!) अंतिम परिणाम dotPeek से कोई स्पष्ट नहीं थे –

संबंधित मुद्दे