0

我使用 ILSpy 和 .NET Reflector 来查看代码,发现代码我不理解,我在网上搜索,但没有发现任何 1 可以帮助解决它。此代码与 ILSpy(.NET Reflector 显示相同)

private void Item_Clicked(object sender, EventArgs e)
    {
        switch (0)
        {
        case 0:
            {
                IL_0E:
                FileSystemItem fileSystemItem;
                while (true)
                {
                    fileSystemItem = (sender as FileSystemItem);
                    int num = 1;
                    while (true)
                    {
                        switch (num)
                        {
                        case 0:
                            if (<PrivateImplementationDetails>{4E2292E7-C82C-431F-9529-B0045F4C1457}.$$method0x60003e4-1 != null)
                            {
                                goto IL_25F;
                            }
                            if (true)
                            {
                                IL_163:
                                num = 3;
                                continue;
                            }
                            goto IL_163;

                        case 1:
                            if (fileSystemItem != null)
                            {
                                num = 11;
                                continue;
                            }
                            return;

                        case 2:
                            goto IL_3B8;

                        case 3:
                            {
                                Dictionary<string, int> expr_1B9 = new Dictionary<string, int>(9);
                                expr_1B9.Add(".mp3", 0);
                                expr_1B9.Add(".wav", 1);
                                expr_1B9.Add(".wma", 2);
                                expr_1B9.Add(".wmv", 3);
                                expr_1B9.Add(".avi", 4);
                                expr_1B9.Add(".jpg", 5);
                                expr_1B9.Add(".png", 6);
                                expr_1B9.Add(".txt", 7);
                                expr_1B9.Add(".inf", 8);
                                <PrivateImplementationDetails>{4E2292E7-C82C-431F-9529-B0045F4C1457}.$$method0x60003e4-1 = expr_1B9;
                                num = 15;
                                continue;
                            }

                        case 4:
                            {
                                string ext;
                                if ((ext = fileSystemItem.Ext) != null)
                                {
                                    num = 8;
                                    continue;
                                }
                                return;
                            }

                        case 5:
                            goto IL_2C9;

                        case 6:
                            num = 12;
                            continue;

                        case 7:
                            {
                                string ext;
                                int num2;
                                if (<PrivateImplementationDetails>{4E2292E7-C82C-431F-9529-B0045F4C1457}.$$method0x60003e4-1.TryGetValue(ext, ref num2))
                                {
                                    num = 6;
                                    continue;
                                }
                                return;
                            }

                        case 8:
                            num = 0;
                            continue;

                        case 9:
                            goto IL_25A;

                        case 10:
                            goto IL_36A;

                        case 11:
                            num = 14;
                            continue;

                        case 12:
                            {
                                int num2;
                                switch (num2)
                                {
                                case 0:
                                case 1:
                                case 2:
                                    num = 16;
                                    continue;

                                case 3:
                                case 4:
                                    goto IL_171;

                                case 5:
                                case 6:
                                    goto IL_1A4;

                                case 7:
                                case 8:
                                    this.ShowText(fileSystemItem.Path);
                                    num = 9;
                                    continue;

                                default:
                                    num = 13;
                                    continue;
                                }
                                break;
                            }

                        case 13:
                            return;

                        case 14:
                            if (fileSystemItem.IsFolder)
                            {
                                switch ((1 == 1) ? 1 : 0)
                                {
                                case 0:
                                case 2:
                                    goto IL_36F;

                                case 1:
                                    IL_2B7:
                                    if (false)
                                    {
                                        IL_2BD:
                                        num = 5;
                                        continue;
                                    }
                                    goto IL_2BD;
                                }
                                goto IL_2B7;
                            }
                            num = 4;
                            continue;

                        case 15:
                            goto IL_25F;

                        case 16:
                            if (fileSystemItem.IsPlaying)
                            {
                                num = 10;
                                continue;
                            }
                            goto IL_36F;
                        }
                        break;
                        IL_25F:
                        num = 7;
                        continue;
                        IL_36F:
                        BackgroundAudioPlayer.get_Instance().set_Track(new AudioTrack(new Uri(fileSystemItem.Path, 2), "Unknown", "Unknown", "Unknown", null));
                        IEnumerator<object> enumerator = this.filesListBox.get_Items().GetEnumerator();
                        num = 2;
                    }
                }
                IL_131:
                BackgroundAudioPlayer.get_Instance().Stop();
                fileSystemItem.IsPlaying = false;
                return;
                IL_171:
                MediaPlayerLauncher mediaPlayerLauncher = new MediaPlayerLauncher();
                mediaPlayerLauncher.set_Media(new Uri(fileSystemItem.Path, 2));
                mediaPlayerLauncher.set_Location(2);
                mediaPlayerLauncher.Show();
                return;
                IL_1A4:
                this.ShowImage(fileSystemItem.Path);
                return;
                IL_25A:
                return;
                IL_2C9:
                this.ShowFolderContents(fileSystemItem.Path);
                return;
                IL_36A:
                goto IL_131;
                IL_3B8:
                try
                {
                    int num = 2;
                    while (true)
                    {
                        switch (num)
                        {
                        case 0:
                            num = 1;
                            continue;

                        case 1:
                            goto IL_EC;

                        case 3:
                            {
                                IEnumerator<object> enumerator;
                                if (!enumerator.MoveNext())
                                {
                                    num = 0;
                                    continue;
                                }
                                FileSystemItem fileSystemItem2 = (FileSystemItem)enumerator.get_Current();
                                fileSystemItem2.IsPlaying = false;
                                num = 4;
                                continue;
                            }
                        }
                        IL_A7:
                        num = 3;
                        continue;
                        goto IL_A7;
                    }
                    IL_EC:
                    goto IL_23A;
                }
                finally
                {
                    int num = 2;
                    while (true)
                    {
                        IEnumerator<object> enumerator;
                        switch (num)
                        {
                        case 0:
                            goto IL_12E;

                        case 1:
                            enumerator.Dispose();
                            num = 0;
                            continue;
                        }
                        if (enumerator == null)
                        {
                            break;
                        }
                        num = 1;
                    }
                    IL_12E:;
                }
                goto IL_131;
                IL_23A:
                fileSystemItem.IsPlaying = true;
                return;
            }
        }
        goto IL_0E;
    }

这个字典的错误告诉我这个错误

<PrivateImplementationDetails>{4E2292E7-C82C-431F-9529-B0045F4C1457}.$$method0x60003e4-1

那么,这是什么?我该如何解决?我需要用另一个变量替换它还是什么?

4

1 回答 1

2

<PrivateImplementationDetails>{4E2292E7-C82C-431F-9529-B0045F4C1457}不是正确的 C# 构造。这可能是 ILSpy 对某些内部框架功能发出的替代名称,一般开发人员不应该使用它。

因此,您需要对代码进行逆向工程并了解它的真正作用。并通过其他方式实现它。你不能只是拿走它并使用它:)

顺便说一句,代码似乎是一个混淆的代码,而那里有很多不必要的指令。在您的情况下,整个循环/开关以一种奇特的方式对状态机进行编码。(可能是它的执行总是顺序的,所以你应该尝试手动跟踪它——用纸和铅笔。试试吧,这很有趣!)

于 2012-04-16T14:10:28.793 回答