⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmmain.cs

📁 VB杀手 v1.0.2007.1210(附源码)
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices.ComTypes;
using System.Reflection;
using System.Runtime.InteropServices;

using TYPEKIND = System.Runtime.InteropServices.ComTypes.TYPEKIND;
using System.IO;
using Microsoft.Win32;

namespace IDLTest
{
    public partial class FrmMain : Form
    {
        public FrmMain()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            TypeLib Lib = new TypeLib(textBox1.Text);

            Lib.IsStruct = checkBox3.Checked;
            Lib.IsVB = !checkBox4.Checked;
            if (!Lib.IsVB && !String.IsNullOrEmpty(textBox2.Text))
                Lib.ImageBase = new IntPtr(Convert.ToInt32(textBox2.Text, 16));
            if (!Lib.IsVB && !String.IsNullOrEmpty(textBox3.Text))
                Lib.VirturlAddress = new IntPtr(Convert.ToInt32(textBox3.Text, 16));

            Lib.SearchVirturlAddress();
            textBox3.Text = Lib.VirturlAddress.ToString("X");

            listBox1.Items.Clear();
            foreach (TypeInfo ti in Lib.TypeInfos)
            {
                if (checkBox2.Checked || ti.TypeKind == TYPEKIND.TKIND_DISPATCH) listBox1.Items.Add(ti);
            }
            listBox1.Tag = Lib;
        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            TypeInfo Info = listBox1.SelectedItem as TypeInfo;
            if (Info == null) return;

            listBox2.Items.Clear();
            foreach (Func f in Info.Funcs)
            {
                if (checkBox1.Checked || f.OffVft >= 7 * 4) listBox2.Items.Add(f);
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            //openFileDialog1.FileName = textBox1.Text;
            openFileDialog1.FileName = "";
            openFileDialog1.Filter = "DLL文件(*.dll)|*.dll|TLB文件(*.tlb)|*.tlb|EXE文件(*.exe)|*.exe";
            openFileDialog1.ShowDialog();
            textBox1.Text = openFileDialog1.FileName;
        }

        private void button3_Click(object sender, EventArgs e)
        {
            TypeLib Lib = listBox1.Tag as TypeLib;
            if (Lib == null) return;

            TypeInfo Info = listBox1.SelectedItem as TypeInfo;
            if (Info == null) return;
            if (Info.TypeKind != TYPEKIND.TKIND_DISPATCH) return;

            Lib.IsStruct = checkBox3.Checked;
            Lib.IsVB = !checkBox4.Checked;
            if (!Lib.IsVB && !String.IsNullOrEmpty(textBox2.Text))
                Lib.ImageBase = new IntPtr(Convert.ToInt32(textBox2.Text, 16));
            if (!Lib.IsVB && !String.IsNullOrEmpty(textBox3.Text))
                Lib.VirturlAddress = new IntPtr(Convert.ToInt32(textBox3.Text, 16));
            String s = Lib.RendIDC(Info, true);
            Save(s);
        }

        private void Save(String s)
        {
            if (String.IsNullOrEmpty(s)) return;

            String filename = Application.ExecutablePath;
            filename = textBox1.Text;
            filename = filename.Substring(0, filename.LastIndexOf(@"."));
            filename += ".idc";
            saveFileDialog1.Filter = "IDC文件(*.idc)|*.idc";
            saveFileDialog1.FileName = "";
            saveFileDialog1.ShowDialog();
            filename = saveFileDialog1.FileName;

            if (String.IsNullOrEmpty(filename)) return;

            using (StreamWriter sw = new StreamWriter(filename, false, Encoding.Default))
            {
                sw.Write(s);
                sw.Close();
            }
        }

        private void button4_Click(object sender, EventArgs e)
        {
            TypeLib Lib = listBox1.Tag as TypeLib;
            if (Lib == null) return;

            Lib.IsStruct = checkBox3.Checked;
            Lib.IsVB = !checkBox4.Checked;
            if (!Lib.IsVB && !String.IsNullOrEmpty(textBox2.Text))
                Lib.ImageBase = new IntPtr(Convert.ToInt32(textBox2.Text, 16));
            if (!Lib.IsVB && !String.IsNullOrEmpty(textBox3.Text))
                Lib.VirturlAddress = new IntPtr(Convert.ToInt32(textBox3.Text, 16));
            String s = Lib.RendIDCs();
            Save(s);
        }

        private void checkBox4_CheckedChanged(object sender, EventArgs e)
        {
            textBox2.Visible = checkBox4.Checked;
            textBox3.Visible = checkBox4.Checked;
        }

        private void button5_Click(object sender, EventArgs e)
        {
            String path = Application.ExecutablePath;
            path = path.Substring(0, path.LastIndexOf(@"\"));
            String filepath = path + @"\UnKown.txt";
            if (!File.Exists(path))
            {
                String[] ss = Directory.GetFiles(path, "UnKown.txt", SearchOption.AllDirectories);
                if (ss == null || ss.Length < 1) return;
                filepath = ss[0];
                path = filepath;
                path = path.Substring(0, path.LastIndexOf(@"\"));
            }

            String content;
            using (StreamReader sr = new StreamReader(filepath, true))
            {
                content = sr.ReadToEnd();
                sr.Close();
            }
            if (String.IsNullOrEmpty(content)) return;

            String[] list = content.Split(new String[] { "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries);
            if (list == null || list.Length < 1) return;
            //调用那几个按钮
            foreach (String s in list)
            {
                textBox1.Text = s;
                checkBox3.Checked = true;
                checkBox4.Checked = true;
                button1_Click(sender, e);
                button4_Click(sender, e);
            }
        }

        private String GetComPath(String guid)
        {
            RegistryKey reg = Registry.ClassesRoot;
            reg = reg.OpenSubKey("CLSID");
            reg = reg.OpenSubKey("{" + guid + "}");
            if (reg == null) return null;
            reg = reg.OpenSubKey("InprocServer32");
            if (reg == null || String.IsNullOrEmpty(reg.GetValue(null).ToString())) return null;
            return reg.GetValue(null).ToString();
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -